-rw-r--r-- | noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | 27 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | 17 |
2 files changed, 31 insertions, 13 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp index 7426e80..549c1d2 100644 --- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | |||
@@ -94,187 +94,199 @@ LibraryDialog::~LibraryDialog() | |||
94 | { | 94 | { |
95 | // delete QList_Item2; | 95 | // delete QList_Item2; |
96 | // delete QList_Item1; | 96 | // delete QList_Item1; |
97 | // delete QList_Item3; | 97 | // delete QList_Item3; |
98 | // delete QList_Item4; | 98 | // delete QList_Item4; |
99 | // delete QList_Item5; | 99 | // delete QList_Item5; |
100 | 100 | ||
101 | // saveConfig(); | 101 | // saveConfig(); |
102 | } | 102 | } |
103 | 103 | ||
104 | /*This groks using PGWHOLE.TXT */ | 104 | /*This groks using PGWHOLE.TXT */ |
105 | void LibraryDialog::Newlibrary() | 105 | void LibraryDialog::Newlibrary() |
106 | { | 106 | { |
107 | #ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files | 107 | #ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files |
108 | //odebug << "Opening new library index " << newindexLib << "" << oendl; | 108 | //odebug << "Opening new library index " << newindexLib << "" << oendl; |
109 | if ( newindexLib.open( IO_ReadOnly) ) { | 109 | if ( newindexLib.open( IO_ReadOnly) ) { |
110 | setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully | 110 | setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully |
111 | QTextStream indexStream( &newindexLib ); | 111 | QTextStream indexStream( &newindexLib ); |
112 | QString indexLine; | 112 | QString indexLine; |
113 | while ( !indexStream.atEnd() ) { // until end of file.. | 113 | while ( !indexStream.atEnd() ) { // until end of file.. |
114 | indexLine = indexStream.readLine(); | 114 | indexLine = indexStream.readLine(); |
115 | if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { | 115 | if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { |
116 | year = indexLine.mid(4,4); | 116 | year = indexLine.mid(4,4); |
117 | year = year.stripWhiteSpace(); | 117 | year = year.stripWhiteSpace(); |
118 | file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); | 118 | file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); |
119 | file = file.stripWhiteSpace(); | 119 | file = file.stripWhiteSpace(); |
120 | number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); | 120 | number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); |
121 | if( year.toInt() < 1984) | 121 | if( year.toInt() < 1984) |
122 | number = number.left( number.length() -1 ); | 122 | number = number.left( number.length() -1 ); |
123 | number = number.stripWhiteSpace(); | 123 | number = number.stripWhiteSpace(); |
124 | title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); | 124 | title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); |
125 | title = title.stripWhiteSpace(); | 125 | title = title.stripWhiteSpace(); |
126 | 126 | ||
127 | getAuthor(); // groks author | 127 | getAuthor(); // groks author |
128 | author = author.stripWhiteSpace(); | 128 | author = author.stripWhiteSpace(); |
129 | if (authBox->isChecked()) { // this reverses the first name and last name of the author | 129 | if (authBox->isChecked()) { // this reverses the first name and last name of the author |
130 | // odebug << "Sorting last name first" << oendl; | 130 | // odebug << "Sorting last name first" << oendl; |
131 | QString lastName, firstName=""; | 131 | QString lastName, firstName=""; |
132 | int finder=author.findRev( ' ', -1, TRUE); | 132 | int finder=author.findRev( ' ', -1, TRUE); |
133 | lastName=author.right( author.length()-finder); | 133 | lastName=author.right( author.length()-finder); |
134 | firstName=author.left(finder); | 134 | firstName=author.left(finder); |
135 | lastName=lastName.stripWhiteSpace(); | 135 | lastName=lastName.stripWhiteSpace(); |
136 | firstName=firstName.stripWhiteSpace(); | 136 | firstName=firstName.stripWhiteSpace(); |
137 | 137 | ||
138 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names | 138 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names |
139 | author=lastName+", "+firstName; | 139 | author=lastName+", "+firstName; |
140 | } | 140 | } |
141 | 141 | ||
142 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) { | 142 | if( !number.isEmpty() |
143 | && (title.find( "reserved",0, FALSE) == -1) | ||
144 | && (file.find( "]",0, TRUE) == -1) | ||
145 | && (title.find( "Audio",0, FALSE) == -1)) { | ||
143 | 146 | ||
144 | // fill string list or something to be able to resort the whole library | 147 | // fill string list or something to be able to resort the whole library |
145 | if( author.isEmpty() ) | 148 | if( author.isEmpty() ) |
146 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); | 149 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); |
147 | else { | 150 | else { |
148 | 151 | ||
149 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || | 152 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || |
150 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) | 153 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) |
151 | QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); | 154 | QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); |
152 | 155 | ||
153 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || | 156 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || |
154 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) | 157 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) |
155 | QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file ); | 158 | QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file ); |
156 | 159 | ||
157 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || | 160 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || |
158 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) | 161 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) |
159 | QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file ); | 162 | QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file ); |
160 | 163 | ||
161 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || | 164 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || |
162 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) | 165 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) |
163 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); | 166 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); |
164 | 167 | ||
165 | else | 168 | else |
166 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); | 169 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); |
167 | } | 170 | } |
168 | } | 171 | } |
169 | }// end if | 172 | }// end if |
170 | }// end while | 173 | }// end while |
171 | newindexLib.close(); | 174 | newindexLib.close(); |
172 | } | 175 | } |
173 | #ifndef Q_WS_QWS | 176 | #ifndef Q_WS_QWS |
174 | setCursor( arrowCursor); | 177 | setCursor( arrowCursor); |
175 | #endif | 178 | #endif |
176 | #endif | 179 | #endif |
177 | } // end Newlibrary() | 180 | } // end Newlibrary() |
178 | 181 | ||
179 | 182 | ||
180 | void LibraryDialog::Library() | 183 | void LibraryDialog::Library() |
181 | {// old library groking method | 184 | {// old library groking method |
182 | 185 | ||
183 | ListView1->clear(); | 186 | ListView1->clear(); |
184 | ListView2->clear(); | 187 | ListView2->clear(); |
185 | ListView3->clear(); | 188 | ListView3->clear(); |
186 | ListView4->clear(); | 189 | ListView4->clear(); |
187 | ListView5->clear(); | 190 | ListView5->clear(); |
188 | 191 | ||
189 | odebug << "opening GUTINDEX.ALL file" << oendl; | 192 | odebug << "opening GUTINDEX.ALL file" << oendl; |
190 | IDontKnowWhy = ""; | 193 | IDontKnowWhy = ""; |
191 | if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully | 194 | if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully |
192 | QTextStream indexStream( &indexLib ); | 195 | QTextStream indexStream( &indexLib ); |
193 | QString indexLine; | 196 | QString indexLine; |
194 | qApp->processEvents(); | 197 | qApp->processEvents(); |
195 | // int jig; | 198 | // int jig; |
196 | while ( !indexStream.eof() ) { | 199 | while ( !indexStream.eof() ) { |
197 | 200 | ||
198 | indexLine = indexStream.readLine(); | 201 | indexLine = indexStream.readLine(); |
199 | if ( indexLine != "") { | 202 | if ( indexLine != "") { |
200 | if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) { | 203 | if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) { |
201 | // month = indexLine.left( 3); | 204 | // month = indexLine.left( 3); |
202 | year = indexLine.mid(4,4); | 205 | year = indexLine.mid(4,4); |
203 | // title = indexLine.mid( 9, 50); | 206 | // title = indexLine.mid( 9, 50); |
204 | file = indexLine.mid(60,12); | 207 | file = indexLine.mid(60,12); |
205 | if(file.left(1).find("[",0,TRUE) != -1) | 208 | if(file.left(1).find("[",0,TRUE) != -1) |
206 | file.remove(1,1); | 209 | file.remove(1,1); |
207 | if( file.find("]",0,TRUE) != -1) | 210 | if( file.find("]",0,TRUE) != -1) |
208 | file = file.left( file.find("]",0,TRUE)); | 211 | file = file.left( file.find("]",0,TRUE)); |
209 | //odebug << "file is "+file << oendl; | 212 | |
210 | /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); | 213 | |
214 | if(file.find("?", 0, false) != -1 ) { | ||
215 | QString tmpfile = file.replace(QRegExp("[?]"), "8"); | ||
216 | // qDebug( "file is now " + tmpfile ); | ||
217 | file = tmpfile; | ||
218 | } | ||
219 | |||
220 | // number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); | ||
211 | number = indexLine.mid(55,5); | 221 | number = indexLine.mid(55,5); |
212 | number = number.stripWhiteSpace(); | 222 | number = number.stripWhiteSpace(); |
213 | // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); | 223 | // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); |
214 | title = indexLine.mid( 9, 50 ); | 224 | title = indexLine.mid( 9, 50 ); |
215 | title = title.stripWhiteSpace(); | 225 | title = title.stripWhiteSpace(); |
216 | //odebug << "title is "+title << oendl; | 226 | //odebug << "title is "+title << oendl; |
217 | getAuthor(); // grok author | 227 | getAuthor(); // grok author |
218 | author = author.stripWhiteSpace(); | 228 | author = author.stripWhiteSpace(); |
219 | //odebug << "author is "+author << oendl; | 229 | //odebug << "author is "+author << oendl; |
220 | if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author | 230 | if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author |
221 | QString lastName, firstName=""; | 231 | QString lastName, firstName=""; |
222 | int finder=author.findRev( ' ', -1, TRUE); | 232 | int finder=author.findRev( ' ', -1, TRUE); |
223 | lastName=author.right( author.length()-finder); | 233 | lastName=author.right( author.length()-finder); |
224 | firstName=author.left(finder); | 234 | firstName=author.left(finder); |
225 | lastName=lastName.stripWhiteSpace(); | 235 | lastName=lastName.stripWhiteSpace(); |
226 | firstName=firstName.stripWhiteSpace(); | 236 | firstName=firstName.stripWhiteSpace(); |
227 | 237 | ||
228 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names | 238 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names |
229 | author=lastName+", "+firstName; | 239 | author=lastName+", "+firstName; |
230 | } | 240 | } |
231 | 241 | ||
232 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) /*&& (file.find( "]",0, TRUE))*/ ) { | 242 | if( !number.isEmpty() |
243 | && (title.find( "reserved",0, FALSE) == -1) | ||
244 | &&(title.find( "Audio",0, FALSE) == -1)) { | ||
233 | // fill string list or something to be able to sort by Author | 245 | // fill string list or something to be able to sort by Author |
234 | if( author.isEmpty() ) | 246 | if( author.isEmpty() ) |
235 | QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); | 247 | QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); |
236 | else { | 248 | else { |
237 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || | 249 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || |
238 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) | 250 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) |
239 | QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); | 251 | QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); |
240 | 252 | ||
241 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || | 253 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || |
242 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) | 254 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) |
243 | QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); | 255 | QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); |
244 | 256 | ||
245 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || | 257 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || |
246 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) | 258 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) |
247 | QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file ); | 259 | QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file ); |
248 | 260 | ||
249 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || | 261 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || |
250 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) | 262 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) |
251 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); | 263 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); |
252 | } | 264 | } |
253 | } | 265 | } |
254 | } | 266 | } |
255 | } | 267 | } |
256 | } | 268 | } |
257 | indexLib.close(); | 269 | indexLib.close(); |
258 | } else { | 270 | } else { |
259 | QString sMsg; | 271 | QString sMsg; |
260 | sMsg = ( tr("<p>Error opening local library index:</P> "))+local_index; | 272 | sMsg = ( tr("<p>Error opening local library index:</P> "))+local_index; |
261 | QMessageBox::message( "Error",sMsg); | 273 | QMessageBox::message( "Error",sMsg); |
262 | } | 274 | } |
263 | 275 | ||
264 | } //end Library() | 276 | } //end Library() |
265 | 277 | ||
266 | 278 | ||
267 | /* | 279 | /* |
268 | Groks the author out of the title */ | 280 | Groks the author out of the title */ |
269 | bool LibraryDialog::getAuthor() | 281 | bool LibraryDialog::getAuthor() |
270 | { | 282 | { |
271 | if( title.contains( ", by", TRUE)) { | 283 | if( title.contains( ", by", TRUE)) { |
272 | int auth; | 284 | int auth; |
273 | auth = title.find(", by", 0, TRUE); | 285 | auth = title.find(", by", 0, TRUE); |
274 | author = title.right(title.length() - (auth + 4) ); | 286 | author = title.right(title.length() - (auth + 4) ); |
275 | if( int finder = author.find("[", 0, TRUE)) { | 287 | if( int finder = author.find("[", 0, TRUE)) { |
276 | author = author.left(finder); | 288 | author = author.left(finder); |
277 | } | 289 | } |
278 | } | 290 | } |
279 | else if ( title.contains( "by, ", TRUE) ) { | 291 | else if ( title.contains( "by, ", TRUE) ) { |
280 | int auth; | 292 | int auth; |
@@ -551,107 +563,104 @@ bool LibraryDialog::httpDownload() | |||
551 | } //end of while loop | 563 | } //end of while loop |
552 | } | 564 | } |
553 | tmp.close(); | 565 | tmp.close(); |
554 | m_getFilePath = local_library + str; | 566 | m_getFilePath = local_library + str; |
555 | i++; | 567 | i++; |
556 | if ( brow != "KFM"){ ///////// use lynx | 568 | if ( brow != "KFM"){ ///////// use lynx |
557 | QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; | 569 | QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; |
558 | // QMessageBox::message("Error", cmd); | 570 | // QMessageBox::message("Error", cmd); |
559 | system(cmd); | 571 | system(cmd); |
560 | } else { ////////// use KFM | 572 | } else { ////////// use KFM |
561 | // KFM::download( httpName, m_getFilePath); | 573 | // KFM::download( httpName, m_getFilePath); |
562 | } | 574 | } |
563 | i++; | 575 | i++; |
564 | #endif | 576 | #endif |
565 | return false; | 577 | return false; |
566 | } | 578 | } |
567 | 579 | ||
568 | void LibraryDialog::cancelIt() | 580 | void LibraryDialog::cancelIt() |
569 | { | 581 | { |
570 | saveConfig(); | 582 | saveConfig(); |
571 | 583 | ||
572 | DlglistItemNumber = ""; | 584 | DlglistItemNumber = ""; |
573 | this->reject(); | 585 | this->reject(); |
574 | } | 586 | } |
575 | 587 | ||
576 | bool LibraryDialog::setTitle() | 588 | bool LibraryDialog::setTitle() |
577 | { | 589 | { |
578 | Config config("Gutenbrowser"); | 590 | Config config("Gutenbrowser"); |
579 | odebug << "setting title" << oendl; | 591 | odebug << "setting title" << oendl; |
580 | odebug << DlglistItemTitle << oendl; | 592 | odebug << DlglistItemTitle << oendl; |
581 | 593 | ||
582 | if( DlglistItemTitle.find("[",0,TRUE) != -1) | 594 | if( DlglistItemTitle.find("[",0,TRUE) != -1) |
583 | DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" ); | 595 | DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" ); |
584 | if( DlglistItemTitle.find("]",0,TRUE) !=-1) | 596 | if( DlglistItemTitle.find("]",0,TRUE) !=-1) |
585 | DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); | 597 | DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); |
586 | odebug << "Title being set is "+DlglistItemTitle << oendl; | 598 | odebug << "Title being set is "+DlglistItemTitle << oendl; |
587 | int test = 0; | 599 | int test = 0; |
588 | QString ramble, temp; | 600 | QString ramble, temp; |
589 | config.setGroup("Files"); | 601 | config.setGroup("Files"); |
590 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 602 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
591 | int i_numofFiles = s_numofFiles.toInt(); | 603 | int i_numofFiles = s_numofFiles.toInt(); |
592 | for ( int i = 0; i <= i_numofFiles; i++){ | 604 | for ( int i = 0; i <= i_numofFiles; i++){ |
593 | temp.setNum( i); | 605 | temp.setNum( i); |
594 | ramble = config.readEntry( temp, "" ); | 606 | ramble = config.readEntry( temp, "" ); |
595 | if( strcmp( ramble, File_Name) == 0){ | 607 | if( strcmp( ramble, File_Name) == 0){ |
596 | test = 1; | 608 | test = 1; |
597 | } | 609 | } |
598 | } | 610 | } |
599 | |||
600 | if(test == 0 ) { | ||
601 | |||
602 | config.setGroup("Files"); | 611 | config.setGroup("Files"); |
603 | config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); | 612 | config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); |
604 | QString interger; | 613 | QString interger; |
605 | interger.setNum( i_numofFiles +1); | 614 | interger.setNum( i_numofFiles +1); |
606 | config.writeEntry( interger, File_Name); | 615 | config.writeEntry( interger, File_Name); |
607 | config.setGroup( "Titles" ); | 616 | config.setGroup( "Titles" ); |
608 | config.writeEntry( File_Name, DlglistItemTitle); | 617 | config.writeEntry( File_Name, DlglistItemTitle); |
609 | } | 618 | |
610 | test = 0; | 619 | test = 0; |
611 | return true; | 620 | return true; |
612 | } | 621 | } |
613 | 622 | ||
614 | 623 | ||
615 | void LibraryDialog::saveConfig() | 624 | void LibraryDialog::saveConfig() |
616 | { | 625 | { |
617 | Config config("Gutenbrowser"); | 626 | Config config("Gutenbrowser"); |
618 | if( httpBox->isChecked() == TRUE) { | 627 | if( httpBox->isChecked() == TRUE) { |
619 | checked = 1; | 628 | checked = 1; |
620 | config.setGroup( "Proxy" ); | 629 | config.setGroup( "Proxy" ); |
621 | config.writeEntry("IsChecked", "TRUE"); | 630 | config.writeEntry("IsChecked", "TRUE"); |
622 | } else { | 631 | } else { |
623 | checked = 0; | 632 | checked = 0; |
624 | config.setGroup( "Proxy" ); | 633 | config.setGroup( "Proxy" ); |
625 | config.writeEntry("IsChecked", "FALSE"); | 634 | config.writeEntry("IsChecked", "FALSE"); |
626 | } | 635 | } |
627 | if (authBox->isChecked() == TRUE) { | 636 | if (authBox->isChecked() == TRUE) { |
628 | config.setGroup("SortAuth"); | 637 | config.setGroup("SortAuth"); |
629 | config.writeEntry("authSort", "TRUE"); | 638 | config.writeEntry("authSort", "TRUE"); |
630 | } else { | 639 | } else { |
631 | config.setGroup("SortAuth"); | 640 | config.setGroup("SortAuth"); |
632 | config.writeEntry("authSort", "FALSE"); | 641 | config.writeEntry("authSort", "FALSE"); |
633 | } | 642 | } |
634 | // config.write(); | 643 | // config.write(); |
635 | } | 644 | } |
636 | 645 | ||
637 | /* | 646 | /* |
638 | searches library index for user word*/ | 647 | searches library index for user word*/ |
639 | void LibraryDialog::onButtonSearch() | 648 | void LibraryDialog::onButtonSearch() |
640 | { | 649 | { |
641 | ListView1->clearSelection(); | 650 | ListView1->clearSelection(); |
642 | ListView2->clearSelection(); | 651 | ListView2->clearSelection(); |
643 | ListView3->clearSelection(); | 652 | ListView3->clearSelection(); |
644 | ListView4->clearSelection(); | 653 | ListView4->clearSelection(); |
645 | ListView5->clearSelection(); | 654 | ListView5->clearSelection(); |
646 | 655 | ||
647 | int curTab=tabWidget->currentPageIndex(); | 656 | int curTab=tabWidget->currentPageIndex(); |
648 | SearchDialog* searchDlg; | 657 | SearchDialog* searchDlg; |
649 | 658 | ||
650 | // if( resultsList) | 659 | // if( resultsList) |
651 | searchDlg = new SearchDialog( this, "Library Search", TRUE); | 660 | searchDlg = new SearchDialog( this, "Library Search", TRUE); |
652 | searchDlg->setCaption( tr( "Library Search" ) ); | 661 | searchDlg->setCaption( tr( "Library Search" ) ); |
653 | searchDlg->setLabel( "- author or title"); | 662 | searchDlg->setLabel( "- author or title"); |
654 | QString resultString; | 663 | QString resultString; |
655 | int i_berger = 0; | 664 | int i_berger = 0; |
656 | if( searchDlg->exec() != 0 ) { | 665 | if( searchDlg->exec() != 0 ) { |
657 | QString searcherStr = searchDlg->get_text(); | 666 | QString searcherStr = searchDlg->get_text(); |
@@ -705,98 +714,96 @@ void LibraryDialog::onButtonSearch() | |||
705 | resultString += (" : "); | 714 | resultString += (" : "); |
706 | resultString += ( it3.current() )->text(2); | 715 | resultString += ( it3.current() )->text(2); |
707 | resultString += (" : "); | 716 | resultString += (" : "); |
708 | resultString += ( it3.current() )->text(3); | 717 | resultString += ( it3.current() )->text(3); |
709 | 718 | ||
710 | if( resultString.find( searcherStr, 0, cS) != -1) { | 719 | if( resultString.find( searcherStr, 0, cS) != -1) { |
711 | Searchlist.append( resultString); | 720 | Searchlist.append( resultString); |
712 | } | 721 | } |
713 | } | 722 | } |
714 | } | 723 | } |
715 | if(fluff==0) { | 724 | if(fluff==0) { |
716 | // search routine here | 725 | // search routine here |
717 | for ( ; it4.current(); ++it4 ) { | 726 | for ( ; it4.current(); ++it4 ) { |
718 | resultString = ( it4.current() )->text(0); | 727 | resultString = ( it4.current() )->text(0); |
719 | resultString += (" : "); | 728 | resultString += (" : "); |
720 | resultString += ( it4.current() )->text(2); | 729 | resultString += ( it4.current() )->text(2); |
721 | resultString += (" : "); | 730 | resultString += (" : "); |
722 | resultString += ( it4.current() )->text(3); | 731 | resultString += ( it4.current() )->text(3); |
723 | if( resultString.find( searcherStr, 0, cS) != -1) { | 732 | if( resultString.find( searcherStr, 0, cS) != -1) { |
724 | Searchlist.append( resultString); | 733 | Searchlist.append( resultString); |
725 | } | 734 | } |
726 | } | 735 | } |
727 | } | 736 | } |
728 | if(fluff==0) { // search routine here | 737 | if(fluff==0) { // search routine here |
729 | for ( ; it5.current(); ++it5 ) { | 738 | for ( ; it5.current(); ++it5 ) { |
730 | resultString = ( it5.current() )->text(0); | 739 | resultString = ( it5.current() )->text(0); |
731 | resultString += (" : "); | 740 | resultString += (" : "); |
732 | resultString += ( it5.current() )->text(2); | 741 | resultString += ( it5.current() )->text(2); |
733 | resultString += (" : "); | 742 | resultString += (" : "); |
734 | resultString += ( it5.current() )->text(3); | 743 | resultString += ( it5.current() )->text(3); |
735 | if( resultString.find( searcherStr, 0, cS) != -1) { | 744 | if( resultString.find( searcherStr, 0, cS) != -1) { |
736 | Searchlist.append( resultString); | 745 | Searchlist.append( resultString); |
737 | } | 746 | } |
738 | } | 747 | } |
739 | } | 748 | } |
740 | 749 | ||
741 | tabWidget->setCurrentPage( curTab); | 750 | tabWidget->setCurrentPage( curTab); |
742 | 751 | ||
743 | Searchlist.sort(); | 752 | Searchlist.sort(); |
744 | SearchResultsDlg* SearchResultsDialog; | 753 | SearchResultsDlg* SearchResultsDialog; |
745 | SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); | 754 | SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); |
746 | 755 | ||
747 | SearchResultsDialog->showMaximized(); | 756 | SearchResultsDialog->showMaximized(); |
748 | if( SearchResultsDialog->exec() != 0) { | 757 | if( SearchResultsDialog->exec() != 0) { |
749 | texter = SearchResultsDialog->selText; | 758 | texter = SearchResultsDialog->selText; |
750 | // odebug << texter << oendl; | 759 | // odebug << texter << oendl; |
751 | resultLs = SearchResultsDialog->resultsList; | 760 | resultLs = SearchResultsDialog->resultsList; |
752 | i_berger = 1; | 761 | i_berger = 1; |
753 | } else { | ||
754 | resultLs.clear(); | ||
755 | } | 762 | } |
756 | Searchlist.clear(); | 763 | Searchlist.clear(); |
757 | 764 | ||
758 | // if(SearchResultsDialog) | 765 | // if(SearchResultsDialog) |
759 | // delete SearchResultsDialog; | 766 | // delete SearchResultsDialog; |
760 | QString tester; | 767 | QString tester; |
761 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { | 768 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { |
762 | texter.sprintf("%s \n",(*it).latin1()); | 769 | texter.sprintf("%s \n",(*it).latin1()); |
763 | // odebug << texter << oendl; | 770 | // odebug << texter << oendl; |
764 | if( tester!=texter) | 771 | if( tester!=texter) |
765 | parseSearchResults( texter); | 772 | parseSearchResults( texter); |
766 | tester = texter; | 773 | tester = texter; |
767 | } | 774 | } |
768 | if(searchDlg) | 775 | if(searchDlg) |
769 | delete searchDlg; | 776 | delete searchDlg; |
770 | } | 777 | } |
771 | if(checkBox->isChecked() ) { | 778 | if(checkBox->isChecked() ) { |
772 | accept(); | 779 | accept(); |
773 | } else { | 780 | } else { |
774 | setActiveWindow(); | 781 | setActiveWindow(); |
775 | } | 782 | } |
776 | } | 783 | } |
777 | 784 | ||
778 | /* | 785 | /* |
779 | splits the result string and calls download for the current search result*/ | 786 | splits the result string and calls download for the current search result*/ |
780 | void LibraryDialog::parseSearchResults( QString resultStr) | 787 | void LibraryDialog::parseSearchResults( QString resultStr) |
781 | { | 788 | { |
782 | 789 | ||
783 | int stringLeng=resultStr.length(); | 790 | int stringLeng=resultStr.length(); |
784 | QString my; | 791 | QString my; |
785 | my.setNum( stringLeng, 10); | 792 | my.setNum( stringLeng, 10); |
786 | 793 | ||
787 | if( resultStr.length() > 2 && resultStr.length() < 130) { | 794 | if( resultStr.length() > 2 && resultStr.length() < 130) { |
788 | int titleInt = resultStr.find( " : ", 0, TRUE); | 795 | int titleInt = resultStr.find( " : ", 0, TRUE); |
789 | DlglistItemTitle = resultStr.left( titleInt); | 796 | DlglistItemTitle = resultStr.left( titleInt); |
790 | int yearInt = resultStr.find( " : ", titleInt+3, TRUE); | 797 | int yearInt = resultStr.find( " : ", titleInt+3, TRUE); |
791 | DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); | 798 | DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); |
792 | DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); | 799 | DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); |
793 | download_Etext(); | 800 | download_Etext(); |
794 | } | 801 | } |
795 | /* | 802 | /* |
796 | printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/ | 803 | printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/ |
797 | } | 804 | } |
798 | 805 | ||
799 | // bool LibraryDialog::UnzipIt( QString zipFile) { | 806 | // bool LibraryDialog::UnzipIt( QString zipFile) { |
800 | // //////////TODO findsome other way of dealingwithzip files. | 807 | // //////////TODO findsome other way of dealingwithzip files. |
801 | // ///usr/bin/unzip"; | 808 | // ///usr/bin/unzip"; |
802 | // if( QFile::exists( zipFile)) { | 809 | // if( QFile::exists( zipFile)) { |
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp index fac21da..c7cdd83 100644 --- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp +++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | |||
@@ -176,113 +176,124 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) | |||
176 | Gutenbrowser::~Gutenbrowser() { | 176 | Gutenbrowser::~Gutenbrowser() { |
177 | // QPEApplication::grabKeyboard(); | 177 | // QPEApplication::grabKeyboard(); |
178 | // QPEApplication::ungrabKeyboard(); | 178 | // QPEApplication::ungrabKeyboard(); |
179 | odebug << "Exit" << oendl; | 179 | odebug << "Exit" << oendl; |
180 | } | 180 | } |
181 | 181 | ||
182 | /* | 182 | /* |
183 | Google.com search */ | 183 | Google.com search */ |
184 | void Gutenbrowser::InfoBarClick() { | 184 | void Gutenbrowser::InfoBarClick() { |
185 | QString text; | 185 | QString text; |
186 | if( Lview->hasSelectedText()) { | 186 | if( Lview->hasSelectedText()) { |
187 | Lview->copy(); | 187 | Lview->copy(); |
188 | QClipboard *cb = QApplication::clipboard(); | 188 | QClipboard *cb = QApplication::clipboard(); |
189 | text = cb->text(); | 189 | text = cb->text(); |
190 | } else { | 190 | } else { |
191 | // text=title; | 191 | // text=title; |
192 | text=this->caption(); | 192 | text=this->caption(); |
193 | } | 193 | } |
194 | searchGoogle(text); | 194 | searchGoogle(text); |
195 | } | 195 | } |
196 | 196 | ||
197 | /* | 197 | /* |
198 | download http with wget or preferred browser */ | 198 | download http with wget or preferred browser */ |
199 | void Gutenbrowser::goGetit( const QString &url, bool showMsg) { | 199 | void Gutenbrowser::goGetit( const QString &url, bool showMsg) { |
200 | // int eexit=0; | 200 | // int eexit=0; |
201 | QString cmd; | 201 | QString cmd; |
202 | // config.read(); | 202 | // config.read(); |
203 | qApp->processEvents(); | 203 | qApp->processEvents(); |
204 | QString filename = QPEApplication::qpeDir(); | 204 | QString filename = QPEApplication::qpeDir(); |
205 | if(filename.right(1)!="/") | 205 | if(filename.right(1)!="/") |
206 | filename+="/etc/gutenbrowser/"; | 206 | filename+="/etc/gutenbrowser/"; |
207 | else | 207 | else |
208 | filename+="etc/gutenbrowser/"; | 208 | filename+="etc/gutenbrowser/"; |
209 | odebug << "filename "+filename << oendl; | 209 | odebug << "filename "+filename << oendl; |
210 | // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; | 210 | // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; |
211 | 211 | ||
212 | filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); | 212 | filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); |
213 | 213 | ||
214 | Config config("Gutenbrowser"); | 214 | Config config("Gutenbrowser"); |
215 | config.setGroup( "Browser" ); | 215 | config.setGroup( "Browser" ); |
216 | QString brow = config.readEntry("Preferred", "Opera"); | 216 | QString brow = config.readEntry("Preferred", "Opera"); |
217 | odebug << "Preferred browser is "+brow << oendl; | 217 | odebug << "Preferred browser is "+brow << oendl; |
218 | if(!showMsg) { //if we just get the gutenindex.all | 218 | if(!showMsg) { //if we just get the gutenindex.all |
219 | cmd="wget -O " + filename +" " + url+" 2>&1" ; | 219 | cmd="wget -O " + filename +" " + url+" 2>&1" ; |
220 | chdir(local_library); | 220 | chdir(local_library); |
221 | odebug << "Issuing the system command: " << cmd << "" << oendl; | 221 | odebug << "Issuing the system command: " << cmd << "" << oendl; |
222 | 222 | ||
223 | Output *outDlg; | 223 | Output *outDlg; |
224 | outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); | 224 | |
225 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); | ||
226 | |||
225 | outDlg->showMaximized(); | 227 | outDlg->showMaximized(); |
226 | outDlg->show(); | 228 | outDlg->show(); |
227 | qApp->processEvents(); | 229 | qApp->processEvents(); |
228 | FILE *fp; | 230 | FILE *fp; |
229 | char line[130]; | 231 | char line[130]; |
230 | outDlg->OutputEdit->append( tr("Running wget") ); | 232 | outDlg->OutputEdit->append( tr("Running wget") ); |
233 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
231 | sleep(1); | 234 | sleep(1); |
232 | fp = popen( (const char *) cmd, "r"); | 235 | fp = popen( (const char *) cmd, "r"); |
233 | odebug << "Issuing the command\n"+cmd << oendl; | 236 | if ( !fp ) { |
237 | } else { | ||
238 | //odebug << "Issuing the command\n"+cmd << oendl; | ||
234 | // system(cmd); | 239 | // system(cmd); |
235 | while ( fgets( line, sizeof line, fp)) { | 240 | while ( fgets( line, sizeof line, fp)) { |
236 | outDlg->OutputEdit->append(line); | 241 | outDlg->OutputEdit->append(line); |
237 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 242 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
238 | } | 243 | } |
239 | pclose(fp); | 244 | pclose(fp); |
245 | outDlg->OutputEdit->append("Finished downloading\n"); | ||
246 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
247 | qApp->processEvents(); | ||
248 | |||
249 | } | ||
240 | outDlg->close(); | 250 | outDlg->close(); |
251 | |||
241 | if(outDlg) | 252 | if(outDlg) |
242 | delete outDlg; | 253 | delete outDlg; |
243 | } else { | 254 | } else { |
244 | if( brow == "Konq") { | 255 | if( brow == "Konq") { |
245 | cmd = "konqueror "+url+" &"; | 256 | cmd = "konqueror "+url+" &"; |
246 | } | 257 | } |
247 | if( brow == "Opera") { //for desktop testing | 258 | if( brow == "Opera") { //for desktop testing |
248 | cmd = "opera "+url+" &"; | 259 | cmd = "opera "+url+" &"; |
249 | } | 260 | } |
250 | // if( brow == "Opera") { // on Zaurus | 261 | // if( brow == "Opera") { // on Zaurus |
251 | // cmd = "operagui "+url+" &"; | 262 | // cmd = "operagui "+url+" &"; |
252 | // } | 263 | // } |
253 | if( brow == "Mozilla") { | 264 | if( brow == "Mozilla") { |
254 | cmd = "mozilla "+url+" &"; | 265 | cmd = "mozilla "+url+" &"; |
255 | } | 266 | } |
256 | if( brow == "Netscape") { | 267 | if( brow == "Netscape") { |
257 | cmd = "netscape "+url+" &"; | 268 | cmd = "netscape "+url+" &"; |
258 | } | 269 | } |
259 | if(brow == "wget") { | 270 | if(brow == "wget") { |
260 | // cmd="wget -q "+url+" &"; | 271 | // cmd="wget -q "+url+" &"; |
261 | QString tempHtml=local_library+"webster.html"; | 272 | QString tempHtml=local_library+"webster.html"; |
262 | cmd="wget -O "+tempHtml+" -q "+url; | 273 | cmd="wget -O "+tempHtml+" -q "+url; |
263 | } | 274 | } |
264 | 275 | ||
265 | chdir(local_library); | 276 | chdir(local_library); |
266 | odebug << "Issuing the sys command: " << cmd << "" << oendl; | 277 | odebug << "Issuing the sys command: " << cmd << "" << oendl; |
267 | system(cmd); | 278 | system(cmd); |
268 | } | 279 | } |
269 | } | 280 | } |
270 | 281 | ||
271 | void Gutenbrowser::toggleButtonIcons( bool useEm) { | 282 | void Gutenbrowser::toggleButtonIcons( bool useEm) { |
272 | QString pixDir; | 283 | QString pixDir; |
273 | if(useEm) | 284 | if(useEm) |
274 | useEm=TRUE; | 285 | useEm=TRUE; |
275 | pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; | 286 | pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; |
276 | odebug << "Docdir is "+QPEApplication::documentDir() << oendl; | 287 | odebug << "Docdir is "+QPEApplication::documentDir() << oendl; |
277 | 288 | ||
278 | if( useIcons && QDir( pixDir).exists() ) { | 289 | if( useIcons && QDir( pixDir).exists() ) { |
279 | LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline | 290 | LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline |
280 | OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook")); | 291 | OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook")); |
281 | ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline | 292 | ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline |
282 | BackButton->setPixmap( Resource::loadPixmap("back") );//in inline | 293 | BackButton->setPixmap( Resource::loadPixmap("back") );//in inline |
283 | SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline | 294 | SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline |
284 | lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder")); | 295 | lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder")); |
285 | setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") ); | 296 | setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") ); |
286 | dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") ); | 297 | dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") ); |
287 | InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google")); | 298 | InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google")); |
288 | } | 299 | } |