summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-07-08 08:37:19 (UTC)
committer llornkcor <llornkcor>2004-07-08 08:37:19 (UTC)
commita53291faf419c90bf22db7cd6d6f26dece2053c1 (patch) (unidiff)
treed0a5a10621b8705502cc87bde43e18de39042be6
parenta7b08ae7dbce8675981321828e61c949968d1afe (diff)
downloadopie-a53291faf419c90bf22db7cd6d6f26dece2053c1.zip
opie-a53291faf419c90bf22db7cd6d6f26dece2053c1.tar.gz
opie-a53291faf419c90bf22db7cd6d6f26dece2053c1.tar.bz2
rework view, fix bookmarking
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp3159
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.h1
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp17
3 files changed, 1596 insertions, 1581 deletions
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
index be920dd..d0af114 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
@@ -1,17 +1,17 @@
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
@@ -65,1924 +65,1931 @@
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 qDebug("init finished"); 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 qDebug("gutenindex "+gutenIndex ); 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 qDebug("attempting new library");
155 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); 155 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */);
156 loadCheck = false; 156 loadCheck = false;
157 chdir(local_library); 157 chdir(local_library);
158 if(!showMainList) { 158 if(!showMainList) {
159 Lview->setFocus(); 159 Lview->setFocus();
160 // if(firstTime) 160 // if(firstTime)
161 // Bookmark(); 161 // Bookmark();
162 for (int i=1;i< qApp->argc();i++) { 162 for (int i=1;i< qApp->argc();i++) {
163 qDebug("Suppose we open somethin"); 163 qDebug("Suppose we open somethin");
164 load(qApp->argv()[i]); 164 if(!load(qApp->argv()[i])) return;
165 } 165 }
166 } else { 166 } else {
167 fillWithTitles(); 167 fillWithTitles();
168 mainList->setFocus(); 168 mainList->setFocus();
169 // mainList->setCurrentItem(0); 169 // mainList->setCurrentItem(0);
170 170
171 } 171 }
172 writeConfig(); 172 writeConfig();
173 QTimer::singleShot( 250, this, SLOT(hideView()) );
173} //end init 174} //end init
174 175
175Gutenbrowser::~Gutenbrowser() { 176Gutenbrowser::~Gutenbrowser() {
176 // QPEApplication::grabKeyboard(); 177 // QPEApplication::grabKeyboard();
177 // QPEApplication::ungrabKeyboard(); 178 // QPEApplication::ungrabKeyboard();
178 odebug << "Exit" << oendl; 179 odebug << "Exit" << oendl;
179} 180}
180 181
181 /* 182 /*
182 Google.com search */ 183 Google.com search */
183void Gutenbrowser::InfoBarClick() { 184void Gutenbrowser::InfoBarClick() {
184 QString text; 185 QString text;
185 if( Lview->hasSelectedText()) { 186 if( Lview->hasSelectedText()) {
186 Lview->copy(); 187 Lview->copy();
187 QClipboard *cb = QApplication::clipboard(); 188 QClipboard *cb = QApplication::clipboard();
188 text = cb->text(); 189 text = cb->text();
189 } else { 190 } else {
190 // text=title; 191 // text=title;
191 text=this->caption(); 192 text=this->caption();
192 } 193 }
193 searchGoogle(text); 194 searchGoogle(text);
194} 195}
195 196
196 /* 197 /*
197 download http with wget or preferred browser */ 198 download http with wget or preferred browser */
198void Gutenbrowser::goGetit( const QString &url, bool showMsg) { 199void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
199 // int eexit=0; 200 // int eexit=0;
200 QString cmd; 201 QString cmd;
201 // config.read(); 202 // config.read();
202 qApp->processEvents(); 203 qApp->processEvents();
203 QString filename = QPEApplication::qpeDir(); 204 QString filename = QPEApplication::qpeDir();
204 if(filename.right(1)!="/") 205 if(filename.right(1)!="/")
205 filename+="/etc/gutenbrowser/"; 206 filename+="/etc/gutenbrowser/";
206 else 207 else
207 filename+="etc/gutenbrowser/"; 208 filename+="etc/gutenbrowser/";
208 odebug << "filename "+filename << oendl; 209 odebug << "filename "+filename << oendl;
209 // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; 210 // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/";
210 211
211 filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); 212 filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1);
212 213
213 Config config("Gutenbrowser"); 214 Config config("Gutenbrowser");
214 config.setGroup( "Browser" ); 215 config.setGroup( "Browser" );
215 QString brow = config.readEntry("Preferred", "Opera"); 216 QString brow = config.readEntry("Preferred", "Opera");
216 odebug << "Preferred browser is "+brow << oendl; 217 odebug << "Preferred browser is "+brow << oendl;
217 if(!showMsg) { //if we just get the gutenindex.all 218 if(!showMsg) { //if we just get the gutenindex.all
218 cmd="wget -O " + filename +" " + url+" 2>&1" ; 219 cmd="wget -O " + filename +" " + url+" 2>&1" ;
219 chdir(local_library); 220 chdir(local_library);
220 odebug << "Issuing the system command: " << cmd << "" << oendl; 221 odebug << "Issuing the system command: " << cmd << "" << oendl;
221 222
222 Output *outDlg; 223 Output *outDlg;
223 outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); 224 outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE);
224 outDlg->showMaximized(); 225 outDlg->showMaximized();
225 outDlg->show(); 226 outDlg->show();
226 qApp->processEvents(); 227 qApp->processEvents();
227 FILE *fp; 228 FILE *fp;
228 char line[130]; 229 char line[130];
229 outDlg->OutputEdit->append( tr("Running wget") ); 230 outDlg->OutputEdit->append( tr("Running wget") );
230 sleep(1); 231 sleep(1);
231 fp = popen( (const char *) cmd, "r"); 232 fp = popen( (const char *) cmd, "r");
232 odebug << "Issuing the command\n"+cmd << oendl; 233 odebug << "Issuing the command\n"+cmd << oendl;
233 // system(cmd); 234 // system(cmd);
234 while ( fgets( line, sizeof line, fp)) { 235 while ( fgets( line, sizeof line, fp)) {
235 outDlg->OutputEdit->append(line); 236 outDlg->OutputEdit->append(line);
236// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 237// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
237 } 238 }
238 pclose(fp); 239 pclose(fp);
239 outDlg->close(); 240 outDlg->close();
240 if(outDlg) 241 if(outDlg)
241 delete outDlg; 242 delete outDlg;
242 } else { 243 } else {
243 if( brow == "Konq") { 244 if( brow == "Konq") {
244 cmd = "konqueror "+url+" &"; 245 cmd = "konqueror "+url+" &";
245 } 246 }
246 if( brow == "Opera") { //for desktop testing 247 if( brow == "Opera") { //for desktop testing
247 cmd = "opera "+url+" &"; 248 cmd = "opera "+url+" &";
248 } 249 }
249 // if( brow == "Opera") { // on Zaurus 250 // if( brow == "Opera") { // on Zaurus
250 // cmd = "operagui "+url+" &"; 251 // cmd = "operagui "+url+" &";
251 // } 252 // }
252 if( brow == "Mozilla") { 253 if( brow == "Mozilla") {
253 cmd = "mozilla "+url+" &"; 254 cmd = "mozilla "+url+" &";
254 } 255 }
255 if( brow == "Netscape") { 256 if( brow == "Netscape") {
256 cmd = "netscape "+url+" &"; 257 cmd = "netscape "+url+" &";
257 } 258 }
258 if(brow == "wget") { 259 if(brow == "wget") {
259 // cmd="wget -q "+url+" &"; 260 // cmd="wget -q "+url+" &";
260 QString tempHtml=local_library+"webster.html"; 261 QString tempHtml=local_library+"webster.html";
261 cmd="wget -O "+tempHtml+" -q "+url; 262 cmd="wget -O "+tempHtml+" -q "+url;
262 } 263 }
263 264
264 chdir(local_library); 265 chdir(local_library);
265 odebug << "Issuing the sys command: " << cmd << "" << oendl; 266 odebug << "Issuing the sys command: " << cmd << "" << oendl;
266 system(cmd); 267 system(cmd);
267 } 268 }
268} 269}
269 270
270void Gutenbrowser::toggleButtonIcons( bool useEm) { 271void Gutenbrowser::toggleButtonIcons( bool useEm) {
271 QString pixDir; 272 QString pixDir;
272 if(useEm) 273 if(useEm)
273 useEm=TRUE; 274 useEm=TRUE;
274 pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; 275 pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser";
275 odebug << "Docdir is "+QPEApplication::documentDir() << oendl; 276 odebug << "Docdir is "+QPEApplication::documentDir() << oendl;
276 277
277 if( useIcons && QDir( pixDir).exists() ) { 278 if( useIcons && QDir( pixDir).exists() ) {
278 LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline 279 LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline
279 OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook")); 280 OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook"));
280 ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline 281 ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline
281 BackButton->setPixmap( Resource::loadPixmap("back") );//in inline 282 BackButton->setPixmap( Resource::loadPixmap("back") );//in inline
282 SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline 283 SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline
283 lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder")); 284 lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder"));
284 setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") ); 285 setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") );
285 dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") ); 286 dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") );
286 InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google")); 287 InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google"));
287 } 288 }
288} 289}
289 290
290 291
291bool Gutenbrowser::queryExit() 292bool Gutenbrowser::queryExit()
292{ 293{
293 int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?", 294 int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?",
294 QMessageBox::Ok, QMessageBox::Cancel); 295 QMessageBox::Ok, QMessageBox::Cancel);
295 if (exit==1) { 296 if (exit==1) {
296 writeConfig(); 297 writeConfig();
297 qApp->quit(); 298 qApp->quit();
298 } else { 299 } else {
299 }; 300 };
300 return (exit==1); 301 return (exit==1);
301} 302}
302 303
303 // SLOT IMPLEMENTATION 304 // SLOT IMPLEMENTATION
304 305
305void Gutenbrowser::slotFilePrint() { 306void Gutenbrowser::slotFilePrint() {
306} 307}
307 308
308void Gutenbrowser::ByeBye() { 309void Gutenbrowser::ByeBye() {
309 if (b_queryExit) 310 if (b_queryExit)
310 queryExit(); 311 queryExit();
311 else { 312 else {
312 // writeConfig(); 313 // writeConfig();
313 qApp->quit(); 314 qApp->quit();
314 } 315 }
315} 316}
316 317
317void Gutenbrowser::HelpBtn() { 318void Gutenbrowser::HelpBtn() {
318 HelpMe* HelpDlg; 319 HelpMe* HelpDlg;
319 HelpDlg = new HelpMe( this, "Help Dialog"); 320 HelpDlg = new HelpMe( this, "Help Dialog");
320 HelpDlg->showMaximized(); 321 HelpDlg->showMaximized();
321} 322}
322 323
323void Gutenbrowser::DownloadIndex() { 324void Gutenbrowser::DownloadIndex() {
324#ifndef Q_WS_QWS 325#ifndef Q_WS_QWS
325 { 326 {
326 switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")), 327 switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")),
327 (tr("Do you want to download the newest\n" 328 (tr("Do you want to download the newest\n"
328 "Project Gutenberg Library Index?\n" 329 "Project Gutenberg Library Index?\n"
329 "or select an ftp site?\n")), 330 "or select an ftp site?\n")),
330 (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) ) 331 (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) )
331 { 332 {
332 case 0: // index clicked, 333 case 0: // index clicked,
333 downloadLibIndex(); 334 downloadLibIndex();
334 break; 335 break;
335 336
336 case 1: // ftp selected 337 case 1: // ftp selected
337 downloadFtpList(); 338 downloadFtpList();
338 break; 339 break;
339 340
340 case 2: // Cancel 341 case 2: // Cancel
341 break; 342 break;
342 }; 343 };
343 } 344 }
344#endif 345#endif
345} // end DownloadIndex 346} // end DownloadIndex
346 347
347 348
348void Gutenbrowser::downloadFtpList() { 349void Gutenbrowser::downloadFtpList() {
349 // QString cmd="wget http://www.promo.net/pg/list.html"); 350 // QString cmd="wget http://www.promo.net/pg/list.html");
350 //system(cmd); 351 //system(cmd);
351 qApp->processEvents(); 352 qApp->processEvents();
352 optionsDialog* optDlg; 353 optionsDialog* optDlg;
353 optDlg = new optionsDialog( this,"Options_Dlg", true); 354 optDlg = new optionsDialog( this,"Options_Dlg", true);
354 optDlg->getSite(); 355 optDlg->getSite();
355 if(optDlg) 356 if(optDlg)
356 delete optDlg; 357 delete optDlg;
357} 358}
358 359
359 360
360void Gutenbrowser::downloadLibIndex() { 361void Gutenbrowser::downloadLibIndex() {
361 // QString dwmloader = local_library + "pgwhole.zip"; 362 // QString dwmloader = local_library + "pgwhole.zip";
362 // QString cmd = "lynx -source http://www.gutenberg.net/pgwhole.zip | cat >> " + dwmloader; 363 // QString cmd = "lynx -source http://www.gutenberg.net/pgwhole.zip | cat >> " + dwmloader;
363 // system(cmd); 364 // system(cmd);
364 365
365 // QString outputFile= local_library+ "GUTINDEX.ALL"; 366 // QString outputFile= local_library+ "GUTINDEX.ALL";
366 // config.setGroup( "FTPsite" ); // ftp server config 367 // config.setGroup( "FTPsite" ); // ftp server config
367 // ftp_host=config.readEntry("SiteName", ""); 368 // ftp_host=config.readEntry("SiteName", "");
368 // ftp_base_dir= config.readEntry("base", ""); 369 // ftp_base_dir= config.readEntry("base", "");
369 // QString networkUrl= "ftp://"+ftp_host+ftp_base_dir+"/GUTINDEX.ALL"; 370 // QString networkUrl= "ftp://"+ftp_host+ftp_base_dir+"/GUTINDEX.ALL";
370 QDir dir( local_library); 371 QDir dir( local_library);
371 dir.cd("", TRUE); 372 dir.cd("", TRUE);
372 goGetit( "http://sailor.gutenberg.org/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3 373 goGetit( "http://sailor.gutenberg.org/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3
373 // goGetit( "http://www.gutenberg.net/pgwhole.zip", true); // until ghttp works on binaries -qt3 374 // goGetit( "http://www.gutenberg.net/pgwhole.zip", true); // until ghttp works on binaries -qt3
374 // NetworkDialog *NetworkDlg; 375 // NetworkDialog *NetworkDlg;
375 // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, outputFile ); 376 // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, outputFile );
376 // if( NetworkDlg->exec() != 0 ) 377 // if( NetworkDlg->exec() != 0 )
377 // { // use new, improved, *INSTANT* network-dialog-file-getterer 378 // { // use new, improved, *INSTANT* network-dialog-file-getterer
378 //// QMessageBox::message("Note",""); 379 //// QMessageBox::message("Note","");
379 // } 380 // }
380 // if(NetworkDlg) 381 // if(NetworkDlg)
381 // delete NetworkDlg; 382 // delete NetworkDlg;
382} 383}
383 384
384 385
385void Gutenbrowser::PrintBtn() { 386void Gutenbrowser::PrintBtn() {
386} 387}
387 388
388void Gutenbrowser::SearchBtn() { 389void Gutenbrowser::SearchBtn() {
389 if( loadCheck) { 390 if( loadCheck) {
390 odebug << "loadCheck: we have a loaded doc" << oendl; 391 odebug << "loadCheck: we have a loaded doc" << oendl;
391 Search(); 392 Search();
392 } 393 }
393 // else 394 // else
394 // QMessageBox::message("Note","Sorry, can't search. No etext is loaded"); 395 // QMessageBox::message("Note","Sorry, can't search. No etext is loaded");
395} 396}
396 397
397 398
398void Gutenbrowser::ForwardBtn() { 399void Gutenbrowser::ForwardBtn() {
399 400
400 if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) { 401 if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) {
401 402
402 QString s; 403 QString s;
403 QString insertString; 404 QString insertString;
404 int pageSize= Lview->PageSize(); 405 int pageSize= Lview->PageSize();
405 Lview->clear(); 406 Lview->clear();
406 407
407 for(int fd=0; fd < pageSize - 1;fd++) { 408 for(int fd=0; fd < pageSize - 1;fd++) {
408 f.readLine(s, 256); 409 f.readLine(s, 256);
409 if(useWrap) 410 if(useWrap)
410 s.replace(QRegExp("\n"),""); 411 s.replace(QRegExp("\n"),"");
411 insertString+=s; 412 insertString+=s;
412 Lview->insertLine( s, -1); 413 Lview->insertLine( s, -1);
413 odebug << s << oendl; 414 // odebug << s << oendl;
414 currentLine++; 415 currentLine++;
415 } 416 }
416 // Lview->insertAt( insertString,0,0, FALSE); 417 // Lview->insertAt( insertString,0,0, FALSE);
417 currentFilePos = f.at(); 418 currentFilePos = f.at();
418 // if( i_pageNum != pages) { 419 // if( i_pageNum != pages) {
419 // Lview->MultiLine_Ex::pageDown( FALSE); 420 // Lview->MultiLine_Ex::pageDown( FALSE);
420 i_pageNum++; 421 i_pageNum++;
421 pageStopArray.resize(i_pageNum + 1); 422 pageStopArray.resize(i_pageNum + 1);
422 // int length = Lview->length(); 423 // int length = Lview->length();
423 424
424 pageStopArray[i_pageNum ] = currentFilePos; 425 pageStopArray[i_pageNum ] = currentFilePos;
425 odebug << currentFilePos << " current page is number " << i_pageNum 426 odebug << currentFilePos << " current page is number " << i_pageNum
426 << ", pagesize " << pageSize << ", length " << Lview->length() 427 << ", pagesize " << pageSize << ", length " << Lview->length()
427 << ", current " << pageStopArray[i_pageNum] << oendl; 428 << ", current " << pageStopArray[i_pageNum] << oendl;
428 setStatus(); 429 setStatus();
429// Lview->setCursorPosition( 0, 0, FALSE); 430// Lview->setCursorPosition( 0, 0, FALSE);
430 // } 431 // }
431 432
432 } else { 433 } else {
433 odebug << "bal" << oendl; 434 odebug << "bal" << oendl;
434 // if( i_pageNum != pages) { 435 // if( i_pageNum != pages) {
435 436
436 // // int newTop = Lview->Top(); 437 // // int newTop = Lview->Top();
437 // // if(Lview->lastRow() > i) 438 // // if(Lview->lastRow() > i)
438 // Lview->ScrollUp(1); 439 // Lview->ScrollUp(1);
439 // // i_pageNum++; 440 // // i_pageNum++;
440 // setStatus(); 441 // setStatus();
441 // Lview->setCursorPosition( Lview->Top(), 0, FALSE); 442 // Lview->setCursorPosition( Lview->Top(), 0, FALSE);
442 443
443 // } 444 // }
444 445
445 } 446 }
446 Lview->setFocus(); 447 Lview->setFocus();
447 448
448 odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl; 449 odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl;
449} 450}
450 451
451 452
452void Gutenbrowser::BackBtn() { 453void Gutenbrowser::BackBtn() {
453 if( i_pageNum > 0) { 454 if( i_pageNum > 0) {
454 int pageSize= Lview->PageSize(); 455 int pageSize= Lview->PageSize();
455 // int length=Lview->length(); 456 // int length=Lview->length();
456 457
457 i_pageNum--; 458 i_pageNum--;
458 currentFilePos = f.at(); 459 currentFilePos = f.at();
459 460
460 odebug << currentFilePos << " move back to " << pageStopArray[i_pageNum - 1 ] 461 odebug << currentFilePos << " move back to " << pageStopArray[i_pageNum - 1 ]
461 << ", current page number " << i_pageNum 462 << ", current page number " << i_pageNum
462 << ", " << pageSize << ", length " << Lview->length() << oendl; 463 << ", " << pageSize << ", length " << Lview->length() << oendl;
463 464
464 if( i_pageNum < 2) { 465 if( i_pageNum < 2) {
465 f.at( 0); 466 f.at( 0);
466 } else { 467 } else {
467 if(!f.at( pageStopArray[i_pageNum - 1] )) 468 if(!f.at( pageStopArray[i_pageNum - 1] ))
468 odebug << "File positioned backward did not work" << oendl; 469 odebug << "File positioned backward did not work" << oendl;
469 } 470 }
470 QString s; 471 QString s;
471 // int sizeLine=0; 472 // int sizeLine=0;
472 Lview->clear(); 473 Lview->clear();
473 // QString insertString; 474 // QString insertString;
474 475
475 for(int fd = 0; fd < pageSize ;fd++) { 476 for(int fd = 0; fd < pageSize ;fd++) {
476 // Lview->removeLine( Lview->PageSize() ); 477 // Lview->removeLine( Lview->PageSize() );
477 f.readLine(s, 256); 478 f.readLine(s, 256);
478 if(useWrap) 479 if(useWrap)
479 s.replace(QRegExp("\n"),""); 480 s.replace(QRegExp("\n"),"");
480 currentLine++; 481 currentLine++;
481 // insertString+=s; 482 // insertString+=s;
482 Lview->insertLine( s, -1); 483 Lview->insertLine( s, -1);
483 } 484 }
484 485
485 // Lview->insertAt( insertString,0,0, FALSE); 486 // Lview->insertAt( insertString,0,0, FALSE);
486 487
487 if( !BackButton->autoRepeat() && !BackButton->isDown()) { 488 if( !BackButton->autoRepeat() && !BackButton->isDown()) {
488 QString topR; 489 QString topR;
489 QString lastR; 490 QString lastR;
490 QString pageR; 491 QString pageR;
491 // int sizer = Lview->lastRow() - Lview->topRow(); 492 // int sizer = Lview->lastRow() - Lview->topRow();
492 // int i_topRow = Lview->topRow(); 493 // int i_topRow = Lview->topRow();
493 if( i_pageNum < 1) 494 if( i_pageNum < 1)
494 i_pageNum = 1; 495 i_pageNum = 1;
495 setCaption(QString::number(i_pageNum)); 496 setCaption(QString::number(i_pageNum));
496 } else { 497 } else {
497 // int newTop = Lview->Top(); 498 // int newTop = Lview->Top();
498 // if(Lview->lastRow() > i) 499 // if(Lview->lastRow() > i)
499 Lview->MultiLine_Ex::pageUp( FALSE); 500 Lview->MultiLine_Ex::pageUp( FALSE);
500 // Lview->ScrollDown(1); 501 // Lview->ScrollDown(1);
501 // i_pageNum--; 502 // i_pageNum--;
502 if( i_pageNum < 1) 503 if( i_pageNum < 1)
503 i_pageNum = 1; 504 i_pageNum = 1;
504 setStatus(); 505 setStatus();
505// Lview->setCursorPosition( Lview->Top(), 0, FALSE); 506// Lview->setCursorPosition( Lview->Top(), 0, FALSE);
506 507
507 } 508 }
508 } 509 }
509 Lview->setFocus(); 510 Lview->setFocus();
510} 511}
511 512
512void Gutenbrowser::doBeginBtn() { 513void Gutenbrowser::doBeginBtn() {
513 if(loadCheck) { 514 if(loadCheck) {
514 qApp->processEvents(); 515 qApp->processEvents();
515 BeginBtn(); 516 BeginBtn();
516 } 517 }
517} 518}
518 519
519 // moves text to the very top = 0 520 // moves text to the very top = 0
520void Gutenbrowser::TopBtn() { 521void Gutenbrowser::TopBtn() {
521 522
522 if(loadCheck) { 523 if(loadCheck) {
523 if( i_pageNum != 0) { 524 if( i_pageNum != 0) {
524 odebug << "top" << oendl; 525 odebug << "top" << oendl;
525 qApp->processEvents(); 526 qApp->processEvents();
526 currentLine = 0; 527 currentLine = 0;
527 i_pageNum = 1; 528 i_pageNum = 1;
528 int pageSize = Lview->PageSize() ; 529 int pageSize = Lview->PageSize() ;
529 Lview->clear(); 530 Lview->clear();
530 QString s; 531 QString s;
531 f.at(0); 532 f.at(0);
532 for(int fd=0; fd < pageSize ;fd++) { 533 for(int fd=0; fd < pageSize ;fd++) {
533 f.readLine(s, 256); 534 f.readLine(s, 256);
534 if(useWrap) 535 if(useWrap)
535 s.replace(QRegExp("\n"),""); 536 s.replace(QRegExp("\n"),"");
536 Lview->insertLine(s ,-1); 537 Lview->insertLine(s ,-1);
537 currentLine++; 538 currentLine++;
538 } 539 }
539// Lview->setCursorPosition( 0,0, FALSE); 540// Lview->setCursorPosition( 0,0, FALSE);
540 i_pageNum=1; 541 i_pageNum=1;
541 setStatus(); 542 setStatus();
542 } 543 }
543 Lview->setFocus(); 544 Lview->setFocus();
544 } 545 }
545} 546}
546 547
547 //moves text to the start of the EText 548 //moves text to the start of the EText
548void Gutenbrowser::BeginBtn() { 549void Gutenbrowser::BeginBtn() {
549 i_pageNum = 1; 550 i_pageNum = 1;
550 currentLine = 0; 551 currentLine = 0;
551 QString s_pattern="*END*THE SMALL PRINT"; 552 QString s_pattern="*END*THE SMALL PRINT";
552 QString sPattern2 = "*END THE SMALL PRINT"; 553 QString sPattern2 = "*END THE SMALL PRINT";
553 554
554 int pageSize = Lview->PageSize(); 555 int pageSize = Lview->PageSize();
555 Lview->clear(); 556 Lview->clear();
556 557
557 // int lines = Lview->numLines(); 558 // int lines = Lview->numLines();
558 int pos = 0;//, i = 0; 559 int pos = 0;//, i = 0;
559 int i_topRow = Lview->topRow(); 560 int i_topRow = Lview->topRow();
560 561
561 QString LeftText;// = Lview->text(); 562 QString LeftText;// = Lview->text();
562 563
563 int linesPerPage = Lview->lastRow() - Lview->topRow(); 564 int linesPerPage = Lview->lastRow() - Lview->topRow();
564 // int pages = (( linesPerPage / Lview->editSize() ) ) +1; 565 // int pages = (( linesPerPage / Lview->editSize() ) ) +1;
565 // int pageN = 0; 566 // int pageN = 0;
566 i_pageNum = 1; 567 i_pageNum = 1;
567 int lastPage=1; 568 int lastPage=1;
568 int lineNo=0; 569 int lineNo=0;
569 QString s; 570 QString s;
570 f.at( 0); 571 f.at( 0);
571 572
572 while ( !f.atEnd() ) { 573 while ( !f.atEnd() ) {
573 f.readLine(s, 256); 574 f.readLine(s, 256);
574 lineNo++; 575 lineNo++;
575 LeftText = s; 576 LeftText = s;
576 currentFilePos = f.at(); 577 currentFilePos = f.at();
577 578
578 i_pageNum = lineNo/pageSize; 579 i_pageNum = lineNo/pageSize;
579 if(lastPage < i_pageNum) { 580 if(lastPage < i_pageNum) {
580 pageStopArray.resize(i_pageNum + 1); 581 pageStopArray.resize(i_pageNum + 1);
581 pageStopArray[i_pageNum ] = currentFilePos; 582 pageStopArray[i_pageNum ] = currentFilePos;
582 odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; 583 // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl;
583 } 584 }
584 // lastPage = i_pageNum; 585 // lastPage = i_pageNum;
585 if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) { 586 if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) {
586 odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; 587 odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl;
587 break; 588 break;
588 } 589 }
589 } 590 }
590 if(f.atEnd()) //in case we didnt find anything, we need to show something 591 if(f.atEnd()) //in case we didnt find anything, we need to show something
591 f.at(0); 592 f.at(0);
592 Lview->clear(); 593 Lview->clear();
593 for(int fd=0; fd < pageSize - 1;fd++) { 594 for(int fd=0; fd < pageSize - 1;fd++) {
594 f.readLine(s, 256); 595 f.readLine(s, 256);
595 if(useWrap) 596 if(useWrap)
596 s.replace(QRegExp("\n"),""); 597 s.replace(QRegExp("\n"),"");
597 Lview->insertLine( s, -1); 598 Lview->insertLine( s, -1);
598 currentLine++; 599 currentLine++;
599 } 600 }
600 601
601 i_pageNum = lineNo/pageSize; 602 i_pageNum = lineNo/pageSize;
602 pageStopArray.resize(i_pageNum + 1); 603 pageStopArray.resize(i_pageNum + 1);
603 // int length = Lview->length(); 604 // int length = Lview->length();
604 605
605 qApp->processEvents(); 606 qApp->processEvents();
606 607
607 if( pos > i_topRow ) { 608 if( pos > i_topRow ) {
608// Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE); 609// Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE);
609 } else { 610 } else {
610// Lview->setCursorPosition( pos+2 , 0, FALSE ); 611// Lview->setCursorPosition( pos+2 , 0, FALSE );
611 } 612 }
612 613
613 Lview->deselect(); 614 Lview->deselect();
614 // AdjustStatus(); 615 // AdjustStatus();
615 Lview->setFocus(); 616 Lview->setFocus();
616} 617}
617 618
618 /* 619 /*
619 sets the current page and place as a bookmark*/ 620 sets the current page and place as a bookmark*/
620void Gutenbrowser::setBookmark() { 621void Gutenbrowser::setBookmark() {
621 int eexit=QMessageBox::information(this, "Note", 622 int eexit=QMessageBox::information(this, "Note",
622 "Do you really want to \nset this bookmark?." 623 "Do you really want to \nset this bookmark?."
623 ,QMessageBox::Yes, QMessageBox::No); 624 ,QMessageBox::Yes, QMessageBox::No);
624 if (eexit== 3) { 625 if (eexit== 3) {
625 626
626 currentFilePos = f.at(); 627 currentFilePos = f.at();
627 628
628 Config cfg("Gutenbrowser"); 629 Config cfg("Gutenbrowser");
629 cfg.setGroup("General"); 630 cfg.setGroup("General");
630 file_name=cfg.readEntry("Current",""); 631 file_name = cfg.readEntry("Current","");
631 qApp->processEvents(); 632 qApp->processEvents();
632 odebug << "Settingbook mark "+file_name << oendl; 633 odebug << "Setting book mark "+file_name << oendl;
633 634
634 cfg.setGroup("Titles"); 635 cfg.setGroup("Titles");
635 title=cfg.readEntry(file_name,""); 636 title = cfg.readEntry(file_name,"");
636 odebug << "title is "+ title << oendl; 637 odebug << "title is "+ title << oendl;
637 638
638 cfg.setGroup( "Bookmarks" ); 639 cfg.setGroup( "Bookmarks" );
639 640
640 cfg.writeEntry("File Name",file_name); 641 cfg.writeEntry("File Name",file_name);
641 cfg.writeEntry("Page Number",QString::number(i_pageNum) ); 642 cfg.writeEntry("Page Number",QString::number(i_pageNum) );
642 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); 643 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1]));
643 cfg.writeEntry("Title", title); 644 cfg.writeEntry("Title", title);
644 645
645 int row = Lview->topRow();// Lview->Top(); 646 int row = Lview->topRow();// Lview->Top();
646 cfg.writeEntry("LineNumber",QString::number(row) ); 647 cfg.writeEntry("LineNumber",QString::number(row) );
647 648
648 cfg.setGroup(title); 649 cfg.setGroup(title);
649 cfg.writeEntry("File Name",file_name); 650 cfg.writeEntry("File Name",file_name);
650 cfg.writeEntry( "LineNumber", QString::number( row)); 651 cfg.writeEntry( "LineNumber", QString::number( row));
651 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); 652 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1]));
652 cfg.writeEntry( "Page Number", QString::number( i_pageNum) ); 653 cfg.writeEntry( "Page Number", QString::number( i_pageNum) );
653 bookmarksMenu->insertItem( title); 654 cfg.write();
654 } 655 bookmarksMenu->insertItem( title);
656 }
655} //end setBookmark 657} //end setBookmark
656 658
657 659
658 /* goes to last set bookmark*/ 660 /* goes to last set bookmark*/
659void Gutenbrowser::Bookmark( int itemId) { 661void Gutenbrowser::Bookmark( int itemId) {
660 662
661 // qApp->processEvents(); 663 // qApp->processEvents();
662 Config config("Gutenbrowser"); 664 Config config("Gutenbrowser");
663 config.setGroup( "Bookmarks" ); 665 config.setGroup( "Bookmarks" );
664 666
665 odebug << "<<<<<< " << Lview->PageSize() << ", " << Lview->lastRow() - Lview->topRow() << "" << oendl; 667 odebug << "<<<<<< " << Lview->PageSize() << ", " << Lview->lastRow() - Lview->topRow() << "" << oendl;
666 668
667 QString itemString; 669 QString itemString;
668 670
669 odebug << "menu item " << itemId << "" << oendl; 671 odebug << "menu item " << itemId << "" << oendl;
670 QString tempTitle; 672 QString tempTitle;
671 QString s_Bmrkrow; 673 QString s_Bmrkrow;
672 QString s_pageNum; 674 QString s_pageNum;
673 int Bmrkrow=0; 675 int Bmrkrow=0;
674 int bookmarkPosition = 0; 676 int bookmarkPosition = 0;
675 677
676 // qApp->processEvents(); 678 // qApp->processEvents();
677 config.setGroup( "Bookmarks" ); 679 config.setGroup( "Bookmarks" );
678 title = config.readEntry("Title", ""); 680 title = config.readEntry("Title", "");
679 file_name = config.readEntry("File Name", ""); 681 file_name = config.readEntry("File Name", "");
680 i_pageNum = config.readNumEntry("Page Number", 0); 682 i_pageNum = config.readNumEntry("Page Number", 0);
681 bookmarkPosition = config.readNumEntry( "PagePosition",0); 683 bookmarkPosition = config.readNumEntry( "PagePosition",0);
682 Bmrkrow = config.readNumEntry("LineNumber",0); 684 Bmrkrow = config.readNumEntry("LineNumber",0);
683 if( !file_name.contains("/")) { 685 if( !file_name.contains("/")) {
684 file_name = local_library + file_name; 686 file_name = local_library + file_name;
685 } 687 }
686 688
687 // getTitle(file_name); 689 // getTitle(file_name);
688 // qApp->processEvents(); 690 // qApp->processEvents();
689 // Lview->setFocus(); 691 // Lview->setFocus();
690 this->setFocus(); 692 this->setFocus();
691 693
692 Lview->clear(); 694 Lview->clear();
693 695
694 load(file_name); 696 if(!load(file_name)) return;
695 697
696 int pageSize= Lview->PageSize(); 698 int pageSize = Lview->PageSize();
697 f.at(0); 699 f.at(0);
698 // Lview->clear(); 700 // Lview->clear();
699 QString s; 701 QString s;
700 int lineNo=0; 702 int lineNo=0;
701 int lastPage=1; 703 int lastPage=1;
702 while ( !f.atEnd() ) { 704 while ( !f.atEnd() ) {
703 f.readLine(s, 256); 705 f.readLine(s, 256);
704 lineNo++; 706 lineNo++;
705 currentFilePos = f.at(); 707 currentFilePos = f.at();
706 708
707 i_pageNum = lineNo/pageSize; 709 i_pageNum = lineNo/pageSize;
708 if(lastPage < i_pageNum) { 710 if(lastPage < i_pageNum) {
709 pageStopArray.resize(i_pageNum + 1); 711 pageStopArray.resize(i_pageNum + 1);
710 pageStopArray[i_pageNum ] = currentFilePos; 712 pageStopArray[i_pageNum ] = currentFilePos;
711 odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; 713 // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl;
712 } 714 }
713 if(currentFilePos == bookmarkPosition) 715 if(currentFilePos == bookmarkPosition)
714 break; 716 break;
715 } 717 }
716 if(f.atEnd()) 718 if(f.atEnd())
717 f.at(0); 719 f.at(0);
718 else 720 else
719 f.at( bookmarkPosition); 721 f.at( bookmarkPosition);
720 722
721 for(int fd=0; fd < pageSize - 1;fd++) { 723 for(int fd=0; fd < pageSize - 1;fd++) {
722 f.readLine(s, 256); 724 f.readLine(s, 256);
723 lineNo++; 725 lineNo++;
724 if(useWrap) 726 if(useWrap)
725 s.replace(QRegExp("\n"),""); 727 s.replace(QRegExp("\n"),"");
726 Lview->insertLine( s, -1); 728 Lview->insertLine( s, -1);
727 currentLine++; 729 currentLine++;
728 } 730 }
729 731
730 i_pageNum = lineNo/pageSize; 732 i_pageNum = lineNo/pageSize;
731 pageStopArray.resize(i_pageNum + 1); 733 pageStopArray.resize(i_pageNum + 1);
732 734
733 if(showMainList) { 735 if(showMainList) {
734 showMainList=FALSE; 736 showMainList=FALSE;
735 mainList->hide(); 737 mainList->hide();
736 Lview->show(); 738 Lview->show();
737 // qApp->processEvents(); 739 // qApp->processEvents();
738 } 740 }
739 741
740 odebug << "bookmark loaded" << oendl; 742 odebug << "bookmark loaded" << oendl;
741 setCaption(title); 743 setCaption(title);
742} 744}
743 745
744 746
745bool Gutenbrowser::load( const char *fileName) { 747bool Gutenbrowser::load( const char *fileName) {
746 748
747 // QCopEnvelope ( "QPE/System", "busy()" ); 749 // QCopEnvelope ( "QPE/System", "busy()" );
748 odebug << "Title is already set as "+title << oendl; 750 odebug << "Title is already set as "+title << oendl;
749 odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl; 751 odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl;
750 if( Lview->PageSize() < 4) { 752 // pointSize = Lview->fontInfo().pointSize();
751 753 // odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl;
752 Lview->setMaximumHeight( sizeHint().height() ); 754 if( Lview->PageSize() < 4) {
753 Lview->setMinimumHeight( sizeHint().height() ); 755
754 pointSize = Lview->fontInfo().pointSize(); 756 //Lview->setMaximumHeight( sizeHint().height() );
755 odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl; 757 Lview->setMinimumHeight( sizeHint().height() );
756 if(pointSize < 10) 758 pointSize = Lview->fontInfo().pointSize();
757 Lview->setFixedVisibleLines(19); 759 odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl;
758 else 760 if(pointSize < 15)
759 Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2); 761 Lview->setFixedVisibleLines(19);
760 } 762 else
761 763 Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2);
762 Config cfg("Gutenbrowser"); 764 }
763 cfg.setGroup("General"); 765
764 cfg.writeEntry("Current",fileName); 766 Config cfg("Gutenbrowser");
765 currentLine=0; 767 cfg.setGroup("General");
766 768 cfg.writeEntry("Current",fileName);
767 file_name=fileName; 769 cfg.write();
768 QString o_file = fileName; 770 currentLine=0;
769 771
770 // if (i_pageNum < 1) { 772 file_name=fileName;
771 i_pageNum = 1; 773 QString o_file = fileName;
772 // } 774
773 odebug << "ready to open "+o_file << oendl; 775 // if (i_pageNum < 1) {
774 776 i_pageNum = 1;
775 if(f.isOpen()) f.close(); 777 // }
776 f.setName( o_file); 778 odebug << "ready to open "+o_file << oendl;
777 779
778 if ( !f.open( IO_ReadOnly)) { 780 if(f.isOpen()) f.close();
779 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) ); 781 f.setName( o_file);
780 return false; 782
781 } 783 if ( !f.open( IO_ReadOnly)) {
782 currentFilePos = 0; 784 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) );
783 pageStopArray.resize(3); 785 return false;
784 pageStopArray[0] = currentFilePos; 786 }
785 787 currentFilePos = 0;
786 fileHandle = f.handle(); 788 pageStopArray.resize(3);
787 QString insertString; 789 pageStopArray[0] = currentFilePos;
788 QTextStream t(&f); 790
789 QString s; 791 fileHandle = f.handle();
790 for(int fd=0; fd < Lview->PageSize() ;fd++) { 792 QString insertString;
791 s=t.readLine(); 793 QTextStream t(&f);
792 // insertString+=s; 794 QString s;
793 if(useWrap) 795 for(int fd=0; fd < Lview->PageSize() ;fd++) {
794 s.replace(QRegExp("\n"),""); 796 s=t.readLine();
795 // s.replace(QRegExp("\r"),""); 797 // insertString+=s;
796 Lview->insertLine( s,-1); 798 if(useWrap)
797 currentLine++; 799 s.replace(QRegExp("\n"),"");
798 } 800 // s.replace(QRegExp("\r"),"");
799 801 Lview->insertLine( s,-1);
800 // int length = Lview->length(); 802 currentLine++;
801 currentFilePos = f.at(); 803 }
802 804
803 pageStopArray[1] = currentFilePos; 805 // int length = Lview->length();
804 806 currentFilePos = f.at();
805 odebug << "<<<<<<<<<<<" << currentFilePos << " current page is number " << i_pageNum 807
806 << ", length " << Lview->length() << ", current " << pageStopArray[i_pageNum] 808 pageStopArray[1] = currentFilePos;
807 << ", pageSize " << Lview->PageSize() << oendl; 809
808 810 odebug << "<<<<<<<<<<<" << currentFilePos << " current page is number " << i_pageNum
809 Lview->setMaxLines(Lview->PageSize()*2); 811 << ", length " << Lview->length() << ", current " << pageStopArray[i_pageNum]
810 odebug << "Gulped " << currentLine << "" << oendl; 812 << ", pageSize " << Lview->PageSize() << oendl;
811 setCaption(title); 813
812 Lview->setAutoUpdate( TRUE); 814 Lview->setMaxLines(Lview->PageSize()*2);
815// odebug << "Gulped " << currentLine << "" << oendl;
816 setCaption(title);
817 Lview->setAutoUpdate( TRUE);
813 818
814// Lview->setCursorPosition(0,0,FALSE); 819// Lview->setCursorPosition(0,0,FALSE);
815 820
816 // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; 821 // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1;
817 //odebug << "number of pages " << pages << "" << oendl; 822 //odebug << "number of pages " << pages << "" << oendl;
818 823
819 loadCheck = true; 824 loadCheck = true;
820 enableButtons(true); 825 enableButtons(true);
821 if( donateMenu->count() == 3) { 826 if( donateMenu->count() == 3) {
822 donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() )); 827 donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() ));
823 } 828 }
824 Lview->setFocus(); 829 Lview->setFocus();
825 830
826 // QCopEnvelope("QPE/System", "notBusy()" ); 831 // QCopEnvelope("QPE/System", "notBusy()" );
827 return true; 832 return true;
828} // end load 833} // end load
829 834
830void Gutenbrowser::Search() { 835void Gutenbrowser::Search() {
831 836
832 // if( searchDlg->isHidden()) 837 // if( searchDlg->isHidden())
833 { 838 {
834 odebug << "Starting search dialog" << oendl; 839 odebug << "Starting search dialog" << oendl;
835 searchDlg = new SearchDialog( this, "Etext Search", true); 840 searchDlg = new SearchDialog( this, "Etext Search", true);
836 searchDlg->setCaption( tr( "Etext Search" )); 841 searchDlg->setCaption( tr( "Etext Search" ));
837 // searchDlg->setLabel( "- searches etext"); 842 // searchDlg->setLabel( "- searches etext");
838 connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); 843 connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot()));
839 connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); 844 connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot()));
840 845
841 QString resultString; 846 QString resultString;
842 QString string = searchDlg->searchString; 847 QString string = searchDlg->searchString;
843 Lview->deselect(); 848 Lview->deselect();
844 searchDlg->show(); 849 searchDlg->show();
845 searchDlg->result(); 850 searchDlg->result();
846 } 851 }
847} 852}
848 853
849void Gutenbrowser::search_slot( ) { 854void Gutenbrowser::search_slot( ) {
850 int line, col; 855 int line, col;
851 if (!searchDlg /*&& !loadCheck */) 856 if (!searchDlg /*&& !loadCheck */)
852 return; 857 return;
853 858
854 Lview->getCursorPosition(&line,&col); 859 Lview->getCursorPosition(&line,&col);
855 QString to_find_string=searchDlg->get_text(); 860 QString to_find_string=searchDlg->get_text();
856 861
857 // searchDlg->get_direction();// is true if searching backward 862 // searchDlg->get_direction();// is true if searching backward
858 if ( last_search != 0 && searchDlg->get_direction() ){ 863 if ( last_search != 0 && searchDlg->get_direction() ){
859 col = col - pattern.length() - 1 ; 864 col = col - pattern.length() - 1 ;
860 } 865 }
861 again: 866 again:
862 int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col); 867 int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col);
863 if(result == 0){ 868 if(result == 0){
864 if(!searchDlg->get_direction()){ // forward search 869 if(!searchDlg->get_direction()){ // forward search
865 int query = QMessageBox::information( searchDlg, "Find", 870 int query = QMessageBox::information( searchDlg, "Find",
866 "End of document reached.\nContinue from the beginning?", 871 "End of document reached.\nContinue from the beginning?",
867 "Yes", "No", "", 0,1); 872 "Yes", "No", "", 0,1);
868 if (query == 0){ 873 if (query == 0){
869 line = 0; 874 line = 0;
870 col = 0; 875 col = 0;
871 goto again; 876 goto again;
872 } 877 }
873 } else { //backward search 878 } else { //backward search
874 int query = QMessageBox::information( searchDlg, "Find", 879 int query = QMessageBox::information( searchDlg, "Find",
875 "End of document reached.\nContinue from the beginning?", 880 "End of document reached.\nContinue from the beginning?",
876 "Yes", "No", "", 0,1); 881 "Yes", "No", "", 0,1);
877 if (query == 0){ 882 if (query == 0){
878 QString string = Lview->textLine( Lview->numLines() - 1 ); 883 QString string = Lview->textLine( Lview->numLines() - 1 );
879 line = Lview->numLines() - 1; 884 line = Lview->numLines() - 1;
880 lineCheck = line; 885 lineCheck = line;
881 col = string.length(); 886 col = string.length();
882 last_search = -1; //BACKWARD; 887 last_search = -1; //BACKWARD;
883 goto again; 888 goto again;
884 } 889 }
885 } 890 }
886 } else { 891 } else {
887 892
888 //// emit CursorPositionChanged(); textLine 893 //// emit CursorPositionChanged(); textLine
889 } 894 }
890} 895}
891 896
892int Gutenbrowser::doSearch( const QString &s_pattern , bool case_sensitive, bool forward, int line, int col ) { 897int Gutenbrowser::doSearch( const QString &s_pattern , bool case_sensitive, bool forward, int line, int col ) {
893 int i, length; 898 int i, length;
894 int pos = -1; 899 int pos = -1;
895 if(forward) { 900 if(forward) {
896 QString string; 901 QString string;
897 for(i = line; i < Lview->numLines(); i++) { 902 for(i = line; i < Lview->numLines(); i++) {
898 903
899 string = Lview->textLine(i); 904 string = Lview->textLine(i);
900 pos = string.find(s_pattern, i == line ? col : 0, case_sensitive); 905 pos = string.find(s_pattern, i == line ? col : 0, case_sensitive);
901 if( pos != -1) { 906 if( pos != -1) {
902 int top = Lview->Top(); 907 int top = Lview->Top();
903 length = s_pattern.length(); 908 length = s_pattern.length();
904 if( i > Lview->lastRow() ) { 909 if( i > Lview->lastRow() ) {
905// Lview->setCursorPosition(i,pos,FALSE); 910// Lview->setCursorPosition(i,pos,FALSE);
906 for(int l = 0 ; l < length; l++) { 911 for(int l = 0 ; l < length; l++) {
907 Lview->cursorRight(TRUE); 912 Lview->cursorRight(TRUE);
908 } 913 }
909// Lview->setCursorPosition( i , pos + length, TRUE ); 914// Lview->setCursorPosition( i , pos + length, TRUE );
910 int newTop = Lview->Top(); 915 int newTop = Lview->Top();
911 if(Lview->lastRow() > i) 916 if(Lview->lastRow() > i)
912 Lview->ScrollUp( newTop - top); 917 Lview->ScrollUp( newTop - top);
913 // AdjustStatus(); 918 // AdjustStatus();
914 } else { 919 } else {
915// Lview->setCursorPosition(i,pos,FALSE); 920// Lview->setCursorPosition(i,pos,FALSE);
916 for(int l = 0 ; l < length; l++) { 921 for(int l = 0 ; l < length; l++) {
917 Lview->cursorRight(TRUE); 922 Lview->cursorRight(TRUE);
918 } 923 }
919// Lview->setCursorPosition( i , pos + length, TRUE ); 924// Lview->setCursorPosition( i , pos + length, TRUE );
920 // AdjustStatus(); 925 // AdjustStatus();
921 } 926 }
922 pattern = s_pattern; 927 pattern = s_pattern;
923 last_search = 1; //FORWARD; 928 last_search = 1; //FORWARD;
924 return 1; 929 return 1;
925 } 930 }
926 } 931 }
927 } else { //////////////// searching backwards 932 } else { //////////////// searching backwards
928 QString string; 933 QString string;
929 for( i = line; i >= 0; i--) { 934 for( i = line; i >= 0; i--) {
930 string = Lview->textLine(i); 935 string = Lview->textLine(i);
931 int line_length = string.length(); 936 int line_length = string.length();
932 pos = string.findRev(s_pattern, line == i ? col : line_length , case_sensitive); 937 pos = string.findRev(s_pattern, line == i ? col : line_length , case_sensitive);
933 if (pos != -1) { 938 if (pos != -1) {
934 // int top = Lview->Top(); 939 // int top = Lview->Top();
935 length = s_pattern.length(); 940 length = s_pattern.length();
936 if( i < Lview->Top() ) { 941 if( i < Lview->Top() ) {
937 Lview->ScrollDown( Lview->PageSize() ); 942 Lview->ScrollDown( Lview->PageSize() );
938 Lview->MultiLine_Ex::pageUp( FALSE ); 943 Lview->MultiLine_Ex::pageUp( FALSE );
939 if( ! (line == i && pos > col ) ) { 944 if( ! (line == i && pos > col ) ) {
940// Lview->setCursorPosition( i ,pos ,FALSE ); 945// Lview->setCursorPosition( i ,pos ,FALSE );
941 for(int l = 0 ; l < length; l++) { 946 for(int l = 0 ; l < length; l++) {
942 Lview->cursorRight(TRUE); 947 Lview->cursorRight(TRUE);
943 } 948 }
944// Lview->setCursorPosition(i ,pos + length ,TRUE ); 949// Lview->setCursorPosition(i ,pos + length ,TRUE );
945 // int newTop = Lview->Top(); 950 // int newTop = Lview->Top();
946 /* if(useSplitter) Rview->ScrollUp( newTop - top); 951 /* if(useSplitter) Rview->ScrollUp( newTop - top);
947 */ } 952 */ }
948 } else { 953 } else {
949 if( ! (line == i && pos > col ) ) { 954 if( ! (line == i && pos > col ) ) {
950// Lview->setCursorPosition( i, pos, FALSE ); 955// Lview->setCursorPosition( i, pos, FALSE );
951 for( int l = 0 ; l < length; l++) { 956 for( int l = 0 ; l < length; l++) {
952 Lview->cursorRight( TRUE); 957 Lview->cursorRight( TRUE);
953 } 958 }
954// Lview->setCursorPosition( i, pos + length, TRUE ); 959// Lview->setCursorPosition( i, pos + length, TRUE );
955 } 960 }
956 pattern = s_pattern; 961 pattern = s_pattern;
957 last_search = -1; 962 last_search = -1;
958 return 1; 963 return 1;
959 } 964 }
960 } 965 }
961 } 966 }
962 } 967 }
963 return 0; 968 return 0;
964} 969}
965 970
966void Gutenbrowser::LibraryBtn() { 971void Gutenbrowser::LibraryBtn() {
967 972
968 QString newestLibraryFile ="pgwhole.zip"; 973 QString newestLibraryFile ="pgwhole.zip";
969 QString zipFile; 974 QString zipFile;
970 // odebug << "Local Library is " << local_library << " " << oendl; 975 // odebug << "Local Library is " << local_library << " " << oendl;
971 zipFile="/usr/bin/unzip"; 976 zipFile="/usr/bin/unzip";
972 // odebug << "newestLibraryFile is " << newestLibraryFile << " " << oendl; 977 // odebug << "newestLibraryFile is " << newestLibraryFile << " " << oendl;
973 if( QFile::exists( local_library+newestLibraryFile)) { 978 if( QFile::exists( local_library+newestLibraryFile)) {
974 if( QFile::exists(zipFile) ) { 979 if( QFile::exists(zipFile) ) {
975 UnZipIt(newestLibraryFile); 980 UnZipIt(newestLibraryFile);
976 } 981 }
977 else 982 else
978 QMessageBox::message( "Note",( tr("Please install unzip")) ); 983 QMessageBox::message( "Note",( tr("Please install unzip")) );
979 } 984 }
980 // LibraryDlg = new LibraryDialog( this, "Library Index"); 985 // LibraryDlg = new LibraryDialog( this, "Library Index");
981 LibraryDlg->setCaption( tr( "Gutenberg Library")); 986 LibraryDlg->setCaption( tr( "Gutenberg Library"));
982 Config config("Gutenbrowser"); 987 Config config("Gutenbrowser");
983 config.setGroup("General"); 988 config.setGroup("General");
984 989
985 if(useSplitter) 990 if(useSplitter)
986 LibraryDlg->useSmallInterface=FALSE; 991 LibraryDlg->useSmallInterface=FALSE;
987 992
988 LibraryDlg->showMaximized(); 993 LibraryDlg->showMaximized();
989 994
990 if( LibraryDlg->exec() != 0 ) { 995 if( LibraryDlg->exec() != 0 ) {
991 listItemNumber = LibraryDlg->DlglistItemNumber; 996 listItemNumber = LibraryDlg->DlglistItemNumber;
992 listItemFile = LibraryDlg->DlglistItemFile; 997 listItemFile = LibraryDlg->DlglistItemFile;
993 listItemYear = LibraryDlg->DlglistItemYear; 998 listItemYear = LibraryDlg->DlglistItemYear;
994 listItemTitle = LibraryDlg->DlglistItemTitle; 999 listItemTitle = LibraryDlg->DlglistItemTitle;
995 file_name = LibraryDlg->File_Name; 1000 file_name = LibraryDlg->File_Name;
996 // odebug << "title is being set as "+title << oendl; 1001 // odebug << "title is being set as "+title << oendl;
997 title = listItemTitle; 1002 title = listItemTitle;
998 1003
999 // config.setGroup( "Proxy" ); 1004 // config.setGroup( "Proxy" );
1000 // if( LibraryDlg->checked == 1) { 1005 // if( LibraryDlg->checked == 1) {
1001 // config.writeEntry("IsChecked", "TRUE"); 1006 // config.writeEntry("IsChecked", "TRUE");
1002 // } else { 1007 // } else {
1003 // config.writeEntry("IsChecked", "FALSE"); 1008 // config.writeEntry("IsChecked", "FALSE");
1004 // } 1009 // }
1005 // config.write(); 1010 // config.write();
1006 // config.read(); 1011 // config.read();
1007 if ( listItemNumber.isNull()) { 1012 if ( listItemNumber.isNull()) {
1008 } else { 1013 } else {
1009 i_pageNum = 1; 1014 i_pageNum = 1;
1010 if( file_name !="Error" && file_name.length() >2 && !file_name.isEmpty() ) { 1015 if( file_name !="Error" && file_name.length() >2 && !file_name.isEmpty() ) {
1011 //replace .zip with txt for opening it. 1016 //replace .zip with txt for opening it.
1012 // printf("\nFile name is now\n"); 1017 // printf("\nFile name is now\n");
1013 // printf(file_name); 1018 // printf(file_name);
1014 // printf("\n"); 1019 // printf("\n");
1015 // 1020 //
1016 if( file_name.find(".zip")) 1021 if( file_name.find(".zip"))
1017 { 1022 {
1018 odebug << "Found zip file\n" << oendl; 1023 odebug << "Found zip file\n" << oendl;
1019 // QStringList args; 1024 // QStringList args;
1020 // args="unzip"; 1025 // args="unzip";
1021 // args+="-o"; 1026 // args+="-o";
1022 // args+=local_library+file_name; 1027 // args+=local_library+file_name;
1023 // args+="-d"; 1028 // args+="-d";
1024 // args+=local_library; 1029 // args+=local_library;
1025 QString cmd = "/usr/bin/unzip -o " + local_library+file_name + " -d " + local_library; 1030 QString cmd = "/usr/bin/unzip -o " + local_library+file_name + " -d " + local_library;
1026 odebug << "Issuing the command "+ cmd << oendl; 1031 odebug << "Issuing the command "+ cmd << oendl;
1027 // unzipProc=new QProcess( this, "unzipProc" ); /// fark that idea! 1032 // unzipProc=new QProcess( this, "unzipProc" ); /// fark that idea!
1028 // unzipProc->start(); 1033 // unzipProc->start();
1029 system(cmd); 1034 system(cmd);
1030 remove( file_name); 1035 remove( file_name);
1031 1036
1032 } 1037 }
1033 // // 1038 // //
1034 // file_name = file_name.left(4)+ ".txt"; 1039 // file_name = file_name.left(4)+ ".txt";
1035 if( LibraryDlg) 1040 if( LibraryDlg)
1036 delete LibraryDlg; 1041 delete LibraryDlg;
1037 setTitle(); 1042 setTitle();
1038 // QCopEnvelope ( "QPE/System", "busy()" ); 1043 // QCopEnvelope ( "QPE/System", "busy()" );
1039 load( file_name); 1044 if( !load( file_name)) return;
1040 } else { 1045 } else {
1041 printf("Not opening the file.\n"); 1046 printf("Not opening the file.\n");
1042 } 1047 }
1043 } 1048 }
1044 } 1049 }
1045 if(showMainList) { 1050 if(showMainList) {
1046 if(!Lview->isHidden()) 1051 if(!Lview->isHidden())
1047 Lview->hide(); 1052 Lview->hide();
1048 qApp->processEvents(); 1053 qApp->processEvents();
1049 showMainList=TRUE; 1054 showMainList=TRUE;
1050 if(mainList->isHidden()) 1055 if(mainList->isHidden())
1051 mainList->show(); 1056 mainList->show();
1052 fillWithTitles(); 1057 fillWithTitles();
1053 qApp->processEvents(); 1058 qApp->processEvents();
1054 } else 1059 } else
1055 setCentralWidget( Lview); 1060 setCentralWidget( Lview);
1056 // QPEApplication::grabKeyboard(); 1061 // QPEApplication::grabKeyboard();
1057 // fixKeys(); 1062 // fixKeys();
1058} 1063}
1059 1064
1060void Gutenbrowser::OpenBtn() { 1065void Gutenbrowser::OpenBtn() {
1061 QString s_temp; 1066 QString s_temp;
1062 s_temp = status; 1067 s_temp = status;
1063 OpenEtext* OpenDlg; 1068 OpenEtext* OpenDlg;
1064 OpenDlg = new OpenEtext(this,"OpenDlg"); 1069 OpenDlg = new OpenEtext(this,"OpenDlg");
1065 OpenDlg->showMaximized(); 1070 OpenDlg->showMaximized();
1066 1071
1067 if( OpenDlg->exec() != 0) { 1072 if( OpenDlg->exec() != 0) {
1068 title = OpenDlg->openFileTitle; 1073 title = OpenDlg->openFileTitle;
1069 odebug << "title open as "+title << oendl; 1074 odebug << "title open as "+title << oendl;
1070 file_name = OpenDlg->file; 1075 file_name = OpenDlg->file;
1071 i_pageNum = 1; 1076 i_pageNum = 1;
1072 1077
1073 if( !file_name.isEmpty() || file_name.length() > 2 ) { 1078 if( !file_name.isEmpty() || file_name.length() > 2 ) {
1074 if(showMainList) { 1079 if(showMainList) {
1075 showMainList=FALSE; 1080 showMainList=FALSE;
1076 odebug << "ShowMainList is now false" << oendl; 1081 odebug << "ShowMainList is now false" << oendl;
1077 mainList->hide(); 1082 mainList->hide();
1078 Lview->show(); 1083 Lview->show();
1079 qApp->processEvents(); 1084 qApp->processEvents();
1080 } 1085 }
1081 Lview->clear(); 1086 Lview->clear();
1082 // QCopEnvelope ( "QPE/System", "busy()" ); 1087 // QCopEnvelope ( "QPE/System", "busy()" );
1083 load(file_name); 1088 if(!load(file_name)) return;
1084 } else { 1089 } else {
1085 odebug << "file_name is empty!" << oendl; 1090 odebug << "file_name is empty!" << oendl;
1086 if(showMainList) { 1091 if(showMainList) {
1087 if(!Lview->isHidden()) 1092 if(!Lview->isHidden())
1088 Lview->hide(); 1093 Lview->hide();
1089 qApp->processEvents(); 1094 qApp->processEvents();
1090 if(mainList->isHidden()) 1095 if(mainList->isHidden())
1091 mainList->show(); 1096 mainList->show();
1092 fillWithTitles(); 1097 fillWithTitles();
1093 qApp->processEvents(); 1098 qApp->processEvents();
1094 } 1099 }
1095 1100
1096 } 1101 }
1097 } 1102 }
1098 if( OpenDlg) 1103 if( OpenDlg)
1099 delete OpenDlg; 1104 delete OpenDlg;
1100 /* 1105 /*
1101 Config config("Gutenbrowser"); 1106 Config config("Gutenbrowser");
1102 config.setGroup( title); 1107 config.setGroup( title);
1103 file_name = config.readEntry("File Name", ""); 1108 file_name = config.readEntry("File Name", "");
1104 i_pageNum = config.readNumEntry("Page Number", -1); 1109 i_pageNum = config.readNumEntry("Page Number", -1);
1105 int Bmrkrow = config.readNumEntry("LineNumber", -1); 1110 int Bmrkrow = config.readNumEntry("LineNumber", -1);
1106 if(Bmrkrow > -1) { 1111 if(Bmrkrow > -1) {
1107 if( Bmrkrow > Lview->topRow() ) { 1112 if( Bmrkrow > Lview->topRow() ) {
1108 Lview->setCursorPosition( Bmrkrow ,0, FALSE ); 1113 Lview->setCursorPosition( Bmrkrow ,0, FALSE );
1109 Lview->ScrollUp( Bmrkrow - Lview->topRow() ); 1114 Lview->ScrollUp( Bmrkrow - Lview->topRow() );
1110 // AdjustStatus(); 1115 // AdjustStatus();
1111 } 1116 }
1112 else if( Bmrkrow < Lview->topRow() ) { 1117 else if( Bmrkrow < Lview->topRow() ) {
1113 Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE ); 1118 Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE );
1114 Lview->ScrollDown( Lview->topRow() - Bmrkrow ); 1119 Lview->ScrollDown( Lview->topRow() - Bmrkrow );
1115 // AdjustStatus(); 1120 // AdjustStatus();
1116 } 1121 }
1117 } 1122 }
1118 */ 1123 */
1119 // ResizeEdits(); 1124 // ResizeEdits();
1120 1125
1121} 1126}
1122 1127
1123void Gutenbrowser::ChangeFont() { 1128void Gutenbrowser::ChangeFont() {
1124#ifndef Q_WS_QWS 1129#ifndef Q_WS_QWS
1125 bool ok; 1130 bool ok;
1126 1131
1127 weight= Lview->fontInfo().weight(); 1132 weight= Lview->fontInfo().weight();
1128 italic = Lview->fontInfo().italic(); 1133 italic = Lview->fontInfo().italic();
1129 bold=Lview->fontInfo().bold(); 1134 bold=Lview->fontInfo().bold();
1130 pointSize= Lview->fontInfo().pointSize(); 1135 pointSize= Lview->fontInfo().pointSize();
1131 fontStr=Lview->fontInfo().family(); 1136 fontStr=Lview->fontInfo().family();
1132 1137
1133 if(italic == true) 1138 if(italic == true)
1134 italicStr="TRUE"; 1139 italicStr="TRUE";
1135 else 1140 else
1136 italicStr="FALSE"; 1141 italicStr="FALSE";
1137 1142
1138 QFont currentfont( fontStr, pointSize, weight, italic ); 1143 QFont currentfont( fontStr, pointSize, weight, italic );
1139 1144
1140 if (ok) { 1145 if (ok) {
1141 QFontInfo fontInfo(font ); 1146 QFontInfo fontInfo(font );
1142 fontStr=fontInfo.family(); 1147 fontStr=fontInfo.family();
1143 1148
1144 pointSize= fontInfo.pointSize(); 1149 pointSize= fontInfo.pointSize();
1145 1150
1146 font.setFontSize(pointSize); 1151 font.setFontSize(pointSize);
1147 1152
1148 pointSizeStr.setNum( pointSize); 1153 pointSizeStr.setNum( pointSize);
1149 1154
1150 weight= fontInfo.weight(); 1155 weight= fontInfo.weight();
1151 weightStr.setNum( weight); 1156 weightStr.setNum( weight);
1152 italic =fontInfo.italic(); 1157 italic =fontInfo.italic();
1153 bold=fontInfo.bold(); 1158 bold=fontInfo.bold();
1154 1159
1155 if(italic == true) 1160 if(italic == true)
1156 italicStr="TRUE"; 1161 italicStr="TRUE";
1157 else 1162 else
1158 italicStr="FALSE"; 1163 italicStr="FALSE";
1159 if(bold == true) 1164 if(bold == true)
1160 boldStr="TRUE"; 1165 boldStr="TRUE";
1161 else 1166 else
1162 boldStr="FALSE"; 1167 boldStr="FALSE";
1163 1168
1164 pointSizeStr.setNum( pointSize); 1169 pointSizeStr.setNum( pointSize);
1165 config.setGroup( "Font" ); 1170 config.setGroup( "Font" );
1166 config.writeEntry("Family", fontStr ); 1171 config.writeEntry("Family", fontStr );
1167 config.writeEntry("Size", pointSizeStr ); 1172 config.writeEntry("Size", pointSizeStr );
1168 config.writeEntry("Weight", weightStr ); 1173 config.writeEntry("Weight", weightStr );
1169 config.writeEntry("Italic", italicStr ); 1174 config.writeEntry("Italic", italicStr );
1170 config.writeEntry("Bold", boldStr ); 1175 config.writeEntry("Bold", boldStr );
1171 // config.write(); 1176 // config.write();
1172 1177
1173 Lview->setFont(font); 1178 Lview->setFont(font);
1174 1179
1175 QRect lRect; 1180 QRect lRect;
1176 QRect rRect; 1181 QRect rRect;
1177 lRect = Lview->rect(); 1182 lRect = Lview->rect();
1178 if(useSplitter) { 1183 if(useSplitter) {
1179 } 1184 }
1180 // if(loadCheck) { 1185 // if(loadCheck) {
1181 // ResizeEdits(); 1186 // ResizeEdits();
1182 // } 1187 // }
1183 update(); 1188 update();
1184 } 1189 }
1185#endif 1190#endif
1186} 1191}
1187 1192
1188 1193
1189 /* 1194 /*
1190 performs dictionary look ups on the web */ 1195 performs dictionary look ups on the web */
1191void Gutenbrowser::LookupBtn() { 1196void Gutenbrowser::LookupBtn() {
1192 QString text; 1197 QString text;
1193 if( Lview->hasSelectedText()) { 1198 if( Lview->hasSelectedText()) {
1194 Lview->copy(); 1199 Lview->copy();
1195 } 1200 }
1196 QClipboard *cb = QApplication::clipboard(); 1201 QClipboard *cb = QApplication::clipboard();
1197 text = cb->text(); 1202 text = cb->text();
1198 int eexit=QMessageBox::information(this, 1203 int eexit=QMessageBox::information(this,
1199 "Note","Do you want to lookup\n\""+text+"\"\non websters web dictionary?", 1204 "Note","Do you want to lookup\n\""+text+"\"\non websters web dictionary?",
1200 QMessageBox::Yes, QMessageBox::No); 1205 QMessageBox::Yes, QMessageBox::No);
1201 if (eexit== 3) { 1206 if (eexit== 3) {
1202 // this link for sale!! 1207 // this link for sale!!
1203 qApp->processEvents(); 1208 qApp->processEvents();
1204 goGetit( "http://www.m-w.com/cgi-bin/dictionary?" + text, true); 1209 goGetit( "http://www.m-w.com/cgi-bin/dictionary?" + text, true);
1205 } 1210 }
1206} 1211}
1207 1212
1208void Gutenbrowser::ClearEdit() { 1213void Gutenbrowser::ClearEdit() {
1209 Lview->setText(""); 1214 Lview->setText("");
1210 loadCheck = false; 1215 loadCheck = false;
1211 status = ( tr("Gutenbrowser")); 1216 status = ( tr("Gutenbrowser"));
1212 InfoBar->setText( ""); 1217 InfoBar->setText( "");
1213 setCaption( tr("Gutenbrowser")); 1218 setCaption( tr("Gutenbrowser"));
1214 i_pageNum = 0; 1219 i_pageNum = 0;
1215 enableButtons(false); 1220 enableButtons(false);
1216 1221
1217 if(!showMainList) { 1222 if(!showMainList) {
1218 Lview->hide(); 1223 Lview->hide();
1219 showMainList=TRUE; 1224 showMainList=TRUE;
1220 mainList->show(); 1225 mainList->show();
1221 fillWithTitles(); 1226 fillWithTitles();
1222 qApp->processEvents(); 1227 qApp->processEvents();
1223 } 1228 }
1224 if(donateMenu->idAt(3) != -1) 1229 if(donateMenu->idAt(3) != -1)
1225 donateMenu->removeItemAt(3); 1230 donateMenu->removeItemAt(3);
1226} 1231}
1227 1232
1228 1233
1229bool Gutenbrowser::getTitle( const char *file ) { 1234bool Gutenbrowser::getTitle( const char *file ) {
1230 QString s_file; 1235 QString s_file;
1231 QString filer = file; 1236 QString filer = file;
1232 if( filer.contains(local_library, TRUE)) { 1237 if( filer.contains(local_library, TRUE)) {
1233 QFileInfo f(file); 1238 QFileInfo f(file);
1234 s_file = f.fileName(); 1239 s_file = f.fileName();
1235 } else { 1240 } else {
1236 s_file = filer; 1241 s_file = filer;
1237 } 1242 }
1238 Config config("Gutenbrowser"); 1243 Config config("Gutenbrowser");
1239 config.setGroup( "Files" ); 1244 config.setGroup( "Files" );
1240 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 1245 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
1241 int i_numofFiles = s_numofFiles.toInt(); 1246 int i_numofFiles = s_numofFiles.toInt();
1242 1247
1243 for (int i = 1; i <= i_numofFiles; i++) { 1248 for (int i = 1; i <= i_numofFiles; i++) {
1244 QString temp; 1249 QString temp;
1245 temp.setNum(i); 1250 temp.setNum(i);
1246 QString ramble = config.readEntry(temp, "" ); 1251 QString ramble = config.readEntry(temp, "" );
1247 1252
1248 if( strcmp(ramble, s_file) == 0) { 1253 if( strcmp(ramble, s_file) == 0) {
1249 config.setGroup( "Titles" ); 1254 config.setGroup( "Titles" );
1250 title = config.readEntry(ramble, ""); 1255 title = config.readEntry(ramble, "");
1251 // odebug << "(getTitle)title is being set as "+title << oendl; 1256 // odebug << "(getTitle)title is being set as "+title << oendl;
1252 } 1257 }
1253 } 1258 }
1254 return true; 1259 return true;
1255} 1260}
1256 1261
1257void Gutenbrowser::searchdone_slot() { 1262void Gutenbrowser::searchdone_slot() {
1258 // if (!searchDlg) 1263 // if (!searchDlg)
1259 // return; 1264 // return;
1260 // searchDlg->hide(); 1265 // searchDlg->hide();
1261 // Lview->setFocus(); 1266 // Lview->setFocus();
1262 this->setFocus(); 1267 this->setFocus();
1263 last_search = 0; 1268 last_search = 0;
1264 // ResizeEdits(); 1269 // ResizeEdits();
1265} 1270}
1266 1271
1267 /* 1272 /*
1268 sets the status message */ 1273 sets the status message */
1269bool Gutenbrowser::setStatus() { 1274bool Gutenbrowser::setStatus() {
1270 1275
1271#ifndef Q_WS_QWS 1276#ifndef Q_WS_QWS
1272 QString s_pages; 1277 QString s_pages;
1273 s_pages.setNum( pages); 1278 s_pages.setNum( pages);
1274 QString chNum; 1279 QString chNum;
1275 statusTop = status.left( status.find(" ", TRUE) ); 1280 statusTop = status.left( status.find(" ", TRUE) );
1276 status.append(chNum.setNum( i_pageNum)); 1281 status.append(chNum.setNum( i_pageNum));
1277 status += " / " + s_pages; 1282 status += " / " + s_pages;
1278 1283
1279 if(loadCheck) { 1284 if(loadCheck) {
1280 statusBar->message( status); 1285 statusBar->message( status);
1281 InfoBar->setText( title); 1286 InfoBar->setText( title);
1282 } else { 1287 } else {
1283 } 1288 }
1284#else 1289#else
1285 QString msg; 1290 QString msg;
1286 msg.sprintf(title+" %d", i_pageNum); 1291 msg.sprintf(title+" %d", i_pageNum);
1287 setCaption( msg); 1292 setCaption( msg);
1288#endif 1293#endif
1289 return true; 1294 return true;
1290} 1295}
1291 1296
1292void Gutenbrowser::keyReleaseEvent( QKeyEvent *e) { 1297void Gutenbrowser::keyReleaseEvent( QKeyEvent *e) {
1293 switch ( e->key() ) { 1298 switch ( e->key() ) {
1294 1299
1295 case Key_M: 1300 case Key_M:
1296 // Bookmark(); 1301 // Bookmark();
1297 break; 1302 break;
1298 case Key_D: 1303 case Key_D:
1299 DownloadIndex(); 1304 DownloadIndex();
1300 break; 1305 break;
1301 case Key_L: 1306 case Key_L:
1302 LibraryBtn(); 1307 LibraryBtn();
1303 break; 1308 break;
1304 case Key_O: 1309 case Key_O:
1305 OpenBtn(); 1310 OpenBtn();
1306 break; 1311 break;
1307 case Key_F: 1312 case Key_F:
1308 ForwardBtn(); 1313 ForwardBtn();
1309 break; 1314 break;
1310 case Key_B: 1315 case Key_B:
1311 BackBtn(); 1316 BackBtn();
1312 break; 1317 break;
1313 case Key_P: 1318 case Key_P:
1314 PrintBtn(); 1319 PrintBtn();
1315 break; 1320 break;
1316 case Key_S: 1321 case Key_S:
1317 SearchBtn(); 1322 SearchBtn();
1318 break; 1323 break;
1319 case Key_E: 1324 case Key_E:
1320 ByeBye(); 1325 ByeBye();
1321 break; 1326 break;
1322 case Key_R: 1327 case Key_R:
1323 // setBookmark(); 1328 // setBookmark();
1324 break; 1329 break;
1325 case Key_T: 1330 case Key_T:
1326 ChangeFont(); 1331 ChangeFont();
1327 break; 1332 break;
1328 case Key_C: 1333 case Key_C:
1329 ClearEdit(); 1334 ClearEdit();
1330 break; 1335 break;
1331 case Key_H: 1336 case Key_H:
1332 HelpBtn(); 1337 HelpBtn();
1333 break; 1338 break;
1334 case Key_K: 1339 case Key_K:
1335 LookupBtn(); 1340 LookupBtn();
1336 break; 1341 break;
1337 case Key_U:// hide menu 1342 case Key_U:// hide menu
1338 if(menubar->isHidden() ) 1343 if(menubar->isHidden() )
1339 menubar->show(); 1344 menubar->show();
1340 else 1345 else
1341 menubar->hide(); 1346 menubar->hide();
1342 break; 1347 break;
1343 case Key_I: 1348 case Key_I:
1344 hideButtons(); 1349 hideButtons();
1345 break; 1350 break;
1346 ////////////////////////////// Zaurus keys 1351 ////////////////////////////// Zaurus keys
1347 case Key_Home: 1352 case Key_Home:
1348 // BeginBtn(); 1353 // BeginBtn();
1349 break; 1354 break;
1350 case Key_F9: //activity 1355 case Key_F9: //activity
1351 OpenBtn(); 1356 OpenBtn();
1352 break; 1357 break;
1353 case Key_F10: //contacts 1358 case Key_F10: //contacts
1354 hideButtons(); 1359 hideButtons();
1355 break; 1360 break;
1356 case Key_F11: //menu 1361 case Key_F11: //menu
1357 if(menubar->isHidden() ) 1362 if(menubar->isHidden() )
1358 menubar->show(); 1363 menubar->show();
1359 else 1364 else
1360 menubar->hide(); 1365 menubar->hide();
1361 break; 1366 break;
1362 case Key_F12: //home 1367 case Key_F12: //home
1363 BeginBtn(); 1368 BeginBtn();
1364 break; 1369 break;
1365 case Key_F13: //mail 1370 case Key_F13: //mail
1366 LibraryBtn(); 1371 LibraryBtn();
1367 break; 1372 break;
1368 case Key_Space: 1373 case Key_Space:
1369 if(loadCheck) 1374 if(loadCheck)
1370 ForwardBtn(); 1375 ForwardBtn();
1371 // else 1376 // else
1372 // Bookmark(); 1377 // Bookmark();
1373 break; 1378 break;
1374 case Key_Down: 1379 case Key_Down:
1375 if(loadCheck) { 1380 if(loadCheck) {
1376 // if( !e->isAutoRepeat() ) 1381 // if( !e->isAutoRepeat() )
1377 // AdjustStatus(); 1382 // AdjustStatus();
1378 // } else { 1383 // } else {
1379 // LibraryBtn(); 1384 // LibraryBtn();
1380 // ForwardBtn(); 1385 // ForwardBtn();
1381 } 1386 }
1382 1387
1383 // ForwardButton->setFocus(); 1388 // ForwardButton->setFocus();
1384 // Lview->setFocus(); 1389 // Lview->setFocus();
1385 // if(s_Wrap=="FALSE") 1390 // if(s_Wrap=="FALSE")
1386 // Lview->MultiLine_Ex::ScrollDown( 1); 1391 // Lview->MultiLine_Ex::ScrollDown( 1);
1387 // LibraryBtn(); 1392 // LibraryBtn();
1388 break; 1393 break;
1389 case Key_Up: 1394 case Key_Up:
1390 if(loadCheck) { 1395 if(loadCheck) {
1391 // if( !e->isAutoRepeat() ) 1396 // if( !e->isAutoRepeat() )
1392 // AdjustStatus(); 1397 // AdjustStatus();
1393 // } else { 1398 // } else {
1394 // OpenBtn(); 1399 // OpenBtn();
1395 // BackBtn(); 1400 // BackBtn();
1396 } 1401 }
1397 // BackButton->setFocus(); 1402 // BackButton->setFocus();
1398 // Lview->setFocus(); 1403 // Lview->setFocus();
1399 // if(s_Wrap=="FALSE") 1404 // if(s_Wrap=="FALSE")
1400 // Lview->MultiLine_Ex::ScrollUp( 1); 1405 // Lview->MultiLine_Ex::ScrollUp( 1);
1401 1406
1402 // LibraryBtn(); 1407 // LibraryBtn();
1403 break; 1408 break;
1404 case Key_Right: 1409 case Key_Right:
1405 ForwardButton->setFocus(); 1410 ForwardButton->setFocus();
1406 ForwardBtn(); 1411 ForwardBtn();
1407 // LibraryBtn(); 1412 // LibraryBtn();
1408 break; 1413 break;
1409 case Key_Left: 1414 case Key_Left:
1410 BackBtn(); 1415 BackBtn();
1411 BackButton->setFocus(); 1416 BackButton->setFocus();
1412 // OpenBtn(); 1417 // OpenBtn();
1413 break; 1418 break;
1414 case Key_Escape: 1419 case Key_Escape:
1415 ByeBye(); 1420 ByeBye();
1416 break; 1421 break;
1417 case Key_PageUp: 1422 case Key_PageUp:
1418 BackBtn(); 1423 BackBtn();
1419 break; 1424 break;
1420 case Key_PageDown: 1425 case Key_PageDown:
1421 ForwardBtn(); 1426 ForwardBtn();
1422 break; 1427 break;
1423 1428
1424 ////////////////////////////// Zaurus keys 1429 ////////////////////////////// Zaurus keys
1425 }; 1430 };
1426} 1431}
1427 1432
1428void Gutenbrowser::keyPressEvent( QKeyEvent *e) { 1433void Gutenbrowser::keyPressEvent( QKeyEvent *e) {
1429 switch ( e->key() ) { 1434 switch ( e->key() ) {
1430 // case Key_Next: 1435 // case Key_Next:
1431 // ForwardBtn(); 1436 // ForwardBtn();
1432 // break; 1437 // break;
1433 // case Key_Prior: 1438 // case Key_Prior:
1434 // BackBtn(); 1439 // BackBtn();
1435 // break; 1440 // break;
1436 // case Key_Space: 1441 // case Key_Space:
1437 // ForwardBtn(); 1442 // ForwardBtn();
1438 // break; 1443 // break;
1439 // case Key_Down: 1444 // case Key_Down:
1440 // Lview->MultiLine_Ex::ScrollUp( 1); 1445 // Lview->MultiLine_Ex::ScrollUp( 1);
1441 // if(useSplitter) Rview->MultiLine_Ex::ScrollUp( 1); 1446 // if(useSplitter) Rview->MultiLine_Ex::ScrollUp( 1);
1442 // break; 1447 // break;
1443 // case Key_Up: 1448 // case Key_Up:
1444 // if( Lview->Top() != 0) { 1449 // if( Lview->Top() != 0) {
1445 // Lview->MultiLine_Ex::ScrollDown( 1); 1450 // Lview->MultiLine_Ex::ScrollDown( 1);
1446 // if(useSplitter) Rview->MultiLine_Ex::ScrollDown( 1); 1451 // if(useSplitter) Rview->MultiLine_Ex::ScrollDown( 1);
1447 // } 1452 // }
1448 // break; 1453 // break;
1449 } 1454 }
1450} 1455}
1451 1456
1452void Gutenbrowser::resizeEvent( QResizeEvent *ev) { 1457void Gutenbrowser::resizeEvent( QResizeEvent *ev) {
1453 // odebug << "resize: " << ev->size().width() << "," << ev->size().height() << "\n" << oendl; 1458 // odebug << "resize: " << ev->size().width() << "," << ev->size().height() << "\n" << oendl;
1454 1459
1455 if( !LibraryDlg->isHidden()) 1460 if( !LibraryDlg->isHidden())
1456 LibraryDlg->resize(ev->size().width(),ev->size().height() ); 1461 LibraryDlg->resize(ev->size().width(),ev->size().height() );
1457 1462
1458 // if( loadCheck == true) { 1463 // if( loadCheck == true) {
1459 // ResizeEdits(); 1464 // ResizeEdits();
1460 // AdjustStatus(); 1465 // AdjustStatus();
1461 // } 1466 // }
1462} 1467}
1463 1468
1464 1469
1465void Gutenbrowser::doOptions() { 1470void Gutenbrowser::doOptions() {
1466 optionsDialog* optDlg; 1471 optionsDialog* optDlg;
1467 optDlg = new optionsDialog( this,"Options_Dlg", true); 1472 optDlg = new optionsDialog( this,"Options_Dlg", true);
1468 QString Ddir; 1473 QString Ddir;
1469 Config config("Gutenbrowser"); 1474 Config config("Gutenbrowser");
1470 config.setGroup( "General" ); 1475 config.setGroup( "General" );
1471 QFont myFont; 1476 QFont myFont;
1472 optDlg->showMaximized(); 1477 optDlg->showMaximized();
1473 1478
1474 if( optDlg->exec() !=0) { 1479 if( optDlg->exec() !=0) {
1475 qApp->processEvents(); 1480 qApp->processEvents();
1476 brow=optDlg->browserName; 1481 brow=optDlg->browserName;
1477 toggleButtonIcons( optDlg->useIcon); 1482 toggleButtonIcons( optDlg->useIcon);
1478 ftp_host= optDlg->ftp_host; 1483 ftp_host= optDlg->ftp_host;
1479 ftp_base_dir= optDlg->ftp_base_dir; 1484 ftp_base_dir= optDlg->ftp_base_dir;
1480 brow=optDlg->browserName; 1485 brow=optDlg->browserName;
1481 Ddir=optDlg->downloadDirEdit->text(); 1486 Ddir=optDlg->downloadDirEdit->text();
1482 1487
1483 odebug << "writing library config" << oendl; 1488 odebug << "writing library config" << oendl;
1484 Config config("Gutenbrowser"); 1489 Config config("Gutenbrowser");
1485 config.setGroup("General"); 1490 config.setGroup("General");
1486 1491
1487 QString dirname= optDlg->downloadDirEdit->text(); 1492 QString dirname= optDlg->downloadDirEdit->text();
1488 if(dirname.right(1)!="/") 1493 if(dirname.right(1)!="/")
1489 dirname+="/"; 1494 dirname+="/";
1490 config.writeEntry( "DownloadDirectory",dirname); 1495 config.writeEntry( "DownloadDirectory",dirname);
1491 QDir newDir( optDlg->downloadDirEdit->text()); 1496 QDir newDir( optDlg->downloadDirEdit->text());
1492 1497
1493 if( !newDir.exists() ) { 1498 if( !newDir.exists() ) {
1494 int exit=QMessageBox::information(this, "Note", "Ok, to make a new directory\n"+Ddir+" ?", 1499 int exit=QMessageBox::information(this, "Note", "Ok, to make a new directory\n"+Ddir+" ?",
1495 QMessageBox::Ok, QMessageBox::Cancel); 1500 QMessageBox::Ok, QMessageBox::Cancel);
1496 if (exit==1) { 1501 if (exit==1) {
1497 QString cmd="mkdir -p "; 1502 QString cmd="mkdir -p ";
1498 cmd+=Ddir.latin1(); 1503 cmd+=Ddir.latin1();
1499 system(cmd); 1504 system(cmd);
1500 odebug << "Making new dir "+cmd << oendl; 1505 odebug << "Making new dir "+cmd << oendl;
1501 if(Ddir.right(1)!="/") { 1506 if(Ddir.right(1)!="/") {
1502 Ddir+="/"; 1507 Ddir+="/";
1503 } 1508 }
1504 config.writeEntry("DownloadDirectory",Ddir); 1509 config.writeEntry("DownloadDirectory",Ddir);
1505 } 1510 }
1506 } 1511 }
1507 1512
1508// if(optDlg->styleChanged) 1513// if(optDlg->styleChanged)
1509// setStyle( optDlg->styleInt); 1514// setStyle( optDlg->styleInt);
1510 if(optDlg->b_qExit==TRUE) 1515 if(optDlg->b_qExit==TRUE)
1511 b_queryExit=TRUE; 1516 b_queryExit=TRUE;
1512 else 1517 else
1513 b_queryExit=FALSE; 1518 b_queryExit=FALSE;
1514 1519
1515 if(optDlg->fontDlg-> changedFonts) { 1520 if(optDlg->fontDlg-> changedFonts) {
1516 odebug << "Setting font" << oendl; 1521 odebug << "Setting font" << oendl;
1517 myFont=optDlg->fontDlg->selectedFont; 1522 myFont=optDlg->fontDlg->selectedFont;
1518 Lview->setFont( myFont); 1523 Lview->setFont( myFont);
1519 } 1524 }
1520 1525
1521 if(optDlg->useWordWrap_CheckBox->isChecked() ) { 1526 if(optDlg->useWordWrap_CheckBox->isChecked() ) {
1522 odebug << "WORD WRAP is set" << oendl; 1527 odebug << "WORD WRAP is set" << oendl;
1523 Lview->setWordWrap(QMultiLineEdit::WidgetWidth); 1528 Lview->setWordWrap(QMultiLineEdit::WidgetWidth);
1524 useWrap=true; 1529 useWrap=true;
1525 } else { 1530 } else {
1526 odebug << "Word wrap is NOT set" << oendl; 1531 odebug << "Word wrap is NOT set" << oendl;
1527 Lview->setWordWrap(QMultiLineEdit::NoWrap); 1532 Lview->setWordWrap(QMultiLineEdit::NoWrap);
1528 useWrap=false; 1533 useWrap=false;
1529 } 1534 }
1530 } 1535 }
1531 if(showMainList) { 1536 if(showMainList) {
1532 if(!Lview->isHidden()) 1537 if(!Lview->isHidden())
1533 Lview->hide(); 1538 Lview->hide();
1534 qApp->processEvents(); 1539 qApp->processEvents();
1535 if(mainList->isHidden()) 1540 if(mainList->isHidden())
1536 mainList->show(); 1541 mainList->show();
1537 fillWithTitles(); 1542 fillWithTitles();
1538 } else { 1543 } else {
1539 Lview->show(); 1544 Lview->show();
1540 showMainList=FALSE; 1545 showMainList=FALSE;
1541 mainList->hide(); 1546 mainList->hide();
1542 } 1547 }
1543 qApp->processEvents(); 1548 qApp->processEvents();
1544 update(); 1549 update();
1545} 1550}
1546 1551
1547bool Gutenbrowser::setTitle() { 1552bool Gutenbrowser::setTitle() {
1548 if( file_name.contains( local_library)) { 1553 if( file_name.contains( local_library)) {
1549 QFileInfo f( file_name); 1554 QFileInfo f( file_name);
1550 QString s_file = f.fileName(); 1555 QString s_file = f.fileName();
1551 file_name = s_file; 1556 file_name = s_file;
1552 } 1557 }
1553 1558
1554 int test = 0; 1559 int test = 0;
1555 Config config("Gutenbrowser"); 1560 Config config("Gutenbrowser");
1556 config.setGroup( "Files" ); 1561 config.setGroup( "Files" );
1557 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 1562 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
1558 int i_numofFiles = s_numofFiles.toInt(); 1563 int i_numofFiles = s_numofFiles.toInt();
1559 1564
1560 for (int i = 1; i <= i_numofFiles; i++) { 1565 for (int i = 1; i <= i_numofFiles; i++) {
1561 QString temp; 1566 QString temp;
1562 temp.setNum(i); 1567 temp.setNum(i);
1563 QString ramble = config.readEntry(temp, "" ); 1568 QString ramble = config.readEntry(temp, "" );
1564 1569
1565 if( strcmp(ramble, file_name) == 0) { 1570 if( strcmp(ramble, file_name) == 0) {
1566 test = 1; 1571 test = 1;
1567 } 1572 }
1568 } 1573 }
1569 if (test == 0) { 1574 if (test == 0) {
1570 config.writeEntry("NumberOfFiles",i_numofFiles +1 ); 1575 config.writeEntry("NumberOfFiles",i_numofFiles +1 );
1571 QString interger; 1576 QString interger;
1572 interger.setNum( i_numofFiles +1); 1577 interger.setNum( i_numofFiles +1);
1573 config.writeEntry(interger, file_name); 1578 config.writeEntry(interger, file_name);
1574 1579
1575 config.setGroup( "Titles" ); 1580 config.setGroup( "Titles" );
1576 config.writeEntry(file_name,listItemTitle); 1581 config.writeEntry(file_name,listItemTitle);
1577 } 1582 }
1578 test = 0; 1583 test = 0;
1579 // config.write(); 1584 // config.write();
1580 return true; 1585 return true;
1581} 1586}
1582 /*Calls new fangled network dialog */ 1587 /*Calls new fangled network dialog */
1583void Gutenbrowser::OnNetworkDialog( const QString &/*networkUrl*/, const QString &/*output*/) 1588void Gutenbrowser::OnNetworkDialog( const QString &/*networkUrl*/, const QString &/*output*/)
1584{ 1589{
1585 // odebug << networkUrl << oendl; 1590 // odebug << networkUrl << oendl;
1586 // odebug << output << oendl; 1591 // odebug << output << oendl;
1587 // #ifndef Q_WS_QWS 1592 // #ifndef Q_WS_QWS
1588 // NetworkDialog *NetworkDlg; 1593 // NetworkDialog *NetworkDlg;
1589 // if( networkUrl.length() < 4 ) networkUrl= "http://sailor.gutenberg.org/mirror.sites.html"; 1594 // if( networkUrl.length() < 4 ) networkUrl= "http://sailor.gutenberg.org/mirror.sites.html";
1590 // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, output); 1595 // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, output);
1591 // if( NetworkDlg->exec() != 0 ) { 1596 // if( NetworkDlg->exec() != 0 ) {
1592 // } 1597 // }
1593 // if(NetworkDlg) 1598 // if(NetworkDlg)
1594 // delete NetworkDlg; 1599 // delete NetworkDlg;
1595 // #endif 1600 // #endif
1596} 1601}
1597 1602
1598void Gutenbrowser::donateGutenberg() 1603void Gutenbrowser::donateGutenberg()
1599{ 1604{
1600 int exit=QMessageBox::information(this, "Info", "http://www.gutenberg.org\ndonate@gutenberg.net", 1605 int exit=QMessageBox::information(this, "Info", "http://www.gutenberg.org\ndonate@gutenberg.net",
1601 QMessageBox::Ok, QMessageBox::Cancel); 1606 QMessageBox::Ok, QMessageBox::Cancel);
1602 1607
1603 if (exit==1) { 1608 if (exit==1) {
1604 } else { 1609 } else {
1605 }; 1610 };
1606} 1611}
1607 1612
1608void Gutenbrowser::donateByteMonkie() 1613void Gutenbrowser::donateByteMonkie()
1609{ 1614{
1610} 1615}
1611 1616
1612void Gutenbrowser::writeConfig() 1617void Gutenbrowser::writeConfig()
1613{ 1618{
1614 // config.read(); 1619 // config.read();
1615 // Config config("Gutenbrowser"); 1620 // Config config("Gutenbrowser");
1616 // #ifndef Q_WS_QWS 1621 // #ifndef Q_WS_QWS
1617 // config.setGroup( "Geometry" ); 1622 // config.setGroup( "Geometry" );
1618 // QString s; 1623 // QString s;
1619 // QString globalPosition; 1624 // QString globalPosition;
1620 // QPoint point; 1625 // QPoint point;
1621 // point=mapToGlobal(QPoint(0,0) ); 1626 // point=mapToGlobal(QPoint(0,0) );
1622 // int posiX, posiY; 1627 // int posiX, posiY;
1623 // posiX=point.x(); 1628 // posiX=point.x();
1624 // posiY=point.y(); 1629 // posiY=point.y();
1625 // globalPosition.sprintf("%i,%i", posiX, posiY); 1630 // globalPosition.sprintf("%i,%i", posiX, posiY);
1626 1631
1627 // QRect frameRect; 1632 // QRect frameRect;
1628 // frameRect = geometry(); 1633 // frameRect = geometry();
1629 // s.sprintf("%i,%i", frameRect.width(), frameRect.height()); 1634 // s.sprintf("%i,%i", frameRect.width(), frameRect.height());
1630 // config.writeEntry("Frame", s); 1635 // config.writeEntry("Frame", s);
1631 // config.writeEntry("Position", globalPosition); 1636 // config.writeEntry("Position", globalPosition);
1632 1637
1633 // if( useIcons==TRUE) 1638 // if( useIcons==TRUE)
1634 // config.writeEntry("Icons", "TRUE"); 1639 // config.writeEntry("Icons", "TRUE");
1635 // else 1640 // else
1636 // config.writeEntry("Icons", "FALSE"); 1641 // config.writeEntry("Icons", "FALSE");
1637 // #endif 1642 // #endif
1638 1643
1639 // #ifndef Q_WS_QWS 1644 // #ifndef Q_WS_QWS
1640 // QString temp; 1645 // QString temp;
1641 // temp.setNum(styleI, 10); 1646 // temp.setNum(styleI, 10);
1642 // config.setGroup( "StyleIze" ); 1647 // config.setGroup( "StyleIze" );
1643 // config.writeEntry( "Style", temp); 1648 // config.writeEntry( "Style", temp);
1644 // #endif 1649 // #endif
1645 1650
1646 // config.setGroup("General"); 1651 // config.setGroup("General");
1647} 1652}
1648 1653
1649void Gutenbrowser::annotations() 1654void Gutenbrowser::annotations()
1650{ 1655{
1651 // #ifndef Q_WS_QWS 1656 // #ifndef Q_WS_QWS
1652 // QMessageBox::message("Note","hi annotate"); 1657 // QMessageBox::message("Note","hi annotate");
1653 // lastBmkButton->setDown(FALSE); 1658 // lastBmkButton->setDown(FALSE);
1654 // #endif 1659 // #endif
1655} 1660}
1656 1661
1657void Gutenbrowser::hideButtons() 1662void Gutenbrowser::hideButtons()
1658{ 1663{
1659 1664
1660 if( !buttonsHidden) { 1665 if( !buttonsHidden) {
1661 buttonsHidden=TRUE; 1666 buttonsHidden=TRUE;
1662 LibraryButton->hide(); 1667 LibraryButton->hide();
1663 SearchButton->hide(); 1668 SearchButton->hide();
1664 InfoBar->hide(); 1669 InfoBar->hide();
1665 OpenButton->hide(); 1670 OpenButton->hide();
1666 BackButton->hide(); 1671 BackButton->hide();
1667 ForwardButton->hide(); 1672 ForwardButton->hide();
1668 setBookmarkButton->hide(); 1673 setBookmarkButton->hide();
1669 lastBmkButton->hide(); 1674 lastBmkButton->hide();
1670 dictionaryButton->hide(); 1675 dictionaryButton->hide();
1671 if(useSplitter) { 1676 if(useSplitter) {
1672 ClearButton->hide(); 1677 ClearButton->hide();
1673 PrintButton->hide(); 1678 PrintButton->hide();
1674 beginButton->hide(); 1679 beginButton->hide();
1675 HelpButton->hide(); 1680 HelpButton->hide();
1676 FontButton->hide(); 1681 FontButton->hide();
1677 ExitButton->hide(); 1682 ExitButton->hide();
1678 OptionsButton->hide(); 1683 OptionsButton->hide();
1679 DownloadButton->hide(); 1684 DownloadButton->hide();
1680 } 1685 }
1681 } else { 1686 } else {
1682 buttonsHidden=FALSE; 1687 buttonsHidden=FALSE;
1683 1688
1684 LibraryButton->show(); 1689 LibraryButton->show();
1685 SearchButton->show(); 1690 SearchButton->show();
1686 InfoBar->show(); 1691 InfoBar->show();
1687 OpenButton->show(); 1692 OpenButton->show();
1688 BackButton->show(); 1693 BackButton->show();
1689 ForwardButton->show(); 1694 ForwardButton->show();
1690 setBookmarkButton->show(); 1695 setBookmarkButton->show();
1691 lastBmkButton->show(); 1696 lastBmkButton->show();
1692 dictionaryButton->show(); 1697 dictionaryButton->show();
1693 if(useSplitter) { 1698 if(useSplitter) {
1694 ClearButton->show(); 1699 ClearButton->show();
1695 PrintButton->show(); 1700 PrintButton->show();
1696 beginButton->show(); 1701 beginButton->show();
1697 HelpButton->show(); 1702 HelpButton->show();
1698 FontButton->show(); 1703 FontButton->show();
1699 ExitButton->show(); 1704 ExitButton->show();
1700 OptionsButton->show(); 1705 OptionsButton->show();
1701 DownloadButton->show(); 1706 DownloadButton->show();
1702 } 1707 }
1703 } 1708 }
1704} 1709}
1705 1710
1706void Gutenbrowser::focusInEvent( QFocusEvent* ) 1711void Gutenbrowser::focusInEvent( QFocusEvent* )
1707{ 1712{
1708} 1713}
1709void Gutenbrowser::focusOutEvent( QFocusEvent* ) 1714void Gutenbrowser::focusOutEvent( QFocusEvent* )
1710{ 1715{
1711} 1716}
1712 1717
1713void Gutenbrowser::cleanUp( ) 1718void Gutenbrowser::cleanUp( )
1714{ 1719{
1715 writeConfig(); 1720 writeConfig();
1716 QPEApplication::grabKeyboard(); 1721 QPEApplication::grabKeyboard();
1717 1722
1718 QPEApplication::ungrabKeyboard(); 1723 QPEApplication::ungrabKeyboard();
1719 // odebug << "Cleanup" << oendl; 1724 // odebug << "Cleanup" << oendl;
1720 if(f.isOpen()) f.close(); 1725 if(f.isOpen()) f.close();
1721} 1726}
1722 1727
1723void Gutenbrowser::fixKeys() 1728void Gutenbrowser::fixKeys()
1724{ 1729{
1725 odebug << "Attempting to fix keys" << oendl; 1730 odebug << "Attempting to fix keys" << oendl;
1726 1731
1727} 1732}
1728 1733
1729void Gutenbrowser::enableButtons(bool b) 1734void Gutenbrowser::enableButtons(bool b)
1730{ 1735{
1731 BackButton->setEnabled(b); 1736 BackButton->setEnabled(b);
1732 ForwardButton->setEnabled(b); 1737 ForwardButton->setEnabled(b);
1733 SearchButton->setEnabled(b); 1738 SearchButton->setEnabled(b);
1734 setBookmarkButton->setEnabled(b); 1739 setBookmarkButton->setEnabled(b);
1735 dictionaryButton->setEnabled(b); 1740 dictionaryButton->setEnabled(b);
1736 InfoBar->setEnabled(b); 1741 InfoBar->setEnabled(b);
1737 1742
1738 editMenu->setItemEnabled( -5, b); 1743 editMenu->setItemEnabled( -5, b);
1739 editMenu->setItemEnabled( -6, b); 1744 editMenu->setItemEnabled( -6, b);
1740 editMenu->setItemEnabled( -7, b); 1745 editMenu->setItemEnabled( -7, b);
1741 editMenu->setItemEnabled( -8, b); 1746 editMenu->setItemEnabled( -8, b);
1742 1747
1743} 1748}
1744 1749
1745void Gutenbrowser::fillWithTitles() { 1750void Gutenbrowser::fillWithTitles() {
1746 Config config("Gutenbrowser"); 1751 Config config("Gutenbrowser");
1747 config.setGroup( "Files" ); 1752 config.setGroup( "Files" );
1748 int i_numofFiles = config.readNumEntry("NumberOfFiles", 0); 1753 int i_numofFiles = config.readNumEntry("NumberOfFiles", 0);
1749 mainList->clear(); 1754 mainList->clear();
1750 QString temp; 1755 QString temp;
1751 for (int i = 1; i <= i_numofFiles; i++) { 1756 for (int i = 1; i <= i_numofFiles; i++) {
1752 temp.setNum(i); 1757 temp.setNum(i);
1753 config.setGroup( "Files" ); 1758 config.setGroup( "Files" );
1754 QString ramble = config.readEntry(temp, "" ); 1759 QString ramble = config.readEntry(temp, "" );
1755 config.setGroup( "Titles" ); 1760 config.setGroup( "Titles" );
1756 temp = config.readEntry(ramble, ""); 1761 temp = config.readEntry(ramble, "");
1757 if( !temp.isEmpty()) { 1762 if( !temp.isEmpty()) {
1758 mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), temp, -1); 1763 mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), temp, -1);
1759 } 1764 }
1760 } 1765 }
1761} 1766}
1762 1767
1763void Gutenbrowser::listClickedSlot( QListBoxItem * index) { 1768void Gutenbrowser::listClickedSlot( QListBoxItem * index) {
1764 // if( !working) { 1769 // if( !working) {
1765 // working=true; 1770 // working=true;
1766 if(index) { 1771 if(index) {
1767 // QCopEnvelope ( "QPE/System", "busy()" ); 1772 // QCopEnvelope ( "QPE/System", "busy()" );
1768 title = index->text(); 1773 title = index->text();
1769 showMainList=FALSE; 1774 showMainList=FALSE;
1770 mainList->hide(); 1775 mainList->hide();
1771 Lview->show(); 1776 Lview->show();
1772 qApp->processEvents(); 1777 qApp->processEvents();
1773 QString temp; 1778 QString temp;
1774 temp.setNum( mainList->currentItem() + 1); 1779 temp.setNum( mainList->currentItem() + 1);
1775 // openFileTitle = title; 1780 // openFileTitle = title;
1776 Config config("Gutenbrowser"); 1781 Config config("Gutenbrowser");
1777 config.setGroup( "Files" ); 1782 config.setGroup( "Files" );
1778 QString file = config.readEntry(temp, ""); 1783 QString file = config.readEntry(temp, "");
1779 odebug << "About to load" << oendl; 1784 odebug << "About to load" << oendl;
1780 if( Lview->isVisible()) 1785 if( Lview->isVisible())
1781 load(file); 1786 if(!load(file)) return;
1782 1787
1783 config.setGroup( title); 1788 config.setGroup( title);
1784 file_name = config.readEntry("File Name", ""); 1789 file_name = config.readEntry("File Name", "");
1785 i_pageNum = config.readNumEntry("Page Number", 1); 1790 i_pageNum = config.readNumEntry("Page Number", 1);
1786 int Bmrkrow = config.readNumEntry("LineNumber", -1); 1791 int Bmrkrow = config.readNumEntry("LineNumber", -1);
1787 if(Bmrkrow > -1) { 1792 if(Bmrkrow > -1) {
1788 if( Bmrkrow > Lview->topRow() ) { 1793 if( Bmrkrow > Lview->topRow() ) {
1789// Lview->setCursorPosition( Bmrkrow /* - Lview->topRow() */,0, FALSE ); 1794// Lview->setCursorPosition( Bmrkrow /* - Lview->topRow() */,0, FALSE );
1790 Lview->ScrollUp( Bmrkrow - Lview->topRow() ); 1795 Lview->ScrollUp( Bmrkrow - Lview->topRow() );
1791 // AdjustStatus(); 1796 // AdjustStatus();
1792 } 1797 }
1793 else if( Bmrkrow < Lview->topRow() ) { 1798 else if( Bmrkrow < Lview->topRow() ) {
1794// Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE ); 1799// Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE );
1795 Lview->ScrollDown( Lview->topRow() - Bmrkrow ); 1800 Lview->ScrollDown( Lview->topRow() - Bmrkrow );
1796 // AdjustStatus(); 1801 // AdjustStatus();
1797 } 1802 }
1798 } 1803 }
1799 } 1804 }
1800} 1805}
1801 1806
1802void Gutenbrowser::infoGutenbrowser() { 1807void Gutenbrowser::infoGutenbrowser() {
1803 QMessageBox::message("Info","Gutenbrowser was developed by\n" 1808 QMessageBox::message("Info","Gutenbrowser was developed by\n"
1804 "Lorn Potter\n" 1809 "Lorn Potter\n"
1805 "ljp<ljp@llornkcor.com>\n"); 1810 "ljp<ljp@llornkcor.com>\n");
1806} 1811}
1807 1812
1808void Gutenbrowser::setDocument(const QString & frozenBoogers) { 1813void Gutenbrowser::setDocument(const QString & frozenBoogers) {
1809 this->hide(); 1814 // this->hide();
1810 if(showMainList) { 1815 qWarning("\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXSET DOCUMENT\n");
1811 showMainList=FALSE; 1816 if(showMainList) {
1812 if(!mainList->isHidden()) 1817 showMainList=FALSE;
1813 mainList->hide(); 1818 if(!mainList->isHidden())
1814 if(Lview->isHidden()) 1819 mainList->hide();
1815 Lview->show(); 1820 if(Lview->isHidden())
1816 qApp->processEvents(); 1821 Lview->show();
1817 } 1822 qApp->processEvents();
1818 DocLnk lnk; 1823 }
1819 lnk = DocLnk(frozenBoogers); 1824 DocLnk lnk;
1820 // odebug << lnk.file() << oendl; 1825 lnk = DocLnk(frozenBoogers);
1821 title=lnk.comment(); 1826 qWarning("open "+frozenBoogers);
1822 load( lnk.file()); 1827 // odebug << lnk.file() << oendl;
1823 this->show(); 1828 title=lnk.comment();
1824 // odebug << title << oendl; 1829 if(!load( lnk.file())) return;
1825 // qApp->processEvents(); 1830 this->show();
1826 // repaint(); 1831 // odebug << title << oendl;
1832 // qApp->processEvents();
1833 // repaint();
1827} 1834}
1828 1835
1829void Gutenbrowser::mainListPressed(int mouse, QListBoxItem * , const QPoint & ) 1836void Gutenbrowser::mainListPressed(int mouse, QListBoxItem * , const QPoint & )
1830{ 1837{
1831 switch (mouse) { 1838 switch (mouse) {
1832 case 1: 1839 case 1:
1833 break; 1840 break;
1834 case 2: { 1841 case 2: {
1835 QPopupMenu m;// = new QPopupMenu( Local_View ); 1842 QPopupMenu m;// = new QPopupMenu( Local_View );
1836 m.insertItem( tr( "Open" ), this, SLOT( menuOpen() )); 1843 m.insertItem( tr( "Open" ), this, SLOT( menuOpen() ));
1837 m.insertSeparator(); 1844 m.insertSeparator();
1838 m.insertItem( tr( "Search google.com" ), this, SLOT( menuGoogle())); 1845 m.insertItem( tr( "Search google.com" ), this, SLOT( menuGoogle()));
1839 m.insertItem( tr( "Edit Title" ), this, SLOT( menuEditTitle())); 1846 m.insertItem( tr( "Edit Title" ), this, SLOT( menuEditTitle()));
1840 // m.insertSeparator(); 1847 // m.insertSeparator();
1841 // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 1848 // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
1842 m.exec( QCursor::pos() ); 1849 m.exec( QCursor::pos() );
1843 } 1850 }
1844 break; 1851 break;
1845 }; 1852 };
1846} 1853}
1847 1854
1848void Gutenbrowser::menuOpen() { 1855void Gutenbrowser::menuOpen() {
1849 listClickedSlot( mainList->item( mainList->currentItem())); 1856 listClickedSlot( mainList->item( mainList->currentItem()));
1850} 1857}
1851 1858
1852void Gutenbrowser::menuGoogle() { 1859void Gutenbrowser::menuGoogle() {
1853 searchGoogle( mainList->text(mainList->currentItem())); 1860 searchGoogle( mainList->text(mainList->currentItem()));
1854} 1861}
1855 1862
1856void Gutenbrowser::searchGoogle( const QString &tempText) { 1863void Gutenbrowser::searchGoogle( const QString &tempText) {
1857 QString text = tempText; 1864 QString text = tempText;
1858 1865
1859 int eexit=QMessageBox::information(this, "Note","Do you want to search for\n"+text+ 1866 int eexit=QMessageBox::information(this, "Note","Do you want to search for\n"+text+
1860 "\non google.com?",QMessageBox::Yes, QMessageBox::No); 1867 "\non google.com?",QMessageBox::Yes, QMessageBox::No);
1861 if (eexit== 3) { 1868 if (eexit== 3) {
1862 qApp->processEvents(); 1869 qApp->processEvents();
1863 text.replace( QRegExp("\\s"), "%20"); 1870 text.replace( QRegExp("\\s"), "%20");
1864 text.replace( QRegExp("#"), ""); 1871 text.replace( QRegExp("#"), "");
1865 text.replace( QRegExp(","), "%20"); 1872 text.replace( QRegExp(","), "%20");
1866 text.replace( QRegExp("'"), "%20"); 1873 text.replace( QRegExp("'"), "%20");
1867 text.replace( QRegExp("("), ""); 1874 text.replace( QRegExp("("), "");
1868 text.replace( QRegExp(")"), ""); 1875 text.replace( QRegExp(")"), "");
1869 // text.replace( QRegExp("[0-9]"), ""); 1876 // text.replace( QRegExp("[0-9]"), "");
1870 QString s_lookup = "http://google.com/search?q="+text+"&num=30&sa=Google+Search"; 1877 QString s_lookup = "http://google.com/search?q="+text+"&num=30&sa=Google+Search";
1871 goGetit( s_lookup, true); 1878 goGetit( s_lookup, true);
1872 } 1879 }
1873 1880
1874} 1881}
1875 1882
1876void Gutenbrowser::menuEditTitle() 1883void Gutenbrowser::menuEditTitle()
1877{ 1884{
1878 int currentItem = mainList->currentItem(); 1885 int currentItem = mainList->currentItem();
1879 QString title_text = mainList->text( currentItem); 1886 QString title_text = mainList->text( currentItem);
1880 //odebug << "Selected "+title_text << oendl; 1887 //odebug << "Selected "+title_text << oendl;
1881 1888
1882 Config config("Gutenbrowser"); 1889 Config config("Gutenbrowser");
1883 config.setGroup( "Files" ); 1890 config.setGroup( "Files" );
1884 QString s_numofFiles = config.readEntry("NumberOfFiles", "0"); 1891 QString s_numofFiles = config.readEntry("NumberOfFiles", "0");
1885 int i_numofFiles = s_numofFiles.toInt(); 1892 int i_numofFiles = s_numofFiles.toInt();
1886 QString fileNum; 1893 QString fileNum;
1887 for (int i = 1; i <= i_numofFiles+1; i++) { 1894 for (int i = 1; i <= i_numofFiles+1; i++) {
1888 1895
1889 fileNum.setNum(i); 1896 fileNum.setNum(i);
1890 config.setGroup( "Files" ); 1897 config.setGroup( "Files" );
1891 QString s_filename = config.readEntry(fileNum, "" ); 1898 QString s_filename = config.readEntry(fileNum, "" );
1892 config.setGroup( "Titles" ); 1899 config.setGroup( "Titles" );
1893 QString file_title = config.readEntry( s_filename, ""); 1900 QString file_title = config.readEntry( s_filename, "");
1894 //odebug << "file_title is "+file_title << oendl; 1901 //odebug << "file_title is "+file_title << oendl;
1895 if(title_text == file_title ) { 1902 if(title_text == file_title ) {
1896 // selFile = s_filename; 1903 // selFile = s_filename;
1897 //odebug << "Edit: "+ file_title << oendl; 1904 //odebug << "Edit: "+ file_title << oendl;
1898 i=i_numofFiles+1; 1905 i=i_numofFiles+1;
1899 Edit_Title *titleEdit; 1906 Edit_Title *titleEdit;
1900 titleEdit = new Edit_Title(this,file_title ,TRUE); 1907 titleEdit = new Edit_Title(this,file_title ,TRUE);
1901 if(titleEdit->exec() !=0) { 1908 if(titleEdit->exec() !=0) {
1902 //odebug << titleEdit->newTitle << oendl; 1909 //odebug << titleEdit->newTitle << oendl;
1903 config.writeEntry( s_filename, titleEdit->newTitle); 1910 config.writeEntry( s_filename, titleEdit->newTitle);
1904 mainList->removeItem(currentItem); 1911 mainList->removeItem(currentItem);
1905 mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), titleEdit->newTitle, currentItem); 1912 mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), titleEdit->newTitle, currentItem);
1906 } 1913 }
1907 } 1914 }
1908 } 1915 }
1909 1916
1910 // getTitles(); 1917 // getTitles();
1911 mainList->triggerUpdate(true); 1918 mainList->triggerUpdate(true);
1912 1919
1913} 1920}
1914 1921
1915 1922
1916 1923
1917bool Gutenbrowser::UnZipIt(const QString &zipFile) { 1924bool Gutenbrowser::UnZipIt(const QString &zipFile) {
1918 odebug << zipFile << oendl; 1925 odebug << zipFile << oendl;
1919#ifndef Q_WS_QWS 1926#ifndef Q_WS_QWS
1920 if( QFile::exists( zipFile)) { // TODO findsome other way of dealingwithzip files. 1927 if( QFile::exists( zipFile)) { // TODO findsome other way of dealingwithzip files.
1921 bool isPgWhole=false; 1928 bool isPgWhole=false;
1922 QString thatFile; 1929 QString thatFile;
1923 if(zipFile.find("pgwhole",0,TRUE)) { 1930 if(zipFile.find("pgwhole",0,TRUE)) {
1924 isPgWhole=TRUE; 1931 isPgWhole=TRUE;
1925 thatFile= local_library +"PGWHOLE.TXT"; 1932 thatFile= local_library +"PGWHOLE.TXT";
1926 } 1933 }
1927 // else { 1934 // else {
1928 // thatFile=zipFile.left(4); 1935 // thatFile=zipFile.left(4);
1929 // } 1936 // }
1930 // odebug << (const char*)local_library.latin1() << oendl; 1937 // odebug << (const char*)local_library.latin1() << oendl;
1931 QString cmd; 1938 QString cmd;
1932#if defined(_WS_X11_) 1939#if defined(_WS_X11_)
1933 if( chdir((const char*)local_library.latin1())!=0) 1940 if( chdir((const char*)local_library.latin1())!=0)
1934 odebug << "chdir failed." << oendl; 1941 odebug << "chdir failed." << oendl;
1935 cmd = "gunzip -S .zip " + local_library+zipFile; 1942 cmd = "gunzip -S .zip " + local_library+zipFile;
1936 //cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; 1943 //cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library;
1937#endif 1944#endif
1938#ifdef Q_WS_QWS 1945#ifdef Q_WS_QWS
1939 if( chdir((const char*)local_library.latin1())!=0) 1946 if( chdir((const char*)local_library.latin1())!=0)
1940 odebug << "chdir failed." << oendl; 1947 odebug << "chdir failed." << oendl;
1941 cmd = "unzip " + local_library+zipFile; 1948 cmd = "unzip " + local_library+zipFile;
1942 // cmd = "/usr/bin/unzip -o " + local_library+zipFile +" -d /usr/share/doc/gutenbrowser" ;//+ local_library; 1949 // cmd = "/usr/bin/unzip -o " + local_library+zipFile +" -d /usr/share/doc/gutenbrowser" ;//+ local_library;
1943#endif 1950#endif
1944 int exit=QMessageBox::information(this, "Ok to unzip?", 1951 int exit=QMessageBox::information(this, "Ok to unzip?",
1945 "Ok to unnzip\n"+ zipFile+" ?", 1952 "Ok to unnzip\n"+ zipFile+" ?",
1946 QMessageBox::Yes, QMessageBox::No); 1953 QMessageBox::Yes, QMessageBox::No);
1947 if (exit==QMessageBox::Yes) { 1954 if (exit==QMessageBox::Yes) {
1948#if defined(_WS_X11_)// 1955#if defined(_WS_X11_)//
1949 odebug << "Issuing the command "+cmd << oendl; 1956 odebug << "Issuing the command "+cmd << oendl;
1950 system( cmd); 1957 system( cmd);
1951 if( QFile::exists(thatFile)) 1958 if( QFile::exists(thatFile))
1952 remove (thatFile); 1959 remove (thatFile);
1953 if(isPgWhole) { 1960 if(isPgWhole) {
1954 if( rename("pgwhole","PGWHOLE.TXT") !=0) 1961 if( rename("pgwhole","PGWHOLE.TXT") !=0)
1955 odebug << "rename failed" << oendl; 1962 odebug << "rename failed" << oendl;
1956 } else { 1963 } else {
1957 if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) 1964 if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0)
1958 odebug << "rename failed" << oendl; 1965 odebug << "rename failed" << oendl;
1959 } 1966 }
1960#endif 1967#endif
1961#ifdef Q_WS_QWS 1968#ifdef Q_WS_QWS
1962 odebug << "Issuing the command "+cmd << oendl; 1969 odebug << "Issuing the command "+cmd << oendl;
1963 system( cmd); 1970 system( cmd);
1964 if( QFile::exists(thatFile)) 1971 if( QFile::exists(thatFile))
1965 remove(thatFile); 1972 remove(thatFile);
1966 if(isPgWhole) { 1973 if(isPgWhole) {
1967 if( rename("pgwhole","PGWHOLE.TXT") !=0) 1974 if( rename("pgwhole","PGWHOLE.TXT") !=0)
1968 odebug << "rename failed" << oendl; 1975 odebug << "rename failed" << oendl;
1969 } else { 1976 } else {
1970 if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) 1977 if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0)
1971 odebug << "rename failed" << oendl; 1978 odebug << "rename failed" << oendl;
1972 } 1979 }
1973#endif 1980#endif
1974 // remove( zipFile); 1981 // remove( zipFile);
1975 return true; 1982 return true;
1976 } 1983 }
1977 else if(exit==QMessageBox::No) { 1984 else if(exit==QMessageBox::No) {
1978 // odebug << "unzip" << oendl; 1985 // odebug << "unzip" << oendl;
1979 return false; 1986 return false;
1980 } 1987 }
1981 } 1988 }
1982 else 1989 else
1983 QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); 1990 QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) );
1984#endif 1991#endif
1985 return false; 1992 return false;
1986} 1993}
1987 1994
1988 1995
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.h b/noncore/apps/opie-gutenbrowser/gutenbrowser.h
index acb6e59..2958f01 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.h
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.h
@@ -159,12 +159,13 @@ protected:
159 bool showMainList; 159 bool showMainList;
160 bool useIcons; 160 bool useIcons;
161 bool working; 161 bool working;
162 162
163 163
164protected slots: 164protected slots:
165 void hideView();
165 166
166 void BackBtn(); 167 void BackBtn();
167 void Bookmark( int); 168 void Bookmark( int);
168 void ByeBye(); 169 void ByeBye();
169 void ChangeFont(); 170 void ChangeFont();
170 void ClearEdit(); 171 void ClearEdit();
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp
index 9473ba9..c93dbc5 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp
@@ -310,22 +310,29 @@ void Gutenbrowser::initView()
310 useWrap=true; 310 useWrap=true;
311 } else { 311 } else {
312 Lview->setWordWrap(QMultiLineEdit::NoWrap); 312 Lview->setWordWrap(QMultiLineEdit::NoWrap);
313 useWrap = false; 313 useWrap = false;
314 } 314 }
315 mainList = new QListBox(this,"mainlist"); 315 mainList = new QListBox(this,"mainlist");
316 316 mainList->hide();
317// QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); 317// QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold);
318 // mainList->showMaximized(); 318 // mainList->showMaximized();
319// mainList->setGeometry(2,30,230,160); 319// mainList->setGeometry(2,30,230,160);
320 Lview->setReadOnly( true); 320 Lview->setReadOnly( true);
321 edits->addWidget( Lview); 321 edits->addWidget( Lview);
322 edits->addWidget(mainList); 322 edits->addWidget(mainList);
323 323
324 if(!showMainList) { 324// if(!showMainList) {
325 Lview->setText( "\nThis is gutenbrowser for the Sharp Zaurus.\nMake your self at home, sit back, relax and read something great. "); 325// Lview->setText( "\nThis is gutenbrowser for the Sharp Zaurus.\nMake your self at home, sit back, relax and read something great. ");
326 } else 326// }
327 Lview->hide(); 327 // else
328// Lview->hide();
328 329
329 topLayout->addLayout( edits, 0); 330 topLayout->addLayout( edits, 0);
330 qDebug("end initView"); 331 qDebug("end initView");
331} 332}
333
334void Gutenbrowser::hideView() {
335 // qWarning("Hide View");
336 mainList->show();
337 Lview->hide();
338}