Diffstat (limited to 'noncore/apps/opie-gutenbrowser/openetext.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-gutenbrowser/openetext.cpp | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/noncore/apps/opie-gutenbrowser/openetext.cpp b/noncore/apps/opie-gutenbrowser/openetext.cpp index bd44ce6..0267416 100644 --- a/noncore/apps/opie-gutenbrowser/openetext.cpp +++ b/noncore/apps/opie-gutenbrowser/openetext.cpp | |||
@@ -9,38 +9,41 @@ | |||
9 | * This program is free software; you can redistribute it and/or modify * | 9 | * This program is free software; you can redistribute it and/or modify * |
10 | * it under the terms of the GNU General Public License as published by * | 10 | * it under the terms of the GNU General Public License as published by * |
11 | * the Free Software Foundation; either version 2 of the License, or * | 11 | * the Free Software Foundation; either version 2 of the License, or * |
12 | * (at your option) any later version. * | 12 | * (at your option) any later version. * |
13 | ***************************************************************************/ | 13 | ***************************************************************************/ |
14 | 14 | ||
15 | #include "gutenbrowser.h" | 15 | #include "gutenbrowser.h" |
16 | #include "openetext.h" | 16 | #include "openetext.h" |
17 | #include "editTitle.h" | 17 | #include "editTitle.h" |
18 | 18 | ||
19 | /* OPIE */ | 19 | /* OPIE */ |
20 | #include <opie2/ofiledialog.h> | 20 | #include <opie2/ofiledialog.h> |
21 | #include <opie2/odebug.h> | ||
21 | #include <qpe/applnk.h> | 22 | #include <qpe/applnk.h> |
22 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
23 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
24 | using namespace Opie::Ui; | 25 | using namespace Opie::Ui; |
25 | 26 | ||
26 | #include <stdlib.h> | 27 | /* QT */ |
27 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
28 | #include <qfileinfo.h> | 29 | #include <qfileinfo.h> |
29 | 30 | ||
31 | /* STD */ | ||
30 | #if defined(_WS_WIN_) | 32 | #if defined(_WS_WIN_) |
31 | #include <windows.h> | 33 | #include <windows.h> |
32 | #else | 34 | #else |
33 | #include <unistd.h> | 35 | #include <unistd.h> |
34 | #include "sys/stat.h" | 36 | #include <stdlib.h> |
37 | #include <sys/stat.h> | ||
35 | #endif | 38 | #endif |
36 | 39 | ||
37 | OpenEtext::OpenEtext(QWidget *parent, QString name) : QDialog(parent,name,true) | 40 | OpenEtext::OpenEtext(QWidget *parent, QString name) : QDialog(parent,name,true) |
38 | { | 41 | { |
39 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; | 42 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; |
40 | local_index=local_library+"GUTINDEX.ALL"; | 43 | local_index=local_library+"GUTINDEX.ALL"; |
41 | initDialog(); | 44 | initDialog(); |
42 | connect( QListBox_1, SIGNAL(selected ( int)),this, SLOT(select_title(int)) ); | 45 | connect( QListBox_1, SIGNAL(selected ( int)),this, SLOT(select_title(int)) ); |
43 | 46 | ||
44 | getTitles(); | 47 | getTitles(); |
45 | } | 48 | } |
46 | 49 | ||
@@ -125,25 +128,25 @@ OpenFileButton->setDown(TRUE); | |||
125 | map.insert(tr("All"), QStringList() ); | 128 | map.insert(tr("All"), QStringList() ); |
126 | QStringList text; | 129 | QStringList text; |
127 | text << "text/*"; | 130 | text << "text/*"; |
128 | map.insert(tr("Text"), text ); | 131 | map.insert(tr("Text"), text ); |
129 | text << "*"; | 132 | text << "*"; |
130 | map.insert(tr("All"), text ); | 133 | map.insert(tr("All"), text ); |
131 | 134 | ||
132 | QString str = OFileDialog::getOpenFileName( 2, dir , QString::null, map); | 135 | QString str = OFileDialog::getOpenFileName( 2, dir , QString::null, map); |
133 | 136 | ||
134 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) { | 137 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) { |
135 | filer = str; | 138 | filer = str; |
136 | 139 | ||
137 | qDebug("Open file: "+str); | 140 | odebug << "Open file: "+str << oendl; |
138 | 141 | ||
139 | // QStringList::ConstIterator f; | 142 | // QStringList::ConstIterator f; |
140 | // QString fileTemp; | 143 | // QString fileTemp; |
141 | // for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 144 | // for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
142 | // fileTemp = *f; | 145 | // fileTemp = *f; |
143 | // fileTemp.right( fileTemp.length()-5); | 146 | // fileTemp.right( fileTemp.length()-5); |
144 | // fileName = fileTemp; | 147 | // fileName = fileTemp; |
145 | // if( !fileName.isEmpty() ){ | 148 | // if( !fileName.isEmpty() ){ |
146 | // filer = fileName; | 149 | // filer = fileName; |
147 | // } else { //filename is empty | 150 | // } else { //filename is empty |
148 | // // QString sMsg; | 151 | // // QString sMsg; |
149 | // // sMsg = "Error opening library filelist "+fileName; | 152 | // // sMsg = "Error opening library filelist "+fileName; |
@@ -155,154 +158,154 @@ OpenFileButton->setDown(TRUE); | |||
155 | || filer.right(4) == ".ETX" | 158 | || filer.right(4) == ".ETX" |
156 | || filer.right(4) == ".etx" | 159 | || filer.right(4) == ".etx" |
157 | || filer.right(4) == ".ETX" | 160 | || filer.right(4) == ".ETX" |
158 | || filer.right(4) == ".zip" | 161 | || filer.right(4) == ".zip" |
159 | || filer.right(4) == ".ZIP" ) { | 162 | || filer.right(4) == ".ZIP" ) { |
160 | QFileInfo zipFile( filer); | 163 | QFileInfo zipFile( filer); |
161 | QString s_fileName = zipFile.fileName(); | 164 | QString s_fileName = zipFile.fileName(); |
162 | QString cmd; | 165 | QString cmd; |
163 | 166 | ||
164 | if( s_fileName.right(4) == ".zip") { // unzip that sucker.... | 167 | if( s_fileName.right(4) == ".zip") { // unzip that sucker.... |
165 | s_fileName = s_fileName.left( s_fileName.length() - 4); | 168 | s_fileName = s_fileName.left( s_fileName.length() - 4); |
166 | if( chdir((const char*)local_library.latin1())!=0) | 169 | if( chdir((const char*)local_library.latin1())!=0) |
167 | qDebug("chdir failed.");// QString cmd = "gunzip -d " + filer + " -d " + local_library; | 170 | odebug << "chdir failed." << oendl; // QString cmd = "gunzip -d " + filer + " -d " + local_library; |
168 | cmd = "gunzip -S .zip " + filer; | 171 | cmd = "gunzip -S .zip " + filer; |
169 | fileName = local_library + s_fileName + ".txt"; | 172 | fileName = local_library + s_fileName + ".txt"; |
170 | system( cmd); | 173 | system( cmd); |
171 | } | 174 | } |
172 | // this renames the .txt to .etx!! | 175 | // this renames the .txt to .etx!! |
173 | else /*if( s_fileName.right(4) == ".txt" || if( s_fileName.right(4) == ".TXT"))*/ { | 176 | else /*if( s_fileName.right(4) == ".txt" || if( s_fileName.right(4) == ".TXT"))*/ { |
174 | // qDebug("Filename is "+fileName); | 177 | // odebug << "Filename is "+fileName << oendl; |
175 | s_fileName = fileName; | 178 | s_fileName = fileName; |
176 | s_fileName.replace( s_fileName.length()-3,3,"gtn");// s_fileName.replace( s_fileName.length()-3,3,"etx"); | 179 | s_fileName.replace( s_fileName.length()-3,3,"gtn");// s_fileName.replace( s_fileName.length()-3,3,"etx"); |
177 | rename(fileName.latin1(),s_fileName.latin1()); | 180 | rename(fileName.latin1(),s_fileName.latin1()); |
178 | fileName = s_fileName; | 181 | fileName = s_fileName; |
179 | // qDebug("Filename is now "+fileName); | 182 | // odebug << "Filename is now "+fileName << oendl; |
180 | } | 183 | } |
181 | } else | 184 | } else |
182 | fileName = str; | 185 | fileName = str; |
183 | 186 | ||
184 | FindTitle(fileName); | 187 | FindTitle(fileName); |
185 | 188 | ||
186 | QFileInfo fi( fileName); | 189 | QFileInfo fi( fileName); |
187 | name_file = fi.fileName(); | 190 | name_file = fi.fileName(); |
188 | name_file = name_file.left(name_file.length() - 4); | 191 | name_file = name_file.left(name_file.length() - 4); |
189 | 192 | ||
190 | qDebug("Setting doclink"); | 193 | odebug << "Setting doclink" << oendl; |
191 | DocLnk lnk; | 194 | DocLnk lnk; |
192 | qDebug("name is " + name_file); | 195 | odebug << "name is " + name_file << oendl; |
193 | lnk.setName(name_file); //sets file name | 196 | lnk.setName(name_file); //sets file name |
194 | qDebug("Title is "+title); | 197 | odebug << "Title is "+title << oendl; |
195 | lnk.setComment(title); | 198 | lnk.setComment(title); |
196 | 199 | ||
197 | QListBox_1->clear(); | 200 | QListBox_1->clear(); |
198 | getTitles(); | 201 | getTitles(); |
199 | qDebug("Filename is "+fileName); | 202 | odebug << "Filename is "+fileName << oendl; |
200 | lnk.setFile(fileName); //sets File property | 203 | lnk.setFile(fileName); //sets File property |
201 | lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D | 204 | lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D |
202 | lnk.setExec(fileName); | 205 | lnk.setExec(fileName); |
203 | lnk.setIcon("gutenbrowser/Gutenbrowser"); | 206 | lnk.setIcon("gutenbrowser/Gutenbrowser"); |
204 | if(!lnk.writeLink()) | 207 | if(!lnk.writeLink()) |
205 | qDebug("Writing doclink did not work"); | 208 | odebug << "Writing doclink did not work" << oendl; |
206 | 209 | ||
207 | } // end of for each file name.... | 210 | } // end of for each file name.... |
208 | OpenFileButton->setDown(FALSE); | 211 | OpenFileButton->setDown(FALSE); |
209 | } | 212 | } |
210 | 213 | ||
211 | /* | 214 | /* |
212 | find the title in the config file */ | 215 | find the title in the config file */ |
213 | bool OpenEtext::FindTitle( QString filename) | 216 | bool OpenEtext::FindTitle( QString filename) |
214 | { | 217 | { |
215 | Config config("Gutenbrowser"); | 218 | Config config("Gutenbrowser"); |
216 | config.setGroup( "Files" ); | 219 | config.setGroup( "Files" ); |
217 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0"); | 220 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0"); |
218 | int i_numofFiles = s_numofFiles.toInt(); | 221 | int i_numofFiles = s_numofFiles.toInt(); |
219 | 222 | ||
220 | QFileInfo fi(filename); | 223 | QFileInfo fi(filename); |
221 | name = fi.fileName(); | 224 | name = fi.fileName(); |
222 | qDebug("filename to open is " + name); | 225 | odebug << "filename to open is " + name << oendl; |
223 | QFile indexLib( filename); | 226 | QFile indexLib( filename); |
224 | bool findCheck = FALSE; | 227 | bool findCheck = FALSE; |
225 | // int Titlenumber=0; | 228 | // int Titlenumber=0; |
226 | 229 | ||
227 | if ( indexLib.open( IO_ReadOnly) ) { | 230 | if ( indexLib.open( IO_ReadOnly) ) { |
228 | qDebug("file opened successfully"); | 231 | odebug << "file opened successfully" << oendl; |
229 | QTextStream indexStream( &indexLib ); | 232 | QTextStream indexStream( &indexLib ); |
230 | QString target = "Project Gutenberg Etext of"; | 233 | QString target = "Project Gutenberg Etext of"; |
231 | QString target2 = "Project Gutenberg Etext"; | 234 | QString target2 = "Project Gutenberg Etext"; |
232 | QString target3 = "Project Gutenberg's Etext of"; | 235 | QString target3 = "Project Gutenberg's Etext of"; |
233 | QString target4 = "Project Gutenberg's Etext"; | 236 | QString target4 = "Project Gutenberg's Etext"; |
234 | QString indexLine; | 237 | QString indexLine; |
235 | while ( !indexStream.eof() ) { | 238 | while ( !indexStream.eof() ) { |
236 | // until end of file.. | 239 | // until end of file.. |
237 | indexLine = indexStream.readLine(); | 240 | indexLine = indexStream.readLine(); |
238 | if( indexLine.find(target, 0, TRUE) > -1 && !findCheck) {findCheck = TRUE; | 241 | if( indexLine.find(target, 0, TRUE) > -1 && !findCheck) {findCheck = TRUE; |
239 | title = indexLine.mid( indexLine.find(target, 0, TRUE) + (target.length()) , indexLine.find("\r", 0, TRUE)); | 242 | title = indexLine.mid( indexLine.find(target, 0, TRUE) + (target.length()) , indexLine.find("\r", 0, TRUE)); |
240 | title = title.left( title.find( "*",0, TRUE)); | 243 | title = title.left( title.find( "*",0, TRUE)); |
241 | title = title.stripWhiteSpace (); | 244 | title = title.stripWhiteSpace (); |
242 | // qDebug("Found the title 1 and it is %s", title.latin1()); | 245 | // odebug << "Found the title 1 and it is " << title << "" << oendl; |
243 | // QListBox_1->insertItem ( title); | 246 | // QListBox_1->insertItem ( title); |
244 | } | 247 | } |
245 | if( indexLine.find( target2, 0, TRUE) > -1 && !findCheck) { | 248 | if( indexLine.find( target2, 0, TRUE) > -1 && !findCheck) { |
246 | findCheck = TRUE; | 249 | findCheck = TRUE; |
247 | title = indexLine.mid( indexLine.find( target2, 0, TRUE ) + ( target2.length()) , indexLine.find("\r", 0, TRUE) ); | 250 | title = indexLine.mid( indexLine.find( target2, 0, TRUE ) + ( target2.length()) , indexLine.find("\r", 0, TRUE) ); |
248 | title = title.left( title.find( "*",0, TRUE)); | 251 | title = title.left( title.find( "*",0, TRUE)); |
249 | title = title.stripWhiteSpace (); | 252 | title = title.stripWhiteSpace (); |
250 | // qDebug("Found the title 2 and it is %s", title.latin1()); | 253 | // odebug << "Found the title 2 and it is " << title << "" << oendl; |
251 | // QListBox_1->insertItem ( title); | 254 | // QListBox_1->insertItem ( title); |
252 | } | 255 | } |
253 | if( indexLine.find( target3, 0, TRUE) > -1 && !findCheck) { | 256 | if( indexLine.find( target3, 0, TRUE) > -1 && !findCheck) { |
254 | findCheck = TRUE; | 257 | findCheck = TRUE; |
255 | title = indexLine.mid( indexLine.find( target3, 0, TRUE) + ( target3.length()) , indexLine.find("\r", 0, TRUE)); | 258 | title = indexLine.mid( indexLine.find( target3, 0, TRUE) + ( target3.length()) , indexLine.find("\r", 0, TRUE)); |
256 | title = title.left( title.find( "*",0, TRUE)); | 259 | title = title.left( title.find( "*",0, TRUE)); |
257 | title = title.stripWhiteSpace (); | 260 | title = title.stripWhiteSpace (); |
258 | // qDebug("Found the title 3 and it is %s", title.latin1()); | 261 | // odebug << "Found the title 3 and it is " << title << "" << oendl; |
259 | } | 262 | } |
260 | if( indexLine.find( target4, 0, TRUE) > -1 && !findCheck) { | 263 | if( indexLine.find( target4, 0, TRUE) > -1 && !findCheck) { |
261 | findCheck = TRUE; | 264 | findCheck = TRUE; |
262 | title = indexLine.mid( indexLine.find( target4, 0, TRUE) + ( target4.length()) , indexLine.find("\r", 0, TRUE)); | 265 | title = indexLine.mid( indexLine.find( target4, 0, TRUE) + ( target4.length()) , indexLine.find("\r", 0, TRUE)); |
263 | title = title.left( title.find( "*",0, TRUE)); | 266 | title = title.left( title.find( "*",0, TRUE)); |
264 | title = title.stripWhiteSpace (); | 267 | title = title.stripWhiteSpace (); |
265 | // qDebug("Found the title 4 and it is %s", title.latin1()); | 268 | // odebug << "Found the title 4 and it is " << title << "" << oendl; |
266 | } | 269 | } |
267 | } //endof file | 270 | } //endof file |
268 | indexLib.close(); | 271 | indexLib.close(); |
269 | 272 | ||
270 | if( !findCheck || title.length() < 2) { | 273 | if( !findCheck || title.length() < 2) { |
271 | qDebug("Trying hard to find title from GUTINDEX.ALL"); | 274 | odebug << "Trying hard to find title from GUTINDEX.ALL" << oendl; |
272 | title = titleFromLibrary( filename); | 275 | title = titleFromLibrary( filename); |
273 | findCheck = TRUE; | 276 | findCheck = TRUE; |
274 | } | 277 | } |
275 | 278 | ||
276 | if ( checkConf() == false && findCheck == TRUE) { | 279 | if ( checkConf() == false && findCheck == TRUE) { |
277 | 280 | ||
278 | config.setGroup( "Files"); | 281 | config.setGroup( "Files"); |
279 | config.writeEntry("NumberOfFiles",i_numofFiles + 1 ); | 282 | config.writeEntry("NumberOfFiles",i_numofFiles + 1 ); |
280 | QString interger; | 283 | QString interger; |
281 | interger.setNum( i_numofFiles +1); | 284 | interger.setNum( i_numofFiles +1); |
282 | config.writeEntry(interger, filename); | 285 | config.writeEntry(interger, filename); |
283 | config.setGroup( "Titles" ); | 286 | config.setGroup( "Titles" ); |
284 | for (int i = 1; i <= i_numofFiles; i++) { //find dup titles in config file | 287 | for (int i = 1; i <= i_numofFiles; i++) { //find dup titles in config file |
285 | QString temp; | 288 | QString temp; |
286 | temp.setNum(i); | 289 | temp.setNum(i); |
287 | config.setGroup( "Files" ); | 290 | config.setGroup( "Files" ); |
288 | QString ramble = config.readEntry(temp, "" ); | 291 | QString ramble = config.readEntry(temp, "" ); |
289 | config.setGroup( "Titles" ); | 292 | config.setGroup( "Titles" ); |
290 | QString title1 = config.readEntry(ramble, ""); | 293 | QString title1 = config.readEntry(ramble, ""); |
291 | if(title1==title) | 294 | if(title1==title) |
292 | title+="1"; | 295 | title+="1"; |
293 | i= i_numofFiles+1; | 296 | i= i_numofFiles+1; |
294 | } | 297 | } |
295 | if(title.length()<3) { | 298 | if(title.length()<3) { |
296 | // qDebug("title is empty"); | 299 | // odebug << "title is empty" << oendl; |
297 | title="Unknown"; | 300 | title="Unknown"; |
298 | } | 301 | } |
299 | config.writeEntry( filename,title); | 302 | config.writeEntry( filename,title); |
300 | } | 303 | } |
301 | } else { | 304 | } else { |
302 | QString sMsg; | 305 | QString sMsg; |
303 | sMsg = "Error opening library file: "+filename; | 306 | sMsg = "Error opening library file: "+filename; |
304 | printf( sMsg+"\n"); | 307 | printf( sMsg+"\n"); |
305 | } | 308 | } |
306 | return true; | 309 | return true; |
307 | } | 310 | } |
308 | 311 | ||
@@ -334,31 +337,31 @@ QString OpenEtext::titleFromLibrary( QString fileName) | |||
334 | // file opened successfully | 337 | // file opened successfully |
335 | QTextStream indexStream( &indexLib ); | 338 | QTextStream indexStream( &indexLib ); |
336 | QString indexLine; | 339 | QString indexLine; |
337 | bool findCheck = FALSE; | 340 | bool findCheck = FALSE; |
338 | while ( !indexStream.atEnd() ) { // until end of file.. | 341 | while ( !indexStream.atEnd() ) { // until end of file.. |
339 | indexLine = indexStream.readLine(); | 342 | indexLine = indexStream.readLine(); |
340 | 343 | ||
341 | if( indexLine.find( target,0,FALSE) > 0 ) { | 344 | if( indexLine.find( target,0,FALSE) > 0 ) { |
342 | findCheck = TRUE; | 345 | findCheck = TRUE; |
343 | title = indexLine.mid( 9, 50); | 346 | title = indexLine.mid( 9, 50); |
344 | // title = indexLine.mid( 26, indexLine.length() ); | 347 | // title = indexLine.mid( 26, indexLine.length() ); |
345 | title = title.stripWhiteSpace (); | 348 | title = title.stripWhiteSpace (); |
346 | // qDebug("Finally Found the title and it is\n %s", title.latin1()); | 349 | // odebug << "Finally Found the title and it is\n " << title << "" << oendl; |
347 | // QListBox_1->insertItem ( title); | 350 | // QListBox_1->insertItem ( title); |
348 | } | 351 | } |
349 | } //end while loop | 352 | } //end while loop |
350 | } | 353 | } |
351 | else | 354 | else |
352 | qDebug("Error opening library index "+ local_index); | 355 | odebug << "Error opening library index "+ local_index << oendl; |
353 | return title; | 356 | return title; |
354 | } | 357 | } |
355 | 358 | ||
356 | bool OpenEtext::checkConf() | 359 | bool OpenEtext::checkConf() |
357 | { | 360 | { |
358 | QString file = fileName; | 361 | QString file = fileName; |
359 | Config config("Gutenbrowser"); | 362 | Config config("Gutenbrowser"); |
360 | config.setGroup( "Files" ); | 363 | config.setGroup( "Files" ); |
361 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 364 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
362 | int i_numofFiles = s_numofFiles.toInt(); | 365 | int i_numofFiles = s_numofFiles.toInt(); |
363 | 366 | ||
364 | for (int i = 1; i <= i_numofFiles; i++) { | 367 | for (int i = 1; i <= i_numofFiles; i++) { |
@@ -405,25 +408,25 @@ void OpenEtext::removeSelection() | |||
405 | QString fileNum; | 408 | QString fileNum; |
406 | 409 | ||
407 | for (int i = 1; i <= i_numofFiles; i++) { | 410 | for (int i = 1; i <= i_numofFiles; i++) { |
408 | fileNum.setNum(i); | 411 | fileNum.setNum(i); |
409 | config.setGroup( "Files" ); | 412 | config.setGroup( "Files" ); |
410 | 413 | ||
411 | QString s_filename = config.readEntry(fileNum, "" ); | 414 | QString s_filename = config.readEntry(fileNum, "" ); |
412 | config.setGroup( "Titles" ); | 415 | config.setGroup( "Titles" ); |
413 | 416 | ||
414 | QString file_title = config.readEntry( s_filename, ""); | 417 | QString file_title = config.readEntry( s_filename, ""); |
415 | if(title_text == file_title) { | 418 | if(title_text == file_title) { |
416 | rem=i; | 419 | rem=i; |
417 | //qDebug("file title to remove is "+file_title); | 420 | //odebug << "file title to remove is "+file_title << oendl; |
418 | selFile = s_filename; | 421 | selFile = s_filename; |
419 | config.removeEntry( s_filename); //removes file=title | 422 | config.removeEntry( s_filename); //removes file=title |
420 | } | 423 | } |
421 | } | 424 | } |
422 | config.setGroup( "Files" ); | 425 | config.setGroup( "Files" ); |
423 | 426 | ||
424 | for(int fg = rem; fg < i_numofFiles ; fg++ ) { //this rewrites Files number entry | 427 | for(int fg = rem; fg < i_numofFiles ; fg++ ) { //this rewrites Files number entry |
425 | fileNum.setNum(fg); | 428 | fileNum.setNum(fg); |
426 | fileNum2.setNum( fg + 1); | 429 | fileNum2.setNum( fg + 1); |
427 | 430 | ||
428 | QString s_filename2 = config.readEntry(fileNum2, "" ); | 431 | QString s_filename2 = config.readEntry(fileNum2, "" ); |
429 | 432 | ||
@@ -473,46 +476,46 @@ void OpenEtext::remFile() | |||
473 | /* | 476 | /* |
474 | sorts the list*/ | 477 | sorts the list*/ |
475 | void OpenEtext::scan() { | 478 | void OpenEtext::scan() { |
476 | 479 | ||
477 | QListBox_1->sort(TRUE); | 480 | QListBox_1->sort(TRUE); |
478 | QListBox_1->triggerUpdate(true); | 481 | QListBox_1->triggerUpdate(true); |
479 | } | 482 | } |
480 | 483 | ||
481 | void OpenEtext::editTitle() { | 484 | void OpenEtext::editTitle() { |
482 | 485 | ||
483 | int currentItem=QListBox_1->currentItem(); | 486 | int currentItem=QListBox_1->currentItem(); |
484 | QString title_text = QListBox_1->text( currentItem); | 487 | QString title_text = QListBox_1->text( currentItem); |
485 | //qDebug("Selected "+title_text); | 488 | //odebug << "Selected "+title_text << oendl; |
486 | 489 | ||
487 | Config config("Gutenbrowser"); | 490 | Config config("Gutenbrowser"); |
488 | config.setGroup( "Files" ); | 491 | config.setGroup( "Files" ); |
489 | s_numofFiles = config.readEntry("NumberOfFiles", "0"); | 492 | s_numofFiles = config.readEntry("NumberOfFiles", "0"); |
490 | int i_numofFiles = s_numofFiles.toInt(); | 493 | int i_numofFiles = s_numofFiles.toInt(); |
491 | QString fileNum; | 494 | QString fileNum; |
492 | for (int i = 1; i <= i_numofFiles+1; i++) { | 495 | for (int i = 1; i <= i_numofFiles+1; i++) { |
493 | 496 | ||
494 | fileNum.setNum(i); | 497 | fileNum.setNum(i); |
495 | config.setGroup( "Files" ); | 498 | config.setGroup( "Files" ); |
496 | QString s_filename = config.readEntry(fileNum, "" ); | 499 | QString s_filename = config.readEntry(fileNum, "" ); |
497 | config.setGroup( "Titles" ); | 500 | config.setGroup( "Titles" ); |
498 | QString file_title = config.readEntry( s_filename, ""); | 501 | QString file_title = config.readEntry( s_filename, ""); |
499 | //qDebug("file_title is "+file_title); | 502 | //odebug << "file_title is "+file_title << oendl; |
500 | if(title_text == file_title ) { | 503 | if(title_text == file_title ) { |
501 | selFile = s_filename; | 504 | selFile = s_filename; |
502 | //qDebug("Edit: "+ file_title ); | 505 | //odebug << "Edit: "+ file_title << oendl; |
503 | i=i_numofFiles+1; | 506 | i=i_numofFiles+1; |
504 | Edit_Title *titleEdit; | 507 | Edit_Title *titleEdit; |
505 | titleEdit = new Edit_Title(this,file_title ,TRUE); | 508 | titleEdit = new Edit_Title(this,file_title ,TRUE); |
506 | if(titleEdit->exec() !=0) { | 509 | if(titleEdit->exec() !=0) { |
507 | //qDebug(titleEdit->newTitle); | 510 | //odebug << titleEdit->newTitle << oendl; |
508 | config.writeEntry( s_filename, titleEdit->newTitle); | 511 | config.writeEntry( s_filename, titleEdit->newTitle); |
509 | QListBox_1->removeItem(currentItem); | 512 | QListBox_1->removeItem(currentItem); |
510 | QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), titleEdit->newTitle, currentItem); | 513 | QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), titleEdit->newTitle, currentItem); |
511 | } | 514 | } |
512 | } | 515 | } |
513 | } | 516 | } |
514 | 517 | ||
515 | // getTitles(); | 518 | // getTitles(); |
516 | QListBox_1->triggerUpdate(true); | 519 | QListBox_1->triggerUpdate(true); |
517 | } | 520 | } |
518 | 521 | ||