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