summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.cpp2
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
index 3b540c5..58babe9 100644
--- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
@@ -739,331 +739,331 @@ void LibraryDialog::onButtonSearch()
resultString += (" : ");
resultString += ( it4.current() )->text(3);
if( resultString.find( searcherStr, 0, cS) != -1) {
Searchlist.append( resultString);
}
}
}
if(fluff==0) { // search routine here
for ( ; it5.current(); ++it5 ) {
resultString = ( it5.current() )->text(0);
resultString += (" : ");
resultString += ( it5.current() )->text(2);
resultString += (" : ");
resultString += ( it5.current() )->text(3);
if( resultString.find( searcherStr, 0, cS) != -1) {
Searchlist.append( resultString);
}
}
}
tabWidget->setCurrentPage( curTab);
Searchlist.sort();
SearchResultsDlg* SearchResultsDialog;
SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist);
SearchResultsDialog->showMaximized();
if( SearchResultsDialog->exec() != 0) {
texter = SearchResultsDialog->selText;
// //odebug << texter << oendl;
resultLs = SearchResultsDialog->resultsList;
i_berger = 1;
} else {
resultLs.clear();
}
Searchlist.clear();
// if(SearchResultsDialog)
// delete SearchResultsDialog;
QString tester;
for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) {
texter.sprintf("%s \n",(*it).latin1());
// //odebug << texter << oendl;
if( tester!=texter)
parseSearchResults( texter);
tester = texter;
}
if(searchDlg)
delete searchDlg;
}
if(checkBox->isChecked() ) {
accept();
} else {
setActiveWindow();
}
}
/*
splits the result string and calls download for the current search result*/
void LibraryDialog::parseSearchResults( QString resultStr)
{
int stringLeng = resultStr.length();
QString my;
my.setNum( stringLeng, 10);
if( resultStr.length() > 2 && resultStr.length() < 130) {
int titleInt = resultStr.find( " : ", 0, true);
DlglistItemTitle = resultStr.left( titleInt);
int yearInt = resultStr.find( " : ", titleInt+3, true);
DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3);
DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3));
DlglistItemFile = DlglistItemFile.left( DlglistItemFile.length() - 2);
cleanStrings();
if(DlglistItemFile.left(1) == "/")
DlglistItemFile = DlglistItemFile.right( DlglistItemFile.length() - 1);
if( DlglistItemFile.toInt() > 10000 ) {
// new directory sturcture
download_newEtext(); //)
} else {
download_Etext(); //)
}
}
}
void LibraryDialog::sort()
{
}
/*
Downloads the current selected listitem*/
bool LibraryDialog::getItem(QListViewItem *it)
{
// //odebug << "selected getItem" << oendl;
// DlglistItemNumber = it->text(0);
DlglistItemTitle = it->text(0);
DlglistItemYear = it->text(2);
DlglistItemFile = it->text(3);
if(download_Etext()) {
if(i_binary == 1) {
}
}
return true;
}
/*
download button is pushed so we get the current items to download*/
bool LibraryDialog::onButtonDownload()
{
// //odebug << "selected onButtonDownloadz" << oendl;
QListViewItemIterator it1( ListView1 );
QListViewItemIterator it2( ListView2 );
QListViewItemIterator it3( ListView3 );
QListViewItemIterator it4( ListView4 );
QListViewItemIterator it5( ListView5 );
// iterate through all items of the listview
for ( ; it1.current(); ++it1 ) {
if ( it1.current()->isSelected() )
getItem(it1.current());
it1.current()->setSelected(false);
}
for ( ; it2.current(); ++it2 ) {
if ( it2.current()->isSelected() )
getItem(it2.current());
it2.current()->setSelected(false);
}
for ( ; it3.current(); ++it3 ) {
if ( it3.current()->isSelected() )
getItem(it3.current());
it3.current()->setSelected(false);
}
for ( ; it4.current(); ++it4 ) {
if ( it4.current()->isSelected() )
getItem(it4.current());
it4.current()->setSelected(false);
}
for ( ; it5.current(); ++it5 ) {
if ( it5.current()->isSelected() )
getItem(it5.current());
it5.current()->setSelected(false);
}
return true;
}
/*
handles the sorting combo box */
void LibraryDialog::comboSelect(int index)
{
// //odebug << "we are sorting" << oendl;
ListView1->setSorting( index, true);
ListView2->setSorting( index, true);
ListView3->setSorting( index, true);
ListView4->setSorting( index, true);
ListView5->setSorting( index, true);
ListView1->sort();
ListView2->sort();
ListView3->sort();
ListView4->sort();
ListView5->sort();
// ListView1->triggerUpdate();
// ListView2->triggerUpdate();
// ListView3->triggerUpdate();
// ListView4->triggerUpdate();
// ListView5->triggerUpdate();
}
void LibraryDialog::newList()
{
if(indexLoaded) {
onButtonDownload();
} else {
Output *outDlg;
buttonNewList->setDown(true);
//odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl;
QString gutenindex1 = local_library + "/GUTINDEX.ALL";
- QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1";
+ QString cmd="wget -O " + gutenindex1 + " http://www.gutenberg.org/dirs/GUTINDEX.ALL 2>&1";
int result = QMessageBox::warning( this,"Download"
,"<p>Ok to use /'wget/' to download a new library list?</P>"
,"Yes","No",0,0,1);
qApp->processEvents();
if(result == 0) {
outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),true);
outDlg->showMaximized();
outDlg->show();
qApp->processEvents();
FILE *fp;
char line[130];
outDlg->OutputEdit->append( tr("Running wget") );
outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,false);
sleep(1);
fp = popen( (const char *) cmd, "r");
if ( !fp ) {
} else {
//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->OutputEdit->append("Finished downloading\n");
outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,false);
qApp->processEvents();
// if( QFile(gutenindex1).exists() ) {
// QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
// if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0)
// //odebug << "renaming error" << oendl;
// }
}
// outDlg->close();
FindLibrary();
if(outDlg) delete outDlg;
}
buttonNewList->setDown(false);
// if(outDlg)
// delete outDlg;
}
}
bool LibraryDialog::moreInfo()
{
QListViewItem * item;
item = 0;
QString titleString;
item = ListView1->currentItem();
if( item != 0) {
titleString = item->text(0);
ListView1->clearSelection();
item = 0;
}
if( item == 0)
item = ListView2->currentItem();
if( item != 0) {
titleString = item->text(0);
ListView2->clearSelection();
item = 0;
}
if( item == 0)
item = ListView3->currentItem();
if( item != 0) {
titleString = item->text(0);
ListView3->clearSelection();
item = 0;
}
if( item == 0)
item = ListView4->currentItem();
if( item != 0) {
titleString = item->text(0);
ListView4->clearSelection();
item = 0;
}
if( item == 0)
item = ListView5->currentItem();
if( item != 0) {
titleString = item->text(0);
ListView5->clearSelection();
item = 0;
}
item=0;
if(titleString.length()>2) {
//odebug << "Title is "+titleString << oendl;
titleString.replace( QRegExp("\\s"), "%20");
titleString.replace( QRegExp("'"), "%20");
titleString.replace( QRegExp("\""), "%20");
titleString.replace( QRegExp("&"), "%20");
QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search";
cmd="opera "+cmd;
system(cmd);
} else
QMessageBox::message( "Note","<p>If you select a title, this will search google.com for that title.</p>");
return true;
}
/*
This loads the library Index*/
void LibraryDialog::FindLibrary()
{
buttonLibrary->setDown(true);
qApp->processEvents();
if( QFile( new_index).exists() /* && this->isHidden() */) {
newindexLib.setName( new_index);
indexLib.setName( new_index);
//odebug << "index file is "+ new_index << oendl;
Newlibrary();
} else {
newindexLib.setName( old_index);
indexLib.setName( old_index);
//odebug << "new index nameis "+ old_index << oendl;
Library();
}
indexLoaded=true;
buttonSearch->setEnabled(true);
moreInfoButton->setEnabled(true);
buttonLibrary->setDown(false);
buttonNewList->setText("Download");
qApp->processEvents();
}
void LibraryDialog::cleanStrings() {
year = year.stripWhiteSpace();
file = file.stripWhiteSpace();
title = title.stripWhiteSpace();
number = number.stripWhiteSpace();
}
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
index e639d4d..733db17 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
@@ -193,385 +193,385 @@ void Gutenbrowser::InfoBarClick() {
text=this->caption();
}
searchGoogle(text);
}
/*
download http with wget or preferred browser */
void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
QString cmd;
qApp->processEvents();
QString filename = local_library + "/GUTINDEX.ALL";
// QString filename = old_index;
// filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1);
Config cfg("Gutenbrowser");
cfg.setGroup("FTPsite");
ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org");
ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg");
// Config config("Gutenbrowser");
// config.setGroup( "Browser" );
// QString brow = config.readEntry("Preferred", "Opera");
// //odebug << "Preferred browser is "+brow << oendl;
if(!showMsg) { //if we just get the gutenindex.all
// QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1";
cmd="wget -O " + filename +" " + url+" 2>&1" ;
chdir(local_library);
// //odebug << "Issuing the system command: " << cmd << "" << oendl;
Output *outDlg;
outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE);
outDlg->showMaximized();
outDlg->show();
qApp->processEvents();
FILE *fp;
char line[130];
outDlg->OutputEdit->append( tr("Running wget") );
outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
sleep(1);
fp = popen( (const char *) cmd, "r");
if ( !fp ) {
} else {
//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->OutputEdit->append("Finished downloading\n");
outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
qApp->processEvents();
}
outDlg->close();
if(outDlg)
delete outDlg;
} else {
if( brow == "Konq") {
cmd = "konqueror "+url+" &";
}
if( brow == "Opera") { //for desktop testing
cmd = "opera "+url+" &";
}
// if( brow == "Opera") { // on Zaurus
// cmd = "operagui "+url+" &";
// }
if( brow == "Mozilla") {
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);
// //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";
odebug << "Docdir is "+QPEApplication::documentDir() << oendl;
if( useIcons && QDir( pixDir).exists() ) {
LibraryButton->setPixmap( Opie::Core::OResource::loadPixmap("home", Opie::Core::OResource::SmallIcon ) );
OpenButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/openbook", Opie::Core::OResource::SmallIcon ));
ForwardButton->setPixmap( Opie::Core::OResource::loadPixmap("forward", Opie::Core::OResource::SmallIcon ));
BackButton->setPixmap( Opie::Core::OResource::loadPixmap("back", Opie::Core::OResource::SmallIcon ) );
SearchButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/search", Opie::Core::OResource::SmallIcon ) );
lastBmkButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/bookmark_folder", Opie::Core::OResource::SmallIcon ));
setBookmarkButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/bookmark", Opie::Core::OResource::SmallIcon ) );
dictionaryButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/spellcheck", Opie::Core::OResource::SmallIcon ) );
InfoBar->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/google", Opie::Core::OResource::SmallIcon ));
}
}
bool Gutenbrowser::queryExit()
{
int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?",
QMessageBox::Ok, QMessageBox::Cancel);
if (exit==1) {
writeConfig();
qApp->quit();
} else {
};
return (exit==1);
}
// SLOT IMPLEMENTATION
void Gutenbrowser::slotFilePrint() {
}
void Gutenbrowser::ByeBye() {
if (b_queryExit)
queryExit();
else {
// writeConfig();
qApp->quit();
}
}
void Gutenbrowser::HelpBtn() {
HelpMe* HelpDlg;
HelpDlg = new HelpMe( this, "Help Dialog");
HelpDlg->showMaximized();
}
void Gutenbrowser::DownloadIndex() {
#ifndef Q_WS_QWS
{
switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")),
(tr("Do you want to download the newest\n"
"Project Gutenberg Library Index?\n"
"or select an ftp site?\n")),
(tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) )
{
case 0: // index clicked,
downloadLibIndex();
break;
case 1: // ftp selected
downloadFtpList();
break;
case 2: // Cancel
break;
};
}
#endif
} // end DownloadIndex
void Gutenbrowser::downloadFtpList() {
// QString cmd="wget http://www.promo.net/pg/list.html");
//system(cmd);
qApp->processEvents();
optionsDialog* optDlg;
optDlg = new optionsDialog( this,"Options_Dlg", true);
optDlg->getSite();
if(optDlg)
delete optDlg;
}
void Gutenbrowser::downloadLibIndex() {
// QString dwmloader = local_library + "pgwhole.zip";
// QString cmd = "lynx -source http://www.gutenberg.net/pgwhole.zip | cat >> " + dwmloader;
// system(cmd);
// QString outputFile= local_library+ "GUTINDEX.ALL";
// config.setGroup( "FTPsite" ); // ftp server config
// ftp_host=config.readEntry("SiteName", "");
// ftp_base_dir= config.readEntry("base", "");
// QString networkUrl= "ftp://"+ftp_host+ftp_base_dir+"/GUTINDEX.ALL";
QDir dir( local_library);
dir.cd("", TRUE);
- goGetit( "http://sailor.gutenberg.org/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3
+ goGetit( "http://www.gutenberg.org/dirs/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3
// goGetit( "http://www.gutenberg.net/pgwhole.zip", true); // until ghttp works on binaries -qt3
// NetworkDialog *NetworkDlg;
// NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, outputFile );
// if( NetworkDlg->exec() != 0 )
// { // use new, improved, *INSTANT* network-dialog-file-getterer
//// QMessageBox::message("Note","");
// }
// if(NetworkDlg)
// delete NetworkDlg;
}
void Gutenbrowser::PrintBtn() {
}
void Gutenbrowser::SearchBtn() {
if( loadCheck) {
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);
// 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;
odebug << currentFilePos << " current page is number " << i_pageNum
<< ", pagesize " << pageSize << ", length " << Lview->length()
<< ", current " << pageStopArray[i_pageNum] << oendl;
setStatus();
// Lview->setCursorPosition( 0, 0, FALSE);
// }
} else {
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();
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();
odebug << currentFilePos << " move back to " << pageStopArray[i_pageNum - 1 ]
<< ", current page number " << i_pageNum
<< ", " << pageSize << ", length " << Lview->length() << oendl;
if( i_pageNum < 2) {
f.at( 0);
} else {
if(!f.at( pageStopArray[i_pageNum - 1] ))
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++;
// insertString+=s;
Lview->insertLine( s, -1);
}
// Lview->insertAt( insertString,0,0, FALSE);
if( !BackButton->autoRepeat() && !BackButton->isDown()) {
QString topR;
QString lastR;
QString pageR;
// int sizer = Lview->lastRow() - Lview->topRow();
// int i_topRow = Lview->topRow();
if( i_pageNum < 1)
i_pageNum = 1;
setCaption(QString::number(i_pageNum));
} else {
// int newTop = Lview->Top();
// if(Lview->lastRow() > i)
Lview->MultiLine_Ex::pageUp( FALSE);
// Lview->ScrollDown(1);
// i_pageNum--;
if( i_pageNum < 1)
i_pageNum = 1;
setStatus();
// Lview->setCursorPosition( Lview->Top(), 0, FALSE);
}
}
Lview->setFocus();
}
void Gutenbrowser::doBeginBtn() {
if(loadCheck) {
qApp->processEvents();
BeginBtn();
}
}
// moves text to the very top = 0
void Gutenbrowser::TopBtn() {
if(loadCheck) {
if( i_pageNum != 0) {
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);
currentLine++;
}
// Lview->setCursorPosition( 0,0, FALSE);
i_pageNum=1;
setStatus();
}
Lview->setFocus();
}
}
//moves text to the start of the EText
void Gutenbrowser::BeginBtn() {
i_pageNum = 1;
currentLine = 0;
QString s_pattern="*END*THE SMALL PRINT";
QString sPattern2 = "*END THE SMALL PRINT";
int pageSize = Lview->PageSize();
Lview->clear();
// int lines = Lview->numLines();
int pos = 0;//, i = 0;
int i_topRow = Lview->topRow();
QString LeftText;// = Lview->text();
// int linesPerPage = Lview->lastRow() - Lview->topRow();
// int pages = (( linesPerPage / Lview->editSize() ) ) +1;