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