summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.cpp1067
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.h126
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.obin0 -> 83212 bytes
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialogData.cpp281
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialogData.obin0 -> 15972 bytes
-rw-r--r--noncore/apps/opie-gutenbrowser/NetworkDialog.cpp329
-rw-r--r--noncore/apps/opie-gutenbrowser/NetworkDialog.h84
-rw-r--r--noncore/apps/opie-gutenbrowser/SearchDialog.cpp135
-rw-r--r--noncore/apps/opie-gutenbrowser/SearchDialog.h57
-rw-r--r--noncore/apps/opie-gutenbrowser/SearchResults.cpp101
-rw-r--r--noncore/apps/opie-gutenbrowser/SearchResults.h51
-rw-r--r--noncore/apps/opie-gutenbrowser/bookmarksdlg.cpp34
-rw-r--r--noncore/apps/opie-gutenbrowser/bookmarksdlg.h55
-rw-r--r--noncore/apps/opie-gutenbrowser/browserDialog.cpp83
-rw-r--r--noncore/apps/opie-gutenbrowser/config.in4
-rw-r--r--noncore/apps/opie-gutenbrowser/editTitle.cpp54
-rw-r--r--noncore/apps/opie-gutenbrowser/editTitle.h34
-rw-r--r--noncore/apps/opie-gutenbrowser/editTitle.ui100
-rw-r--r--noncore/apps/opie-gutenbrowser/fontDialog.cpp260
-rw-r--r--noncore/apps/opie-gutenbrowser/fontDialog.h59
-rw-r--r--noncore/apps/opie-gutenbrowser/fontDialog.ui201
-rw-r--r--noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp247
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp1984
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.h226
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp328
-rw-r--r--noncore/apps/opie-gutenbrowser/helpme.cpp122
-rw-r--r--noncore/apps/opie-gutenbrowser/helpme.h60
-rw-r--r--noncore/apps/opie-gutenbrowser/helpwindow.cpp326
-rw-r--r--noncore/apps/opie-gutenbrowser/helpwindow.h67
-rw-r--r--noncore/apps/opie-gutenbrowser/main.cpp64
-rw-r--r--noncore/apps/opie-gutenbrowser/multiline_ex.cpp133
-rw-r--r--noncore/apps/opie-gutenbrowser/multiline_ex.h108
-rw-r--r--noncore/apps/opie-gutenbrowser/openetext.cpp517
-rw-r--r--noncore/apps/opie-gutenbrowser/openetext.h82
-rw-r--r--noncore/apps/opie-gutenbrowser/openetextdata.cpp77
-rw-r--r--noncore/apps/opie-gutenbrowser/opie-gutenbrowser.control11
-rw-r--r--noncore/apps/opie-gutenbrowser/opie-gutenbrowser.pro45
-rw-r--r--noncore/apps/opie-gutenbrowser/optionsDialog.cpp207
-rw-r--r--noncore/apps/opie-gutenbrowser/optionsDialog.h112
-rw-r--r--noncore/apps/opie-gutenbrowser/optionsDialogData.cpp171
-rw-r--r--noncore/apps/opie-gutenbrowser/output.cpp36
-rw-r--r--noncore/apps/opie-gutenbrowser/output.h30
-rw-r--r--noncore/apps/opie-gutenbrowser/resource.h73
-rw-r--r--noncore/apps/opie-gutenbrowser/unzip.readme4
44 files changed, 8145 insertions, 0 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
new file mode 100644
index 0000000..157a3da
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
@@ -0,0 +1,1067 @@
1/***************************************************************************
2// LibraryDialog.cpp - description
3// -------------------
4// begin : Sat Aug 19 2000
5// copyright : (C) 2000 - 2004 by llornkcor
6// email : ljp@llornkcor.com
7// ***************************************************/
8// /***************************************************************************
9// * This program is free software; you can redistribute it and/or modify *
10// * it under the terms of the GNU General Public License as published by *
11// * the Free Software Foundation; either version 2 of the License, or *
12// * (at your option) any later version. *
13// ***************************************************************************/
14//ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL
15
16#include <qpe/applnk.h>
17#include <qpe/qpeapplication.h>
18#include <qpe/qpedialog.h>
19
20#include "LibraryDialog.h"
21#include "output.h"
22
23#include <qpushbutton.h>
24#include <qmultilineedit.h>
25//#include <qlayout.h>
26
27#include <unistd.h>
28#include <stdio.h>
29#include <stdlib.h>
30
31/*
32 * The dialog will by default be modeless, unless you set 'modal' to
33 * TRUE to construct a modal dialog. */
34LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool modal, WFlags fl )
35 : QDialog( parent, name, true/* modal*/, fl )
36{
37 if ( !name )
38 setName( "LibraryDialog" );
39 indexLoaded=false;
40 initDialog();
41
42 // this->setMaximumWidth(240);
43
44 index = "GUTINDEX.ALL";
45 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
46 local_index = local_library + index;
47
48 QString iniFile ;
49 iniFile = QPEApplication::qpeDir()+"/etc/gutenbrowser/gutenbrowserrc";
50
51 new_index =QPEApplication::qpeDir()+"/etc/gutenbrowser/PGWHOLE.TXT";
52
53 old_index = QPEApplication::qpeDir()+"/etc/gutenbrowser/GUTINDEX.ALL";
54 // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
55
56 // iniFile = local_library+"gutenbrowserrc";
57 // new_index = local_library + "PGWHOLE.TXT";
58 // old_index = local_library + "GUTINDEX.ALL";
59
60 Config config("Gutenbrowser");
61
62 config.setGroup( "HttpServer" );
63 proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org");
64
65 config.setGroup( "FTPsite" );
66 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
67 qDebug("Library Dialog: ftp_host is "+ftp_host);
68 // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) );
69 // ftp_host=ftp_host.stripWhiteSpace();
70 ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
71
72 i_binary = 0;
73
74 config.setGroup("SortAuth");
75 if( config.readEntry("authSort", "FALSE") == "TRUE")
76 authBox->setChecked(TRUE);
77
78 config.setGroup("General");
79 downDir =config.readEntry( "DownloadDirectory",local_library);
80 qDebug("downDir is "+downDir);
81 newindexLib.setName( old_index);
82 indexLib.setName( old_index);
83
84 new QPEDialogListener(this);
85}
86
87LibraryDialog::~LibraryDialog()
88{
89 delete QList_Item2;
90 delete QList_Item1;
91 delete QList_Item3;
92 delete QList_Item4;
93 delete QList_Item5;
94
95 saveConfig();
96}
97
98 /*This groks using PGWHOLE.TXT */
99void LibraryDialog::Newlibrary()
100{
101#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files
102 //qDebug("Opening new library index %s",newindexLib);
103 if ( newindexLib.open( IO_ReadOnly) ) {
104 setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully
105 QTextStream indexStream( &newindexLib );
106 QString indexLine;
107 while ( !indexStream.atEnd() ) { // until end of file..
108 indexLine = indexStream.readLine();
109 if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) {
110 year = indexLine.mid(4,4);
111 year = year.stripWhiteSpace();
112 file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 );
113 file = file.stripWhiteSpace();
114 number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 );
115 if( year.toInt() < 1984)
116 number = number.left( number.length() -1 );
117 number = number.stripWhiteSpace();
118 title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() );
119 title = title.stripWhiteSpace();
120
121 getAuthor(); // groks author
122 author = author.stripWhiteSpace();
123 if (authBox->isChecked()) { // this reverses the first name and last name of the author
124 // qDebug("Sorting last name first");
125 QString lastName, firstName="";
126 int finder=author.findRev( ' ', -1, TRUE);
127 lastName=author.right( author.length()-finder);
128 firstName=author.left(finder);
129 lastName=lastName.stripWhiteSpace();
130 firstName=firstName.stripWhiteSpace();
131
132 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names
133 author=lastName+", "+firstName;
134 }
135
136 if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) {
137
138 // fill string list or something to be able to resort the whole library
139 if( author.isEmpty() )
140 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file );
141 else {
142
143 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) ||
144 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) )
145 QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file );
146
147 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) ||
148 (author.left(1) >= QString("g") && author.left(1) <= QString("m")) )
149 QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file );
150
151 else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) ||
152 (author.left(1) >= QString("n") && author.left(1) <= QString("r")) )
153 QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file );
154
155 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) ||
156 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) )
157 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file );
158
159 else
160 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file );
161 }
162 }
163 }// end if
164 }// end while
165 newindexLib.close();
166 }
167#ifndef Q_WS_QWS
168 setCursor( arrowCursor);
169#endif
170#endif
171} // end Newlibrary()
172
173
174void LibraryDialog::Library()
175{// old library groking method
176
177 ListView1->clear();
178 ListView2->clear();
179 ListView3->clear();
180 ListView4->clear();
181 ListView5->clear();
182
183 qDebug("opening GUTINDEX.ALL file");
184 IDontKnowWhy = "";
185 if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully
186 QTextStream indexStream( &indexLib );
187 QString indexLine;
188 qApp->processEvents();
189 // int jig;
190 while ( !indexStream.eof() ) {
191
192 indexLine = indexStream.readLine();
193 if ( indexLine != "") {
194 if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) {
195 // month = indexLine.left( 3);
196 year = indexLine.mid(4,4);
197 // title = indexLine.mid( 9, 50);
198 file = indexLine.mid(60,12);
199 if(file.left(1).find("[",0,TRUE) != -1)
200 file.remove(1,1);
201 if( file.find("]",0,TRUE) != -1)
202 file = file.left( file.find("]",0,TRUE));
203 //qDebug("file is "+file);
204 /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 );
205 number = indexLine.mid(55,5);
206 number = number.stripWhiteSpace();
207 // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() );
208 title = indexLine.mid( 9, 50 );
209 title = title.stripWhiteSpace();
210 //qDebug("title is "+title);
211 getAuthor(); // grok author
212 author = author.stripWhiteSpace();
213 //qDebug("author is "+author);
214 if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author
215 QString lastName, firstName="";
216 int finder=author.findRev( ' ', -1, TRUE);
217 lastName=author.right( author.length()-finder);
218 firstName=author.left(finder);
219 lastName=lastName.stripWhiteSpace();
220 firstName=firstName.stripWhiteSpace();
221
222 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names
223 author=lastName+", "+firstName;
224 }
225
226 if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) /*&& (file.find( "]",0, TRUE))*/ ) {
227 // fill string list or something to be able to sort by Author
228 if( author.isEmpty() )
229 QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file );
230 else {
231 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) ||
232 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) )
233 QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file );
234
235 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) ||
236 (author.left(1) >= QString("g") && author.left(1) <= QString("m")) )
237 QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file );
238
239 else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) ||
240 (author.left(1) >= QString("n") && author.left(1) <= QString("r")) )
241 QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file );
242
243 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) ||
244 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) )
245 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file );
246 }
247 }
248 }
249 }
250 }
251 indexLib.close();
252 } else {
253 QString sMsg;
254 sMsg = ( tr("Error opening local library index:\n "))+local_index;
255 QMessageBox::message( "Error",sMsg);
256 }
257
258} //end Library()
259
260
261 /*
262 Groks the author out of the title */
263bool LibraryDialog::getAuthor()
264{
265 if( title.contains( ", by", TRUE)) {
266 int auth;
267 auth = title.find(", by", 0, TRUE);
268 author = title.right(title.length() - (auth + 4) );
269 if( int finder = author.find("[", 0, TRUE)) {
270 author = author.left(finder);
271 }
272 }
273 else if ( title.contains( "by, ", TRUE) ) {
274 int auth;
275 auth = title.find("by, ", 0, TRUE);
276 author = title.right(title.length() - (auth + 4) );
277 if( int finder = author.find("[", 0, TRUE)) {
278 author = author.left( finder);
279 }
280 }
281 else if ( title.contains( " by", TRUE) ) {
282 int auth;
283 auth = title.find(" by", 0, TRUE);
284 author = title.right(title.length() - (auth + 3) );
285 if( int finder = author.find("[", 0, TRUE)) {
286 author = author.left( finder);
287 }
288 }
289 else if ( title.contains( "by ", TRUE) ) {
290 int auth;
291 auth = title.find("by ", 0, TRUE);
292 author = title.right(title.length() - (auth + 3) );
293 if( int finder = author.find("[", 0, TRUE)) {
294 author = author.left( finder);
295 }
296 }
297 else if ( title.contains( ",", TRUE) ) {
298 int auth;
299 auth = title.find(",", 0, TRUE);
300 author = title.right( title.length() - (auth + 1) );
301 if ( author.contains( ",", TRUE) ) {
302 int auth;
303 auth = author.find(",", 0, TRUE);
304 author = author.right( author.length() - (auth + 1) );
305 }
306 if( int finder = author.find("[", 0, TRUE)) {
307 author = author.left( finder);
308 }
309 }
310 else if ( title.contains( "/", TRUE) ) {
311 int auth;
312 auth = title.find("/", 0, TRUE);
313 author = title.right(title.length() - (auth + 1) );
314 if( int finder = author.find("[", 0, TRUE)) {
315 author = author.left( finder);
316 }
317 }
318 else if ( title.contains( "of", TRUE) ) {
319 int auth;
320 auth = title.find("of", 0, TRUE);
321 author = title.right(title.length() - (auth + 2) );
322 if( int finder = author.find("[", 0, TRUE))
323 {
324 author = author.left( finder);
325 }
326 } else {
327 author = "";
328 }
329 if ( author.contains("et. al")) {
330 int auth;
331 auth = author.find("et. al", 0, TRUE);
332 author = author.left( auth );
333 }
334 if ( author.contains("#")) {
335 int auth;
336 auth = author.find("#", 0, TRUE);
337 author = author.left( auth);
338 }
339 if ( author.contains("(")) {
340 int auth;
341 auth = author.find("(", 0, TRUE);
342 author = author.left( auth);
343 }
344 if ( author.contains("et al")) {
345 int auth;
346 auth = author.find("et al", 0, TRUE);
347 author = author.left( auth );
348 }
349 QRegExp r = QRegExp("[0-9]", TRUE, FALSE);
350 if ( author.left(2).find( r) != -1 ) {
351 author = "";
352 }
353 // if( author.contains(" ", TRUE)) {
354 // int suth = author.findRev(" ", -1, TRUE);
355 // author = author.right( author.length() - suth);
356 // }
357
358 // title
359 // author
360 return true;
361}////// end getAuthor()
362
363 /*
364 selected one etext*/
365void LibraryDialog::select_title( QListViewItem * item)
366{
367 if(item != NULL) {
368 i++;
369 int index = tabWidget->currentPageIndex();
370 DlglistItemTitle = item->text(0);
371 DlglistItemYear = item->text(2);
372 DlglistItemFile = item->text(3);
373 switch (index) {
374 case 0: {
375 ListView1->clearSelection();
376 }
377 break;
378 case 1: {
379 ListView2->clearSelection();
380 }
381 break;
382 case 2: {
383 ListView3->clearSelection();
384 }
385 break;
386 case 3: {
387 ListView4->clearSelection();
388 }
389 break;
390 case 4: {
391 ListView5->clearSelection();
392 }
393 break;
394 };
395 }
396
397 if(DlglistItemTitle.length()>2) {
398 // DlglistItemNumber = item->text(0);
399 item = 0;
400 qDebug( "string from librarydialog is:%s %s %s", DlglistItemYear.latin1(),DlglistItemFile.latin1(),DlglistItemNumber.latin1());
401 qDebug("Title is "+DlglistItemTitle);
402
403 // check for connection here
404 // if( get_extext())
405
406 if(download_Etext()) {
407 // qDebug("get here 2");
408 if(i_binary == 1) {
409
410 }
411 if(checkBox->isChecked () ) {
412 accept();
413 }
414 }
415 }
416}
417
418bool LibraryDialog::download_Etext()
419{ // ftp method
420 // might have to use old gpl'd ftp for embedded!!
421 Config cfg("Gutenbrowser");
422 cfg.setGroup("FTPsite");
423 ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org");
424 ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg");
425
426 qDebug("about to network dialog");
427 QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile;
428
429 //////////////////// FIXME- if 'x' is part of real name....
430 NewlistItemFile = DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).left(DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).find("x", 1, FALSE));
431
432 if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) {
433 NewlistItemFile.replace( 0,4, DlglistItemFile.left(4));
434 qDebug("NewlistItemFile is now "+NewlistItemFile);
435 }
436 NewlistItemYear = DlglistItemYear.right(2);
437 int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10);
438 qDebug(NewlistItemYear);
439 if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) {
440 NewlistItemYear = "90";
441 }
442 Edir ="etext" +NewlistItemYear;
443 dir= ftp_base_dir + "/etext" +NewlistItemYear+"/";
444 if( ftp_base_dir.find("=",0,true) )
445 ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1);
446
447 networkUrl= "ftp://"+ftp_host+dir;
448
449 outputFile=local_library+".guten_temp";
450 //qDebug("Download file:%s",NewlistItemFile.latin1() );
451 qDebug("Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile);
452 QStringList networkList;
453 networkList.append((const char *)ftp_host);
454 networkList.append((const char *)dir);
455 networkList.append((const char *)outputFile);
456 networkList.append((const char *)NewlistItemFile);
457//<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile;
458
459 NetworkDialog *NetworkDlg;
460 NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList);
461
462
463 if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer
464 File_Name= NetworkDlg->localFileName;
465 qDebug("back to Library from Network Dialog");
466 qDebug("Just downloaded "+NetworkDlg->localFileName);
467
468 // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found
469 // QString oldName=File_Name;
470 // File_Name.replace(0,local_library.length(),downDir);
471 // qDebug("File_Name now is "+File_Name);
472
473 // }
474 // rename .txt to .etx
475 if(NetworkDlg->successDownload) {
476 qDebug("Filename is "+File_Name);
477 if(File_Name.right(4)==".txt") {
478 QString s_fileName=File_Name;
479 s_fileName.replace( s_fileName.length()-3,3,"gtn");
480 // s_fileName.replace( s_fileName.length()-3,3,"etx");
481 rename(File_Name.latin1(),s_fileName.latin1());
482 File_Name=s_fileName;
483
484 qDebug("Filename is now "+File_Name);
485
486 }
487 if(File_Name.length() > 5 ) {
488 setTitle();
489 QFileInfo fi(File_Name);
490 QString name_file=fi.fileName();
491 name_file=name_file.left(name_file.length()-4);
492
493 qDebug("Setting doclink");
494 DocLnk lnk;
495 qDebug("name is "+name_file);
496 lnk.setName(name_file); //sets file name
497 qDebug("Title is "+DlglistItemTitle);
498 lnk.setComment(DlglistItemTitle);
499
500 qDebug("Filename is "+File_Name);
501 lnk.setFile(File_Name); //sets File property
502 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
503 lnk.setExec(File_Name);
504 lnk.setIcon("gutenbrowser/Gutenbrowser");
505 if(!lnk.writeLink()) {
506 qDebug("Writing doclink did not work");
507 } else {
508 }
509 } else
510 QMessageBox::message("Note","There was an error\nwith the file");
511 }
512 }
513 return true;
514}
515
516bool LibraryDialog::httpDownload()
517{// httpDownload
518#ifndef Q_WS_QWS
519 Config config("Gutenbrowser");
520 config.setGroup( "Browser" );
521 QString brow = config.readEntry("Preferred", "");
522 QString file_name = "./.guten_temp";
523 // config.setGroup( "HttpServer" );
524 // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org");
525 QString httpName = proxy_http + "/"+Edir;
526 // progressBar->setProgress( i);
527 i++;
528 if ( brow != "Konq") { /////////// use lynx
529 // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name;
530 // system(cmd);
531 } else { //////////// use KFM
532 // KFM::download( httpName, file_name);
533 }
534 i++;
535 QFile tmp( file_name);
536 QString str;
537 if (tmp.open(IO_ReadOnly)) {
538 QTextStream t( &tmp ); // use a text stream
539 while ( !t.eof()) {
540 QString s = t.readLine();
541 if (s.contains( NewlistItemFile, FALSE) && (s.contains(".txt")) ) {
542 str = s.mid( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6, (s.find( ".txt</A>", 0, TRUE) + 4) - ( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6 ) );
543 httpName += "/" + str;
544 }
545 } //end of while loop
546 }
547 tmp.close();
548 m_getFilePath = local_library + str;
549 i++;
550 if ( brow != "KFM"){ ///////// use lynx
551 QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath;
552 // QMessageBox::message("Error", cmd);
553 system(cmd);
554 } else { ////////// use KFM
555 // KFM::download( httpName, m_getFilePath);
556 }
557 i++;
558#endif
559 return false;
560}
561
562void LibraryDialog::cancelIt()
563{
564 saveConfig();
565
566 DlglistItemNumber = "";
567 this->reject();
568}
569
570bool LibraryDialog::setTitle()
571{
572 Config config("Gutenbrowser");
573 qDebug("setting title");
574 qDebug(DlglistItemTitle);
575
576 if( DlglistItemTitle.find("[",0,TRUE) != -1)
577 DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" );
578 if( DlglistItemTitle.find("]",0,TRUE) !=-1)
579 DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" );
580 qDebug("Title being set is "+DlglistItemTitle);
581 int test = 0;
582 QString ramble, temp;
583 config.setGroup("Files");
584 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
585 int i_numofFiles = s_numofFiles.toInt();
586 for ( int i = 0; i <= i_numofFiles; i++){
587 temp.setNum( i);
588 ramble = config.readEntry( temp, "" );
589 if( strcmp( ramble, File_Name) == 0){
590 test = 1;
591 }
592 }
593 config.setGroup("Files");
594 config.writeEntry( "NumberOfFiles", i_numofFiles +1 );
595 QString interger;
596 interger.setNum( i_numofFiles +1);
597 config.writeEntry( interger, File_Name);
598 config.setGroup( "Titles" );
599 config.writeEntry( File_Name, DlglistItemTitle);
600
601 test = 0;
602 return true;
603}
604
605
606void LibraryDialog::saveConfig()
607{
608 Config config("Gutenbrowser");
609 if( httpBox->isChecked() == TRUE) {
610 checked = 1;
611 config.setGroup( "Proxy" );
612 config.writeEntry("IsChecked", "TRUE");
613 } else {
614 checked = 0;
615 config.setGroup( "Proxy" );
616 config.writeEntry("IsChecked", "FALSE");
617 }
618 if (authBox->isChecked() == TRUE) {
619 config.setGroup("SortAuth");
620 config.writeEntry("authSort", "TRUE");
621 } else {
622 config.setGroup("SortAuth");
623 config.writeEntry("authSort", "FALSE");
624 }
625 // config.write();
626}
627
628 /*
629 searches library index for user word*/
630void LibraryDialog::onButtonSearch()
631{
632 ListView1->clearSelection();
633 ListView2->clearSelection();
634 ListView3->clearSelection();
635 ListView4->clearSelection();
636 ListView5->clearSelection();
637
638 int curTab=tabWidget->currentPageIndex();
639 SearchDialog* searchDlg;
640
641 // if( resultsList)
642 searchDlg = new SearchDialog( this, "Library Search", TRUE);
643 searchDlg->setCaption( tr( "Library Search" ) );
644 searchDlg->setLabel( "- author or title");
645 QString resultString;
646 int i_berger = 0;
647 if( searchDlg->exec() != 0 ) {
648 QString searcherStr = searchDlg->get_text();
649 int fluff=0;
650
651 // int tabPage = tabWidget->currentPageIndex();
652 // TODO ititerate here... struct<listViews>??
653
654 QListViewItemIterator it1( ListView1 );
655 QListViewItemIterator it2( ListView2 );
656 QListViewItemIterator it3( ListView3 );
657 QListViewItemIterator it4( ListView4 );
658 QListViewItemIterator it5( ListView5 );
659
660 //// this is really pitiful work,
661 ///////
662 bool cS;
663 if( searchDlg->caseSensitiveCheckBox->isChecked())
664 cS=true; //case sensitive
665 else
666 cS=false;
667
668 if(fluff==0) {
669 for ( ; it1.current(); ++it1 ) {
670 resultString = ( it1.current() )->text(0);
671 resultString += (" : ");
672 resultString += ( it1.current() )->text(2);
673 resultString += (" : ");
674 resultString += ( it1.current() )->text(3);
675 if( resultString.find( searcherStr, 0, cS) != -1)
676 {
677 Searchlist.append( resultString);
678 }
679 }
680 }
681 if(fluff==0) {// search routine here
682 for ( ; it2.current(); ++it2 ) {
683 resultString = ( it2.current() )->text(0);
684 resultString += (" : ");
685 resultString += ( it2.current() )->text(2);
686 resultString += (" : ");
687 resultString += ( it2.current() )->text(3);
688 if( resultString.find( searcherStr, 0, cS) != -1) {
689 Searchlist.append( resultString);
690 }
691 }
692 }
693 if(fluff==0) {// search routine here
694 for ( ; it3.current(); ++it3 ) {
695 resultString = ( it3.current() )->text(0);
696 resultString += (" : ");
697 resultString += ( it3.current() )->text(2);
698 resultString += (" : ");
699 resultString += ( it3.current() )->text(3);
700
701 if( resultString.find( searcherStr, 0, cS) != -1) {
702 Searchlist.append( resultString);
703 }
704 }
705 }
706 if(fluff==0) {
707 // search routine here
708 for ( ; it4.current(); ++it4 ) {
709 resultString = ( it4.current() )->text(0);
710 resultString += (" : ");
711 resultString += ( it4.current() )->text(2);
712 resultString += (" : ");
713 resultString += ( it4.current() )->text(3);
714 if( resultString.find( searcherStr, 0, cS) != -1) {
715 Searchlist.append( resultString);
716 }
717 }
718 }
719 if(fluff==0) { // search routine here
720 for ( ; it5.current(); ++it5 ) {
721 resultString = ( it5.current() )->text(0);
722 resultString += (" : ");
723 resultString += ( it5.current() )->text(2);
724 resultString += (" : ");
725 resultString += ( it5.current() )->text(3);
726 if( resultString.find( searcherStr, 0, cS) != -1) {
727 Searchlist.append( resultString);
728 }
729 }
730 }
731
732 tabWidget->setCurrentPage( curTab);
733
734 Searchlist.sort();
735 SearchResultsDlg* SearchResultsDialog;
736 SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist);
737
738 SearchResultsDialog->showMaximized();
739 if( SearchResultsDialog->exec() != 0) {
740 texter = SearchResultsDialog->selText;
741 // qDebug(texter);
742 resultLs= SearchResultsDialog->resultsList;
743 i_berger = 1;
744 }
745 Searchlist.clear();
746
747 // if(SearchResultsDialog)
748 // delete SearchResultsDialog;
749 QString tester;
750 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) {
751 texter.sprintf("%s \n",(*it).latin1());
752 // qDebug(texter);
753 if( tester!=texter)
754 parseSearchResults( texter);
755 tester = texter;
756 }
757 if(searchDlg)
758 delete searchDlg;
759 }
760 if(checkBox->isChecked() ) {
761 accept();
762 } else {
763 setActiveWindow();
764 }
765}
766
767 /*
768 splits the result string and calls download for the current search result*/
769void LibraryDialog::parseSearchResults( QString resultStr)
770{
771
772 int stringLeng=resultStr.length();
773 QString my;
774 my.setNum( stringLeng, 10);
775
776 if( resultStr.length() > 2 && resultStr.length() < 130) {
777 int titleInt = resultStr.find( " : ", 0, TRUE);
778 DlglistItemTitle = resultStr.left( titleInt);
779 int yearInt = resultStr.find( " : ", titleInt+3, TRUE);
780 DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3);
781 DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3));
782 download_Etext();
783 }
784 /*
785 printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/
786}
787
788 // bool LibraryDialog::UnzipIt( QString zipFile) {
789 // //////////TODO findsome other way of dealingwithzip files.
790 // ///usr/bin/unzip";
791 // if( QFile::exists( zipFile)) {
792 // // QString thatFile = local_library +"PGWHOLE.TXT";
793 // QString cmd;
794 // #if defined(_WS_X11_)
795 // cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library;
796 // #endif
797 // #if defined(_WS_WIN_)
798 // QString temp= QDir::convertSeparators(local_library);
799 // zipFile=QDir::convertSeparators( zipFile);
800 // cmd = temp+"unzip.exe -o " +zipFile/*newestLibraryFile */+" -d " + temp;
801 // #endif
802 // #ifndef Q_WS_QWS
803 // // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library;
804 // cmd = "unzip " + zipFile;
805 // #endif
806
807 // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No);
808 // if (exit==QMessageBox::Yes) {
809 // qDebug("Issuing the command "+cmd);
810 // #if defined(_WS_WIN_)
811 // WinExec( cmd, SW_HIDE );
812 // #endif
813 // #if defined(_WS_X11_)
814 // system( cmd);
815 // #endif
816 // #ifndef Q_WS_QWS
817 // system( cmd);
818 // #endif
819 // // printf("unzip\n");
820 // // remove( zipFile /*newestLibraryFile*/);
821 // return true;
822 // }
823 // else if(exit==QMessageBox::No) {
824 // // printf("unzip\n");
825 // return false;
826 // }
827 // } else {
828 // // QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) );
829 // return false;
830 // }
831 // return true;
832 // }
833
834void LibraryDialog::sort()
835{
836
837}
838
839 /*
840 Downloads the current selected listitem*/
841bool LibraryDialog::getItem(QListViewItem *it)
842{
843 // qDebug("selected getItem");
844
845 // DlglistItemNumber = it->text(0);
846 DlglistItemTitle = it->text(0);
847 DlglistItemYear = it->text(2);
848 DlglistItemFile = it->text(3);
849
850 if(download_Etext()) {
851 if(i_binary == 1) {
852 }
853 }
854 return true;
855}
856
857 /*
858 download button is pushed so we get the current items to download*/
859bool LibraryDialog::onButtonDownload()
860{
861 // qDebug("selected onButtonDownloadz");
862
863 QListViewItemIterator it1( ListView1 );
864 QListViewItemIterator it2( ListView2 );
865 QListViewItemIterator it3( ListView3 );
866 QListViewItemIterator it4( ListView4 );
867 QListViewItemIterator it5( ListView5 );
868
869 // iterate through all items of the listview
870 for ( ; it1.current(); ++it1 ) {
871 if ( it1.current()->isSelected() )
872 getItem(it1.current());
873 it1.current()->setSelected(FALSE);
874 }
875 for ( ; it2.current(); ++it2 ) {
876 if ( it2.current()->isSelected() )
877 getItem(it2.current());
878 it2.current()->setSelected(FALSE);
879 }
880 for ( ; it3.current(); ++it3 ) {
881 if ( it3.current()->isSelected() )
882 getItem(it3.current());
883 it3.current()->setSelected(FALSE);
884 }
885 for ( ; it4.current(); ++it4 ) {
886 if ( it4.current()->isSelected() )
887 getItem(it4.current());
888 it4.current()->setSelected(FALSE);
889 }
890 for ( ; it5.current(); ++it5 ) {
891 if ( it5.current()->isSelected() )
892 getItem(it5.current());
893 it5.current()->setSelected(FALSE);
894 }
895 return true;
896}
897
898
899 /*
900 handles the sorting combo box */
901void LibraryDialog::comboSelect(int index)
902{
903 // qDebug("we are sorting");
904 ListView1->setSorting( index, TRUE);
905 ListView2->setSorting( index, TRUE);
906 ListView3->setSorting( index, TRUE);
907 ListView4->setSorting( index, TRUE);
908 ListView5->setSorting( index, TRUE);
909
910 ListView1->sort();
911 ListView2->sort();
912 ListView3->sort();
913 ListView4->sort();
914 ListView5->sort();
915
916 // ListView1->triggerUpdate();
917 // ListView2->triggerUpdate();
918 // ListView3->triggerUpdate();
919 // ListView4->triggerUpdate();
920 // ListView5->triggerUpdate();
921}
922
923void LibraryDialog::newList()
924{
925 if(indexLoaded) {
926 onButtonDownload();
927 } else {
928 Output *outDlg;
929 buttonNewList->setDown(TRUE);
930 QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser");
931 if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true);
932 if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) {
933 qDebug("changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser");
934 QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
935 QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1";
936
937 int result = QMessageBox::warning( this,"Download"
938 ,"Ok to use /'wget/' to download\na new library list?\n"
939 ,"Yes","No",0,0,1);
940 qApp->processEvents();
941 if(result == 0) {
942 outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE);
943 outDlg->showMaximized();
944 outDlg->show();
945 qApp->processEvents();
946 FILE *fp;
947 char line[130];
948 outDlg->OutputEdit->append( tr("Running wget") );
949 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
950 sleep(1);
951 fp = popen( (const char *) cmd, "r");
952 if ( !fp ) {
953 } else {
954 qDebug("Issuing the command\n"+cmd);
955 // system(cmd);
956 while ( fgets( line, sizeof line, fp)) {
957 outDlg->OutputEdit->append(line);
958 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
959 }
960 pclose(fp);
961 outDlg->OutputEdit->append("Finished downloading\n");
962 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
963 qApp->processEvents();
964
965 // if( QFile(gutenindex1).exists() ) {
966 // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
967 // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0)
968 // qDebug("renaming error");
969 // }
970
971 }
972 // outDlg->close();
973 FindLibrary();
974 if(outDlg) delete outDlg;
975 }
976 buttonNewList->setDown(FALSE);
977 } else {
978 QMessageBox::message("Note","Could not change directories");
979 }
980 // if(outDlg)
981 // delete outDlg;
982 }
983}
984
985bool LibraryDialog::moreInfo()
986{
987
988 QListViewItem * item;
989 item = 0;
990 QString titleString;
991 item = ListView1->currentItem();
992 if( item != 0) {
993 titleString = item->text(0);
994 ListView1->clearSelection();
995 item = 0;
996 }
997 if( item == 0)
998 item = ListView2->currentItem();
999 if( item != 0) {
1000 titleString = item->text(0);
1001 ListView2->clearSelection();
1002 item = 0;
1003 }
1004 if( item == 0)
1005 item = ListView3->currentItem();
1006 if( item != 0) {
1007 titleString = item->text(0);
1008 ListView3->clearSelection();
1009 item = 0;
1010 }
1011 if( item == 0)
1012 item = ListView4->currentItem();
1013 if( item != 0) {
1014 titleString = item->text(0);
1015 ListView4->clearSelection();
1016 item = 0;
1017 }
1018 if( item == 0)
1019 item = ListView5->currentItem();
1020 if( item != 0) {
1021 titleString = item->text(0);
1022 ListView5->clearSelection();
1023 item = 0;
1024 }
1025 item=0;
1026 if(titleString.length()>2) {
1027 qDebug( "Title is "+titleString );
1028 titleString.replace( QRegExp("\\s"), "%20");
1029 titleString.replace( QRegExp("'"), "%20");
1030 titleString.replace( QRegExp("\""), "%20");
1031 titleString.replace( QRegExp("&"), "%20");
1032 QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search";
1033 cmd="opera "+cmd;
1034 system(cmd);
1035 } else
1036 QMessageBox::message( "Note","If you select a title, this will\nsearch google.com for that title.");
1037 return true;
1038
1039}
1040
1041 /*
1042 This loads the library Index*/
1043void LibraryDialog::FindLibrary()
1044{
1045 buttonLibrary->setDown(TRUE);
1046
1047 qApp->processEvents();
1048 if( QFile( new_index).exists() /* && this->isHidden() */) {
1049 newindexLib.setName( new_index);
1050 indexLib.setName( new_index);
1051 qDebug("index file is "+ new_index);
1052 Newlibrary();
1053 } else {
1054 newindexLib.setName( old_index);
1055 indexLib.setName( old_index);
1056 qDebug("new index nameis "+ old_index);
1057 Library();
1058 }
1059 indexLoaded=true;
1060 buttonSearch->setEnabled(TRUE);
1061 moreInfoButton->setEnabled(TRUE);
1062
1063 buttonLibrary->setDown(FALSE);
1064 buttonNewList->setText("Download");
1065 qApp->processEvents();
1066
1067}
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.h b/noncore/apps/opie-gutenbrowser/LibraryDialog.h
new file mode 100644
index 0000000..f5bfe08
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.h
@@ -0,0 +1,126 @@
1/***************************************************************************
2 LibraryDialog.h - description
3 -------------------
4 begin : Sat Aug 19 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 ***************************************************************************/
12#ifndef LIBRARYDIALOG_H
13#define LIBRARYDIALOG_H
14
15#include <qpe/config.h>
16
17#include "SearchDialog.h"
18#include "NetworkDialog.h"
19#include <qstringlist.h>
20#include <qdialog.h>
21#include <qcheckbox.h>
22#include <qdatetime.h>
23#include <qfile.h>
24#include <qheader.h>
25#include <qlistview.h>
26#include <qmessagebox.h>
27#include <qregexp.h>
28#include <qstring.h>
29#include <qtextstream.h>
30#include <qlabel.h>
31#include <stdlib.h>
32#include <qtabwidget.h>
33
34class QVBoxLayout;
35class QHBoxLayout;
36class QGridLayout;
37class QListView;
38class QListViewItem;
39class QPushButton;
40//class QTabWidget;
41class QWidget;
42//class Gutenbrowser;
43
44class LibraryDialog : public QDialog {
45 Q_OBJECT
46
47public:
48 LibraryDialog( QWidget* parent = 0, const char* name = 0 , bool modal = TRUE, WFlags fl = 0 );
49 ~LibraryDialog();
50
51 QTabWidget *tabWidget;
52 QListView *ListView1,*ListView2,*ListView3,*ListView4,*ListView5;
53 QWidget *widget_1,*widget_2,*widget_3,*widget_4,*widget_5,*widget_6;
54 QString ftp_host,ftp_base_dir;
55 QLabel *statusLabel;
56 QListViewItem *QList_Item1,*QList_Item2,*QList_Item3,*QList_Item4,*QList_Item5;
57 QStringList list,ItemStrlist,Searchlist,resultLs;
58// QStringList list1,list2,list3,list4;
59
60 QPushButton *buttonSearch,*buttonCancel,*buttonDownload,*buttonLibrary,*buttonNewList,*moreInfoButton;
61 QString new_index,old_index;
62 QFile newindexLib,indexLib;
63
64 int checked;
65 int i_binary;
66 bool useSmallInterface;
67bool indexLoaded;
68 QPushButton *cancel,*DownloadAll;
69 QCheckBox *checkBox,*httpBox,*authBox;
70// QCheckBox * httpBox;
71
72 QString filename;
73 QString downDir;
74 int ftpNumb;
75 int i;
76 QString year,title,number,file,author;
77 QString DlglistItemNumber,DlglistItemFile,DlglistItemYear,DlglistItemTitle,NewlistItemFile;
78 QString m_getFilePath;
79 QString Edir;
80
81 QString index;
82 QString IDontKnowWhy;
83 QString local_library;
84 QString local_index;
85 QString File_Name;
86 QString proxy_http;
87 int doitAll;
88 QString texter;
89// CConfigFile *config;
90 void parseSearchResults( QString resultStr);
91
92public slots:
93 bool getItem(QListViewItem* );
94 void doListView();
95 void FindLibrary();
96 void newList();
97 void Newlibrary();
98 void Library();
99 bool getAuthor();
100 void select_title(QListViewItem*);
101 void cancelIt();
102 void sort();
103 bool moreInfo();
104// void DownloadEmAll();
105 bool httpDownload();
106 bool setTitle();
107 void saveConfig();
108 bool download_Etext();
109 void onButtonSearch();
110 bool onButtonDownload();
111
112// bool UnzipIt( QString fileName);
113 void comboSelect(int index);
114protected slots:
115
116
117protected:
118
119 void initDialog();
120 QHBoxLayout *hbox,*hbox1,*hbox2;
121 QVBoxLayout *vbox;
122// void search_slot();
123
124};
125
126#endif // LIBRARYDIALOG_H
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.o b/noncore/apps/opie-gutenbrowser/LibraryDialog.o
new file mode 100644
index 0000000..d8dcaa8
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.o
Binary files differ
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialogData.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialogData.cpp
new file mode 100644
index 0000000..72d605e
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialogData.cpp
@@ -0,0 +1,281 @@
1/***************************************************************************
2LibraryDialogData.cpp - description
3 begin : Sat Dec 4 1999
4 begin : Tue Jul 25 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7***************************************************************************/
8/***************************************************************************
9 * *
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 *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 ***************************************************************************/
15#include "LibraryDialog.h"
16#include <qpe/config.h>
17
18#include <qpushbutton.h>
19#include <qtabwidget.h>
20#include <qwidget.h>
21#include <qlayout.h>
22
23#include <qimage.h>
24#include <qpixmap.h>
25#include <qlistview.h>
26#include <qpushbutton.h>
27#include <qtooltip.h>
28#include <qdialog.h>
29#include <qcheckbox.h>
30#include <qdatetime.h>
31#include <qfile.h>
32#include <qheader.h>
33#include <qlistview.h>
34#include <qmessagebox.h>
35#include <qregexp.h>
36#include <qstring.h>
37#include <qtextstream.h>
38#include <qprogressbar.h>
39#include <qcheckbox.h>
40#include <qlabel.h>
41#include <qcombobox.h>
42
43
44void LibraryDialog::initDialog(){
45
46
47 QGridLayout *layout = new QGridLayout( this );
48 layout->setSpacing(2);
49 layout->setMargin(4);
50
51 tabWidget = new QTabWidget( this, "tabWidget" );
52 layout->addMultiCellWidget( tabWidget, 0, 0, 0, 3);
53
54 widget_1 = new QWidget( tabWidget, "widget" );
55 ListView1 = new QListView( widget_1, "ListView1" );
56 QGridLayout *layout1 = new QGridLayout(widget_1 );
57
58 widget_2 = new QWidget( tabWidget, "widget_2" );
59 ListView2 = new QListView( widget_2, "ListView2" );
60 QGridLayout *layout2 = new QGridLayout(widget_2 );
61
62 widget_3 = new QWidget( tabWidget, "widget_3" );
63 ListView3 = new QListView( widget_3, "ListView3" );
64 QGridLayout *layout3 = new QGridLayout(widget_3 );
65
66 widget_4 = new QWidget( tabWidget, "widget_4" );
67 ListView4 = new QListView( widget_4, "ListView4" );
68 QGridLayout *layout4 = new QGridLayout(widget_4 );
69
70 widget_5 = new QWidget( tabWidget, "widget_5" );
71 ListView5 = new QListView( widget_5, "ListView5" );
72 QGridLayout *layout5 = new QGridLayout(widget_5 );
73
74
75 ListView1->addColumn( tr( "Title" ) );
76 ListView1->setColumnWidthMode( 0, QListView::Manual );
77 ListView1->setColumnWidth(0, 330);
78 ListView1->setColumnAlignment( 0, 1 );
79
80 ListView1->addColumn( tr( "Author" ) );
81 ListView1->setColumnWidthMode( 1, QListView::Manual );
82 ListView1->setColumnWidth(1, 170);
83 ListView1->setColumnAlignment( 1, 1 );
84
85 ListView1->addColumn( tr( "Year" ) );
86 ListView1->setColumnWidthMode( 2, QListView::Manual );
87 ListView1->setColumnWidth(2, 50);
88 ListView1->setColumnAlignment( 2, 1 );
89
90 ListView1->addColumn( tr( "File" ) );
91 ListView1->setColumnWidthMode( 2, QListView::Manual );
92 ListView1->setColumnWidth(2, 100);
93 ListView1->setColumnAlignment( 2, 1 );
94
95 ListView2->addColumn( tr( "Title" ) );
96 ListView2->setColumnWidthMode( 0, QListView::Manual );
97 ListView2->setColumnWidth(0, 330);
98 ListView2->setColumnAlignment( 0, 1 );
99
100 ListView2->addColumn( tr( "Author" ) );
101 ListView2->setColumnWidthMode( 1, QListView::Manual );
102 ListView2->setColumnWidth(1, 170);
103 ListView2->setColumnAlignment( 1, 1 );
104
105 ListView2->addColumn( tr( "Year" ) );
106 ListView2->setColumnWidthMode( 2, QListView::Manual );
107 ListView2->setColumnWidth(2, 50);
108 ListView2->setColumnAlignment( 2, 1 );
109
110 ListView2->addColumn( tr( "File" ) );
111 ListView2->setColumnWidthMode( 3, QListView::Manual );
112 ListView2->setColumnWidth(3, 100);
113 ListView2->setColumnAlignment( 3, 1 );
114
115 ListView3->addColumn( tr( "Title" ) );
116 ListView3->setColumnWidthMode( 0, QListView::Manual );
117 ListView3->setColumnWidth(0, 330);
118 ListView3->setColumnAlignment( 0, 1 );
119
120 ListView3->addColumn( tr( "Author" ) );
121 ListView3->setColumnWidthMode( 1, QListView::Manual );
122 ListView3->setColumnWidth(1, 170);
123 ListView3->setColumnAlignment( 1, 1 );
124
125 ListView3->addColumn( tr( "Year" ) );
126 ListView3->setColumnWidthMode( 2, QListView::Manual );
127 ListView3->setColumnWidth(2, 50);
128 ListView3->setColumnAlignment( 2, 1 );
129
130 ListView3->addColumn( tr( "File" ) );
131 ListView3->setColumnWidthMode( 3, QListView::Manual );
132 ListView3->setColumnWidth(3, 100);
133 ListView3->setColumnAlignment( 3, 1 );
134
135
136 ListView4->addColumn( tr( "Title" ) );
137 ListView4->setColumnWidthMode( 0, QListView::Manual );
138 ListView4->setColumnWidth(0, 330);
139 ListView4->setColumnAlignment( 0, 1 );
140
141 ListView4->addColumn( tr( "Author" ) );
142 ListView4->setColumnWidthMode( 1, QListView::Manual );
143 ListView4->setColumnWidth(1, 170);
144 ListView4->setColumnAlignment( 1, 1 );
145
146 ListView4->addColumn( tr( "Year" ) );
147 ListView4->setColumnWidthMode( 2, QListView::Manual );
148 ListView4->setColumnWidth(2, 50);
149 ListView4->setColumnAlignment( 2, 1 );
150
151 ListView4->addColumn( tr( "File" ) );
152 ListView4->setColumnWidthMode( 3, QListView::Manual );
153 ListView4->setColumnWidth(3, 100);
154 ListView4->setColumnAlignment( 3, 1 );
155
156 ListView5->addColumn( tr( "Title" ) );
157 ListView5->setColumnWidthMode( 0, QListView::Manual );
158 ListView5->setColumnWidth(0, 330);
159 ListView5->setColumnAlignment( 0, 1 );
160
161 ListView5->addColumn( tr( "Author" ) );
162 ListView5->setColumnWidthMode( 1, QListView::Manual );
163 ListView5->setColumnWidth(1, 170);
164 ListView5->setColumnAlignment( 1, 1 );
165
166 ListView5->addColumn( tr( "Year" ) );
167 ListView5->setColumnWidthMode( 2, QListView::Manual );
168 ListView5->setColumnWidth(2, 50);
169 ListView5->setColumnAlignment( 2, 1 );
170
171 ListView5->addColumn( tr( "File" ) );
172 ListView5->setColumnWidthMode( 3, QListView::Manual );
173 ListView5->setColumnWidth(3, 100);
174 ListView5->setColumnAlignment( 3, 1 );
175
176 tabWidget->insertTab( widget_1, tr( "A-F" ) );
177 tabWidget->insertTab( widget_2, tr( "G-M" ) );
178 tabWidget->insertTab( widget_3, tr( "N-R" ) );
179 tabWidget->insertTab( widget_4, tr( "S-Z" ) );
180 tabWidget->insertTab( widget_5, tr( " " ) );
181
182 ListView1->setMultiSelection(TRUE);
183 ListView2->setMultiSelection(TRUE);
184 ListView3->setMultiSelection(TRUE);
185 ListView4->setMultiSelection(TRUE);
186 ListView5->setMultiSelection(TRUE);
187
188 widget_6 = new QWidget( tabWidget, "widget_6" );
189 tabWidget->insertTab(widget_6,tr("Options"));
190
191 ListView1->setSorting( 2, TRUE);
192 ListView2->setSorting( 2, TRUE);
193 ListView3->setSorting( 2, TRUE);
194 ListView4->setSorting( 2, TRUE);
195 ListView5->setSorting( 2, TRUE);
196 ListView1->setAllColumnsShowFocus( TRUE );
197 ListView2->setAllColumnsShowFocus( TRUE );
198 ListView3->setAllColumnsShowFocus( TRUE );
199 ListView4->setAllColumnsShowFocus( TRUE );
200 ListView5->setAllColumnsShowFocus( TRUE );
201
202 QGridLayout *layout6 = new QGridLayout(widget_6 );
203 QComboBox * sortingCombo;
204 buttonCancel = new QPushButton( widget_6, "buttonCancel" );
205 checkBox = new QCheckBox( ( tr("Open Automatically")), widget_6);
206 checkBox->setChecked( FALSE);
207// httpBox = new QCheckBox( ( tr("Use http")),widget_6);
208// httpBox->setChecked( FALSE);
209// QToolTip::add( httpBox, ( tr("Use http to download \nproxy users should probably use this.")) );
210 authBox= new QCheckBox( ( tr("Last name first \n(requires library restart)")),widget_6);
211 authBox->setChecked( FALSE);
212
213 layout1->addMultiCellWidget( ListView1, 0, 0, 0, 4);
214 layout2->addMultiCellWidget( ListView2, 0, 0, 0, 4);
215 layout3->addMultiCellWidget( ListView3, 0, 0, 0, 4);
216 layout4->addMultiCellWidget( ListView4, 0, 0, 0, 4);
217 layout5->addMultiCellWidget( ListView5, 0, 0, 0, 4);
218
219 buttonSearch = new QPushButton(this,"buttonSearch");
220 buttonLibrary=new QPushButton(this,"buttenLibrary");
221 buttonNewList=new QPushButton(this,"NewList");
222 moreInfoButton= new QPushButton(this,"moreInfo");
223 sortingCombo=new QComboBox(widget_6,"sort by combo");
224
225
226 layout6->addMultiCellWidget(buttonCancel, 0, 0, 4, 4);
227 layout6->addMultiCellWidget(checkBox, 1, 1, 0, 0);
228 layout6->addMultiCellWidget(sortingCombo, 2, 2, 0, 0);
229 layout6->addMultiCellWidget(authBox, 3, 3, 0, 0);
230
231 layout->addMultiCellWidget( buttonSearch, 1, 1, 0, 0);
232 layout->addMultiCellWidget( buttonLibrary, 1, 1, 1, 1);
233 layout->addMultiCellWidget( moreInfoButton, 1, 1, 2, 2);
234 layout->addMultiCellWidget( buttonNewList, 1, 1, 3, 3);
235
236 moreInfoButton->setText("Info");
237 moreInfoButton->setDisabled(TRUE);
238 buttonSearch->setDisabled(TRUE);
239
240 buttonSearch->setText(tr("Search"));
241
242 buttonCancel->setText(tr("Close"));
243 buttonLibrary->setText("Load");
244 buttonLibrary->setDefault(TRUE);
245 buttonNewList->setText("New List");
246
247 QStrList sortingList;
248 sortingList.append( "Sort by Number");
249 sortingList.append("Sort by Title");
250 sortingList.append( "Sort by Author");
251 sortingList.append("Sort by Year");
252
253 sortingCombo->insertStrList(sortingList,0);
254 sortingCombo->setCurrentItem(2);
255 sortingCombo->setMaximumWidth(180);
256
257 // signals and slots connections
258 connect(buttonSearch,SIGNAL(clicked()),this,SLOT(onButtonSearch()));
259 connect(buttonLibrary,SIGNAL(clicked()),this,SLOT(FindLibrary()));
260 connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject()));
261 connect(moreInfoButton,SIGNAL(clicked()),this,SLOT(moreInfo()));
262 connect(buttonNewList,SIGNAL(clicked()),this,SLOT(newList()));
263
264 connect(ListView1,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*)));
265 connect(ListView1,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*)));
266 connect(ListView2,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*)));
267 connect(ListView2,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*)));
268 connect(ListView3,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*)));
269 connect(ListView3,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*)));
270 connect(ListView4,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*)));
271 connect(ListView4,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*)));
272 connect(ListView5,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*)));
273 connect(ListView5,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*)));
274
275 connect(sortingCombo,SIGNAL(activated(int)),SLOT(comboSelect(int)));
276
277}
278
279void LibraryDialog::doListView() {
280
281}
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialogData.o b/noncore/apps/opie-gutenbrowser/LibraryDialogData.o
new file mode 100644
index 0000000..b9323c0
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialogData.o
Binary files differ
diff --git a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
new file mode 100644
index 0000000..e8ade87
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
@@ -0,0 +1,329 @@
1// /***************************************************************************
2// NetworkDialog.cpp - description
3// begin : Sun Aug 27 2000
4// copyright : (C) 2000 - 2004 by L.J. Potter
5// email : ljp@llornkcor.com
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 *
8// * the Free Software Foundation; either version 2 of the License, or *
9// * (at your option) any later version. *
10// ***************************************************************************/
11// // half-assed attempt at providing a network dialog.
12// /* Created: Sun Aug 27 15:24:52 2000*/
13#include <unistd.h>
14extern "C" {
15#include "../../net/ftplib/ftplib.h"
16}
17
18
19#include "NetworkDialog.h"
20#include "gutenbrowser.h"
21
22#include <qprogressbar.h>
23#include <qstringlist.h>
24#include <qpe/config.h>
25#include <qvaluelist.h>
26#include <qapplication.h>
27#include <qfile.h>
28#include <qstringlist.h>
29#include <qlabel.h>
30#include <qpushbutton.h>
31#include <qlayout.h>
32
33QProgressBar* ProgressBar1;
34QPushButton* buttonCancel;
35static netbuf *conn = NULL;
36
37static int log_progress(netbuf *ctl, int xfered, void *arg) {
38 int fsz = *(int *)arg;
39 int pct = (xfered * 100) / fsz;
40 printf("%3d%%\r", pct);
41 fflush(stdout);
42 ProgressBar1->setProgress(xfered);
43 qApp->processEvents();
44
45 return 1;
46}
47
48NetworkDialog::NetworkDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QStringList netL)
49 : QDialog( parent, name, modal, fl )
50{
51
52 ftp_host = netL[0];
53 networkUrl = strUrl = netL[0];
54
55 dir = ftp_base_dir = netL[1];
56 localFileName = netL[2];
57 s_partialFileName = netL[3];
58
59 resize(240,110);
60
61 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
62 // autoOk = autoDownload;
63// if( networkUrl.find("ftp",0,false)== -1 ) {
64// if ( !name )
65// setName( "HTTP NetworkDialog" );
66// setCaption( tr( "HTTP Download ) );
67// qInitNetworkProtocols(); // registers ftp protocol // for now
68// QNetworkProtocol::registerNetworkProtocol( "http", new QNetworkProtocolFactory<Http> );
69// } else {
70 if ( !name )
71 setName( "FTP NetworkDialog" );
72 setCaption(tr("FTP Download"));
73// }
74 initDialog(); //opens file to be written
75}
76
77NetworkDialog::~NetworkDialog() {
78}
79
80void NetworkDialog::initDialog() {
81
82 totalBytesDownloaded=0;
83 warnLabel = new QLabel( this, "TextLabel" );
84 warnLabel ->setText( tr( "Push Ok to download file...." ) );
85 TextLabel3 = new QLabel( this, "TextLabel3" );
86 TextLabel3->setText( "");
87 QWidget* Layout1 = new QWidget( this, "Layout1" );
88
89 hbox = new QHBoxLayout(Layout1);
90 hbox->setMargin(4);
91
92 ProgressBar1 = new QProgressBar( Layout1, "ProgressBar1" );
93 ProgressBar1->setProgress(0);
94 hbox->addWidget(ProgressBar1,10,AlignCenter);
95
96 hbox->addStretch(1);
97 buttonOk = new QPushButton( Layout1, "buttonOk" );
98 buttonOk->setText( tr( "&OK" ) );
99 hbox->addWidget(buttonOk,0,AlignRight);
100 hbox->addSpacing(5);
101 buttonCancel = new QPushButton( Layout1, "buttonCancel" );
102 buttonCancel->setText( tr( "&Cancel" ) );
103 buttonCancel->setAutoDefault( TRUE );
104 buttonCancel->setDefault( TRUE );
105 hbox->addWidget(buttonCancel,0,AlignRight);
106
107 ProgressBar1->setFixedSize(140,22);
108 buttonOk->setFixedSize(35,22);
109 buttonCancel->setFixedSize(35,22);
110 warnLabel ->setGeometry( QRect( 5,1,230,25));
111 TextLabel3->setGeometry( QRect( 5,20,230,25));
112 Layout1->setGeometry( QRect(1,60,235,50)); //TODO check these!!
113
114// timer= new QTimer(this,"vu timer");
115// connectionTimer=new QTimer(this,"connectionTimeout");
116
117 connect(buttonOk,SIGNAL(clicked()),this,SLOT(doOk()));
118 connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject()));
119// connect( timer, SIGNAL(timeout()), this , SLOT(timeSlot()));
120// connect( connectionTimer,SIGNAL( timeout()),this,SLOT( connectionTimeSlot()));
121 if(autoOk) {
122 qWarning("XXXXXXXXXXXXXXXXXXXXXXXX");
123 buttonOk->setDown(true);
124 doOk();
125 }
126}
127
128void NetworkDialog::timeSlot() {
129
130// if(timerProgess < 19 && posTimer) {
131// ProgressBar1->setProgress(timerProgess);
132// timerProgess++;
133// } else if(timerProgess > 19 && posTimer) {
134// ProgressBar1->setProgress(timerProgess);
135// timerProgess++;
136// posTimer=FALSE;
137// }
138// if(timerProgess > 1 &&!posTimer) {
139// ProgressBar1->setProgress(timerProgess);
140// timerProgess--;
141// } else if(timerProgess > 1 &&!posTimer){
142// ProgressBar1->setProgress(timerProgess);
143// timerProgess--;
144// posTimer=TRUE;
145// }
146// // qDebug("timer event");
147// qApp->processEvents();
148// repaint();
149}
150
151void NetworkDialog::connectionTimeSlot() {
152// qDebug("Connections timed out");
153// ftpQuit();
154// qApp->processEvents();
155// repaint();
156// reject();
157}
158
159
160/*
161downloads the file networkUrl */
162bool NetworkDialog::downloadFile( QString networkUrl )
163{
164 int fsz;
165// timer->start( 250 , FALSE);
166// posTimer=TRUE;
167// connectionTimer->start( 600 , FALSE);
168 warnLabel ->setText( "");
169 qApp->processEvents();
170 qDebug("Downloading: %s",networkUrl.latin1());
171 qDebug("Into: %s",localFileName.latin1());
172 if( networkUrl.length() > 5) {
173 QString ftp_user = "anonymous";
174 QString ftp_pass = "zaurus@gutenbrowser.com";
175// ftp_host= networkUrl.mid(networkUrl.find("ftp://",0, TRUE),
176 if(ftp_host.length() < 2) {
177 qDebug("Please select an ftp host" );
178 successDownload=false;
179 QMessageBox::message("Note","You need to select an ftp host");
180 return false;
181 }
182 QString msg;
183 qDebug(ftp_host);
184 qDebug("Opening ftp connection.");
185 warnLabel->setText("connecting to: "+ftp_host );
186 qApp->processEvents();
187 /////////// Open FTP connection
188 if (!FtpConnect( ftp_host.latin1(), &conn)) {
189 i=0;
190 successDownload=false;
191 QMessageBox::message("Note","Unable to connect to\n"+ftp_host);
192 return false;
193 }
194 TextLabel3->setText("Opening ftp connection.");
195 qApp->processEvents();
196 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
197 FtpQuit(conn);
198 successDownload=false;
199 msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn));
200 QMessageBox::message("Note",msg);
201 return false;
202 }
203 qDebug("Changing directories.");
204 TextLabel3->setText("Changing directories.");
205 qApp->processEvents();
206 if (!FtpChdir( dir.latin1(), conn )) {
207 successDownload=false;
208 msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn));
209 QMessageBox::message("Note",msg);
210 FtpQuit(conn);
211 return false;
212 }
213// if (!FtpNlst( "./.guten_temp", dir, conn)) {
214// successDownload=false;
215// msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn));
216// QMessageBox::message("Note",msg);
217// FtpQuit(conn);
218// return false;
219// }
220 qDebug("Requesting directory list.");
221 TextLabel3->setText("Getting directory list.");
222 qApp->processEvents();
223 if (!FtpDir( "./.guten_temp", dir.latin1(), conn) ) {
224 msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn));
225 QMessageBox::message("Note",msg);
226 successDownload=false;
227 FtpQuit(conn);
228 return false;
229 }
230 QFile tmp("./.guten_temp");
231 QString s, File_Name;
232
233 if (tmp.open(IO_ReadOnly)) {
234 QTextStream t( &tmp ); // use a text stream
235 qDebug("Finding partial filename "+s_partialFileName);
236 while ( !t.eof()) {
237 s = t.readLine();
238
239 if (s.contains(s_partialFileName, FALSE)) {
240 QString str = s.right( (s.length()) - (s.find(s_partialFileName, FALSE)) );
241
242 if (str.contains(".txt")) {
243 File_Name = str;
244 qDebug("Found file_name "+ File_Name);
245 break;
246 }
247// if (str.contains(".zip")) {
248// File_Name = str;
249// qDebug("Found file_name "+ File_Name);
250// break;
251// }
252
253 }
254 } //end of while loop
255 tmp.close();
256// tmp.remove(); ///TODO this is for release version Zaurus
257 }
258 else
259 qDebug("Error opening temp file.");
260
261 Config cfg("Gutenbrowser");
262 cfg.setGroup("General");
263 QString temp=cfg.readEntry("DownloadDirectory",local_library);
264
265 localFileName = temp+File_Name;
266 qDebug("Requesting file "+ File_Name);
267 qDebug( "Saving as "+localFileName);
268 msg="Requesting file "+ File_Name;
269 TextLabel3->setText(msg);
270 qApp->processEvents();
271 if( File_Name.length()>3) {
272 if (!FtpSize( File_Name.latin1(), &fsz, FTPLIB_ASCII, conn))
273 fsz = 0;
274 QString temp;
275 temp.sprintf( File_Name+" "+" %dkb", fsz);
276 TextLabel3->setText(temp);
277
278 ProgressBar1->setTotalSteps(fsz);
279 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
280 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
281 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
282 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
283
284 if (!FtpGet( localFileName.latin1(), File_Name.latin1(), FTPLIB_ASCII, conn)) {
285 msg.sprintf("Could not download "+ File_Name+"\n%s",FtpLastResponse(conn));
286 successDownload=false;
287 QMessageBox::message("Note",msg);
288 update();
289 }
290 } else {
291 QMessageBox::message("Note","Could not download file "+ File_Name);
292 successDownload=false;
293 FtpQuit(conn);
294 return false;
295 }
296 qDebug("Ftp session successful");
297 successDownload=TRUE;
298 FtpQuit(conn);
299 return true;
300 } //no network url
301 return false;
302}
303
304void NetworkDialog::doOk() {
305 qWarning("Do OK");
306 QString loginStr;
307 loginStr = "gutenbrowser";
308 if ( !ftp_host.isEmpty() ) {
309 if( ftp_host.find( "/", ftp_host.length() - 1,TRUE) != -1 && ftp_host.find("ftp://",0, TRUE) != -1) {
310 TextLabel3->setText( tr( "List remote dir:\n" + ftp_host) );
311// TextLabel2->setText( tr( "local file to download into: " +localFileName ) );
312
313 if( downloadFile(ftp_host))
314 successDownload = true;
315 else {
316 successDownload = false;
317 reject();
318 }
319 } else {
320 if(downloadFile(ftp_host))
321 successDownload = true;
322 else {
323 successDownload = false;
324 reject();
325 }
326 }
327 }
328 accept();
329}
diff --git a/noncore/apps/opie-gutenbrowser/NetworkDialog.h b/noncore/apps/opie-gutenbrowser/NetworkDialog.h
new file mode 100644
index 0000000..447979f
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/NetworkDialog.h
@@ -0,0 +1,84 @@
1/***************************************************************************
2 NetworkDialog.h - description
3 -------------------
4 begin : Sun Aug 27 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7***************************************************************************/
8/***************************************************************************
9 * *
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 *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef NETWORKDIALOG_H
17#define NETWORKDIALOG_H
18
19#include <qdialog.h>
20#include <qurloperator.h>
21#include <qcstring.h>
22#include <qfile.h>
23#include <qlayout.h>
24#include <qlabel.h>
25#include <qpushbutton.h>
26#include <qstringlist.h>
27
28//#include <qtimer.h>
29
30//class QProgressBar;
31
32class NetworkDialog : public QDialog
33{
34 Q_OBJECT
35
36public:
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); */
39 ~NetworkDialog();
40
41 QFile fiole;
42 QTimer * connectionTimer;
43 QTimer * timer;
44 int timerProgess;
45 bool posTimer;
46 QString s_partialFileName, s_finally;
47 bool foundIt, successDownload;
48 QLabel * warnLabel;
49 QLabel* TextLabel3;
50 QPushButton* buttonHelp;
51 bool ok;
52 QString local_library;
53 QString ftp_host;
54 QString ftp_base_dir;
55 QString dir, strUrl, networkUrl;
56
57 QPushButton* buttonOk;
58 QPushButton* buttonCancel;
59
60 QString localFileName;
61 bool fileFound;
62 int i, totalBytesDownloaded;
63 bool autoOk;
64
65 void initDialog();
66
67protected:
68 QHBoxLayout* hbox;
69
70private slots:
71 bool downloadFile( QString strUrl);
72 void connectionTimeSlot();
73 void timeSlot();
74 void doOk();
75
76 private:
77/* #ifndef Q_WS_QWS */
78
79/* QString getOpenFileName(); */
80/* QUrlOperator op; */
81/* #endif */
82};
83
84#endif // NETWORKDIALOG_H
diff --git a/noncore/apps/opie-gutenbrowser/SearchDialog.cpp b/noncore/apps/opie-gutenbrowser/SearchDialog.cpp
new file mode 100644
index 0000000..dab4789
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/SearchDialog.cpp
@@ -0,0 +1,135 @@
1/****************************************************************************
2** Created: Tue Aug 29 11:45:00 2000**/
3// copyright : (C) 2000 -2004 by llornkcor
4// email : ljp@llornkcor.com
5
6#include "SearchDialog.h"
7#include "SearchResults.h"
8
9#include <qlayout.h>
10#include <qcheckbox.h>
11#include <qlabel.h>
12#include <qlineedit.h>
13#include <qpushbutton.h>
14#include <qvariant.h>
15#include <qtooltip.h>
16#include <qwhatsthis.h>
17#include <qmessagebox.h>
18#include <qdir.h>
19#include <qpe/config.h>
20
21/*This is just a single text entry dialog */
22SearchDialog::SearchDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
23 : QDialog( parent, name, modal, fl )
24{
25 if ( !name )
26 setName( "SearchDialog" );
27 Config cfg("Gutenbrowser");
28 cfg.setGroup("General");
29 QString lastSearch=cfg.readEntry("LastSearch","");
30
31#warning FIXME
32 // FIXME
33 resize( 220,100);
34
35 QGridLayout *layout = new QGridLayout( this );
36 layout->setSpacing( 2);
37 layout->setMargin( 2);
38
39 QString local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
40 TextLabel1 = new QLabel( this, "TextLabel1" );
41 layout->addMultiCellWidget( TextLabel1, 0, 0, 0, 1);
42
43 label1Str= "<P>Enter text to search etext for </P>" ;
44 TextLabel1->setText( tr( label1Str) );
45
46 SearchLineEdit = new QLineEdit( this, "SearchLineEdit" );
47 layout->addMultiCellWidget( SearchLineEdit, 1, 1, 0, 1);
48
49 buttonOk = new QPushButton( this, "buttonOk" );
50 buttonOk->setText( tr( "Sea&rch" ) );
51 buttonOk->setAutoDefault( TRUE );
52 buttonOk->setToggleButton( TRUE);
53 buttonOk->setDefault( TRUE );
54
55 layout->addMultiCellWidget(buttonOk, 2, 2, 0, 0);
56
57 buttonCancel = new QPushButton( this, "buttonCancel" );
58 buttonCancel->setText( tr( "&Cancel" ) );
59 buttonCancel->setAutoDefault( TRUE );
60// buttonCancel->setMaximumWidth(40);
61
62
63 if( (QString)name !="Etext Search" )
64 SearchLineEdit->setText(lastSearch);
65
66 caseSensitiveCheckBox = new QCheckBox ( tr("Case Sensitive"), this );
67 layout->addMultiCellWidget( caseSensitiveCheckBox, 3, 3, 0, 1);
68
69 // signals and slots connections
70 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( byeBye() ) );
71
72 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( closed() ) );
73 SearchLineEdit->setFocus();
74}
75
76SearchDialog::~SearchDialog()
77{
78}
79
80QString SearchDialog::get_text() {
81 return SearchLineEdit->text();
82}
83
84bool SearchDialog::get_direction() {
85 return false; //search forward
86}
87
88bool SearchDialog::case_sensitive() {
89 return true;
90}
91
92bool SearchDialog::forward_search() {
93 return true;
94}
95
96void SearchDialog::byeBye()
97{
98
99 searchString = get_text();
100// qDebug("Search string is "+searchString);
101 Config cfg("Gutenbrowser");
102 cfg.setGroup("General");
103 cfg.writeEntry("LastSearch",searchString);
104
105 QString thisName=name();
106 if( thisName.find("Library Search", 0, TRUE) != -1) {
107 // searchString = SearchLineEdit->text();
108 accept();
109 } else {
110
111 buttonOk->setDown(TRUE);
112
113 emit search_signal();
114 buttonOk->setDown(FALSE);
115 }
116}
117
118void SearchDialog::closed()
119{
120 searchString = get_text();
121// qDebug("Search string is "+searchString);
122 Config cfg("Gutenbrowser");
123 cfg.setGroup("General");
124 cfg.writeEntry("LastSearch",searchString);
125
126 emit search_done_signal();
127 //this->reject();
128 this->hide();
129}
130
131
132void SearchDialog::setLabel(QString labelText)
133{
134 TextLabel1->setText( tr( label1Str+labelText) );
135}
diff --git a/noncore/apps/opie-gutenbrowser/SearchDialog.h b/noncore/apps/opie-gutenbrowser/SearchDialog.h
new file mode 100644
index 0000000..a7effdd
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/SearchDialog.h
@@ -0,0 +1,57 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'SearchDialog.ui'
3**
4** Created: Tue Aug 29 11:12:09 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7****************************************************************************/
8#ifndef SEARCHDIALOG_H
9#define SEARCHDIALOG_H
10
11#include <qdialog.h>
12#include "SearchResults.h"
13#include <qpe/config.h>
14
15class QVBoxLayout;
16class QHBoxLayout;
17class QGridLayout;
18class QLabel;
19class QLineEdit;
20class QPushButton;
21class QCheckBox;
22
23class SearchDialog : public QDialog
24{
25 Q_OBJECT
26
27public:
28 SearchDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
29 ~SearchDialog();
30
31 QLabel* TextLabel1;
32 QPushButton* buttonOk;
33 QPushButton* buttonCancel;
34 QLineEdit* SearchLineEdit;
35 QString searchString;
36 QString label1Str;
37 QCheckBox *caseSensitiveCheckBox;
38Config *cfg;
39protected:
40 QHBoxLayout* hbox;
41
42public slots: // Public slots
43 void setLabel( QString labelText);
44 void byeBye();
45 bool get_direction();
46 bool case_sensitive();
47 bool forward_search();
48 //void setLabel();
49 void closed();
50 QString get_text();
51signals:
52
53 void search_signal();
54 void search_done_signal();
55};
56
57#endif // SEARCHDIALOG_H
diff --git a/noncore/apps/opie-gutenbrowser/SearchResults.cpp b/noncore/apps/opie-gutenbrowser/SearchResults.cpp
new file mode 100644
index 0000000..c98c53f
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/SearchResults.cpp
@@ -0,0 +1,101 @@
1/****************************************************************************
2** Created: Sat Feb 24 23:35:01 2001
3 copyright : (C) 2000 -2004 by llornkcor
4 email : ljp@llornkcor.com
5****************************************************************************/
6#include "SearchResults.h"
7#include "gutenbrowser.h"
8#include "LibraryDialog.h"
9
10#include <qpe/qpeapplication.h>
11#include <stdio.h>
12#include <qstrlist.h>
13#include <qclipboard.h>
14
15#include <qlayout.h>
16#include <qlistbox.h>
17#include <qpushbutton.h>
18#include <qlayout.h>
19#include <qvariant.h>
20//#include <qtooltip.h>
21//#include <qwhatsthis.h>
22
23SearchResultsDlg::SearchResultsDlg( QWidget* parent, const char* name, bool modal, WFlags fl, QStringList stringList )
24 : QDialog( parent, name, modal, fl )
25{
26 if ( !name )
27 setName( "SearchResultsDlg" );
28
29 QGridLayout *layout = new QGridLayout( this );
30 layout->setSpacing( 2);
31 layout->setMargin( 2);
32
33 ListBox1 = new QListBox( this, "ListBox1" );
34 outPutLabel=new QLabel( this, "outPutLabel" );
35 statusLabel=new QLabel( this, "StatusLabel" );
36 QString local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
37
38 buttonOk = new QPushButton(this,"buttonOk");
39 buttonCancel = new QPushButton(this,"buttonCancel");
40
41 layout->addMultiCellWidget( buttonOk, 0, 0, 0, 0);
42 layout->addMultiCellWidget( buttonCancel, 0, 0, 1, 1);
43
44 layout->addMultiCellWidget( ListBox1, 1, 4, 0, 1);
45
46 outPutLabel->setMaximumHeight(30);
47 statusLabel->setMaximumHeight(30);
48
49 layout->addMultiCellWidget( outPutLabel, 5, 5, 0, 1);
50 layout->addMultiCellWidget( statusLabel, 6, 6, 0, 1);
51
52
53 setCaption( tr( "Search Results" ) );
54 buttonOk->setText( tr( "&Download" ) );
55 buttonOk->setAutoDefault( TRUE );
56 buttonCancel->setText( tr( "&Cancel" ) );
57 buttonCancel->setAutoDefault( TRUE );
58 buttonOk->setDefault( TRUE );
59 ListBox1->setSelectionMode( QListBox::Single );
60 ListBox1->setMultiSelection(true);
61 statusLabel->setText( "Double click a title to begin downloading." );
62
63 // signals and slots connections
64 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( dwnLd() ) );
65 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
66 connect( ListBox1, SIGNAL( doubleClicked(QListBoxItem *)), SLOT( slotListClicked(QListBoxItem * )) );
67
68 ListBox1->insertStringList( stringList);
69 numListItems= ListBox1->numRows();
70 QString strOut;
71
72 outPutLabel->setText( "Number of results: "+ strOut.sprintf("%d", numListItems) );
73
74// printf( "Sucessfully entered SearchResults Dialog\n");
75// selText = resultStr;
76}
77
78SearchResultsDlg::~SearchResultsDlg()
79{
80}
81
82void SearchResultsDlg::slotListClicked(QListBoxItem *it) {
83
84 resultsList.append(it->text() );
85// resultsList.append(ListBox1->text( 0));
86// selText = ListBox1->currentText();
87 accept();
88}
89
90void SearchResultsDlg::dwnLd() {
91
92 for(unsigned int ji=0; ji< ListBox1->count() ; ji++ ) {
93 if( ListBox1->isSelected( ji) )
94 resultsList.append(ListBox1->text( ji));
95 }
96 accept();
97}
98
99void SearchResultsDlg::downloadButtonSlot() {
100
101}
diff --git a/noncore/apps/opie-gutenbrowser/SearchResults.h b/noncore/apps/opie-gutenbrowser/SearchResults.h
new file mode 100644
index 0000000..bab8e48
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/SearchResults.h
@@ -0,0 +1,51 @@
1
2/****************************************************************************
3** Created: Sat Feb 24 23:32:10 2001
4 copyright : (C) 2000 -2004 by llornkcor
5 email : ljp@llornkcor.com
6
7****************************************************************************/
8#ifndef SEARCHRESULTSDLG_H
9#define SEARCHRESULTSDLG_H
10
11//#include "gutenbrowser.h"
12#include <qdialog.h>
13#include <qlabel.h>
14#include <qstringlist.h>
15#include <qlistbox.h>
16
17class QVBoxLayout;
18class QHBoxLayout;
19class QGridLayout;
20//class QListBox;
21class QListBoxItem;
22class QPushButton;
23
24class SearchResultsDlg : public QDialog
25{
26 Q_OBJECT
27
28public:
29 SearchResultsDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0, QStringList stringList=0);
30 ~SearchResultsDlg();
31
32 QLabel* statusLabel, *outPutLabel;
33 QPushButton* buttonOk;
34 QPushButton* buttonCancel;
35 QListBox* ListBox1;
36 QString selText;
37 QStringList resultsList;
38 int numListItems;
39
40protected:
41 QHBoxLayout* hbox;
42public slots:
43 void slotListClicked(QListBoxItem *);
44
45protected slots:
46 void dwnLd();
47 void downloadButtonSlot();
48
49};
50
51#endif // SEARCHRESULTSDLG_H
diff --git a/noncore/apps/opie-gutenbrowser/bookmarksdlg.cpp b/noncore/apps/opie-gutenbrowser/bookmarksdlg.cpp
new file mode 100644
index 0000000..ba042c6
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/bookmarksdlg.cpp
@@ -0,0 +1,34 @@
1/***************************************************************************
2 bookmarksdlg.cpp - description
3 -------------------
4 begin : Wed Dec 1 1999
5 copyright : (C) 1999 -2004 by llornkcor
6 email : ljp@llornkcor.com
7 ***************************************************************************/
8 /***************************************************************************
9 * *
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 *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16// QMessageBox::message( "Note", listItemNumber );
17#include "bookmarksdlg.h"
18
19
20bookMarksDlg::bookMarksDlg(QWidget *parent,QString name) : QDialog(parent,name,true)
21{
22 //initDialog();
23
24}
25
26bookMarksDlg::~bookMarksDlg(){
27}
28
29void bookMarksDlg::doIt()
30{
31
32
33 accept();
34}
diff --git a/noncore/apps/opie-gutenbrowser/bookmarksdlg.h b/noncore/apps/opie-gutenbrowser/bookmarksdlg.h
new file mode 100644
index 0000000..8d99b2b
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/bookmarksdlg.h
@@ -0,0 +1,55 @@
1/***************************************************************************
2 bookmarksdlg.h - description
3 -------------------
4 begin : Wed Dec 1 1999
5 copyright : (C) 1999 - 2004 by llornkcor
6 email : ljp@llornkcor.com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef BOOKMARKSDLG_H
19#define BOOKMARKSDLG_H
20
21#include <qwidget.h>
22#include <qlineedit.h>
23#include <qmultilineedit.h>
24#include <qlabel.h>
25//#include <qlistbox.h>
26#include <qpushbutton.h>
27#include <qcombobox.h>
28#include <qdialog.h>
29
30
31class bookMarksDlg : public QDialog {
32 Q_OBJECT
33public:
34 bookMarksDlg(QWidget *parent, QString name);
35 ~bookMarksDlg();
36
37protected:
38 //void initDialog();
39 QLineEdit *QLineEdit_1;
40 QMultiLineEdit *QMultiLineEdit_1;
41 QLabel *QLabel_1;
42 QLabel *QLabel_2;
43 QLabel *QLabel_3;
44 QComboBox *QComboBox_1;
45 QPushButton *QPushButton_Ok;
46 QPushButton *QPushButton_cancel;
47
48
49private:
50
51protected slots:
52 virtual void doIt();
53};
54
55#endif
diff --git a/noncore/apps/opie-gutenbrowser/browserDialog.cpp b/noncore/apps/opie-gutenbrowser/browserDialog.cpp
new file mode 100644
index 0000000..5c48da1
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/browserDialog.cpp
@@ -0,0 +1,83 @@
1/****************************************************************************
2copyright 2001 by L.J. Potter ljp@llornkcor.com
3 copyright : (C) 2000 -2004 by llornkcor
4 email : ljp@llornkcor.com
5
6****************************************************************************/
7
8#include "optionsDialog.h"
9//#include "fileBrowser.h"
10
11#include <qlabel.h>
12#include <qlistbox.h>
13#include <qpushbutton.h>
14#include <qlayout.h>
15
16#include <opie/ofiledialog.h>
17
18void optionsDialog::BrowserDlg( )
19{
20// setCaption( tr( "Choose Browser" ) );
21 http_ListBox1->insertItem( tr( "Opera"));
22 http_ListBox1->insertItem( tr( "Konqueror"));
23 http_ListBox1->insertItem( tr( "wget"));
24}
25
26void optionsDialog::select_title(int) {
27 browserName = http_ListBox1->currentText();
28 Config config("Gutenbrowser");
29 config.setGroup( "Browser" );
30 printf("Brow is: "+browserName+"\n");
31 config.writeEntry("Preferred", browserName);
32 TextLabel3_3->setText( "Current http browser: "+browserName );
33}
34
35void optionsDialog::BrowseSelected() {
36 QString fileName;
37 Config cfg("Gutenbrowser");
38 cfg. setGroup ( "View" );
39 QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir());
40 QMap<QString, QStringList> map;
41 map.insert(tr("All"), QStringList() );
42 QStringList text;
43 text << "text/*";
44 map.insert(tr("Text"), text );
45 text << "*";
46 map.insert(tr("All"), text );
47
48 QString str = OFileDialog::getOpenFileName( 2, dir , QString::null, map);
49 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) {
50 fileName = str;
51// QStringList fileList=browseForFiles->fileList;
52// qDebug(selFile);
53// QStringList::ConstIterator f;
54// QString fileTemp,filer;
55// for ( f = fileList.begin(); f != fileList.end(); f++ ) {
56
57// fileTemp = *f;
58// fileTemp.right( fileTemp.length()-5);
59// fileName = fileTemp;
60// if( !fileName.isEmpty() ){
61// filer = fileName;
62// } else {
63// QString sMsg;
64// sMsg = "Error opening library filelist "+fileName;
65// }
66 if ( !fileName.isNull() ) { // got a file name
67 // ...
68 }
69 }
70
71}
72
73void optionsDialog::setHttp(int index) {
74 Config config("Gutenbrowser");
75 config.setGroup( "HttpServer" );
76 qDebug("writing http server");
77 if( index== 0) {
78 config.writeEntry("Preferred", "http://sailor.gutenberg.org");
79 } else {
80 config.writeEntry("Preferred", "http://www.prairienet.org/pg");
81 }
82
83}
diff --git a/noncore/apps/opie-gutenbrowser/config.in b/noncore/apps/opie-gutenbrowser/config.in
new file mode 100644
index 0000000..ec67d6e
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/config.in
@@ -0,0 +1,4 @@
1 config OPIE-GUTENBROWSER
2 boolean "gutenbrowser - Gutenberg Project etext reader and selector"
3 default "n"
4 depends ( LIBQPE || LIBQPE-X11 ) && FTPLIB
diff --git a/noncore/apps/opie-gutenbrowser/editTitle.cpp b/noncore/apps/opie-gutenbrowser/editTitle.cpp
new file mode 100644
index 0000000..100370c
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/editTitle.cpp
@@ -0,0 +1,54 @@
1/****************************************************************************
2** Created: Thu Jan 24 08:47:37 2002
3 copyright : (C) 2000 -2004 by llornkcor
4 email : ljp@llornkcor.com
5****************************************************************************/
6#include "editTitle.h"
7
8#include <qlineedit.h>
9#include <qpushbutton.h>
10
11Edit_Title::Edit_Title( QWidget* parent, const char* name, bool modal, WFlags fl)
12 : QDialog( parent, name, modal, fl )
13{
14 if ( !name )
15 setName( "Edit_Title" );
16 resize( 240, 110 );
17 setMaximumSize( QSize( 240, 110 ) );
18 setCaption( tr( "Edit Title" ) );
19
20 LineEdit1 = new QLineEdit( this, "LineEdit1" );
21 LineEdit1->setGeometry( QRect( 5, 22, 230, 22 ) );
22 newTitle=name;
23 LineEdit1->setText(newTitle);
24
25 PushButton_Cancel = new QPushButton( this, "PushButton_Cancel" );
26 PushButton_Cancel->setGeometry( QRect( 180, 80, 50, 20 ) );
27 PushButton_Cancel->setText( tr( "Cancel" ) );
28
29 PushButton_Apply = new QPushButton( this, "PushButton_Apply" );
30 PushButton_Apply->setGeometry( QRect( 120, 80, 50, 20 ) );
31
32 PushButton_Apply->setText( tr( "Apply" ) );
33
34 // signals and slots connections
35 connect( PushButton_Cancel, SIGNAL( released() ),this, SLOT( onCancel() ) );
36 connect( PushButton_Apply, SIGNAL( released() ), this, SLOT( onApply() ) );
37}
38
39/*
40 * Destroys the object and frees any allocated resources
41 */
42Edit_Title::~Edit_Title()
43{
44 // no need to delete child widgets, Qt does it all for us
45}
46
47void Edit_Title::onCancel() {
48 reject();
49}
50
51void Edit_Title::onApply() {
52 newTitle= LineEdit1->text();
53 accept();
54}
diff --git a/noncore/apps/opie-gutenbrowser/editTitle.h b/noncore/apps/opie-gutenbrowser/editTitle.h
new file mode 100644
index 0000000..2480a01
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/editTitle.h
@@ -0,0 +1,34 @@
1/****************************************************************************
2** Created: Thu Jan 24 08:47:13 2002
3 copyright : (C) 2000 -2004 by llornkcor
4 email : ljp@llornkcor.com
5****************************************************************************/
6#ifndef EDIT_TITLE_H
7#define EDIT_TITLE_H
8
9#include <qvariant.h>
10#include <qdialog.h>
11class QVBoxLayout;
12class QHBoxLayout;
13class QGridLayout;
14class QLineEdit;
15class QPushButton;
16
17class Edit_Title : public QDialog
18{
19 Q_OBJECT
20
21public:
22 Edit_Title( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0);
23 ~Edit_Title();
24
25 QLineEdit* LineEdit1;
26 QPushButton* PushButton_Cancel;
27 QPushButton* PushButton_Apply;
28 QString newTitle;
29public slots:
30 void onCancel();
31 void onApply();
32};
33
34#endif // EDIT_TITLE_H
diff --git a/noncore/apps/opie-gutenbrowser/editTitle.ui b/noncore/apps/opie-gutenbrowser/editTitle.ui
new file mode 100644
index 0000000..8c4de4d
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/editTitle.ui
@@ -0,0 +1,100 @@
1<!DOCTYPE UI><UI>
2<class>Edit_Title</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>Edit_Title</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>21</x>
13 <y>8</y>
14 <width>240</width>
15 <height>110</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>maximumSize</name>
20 <size>
21 <width>240</width>
22 <height>110</height>
23 </size>
24 </property>
25 <property stdset="1">
26 <name>caption</name>
27 <string>Edit Title</string>
28 </property>
29 <widget>
30 <class>QLineEdit</class>
31 <property stdset="1">
32 <name>name</name>
33 <cstring>LineEdit1</cstring>
34 </property>
35 <property stdset="1">
36 <name>geometry</name>
37 <rect>
38 <x>0</x>
39 <y>22</y>
40 <width>230</width>
41 <height>22</height>
42 </rect>
43 </property>
44 </widget>
45 <widget>
46 <class>QPushButton</class>
47 <property stdset="1">
48 <name>name</name>
49 <cstring>PushButton_Cancel</cstring>
50 </property>
51 <property stdset="1">
52 <name>geometry</name>
53 <rect>
54 <x>120</x>
55 <y>80</y>
56 <width>50</width>
57 <height>20</height>
58 </rect>
59 </property>
60 <property stdset="1">
61 <name>text</name>
62 <string>Cancel</string>
63 </property>
64 </widget>
65 <widget>
66 <class>QPushButton</class>
67 <property stdset="1">
68 <name>name</name>
69 <cstring>PushButton_Apply</cstring>
70 </property>
71 <property stdset="1">
72 <name>geometry</name>
73 <rect>
74 <x>180</x>
75 <y>80</y>
76 <width>50</width>
77 <height>20</height>
78 </rect>
79 </property>
80 <property stdset="1">
81 <name>text</name>
82 <string>Apply</string>
83 </property>
84 </widget>
85</widget>
86<connections>
87 <connection>
88 <sender>PushButton_Cancel</sender>
89 <signal>released()</signal>
90 <receiver>PushButton_Cancel</receiver>
91 <slot>onCancel()</slot>
92 </connection>
93 <connection>
94 <sender>PushButton_Apply</sender>
95 <signal>released()</signal>
96 <receiver>PushButton_Apply</receiver>
97 <slot>onApply()</slot>
98 </connection>
99</connections>
100</UI>
diff --git a/noncore/apps/opie-gutenbrowser/fontDialog.cpp b/noncore/apps/opie-gutenbrowser/fontDialog.cpp
new file mode 100644
index 0000000..a17b1d3
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/fontDialog.cpp
@@ -0,0 +1,260 @@
1/****************************************************************************
2** Created: Sun Jan 27 11:03:24 2002
3copyright 2002 by L.J. Potter ljp@llornkcor.com
4 copyright : (C) 2000 -2004 by llornkcor
5 email : ljp@llornkcor.com
6****************************************************************************/
7#include "fontDialog.h"
8#include "optionsDialog.h"
9
10#include <qpe/fontdatabase.h>
11#include <qpe/config.h>
12
13#include <qstringlist.h>
14#include <qfontinfo.h>
15#include <qvaluelist.h>
16#include <qpe/qpeapplication.h>
17
18#include <qgroupbox.h>
19#include <qlabel.h>
20#include <qlistbox.h>
21#include <qmultilineedit.h>
22#include <qpushbutton.h>
23#include <qlayout.h>
24#include <qvariant.h>
25#include <qtooltip.h>
26#include <qwhatsthis.h>
27#include <qcombobox.h>
28
29//#define BUGGY_SHARP_ZAURUS 0
30
31static const int nfontsizes = 9;
32static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24};
33
34
35FontDialog::FontDialog( QWidget * parent, const char* name /*, bool modal, WFlags fl */)
36 :/* QDialog*/ QWidget( parent, name /*, modal, fl */)
37{
38 if ( !name )
39 setName( "FontDialog" );
40 setCaption( tr( "Font Dialog" ) );
41
42 QGridLayout *layout = new QGridLayout( this );
43 layout->setSpacing(2);
44 layout->setMargin(2);
45
46 familyListBox = new QListBox( this, "familyListBox" );
47 layout->addMultiCellWidget( familyListBox, 0, 2, 0, 0);
48
49 QBoxLayout * hbox = new QHBoxLayout(this);
50 QBoxLayout * vbox = new QVBoxLayout(this);
51
52 styleListBox = new QListBox( this, "styleListBox" );
53 vbox->addWidget( styleListBox, 0);
54
55 FontTextLabel4 = new QLabel( this, "TextLabel4" );
56 FontTextLabel4->setText( tr( "Size" ) );
57 hbox->addWidget( FontTextLabel4,0);
58
59 sizeComboBox = new QComboBox( FALSE, this, "SizeCombo");
60// sizeComboBox->setMaximumWidth(60);
61 hbox->addWidget( sizeComboBox, 0);
62
63 vbox->addLayout(hbox,0);
64 layout->addLayout( vbox,0,3);
65
66 MultiLineEdit1 = new QMultiLineEdit( this, "MultiLineEdit1" );
67 MultiLineEdit1->setText( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ) );
68 MultiLineEdit1->setWordWrap( QMultiLineEdit::WidgetWidth);
69
70 layout->addMultiCellWidget( MultiLineEdit1, 4, 4, 0, 3);
71
72 connect(familyListBox,SIGNAL(highlighted(const QString &)),SLOT(familyListBoxSlot(const QString &)));
73 connect(styleListBox,SIGNAL(highlighted(const QString &)),SLOT(styleListBoxSlot(const QString &)));
74 connect(sizeComboBox,SIGNAL(activated(const QString &)),SLOT(sizeComboBoxSlot(const QString &)));
75
76 populateLists();
77
78}
79
80FontDialog::~FontDialog()
81{
82}
83
84void FontDialog::familyListBoxSlot(const QString & text)
85{
86 int styleInt = styleListBox->currentItem();
87 int sizeInt = sizeComboBox->currentText().toInt();
88
89 sizeComboBox->clear();
90 styleListBox->clear();
91// clearListBoxes();
92 family = text;
93// qDebug(family);
94 QStringList styles = fdb.styles( family ); // string list of styles of our current font family
95 styleListBox->insertStringList( styles);
96 QString dstyle;// = "\t" + style + " (";
97
98#ifdef BUGGY_SHARP_ZAURUS
99
100QValueList<int> smoothies = fdb.smoothSizes( family, styleListBox->text(0) );
101 for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) {
102 dstyle = QString::number( *points );
103 qDebug(dstyle);
104 sizeComboBox->insertItem( dstyle.left( dstyle.length() - 1 ));
105 }
106#else
107
108 for (int i=0; i<nfontsizes; i++) {
109 sizeComboBox->insertItem( QString::number(fontsize[i]));
110 if(fontsize[i] == sizeInt) {
111 sizeComboBox->setCurrentItem(i);
112 }
113 }
114#endif
115
116 if(styleInt == -1 || styleInt > styleListBox->count() )
117 styleListBox->setCurrentItem(0);
118 else
119 styleListBox->setCurrentItem(styleInt);
120
121 changeText();
122}
123
124void FontDialog::styleListBoxSlot(const QString &text)
125{
126 changeText();
127}
128
129void FontDialog::sizeComboBoxSlot(const QString & text)
130{
131 changeText();
132}
133
134void FontDialog::populateLists()
135{
136// QFont defaultFont=MultiLineEdit1->font();
137// QFont defaultFont=Lview->font();
138// QFontInfo fontInfo(defaultFont);
139 Config config("Gutenbrowser");
140 config.setGroup("Font");
141 QString familyStr = config.readEntry("Family", "fixed");
142 QString styleStr = config.readEntry("Style", "Regular");
143 QString sizeStr = config.readEntry("Size", "10");
144 QString charSetStr = config.readEntry("CharSet", "iso10646-1" );
145 bool ok;
146 int i_size = sizeStr.toInt(&ok,10);
147 selectedFont = fdb.font(familyStr,styleStr,i_size,charSetStr);
148// defaultFont.setItalic(TRUE);
149 families = fdb.families();
150
151 for ( QStringList::Iterator f = families.begin(); f != families.end();++f ) {
152 QString family = *f;
153// if(family == defaultFont.family())
154// qDebug(family);
155 familyListBox->insertItem( family);
156
157 if( familyListBox->text(0) == family) {
158 QStringList styles = fdb.styles( family );
159// string list of styles of our current font family
160 styleListBox->insertStringList( styles);
161
162 for ( QStringList::Iterator s = styles.begin(); s != styles.end();++s ) { // for each font style
163 style = *s;
164 QString dstyle;// = "\t" + style + " (";
165 if(styleListBox->text(0) == style) {
166
167 QValueList<int> smoothies = fdb.smoothSizes( family, style );
168 for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) {
169 dstyle = QString::number( *points ) + " ";
170 sizeComboBox ->insertItem( dstyle.left( dstyle.length() - 1 ));
171 }
172 dstyle = dstyle.left( dstyle.length() - 1 ) + ")";
173 }
174 } // styles
175 }
176 }
177 for(int i=0;i < familyListBox->count();i++) {
178 if( familyListBox->text(i) == familyStr)
179 familyListBox->setSelected( i, TRUE);
180 }
181
182 for(int i=0;i < styleListBox->count();i++) {
183 if( styleListBox->text(i) == styleStr)
184 styleListBox->setSelected( i, TRUE);
185 }
186
187 for (int i=0; i<sizeComboBox->count(); i++) {
188
189#ifdef BUGGY_SHARP_ZAURUS
190 if(sizeComboBox->text(i) == sizeStr)
191#else
192 if(fontsize[i] == i_size)
193#endif
194 sizeComboBox->setCurrentItem(i);
195 }
196 changeText();
197}
198
199void FontDialog::clearListBoxes() {
200 familyListBox->clear();
201 sizeComboBox->clear();
202 styleListBox->clear();
203}
204
205void FontDialog::changeText()
206{
207 if( familyListBox->currentItem() == -1)
208 family= familyListBox->text(0);
209 else {
210 family = familyListBox->currentText();
211 }
212// qDebug("Font family is "+family);
213 if( styleListBox->currentItem() == -1)
214 style=styleListBox->text(0);
215 else {
216 style = styleListBox->currentText();
217 }
218// qDebug("font style is "+style);
219
220 if( sizeComboBox->currentItem() == -1 )
221 size = sizeComboBox->text(0);
222 else {
223 size = sizeComboBox->currentText();
224 }
225
226// qDebug("Font size is "+size);
227 bool ok;
228 int i_size = size.toInt(&ok,10);
229 QStringList charSetList = fdb.charSets(family);
230// QStringList styles = fdb.styles( family ); // string list of styles of our current font family
231 QString charSet;
232 for ( QStringList::Iterator s = charSetList.begin(); s != charSetList.end();++s ) { // for each font style
233 charSet = *s;
234// qDebug(charSet);
235 }
236 selectedFont = fdb.font(family,style,i_size,charSet);
237 QFontInfo fontInfo( selectedFont);
238// if(fontInfo.italic() ) qDebug("italic");
239 selectedFont.setWeight(fontInfo.weight() );
240// qDebug("Style are "+style+" %d ",fontInfo.weight());
241 Config cfg("Gutenbrowser");
242 cfg.setGroup("Font");
243 cfg.writeEntry("Family",family);
244 cfg.writeEntry("Style",style);
245 cfg.writeEntry("Size",size);
246 cfg.writeEntry("CharSet",charSet);
247
248 if(style.find("Italic",0,TRUE) != -1) {
249 selectedFont = fdb.font(family,"Regular",i_size,charSet);
250 selectedFont.setItalic(TRUE); //ya right
251 cfg.writeEntry("Italic","TRUE");
252// qDebug("Style is "+styleListBox->currentText());
253 } else
254 cfg.writeEntry("Italic","FALSE");
255
256 MultiLineEdit1->setFont( selectedFont);
257 MultiLineEdit1->update();
258 changedFonts=TRUE;
259}
260
diff --git a/noncore/apps/opie-gutenbrowser/fontDialog.h b/noncore/apps/opie-gutenbrowser/fontDialog.h
new file mode 100644
index 0000000..08a83ac
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/fontDialog.h
@@ -0,0 +1,59 @@
1/****************************************************************************
2** Created: Sun Jan 27 11:02:59 2002
3copyright 2002 by L.J. Potter ljp@llornkcor.com
4 copyright : (C) 2000 -2004 by llornkcor
5 email : ljp@llornkcor.com
6****************************************************************************/
7#ifndef FONTDIALOG_H
8#define FONTDIALOG_H
9
10#include <qvariant.h>
11#include <qdialog.h>
12#include <qpe/fontdatabase.h>
13#include <qfont.h>
14
15class QVBoxLayout;
16class QHBoxLayout;
17class QGridLayout;
18class QLabel;
19class QListBox;
20class QListBoxItem;
21class QPushButton;
22class QGroupBox;
23class QMultiLineEdit;
24class QComboBox;
25
26class FontDialog : public /*QDialog*/ QWidget
27{
28 Q_OBJECT
29
30public:
31 FontDialog( QWidget * parent = 0, const char* name = 0 /*, bool modal=FALSE, WFlags fl = 0 */);
32 ~FontDialog();
33
34 QLabel *FontTextLabel4;
35 QGroupBox *FamilyGroup, *GroupBox2;
36 QListBox *familyListBox, *styleListBox, *sizeListBox;
37 QMultiLineEdit *MultiLineEdit1;
38 QPushButton *PushButtonOk,*PushButtonCancel;
39 QStringList families;
40 QComboBox *sizeComboBox;
41
42 FontDatabase fdb;
43 QString family, style, size;
44 QFont selectedFont;
45 bool changedFonts;
46 void populateLists();
47 void clearListBoxes();
48 void changeText();
49protected slots:
50
51 void familyListBoxSlot(const QString &);
52 void styleListBoxSlot(const QString &);
53 void sizeComboBoxSlot(const QString &);
54// void sizeListBoxSlot(const QString &);
55
56
57};
58
59#endif // FONTDIALOG_H
diff --git a/noncore/apps/opie-gutenbrowser/fontDialog.ui b/noncore/apps/opie-gutenbrowser/fontDialog.ui
new file mode 100644
index 0000000..e065c80
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/fontDialog.ui
@@ -0,0 +1,201 @@
1<!DOCTYPE UI><UI>
2<class>FontDialog</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>FontDialog</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>232</width>
15 <height>320</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>maximumSize</name>
20 <size>
21 <width>240</width>
22 <height>320</height>
23 </size>
24 </property>
25 <property stdset="1">
26 <name>caption</name>
27 <string>Font Dialog</string>
28 </property>
29 <widget>
30 <class>QGroupBox</class>
31 <property stdset="1">
32 <name>name</name>
33 <cstring>GroupBox2</cstring>
34 </property>
35 <property stdset="1">
36 <name>geometry</name>
37 <rect>
38 <x>120</x>
39 <y>5</y>
40 <width>110</width>
41 <height>90</height>
42 </rect>
43 </property>
44 <property stdset="1">
45 <name>title</name>
46 <string>Font Style</string>
47 </property>
48 <widget>
49 <class>QListBox</class>
50 <item>
51 <property>
52 <name>text</name>
53 <string>New Item</string>
54 </property>
55 </item>
56 <property stdset="1">
57 <name>name</name>
58 <cstring>styleListBox</cstring>
59 </property>
60 <property stdset="1">
61 <name>geometry</name>
62 <rect>
63 <x>5</x>
64 <y>20</y>
65 <width>100</width>
66 <height>61</height>
67 </rect>
68 </property>
69 <property stdset="1">
70 <name>sizePolicy</name>
71 <sizepolicy>
72 <hsizetype>0</hsizetype>
73 <vsizetype>0</vsizetype>
74 </sizepolicy>
75 </property>
76 </widget>
77 </widget>
78 <widget>
79 <class>QGroupBox</class>
80 <property stdset="1">
81 <name>name</name>
82 <cstring>FamilyGroup</cstring>
83 </property>
84 <property stdset="1">
85 <name>geometry</name>
86 <rect>
87 <x>5</x>
88 <y>5</y>
89 <width>115</width>
90 <height>135</height>
91 </rect>
92 </property>
93 <property stdset="1">
94 <name>title</name>
95 <string>Font</string>
96 </property>
97 <widget>
98 <class>QListBox</class>
99 <item>
100 <property>
101 <name>text</name>
102 <string>New Item</string>
103 </property>
104 </item>
105 <property stdset="1">
106 <name>name</name>
107 <cstring>familyListBox</cstring>
108 </property>
109 <property stdset="1">
110 <name>geometry</name>
111 <rect>
112 <x>5</x>
113 <y>20</y>
114 <width>100</width>
115 <height>105</height>
116 </rect>
117 </property>
118 <property stdset="1">
119 <name>sizePolicy</name>
120 <sizepolicy>
121 <hsizetype>0</hsizetype>
122 <vsizetype>0</vsizetype>
123 </sizepolicy>
124 </property>
125 </widget>
126 </widget>
127 <widget>
128 <class>QLabel</class>
129 <property stdset="1">
130 <name>name</name>
131 <cstring>TextLabel4</cstring>
132 </property>
133 <property stdset="1">
134 <name>geometry</name>
135 <rect>
136 <x>145</x>
137 <y>100</y>
138 <width>30</width>
139 <height>19</height>
140 </rect>
141 </property>
142 <property stdset="1">
143 <name>text</name>
144 <string>Size</string>
145 </property>
146 </widget>
147 <widget>
148 <class>QListBox</class>
149 <item>
150 <property>
151 <name>text</name>
152 <string>1</string>
153 </property>
154 </item>
155 <property stdset="1">
156 <name>name</name>
157 <cstring>sizeListBox</cstring>
158 </property>
159 <property stdset="1">
160 <name>geometry</name>
161 <rect>
162 <x>180</x>
163 <y>100</y>
164 <width>40</width>
165 <height>60</height>
166 </rect>
167 </property>
168 <property stdset="1">
169 <name>sizePolicy</name>
170 <sizepolicy>
171 <hsizetype>0</hsizetype>
172 <vsizetype>0</vsizetype>
173 </sizepolicy>
174 </property>
175 </widget>
176 <widget>
177 <class>QMultiLineEdit</class>
178 <property stdset="1">
179 <name>name</name>
180 <cstring>MultiLineEdit1</cstring>
181 </property>
182 <property stdset="1">
183 <name>geometry</name>
184 <rect>
185 <x>5</x>
186 <y>165</y>
187 <width>222</width>
188 <height>45</height>
189 </rect>
190 </property>
191 <property stdset="1">
192 <name>wordWrap</name>
193 <enum>WidgetWidth</enum>
194 </property>
195 <property stdset="1">
196 <name>text</name>
197 <string>The Quick Brown Fox Jumps Over The Lazy Dog</string>
198 </property>
199 </widget>
200</widget>
201</UI>
diff --git a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
new file mode 100644
index 0000000..ad770b5
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
@@ -0,0 +1,247 @@
1/***************************************************************************
2 ftpsitedlg.cpp - description
3 -------------------
4 begin : Tue Jul 25 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7 ***************************************************************************/
8/***************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 ***************************************************************************/
14#include "optionsDialog.h"
15#include "gutenbrowser.h"
16//#include "NetworkDialog.h"
17#include "output.h"
18
19#include <qprogressbar.h>
20#include <stdlib.h>
21#include <qurloperator.h>
22#include <qpe/config.h>
23#include <qlistbox.h>
24
25#include <unistd.h>
26#include <stdio.h>
27#include <stdlib.h>
28
29// :)~
30void optionsDialog::ftpSiteDlg( )
31{
32//printf( "ftpSiteDlg: ListFile is "+ ListFile +"\n" );
33// initDialog();
34 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
35// ListFile = local_library + "ftpList";
36 ListFile = QPEApplication::qpeDir() + "/etc/gutenbrowser";
37 QDir dir(ListFile);
38 if( !dir.exists())
39 dir.mkdir(ListFile,true);
40 ListFile+="/ftpList";
41 qDebug("opening "+ListFile);
42 if ( QFile(ListFile).exists() ) {
43 openSiteList();
44 } else {
45 switch( QMessageBox::warning( this, "Gutenbrowser",
46 "Do you want to download \nan ftp site list?",
47 QMessageBox::Yes, QMessageBox::No)) {
48 case QMessageBox::Yes: // yes
49 getSite();
50 break;
51 case QMessageBox::No: // No
52 // exit
53 break;
54 }
55
56 }
57}
58
59
60/*
61// get ftp list from web- parse it. */
62void optionsDialog::getSite()
63{
64 QString file_name;
65 QString ftp_listFileURL;
66 QString outputFile;
67// outputFile = local_library+ "list.html";
68 outputFile = ListFile + "list.html";
69 QString networkUrl= "http://www.gutenberg.org/www/mirror.sites.html";
70//http://www.gutenberg.org/index.html";
71// QString networkUrl= "http://llornkcor.com/index.shtml";
72// // "http://www.gutenberg.org/index.html"
73//
74//Qhttp stops working at times.... :(
75// NetworkDialog *NetworkDlg;
76// NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile);
77// if( NetworkDlg->exec() != 0 )
78// { // use new, improved, *INSTANT* network-dialog-file-getterer
79// qDebug("gitcha!");
80// }
81// delete NetworkDlg;
82//#ifdef Q_WS_QWS
83
84// TODO qprocess here
85
86 QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl + " 2>&1" ;
87 qDebug("Issuing the command "+cmd);
88 Output *outDlg;
89 outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE);
90 outDlg->showMaximized();
91 outDlg->show();
92 qApp->processEvents();
93 FILE *fp;
94 char line[130];
95 outDlg->OutputEdit->append( tr("Running wget") );
96 sleep(1);
97 fp = popen( (const char *) cmd, "r");
98 while ( fgets( line, sizeof line, fp)) {
99 outDlg->OutputEdit->append(line);
100 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
101 }
102 pclose(fp);
103 outDlg->close();
104 if(outDlg)
105 delete outDlg;
106
107// outputFile=ListFile;
108 ftp_QListBox_1->clear();
109 parseFtpList( outputFile); // got the html list, now parse it so we can use it
110}
111
112bool optionsDialog::parseFtpList( QString outputFile)
113{
114// parse ftplist html and extract just the machine names/directories
115// TODO: add locations!!
116 qDebug("parse ftplist "+outputFile);
117 QString ftpList, s_location;
118 QFile f( outputFile );
119
120 if( f.open( IO_ReadWrite )) {
121 QTextStream t( &f);
122 QString countryName;
123 bool b_gotchTest=false;
124
125 while ( !t.eof() ) {
126 QString s = t.readLine();
127 int start;
128 int end;
129 if( s.find( "FTP mirror sites for Project Gutenberg:", 0, TRUE) !=-1) { //lower end of this file
130 b_gotchTest = true;
131 }
132 if( b_gotchTest) {
133 if(( start = s.find( "ftp://", 0, TRUE))!=-1 ) {
134 end = s.find( "/\"", 0, TRUE);// ==-1)) {
135 if( end == -1) {
136 end = s.find( "\">");
137 }
138 ftpSite = s.mid( start, (end - start) );
139 if(ftpSite.right(1) != "/") {
140 // ftpSite += "/";
141 }
142 ftpSite=ftpSite.right( ftpSite.length()-6);
143 if( ftpSite.find("\n", 0, TRUE) )
144 ftpSite.remove( ftpSite.find("\n", 0, TRUE), 1);
145
146 if( ftpSite.find("\"", 0, TRUE) )
147 ftpSite.remove( ftpSite.find("\"", 0, TRUE), 1);
148 if( ftpSite.find("a>", 0, TRUE) )
149 ftpSite.remove( ftpSite.find("a>", 0, TRUE) -2, 4);
150
151
152 s = t.readLine();
153 s = t.readLine();
154 if(( start=s.find("<BR>(", 0, TRUE) ) != -1) {
155// qDebug("%s",s.latin1());
156 end = s.find( ")", 0, TRUE)+1;
157 s_location= s.mid( start+4, (end - start) );
158
159// qDebug("%s", s_location.latin1());
160// ftpList += ftpSite + "\n";
161// ftp_QListBox_1->sort( TRUE );
162 ftpList += s_location+ " "+ftpSite+"\n";
163
164 ftp_QListBox_1->sort( TRUE );
165 QString winbug=" ";
166 ftp_QListBox_1->insertItem ( s_location.latin1() +winbug+ftpSite);
167 // ftp_QListBox_1->insertItem ( ftpSite+" "+s_location.latin1());
168 }
169
170 // ftp_QListBox_1->insertItem ( ftpSite);
171 }
172 } // end find ftp://
173
174 } // end while loop
175 QFile f2( ListFile);
176 if(!f2.open( IO_ReadWrite | IO_Truncate))
177 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n"+ListFile )) );
178 f2.writeBlock( ftpList, ftpList.length() );
179 f.close();
180 f2.close();
181 if( f.exists() )
182 f.remove();
183 } else {
184 QMessageBox::message( (tr("ftpSiteDlg")), (tr("List File not opened sucessfully." )) );
185 return false;
186 }
187 setActiveWindow();
188 return true;
189}
190
191void optionsDialog::openSiteList() {
192
193 qDebug(" just opens the ftp site list");
194// ListFile = ( QDir::homeDirPath ()) +"/.gutenbrowser/ftpList";
195 QFile f( ListFile);
196 if(!f.open( IO_ReadWrite )) {
197 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully." )) );
198 } else {
199 QTextStream t( &f);
200 while ( !t.atEnd() ) {
201 QString ftpSite = t.readLine();
202 ftp_QListBox_1->sort( TRUE );
203 ftp_QListBox_1->insertItem ( ftpSite);
204
205 } // end while loop
206 f.close();
207 }
208
209 QListBoxItem *itemSel=0;
210 if( (itemSel=ftp_QListBox_1->findItem( ftp_host)) )
211 ftp_QListBox_1->setSelected( itemSel, true);
212}
213
214/*
215List box clicked */
216void optionsDialog::getSelection( QListBoxItem *item)
217{
218 QString selctionStr;
219 selctionStr = item->text();
220// selctionStr = ftp_QListBox_1->currentText();
221// printf( selctionStr+"\n" );
222 select_site( selctionStr );
223}
224
225void optionsDialog::select_site( const char *index )
226{
227// ftp://ftp.datacanyon.com/pub/gutenberg/
228
229 s_site = index;
230 QString s_site2;
231// if(s_site.find("(",0,TRUE))
232 s_site2=s_site.right( s_site.length()-(s_site.find(" ",0,TRUE)+4) );
233qDebug("Selected ftp site is "+ s_site2);
234 int i_ftp = s_site2.find("/", 0, FALSE);
235 ftp_host = s_site2.left(i_ftp );
236 ftp_base_dir = s_site2.right( s_site2.length() - i_ftp);
237
238// config->read();
239 Config config("Gutenbrowser");
240 config.setGroup( "FTPsite" );
241 config.writeEntry("SiteName",ftp_host);
242 config.writeEntry("base",ftp_base_dir);
243// config->write();
244 TextLabel3->setText( "Current ftp server:\n"+ftp_host /*+ ftp_base_dir*/ );
245// optionsDialog::accept();
246}
247
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
new file mode 100644
index 0000000..2a9a71e
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
@@ -0,0 +1,1984 @@
1/***************************************************************************
2 gutenbrowser.cpp - description
3 -------------------
4 begin : Mon Jul 24 22:33:12 MDT 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7* This program is free software; you can redistribute it and/or modify *
8* it under the terms of the GNU General Public License as published by *
9* the Free Software Foundation; either version 2 of the License, or *
10* (at your option) any later version. *
11***************************************************************************/
12// http search
13// http://digital.library.upenn.edu/books/authors.html
14// http://digital.library.upenn.edu/books/titles.html
15// ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL
16// donate@gutenberg.net
17#include <qpe/qpeapplication.h>
18#include <qpe/fontdatabase.h>
19#include <qpe/config.h>
20#include <qpe/qcopenvelope_qws.h>
21#include <qpe/mimetype.h>
22#include <qpe/resource.h>
23#include <qpe/applnk.h>
24
25#include "editTitle.h"
26#include "gutenbrowser.h"
27#include "LibraryDialog.h"
28 //#include "bookmarksdlg.h"
29#include "optionsDialog.h"
30#include "helpme.h"
31#include "NetworkDialog.h"
32
33#include "openetext.h"
34#include "output.h"
35
36
37#include <qregexp.h>
38#include <qregion.h>
39#include <qpaintdevicemetrics.h>
40#include <qvaluelist.h>
41#include <qlabel.h>
42#include <qclipboard.h>
43#include <qpainter.h>
44#include <qpalette.h>
45#include <qobjectlist.h>
46#include <qfontdialog.h>
47#include <qtextview.h>
48#include <qbrush.h>
49#include <qfile.h>
50#include <qfontinfo.h>
51#include <qscrollview.h>
52#include <qpoint.h>
53
54#include <stdio.h>
55#include <stdlib.h>
56#include <unistd.h>
57#include <sys/stat.h>
58#include <fcntl.h>
59#include <errno.h>
60
61static const int nfontsizes = 9;
62static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24};
63
64#ifdef NOQUICKLAUNCH
65Gutenbrowser::Gutenbrowser()
66 Gutenbrowser();
67#else
68Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
69#endif
70 : QMainWindow()
71 {
72 // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
73 // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" );
74 // e << "";
75 // QPEApplication::grabKeyboard();
76 showMainList=TRUE;
77 working=false;
78 this->setUpdatesEnabled(TRUE);
79 // #ifndef Q_WS_QWS
80 QString msg;
81 msg="You have now entered unto gutenbrowser,\n";
82 msg+="make your self at home, sit back, relax and read something great.\n";
83
84 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
85 setCaption("Gutenbrowser");// Embedded " VERSION);
86 this->setUpdatesEnabled(TRUE);
87
88 // bool firstTime=FALSE;
89 topLayout = new QVBoxLayout( this, 0, 0, "topLayout");
90
91 menu = new QHBoxLayout(-1,"menu");
92 buttons2 = new QHBoxLayout(-1,"buttons2");
93 edits = new QHBoxLayout(-1,"edits");
94
95 useSplitter=TRUE;
96
97 initConfig();
98 initMenuBar();
99 initButtonBar();
100 initStatusBar();
101 initView();
102 initSlots();
103
104 QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold);
105
106 connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)),
107 this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) );
108 if( useIcons)
109 toggleButtonIcons( TRUE);
110 else
111 toggleButtonIcons( FALSE);
112
113 enableButtons(false);
114
115 Config config("Gutenbrowser"); // populate menubuttonlist
116 config.setGroup("General");
117
118 config.setGroup( "Files" );
119 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
120 int i_numofFiles = s_numofFiles.toInt();
121
122 QString tempFileName;
123
124 for (int i = 0; i <= i_numofFiles; i++) {
125 // tempFileName.setNum(i);
126 config.setGroup( "Files" );
127 QString ramble = config.readEntry( QString::number(i), "" );
128
129 config.setGroup( "Titles" );
130 QString tempTitle = config.readEntry( ramble, "");
131 config.setGroup( tempTitle);
132 int index=config.readNumEntry( "LineNumber", -1 );
133 if( index != -1) {
134 // qDebug( tempTitle);
135 bookmarksMenu->insertItem( tempTitle);
136 }
137 }
138
139 // QString gutenIndex= local_library + "GUTINDEX.ALL";
140 QString gutenIndex= QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL";
141
142 if( QFile( gutenIndex).exists() ) {
143 indexLib.setName( gutenIndex);
144 } else {
145 QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT";
146 // QString localLibIndexFile= local_library + "PGWHOLE.TXT";
147 newindexLib.setName( localLibIndexFile);
148 }
149 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */);
150 loadCheck=false;
151 chdir(local_library);
152 if(!showMainList) {
153 Lview->setFocus();
154 // if(firstTime)
155 // Bookmark();
156 for (int i=1;i< qApp->argc();i++) {
157 qDebug("Suppose we open somethin");
158 load(qApp->argv()[i]);
159 }
160 } else {
161 fillWithTitles();
162 mainList->setFocus();
163 // mainList->setCurrentItem(0);
164
165 }
166 writeConfig();
167} //end init
168
169Gutenbrowser::~Gutenbrowser() {
170 // QPEApplication::grabKeyboard();
171 // QPEApplication::ungrabKeyboard();
172 qDebug("Exit");
173}
174
175 /*
176 Google.com search */
177void Gutenbrowser::InfoBarClick() {
178 QString text;
179 if( Lview->hasSelectedText()) {
180 Lview->copy();
181 QClipboard *cb = QApplication::clipboard();
182 text = cb->text();
183 } else {
184 // text=title;
185 text=this->caption();
186 }
187 searchGoogle(text);
188}
189
190 /*
191 download http with wget or preferred browser */
192void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
193 // int eexit=0;
194 QString cmd;
195 // config.read();
196 qApp->processEvents();
197 QString filename = QPEApplication::qpeDir();
198 if(filename.right(1)!="/")
199 filename+="/etc/gutenbrowser/";
200 else
201 filename+="etc/gutenbrowser/";
202 qDebug("filename "+filename);
203 // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/";
204
205 filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1);
206
207 Config config("Gutenbrowser");
208 config.setGroup( "Browser" );
209 QString brow = config.readEntry("Preferred", "Opera");
210 qDebug("Preferred browser is "+brow);
211 if(!showMsg) { //if we just get the gutenindex.all
212 cmd="wget -O " + filename +" " + url+" 2>&1" ;
213 chdir(local_library);
214 qDebug("Issuing the system command: %s", cmd.latin1());
215
216 Output *outDlg;
217 outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE);
218 outDlg->showMaximized();
219 outDlg->show();
220 qApp->processEvents();
221 FILE *fp;
222 char line[130];
223 outDlg->OutputEdit->append( tr("Running wget") );
224 sleep(1);
225 fp = popen( (const char *) cmd, "r");
226 // qDebug("Issuing the command\n"+cmd);
227 // system(cmd);
228 while ( fgets( line, sizeof line, fp)) {
229 outDlg->OutputEdit->append(line);
230 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
231 }
232 pclose(fp);
233 outDlg->close();
234 if(outDlg)
235 delete outDlg;
236 } else {
237 if( brow == "Konq") {
238 cmd = "konqueror "+url+" &";
239 }
240 if( brow == "Opera") { //for desktop testing
241 cmd = "opera "+url+" &";
242 }
243 // if( brow == "Opera") { // on Zaurus
244 // cmd = "operagui "+url+" &";
245 // }
246 if( brow == "Mozilla") {
247 cmd = "mozilla "+url+" &";
248 }
249 if( brow == "Netscape") {
250 cmd = "netscape "+url+" &";
251 }
252 if(brow == "wget") {
253 // cmd="wget -q "+url+" &";
254 QString tempHtml=local_library+"webster.html";
255 cmd="wget -O "+tempHtml+" -q "+url;
256 }
257
258 chdir(local_library);
259 qDebug("Issuing the sys command: %s", cmd.latin1());
260 system(cmd);
261 }
262}
263
264void Gutenbrowser::toggleButtonIcons( bool useEm) {
265 QString pixDir;
266 if(useEm)
267 useEm=TRUE;
268 pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser";
269 qDebug("Docdir is "+QPEApplication::documentDir());
270
271 if( useIcons && QDir( pixDir).exists() ) {
272 LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline
273 OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook"));
274 ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline
275 BackButton->setPixmap( Resource::loadPixmap("back") );//in inline
276 SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline
277 lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder"));
278 setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") );
279 dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") );
280 InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google"));
281 }
282}
283
284
285bool Gutenbrowser::queryExit()
286{
287 int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?",
288 QMessageBox::Ok, QMessageBox::Cancel);
289 if (exit==1) {
290 writeConfig();
291 qApp->quit();
292 } else {
293 };
294 return (exit==1);
295}
296
297 // SLOT IMPLEMENTATION
298
299void Gutenbrowser::slotFilePrint() {
300}
301
302void Gutenbrowser::ByeBye() {
303 if (b_queryExit)
304 queryExit();
305 else {
306 // writeConfig();
307 qApp->quit();
308 }
309}
310
311void Gutenbrowser::HelpBtn() {
312 HelpMe* HelpDlg;
313 HelpDlg = new HelpMe( this, "Help Dialog");
314 HelpDlg->showMaximized();
315}
316
317void Gutenbrowser::DownloadIndex() {
318#ifndef Q_WS_QWS
319 {
320 switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")),
321 (tr("Do you want to download the newest\n"
322 "Project Gutenberg Library Index?\n"
323 "or select an ftp site?\n")),
324 (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) )
325 {
326 case 0: // index clicked,
327 downloadLibIndex();
328 break;
329
330 case 1: // ftp selected
331 downloadFtpList();
332 break;
333
334 case 2: // Cancel
335 break;
336 };
337 }
338#endif
339} // end DownloadIndex
340
341
342void Gutenbrowser::downloadFtpList() {
343 // QString cmd="wget http://www.promo.net/pg/list.html");
344 //system(cmd);
345 qApp->processEvents();
346 optionsDialog* optDlg;
347 optDlg = new optionsDialog( this,"Options_Dlg", true);
348 optDlg->getSite();
349 if(optDlg)
350 delete optDlg;
351}
352
353
354void Gutenbrowser::downloadLibIndex() {
355 // QString dwmloader = local_library + "pgwhole.zip";
356 // QString cmd = "lynx -source http://www.gutenberg.net/pgwhole.zip | cat >> " + dwmloader;
357 // system(cmd);
358
359 // QString outputFile= local_library+ "GUTINDEX.ALL";
360 // config.setGroup( "FTPsite" ); // ftp server config
361 // ftp_host=config.readEntry("SiteName", "");
362 // ftp_base_dir= config.readEntry("base", "");
363 // QString networkUrl= "ftp://"+ftp_host+ftp_base_dir+"/GUTINDEX.ALL";
364 QDir dir( local_library);
365 dir.cd("", TRUE);
366 goGetit( "http://sailor.gutenberg.org/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3
367 // goGetit( "http://www.gutenberg.net/pgwhole.zip", true); // until ghttp works on binaries -qt3
368 // NetworkDialog *NetworkDlg;
369 // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, outputFile );
370 // if( NetworkDlg->exec() != 0 )
371 // { // use new, improved, *INSTANT* network-dialog-file-getterer
372 //// QMessageBox::message("Note","");
373 // }
374 // if(NetworkDlg)
375 // delete NetworkDlg;
376}
377
378
379void Gutenbrowser::PrintBtn() {
380}
381
382void Gutenbrowser::SearchBtn() {
383 if( loadCheck) {
384 qDebug("loadCheck: we have a loaded doc");
385 Search();
386 }
387 // else
388 // QMessageBox::message("Note","Sorry, can't search. No etext is loaded");
389}
390
391
392void Gutenbrowser::ForwardBtn() {
393
394 if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) {
395
396 QString s;
397 QString insertString;
398 int pageSize= Lview->PageSize();
399 Lview->clear();
400
401 for(int fd=0; fd < pageSize - 1;fd++) {
402 f.readLine(s, 256);
403 if(useWrap)
404 s.replace(QRegExp("\n"),"");
405 insertString+=s;
406 Lview->insertLine( s, -1);
407 // qDebug(s);
408 currentLine++;
409 }
410 // Lview->insertAt( insertString,0,0, FALSE);
411 currentFilePos = f.at();
412 // if( i_pageNum != pages) {
413 // Lview->MultiLine_Ex::pageDown( FALSE);
414 i_pageNum++;
415 pageStopArray.resize(i_pageNum + 1);
416 // int length = Lview->length();
417
418 pageStopArray[i_pageNum ] = currentFilePos;
419 // qDebug("%d current page is number %d, pagesize %d, length %d, current %d",
420 // currentFilePos, i_pageNum, pageSize, Lview->length(), pageStopArray[i_pageNum] );
421 setStatus();
422 Lview->setCursorPosition( 0, 0, FALSE);
423 // }
424
425 } else {
426 // qDebug("bal");
427 // if( i_pageNum != pages) {
428
429 // // int newTop = Lview->Top();
430 // // if(Lview->lastRow() > i)
431 // Lview->ScrollUp(1);
432 // // i_pageNum++;
433 // setStatus();
434 // Lview->setCursorPosition( Lview->Top(), 0, FALSE);
435
436 // }
437
438 }
439 Lview->setFocus();
440
441 // qDebug("page number %d line number %d", i_pageNum, currentLine);
442}
443
444
445void Gutenbrowser::BackBtn() {
446 if( i_pageNum > 0) {
447 int pageSize= Lview->PageSize();
448 // int length=Lview->length();
449
450 i_pageNum--;
451 currentFilePos = f.at();
452
453 // qDebug("%d move back to %d, current page number %d, %d, length %d",
454 // currentFilePos, pageStopArray[i_pageNum - 1 ], i_pageNum, pageSize, Lview->length() );
455
456 if( i_pageNum < 2) {
457 f.at( 0);
458 } else {
459 if(!f.at( pageStopArray[i_pageNum - 1] ))
460 qDebug("File positioned backward did not work");
461 }
462 QString s;
463 // int sizeLine=0;
464 Lview->clear();
465 // QString insertString;
466
467 for(int fd = 0; fd < pageSize ;fd++) {
468 // Lview->removeLine( Lview->PageSize() );
469 f.readLine(s, 256);
470 if(useWrap)
471 s.replace(QRegExp("\n"),"");
472 currentLine++;
473 // insertString+=s;
474 Lview->insertLine( s, -1);
475 }
476
477 // Lview->insertAt( insertString,0,0, FALSE);
478
479 if( !BackButton->autoRepeat() && !BackButton->isDown()) {
480 QString topR;
481 QString lastR;
482 QString pageR;
483 // int sizer = Lview->lastRow() - Lview->topRow();
484 // int i_topRow = Lview->topRow();
485 if( i_pageNum < 1)
486 i_pageNum = 1;
487 setCaption(QString::number(i_pageNum));
488 } else {
489 // int newTop = Lview->Top();
490 // if(Lview->lastRow() > i)
491 Lview->MultiLine_Ex::pageUp( FALSE);
492 // Lview->ScrollDown(1);
493 // i_pageNum--;
494 if( i_pageNum < 1)
495 i_pageNum = 1;
496 setStatus();
497 Lview->setCursorPosition( Lview->Top(), 0, FALSE);
498
499 }
500 }
501 Lview->setFocus();
502}
503
504void Gutenbrowser::doBeginBtn() {
505 if(loadCheck) {
506 qApp->processEvents();
507 BeginBtn();
508 }
509}
510
511 // moves text to the very top = 0
512void Gutenbrowser::TopBtn() {
513
514 if(loadCheck) {
515 if( i_pageNum != 0) {
516 qDebug("top");
517 qApp->processEvents();
518 currentLine = 0;
519 i_pageNum = 1;
520 int pageSize = Lview->PageSize() ;
521 Lview->clear();
522 QString s;
523 f.at(0);
524 for(int fd=0; fd < pageSize ;fd++) {
525 f.readLine(s, 256);
526 if(useWrap)
527 s.replace(QRegExp("\n"),"");
528 Lview->insertLine(s ,-1);
529 currentLine++;
530 }
531 Lview->setCursorPosition( 0,0, FALSE);
532 i_pageNum=1;
533 setStatus();
534 }
535 Lview->setFocus();
536 }
537}
538
539 //moves text to the start of the EText
540void Gutenbrowser::BeginBtn() {
541 i_pageNum = 1;
542 currentLine = 0;
543 QString s_pattern="*END*THE SMALL PRINT";
544 QString sPattern2 = "*END THE SMALL PRINT";
545
546 int pageSize = Lview->PageSize();
547 Lview->clear();
548
549 // int lines = Lview->numLines();
550 int pos = 0;//, i = 0;
551 int i_topRow = Lview->topRow();
552
553 QString LeftText;// = Lview->text();
554
555 int linesPerPage = Lview->lastRow() - Lview->topRow();
556 // int pages = (( linesPerPage / Lview->editSize() ) ) +1;
557 // int pageN = 0;
558 i_pageNum = 1;
559 int lastPage=1;
560 int lineNo=0;
561 QString s;
562 f.at( 0);
563
564 while ( !f.atEnd() ) {
565 f.readLine(s, 256);
566 lineNo++;
567 LeftText = s;
568 currentFilePos = f.at();
569
570 i_pageNum = lineNo/pageSize;
571 if(lastPage < i_pageNum) {
572 pageStopArray.resize(i_pageNum + 1);
573 pageStopArray[i_pageNum ] = currentFilePos;
574 // qDebug("new page number %d, found at %d", i_pageNum, currentFilePos);
575 }
576 // lastPage = i_pageNum;
577 if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) {
578 qDebug("<<<<<< FOUND IT!! new page number %d, found at %d", i_pageNum, currentFilePos);
579 break;
580 }
581 }
582 if(f.atEnd()) //in case we didnt find anything, we need to show something
583 f.at(0);
584 Lview->clear();
585 for(int fd=0; fd < pageSize - 1;fd++) {
586 f.readLine(s, 256);
587 if(useWrap)
588 s.replace(QRegExp("\n"),"");
589 Lview->insertLine( s, -1);
590 currentLine++;
591 }
592
593 i_pageNum = lineNo/pageSize;
594 pageStopArray.resize(i_pageNum + 1);
595 // int length = Lview->length();
596
597 qApp->processEvents();
598
599 if( pos > i_topRow ) {
600 Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE);
601 } else {
602 Lview->setCursorPosition( pos+2 , 0, FALSE );
603 }
604
605 Lview->deselect();
606 // AdjustStatus();
607 Lview->setFocus();
608}
609
610 /*
611 sets the current page and place as a bookmark*/
612void Gutenbrowser::setBookmark() {
613 int eexit=QMessageBox::information(this, "Note",
614 "Do you really want to \nset this bookmark?."
615 ,QMessageBox::Yes, QMessageBox::No);
616 if (eexit== 3) {
617
618 currentFilePos = f.at();
619
620 Config cfg("Gutenbrowser");
621 cfg.setGroup("General");
622 file_name=cfg.readEntry("Current","");
623 qApp->processEvents();
624 qDebug("Settingbook mark "+file_name);
625
626 cfg.setGroup("Titles");
627 title=cfg.readEntry(file_name,"");
628 qDebug("title is "+ title);
629
630 cfg.setGroup( "Bookmarks" );
631
632 cfg.writeEntry("File Name",file_name);
633 cfg.writeEntry("Page Number",QString::number(i_pageNum) );
634 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1]));
635 cfg.writeEntry("Title", title);
636
637 int row = Lview->topRow();// Lview->Top();
638 cfg.writeEntry("LineNumber",QString::number(row) );
639
640 cfg.setGroup(title);
641 cfg.writeEntry("File Name",file_name);
642 cfg.writeEntry( "LineNumber", QString::number( row));
643 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1]));
644 cfg.writeEntry( "Page Number", QString::number( i_pageNum) );
645 bookmarksMenu->insertItem( title);
646 }
647} //end setBookmark
648
649
650 /* goes to last set bookmark*/
651void Gutenbrowser::Bookmark( int itemId) {
652
653 // qApp->processEvents();
654 Config config("Gutenbrowser");
655 config.setGroup( "Bookmarks" );
656
657 // qDebug("<<<<<< %d, %d", Lview->PageSize(), Lview->lastRow() - Lview->topRow() );
658
659 QString itemString;
660
661 qDebug("menu item %d", itemId);
662 QString tempTitle;
663 QString s_Bmrkrow;
664 QString s_pageNum;
665 int Bmrkrow=0;
666 int bookmarkPosition = 0;
667
668 // qApp->processEvents();
669 config.setGroup( "Bookmarks" );
670 title = config.readEntry("Title", "");
671 file_name = config.readEntry("File Name", "");
672 i_pageNum = config.readNumEntry("Page Number", 0);
673 bookmarkPosition = config.readNumEntry( "PagePosition",0);
674 Bmrkrow = config.readNumEntry("LineNumber",0);
675 if( !file_name.contains("/")) {
676 file_name = local_library + file_name;
677 }
678
679 // getTitle(file_name);
680 // qApp->processEvents();
681 // Lview->setFocus();
682 this->setFocus();
683
684 Lview->clear();
685
686 load(file_name);
687
688 int pageSize= Lview->PageSize();
689 f.at(0);
690 // Lview->clear();
691 QString s;
692 int lineNo=0;
693 int lastPage=1;
694 while ( !f.atEnd() ) {
695 f.readLine(s, 256);
696 lineNo++;
697 currentFilePos = f.at();
698
699 i_pageNum = lineNo/pageSize;
700 if(lastPage < i_pageNum) {
701 pageStopArray.resize(i_pageNum + 1);
702 pageStopArray[i_pageNum ] = currentFilePos;
703 // qDebug("new page number %d, found at %d", i_pageNum, currentFilePos);
704 }
705 if(currentFilePos == bookmarkPosition)
706 break;
707 }
708 if(f.atEnd())
709 f.at(0);
710 else
711 f.at( bookmarkPosition);
712
713 for(int fd=0; fd < pageSize - 1;fd++) {
714 f.readLine(s, 256);
715 lineNo++;
716 if(useWrap)
717 s.replace(QRegExp("\n"),"");
718 Lview->insertLine( s, -1);
719 currentLine++;
720 }
721
722 i_pageNum = lineNo/pageSize;
723 pageStopArray.resize(i_pageNum + 1);
724
725 if(showMainList) {
726 showMainList=FALSE;
727 mainList->hide();
728 Lview->show();
729 // qApp->processEvents();
730 }
731
732 qDebug("bookmark loaded");
733 setCaption(title);
734}
735
736
737bool Gutenbrowser::load( const char *fileName) {
738
739 // QCopEnvelope ( "QPE/System", "busy()" );
740 // qDebug("Title is already set as "+title);
741 qDebug("sizeHint %d pageSize %d", sizeHint().height(),Lview->PageSize() );
742 if( Lview->PageSize() < 4) {
743
744 Lview->setMaximumHeight( sizeHint().height() );
745 Lview->setMinimumHeight( sizeHint().height() );
746 pointSize = Lview->fontInfo().pointSize();
747 qDebug("sizeHint %d point size %d", sizeHint().height(), pointSize);
748 if(pointSize < 10)
749 Lview->setFixedVisibleLines(19);
750 else
751 Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2);
752 }
753
754 Config cfg("Gutenbrowser");
755 cfg.setGroup("General");
756 cfg.writeEntry("Current",fileName);
757 currentLine=0;
758
759 file_name=fileName;
760 QString o_file = fileName;
761
762 // if (i_pageNum < 1) {
763 i_pageNum = 1;
764 // }
765 qDebug("ready to open "+o_file);
766
767 if(f.isOpen()) f.close();
768 f.setName( o_file);
769
770 if ( !f.open( IO_ReadOnly)) {
771 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) );
772 return false;
773 }
774 currentFilePos = 0;
775 pageStopArray.resize(3);
776 pageStopArray[0] = currentFilePos;
777
778 fileHandle = f.handle();
779 QString insertString;
780 QTextStream t(&f);
781 QString s;
782 for(int fd=0; fd < Lview->PageSize() ;fd++) {
783 s=t.readLine();
784 // insertString+=s;
785 if(useWrap)
786 s.replace(QRegExp("\n"),"");
787 // s.replace(QRegExp("\r"),"");
788 Lview->insertLine( s,-1);
789 currentLine++;
790 }
791
792 // int length = Lview->length();
793 currentFilePos = f.at();
794
795 pageStopArray[1] = currentFilePos;
796
797 qDebug("<<<<<<<<<<<%d current page is number %d, length %d, current %d, pageSize %d",
798 currentFilePos, i_pageNum, Lview->length(), pageStopArray[i_pageNum], Lview->PageSize() );
799
800 Lview->setMaxLines(Lview->PageSize()*2);
801 qDebug("Gulped %d", currentLine);
802 setCaption(title);
803 Lview->setAutoUpdate( TRUE);
804
805 Lview->setCursorPosition(0,0,FALSE);
806
807 // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1;
808 //qDebug("number of pages %d", pages);
809
810 loadCheck = true;
811 enableButtons(true);
812 if( donateMenu->count() == 3) {
813 donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() ));
814 }
815 Lview->setFocus();
816
817 // QCopEnvelope("QPE/System", "notBusy()" );
818 return true;
819} // end load
820
821void Gutenbrowser::Search() {
822
823 // if( searchDlg->isHidden())
824 {
825 qDebug("Starting search dialog");
826 searchDlg = new SearchDialog( this, "Etext Search", true);
827 searchDlg->setCaption( tr( "Etext Search" ));
828 // searchDlg->setLabel( "- searches etext");
829 connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot()));
830 connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot()));
831
832 QString resultString;
833 QString string = searchDlg->searchString;
834 Lview->deselect();
835 searchDlg->show();
836 searchDlg->result();
837 }
838}
839
840void Gutenbrowser::search_slot( ) {
841 int line, col;
842 if (!searchDlg /*&& !loadCheck */)
843 return;
844
845 Lview->getCursorPosition(&line,&col);
846 QString to_find_string=searchDlg->get_text();
847
848 // searchDlg->get_direction();// is true if searching backward
849 if ( last_search != 0 && searchDlg->get_direction() ){
850 col = col - pattern.length() - 1 ;
851 }
852 again:
853 int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col);
854 if(result == 0){
855 if(!searchDlg->get_direction()){ // forward search
856 int query = QMessageBox::information( searchDlg, "Find",
857 "End of document reached.\nContinue from the beginning?",
858 "Yes", "No", "", 0,1);
859 if (query == 0){
860 line = 0;
861 col = 0;
862 goto again;
863 }
864 } else { //backward search
865 int query = QMessageBox::information( searchDlg, "Find",
866 "End of document reached.\nContinue from the beginning?",
867 "Yes", "No", "", 0,1);
868 if (query == 0){
869 QString string = Lview->textLine( Lview->numLines() - 1 );
870 line = Lview->numLines() - 1;
871 lineCheck = line;
872 col = string.length();
873 last_search = -1; //BACKWARD;
874 goto again;
875 }
876 }
877 } else {
878
879 //// emit CursorPositionChanged(); textLine
880 }
881}
882
883int Gutenbrowser::doSearch( const QString &s_pattern , bool case_sensitive, bool forward, int line, int col ) {
884 int i, length;
885 int pos = -1;
886 if(forward) {
887 QString string;
888 for(i = line; i < Lview->numLines(); i++) {
889
890 string = Lview->textLine(i);
891 pos = string.find(s_pattern, i == line ? col : 0, case_sensitive);
892 if( pos != -1) {
893 int top = Lview->Top();
894 length = s_pattern.length();
895 if( i > Lview->lastRow() ) {
896 Lview->setCursorPosition(i,pos,FALSE);
897 for(int l = 0 ; l < length; l++) {
898 Lview->cursorRight(TRUE);
899 }
900 Lview->setCursorPosition( i , pos + length, TRUE );
901 int newTop = Lview->Top();
902 if(Lview->lastRow() > i)
903 Lview->ScrollUp( newTop - top);
904 // AdjustStatus();
905 } else {
906 Lview->setCursorPosition(i,pos,FALSE);
907 for(int l = 0 ; l < length; l++) {
908 Lview->cursorRight(TRUE);
909 }
910 Lview->setCursorPosition( i , pos + length, TRUE );
911 // AdjustStatus();
912 }
913 pattern = s_pattern;
914 last_search = 1; //FORWARD;
915 return 1;
916 }
917 }
918 } else { //////////////// searching backwards
919 QString string;
920 for( i = line; i >= 0; i--) {
921 string = Lview->textLine(i);
922 int line_length = string.length();
923 pos = string.findRev(s_pattern, line == i ? col : line_length , case_sensitive);
924 if (pos != -1) {
925 // int top = Lview->Top();
926 length = s_pattern.length();
927 if( i < Lview->Top() ) {
928 Lview->ScrollDown( Lview->PageSize() );
929 Lview->MultiLine_Ex::pageUp( FALSE );
930 if( ! (line == i && pos > col ) ) {
931 Lview->setCursorPosition( i ,pos ,FALSE );
932 for(int l = 0 ; l < length; l++) {
933 Lview->cursorRight(TRUE);
934 }
935 Lview->setCursorPosition(i ,pos + length ,TRUE );
936 // int newTop = Lview->Top();
937 /* if(useSplitter) Rview->ScrollUp( newTop - top);
938 */ }
939 } else {
940 if( ! (line == i && pos > col ) ) {
941 Lview->setCursorPosition( i, pos, FALSE );
942 for( int l = 0 ; l < length; l++) {
943 Lview->cursorRight( TRUE);
944 }
945 Lview->setCursorPosition( i, pos + length, TRUE );
946 }
947 pattern = s_pattern;
948 last_search = -1;
949 return 1;
950 }
951 }
952 }
953 }
954 return 0;
955}
956
957void Gutenbrowser::LibraryBtn() {
958
959 QString newestLibraryFile ="pgwhole.zip";
960 QString zipFile;
961 // qDebug("Local Library is %s ", local_library.latin1());
962 zipFile="/usr/bin/unzip";
963 // qDebug("newestLibraryFile is %s ", newestLibraryFile.latin1());
964 if( QFile::exists( local_library+newestLibraryFile)) {
965 if( QFile::exists(zipFile) ) {
966 UnZipIt(newestLibraryFile);
967 }
968 else
969 QMessageBox::message( "Note",( tr("Please install unzip")) );
970 }
971 // LibraryDlg = new LibraryDialog( this, "Library Index");
972 LibraryDlg->setCaption( tr( "Gutenberg Library"));
973 Config config("Gutenbrowser");
974 config.setGroup("General");
975 QString tmp=config.readEntry("RunBefore","FALSE");
976 if(tmp=="FALSE") {
977 QMessageBox::message( "Note",
978 "<P>Your first time running gutenbrowser. You'll need to click the \"load library\" button to load the gutenberg index.</P>");
979 config.writeEntry("RunBefore","TRUE");
980 }
981 if(useSplitter)
982 LibraryDlg->useSmallInterface=FALSE;
983
984 LibraryDlg->showMaximized();
985
986 if( LibraryDlg->exec() != 0 ) {
987 listItemNumber = LibraryDlg->DlglistItemNumber;
988 listItemFile = LibraryDlg->DlglistItemFile;
989 listItemYear = LibraryDlg->DlglistItemYear;
990 listItemTitle = LibraryDlg->DlglistItemTitle;
991 file_name = LibraryDlg->File_Name;
992 // qDebug("title is being set as "+title);
993 title = listItemTitle;
994
995 // config.setGroup( "Proxy" );
996 // if( LibraryDlg->checked == 1) {
997 // config.writeEntry("IsChecked", "TRUE");
998 // } else {
999 // config.writeEntry("IsChecked", "FALSE");
1000 // }
1001 // config.write();
1002 // config.read();
1003 if ( listItemNumber.isNull()) {
1004 } else {
1005 i_pageNum = 1;
1006 if( file_name !="Error" && file_name.length() >2 && !file_name.isEmpty() ) {
1007 //replace .zip with txt for opening it.
1008 // printf("\nFile name is now\n");
1009 // printf(file_name);
1010 // printf("\n");
1011 //
1012 if( file_name.find(".zip"))
1013 {
1014 qDebug("Found zip file\n");
1015 // QStringList args;
1016 // args="unzip";
1017 // args+="-o";
1018 // args+=local_library+file_name;
1019 // args+="-d";
1020 // args+=local_library;
1021 QString cmd = "/usr/bin/unzip -o " + local_library+file_name + " -d " + local_library;
1022 qDebug("Issuing the command "+ cmd);
1023 // unzipProc=new QProcess( this, "unzipProc" ); /// fark that idea!
1024 // unzipProc->start();
1025 system(cmd);
1026 remove( file_name);
1027
1028 }
1029 // //
1030 // file_name = file_name.left(4)+ ".txt";
1031 if( LibraryDlg)
1032 delete LibraryDlg;
1033 setTitle();
1034 // QCopEnvelope ( "QPE/System", "busy()" );
1035 load( file_name);
1036 } else {
1037 printf("Not opening the file.\n");
1038 }
1039 }
1040 }
1041 if(showMainList) {
1042 if(!Lview->isHidden())
1043 Lview->hide();
1044 qApp->processEvents();
1045 showMainList=TRUE;
1046 if(mainList->isHidden())
1047 mainList->show();
1048 fillWithTitles();
1049 qApp->processEvents();
1050 } else
1051 setCentralWidget( Lview);
1052 // QPEApplication::grabKeyboard();
1053 // fixKeys();
1054}
1055
1056void Gutenbrowser::OpenBtn() {
1057 QString s_temp;
1058 s_temp = status;
1059 OpenEtext* OpenDlg;
1060 OpenDlg = new OpenEtext(this,"OpenDlg");
1061 OpenDlg->showMaximized();
1062
1063 if( OpenDlg->exec() != 0) {
1064 title = OpenDlg->openFileTitle;
1065 qDebug("title open as "+title);
1066 file_name = OpenDlg->file;
1067 i_pageNum = 1;
1068
1069 if( !file_name.isEmpty() || file_name.length() > 2 ) {
1070 if(showMainList) {
1071 showMainList=FALSE;
1072 qDebug("ShowMainList is now false");
1073 mainList->hide();
1074 Lview->show();
1075 qApp->processEvents();
1076 }
1077 Lview->clear();
1078 // QCopEnvelope ( "QPE/System", "busy()" );
1079 load(file_name);
1080 } else {
1081 qDebug("file_name is empty!");
1082 if(showMainList) {
1083 if(!Lview->isHidden())
1084 Lview->hide();
1085 qApp->processEvents();
1086 if(mainList->isHidden())
1087 mainList->show();
1088 fillWithTitles();
1089 qApp->processEvents();
1090 }
1091
1092 }
1093 }
1094 if( OpenDlg)
1095 delete OpenDlg;
1096 /*
1097 Config config("Gutenbrowser");
1098 config.setGroup( title);
1099 file_name = config.readEntry("File Name", "");
1100 i_pageNum = config.readNumEntry("Page Number", -1);
1101 int Bmrkrow = config.readNumEntry("LineNumber", -1);
1102 if(Bmrkrow > -1) {
1103 if( Bmrkrow > Lview->topRow() ) {
1104 Lview->setCursorPosition( Bmrkrow ,0, FALSE );
1105 Lview->ScrollUp( Bmrkrow - Lview->topRow() );
1106 // AdjustStatus();
1107 }
1108 else if( Bmrkrow < Lview->topRow() ) {
1109 Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE );
1110 Lview->ScrollDown( Lview->topRow() - Bmrkrow );
1111 // AdjustStatus();
1112 }
1113 }
1114 */
1115 // ResizeEdits();
1116
1117}
1118
1119void Gutenbrowser::ChangeFont() {
1120#ifndef Q_WS_QWS
1121 bool ok;
1122
1123 weight= Lview->fontInfo().weight();
1124 italic = Lview->fontInfo().italic();
1125 bold=Lview->fontInfo().bold();
1126 pointSize= Lview->fontInfo().pointSize();
1127 fontStr=Lview->fontInfo().family();
1128
1129 if(italic == true)
1130 italicStr="TRUE";
1131 else
1132 italicStr="FALSE";
1133
1134 QFont currentfont( fontStr, pointSize, weight, italic );
1135
1136 if (ok) {
1137 QFontInfo fontInfo(font );
1138 fontStr=fontInfo.family();
1139
1140 pointSize= fontInfo.pointSize();
1141
1142 font.setFontSize(pointSize);
1143
1144 pointSizeStr.setNum( pointSize);
1145
1146 weight= fontInfo.weight();
1147 weightStr.setNum( weight);
1148 italic =fontInfo.italic();
1149 bold=fontInfo.bold();
1150
1151 if(italic == true)
1152 italicStr="TRUE";
1153 else
1154 italicStr="FALSE";
1155 if(bold == true)
1156 boldStr="TRUE";
1157 else
1158 boldStr="FALSE";
1159
1160 pointSizeStr.setNum( pointSize);
1161 config.setGroup( "Font" );
1162 config.writeEntry("Family", fontStr );
1163 config.writeEntry("Size", pointSizeStr );
1164 config.writeEntry("Weight", weightStr );
1165 config.writeEntry("Italic", italicStr );
1166 config.writeEntry("Bold", boldStr );
1167 // config.write();
1168
1169 Lview->setFont(font);
1170
1171 QRect lRect;
1172 QRect rRect;
1173 lRect = Lview->rect();
1174 if(useSplitter) {
1175 }
1176 // if(loadCheck) {
1177 // ResizeEdits();
1178 // }
1179 update();
1180 }
1181#endif
1182}
1183
1184
1185 /*
1186 performs dictionary look ups on the web */
1187void Gutenbrowser::LookupBtn() {
1188 QString text;
1189 if( Lview->hasSelectedText()) {
1190 Lview->copy();
1191 }
1192 QClipboard *cb = QApplication::clipboard();
1193 text = cb->text();
1194 int eexit=QMessageBox::information(this,
1195 "Note","Do you want to lookup\n\""+text+"\"\non websters web dictionary?",
1196 QMessageBox::Yes, QMessageBox::No);
1197 if (eexit== 3) {
1198 // this link for sale!!
1199 qApp->processEvents();
1200 goGetit( "http://www.m-w.com/cgi-bin/dictionary?" + text, true);
1201 }
1202}
1203
1204void Gutenbrowser::ClearEdit() {
1205 Lview->setText("");
1206 loadCheck = false;
1207 status = ( tr("Gutenbrowser"));
1208 InfoBar->setText( "");
1209 setCaption( tr("Gutenbrowser"));
1210 i_pageNum = 0;
1211 enableButtons(false);
1212
1213 if(!showMainList) {
1214 Lview->hide();
1215 showMainList=TRUE;
1216 mainList->show();
1217 fillWithTitles();
1218 qApp->processEvents();
1219 }
1220 if(donateMenu->idAt(3) != -1)
1221 donateMenu->removeItemAt(3);
1222}
1223
1224
1225bool Gutenbrowser::getTitle( const char *file ) {
1226 QString s_file;
1227 QString filer = file;
1228 if( filer.contains(local_library, TRUE)) {
1229 QFileInfo f(file);
1230 s_file = f.fileName();
1231 } else {
1232 s_file = filer;
1233 }
1234 Config config("Gutenbrowser");
1235 config.setGroup( "Files" );
1236 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
1237 int i_numofFiles = s_numofFiles.toInt();
1238
1239 for (int i = 1; i <= i_numofFiles; i++) {
1240 QString temp;
1241 temp.setNum(i);
1242 QString ramble = config.readEntry(temp, "" );
1243
1244 if( strcmp(ramble, s_file) == 0) {
1245 config.setGroup( "Titles" );
1246 title = config.readEntry(ramble, "");
1247 // qDebug("(getTitle)title is being set as "+title);
1248 }
1249 }
1250 return true;
1251}
1252
1253void Gutenbrowser::searchdone_slot() {
1254 // if (!searchDlg)
1255 // return;
1256 // searchDlg->hide();
1257 // Lview->setFocus();
1258 this->setFocus();
1259 last_search = 0;
1260 // ResizeEdits();
1261}
1262
1263 /*
1264 sets the status message */
1265bool Gutenbrowser::setStatus() {
1266
1267#ifndef Q_WS_QWS
1268 QString s_pages;
1269 s_pages.setNum( pages);
1270 QString chNum;
1271 statusTop = status.left( status.find(" ", TRUE) );
1272 status.append(chNum.setNum( i_pageNum));
1273 status += " / " + s_pages;
1274
1275 if(loadCheck) {
1276 statusBar->message( status);
1277 InfoBar->setText( title);
1278 } else {
1279 }
1280#else
1281 QString msg;
1282 msg.sprintf(title+" %d", i_pageNum);
1283 setCaption( msg);
1284#endif
1285 return true;
1286}
1287
1288void Gutenbrowser::keyReleaseEvent( QKeyEvent *e) {
1289 switch ( e->key() ) {
1290
1291 case Key_M:
1292 // Bookmark();
1293 break;
1294 case Key_D:
1295 DownloadIndex();
1296 break;
1297 case Key_L:
1298 LibraryBtn();
1299 break;
1300 case Key_O:
1301 OpenBtn();
1302 break;
1303 case Key_F:
1304 ForwardBtn();
1305 break;
1306 case Key_B:
1307 BackBtn();
1308 break;
1309 case Key_P:
1310 PrintBtn();
1311 break;
1312 case Key_S:
1313 SearchBtn();
1314 break;
1315 case Key_E:
1316 ByeBye();
1317 break;
1318 case Key_R:
1319 // setBookmark();
1320 break;
1321 case Key_T:
1322 ChangeFont();
1323 break;
1324 case Key_C:
1325 ClearEdit();
1326 break;
1327 case Key_H:
1328 HelpBtn();
1329 break;
1330 case Key_K:
1331 LookupBtn();
1332 break;
1333 case Key_U:// hide menu
1334 if(menubar->isHidden() )
1335 menubar->show();
1336 else
1337 menubar->hide();
1338 break;
1339 case Key_I:
1340 hideButtons();
1341 break;
1342 ////////////////////////////// Zaurus keys
1343 case Key_Home:
1344 // BeginBtn();
1345 break;
1346 case Key_F9: //activity
1347 OpenBtn();
1348 break;
1349 case Key_F10: //contacts
1350 hideButtons();
1351 break;
1352 case Key_F11: //menu
1353 if(menubar->isHidden() )
1354 menubar->show();
1355 else
1356 menubar->hide();
1357 break;
1358 case Key_F12: //home
1359 BeginBtn();
1360 break;
1361 case Key_F13: //mail
1362 LibraryBtn();
1363 break;
1364 case Key_Space:
1365 if(loadCheck)
1366 ForwardBtn();
1367 // else
1368 // Bookmark();
1369 break;
1370 case Key_Down:
1371 if(loadCheck) {
1372 // if( !e->isAutoRepeat() )
1373 // AdjustStatus();
1374 // } else {
1375 // LibraryBtn();
1376 // ForwardBtn();
1377 }
1378
1379 // ForwardButton->setFocus();
1380 // Lview->setFocus();
1381 // if(s_Wrap=="FALSE")
1382 // Lview->MultiLine_Ex::ScrollDown( 1);
1383 // LibraryBtn();
1384 break;
1385 case Key_Up:
1386 if(loadCheck) {
1387 // if( !e->isAutoRepeat() )
1388 // AdjustStatus();
1389 // } else {
1390 // OpenBtn();
1391 // BackBtn();
1392 }
1393 // BackButton->setFocus();
1394 // Lview->setFocus();
1395 // if(s_Wrap=="FALSE")
1396 // Lview->MultiLine_Ex::ScrollUp( 1);
1397
1398 // LibraryBtn();
1399 break;
1400 case Key_Right:
1401 ForwardButton->setFocus();
1402 ForwardBtn();
1403 // LibraryBtn();
1404 break;
1405 case Key_Left:
1406 BackBtn();
1407 BackButton->setFocus();
1408 // OpenBtn();
1409 break;
1410 case Key_Escape:
1411 ByeBye();
1412 break;
1413 case Key_PageUp:
1414 BackBtn();
1415 break;
1416 case Key_PageDown:
1417 ForwardBtn();
1418 break;
1419
1420 ////////////////////////////// Zaurus keys
1421 };
1422}
1423
1424void Gutenbrowser::keyPressEvent( QKeyEvent *e) {
1425 switch ( e->key() ) {
1426 // case Key_Next:
1427 // ForwardBtn();
1428 // break;
1429 // case Key_Prior:
1430 // BackBtn();
1431 // break;
1432 // case Key_Space:
1433 // ForwardBtn();
1434 // break;
1435 // case Key_Down:
1436 // Lview->MultiLine_Ex::ScrollUp( 1);
1437 // if(useSplitter) Rview->MultiLine_Ex::ScrollUp( 1);
1438 // break;
1439 // case Key_Up:
1440 // if( Lview->Top() != 0) {
1441 // Lview->MultiLine_Ex::ScrollDown( 1);
1442 // if(useSplitter) Rview->MultiLine_Ex::ScrollDown( 1);
1443 // }
1444 // break;
1445 }
1446}
1447
1448void Gutenbrowser::resizeEvent( QResizeEvent *ev) {
1449 // qDebug("resize: %d,%d\n",ev->size().width(),ev->size().height());
1450
1451 if( !LibraryDlg->isHidden())
1452 LibraryDlg->resize(ev->size().width(),ev->size().height() );
1453
1454 // if( loadCheck == true) {
1455 // ResizeEdits();
1456 // AdjustStatus();
1457 // }
1458}
1459
1460
1461void Gutenbrowser::doOptions() {
1462 optionsDialog* optDlg;
1463 optDlg = new optionsDialog( this,"Options_Dlg", true);
1464 QString Ddir;
1465 Config config("Gutenbrowser");
1466 config.setGroup( "General" );
1467 QFont myFont;
1468 optDlg->showMaximized();
1469
1470 if( optDlg->exec() !=0) {
1471 qApp->processEvents();
1472 brow=optDlg->browserName;
1473 toggleButtonIcons( optDlg->useIcon);
1474 ftp_host= optDlg->ftp_host;
1475 ftp_base_dir= optDlg->ftp_base_dir;
1476 brow=optDlg->browserName;
1477 Ddir=optDlg->downloadDirEdit->text();
1478
1479 qDebug("writing library config");
1480 Config config("Gutenbrowser");
1481 config.setGroup("General");
1482
1483 QString dirname= optDlg->downloadDirEdit->text();
1484 if(dirname.right(1)!="/")
1485 dirname+="/";
1486 config.writeEntry( "DownloadDirectory",dirname);
1487 QDir newDir( optDlg->downloadDirEdit->text());
1488
1489 if( !newDir.exists() ) {
1490 int exit=QMessageBox::information(this, "Note", "Ok, to make a new directory\n"+Ddir+" ?",
1491 QMessageBox::Ok, QMessageBox::Cancel);
1492 if (exit==1) {
1493 QString cmd="mkdir -p ";
1494 cmd+=Ddir.latin1();
1495 system(cmd);
1496 qDebug("Making new dir "+cmd);
1497 if(Ddir.right(1)!="/") {
1498 Ddir+="/";
1499 }
1500 config.writeEntry("DownloadDirectory",Ddir);
1501 }
1502 }
1503
1504// if(optDlg->styleChanged)
1505// setStyle( optDlg->styleInt);
1506 if(optDlg->b_qExit==TRUE)
1507 b_queryExit=TRUE;
1508 else
1509 b_queryExit=FALSE;
1510
1511 if(optDlg->fontDlg-> changedFonts) {
1512 qDebug("Setting font");
1513 myFont=optDlg->fontDlg->selectedFont;
1514 Lview->setFont( myFont);
1515 }
1516
1517 if(optDlg->useWordWrap_CheckBox->isChecked() ) {
1518 qDebug("WORD WRAP is set");
1519 Lview->setWordWrap(QMultiLineEdit::WidgetWidth);
1520 useWrap=true;
1521 } else {
1522 qDebug("Word wrap is NOT set");
1523 Lview->setWordWrap(QMultiLineEdit::NoWrap);
1524 useWrap=false;
1525 }
1526 }
1527 if(showMainList) {
1528 if(!Lview->isHidden())
1529 Lview->hide();
1530 qApp->processEvents();
1531 if(mainList->isHidden())
1532 mainList->show();
1533 fillWithTitles();
1534 } else {
1535 Lview->show();
1536 showMainList=FALSE;
1537 mainList->hide();
1538 }
1539 qApp->processEvents();
1540 update();
1541}
1542
1543bool Gutenbrowser::setTitle() {
1544 if( file_name.contains( local_library)) {
1545 QFileInfo f( file_name);
1546 QString s_file = f.fileName();
1547 file_name = s_file;
1548 }
1549
1550 int test = 0;
1551 Config config("Gutenbrowser");
1552 config.setGroup( "Files" );
1553 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
1554 int i_numofFiles = s_numofFiles.toInt();
1555
1556 for (int i = 1; i <= i_numofFiles; i++) {
1557 QString temp;
1558 temp.setNum(i);
1559 QString ramble = config.readEntry(temp, "" );
1560
1561 if( strcmp(ramble, file_name) == 0) {
1562 test = 1;
1563 }
1564 }
1565 if (test == 0) {
1566 config.writeEntry("NumberOfFiles",i_numofFiles +1 );
1567 QString interger;
1568 interger.setNum( i_numofFiles +1);
1569 config.writeEntry(interger, file_name);
1570
1571 config.setGroup( "Titles" );
1572 config.writeEntry(file_name,listItemTitle);
1573 }
1574 test = 0;
1575 // config.write();
1576 return true;
1577}
1578 /*Calls new fangled network dialog */
1579void Gutenbrowser::OnNetworkDialog( const QString &/*networkUrl*/, const QString &/*output*/)
1580{
1581 // qDebug(networkUrl);
1582 // qDebug(output);
1583 // #ifndef Q_WS_QWS
1584 // NetworkDialog *NetworkDlg;
1585 // if( networkUrl.length() < 4 ) networkUrl= "http://sailor.gutenberg.org/mirror.sites.html";
1586 // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, output);
1587 // if( NetworkDlg->exec() != 0 ) {
1588 // }
1589 // if(NetworkDlg)
1590 // delete NetworkDlg;
1591 // #endif
1592}
1593
1594void Gutenbrowser::donateGutenberg()
1595{
1596 int exit=QMessageBox::information(this,"Info", "http://www.gutenberg.org\ndonate@gutenberg.net",
1597 QMessageBox::Ok, QMessageBox::Cancel);
1598
1599 if (exit==1) {
1600 } else {
1601 };
1602}
1603
1604void Gutenbrowser::donateByteMonkie()
1605{
1606}
1607
1608void Gutenbrowser::writeConfig()
1609{
1610 // config.read();
1611 // Config config("Gutenbrowser");
1612 // #ifndef Q_WS_QWS
1613 // config.setGroup( "Geometry" );
1614 // QString s;
1615 // QString globalPosition;
1616 // QPoint point;
1617 // point=mapToGlobal(QPoint(0,0) );
1618 // int posiX, posiY;
1619 // posiX=point.x();
1620 // posiY=point.y();
1621 // globalPosition.sprintf("%i,%i", posiX, posiY);
1622
1623 // QRect frameRect;
1624 // frameRect = geometry();
1625 // s.sprintf("%i,%i", frameRect.width(), frameRect.height());
1626 // config.writeEntry("Frame", s);
1627 // config.writeEntry("Position", globalPosition);
1628
1629 // if( useIcons==TRUE)
1630 // config.writeEntry("Icons", "TRUE");
1631 // else
1632 // config.writeEntry("Icons", "FALSE");
1633 // #endif
1634
1635 // #ifndef Q_WS_QWS
1636 // QString temp;
1637 // temp.setNum(styleI, 10);
1638 // config.setGroup( "StyleIze" );
1639 // config.writeEntry( "Style", temp);
1640 // #endif
1641
1642 // config.setGroup("General");
1643}
1644
1645void Gutenbrowser::annotations()
1646{
1647 // #ifndef Q_WS_QWS
1648 // QMessageBox::message("Note","hi annotate");
1649 // lastBmkButton->setDown(FALSE);
1650 // #endif
1651}
1652
1653void Gutenbrowser::hideButtons()
1654{
1655
1656 if( !buttonsHidden) {
1657 buttonsHidden=TRUE;
1658 LibraryButton->hide();
1659 SearchButton->hide();
1660 InfoBar->hide();
1661 OpenButton->hide();
1662 BackButton->hide();
1663 ForwardButton->hide();
1664 setBookmarkButton->hide();
1665 lastBmkButton->hide();
1666 dictionaryButton->hide();
1667 if(useSplitter) {
1668 ClearButton->hide();
1669 PrintButton->hide();
1670 beginButton->hide();
1671 HelpButton->hide();
1672 FontButton->hide();
1673 ExitButton->hide();
1674 OptionsButton->hide();
1675 DownloadButton->hide();
1676 }
1677 } else {
1678 buttonsHidden=FALSE;
1679
1680 LibraryButton->show();
1681 SearchButton->show();
1682 InfoBar->show();
1683 OpenButton->show();
1684 BackButton->show();
1685 ForwardButton->show();
1686 setBookmarkButton->show();
1687 lastBmkButton->show();
1688 dictionaryButton->show();
1689 if(useSplitter) {
1690 ClearButton->show();
1691 PrintButton->show();
1692 beginButton->show();
1693 HelpButton->show();
1694 FontButton->show();
1695 ExitButton->show();
1696 OptionsButton->show();
1697 DownloadButton->show();
1698 }
1699 }
1700}
1701
1702void Gutenbrowser::focusInEvent( QFocusEvent* )
1703{
1704}
1705void Gutenbrowser::focusOutEvent( QFocusEvent* )
1706{
1707}
1708
1709void Gutenbrowser::cleanUp( )
1710{
1711 writeConfig();
1712 QPEApplication::grabKeyboard();
1713
1714 QPEApplication::ungrabKeyboard();
1715 // qDebug("Cleanup");
1716 if(f.isOpen()) f.close();
1717}
1718
1719void Gutenbrowser::fixKeys()
1720{
1721 qDebug("Attempting to fix keys");
1722
1723}
1724
1725void Gutenbrowser::enableButtons(bool b)
1726{
1727 BackButton->setEnabled(b);
1728 ForwardButton->setEnabled(b);
1729 SearchButton->setEnabled(b);
1730 setBookmarkButton->setEnabled(b);
1731 dictionaryButton->setEnabled(b);
1732 InfoBar->setEnabled(b);
1733
1734 editMenu->setItemEnabled( -5, b);
1735 editMenu->setItemEnabled( -6, b);
1736 editMenu->setItemEnabled( -7, b);
1737 editMenu->setItemEnabled( -8, b);
1738
1739}
1740
1741void Gutenbrowser::fillWithTitles() {
1742 Config config("Gutenbrowser");
1743 config.setGroup( "Files" );
1744 int i_numofFiles = config.readNumEntry("NumberOfFiles", 0);
1745 mainList->clear();
1746 QString temp;
1747 for (int i = 1; i <= i_numofFiles; i++) {
1748 temp.setNum(i);
1749 config.setGroup( "Files" );
1750 QString ramble = config.readEntry(temp, "" );
1751 config.setGroup( "Titles" );
1752 temp = config.readEntry(ramble, "");
1753 if( !temp.isEmpty()) {
1754 mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), temp, -1);
1755 }
1756 }
1757}
1758
1759void Gutenbrowser::listClickedSlot( QListBoxItem * index) {
1760 // if( !working) {
1761 // working=true;
1762 if(index) {
1763 // QCopEnvelope ( "QPE/System", "busy()" );
1764 title = index->text();
1765 showMainList=FALSE;
1766 mainList->hide();
1767 Lview->show();
1768 qApp->processEvents();
1769 QString temp;
1770 temp.setNum( mainList->currentItem() + 1);
1771 // openFileTitle = title;
1772 Config config("Gutenbrowser");
1773 config.setGroup( "Files" );
1774 QString file = config.readEntry(temp, "");
1775 qDebug("About to load");
1776 if( Lview->isVisible())
1777 load(file);
1778
1779 config.setGroup( title);
1780 file_name = config.readEntry("File Name", "");
1781 i_pageNum = config.readNumEntry("Page Number", 1);
1782 int Bmrkrow = config.readNumEntry("LineNumber", -1);
1783 if(Bmrkrow > -1) {
1784 if( Bmrkrow > Lview->topRow() ) {
1785 Lview->setCursorPosition( Bmrkrow /* - Lview->topRow() */,0, FALSE );
1786 Lview->ScrollUp( Bmrkrow - Lview->topRow() );
1787 // AdjustStatus();
1788 }
1789 else if( Bmrkrow < Lview->topRow() ) {
1790 Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE );
1791 Lview->ScrollDown( Lview->topRow() - Bmrkrow );
1792 // AdjustStatus();
1793 }
1794 }
1795 }
1796}
1797
1798void Gutenbrowser::infoGutenbrowser() {
1799 QMessageBox::message("Info","Gutenbrowser was developed by\n"
1800 "Lorn Potter\n"
1801 "ljp<ljp@llornkcor.com>\n");
1802}
1803
1804void Gutenbrowser::setDocument(const QString & frozenBoogers) {
1805 this->hide();
1806 if(showMainList) {
1807 showMainList=FALSE;
1808 if(!mainList->isHidden())
1809 mainList->hide();
1810 if(Lview->isHidden())
1811 Lview->show();
1812 qApp->processEvents();
1813 }
1814 DocLnk lnk;
1815 lnk = DocLnk(frozenBoogers);
1816 // qDebug(lnk.file() );
1817 title=lnk.comment();
1818 load( lnk.file());
1819 this->show();
1820 // qDebug(title);
1821 // qApp->processEvents();
1822 // repaint();
1823}
1824
1825void Gutenbrowser::mainListPressed(int mouse, QListBoxItem * , const QPoint & )
1826{
1827 switch (mouse) {
1828 case 1:
1829 break;
1830 case 2: {
1831 QPopupMenu m;// = new QPopupMenu( Local_View );
1832 m.insertItem( tr( "Open" ), this, SLOT( menuOpen() ));
1833 m.insertSeparator();
1834 m.insertItem( tr( "Search google.com" ), this, SLOT( menuGoogle()));
1835 m.insertItem( tr( "Edit Title" ), this, SLOT( menuEditTitle()));
1836 // m.insertSeparator();
1837 // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
1838 m.exec( QCursor::pos() );
1839 }
1840 break;
1841 };
1842}
1843
1844void Gutenbrowser::menuOpen() {
1845 listClickedSlot( mainList->item( mainList->currentItem()));
1846}
1847
1848void Gutenbrowser::menuGoogle() {
1849 searchGoogle( mainList->text(mainList->currentItem()));
1850}
1851
1852void Gutenbrowser::searchGoogle( const QString &tempText) {
1853 QString text = tempText;
1854
1855 int eexit=QMessageBox::information(this, "Note","Do you want to search for\n"+text+
1856 "\non google.com?",QMessageBox::Yes, QMessageBox::No);
1857 if (eexit== 3) {
1858 qApp->processEvents();
1859 text.replace( QRegExp("\\s"), "%20");
1860 text.replace( QRegExp("#"), "");
1861 text.replace( QRegExp(","), "%20");
1862 text.replace( QRegExp("'"), "%20");
1863 text.replace( QRegExp("("), "");
1864 text.replace( QRegExp(")"), "");
1865 // text.replace( QRegExp("[0-9]"), "");
1866 QString s_lookup = "http://google.com/search?q="+text+"&num=30&sa=Google+Search";
1867 goGetit( s_lookup, true);
1868 }
1869
1870}
1871
1872void Gutenbrowser::menuEditTitle()
1873{
1874 int currentItem = mainList->currentItem();
1875 QString title_text = mainList->text( currentItem);
1876 //qDebug("Selected "+title_text);
1877
1878 Config config("Gutenbrowser");
1879 config.setGroup( "Files" );
1880 QString s_numofFiles = config.readEntry("NumberOfFiles", "0");
1881 int i_numofFiles = s_numofFiles.toInt();
1882 QString fileNum;
1883 for (int i = 1; i <= i_numofFiles+1; i++) {
1884
1885 fileNum.setNum(i);
1886 config.setGroup( "Files" );
1887 QString s_filename = config.readEntry(fileNum, "" );
1888 config.setGroup( "Titles" );
1889 QString file_title = config.readEntry( s_filename, "");
1890 //qDebug("file_title is "+file_title);
1891 if(title_text == file_title ) {
1892 // selFile = s_filename;
1893 //qDebug("Edit: "+ file_title );
1894 i=i_numofFiles+1;
1895 Edit_Title *titleEdit;
1896 titleEdit = new Edit_Title(this,file_title ,TRUE);
1897 if(titleEdit->exec() !=0) {
1898 //qDebug(titleEdit->newTitle);
1899 config.writeEntry( s_filename, titleEdit->newTitle);
1900 mainList->removeItem(currentItem);
1901 mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), titleEdit->newTitle, currentItem);
1902 }
1903 }
1904 }
1905
1906 // getTitles();
1907 mainList->triggerUpdate(true);
1908
1909}
1910
1911
1912
1913bool Gutenbrowser::UnZipIt(const QString &zipFile) {
1914 qDebug(zipFile);
1915#ifndef Q_WS_QWS
1916 if( QFile::exists( zipFile)) { // TODO findsome other way of dealingwithzip files.
1917 bool isPgWhole=false;
1918 QString thatFile;
1919 if(zipFile.find("pgwhole",0,TRUE)) {
1920 isPgWhole=TRUE;
1921 thatFile= local_library +"PGWHOLE.TXT";
1922 }
1923 // else {
1924 // thatFile=zipFile.left(4);
1925 // }
1926 // qDebug((const char*)local_library.latin1());
1927 QString cmd;
1928#if defined(_WS_X11_)
1929 if( chdir((const char*)local_library.latin1())!=0)
1930 qDebug("chdir failed.");
1931 cmd = "gunzip -S .zip " + local_library+zipFile;
1932 //cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library;
1933#endif
1934#ifdef Q_WS_QWS
1935 if( chdir((const char*)local_library.latin1())!=0)
1936 qDebug("chdir failed.");
1937 cmd = "unzip " + local_library+zipFile;
1938 // cmd = "/usr/bin/unzip -o " + local_library+zipFile +" -d /usr/share/doc/gutenbrowser" ;//+ local_library;
1939#endif
1940 int exit=QMessageBox::information(this, "Ok to unzip?",
1941 "Ok to unnzip\n"+ zipFile+" ?",
1942 QMessageBox::Yes, QMessageBox::No);
1943 if (exit==QMessageBox::Yes) {
1944#if defined(_WS_X11_)//
1945 qDebug("Issuing the command "+cmd);
1946 system( cmd);
1947 if( QFile::exists(thatFile))
1948 remove (thatFile);
1949 if(isPgWhole) {
1950 if( rename("pgwhole","PGWHOLE.TXT") !=0)
1951 qDebug("rename failed");
1952 } else {
1953 if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0)
1954 qDebug("rename failed");
1955 }
1956#endif
1957#ifdef Q_WS_QWS
1958 qDebug("Issuing the command "+cmd);
1959 system( cmd);
1960 if( QFile::exists(thatFile))
1961 remove(thatFile);
1962 if(isPgWhole) {
1963 if( rename("pgwhole","PGWHOLE.TXT") !=0)
1964 qDebug("rename failed");
1965 } else {
1966 if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0)
1967 qDebug("rename failed");
1968 }
1969#endif
1970 // remove( zipFile);
1971 return true;
1972 }
1973 else if(exit==QMessageBox::No) {
1974 // qDebug("unzip");
1975 return false;
1976 }
1977 }
1978 else
1979 QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) );
1980#endif
1981 return false;
1982}
1983
1984
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.h b/noncore/apps/opie-gutenbrowser/gutenbrowser.h
new file mode 100644
index 0000000..acb6e59
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.h
@@ -0,0 +1,226 @@
1/***************************************************************************
2 gutenbrowser.h - description
3 -------------------
4 begin : Mon Jul 24 22:33:12 MDT 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7***************************************************************************/
8/***************************************************************************
9 * *
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 *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef GUTENBROWSER_H
17#define GUTENBROWSER_H
18
19class QPainter;
20class QPushButton;
21class QListView;
22class QString;
23class QTextView;
24class QPopupMenu;
25class QMenuBar;
26class QToolBar;
27class QLayout;
28class QToolTip;
29class QPixMap;
30class QFile;
31
32#include <qtoolbutton.h>
33
34#include <qpe/qpeapplication.h>
35#include <qpe/qpemenubar.h>
36#include <qpe/menubutton.h>
37
38#include <qmainwindow.h>
39#include <qapplication.h>
40#include <qwhatsthis.h>
41#include <qfontmetrics.h>
42#include <qfontinfo.h>
43#include <qpoint.h>
44
45#include "LibraryDialog.h"
46#include "multiline_ex.h"
47#include "resource.h"
48
49#include <qvaluelist.h>
50
51class Gutenbrowser : public QMainWindow {
52 Q_OBJECT
53public:
54 static QString appName() { return QString::fromLatin1("gutenbrowser"); }
55#ifdef NOQUICKLAUNCH
56 Gutenbrowser();
57#else
58 Gutenbrowser(QWidget *p = 0, const char* name = 0, WFlags fl = 0);
59#endif
60 ~Gutenbrowser();
61 LibraryDialog* LibraryDlg;
62 QButton* InfoBar;
63 QFile newindexLib, indexLib;
64 QListBox *mainList;
65 QPrinter *printer;
66 QString brow;
67 QString file_name;
68 QString fontStr, pointSizeStr, weightStr, italicStr, boldStr;
69 QString ftp_base_dir;
70 QString ftp_host;
71 QString iniFile;
72 QString listItemFile;
73 QString listItemNumber;
74 QString listItemTitle;
75 QString listItemYear;
76 QString local_index;
77 QString local_library;
78 QString networkUrl;
79 QString pattern;
80 QString prefBrowser;
81 QString s_Wrap;
82 QString status;
83 QString statusTop;
84 QString title;
85 QPushButton *DownloadButton, *LibraryButton, *OpenButton, *ForwardButton, *BackButton, *PrintButton, *SearchButton, *dictionaryButton, *beginButton, *ExitButton, *OptionsButton, *FontButton, *ClearButton, *HelpButton, *setBookmarkButton;
86 MenuButton* lastBmkButton;
87 SearchDialog* searchDlg;
88
89 bool buttonsHidden;
90 bool italic, bold;
91 bool loadCheck;
92 bool useSplitter;
93 char host[1024];
94 char login[1024];
95 char password[1024];
96 int check;
97 int direction;
98 int i_pageNum;
99 int lastScrollRow;
100 int lineCheck;
101 int pages;
102 int pointSize, weight;
103// int styleI;
104
105public slots:
106
107private:
108
109/* typedef QValueList<int> pageStop; */
110/* pageStop pageStopArray; */
111// QVector<int> pageStopArray;
112 QArray<int> pageStopArray;
113
114 MultiLine_Ex* Lview;
115 QBoxLayout *buttons2;
116 QBoxLayout *buttons;
117 QBoxLayout *edits;
118 QBoxLayout *menu;
119 QBoxLayout *topLayout;
120 QFile f;
121 QPEMenuBar* menubar;
122 QPopupMenu *fileMenu, *editMenu, *viewMenu, *DownloadMenu, *optionsMenu, *bookmarksMenu, *donateMenu, *helpMenu;
123 bool useWrap;
124 int fileHandle, currentFilePos, currentLine;
125 int last_search;
126
127 bool getTitle( const char *file);
128 bool setTitle();
129 int repeatSearch();
130 void Search();
131 void OnNetworkDialog( const QString &networkUrl,const QString & output);
132 void hideButtons();
133
134private slots:
135
136 bool load( const char *fileName );
137 bool setStatus();
138 void BeginBtn();
139 void TopBtn();
140 void cleanUp();
141 void doBeginBtn();
142 void goGetit(const QString &url, bool showMsg);
143 void infoGutenbrowser();
144 void listClickedSlot( QListBoxItem *);
145 void mainListPressed(int, QListBoxItem *, const QPoint &);
146 void menuEditTitle();
147 void search_slot();
148 void searchdone_slot();
149 void setDocument(const QString&);
150 void slotFilePrint();
151// void setStyle(int styleInt);
152
153
154protected:
155
156 bool UnZipIt(const QString &zipFile);
157 bool b_queryExit;
158 bool queryExit();
159 bool showMainList;
160 bool useIcons;
161 bool working;
162
163
164protected slots:
165
166 void BackBtn();
167 void Bookmark( int);
168 void ByeBye();
169 void ChangeFont();
170 void ClearEdit();
171 void DownloadIndex();
172 void ForwardBtn();
173 void HelpBtn();
174 void InfoBarClick();
175 void LibraryBtn();
176 void LookupBtn();
177 void OpenBtn();
178 void PrintBtn();
179 void SearchBtn();
180 void annotations();
181 void doOptions();
182 void donateByteMonkie();
183 void donateGutenberg();
184 void downloadFtpList();
185 void downloadLibIndex();
186 void enableButtons(bool);
187 void fillWithTitles();
188 void fixKeys();
189 void initButtonBar();
190 void initConfig();
191 void initMenuBar();
192 void initSlots();
193 void initStatusBar();
194 void initView();
195 void menuGoogle();
196 void menuOpen();
197 void searchGoogle(const QString &);
198 void setBookmark();
199 void toggleButtonIcons( bool usingIcons);
200// virtual void setBrowser();
201// void stylePlatinum();
202// void styleWindows();
203// void defaultStyle();
204/* void styleMotif(); */
205/* void styleMotifPlus(); */
206/* void styleWood(); */
207/* void stylePlatinumPlus(); */
208/* void styleCDE(); */
209// void styleMetal();
210/* void styleSgi(); */
211/* void styleLace(); */
212/* void styleLacePlus(); */
213/* #endif */
214protected:
215
216 int doSearch(const QString & s_pattern , bool case_sensitive, bool forward, int line, int col );
217 void focusInEvent( QFocusEvent* );
218 void focusOutEvent( QFocusEvent* );
219 void keyPressEvent( QKeyEvent * );
220 void keyReleaseEvent( QKeyEvent *e);
221 void resizeEvent( QResizeEvent * );
222 void writeConfig();
223// void moveSplitter( int pos);
224};
225#endif
226
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp
new file mode 100644
index 0000000..c9149ac
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp
@@ -0,0 +1,328 @@
1/***************************************************************************
2 gutenbrowser.cpp - description
3 -------------------
4 begin : Mon Jul 24 22:33:12 MDT 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7***************************************************************************/
8/***************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 ***************************************************************************/
14//#include "gutenbrowserData.h"
15#include "gutenbrowser.h"
16
17#include <qpe/config.h>
18#include <qpe/fontdatabase.h>
19#include <qpe/menubutton.h>
20#include <qpe/resource.h>
21#include <qpe/qpeapplication.h>
22
23#include <qfontinfo.h>
24#include <qtoolbutton.h>
25
26void Gutenbrowser::initSlots() {
27
28 connect(LibraryButton,SIGNAL(released()),SLOT(LibraryBtn()));
29 connect(OpenButton,SIGNAL(released()),SLOT(OpenBtn()));
30 connect(SearchButton,SIGNAL(released()),SLOT(SearchBtn()));
31 connect(ForwardButton,SIGNAL(clicked()),SLOT(ForwardBtn()));
32 connect(BackButton,SIGNAL(clicked()),SLOT(BackBtn()));
33 connect(setBookmarkButton,SIGNAL(released()),SLOT(setBookmark()));
34 connect(dictionaryButton,SIGNAL(released()),SLOT(LookupBtn()));
35 connect(InfoBar,SIGNAL(clicked()),SLOT(InfoBarClick()));
36 connect(qApp,SIGNAL(aboutToQuit()),SLOT(cleanUp()));
37 connect(mainList,SIGNAL(clicked(QListBoxItem *)),SLOT(listClickedSlot(QListBoxItem *)));
38 connect(bookmarksMenu,SIGNAL(activated(int)),SLOT(Bookmark(int)));
39}
40
41void Gutenbrowser::initConfig() {
42//qDebug("Starting configuration.");
43 QDir library(local_library);
44 if ( !library.exists()) {
45 library.mkdir(local_library, TRUE);
46 QString msg;
47// #ifndef Q_WS_WIN
48 msg = "chmod 755 " + local_library;
49 system(msg);
50// QDir pixdir(local_library+"pix");
51// if ( !pixdir.exists()) {
52// pixdir.mkdir(local_library+"pix", TRUE);
53// QString msg;
54// msg = "chmod 755 " + local_library+"pix";
55// system(msg);
56// }
57// #endif
58
59 }
60 // qDebug( "init file is %s",iniFile.latin1());
61
62#ifdef Q_WS_QWS
63 useSplitter=FALSE;
64 Config config("Gutenbrowser");
65
66 config.setGroup( "General" );
67//useWordWrap_CheckBox
68 useIcons=TRUE;
69#else
70
71 config.setGroup( "General" );
72 QString s_Split=config.readEntry("Splitter", "TRUE" );
73 QWidget *d = QApplication::desktop();
74 int width=d->width();
75 int height=d->height();
76 int w=0, h=0;
77 QString str, str2;
78
79 this->setMaximumWidth(width);
80
81 if(s_Split=="TRUE")
82 useSplitter=TRUE;
83 else
84 useSplitter=FALSE;
85
86 config.setGroup( "Geometry" );
87 if(width < 1030) {
88 str = config.readEntry("Frame", "700,500");
89 if( !str.isEmpty() && str.find(',')>=0) {
90 sscanf(str,"%d,%d",&w,&h);
91 resize(w,h);
92 str2.sprintf("%d,%d", (width-w)/2,(height-h)/2);
93 str = config.readEntry( "Position", str2);
94 } else {
95 resize( 740,510 );
96 str2.sprintf("%d,%d", (width-w)/2,(height-h)/2);
97 str = config.readEntry( "Position",str2);
98 }
99 } else {// desktop is high res
100 str = config.readEntry("Frame", "990,640");
101 if( !str.isEmpty() && str.find(',')>=0) {
102 sscanf(str,"%d,%d",&w,&h);
103 resize(w,h);
104 str2.sprintf("%d,%d", (width-w)/2,(height-h)/2);
105 str = config.readEntry( "Position", str2);
106 } else {
107 resize( 990,640 );
108 str2.sprintf("%d,%d", (width-w)/2,(height-h)/2);
109 str = config.readEntry( "Position", str2);
110 }
111 }
112 int posX, posY;
113 bool ok;
114 QString goober;
115 goober=str.left( str.find(",", 0, TRUE) );
116 posX=goober.toInt( &ok, 10);
117 goober=str.right( str.findRev(",", -1, TRUE) );
118 posY= goober.toInt( &ok, 10);
119// move( posX, posY);
120 str = config.readEntry("Icons", "TRUE");
121 if(str == "TRUE")
122 useIcons=TRUE;
123 else
124 useIcons=FALSE;
125#endif
126// #if defined(_WS_WIN_)
127// move( posX-4, posY-20);
128// #endif
129
130 config.setGroup( "Browser" );
131 brow = config.readEntry( "Preferred", "Opera");
132 config.setGroup( "FTPsite" ); // ftp server config
133 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
134// ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) );
135 ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) );
136 ftp_host=ftp_host.stripWhiteSpace();
137
138 ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
139
140 //bool ok2;
141 QString temp;
142 QString copying;
143 copying="";
144
145 config.setGroup("General");
146 QString qExit;
147 qExit=config.readEntry("queryExit","TRUE");
148 if(qExit=="TRUE") {
149 b_queryExit=TRUE;
150// qDebug("Please query before leaving the library.");
151 } else {
152// qDebug("Please DO NOT query before leaving the library.");
153 b_queryExit=FALSE;
154 }
155// bookmarks
156// config.setGroup("Titles");
157// QString tmpTitle=config.readEntry(file_name,"");
158
159
160}// end initConfig()
161
162void Gutenbrowser::initMenuBar()
163{
164// qDebug("Starting menu init.");
165 // menuBar entry fileMenu
166 menubar = new QPEMenuBar(this);
167
168 fileMenu=new QPopupMenu();
169 fileMenu->insertItem(Resource::loadPixmap("gutenbrowser/openbook"),
170 "Open Local Library...", this, SLOT( OpenBtn()) );
171// fileMenu->insertItem("Download FTPSite", this, SLOT( downloadFtpList()) );
172 fileMenu->insertItem( Resource::loadPixmap("home"),
173 "Download Library Index", this, SLOT( downloadLibIndex()) );
174 fileMenu->insertItem( Resource::loadPixmap("quit"),
175 "Quit Gutenbrowser...", this, SLOT( ByeBye()) );
176 // menuBar entry editMenu
177
178 editMenu=new QPopupMenu();
179
180 editMenu->insertItem(Resource::loadPixmap("up"), "Top",
181 this, SLOT(TopBtn()) );
182 editMenu->insertItem( Resource::loadPixmap("back"), "Beginning",
183 this, SLOT(doBeginBtn()) );
184 editMenu->insertItem( Resource::loadPixmap("gutenbrowser/search"), "Search",
185 this, SLOT(SearchBtn()) );
186
187 editMenu->insertItem("Clear", this, SLOT(ClearEdit()) );
188
189 optionsMenu= new QPopupMenu();
190 optionsMenu->insertItem( Resource::loadPixmap("gutenbrowser/configure"),
191 "Configure", this, SLOT(doOptions()) );
192
193 donateMenu = new QPopupMenu();
194// donateMenu->insertItem("Gutenberg", this, SLOT(donateGutenberg()) );
195 donateMenu->insertItem( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"),
196 "Gutenbrowser Developer", this, SLOT(infoGutenbrowser()) );
197
198 menubar->insertItem("File", fileMenu);
199 menubar->insertItem("Page", editMenu);
200 menubar->insertItem("Options", optionsMenu);
201// menubar->insertItem("More Info", donateMenu);
202
203 menu->addWidget( menubar,0);
204
205 topLayout->addLayout( menu, 0);
206}
207
208void Gutenbrowser::initButtonBar()
209{
210//qDebug("Starting buttonbar init.");
211
212 OpenButton = new QPushButton( this, "OpenButton" );
213 OpenButton->setFocusPolicy( QWidget::TabFocus );
214
215 LibraryButton = new QPushButton( this, "LibraryButton" );
216 LibraryButton->setFocusPolicy( QWidget::TabFocus );
217
218 BackButton = new QPushButton( this, "BackButton" );
219 BackButton->setFocusPolicy( QWidget::TabFocus );
220 BackButton->setAutoRepeat(TRUE);
221
222 ForwardButton = new QPushButton( this, "ForwardButton" );
223 ForwardButton->setFocusPolicy( QWidget::TabFocus );
224// ForwardButton->setAutoRepeat(TRUE);
225
226 SearchButton = new QPushButton( this, "SearchButton" );
227 SearchButton->setFocusPolicy( QWidget::TabFocus );
228
229 setBookmarkButton = new QPushButton( this, "setBookmark" );
230 setBookmarkButton->setFocusPolicy( QWidget::TabFocus );
231
232 lastBmkButton = new MenuButton( this, "lastBmkButton" );
233 lastBmkButton->setFocusPolicy( QWidget::TabFocus );
234
235 bookmarksMenu = new QPopupMenu();
236 bookmarksMenu->insertItem("Last Set", this, SLOT(Bookmark( int) ));
237
238 lastBmkButton->setPopup(bookmarksMenu);
239
240 dictionaryButton = new QPushButton( this, "dictionaryButton" );
241 dictionaryButton->setFocusPolicy( QWidget::TabFocus );
242
243 InfoBar = new QPushButton( this, "Info_Bar" );
244// qDebug("Infobar");
245// if(!useSplitter) {
246
247 buttonsHidden=FALSE;
248 buttons2->setSpacing(2);
249 buttons2->addWidget(OpenButton, 0, AlignCenter);
250 buttons2->addWidget(LibraryButton, 0, AlignCenter);
251 buttons2->addWidget(BackButton, 0, AlignCenter);
252 buttons2->addWidget(ForwardButton, 0, AlignCenter);
253 buttons2->addWidget(SearchButton, 0, AlignCenter);
254 buttons2->addWidget(setBookmarkButton, 0, AlignCenter);
255 buttons2->addWidget(lastBmkButton, 0, AlignCenter);
256 buttons2->addWidget(dictionaryButton, 0, AlignCenter);
257 buttons2->addWidget(InfoBar, 0, AlignCenter);
258
259 topLayout->setSpacing(0);
260 topLayout->addLayout( buttons2,0);
261
262}
263
264/* STATUSBAR*/
265void Gutenbrowser::initStatusBar()
266{
267// #ifndef Q_WS_QWS
268
269// statusBar = new QStatusBar( this, "Status Bar");
270// statusBar->message(IDS_STATUS_DEFAULT, 2000);
271// #endif
272}
273
274void Gutenbrowser::initView()
275{
276 // set the main widget here
277// QFont defaultFont( "charter", 10, 50, 0 );
278 Lview = new MultiLine_Ex(this);
279
280 Config cfg("Gutenbrowser");
281 cfg.setGroup("Font");
282
283 FontDatabase fdb;
284 QFont defaultFont=Lview->font();
285 QFontInfo fontInfo(defaultFont);
286
287 QString family = cfg.readEntry("Family", fontInfo.family());
288 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
289 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
290 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
291
292 defaultFont = fdb.font(family,style,i_size,charSet);
293
294 QString italic=cfg.readEntry("Italic","FALSE");
295 if(italic=="TRUE") {
296 qDebug("Set Italic font");
297 defaultFont = fdb.font(family,"Regular",i_size,charSet); //workaround
298 defaultFont.setItalic(TRUE);
299 }
300
301 Lview->setFont( defaultFont);
302 update();
303
304 cfg.setGroup("General");
305
306 if( cfg.readBoolEntry("WordWrap", 1)) {
307 Lview->setWordWrap(QMultiLineEdit::WidgetWidth);
308 useWrap=true;
309 } else {
310 Lview->setWordWrap(QMultiLineEdit::NoWrap);
311 useWrap=false;
312 }
313 mainList = new QListBox(this,"mainlist");
314
315// QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold);
316 // mainList->showMaximized();
317// mainList->setGeometry(2,30,230,160);
318 Lview->setReadOnly( true);
319 edits->addWidget( Lview);
320 edits->addWidget(mainList);
321
322 if(!showMainList) {
323 Lview->setText( "\nThis is gutenbrowser for the Sharp Zaurus.\nMake your self at home, sit back, relax and read something great. ");
324 } else
325 Lview->hide();
326
327 topLayout->addLayout( edits, 0);
328}
diff --git a/noncore/apps/opie-gutenbrowser/helpme.cpp b/noncore/apps/opie-gutenbrowser/helpme.cpp
new file mode 100644
index 0000000..6a9b8c0
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/helpme.cpp
@@ -0,0 +1,122 @@
1/***************************************************************************
2 helpme.cpp - description
3 -------------------
4 begin : Tue Jul 25 2000
5 begin : Sat Dec 4 1999
6 copyright : (C) 2000 -2004 by llornkcor
7 email : ljp@llornkcor.com
8 ***************************************************************************/
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#include <qpe/qcopenvelope_qws.h>
18#include <qpe/qpeapplication.h>
19
20#include "helpme.h"
21#include "helpwindow.h"
22
23#include <qprogressdialog.h>
24#include <qlayout.h>
25
26#include <sys/stat.h>
27#include <unistd.h>
28
29HelpMe::HelpMe(QWidget *parent, QString name ) : QDialog(parent,name)
30{
31 local_library = ( QDir::homeDirPath ())+"/Applications/gutenbrowser/";
32 setCaption(tr("Gutenbrowser About " VERSION));
33
34 QGridLayout *layout = new QGridLayout( this );
35 layout->setSpacing( 4 );
36 layout->setMargin( 4 );
37
38 Edit = new QMultiLineEdit(this, "");
39 Edit->setReadOnly(true);
40 Edit->append(tr("Based on gutenbook.pl, available from http://www.gutenbook.org"));
41 Edit->append(tr("Much appreciation to Lee Burgess,"));
42 Edit->append(tr("for the original idea and concept of gutenbook.\n"));
43 Edit->append(tr("A list of current Gutenberg ftp sites is at http://promo.net/pg/index.html\n"));
44 Edit->append(tr("For bug reports, comments or questions about Gutenbrowser, email"));
45 Edit->append(tr("ljp@llornkcor.com\n"));
46 Edit->append(tr("\nMade using Qt, Qt Embedded, and Qtopia, a cross platform development API\nhttp://www.trolltech.com\n\n"));
47 Edit->append(tr("Arnold's Laws of Documentation:"));
48 Edit->append(tr("(1) If it should exist, it doesn't."));
49 Edit->append(tr("(2) If it does exist, it's out of date."));
50 Edit->append(tr("(3) Only documentation for"));
51 Edit->append(tr("useless programs transcends the"));
52 Edit->append(tr("first two laws.\n"));
53 Edit->append(tr("Everything is temporary, anyway....\n :o)"));
54 Edit->setWordWrap(QMultiLineEdit::WidgetWidth);
55 QString pixDir;
56 pixDir=QPEApplication::qpeDir()+"/pics/";
57 QPushButton *help;
58 help = new QPushButton(this);
59 help->setPixmap( QPixmap( pixDir+"gutenbrowser/help.png"));
60 help->setText("Help");
61 connect( help,SIGNAL(clicked()),this,SLOT( help() ));
62
63/* QPushButton *ok;
64 ok = new QPushButton(this);
65 ok->setPixmap( QPixmap( pixDir+"/gutenbrowser/exit.png"));
66 ok->setText("ok");
67 connect(ok,SIGNAL(clicked()),this,SLOT(accept() ));
68*/
69 help->setFixedHeight(25);
70// ok->setFixedHeight(25);
71
72// layout->addMultiCellWidget( ok, 0, 0, 4, 4 );
73 layout->addMultiCellWidget( help, 0, 0, 4, 4 );
74 layout->addMultiCellWidget( Edit, 1, 1, 0, 4 );
75}
76
77HelpMe::~HelpMe()
78{
79//delete Edit;
80
81}
82
83void HelpMe::goToURL()
84{
85
86 url = "http://www.llornkcor.com/";
87 goGetit( url);
88}
89
90void HelpMe::goToURL2()
91{
92 url = "http://www.gutenberg.org";
93 goGetit( url);
94}
95
96void HelpMe::goToURL3()
97{
98 url = "http://www.gutenbook.org";
99 goGetit( url);
100}
101
102void HelpMe::goGetit( QString url)
103{
104 HelpWindow *help = new HelpWindow( url, ".", 0, "gutenbrowser");
105 help->setCaption("Qt Example - Helpviewer");
106 help->showMaximized();
107 help->show();
108}
109
110void HelpMe::help()
111{
112 QString msg ;
113 msg=QPEApplication::qpeDir()+"help/html/gutenbrowser-index.html"; // or where ever this ends up to be
114qDebug(msg);
115 QString url = "file://"+msg;
116 goGetit( url);
117
118// QCopEnvelope e("QPE/Application/helpbrowser", "setDocument(QString)" );
119// e << msg;
120
121// goGetit( msg);
122}
diff --git a/noncore/apps/opie-gutenbrowser/helpme.h b/noncore/apps/opie-gutenbrowser/helpme.h
new file mode 100644
index 0000000..f39ca2c
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/helpme.h
@@ -0,0 +1,60 @@
1/***************************************************************************
2 helpme.h - description
3 -------------------
4 begin : Sat Dec 4 1999
5 begin : Tue Jul 25 2000
6 copyright : (C) 2000 -2004 by llornkcor
7 email : ljp@llornkcor.com
8 ***************************************************************************/
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef HELPME_H
19#define HELPME_H
20
21#include "gutenbrowser.h"
22#include <qmultilineedit.h>
23//#include "CConfigFile.h"
24//#include <kprocess.h>
25//#include <kprogress.h>
26#include <qdialog.h>
27#include <qprogressdialog.h>
28#include <qwidget.h>
29
30
31/**
32 *@author llornkcor
33 */
34
35class HelpMe : public QDialog {
36 Q_OBJECT
37public:
38 HelpMe(QWidget *parent, QString name);
39 ~HelpMe();
40
41// KProgress *progressBar;
42 QString url;
43 QLabel *label;
44QLabel *QTlabel;
45// CConfigFile *config;
46 QString local_library;
47
48private slots:
49 void goToURL();
50 void goToURL2();
51 void goToURL3();
52 void help();
53 void goGetit( QString url);
54 private:
55 QMultiLineEdit* Edit;
56
57
58};
59
60#endif
diff --git a/noncore/apps/opie-gutenbrowser/helpwindow.cpp b/noncore/apps/opie-gutenbrowser/helpwindow.cpp
new file mode 100644
index 0000000..e86ca49
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/helpwindow.cpp
@@ -0,0 +1,326 @@
1/****************************************************************************
2** $Id$
3**
4** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
5**
6** This file is part of an example program for Qt. This example
7** program may be used, distributed and modified without limitation.
8**
9 copyright : (C) 2000 -2004 by llornkcor
10 email : ljp@llornkcor.com
11*****************************************************************************/
12
13#include "helpwindow.h"
14#include <qstatusbar.h>
15
16#include <qmenubar.h>
17#include <qtoolbar.h>
18#include <qtoolbutton.h>
19#include <qcombobox.h>
20
21#include <ctype.h>
22
23HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name )
24 : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL()
25{
26 QString local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
27// readHistory();
28// readBookmarks();
29
30 browser = new QTextBrowser( this );
31 QStringList Strlist;
32 Strlist.append( home_);
33 browser->mimeSourceFactory()->setFilePath( Strlist );
34
35 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
36
37 connect(browser,SIGNAL(textChanged()),this,SLOT(textChanged()));
38
39 setCentralWidget( browser );
40
41 if ( !home_.isEmpty() )
42
43////////////////////////////////
44 browser->setSource( home_ );
45
46////////////////////////////////
47 connect( browser, SIGNAL( highlighted( const QString&) ),
48 statusBar(), SLOT( message( const QString&)) );
49
50// resize( 640,600 );
51#ifdef Q_WS_QWS
52 setGeometry( 0,0,236,280);
53#else
54 setGeometry( 10,30,520,420 );
55// resize(520,420);
56#endif
57
58 QPopupMenu* file = new QPopupMenu( this );
59// file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N );
60 file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O );
61// file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P );
62 file->insertSeparator();
63 file->insertItem( tr("&Close"), this, SLOT( close() ), ALT | Key_Q );
64// file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), ALT | Key_X );
65
66 // The same three icons are used twice each.
67////F FIXME
68 QString pixs=(QDir::homeDirPath ()) +"/Applications/gutenbrowser/pix/";
69 QIconSet icon_back( QPixmap(pixs+"back.png") );
70 QIconSet icon_forward( QPixmap(pixs+"forward.png") );
71 QIconSet icon_home( QPixmap(pixs+"home.png") );
72
73 QPopupMenu* go = new QPopupMenu( this );
74 backwardId = go->insertItem( icon_back, tr("&Backward"), browser, SLOT( backward() ), ALT | Key_Left );
75 forwardId = go->insertItem( icon_forward, tr("&Forward"), browser, SLOT( forward() ), ALT | Key_Right );
76 go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) );
77
78// QPopupMenu* help = new QPopupMenu( this );
79// help->insertItem( tr("&About ..."), this, SLOT( about() ) );
80// help->insertItem( tr("About &Qt ..."), this, SLOT( aboutQt() ) );
81
82
83 hist = new QPopupMenu( this );
84 QStringList::Iterator it = history.begin();
85 for ( ; it != history.end(); ++it )
86 mHistory[ hist->insertItem( *it ) ] = *it;
87 connect( hist, SIGNAL( activated( int ) ), this, SLOT( histChosen( int ) ) );
88
89 bookm = new QPopupMenu( this );
90 bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) );
91 bookm->insertSeparator();
92
93 QStringList::Iterator it2 = bookmarks.begin();
94 for ( ; it2 != bookmarks.end(); ++it2 )
95 mBookmarks[ bookm->insertItem( *it2 ) ] = *it2;
96 connect( bookm, SIGNAL( activated( int ) ),
97 this, SLOT( bookmChosen( int ) ) );
98
99 menuBar()->insertItem( tr("&File"), file );
100 menuBar()->insertItem( tr("&Go"), go );
101 menuBar()->insertItem( tr( "History" ), hist );
102 menuBar()->insertItem( tr( "Bookmarks" ), bookm );
103// menuBar()->insertSeparator();
104// menuBar()->insertItem( tr("&Help"), help );
105
106 menuBar()->setItemEnabled( forwardId, FALSE);
107 menuBar()->setItemEnabled( backwardId, FALSE);
108 connect( browser, SIGNAL( backwardAvailable( bool ) ), this, SLOT( setBackwardAvailable( bool ) ) );
109 connect( browser, SIGNAL( forwardAvailable( bool ) ), this, SLOT( setForwardAvailable( bool ) ) );
110
111
112 QToolBar* toolbar = new QToolBar( this );
113 addToolBar( toolbar, "Toolbar");
114 QToolButton* button;
115
116 button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar );
117 connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) );
118 button->setEnabled( FALSE );
119 button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar );
120 connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) );
121 button->setEnabled( FALSE );
122 button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar );
123
124 toolbar->addSeparator();
125
126 pathCombo = new QComboBox( TRUE, toolbar );
127 connect( pathCombo, SIGNAL( activated( const QString & ) ), this, SLOT( pathSelected( const QString & ) ) );
128 toolbar->setStretchableWidget( pathCombo );
129
130// pathCombo->setMaximumWidth(190);
131// setRightJustification( TRUE );
132// setDockEnabled( Left, FALSE );
133// setDockEnabled( Right, FALSE );
134
135 pathCombo->insertItem( home_ );
136
137 browser->setFocus();
138
139
140}
141
142
143void HelpWindow::setBackwardAvailable( bool b)
144{
145 menuBar()->setItemEnabled( backwardId, b);
146}
147
148void HelpWindow::setForwardAvailable( bool b)
149{
150 menuBar()->setItemEnabled( forwardId, b);
151}
152
153
154void HelpWindow::textChanged()
155{
156 if ( browser->documentTitle().isNull() ) {
157 setCaption( "Gutenbrowser - Helpviewer - " + browser->context() );
158 selectedURL = browser->context();
159 }
160 else {
161 setCaption( "Gutenbrowser - Helpviewer - " + browser->documentTitle() ) ;
162 selectedURL = browser->documentTitle();
163 }
164
165 if ( !selectedURL.isEmpty() && pathCombo ) {
166 bool exists = FALSE;
167 int i;
168 for ( i = 0; i < pathCombo->count(); ++i ) {
169 if ( pathCombo->text( i ) == selectedURL ) {
170 exists = TRUE;
171 break;
172 }
173 }
174 if ( !exists ) {
175 pathCombo->insertItem( selectedURL, 0 );
176 pathCombo->setCurrentItem( 0 );
177 mHistory[ hist->insertItem( selectedURL ) ] = selectedURL;
178 } else
179 pathCombo->setCurrentItem( i );
180 selectedURL = QString::null;
181 }
182}
183
184HelpWindow::~HelpWindow()
185{
186 history.clear();
187 QMap<int, QString>::Iterator it = mHistory.begin();
188 for ( ; it != mHistory.end(); ++it )
189 history.append( *it );
190
191 QFile f( QDir::currentDirPath() + "/.history" );
192 f.open( IO_WriteOnly );
193 QDataStream s( &f );
194 s << history;
195 f.close();
196
197 bookmarks.clear();
198 QMap<int, QString>::Iterator it2 = mBookmarks.begin();
199 for ( ; it2 != mBookmarks.end(); ++it2 )
200 bookmarks.append( *it2 );
201
202 QFile f2( QDir::currentDirPath() + "/.bookmarks" );
203 f2.open( IO_WriteOnly );
204 QDataStream s2( &f2 );
205 s2 << bookmarks;
206 f2.close();
207}
208
209// void HelpWindow::about()
210// {
211// QMessageBox::about( this, "Gutenbrowser", "<p>Thanks to Trolltech for this</p>" );
212// }
213
214// void HelpWindow::aboutQt()
215// {
216// QMessageBox::aboutQt( this, "QBrowser" );
217// }
218
219void HelpWindow::openFile()
220{
221#ifndef QT_NO_FILEDIALOG
222 QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this );
223 if ( !fn.isEmpty() )
224 browser->setSource( fn );
225#endif
226}
227
228void HelpWindow::newWindow()
229{
230 ( new HelpWindow(browser->source(), "qbrowser") )->show();
231}
232
233void HelpWindow::print()
234{
235#ifndef QT_NO_PRINTER
236 QPrinter printer;
237 printer.setFullPage(TRUE);
238 if ( printer.setup() ) {
239 QPainter p( &printer );
240 QPaintDeviceMetrics metrics(p.device());
241 int dpix = metrics.logicalDpiX();
242 int dpiy = metrics.logicalDpiY();
243 const int margin = 72; // pt
244 QRect body(margin*dpix/72, margin*dpiy/72,
245 metrics.width()-margin*dpix/72*2,
246 metrics.height()-margin*dpiy/72*2 );
247 QFont font("times", 10);
248 QSimpleRichText richText( browser->text(), font, browser->context(), browser->styleSheet(),
249 browser->mimeSourceFactory(), body.height() );
250 richText.setWidth( &p, body.width() );
251 QRect view( body );
252 int page = 1;
253 do {
254 p.setClipRect( body );
255 richText.draw( &p, body.left(), body.top(), view, colorGroup() );
256 p.setClipping( FALSE );
257 view.moveBy( 0, body.height() );
258 p.translate( 0 , -body.height() );
259 p.setFont( font );
260 p.drawText( view.right() - p.fontMetrics().width( QString::number(page) ),
261 view.bottom() + p.fontMetrics().ascent() + 5, QString::number(page) );
262 if ( view.top() >= richText.height() )
263 break;
264 printer.newPage();
265 page++;
266 } while (TRUE);
267 }
268#endif
269}
270
271void HelpWindow::pathSelected( const QString &_path )
272{
273 browser->setSource( _path );
274 QMap<int, QString>::Iterator it = mHistory.begin();
275 bool exists = FALSE;
276 for ( ; it != mHistory.end(); ++it ) {
277 if ( *it == _path ) {
278 exists = TRUE;
279 break;
280 }
281 }
282 if ( !exists )
283 mHistory[ hist->insertItem( _path ) ] = _path;
284}
285
286void HelpWindow::readHistory()
287{
288 if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) {
289 QFile f( QDir::currentDirPath() + "/.history" );
290 f.open( IO_ReadOnly );
291 QDataStream s( &f );
292 s >> history;
293 f.close();
294 while ( history.count() > 20 )
295 history.remove( history.begin() );
296 }
297}
298
299void HelpWindow::readBookmarks()
300{
301 if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) {
302 QFile f( QDir::currentDirPath() + "/.bookmarks" );
303 f.open( IO_ReadOnly );
304 QDataStream s( &f );
305 s >> bookmarks;
306 f.close();
307 }
308}
309
310void HelpWindow::histChosen( int i )
311{
312 if ( mHistory.contains( i ) )
313 browser->setSource( mHistory[ i ] );
314}
315
316void HelpWindow::bookmChosen( int i )
317{
318 if ( mBookmarks.contains( i ) )
319 browser->setSource( mBookmarks[ i ] );
320}
321
322void HelpWindow::addBookmark()
323{
324 mBookmarks[ bookm->insertItem( caption() ) ] = caption();
325}
326
diff --git a/noncore/apps/opie-gutenbrowser/helpwindow.h b/noncore/apps/opie-gutenbrowser/helpwindow.h
new file mode 100644
index 0000000..8b3821b
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/helpwindow.h
@@ -0,0 +1,67 @@
1/****************************************************************************
2** $Id$
3**
4** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
5**
6** This file is part of an example program for Qt. This example
7** program may be used, distributed and modified without limitation.
8**
9 copyright : (C) 2000 -2004 by llornkcor
10 email : ljp@llornkcor.com
11*****************************************************************************/
12
13#ifndef HELPWINDOW_H
14#define HELPWINDOW_H
15
16#include <qmainwindow.h>
17#include <qtextbrowser.h>
18#include <qstringlist.h>
19#include <qmap.h>
20#include <qdir.h>
21#include <qevent.h>
22
23class QComboBox;
24class QPopupMenu;
25
26class HelpWindow : public QMainWindow
27{
28 Q_OBJECT
29public:
30 HelpWindow( const QString& home_, const QString& path, QWidget* parent = 0, const char *name=0 );
31 ~HelpWindow();
32
33private slots:
34 void setBackwardAvailable( bool );
35 void setForwardAvailable( bool );
36
37 void textChanged();
38// void about();
39// void aboutQt();
40 void openFile();
41 void newWindow();
42 void print();
43
44 void pathSelected( const QString & );
45 void histChosen( int );
46 void bookmChosen( int );
47 void addBookmark();
48private:
49 void readHistory();
50 void readBookmarks();
51
52 QTextBrowser* browser;
53 QComboBox *pathCombo;
54 int backwardId, forwardId;
55 QString selectedURL;
56 QStringList history, bookmarks;
57 QMap<int, QString> mHistory, mBookmarks;
58 QPopupMenu *hist, *bookm;
59
60};
61
62
63
64
65
66#endif
67
diff --git a/noncore/apps/opie-gutenbrowser/main.cpp b/noncore/apps/opie-gutenbrowser/main.cpp
new file mode 100644
index 0000000..5c3348c
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/main.cpp
@@ -0,0 +1,64 @@
1
2/***************************************************************************
3 main.cpp - description
4 -------------------
5 begin : Mon Jul 24 22:33:12 MDT 2000
6 copyright : (C) 2000 -2004 by llornkcor
7 email : ljp@llornkcor.com
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 ***************************************************************************/
13#include "gutenbrowser.h"
14#include <opie2/oapplicationfactory.h>
15
16using namespace Opie::Core;
17
18OPIE_EXPORT_APP( OApplicationFactory<Gutenbrowser> )
19
20// #ifdef QT_QWS_NONOPIE
21
22// #include <qpe/qpeapplication.h>
23// #include "gutenbrowser.h"
24// #include <qstring.h>
25// // #include <stdio.h>
26// // #include <stdlib.h>
27
28// int main(int argc, char *argv[]){
29 // QPEApplication a(argc, argv);
30// // char * psz;
31// // if (argc > 1) {
32// // for( int i=0; i < argc; i++) {
33// // psz = argv[i];
34// // if( psz[0] == '-' || psz[0] == '/' ) {
35// // // The next character is the option.
36// // switch( psz[1] )
37// // {
38// // case 'v': // help
39// // printf("Gutenbrowser: "VERSION"\n");
40// // // qDebug("Gutenbrowser: "VERSION);
41// // // return 0;
42// // break;
43// // case 't': // current time 19:34:20 04/03/00
44// // // return 0;
45// // break;
46// // case 'f': //
47// // // file_Name=argv[i+1];
48// // break;
49// // }
50// // }
51// // }
52// // }
53// // QNetworkProtocol::registerNetworkProtocol("http", new QNetworkProtocolFactory<Http>);
54// // qInitNetworkProtocols();//registers ftp protocol // for now
55 // Gutenbrowser *gutenbrowser=new Gutenbrowser();
56// // a.setMainWidget(gutenbrowser);
57 // a.showMainWidget(gutenbrowser,TRUE);
58 // gutenbrowser->showMaximized();
59 // gutenbrowser->show();
60 // return a.exec();
61// }
62
63
64// #endif
diff --git a/noncore/apps/opie-gutenbrowser/multiline_ex.cpp b/noncore/apps/opie-gutenbrowser/multiline_ex.cpp
new file mode 100644
index 0000000..16ddd67
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/multiline_ex.cpp
@@ -0,0 +1,133 @@
1/***************************************************************************
2 multiline_ex.cpp - description
3 -------------------
4 begin : Fri Aug 25 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17//#include <qmultilineedit.h>
18#include "multiline_ex.h"
19
20struct MultiLine_ExData
21//class MultiLine_ExData
22{
23public:
24 QColorGroup mypapcolgrp;
25 QColorGroup papcolgrp;
26 uint ownpalette : 1;
27};
28
29
30MultiLine_Ex::MultiLine_Ex( QWidget *parent , const char *name )
31 :QMultiLineEdit( parent,name )
32{
33
34#ifndef Q_WS_QWS
35// clearTableFlags( Tbl_autoHScrollBar | Tbl_autoVScrollBar); //for pre release testing
36#else
37// clearTableFlags( Tbl_autoVScrollBar ); //for pre release testing
38#endif
39// clearTableFlags( Tbl_autoHScrollBar | Tbl_autoVScrollBar); // for release
40// init();
41}
42
43void MultiLine_Ex::pageDown( bool mark )
44{
45 QMultiLineEdit::pageDown( mark );
46}
47
48void MultiLine_Ex::pageUp( bool mark )
49{
50 QMultiLineEdit::pageUp( mark );
51}
52
53
54void MultiLine_Ex::cursorLeft( bool mark, bool wrap )
55{
56 QMultiLineEdit::cursorLeft( mark, wrap );
57}
58
59void MultiLine_Ex::cursorRight( bool mark, bool wrap )
60{
61 QMultiLineEdit::cursorRight( mark, wrap );
62}
63
64void MultiLine_Ex::cursorUp( bool mark )
65{
66 QMultiLineEdit::cursorUp( mark );
67}
68
69void MultiLine_Ex::cursorDown( bool mark )
70{
71 QMultiLineEdit::cursorDown( mark );
72}
73
74
75//void MultiLine_Ex::setPaper( const QBrush& pap)
76//{
77
78//}
79
80int MultiLine_Ex::lastRow()
81{
82 return lastRowVisible();
83}
84
85int MultiLine_Ex::topRow()
86{
87 return topCell();
88}
89
90int MultiLine_Ex::editSize( )
91{
92 return viewHeight() / cellHeight();
93//scroll( 0, int yPixels );
94}
95
96void MultiLine_Ex::ScrollUp( int lines )
97{
98 for( int i = 0; i < lines; i++) {
99 this->setTopCell( topCell() + 1 );
100 }
101}
102
103void MultiLine_Ex::ScrollDown( int lines )
104{
105 for( int i = 0; i < lines; i++) {
106 this->setTopCell( topCell() -1 );
107 }
108}
109
110int MultiLine_Ex::lineHeight( int row)
111{
112 return this->cellHeight(row );
113}
114
115int MultiLine_Ex::Top( )
116{
117 return this->topCell();
118}
119
120int MultiLine_Ex::Rows( )
121{
122 return findRow ( 1 );
123}
124
125int MultiLine_Ex::PageSize()
126{
127 return viewHeight() / cellHeight() ;
128}
129
130bool MultiLine_Ex::hasSelectedText()
131{
132 return QMultiLineEdit::hasMarkedText();
133}
diff --git a/noncore/apps/opie-gutenbrowser/multiline_ex.h b/noncore/apps/opie-gutenbrowser/multiline_ex.h
new file mode 100644
index 0000000..5ef9c40
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/multiline_ex.h
@@ -0,0 +1,108 @@
1/**********************************************************************
2** $Id$
3**
4** Definition of MultiLine_Ex widget class
5** Copyright (C) 1992-1999 Troll Tech AS. All rights reserved.
6**
7** See the file LICENSE included in the distribution for the usage
8** and distribution terms, or http://www.troll.no/free-license.html.
9**
10 copyright : (C) 2000 -2004 by llornkcor
11 email : ljp@llornkcor.com
12*****************************************************************************/
13
14#ifndef MULTILINE_EX_H
15#define MULTILINE_EX_H
16
17#ifndef QT_H
18#include <qlist.h>
19#include <qstring.h>
20#include <qtableview.h>
21//#include <qtable.h>
22
23#include <qmultilineedit.h>
24#endif // QT_H
25
26struct MultiLine_ExData;
27//class MultiLine_ExData;
28
29class/* Q_EXPORT*/ MultiLine_Ex : public QMultiLineEdit
30{
31 Q_OBJECT
32public:
33 MultiLine_Ex( QWidget *parent=0, const char *name=0 );//:
34// QMultiLineEdit(QWidget *parent=0, QString& name=0 );
35 // ~MultiLine_Ex();
36
37// const char *textLine( int line ) const;
38// QString text() const;
39//int row;
40// int numLines() const;
41//
42// bool isReadOnly() const;
43// bool isOverwriteMode() const;
44//
45// void setFont( const QFont &font );
46// void insertLine( const char *s, int line = -1 );
47// void insertAt( const char *s, int line, int col );
48// void removeLine( int line );
49//
50// void cursorPosition( int *line, int *col ) const;
51// void setCursorPosition( int line, int col, bool mark = FALSE );
52// void getCursorPosition( int *line, int *col );
53// bool atBeginning() const;
54// bool atEnd() const;
55//
56// bool autoUpdate() const;
57// void setAutoUpdate( bool );
58//
59// void setFixedVisibleLines( int lines );
60public:
61int row;
62//setPaper( QBrush& pap);
63 bool hasSelectedText();
64 void pageUp( bool mark=FALSE );
65 void pageDown( bool mark=FALSE );
66 void cursorLeft( bool mark=FALSE, bool wrap = TRUE );
67 void cursorRight( bool mark=FALSE, bool wrap = TRUE );
68 void cursorUp( bool mark=FALSE );
69 void cursorDown( bool mark=FALSE );
70 int lastRow();
71 int topRow();
72 int editSize( );
73 int pageSize ;
74 int maxLineWidth() const;
75 void ScrollUp( int lines);
76 void ScrollDown( int lines);
77 int Rows();
78 int Top();
79 int lineHeight( int row );
80 int PageSize();
81public slots:
82// void clear();
83// void setText( const char * );
84// void append( const char * );
85// void deselect();
86// void selectAll();
87// void setReadOnly( bool );
88// void setOverwriteMode( bool );
89// void paste();
90// void copyText();
91// void cut();
92signals:
93// void textChanged();
94// void returnPressed();
95
96protected:
97protected:
98private slots:
99private:
100
101private: // Disabled copy constructor and operator=
102#if defined(Q_DISABLE_COPY)
103 MultiLine_Ex( const MultiLine_Ex & );
104 MultiLine_Ex &operator=( const MultiLine_Ex & );
105#endif
106};
107#endif
108
diff --git a/noncore/apps/opie-gutenbrowser/openetext.cpp b/noncore/apps/opie-gutenbrowser/openetext.cpp
new file mode 100644
index 0000000..40f35d6
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/openetext.cpp
@@ -0,0 +1,517 @@
1/***************************************************************************
2 openetext.cpp - description
3 begin : Sat Dec 4 1999
4 begin : Tue Jul 25 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7 ***************************************************************************/
8/***************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 ***************************************************************************/
14
15#include "gutenbrowser.h"
16#include "openetext.h"
17#include "editTitle.h"
18
19#include <qfileinfo.h>
20#include <qpe/applnk.h>
21#include <qpe/qpeapplication.h>
22
23#include <stdlib.h>
24#include <qtextstream.h>
25#include <qpe/config.h>
26
27#include <opie/ofiledialog.h>
28
29#if defined(_WS_WIN_)
30#include <windows.h>
31#else
32#include <unistd.h>
33#include "sys/stat.h"
34#endif
35
36OpenEtext::OpenEtext(QWidget *parent, QString name) : QDialog(parent,name,true)
37{
38 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
39 local_index=local_library+"GUTINDEX.ALL";
40 initDialog();
41 connect( QListBox_1, SIGNAL(selected ( int)),this, SLOT(select_title(int)) );
42
43 getTitles();
44}
45
46OpenEtext::~OpenEtext()
47{
48}
49
50void OpenEtext::getTitles()
51{
52 QListBox_1->clear();
53 Config config("Gutenbrowser");
54 config.setGroup( "Files" );
55 s_numofFiles = config.readEntry("NumberOfFiles", "0");
56 QLabel_1->setText( tr(
57 s_numofFiles+" etexts in your library."));
58 int i_numofFiles = s_numofFiles.toInt();
59 for (int i = 1; i <= i_numofFiles+1; i++) {
60 QString temp;
61 temp.setNum(i);
62 config.setGroup( "Files" );
63 QString ramble = config.readEntry(temp, "" );
64 config.setGroup( "Titles" );
65 title = config.readEntry(ramble, "");
66 if( !title.isEmpty()) {
67 QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), title, -1);
68 }
69 }
70}
71
72/*
73 opens selected title */
74void OpenEtext::OpenTitle()
75{
76 if( QListBox_1->currentItem() != -1)
77 select_title( QListBox_1->currentItem() );
78 else {
79 QString sMsg;
80 sMsg = "You must select an Etext to open";
81 QMessageBox::message( "Error",sMsg);
82 }
83}
84
85void OpenEtext::select_title(int index )
86{
87 OpenButton->setDown(TRUE);
88 QString temp;
89 temp.setNum( index + 1);
90 const char * title;
91 title = QListBox_1->text( index );
92 openFileTitle = title;
93 Config config("Gutenbrowser");
94 config.setGroup( "Files" );
95 file = config.readEntry(temp, "");
96 OpenEtext::accept();
97}
98
99/*
100 This function imports already existing etexts into the local library list*/
101void OpenEtext::open()
102{
103OpenFileButton->setDown(TRUE);
104 title = "";
105 QString currDir="";
106 QString filer;
107 QString name_file;
108 QString local ;
109 local = (QDir::homeDirPath () +"Applications/gutenbrowser");
110 QDir library( local);
111
112// fileBrowser *browseForFiles;
113// browseForFiles=new fileBrowser(this,"Browse for File", TRUE, 0, "guten/plain;text/plain");
114// // browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*");
115// browseForFiles->setFileView( 0);
116// browseForFiles->showMaximized();
117// browseForFiles->exec();
118// QString selFile= browseForFiles->selectedFileName;
119// fileList=browseForFiles->fileList;
120 Config cfg("Gutenbrowser");
121 cfg. setGroup ( "View" );
122 QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir());
123 QMap<QString, QStringList> map;
124 map.insert(tr("All"), QStringList() );
125 QStringList text;
126 text << "text/*";
127 map.insert(tr("Text"), text );
128 text << "*";
129 map.insert(tr("All"), text );
130
131 QString str = OFileDialog::getOpenFileName( 2, dir , QString::null, map);
132
133 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) {
134 filer = str;
135
136 qDebug("Open file: "+str);
137
138 // QStringList::ConstIterator f;
139// QString fileTemp;
140// for ( f = fileList.begin(); f != fileList.end(); f++ ) {
141// fileTemp = *f;
142// fileTemp.right( fileTemp.length()-5);
143// fileName = fileTemp;
144// if( !fileName.isEmpty() ){
145// filer = fileName;
146// } else { //filename is empty
147// // QString sMsg;
148// // sMsg = "Error opening library filelist "+fileName;
149// }
150
151 if( filer.right(4) == ".txt"
152 || filer.right(4) == ".TXT"
153 || filer.right(4) == ".etx"
154 || filer.right(4) == ".ETX"
155 || filer.right(4) == ".etx"
156 || filer.right(4) == ".ETX"
157 || filer.right(4) == ".zip"
158 || filer.right(4) == ".ZIP" ) {
159 QFileInfo zipFile( filer);
160 QString s_fileName = zipFile.fileName();
161 QString cmd;
162
163 if( s_fileName.right(4) == ".zip") { // unzip that sucker....
164 s_fileName = s_fileName.left( s_fileName.length() - 4);
165 if( chdir((const char*)local_library.latin1())!=0)
166 qDebug("chdir failed.");// QString cmd = "gunzip -d " + filer + " -d " + local_library;
167 cmd = "gunzip -S .zip " + filer;
168 fileName = local_library + s_fileName + ".txt";
169 system( cmd);
170 }
171// this renames the .txt to .etx!!
172 else /*if( s_fileName.right(4) == ".txt" || if( s_fileName.right(4) == ".TXT"))*/ {
173// qDebug("Filename is "+fileName);
174 s_fileName = fileName;
175 s_fileName.replace( s_fileName.length()-3,3,"gtn");// s_fileName.replace( s_fileName.length()-3,3,"etx");
176 rename(fileName.latin1(),s_fileName.latin1());
177 fileName = s_fileName;
178// qDebug("Filename is now "+fileName);
179 }
180 } else
181 fileName = str;
182
183 FindTitle(fileName);
184
185 QFileInfo fi( fileName);
186 name_file = fi.fileName();
187 name_file = name_file.left(name_file.length() - 4);
188
189 qDebug("Setting doclink");
190 DocLnk lnk;
191 qDebug("name is " + name_file);
192 lnk.setName(name_file); //sets file name
193 qDebug("Title is "+title);
194 lnk.setComment(title);
195
196 QListBox_1->clear();
197 getTitles();
198 qDebug("Filename is "+fileName);
199 lnk.setFile(fileName); //sets File property
200 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
201 lnk.setExec(fileName);
202 lnk.setIcon("gutenbrowser/Gutenbrowser");
203 if(!lnk.writeLink())
204 qDebug("Writing doclink did not work");
205
206 } // end of for each file name....
207 OpenFileButton->setDown(FALSE);
208}
209
210/*
211find the title in the config file */
212bool OpenEtext::FindTitle( QString filename)
213{
214 Config config("Gutenbrowser");
215 config.setGroup( "Files" );
216 QString s_numofFiles = config.readEntry("NumberOfFiles", "0");
217 int i_numofFiles = s_numofFiles.toInt();
218
219 QFileInfo fi(filename);
220 name = fi.fileName();
221 qDebug("filename to open is " + name);
222 QFile indexLib( filename);
223 bool findCheck = FALSE;
224 // int Titlenumber=0;
225
226 if ( indexLib.open( IO_ReadOnly) ) {
227 qDebug("file opened successfully");
228 QTextStream indexStream( &indexLib );
229 QString target = "Project Gutenberg Etext of";
230 QString target2 = "Project Gutenberg Etext";
231 QString target3 = "Project Gutenberg's Etext of";
232 QString target4 = "Project Gutenberg's Etext";
233 QString indexLine;
234 while ( !indexStream.eof() ) {
235 // until end of file..
236 indexLine = indexStream.readLine();
237 if( indexLine.find(target, 0, TRUE) > -1 && !findCheck) {findCheck = TRUE;
238 title = indexLine.mid( indexLine.find(target, 0, TRUE) + (target.length()) , indexLine.find("\r", 0, TRUE));
239 title = title.left( title.find( "*",0, TRUE));
240 title = title.stripWhiteSpace ();
241// qDebug("Found the title 1 and it is %s", title.latin1());
242// QListBox_1->insertItem ( title);
243 }
244 if( indexLine.find( target2, 0, TRUE) > -1 && !findCheck) {
245 findCheck = TRUE;
246 title = indexLine.mid( indexLine.find( target2, 0, TRUE ) + ( target2.length()) , indexLine.find("\r", 0, TRUE) );
247 title = title.left( title.find( "*",0, TRUE));
248 title = title.stripWhiteSpace ();
249// qDebug("Found the title 2 and it is %s", title.latin1());
250// QListBox_1->insertItem ( title);
251 }
252 if( indexLine.find( target3, 0, TRUE) > -1 && !findCheck) {
253 findCheck = TRUE;
254 title = indexLine.mid( indexLine.find( target3, 0, TRUE) + ( target3.length()) , indexLine.find("\r", 0, TRUE));
255 title = title.left( title.find( "*",0, TRUE));
256 title = title.stripWhiteSpace ();
257// qDebug("Found the title 3 and it is %s", title.latin1());
258 }
259 if( indexLine.find( target4, 0, TRUE) > -1 && !findCheck) {
260 findCheck = TRUE;
261 title = indexLine.mid( indexLine.find( target4, 0, TRUE) + ( target4.length()) , indexLine.find("\r", 0, TRUE));
262 title = title.left( title.find( "*",0, TRUE));
263 title = title.stripWhiteSpace ();
264// qDebug("Found the title 4 and it is %s", title.latin1());
265 }
266 } //endof file
267 indexLib.close();
268
269 if( !findCheck || title.length() < 2) {
270 qDebug("Trying hard to find title from GUTINDEX.ALL");
271 title = titleFromLibrary( filename);
272 findCheck = TRUE;
273 }
274
275 if ( checkConf() == false && findCheck == TRUE) {
276
277 config.setGroup( "Files");
278 config.writeEntry("NumberOfFiles",i_numofFiles + 1 );
279 QString interger;
280 interger.setNum( i_numofFiles +1);
281 config.writeEntry(interger, filename);
282 config.setGroup( "Titles" );
283 for (int i = 1; i <= i_numofFiles; i++) { //find dup titles in config file
284 QString temp;
285 temp.setNum(i);
286 config.setGroup( "Files" );
287 QString ramble = config.readEntry(temp, "" );
288 config.setGroup( "Titles" );
289 QString title1 = config.readEntry(ramble, "");
290 if(title1==title)
291 title+="1";
292 i= i_numofFiles+1;
293 }
294 if(title.length()<3) {
295// qDebug("title is empty");
296 title="Unknown";
297 }
298 config.writeEntry( filename,title);
299 }
300 } else {
301 QString sMsg;
302 sMsg = "Error opening library file: "+filename;
303 printf( sMsg+"\n");
304 }
305 return true;
306}
307
308QString OpenEtext::titleFromLibrary( QString fileName)
309{
310 QFile indexLib( local_index);
311 QString target;
312 int find1 = fileName.findRev("/",-1,TRUE) + 1;
313 int find2 = fileName.findRev(".gtn",-1,TRUE) - find1;
314 if(find2==-1-find1)
315 int find2 = fileName.findRev(".etx",-1,TRUE) - find1;
316 else if(find2==-1-find1)
317 int find2 = fileName.findRev(".txt",-1,TRUE) - find1;
318
319 target = fileName.mid( find1, find2 );
320 QString checker = target.right(1);
321 bool ok;
322 checker.toInt( &ok,10);
323 if( ok) {
324 target = target.left( target.length()-1);
325 checker = target.right(1);
326 ok = FALSE;
327 checker.toInt( &ok,10);
328 if( ok) {
329 target = target.left( target.length()-1);
330 }
331 }
332 if ( indexLib.open( IO_ReadOnly) ) {
333 // file opened successfully
334 QTextStream indexStream( &indexLib );
335 QString indexLine;
336 bool findCheck = FALSE;
337 while ( !indexStream.atEnd() ) { // until end of file..
338 indexLine = indexStream.readLine();
339
340 if( indexLine.find( target,0,FALSE) > 0 ) {
341 findCheck = TRUE;
342 title = indexLine.mid( 9, 50);
343// title = indexLine.mid( 26, indexLine.length() );
344 title = title.stripWhiteSpace ();
345// qDebug("Finally Found the title and it is\n %s", title.latin1());
346// QListBox_1->insertItem ( title);
347 }
348 } //end while loop
349 }
350 else
351 qDebug("Error opening library index "+ local_index);
352 return title;
353}
354
355bool OpenEtext::checkConf()
356{
357 QString file = fileName;
358 Config config("Gutenbrowser");
359 config.setGroup( "Files" );
360 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
361 int i_numofFiles = s_numofFiles.toInt();
362
363 for (int i = 1; i <= i_numofFiles; i++) {
364 QString temp;
365 temp.setNum(i);
366 config.setGroup( "Files");
367 QString ramble = config.readEntry(temp, "" );
368
369 if(ramble == file ) {
370 return true;
371 }
372 }
373 return false;
374}
375
376void OpenEtext::remove()
377{
378 title_text = QListBox_1->text( QListBox_1->currentItem() );
379 title_text=title_text.stripWhiteSpace();
380 QString msg ="<p>Do you really want to REMOVE\n" +title_text +"?\nThis will not delete the file.</P>";
381 switch( QMessageBox::information( this, (tr("Remove Etext")),
382 (tr(msg)),
383 (tr("&Yes")), (tr("&Cancel")), 0 )){
384 case 0: // Yes clicked,
385 removeSelection();
386 QListBox_1->clear();
387 getTitles();
388 break;
389 case 1: // Cancel
390 break;
391 };
392}
393
394/*
395 this removes selected title entry*/
396void OpenEtext::removeSelection()
397{
398 Config config("Gutenbrowser");
399 config.setGroup( "Files" );
400 s_numofFiles = config.readEntry("NumberOfFiles", "0");
401 int rem=0;
402 int i_numofFiles = s_numofFiles.toInt();
403 QString fileNum2;
404 QString fileNum;
405
406 for (int i = 1; i <= i_numofFiles; i++) {
407 fileNum.setNum(i);
408 config.setGroup( "Files" );
409
410 QString s_filename = config.readEntry(fileNum, "" );
411 config.setGroup( "Titles" );
412
413 QString file_title = config.readEntry( s_filename, "");
414 if(title_text == file_title) {
415 rem=i;
416//qDebug("file title to remove is "+file_title);
417 selFile = s_filename;
418 config.removeEntry( s_filename); //removes file=title
419 }
420 }
421 config.setGroup( "Files" );
422
423 for(int fg = rem; fg < i_numofFiles ; fg++ ) { //this rewrites Files number entry
424 fileNum.setNum(fg);
425 fileNum2.setNum( fg + 1);
426
427 QString s_filename2 = config.readEntry(fileNum2, "" );
428
429 if (!s_filename2.isEmpty()) {
430 config.writeEntry(fileNum, s_filename2 );
431 }
432 }
433 config.writeEntry("NumberOfFiles", i_numofFiles - 1 );
434 config.removeEntry(fileNum2);
435// remFile();
436}
437
438/*
439 removes file title name from list and config file*/
440void OpenEtext::remFile()
441{
442 Config config("Gutenbrowser");
443 config.setGroup( "Files" );
444 QString remFile;
445 s_numofFiles = config.readEntry("NumberOfFiles", "0");
446 int i_numofFiles = s_numofFiles.toInt();
447 for (int i = 1; i <= i_numofFiles; i++) {
448 QString fileNum;
449 fileNum.setNum(i);
450 QString s_filename = config.readEntry(fileNum, "" );
451
452 if( s_filename == selFile) {
453 config.removeEntry(selFile);
454
455 for(int fg = i_numofFiles - i; fg < i_numofFiles ; fg++ ) { //this rewrites Files number entry
456 QString fileNum2;
457 fileNum2.setNum( fg + 1);
458 QString s_filename2 = config.readEntry(fileNum2, "" );
459
460 if (!s_filename2.isEmpty()) {
461 config.writeEntry(fileNum, s_filename2 );
462 }
463 }
464 }
465 }
466 config.writeEntry("NumberOfFiles", i_numofFiles - 1 );
467 config.removeEntry(s_numofFiles);
468
469 QListBox_1->triggerUpdate(true);
470}
471
472/*
473sorts the list*/
474void OpenEtext::scan() {
475
476 QListBox_1->sort(TRUE);
477 QListBox_1->triggerUpdate(true);
478}
479
480void OpenEtext::editTitle() {
481
482 int currentItem=QListBox_1->currentItem();
483 QString title_text = QListBox_1->text( currentItem);
484//qDebug("Selected "+title_text);
485
486 Config config("Gutenbrowser");
487 config.setGroup( "Files" );
488 s_numofFiles = config.readEntry("NumberOfFiles", "0");
489 int i_numofFiles = s_numofFiles.toInt();
490 QString fileNum;
491 for (int i = 1; i <= i_numofFiles+1; i++) {
492
493 fileNum.setNum(i);
494 config.setGroup( "Files" );
495 QString s_filename = config.readEntry(fileNum, "" );
496 config.setGroup( "Titles" );
497 QString file_title = config.readEntry( s_filename, "");
498//qDebug("file_title is "+file_title);
499 if(title_text == file_title ) {
500 selFile = s_filename;
501//qDebug("Edit: "+ file_title );
502 i=i_numofFiles+1;
503 Edit_Title *titleEdit;
504 titleEdit = new Edit_Title(this,file_title ,TRUE);
505 if(titleEdit->exec() !=0) {
506//qDebug(titleEdit->newTitle);
507 config.writeEntry( s_filename, titleEdit->newTitle);
508 QListBox_1->removeItem(currentItem);
509 QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), titleEdit->newTitle, currentItem);
510 }
511 }
512 }
513
514// getTitles();
515 QListBox_1->triggerUpdate(true);
516}
517
diff --git a/noncore/apps/opie-gutenbrowser/openetext.h b/noncore/apps/opie-gutenbrowser/openetext.h
new file mode 100644
index 0000000..6db71c4
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/openetext.h
@@ -0,0 +1,82 @@
1/***************************************************************************
2 openetext.h - description
3 -------------------
4 begin : Tue Jul 25 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7 ***************************************************************************/
8/***************************************************************************
9 * *
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 *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef OPENETEXT_H
18#define OPENETEXT_H
19#include "gutenbrowser.h"
20#include <qdialog.h>
21#include <qstringlist.h>
22#ifndef Q_WS_QWS
23#include <qfiledialog.h>
24#endif
25//#include <fileselector.h>
26#include <qlabel.h>
27#include <qlistbox.h>
28#include <qpushbutton.h>
29#include <qstrlist.h>
30#include <qwidget.h>
31//#include "CConfigFile.h"
32
33/**
34 *@author llornkcor
35 */
36
37class OpenEtext : public QDialog {
38 Q_OBJECT
39public:
40 OpenEtext(QWidget *parent, QString name);
41 ~OpenEtext();
42
43 QPushButton* RemoveButton, * OpenFileButton, * OpenButton, *scanButton, *editButton;
44 void getTitles();
45 QString title;
46 QString file;
47 QString selFile;
48 QString s_numofFiles;
49 QString fileName;
50 QString name;
51 QString openFileTitle;
52 QStringList fileList;
53 QString local_library;
54 QString local_index;
55 QString title_text;
56 void remFile();
57 void removeSelection();
58 QString titleFromLibrary( const QString fileName);
59 bool FindTitle( const QString filename);
60 bool checkConf();
61// CConfigFile *config;
62
63protected:
64
65 void initDialog();
66 QListBox *QListBox_1;
67 QPushButton *QPushButton_OK;
68 QPushButton *QPushButton_Cancel;
69 QLabel *QLabel_1;
70
71private:
72private slots:
73
74 virtual void select_title(int index );
75 virtual void remove();
76 virtual void scan();
77 virtual void open();
78 virtual void OpenTitle();
79 virtual void editTitle();
80};
81
82#endif
diff --git a/noncore/apps/opie-gutenbrowser/openetextdata.cpp b/noncore/apps/opie-gutenbrowser/openetextdata.cpp
new file mode 100644
index 0000000..36b3e0e
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/openetextdata.cpp
@@ -0,0 +1,77 @@
1/***************************************************************************
2 openetextdata.cpp - description
3 -------------------
4 begin : Sat Dec 4 1999
5 begin : Tue Jul 25 2000
6 copyright : (C) 2000 -2004 by llornkcor
7 email : ljp@llornkcor.com
8 ***************************************************************************/
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "openetext.h"
19#include <qtooltip.h>
20#include <qlayout.h>
21#include <qpe/config.h>
22
23void OpenEtext::initDialog()
24{
25 this->setCaption("gutenbrowser local library");
26
27 QGridLayout *layout = new QGridLayout( this );
28 layout->setSpacing( 4 );
29 layout->setMargin( 4 );
30
31// local_index = local_library +"PGWHOLE.TXT";
32 local_index = local_library +"GUTINDEX.ALL";
33
34 QListBox_1= new QListBox(this,"ListBox");
35 QListBox_1->setAutoUpdate( TRUE );
36
37 OpenButton = new QPushButton( this, "OpenButton" );
38 OpenButton->setFocusPolicy( QWidget::TabFocus );
39 OpenButton->setText("&Open");
40 OpenFileButton = new QPushButton( this, "addButton" );
41 OpenFileButton->setText("&Import");
42
43 RemoveButton = new QPushButton( this, "removeButton" );
44 RemoveButton->setFocusPolicy( QWidget::TabFocus );
45 RemoveButton->setText("&Delete");
46
47 QPushButton * scanButton;
48 scanButton= new QPushButton( this, "scanButton" );
49 scanButton->setFocusPolicy( QWidget::TabFocus );
50
51 scanButton->setText("&Sort");
52 editButton= new QPushButton(this,"EditBtn");
53 editButton->setText("&Edit");
54
55 QLabel_1= new QLabel(this,"label");
56
57 layout->addMultiCellWidget( OpenButton, 0, 0, 0, 0 );
58 layout->addMultiCellWidget( OpenFileButton, 0, 0, 1, 1 );
59 layout->addMultiCellWidget( RemoveButton, 0, 0, 2, 2 );
60 layout->addMultiCellWidget( scanButton, 0, 0, 3, 3 );
61 layout->addMultiCellWidget( editButton, 0, 0, 5, 5 );
62
63 layout->addMultiCellWidget( QLabel_1, 1, 1, 0, 5 );
64 layout->addMultiCellWidget( QListBox_1, 2, 2, 0, 5 );
65
66 OpenButton->setFixedHeight(22);
67 OpenFileButton->setFixedHeight(22);
68 RemoveButton->setFixedHeight(22);
69 scanButton->setFixedHeight(22);
70 editButton->setFixedHeight(22);
71
72 connect( OpenButton, SIGNAL(released()), SLOT( OpenTitle()) );
73 connect( OpenFileButton, SIGNAL(released()), SLOT(open()) );
74 connect( RemoveButton, SIGNAL(released()), SLOT(remove()) );
75 connect( scanButton, SIGNAL(released()), SLOT( scan()) );
76 connect( editButton, SIGNAL(released()),SLOT(editTitle()));
77}
diff --git a/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.control b/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.control
new file mode 100644
index 0000000..b3a9157
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.control
@@ -0,0 +1,11 @@
1Package: opie-gutenbrowser
2Files: bin/gutenbrowser apps/Applications/gutenbrowser.desktop etc/gutenbrowser/* pics/gutenbrowser/*
3Priority: optional
4Section: opie
5Maintainer: ljp <lpotter@trolltech.com>
6Source: opie.handhelds.org
7Architecture: arm
8Version: $QPE_VERSION-$SUB_VERSION
9Depends: ftplib, libopie
10Description: Etext read for the Project Gutenberg.
11
diff --git a/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.pro b/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.pro
new file mode 100644
index 0000000..e34e922
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.pro
@@ -0,0 +1,45 @@
1TEMPLATE = app
2CONFIG += qt warn_on release quick-app
3#CONFIG += qt warn_on release qpp
4HEADERS = LibraryDialog.h \
5 SearchDialog.h \
6 SearchResults.h \
7 helpme.h \
8 multiline_ex.h \
9 openetext.h \
10 editTitle.h \
11 fontDialog.h \
12 optionsDialog.h \
13 helpwindow.h \
14 output.h \
15 NetworkDialog.h \
16 gutenbrowser.h \
17 resource.h
18SOURCES = LibraryDialog.cpp \
19 LibraryDialogData.cpp \
20 SearchDialog.cpp \
21 SearchResults.cpp \
22 browserDialog.cpp \
23 helpme.cpp \
24 multiline_ex.cpp \
25 fontDialog.cpp \
26 openetext.cpp \
27 openetextdata.cpp \
28 editTitle.cpp \
29 ftpsitedlg.cpp \
30 optionsDialog.cpp \
31 optionsDialogData.cpp \
32 helpwindow.cpp \
33 output.cpp \
34 NetworkDialog.cpp \
35 gutenbrowserData.cpp \
36 gutenbrowser.cpp \
37 main.cpp
38TARGET = gutenbrowser
39
40INCLUDEPATH += $(OPIEDIR)/include
41DEPENDPATH += $(OPIEDIR)/include
42DESTDIR = $(OPIEDIR)/bin
43LIBS += -lqpe -lpthread -lftplib -lopie
44
45include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/opie-gutenbrowser/optionsDialog.cpp b/noncore/apps/opie-gutenbrowser/optionsDialog.cpp
new file mode 100644
index 0000000..bfd9c26
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/optionsDialog.cpp
@@ -0,0 +1,207 @@
1/***************************************************************************
2 optionsDialog.cpp - description
3 -------------------
4 begin : Tue Jul 25 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7 ***************************************************************************/
8/***************************************************************************
9 * *
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 *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#include "optionsDialog.h"
17#include <qpe/config.h>
18#include "fontDialog.h"
19
20// #include <unistd.h>
21// #include <stdio.h>
22// #include <stdlib.h>
23
24//#include "ftpsitedlg.h"
25//#include "browserDialog.h"
26//#define Inherited QDialog
27#include <qfont.h>
28#include <qcheckbox.h>
29#include <qcombobox.h>
30#include <qlabel.h>
31#include <qlistbox.h>
32#include <qpushbutton.h>
33#include <qtabwidget.h>
34#include <qwidget.h>
35#include <qlayout.h>
36#include <qvariant.h>
37#include <qtooltip.h>
38#ifndef Q_WS_QWS
39#include <qwhatsthis.h>
40#endif
41/*
42 * The dialog will by default be modeless, unless you set 'modal' to
43 * TRUE to construct a modal dialog.
44 */
45optionsDialog::optionsDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
46 : QDialog( parent, name, modal, fl )
47{
48 if ( !name )
49 setName( "optionsDialog" );
50 changedFonts=FALSE;
51 // styleChanged=FALSE;
52// connect( this,SIGNAL( aboutToQuit()),SLOT( OnExit()) );
53 b_qExit=TRUE;
54 initDialog();
55
56 ftpSiteDlg();
57 BrowserDlg();
58 FontDialog();
59}
60
61optionsDialog::~optionsDialog()
62{
63//qDebug("OnExit()");
64// writeConfig();
65}
66
67/// optionsDialog
68void optionsDialog::doOptions() {
69
70// config.read();
71 getConfig();
72}
73
74void optionsDialog::getConfig()
75{
76 Config config("Gutenbrowser");
77 config.setGroup( "FTPsite" ); // ftp server config
78 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
79 ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
80
81 TextLabel3->setText( "Current ftp server:\n"+ftp_host/* + ftp_base_dir */);
82
83 config.setGroup( "Proxy" ); // use ftp/http config
84 if( config.readEntry("IsChecked", "FALSE") == "TRUE") {
85 Ftp_CheckBox->setChecked( FALSE);
86 } else {
87 Ftp_CheckBox->setChecked( TRUE);
88 }
89
90 config.setGroup( "HttpServer" );
91 QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org");
92 if( s_http == "http://sailor.gutenbook.org")
93 ComboBox1->setCurrentItem(0);
94 else
95 ComboBox1->setCurrentItem(1);
96
97 config.setGroup( "Browser" );
98 brow = config.readEntry("Preferred", "Opera");
99 browserName=brow;
100
101 TextLabel3_3->setText( "Current http browser:\n"+brow );
102
103 config.setGroup( "Geometry" );
104
105 // bool ok2;
106 QString temp;
107// config.setGroup( "StyleIze" );
108// temp = config.readEntry( "Style", "0");
109// int i_style=temp.toInt( &ok2,10);
110// #ifndef Q_WS_QWS
111
112// if( i_style==0){ styleInt=0; ComboBoxStyle->setCurrentItem(0);}//"styleMetal"));
113// if( i_style==1) { styleInt=1; ComboBoxStyle->setCurrentItem(1);}//"styleWindows") );
114// if( i_style==2) { styleInt=2; ComboBoxStyle->setCurrentItem(2);}//"stylePlatinum"));
115// if( i_style==2){ styleInt=2; ComboBoxStyle->setCurrentItem(2);}//"styleCDE") );
116// if( i_style==3) { styleInt=3; ComboBoxStyle->setCurrentItem(3);}//"styleMotif") );
117// if( i_style==4) { styleInt=4; ComboBoxStyle->setCurrentItem(4);}//"styleMotifPlus"));
118// // if( i_style==5) { styleInt=5; ComboBoxStyle->setCurrentItem(5);}//"styleWood") );
119// if( i_style==6) { styleInt=6; ComboBoxStyle->setCurrentItem(6);}//"styleSgi") );
120// if( i_style==7) { styleInt=7; ComboBoxStyle->setCurrentItem(7);}//"stylePlatinumPlus") );
121// if( i_style==9){ styleInt=9; ComboBoxStyle->setCurrentItem(9);}//"styleLace"));
122// if( i_style==10){ styleInt=10; ComboBoxStyle->setCurrentItem(10);}//"styleLacePlus"));
123// #endif
124 config.setGroup("General");
125 QString qExit=config.readEntry("queryExit","TRUE");
126 if(qExit=="TRUE") {
127 cb_queryExit->setChecked(TRUE);
128 qDebug("Config Setting b_qExit=TRUE;");
129 b_qExit=TRUE;
130 } else {
131 cb_queryExit->setChecked(FALSE);
132 qDebug("ConfigSetting b_qExit=FALSE;");
133 b_qExit=FALSE;
134 }
135
136
137 useWordWrap_CheckBox->setChecked( config.readBoolEntry("WordWrap", 1));
138 QString downDir=config.readEntry( "DownloadDirectory",local_library);
139 downloadDirEdit->setText(downDir);
140} // end getConfig
141
142// // void optionsDialog::setStyle( int index) {
143
144// // qDebug("Set style%d",index);
145// // //int styleInt= index;
146// // styleChanged=TRUE;
147// // if( ComboBoxStyle->currentItem()==0) styleInt=0;//"styleMetal"));
148// // if( ComboBoxStyle->currentItem()==1) styleInt=1;//"styleWindows") );
149// // if( ComboBoxStyle->currentItem()==2) styleInt=2;//"stylePlatinum"));
150// // // if( ComboBoxStyle->currentItem()==2) styleInt=2;//"styleCDE") );
151// // // if( ComboBoxStyle->currentItem()==3) styleInt=3;//"styleMotif") );
152// // // if( ComboBoxStyle->currentItem()==4) styleInt=4;//"styleMotifPlus"));
153// // // // if( ComboBoxStyle->currentItem()==5) styleInt=5;//"styleWood") );
154// // // if( ComboBoxStyle->currentItem()==6) styleInt=6;//"styleSgi") );
155// // // if( ComboBoxStyle->currentItem()==7) styleInt=7;//"stylePlatinumPlus") );
156// // // if( ComboBoxStyle->currentItem()==9) styleInt=9;//"styleLace"));
157// // // if( ComboBoxStyle->currentItem()==10) styleInt=10;//"styleLacePlus"));
158// // QString temp;
159// // temp.setNum(styleInt, 10);
160// // Config config("Gutenbrowser");
161// // config.setGroup( "StyleIze" );
162// // config.writeEntry( "Style", temp);
163// // config.write();
164// // }
165
166void optionsDialog::slotQueryExit()
167{
168 Config config("Gutenbrowser");
169 config.setGroup("General");
170 qDebug("writing queryExit");
171 if(cb_queryExit->isChecked()) {
172 b_qExit=TRUE;
173 config.writeEntry("queryExit","TRUE");
174 qDebug("WritingConfig queryExit=TRUE");
175 } else {
176 b_qExit=FALSE;
177 config.writeEntry("queryExit","FALSE");
178 qDebug("WritingConfig queryExit=FALSE");
179 }
180 config.write();
181}
182
183
184// void optionsDialog::slotUseSplit()
185// {
186
187// }
188
189// void optionsDialog::lineEditChanged(const QString &editText) {
190// qDebug(editText);
191// }
192
193void optionsDialog::changeFonts()
194{
195 changedFonts=TRUE;
196}
197
198
199void optionsDialog::slotWordWrap(bool b) {
200
201 Config config("Gutenbrowser");
202 config.setGroup("General");
203
204 config.writeEntry("WordWrap", b);
205 config.write();
206
207}
diff --git a/noncore/apps/opie-gutenbrowser/optionsDialog.h b/noncore/apps/opie-gutenbrowser/optionsDialog.h
new file mode 100644
index 0000000..091b169
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/optionsDialog.h
@@ -0,0 +1,112 @@
1/***************************************************************************
2 optionsDialog.h - description
3 -------------------
4 begin : Tue Jul 25 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 ***************************************************************************/
13#ifndef OPTIONSDIALOG_H
14#define OPTIONSDIALOG_H
15
16#include "gutenbrowser.h"
17#include "fontDialog.h"
18
19#include <qvariant.h>
20#include <qdialog.h>
21#include <qlineedit.h>
22#include <qpe/fontdatabase.h>
23#include <qfont.h>
24
25class QVBoxLayout;
26class QHBoxLayout;
27class QGridLayout;
28class QCheckBox;
29class QComboBox;
30class QLabel;
31class QListBox;
32class QListBoxItem;
33class QPushButton;
34class QTabWidget;
35class QWidget;
36
37class optionsDialog : public QDialog
38{
39 Q_OBJECT
40
41 public:
42 optionsDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
43 ~optionsDialog();
44
45 QListBox* listBox,*http_ListBox1;
46 QPushButton* buttonOk, *fontChangeButton,*PushButton_Browse;
47 QTabWidget* tabWidget;
48 QWidget *tab, *Widget3, * Widget2, *fontWidget;
49 QCheckBox* Ftp_CheckBox,*Http_CheckBox;
50 QString s_Wrap;
51
52 QCheckBox* useWordWrap_CheckBox;
53 QCheckBox* cb_queryExit;
54 bool b_qExit;
55 QLabel* TextLabel2,*TextLabel3;
56 QListBox* ftp_QListBox_1;
57 QPushButton* ftp_DownloadButton;
58 QLabel* TextLabel3_3, *TextLabel4,*TextLabel5;
59 QComboBox *ComboBox1 ;///* * ComboBoxStyle,*/ ;
60 QLineEdit *downloadDirEdit;
61 bool changedFonts;
62 /////////////////////////////////////////////////////
63
64 void initDialog();
65 void initConnections();
66
67 // CConfigFile *config;
68 QString ftp_base_dir, ftp_host, brow, local_library;
69
70 // ftpsite
71 bool useIcon;
72 bool parseFtpList(QString outputFile);
73 QString ftpSite, ListFile, s_site, host, base_dir, browserName;
74// int styleInt;
75 // font dialog
76 FontDialog *fontDlg;
77
78// bool styleChanged;
79 protected:
80 void openSiteList();
81 void doOptions();
82 void ftpSiteDlg();
83 void BrowserDlg();
84 public slots:
85 void getConfig();
86 // void writeConfig();
87 // void iconCheckB();
88 void getSite();
89 void select_site( const char *index );
90 void getSelection( QListBoxItem *item);
91 // void lineEditChanged(const QString &);
92 private slots:
93 void slotWordWrap(bool);
94 void slotQueryExit();
95 void changeFonts();
96 protected slots:
97 // virtual void OnOK();
98 void listBoxMainSel( int index);
99// void setStyle( int index);
100 void setHttp(int);
101 // virtual void OptionsFtpClicked();
102 // virtual void httpCheckB();
103 // virtual void FtpCheckB();
104 // virtual void slotUseSplit();
105 // virtual void goBrowser(const QString&);
106 // virtual void chooseBrowser();
107 void select_title(int index);
108 void BrowseSelected();
109
110};
111
112#endif // OPTIONSDIALOG_H
diff --git a/noncore/apps/opie-gutenbrowser/optionsDialogData.cpp b/noncore/apps/opie-gutenbrowser/optionsDialogData.cpp
new file mode 100644
index 0000000..e03fa2c
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/optionsDialogData.cpp
@@ -0,0 +1,171 @@
1/***************************************************************************
2 optionsDialogData.cpp - description
3 -------------------
4 begin : Tue Jul 25 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7 ***************************************************************************/
8/***************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 ***************************************************************************/
14#include <qpixmap.h>
15#include "optionsDialog.h"
16#include "fontDialog.h"
17
18#include <qlabel.h>
19#include <qpushbutton.h>
20#include <qlineedit.h>
21#include <qcombobox.h>
22
23void optionsDialog::initDialog()
24{
25 QWidget *d = QApplication::desktop();
26 int width = d->width();
27 int height = d->height();
28
29 QGridLayout *layout = new QGridLayout( this );
30 layout->setSpacing(2);
31 layout->setMargin(2);
32
33 tabWidget = new QTabWidget( this, "tabWidget" );
34 layout->addMultiCellWidget( tabWidget, 0, 0, 0, 3);
35
36 Widget2 = new QWidget( tabWidget, "Widget2" );
37
38 QGridLayout *layout2 = new QGridLayout(Widget2 );
39 layout2->setSpacing(2);
40 layout2->setMargin(2);
41
42// Http_CheckBox = new QCheckBox( Widget2, "Http_CheckBox" );
43
44 QLabel *downLabel= new QLabel(Widget2,"Label1");
45 downLabel->setText("Download Directory:");
46 downLabel->setMaximumHeight(30);
47
48 downloadDirEdit = new QLineEdit(Widget2,"downloadDir");
49
50// ComboBoxStyle = new QComboBox( FALSE, Widget2, "ComboBoxStyle" );
51// ComboBoxStyle->insertItem( tr( "styleMetal") );
52// ComboBoxStyle->insertItem( tr( "styleWindows") );
53// ComboBoxStyle->insertItem( tr( "default style") );
54
55 cb_queryExit = new QCheckBox( Widget2, "cb_queryExit" );
56 cb_queryExit->setText("Query before exit.");
57
58 useWordWrap_CheckBox = new QCheckBox( Widget2, "WordWrap_CheckBox" );
59 useWordWrap_CheckBox->setText("Use Word Wrap");
60// Http_CheckBox->setText("Use pg index instead of ftp library index" ) ;
61 Ftp_CheckBox = new QCheckBox( Widget2, "Ftp_CheckBox" );
62 Ftp_CheckBox->setText("Use FTP");
63 Ftp_CheckBox->hide();
64
65 layout2->addMultiCellWidget( downLabel, 0, 0, 0, 2);
66 // downloadDirEdit->setMaximumWidth( 200);
67 layout2->addMultiCellWidget( downloadDirEdit, 1, 1, 0, 0);
68 // layout2->addMultiCellWidget( ComboBoxStyle, 3, 3, 0, 0);
69 layout2->addMultiCellWidget( cb_queryExit, 2, 2, 0, 1);
70 layout2->addMultiCellWidget( useWordWrap_CheckBox, 3, 3, 0, 1);
71 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
72 layout2->addItem( spacer, 4, 0 );
73// downloadDirEdit->hide();
74
75//////////////////////////////////////////////////////////
76 tabWidget->insertTab( Widget2, tr( "Main" ) );
77
78 Widget3 = new QWidget( tabWidget, "Widget3" );
79
80 QGridLayout *layout3 = new QGridLayout(Widget3 );
81 layout3->setSpacing(2);
82 layout3->setMargin(4);
83
84 TextLabel3 = new QLabel( Widget3, "TextLabel3" );
85 // TextLabel3->setProperty( "text", tr( "Current ftp server:/n" ) );
86 ftp_QListBox_1 = new QListBox( Widget3, "ftp_QListBox_1" );
87 ftp_DownloadButton = new QPushButton( Widget3, "ftp_DownloadButton" );
88
89//////////////////////////////////////////////////////////
90 tabWidget->insertTab( Widget3, tr( "FTP" ) );
91 tab = new QWidget( tabWidget, "tab" );
92
93 TextLabel3_3 = new QLabel( tab, "TextLabel3_3" );
94
95// TextLabel4 = new QLabel( tab, "TextLabel4" );
96// TextLabel5 = new QLabel( tab, "TextLabel5" );
97
98 PushButton_Browse = new QPushButton( tab, "PushButton_Browse" );
99
100 ComboBox1 = new QComboBox( FALSE, tab, "ComboBox1" );
101
102 ComboBox1->insertItem( tr( "http://sailor.gutenberg.org" ) );
103 ComboBox1->insertItem( tr( "http://www.prairienet.org/pg" ) );
104
105 http_ListBox1 = new QListBox( tab, "http_ListBox1" );
106
107//////////////////////////////////////////////////////////
108 tabWidget->insertTab( tab, tr( "HTTP" ) );
109
110 QGridLayout *layout4 = new QGridLayout(tab );
111 layout4->setSpacing(2);
112 layout4->setMargin(2);
113
114 fontDlg = new FontDialog( tabWidget,"FontDialog");
115// fontWidget= new QWidget( tabWidget, "fontWidget" );
116 tabWidget->insertTab( fontDlg,"Font");
117// fontDlg = new FontDialog( fontWidget,"FontDialog");
118// fontDlg->show();
119
120 initConnections();
121
122 ftp_DownloadButton->setText("New List");
123 PushButton_Browse->setText("Browse");
124
125 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
126// config = new CConfigFile( local_library+"gutenbrowserrc");
127 doOptions();
128
129 layout3->addMultiCellWidget( ftp_DownloadButton, 0, 0, 1, 2);
130 layout3->addMultiCellWidget( TextLabel3, 1, 1, 0, 1);
131 layout3->addMultiCellWidget( ftp_QListBox_1, 2, 2, 0, 2);
132
133 TextLabel3_3->setMaximumHeight(50);
134 layout4->addMultiCellWidget( PushButton_Browse, 0, 0, 1, 2);
135 layout4->addMultiCellWidget( TextLabel3_3, 1, 1, 0, 1);
136 layout4->addMultiCellWidget( http_ListBox1, 2, 3, 0, 2);
137 layout4->addMultiCellWidget( ComboBox1, 4, 4, 0, 2);
138 setCaption(tr("Gutenbrowser Options"));
139}
140
141void optionsDialog::initConnections() {
142 // signals and slots connections
143// connect( buttonOk, SIGNAL( clicked() ), this, SLOT( OnExit() ) );
144// connect( fontChangeButton, SIGNAL( clicked() ), this, SLOT( changeFonts() ) );
145
146// connect( s_Browser, SIGNAL( activated(const QString&)), SLOT( goBrowser(const QString&) ) );
147// connect( Http_CheckBox, SIGNAL( clicked()), SLOT( httpCheckB()) );
148// connect( downloadDirEdit, SIGNAL(textChanged(const QString &)),SLOT( lineEditChanged(const QString &) ));
149
150// connect( Ftp_CheckBox, SIGNAL( clicked()), SLOT( FtpCheckB()) );
151// downloadLineEdit
152
153// ftpsiteDlg
154 connect( ftp_DownloadButton, SIGNAL( released() ),this, SLOT( getSite() ));
155 connect( ftp_QListBox_1, SIGNAL( clicked ( QListBoxItem *)),this, SLOT( getSelection( QListBoxItem *)) );
156
157//browserDialog
158 connect( http_ListBox1, SIGNAL(highlighted ( int)),this, SLOT(select_title(int)) );
159 connect( PushButton_Browse, SIGNAL( clicked() ), SLOT( BrowseSelected() ) );
160// connect( ComboBox1,SIGNAL(activated(int)),this,SLOT( setHttp(int)));
161
162// connect( tabWidget,SIGNAL(currentChanged(QWidget *tabber)),SLOT( onTab( QWidget * tabber)) );
163
164 connect(cb_queryExit,SIGNAL(clicked()),SLOT( slotQueryExit()) );
165 // connect(ComboBoxStyle,SIGNAL(activated(int)),this,SLOT(setStyle(int)));
166 connect( useWordWrap_CheckBox,SIGNAL( toggled(bool)),SLOT( slotWordWrap(bool)) );
167}
168
169void optionsDialog::listBoxMainSel( int index) {
170 tabWidget->setCurrentPage( index);
171}
diff --git a/noncore/apps/opie-gutenbrowser/output.cpp b/noncore/apps/opie-gutenbrowser/output.cpp
new file mode 100644
index 0000000..07a517f
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/output.cpp
@@ -0,0 +1,36 @@
1/****************************************************************************
2** outputEdit.cpp
3**
4** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com>
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7****************************************************************************/
8#include "output.h"
9
10#include <qmultilineedit.h>
11#include <qlayout.h>
12
13Output::Output( QWidget* parent, const char* name, bool modal, WFlags fl )
14 : QDialog( parent, name, modal, fl )
15{
16 if ( !name )
17 setName( "Output" );
18 resize( 196, 269 );
19 setCaption( name );
20 OutputLayout = new QGridLayout( this );
21 OutputLayout->setSpacing( 6 );
22 OutputLayout->setMargin( 11 );
23
24 OutputEdit = new QMultiLineEdit( this, "OutputEdit" );
25 OutputEdit->setWordWrap(QMultiLineEdit::WidgetWidth);
26 OutputLayout->addWidget( OutputEdit, 0, 0 );
27}
28
29/*
30 * Destroys the object and frees any allocated resources
31 */
32Output::~Output()
33{
34 // no need to delete child widgets, Qt does it all for us
35}
36
diff --git a/noncore/apps/opie-gutenbrowser/output.h b/noncore/apps/opie-gutenbrowser/output.h
new file mode 100644
index 0000000..39c3eec
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/output.h
@@ -0,0 +1,30 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'outputEdit.ui'
3 copyright : (C) 2000 -2004 by llornkcor
4 email : ljp@llornkcor.com
5****************************************************************************/
6#ifndef OUTPUT_H
7#define OUTPUT_H
8
9#include <qvariant.h>
10#include <qdialog.h>
11class QVBoxLayout;
12class QHBoxLayout;
13class QGridLayout;
14class QMultiLineEdit;
15
16class Output : public QDialog
17{
18 Q_OBJECT
19
20public:
21 Output( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
22 ~Output();
23
24 QMultiLineEdit* OutputEdit;
25
26protected:
27 QGridLayout* OutputLayout;
28};
29
30#endif // OUTPUT_H
diff --git a/noncore/apps/opie-gutenbrowser/resource.h b/noncore/apps/opie-gutenbrowser/resource.h
new file mode 100644
index 0000000..e335f85
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/resource.h
@@ -0,0 +1,73 @@
1/***************************************************************************
2 resource.h - description
3 -------------------
4 begin : Mon Jul 24 22:33:12 MDT 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef RESOURCE_H
18#define RESOURCE_H
19
20#ifdef HAVE_CONFIG_H
21#include <config.h>
22#endif
23
24//#define NO_DEBUG
25///////////////////////////////////////////////////////////////////
26// File-menu entries
27#define ID_FILE_NEW 10020
28#define ID_FILE_OPEN 10030
29
30#define ID_FILE_SAVE 10050
31#define ID_FILE_SAVE_AS 10060
32#define ID_FILE_CLOSE 10070
33
34#define ID_FILE_PRINT 10080
35
36#define ID_FILE_QUIT 10100
37
38
39///////////////////////////////////////////////////////////////////
40// Edit-menu entries
41#define ID_EDIT_UNDO 11010
42#define ID_EDIT_REDO 11020
43#define ID_EDIT_COPY 11030
44#define ID_EDIT_CUT 11040
45#define ID_EDIT_PASTE 11050
46#define ID_EDIT_SELECT_ALL 11060
47
48
49///////////////////////////////////////////////////////////////////
50// View-menu entries
51#define ID_VIEW_TOOLBAR 12010
52#define ID_VIEW_STATUSBAR 12020
53
54///////////////////////////////////////////////////////////////////
55// Help-menu entries
56#define ID_HELP_ABOUT 1002
57
58
59///////////////////////////////////////////////////////////////////
60// General application values
61#define VERSION "0.8.0"
62#define METAL 13030
63
64#if defined(_WS_X11_)
65#define IDS_APP_ABOUT "linuxgutenbrowser\n " VERSION "\n(w) 2001 -2004 by llornkcor"
66#endif
67#if defined(_WS_WIN_)
68#define IDS_APP_ABOUT "winuxgutenbrowser\n " VERSION "\n(w) 2001 -2004 by llornkcor"
69#endif
70//#define IDS_STATUS_DEFAULT "resistence is futile, prepare to be assimilated..."
71#define IDS_STATUS_DEFAULT ">>>=====> gutenbrowser <=====<<<"
72
73#endif // RESOURCE_H
diff --git a/noncore/apps/opie-gutenbrowser/unzip.readme b/noncore/apps/opie-gutenbrowser/unzip.readme
new file mode 100644
index 0000000..0fa23fc
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/unzip.readme
@@ -0,0 +1,4 @@
1Unzip sources can be had here.
2It is gpl'd.
3
4http://www.ctan.org/tex-archive/tools/zip/info-zip/UnZip.html