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
@@ -5,61 +5,66 @@
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. *
***************************************************************************/
// http search
// http://digital.library.upenn.edu/books/authors.html
// 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"
#include "LibraryDialog.h"
//#include "bookmarksdlg.h"
#include "optionsDialog.h"
#include "helpme.h"
#include "NetworkDialog.h"
#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>
#include <qvaluelist.h>
#include <qlabel.h>
#include <qclipboard.h>
#include <qpainter.h>
#include <qpalette.h>
#include <qobjectlist.h>
#include <qfontdialog.h>
#include <qtextview.h>
#include <qbrush.h>
#include <qfile.h>
#include <qfontinfo.h>
#include <qscrollview.h>
#include <qpoint.h>
+/* STD */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
static const int nfontsizes = 9;
static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24};
#ifdef NOQUICKLAUNCH
Gutenbrowser::Gutenbrowser()
@@ -122,63 +127,63 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
QString tempFileName;
for (int i = 0; i <= i_numofFiles; i++) {
// tempFileName.setNum(i);
config.setGroup( "Files" );
QString ramble = config.readEntry( QString::number(i), "" );
config.setGroup( "Titles" );
QString tempTitle = config.readEntry( ramble, "");
config.setGroup( tempTitle);
int index=config.readNumEntry( "LineNumber", -1 );
if( index != -1) {
- // qDebug( tempTitle);
+ // odebug << tempTitle << oendl;
bookmarksMenu->insertItem( tempTitle);
}
}
// QString gutenIndex= local_library + "GUTINDEX.ALL";
QString gutenIndex= QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL";
if( QFile( gutenIndex).exists() ) {
indexLib.setName( gutenIndex);
} else {
QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT";
// QString localLibIndexFile= local_library + "PGWHOLE.TXT";
newindexLib.setName( localLibIndexFile);
}
LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */);
loadCheck=false;
chdir(local_library);
if(!showMainList) {
Lview->setFocus();
// 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 {
fillWithTitles();
mainList->setFocus();
// mainList->setCurrentItem(0);
}
writeConfig();
} //end init
Gutenbrowser::~Gutenbrowser() {
// QPEApplication::grabKeyboard();
// QPEApplication::ungrabKeyboard();
- qDebug("Exit");
+ odebug << "Exit" << oendl;
}
/*
Google.com search */
void Gutenbrowser::InfoBarClick() {
QString text;
if( Lview->hasSelectedText()) {
Lview->copy();
QClipboard *cb = QApplication::clipboard();
text = cb->text();
} else {
// text=title;
@@ -190,49 +195,49 @@ void Gutenbrowser::InfoBarClick() {
/*
download http with wget or preferred browser */
void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
// int eexit=0;
QString cmd;
// config.read();
qApp->processEvents();
QString filename = QPEApplication::qpeDir();
if(filename.right(1)!="/")
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);
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);
outDlg->showMaximized();
outDlg->show();
qApp->processEvents();
FILE *fp;
char line[130];
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);
outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
}
pclose(fp);
outDlg->close();
if(outDlg)
delete outDlg;
} else {
if( brow == "Konq") {
cmd = "konqueror "+url+" &";
@@ -247,35 +252,35 @@ void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
cmd = "mozilla "+url+" &";
}
if( brow == "Netscape") {
cmd = "netscape "+url+" &";
}
if(brow == "wget") {
// cmd="wget -q "+url+" &";
QString tempHtml=local_library+"webster.html";
cmd="wget -O "+tempHtml+" -q "+url;
}
chdir(local_library);
- qDebug("Issuing the sys command: %s", cmd.latin1());
+ odebug << "Issuing the sys command: " << cmd << "" << oendl;
system(cmd);
}
}
void Gutenbrowser::toggleButtonIcons( bool useEm) {
QString pixDir;
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
OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook"));
ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline
BackButton->setPixmap( Resource::loadPixmap("back") );//in inline
SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline
lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder"));
setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") );
dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") );
InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google"));
}
@@ -372,101 +377,101 @@ void Gutenbrowser::downloadLibIndex() {
//// QMessageBox::message("Note","");
// }
// if(NetworkDlg)
// delete NetworkDlg;
}
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
// QMessageBox::message("Note","Sorry, can't search. No etext is loaded");
}
void Gutenbrowser::ForwardBtn() {
if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) {
QString s;
QString insertString;
int pageSize= Lview->PageSize();
Lview->clear();
for(int fd=0; fd < pageSize - 1;fd++) {
f.readLine(s, 256);
if(useWrap)
s.replace(QRegExp("\n"),"");
insertString+=s;
Lview->insertLine( s, -1);
- // qDebug(s);
+ // odebug << s << oendl;
currentLine++;
}
// Lview->insertAt( insertString,0,0, FALSE);
currentFilePos = f.at();
// if( i_pageNum != pages) {
// Lview->MultiLine_Ex::pageDown( FALSE);
i_pageNum++;
pageStopArray.resize(i_pageNum + 1);
// int length = Lview->length();
pageStopArray[i_pageNum ] = currentFilePos;
// qDebug("%d current page is number %d, pagesize %d, length %d, current %d",
// currentFilePos, i_pageNum, pageSize, Lview->length(), pageStopArray[i_pageNum] );
setStatus();
Lview->setCursorPosition( 0, 0, FALSE);
// }
} else {
- // qDebug("bal");
+ // odebug << "bal" << oendl;
// if( i_pageNum != pages) {
// // int newTop = Lview->Top();
// // if(Lview->lastRow() > i)
// Lview->ScrollUp(1);
// // i_pageNum++;
// setStatus();
// Lview->setCursorPosition( Lview->Top(), 0, FALSE);
// }
}
Lview->setFocus();
- // qDebug("page number %d line number %d", i_pageNum, currentLine);
+ // odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl;
}
void Gutenbrowser::BackBtn() {
if( i_pageNum > 0) {
int pageSize= Lview->PageSize();
// int length=Lview->length();
i_pageNum--;
currentFilePos = f.at();
// qDebug("%d move back to %d, current page number %d, %d, length %d",
// currentFilePos, pageStopArray[i_pageNum - 1 ], i_pageNum, pageSize, Lview->length() );
if( i_pageNum < 2) {
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;
Lview->clear();
// QString insertString;
for(int fd = 0; fd < pageSize ;fd++) {
// Lview->removeLine( Lview->PageSize() );
f.readLine(s, 256);
if(useWrap)
s.replace(QRegExp("\n"),"");
currentLine++;
@@ -504,25 +509,25 @@ void Gutenbrowser::BackBtn() {
void Gutenbrowser::doBeginBtn() {
if(loadCheck) {
qApp->processEvents();
BeginBtn();
}
}
// moves text to the very top = 0
void Gutenbrowser::TopBtn() {
if(loadCheck) {
if( i_pageNum != 0) {
- qDebug("top");
+ odebug << "top" << oendl;
qApp->processEvents();
currentLine = 0;
i_pageNum = 1;
int pageSize = Lview->PageSize() ;
Lview->clear();
QString s;
f.at(0);
for(int fd=0; fd < pageSize ;fd++) {
f.readLine(s, 256);
if(useWrap)
s.replace(QRegExp("\n"),"");
Lview->insertLine(s ,-1);
@@ -562,29 +567,29 @@ void Gutenbrowser::BeginBtn() {
f.at( 0);
while ( !f.atEnd() ) {
f.readLine(s, 256);
lineNo++;
LeftText = s;
currentFilePos = f.at();
i_pageNum = lineNo/pageSize;
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;
}
}
if(f.atEnd()) //in case we didnt find anything, we need to show something
f.at(0);
Lview->clear();
for(int fd=0; fd < pageSize - 1;fd++) {
f.readLine(s, 256);
if(useWrap)
s.replace(QRegExp("\n"),"");
Lview->insertLine( s, -1);
currentLine++;
@@ -612,29 +617,29 @@ void Gutenbrowser::BeginBtn() {
void Gutenbrowser::setBookmark() {
int eexit=QMessageBox::information(this, "Note",
"Do you really want to \nset this bookmark?."
,QMessageBox::Yes, QMessageBox::No);
if (eexit== 3) {
currentFilePos = f.at();
Config cfg("Gutenbrowser");
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" );
cfg.writeEntry("File Name",file_name);
cfg.writeEntry("Page Number",QString::number(i_pageNum) );
cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1]));
cfg.writeEntry("Title", title);
int row = Lview->topRow();// Lview->Top();
cfg.writeEntry("LineNumber",QString::number(row) );
cfg.setGroup(title);
@@ -645,29 +650,29 @@ void Gutenbrowser::setBookmark() {
bookmarksMenu->insertItem( title);
}
} //end setBookmark
/* goes to last set bookmark*/
void Gutenbrowser::Bookmark( int itemId) {
// qApp->processEvents();
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;
int Bmrkrow=0;
int bookmarkPosition = 0;
// qApp->processEvents();
config.setGroup( "Bookmarks" );
title = config.readEntry("Title", "");
file_name = config.readEntry("File Name", "");
i_pageNum = config.readNumEntry("Page Number", 0);
bookmarkPosition = config.readNumEntry( "PagePosition",0);
@@ -691,25 +696,25 @@ void Gutenbrowser::Bookmark( int itemId) {
QString s;
int lineNo=0;
int lastPage=1;
while ( !f.atEnd() ) {
f.readLine(s, 256);
lineNo++;
currentFilePos = f.at();
i_pageNum = lineNo/pageSize;
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;
}
if(f.atEnd())
f.at(0);
else
f.at( bookmarkPosition);
for(int fd=0; fd < pageSize - 1;fd++) {
f.readLine(s, 256);
lineNo++;
@@ -720,58 +725,58 @@ void Gutenbrowser::Bookmark( int itemId) {
}
i_pageNum = lineNo/pageSize;
pageStopArray.resize(i_pageNum + 1);
if(showMainList) {
showMainList=FALSE;
mainList->hide();
Lview->show();
// qApp->processEvents();
}
- qDebug("bookmark loaded");
+ odebug << "bookmark loaded" << oendl;
setCaption(title);
}
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
Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2);
}
Config cfg("Gutenbrowser");
cfg.setGroup("General");
cfg.writeEntry("Current",fileName);
currentLine=0;
file_name=fileName;
QString o_file = 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);
if ( !f.open( IO_ReadOnly)) {
QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) );
return false;
}
currentFilePos = 0;
pageStopArray.resize(3);
pageStopArray[0] = currentFilePos;
@@ -789,49 +794,49 @@ bool Gutenbrowser::load( const char *fileName) {
currentLine++;
}
// int length = Lview->length();
currentFilePos = f.at();
pageStopArray[1] = currentFilePos;
qDebug("<<<<<<<<<<<%d current page is number %d, length %d, current %d, pageSize %d",
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);
if( donateMenu->count() == 3) {
donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() ));
}
Lview->setFocus();
// QCopEnvelope("QPE/System", "notBusy()" );
return true;
} // end load
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");
connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot()));
connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot()));
QString resultString;
QString string = searchDlg->searchString;
Lview->deselect();
searchDlg->show();
searchDlg->result();
}
@@ -949,27 +954,27 @@ int Gutenbrowser::doSearch( const QString &s_pattern , bool case_sensitive, boo
return 1;
}
}
}
}
return 0;
}
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);
}
else
QMessageBox::message( "Note",( tr("Please install unzip")) );
}
// LibraryDlg = new LibraryDialog( this, "Library Index");
LibraryDlg->setCaption( tr( "Gutenberg Library"));
Config config("Gutenbrowser");
config.setGroup("General");
QString tmp=config.readEntry("RunBefore","FALSE");
@@ -980,55 +985,55 @@ void Gutenbrowser::LibraryBtn() {
}
if(useSplitter)
LibraryDlg->useSmallInterface=FALSE;
LibraryDlg->showMaximized();
if( LibraryDlg->exec() != 0 ) {
listItemNumber = LibraryDlg->DlglistItemNumber;
listItemFile = LibraryDlg->DlglistItemFile;
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" );
// if( LibraryDlg->checked == 1) {
// config.writeEntry("IsChecked", "TRUE");
// } else {
// config.writeEntry("IsChecked", "FALSE");
// }
// config.write();
// config.read();
if ( listItemNumber.isNull()) {
} else {
i_pageNum = 1;
if( file_name !="Error" && file_name.length() >2 && !file_name.isEmpty() ) {
//replace .zip with txt for opening it.
// printf("\nFile name is now\n");
// printf(file_name);
// printf("\n");
//
if( file_name.find(".zip"))
{
- qDebug("Found zip file\n");
+ odebug << "Found zip file\n" << oendl;
// QStringList args;
// args="unzip";
// args+="-o";
// args+=local_library+file_name;
// 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);
remove( file_name);
}
// //
// file_name = file_name.left(4)+ ".txt";
if( LibraryDlg)
delete LibraryDlg;
setTitle();
// QCopEnvelope ( "QPE/System", "busy()" );
@@ -1053,41 +1058,41 @@ void Gutenbrowser::LibraryBtn() {
// fixKeys();
}
void Gutenbrowser::OpenBtn() {
QString s_temp;
s_temp = status;
OpenEtext* OpenDlg;
OpenDlg = new OpenEtext(this,"OpenDlg");
OpenDlg->showMaximized();
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();
}
Lview->clear();
// 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();
qApp->processEvents();
if(mainList->isHidden())
mainList->show();
fillWithTitles();
qApp->processEvents();
}
}
}
@@ -1235,25 +1240,25 @@ bool Gutenbrowser::getTitle( const char *file ) {
config.setGroup( "Files" );
QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
int i_numofFiles = s_numofFiles.toInt();
for (int i = 1; i <= i_numofFiles; i++) {
QString temp;
temp.setNum(i);
QString ramble = config.readEntry(temp, "" );
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;
}
void Gutenbrowser::searchdone_slot() {
// if (!searchDlg)
// return;
// searchDlg->hide();
// Lview->setFocus();
this->setFocus();
last_search = 0;
@@ -1437,25 +1442,25 @@ void Gutenbrowser::keyPressEvent( QKeyEvent *e) {
// if(useSplitter) Rview->MultiLine_Ex::ScrollUp( 1);
// break;
// case Key_Up:
// if( Lview->Top() != 0) {
// Lview->MultiLine_Ex::ScrollDown( 1);
// if(useSplitter) Rview->MultiLine_Ex::ScrollDown( 1);
// }
// break;
}
}
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() );
// if( loadCheck == true) {
// ResizeEdits();
// AdjustStatus();
// }
}
void Gutenbrowser::doOptions() {
@@ -1467,68 +1472,68 @@ void Gutenbrowser::doOptions() {
QFont myFont;
optDlg->showMaximized();
if( optDlg->exec() !=0) {
qApp->processEvents();
brow=optDlg->browserName;
toggleButtonIcons( optDlg->useIcon);
ftp_host= optDlg->ftp_host;
ftp_base_dir= optDlg->ftp_base_dir;
brow=optDlg->browserName;
Ddir=optDlg->downloadDirEdit->text();
- qDebug("writing library config");
+ odebug << "writing library config" << oendl;
Config config("Gutenbrowser");
config.setGroup("General");
QString dirname= optDlg->downloadDirEdit->text();
if(dirname.right(1)!="/")
dirname+="/";
config.writeEntry( "DownloadDirectory",dirname);
QDir newDir( optDlg->downloadDirEdit->text());
if( !newDir.exists() ) {
int exit=QMessageBox::information(this, "Note", "Ok, to make a new directory\n"+Ddir+" ?",
QMessageBox::Ok, QMessageBox::Cancel);
if (exit==1) {
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+="/";
}
config.writeEntry("DownloadDirectory",Ddir);
}
}
// if(optDlg->styleChanged)
// setStyle( optDlg->styleInt);
if(optDlg->b_qExit==TRUE)
b_queryExit=TRUE;
else
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;
}
}
if(showMainList) {
if(!Lview->isHidden())
Lview->hide();
qApp->processEvents();
if(mainList->isHidden())
mainList->show();
fillWithTitles();
} else {
@@ -1569,26 +1574,26 @@ bool Gutenbrowser::setTitle() {
config.writeEntry(interger, file_name);
config.setGroup( "Titles" );
config.writeEntry(file_name,listItemTitle);
}
test = 0;
// config.write();
return true;
}
/*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";
// NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, output);
// if( NetworkDlg->exec() != 0 ) {
// }
// if(NetworkDlg)
// delete NetworkDlg;
// #endif
}
void Gutenbrowser::donateGutenberg()
@@ -1703,31 +1708,31 @@ void Gutenbrowser::focusInEvent( QFocusEvent* )
{
}
void Gutenbrowser::focusOutEvent( QFocusEvent* )
{
}
void Gutenbrowser::cleanUp( )
{
writeConfig();
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;
}
void Gutenbrowser::enableButtons(bool b)
{
BackButton->setEnabled(b);
ForwardButton->setEnabled(b);
SearchButton->setEnabled(b);
setBookmarkButton->setEnabled(b);
dictionaryButton->setEnabled(b);
InfoBar->setEnabled(b);
@@ -1763,25 +1768,25 @@ void Gutenbrowser::listClickedSlot( QListBoxItem * index) {
// QCopEnvelope ( "QPE/System", "busy()" );
title = index->text();
showMainList=FALSE;
mainList->hide();
Lview->show();
qApp->processEvents();
QString temp;
temp.setNum( mainList->currentItem() + 1);
// openFileTitle = title;
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);
config.setGroup( title);
file_name = config.readEntry("File Name", "");
i_pageNum = config.readNumEntry("Page Number", 1);
int Bmrkrow = config.readNumEntry("LineNumber", -1);
if(Bmrkrow > -1) {
if( Bmrkrow > Lview->topRow() ) {
Lview->setCursorPosition( Bmrkrow /* - Lview->topRow() */,0, FALSE );
Lview->ScrollUp( Bmrkrow - Lview->topRow() );
// AdjustStatus();
@@ -1804,29 +1809,29 @@ void Gutenbrowser::infoGutenbrowser() {
void Gutenbrowser::setDocument(const QString & frozenBoogers) {
this->hide();
if(showMainList) {
showMainList=FALSE;
if(!mainList->isHidden())
mainList->hide();
if(Lview->isHidden())
Lview->show();
qApp->processEvents();
}
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();
}
void Gutenbrowser::mainListPressed(int mouse, QListBoxItem * , const QPoint & )
{
switch (mouse) {
case 1:
break;
case 2: {
QPopupMenu m;// = new QPopupMenu( Local_View );
m.insertItem( tr( "Open" ), this, SLOT( menuOpen() ));
@@ -1864,121 +1869,121 @@ void Gutenbrowser::searchGoogle( const QString &tempText) {
text.replace( QRegExp(")"), "");
// text.replace( QRegExp("[0-9]"), "");
QString s_lookup = "http://google.com/search?q="+text+"&num=30&sa=Google+Search";
goGetit( s_lookup, true);
}
}
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" );
QString s_numofFiles = config.readEntry("NumberOfFiles", "0");
int i_numofFiles = s_numofFiles.toInt();
QString fileNum;
for (int i = 1; i <= i_numofFiles+1; i++) {
fileNum.setNum(i);
config.setGroup( "Files" );
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);
}
}
}
// getTitles();
mainList->triggerUpdate(true);
}
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;
QString thatFile;
if(zipFile.find("pgwhole",0,TRUE)) {
isPgWhole=TRUE;
thatFile= local_library +"PGWHOLE.TXT";
}
// 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
int exit=QMessageBox::information(this, "Ok to unzip?",
"Ok to unnzip\n"+ 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;
}
}
else
QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) );
#endif
return false;
}