author | llornkcor <llornkcor> | 2004-04-08 23:13:24 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-04-08 23:13:24 (UTC) |
commit | 8ea8d193ff14250d4dbc0fc3d4699e5888ba35fe (patch) (side-by-side diff) | |
tree | fced2b714b39a5f2747e36a9784f6fc131e77c55 | |
parent | 502281033b395bb5f089a2bbaa86f9ba423dec84 (diff) | |
download | opie-8ea8d193ff14250d4dbc0fc3d4699e5888ba35fe.zip opie-8ea8d193ff14250d4dbc0fc3d4699e5888ba35fe.tar.gz opie-8ea8d193ff14250d4dbc0fc3d4699e5888ba35fe.tar.bz2 |
fix segfault in d'tor
-rw-r--r-- | noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp index 157a3da..5b22b00 100644 --- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp @@ -1,287 +1,287 @@ /*************************************************************************** // LibraryDialog.cpp - description // ------------------- // begin : Sat Aug 19 2000 // copyright : (C) 2000 - 2004 by llornkcor // email : ljp@llornkcor.com // ***************************************************/ // /*************************************************************************** // * This program is free software; you can redistribute it and/or modify * // * it under the terms of the GNU General Public License as published by * // * the Free Software Foundation; either version 2 of the License, or * // * (at your option) any later version. * // ***************************************************************************/ //ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL #include <qpe/applnk.h> #include <qpe/qpeapplication.h> #include <qpe/qpedialog.h> #include "LibraryDialog.h" #include "output.h" #include <qpushbutton.h> #include <qmultilineedit.h> //#include <qlayout.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> /* * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool modal, WFlags fl ) : QDialog( parent, name, true/* modal*/, fl ) { if ( !name ) setName( "LibraryDialog" ); indexLoaded=false; initDialog(); // this->setMaximumWidth(240); index = "GUTINDEX.ALL"; local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; local_index = local_library + index; QString iniFile ; iniFile = QPEApplication::qpeDir()+"/etc/gutenbrowser/gutenbrowserrc"; new_index =QPEApplication::qpeDir()+"/etc/gutenbrowser/PGWHOLE.TXT"; old_index = QPEApplication::qpeDir()+"/etc/gutenbrowser/GUTINDEX.ALL"; // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; // iniFile = local_library+"gutenbrowserrc"; // new_index = local_library + "PGWHOLE.TXT"; // old_index = local_library + "GUTINDEX.ALL"; Config config("Gutenbrowser"); config.setGroup( "HttpServer" ); proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); config.setGroup( "FTPsite" ); ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); qDebug("Library Dialog: ftp_host is "+ftp_host); // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); // ftp_host=ftp_host.stripWhiteSpace(); ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); i_binary = 0; config.setGroup("SortAuth"); if( config.readEntry("authSort", "FALSE") == "TRUE") authBox->setChecked(TRUE); config.setGroup("General"); downDir =config.readEntry( "DownloadDirectory",local_library); qDebug("downDir is "+downDir); newindexLib.setName( old_index); indexLib.setName( old_index); new QPEDialogListener(this); } LibraryDialog::~LibraryDialog() { - delete QList_Item2; - delete QList_Item1; - delete QList_Item3; - delete QList_Item4; - delete QList_Item5; +// delete QList_Item2; +// delete QList_Item1; +// delete QList_Item3; +// delete QList_Item4; +// delete QList_Item5; - saveConfig(); + // saveConfig(); } /*This groks using PGWHOLE.TXT */ void LibraryDialog::Newlibrary() { #ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files //qDebug("Opening new library index %s",newindexLib); if ( newindexLib.open( IO_ReadOnly) ) { setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully QTextStream indexStream( &newindexLib ); QString indexLine; while ( !indexStream.atEnd() ) { // until end of file.. indexLine = indexStream.readLine(); if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { year = indexLine.mid(4,4); year = year.stripWhiteSpace(); file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); file = file.stripWhiteSpace(); number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); if( year.toInt() < 1984) number = number.left( number.length() -1 ); number = number.stripWhiteSpace(); title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); title = title.stripWhiteSpace(); getAuthor(); // groks author author = author.stripWhiteSpace(); if (authBox->isChecked()) { // this reverses the first name and last name of the author // qDebug("Sorting last name first"); QString lastName, firstName=""; int finder=author.findRev( ' ', -1, TRUE); lastName=author.right( author.length()-finder); firstName=author.left(finder); lastName=lastName.stripWhiteSpace(); firstName=firstName.stripWhiteSpace(); if( lastName.find( firstName, 0, true) == -1) // this avoids dup names author=lastName+", "+firstName; } if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) { // fill string list or something to be able to resort the whole library if( author.isEmpty() ) QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); else { if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file ); else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file ); else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); else QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); } } }// end if }// end while newindexLib.close(); } #ifndef Q_WS_QWS setCursor( arrowCursor); #endif #endif } // end Newlibrary() void LibraryDialog::Library() {// old library groking method ListView1->clear(); ListView2->clear(); ListView3->clear(); ListView4->clear(); ListView5->clear(); qDebug("opening GUTINDEX.ALL file"); IDontKnowWhy = ""; if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully QTextStream indexStream( &indexLib ); QString indexLine; qApp->processEvents(); // int jig; while ( !indexStream.eof() ) { indexLine = indexStream.readLine(); if ( indexLine != "") { if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) { // month = indexLine.left( 3); year = indexLine.mid(4,4); // title = indexLine.mid( 9, 50); file = indexLine.mid(60,12); if(file.left(1).find("[",0,TRUE) != -1) file.remove(1,1); if( file.find("]",0,TRUE) != -1) file = file.left( file.find("]",0,TRUE)); //qDebug("file is "+file); /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); number = indexLine.mid(55,5); number = number.stripWhiteSpace(); // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); title = indexLine.mid( 9, 50 ); title = title.stripWhiteSpace(); //qDebug("title is "+title); getAuthor(); // grok author author = author.stripWhiteSpace(); //qDebug("author is "+author); if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author QString lastName, firstName=""; int finder=author.findRev( ' ', -1, TRUE); lastName=author.right( author.length()-finder); firstName=author.left(finder); lastName=lastName.stripWhiteSpace(); firstName=firstName.stripWhiteSpace(); if( lastName.find( firstName, 0, true) == -1) // this avoids dup names author=lastName+", "+firstName; } if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) /*&& (file.find( "]",0, TRUE))*/ ) { // fill string list or something to be able to sort by Author if( author.isEmpty() ) QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); else { if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file ); else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); } } } } } indexLib.close(); } else { QString sMsg; sMsg = ( tr("Error opening local library index:\n "))+local_index; QMessageBox::message( "Error",sMsg); } } //end Library() /* Groks the author out of the title */ bool LibraryDialog::getAuthor() { if( title.contains( ", by", TRUE)) { int auth; auth = title.find(", by", 0, TRUE); author = title.right(title.length() - (auth + 4) ); if( int finder = author.find("[", 0, TRUE)) { author = author.left(finder); } } else if ( title.contains( "by, ", TRUE) ) { int auth; auth = title.find("by, ", 0, TRUE); author = title.right(title.length() - (auth + 4) ); if( int finder = author.find("[", 0, TRUE)) { author = author.left( finder); } } else if ( title.contains( " by", TRUE) ) { int auth; auth = title.find(" by", 0, TRUE); author = title.right(title.length() - (auth + 3) ); if( int finder = author.find("[", 0, TRUE)) { author = author.left( finder); } |