Diffstat (limited to 'noncore/apps/opie-gutenbrowser/LibraryDialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | 1067 |
1 files changed, 1067 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. */ | ||
34 | LibraryDialog::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 | |||
87 | LibraryDialog::~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 */ | ||
99 | void 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 | |||
174 | void 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 */ | ||
263 | bool 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*/ | ||
365 | void 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 | |||
418 | bool 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 | |||
516 | bool 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 | |||
562 | void LibraryDialog::cancelIt() | ||
563 | { | ||
564 | saveConfig(); | ||
565 | |||
566 | DlglistItemNumber = ""; | ||
567 | this->reject(); | ||
568 | } | ||
569 | |||
570 | bool 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 | |||
606 | void 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*/ | ||
630 | void 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*/ | ||
769 | void 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 | |||
834 | void LibraryDialog::sort() | ||
835 | { | ||
836 | |||
837 | } | ||
838 | |||
839 | /* | ||
840 | Downloads the current selected listitem*/ | ||
841 | bool 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*/ | ||
859 | bool 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 */ | ||
901 | void 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 | |||
923 | void 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 | |||
985 | bool 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*/ | ||
1043 | void 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 | } | ||