Diffstat (limited to 'noncore/apps/opie-gutenbrowser/gutenbrowser.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | 153 |
1 files changed, 79 insertions, 74 deletions
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp index 2a9a71e..be2b897 100644 --- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp +++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | |||
@@ -5,61 +5,66 @@ | |||
5 | copyright : (C) 2000 -2004 by llornkcor | 5 | copyright : (C) 2000 -2004 by llornkcor |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 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 * | 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 * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | // http search | 12 | // http search |
13 | // http://digital.library.upenn.edu/books/authors.html | 13 | // http://digital.library.upenn.edu/books/authors.html |
14 | // http://digital.library.upenn.edu/books/titles.html | 14 | // http://digital.library.upenn.edu/books/titles.html |
15 | // ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL | 15 | // ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL |
16 | // donate@gutenberg.net | 16 | // donate@gutenberg.net |
17 | #include <qpe/qpeapplication.h> | 17 | |
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 | 18 | ||
25 | #include "editTitle.h" | 19 | #include "editTitle.h" |
26 | #include "gutenbrowser.h" | 20 | #include "gutenbrowser.h" |
27 | #include "LibraryDialog.h" | 21 | #include "LibraryDialog.h" |
28 | //#include "bookmarksdlg.h" | 22 | //#include "bookmarksdlg.h" |
29 | #include "optionsDialog.h" | 23 | #include "optionsDialog.h" |
30 | #include "helpme.h" | 24 | #include "helpme.h" |
31 | #include "NetworkDialog.h" | 25 | #include "NetworkDialog.h" |
32 | 26 | ||
33 | #include "openetext.h" | 27 | #include "openetext.h" |
34 | #include "output.h" | 28 | #include "output.h" |
35 | 29 | ||
30 | /* OPIE */ | ||
31 | #include <opie2/odebug.h> | ||
32 | #include <qpe/qpeapplication.h> | ||
33 | #include <qpe/fontdatabase.h> | ||
34 | #include <qpe/config.h> | ||
35 | #include <qpe/qcopenvelope_qws.h> | ||
36 | #include <qpe/mimetype.h> | ||
37 | #include <qpe/resource.h> | ||
38 | #include <qpe/applnk.h> | ||
36 | 39 | ||
40 | /* QT */ | ||
37 | #include <qregexp.h> | 41 | #include <qregexp.h> |
38 | #include <qregion.h> | 42 | #include <qregion.h> |
39 | #include <qpaintdevicemetrics.h> | 43 | #include <qpaintdevicemetrics.h> |
40 | #include <qvaluelist.h> | 44 | #include <qvaluelist.h> |
41 | #include <qlabel.h> | 45 | #include <qlabel.h> |
42 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
43 | #include <qpainter.h> | 47 | #include <qpainter.h> |
44 | #include <qpalette.h> | 48 | #include <qpalette.h> |
45 | #include <qobjectlist.h> | 49 | #include <qobjectlist.h> |
46 | #include <qfontdialog.h> | 50 | #include <qfontdialog.h> |
47 | #include <qtextview.h> | 51 | #include <qtextview.h> |
48 | #include <qbrush.h> | 52 | #include <qbrush.h> |
49 | #include <qfile.h> | 53 | #include <qfile.h> |
50 | #include <qfontinfo.h> | 54 | #include <qfontinfo.h> |
51 | #include <qscrollview.h> | 55 | #include <qscrollview.h> |
52 | #include <qpoint.h> | 56 | #include <qpoint.h> |
53 | 57 | ||
58 | /* STD */ | ||
54 | #include <stdio.h> | 59 | #include <stdio.h> |
55 | #include <stdlib.h> | 60 | #include <stdlib.h> |
56 | #include <unistd.h> | 61 | #include <unistd.h> |
57 | #include <sys/stat.h> | 62 | #include <sys/stat.h> |
58 | #include <fcntl.h> | 63 | #include <fcntl.h> |
59 | #include <errno.h> | 64 | #include <errno.h> |
60 | 65 | ||
61 | static const int nfontsizes = 9; | 66 | static const int nfontsizes = 9; |
62 | static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; | 67 | static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; |
63 | 68 | ||
64 | #ifdef NOQUICKLAUNCH | 69 | #ifdef NOQUICKLAUNCH |
65 | Gutenbrowser::Gutenbrowser() | 70 | Gutenbrowser::Gutenbrowser() |
@@ -122,63 +127,63 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) | |||
122 | QString tempFileName; | 127 | QString tempFileName; |
123 | 128 | ||
124 | for (int i = 0; i <= i_numofFiles; i++) { | 129 | for (int i = 0; i <= i_numofFiles; i++) { |
125 | // tempFileName.setNum(i); | 130 | // tempFileName.setNum(i); |
126 | config.setGroup( "Files" ); | 131 | config.setGroup( "Files" ); |
127 | QString ramble = config.readEntry( QString::number(i), "" ); | 132 | QString ramble = config.readEntry( QString::number(i), "" ); |
128 | 133 | ||
129 | config.setGroup( "Titles" ); | 134 | config.setGroup( "Titles" ); |
130 | QString tempTitle = config.readEntry( ramble, ""); | 135 | QString tempTitle = config.readEntry( ramble, ""); |
131 | config.setGroup( tempTitle); | 136 | config.setGroup( tempTitle); |
132 | int index=config.readNumEntry( "LineNumber", -1 ); | 137 | int index=config.readNumEntry( "LineNumber", -1 ); |
133 | if( index != -1) { | 138 | if( index != -1) { |
134 | // qDebug( tempTitle); | 139 | // odebug << tempTitle << oendl; |
135 | bookmarksMenu->insertItem( tempTitle); | 140 | bookmarksMenu->insertItem( tempTitle); |
136 | } | 141 | } |
137 | } | 142 | } |
138 | 143 | ||
139 | // QString gutenIndex= local_library + "GUTINDEX.ALL"; | 144 | // QString gutenIndex= local_library + "GUTINDEX.ALL"; |
140 | QString gutenIndex= QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL"; | 145 | QString gutenIndex= QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL"; |
141 | 146 | ||
142 | if( QFile( gutenIndex).exists() ) { | 147 | if( QFile( gutenIndex).exists() ) { |
143 | indexLib.setName( gutenIndex); | 148 | indexLib.setName( gutenIndex); |
144 | } else { | 149 | } else { |
145 | QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT"; | 150 | QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT"; |
146 | // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; | 151 | // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; |
147 | newindexLib.setName( localLibIndexFile); | 152 | newindexLib.setName( localLibIndexFile); |
148 | } | 153 | } |
149 | LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); | 154 | LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); |
150 | loadCheck=false; | 155 | loadCheck=false; |
151 | chdir(local_library); | 156 | chdir(local_library); |
152 | if(!showMainList) { | 157 | if(!showMainList) { |
153 | Lview->setFocus(); | 158 | Lview->setFocus(); |
154 | // if(firstTime) | 159 | // if(firstTime) |
155 | // Bookmark(); | 160 | // Bookmark(); |
156 | for (int i=1;i< qApp->argc();i++) { | 161 | for (int i=1;i< qApp->argc();i++) { |
157 | qDebug("Suppose we open somethin"); | 162 | odebug << "Suppose we open somethin" << oendl; |
158 | load(qApp->argv()[i]); | 163 | load(qApp->argv()[i]); |
159 | } | 164 | } |
160 | } else { | 165 | } else { |
161 | fillWithTitles(); | 166 | fillWithTitles(); |
162 | mainList->setFocus(); | 167 | mainList->setFocus(); |
163 | // mainList->setCurrentItem(0); | 168 | // mainList->setCurrentItem(0); |
164 | 169 | ||
165 | } | 170 | } |
166 | writeConfig(); | 171 | writeConfig(); |
167 | } //end init | 172 | } //end init |
168 | 173 | ||
169 | Gutenbrowser::~Gutenbrowser() { | 174 | Gutenbrowser::~Gutenbrowser() { |
170 | // QPEApplication::grabKeyboard(); | 175 | // QPEApplication::grabKeyboard(); |
171 | // QPEApplication::ungrabKeyboard(); | 176 | // QPEApplication::ungrabKeyboard(); |
172 | qDebug("Exit"); | 177 | odebug << "Exit" << oendl; |
173 | } | 178 | } |
174 | 179 | ||
175 | /* | 180 | /* |
176 | Google.com search */ | 181 | Google.com search */ |
177 | void Gutenbrowser::InfoBarClick() { | 182 | void Gutenbrowser::InfoBarClick() { |
178 | QString text; | 183 | QString text; |
179 | if( Lview->hasSelectedText()) { | 184 | if( Lview->hasSelectedText()) { |
180 | Lview->copy(); | 185 | Lview->copy(); |
181 | QClipboard *cb = QApplication::clipboard(); | 186 | QClipboard *cb = QApplication::clipboard(); |
182 | text = cb->text(); | 187 | text = cb->text(); |
183 | } else { | 188 | } else { |
184 | // text=title; | 189 | // text=title; |
@@ -190,49 +195,49 @@ void Gutenbrowser::InfoBarClick() { | |||
190 | /* | 195 | /* |
191 | download http with wget or preferred browser */ | 196 | download http with wget or preferred browser */ |
192 | void Gutenbrowser::goGetit( const QString &url, bool showMsg) { | 197 | void Gutenbrowser::goGetit( const QString &url, bool showMsg) { |
193 | // int eexit=0; | 198 | // int eexit=0; |
194 | QString cmd; | 199 | QString cmd; |
195 | // config.read(); | 200 | // config.read(); |
196 | qApp->processEvents(); | 201 | qApp->processEvents(); |
197 | QString filename = QPEApplication::qpeDir(); | 202 | QString filename = QPEApplication::qpeDir(); |
198 | if(filename.right(1)!="/") | 203 | if(filename.right(1)!="/") |
199 | filename+="/etc/gutenbrowser/"; | 204 | filename+="/etc/gutenbrowser/"; |
200 | else | 205 | else |
201 | filename+="etc/gutenbrowser/"; | 206 | filename+="etc/gutenbrowser/"; |
202 | qDebug("filename "+filename); | 207 | odebug << "filename "+filename << oendl; |
203 | // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; | 208 | // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; |
204 | 209 | ||
205 | filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); | 210 | filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); |
206 | 211 | ||
207 | Config config("Gutenbrowser"); | 212 | Config config("Gutenbrowser"); |
208 | config.setGroup( "Browser" ); | 213 | config.setGroup( "Browser" ); |
209 | QString brow = config.readEntry("Preferred", "Opera"); | 214 | QString brow = config.readEntry("Preferred", "Opera"); |
210 | qDebug("Preferred browser is "+brow); | 215 | odebug << "Preferred browser is "+brow << oendl; |
211 | if(!showMsg) { //if we just get the gutenindex.all | 216 | if(!showMsg) { //if we just get the gutenindex.all |
212 | cmd="wget -O " + filename +" " + url+" 2>&1" ; | 217 | cmd="wget -O " + filename +" " + url+" 2>&1" ; |
213 | chdir(local_library); | 218 | chdir(local_library); |
214 | qDebug("Issuing the system command: %s", cmd.latin1()); | 219 | odebug << "Issuing the system command: " << cmd << "" << oendl; |
215 | 220 | ||
216 | Output *outDlg; | 221 | Output *outDlg; |
217 | outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); | 222 | outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); |
218 | outDlg->showMaximized(); | 223 | outDlg->showMaximized(); |
219 | outDlg->show(); | 224 | outDlg->show(); |
220 | qApp->processEvents(); | 225 | qApp->processEvents(); |
221 | FILE *fp; | 226 | FILE *fp; |
222 | char line[130]; | 227 | char line[130]; |
223 | outDlg->OutputEdit->append( tr("Running wget") ); | 228 | outDlg->OutputEdit->append( tr("Running wget") ); |
224 | sleep(1); | 229 | sleep(1); |
225 | fp = popen( (const char *) cmd, "r"); | 230 | fp = popen( (const char *) cmd, "r"); |
226 | // qDebug("Issuing the command\n"+cmd); | 231 | // odebug << "Issuing the command\n"+cmd << oendl; |
227 | // system(cmd); | 232 | // system(cmd); |
228 | while ( fgets( line, sizeof line, fp)) { | 233 | while ( fgets( line, sizeof line, fp)) { |
229 | outDlg->OutputEdit->append(line); | 234 | outDlg->OutputEdit->append(line); |
230 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 235 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
231 | } | 236 | } |
232 | pclose(fp); | 237 | pclose(fp); |
233 | outDlg->close(); | 238 | outDlg->close(); |
234 | if(outDlg) | 239 | if(outDlg) |
235 | delete outDlg; | 240 | delete outDlg; |
236 | } else { | 241 | } else { |
237 | if( brow == "Konq") { | 242 | if( brow == "Konq") { |
238 | cmd = "konqueror "+url+" &"; | 243 | cmd = "konqueror "+url+" &"; |
@@ -247,35 +252,35 @@ void Gutenbrowser::goGetit( const QString &url, bool showMsg) { | |||
247 | cmd = "mozilla "+url+" &"; | 252 | cmd = "mozilla "+url+" &"; |
248 | } | 253 | } |
249 | if( brow == "Netscape") { | 254 | if( brow == "Netscape") { |
250 | cmd = "netscape "+url+" &"; | 255 | cmd = "netscape "+url+" &"; |
251 | } | 256 | } |
252 | if(brow == "wget") { | 257 | if(brow == "wget") { |
253 | // cmd="wget -q "+url+" &"; | 258 | // cmd="wget -q "+url+" &"; |
254 | QString tempHtml=local_library+"webster.html"; | 259 | QString tempHtml=local_library+"webster.html"; |
255 | cmd="wget -O "+tempHtml+" -q "+url; | 260 | cmd="wget -O "+tempHtml+" -q "+url; |
256 | } | 261 | } |
257 | 262 | ||
258 | chdir(local_library); | 263 | chdir(local_library); |
259 | qDebug("Issuing the sys command: %s", cmd.latin1()); | 264 | odebug << "Issuing the sys command: " << cmd << "" << oendl; |
260 | system(cmd); | 265 | system(cmd); |
261 | } | 266 | } |
262 | } | 267 | } |
263 | 268 | ||
264 | void Gutenbrowser::toggleButtonIcons( bool useEm) { | 269 | void Gutenbrowser::toggleButtonIcons( bool useEm) { |
265 | QString pixDir; | 270 | QString pixDir; |
266 | if(useEm) | 271 | if(useEm) |
267 | useEm=TRUE; | 272 | useEm=TRUE; |
268 | pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; | 273 | pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; |
269 | qDebug("Docdir is "+QPEApplication::documentDir()); | 274 | odebug << "Docdir is "+QPEApplication::documentDir() << oendl; |
270 | 275 | ||
271 | if( useIcons && QDir( pixDir).exists() ) { | 276 | if( useIcons && QDir( pixDir).exists() ) { |
272 | LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline | 277 | LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline |
273 | OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook")); | 278 | OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook")); |
274 | ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline | 279 | ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline |
275 | BackButton->setPixmap( Resource::loadPixmap("back") );//in inline | 280 | BackButton->setPixmap( Resource::loadPixmap("back") );//in inline |
276 | SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline | 281 | SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline |
277 | lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder")); | 282 | lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder")); |
278 | setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") ); | 283 | setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") ); |
279 | dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") ); | 284 | dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") ); |
280 | InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google")); | 285 | InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google")); |
281 | } | 286 | } |
@@ -372,101 +377,101 @@ void Gutenbrowser::downloadLibIndex() { | |||
372 | //// QMessageBox::message("Note",""); | 377 | //// QMessageBox::message("Note",""); |
373 | // } | 378 | // } |
374 | // if(NetworkDlg) | 379 | // if(NetworkDlg) |
375 | // delete NetworkDlg; | 380 | // delete NetworkDlg; |
376 | } | 381 | } |
377 | 382 | ||
378 | 383 | ||
379 | void Gutenbrowser::PrintBtn() { | 384 | void Gutenbrowser::PrintBtn() { |
380 | } | 385 | } |
381 | 386 | ||
382 | void Gutenbrowser::SearchBtn() { | 387 | void Gutenbrowser::SearchBtn() { |
383 | if( loadCheck) { | 388 | if( loadCheck) { |
384 | qDebug("loadCheck: we have a loaded doc"); | 389 | odebug << "loadCheck: we have a loaded doc" << oendl; |
385 | Search(); | 390 | Search(); |
386 | } | 391 | } |
387 | // else | 392 | // else |
388 | // QMessageBox::message("Note","Sorry, can't search. No etext is loaded"); | 393 | // QMessageBox::message("Note","Sorry, can't search. No etext is loaded"); |
389 | } | 394 | } |
390 | 395 | ||
391 | 396 | ||
392 | void Gutenbrowser::ForwardBtn() { | 397 | void Gutenbrowser::ForwardBtn() { |
393 | 398 | ||
394 | if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) { | 399 | if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) { |
395 | 400 | ||
396 | QString s; | 401 | QString s; |
397 | QString insertString; | 402 | QString insertString; |
398 | int pageSize= Lview->PageSize(); | 403 | int pageSize= Lview->PageSize(); |
399 | Lview->clear(); | 404 | Lview->clear(); |
400 | 405 | ||
401 | for(int fd=0; fd < pageSize - 1;fd++) { | 406 | for(int fd=0; fd < pageSize - 1;fd++) { |
402 | f.readLine(s, 256); | 407 | f.readLine(s, 256); |
403 | if(useWrap) | 408 | if(useWrap) |
404 | s.replace(QRegExp("\n"),""); | 409 | s.replace(QRegExp("\n"),""); |
405 | insertString+=s; | 410 | insertString+=s; |
406 | Lview->insertLine( s, -1); | 411 | Lview->insertLine( s, -1); |
407 | // qDebug(s); | 412 | // odebug << s << oendl; |
408 | currentLine++; | 413 | currentLine++; |
409 | } | 414 | } |
410 | // Lview->insertAt( insertString,0,0, FALSE); | 415 | // Lview->insertAt( insertString,0,0, FALSE); |
411 | currentFilePos = f.at(); | 416 | currentFilePos = f.at(); |
412 | // if( i_pageNum != pages) { | 417 | // if( i_pageNum != pages) { |
413 | // Lview->MultiLine_Ex::pageDown( FALSE); | 418 | // Lview->MultiLine_Ex::pageDown( FALSE); |
414 | i_pageNum++; | 419 | i_pageNum++; |
415 | pageStopArray.resize(i_pageNum + 1); | 420 | pageStopArray.resize(i_pageNum + 1); |
416 | // int length = Lview->length(); | 421 | // int length = Lview->length(); |
417 | 422 | ||
418 | pageStopArray[i_pageNum ] = currentFilePos; | 423 | pageStopArray[i_pageNum ] = currentFilePos; |
419 | // qDebug("%d current page is number %d, pagesize %d, length %d, current %d", | 424 | // qDebug("%d current page is number %d, pagesize %d, length %d, current %d", |
420 | // currentFilePos, i_pageNum, pageSize, Lview->length(), pageStopArray[i_pageNum] ); | 425 | // currentFilePos, i_pageNum, pageSize, Lview->length(), pageStopArray[i_pageNum] ); |
421 | setStatus(); | 426 | setStatus(); |
422 | Lview->setCursorPosition( 0, 0, FALSE); | 427 | Lview->setCursorPosition( 0, 0, FALSE); |
423 | // } | 428 | // } |
424 | 429 | ||
425 | } else { | 430 | } else { |
426 | // qDebug("bal"); | 431 | // odebug << "bal" << oendl; |
427 | // if( i_pageNum != pages) { | 432 | // if( i_pageNum != pages) { |
428 | 433 | ||
429 | // // int newTop = Lview->Top(); | 434 | // // int newTop = Lview->Top(); |
430 | // // if(Lview->lastRow() > i) | 435 | // // if(Lview->lastRow() > i) |
431 | // Lview->ScrollUp(1); | 436 | // Lview->ScrollUp(1); |
432 | // // i_pageNum++; | 437 | // // i_pageNum++; |
433 | // setStatus(); | 438 | // setStatus(); |
434 | // Lview->setCursorPosition( Lview->Top(), 0, FALSE); | 439 | // Lview->setCursorPosition( Lview->Top(), 0, FALSE); |
435 | 440 | ||
436 | // } | 441 | // } |
437 | 442 | ||
438 | } | 443 | } |
439 | Lview->setFocus(); | 444 | Lview->setFocus(); |
440 | 445 | ||
441 | // qDebug("page number %d line number %d", i_pageNum, currentLine); | 446 | // odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl; |
442 | } | 447 | } |
443 | 448 | ||
444 | 449 | ||
445 | void Gutenbrowser::BackBtn() { | 450 | void Gutenbrowser::BackBtn() { |
446 | if( i_pageNum > 0) { | 451 | if( i_pageNum > 0) { |
447 | int pageSize= Lview->PageSize(); | 452 | int pageSize= Lview->PageSize(); |
448 | // int length=Lview->length(); | 453 | // int length=Lview->length(); |
449 | 454 | ||
450 | i_pageNum--; | 455 | i_pageNum--; |
451 | currentFilePos = f.at(); | 456 | currentFilePos = f.at(); |
452 | 457 | ||
453 | // qDebug("%d move back to %d, current page number %d, %d, length %d", | 458 | // qDebug("%d move back to %d, current page number %d, %d, length %d", |
454 | // currentFilePos, pageStopArray[i_pageNum - 1 ], i_pageNum, pageSize, Lview->length() ); | 459 | // currentFilePos, pageStopArray[i_pageNum - 1 ], i_pageNum, pageSize, Lview->length() ); |
455 | 460 | ||
456 | if( i_pageNum < 2) { | 461 | if( i_pageNum < 2) { |
457 | f.at( 0); | 462 | f.at( 0); |
458 | } else { | 463 | } else { |
459 | if(!f.at( pageStopArray[i_pageNum - 1] )) | 464 | if(!f.at( pageStopArray[i_pageNum - 1] )) |
460 | qDebug("File positioned backward did not work"); | 465 | odebug << "File positioned backward did not work" << oendl; |
461 | } | 466 | } |
462 | QString s; | 467 | QString s; |
463 | // int sizeLine=0; | 468 | // int sizeLine=0; |
464 | Lview->clear(); | 469 | Lview->clear(); |
465 | // QString insertString; | 470 | // QString insertString; |
466 | 471 | ||
467 | for(int fd = 0; fd < pageSize ;fd++) { | 472 | for(int fd = 0; fd < pageSize ;fd++) { |
468 | // Lview->removeLine( Lview->PageSize() ); | 473 | // Lview->removeLine( Lview->PageSize() ); |
469 | f.readLine(s, 256); | 474 | f.readLine(s, 256); |
470 | if(useWrap) | 475 | if(useWrap) |
471 | s.replace(QRegExp("\n"),""); | 476 | s.replace(QRegExp("\n"),""); |
472 | currentLine++; | 477 | currentLine++; |
@@ -504,25 +509,25 @@ void Gutenbrowser::BackBtn() { | |||
504 | void Gutenbrowser::doBeginBtn() { | 509 | void Gutenbrowser::doBeginBtn() { |
505 | if(loadCheck) { | 510 | if(loadCheck) { |
506 | qApp->processEvents(); | 511 | qApp->processEvents(); |
507 | BeginBtn(); | 512 | BeginBtn(); |
508 | } | 513 | } |
509 | } | 514 | } |
510 | 515 | ||
511 | // moves text to the very top = 0 | 516 | // moves text to the very top = 0 |
512 | void Gutenbrowser::TopBtn() { | 517 | void Gutenbrowser::TopBtn() { |
513 | 518 | ||
514 | if(loadCheck) { | 519 | if(loadCheck) { |
515 | if( i_pageNum != 0) { | 520 | if( i_pageNum != 0) { |
516 | qDebug("top"); | 521 | odebug << "top" << oendl; |
517 | qApp->processEvents(); | 522 | qApp->processEvents(); |
518 | currentLine = 0; | 523 | currentLine = 0; |
519 | i_pageNum = 1; | 524 | i_pageNum = 1; |
520 | int pageSize = Lview->PageSize() ; | 525 | int pageSize = Lview->PageSize() ; |
521 | Lview->clear(); | 526 | Lview->clear(); |
522 | QString s; | 527 | QString s; |
523 | f.at(0); | 528 | f.at(0); |
524 | for(int fd=0; fd < pageSize ;fd++) { | 529 | for(int fd=0; fd < pageSize ;fd++) { |
525 | f.readLine(s, 256); | 530 | f.readLine(s, 256); |
526 | if(useWrap) | 531 | if(useWrap) |
527 | s.replace(QRegExp("\n"),""); | 532 | s.replace(QRegExp("\n"),""); |
528 | Lview->insertLine(s ,-1); | 533 | Lview->insertLine(s ,-1); |
@@ -562,29 +567,29 @@ void Gutenbrowser::BeginBtn() { | |||
562 | f.at( 0); | 567 | f.at( 0); |
563 | 568 | ||
564 | while ( !f.atEnd() ) { | 569 | while ( !f.atEnd() ) { |
565 | f.readLine(s, 256); | 570 | f.readLine(s, 256); |
566 | lineNo++; | 571 | lineNo++; |
567 | LeftText = s; | 572 | LeftText = s; |
568 | currentFilePos = f.at(); | 573 | currentFilePos = f.at(); |
569 | 574 | ||
570 | i_pageNum = lineNo/pageSize; | 575 | i_pageNum = lineNo/pageSize; |
571 | if(lastPage < i_pageNum) { | 576 | if(lastPage < i_pageNum) { |
572 | pageStopArray.resize(i_pageNum + 1); | 577 | pageStopArray.resize(i_pageNum + 1); |
573 | pageStopArray[i_pageNum ] = currentFilePos; | 578 | pageStopArray[i_pageNum ] = currentFilePos; |
574 | // qDebug("new page number %d, found at %d", i_pageNum, currentFilePos); | 579 | // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; |
575 | } | 580 | } |
576 | // lastPage = i_pageNum; | 581 | // lastPage = i_pageNum; |
577 | if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) { | 582 | 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); | 583 | odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; |
579 | break; | 584 | break; |
580 | } | 585 | } |
581 | } | 586 | } |
582 | if(f.atEnd()) //in case we didnt find anything, we need to show something | 587 | if(f.atEnd()) //in case we didnt find anything, we need to show something |
583 | f.at(0); | 588 | f.at(0); |
584 | Lview->clear(); | 589 | Lview->clear(); |
585 | for(int fd=0; fd < pageSize - 1;fd++) { | 590 | for(int fd=0; fd < pageSize - 1;fd++) { |
586 | f.readLine(s, 256); | 591 | f.readLine(s, 256); |
587 | if(useWrap) | 592 | if(useWrap) |
588 | s.replace(QRegExp("\n"),""); | 593 | s.replace(QRegExp("\n"),""); |
589 | Lview->insertLine( s, -1); | 594 | Lview->insertLine( s, -1); |
590 | currentLine++; | 595 | currentLine++; |
@@ -612,29 +617,29 @@ void Gutenbrowser::BeginBtn() { | |||
612 | void Gutenbrowser::setBookmark() { | 617 | void Gutenbrowser::setBookmark() { |
613 | int eexit=QMessageBox::information(this, "Note", | 618 | int eexit=QMessageBox::information(this, "Note", |
614 | "Do you really want to \nset this bookmark?." | 619 | "Do you really want to \nset this bookmark?." |
615 | ,QMessageBox::Yes, QMessageBox::No); | 620 | ,QMessageBox::Yes, QMessageBox::No); |
616 | if (eexit== 3) { | 621 | if (eexit== 3) { |
617 | 622 | ||
618 | currentFilePos = f.at(); | 623 | currentFilePos = f.at(); |
619 | 624 | ||
620 | Config cfg("Gutenbrowser"); | 625 | Config cfg("Gutenbrowser"); |
621 | cfg.setGroup("General"); | 626 | cfg.setGroup("General"); |
622 | file_name=cfg.readEntry("Current",""); | 627 | file_name=cfg.readEntry("Current",""); |
623 | qApp->processEvents(); | 628 | qApp->processEvents(); |
624 | qDebug("Settingbook mark "+file_name); | 629 | odebug << "Settingbook mark "+file_name << oendl; |
625 | 630 | ||
626 | cfg.setGroup("Titles"); | 631 | cfg.setGroup("Titles"); |
627 | title=cfg.readEntry(file_name,""); | 632 | title=cfg.readEntry(file_name,""); |
628 | qDebug("title is "+ title); | 633 | odebug << "title is "+ title << oendl; |
629 | 634 | ||
630 | cfg.setGroup( "Bookmarks" ); | 635 | cfg.setGroup( "Bookmarks" ); |
631 | 636 | ||
632 | cfg.writeEntry("File Name",file_name); | 637 | cfg.writeEntry("File Name",file_name); |
633 | cfg.writeEntry("Page Number",QString::number(i_pageNum) ); | 638 | cfg.writeEntry("Page Number",QString::number(i_pageNum) ); |
634 | cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); | 639 | cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); |
635 | cfg.writeEntry("Title", title); | 640 | cfg.writeEntry("Title", title); |
636 | 641 | ||
637 | int row = Lview->topRow();// Lview->Top(); | 642 | int row = Lview->topRow();// Lview->Top(); |
638 | cfg.writeEntry("LineNumber",QString::number(row) ); | 643 | cfg.writeEntry("LineNumber",QString::number(row) ); |
639 | 644 | ||
640 | cfg.setGroup(title); | 645 | cfg.setGroup(title); |
@@ -645,29 +650,29 @@ void Gutenbrowser::setBookmark() { | |||
645 | bookmarksMenu->insertItem( title); | 650 | bookmarksMenu->insertItem( title); |
646 | } | 651 | } |
647 | } //end setBookmark | 652 | } //end setBookmark |
648 | 653 | ||
649 | 654 | ||
650 | /* goes to last set bookmark*/ | 655 | /* goes to last set bookmark*/ |
651 | void Gutenbrowser::Bookmark( int itemId) { | 656 | void Gutenbrowser::Bookmark( int itemId) { |
652 | 657 | ||
653 | // qApp->processEvents(); | 658 | // qApp->processEvents(); |
654 | Config config("Gutenbrowser"); | 659 | Config config("Gutenbrowser"); |
655 | config.setGroup( "Bookmarks" ); | 660 | config.setGroup( "Bookmarks" ); |
656 | 661 | ||
657 | // qDebug("<<<<<< %d, %d", Lview->PageSize(), Lview->lastRow() - Lview->topRow() ); | 662 | // odebug << "<<<<<< " << Lview->PageSize() << ", " << Lview->lastRow() - Lview->topRow() << "" << oendl; |
658 | 663 | ||
659 | QString itemString; | 664 | QString itemString; |
660 | 665 | ||
661 | qDebug("menu item %d", itemId); | 666 | odebug << "menu item " << itemId << "" << oendl; |
662 | QString tempTitle; | 667 | QString tempTitle; |
663 | QString s_Bmrkrow; | 668 | QString s_Bmrkrow; |
664 | QString s_pageNum; | 669 | QString s_pageNum; |
665 | int Bmrkrow=0; | 670 | int Bmrkrow=0; |
666 | int bookmarkPosition = 0; | 671 | int bookmarkPosition = 0; |
667 | 672 | ||
668 | // qApp->processEvents(); | 673 | // qApp->processEvents(); |
669 | config.setGroup( "Bookmarks" ); | 674 | config.setGroup( "Bookmarks" ); |
670 | title = config.readEntry("Title", ""); | 675 | title = config.readEntry("Title", ""); |
671 | file_name = config.readEntry("File Name", ""); | 676 | file_name = config.readEntry("File Name", ""); |
672 | i_pageNum = config.readNumEntry("Page Number", 0); | 677 | i_pageNum = config.readNumEntry("Page Number", 0); |
673 | bookmarkPosition = config.readNumEntry( "PagePosition",0); | 678 | bookmarkPosition = config.readNumEntry( "PagePosition",0); |
@@ -691,25 +696,25 @@ void Gutenbrowser::Bookmark( int itemId) { | |||
691 | QString s; | 696 | QString s; |
692 | int lineNo=0; | 697 | int lineNo=0; |
693 | int lastPage=1; | 698 | int lastPage=1; |
694 | while ( !f.atEnd() ) { | 699 | while ( !f.atEnd() ) { |
695 | f.readLine(s, 256); | 700 | f.readLine(s, 256); |
696 | lineNo++; | 701 | lineNo++; |
697 | currentFilePos = f.at(); | 702 | currentFilePos = f.at(); |
698 | 703 | ||
699 | i_pageNum = lineNo/pageSize; | 704 | i_pageNum = lineNo/pageSize; |
700 | if(lastPage < i_pageNum) { | 705 | if(lastPage < i_pageNum) { |
701 | pageStopArray.resize(i_pageNum + 1); | 706 | pageStopArray.resize(i_pageNum + 1); |
702 | pageStopArray[i_pageNum ] = currentFilePos; | 707 | pageStopArray[i_pageNum ] = currentFilePos; |
703 | // qDebug("new page number %d, found at %d", i_pageNum, currentFilePos); | 708 | // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; |
704 | } | 709 | } |
705 | if(currentFilePos == bookmarkPosition) | 710 | if(currentFilePos == bookmarkPosition) |
706 | break; | 711 | break; |
707 | } | 712 | } |
708 | if(f.atEnd()) | 713 | if(f.atEnd()) |
709 | f.at(0); | 714 | f.at(0); |
710 | else | 715 | else |
711 | f.at( bookmarkPosition); | 716 | f.at( bookmarkPosition); |
712 | 717 | ||
713 | for(int fd=0; fd < pageSize - 1;fd++) { | 718 | for(int fd=0; fd < pageSize - 1;fd++) { |
714 | f.readLine(s, 256); | 719 | f.readLine(s, 256); |
715 | lineNo++; | 720 | lineNo++; |
@@ -720,58 +725,58 @@ void Gutenbrowser::Bookmark( int itemId) { | |||
720 | } | 725 | } |
721 | 726 | ||
722 | i_pageNum = lineNo/pageSize; | 727 | i_pageNum = lineNo/pageSize; |
723 | pageStopArray.resize(i_pageNum + 1); | 728 | pageStopArray.resize(i_pageNum + 1); |
724 | 729 | ||
725 | if(showMainList) { | 730 | if(showMainList) { |
726 | showMainList=FALSE; | 731 | showMainList=FALSE; |
727 | mainList->hide(); | 732 | mainList->hide(); |
728 | Lview->show(); | 733 | Lview->show(); |
729 | // qApp->processEvents(); | 734 | // qApp->processEvents(); |
730 | } | 735 | } |
731 | 736 | ||
732 | qDebug("bookmark loaded"); | 737 | odebug << "bookmark loaded" << oendl; |
733 | setCaption(title); | 738 | setCaption(title); |
734 | } | 739 | } |
735 | 740 | ||
736 | 741 | ||
737 | bool Gutenbrowser::load( const char *fileName) { | 742 | bool Gutenbrowser::load( const char *fileName) { |
738 | 743 | ||
739 | // QCopEnvelope ( "QPE/System", "busy()" ); | 744 | // QCopEnvelope ( "QPE/System", "busy()" ); |
740 | // qDebug("Title is already set as "+title); | 745 | // odebug << "Title is already set as "+title << oendl; |
741 | qDebug("sizeHint %d pageSize %d", sizeHint().height(),Lview->PageSize() ); | 746 | odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl; |
742 | if( Lview->PageSize() < 4) { | 747 | if( Lview->PageSize() < 4) { |
743 | 748 | ||
744 | Lview->setMaximumHeight( sizeHint().height() ); | 749 | Lview->setMaximumHeight( sizeHint().height() ); |
745 | Lview->setMinimumHeight( sizeHint().height() ); | 750 | Lview->setMinimumHeight( sizeHint().height() ); |
746 | pointSize = Lview->fontInfo().pointSize(); | 751 | pointSize = Lview->fontInfo().pointSize(); |
747 | qDebug("sizeHint %d point size %d", sizeHint().height(), pointSize); | 752 | odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl; |
748 | if(pointSize < 10) | 753 | if(pointSize < 10) |
749 | Lview->setFixedVisibleLines(19); | 754 | Lview->setFixedVisibleLines(19); |
750 | else | 755 | else |
751 | Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2); | 756 | Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2); |
752 | } | 757 | } |
753 | 758 | ||
754 | Config cfg("Gutenbrowser"); | 759 | Config cfg("Gutenbrowser"); |
755 | cfg.setGroup("General"); | 760 | cfg.setGroup("General"); |
756 | cfg.writeEntry("Current",fileName); | 761 | cfg.writeEntry("Current",fileName); |
757 | currentLine=0; | 762 | currentLine=0; |
758 | 763 | ||
759 | file_name=fileName; | 764 | file_name=fileName; |
760 | QString o_file = fileName; | 765 | QString o_file = fileName; |
761 | 766 | ||
762 | // if (i_pageNum < 1) { | 767 | // if (i_pageNum < 1) { |
763 | i_pageNum = 1; | 768 | i_pageNum = 1; |
764 | // } | 769 | // } |
765 | qDebug("ready to open "+o_file); | 770 | odebug << "ready to open "+o_file << oendl; |
766 | 771 | ||
767 | if(f.isOpen()) f.close(); | 772 | if(f.isOpen()) f.close(); |
768 | f.setName( o_file); | 773 | f.setName( o_file); |
769 | 774 | ||
770 | if ( !f.open( IO_ReadOnly)) { | 775 | if ( !f.open( IO_ReadOnly)) { |
771 | QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) ); | 776 | QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) ); |
772 | return false; | 777 | return false; |
773 | } | 778 | } |
774 | currentFilePos = 0; | 779 | currentFilePos = 0; |
775 | pageStopArray.resize(3); | 780 | pageStopArray.resize(3); |
776 | pageStopArray[0] = currentFilePos; | 781 | pageStopArray[0] = currentFilePos; |
777 | 782 | ||
@@ -789,49 +794,49 @@ bool Gutenbrowser::load( const char *fileName) { | |||
789 | currentLine++; | 794 | currentLine++; |
790 | } | 795 | } |
791 | 796 | ||
792 | // int length = Lview->length(); | 797 | // int length = Lview->length(); |
793 | currentFilePos = f.at(); | 798 | currentFilePos = f.at(); |
794 | 799 | ||
795 | pageStopArray[1] = currentFilePos; | 800 | pageStopArray[1] = currentFilePos; |
796 | 801 | ||
797 | qDebug("<<<<<<<<<<<%d current page is number %d, length %d, current %d, pageSize %d", | 802 | qDebug("<<<<<<<<<<<%d current page is number %d, length %d, current %d, pageSize %d", |
798 | currentFilePos, i_pageNum, Lview->length(), pageStopArray[i_pageNum], Lview->PageSize() ); | 803 | currentFilePos, i_pageNum, Lview->length(), pageStopArray[i_pageNum], Lview->PageSize() ); |
799 | 804 | ||
800 | Lview->setMaxLines(Lview->PageSize()*2); | 805 | Lview->setMaxLines(Lview->PageSize()*2); |
801 | qDebug("Gulped %d", currentLine); | 806 | odebug << "Gulped " << currentLine << "" << oendl; |
802 | setCaption(title); | 807 | setCaption(title); |
803 | Lview->setAutoUpdate( TRUE); | 808 | Lview->setAutoUpdate( TRUE); |
804 | 809 | ||
805 | Lview->setCursorPosition(0,0,FALSE); | 810 | Lview->setCursorPosition(0,0,FALSE); |
806 | 811 | ||
807 | // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; | 812 | // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; |
808 | //qDebug("number of pages %d", pages); | 813 | //odebug << "number of pages " << pages << "" << oendl; |
809 | 814 | ||
810 | loadCheck = true; | 815 | loadCheck = true; |
811 | enableButtons(true); | 816 | enableButtons(true); |
812 | if( donateMenu->count() == 3) { | 817 | if( donateMenu->count() == 3) { |
813 | donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() )); | 818 | donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() )); |
814 | } | 819 | } |
815 | Lview->setFocus(); | 820 | Lview->setFocus(); |
816 | 821 | ||
817 | // QCopEnvelope("QPE/System", "notBusy()" ); | 822 | // QCopEnvelope("QPE/System", "notBusy()" ); |
818 | return true; | 823 | return true; |
819 | } // end load | 824 | } // end load |
820 | 825 | ||
821 | void Gutenbrowser::Search() { | 826 | void Gutenbrowser::Search() { |
822 | 827 | ||
823 | // if( searchDlg->isHidden()) | 828 | // if( searchDlg->isHidden()) |
824 | { | 829 | { |
825 | qDebug("Starting search dialog"); | 830 | odebug << "Starting search dialog" << oendl; |
826 | searchDlg = new SearchDialog( this, "Etext Search", true); | 831 | searchDlg = new SearchDialog( this, "Etext Search", true); |
827 | searchDlg->setCaption( tr( "Etext Search" )); | 832 | searchDlg->setCaption( tr( "Etext Search" )); |
828 | // searchDlg->setLabel( "- searches etext"); | 833 | // searchDlg->setLabel( "- searches etext"); |
829 | connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); | 834 | connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); |
830 | connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); | 835 | connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); |
831 | 836 | ||
832 | QString resultString; | 837 | QString resultString; |
833 | QString string = searchDlg->searchString; | 838 | QString string = searchDlg->searchString; |
834 | Lview->deselect(); | 839 | Lview->deselect(); |
835 | searchDlg->show(); | 840 | searchDlg->show(); |
836 | searchDlg->result(); | 841 | searchDlg->result(); |
837 | } | 842 | } |
@@ -949,27 +954,27 @@ int Gutenbrowser::doSearch( const QString &s_pattern , bool case_sensitive, boo | |||
949 | return 1; | 954 | return 1; |
950 | } | 955 | } |
951 | } | 956 | } |
952 | } | 957 | } |
953 | } | 958 | } |
954 | return 0; | 959 | return 0; |
955 | } | 960 | } |
956 | 961 | ||
957 | void Gutenbrowser::LibraryBtn() { | 962 | void Gutenbrowser::LibraryBtn() { |
958 | 963 | ||
959 | QString newestLibraryFile ="pgwhole.zip"; | 964 | QString newestLibraryFile ="pgwhole.zip"; |
960 | QString zipFile; | 965 | QString zipFile; |
961 | // qDebug("Local Library is %s ", local_library.latin1()); | 966 | // odebug << "Local Library is " << local_library << " " << oendl; |
962 | zipFile="/usr/bin/unzip"; | 967 | zipFile="/usr/bin/unzip"; |
963 | // qDebug("newestLibraryFile is %s ", newestLibraryFile.latin1()); | 968 | // odebug << "newestLibraryFile is " << newestLibraryFile << " " << oendl; |
964 | if( QFile::exists( local_library+newestLibraryFile)) { | 969 | if( QFile::exists( local_library+newestLibraryFile)) { |
965 | if( QFile::exists(zipFile) ) { | 970 | if( QFile::exists(zipFile) ) { |
966 | UnZipIt(newestLibraryFile); | 971 | UnZipIt(newestLibraryFile); |
967 | } | 972 | } |
968 | else | 973 | else |
969 | QMessageBox::message( "Note",( tr("Please install unzip")) ); | 974 | QMessageBox::message( "Note",( tr("Please install unzip")) ); |
970 | } | 975 | } |
971 | // LibraryDlg = new LibraryDialog( this, "Library Index"); | 976 | // LibraryDlg = new LibraryDialog( this, "Library Index"); |
972 | LibraryDlg->setCaption( tr( "Gutenberg Library")); | 977 | LibraryDlg->setCaption( tr( "Gutenberg Library")); |
973 | Config config("Gutenbrowser"); | 978 | Config config("Gutenbrowser"); |
974 | config.setGroup("General"); | 979 | config.setGroup("General"); |
975 | QString tmp=config.readEntry("RunBefore","FALSE"); | 980 | QString tmp=config.readEntry("RunBefore","FALSE"); |
@@ -980,55 +985,55 @@ void Gutenbrowser::LibraryBtn() { | |||
980 | } | 985 | } |
981 | if(useSplitter) | 986 | if(useSplitter) |
982 | LibraryDlg->useSmallInterface=FALSE; | 987 | LibraryDlg->useSmallInterface=FALSE; |
983 | 988 | ||
984 | LibraryDlg->showMaximized(); | 989 | LibraryDlg->showMaximized(); |
985 | 990 | ||
986 | if( LibraryDlg->exec() != 0 ) { | 991 | if( LibraryDlg->exec() != 0 ) { |
987 | listItemNumber = LibraryDlg->DlglistItemNumber; | 992 | listItemNumber = LibraryDlg->DlglistItemNumber; |
988 | listItemFile = LibraryDlg->DlglistItemFile; | 993 | listItemFile = LibraryDlg->DlglistItemFile; |
989 | listItemYear = LibraryDlg->DlglistItemYear; | 994 | listItemYear = LibraryDlg->DlglistItemYear; |
990 | listItemTitle = LibraryDlg->DlglistItemTitle; | 995 | listItemTitle = LibraryDlg->DlglistItemTitle; |
991 | file_name = LibraryDlg->File_Name; | 996 | file_name = LibraryDlg->File_Name; |
992 | // qDebug("title is being set as "+title); | 997 | // odebug << "title is being set as "+title << oendl; |
993 | title = listItemTitle; | 998 | title = listItemTitle; |
994 | 999 | ||
995 | // config.setGroup( "Proxy" ); | 1000 | // config.setGroup( "Proxy" ); |
996 | // if( LibraryDlg->checked == 1) { | 1001 | // if( LibraryDlg->checked == 1) { |
997 | // config.writeEntry("IsChecked", "TRUE"); | 1002 | // config.writeEntry("IsChecked", "TRUE"); |
998 | // } else { | 1003 | // } else { |
999 | // config.writeEntry("IsChecked", "FALSE"); | 1004 | // config.writeEntry("IsChecked", "FALSE"); |
1000 | // } | 1005 | // } |
1001 | // config.write(); | 1006 | // config.write(); |
1002 | // config.read(); | 1007 | // config.read(); |
1003 | if ( listItemNumber.isNull()) { | 1008 | if ( listItemNumber.isNull()) { |
1004 | } else { | 1009 | } else { |
1005 | i_pageNum = 1; | 1010 | i_pageNum = 1; |
1006 | if( file_name !="Error" && file_name.length() >2 && !file_name.isEmpty() ) { | 1011 | if( file_name !="Error" && file_name.length() >2 && !file_name.isEmpty() ) { |
1007 | //replace .zip with txt for opening it. | 1012 | //replace .zip with txt for opening it. |
1008 | // printf("\nFile name is now\n"); | 1013 | // printf("\nFile name is now\n"); |
1009 | // printf(file_name); | 1014 | // printf(file_name); |
1010 | // printf("\n"); | 1015 | // printf("\n"); |
1011 | // | 1016 | // |
1012 | if( file_name.find(".zip")) | 1017 | if( file_name.find(".zip")) |
1013 | { | 1018 | { |
1014 | qDebug("Found zip file\n"); | 1019 | odebug << "Found zip file\n" << oendl; |
1015 | // QStringList args; | 1020 | // QStringList args; |
1016 | // args="unzip"; | 1021 | // args="unzip"; |
1017 | // args+="-o"; | 1022 | // args+="-o"; |
1018 | // args+=local_library+file_name; | 1023 | // args+=local_library+file_name; |
1019 | // args+="-d"; | 1024 | // args+="-d"; |
1020 | // args+=local_library; | 1025 | // args+=local_library; |
1021 | QString cmd = "/usr/bin/unzip -o " + local_library+file_name + " -d " + local_library; | 1026 | QString cmd = "/usr/bin/unzip -o " + local_library+file_name + " -d " + local_library; |
1022 | qDebug("Issuing the command "+ cmd); | 1027 | odebug << "Issuing the command "+ cmd << oendl; |
1023 | // unzipProc=new QProcess( this, "unzipProc" ); /// fark that idea! | 1028 | // unzipProc=new QProcess( this, "unzipProc" ); /// fark that idea! |
1024 | // unzipProc->start(); | 1029 | // unzipProc->start(); |
1025 | system(cmd); | 1030 | system(cmd); |
1026 | remove( file_name); | 1031 | remove( file_name); |
1027 | 1032 | ||
1028 | } | 1033 | } |
1029 | // // | 1034 | // // |
1030 | // file_name = file_name.left(4)+ ".txt"; | 1035 | // file_name = file_name.left(4)+ ".txt"; |
1031 | if( LibraryDlg) | 1036 | if( LibraryDlg) |
1032 | delete LibraryDlg; | 1037 | delete LibraryDlg; |
1033 | setTitle(); | 1038 | setTitle(); |
1034 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1039 | // QCopEnvelope ( "QPE/System", "busy()" ); |
@@ -1053,41 +1058,41 @@ void Gutenbrowser::LibraryBtn() { | |||
1053 | // fixKeys(); | 1058 | // fixKeys(); |
1054 | } | 1059 | } |
1055 | 1060 | ||
1056 | void Gutenbrowser::OpenBtn() { | 1061 | void Gutenbrowser::OpenBtn() { |
1057 | QString s_temp; | 1062 | QString s_temp; |
1058 | s_temp = status; | 1063 | s_temp = status; |
1059 | OpenEtext* OpenDlg; | 1064 | OpenEtext* OpenDlg; |
1060 | OpenDlg = new OpenEtext(this,"OpenDlg"); | 1065 | OpenDlg = new OpenEtext(this,"OpenDlg"); |
1061 | OpenDlg->showMaximized(); | 1066 | OpenDlg->showMaximized(); |
1062 | 1067 | ||
1063 | if( OpenDlg->exec() != 0) { | 1068 | if( OpenDlg->exec() != 0) { |
1064 | title = OpenDlg->openFileTitle; | 1069 | title = OpenDlg->openFileTitle; |
1065 | qDebug("title open as "+title); | 1070 | odebug << "title open as "+title << oendl; |
1066 | file_name = OpenDlg->file; | 1071 | file_name = OpenDlg->file; |
1067 | i_pageNum = 1; | 1072 | i_pageNum = 1; |
1068 | 1073 | ||
1069 | if( !file_name.isEmpty() || file_name.length() > 2 ) { | 1074 | if( !file_name.isEmpty() || file_name.length() > 2 ) { |
1070 | if(showMainList) { | 1075 | if(showMainList) { |
1071 | showMainList=FALSE; | 1076 | showMainList=FALSE; |
1072 | qDebug("ShowMainList is now false"); | 1077 | odebug << "ShowMainList is now false" << oendl; |
1073 | mainList->hide(); | 1078 | mainList->hide(); |
1074 | Lview->show(); | 1079 | Lview->show(); |
1075 | qApp->processEvents(); | 1080 | qApp->processEvents(); |
1076 | } | 1081 | } |
1077 | Lview->clear(); | 1082 | Lview->clear(); |
1078 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1083 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1079 | load(file_name); | 1084 | load(file_name); |
1080 | } else { | 1085 | } else { |
1081 | qDebug("file_name is empty!"); | 1086 | odebug << "file_name is empty!" << oendl; |
1082 | if(showMainList) { | 1087 | if(showMainList) { |
1083 | if(!Lview->isHidden()) | 1088 | if(!Lview->isHidden()) |
1084 | Lview->hide(); | 1089 | Lview->hide(); |
1085 | qApp->processEvents(); | 1090 | qApp->processEvents(); |
1086 | if(mainList->isHidden()) | 1091 | if(mainList->isHidden()) |
1087 | mainList->show(); | 1092 | mainList->show(); |
1088 | fillWithTitles(); | 1093 | fillWithTitles(); |
1089 | qApp->processEvents(); | 1094 | qApp->processEvents(); |
1090 | } | 1095 | } |
1091 | 1096 | ||
1092 | } | 1097 | } |
1093 | } | 1098 | } |
@@ -1235,25 +1240,25 @@ bool Gutenbrowser::getTitle( const char *file ) { | |||
1235 | config.setGroup( "Files" ); | 1240 | config.setGroup( "Files" ); |
1236 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 1241 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
1237 | int i_numofFiles = s_numofFiles.toInt(); | 1242 | int i_numofFiles = s_numofFiles.toInt(); |
1238 | 1243 | ||
1239 | for (int i = 1; i <= i_numofFiles; i++) { | 1244 | for (int i = 1; i <= i_numofFiles; i++) { |
1240 | QString temp; | 1245 | QString temp; |
1241 | temp.setNum(i); | 1246 | temp.setNum(i); |
1242 | QString ramble = config.readEntry(temp, "" ); | 1247 | QString ramble = config.readEntry(temp, "" ); |
1243 | 1248 | ||
1244 | if( strcmp(ramble, s_file) == 0) { | 1249 | if( strcmp(ramble, s_file) == 0) { |
1245 | config.setGroup( "Titles" ); | 1250 | config.setGroup( "Titles" ); |
1246 | title = config.readEntry(ramble, ""); | 1251 | title = config.readEntry(ramble, ""); |
1247 | // qDebug("(getTitle)title is being set as "+title); | 1252 | // odebug << "(getTitle)title is being set as "+title << oendl; |
1248 | } | 1253 | } |
1249 | } | 1254 | } |
1250 | return true; | 1255 | return true; |
1251 | } | 1256 | } |
1252 | 1257 | ||
1253 | void Gutenbrowser::searchdone_slot() { | 1258 | void Gutenbrowser::searchdone_slot() { |
1254 | // if (!searchDlg) | 1259 | // if (!searchDlg) |
1255 | // return; | 1260 | // return; |
1256 | // searchDlg->hide(); | 1261 | // searchDlg->hide(); |
1257 | // Lview->setFocus(); | 1262 | // Lview->setFocus(); |
1258 | this->setFocus(); | 1263 | this->setFocus(); |
1259 | last_search = 0; | 1264 | last_search = 0; |
@@ -1437,25 +1442,25 @@ void Gutenbrowser::keyPressEvent( QKeyEvent *e) { | |||
1437 | // if(useSplitter) Rview->MultiLine_Ex::ScrollUp( 1); | 1442 | // if(useSplitter) Rview->MultiLine_Ex::ScrollUp( 1); |
1438 | // break; | 1443 | // break; |
1439 | // case Key_Up: | 1444 | // case Key_Up: |
1440 | // if( Lview->Top() != 0) { | 1445 | // if( Lview->Top() != 0) { |
1441 | // Lview->MultiLine_Ex::ScrollDown( 1); | 1446 | // Lview->MultiLine_Ex::ScrollDown( 1); |
1442 | // if(useSplitter) Rview->MultiLine_Ex::ScrollDown( 1); | 1447 | // if(useSplitter) Rview->MultiLine_Ex::ScrollDown( 1); |
1443 | // } | 1448 | // } |
1444 | // break; | 1449 | // break; |
1445 | } | 1450 | } |
1446 | } | 1451 | } |
1447 | 1452 | ||
1448 | void Gutenbrowser::resizeEvent( QResizeEvent *ev) { | 1453 | void Gutenbrowser::resizeEvent( QResizeEvent *ev) { |
1449 | // qDebug("resize: %d,%d\n",ev->size().width(),ev->size().height()); | 1454 | // odebug << "resize: " << ev->size().width() << "," << ev->size().height() << "\n" << oendl; |
1450 | 1455 | ||
1451 | if( !LibraryDlg->isHidden()) | 1456 | if( !LibraryDlg->isHidden()) |
1452 | LibraryDlg->resize(ev->size().width(),ev->size().height() ); | 1457 | LibraryDlg->resize(ev->size().width(),ev->size().height() ); |
1453 | 1458 | ||
1454 | // if( loadCheck == true) { | 1459 | // if( loadCheck == true) { |
1455 | // ResizeEdits(); | 1460 | // ResizeEdits(); |
1456 | // AdjustStatus(); | 1461 | // AdjustStatus(); |
1457 | // } | 1462 | // } |
1458 | } | 1463 | } |
1459 | 1464 | ||
1460 | 1465 | ||
1461 | void Gutenbrowser::doOptions() { | 1466 | void Gutenbrowser::doOptions() { |
@@ -1467,68 +1472,68 @@ void Gutenbrowser::doOptions() { | |||
1467 | QFont myFont; | 1472 | QFont myFont; |
1468 | optDlg->showMaximized(); | 1473 | optDlg->showMaximized(); |
1469 | 1474 | ||
1470 | if( optDlg->exec() !=0) { | 1475 | if( optDlg->exec() !=0) { |
1471 | qApp->processEvents(); | 1476 | qApp->processEvents(); |
1472 | brow=optDlg->browserName; | 1477 | brow=optDlg->browserName; |
1473 | toggleButtonIcons( optDlg->useIcon); | 1478 | toggleButtonIcons( optDlg->useIcon); |
1474 | ftp_host= optDlg->ftp_host; | 1479 | ftp_host= optDlg->ftp_host; |
1475 | ftp_base_dir= optDlg->ftp_base_dir; | 1480 | ftp_base_dir= optDlg->ftp_base_dir; |
1476 | brow=optDlg->browserName; | 1481 | brow=optDlg->browserName; |
1477 | Ddir=optDlg->downloadDirEdit->text(); | 1482 | Ddir=optDlg->downloadDirEdit->text(); |
1478 | 1483 | ||
1479 | qDebug("writing library config"); | 1484 | odebug << "writing library config" << oendl; |
1480 | Config config("Gutenbrowser"); | 1485 | Config config("Gutenbrowser"); |
1481 | config.setGroup("General"); | 1486 | config.setGroup("General"); |
1482 | 1487 | ||
1483 | QString dirname= optDlg->downloadDirEdit->text(); | 1488 | QString dirname= optDlg->downloadDirEdit->text(); |
1484 | if(dirname.right(1)!="/") | 1489 | if(dirname.right(1)!="/") |
1485 | dirname+="/"; | 1490 | dirname+="/"; |
1486 | config.writeEntry( "DownloadDirectory",dirname); | 1491 | config.writeEntry( "DownloadDirectory",dirname); |
1487 | QDir newDir( optDlg->downloadDirEdit->text()); | 1492 | QDir newDir( optDlg->downloadDirEdit->text()); |
1488 | 1493 | ||
1489 | if( !newDir.exists() ) { | 1494 | if( !newDir.exists() ) { |
1490 | int exit=QMessageBox::information(this, "Note", "Ok, to make a new directory\n"+Ddir+" ?", | 1495 | int exit=QMessageBox::information(this, "Note", "Ok, to make a new directory\n"+Ddir+" ?", |
1491 | QMessageBox::Ok, QMessageBox::Cancel); | 1496 | QMessageBox::Ok, QMessageBox::Cancel); |
1492 | if (exit==1) { | 1497 | if (exit==1) { |
1493 | QString cmd="mkdir -p "; | 1498 | QString cmd="mkdir -p "; |
1494 | cmd+=Ddir.latin1(); | 1499 | cmd+=Ddir.latin1(); |
1495 | system(cmd); | 1500 | system(cmd); |
1496 | qDebug("Making new dir "+cmd); | 1501 | odebug << "Making new dir "+cmd << oendl; |
1497 | if(Ddir.right(1)!="/") { | 1502 | if(Ddir.right(1)!="/") { |
1498 | Ddir+="/"; | 1503 | Ddir+="/"; |
1499 | } | 1504 | } |
1500 | config.writeEntry("DownloadDirectory",Ddir); | 1505 | config.writeEntry("DownloadDirectory",Ddir); |
1501 | } | 1506 | } |
1502 | } | 1507 | } |
1503 | 1508 | ||
1504 | // if(optDlg->styleChanged) | 1509 | // if(optDlg->styleChanged) |
1505 | // setStyle( optDlg->styleInt); | 1510 | // setStyle( optDlg->styleInt); |
1506 | if(optDlg->b_qExit==TRUE) | 1511 | if(optDlg->b_qExit==TRUE) |
1507 | b_queryExit=TRUE; | 1512 | b_queryExit=TRUE; |
1508 | else | 1513 | else |
1509 | b_queryExit=FALSE; | 1514 | b_queryExit=FALSE; |
1510 | 1515 | ||
1511 | if(optDlg->fontDlg-> changedFonts) { | 1516 | if(optDlg->fontDlg-> changedFonts) { |
1512 | qDebug("Setting font"); | 1517 | odebug << "Setting font" << oendl; |
1513 | myFont=optDlg->fontDlg->selectedFont; | 1518 | myFont=optDlg->fontDlg->selectedFont; |
1514 | Lview->setFont( myFont); | 1519 | Lview->setFont( myFont); |
1515 | } | 1520 | } |
1516 | 1521 | ||
1517 | if(optDlg->useWordWrap_CheckBox->isChecked() ) { | 1522 | if(optDlg->useWordWrap_CheckBox->isChecked() ) { |
1518 | qDebug("WORD WRAP is set"); | 1523 | odebug << "WORD WRAP is set" << oendl; |
1519 | Lview->setWordWrap(QMultiLineEdit::WidgetWidth); | 1524 | Lview->setWordWrap(QMultiLineEdit::WidgetWidth); |
1520 | useWrap=true; | 1525 | useWrap=true; |
1521 | } else { | 1526 | } else { |
1522 | qDebug("Word wrap is NOT set"); | 1527 | odebug << "Word wrap is NOT set" << oendl; |
1523 | Lview->setWordWrap(QMultiLineEdit::NoWrap); | 1528 | Lview->setWordWrap(QMultiLineEdit::NoWrap); |
1524 | useWrap=false; | 1529 | useWrap=false; |
1525 | } | 1530 | } |
1526 | } | 1531 | } |
1527 | if(showMainList) { | 1532 | if(showMainList) { |
1528 | if(!Lview->isHidden()) | 1533 | if(!Lview->isHidden()) |
1529 | Lview->hide(); | 1534 | Lview->hide(); |
1530 | qApp->processEvents(); | 1535 | qApp->processEvents(); |
1531 | if(mainList->isHidden()) | 1536 | if(mainList->isHidden()) |
1532 | mainList->show(); | 1537 | mainList->show(); |
1533 | fillWithTitles(); | 1538 | fillWithTitles(); |
1534 | } else { | 1539 | } else { |
@@ -1569,26 +1574,26 @@ bool Gutenbrowser::setTitle() { | |||
1569 | config.writeEntry(interger, file_name); | 1574 | config.writeEntry(interger, file_name); |
1570 | 1575 | ||
1571 | config.setGroup( "Titles" ); | 1576 | config.setGroup( "Titles" ); |
1572 | config.writeEntry(file_name,listItemTitle); | 1577 | config.writeEntry(file_name,listItemTitle); |
1573 | } | 1578 | } |
1574 | test = 0; | 1579 | test = 0; |
1575 | // config.write(); | 1580 | // config.write(); |
1576 | return true; | 1581 | return true; |
1577 | } | 1582 | } |
1578 | /*Calls new fangled network dialog */ | 1583 | /*Calls new fangled network dialog */ |
1579 | void Gutenbrowser::OnNetworkDialog( const QString &/*networkUrl*/, const QString &/*output*/) | 1584 | void Gutenbrowser::OnNetworkDialog( const QString &/*networkUrl*/, const QString &/*output*/) |
1580 | { | 1585 | { |
1581 | // qDebug(networkUrl); | 1586 | // odebug << networkUrl << oendl; |
1582 | // qDebug(output); | 1587 | // odebug << output << oendl; |
1583 | // #ifndef Q_WS_QWS | 1588 | // #ifndef Q_WS_QWS |
1584 | // NetworkDialog *NetworkDlg; | 1589 | // NetworkDialog *NetworkDlg; |
1585 | // if( networkUrl.length() < 4 ) networkUrl= "http://sailor.gutenberg.org/mirror.sites.html"; | 1590 | // if( networkUrl.length() < 4 ) networkUrl= "http://sailor.gutenberg.org/mirror.sites.html"; |
1586 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, output); | 1591 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, output); |
1587 | // if( NetworkDlg->exec() != 0 ) { | 1592 | // if( NetworkDlg->exec() != 0 ) { |
1588 | // } | 1593 | // } |
1589 | // if(NetworkDlg) | 1594 | // if(NetworkDlg) |
1590 | // delete NetworkDlg; | 1595 | // delete NetworkDlg; |
1591 | // #endif | 1596 | // #endif |
1592 | } | 1597 | } |
1593 | 1598 | ||
1594 | void Gutenbrowser::donateGutenberg() | 1599 | void Gutenbrowser::donateGutenberg() |
@@ -1703,31 +1708,31 @@ void Gutenbrowser::focusInEvent( QFocusEvent* ) | |||
1703 | { | 1708 | { |
1704 | } | 1709 | } |
1705 | void Gutenbrowser::focusOutEvent( QFocusEvent* ) | 1710 | void Gutenbrowser::focusOutEvent( QFocusEvent* ) |
1706 | { | 1711 | { |
1707 | } | 1712 | } |
1708 | 1713 | ||
1709 | void Gutenbrowser::cleanUp( ) | 1714 | void Gutenbrowser::cleanUp( ) |
1710 | { | 1715 | { |
1711 | writeConfig(); | 1716 | writeConfig(); |
1712 | QPEApplication::grabKeyboard(); | 1717 | QPEApplication::grabKeyboard(); |
1713 | 1718 | ||
1714 | QPEApplication::ungrabKeyboard(); | 1719 | QPEApplication::ungrabKeyboard(); |
1715 | // qDebug("Cleanup"); | 1720 | // odebug << "Cleanup" << oendl; |
1716 | if(f.isOpen()) f.close(); | 1721 | if(f.isOpen()) f.close(); |
1717 | } | 1722 | } |
1718 | 1723 | ||
1719 | void Gutenbrowser::fixKeys() | 1724 | void Gutenbrowser::fixKeys() |
1720 | { | 1725 | { |
1721 | qDebug("Attempting to fix keys"); | 1726 | odebug << "Attempting to fix keys" << oendl; |
1722 | 1727 | ||
1723 | } | 1728 | } |
1724 | 1729 | ||
1725 | void Gutenbrowser::enableButtons(bool b) | 1730 | void Gutenbrowser::enableButtons(bool b) |
1726 | { | 1731 | { |
1727 | BackButton->setEnabled(b); | 1732 | BackButton->setEnabled(b); |
1728 | ForwardButton->setEnabled(b); | 1733 | ForwardButton->setEnabled(b); |
1729 | SearchButton->setEnabled(b); | 1734 | SearchButton->setEnabled(b); |
1730 | setBookmarkButton->setEnabled(b); | 1735 | setBookmarkButton->setEnabled(b); |
1731 | dictionaryButton->setEnabled(b); | 1736 | dictionaryButton->setEnabled(b); |
1732 | InfoBar->setEnabled(b); | 1737 | InfoBar->setEnabled(b); |
1733 | 1738 | ||
@@ -1763,25 +1768,25 @@ void Gutenbrowser::listClickedSlot( QListBoxItem * index) { | |||
1763 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1768 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1764 | title = index->text(); | 1769 | title = index->text(); |
1765 | showMainList=FALSE; | 1770 | showMainList=FALSE; |
1766 | mainList->hide(); | 1771 | mainList->hide(); |
1767 | Lview->show(); | 1772 | Lview->show(); |
1768 | qApp->processEvents(); | 1773 | qApp->processEvents(); |
1769 | QString temp; | 1774 | QString temp; |
1770 | temp.setNum( mainList->currentItem() + 1); | 1775 | temp.setNum( mainList->currentItem() + 1); |
1771 | // openFileTitle = title; | 1776 | // openFileTitle = title; |
1772 | Config config("Gutenbrowser"); | 1777 | Config config("Gutenbrowser"); |
1773 | config.setGroup( "Files" ); | 1778 | config.setGroup( "Files" ); |
1774 | QString file = config.readEntry(temp, ""); | 1779 | QString file = config.readEntry(temp, ""); |
1775 | qDebug("About to load"); | 1780 | odebug << "About to load" << oendl; |
1776 | if( Lview->isVisible()) | 1781 | if( Lview->isVisible()) |
1777 | load(file); | 1782 | load(file); |
1778 | 1783 | ||
1779 | config.setGroup( title); | 1784 | config.setGroup( title); |
1780 | file_name = config.readEntry("File Name", ""); | 1785 | file_name = config.readEntry("File Name", ""); |
1781 | i_pageNum = config.readNumEntry("Page Number", 1); | 1786 | i_pageNum = config.readNumEntry("Page Number", 1); |
1782 | int Bmrkrow = config.readNumEntry("LineNumber", -1); | 1787 | int Bmrkrow = config.readNumEntry("LineNumber", -1); |
1783 | if(Bmrkrow > -1) { | 1788 | if(Bmrkrow > -1) { |
1784 | if( Bmrkrow > Lview->topRow() ) { | 1789 | if( Bmrkrow > Lview->topRow() ) { |
1785 | Lview->setCursorPosition( Bmrkrow /* - Lview->topRow() */,0, FALSE ); | 1790 | Lview->setCursorPosition( Bmrkrow /* - Lview->topRow() */,0, FALSE ); |
1786 | Lview->ScrollUp( Bmrkrow - Lview->topRow() ); | 1791 | Lview->ScrollUp( Bmrkrow - Lview->topRow() ); |
1787 | // AdjustStatus(); | 1792 | // AdjustStatus(); |
@@ -1804,29 +1809,29 @@ void Gutenbrowser::infoGutenbrowser() { | |||
1804 | void Gutenbrowser::setDocument(const QString & frozenBoogers) { | 1809 | void Gutenbrowser::setDocument(const QString & frozenBoogers) { |
1805 | this->hide(); | 1810 | this->hide(); |
1806 | if(showMainList) { | 1811 | if(showMainList) { |
1807 | showMainList=FALSE; | 1812 | showMainList=FALSE; |
1808 | if(!mainList->isHidden()) | 1813 | if(!mainList->isHidden()) |
1809 | mainList->hide(); | 1814 | mainList->hide(); |
1810 | if(Lview->isHidden()) | 1815 | if(Lview->isHidden()) |
1811 | Lview->show(); | 1816 | Lview->show(); |
1812 | qApp->processEvents(); | 1817 | qApp->processEvents(); |
1813 | } | 1818 | } |
1814 | DocLnk lnk; | 1819 | DocLnk lnk; |
1815 | lnk = DocLnk(frozenBoogers); | 1820 | lnk = DocLnk(frozenBoogers); |
1816 | // qDebug(lnk.file() ); | 1821 | // odebug << lnk.file() << oendl; |
1817 | title=lnk.comment(); | 1822 | title=lnk.comment(); |
1818 | load( lnk.file()); | 1823 | load( lnk.file()); |
1819 | this->show(); | 1824 | this->show(); |
1820 | // qDebug(title); | 1825 | // odebug << title << oendl; |
1821 | // qApp->processEvents(); | 1826 | // qApp->processEvents(); |
1822 | // repaint(); | 1827 | // repaint(); |
1823 | } | 1828 | } |
1824 | 1829 | ||
1825 | void Gutenbrowser::mainListPressed(int mouse, QListBoxItem * , const QPoint & ) | 1830 | void Gutenbrowser::mainListPressed(int mouse, QListBoxItem * , const QPoint & ) |
1826 | { | 1831 | { |
1827 | switch (mouse) { | 1832 | switch (mouse) { |
1828 | case 1: | 1833 | case 1: |
1829 | break; | 1834 | break; |
1830 | case 2: { | 1835 | case 2: { |
1831 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 1836 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
1832 | m.insertItem( tr( "Open" ), this, SLOT( menuOpen() )); | 1837 | m.insertItem( tr( "Open" ), this, SLOT( menuOpen() )); |
@@ -1864,121 +1869,121 @@ void Gutenbrowser::searchGoogle( const QString &tempText) { | |||
1864 | text.replace( QRegExp(")"), ""); | 1869 | text.replace( QRegExp(")"), ""); |
1865 | // text.replace( QRegExp("[0-9]"), ""); | 1870 | // text.replace( QRegExp("[0-9]"), ""); |
1866 | QString s_lookup = "http://google.com/search?q="+text+"&num=30&sa=Google+Search"; | 1871 | QString s_lookup = "http://google.com/search?q="+text+"&num=30&sa=Google+Search"; |
1867 | goGetit( s_lookup, true); | 1872 | goGetit( s_lookup, true); |
1868 | } | 1873 | } |
1869 | 1874 | ||
1870 | } | 1875 | } |
1871 | 1876 | ||
1872 | void Gutenbrowser::menuEditTitle() | 1877 | void Gutenbrowser::menuEditTitle() |
1873 | { | 1878 | { |
1874 | int currentItem = mainList->currentItem(); | 1879 | int currentItem = mainList->currentItem(); |
1875 | QString title_text = mainList->text( currentItem); | 1880 | QString title_text = mainList->text( currentItem); |
1876 | //qDebug("Selected "+title_text); | 1881 | //odebug << "Selected "+title_text << oendl; |
1877 | 1882 | ||
1878 | Config config("Gutenbrowser"); | 1883 | Config config("Gutenbrowser"); |
1879 | config.setGroup( "Files" ); | 1884 | config.setGroup( "Files" ); |
1880 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0"); | 1885 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0"); |
1881 | int i_numofFiles = s_numofFiles.toInt(); | 1886 | int i_numofFiles = s_numofFiles.toInt(); |
1882 | QString fileNum; | 1887 | QString fileNum; |
1883 | for (int i = 1; i <= i_numofFiles+1; i++) { | 1888 | for (int i = 1; i <= i_numofFiles+1; i++) { |
1884 | 1889 | ||
1885 | fileNum.setNum(i); | 1890 | fileNum.setNum(i); |
1886 | config.setGroup( "Files" ); | 1891 | config.setGroup( "Files" ); |
1887 | QString s_filename = config.readEntry(fileNum, "" ); | 1892 | QString s_filename = config.readEntry(fileNum, "" ); |
1888 | config.setGroup( "Titles" ); | 1893 | config.setGroup( "Titles" ); |
1889 | QString file_title = config.readEntry( s_filename, ""); | 1894 | QString file_title = config.readEntry( s_filename, ""); |
1890 | //qDebug("file_title is "+file_title); | 1895 | //odebug << "file_title is "+file_title << oendl; |
1891 | if(title_text == file_title ) { | 1896 | if(title_text == file_title ) { |
1892 | // selFile = s_filename; | 1897 | // selFile = s_filename; |
1893 | //qDebug("Edit: "+ file_title ); | 1898 | //odebug << "Edit: "+ file_title << oendl; |
1894 | i=i_numofFiles+1; | 1899 | i=i_numofFiles+1; |
1895 | Edit_Title *titleEdit; | 1900 | Edit_Title *titleEdit; |
1896 | titleEdit = new Edit_Title(this,file_title ,TRUE); | 1901 | titleEdit = new Edit_Title(this,file_title ,TRUE); |
1897 | if(titleEdit->exec() !=0) { | 1902 | if(titleEdit->exec() !=0) { |
1898 | //qDebug(titleEdit->newTitle); | 1903 | //odebug << titleEdit->newTitle << oendl; |
1899 | config.writeEntry( s_filename, titleEdit->newTitle); | 1904 | config.writeEntry( s_filename, titleEdit->newTitle); |
1900 | mainList->removeItem(currentItem); | 1905 | mainList->removeItem(currentItem); |
1901 | mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), titleEdit->newTitle, currentItem); | 1906 | mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), titleEdit->newTitle, currentItem); |
1902 | } | 1907 | } |
1903 | } | 1908 | } |
1904 | } | 1909 | } |
1905 | 1910 | ||
1906 | // getTitles(); | 1911 | // getTitles(); |
1907 | mainList->triggerUpdate(true); | 1912 | mainList->triggerUpdate(true); |
1908 | 1913 | ||
1909 | } | 1914 | } |
1910 | 1915 | ||
1911 | 1916 | ||
1912 | 1917 | ||
1913 | bool Gutenbrowser::UnZipIt(const QString &zipFile) { | 1918 | bool Gutenbrowser::UnZipIt(const QString &zipFile) { |
1914 | qDebug(zipFile); | 1919 | odebug << zipFile << oendl; |
1915 | #ifndef Q_WS_QWS | 1920 | #ifndef Q_WS_QWS |
1916 | if( QFile::exists( zipFile)) { // TODO findsome other way of dealingwithzip files. | 1921 | if( QFile::exists( zipFile)) { // TODO findsome other way of dealingwithzip files. |
1917 | bool isPgWhole=false; | 1922 | bool isPgWhole=false; |
1918 | QString thatFile; | 1923 | QString thatFile; |
1919 | if(zipFile.find("pgwhole",0,TRUE)) { | 1924 | if(zipFile.find("pgwhole",0,TRUE)) { |
1920 | isPgWhole=TRUE; | 1925 | isPgWhole=TRUE; |
1921 | thatFile= local_library +"PGWHOLE.TXT"; | 1926 | thatFile= local_library +"PGWHOLE.TXT"; |
1922 | } | 1927 | } |
1923 | // else { | 1928 | // else { |
1924 | // thatFile=zipFile.left(4); | 1929 | // thatFile=zipFile.left(4); |
1925 | // } | 1930 | // } |
1926 | // qDebug((const char*)local_library.latin1()); | 1931 | // odebug << (const char*)local_library.latin1() << oendl; |
1927 | QString cmd; | 1932 | QString cmd; |
1928 | #if defined(_WS_X11_) | 1933 | #if defined(_WS_X11_) |
1929 | if( chdir((const char*)local_library.latin1())!=0) | 1934 | if( chdir((const char*)local_library.latin1())!=0) |
1930 | qDebug("chdir failed."); | 1935 | odebug << "chdir failed." << oendl; |
1931 | cmd = "gunzip -S .zip " + local_library+zipFile; | 1936 | cmd = "gunzip -S .zip " + local_library+zipFile; |
1932 | //cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; | 1937 | //cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; |
1933 | #endif | 1938 | #endif |
1934 | #ifdef Q_WS_QWS | 1939 | #ifdef Q_WS_QWS |
1935 | if( chdir((const char*)local_library.latin1())!=0) | 1940 | if( chdir((const char*)local_library.latin1())!=0) |
1936 | qDebug("chdir failed."); | 1941 | odebug << "chdir failed." << oendl; |
1937 | cmd = "unzip " + local_library+zipFile; | 1942 | cmd = "unzip " + local_library+zipFile; |
1938 | // cmd = "/usr/bin/unzip -o " + local_library+zipFile +" -d /usr/share/doc/gutenbrowser" ;//+ local_library; | 1943 | // cmd = "/usr/bin/unzip -o " + local_library+zipFile +" -d /usr/share/doc/gutenbrowser" ;//+ local_library; |
1939 | #endif | 1944 | #endif |
1940 | int exit=QMessageBox::information(this, "Ok to unzip?", | 1945 | int exit=QMessageBox::information(this, "Ok to unzip?", |
1941 | "Ok to unnzip\n"+ zipFile+" ?", | 1946 | "Ok to unnzip\n"+ zipFile+" ?", |
1942 | QMessageBox::Yes, QMessageBox::No); | 1947 | QMessageBox::Yes, QMessageBox::No); |
1943 | if (exit==QMessageBox::Yes) { | 1948 | if (exit==QMessageBox::Yes) { |
1944 | #if defined(_WS_X11_)// | 1949 | #if defined(_WS_X11_)// |
1945 | qDebug("Issuing the command "+cmd); | 1950 | odebug << "Issuing the command "+cmd << oendl; |
1946 | system( cmd); | 1951 | system( cmd); |
1947 | if( QFile::exists(thatFile)) | 1952 | if( QFile::exists(thatFile)) |
1948 | remove (thatFile); | 1953 | remove (thatFile); |
1949 | if(isPgWhole) { | 1954 | if(isPgWhole) { |
1950 | if( rename("pgwhole","PGWHOLE.TXT") !=0) | 1955 | if( rename("pgwhole","PGWHOLE.TXT") !=0) |
1951 | qDebug("rename failed"); | 1956 | odebug << "rename failed" << oendl; |
1952 | } else { | 1957 | } else { |
1953 | if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) | 1958 | if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) |
1954 | qDebug("rename failed"); | 1959 | odebug << "rename failed" << oendl; |
1955 | } | 1960 | } |
1956 | #endif | 1961 | #endif |
1957 | #ifdef Q_WS_QWS | 1962 | #ifdef Q_WS_QWS |
1958 | qDebug("Issuing the command "+cmd); | 1963 | odebug << "Issuing the command "+cmd << oendl; |
1959 | system( cmd); | 1964 | system( cmd); |
1960 | if( QFile::exists(thatFile)) | 1965 | if( QFile::exists(thatFile)) |
1961 | remove(thatFile); | 1966 | remove(thatFile); |
1962 | if(isPgWhole) { | 1967 | if(isPgWhole) { |
1963 | if( rename("pgwhole","PGWHOLE.TXT") !=0) | 1968 | if( rename("pgwhole","PGWHOLE.TXT") !=0) |
1964 | qDebug("rename failed"); | 1969 | odebug << "rename failed" << oendl; |
1965 | } else { | 1970 | } else { |
1966 | if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) | 1971 | if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) |
1967 | qDebug("rename failed"); | 1972 | odebug << "rename failed" << oendl; |
1968 | } | 1973 | } |
1969 | #endif | 1974 | #endif |
1970 | // remove( zipFile); | 1975 | // remove( zipFile); |
1971 | return true; | 1976 | return true; |
1972 | } | 1977 | } |
1973 | else if(exit==QMessageBox::No) { | 1978 | else if(exit==QMessageBox::No) { |
1974 | // qDebug("unzip"); | 1979 | // odebug << "unzip" << oendl; |
1975 | return false; | 1980 | return false; |
1976 | } | 1981 | } |
1977 | } | 1982 | } |
1978 | else | 1983 | else |
1979 | QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); | 1984 | QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); |
1980 | #endif | 1985 | #endif |
1981 | return false; | 1986 | return false; |
1982 | } | 1987 | } |
1983 | 1988 | ||
1984 | 1989 | ||