summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/gutenbrowser.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp153
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
@@ -14,13 +14,7 @@
// http://digital.library.upenn.edu/books/titles.html
// 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"
#include "gutenbrowser.h"
@@ -33,7 +27,17 @@
#include "openetext.h"
#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>
#include <qpaintdevicemetrics.h>
@@ -51,6 +55,7 @@
#include <qscrollview.h>
#include <qpoint.h>
+/* STD */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -131,7 +136,7 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
config.setGroup( tempTitle);
int index=config.readNumEntry( "LineNumber", -1 );
if( index != -1) {
- // qDebug( tempTitle);
+ // odebug << tempTitle << oendl;
bookmarksMenu->insertItem( tempTitle);
}
}
@@ -154,7 +159,7 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
// if(firstTime)
// Bookmark();
for (int i=1;i< qApp->argc();i++) {
- qDebug("Suppose we open somethin");
+ odebug << "Suppose we open somethin" << oendl;
load(qApp->argv()[i]);
}
} else {
@@ -169,7 +174,7 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
Gutenbrowser::~Gutenbrowser() {
// QPEApplication::grabKeyboard();
// QPEApplication::ungrabKeyboard();
- qDebug("Exit");
+ odebug << "Exit" << oendl;
}
/*
@@ -199,7 +204,7 @@ void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
filename+="/etc/gutenbrowser/";
else
filename+="etc/gutenbrowser/";
- qDebug("filename "+filename);
+ odebug << "filename "+filename << oendl;
// QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/";
filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1);
@@ -207,11 +212,11 @@ void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
Config config("Gutenbrowser");
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;
outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE);
@@ -223,7 +228,7 @@ void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
outDlg->OutputEdit->append( tr("Running wget") );
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)) {
outDlg->OutputEdit->append(line);
@@ -256,7 +261,7 @@ 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);
}
}
@@ -266,7 +271,7 @@ void Gutenbrowser::toggleButtonIcons( bool useEm) {
if(useEm)
useEm=TRUE;
pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser";
- qDebug("Docdir is "+QPEApplication::documentDir());
+ odebug << "Docdir is "+QPEApplication::documentDir() << oendl;
if( useIcons && QDir( pixDir).exists() ) {
LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline
@@ -381,7 +386,7 @@ void Gutenbrowser::PrintBtn() {
void Gutenbrowser::SearchBtn() {
if( loadCheck) {
- qDebug("loadCheck: we have a loaded doc");
+ odebug << "loadCheck: we have a loaded doc" << oendl;
Search();
}
// else
@@ -404,7 +409,7 @@ void Gutenbrowser::ForwardBtn() {
s.replace(QRegExp("\n"),"");
insertString+=s;
Lview->insertLine( s, -1);
- // qDebug(s);
+ // odebug << s << oendl;
currentLine++;
}
// Lview->insertAt( insertString,0,0, FALSE);
@@ -423,7 +428,7 @@ void Gutenbrowser::ForwardBtn() {
// }
} else {
- // qDebug("bal");
+ // odebug << "bal" << oendl;
// if( i_pageNum != pages) {
// // int newTop = Lview->Top();
@@ -438,7 +443,7 @@ void Gutenbrowser::ForwardBtn() {
}
Lview->setFocus();
- // qDebug("page number %d line number %d", i_pageNum, currentLine);
+ // odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl;
}
@@ -457,7 +462,7 @@ void Gutenbrowser::BackBtn() {
f.at( 0);
} 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;
// int sizeLine=0;
@@ -513,7 +518,7 @@ void Gutenbrowser::TopBtn() {
if(loadCheck) {
if( i_pageNum != 0) {
- qDebug("top");
+ odebug << "top" << oendl;
qApp->processEvents();
currentLine = 0;
i_pageNum = 1;
@@ -571,11 +576,11 @@ void Gutenbrowser::BeginBtn() {
if(lastPage < i_pageNum) {
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;
}
}
@@ -621,11 +626,11 @@ void Gutenbrowser::setBookmark() {
cfg.setGroup("General");
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" );
@@ -654,11 +659,11 @@ void Gutenbrowser::Bookmark( int itemId) {
Config config("Gutenbrowser");
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;
QString s_pageNum;
@@ -700,7 +705,7 @@ void Gutenbrowser::Bookmark( int itemId) {
if(lastPage < i_pageNum) {
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)
break;
@@ -729,7 +734,7 @@ void Gutenbrowser::Bookmark( int itemId) {
// qApp->processEvents();
}
- qDebug("bookmark loaded");
+ odebug << "bookmark loaded" << oendl;
setCaption(title);
}
@@ -737,14 +742,14 @@ void Gutenbrowser::Bookmark( int itemId) {
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) {
Lview->setMaximumHeight( sizeHint().height() );
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);
else
@@ -762,7 +767,7 @@ bool Gutenbrowser::load( const char *fileName) {
// if (i_pageNum < 1) {
i_pageNum = 1;
// }
- qDebug("ready to open "+o_file);
+ odebug << "ready to open "+o_file << oendl;
if(f.isOpen()) f.close();
f.setName( o_file);
@@ -798,14 +803,14 @@ bool Gutenbrowser::load( const char *fileName) {
currentFilePos, i_pageNum, Lview->length(), pageStopArray[i_pageNum], Lview->PageSize() );
Lview->setMaxLines(Lview->PageSize()*2);
- qDebug("Gulped %d", currentLine);
+ odebug << "Gulped " << currentLine << "" << oendl;
setCaption(title);
Lview->setAutoUpdate( TRUE);
Lview->setCursorPosition(0,0,FALSE);
// pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1;
- //qDebug("number of pages %d", pages);
+ //odebug << "number of pages " << pages << "" << oendl;
loadCheck = true;
enableButtons(true);
@@ -822,7 +827,7 @@ 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" ));
// searchDlg->setLabel( "- searches etext");
@@ -958,9 +963,9 @@ 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) ) {
UnZipIt(newestLibraryFile);
@@ -989,7 +994,7 @@ void Gutenbrowser::LibraryBtn() {
listItemYear = LibraryDlg->DlglistItemYear;
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;
// config.setGroup( "Proxy" );
@@ -1011,7 +1016,7 @@ void Gutenbrowser::LibraryBtn() {
//
if( file_name.find(".zip"))
{
- qDebug("Found zip file\n");
+ odebug << "Found zip file\n" << oendl;
// QStringList args;
// args="unzip";
// args+="-o";
@@ -1019,7 +1024,7 @@ void Gutenbrowser::LibraryBtn() {
// args+="-d";
// 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();
system(cmd);
@@ -1062,14 +1067,14 @@ 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;
if( !file_name.isEmpty() || file_name.length() > 2 ) {
if(showMainList) {
showMainList=FALSE;
- qDebug("ShowMainList is now false");
+ odebug << "ShowMainList is now false" << oendl;
mainList->hide();
Lview->show();
qApp->processEvents();
@@ -1078,7 +1083,7 @@ void Gutenbrowser::OpenBtn() {
// QCopEnvelope ( "QPE/System", "busy()" );
load(file_name);
} else {
- qDebug("file_name is empty!");
+ odebug << "file_name is empty!" << oendl;
if(showMainList) {
if(!Lview->isHidden())
Lview->hide();
@@ -1244,7 +1249,7 @@ bool Gutenbrowser::getTitle( const char *file ) {
if( strcmp(ramble, s_file) == 0) {
config.setGroup( "Titles" );
title = config.readEntry(ramble, "");
- // qDebug("(getTitle)title is being set as "+title);
+ // odebug << "(getTitle)title is being set as "+title << oendl;
}
}
return true;
@@ -1446,7 +1451,7 @@ 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())
LibraryDlg->resize(ev->size().width(),ev->size().height() );
@@ -1476,7 +1481,7 @@ void Gutenbrowser::doOptions() {
brow=optDlg->browserName;
Ddir=optDlg->downloadDirEdit->text();
- qDebug("writing library config");
+ odebug << "writing library config" << oendl;
Config config("Gutenbrowser");
config.setGroup("General");
@@ -1493,7 +1498,7 @@ void Gutenbrowser::doOptions() {
QString cmd="mkdir -p ";
cmd+=Ddir.latin1();
system(cmd);
- qDebug("Making new dir "+cmd);
+ odebug << "Making new dir "+cmd << oendl;
if(Ddir.right(1)!="/") {
Ddir+="/";
}
@@ -1509,17 +1514,17 @@ void Gutenbrowser::doOptions() {
b_queryExit=FALSE;
if(optDlg->fontDlg-> changedFonts) {
- qDebug("Setting font");
+ odebug << "Setting font" << oendl;
myFont=optDlg->fontDlg->selectedFont;
Lview->setFont( myFont);
}
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;
}
@@ -1578,8 +1583,8 @@ bool Gutenbrowser::setTitle() {
/*Calls new fangled network dialog */
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;
// if( networkUrl.length() < 4 ) networkUrl= "http://sailor.gutenberg.org/mirror.sites.html";
@@ -1712,13 +1717,13 @@ void Gutenbrowser::cleanUp( )
QPEApplication::grabKeyboard();
QPEApplication::ungrabKeyboard();
- // qDebug("Cleanup");
+ // odebug << "Cleanup" << oendl;
if(f.isOpen()) f.close();
}
void Gutenbrowser::fixKeys()
{
- qDebug("Attempting to fix keys");
+ odebug << "Attempting to fix keys" << oendl;
}
@@ -1772,7 +1777,7 @@ void Gutenbrowser::listClickedSlot( QListBoxItem * index) {
Config config("Gutenbrowser");
config.setGroup( "Files" );
QString file = config.readEntry(temp, "");
- qDebug("About to load");
+ odebug << "About to load" << oendl;
if( Lview->isVisible())
load(file);
@@ -1813,11 +1818,11 @@ 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();
}
@@ -1873,7 +1878,7 @@ 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");
config.setGroup( "Files" );
@@ -1887,15 +1892,15 @@ void Gutenbrowser::menuEditTitle()
QString s_filename = config.readEntry(fileNum, "" );
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);
mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), titleEdit->newTitle, currentItem);
@@ -1911,7 +1916,7 @@ 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.
bool isPgWhole=false;
@@ -1923,17 +1928,17 @@ bool Gutenbrowser::UnZipIt(const QString &zipFile) {
// else {
// 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;
#endif
#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;
#endif
@@ -1942,36 +1947,36 @@ bool Gutenbrowser::UnZipIt(const QString &zipFile) {
QMessageBox::Yes, QMessageBox::No);
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))
remove (thatFile);
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))
remove(thatFile);
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
// remove( zipFile);
return true;
}
else if(exit==QMessageBox::No) {
- // qDebug("unzip");
+ // odebug << "unzip" << oendl;
return false;
}
}