summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/gutenbrowser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp82
1 files changed, 39 insertions, 43 deletions
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
index f14080f..be920dd 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
@@ -1,1180 +1,1176 @@
1/*************************************************************************** 1/***************************************************************************
2 gutenbrowser.cpp - description 2 gutenbrowser.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Jul 24 22:33:12 MDT 2000 4 begin : Mon Jul 24 22:33:12 MDT 2000
5 copyright : (C) 2000 -2004 by llornkcor 5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7* 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 17
18 18
19#include "editTitle.h" 19#include "editTitle.h"
20#include "gutenbrowser.h" 20#include "gutenbrowser.h"
21#include "LibraryDialog.h" 21#include "LibraryDialog.h"
22 //#include "bookmarksdlg.h" 22 //#include "bookmarksdlg.h"
23#include "optionsDialog.h" 23#include "optionsDialog.h"
24#include "helpme.h" 24#include "helpme.h"
25#include "NetworkDialog.h" 25#include "NetworkDialog.h"
26 26
27#include "openetext.h" 27#include "openetext.h"
28#include "output.h" 28#include "output.h"
29 29
30/* OPIE */ 30/* OPIE */
31#include <opie2/odebug.h> 31#include <opie2/odebug.h>
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/fontdatabase.h> 33#include <qpe/fontdatabase.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36#include <qpe/mimetype.h> 36#include <qpe/mimetype.h>
37#include <qpe/resource.h> 37#include <qpe/resource.h>
38#include <qpe/applnk.h> 38#include <qpe/applnk.h>
39 39
40/* QT */ 40/* QT */
41#include <qregexp.h> 41#include <qregexp.h>
42#include <qregion.h> 42#include <qregion.h>
43#include <qpaintdevicemetrics.h> 43#include <qpaintdevicemetrics.h>
44#include <qvaluelist.h> 44#include <qvaluelist.h>
45#include <qlabel.h> 45#include <qlabel.h>
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qpainter.h> 47#include <qpainter.h>
48#include <qpalette.h> 48#include <qpalette.h>
49#include <qobjectlist.h> 49#include <qobjectlist.h>
50#include <qfontdialog.h> 50#include <qfontdialog.h>
51#include <qtextview.h> 51#include <qtextview.h>
52#include <qbrush.h> 52#include <qbrush.h>
53#include <qfile.h> 53#include <qfile.h>
54#include <qfontinfo.h> 54#include <qfontinfo.h>
55#include <qscrollview.h> 55#include <qscrollview.h>
56#include <qpoint.h> 56#include <qpoint.h>
57 57
58/* STD */ 58/* STD */
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <unistd.h> 61#include <unistd.h>
62#include <sys/stat.h> 62#include <sys/stat.h>
63#include <fcntl.h> 63#include <fcntl.h>
64#include <errno.h> 64#include <errno.h>
65 65
66static const int nfontsizes = 9; 66static const int nfontsizes = 9;
67static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; 67static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24};
68 68
69#ifdef NOQUICKLAUNCH 69#ifdef NOQUICKLAUNCH
70Gutenbrowser::Gutenbrowser() 70Gutenbrowser::Gutenbrowser()
71 Gutenbrowser(); 71 Gutenbrowser();
72#else 72#else
73Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) 73Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
74#endif 74#endif
75 : QMainWindow() 75 : QMainWindow()
76 { 76 {
77 // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 77 // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
78 // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); 78 // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" );
79 // e << ""; 79 // e << "";
80 // QPEApplication::grabKeyboard(); 80 // QPEApplication::grabKeyboard();
81 showMainList=TRUE; 81 showMainList=TRUE;
82 working=false; 82 working=false;
83 this->setUpdatesEnabled(TRUE); 83 this->setUpdatesEnabled(TRUE);
84 // #ifndef Q_WS_QWS 84 // #ifndef Q_WS_QWS
85 QString msg; 85 QString msg;
86 msg="You have now entered unto gutenbrowser,\n"; 86 msg="You have now entered unto gutenbrowser,\n";
87 msg+="make your self at home, sit back, relax and read something great.\n"; 87 msg+="make your self at home, sit back, relax and read something great.\n";
88 88
89 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 89 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
90 setCaption("Gutenbrowser");// Embedded " VERSION); 90 setCaption("Gutenbrowser");// Embedded " VERSION);
91 this->setUpdatesEnabled(TRUE); 91 this->setUpdatesEnabled(TRUE);
92 92
93 // bool firstTime=FALSE; 93 // bool firstTime=FALSE;
94 topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); 94 topLayout = new QVBoxLayout( this, 0, 0, "topLayout");
95 95
96 menu = new QHBoxLayout(-1,"menu"); 96 menu = new QHBoxLayout(-1,"menu");
97 buttons2 = new QHBoxLayout(-1,"buttons2"); 97 buttons2 = new QHBoxLayout(-1,"buttons2");
98 edits = new QHBoxLayout(-1,"edits"); 98 edits = new QHBoxLayout(-1,"edits");
99 99
100 useSplitter=TRUE; 100 useSplitter=TRUE;
101 101
102 initConfig(); 102 initConfig();
103 initMenuBar(); 103 initMenuBar();
104 initButtonBar(); 104 initButtonBar();
105 initStatusBar(); 105 initStatusBar();
106 initView(); 106 initView();
107 initSlots(); 107 initSlots();
108 108 qDebug("init finished");
109 QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); 109 QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold);
110 110
111 connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), 111 connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)),
112 this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); 112 this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) );
113 if( useIcons) 113 if( useIcons)
114 toggleButtonIcons( TRUE); 114 toggleButtonIcons( TRUE);
115 else 115 else
116 toggleButtonIcons( FALSE); 116 toggleButtonIcons( FALSE);
117 117
118 enableButtons(false); 118 enableButtons(false);
119 119
120 Config config("Gutenbrowser"); // populate menubuttonlist 120 Config config("Gutenbrowser"); // populate menubuttonlist
121 config.setGroup("General"); 121 config.setGroup("General");
122 122
123 config.setGroup( "Files" ); 123 config.setGroup( "Files" );
124 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 124 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
125 int i_numofFiles = s_numofFiles.toInt(); 125 int i_numofFiles = s_numofFiles.toInt();
126 126
127 QString tempFileName; 127 QString tempFileName;
128 128
129 for (int i = 0; i <= i_numofFiles; i++) { 129 for (int i = 0; i <= i_numofFiles; i++) {
130 // tempFileName.setNum(i); 130 // tempFileName.setNum(i);
131 config.setGroup( "Files" ); 131 config.setGroup( "Files" );
132 QString ramble = config.readEntry( QString::number(i), "" ); 132 QString ramble = config.readEntry( QString::number(i), "" );
133 133
134 config.setGroup( "Titles" ); 134 config.setGroup( "Titles" );
135 QString tempTitle = config.readEntry( ramble, ""); 135 QString tempTitle = config.readEntry( ramble, "");
136 config.setGroup( tempTitle); 136 config.setGroup( tempTitle);
137 int index=config.readNumEntry( "LineNumber", -1 ); 137 int index=config.readNumEntry( "LineNumber", -1 );
138 if( index != -1) { 138 if( index != -1) {
139 // odebug << tempTitle << oendl; 139 odebug << tempTitle << oendl;
140 bookmarksMenu->insertItem( tempTitle); 140 bookmarksMenu->insertItem( tempTitle);
141 } 141 }
142 } 142 }
143 143
144 // QString gutenIndex= local_library + "GUTINDEX.ALL"; 144 // QString gutenIndex= local_library + "GUTINDEX.ALL";
145 QString gutenIndex= QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL"; 145 QString gutenIndex = QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL";
146 146 qDebug("gutenindex "+gutenIndex );
147 if( QFile( gutenIndex).exists() ) { 147 if( QFile( gutenIndex).exists() ) {
148 indexLib.setName( gutenIndex); 148 indexLib.setName( gutenIndex);
149 } else { 149 } else {
150 QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT"; 150 QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT";
151 // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; 151 // QString localLibIndexFile= local_library + "PGWHOLE.TXT";
152 newindexLib.setName( localLibIndexFile); 152 newindexLib.setName( localLibIndexFile);
153 } 153 }
154 qDebug("attempting new library");
154 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); 155 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */);
155 loadCheck=false; 156 loadCheck = false;
156 chdir(local_library); 157 chdir(local_library);
157 if(!showMainList) { 158 if(!showMainList) {
158 Lview->setFocus(); 159 Lview->setFocus();
159 // if(firstTime) 160 // if(firstTime)
160 // Bookmark(); 161 // Bookmark();
161 for (int i=1;i< qApp->argc();i++) { 162 for (int i=1;i< qApp->argc();i++) {
162 odebug << "Suppose we open somethin" << oendl; 163 qDebug("Suppose we open somethin");
163 load(qApp->argv()[i]); 164 load(qApp->argv()[i]);
164 } 165 }
165 } else { 166 } else {
166 fillWithTitles(); 167 fillWithTitles();
167 mainList->setFocus(); 168 mainList->setFocus();
168 // mainList->setCurrentItem(0); 169 // mainList->setCurrentItem(0);
169 170
170 } 171 }
171 writeConfig(); 172 writeConfig();
172} //end init 173} //end init
173 174
174Gutenbrowser::~Gutenbrowser() { 175Gutenbrowser::~Gutenbrowser() {
175 // QPEApplication::grabKeyboard(); 176 // QPEApplication::grabKeyboard();
176 // QPEApplication::ungrabKeyboard(); 177 // QPEApplication::ungrabKeyboard();
177 odebug << "Exit" << oendl; 178 odebug << "Exit" << oendl;
178} 179}
179 180
180 /* 181 /*
181 Google.com search */ 182 Google.com search */
182void Gutenbrowser::InfoBarClick() { 183void Gutenbrowser::InfoBarClick() {
183 QString text; 184 QString text;
184 if( Lview->hasSelectedText()) { 185 if( Lview->hasSelectedText()) {
185 Lview->copy(); 186 Lview->copy();
186 QClipboard *cb = QApplication::clipboard(); 187 QClipboard *cb = QApplication::clipboard();
187 text = cb->text(); 188 text = cb->text();
188 } else { 189 } else {
189 // text=title; 190 // text=title;
190 text=this->caption(); 191 text=this->caption();
191 } 192 }
192 searchGoogle(text); 193 searchGoogle(text);
193} 194}
194 195
195 /* 196 /*
196 download http with wget or preferred browser */ 197 download http with wget or preferred browser */
197void Gutenbrowser::goGetit( const QString &url, bool showMsg) { 198void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
198 // int eexit=0; 199 // int eexit=0;
199 QString cmd; 200 QString cmd;
200 // config.read(); 201 // config.read();
201 qApp->processEvents(); 202 qApp->processEvents();
202 QString filename = QPEApplication::qpeDir(); 203 QString filename = QPEApplication::qpeDir();
203 if(filename.right(1)!="/") 204 if(filename.right(1)!="/")
204 filename+="/etc/gutenbrowser/"; 205 filename+="/etc/gutenbrowser/";
205 else 206 else
206 filename+="etc/gutenbrowser/"; 207 filename+="etc/gutenbrowser/";
207 odebug << "filename "+filename << oendl; 208 odebug << "filename "+filename << oendl;
208 // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; 209 // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/";
209 210
210 filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); 211 filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1);
211 212
212 Config config("Gutenbrowser"); 213 Config config("Gutenbrowser");
213 config.setGroup( "Browser" ); 214 config.setGroup( "Browser" );
214 QString brow = config.readEntry("Preferred", "Opera"); 215 QString brow = config.readEntry("Preferred", "Opera");
215 odebug << "Preferred browser is "+brow << oendl; 216 odebug << "Preferred browser is "+brow << oendl;
216 if(!showMsg) { //if we just get the gutenindex.all 217 if(!showMsg) { //if we just get the gutenindex.all
217 cmd="wget -O " + filename +" " + url+" 2>&1" ; 218 cmd="wget -O " + filename +" " + url+" 2>&1" ;
218 chdir(local_library); 219 chdir(local_library);
219 odebug << "Issuing the system command: " << cmd << "" << oendl; 220 odebug << "Issuing the system command: " << cmd << "" << oendl;
220 221
221 Output *outDlg; 222 Output *outDlg;
222 outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); 223 outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE);
223 outDlg->showMaximized(); 224 outDlg->showMaximized();
224 outDlg->show(); 225 outDlg->show();
225 qApp->processEvents(); 226 qApp->processEvents();
226 FILE *fp; 227 FILE *fp;
227 char line[130]; 228 char line[130];
228 outDlg->OutputEdit->append( tr("Running wget") ); 229 outDlg->OutputEdit->append( tr("Running wget") );
229 sleep(1); 230 sleep(1);
230 fp = popen( (const char *) cmd, "r"); 231 fp = popen( (const char *) cmd, "r");
231 // odebug << "Issuing the command\n"+cmd << oendl; 232 odebug << "Issuing the command\n"+cmd << oendl;
232 // system(cmd); 233 // system(cmd);
233 while ( fgets( line, sizeof line, fp)) { 234 while ( fgets( line, sizeof line, fp)) {
234 outDlg->OutputEdit->append(line); 235 outDlg->OutputEdit->append(line);
235 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 236// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
236 } 237 }
237 pclose(fp); 238 pclose(fp);
238 outDlg->close(); 239 outDlg->close();
239 if(outDlg) 240 if(outDlg)
240 delete outDlg; 241 delete outDlg;
241 } else { 242 } else {
242 if( brow == "Konq") { 243 if( brow == "Konq") {
243 cmd = "konqueror "+url+" &"; 244 cmd = "konqueror "+url+" &";
244 } 245 }
245 if( brow == "Opera") { //for desktop testing 246 if( brow == "Opera") { //for desktop testing
246 cmd = "opera "+url+" &"; 247 cmd = "opera "+url+" &";
247 } 248 }
248 // if( brow == "Opera") { // on Zaurus 249 // if( brow == "Opera") { // on Zaurus
249 // cmd = "operagui "+url+" &"; 250 // cmd = "operagui "+url+" &";
250 // } 251 // }
251 if( brow == "Mozilla") { 252 if( brow == "Mozilla") {
252 cmd = "mozilla "+url+" &"; 253 cmd = "mozilla "+url+" &";
253 } 254 }
254 if( brow == "Netscape") { 255 if( brow == "Netscape") {
255 cmd = "netscape "+url+" &"; 256 cmd = "netscape "+url+" &";
256 } 257 }
257 if(brow == "wget") { 258 if(brow == "wget") {
258 // cmd="wget -q "+url+" &"; 259 // cmd="wget -q "+url+" &";
259 QString tempHtml=local_library+"webster.html"; 260 QString tempHtml=local_library+"webster.html";
260 cmd="wget -O "+tempHtml+" -q "+url; 261 cmd="wget -O "+tempHtml+" -q "+url;
261 } 262 }
262 263
263 chdir(local_library); 264 chdir(local_library);
264 odebug << "Issuing the sys command: " << cmd << "" << oendl; 265 odebug << "Issuing the sys command: " << cmd << "" << oendl;
265 system(cmd); 266 system(cmd);
266 } 267 }
267} 268}
268 269
269void Gutenbrowser::toggleButtonIcons( bool useEm) { 270void Gutenbrowser::toggleButtonIcons( bool useEm) {
270 QString pixDir; 271 QString pixDir;
271 if(useEm) 272 if(useEm)
272 useEm=TRUE; 273 useEm=TRUE;
273 pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; 274 pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser";
274 odebug << "Docdir is "+QPEApplication::documentDir() << oendl; 275 odebug << "Docdir is "+QPEApplication::documentDir() << oendl;
275 276
276 if( useIcons && QDir( pixDir).exists() ) { 277 if( useIcons && QDir( pixDir).exists() ) {
277 LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline 278 LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline
278 OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook")); 279 OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook"));
279 ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline 280 ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline
280 BackButton->setPixmap( Resource::loadPixmap("back") );//in inline 281 BackButton->setPixmap( Resource::loadPixmap("back") );//in inline
281 SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline 282 SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline
282 lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder")); 283 lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder"));
283 setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") ); 284 setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") );
284 dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") ); 285 dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") );
285 InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google")); 286 InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google"));
286 } 287 }
287} 288}
288 289
289 290
290bool Gutenbrowser::queryExit() 291bool Gutenbrowser::queryExit()
291{ 292{
292 int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?", 293 int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?",
293 QMessageBox::Ok, QMessageBox::Cancel); 294 QMessageBox::Ok, QMessageBox::Cancel);
294 if (exit==1) { 295 if (exit==1) {
295 writeConfig(); 296 writeConfig();
296 qApp->quit(); 297 qApp->quit();
297 } else { 298 } else {
298 }; 299 };
299 return (exit==1); 300 return (exit==1);
300} 301}
301 302
302 // SLOT IMPLEMENTATION 303 // SLOT IMPLEMENTATION
303 304
304void Gutenbrowser::slotFilePrint() { 305void Gutenbrowser::slotFilePrint() {
305} 306}
306 307
307void Gutenbrowser::ByeBye() { 308void Gutenbrowser::ByeBye() {
308 if (b_queryExit) 309 if (b_queryExit)
309 queryExit(); 310 queryExit();
310 else { 311 else {
311 // writeConfig(); 312 // writeConfig();
312 qApp->quit(); 313 qApp->quit();
313 } 314 }
314} 315}
315 316
316void Gutenbrowser::HelpBtn() { 317void Gutenbrowser::HelpBtn() {
317 HelpMe* HelpDlg; 318 HelpMe* HelpDlg;
318 HelpDlg = new HelpMe( this, "Help Dialog"); 319 HelpDlg = new HelpMe( this, "Help Dialog");
319 HelpDlg->showMaximized(); 320 HelpDlg->showMaximized();
320} 321}
321 322
322void Gutenbrowser::DownloadIndex() { 323void Gutenbrowser::DownloadIndex() {
323#ifndef Q_WS_QWS 324#ifndef Q_WS_QWS
324 { 325 {
325 switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")), 326 switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")),
326 (tr("Do you want to download the newest\n" 327 (tr("Do you want to download the newest\n"
327 "Project Gutenberg Library Index?\n" 328 "Project Gutenberg Library Index?\n"
328 "or select an ftp site?\n")), 329 "or select an ftp site?\n")),
329 (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) ) 330 (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) )
330 { 331 {
331 case 0: // index clicked, 332 case 0: // index clicked,
332 downloadLibIndex(); 333 downloadLibIndex();
333 break; 334 break;
334 335
335 case 1: // ftp selected 336 case 1: // ftp selected
336 downloadFtpList(); 337 downloadFtpList();
337 break; 338 break;
338 339
339 case 2: // Cancel 340 case 2: // Cancel
340 break; 341 break;
341 }; 342 };
342 } 343 }
343#endif 344#endif
344} // end DownloadIndex 345} // end DownloadIndex
345 346
346 347
347void Gutenbrowser::downloadFtpList() { 348void Gutenbrowser::downloadFtpList() {
348 // QString cmd="wget http://www.promo.net/pg/list.html"); 349 // QString cmd="wget http://www.promo.net/pg/list.html");
349 //system(cmd); 350 //system(cmd);
350 qApp->processEvents(); 351 qApp->processEvents();
351 optionsDialog* optDlg; 352 optionsDialog* optDlg;
352 optDlg = new optionsDialog( this,"Options_Dlg", true); 353 optDlg = new optionsDialog( this,"Options_Dlg", true);
353 optDlg->getSite(); 354 optDlg->getSite();
354 if(optDlg) 355 if(optDlg)
355 delete optDlg; 356 delete optDlg;
356} 357}
357 358
358 359
359void Gutenbrowser::downloadLibIndex() { 360void Gutenbrowser::downloadLibIndex() {
360 // QString dwmloader = local_library + "pgwhole.zip"; 361 // QString dwmloader = local_library + "pgwhole.zip";
361 // QString cmd = "lynx -source http://www.gutenberg.net/pgwhole.zip | cat >> " + dwmloader; 362 // QString cmd = "lynx -source http://www.gutenberg.net/pgwhole.zip | cat >> " + dwmloader;
362 // system(cmd); 363 // system(cmd);
363 364
364 // QString outputFile= local_library+ "GUTINDEX.ALL"; 365 // QString outputFile= local_library+ "GUTINDEX.ALL";
365 // config.setGroup( "FTPsite" ); // ftp server config 366 // config.setGroup( "FTPsite" ); // ftp server config
366 // ftp_host=config.readEntry("SiteName", ""); 367 // ftp_host=config.readEntry("SiteName", "");
367 // ftp_base_dir= config.readEntry("base", ""); 368 // ftp_base_dir= config.readEntry("base", "");
368 // QString networkUrl= "ftp://"+ftp_host+ftp_base_dir+"/GUTINDEX.ALL"; 369 // QString networkUrl= "ftp://"+ftp_host+ftp_base_dir+"/GUTINDEX.ALL";
369 QDir dir( local_library); 370 QDir dir( local_library);
370 dir.cd("", TRUE); 371 dir.cd("", TRUE);
371 goGetit( "http://sailor.gutenberg.org/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3 372 goGetit( "http://sailor.gutenberg.org/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3
372 // goGetit( "http://www.gutenberg.net/pgwhole.zip", true); // until ghttp works on binaries -qt3 373 // goGetit( "http://www.gutenberg.net/pgwhole.zip", true); // until ghttp works on binaries -qt3
373 // NetworkDialog *NetworkDlg; 374 // NetworkDialog *NetworkDlg;
374 // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, outputFile ); 375 // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, outputFile );
375 // if( NetworkDlg->exec() != 0 ) 376 // if( NetworkDlg->exec() != 0 )
376 // { // use new, improved, *INSTANT* network-dialog-file-getterer 377 // { // use new, improved, *INSTANT* network-dialog-file-getterer
377 //// QMessageBox::message("Note",""); 378 //// QMessageBox::message("Note","");
378 // } 379 // }
379 // if(NetworkDlg) 380 // if(NetworkDlg)
380 // delete NetworkDlg; 381 // delete NetworkDlg;
381} 382}
382 383
383 384
384void Gutenbrowser::PrintBtn() { 385void Gutenbrowser::PrintBtn() {
385} 386}
386 387
387void Gutenbrowser::SearchBtn() { 388void Gutenbrowser::SearchBtn() {
388 if( loadCheck) { 389 if( loadCheck) {
389 odebug << "loadCheck: we have a loaded doc" << oendl; 390 odebug << "loadCheck: we have a loaded doc" << oendl;
390 Search(); 391 Search();
391 } 392 }
392 // else 393 // else
393 // QMessageBox::message("Note","Sorry, can't search. No etext is loaded"); 394 // QMessageBox::message("Note","Sorry, can't search. No etext is loaded");
394} 395}
395 396
396 397
397void Gutenbrowser::ForwardBtn() { 398void Gutenbrowser::ForwardBtn() {
398 399
399 if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) { 400 if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) {
400 401
401 QString s; 402 QString s;
402 QString insertString; 403 QString insertString;
403 int pageSize= Lview->PageSize(); 404 int pageSize= Lview->PageSize();
404 Lview->clear(); 405 Lview->clear();
405 406
406 for(int fd=0; fd < pageSize - 1;fd++) { 407 for(int fd=0; fd < pageSize - 1;fd++) {
407 f.readLine(s, 256); 408 f.readLine(s, 256);
408 if(useWrap) 409 if(useWrap)
409 s.replace(QRegExp("\n"),""); 410 s.replace(QRegExp("\n"),"");
410 insertString+=s; 411 insertString+=s;
411 Lview->insertLine( s, -1); 412 Lview->insertLine( s, -1);
412 // odebug << s << oendl; 413 odebug << s << oendl;
413 currentLine++; 414 currentLine++;
414 } 415 }
415 // Lview->insertAt( insertString,0,0, FALSE); 416 // Lview->insertAt( insertString,0,0, FALSE);
416 currentFilePos = f.at(); 417 currentFilePos = f.at();
417 // if( i_pageNum != pages) { 418 // if( i_pageNum != pages) {
418 // Lview->MultiLine_Ex::pageDown( FALSE); 419 // Lview->MultiLine_Ex::pageDown( FALSE);
419 i_pageNum++; 420 i_pageNum++;
420 pageStopArray.resize(i_pageNum + 1); 421 pageStopArray.resize(i_pageNum + 1);
421 // int length = Lview->length(); 422 // int length = Lview->length();
422 423
423 pageStopArray[i_pageNum ] = currentFilePos; 424 pageStopArray[i_pageNum ] = currentFilePos;
424 // odebug << currentFilePos << " current page is number " << i_pageNum 425 odebug << currentFilePos << " current page is number " << i_pageNum
425 // << ", pagesize " << pageSize << ", length " << Lview->length() 426 << ", pagesize " << pageSize << ", length " << Lview->length()
426 // << ", current " << pageStopArray[i_pageNum] << oendl; 427 << ", current " << pageStopArray[i_pageNum] << oendl;
427 setStatus(); 428 setStatus();
428 Lview->setCursorPosition( 0, 0, FALSE); 429// Lview->setCursorPosition( 0, 0, FALSE);
429 // } 430 // }
430 431
431 } else { 432 } else {
432 // odebug << "bal" << oendl; 433 odebug << "bal" << oendl;
433 // if( i_pageNum != pages) { 434 // if( i_pageNum != pages) {
434 435
435 // // int newTop = Lview->Top(); 436 // // int newTop = Lview->Top();
436 // // if(Lview->lastRow() > i) 437 // // if(Lview->lastRow() > i)
437 // Lview->ScrollUp(1); 438 // Lview->ScrollUp(1);
438 // // i_pageNum++; 439 // // i_pageNum++;
439 // setStatus(); 440 // setStatus();
440 // Lview->setCursorPosition( Lview->Top(), 0, FALSE); 441 // Lview->setCursorPosition( Lview->Top(), 0, FALSE);
441 442
442 // } 443 // }
443 444
444 } 445 }
445 Lview->setFocus(); 446 Lview->setFocus();
446 447
447 // odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl; 448 odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl;
448} 449}
449 450
450 451
451void Gutenbrowser::BackBtn() { 452void Gutenbrowser::BackBtn() {
452 if( i_pageNum > 0) { 453 if( i_pageNum > 0) {
453 int pageSize= Lview->PageSize(); 454 int pageSize= Lview->PageSize();
454 // int length=Lview->length(); 455 // int length=Lview->length();
455 456
456 i_pageNum--; 457 i_pageNum--;
457 currentFilePos = f.at(); 458 currentFilePos = f.at();
458 459
459 // odebug << currentFilePos << " move back to " << pageStopArray[i_pageNum - 1 ] 460 odebug << currentFilePos << " move back to " << pageStopArray[i_pageNum - 1 ]
460 // << ", current page number " << i_pageNum 461 << ", current page number " << i_pageNum
461 // << ", " << pageSize << ", length " << Lview->length() << oendl; 462 << ", " << pageSize << ", length " << Lview->length() << oendl;
462 463
463 if( i_pageNum < 2) { 464 if( i_pageNum < 2) {
464 f.at( 0); 465 f.at( 0);
465 } else { 466 } else {
466 if(!f.at( pageStopArray[i_pageNum - 1] )) 467 if(!f.at( pageStopArray[i_pageNum - 1] ))
467 odebug << "File positioned backward did not work" << oendl; 468 odebug << "File positioned backward did not work" << oendl;
468 } 469 }
469 QString s; 470 QString s;
470 // int sizeLine=0; 471 // int sizeLine=0;
471 Lview->clear(); 472 Lview->clear();
472 // QString insertString; 473 // QString insertString;
473 474
474 for(int fd = 0; fd < pageSize ;fd++) { 475 for(int fd = 0; fd < pageSize ;fd++) {
475 // Lview->removeLine( Lview->PageSize() ); 476 // Lview->removeLine( Lview->PageSize() );
476 f.readLine(s, 256); 477 f.readLine(s, 256);
477 if(useWrap) 478 if(useWrap)
478 s.replace(QRegExp("\n"),""); 479 s.replace(QRegExp("\n"),"");
479 currentLine++; 480 currentLine++;
480 // insertString+=s; 481 // insertString+=s;
481 Lview->insertLine( s, -1); 482 Lview->insertLine( s, -1);
482 } 483 }
483 484
484 // Lview->insertAt( insertString,0,0, FALSE); 485 // Lview->insertAt( insertString,0,0, FALSE);
485 486
486 if( !BackButton->autoRepeat() && !BackButton->isDown()) { 487 if( !BackButton->autoRepeat() && !BackButton->isDown()) {
487 QString topR; 488 QString topR;
488 QString lastR; 489 QString lastR;
489 QString pageR; 490 QString pageR;
490 // int sizer = Lview->lastRow() - Lview->topRow(); 491 // int sizer = Lview->lastRow() - Lview->topRow();
491 // int i_topRow = Lview->topRow(); 492 // int i_topRow = Lview->topRow();
492 if( i_pageNum < 1) 493 if( i_pageNum < 1)
493 i_pageNum = 1; 494 i_pageNum = 1;
494 setCaption(QString::number(i_pageNum)); 495 setCaption(QString::number(i_pageNum));
495 } else { 496 } else {
496 // int newTop = Lview->Top(); 497 // int newTop = Lview->Top();
497 // if(Lview->lastRow() > i) 498 // if(Lview->lastRow() > i)
498 Lview->MultiLine_Ex::pageUp( FALSE); 499 Lview->MultiLine_Ex::pageUp( FALSE);
499 // Lview->ScrollDown(1); 500 // Lview->ScrollDown(1);
500 // i_pageNum--; 501 // i_pageNum--;
501 if( i_pageNum < 1) 502 if( i_pageNum < 1)
502 i_pageNum = 1; 503 i_pageNum = 1;
503 setStatus(); 504 setStatus();
504 Lview->setCursorPosition( Lview->Top(), 0, FALSE); 505// Lview->setCursorPosition( Lview->Top(), 0, FALSE);
505 506
506 } 507 }
507 } 508 }
508 Lview->setFocus(); 509 Lview->setFocus();
509} 510}
510 511
511void Gutenbrowser::doBeginBtn() { 512void Gutenbrowser::doBeginBtn() {
512 if(loadCheck) { 513 if(loadCheck) {
513 qApp->processEvents(); 514 qApp->processEvents();
514 BeginBtn(); 515 BeginBtn();
515 } 516 }
516} 517}
517 518
518 // moves text to the very top = 0 519 // moves text to the very top = 0
519void Gutenbrowser::TopBtn() { 520void Gutenbrowser::TopBtn() {
520 521
521 if(loadCheck) { 522 if(loadCheck) {
522 if( i_pageNum != 0) { 523 if( i_pageNum != 0) {
523 odebug << "top" << oendl; 524 odebug << "top" << oendl;
524 qApp->processEvents(); 525 qApp->processEvents();
525 currentLine = 0; 526 currentLine = 0;
526 i_pageNum = 1; 527 i_pageNum = 1;
527 int pageSize = Lview->PageSize() ; 528 int pageSize = Lview->PageSize() ;
528 Lview->clear(); 529 Lview->clear();
529 QString s; 530 QString s;
530 f.at(0); 531 f.at(0);
531 for(int fd=0; fd < pageSize ;fd++) { 532 for(int fd=0; fd < pageSize ;fd++) {
532 f.readLine(s, 256); 533 f.readLine(s, 256);
533 if(useWrap) 534 if(useWrap)
534 s.replace(QRegExp("\n"),""); 535 s.replace(QRegExp("\n"),"");
535 Lview->insertLine(s ,-1); 536 Lview->insertLine(s ,-1);
536 currentLine++; 537 currentLine++;
537 } 538 }
538 Lview->setCursorPosition( 0,0, FALSE); 539// Lview->setCursorPosition( 0,0, FALSE);
539 i_pageNum=1; 540 i_pageNum=1;
540 setStatus(); 541 setStatus();
541 } 542 }
542 Lview->setFocus(); 543 Lview->setFocus();
543 } 544 }
544} 545}
545 546
546 //moves text to the start of the EText 547 //moves text to the start of the EText
547void Gutenbrowser::BeginBtn() { 548void Gutenbrowser::BeginBtn() {
548 i_pageNum = 1; 549 i_pageNum = 1;
549 currentLine = 0; 550 currentLine = 0;
550 QString s_pattern="*END*THE SMALL PRINT"; 551 QString s_pattern="*END*THE SMALL PRINT";
551 QString sPattern2 = "*END THE SMALL PRINT"; 552 QString sPattern2 = "*END THE SMALL PRINT";
552 553
553 int pageSize = Lview->PageSize(); 554 int pageSize = Lview->PageSize();
554 Lview->clear(); 555 Lview->clear();
555 556
556 // int lines = Lview->numLines(); 557 // int lines = Lview->numLines();
557 int pos = 0;//, i = 0; 558 int pos = 0;//, i = 0;
558 int i_topRow = Lview->topRow(); 559 int i_topRow = Lview->topRow();
559 560
560 QString LeftText;// = Lview->text(); 561 QString LeftText;// = Lview->text();
561 562
562 int linesPerPage = Lview->lastRow() - Lview->topRow(); 563 int linesPerPage = Lview->lastRow() - Lview->topRow();
563 // int pages = (( linesPerPage / Lview->editSize() ) ) +1; 564 // int pages = (( linesPerPage / Lview->editSize() ) ) +1;
564 // int pageN = 0; 565 // int pageN = 0;
565 i_pageNum = 1; 566 i_pageNum = 1;
566 int lastPage=1; 567 int lastPage=1;
567 int lineNo=0; 568 int lineNo=0;
568 QString s; 569 QString s;
569 f.at( 0); 570 f.at( 0);
570 571
571 while ( !f.atEnd() ) { 572 while ( !f.atEnd() ) {
572 f.readLine(s, 256); 573 f.readLine(s, 256);
573 lineNo++; 574 lineNo++;
574 LeftText = s; 575 LeftText = s;
575 currentFilePos = f.at(); 576 currentFilePos = f.at();
576 577
577 i_pageNum = lineNo/pageSize; 578 i_pageNum = lineNo/pageSize;
578 if(lastPage < i_pageNum) { 579 if(lastPage < i_pageNum) {
579 pageStopArray.resize(i_pageNum + 1); 580 pageStopArray.resize(i_pageNum + 1);
580 pageStopArray[i_pageNum ] = currentFilePos; 581 pageStopArray[i_pageNum ] = currentFilePos;
581 // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; 582 odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl;
582 } 583 }
583 // lastPage = i_pageNum; 584 // lastPage = i_pageNum;
584 if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) { 585 if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) {
585 odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; 586 odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl;
586 break; 587 break;
587 } 588 }
588 } 589 }
589 if(f.atEnd()) //in case we didnt find anything, we need to show something 590 if(f.atEnd()) //in case we didnt find anything, we need to show something
590 f.at(0); 591 f.at(0);
591 Lview->clear(); 592 Lview->clear();
592 for(int fd=0; fd < pageSize - 1;fd++) { 593 for(int fd=0; fd < pageSize - 1;fd++) {
593 f.readLine(s, 256); 594 f.readLine(s, 256);
594 if(useWrap) 595 if(useWrap)
595 s.replace(QRegExp("\n"),""); 596 s.replace(QRegExp("\n"),"");
596 Lview->insertLine( s, -1); 597 Lview->insertLine( s, -1);
597 currentLine++; 598 currentLine++;
598 } 599 }
599 600
600 i_pageNum = lineNo/pageSize; 601 i_pageNum = lineNo/pageSize;
601 pageStopArray.resize(i_pageNum + 1); 602 pageStopArray.resize(i_pageNum + 1);
602 // int length = Lview->length(); 603 // int length = Lview->length();
603 604
604 qApp->processEvents(); 605 qApp->processEvents();
605 606
606 if( pos > i_topRow ) { 607 if( pos > i_topRow ) {
607 Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE); 608// Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE);
608 } else { 609 } else {
609 Lview->setCursorPosition( pos+2 , 0, FALSE ); 610// Lview->setCursorPosition( pos+2 , 0, FALSE );
610 } 611 }
611 612
612 Lview->deselect(); 613 Lview->deselect();
613 // AdjustStatus(); 614 // AdjustStatus();
614 Lview->setFocus(); 615 Lview->setFocus();
615} 616}
616 617
617 /* 618 /*
618 sets the current page and place as a bookmark*/ 619 sets the current page and place as a bookmark*/
619void Gutenbrowser::setBookmark() { 620void Gutenbrowser::setBookmark() {
620 int eexit=QMessageBox::information(this, "Note", 621 int eexit=QMessageBox::information(this, "Note",
621 "Do you really want to \nset this bookmark?." 622 "Do you really want to \nset this bookmark?."
622 ,QMessageBox::Yes, QMessageBox::No); 623 ,QMessageBox::Yes, QMessageBox::No);
623 if (eexit== 3) { 624 if (eexit== 3) {
624 625
625 currentFilePos = f.at(); 626 currentFilePos = f.at();
626 627
627 Config cfg("Gutenbrowser"); 628 Config cfg("Gutenbrowser");
628 cfg.setGroup("General"); 629 cfg.setGroup("General");
629 file_name=cfg.readEntry("Current",""); 630 file_name=cfg.readEntry("Current","");
630 qApp->processEvents(); 631 qApp->processEvents();
631 odebug << "Settingbook mark "+file_name << oendl; 632 odebug << "Settingbook mark "+file_name << oendl;
632 633
633 cfg.setGroup("Titles"); 634 cfg.setGroup("Titles");
634 title=cfg.readEntry(file_name,""); 635 title=cfg.readEntry(file_name,"");
635 odebug << "title is "+ title << oendl; 636 odebug << "title is "+ title << oendl;
636 637
637 cfg.setGroup( "Bookmarks" ); 638 cfg.setGroup( "Bookmarks" );
638 639
639 cfg.writeEntry("File Name",file_name); 640 cfg.writeEntry("File Name",file_name);
640 cfg.writeEntry("Page Number",QString::number(i_pageNum) ); 641 cfg.writeEntry("Page Number",QString::number(i_pageNum) );
641 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); 642 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1]));
642 cfg.writeEntry("Title", title); 643 cfg.writeEntry("Title", title);
643 644
644 int row = Lview->topRow();// Lview->Top(); 645 int row = Lview->topRow();// Lview->Top();
645 cfg.writeEntry("LineNumber",QString::number(row) ); 646 cfg.writeEntry("LineNumber",QString::number(row) );
646 647
647 cfg.setGroup(title); 648 cfg.setGroup(title);
648 cfg.writeEntry("File Name",file_name); 649 cfg.writeEntry("File Name",file_name);
649 cfg.writeEntry( "LineNumber", QString::number( row)); 650 cfg.writeEntry( "LineNumber", QString::number( row));
650 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); 651 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1]));
651 cfg.writeEntry( "Page Number", QString::number( i_pageNum) ); 652 cfg.writeEntry( "Page Number", QString::number( i_pageNum) );
652 bookmarksMenu->insertItem( title); 653 bookmarksMenu->insertItem( title);
653 } 654 }
654} //end setBookmark 655} //end setBookmark
655 656
656 657
657 /* goes to last set bookmark*/ 658 /* goes to last set bookmark*/
658void Gutenbrowser::Bookmark( int itemId) { 659void Gutenbrowser::Bookmark( int itemId) {
659 660
660 // qApp->processEvents(); 661 // qApp->processEvents();
661 Config config("Gutenbrowser"); 662 Config config("Gutenbrowser");
662 config.setGroup( "Bookmarks" ); 663 config.setGroup( "Bookmarks" );
663 664
664 // odebug << "<<<<<< " << Lview->PageSize() << ", " << Lview->lastRow() - Lview->topRow() << "" << oendl; 665 odebug << "<<<<<< " << Lview->PageSize() << ", " << Lview->lastRow() - Lview->topRow() << "" << oendl;
665 666
666 QString itemString; 667 QString itemString;
667 668
668 odebug << "menu item " << itemId << "" << oendl; 669 odebug << "menu item " << itemId << "" << oendl;
669 QString tempTitle; 670 QString tempTitle;
670 QString s_Bmrkrow; 671 QString s_Bmrkrow;
671 QString s_pageNum; 672 QString s_pageNum;
672 int Bmrkrow=0; 673 int Bmrkrow=0;
673 int bookmarkPosition = 0; 674 int bookmarkPosition = 0;
674 675
675 // qApp->processEvents(); 676 // qApp->processEvents();
676 config.setGroup( "Bookmarks" ); 677 config.setGroup( "Bookmarks" );
677 title = config.readEntry("Title", ""); 678 title = config.readEntry("Title", "");
678 file_name = config.readEntry("File Name", ""); 679 file_name = config.readEntry("File Name", "");
679 i_pageNum = config.readNumEntry("Page Number", 0); 680 i_pageNum = config.readNumEntry("Page Number", 0);
680 bookmarkPosition = config.readNumEntry( "PagePosition",0); 681 bookmarkPosition = config.readNumEntry( "PagePosition",0);
681 Bmrkrow = config.readNumEntry("LineNumber",0); 682 Bmrkrow = config.readNumEntry("LineNumber",0);
682 if( !file_name.contains("/")) { 683 if( !file_name.contains("/")) {
683 file_name = local_library + file_name; 684 file_name = local_library + file_name;
684 } 685 }
685 686
686 // getTitle(file_name); 687 // getTitle(file_name);
687 // qApp->processEvents(); 688 // qApp->processEvents();
688 // Lview->setFocus(); 689 // Lview->setFocus();
689 this->setFocus(); 690 this->setFocus();
690 691
691 Lview->clear(); 692 Lview->clear();
692 693
693 load(file_name); 694 load(file_name);
694 695
695 int pageSize= Lview->PageSize(); 696 int pageSize= Lview->PageSize();
696 f.at(0); 697 f.at(0);
697 // Lview->clear(); 698 // Lview->clear();
698 QString s; 699 QString s;
699 int lineNo=0; 700 int lineNo=0;
700 int lastPage=1; 701 int lastPage=1;
701 while ( !f.atEnd() ) { 702 while ( !f.atEnd() ) {
702 f.readLine(s, 256); 703 f.readLine(s, 256);
703 lineNo++; 704 lineNo++;
704 currentFilePos = f.at(); 705 currentFilePos = f.at();
705 706
706 i_pageNum = lineNo/pageSize; 707 i_pageNum = lineNo/pageSize;
707 if(lastPage < i_pageNum) { 708 if(lastPage < i_pageNum) {
708 pageStopArray.resize(i_pageNum + 1); 709 pageStopArray.resize(i_pageNum + 1);
709 pageStopArray[i_pageNum ] = currentFilePos; 710 pageStopArray[i_pageNum ] = currentFilePos;
710 // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; 711 odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl;
711 } 712 }
712 if(currentFilePos == bookmarkPosition) 713 if(currentFilePos == bookmarkPosition)
713 break; 714 break;
714 } 715 }
715 if(f.atEnd()) 716 if(f.atEnd())
716 f.at(0); 717 f.at(0);
717 else 718 else
718 f.at( bookmarkPosition); 719 f.at( bookmarkPosition);
719 720
720 for(int fd=0; fd < pageSize - 1;fd++) { 721 for(int fd=0; fd < pageSize - 1;fd++) {
721 f.readLine(s, 256); 722 f.readLine(s, 256);
722 lineNo++; 723 lineNo++;
723 if(useWrap) 724 if(useWrap)
724 s.replace(QRegExp("\n"),""); 725 s.replace(QRegExp("\n"),"");
725 Lview->insertLine( s, -1); 726 Lview->insertLine( s, -1);
726 currentLine++; 727 currentLine++;
727 } 728 }
728 729
729 i_pageNum = lineNo/pageSize; 730 i_pageNum = lineNo/pageSize;
730 pageStopArray.resize(i_pageNum + 1); 731 pageStopArray.resize(i_pageNum + 1);
731 732
732 if(showMainList) { 733 if(showMainList) {
733 showMainList=FALSE; 734 showMainList=FALSE;
734 mainList->hide(); 735 mainList->hide();
735 Lview->show(); 736 Lview->show();
736 // qApp->processEvents(); 737 // qApp->processEvents();
737 } 738 }
738 739
739 odebug << "bookmark loaded" << oendl; 740 odebug << "bookmark loaded" << oendl;
740 setCaption(title); 741 setCaption(title);
741} 742}
742 743
743 744
744bool Gutenbrowser::load( const char *fileName) { 745bool Gutenbrowser::load( const char *fileName) {
745 746
746 // QCopEnvelope ( "QPE/System", "busy()" ); 747 // QCopEnvelope ( "QPE/System", "busy()" );
747 // odebug << "Title is already set as "+title << oendl; 748 odebug << "Title is already set as "+title << oendl;
748 odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl; 749 odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl;
749 if( Lview->PageSize() < 4) { 750 if( Lview->PageSize() < 4) {
750 751
751 Lview->setMaximumHeight( sizeHint().height() ); 752 Lview->setMaximumHeight( sizeHint().height() );
752 Lview->setMinimumHeight( sizeHint().height() ); 753 Lview->setMinimumHeight( sizeHint().height() );
753 pointSize = Lview->fontInfo().pointSize(); 754 pointSize = Lview->fontInfo().pointSize();
754 odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl; 755 odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl;
755 if(pointSize < 10) 756 if(pointSize < 10)
756 Lview->setFixedVisibleLines(19); 757 Lview->setFixedVisibleLines(19);
757 else 758 else
758 Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2); 759 Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2);
759 } 760 }
760 761
761 Config cfg("Gutenbrowser"); 762 Config cfg("Gutenbrowser");
762 cfg.setGroup("General"); 763 cfg.setGroup("General");
763 cfg.writeEntry("Current",fileName); 764 cfg.writeEntry("Current",fileName);
764 currentLine=0; 765 currentLine=0;
765 766
766 file_name=fileName; 767 file_name=fileName;
767 QString o_file = fileName; 768 QString o_file = fileName;
768 769
769 // if (i_pageNum < 1) { 770 // if (i_pageNum < 1) {
770 i_pageNum = 1; 771 i_pageNum = 1;
771 // } 772 // }
772 odebug << "ready to open "+o_file << oendl; 773 odebug << "ready to open "+o_file << oendl;
773 774
774 if(f.isOpen()) f.close(); 775 if(f.isOpen()) f.close();
775 f.setName( o_file); 776 f.setName( o_file);
776 777
777 if ( !f.open( IO_ReadOnly)) { 778 if ( !f.open( IO_ReadOnly)) {
778 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) ); 779 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) );
779 return false; 780 return false;
780 } 781 }
781 currentFilePos = 0; 782 currentFilePos = 0;
782 pageStopArray.resize(3); 783 pageStopArray.resize(3);
783 pageStopArray[0] = currentFilePos; 784 pageStopArray[0] = currentFilePos;
784 785
785 fileHandle = f.handle(); 786 fileHandle = f.handle();
786 QString insertString; 787 QString insertString;
787 QTextStream t(&f); 788 QTextStream t(&f);
788 QString s; 789 QString s;
789 for(int fd=0; fd < Lview->PageSize() ;fd++) { 790 for(int fd=0; fd < Lview->PageSize() ;fd++) {
790 s=t.readLine(); 791 s=t.readLine();
791 // insertString+=s; 792 // insertString+=s;
792 if(useWrap) 793 if(useWrap)
793 s.replace(QRegExp("\n"),""); 794 s.replace(QRegExp("\n"),"");
794 // s.replace(QRegExp("\r"),""); 795 // s.replace(QRegExp("\r"),"");
795 Lview->insertLine( s,-1); 796 Lview->insertLine( s,-1);
796 currentLine++; 797 currentLine++;
797 } 798 }
798 799
799 // int length = Lview->length(); 800 // int length = Lview->length();
800 currentFilePos = f.at(); 801 currentFilePos = f.at();
801 802
802 pageStopArray[1] = currentFilePos; 803 pageStopArray[1] = currentFilePos;
803 804
804 odebug << "<<<<<<<<<<<" << currentFilePos << " current page is number " << i_pageNum 805 odebug << "<<<<<<<<<<<" << currentFilePos << " current page is number " << i_pageNum
805 << ", length " << Lview->length() << ", current " << pageStopArray[i_pageNum] 806 << ", length " << Lview->length() << ", current " << pageStopArray[i_pageNum]
806 << ", pageSize " << Lview->PageSize() << oendl; 807 << ", pageSize " << Lview->PageSize() << oendl;
807 808
808 Lview->setMaxLines(Lview->PageSize()*2); 809 Lview->setMaxLines(Lview->PageSize()*2);
809 odebug << "Gulped " << currentLine << "" << oendl; 810 odebug << "Gulped " << currentLine << "" << oendl;
810 setCaption(title); 811 setCaption(title);
811 Lview->setAutoUpdate( TRUE); 812 Lview->setAutoUpdate( TRUE);
812 813
813 Lview->setCursorPosition(0,0,FALSE); 814// Lview->setCursorPosition(0,0,FALSE);
814 815
815 // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; 816 // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1;
816 //odebug << "number of pages " << pages << "" << oendl; 817 //odebug << "number of pages " << pages << "" << oendl;
817 818
818 loadCheck = true; 819 loadCheck = true;
819 enableButtons(true); 820 enableButtons(true);
820 if( donateMenu->count() == 3) { 821 if( donateMenu->count() == 3) {
821 donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() )); 822 donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() ));
822 } 823 }
823 Lview->setFocus(); 824 Lview->setFocus();
824 825
825 // QCopEnvelope("QPE/System", "notBusy()" ); 826 // QCopEnvelope("QPE/System", "notBusy()" );
826 return true; 827 return true;
827} // end load 828} // end load
828 829
829void Gutenbrowser::Search() { 830void Gutenbrowser::Search() {
830 831
831 // if( searchDlg->isHidden()) 832 // if( searchDlg->isHidden())
832 { 833 {
833 odebug << "Starting search dialog" << oendl; 834 odebug << "Starting search dialog" << oendl;
834 searchDlg = new SearchDialog( this, "Etext Search", true); 835 searchDlg = new SearchDialog( this, "Etext Search", true);
835 searchDlg->setCaption( tr( "Etext Search" )); 836 searchDlg->setCaption( tr( "Etext Search" ));
836 // searchDlg->setLabel( "- searches etext"); 837 // searchDlg->setLabel( "- searches etext");
837 connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); 838 connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot()));
838 connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); 839 connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot()));
839 840
840 QString resultString; 841 QString resultString;
841 QString string = searchDlg->searchString; 842 QString string = searchDlg->searchString;
842 Lview->deselect(); 843 Lview->deselect();
843 searchDlg->show(); 844 searchDlg->show();
844 searchDlg->result(); 845 searchDlg->result();
845 } 846 }
846} 847}
847 848
848void Gutenbrowser::search_slot( ) { 849void Gutenbrowser::search_slot( ) {
849 int line, col; 850 int line, col;
850 if (!searchDlg /*&& !loadCheck */) 851 if (!searchDlg /*&& !loadCheck */)
851 return; 852 return;
852 853
853 Lview->getCursorPosition(&line,&col); 854 Lview->getCursorPosition(&line,&col);
854 QString to_find_string=searchDlg->get_text(); 855 QString to_find_string=searchDlg->get_text();
855 856
856 // searchDlg->get_direction();// is true if searching backward 857 // searchDlg->get_direction();// is true if searching backward
857 if ( last_search != 0 && searchDlg->get_direction() ){ 858 if ( last_search != 0 && searchDlg->get_direction() ){
858 col = col - pattern.length() - 1 ; 859 col = col - pattern.length() - 1 ;
859 } 860 }
860 again: 861 again:
861 int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col); 862 int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col);
862 if(result == 0){ 863 if(result == 0){
863 if(!searchDlg->get_direction()){ // forward search 864 if(!searchDlg->get_direction()){ // forward search
864 int query = QMessageBox::information( searchDlg, "Find", 865 int query = QMessageBox::information( searchDlg, "Find",
865 "End of document reached.\nContinue from the beginning?", 866 "End of document reached.\nContinue from the beginning?",
866 "Yes", "No", "", 0,1); 867 "Yes", "No", "", 0,1);
867 if (query == 0){ 868 if (query == 0){
868 line = 0; 869 line = 0;
869 col = 0; 870 col = 0;
870 goto again; 871 goto again;
871 } 872 }
872 } else { //backward search 873 } else { //backward search
873 int query = QMessageBox::information( searchDlg, "Find", 874 int query = QMessageBox::information( searchDlg, "Find",
874 "End of document reached.\nContinue from the beginning?", 875 "End of document reached.\nContinue from the beginning?",
875 "Yes", "No", "", 0,1); 876 "Yes", "No", "", 0,1);
876 if (query == 0){ 877 if (query == 0){
877 QString string = Lview->textLine( Lview->numLines() - 1 ); 878 QString string = Lview->textLine( Lview->numLines() - 1 );
878 line = Lview->numLines() - 1; 879 line = Lview->numLines() - 1;
879 lineCheck = line; 880 lineCheck = line;
880 col = string.length(); 881 col = string.length();
881 last_search = -1; //BACKWARD; 882 last_search = -1; //BACKWARD;
882 goto again; 883 goto again;
883 } 884 }
884 } 885 }
885 } else { 886 } else {
886 887
887 //// emit CursorPositionChanged(); textLine 888 //// emit CursorPositionChanged(); textLine
888 } 889 }
889} 890}
890 891
891int Gutenbrowser::doSearch( const QString &s_pattern , bool case_sensitive, bool forward, int line, int col ) { 892int Gutenbrowser::doSearch( const QString &s_pattern , bool case_sensitive, bool forward, int line, int col ) {
892 int i, length; 893 int i, length;
893 int pos = -1; 894 int pos = -1;
894 if(forward) { 895 if(forward) {
895 QString string; 896 QString string;
896 for(i = line; i < Lview->numLines(); i++) { 897 for(i = line; i < Lview->numLines(); i++) {
897 898
898 string = Lview->textLine(i); 899 string = Lview->textLine(i);
899 pos = string.find(s_pattern, i == line ? col : 0, case_sensitive); 900 pos = string.find(s_pattern, i == line ? col : 0, case_sensitive);
900 if( pos != -1) { 901 if( pos != -1) {
901 int top = Lview->Top(); 902 int top = Lview->Top();
902 length = s_pattern.length(); 903 length = s_pattern.length();
903 if( i > Lview->lastRow() ) { 904 if( i > Lview->lastRow() ) {
904 Lview->setCursorPosition(i,pos,FALSE); 905// Lview->setCursorPosition(i,pos,FALSE);
905 for(int l = 0 ; l < length; l++) { 906 for(int l = 0 ; l < length; l++) {
906 Lview->cursorRight(TRUE); 907 Lview->cursorRight(TRUE);
907 } 908 }
908 Lview->setCursorPosition( i , pos + length, TRUE ); 909// Lview->setCursorPosition( i , pos + length, TRUE );
909 int newTop = Lview->Top(); 910 int newTop = Lview->Top();
910 if(Lview->lastRow() > i) 911 if(Lview->lastRow() > i)
911 Lview->ScrollUp( newTop - top); 912 Lview->ScrollUp( newTop - top);
912 // AdjustStatus(); 913 // AdjustStatus();
913 } else { 914 } else {
914 Lview->setCursorPosition(i,pos,FALSE); 915// Lview->setCursorPosition(i,pos,FALSE);
915 for(int l = 0 ; l < length; l++) { 916 for(int l = 0 ; l < length; l++) {
916 Lview->cursorRight(TRUE); 917 Lview->cursorRight(TRUE);
917 } 918 }
918 Lview->setCursorPosition( i , pos + length, TRUE ); 919// Lview->setCursorPosition( i , pos + length, TRUE );
919 // AdjustStatus(); 920 // AdjustStatus();
920 } 921 }
921 pattern = s_pattern; 922 pattern = s_pattern;
922 last_search = 1; //FORWARD; 923 last_search = 1; //FORWARD;
923 return 1; 924 return 1;
924 } 925 }
925 } 926 }
926 } else { //////////////// searching backwards 927 } else { //////////////// searching backwards
927 QString string; 928 QString string;
928 for( i = line; i >= 0; i--) { 929 for( i = line; i >= 0; i--) {
929 string = Lview->textLine(i); 930 string = Lview->textLine(i);
930 int line_length = string.length(); 931 int line_length = string.length();
931 pos = string.findRev(s_pattern, line == i ? col : line_length , case_sensitive); 932 pos = string.findRev(s_pattern, line == i ? col : line_length , case_sensitive);
932 if (pos != -1) { 933 if (pos != -1) {
933 // int top = Lview->Top(); 934 // int top = Lview->Top();
934 length = s_pattern.length(); 935 length = s_pattern.length();
935 if( i < Lview->Top() ) { 936 if( i < Lview->Top() ) {
936 Lview->ScrollDown( Lview->PageSize() ); 937 Lview->ScrollDown( Lview->PageSize() );
937 Lview->MultiLine_Ex::pageUp( FALSE ); 938 Lview->MultiLine_Ex::pageUp( FALSE );
938 if( ! (line == i && pos > col ) ) { 939 if( ! (line == i && pos > col ) ) {
939 Lview->setCursorPosition( i ,pos ,FALSE ); 940// Lview->setCursorPosition( i ,pos ,FALSE );
940 for(int l = 0 ; l < length; l++) { 941 for(int l = 0 ; l < length; l++) {
941 Lview->cursorRight(TRUE); 942 Lview->cursorRight(TRUE);
942 } 943 }
943 Lview->setCursorPosition(i ,pos + length ,TRUE ); 944// Lview->setCursorPosition(i ,pos + length ,TRUE );
944 // int newTop = Lview->Top(); 945 // int newTop = Lview->Top();
945 /* if(useSplitter) Rview->ScrollUp( newTop - top); 946 /* if(useSplitter) Rview->ScrollUp( newTop - top);
946 */ } 947 */ }
947 } else { 948 } else {
948 if( ! (line == i && pos > col ) ) { 949 if( ! (line == i && pos > col ) ) {
949 Lview->setCursorPosition( i, pos, FALSE ); 950// Lview->setCursorPosition( i, pos, FALSE );
950 for( int l = 0 ; l < length; l++) { 951 for( int l = 0 ; l < length; l++) {
951 Lview->cursorRight( TRUE); 952 Lview->cursorRight( TRUE);
952 } 953 }
953 Lview->setCursorPosition( i, pos + length, TRUE ); 954// Lview->setCursorPosition( i, pos + length, TRUE );
954 } 955 }
955 pattern = s_pattern; 956 pattern = s_pattern;
956 last_search = -1; 957 last_search = -1;
957 return 1; 958 return 1;
958 } 959 }
959 } 960 }
960 } 961 }
961 } 962 }
962 return 0; 963 return 0;
963} 964}
964 965
965void Gutenbrowser::LibraryBtn() { 966void Gutenbrowser::LibraryBtn() {
966 967
967 QString newestLibraryFile ="pgwhole.zip"; 968 QString newestLibraryFile ="pgwhole.zip";
968 QString zipFile; 969 QString zipFile;
969 // odebug << "Local Library is " << local_library << " " << oendl; 970 // odebug << "Local Library is " << local_library << " " << oendl;
970 zipFile="/usr/bin/unzip"; 971 zipFile="/usr/bin/unzip";
971 // odebug << "newestLibraryFile is " << newestLibraryFile << " " << oendl; 972 // odebug << "newestLibraryFile is " << newestLibraryFile << " " << oendl;
972 if( QFile::exists( local_library+newestLibraryFile)) { 973 if( QFile::exists( local_library+newestLibraryFile)) {
973 if( QFile::exists(zipFile) ) { 974 if( QFile::exists(zipFile) ) {
974 UnZipIt(newestLibraryFile); 975 UnZipIt(newestLibraryFile);
975 } 976 }
976 else 977 else
977 QMessageBox::message( "Note",( tr("Please install unzip")) ); 978 QMessageBox::message( "Note",( tr("Please install unzip")) );
978 } 979 }
979 // LibraryDlg = new LibraryDialog( this, "Library Index"); 980 // LibraryDlg = new LibraryDialog( this, "Library Index");
980 LibraryDlg->setCaption( tr( "Gutenberg Library")); 981 LibraryDlg->setCaption( tr( "Gutenberg Library"));
981 Config config("Gutenbrowser"); 982 Config config("Gutenbrowser");
982 config.setGroup("General"); 983 config.setGroup("General");
983 QString tmp=config.readEntry("RunBefore","FALSE"); 984
984 if(tmp=="FALSE") {
985 QMessageBox::message( "Note",
986 "<P>Your first time running gutenbrowser. You'll need to click the \"load library\" button to load the gutenberg index.</P>");
987 config.writeEntry("RunBefore","TRUE");
988 }
989 if(useSplitter) 985 if(useSplitter)
990 LibraryDlg->useSmallInterface=FALSE; 986 LibraryDlg->useSmallInterface=FALSE;
991 987
992 LibraryDlg->showMaximized(); 988 LibraryDlg->showMaximized();
993 989
994 if( LibraryDlg->exec() != 0 ) { 990 if( LibraryDlg->exec() != 0 ) {
995 listItemNumber = LibraryDlg->DlglistItemNumber; 991 listItemNumber = LibraryDlg->DlglistItemNumber;
996 listItemFile = LibraryDlg->DlglistItemFile; 992 listItemFile = LibraryDlg->DlglistItemFile;
997 listItemYear = LibraryDlg->DlglistItemYear; 993 listItemYear = LibraryDlg->DlglistItemYear;
998 listItemTitle = LibraryDlg->DlglistItemTitle; 994 listItemTitle = LibraryDlg->DlglistItemTitle;
999 file_name = LibraryDlg->File_Name; 995 file_name = LibraryDlg->File_Name;
1000 // odebug << "title is being set as "+title << oendl; 996 // odebug << "title is being set as "+title << oendl;
1001 title = listItemTitle; 997 title = listItemTitle;
1002 998
1003 // config.setGroup( "Proxy" ); 999 // config.setGroup( "Proxy" );
1004 // if( LibraryDlg->checked == 1) { 1000 // if( LibraryDlg->checked == 1) {
1005 // config.writeEntry("IsChecked", "TRUE"); 1001 // config.writeEntry("IsChecked", "TRUE");
1006 // } else { 1002 // } else {
1007 // config.writeEntry("IsChecked", "FALSE"); 1003 // config.writeEntry("IsChecked", "FALSE");
1008 // } 1004 // }
1009 // config.write(); 1005 // config.write();
1010 // config.read(); 1006 // config.read();
1011 if ( listItemNumber.isNull()) { 1007 if ( listItemNumber.isNull()) {
1012 } else { 1008 } else {
1013 i_pageNum = 1; 1009 i_pageNum = 1;
1014 if( file_name !="Error" && file_name.length() >2 && !file_name.isEmpty() ) { 1010 if( file_name !="Error" && file_name.length() >2 && !file_name.isEmpty() ) {
1015 //replace .zip with txt for opening it. 1011 //replace .zip with txt for opening it.
1016 // printf("\nFile name is now\n"); 1012 // printf("\nFile name is now\n");
1017 // printf(file_name); 1013 // printf(file_name);
1018 // printf("\n"); 1014 // printf("\n");
1019 // 1015 //
1020 if( file_name.find(".zip")) 1016 if( file_name.find(".zip"))
1021 { 1017 {
1022 odebug << "Found zip file\n" << oendl; 1018 odebug << "Found zip file\n" << oendl;
1023 // QStringList args; 1019 // QStringList args;
1024 // args="unzip"; 1020 // args="unzip";
1025 // args+="-o"; 1021 // args+="-o";
1026 // args+=local_library+file_name; 1022 // args+=local_library+file_name;
1027 // args+="-d"; 1023 // args+="-d";
1028 // args+=local_library; 1024 // args+=local_library;
1029 QString cmd = "/usr/bin/unzip -o " + local_library+file_name + " -d " + local_library; 1025 QString cmd = "/usr/bin/unzip -o " + local_library+file_name + " -d " + local_library;
1030 odebug << "Issuing the command "+ cmd << oendl; 1026 odebug << "Issuing the command "+ cmd << oendl;
1031 // unzipProc=new QProcess( this, "unzipProc" ); /// fark that idea! 1027 // unzipProc=new QProcess( this, "unzipProc" ); /// fark that idea!
1032 // unzipProc->start(); 1028 // unzipProc->start();
1033 system(cmd); 1029 system(cmd);
1034 remove( file_name); 1030 remove( file_name);
1035 1031
1036 } 1032 }
1037 // // 1033 // //
1038 // file_name = file_name.left(4)+ ".txt"; 1034 // file_name = file_name.left(4)+ ".txt";
1039 if( LibraryDlg) 1035 if( LibraryDlg)
1040 delete LibraryDlg; 1036 delete LibraryDlg;
1041 setTitle(); 1037 setTitle();
1042 // QCopEnvelope ( "QPE/System", "busy()" ); 1038 // QCopEnvelope ( "QPE/System", "busy()" );
1043 load( file_name); 1039 load( file_name);
1044 } else { 1040 } else {
1045 printf("Not opening the file.\n"); 1041 printf("Not opening the file.\n");
1046 } 1042 }
1047 } 1043 }
1048 } 1044 }
1049 if(showMainList) { 1045 if(showMainList) {
1050 if(!Lview->isHidden()) 1046 if(!Lview->isHidden())
1051 Lview->hide(); 1047 Lview->hide();
1052 qApp->processEvents(); 1048 qApp->processEvents();
1053 showMainList=TRUE; 1049 showMainList=TRUE;
1054 if(mainList->isHidden()) 1050 if(mainList->isHidden())
1055 mainList->show(); 1051 mainList->show();
1056 fillWithTitles(); 1052 fillWithTitles();
1057 qApp->processEvents(); 1053 qApp->processEvents();
1058 } else 1054 } else
1059 setCentralWidget( Lview); 1055 setCentralWidget( Lview);
1060 // QPEApplication::grabKeyboard(); 1056 // QPEApplication::grabKeyboard();
1061 // fixKeys(); 1057 // fixKeys();
1062} 1058}
1063 1059
1064void Gutenbrowser::OpenBtn() { 1060void Gutenbrowser::OpenBtn() {
1065 QString s_temp; 1061 QString s_temp;
1066 s_temp = status; 1062 s_temp = status;
1067 OpenEtext* OpenDlg; 1063 OpenEtext* OpenDlg;
1068 OpenDlg = new OpenEtext(this,"OpenDlg"); 1064 OpenDlg = new OpenEtext(this,"OpenDlg");
1069 OpenDlg->showMaximized(); 1065 OpenDlg->showMaximized();
1070 1066
1071 if( OpenDlg->exec() != 0) { 1067 if( OpenDlg->exec() != 0) {
1072 title = OpenDlg->openFileTitle; 1068 title = OpenDlg->openFileTitle;
1073 odebug << "title open as "+title << oendl; 1069 odebug << "title open as "+title << oendl;
1074 file_name = OpenDlg->file; 1070 file_name = OpenDlg->file;
1075 i_pageNum = 1; 1071 i_pageNum = 1;
1076 1072
1077 if( !file_name.isEmpty() || file_name.length() > 2 ) { 1073 if( !file_name.isEmpty() || file_name.length() > 2 ) {
1078 if(showMainList) { 1074 if(showMainList) {
1079 showMainList=FALSE; 1075 showMainList=FALSE;
1080 odebug << "ShowMainList is now false" << oendl; 1076 odebug << "ShowMainList is now false" << oendl;
1081 mainList->hide(); 1077 mainList->hide();
1082 Lview->show(); 1078 Lview->show();
1083 qApp->processEvents(); 1079 qApp->processEvents();
1084 } 1080 }
1085 Lview->clear(); 1081 Lview->clear();
1086 // QCopEnvelope ( "QPE/System", "busy()" ); 1082 // QCopEnvelope ( "QPE/System", "busy()" );
1087 load(file_name); 1083 load(file_name);
1088 } else { 1084 } else {
1089 odebug << "file_name is empty!" << oendl; 1085 odebug << "file_name is empty!" << oendl;
1090 if(showMainList) { 1086 if(showMainList) {
1091 if(!Lview->isHidden()) 1087 if(!Lview->isHidden())
1092 Lview->hide(); 1088 Lview->hide();
1093 qApp->processEvents(); 1089 qApp->processEvents();
1094 if(mainList->isHidden()) 1090 if(mainList->isHidden())
1095 mainList->show(); 1091 mainList->show();
1096 fillWithTitles(); 1092 fillWithTitles();
1097 qApp->processEvents(); 1093 qApp->processEvents();
1098 } 1094 }
1099 1095
1100 } 1096 }
1101 } 1097 }
1102 if( OpenDlg) 1098 if( OpenDlg)
1103 delete OpenDlg; 1099 delete OpenDlg;
1104 /* 1100 /*
1105 Config config("Gutenbrowser"); 1101 Config config("Gutenbrowser");
1106 config.setGroup( title); 1102 config.setGroup( title);
1107 file_name = config.readEntry("File Name", ""); 1103 file_name = config.readEntry("File Name", "");
1108 i_pageNum = config.readNumEntry("Page Number", -1); 1104 i_pageNum = config.readNumEntry("Page Number", -1);
1109 int Bmrkrow = config.readNumEntry("LineNumber", -1); 1105 int Bmrkrow = config.readNumEntry("LineNumber", -1);
1110 if(Bmrkrow > -1) { 1106 if(Bmrkrow > -1) {
1111 if( Bmrkrow > Lview->topRow() ) { 1107 if( Bmrkrow > Lview->topRow() ) {
1112 Lview->setCursorPosition( Bmrkrow ,0, FALSE ); 1108 Lview->setCursorPosition( Bmrkrow ,0, FALSE );
1113 Lview->ScrollUp( Bmrkrow - Lview->topRow() ); 1109 Lview->ScrollUp( Bmrkrow - Lview->topRow() );
1114 // AdjustStatus(); 1110 // AdjustStatus();
1115 } 1111 }
1116 else if( Bmrkrow < Lview->topRow() ) { 1112 else if( Bmrkrow < Lview->topRow() ) {
1117 Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE ); 1113 Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE );
1118 Lview->ScrollDown( Lview->topRow() - Bmrkrow ); 1114 Lview->ScrollDown( Lview->topRow() - Bmrkrow );
1119 // AdjustStatus(); 1115 // AdjustStatus();
1120 } 1116 }
1121 } 1117 }
1122 */ 1118 */
1123 // ResizeEdits(); 1119 // ResizeEdits();
1124 1120
1125} 1121}
1126 1122
1127void Gutenbrowser::ChangeFont() { 1123void Gutenbrowser::ChangeFont() {
1128#ifndef Q_WS_QWS 1124#ifndef Q_WS_QWS
1129 bool ok; 1125 bool ok;
1130 1126
1131 weight= Lview->fontInfo().weight(); 1127 weight= Lview->fontInfo().weight();
1132 italic = Lview->fontInfo().italic(); 1128 italic = Lview->fontInfo().italic();
1133 bold=Lview->fontInfo().bold(); 1129 bold=Lview->fontInfo().bold();
1134 pointSize= Lview->fontInfo().pointSize(); 1130 pointSize= Lview->fontInfo().pointSize();
1135 fontStr=Lview->fontInfo().family(); 1131 fontStr=Lview->fontInfo().family();
1136 1132
1137 if(italic == true) 1133 if(italic == true)
1138 italicStr="TRUE"; 1134 italicStr="TRUE";
1139 else 1135 else
1140 italicStr="FALSE"; 1136 italicStr="FALSE";
1141 1137
1142 QFont currentfont( fontStr, pointSize, weight, italic ); 1138 QFont currentfont( fontStr, pointSize, weight, italic );
1143 1139
1144 if (ok) { 1140 if (ok) {
1145 QFontInfo fontInfo(font ); 1141 QFontInfo fontInfo(font );
1146 fontStr=fontInfo.family(); 1142 fontStr=fontInfo.family();
1147 1143
1148 pointSize= fontInfo.pointSize(); 1144 pointSize= fontInfo.pointSize();
1149 1145
1150 font.setFontSize(pointSize); 1146 font.setFontSize(pointSize);
1151 1147
1152 pointSizeStr.setNum( pointSize); 1148 pointSizeStr.setNum( pointSize);
1153 1149
1154 weight= fontInfo.weight(); 1150 weight= fontInfo.weight();
1155 weightStr.setNum( weight); 1151 weightStr.setNum( weight);
1156 italic =fontInfo.italic(); 1152 italic =fontInfo.italic();
1157 bold=fontInfo.bold(); 1153 bold=fontInfo.bold();
1158 1154
1159 if(italic == true) 1155 if(italic == true)
1160 italicStr="TRUE"; 1156 italicStr="TRUE";
1161 else 1157 else
1162 italicStr="FALSE"; 1158 italicStr="FALSE";
1163 if(bold == true) 1159 if(bold == true)
1164 boldStr="TRUE"; 1160 boldStr="TRUE";
1165 else 1161 else
1166 boldStr="FALSE"; 1162 boldStr="FALSE";
1167 1163
1168 pointSizeStr.setNum( pointSize); 1164 pointSizeStr.setNum( pointSize);
1169 config.setGroup( "Font" ); 1165 config.setGroup( "Font" );
1170 config.writeEntry("Family", fontStr ); 1166 config.writeEntry("Family", fontStr );
1171 config.writeEntry("Size", pointSizeStr ); 1167 config.writeEntry("Size", pointSizeStr );
1172 config.writeEntry("Weight", weightStr ); 1168 config.writeEntry("Weight", weightStr );
1173 config.writeEntry("Italic", italicStr ); 1169 config.writeEntry("Italic", italicStr );
1174 config.writeEntry("Bold", boldStr ); 1170 config.writeEntry("Bold", boldStr );
1175 // config.write(); 1171 // config.write();
1176 1172
1177 Lview->setFont(font); 1173 Lview->setFont(font);
1178 1174
1179 QRect lRect; 1175 QRect lRect;
1180 QRect rRect; 1176 QRect rRect;
@@ -1601,390 +1597,390 @@ void Gutenbrowser::OnNetworkDialog( const QString &/*networkUrl*/, const QString
1601 1597
1602void Gutenbrowser::donateGutenberg() 1598void Gutenbrowser::donateGutenberg()
1603{ 1599{
1604 int exit=QMessageBox::information(this, "Info", "http://www.gutenberg.org\ndonate@gutenberg.net", 1600 int exit=QMessageBox::information(this, "Info", "http://www.gutenberg.org\ndonate@gutenberg.net",
1605 QMessageBox::Ok, QMessageBox::Cancel); 1601 QMessageBox::Ok, QMessageBox::Cancel);
1606 1602
1607 if (exit==1) { 1603 if (exit==1) {
1608 } else { 1604 } else {
1609 }; 1605 };
1610} 1606}
1611 1607
1612void Gutenbrowser::donateByteMonkie() 1608void Gutenbrowser::donateByteMonkie()
1613{ 1609{
1614} 1610}
1615 1611
1616void Gutenbrowser::writeConfig() 1612void Gutenbrowser::writeConfig()
1617{ 1613{
1618 // config.read(); 1614 // config.read();
1619 // Config config("Gutenbrowser"); 1615 // Config config("Gutenbrowser");
1620 // #ifndef Q_WS_QWS 1616 // #ifndef Q_WS_QWS
1621 // config.setGroup( "Geometry" ); 1617 // config.setGroup( "Geometry" );
1622 // QString s; 1618 // QString s;
1623 // QString globalPosition; 1619 // QString globalPosition;
1624 // QPoint point; 1620 // QPoint point;
1625 // point=mapToGlobal(QPoint(0,0) ); 1621 // point=mapToGlobal(QPoint(0,0) );
1626 // int posiX, posiY; 1622 // int posiX, posiY;
1627 // posiX=point.x(); 1623 // posiX=point.x();
1628 // posiY=point.y(); 1624 // posiY=point.y();
1629 // globalPosition.sprintf("%i,%i", posiX, posiY); 1625 // globalPosition.sprintf("%i,%i", posiX, posiY);
1630 1626
1631 // QRect frameRect; 1627 // QRect frameRect;
1632 // frameRect = geometry(); 1628 // frameRect = geometry();
1633 // s.sprintf("%i,%i", frameRect.width(), frameRect.height()); 1629 // s.sprintf("%i,%i", frameRect.width(), frameRect.height());
1634 // config.writeEntry("Frame", s); 1630 // config.writeEntry("Frame", s);
1635 // config.writeEntry("Position", globalPosition); 1631 // config.writeEntry("Position", globalPosition);
1636 1632
1637 // if( useIcons==TRUE) 1633 // if( useIcons==TRUE)
1638 // config.writeEntry("Icons", "TRUE"); 1634 // config.writeEntry("Icons", "TRUE");
1639 // else 1635 // else
1640 // config.writeEntry("Icons", "FALSE"); 1636 // config.writeEntry("Icons", "FALSE");
1641 // #endif 1637 // #endif
1642 1638
1643 // #ifndef Q_WS_QWS 1639 // #ifndef Q_WS_QWS
1644 // QString temp; 1640 // QString temp;
1645 // temp.setNum(styleI, 10); 1641 // temp.setNum(styleI, 10);
1646 // config.setGroup( "StyleIze" ); 1642 // config.setGroup( "StyleIze" );
1647 // config.writeEntry( "Style", temp); 1643 // config.writeEntry( "Style", temp);
1648 // #endif 1644 // #endif
1649 1645
1650 // config.setGroup("General"); 1646 // config.setGroup("General");
1651} 1647}
1652 1648
1653void Gutenbrowser::annotations() 1649void Gutenbrowser::annotations()
1654{ 1650{
1655 // #ifndef Q_WS_QWS 1651 // #ifndef Q_WS_QWS
1656 // QMessageBox::message("Note","hi annotate"); 1652 // QMessageBox::message("Note","hi annotate");
1657 // lastBmkButton->setDown(FALSE); 1653 // lastBmkButton->setDown(FALSE);
1658 // #endif 1654 // #endif
1659} 1655}
1660 1656
1661void Gutenbrowser::hideButtons() 1657void Gutenbrowser::hideButtons()
1662{ 1658{
1663 1659
1664 if( !buttonsHidden) { 1660 if( !buttonsHidden) {
1665 buttonsHidden=TRUE; 1661 buttonsHidden=TRUE;
1666 LibraryButton->hide(); 1662 LibraryButton->hide();
1667 SearchButton->hide(); 1663 SearchButton->hide();
1668 InfoBar->hide(); 1664 InfoBar->hide();
1669 OpenButton->hide(); 1665 OpenButton->hide();
1670 BackButton->hide(); 1666 BackButton->hide();
1671 ForwardButton->hide(); 1667 ForwardButton->hide();
1672 setBookmarkButton->hide(); 1668 setBookmarkButton->hide();
1673 lastBmkButton->hide(); 1669 lastBmkButton->hide();
1674 dictionaryButton->hide(); 1670 dictionaryButton->hide();
1675 if(useSplitter) { 1671 if(useSplitter) {
1676 ClearButton->hide(); 1672 ClearButton->hide();
1677 PrintButton->hide(); 1673 PrintButton->hide();
1678 beginButton->hide(); 1674 beginButton->hide();
1679 HelpButton->hide(); 1675 HelpButton->hide();
1680 FontButton->hide(); 1676 FontButton->hide();
1681 ExitButton->hide(); 1677 ExitButton->hide();
1682 OptionsButton->hide(); 1678 OptionsButton->hide();
1683 DownloadButton->hide(); 1679 DownloadButton->hide();
1684 } 1680 }
1685 } else { 1681 } else {
1686 buttonsHidden=FALSE; 1682 buttonsHidden=FALSE;
1687 1683
1688 LibraryButton->show(); 1684 LibraryButton->show();
1689 SearchButton->show(); 1685 SearchButton->show();
1690 InfoBar->show(); 1686 InfoBar->show();
1691 OpenButton->show(); 1687 OpenButton->show();
1692 BackButton->show(); 1688 BackButton->show();
1693 ForwardButton->show(); 1689 ForwardButton->show();
1694 setBookmarkButton->show(); 1690 setBookmarkButton->show();
1695 lastBmkButton->show(); 1691 lastBmkButton->show();
1696 dictionaryButton->show(); 1692 dictionaryButton->show();
1697 if(useSplitter) { 1693 if(useSplitter) {
1698 ClearButton->show(); 1694 ClearButton->show();
1699 PrintButton->show(); 1695 PrintButton->show();
1700 beginButton->show(); 1696 beginButton->show();
1701 HelpButton->show(); 1697 HelpButton->show();
1702 FontButton->show(); 1698 FontButton->show();
1703 ExitButton->show(); 1699 ExitButton->show();
1704 OptionsButton->show(); 1700 OptionsButton->show();
1705 DownloadButton->show(); 1701 DownloadButton->show();
1706 } 1702 }
1707 } 1703 }
1708} 1704}
1709 1705
1710void Gutenbrowser::focusInEvent( QFocusEvent* ) 1706void Gutenbrowser::focusInEvent( QFocusEvent* )
1711{ 1707{
1712} 1708}
1713void Gutenbrowser::focusOutEvent( QFocusEvent* ) 1709void Gutenbrowser::focusOutEvent( QFocusEvent* )
1714{ 1710{
1715} 1711}
1716 1712
1717void Gutenbrowser::cleanUp( ) 1713void Gutenbrowser::cleanUp( )
1718{ 1714{
1719 writeConfig(); 1715 writeConfig();
1720 QPEApplication::grabKeyboard(); 1716 QPEApplication::grabKeyboard();
1721 1717
1722 QPEApplication::ungrabKeyboard(); 1718 QPEApplication::ungrabKeyboard();
1723 // odebug << "Cleanup" << oendl; 1719 // odebug << "Cleanup" << oendl;
1724 if(f.isOpen()) f.close(); 1720 if(f.isOpen()) f.close();
1725} 1721}
1726 1722
1727void Gutenbrowser::fixKeys() 1723void Gutenbrowser::fixKeys()
1728{ 1724{
1729 odebug << "Attempting to fix keys" << oendl; 1725 odebug << "Attempting to fix keys" << oendl;
1730 1726
1731} 1727}
1732 1728
1733void Gutenbrowser::enableButtons(bool b) 1729void Gutenbrowser::enableButtons(bool b)
1734{ 1730{
1735 BackButton->setEnabled(b); 1731 BackButton->setEnabled(b);
1736 ForwardButton->setEnabled(b); 1732 ForwardButton->setEnabled(b);
1737 SearchButton->setEnabled(b); 1733 SearchButton->setEnabled(b);
1738 setBookmarkButton->setEnabled(b); 1734 setBookmarkButton->setEnabled(b);
1739 dictionaryButton->setEnabled(b); 1735 dictionaryButton->setEnabled(b);
1740 InfoBar->setEnabled(b); 1736 InfoBar->setEnabled(b);
1741 1737
1742 editMenu->setItemEnabled( -5, b); 1738 editMenu->setItemEnabled( -5, b);
1743 editMenu->setItemEnabled( -6, b); 1739 editMenu->setItemEnabled( -6, b);
1744 editMenu->setItemEnabled( -7, b); 1740 editMenu->setItemEnabled( -7, b);
1745 editMenu->setItemEnabled( -8, b); 1741 editMenu->setItemEnabled( -8, b);
1746 1742
1747} 1743}
1748 1744
1749void Gutenbrowser::fillWithTitles() { 1745void Gutenbrowser::fillWithTitles() {
1750 Config config("Gutenbrowser"); 1746 Config config("Gutenbrowser");
1751 config.setGroup( "Files" ); 1747 config.setGroup( "Files" );
1752 int i_numofFiles = config.readNumEntry("NumberOfFiles", 0); 1748 int i_numofFiles = config.readNumEntry("NumberOfFiles", 0);
1753 mainList->clear(); 1749 mainList->clear();
1754 QString temp; 1750 QString temp;
1755 for (int i = 1; i <= i_numofFiles; i++) { 1751 for (int i = 1; i <= i_numofFiles; i++) {
1756 temp.setNum(i); 1752 temp.setNum(i);
1757 config.setGroup( "Files" ); 1753 config.setGroup( "Files" );
1758 QString ramble = config.readEntry(temp, "" ); 1754 QString ramble = config.readEntry(temp, "" );
1759 config.setGroup( "Titles" ); 1755 config.setGroup( "Titles" );
1760 temp = config.readEntry(ramble, ""); 1756 temp = config.readEntry(ramble, "");
1761 if( !temp.isEmpty()) { 1757 if( !temp.isEmpty()) {
1762 mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), temp, -1); 1758 mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), temp, -1);
1763 } 1759 }
1764 } 1760 }
1765} 1761}
1766 1762
1767void Gutenbrowser::listClickedSlot( QListBoxItem * index) { 1763void Gutenbrowser::listClickedSlot( QListBoxItem * index) {
1768 // if( !working) { 1764 // if( !working) {
1769 // working=true; 1765 // working=true;
1770 if(index) { 1766 if(index) {
1771 // QCopEnvelope ( "QPE/System", "busy()" ); 1767 // QCopEnvelope ( "QPE/System", "busy()" );
1772 title = index->text(); 1768 title = index->text();
1773 showMainList=FALSE; 1769 showMainList=FALSE;
1774 mainList->hide(); 1770 mainList->hide();
1775 Lview->show(); 1771 Lview->show();
1776 qApp->processEvents(); 1772 qApp->processEvents();
1777 QString temp; 1773 QString temp;
1778 temp.setNum( mainList->currentItem() + 1); 1774 temp.setNum( mainList->currentItem() + 1);
1779 // openFileTitle = title; 1775 // openFileTitle = title;
1780 Config config("Gutenbrowser"); 1776 Config config("Gutenbrowser");
1781 config.setGroup( "Files" ); 1777 config.setGroup( "Files" );
1782 QString file = config.readEntry(temp, ""); 1778 QString file = config.readEntry(temp, "");
1783 odebug << "About to load" << oendl; 1779 odebug << "About to load" << oendl;
1784 if( Lview->isVisible()) 1780 if( Lview->isVisible())
1785 load(file); 1781 load(file);
1786 1782
1787 config.setGroup( title); 1783 config.setGroup( title);
1788 file_name = config.readEntry("File Name", ""); 1784 file_name = config.readEntry("File Name", "");
1789 i_pageNum = config.readNumEntry("Page Number", 1); 1785 i_pageNum = config.readNumEntry("Page Number", 1);
1790 int Bmrkrow = config.readNumEntry("LineNumber", -1); 1786 int Bmrkrow = config.readNumEntry("LineNumber", -1);
1791 if(Bmrkrow > -1) { 1787 if(Bmrkrow > -1) {
1792 if( Bmrkrow > Lview->topRow() ) { 1788 if( Bmrkrow > Lview->topRow() ) {
1793 Lview->setCursorPosition( Bmrkrow /* - Lview->topRow() */,0, FALSE ); 1789// Lview->setCursorPosition( Bmrkrow /* - Lview->topRow() */,0, FALSE );
1794 Lview->ScrollUp( Bmrkrow - Lview->topRow() ); 1790 Lview->ScrollUp( Bmrkrow - Lview->topRow() );
1795 // AdjustStatus(); 1791 // AdjustStatus();
1796 } 1792 }
1797 else if( Bmrkrow < Lview->topRow() ) { 1793 else if( Bmrkrow < Lview->topRow() ) {
1798 Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE ); 1794// Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE );
1799 Lview->ScrollDown( Lview->topRow() - Bmrkrow ); 1795 Lview->ScrollDown( Lview->topRow() - Bmrkrow );
1800 // AdjustStatus(); 1796 // AdjustStatus();
1801 } 1797 }
1802 } 1798 }
1803 } 1799 }
1804} 1800}
1805 1801
1806void Gutenbrowser::infoGutenbrowser() { 1802void Gutenbrowser::infoGutenbrowser() {
1807 QMessageBox::message("Info","Gutenbrowser was developed by\n" 1803 QMessageBox::message("Info","Gutenbrowser was developed by\n"
1808 "Lorn Potter\n" 1804 "Lorn Potter\n"
1809 "ljp<ljp@llornkcor.com>\n"); 1805 "ljp<ljp@llornkcor.com>\n");
1810} 1806}
1811 1807
1812void Gutenbrowser::setDocument(const QString & frozenBoogers) { 1808void Gutenbrowser::setDocument(const QString & frozenBoogers) {
1813 this->hide(); 1809 this->hide();
1814 if(showMainList) { 1810 if(showMainList) {
1815 showMainList=FALSE; 1811 showMainList=FALSE;
1816 if(!mainList->isHidden()) 1812 if(!mainList->isHidden())
1817 mainList->hide(); 1813 mainList->hide();
1818 if(Lview->isHidden()) 1814 if(Lview->isHidden())
1819 Lview->show(); 1815 Lview->show();
1820 qApp->processEvents(); 1816 qApp->processEvents();
1821 } 1817 }
1822 DocLnk lnk; 1818 DocLnk lnk;
1823 lnk = DocLnk(frozenBoogers); 1819 lnk = DocLnk(frozenBoogers);
1824 // odebug << lnk.file() << oendl; 1820 // odebug << lnk.file() << oendl;
1825 title=lnk.comment(); 1821 title=lnk.comment();
1826 load( lnk.file()); 1822 load( lnk.file());
1827 this->show(); 1823 this->show();
1828 // odebug << title << oendl; 1824 // odebug << title << oendl;
1829 // qApp->processEvents(); 1825 // qApp->processEvents();
1830 // repaint(); 1826 // repaint();
1831} 1827}
1832 1828
1833void Gutenbrowser::mainListPressed(int mouse, QListBoxItem * , const QPoint & ) 1829void Gutenbrowser::mainListPressed(int mouse, QListBoxItem * , const QPoint & )
1834{ 1830{
1835 switch (mouse) { 1831 switch (mouse) {
1836 case 1: 1832 case 1:
1837 break; 1833 break;
1838 case 2: { 1834 case 2: {
1839 QPopupMenu m;// = new QPopupMenu( Local_View ); 1835 QPopupMenu m;// = new QPopupMenu( Local_View );
1840 m.insertItem( tr( "Open" ), this, SLOT( menuOpen() )); 1836 m.insertItem( tr( "Open" ), this, SLOT( menuOpen() ));
1841 m.insertSeparator(); 1837 m.insertSeparator();
1842 m.insertItem( tr( "Search google.com" ), this, SLOT( menuGoogle())); 1838 m.insertItem( tr( "Search google.com" ), this, SLOT( menuGoogle()));
1843 m.insertItem( tr( "Edit Title" ), this, SLOT( menuEditTitle())); 1839 m.insertItem( tr( "Edit Title" ), this, SLOT( menuEditTitle()));
1844 // m.insertSeparator(); 1840 // m.insertSeparator();
1845 // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 1841 // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
1846 m.exec( QCursor::pos() ); 1842 m.exec( QCursor::pos() );
1847 } 1843 }
1848 break; 1844 break;
1849 }; 1845 };
1850} 1846}
1851 1847
1852void Gutenbrowser::menuOpen() { 1848void Gutenbrowser::menuOpen() {
1853 listClickedSlot( mainList->item( mainList->currentItem())); 1849 listClickedSlot( mainList->item( mainList->currentItem()));
1854} 1850}
1855 1851
1856void Gutenbrowser::menuGoogle() { 1852void Gutenbrowser::menuGoogle() {
1857 searchGoogle( mainList->text(mainList->currentItem())); 1853 searchGoogle( mainList->text(mainList->currentItem()));
1858} 1854}
1859 1855
1860void Gutenbrowser::searchGoogle( const QString &tempText) { 1856void Gutenbrowser::searchGoogle( const QString &tempText) {
1861 QString text = tempText; 1857 QString text = tempText;
1862 1858
1863 int eexit=QMessageBox::information(this, "Note","Do you want to search for\n"+text+ 1859 int eexit=QMessageBox::information(this, "Note","Do you want to search for\n"+text+
1864 "\non google.com?",QMessageBox::Yes, QMessageBox::No); 1860 "\non google.com?",QMessageBox::Yes, QMessageBox::No);
1865 if (eexit== 3) { 1861 if (eexit== 3) {
1866 qApp->processEvents(); 1862 qApp->processEvents();
1867 text.replace( QRegExp("\\s"), "%20"); 1863 text.replace( QRegExp("\\s"), "%20");
1868 text.replace( QRegExp("#"), ""); 1864 text.replace( QRegExp("#"), "");
1869 text.replace( QRegExp(","), "%20"); 1865 text.replace( QRegExp(","), "%20");
1870 text.replace( QRegExp("'"), "%20"); 1866 text.replace( QRegExp("'"), "%20");
1871 text.replace( QRegExp("("), ""); 1867 text.replace( QRegExp("("), "");
1872 text.replace( QRegExp(")"), ""); 1868 text.replace( QRegExp(")"), "");
1873 // text.replace( QRegExp("[0-9]"), ""); 1869 // text.replace( QRegExp("[0-9]"), "");
1874 QString s_lookup = "http://google.com/search?q="+text+"&num=30&sa=Google+Search"; 1870 QString s_lookup = "http://google.com/search?q="+text+"&num=30&sa=Google+Search";
1875 goGetit( s_lookup, true); 1871 goGetit( s_lookup, true);
1876 } 1872 }
1877 1873
1878} 1874}
1879 1875
1880void Gutenbrowser::menuEditTitle() 1876void Gutenbrowser::menuEditTitle()
1881{ 1877{
1882 int currentItem = mainList->currentItem(); 1878 int currentItem = mainList->currentItem();
1883 QString title_text = mainList->text( currentItem); 1879 QString title_text = mainList->text( currentItem);
1884 //odebug << "Selected "+title_text << oendl; 1880 //odebug << "Selected "+title_text << oendl;
1885 1881
1886 Config config("Gutenbrowser"); 1882 Config config("Gutenbrowser");
1887 config.setGroup( "Files" ); 1883 config.setGroup( "Files" );
1888 QString s_numofFiles = config.readEntry("NumberOfFiles", "0"); 1884 QString s_numofFiles = config.readEntry("NumberOfFiles", "0");
1889 int i_numofFiles = s_numofFiles.toInt(); 1885 int i_numofFiles = s_numofFiles.toInt();
1890 QString fileNum; 1886 QString fileNum;
1891 for (int i = 1; i <= i_numofFiles+1; i++) { 1887 for (int i = 1; i <= i_numofFiles+1; i++) {
1892 1888
1893 fileNum.setNum(i); 1889 fileNum.setNum(i);
1894 config.setGroup( "Files" ); 1890 config.setGroup( "Files" );
1895 QString s_filename = config.readEntry(fileNum, "" ); 1891 QString s_filename = config.readEntry(fileNum, "" );
1896 config.setGroup( "Titles" ); 1892 config.setGroup( "Titles" );
1897 QString file_title = config.readEntry( s_filename, ""); 1893 QString file_title = config.readEntry( s_filename, "");
1898 //odebug << "file_title is "+file_title << oendl; 1894 //odebug << "file_title is "+file_title << oendl;
1899 if(title_text == file_title ) { 1895 if(title_text == file_title ) {
1900 // selFile = s_filename; 1896 // selFile = s_filename;
1901 //odebug << "Edit: "+ file_title << oendl; 1897 //odebug << "Edit: "+ file_title << oendl;
1902 i=i_numofFiles+1; 1898 i=i_numofFiles+1;
1903 Edit_Title *titleEdit; 1899 Edit_Title *titleEdit;
1904 titleEdit = new Edit_Title(this,file_title ,TRUE); 1900 titleEdit = new Edit_Title(this,file_title ,TRUE);
1905 if(titleEdit->exec() !=0) { 1901 if(titleEdit->exec() !=0) {
1906 //odebug << titleEdit->newTitle << oendl; 1902 //odebug << titleEdit->newTitle << oendl;
1907 config.writeEntry( s_filename, titleEdit->newTitle); 1903 config.writeEntry( s_filename, titleEdit->newTitle);
1908 mainList->removeItem(currentItem); 1904 mainList->removeItem(currentItem);
1909 mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), titleEdit->newTitle, currentItem); 1905 mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), titleEdit->newTitle, currentItem);
1910 } 1906 }
1911 } 1907 }
1912 } 1908 }
1913 1909
1914 // getTitles(); 1910 // getTitles();
1915 mainList->triggerUpdate(true); 1911 mainList->triggerUpdate(true);
1916 1912
1917} 1913}
1918 1914
1919 1915
1920 1916
1921bool Gutenbrowser::UnZipIt(const QString &zipFile) { 1917bool Gutenbrowser::UnZipIt(const QString &zipFile) {
1922 odebug << zipFile << oendl; 1918 odebug << zipFile << oendl;
1923#ifndef Q_WS_QWS 1919#ifndef Q_WS_QWS
1924 if( QFile::exists( zipFile)) { // TODO findsome other way of dealingwithzip files. 1920 if( QFile::exists( zipFile)) { // TODO findsome other way of dealingwithzip files.
1925 bool isPgWhole=false; 1921 bool isPgWhole=false;
1926 QString thatFile; 1922 QString thatFile;
1927 if(zipFile.find("pgwhole",0,TRUE)) { 1923 if(zipFile.find("pgwhole",0,TRUE)) {
1928 isPgWhole=TRUE; 1924 isPgWhole=TRUE;
1929 thatFile= local_library +"PGWHOLE.TXT"; 1925 thatFile= local_library +"PGWHOLE.TXT";
1930 } 1926 }
1931 // else { 1927 // else {
1932 // thatFile=zipFile.left(4); 1928 // thatFile=zipFile.left(4);
1933 // } 1929 // }
1934 // odebug << (const char*)local_library.latin1() << oendl; 1930 // odebug << (const char*)local_library.latin1() << oendl;
1935 QString cmd; 1931 QString cmd;
1936#if defined(_WS_X11_) 1932#if defined(_WS_X11_)
1937 if( chdir((const char*)local_library.latin1())!=0) 1933 if( chdir((const char*)local_library.latin1())!=0)
1938 odebug << "chdir failed." << oendl; 1934 odebug << "chdir failed." << oendl;
1939 cmd = "gunzip -S .zip " + local_library+zipFile; 1935 cmd = "gunzip -S .zip " + local_library+zipFile;
1940 //cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; 1936 //cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library;
1941#endif 1937#endif
1942#ifdef Q_WS_QWS 1938#ifdef Q_WS_QWS
1943 if( chdir((const char*)local_library.latin1())!=0) 1939 if( chdir((const char*)local_library.latin1())!=0)
1944 odebug << "chdir failed." << oendl; 1940 odebug << "chdir failed." << oendl;
1945 cmd = "unzip " + local_library+zipFile; 1941 cmd = "unzip " + local_library+zipFile;
1946 // cmd = "/usr/bin/unzip -o " + local_library+zipFile +" -d /usr/share/doc/gutenbrowser" ;//+ local_library; 1942 // cmd = "/usr/bin/unzip -o " + local_library+zipFile +" -d /usr/share/doc/gutenbrowser" ;//+ local_library;
1947#endif 1943#endif
1948 int exit=QMessageBox::information(this, "Ok to unzip?", 1944 int exit=QMessageBox::information(this, "Ok to unzip?",
1949 "Ok to unnzip\n"+ zipFile+" ?", 1945 "Ok to unnzip\n"+ zipFile+" ?",
1950 QMessageBox::Yes, QMessageBox::No); 1946 QMessageBox::Yes, QMessageBox::No);
1951 if (exit==QMessageBox::Yes) { 1947 if (exit==QMessageBox::Yes) {
1952#if defined(_WS_X11_)// 1948#if defined(_WS_X11_)//
1953 odebug << "Issuing the command "+cmd << oendl; 1949 odebug << "Issuing the command "+cmd << oendl;
1954 system( cmd); 1950 system( cmd);
1955 if( QFile::exists(thatFile)) 1951 if( QFile::exists(thatFile))
1956 remove (thatFile); 1952 remove (thatFile);
1957 if(isPgWhole) { 1953 if(isPgWhole) {
1958 if( rename("pgwhole","PGWHOLE.TXT") !=0) 1954 if( rename("pgwhole","PGWHOLE.TXT") !=0)
1959 odebug << "rename failed" << oendl; 1955 odebug << "rename failed" << oendl;
1960 } else { 1956 } else {
1961 if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) 1957 if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0)
1962 odebug << "rename failed" << oendl; 1958 odebug << "rename failed" << oendl;
1963 } 1959 }
1964#endif 1960#endif
1965#ifdef Q_WS_QWS 1961#ifdef Q_WS_QWS
1966 odebug << "Issuing the command "+cmd << oendl; 1962 odebug << "Issuing the command "+cmd << oendl;
1967 system( cmd); 1963 system( cmd);
1968 if( QFile::exists(thatFile)) 1964 if( QFile::exists(thatFile))
1969 remove(thatFile); 1965 remove(thatFile);
1970 if(isPgWhole) { 1966 if(isPgWhole) {
1971 if( rename("pgwhole","PGWHOLE.TXT") !=0) 1967 if( rename("pgwhole","PGWHOLE.TXT") !=0)
1972 odebug << "rename failed" << oendl; 1968 odebug << "rename failed" << oendl;
1973 } else { 1969 } else {
1974 if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) 1970 if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0)
1975 odebug << "rename failed" << oendl; 1971 odebug << "rename failed" << oendl;
1976 } 1972 }
1977#endif 1973#endif
1978 // remove( zipFile); 1974 // remove( zipFile);
1979 return true; 1975 return true;
1980 } 1976 }
1981 else if(exit==QMessageBox::No) { 1977 else if(exit==QMessageBox::No) {
1982 // odebug << "unzip" << oendl; 1978 // odebug << "unzip" << oendl;
1983 return false; 1979 return false;
1984 } 1980 }
1985 } 1981 }
1986 else 1982 else
1987 QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); 1983 QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) );
1988#endif 1984#endif
1989 return false; 1985 return false;
1990} 1986}