diff options
Diffstat (limited to 'doc/html/ftpclient-example.html')
-rw-r--r-- | doc/html/ftpclient-example.html | 180 |
1 files changed, 90 insertions, 90 deletions
diff --git a/doc/html/ftpclient-example.html b/doc/html/ftpclient-example.html index a11223e67..3dcedc208 100644 --- a/doc/html/ftpclient-example.html +++ b/doc/html/ftpclient-example.html @@ -33,7 +33,7 @@ body { background: #ffffff; color: black; } <p> -<p> This example implements a FTP client. It uses <a href="qftp.html">TQFtp</a> to perform its FTP +<p> This example implements a FTP client. It uses <a href="ntqftp.html">TQFtp</a> to perform its FTP commands. The GUI parts are done in the Designer. <p> <hr> <p> The implementation of the FTP commands (ftpmainwindow.ui.h): @@ -58,82 +58,82 @@ commands. The GUI parts are done in the Designer. ** *****************************************************************************/ -#include <<a href="qftp-h.html">qftp.h</a>> -#include <<a href="qlineedit-h.html">qlineedit.h</a>> -#include <<a href="qspinbox-h.html">qspinbox.h</a>> -#include <<a href="qstatusbar-h.html">qstatusbar.h</a>> -#include <<a href="qmessagebox-h.html">qmessagebox.h</a>> -#include <<a href="qfiledialog-h.html">qfiledialog.h</a>> -#include <<a href="qprogressdialog-h.html">qprogressdialog.h</a>> -#include <<a href="qapplication-h.html">qapplication.h</a>> +#include <<a href="qftp-h.html">ntqftp.h</a>> +#include <<a href="qlineedit-h.html">ntqlineedit.h</a>> +#include <<a href="qspinbox-h.html">ntqspinbox.h</a>> +#include <<a href="qstatusbar-h.html">ntqstatusbar.h</a>> +#include <<a href="qmessagebox-h.html">ntqmessagebox.h</a>> +#include <<a href="qfiledialog-h.html">ntqfiledialog.h</a>> +#include <<a href="qprogressdialog-h.html">ntqprogressdialog.h</a>> +#include <<a href="qapplication-h.html">ntqapplication.h</a>> #include "connectdialog.h" #include "ftpviewitem.h" void FtpMainWindow::init() { - stateFtp = new <a href="qlabel.html">TQLabel</a>( tr("Unconnected"), statusBar() ); + stateFtp = new <a href="ntqlabel.html">TQLabel</a>( tr("Unconnected"), statusBar() ); statusBar()->addWidget( stateFtp, 0, TRUE ); - ftp = new <a href="qftp.html">TQFtp</a>( this ); -<a name="x748"></a> connect( ftp, SIGNAL(<a href="qftp.html#commandStarted">commandStarted</a>(int)), + ftp = new <a href="ntqftp.html">TQFtp</a>( this ); +<a name="x748"></a> connect( ftp, SIGNAL(<a href="ntqftp.html#commandStarted">commandStarted</a>(int)), SLOT(ftp_commandStarted()) ); -<a name="x747"></a> connect( ftp, SIGNAL(<a href="qftp.html#commandFinished">commandFinished</a>(int,bool)), +<a name="x747"></a> connect( ftp, SIGNAL(<a href="ntqftp.html#commandFinished">commandFinished</a>(int,bool)), SLOT(ftp_commandFinished()) ); -<a name="x753"></a> connect( ftp, SIGNAL(<a href="qftp.html#done">done</a>(bool)), +<a name="x753"></a> connect( ftp, SIGNAL(<a href="ntqftp.html#done">done</a>(bool)), SLOT(ftp_done(bool)) ); -<a name="x764"></a> connect( ftp, SIGNAL(<a href="qftp.html#stateChanged">stateChanged</a>(int)), +<a name="x764"></a> connect( ftp, SIGNAL(<a href="ntqftp.html#stateChanged">stateChanged</a>(int)), SLOT(ftp_stateChanged(int)) ); -<a name="x757"></a> connect( ftp, SIGNAL(<a href="qftp.html#listInfo">listInfo</a>(const <a href="qurlinfo.html">TQUrlInfo</a> &)), - SLOT(ftp_listInfo(const <a href="qurlinfo.html">TQUrlInfo</a> &)) ); -<a name="x761"></a> connect( ftp, SIGNAL(<a href="qftp.html#rawCommandReply">rawCommandReply</a>(int, const <a href="qstring.html">TQString</a> &)), - SLOT(ftp_rawCommandReply(int, const <a href="qstring.html">TQString</a> &)) ); +<a name="x757"></a> connect( ftp, SIGNAL(<a href="ntqftp.html#listInfo">listInfo</a>(const <a href="ntqurlinfo.html">TQUrlInfo</a> &)), + SLOT(ftp_listInfo(const <a href="ntqurlinfo.html">TQUrlInfo</a> &)) ); +<a name="x761"></a> connect( ftp, SIGNAL(<a href="ntqftp.html#rawCommandReply">rawCommandReply</a>(int, const <a href="ntqstring.html">TQString</a> &)), + SLOT(ftp_rawCommandReply(int, const <a href="ntqstring.html">TQString</a> &)) ); } void FtpMainWindow::destroy() { -<a name="x763"></a> if ( ftp-><a href="qftp.html#state">state</a>() != TQFtp::Unconnected ) -<a name="x746"></a> ftp-><a href="qftp.html#close">close</a>(); +<a name="x763"></a> if ( ftp-><a href="ntqftp.html#state">state</a>() != TQFtp::Unconnected ) +<a name="x746"></a> ftp-><a href="ntqftp.html#close">close</a>(); } void FtpMainWindow::uploadFile() { -<a name="x741"></a> <a href="qstring.html">TQString</a> fileName = TQFileDialog::<a href="qfiledialog.html#getOpenFileName">getOpenFileName</a>( - <a href="qstring.html#TQString-null">TQString::null</a>, +<a name="x741"></a> <a href="ntqstring.html">TQString</a> fileName = TQFileDialog::<a href="ntqfiledialog.html#getOpenFileName">getOpenFileName</a>( + <a href="ntqstring.html#TQString-null">TQString::null</a>, TQString::null, this, "upload file dialog", tr("Choose a file to upload") ); -<a name="x771"></a> if ( fileName.<a href="qstring.html#isNull">isNull</a>() ) +<a name="x771"></a> if ( fileName.<a href="ntqstring.html#isNull">isNull</a>() ) return; - <a href="qfile.html">TQFile</a> *file = new <a href="qfile.html">TQFile</a>( fileName ); - if ( !file-><a href="qfile.html#open">open</a>( <a href="qfile.html#open">IO_ReadOnly</a> ) ) { -<a name="x767"></a> TQMessageBox::<a href="qmessagebox.html#critical">critical</a>( this, tr("Upload error"), + <a href="ntqfile.html">TQFile</a> *file = new <a href="ntqfile.html">TQFile</a>( fileName ); + if ( !file-><a href="ntqfile.html#open">open</a>( <a href="ntqfile.html#open">IO_ReadOnly</a> ) ) { +<a name="x767"></a> TQMessageBox::<a href="ntqmessagebox.html#critical">critical</a>( this, tr("Upload error"), tr("Can't open file '%1' for reading.").arg(fileName) ); delete file; return; } - <a href="qprogressdialog.html">TQProgressDialog</a> progress( + <a href="ntqprogressdialog.html">TQProgressDialog</a> progress( tr("Uploading file..."), tr("Cancel"), 0, this, "upload progress dialog", TRUE ); -<a name="x752"></a> connect( ftp, SIGNAL(<a href="qftp.html#dataTransferProgress">dataTransferProgress</a>(int,int)), -<a name="x770"></a> &progress, SLOT(<a href="qprogressdialog.html#setProgress">setProgress</a>(int,int)) ); - connect( ftp, SIGNAL(<a href="qftp.html#commandFinished">commandFinished</a>(int,bool)), -<a name="x769"></a> &progress, SLOT(<a href="qprogressdialog.html#reset">reset</a>()) ); -<a name="x768"></a> connect( &progress, SIGNAL(<a href="qprogressdialog.html#cancelled">cancelled</a>()), -<a name="x744"></a> ftp, SLOT(<a href="qftp.html#abort">abort</a>()) ); - - <a href="qfileinfo.html">TQFileInfo</a> fi( fileName ); -<a name="x759"></a><a name="x743"></a> ftp-><a href="qftp.html#put">put</a>( file, fi.<a href="qfileinfo.html#fileName">fileName</a>() ); -<a name="x739"></a> progress.<a href="qdialog.html#exec">exec</a>(); // ### takes a lot of time!!! - -<a name="x756"></a> ftp-><a href="qftp.html#list">list</a>(); +<a name="x752"></a> connect( ftp, SIGNAL(<a href="ntqftp.html#dataTransferProgress">dataTransferProgress</a>(int,int)), +<a name="x770"></a> &progress, SLOT(<a href="ntqprogressdialog.html#setProgress">setProgress</a>(int,int)) ); + connect( ftp, SIGNAL(<a href="ntqftp.html#commandFinished">commandFinished</a>(int,bool)), +<a name="x769"></a> &progress, SLOT(<a href="ntqprogressdialog.html#reset">reset</a>()) ); +<a name="x768"></a> connect( &progress, SIGNAL(<a href="ntqprogressdialog.html#cancelled">cancelled</a>()), +<a name="x744"></a> ftp, SLOT(<a href="ntqftp.html#abort">abort</a>()) ); + + <a href="ntqfileinfo.html">TQFileInfo</a> fi( fileName ); +<a name="x759"></a><a name="x743"></a> ftp-><a href="ntqftp.html#put">put</a>( file, fi.<a href="ntqfileinfo.html#fileName">fileName</a>() ); +<a name="x739"></a> progress.<a href="ntqdialog.html#exec">exec</a>(); // ### takes a lot of time!!! + +<a name="x756"></a> ftp-><a href="ntqftp.html#list">list</a>(); } void FtpMainWindow::downloadFile() @@ -142,41 +142,41 @@ void FtpMainWindow::downloadFile() if ( !item || item->isDir() ) return; -<a name="x742"></a> <a href="qstring.html">TQString</a> fileName = TQFileDialog::<a href="qfiledialog.html#getSaveFileName">getSaveFileName</a>( +<a name="x742"></a> <a href="ntqstring.html">TQString</a> fileName = TQFileDialog::<a href="ntqfiledialog.html#getSaveFileName">getSaveFileName</a>( <a name="x766"></a> item-><a href="qlistviewitem.html#text">text</a>(0), TQString::null, this, "download file dialog", tr("Save downloaded file as") ); - if ( fileName.<a href="qstring.html#isNull">isNull</a>() ) + if ( fileName.<a href="ntqstring.html#isNull">isNull</a>() ) return; // create file on the heap because it has to be valid throughout the whole // asynchronous download operation - <a href="qfile.html">TQFile</a> *file = new <a href="qfile.html">TQFile</a>( fileName ); - if ( !file-><a href="qfile.html#open">open</a>( <a href="qfile.html#open">IO_WriteOnly</a> ) ) { - TQMessageBox::<a href="qmessagebox.html#critical">critical</a>( this, tr("Download error"), + <a href="ntqfile.html">TQFile</a> *file = new <a href="ntqfile.html">TQFile</a>( fileName ); + if ( !file-><a href="ntqfile.html#open">open</a>( <a href="ntqfile.html#open">IO_WriteOnly</a> ) ) { + TQMessageBox::<a href="ntqmessagebox.html#critical">critical</a>( this, tr("Download error"), tr("Can't open file '%1' for writing.").arg(fileName) ); delete file; return; } - <a href="qprogressdialog.html">TQProgressDialog</a> progress( + <a href="ntqprogressdialog.html">TQProgressDialog</a> progress( tr("Downloading file..."), tr("Cancel"), 0, this, "download progress dialog", TRUE ); - connect( ftp, SIGNAL(<a href="qftp.html#dataTransferProgress">dataTransferProgress</a>(int,int)), - &progress, SLOT(<a href="qprogressdialog.html#setProgress">setProgress</a>(int,int)) ); - connect( ftp, SIGNAL(<a href="qftp.html#commandFinished">commandFinished</a>(int,bool)), - &progress, SLOT(<a href="qprogressdialog.html#reset">reset</a>()) ); - connect( &progress, SIGNAL(<a href="qprogressdialog.html#cancelled">cancelled</a>()), - ftp, SLOT(<a href="qftp.html#abort">abort</a>()) ); - -<a name="x755"></a> ftp-><a href="qftp.html#get">get</a>( item-><a href="qlistviewitem.html#text">text</a>(0), file ); - progress.<a href="qdialog.html#exec">exec</a>(); // ### takes a lot of time!!! + connect( ftp, SIGNAL(<a href="ntqftp.html#dataTransferProgress">dataTransferProgress</a>(int,int)), + &progress, SLOT(<a href="ntqprogressdialog.html#setProgress">setProgress</a>(int,int)) ); + connect( ftp, SIGNAL(<a href="ntqftp.html#commandFinished">commandFinished</a>(int,bool)), + &progress, SLOT(<a href="ntqprogressdialog.html#reset">reset</a>()) ); + connect( &progress, SIGNAL(<a href="ntqprogressdialog.html#cancelled">cancelled</a>()), + ftp, SLOT(<a href="ntqftp.html#abort">abort</a>()) ); + +<a name="x755"></a> ftp-><a href="ntqftp.html#get">get</a>( item-><a href="qlistviewitem.html#text">text</a>(0), file ); + progress.<a href="ntqdialog.html#exec">exec</a>(); // ### takes a lot of time!!! } void FtpMainWindow::removeFile() @@ -185,8 +185,8 @@ void FtpMainWindow::removeFile() if ( !item || item->isDir() ) return; -<a name="x762"></a> ftp-><a href="qftp.html#remove">remove</a>( item-><a href="qlistviewitem.html#text">text</a>(0) ); - ftp-><a href="qftp.html#list">list</a>(); +<a name="x762"></a> ftp-><a href="ntqftp.html#remove">remove</a>( item-><a href="qlistviewitem.html#text">text</a>(0) ); + ftp-><a href="ntqftp.html#list">list</a>(); } void FtpMainWindow::connectToHost() @@ -198,22 +198,22 @@ void FtpMainWindow::connectToHost() remotePath->clear(); remoteView->clear(); - if ( ftp-><a href="qftp.html#state">state</a>() != TQFtp::Unconnected ) - ftp-><a href="qftp.html#close">close</a>(); + if ( ftp-><a href="ntqftp.html#state">state</a>() != TQFtp::Unconnected ) + ftp-><a href="ntqftp.html#close">close</a>(); -<a name="x749"></a> ftp-><a href="qftp.html#connectToHost">connectToHost</a>( connectDialog.host->text(), connectDialog.port->value() ); -<a name="x758"></a> ftp-><a href="qftp.html#login">login</a>( connectDialog.username->text(), connectDialog.password->text() ); -<a name="x760"></a> ftp-><a href="qftp.html#rawCommand">rawCommand</a>( "PWD" ); - ftp-><a href="qftp.html#list">list</a>(); +<a name="x749"></a> ftp-><a href="ntqftp.html#connectToHost">connectToHost</a>( connectDialog.host->text(), connectDialog.port->value() ); +<a name="x758"></a> ftp-><a href="ntqftp.html#login">login</a>( connectDialog.username->text(), connectDialog.password->text() ); +<a name="x760"></a> ftp-><a href="ntqftp.html#rawCommand">rawCommand</a>( "PWD" ); + ftp-><a href="ntqftp.html#list">list</a>(); } // This slot is connected to the TQComboBox::activated() signal of the // remotePath. -void FtpMainWindow::changePath( const <a href="qstring.html">TQString</a> &newPath ) +void FtpMainWindow::changePath( const <a href="ntqstring.html">TQString</a> &newPath ) { -<a name="x745"></a> ftp-><a href="qftp.html#cd">cd</a>( newPath ); - ftp-><a href="qftp.html#rawCommand">rawCommand</a>( "PWD" ); - ftp-><a href="qftp.html#list">list</a>(); +<a name="x745"></a> ftp-><a href="ntqftp.html#cd">cd</a>( newPath ); + ftp-><a href="ntqftp.html#rawCommand">rawCommand</a>( "PWD" ); + ftp-><a href="ntqftp.html#list">list</a>(); } // This slot is connected to the TQListView::doubleClicked() and @@ -234,8 +234,8 @@ void FtpMainWindow::changePathOrDownload( <a href="qlistviewitem.html">TQListVie void FtpMainWindow::ftp_commandStarted() { -<a name="x738"></a> TQApplication::<a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>( TQCursor(TQt::WaitCursor) ); -<a name="x750"></a> if ( ftp-><a href="qftp.html#currentCommand">currentCommand</a>() == TQFtp::List ) { +<a name="x738"></a> TQApplication::<a href="ntqapplication.html#setOverrideCursor">setOverrideCursor</a>( TQCursor(TQt::WaitCursor) ); +<a name="x750"></a> if ( ftp-><a href="ntqftp.html#currentCommand">currentCommand</a>() == TQFtp::List ) { remoteView->clear(); if ( currentFtpDir != "/" ) new FtpViewItem( remoteView, FtpViewItem::Directory, "..", "", "" ); @@ -244,20 +244,20 @@ void FtpMainWindow::ftp_commandStarted() void FtpMainWindow::ftp_commandFinished() { -<a name="x737"></a> TQApplication::<a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a>(); -<a name="x751"></a> delete ftp-><a href="qftp.html#currentDevice">currentDevice</a>(); +<a name="x737"></a> TQApplication::<a href="ntqapplication.html#restoreOverrideCursor">restoreOverrideCursor</a>(); +<a name="x751"></a> delete ftp-><a href="ntqftp.html#currentDevice">currentDevice</a>(); } void FtpMainWindow::ftp_done( bool error ) { if ( error ) { -<a name="x754"></a> TQMessageBox::<a href="qmessagebox.html#critical">critical</a>( this, tr("FTP Error"), ftp-><a href="qftp.html#errorString">errorString</a>() ); +<a name="x754"></a> TQMessageBox::<a href="ntqmessagebox.html#critical">critical</a>( this, tr("FTP Error"), ftp-><a href="ntqftp.html#errorString">errorString</a>() ); // If we are connected, but not logged in, it is not meaningful to stay // connected to the server since the error is a really fatal one (login // failed). - if ( ftp-><a href="qftp.html#state">state</a>() == TQFtp::Connected ) - ftp-><a href="qftp.html#close">close</a>(); + if ( ftp-><a href="ntqftp.html#state">state</a>() == TQFtp::Connected ) + ftp-><a href="ntqftp.html#close">close</a>(); } } @@ -265,42 +265,42 @@ void FtpMainWindow::ftp_stateChanged( int state ) { switch ( (TQFtp::State)state ) { case TQFtp::Unconnected: -<a name="x765"></a> stateFtp-><a href="qlabel.html#setText">setText</a>( tr("Unconnected") ); +<a name="x765"></a> stateFtp-><a href="ntqlabel.html#setText">setText</a>( tr("Unconnected") ); break; case TQFtp::HostLookup: - stateFtp-><a href="qlabel.html#setText">setText</a>( tr("Host lookup") ); + stateFtp-><a href="ntqlabel.html#setText">setText</a>( tr("Host lookup") ); break; case TQFtp::Connecting: - stateFtp-><a href="qlabel.html#setText">setText</a>( tr("Connecting") ); + stateFtp-><a href="ntqlabel.html#setText">setText</a>( tr("Connecting") ); break; case TQFtp::Connected: - stateFtp-><a href="qlabel.html#setText">setText</a>( tr("Connected") ); + stateFtp-><a href="ntqlabel.html#setText">setText</a>( tr("Connected") ); break; case TQFtp::LoggedIn: - stateFtp-><a href="qlabel.html#setText">setText</a>( tr("Logged in") ); + stateFtp-><a href="ntqlabel.html#setText">setText</a>( tr("Logged in") ); break; case TQFtp::Closing: - stateFtp-><a href="qlabel.html#setText">setText</a>( tr("Closing") ); + stateFtp-><a href="ntqlabel.html#setText">setText</a>( tr("Closing") ); break; } } -void FtpMainWindow::ftp_listInfo( const <a href="qurlinfo.html">TQUrlInfo</a> &i ) +void FtpMainWindow::ftp_listInfo( const <a href="ntqurlinfo.html">TQUrlInfo</a> &i ) { FtpViewItem::Type type; -<a name="x773"></a> if ( i.<a href="qurlinfo.html#isDir">isDir</a>() ) +<a name="x773"></a> if ( i.<a href="ntqurlinfo.html#isDir">isDir</a>() ) type = FtpViewItem::Directory; else type = FtpViewItem::File; new FtpViewItem( remoteView, type, -<a name="x776"></a><a name="x775"></a><a name="x774"></a> i.<a href="qurlinfo.html#name">name</a>(), TQString::number(i.<a href="qurlinfo.html#size">size</a>()), i.<a href="qurlinfo.html#lastModified">lastModified</a>().toString() ); +<a name="x776"></a><a name="x775"></a><a name="x774"></a> i.<a href="ntqurlinfo.html#name">name</a>(), TQString::number(i.<a href="ntqurlinfo.html#size">size</a>()), i.<a href="ntqurlinfo.html#lastModified">lastModified</a>().toString() ); } -void FtpMainWindow::ftp_rawCommandReply( int code, const <a href="qstring.html">TQString</a> &text ) +void FtpMainWindow::ftp_rawCommandReply( int code, const <a href="ntqstring.html">TQString</a> &text ) { if ( code == 257 ) { -<a name="x772"></a> currentFtpDir = text.<a href="qstring.html#section">section</a>( '"', 1, 1 ); +<a name="x772"></a> currentFtpDir = text.<a href="ntqstring.html#section">section</a>( '"', 1, 1 ); for ( int i = 0; i<remotePath->count(); i++ ) { // make sure that we don't insert duplicates @@ -325,19 +325,19 @@ void FtpMainWindow::ftp_rawCommandReply( int code, const <a href="qstring.html"> ** *****************************************************************************/ -#include <<a href="qapplication-h.html">qapplication.h</a>> +#include <<a href="qapplication-h.html">ntqapplication.h</a>> #include "ftpmainwindow.h" int main( int argc, char **argv ) { - <a href="qapplication.html">TQApplication</a> a( argc, argv ); + <a href="ntqapplication.html">TQApplication</a> a( argc, argv ); FtpMainWindow m; -<a name="x779"></a> a.<a href="qapplication.html#setMainWidget">setMainWidget</a>( &m ); +<a name="x779"></a> a.<a href="ntqapplication.html#setMainWidget">setMainWidget</a>( &m ); m.show(); -<a name="x778"></a> a.<a href="qapplication.html#processEvents">processEvents</a>(); +<a name="x778"></a> a.<a href="ntqapplication.html#processEvents">processEvents</a>(); m.connectToHost(); -<a name="x777"></a> return a.<a href="qapplication.html#exec">exec</a>(); +<a name="x777"></a> return a.<a href="ntqapplication.html#exec">exec</a>(); } </pre> |