summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/NetworkDialog.cpp30
-rw-r--r--noncore/apps/opie-gutenbrowser/NetworkDialog.h14
-rw-r--r--noncore/apps/opie-gutenbrowser/SearchDialog.cpp8
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 @@
1// /*************************************************************************** 1// /***************************************************************************
2// NetworkDialog.cpp - description 2// NetworkDialog.cpp - description
3// begin : Sun Aug 27 2000 3// begin : Sun Aug 27 2000
4// copyright : (C) 2000 - 2004 by L.J. Potter 4// copyright : (C) 2000 - 2004 by L.J. Potter
5// email : ljp@llornkcor.com 5// email : ljp@llornkcor.com
6// * This program is free software; you can redistribute it and/or modify * 6// * This program is free software; you can redistribute it and/or modify *
7// * it under the terms of the GNU General Public License as published by * 7// * it under the terms of the GNU General Public License as published by *
8// * the Free Software Foundation; either version 2 of the License, or * 8// * the Free Software Foundation; either version 2 of the License, or *
9// * (at your option) any later version. * 9// * (at your option) any later version. *
10// ***************************************************************************/ 10// ***************************************************************************/
11// // half-assed attempt at providing a network dialog. 11// // half-assed attempt at providing a network dialog.
12// /* Created: Sun Aug 27 15:24:52 2000*/ 12// /* Created: Sun Aug 27 15:24:52 2000*/
13 13
14 14
15#include "NetworkDialog.h" 15#include "NetworkDialog.h"
16#include "gutenbrowser.h" 16#include "gutenbrowser.h"
17 17
18/* OPIE */ 18/* OPIE */
19#include <opie2/odebug.h> 19#include <opie2/odebug.h>
20 20
21/* QT */ 21/* QT */
22#include <qprogressbar.h> 22#include <qprogressbar.h>
23#include <qstringlist.h> 23#include <qstringlist.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qvaluelist.h> 25#include <qvaluelist.h>
26#include <qapplication.h> 26#include <qapplication.h>
27#include <qfile.h> 27#include <qfile.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qlayout.h> 31#include <qlayout.h>
32 32
33/* STD */ 33/* STD */
34#include <unistd.h> 34#include <unistd.h>
35extern "C" { 35extern "C" {
36#include <ftplib.h> 36#include <ftplib.h>
37} 37}
38 38
39QProgressBar* ProgressBar1; 39QProgressBar* ProgressBar1;
40QPushButton* buttonCancel; 40QPushButton* buttonCancel;
41static netbuf *conn = NULL; 41static netbuf *conn = NULL;
42 42
43static int log_progress(netbuf *ctl, int xfered, void *arg) { 43static int log_progress(netbuf *ctl, int xfered, void *arg) {
44 int fsz = *(int *)arg; 44 int fsz = *(int *)arg;
45 int pct = (xfered * 100) / fsz; 45 int pct = (xfered * 100) / fsz;
46 printf("%3d%%\r", pct); 46 printf("%3d%%\r", pct);
47 fflush(stdout); 47 fflush(stdout);
48 ProgressBar1->setProgress(xfered); 48 ProgressBar1->setProgress(xfered);
49 qApp->processEvents(); 49 qApp->processEvents();
50 50
51 return 1; 51 return 1;
52} 52}
53 53
54NetworkDialog::NetworkDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QStringList netL) 54NetworkDialog::NetworkDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QStringList netL)
55 : QDialog( parent, name, modal, fl ) 55 : QDialog( parent, name, modal, fl )
56{ 56{
57 57
58 ftp_host = netL[0]; 58 ftp_host = netL[0];
59 networkUrl = strUrl = netL[0]; 59 networkUrl = strUrl = netL[0];
60 60
61 dir = ftp_base_dir = netL[1]; 61 dir = ftp_base_dir = netL[1];
62 localFileName = netL[2]; 62 localFileName = netL[2];
63 s_partialFileName = netL[3]; 63 s_partialFileName = netL[3];
64 64
65 resize(240,110); 65 resize(240,120);
66 66
67 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 67 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
68// autoOk = autoDownload; 68// autoOk = autoDownload;
69// if( networkUrl.find("ftp",0,false)== -1 ) { 69// if( networkUrl.find("ftp",0,false)== -1 ) {
70// if ( !name ) 70// if ( !name )
71// setName( "HTTP NetworkDialog" ); 71// setName( "HTTP NetworkDialog" );
72// setCaption( tr( "HTTP Download ) ); 72// setCaption( tr( "HTTP Download ) );
73// qInitNetworkProtocols(); // registers ftp protocol // for now 73// qInitNetworkProtocols(); // registers ftp protocol // for now
74// QNetworkProtocol::registerNetworkProtocol( "http", new QNetworkProtocolFactory<Http> ); 74// QNetworkProtocol::registerNetworkProtocol( "http", new QNetworkProtocolFactory<Http> );
75// } else { 75// } else {
76 if ( !name ) 76 if ( !name )
77 setName( "FTP NetworkDialog" ); 77 setName( "FTP NetworkDialog" );
78 setCaption(tr("FTP Download")); 78 setCaption(tr("FTP Download"));
79// } 79// }
80 initDialog(); //opens file to be written 80 initDialog(); //opens file to be written
81} 81}
82 82
83NetworkDialog::~NetworkDialog() { 83NetworkDialog::~NetworkDialog() {
84} 84}
85 85
86void NetworkDialog::initDialog() { 86void NetworkDialog::initDialog() {
87 87
88 totalBytesDownloaded=0; 88 totalBytesDownloaded=0;
89 warnLabel = new QLabel( this, "TextLabel" ); 89 warnLabel = new QLabel( this, "TextLabel" );
90 warnLabel ->setText( tr( "Push Ok to download file...." ) ); 90 warnLabel ->setText( tr( "Push Ok to download file...." ) );
91 TextLabel3 = new QLabel( this, "TextLabel3" ); 91 TextLabel3 = new QLabel( this, "TextLabel3" );
92 TextLabel3->setText( ""); 92 TextLabel3->setText( "");
93 QWidget* Layout1 = new QWidget( this, "Layout1" ); 93 QWidget* Layout1 = new QWidget( this, "Layout1" );
94 94
95 hbox = new QHBoxLayout(Layout1); 95 hbox = new QHBoxLayout(Layout1);
96 hbox->setMargin(4); 96 hbox->setMargin(4);
97 97
98 ProgressBar1 = new QProgressBar( Layout1, "ProgressBar1" ); 98 ProgressBar1 = new QProgressBar( Layout1, "ProgressBar1" );
99 ProgressBar1->setProgress(0); 99 ProgressBar1->setProgress(0);
100 hbox->addWidget(ProgressBar1,10,AlignCenter); 100 hbox->addWidget(ProgressBar1,10,AlignCenter);
101 101
102 hbox->addStretch(1); 102 // hbox->addStretch(1);
103 buttonOk = new QPushButton( Layout1, "buttonOk" ); 103// buttonOk = new QPushButton( Layout1, "buttonOk" );
104 buttonOk->setText( tr( "&OK" ) ); 104// buttonOk->setText( tr( "&OK" ) );
105 hbox->addWidget(buttonOk,0,AlignRight); 105// hbox->addWidget(buttonOk,0,AlignRight);
106 hbox->addSpacing(5); 106// hbox->addSpacing(5);
107 buttonCancel = new QPushButton( Layout1, "buttonCancel" ); 107 buttonCancel = new QPushButton( Layout1, "buttonCancel" );
108 buttonCancel->setText( tr( "&Cancel" ) ); 108 buttonCancel->setText( tr( "&Cancel" ) );
109 buttonCancel->setAutoDefault( TRUE ); 109 buttonCancel->setAutoDefault( TRUE );
110 buttonCancel->setDefault( TRUE ); 110 buttonCancel->setDefault( TRUE );
111 hbox->addWidget(buttonCancel,0,AlignRight); 111 hbox->addWidget(buttonCancel,0,AlignRight);
112 112
113 ProgressBar1->setFixedSize(140,22); 113 ProgressBar1->setFixedSize(150,25);
114 buttonOk->setFixedSize(35,22); 114// buttonOk->setFixedSize(35,22);
115 buttonCancel->setFixedSize(35,22); 115 buttonCancel->setFixedSize(50,25);
116 warnLabel ->setGeometry( QRect( 5,1,230,25)); 116 warnLabel ->setGeometry( QRect( 5,1,230,25));
117 TextLabel3->setGeometry( QRect( 5,20,230,25)); 117 TextLabel3->setGeometry( QRect( 5,20,230,25));
118 Layout1->setGeometry( QRect(1,60,235,50)); //TODO check these!! 118 Layout1->setGeometry( QRect(1,60,235,50)); //TODO check these!!
119 119
120// timer= new QTimer(this,"vu timer"); 120// timer= new QTimer(this,"vu timer");
121// connectionTimer=new QTimer(this,"connectionTimeout"); 121// connectionTimer=new QTimer(this,"connectionTimeout");
122 122
123 connect(buttonOk,SIGNAL(clicked()),this,SLOT(doOk())); 123// connect(buttonOk,SIGNAL(clicked()),this,SLOT(doOk()));
124 connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject())); 124 connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject()));
125// connect( timer, SIGNAL(timeout()), this , SLOT(timeSlot())); 125// connect( timer, SIGNAL(timeout()), this , SLOT(timeSlot()));
126// connect( connectionTimer,SIGNAL( timeout()),this,SLOT( connectionTimeSlot())); 126// connect( connectionTimer,SIGNAL( timeout()),this,SLOT( connectionTimeSlot()));
127 if(autoOk) { 127// if(autoOk) {
128 owarn << "XXXXXXXXXXXXXXXXXXXXXXXX" << oendl; 128// buttonOk->setDown(true);
129 buttonOk->setDown(true); 129 QTimer::singleShot( 1000, this, SLOT( doOk() ));
130 doOk(); 130// }
131 } 131
132} 132}
133 133
134void NetworkDialog::timeSlot() { 134void NetworkDialog::timeSlot() {
135 135
136// if(timerProgess < 19 && posTimer) { 136// if(timerProgess < 19 && posTimer) {
137// ProgressBar1->setProgress(timerProgess); 137// ProgressBar1->setProgress(timerProgess);
138// timerProgess++; 138// timerProgess++;
139// } else if(timerProgess > 19 && posTimer) { 139// } else if(timerProgess > 19 && posTimer) {
140// ProgressBar1->setProgress(timerProgess); 140// ProgressBar1->setProgress(timerProgess);
141// timerProgess++; 141// timerProgess++;
142// posTimer=FALSE; 142// posTimer=FALSE;
143// } 143// }
144// if(timerProgess > 1 &&!posTimer) { 144// if(timerProgess > 1 &&!posTimer) {
145// ProgressBar1->setProgress(timerProgess); 145// ProgressBar1->setProgress(timerProgess);
146// timerProgess--; 146// timerProgess--;
147// } else if(timerProgess > 1 &&!posTimer){ 147// } else if(timerProgess > 1 &&!posTimer){
148// ProgressBar1->setProgress(timerProgess); 148// ProgressBar1->setProgress(timerProgess);
149// timerProgess--; 149// timerProgess--;
150// posTimer=TRUE; 150// posTimer=TRUE;
151// } 151// }
152// // odebug << "timer event" << oendl; 152// // odebug << "timer event" << oendl;
153// qApp->processEvents(); 153// qApp->processEvents();
154// repaint(); 154// repaint();
155} 155}
156 156
157void NetworkDialog::connectionTimeSlot() { 157void NetworkDialog::connectionTimeSlot() {
158// odebug << "Connections timed out" << oendl; 158// odebug << "Connections timed out" << oendl;
159// ftpQuit(); 159// ftpQuit();
160// qApp->processEvents(); 160// qApp->processEvents();
161// repaint(); 161// repaint();
162// reject(); 162// reject();
163} 163}
164 164
165 165
166/* 166/*
167downloads the file networkUrl */ 167downloads the file networkUrl */
168bool NetworkDialog::downloadFile( QString networkUrl ) 168bool NetworkDialog::downloadFile( QString networkUrl )
169{ 169{
170 int fsz; 170 int fsz;
171// timer->start( 250 , FALSE); 171// timer->start( 250 , FALSE);
172// posTimer=TRUE; 172// posTimer=TRUE;
173// connectionTimer->start( 600 , FALSE); 173// connectionTimer->start( 600 , FALSE);
174 warnLabel ->setText( ""); 174 warnLabel ->setText( "");
175 qApp->processEvents(); 175 qApp->processEvents();
176 odebug << "Downloading: " << networkUrl << "" << oendl; 176 odebug << "Downloading: " << networkUrl << "" << oendl;
177 odebug << "Into: " << localFileName << "" << oendl; 177 odebug << "Into: " << localFileName << "" << oendl;
178 if( networkUrl.length() > 5) { 178 if( networkUrl.length() > 5) {
179 QString ftp_user = "anonymous"; 179 QString ftp_user = "anonymous";
180 QString ftp_pass = "zaurus@gutenbrowser.com"; 180 QString ftp_pass = "zaurus@gutenbrowser.com";
181// ftp_host= networkUrl.mid(networkUrl.find("ftp://",0, TRUE), 181// ftp_host= networkUrl.mid(networkUrl.find("ftp://",0, TRUE),
182 if(ftp_host.length() < 2) { 182 if(ftp_host.length() < 2) {
183 odebug << "Please select an ftp host" << oendl; 183 odebug << "Please select an ftp host" << oendl;
184 successDownload=false; 184 successDownload=false;
185 QMessageBox::message("Note","You need to select an ftp host"); 185 QMessageBox::message("Note","You need to select an ftp host");
186 return false; 186 return false;
187 } 187 }
188 QString msg; 188 QString msg;
189 odebug << ftp_host << oendl; 189 odebug << ftp_host << oendl;
190 odebug << "Opening ftp connection." << oendl; 190 odebug << "Opening ftp connection." << oendl;
191 warnLabel->setText("connecting to: "+ftp_host ); 191 warnLabel->setText("connecting to: "+ftp_host );
192 qApp->processEvents(); 192 qApp->processEvents();
193 /////////// Open FTP connection 193 /////////// Open FTP connection
194 if (!FtpConnect( ftp_host.latin1(), &conn)) { 194 if (!FtpConnect( ftp_host.latin1(), &conn)) {
195 i=0; 195 i=0;
196 successDownload=false; 196 successDownload=false;
197 QMessageBox::message("Note","Unable to connect to\n"+ftp_host); 197 QMessageBox::message("Note","Unable to connect to\n"+ftp_host);
198 return false; 198 return false;
199 } 199 }
200 TextLabel3->setText("Opening ftp connection."); 200 TextLabel3->setText("Opening ftp connection.");
201 qApp->processEvents(); 201 qApp->processEvents();
202 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 202 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
203 FtpQuit(conn); 203 FtpQuit(conn);
204 successDownload=false; 204 successDownload=false;
205 msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn)); 205 msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn));
206 QMessageBox::message("Note",msg); 206 QMessageBox::message("Note",msg);
207 return false; 207 return false;
208 } 208 }
209 odebug << "Changing directories." << oendl; 209 odebug << "Changing directories." << oendl;
210 TextLabel3->setText("Changing directories."); 210 TextLabel3->setText("Changing directories.");
211 qApp->processEvents(); 211 qApp->processEvents();
212 if (!FtpChdir( dir.latin1(), conn )) { 212 if (!FtpChdir( dir.latin1(), conn )) {
213 successDownload=false; 213 successDownload=false;
214 msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); 214 msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn));
215 QMessageBox::message("Note",msg); 215 QMessageBox::message("Note",msg);
216 FtpQuit(conn); 216 FtpQuit(conn);
217 return false; 217 return false;
218 } 218 }
219// if (!FtpNlst( "./.guten_temp", dir, conn)) { 219// if (!FtpNlst( "./.guten_temp", dir, conn)) {
220// successDownload=false; 220// successDownload=false;
221// msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); 221// msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn));
222// QMessageBox::message("Note",msg); 222// QMessageBox::message("Note",msg);
223// FtpQuit(conn); 223// FtpQuit(conn);
224// return false; 224// return false;
225// } 225// }
226 odebug << "Requesting directory list." << oendl; 226 odebug << "Requesting directory list." << oendl;
227 TextLabel3->setText("Getting directory list."); 227 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 @@
1/*************************************************************************** 1/***************************************************************************
2 NetworkDialog.h - description 2 NetworkDialog.h - description
3 ------------------- 3 -------------------
4 begin : Sun Aug 27 2000 4 begin : Sun Aug 27 2000
5 copyright : (C) 2000 -2004 by llornkcor 5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7***************************************************************************/ 7***************************************************************************/
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16#ifndef NETWORKDIALOG_H 16#ifndef NETWORKDIALOG_H
17#define NETWORKDIALOG_H 17#define NETWORKDIALOG_H
18 18
19#include <qdialog.h> 19#include <qdialog.h>
20#include <qurloperator.h> 20#include <qurloperator.h>
21#include <qcstring.h> 21#include <qcstring.h>
22#include <qfile.h> 22#include <qfile.h>
23#include <qlayout.h> 23#include <qlayout.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27 27
28//#include <qtimer.h> 28//#include <qtimer.h>
29 29
30//class QProgressBar; 30//class QProgressBar;
31 31
32class NetworkDialog : public QDialog 32class NetworkDialog : public QDialog
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35 35
36public: 36public:
37 NetworkDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0, const QStringList netList=0); 37 NetworkDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0, const QStringList netList=0);
38/* 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); */ 38/* 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); */
39 ~NetworkDialog(); 39 ~NetworkDialog();
40 40
41 QFile fiole; 41 QFile fiole;
42 QTimer * connectionTimer; 42 QTimer * connectionTimer;
43 QTimer * timer; 43 QTimer * timer;
44 int timerProgess; 44 int timerProgess;
45 bool posTimer; 45 bool posTimer;
46 QString s_partialFileName, s_finally; 46 QString s_partialFileName, s_finally;
47 bool foundIt, successDownload; 47 bool foundIt, successDownload;
48 QLabel * warnLabel; 48 QLabel * warnLabel;
49 QLabel* TextLabel3; 49 QLabel* TextLabel3;
50 QPushButton* buttonHelp; 50 QPushButton* buttonHelp;
51 bool ok; 51 bool ok;
52 QString local_library; 52 QString local_library;
53 QString ftp_host; 53 QString ftp_host;
54 QString ftp_base_dir; 54 QString ftp_base_dir;
55 QString dir, strUrl, networkUrl; 55 QString dir, strUrl, networkUrl;
56 56
57 QPushButton* buttonOk; 57// QPushButton* buttonOk;
58 QPushButton* buttonCancel; 58 QPushButton* buttonCancel;
59 59
60 QString localFileName; 60 QString localFileName;
61 bool fileFound; 61 bool fileFound;
62 int i, totalBytesDownloaded; 62 int i, totalBytesDownloaded;
63 bool autoOk; 63 bool autoOk;
64 64
65 void initDialog(); 65 void initDialog();
66 66
67protected: 67protected:
68 QHBoxLayout* hbox; 68 QHBoxLayout* hbox;
69 69
70private slots: 70private slots:
71 bool downloadFile( QString strUrl); 71 bool downloadFile( QString strUrl);
72 void connectionTimeSlot(); 72 void connectionTimeSlot();
73 void timeSlot(); 73 void timeSlot();
74 void doOk(); 74 void doOk();
75 75
76 private: 76 private:
77/* #ifndef Q_WS_QWS */ 77/* #ifndef Q_WS_QWS */
78 78
79/* QString getOpenFileName(); */ 79/* QString getOpenFileName(); */
80/* QUrlOperator op; */ 80/* QUrlOperator op; */
81/* #endif */ 81/* #endif */
82}; 82};
83 83
84#endif // NETWORKDIALOG_H 84#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 @@
1/**************************************************************************** 1/****************************************************************************
2** Created: Tue Aug 29 11:45:00 2000**/ 2** Created: Tue Aug 29 11:45:00 2000**/
3// copyright : (C) 2000 -2004 by llornkcor 3// copyright : (C) 2000 -2004 by llornkcor
4// email : ljp@llornkcor.com 4// email : ljp@llornkcor.com
5 5
6#include "SearchDialog.h" 6#include "SearchDialog.h"
7#include "SearchResults.h" 7#include "SearchResults.h"
8 8
9#include <qlayout.h> 9#include <qlayout.h>
10#include <qcheckbox.h> 10#include <qcheckbox.h>
11#include <qlabel.h> 11#include <qlabel.h>
12#include <qlineedit.h> 12#include <qlineedit.h>
13#include <qpushbutton.h> 13#include <qpushbutton.h>
14#include <qvariant.h> 14#include <qvariant.h>
15#include <qtooltip.h> 15#include <qtooltip.h>
16#include <qwhatsthis.h> 16#include <qwhatsthis.h>
17#include <qmessagebox.h> 17#include <qmessagebox.h>
18#include <qdir.h> 18#include <qdir.h>
19#include <qpe/config.h> 19#include <qpe/config.h>
20 20
21/*This is just a single text entry dialog */ 21/*This is just a single text entry dialog */
22SearchDialog::SearchDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 22SearchDialog::SearchDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
23 : QDialog( parent, name, modal, fl ) 23 : QDialog( parent, name, modal, fl )
24{ 24{
25 if ( !name ) 25 if ( !name )
26 setName( "SearchDialog" ); 26 setName( "SearchDialog" );
27 Config cfg("Gutenbrowser"); 27 Config cfg("Gutenbrowser");
28 cfg.setGroup("General"); 28 cfg.setGroup("General");
29 QString lastSearch=cfg.readEntry("LastSearch",""); 29 QString lastSearch=cfg.readEntry("LastSearch","");
30 30
31#warning FIXME 31#warning FIXME
32 // FIXME 32 // FIXME
33 resize( 220,100); 33 resize( 220,110);
34 34
35 QGridLayout *layout = new QGridLayout( this ); 35 QGridLayout *layout = new QGridLayout( this );
36 layout->setSpacing( 2); 36 layout->setSpacing( 2);
37 layout->setMargin( 2); 37 layout->setMargin( 2);
38 38
39 QString local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 39 QString local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
40 TextLabel1 = new QLabel( this, "TextLabel1" ); 40 TextLabel1 = new QLabel( this, "TextLabel1" );
41 layout->addMultiCellWidget( TextLabel1, 0, 0, 0, 1); 41 layout->addMultiCellWidget( TextLabel1, 0, 0, 0, 1);
42 42
43 label1Str= "<P>Enter text to search etext for </P>" ; 43 label1Str= "<P>Enter text to search etext for </P>" ;
44 TextLabel1->setText( tr( label1Str) ); 44 TextLabel1->setText( tr( label1Str) );
45 45
46 SearchLineEdit = new QLineEdit( this, "SearchLineEdit" ); 46 SearchLineEdit = new QLineEdit( this, "SearchLineEdit" );
47 layout->addMultiCellWidget( SearchLineEdit, 1, 1, 0, 1); 47 layout->addMultiCellWidget( SearchLineEdit, 1, 1, 0, 1);
48 48
49 buttonOk = new QPushButton( this, "buttonOk" ); 49 buttonOk = new QPushButton( this, "buttonOk" );
50 buttonOk->setText( tr( "Sea&rch" ) ); 50 buttonOk->setText( tr( "Sea&rch" ) );
51 buttonOk->setAutoDefault( TRUE ); 51 buttonOk->setAutoDefault( TRUE );
52 buttonOk->setToggleButton( TRUE); 52 buttonOk->setToggleButton( TRUE);
53 buttonOk->setDefault( TRUE ); 53 buttonOk->setDefault( TRUE );
54 54
55 layout->addMultiCellWidget(buttonOk, 2, 2, 0, 0); 55 layout->addMultiCellWidget(buttonOk, 2, 2, 0, 0);
56 56
57 buttonCancel = new QPushButton( this, "buttonCancel" ); 57 buttonCancel = new QPushButton( this, "buttonCancel" );
58 buttonCancel->setText( tr( "&Cancel" ) ); 58 buttonCancel->setText( tr( "&Cancel" ) );
59 buttonCancel->setAutoDefault( TRUE ); 59 buttonCancel->setAutoDefault( TRUE );
60 layout->addMultiCellWidget(buttonCancel, 2, 2, 1, 1); 60 layout->addMultiCellWidget(buttonCancel, 2, 2, 1, 1);
61// buttonCancel->setMaximumWidth(40); 61// buttonCancel->setMaximumWidth(40);
62 62
63 63
64 if( (QString)name !="Etext Search" ) 64 if( (QString)name !="Etext Search" )
65 SearchLineEdit->setText(lastSearch); 65 SearchLineEdit->setText(lastSearch);
66 66
67 caseSensitiveCheckBox = new QCheckBox ( tr("Case Sensitive"), this ); 67 caseSensitiveCheckBox = new QCheckBox ( tr("Case Sensitive"), this );
68 layout->addMultiCellWidget( caseSensitiveCheckBox, 3, 3, 0, 1); 68 layout->addMultiCellWidget( caseSensitiveCheckBox, 3, 3, 0, 1);
69 69
70 // signals and slots connections 70 // signals and slots connections
71 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( byeBye() ) ); 71 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( byeBye() ) );
72 72
73 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( closed() ) ); 73 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( closed() ) );
74 SearchLineEdit->setFocus(); 74 SearchLineEdit->setFocus();
75} 75}
76 76
77SearchDialog::~SearchDialog() 77SearchDialog::~SearchDialog()
78{ 78{
79} 79}
80 80
81QString SearchDialog::get_text() { 81QString SearchDialog::get_text() {
82 return SearchLineEdit->text(); 82 return SearchLineEdit->text();
83} 83}
84 84
85bool SearchDialog::get_direction() { 85bool SearchDialog::get_direction() {
86 return false; //search forward 86 return false; //search forward
87} 87}
88 88
89bool SearchDialog::case_sensitive() { 89bool SearchDialog::case_sensitive() {
90 return true; 90 return true;
91} 91}
92 92
93bool SearchDialog::forward_search() { 93bool SearchDialog::forward_search() {
94 return true; 94 return true;
95} 95}
96 96
97void SearchDialog::byeBye() 97void SearchDialog::byeBye()
98{ 98{
99 99
100 searchString = get_text(); 100 searchString = get_text();
101// odebug << "Search string is "+searchString << oendl; 101// odebug << "Search string is "+searchString << oendl;
102 Config cfg("Gutenbrowser"); 102 Config cfg("Gutenbrowser");
103 cfg.setGroup("General"); 103 cfg.setGroup("General");
104 cfg.writeEntry("LastSearch",searchString); 104 cfg.writeEntry("LastSearch",searchString);
105 105
106 QString thisName=name(); 106 QString thisName=name();
107 if( thisName.find("Library Search", 0, TRUE) != -1) { 107 if( thisName.find("Library Search", 0, TRUE) != -1) {
108 // searchString = SearchLineEdit->text(); 108 // searchString = SearchLineEdit->text();
109 accept(); 109 accept();
110 } else { 110 } else {
111 111
112 buttonOk->setDown(TRUE); 112 buttonOk->setDown(TRUE);
113 113
114 emit search_signal(); 114 emit search_signal();
115 buttonOk->setDown(FALSE); 115 buttonOk->setDown(FALSE);
116 } 116 }
117} 117}
118 118
119void SearchDialog::closed() 119void SearchDialog::closed()
120{ 120{
121 searchString = get_text(); 121 searchString = get_text();
122// odebug << "Search string is "+searchString << oendl; 122// odebug << "Search string is "+searchString << oendl;
123 Config cfg("Gutenbrowser"); 123 Config cfg("Gutenbrowser");
124 cfg.setGroup("General"); 124 cfg.setGroup("General");
125 cfg.writeEntry("LastSearch",searchString); 125 cfg.writeEntry("LastSearch",searchString);
126 126
127 emit search_done_signal(); 127 emit search_done_signal();
128 //this->reject(); 128 //this->reject();
129 this->hide(); 129 this->hide();
130} 130}
131 131
132 132
133void SearchDialog::setLabel(QString labelText) 133void SearchDialog::setLabel(QString labelText)
134{ 134{
135 TextLabel1->setText( tr( label1Str+labelText) ); 135 TextLabel1->setText( tr( label1Str+labelText) );
136} 136}