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