author | llornkcor <llornkcor> | 2004-06-15 10:18:36 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-06-15 10:18:36 (UTC) |
commit | c711eea6fb1fa136cd62dc8b7134ee72968c8a53 (patch) (side-by-side diff) | |
tree | 5f467c8abff45e468c4b119122553c1eef7f3beb | |
parent | 83b4b2d2670b63a2a540006cea2ea8808100d308 (diff) | |
download | opie-c711eea6fb1fa136cd62dc8b7134ee72968c8a53.zip opie-c711eea6fb1fa136cd62dc8b7134ee72968c8a53.tar.gz opie-c711eea6fb1fa136cd62dc8b7134ee72968c8a53.tar.bz2 |
start download, fix dialogs
-rw-r--r-- | noncore/apps/opie-gutenbrowser/NetworkDialog.cpp | 30 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/NetworkDialog.h | 14 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/SearchDialog.cpp | 8 |
3 files changed, 26 insertions, 26 deletions
diff --git a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp index 6e6b707..d629449 100644 --- a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp @@ -1,227 +1,227 @@ // /*************************************************************************** // NetworkDialog.cpp - description // begin : Sun Aug 27 2000 // copyright : (C) 2000 - 2004 by L.J. Potter // email : ljp@llornkcor.com // * This program is free software; you can redistribute it and/or modify * // * it under the terms of the GNU General Public License as published by * // * the Free Software Foundation; either version 2 of the License, or * // * (at your option) any later version. * // ***************************************************************************/ // // half-assed attempt at providing a network dialog. // /* Created: Sun Aug 27 15:24:52 2000*/ #include "NetworkDialog.h" #include "gutenbrowser.h" /* OPIE */ #include <opie2/odebug.h> /* QT */ #include <qprogressbar.h> #include <qstringlist.h> #include <qpe/config.h> #include <qvaluelist.h> #include <qapplication.h> #include <qfile.h> #include <qstringlist.h> #include <qlabel.h> #include <qpushbutton.h> #include <qlayout.h> /* STD */ #include <unistd.h> extern "C" { #include <ftplib.h> } QProgressBar* ProgressBar1; QPushButton* buttonCancel; static netbuf *conn = NULL; static int log_progress(netbuf *ctl, int xfered, void *arg) { int fsz = *(int *)arg; int pct = (xfered * 100) / fsz; printf("%3d%%\r", pct); fflush(stdout); ProgressBar1->setProgress(xfered); qApp->processEvents(); return 1; } NetworkDialog::NetworkDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QStringList netL) : QDialog( parent, name, modal, fl ) { ftp_host = netL[0]; networkUrl = strUrl = netL[0]; dir = ftp_base_dir = netL[1]; localFileName = netL[2]; s_partialFileName = netL[3]; - resize(240,110); + resize(240,120); local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; // autoOk = autoDownload; // if( networkUrl.find("ftp",0,false)== -1 ) { // if ( !name ) // setName( "HTTP NetworkDialog" ); // setCaption( tr( "HTTP Download ) ); // qInitNetworkProtocols(); // registers ftp protocol // for now // QNetworkProtocol::registerNetworkProtocol( "http", new QNetworkProtocolFactory<Http> ); // } else { if ( !name ) setName( "FTP NetworkDialog" ); setCaption(tr("FTP Download")); // } initDialog(); //opens file to be written } NetworkDialog::~NetworkDialog() { } void NetworkDialog::initDialog() { totalBytesDownloaded=0; warnLabel = new QLabel( this, "TextLabel" ); warnLabel ->setText( tr( "Push Ok to download file...." ) ); TextLabel3 = new QLabel( this, "TextLabel3" ); TextLabel3->setText( ""); QWidget* Layout1 = new QWidget( this, "Layout1" ); hbox = new QHBoxLayout(Layout1); hbox->setMargin(4); ProgressBar1 = new QProgressBar( Layout1, "ProgressBar1" ); ProgressBar1->setProgress(0); hbox->addWidget(ProgressBar1,10,AlignCenter); - hbox->addStretch(1); - buttonOk = new QPushButton( Layout1, "buttonOk" ); - buttonOk->setText( tr( "&OK" ) ); - hbox->addWidget(buttonOk,0,AlignRight); - hbox->addSpacing(5); + // hbox->addStretch(1); +// buttonOk = new QPushButton( Layout1, "buttonOk" ); +// buttonOk->setText( tr( "&OK" ) ); +// hbox->addWidget(buttonOk,0,AlignRight); +// hbox->addSpacing(5); buttonCancel = new QPushButton( Layout1, "buttonCancel" ); buttonCancel->setText( tr( "&Cancel" ) ); buttonCancel->setAutoDefault( TRUE ); buttonCancel->setDefault( TRUE ); hbox->addWidget(buttonCancel,0,AlignRight); - ProgressBar1->setFixedSize(140,22); - buttonOk->setFixedSize(35,22); - buttonCancel->setFixedSize(35,22); + ProgressBar1->setFixedSize(150,25); +// buttonOk->setFixedSize(35,22); + buttonCancel->setFixedSize(50,25); warnLabel ->setGeometry( QRect( 5,1,230,25)); TextLabel3->setGeometry( QRect( 5,20,230,25)); Layout1->setGeometry( QRect(1,60,235,50)); //TODO check these!! // timer= new QTimer(this,"vu timer"); // connectionTimer=new QTimer(this,"connectionTimeout"); - connect(buttonOk,SIGNAL(clicked()),this,SLOT(doOk())); +// connect(buttonOk,SIGNAL(clicked()),this,SLOT(doOk())); connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject())); // connect( timer, SIGNAL(timeout()), this , SLOT(timeSlot())); // connect( connectionTimer,SIGNAL( timeout()),this,SLOT( connectionTimeSlot())); - if(autoOk) { - owarn << "XXXXXXXXXXXXXXXXXXXXXXXX" << oendl; - buttonOk->setDown(true); - doOk(); - } +// if(autoOk) { +// buttonOk->setDown(true); + QTimer::singleShot( 1000, this, SLOT( doOk() )); +// } + } void NetworkDialog::timeSlot() { // if(timerProgess < 19 && posTimer) { // ProgressBar1->setProgress(timerProgess); // timerProgess++; // } else if(timerProgess > 19 && posTimer) { // ProgressBar1->setProgress(timerProgess); // timerProgess++; // posTimer=FALSE; // } // if(timerProgess > 1 &&!posTimer) { // ProgressBar1->setProgress(timerProgess); // timerProgess--; // } else if(timerProgess > 1 &&!posTimer){ // ProgressBar1->setProgress(timerProgess); // timerProgess--; // posTimer=TRUE; // } // // odebug << "timer event" << oendl; // qApp->processEvents(); // repaint(); } void NetworkDialog::connectionTimeSlot() { // odebug << "Connections timed out" << oendl; // ftpQuit(); // qApp->processEvents(); // repaint(); // reject(); } /* downloads the file networkUrl */ bool NetworkDialog::downloadFile( QString networkUrl ) { int fsz; // timer->start( 250 , FALSE); // posTimer=TRUE; // connectionTimer->start( 600 , FALSE); warnLabel ->setText( ""); qApp->processEvents(); odebug << "Downloading: " << networkUrl << "" << oendl; odebug << "Into: " << localFileName << "" << oendl; if( networkUrl.length() > 5) { QString ftp_user = "anonymous"; QString ftp_pass = "zaurus@gutenbrowser.com"; // ftp_host= networkUrl.mid(networkUrl.find("ftp://",0, TRUE), if(ftp_host.length() < 2) { odebug << "Please select an ftp host" << oendl; successDownload=false; QMessageBox::message("Note","You need to select an ftp host"); return false; } QString msg; odebug << ftp_host << oendl; odebug << "Opening ftp connection." << oendl; warnLabel->setText("connecting to: "+ftp_host ); qApp->processEvents(); /////////// Open FTP connection if (!FtpConnect( ftp_host.latin1(), &conn)) { i=0; successDownload=false; QMessageBox::message("Note","Unable to connect to\n"+ftp_host); return false; } TextLabel3->setText("Opening ftp connection."); qApp->processEvents(); if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { FtpQuit(conn); successDownload=false; msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn)); QMessageBox::message("Note",msg); return false; } odebug << "Changing directories." << oendl; TextLabel3->setText("Changing directories."); qApp->processEvents(); if (!FtpChdir( dir.latin1(), conn )) { successDownload=false; msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); QMessageBox::message("Note",msg); FtpQuit(conn); return false; } // if (!FtpNlst( "./.guten_temp", dir, conn)) { // successDownload=false; // msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); // QMessageBox::message("Note",msg); // FtpQuit(conn); // return false; // } odebug << "Requesting directory list." << oendl; TextLabel3->setText("Getting directory list."); diff --git a/noncore/apps/opie-gutenbrowser/NetworkDialog.h b/noncore/apps/opie-gutenbrowser/NetworkDialog.h index 447979f..61595a8 100644 --- a/noncore/apps/opie-gutenbrowser/NetworkDialog.h +++ b/noncore/apps/opie-gutenbrowser/NetworkDialog.h @@ -1,84 +1,84 @@ /*************************************************************************** NetworkDialog.h - description ------------------- begin : Sun Aug 27 2000 copyright : (C) 2000 -2004 by llornkcor email : ljp@llornkcor.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef NETWORKDIALOG_H #define NETWORKDIALOG_H #include <qdialog.h> #include <qurloperator.h> #include <qcstring.h> #include <qfile.h> #include <qlayout.h> #include <qlabel.h> #include <qpushbutton.h> #include <qstringlist.h> //#include <qtimer.h> //class QProgressBar; class NetworkDialog : public QDialog -{ +{ Q_OBJECT public: NetworkDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0, const QStringList netList=0); /* NetworkDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0, const QString & UrlStr = 0, const QString & dirStr=0,const QString & fileStr=0, const QString & psrtialFile=0); */ ~NetworkDialog(); - + QFile fiole; QTimer * connectionTimer; QTimer * timer; int timerProgess; - bool posTimer; + bool posTimer; QString s_partialFileName, s_finally; bool foundIt, successDownload; QLabel * warnLabel; QLabel* TextLabel3; QPushButton* buttonHelp; bool ok; QString local_library; QString ftp_host; QString ftp_base_dir; - QString dir, strUrl, networkUrl; - - QPushButton* buttonOk; + QString dir, strUrl, networkUrl; + +// QPushButton* buttonOk; QPushButton* buttonCancel; QString localFileName; bool fileFound; int i, totalBytesDownloaded; bool autoOk; void initDialog(); protected: QHBoxLayout* hbox; private slots: bool downloadFile( QString strUrl); void connectionTimeSlot(); void timeSlot(); void doOk(); - + private: /* #ifndef Q_WS_QWS */ /* QString getOpenFileName(); */ /* QUrlOperator op; */ /* #endif */ }; #endif // NETWORKDIALOG_H diff --git a/noncore/apps/opie-gutenbrowser/SearchDialog.cpp b/noncore/apps/opie-gutenbrowser/SearchDialog.cpp index d989304..055ffee 100644 --- a/noncore/apps/opie-gutenbrowser/SearchDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/SearchDialog.cpp @@ -1,136 +1,136 @@ /**************************************************************************** ** Created: Tue Aug 29 11:45:00 2000**/ // copyright : (C) 2000 -2004 by llornkcor // email : ljp@llornkcor.com #include "SearchDialog.h" #include "SearchResults.h" #include <qlayout.h> #include <qcheckbox.h> #include <qlabel.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qvariant.h> #include <qtooltip.h> #include <qwhatsthis.h> #include <qmessagebox.h> #include <qdir.h> #include <qpe/config.h> /*This is just a single text entry dialog */ SearchDialog::SearchDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "SearchDialog" ); Config cfg("Gutenbrowser"); cfg.setGroup("General"); QString lastSearch=cfg.readEntry("LastSearch",""); #warning FIXME // FIXME - resize( 220,100); - + resize( 220,110); + QGridLayout *layout = new QGridLayout( this ); layout->setSpacing( 2); layout->setMargin( 2); QString local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; TextLabel1 = new QLabel( this, "TextLabel1" ); layout->addMultiCellWidget( TextLabel1, 0, 0, 0, 1); label1Str= "<P>Enter text to search etext for </P>" ; TextLabel1->setText( tr( label1Str) ); SearchLineEdit = new QLineEdit( this, "SearchLineEdit" ); layout->addMultiCellWidget( SearchLineEdit, 1, 1, 0, 1); buttonOk = new QPushButton( this, "buttonOk" ); buttonOk->setText( tr( "Sea&rch" ) ); buttonOk->setAutoDefault( TRUE ); buttonOk->setToggleButton( TRUE); buttonOk->setDefault( TRUE ); layout->addMultiCellWidget(buttonOk, 2, 2, 0, 0); buttonCancel = new QPushButton( this, "buttonCancel" ); buttonCancel->setText( tr( "&Cancel" ) ); buttonCancel->setAutoDefault( TRUE ); layout->addMultiCellWidget(buttonCancel, 2, 2, 1, 1); // buttonCancel->setMaximumWidth(40); if( (QString)name !="Etext Search" ) SearchLineEdit->setText(lastSearch); caseSensitiveCheckBox = new QCheckBox ( tr("Case Sensitive"), this ); layout->addMultiCellWidget( caseSensitiveCheckBox, 3, 3, 0, 1); // signals and slots connections connect( buttonOk, SIGNAL( clicked() ), this, SLOT( byeBye() ) ); connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( closed() ) ); SearchLineEdit->setFocus(); } SearchDialog::~SearchDialog() { } QString SearchDialog::get_text() { return SearchLineEdit->text(); } bool SearchDialog::get_direction() { return false; //search forward } bool SearchDialog::case_sensitive() { return true; } bool SearchDialog::forward_search() { return true; } void SearchDialog::byeBye() { searchString = get_text(); -// odebug << "Search string is "+searchString << oendl; +// odebug << "Search string is "+searchString << oendl; Config cfg("Gutenbrowser"); cfg.setGroup("General"); cfg.writeEntry("LastSearch",searchString); QString thisName=name(); if( thisName.find("Library Search", 0, TRUE) != -1) { // searchString = SearchLineEdit->text(); accept(); } else { buttonOk->setDown(TRUE); emit search_signal(); buttonOk->setDown(FALSE); } } void SearchDialog::closed() { searchString = get_text(); -// odebug << "Search string is "+searchString << oendl; +// odebug << "Search string is "+searchString << oendl; Config cfg("Gutenbrowser"); cfg.setGroup("General"); cfg.writeEntry("LastSearch",searchString); emit search_done_signal(); //this->reject(); this->hide(); } void SearchDialog::setLabel(QString labelText) { TextLabel1->setText( tr( label1Str+labelText) ); } |