Diffstat (limited to 'noncore/apps/opie-gutenbrowser/gutenbrowser.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | 153 |
1 files changed, 79 insertions, 74 deletions
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp index 2a9a71e..be2b897 100644 --- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp +++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp @@ -15,11 +15,5 @@ // ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL // donate@gutenberg.net -#include <qpe/qpeapplication.h> -#include <qpe/fontdatabase.h> -#include <qpe/config.h> -#include <qpe/qcopenvelope_qws.h> -#include <qpe/mimetype.h> -#include <qpe/resource.h> -#include <qpe/applnk.h> + #include "editTitle.h" @@ -34,5 +28,15 @@ #include "output.h" +/* OPIE */ +#include <opie2/odebug.h> +#include <qpe/qpeapplication.h> +#include <qpe/fontdatabase.h> +#include <qpe/config.h> +#include <qpe/qcopenvelope_qws.h> +#include <qpe/mimetype.h> +#include <qpe/resource.h> +#include <qpe/applnk.h> +/* QT */ #include <qregexp.h> #include <qregion.h> @@ -52,4 +56,5 @@ #include <qpoint.h> +/* STD */ #include <stdio.h> #include <stdlib.h> @@ -132,5 +137,5 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) int index=config.readNumEntry( "LineNumber", -1 ); if( index != -1) { - // qDebug( tempTitle); + // odebug << tempTitle << oendl; bookmarksMenu->insertItem( tempTitle); } @@ -155,5 +160,5 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) // Bookmark(); for (int i=1;i< qApp->argc();i++) { - qDebug("Suppose we open somethin"); + odebug << "Suppose we open somethin" << oendl; load(qApp->argv()[i]); } @@ -170,5 +175,5 @@ Gutenbrowser::~Gutenbrowser() { // QPEApplication::grabKeyboard(); // QPEApplication::ungrabKeyboard(); - qDebug("Exit"); + odebug << "Exit" << oendl; } @@ -200,5 +205,5 @@ void Gutenbrowser::goGetit( const QString &url, bool showMsg) { else filename+="etc/gutenbrowser/"; - qDebug("filename "+filename); + odebug << "filename "+filename << oendl; // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; @@ -208,9 +213,9 @@ void Gutenbrowser::goGetit( const QString &url, bool showMsg) { config.setGroup( "Browser" ); QString brow = config.readEntry("Preferred", "Opera"); - qDebug("Preferred browser is "+brow); + odebug << "Preferred browser is "+brow << oendl; if(!showMsg) { //if we just get the gutenindex.all cmd="wget -O " + filename +" " + url+" 2>&1" ; chdir(local_library); - qDebug("Issuing the system command: %s", cmd.latin1()); + odebug << "Issuing the system command: " << cmd << "" << oendl; Output *outDlg; @@ -224,5 +229,5 @@ void Gutenbrowser::goGetit( const QString &url, bool showMsg) { sleep(1); fp = popen( (const char *) cmd, "r"); - // qDebug("Issuing the command\n"+cmd); + // odebug << "Issuing the command\n"+cmd << oendl; // system(cmd); while ( fgets( line, sizeof line, fp)) { @@ -257,5 +262,5 @@ void Gutenbrowser::goGetit( const QString &url, bool showMsg) { chdir(local_library); - qDebug("Issuing the sys command: %s", cmd.latin1()); + odebug << "Issuing the sys command: " << cmd << "" << oendl; system(cmd); } @@ -267,5 +272,5 @@ void Gutenbrowser::toggleButtonIcons( bool useEm) { useEm=TRUE; pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; - qDebug("Docdir is "+QPEApplication::documentDir()); + odebug << "Docdir is "+QPEApplication::documentDir() << oendl; if( useIcons && QDir( pixDir).exists() ) { @@ -382,5 +387,5 @@ void Gutenbrowser::PrintBtn() { void Gutenbrowser::SearchBtn() { if( loadCheck) { - qDebug("loadCheck: we have a loaded doc"); + odebug << "loadCheck: we have a loaded doc" << oendl; Search(); } @@ -405,5 +410,5 @@ void Gutenbrowser::ForwardBtn() { insertString+=s; Lview->insertLine( s, -1); - // qDebug(s); + // odebug << s << oendl; currentLine++; } @@ -424,5 +429,5 @@ void Gutenbrowser::ForwardBtn() { } else { - // qDebug("bal"); + // odebug << "bal" << oendl; // if( i_pageNum != pages) { @@ -439,5 +444,5 @@ void Gutenbrowser::ForwardBtn() { Lview->setFocus(); - // qDebug("page number %d line number %d", i_pageNum, currentLine); + // odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl; } @@ -458,5 +463,5 @@ void Gutenbrowser::BackBtn() { } else { if(!f.at( pageStopArray[i_pageNum - 1] )) - qDebug("File positioned backward did not work"); + odebug << "File positioned backward did not work" << oendl; } QString s; @@ -514,5 +519,5 @@ void Gutenbrowser::TopBtn() { if(loadCheck) { if( i_pageNum != 0) { - qDebug("top"); + odebug << "top" << oendl; qApp->processEvents(); currentLine = 0; @@ -572,9 +577,9 @@ void Gutenbrowser::BeginBtn() { pageStopArray.resize(i_pageNum + 1); pageStopArray[i_pageNum ] = currentFilePos; - // qDebug("new page number %d, found at %d", i_pageNum, currentFilePos); + // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; } // lastPage = i_pageNum; if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) { - qDebug("<<<<<< FOUND IT!! new page number %d, found at %d", i_pageNum, currentFilePos); + odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; break; } @@ -622,9 +627,9 @@ void Gutenbrowser::setBookmark() { file_name=cfg.readEntry("Current",""); qApp->processEvents(); - qDebug("Settingbook mark "+file_name); + odebug << "Settingbook mark "+file_name << oendl; cfg.setGroup("Titles"); title=cfg.readEntry(file_name,""); - qDebug("title is "+ title); + odebug << "title is "+ title << oendl; cfg.setGroup( "Bookmarks" ); @@ -655,9 +660,9 @@ void Gutenbrowser::Bookmark( int itemId) { config.setGroup( "Bookmarks" ); - // qDebug("<<<<<< %d, %d", Lview->PageSize(), Lview->lastRow() - Lview->topRow() ); + // odebug << "<<<<<< " << Lview->PageSize() << ", " << Lview->lastRow() - Lview->topRow() << "" << oendl; QString itemString; - qDebug("menu item %d", itemId); + odebug << "menu item " << itemId << "" << oendl; QString tempTitle; QString s_Bmrkrow; @@ -701,5 +706,5 @@ void Gutenbrowser::Bookmark( int itemId) { pageStopArray.resize(i_pageNum + 1); pageStopArray[i_pageNum ] = currentFilePos; - // qDebug("new page number %d, found at %d", i_pageNum, currentFilePos); + // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; } if(currentFilePos == bookmarkPosition) @@ -730,5 +735,5 @@ void Gutenbrowser::Bookmark( int itemId) { } - qDebug("bookmark loaded"); + odebug << "bookmark loaded" << oendl; setCaption(title); } @@ -738,6 +743,6 @@ bool Gutenbrowser::load( const char *fileName) { // QCopEnvelope ( "QPE/System", "busy()" ); - // qDebug("Title is already set as "+title); - qDebug("sizeHint %d pageSize %d", sizeHint().height(),Lview->PageSize() ); + // odebug << "Title is already set as "+title << oendl; + odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl; if( Lview->PageSize() < 4) { @@ -745,5 +750,5 @@ bool Gutenbrowser::load( const char *fileName) { Lview->setMinimumHeight( sizeHint().height() ); pointSize = Lview->fontInfo().pointSize(); - qDebug("sizeHint %d point size %d", sizeHint().height(), pointSize); + odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl; if(pointSize < 10) Lview->setFixedVisibleLines(19); @@ -763,5 +768,5 @@ bool Gutenbrowser::load( const char *fileName) { i_pageNum = 1; // } - qDebug("ready to open "+o_file); + odebug << "ready to open "+o_file << oendl; if(f.isOpen()) f.close(); @@ -799,5 +804,5 @@ bool Gutenbrowser::load( const char *fileName) { Lview->setMaxLines(Lview->PageSize()*2); - qDebug("Gulped %d", currentLine); + odebug << "Gulped " << currentLine << "" << oendl; setCaption(title); Lview->setAutoUpdate( TRUE); @@ -806,5 +811,5 @@ bool Gutenbrowser::load( const char *fileName) { // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; - //qDebug("number of pages %d", pages); + //odebug << "number of pages " << pages << "" << oendl; loadCheck = true; @@ -823,5 +828,5 @@ void Gutenbrowser::Search() { // if( searchDlg->isHidden()) { - qDebug("Starting search dialog"); + odebug << "Starting search dialog" << oendl; searchDlg = new SearchDialog( this, "Etext Search", true); searchDlg->setCaption( tr( "Etext Search" )); @@ -959,7 +964,7 @@ void Gutenbrowser::LibraryBtn() { QString newestLibraryFile ="pgwhole.zip"; QString zipFile; - // qDebug("Local Library is %s ", local_library.latin1()); + // odebug << "Local Library is " << local_library << " " << oendl; zipFile="/usr/bin/unzip"; - // qDebug("newestLibraryFile is %s ", newestLibraryFile.latin1()); + // odebug << "newestLibraryFile is " << newestLibraryFile << " " << oendl; if( QFile::exists( local_library+newestLibraryFile)) { if( QFile::exists(zipFile) ) { @@ -990,5 +995,5 @@ void Gutenbrowser::LibraryBtn() { listItemTitle = LibraryDlg->DlglistItemTitle; file_name = LibraryDlg->File_Name; - // qDebug("title is being set as "+title); + // odebug << "title is being set as "+title << oendl; title = listItemTitle; @@ -1012,5 +1017,5 @@ void Gutenbrowser::LibraryBtn() { if( file_name.find(".zip")) { - qDebug("Found zip file\n"); + odebug << "Found zip file\n" << oendl; // QStringList args; // args="unzip"; @@ -1020,5 +1025,5 @@ void Gutenbrowser::LibraryBtn() { // args+=local_library; QString cmd = "/usr/bin/unzip -o " + local_library+file_name + " -d " + local_library; - qDebug("Issuing the command "+ cmd); + odebug << "Issuing the command "+ cmd << oendl; // unzipProc=new QProcess( this, "unzipProc" ); /// fark that idea! // unzipProc->start(); @@ -1063,5 +1068,5 @@ void Gutenbrowser::OpenBtn() { if( OpenDlg->exec() != 0) { title = OpenDlg->openFileTitle; - qDebug("title open as "+title); + odebug << "title open as "+title << oendl; file_name = OpenDlg->file; i_pageNum = 1; @@ -1070,5 +1075,5 @@ void Gutenbrowser::OpenBtn() { if(showMainList) { showMainList=FALSE; - qDebug("ShowMainList is now false"); + odebug << "ShowMainList is now false" << oendl; mainList->hide(); Lview->show(); @@ -1079,5 +1084,5 @@ void Gutenbrowser::OpenBtn() { load(file_name); } else { - qDebug("file_name is empty!"); + odebug << "file_name is empty!" << oendl; if(showMainList) { if(!Lview->isHidden()) @@ -1245,5 +1250,5 @@ bool Gutenbrowser::getTitle( const char *file ) { config.setGroup( "Titles" ); title = config.readEntry(ramble, ""); - // qDebug("(getTitle)title is being set as "+title); + // odebug << "(getTitle)title is being set as "+title << oendl; } } @@ -1447,5 +1452,5 @@ void Gutenbrowser::keyPressEvent( QKeyEvent *e) { void Gutenbrowser::resizeEvent( QResizeEvent *ev) { - // qDebug("resize: %d,%d\n",ev->size().width(),ev->size().height()); + // odebug << "resize: " << ev->size().width() << "," << ev->size().height() << "\n" << oendl; if( !LibraryDlg->isHidden()) @@ -1477,5 +1482,5 @@ void Gutenbrowser::doOptions() { Ddir=optDlg->downloadDirEdit->text(); - qDebug("writing library config"); + odebug << "writing library config" << oendl; Config config("Gutenbrowser"); config.setGroup("General"); @@ -1494,5 +1499,5 @@ void Gutenbrowser::doOptions() { cmd+=Ddir.latin1(); system(cmd); - qDebug("Making new dir "+cmd); + odebug << "Making new dir "+cmd << oendl; if(Ddir.right(1)!="/") { Ddir+="/"; @@ -1510,5 +1515,5 @@ void Gutenbrowser::doOptions() { if(optDlg->fontDlg-> changedFonts) { - qDebug("Setting font"); + odebug << "Setting font" << oendl; myFont=optDlg->fontDlg->selectedFont; Lview->setFont( myFont); @@ -1516,9 +1521,9 @@ void Gutenbrowser::doOptions() { if(optDlg->useWordWrap_CheckBox->isChecked() ) { - qDebug("WORD WRAP is set"); + odebug << "WORD WRAP is set" << oendl; Lview->setWordWrap(QMultiLineEdit::WidgetWidth); useWrap=true; } else { - qDebug("Word wrap is NOT set"); + odebug << "Word wrap is NOT set" << oendl; Lview->setWordWrap(QMultiLineEdit::NoWrap); useWrap=false; @@ -1579,6 +1584,6 @@ bool Gutenbrowser::setTitle() { void Gutenbrowser::OnNetworkDialog( const QString &/*networkUrl*/, const QString &/*output*/) { - // qDebug(networkUrl); - // qDebug(output); + // odebug << networkUrl << oendl; + // odebug << output << oendl; // #ifndef Q_WS_QWS // NetworkDialog *NetworkDlg; @@ -1713,5 +1718,5 @@ void Gutenbrowser::cleanUp( ) QPEApplication::ungrabKeyboard(); - // qDebug("Cleanup"); + // odebug << "Cleanup" << oendl; if(f.isOpen()) f.close(); } @@ -1719,5 +1724,5 @@ void Gutenbrowser::cleanUp( ) void Gutenbrowser::fixKeys() { - qDebug("Attempting to fix keys"); + odebug << "Attempting to fix keys" << oendl; } @@ -1773,5 +1778,5 @@ void Gutenbrowser::listClickedSlot( QListBoxItem * index) { config.setGroup( "Files" ); QString file = config.readEntry(temp, ""); - qDebug("About to load"); + odebug << "About to load" << oendl; if( Lview->isVisible()) load(file); @@ -1814,9 +1819,9 @@ void Gutenbrowser::setDocument(const QString & frozenBoogers) { DocLnk lnk; lnk = DocLnk(frozenBoogers); - // qDebug(lnk.file() ); + // odebug << lnk.file() << oendl; title=lnk.comment(); load( lnk.file()); this->show(); - // qDebug(title); + // odebug << title << oendl; // qApp->processEvents(); // repaint(); @@ -1874,5 +1879,5 @@ void Gutenbrowser::menuEditTitle() int currentItem = mainList->currentItem(); QString title_text = mainList->text( currentItem); - //qDebug("Selected "+title_text); + //odebug << "Selected "+title_text << oendl; Config config("Gutenbrowser"); @@ -1888,13 +1893,13 @@ void Gutenbrowser::menuEditTitle() config.setGroup( "Titles" ); QString file_title = config.readEntry( s_filename, ""); - //qDebug("file_title is "+file_title); + //odebug << "file_title is "+file_title << oendl; if(title_text == file_title ) { // selFile = s_filename; - //qDebug("Edit: "+ file_title ); + //odebug << "Edit: "+ file_title << oendl; i=i_numofFiles+1; Edit_Title *titleEdit; titleEdit = new Edit_Title(this,file_title ,TRUE); if(titleEdit->exec() !=0) { - //qDebug(titleEdit->newTitle); + //odebug << titleEdit->newTitle << oendl; config.writeEntry( s_filename, titleEdit->newTitle); mainList->removeItem(currentItem); @@ -1912,5 +1917,5 @@ void Gutenbrowser::menuEditTitle() bool Gutenbrowser::UnZipIt(const QString &zipFile) { - qDebug(zipFile); + odebug << zipFile << oendl; #ifndef Q_WS_QWS if( QFile::exists( zipFile)) { // TODO findsome other way of dealingwithzip files. @@ -1924,9 +1929,9 @@ bool Gutenbrowser::UnZipIt(const QString &zipFile) { // thatFile=zipFile.left(4); // } - // qDebug((const char*)local_library.latin1()); + // odebug << (const char*)local_library.latin1() << oendl; QString cmd; #if defined(_WS_X11_) if( chdir((const char*)local_library.latin1())!=0) - qDebug("chdir failed."); + odebug << "chdir failed." << oendl; cmd = "gunzip -S .zip " + local_library+zipFile; //cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; @@ -1934,5 +1939,5 @@ bool Gutenbrowser::UnZipIt(const QString &zipFile) { #ifdef Q_WS_QWS if( chdir((const char*)local_library.latin1())!=0) - qDebug("chdir failed."); + odebug << "chdir failed." << oendl; cmd = "unzip " + local_library+zipFile; // cmd = "/usr/bin/unzip -o " + local_library+zipFile +" -d /usr/share/doc/gutenbrowser" ;//+ local_library; @@ -1943,5 +1948,5 @@ bool Gutenbrowser::UnZipIt(const QString &zipFile) { if (exit==QMessageBox::Yes) { #if defined(_WS_X11_)// - qDebug("Issuing the command "+cmd); + odebug << "Issuing the command "+cmd << oendl; system( cmd); if( QFile::exists(thatFile)) @@ -1949,12 +1954,12 @@ bool Gutenbrowser::UnZipIt(const QString &zipFile) { if(isPgWhole) { if( rename("pgwhole","PGWHOLE.TXT") !=0) - qDebug("rename failed"); + odebug << "rename failed" << oendl; } else { if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) - qDebug("rename failed"); + odebug << "rename failed" << oendl; } #endif #ifdef Q_WS_QWS - qDebug("Issuing the command "+cmd); + odebug << "Issuing the command "+cmd << oendl; system( cmd); if( QFile::exists(thatFile)) @@ -1962,8 +1967,8 @@ bool Gutenbrowser::UnZipIt(const QString &zipFile) { if(isPgWhole) { if( rename("pgwhole","PGWHOLE.TXT") !=0) - qDebug("rename failed"); + odebug << "rename failed" << oendl; } else { if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) - qDebug("rename failed"); + odebug << "rename failed" << oendl; } #endif @@ -1972,5 +1977,5 @@ bool Gutenbrowser::UnZipIt(const QString &zipFile) { } else if(exit==QMessageBox::No) { - // qDebug("unzip"); + // odebug << "unzip" << oendl; return false; } |