summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/LibraryDialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.cpp92
1 files changed, 48 insertions, 44 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
index 5b22b00..270a4cf 100644
--- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
@@ -13,17 +13,21 @@
// ***************************************************************************/
//ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL
+#include "LibraryDialog.h"
+#include "output.h"
+
+/* OPIE */
#include <qpe/applnk.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpedialog.h>
+#include <opie2/odebug.h>
-#include "LibraryDialog.h"
-#include "output.h"
-
+/* QT */
#include <qpushbutton.h>
#include <qmultilineedit.h>
//#include <qlayout.h>
+/* STD */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -64,7 +68,7 @@ LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool modal, W
config.setGroup( "FTPsite" );
ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
- qDebug("Library Dialog: ftp_host is "+ftp_host);
+ odebug << "Library Dialog: ftp_host is "+ftp_host << oendl;
// 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");
@@ -77,7 +81,7 @@ LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool modal, W
config.setGroup("General");
downDir =config.readEntry( "DownloadDirectory",local_library);
- qDebug("downDir is "+downDir);
+ odebug << "downDir is "+downDir << oendl;
newindexLib.setName( old_index);
indexLib.setName( old_index);
@@ -99,7 +103,7 @@ LibraryDialog::~LibraryDialog()
void LibraryDialog::Newlibrary()
{
#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files
- //qDebug("Opening new library index %s",newindexLib);
+ //odebug << "Opening new library index " << newindexLib << "" << oendl;
if ( newindexLib.open( IO_ReadOnly) ) {
setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully
QTextStream indexStream( &newindexLib );
@@ -121,7 +125,7 @@ void LibraryDialog::Newlibrary()
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");
+ // odebug << "Sorting last name first" << oendl;
QString lastName, firstName="";
int finder=author.findRev( ' ', -1, TRUE);
lastName=author.right( author.length()-finder);
@@ -180,7 +184,7 @@ void LibraryDialog::Library()
ListView4->clear();
ListView5->clear();
- qDebug("opening GUTINDEX.ALL file");
+ odebug << "opening GUTINDEX.ALL file" << oendl;
IDontKnowWhy = "";
if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully
QTextStream indexStream( &indexLib );
@@ -200,17 +204,17 @@ void LibraryDialog::Library()
file.remove(1,1);
if( file.find("]",0,TRUE) != -1)
file = file.left( file.find("]",0,TRUE));
- //qDebug("file is "+file);
+ //odebug << "file is "+file << oendl;
/// 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);
+ //odebug << "title is "+title << oendl;
getAuthor(); // grok author
author = author.stripWhiteSpace();
- //qDebug("author is "+author);
+ //odebug << "author is "+author << oendl;
if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author
QString lastName, firstName="";
int finder=author.findRev( ' ', -1, TRUE);
@@ -397,14 +401,14 @@ void LibraryDialog::select_title( QListViewItem * item)
if(DlglistItemTitle.length()>2) {
// DlglistItemNumber = item->text(0);
item = 0;
- qDebug( "string from librarydialog is:%s %s %s", DlglistItemYear.latin1(),DlglistItemFile.latin1(),DlglistItemNumber.latin1());
- qDebug("Title is "+DlglistItemTitle);
+ odebug << "string from librarydialog is:" << DlglistItemYear << " " << DlglistItemFile << " " << DlglistItemNumber << "" << oendl;
+ odebug << "Title is "+DlglistItemTitle << oendl;
// check for connection here
// if( get_extext())
if(download_Etext()) {
- // qDebug("get here 2");
+ // odebug << "get here 2" << oendl;
if(i_binary == 1) {
}
@@ -423,7 +427,7 @@ bool LibraryDialog::download_Etext()
ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org");
ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg");
- qDebug("about to network dialog");
+ odebug << "about to network dialog" << oendl;
QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile;
//////////////////// FIXME- if 'x' is part of real name....
@@ -431,11 +435,11 @@ bool LibraryDialog::download_Etext()
if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) {
NewlistItemFile.replace( 0,4, DlglistItemFile.left(4));
- qDebug("NewlistItemFile is now "+NewlistItemFile);
+ odebug << "NewlistItemFile is now "+NewlistItemFile << oendl;
}
NewlistItemYear = DlglistItemYear.right(2);
int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10);
- qDebug(NewlistItemYear);
+ odebug << NewlistItemYear << oendl;
if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) {
NewlistItemYear = "90";
}
@@ -447,8 +451,8 @@ bool LibraryDialog::download_Etext()
networkUrl= "ftp://"+ftp_host+dir;
outputFile=local_library+".guten_temp";
- //qDebug("Download file:%s",NewlistItemFile.latin1() );
- qDebug("Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile);
+ //odebug << "Download file:" << NewlistItemFile << "" << oendl;
+ odebug << "Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile << oendl;
QStringList networkList;
networkList.append((const char *)ftp_host);
networkList.append((const char *)dir);
@@ -462,18 +466,18 @@ bool LibraryDialog::download_Etext()
if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer
File_Name= NetworkDlg->localFileName;
- qDebug("back to Library from Network Dialog");
- qDebug("Just downloaded "+NetworkDlg->localFileName);
+ odebug << "back to Library from Network Dialog" << oendl;
+ odebug << "Just downloaded "+NetworkDlg->localFileName << oendl;
// if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found
// QString oldName=File_Name;
// File_Name.replace(0,local_library.length(),downDir);
- // qDebug("File_Name now is "+File_Name);
+ // odebug << "File_Name now is "+File_Name << oendl;
// }
// rename .txt to .etx
if(NetworkDlg->successDownload) {
- qDebug("Filename is "+File_Name);
+ odebug << "Filename is "+File_Name << oendl;
if(File_Name.right(4)==".txt") {
QString s_fileName=File_Name;
s_fileName.replace( s_fileName.length()-3,3,"gtn");
@@ -481,7 +485,7 @@ bool LibraryDialog::download_Etext()
rename(File_Name.latin1(),s_fileName.latin1());
File_Name=s_fileName;
- qDebug("Filename is now "+File_Name);
+ odebug << "Filename is now "+File_Name << oendl;
}
if(File_Name.length() > 5 ) {
@@ -490,20 +494,20 @@ bool LibraryDialog::download_Etext()
QString name_file=fi.fileName();
name_file=name_file.left(name_file.length()-4);
- qDebug("Setting doclink");
+ odebug << "Setting doclink" << oendl;
DocLnk lnk;
- qDebug("name is "+name_file);
+ odebug << "name is "+name_file << oendl;
lnk.setName(name_file); //sets file name
- qDebug("Title is "+DlglistItemTitle);
+ odebug << "Title is "+DlglistItemTitle << oendl;
lnk.setComment(DlglistItemTitle);
- qDebug("Filename is "+File_Name);
+ odebug << "Filename is "+File_Name << oendl;
lnk.setFile(File_Name); //sets File property
lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
lnk.setExec(File_Name);
lnk.setIcon("gutenbrowser/Gutenbrowser");
if(!lnk.writeLink()) {
- qDebug("Writing doclink did not work");
+ odebug << "Writing doclink did not work" << oendl;
} else {
}
} else
@@ -570,14 +574,14 @@ void LibraryDialog::cancelIt()
bool LibraryDialog::setTitle()
{
Config config("Gutenbrowser");
- qDebug("setting title");
- qDebug(DlglistItemTitle);
+ odebug << "setting title" << oendl;
+ odebug << DlglistItemTitle << oendl;
if( DlglistItemTitle.find("[",0,TRUE) != -1)
DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" );
if( DlglistItemTitle.find("]",0,TRUE) !=-1)
DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" );
- qDebug("Title being set is "+DlglistItemTitle);
+ odebug << "Title being set is "+DlglistItemTitle << oendl;
int test = 0;
QString ramble, temp;
config.setGroup("Files");
@@ -738,7 +742,7 @@ void LibraryDialog::onButtonSearch()
SearchResultsDialog->showMaximized();
if( SearchResultsDialog->exec() != 0) {
texter = SearchResultsDialog->selText;
- // qDebug(texter);
+ // odebug << texter << oendl;
resultLs= SearchResultsDialog->resultsList;
i_berger = 1;
}
@@ -749,7 +753,7 @@ void LibraryDialog::onButtonSearch()
QString tester;
for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) {
texter.sprintf("%s \n",(*it).latin1());
- // qDebug(texter);
+ // odebug << texter << oendl;
if( tester!=texter)
parseSearchResults( texter);
tester = texter;
@@ -806,7 +810,7 @@ void LibraryDialog::parseSearchResults( QString resultStr)
// int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No);
// if (exit==QMessageBox::Yes) {
- // qDebug("Issuing the command "+cmd);
+ // odebug << "Issuing the command "+cmd << oendl;
// #if defined(_WS_WIN_)
// WinExec( cmd, SW_HIDE );
// #endif
@@ -840,7 +844,7 @@ void LibraryDialog::sort()
Downloads the current selected listitem*/
bool LibraryDialog::getItem(QListViewItem *it)
{
- // qDebug("selected getItem");
+ // odebug << "selected getItem" << oendl;
// DlglistItemNumber = it->text(0);
DlglistItemTitle = it->text(0);
@@ -858,7 +862,7 @@ bool LibraryDialog::getItem(QListViewItem *it)
download button is pushed so we get the current items to download*/
bool LibraryDialog::onButtonDownload()
{
- // qDebug("selected onButtonDownloadz");
+ // odebug << "selected onButtonDownloadz" << oendl;
QListViewItemIterator it1( ListView1 );
QListViewItemIterator it2( ListView2 );
@@ -900,7 +904,7 @@ bool LibraryDialog::onButtonDownload()
handles the sorting combo box */
void LibraryDialog::comboSelect(int index)
{
- // qDebug("we are sorting");
+ // odebug << "we are sorting" << oendl;
ListView1->setSorting( index, TRUE);
ListView2->setSorting( index, TRUE);
ListView3->setSorting( index, TRUE);
@@ -930,7 +934,7 @@ void LibraryDialog::newList()
QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser");
if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true);
if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) {
- qDebug("changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser");
+ odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl;
QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1";
@@ -951,7 +955,7 @@ void LibraryDialog::newList()
fp = popen( (const char *) cmd, "r");
if ( !fp ) {
} else {
- qDebug("Issuing the command\n"+cmd);
+ odebug << "Issuing the command\n"+cmd << oendl;
// system(cmd);
while ( fgets( line, sizeof line, fp)) {
outDlg->OutputEdit->append(line);
@@ -965,7 +969,7 @@ void LibraryDialog::newList()
// if( QFile(gutenindex1).exists() ) {
// QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
// if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0)
- // qDebug("renaming error");
+ // odebug << "renaming error" << oendl;
// }
}
@@ -1024,7 +1028,7 @@ bool LibraryDialog::moreInfo()
}
item=0;
if(titleString.length()>2) {
- qDebug( "Title is "+titleString );
+ odebug << "Title is "+titleString << oendl;
titleString.replace( QRegExp("\\s"), "%20");
titleString.replace( QRegExp("'"), "%20");
titleString.replace( QRegExp("\""), "%20");
@@ -1048,12 +1052,12 @@ void LibraryDialog::FindLibrary()
if( QFile( new_index).exists() /* && this->isHidden() */) {
newindexLib.setName( new_index);
indexLib.setName( new_index);
- qDebug("index file is "+ new_index);
+ odebug << "index file is "+ new_index << oendl;
Newlibrary();
} else {
newindexLib.setName( old_index);
indexLib.setName( old_index);
- qDebug("new index nameis "+ old_index);
+ odebug << "new index nameis "+ old_index << oendl;
Library();
}
indexLoaded=true;