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