author | mickeyl <mickeyl> | 2004-04-09 14:06:05 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-09 14:06:05 (UTC) |
commit | 5f294a018a0f44a6547485bc73a095cd0c153903 (patch) (side-by-side diff) | |
tree | ea19ba0afea3e8d4a226719a3590cf11e5fc5178 | |
parent | 208a155ee480e5c1ae0fd6e8876a6ffea7f1c4a5 (diff) | |
download | opie-5f294a018a0f44a6547485bc73a095cd0c153903.zip opie-5f294a018a0f44a6547485bc73a095cd0c153903.tar.gz opie-5f294a018a0f44a6547485bc73a095cd0c153903.tar.bz2 |
libopie1 --> libopie2
-rw-r--r-- | noncore/apps/opie-gutenbrowser/browserDialog.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/config.in | 6 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/openetext.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/opie-gutenbrowser.pro | 5 |
4 files changed, 16 insertions, 11 deletions
diff --git a/noncore/apps/opie-gutenbrowser/browserDialog.cpp b/noncore/apps/opie-gutenbrowser/browserDialog.cpp index 5c48da1..81dd516 100644 --- a/noncore/apps/opie-gutenbrowser/browserDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/browserDialog.cpp @@ -1,83 +1,86 @@ /**************************************************************************** copyright 2001 by L.J. Potter ljp@llornkcor.com copyright : (C) 2000 -2004 by llornkcor email : ljp@llornkcor.com ****************************************************************************/ #include "optionsDialog.h" //#include "fileBrowser.h" +/* OPIE */ +#include <opie2/ofiledialog.h> +using namespace Opie::Ui; + +/* QT */ #include <qlabel.h> #include <qlistbox.h> #include <qpushbutton.h> #include <qlayout.h> -#include <opie/ofiledialog.h> - void optionsDialog::BrowserDlg( ) { // setCaption( tr( "Choose Browser" ) ); http_ListBox1->insertItem( tr( "Opera")); http_ListBox1->insertItem( tr( "Konqueror")); http_ListBox1->insertItem( tr( "wget")); } void optionsDialog::select_title(int) { browserName = http_ListBox1->currentText(); Config config("Gutenbrowser"); config.setGroup( "Browser" ); printf("Brow is: "+browserName+"\n"); config.writeEntry("Preferred", browserName); TextLabel3_3->setText( "Current http browser: "+browserName ); } void optionsDialog::BrowseSelected() { QString fileName; Config cfg("Gutenbrowser"); cfg. setGroup ( "View" ); QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); QMap<QString, QStringList> map; map.insert(tr("All"), QStringList() ); QStringList text; text << "text/*"; map.insert(tr("Text"), text ); text << "*"; map.insert(tr("All"), text ); QString str = OFileDialog::getOpenFileName( 2, dir , QString::null, map); if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) { fileName = str; // QStringList fileList=browseForFiles->fileList; // qDebug(selFile); // QStringList::ConstIterator f; // QString fileTemp,filer; // for ( f = fileList.begin(); f != fileList.end(); f++ ) { // fileTemp = *f; // fileTemp.right( fileTemp.length()-5); // fileName = fileTemp; // if( !fileName.isEmpty() ){ // filer = fileName; // } else { // QString sMsg; // sMsg = "Error opening library filelist "+fileName; // } if ( !fileName.isNull() ) { // got a file name // ... } } } void optionsDialog::setHttp(int index) { Config config("Gutenbrowser"); config.setGroup( "HttpServer" ); qDebug("writing http server"); if( index== 0) { config.writeEntry("Preferred", "http://sailor.gutenberg.org"); } else { config.writeEntry("Preferred", "http://www.prairienet.org/pg"); } } diff --git a/noncore/apps/opie-gutenbrowser/config.in b/noncore/apps/opie-gutenbrowser/config.in index ec67d6e..d2a3033 100644 --- a/noncore/apps/opie-gutenbrowser/config.in +++ b/noncore/apps/opie-gutenbrowser/config.in @@ -1,4 +1,6 @@ - config OPIE-GUTENBROWSER + config GUTENBROWSER boolean "gutenbrowser - Gutenberg Project etext reader and selector" default "n" - depends ( LIBQPE || LIBQPE-X11 ) && FTPLIB + depends ( LIBQPE || LIBQPE-X11 ) && FTPLIB && LIBOPIE2CORE && LIBOPIE2UI + comment "gutenbrowser needs a libqpe, ftplib, libopie2core and libopie2ui" + depends !(( LIBQPE || LIBQPE-X11 ) && FTPLIB && LIBOPIE2CORE && LIBOPIE2UI) diff --git a/noncore/apps/opie-gutenbrowser/openetext.cpp b/noncore/apps/opie-gutenbrowser/openetext.cpp index 40f35d6..bd44ce6 100644 --- a/noncore/apps/opie-gutenbrowser/openetext.cpp +++ b/noncore/apps/opie-gutenbrowser/openetext.cpp @@ -1,517 +1,518 @@ /*************************************************************************** openetext.cpp - description begin : Sat Dec 4 1999 begin : Tue Jul 25 2000 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. * ***************************************************************************/ #include "gutenbrowser.h" #include "openetext.h" #include "editTitle.h" -#include <qfileinfo.h> +/* OPIE */ +#include <opie2/ofiledialog.h> #include <qpe/applnk.h> +#include <qpe/config.h> #include <qpe/qpeapplication.h> +using namespace Opie::Ui; #include <stdlib.h> #include <qtextstream.h> -#include <qpe/config.h> - -#include <opie/ofiledialog.h> +#include <qfileinfo.h> #if defined(_WS_WIN_) #include <windows.h> #else #include <unistd.h> #include "sys/stat.h" #endif OpenEtext::OpenEtext(QWidget *parent, QString name) : QDialog(parent,name,true) { local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; local_index=local_library+"GUTINDEX.ALL"; initDialog(); connect( QListBox_1, SIGNAL(selected ( int)),this, SLOT(select_title(int)) ); getTitles(); } OpenEtext::~OpenEtext() { } void OpenEtext::getTitles() { QListBox_1->clear(); Config config("Gutenbrowser"); config.setGroup( "Files" ); s_numofFiles = config.readEntry("NumberOfFiles", "0"); QLabel_1->setText( tr( s_numofFiles+" etexts in your library.")); int i_numofFiles = s_numofFiles.toInt(); for (int i = 1; i <= i_numofFiles+1; i++) { QString temp; temp.setNum(i); config.setGroup( "Files" ); QString ramble = config.readEntry(temp, "" ); config.setGroup( "Titles" ); title = config.readEntry(ramble, ""); if( !title.isEmpty()) { QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), title, -1); } } } /* opens selected title */ void OpenEtext::OpenTitle() { if( QListBox_1->currentItem() != -1) select_title( QListBox_1->currentItem() ); else { QString sMsg; sMsg = "You must select an Etext to open"; QMessageBox::message( "Error",sMsg); } } void OpenEtext::select_title(int index ) { OpenButton->setDown(TRUE); QString temp; temp.setNum( index + 1); const char * title; title = QListBox_1->text( index ); openFileTitle = title; Config config("Gutenbrowser"); config.setGroup( "Files" ); file = config.readEntry(temp, ""); OpenEtext::accept(); } /* This function imports already existing etexts into the local library list*/ void OpenEtext::open() { OpenFileButton->setDown(TRUE); title = ""; QString currDir=""; QString filer; QString name_file; QString local ; local = (QDir::homeDirPath () +"Applications/gutenbrowser"); QDir library( local); // fileBrowser *browseForFiles; // browseForFiles=new fileBrowser(this,"Browse for File", TRUE, 0, "guten/plain;text/plain"); // // browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*"); // browseForFiles->setFileView( 0); // browseForFiles->showMaximized(); // browseForFiles->exec(); // QString selFile= browseForFiles->selectedFileName; // fileList=browseForFiles->fileList; Config cfg("Gutenbrowser"); cfg. setGroup ( "View" ); QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); QMap<QString, QStringList> map; map.insert(tr("All"), QStringList() ); QStringList text; text << "text/*"; map.insert(tr("Text"), text ); text << "*"; map.insert(tr("All"), text ); QString str = OFileDialog::getOpenFileName( 2, dir , QString::null, map); if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) { filer = str; qDebug("Open file: "+str); // QStringList::ConstIterator f; // QString fileTemp; // for ( f = fileList.begin(); f != fileList.end(); f++ ) { // fileTemp = *f; // fileTemp.right( fileTemp.length()-5); // fileName = fileTemp; // if( !fileName.isEmpty() ){ // filer = fileName; // } else { //filename is empty // // QString sMsg; // // sMsg = "Error opening library filelist "+fileName; // } if( filer.right(4) == ".txt" || filer.right(4) == ".TXT" || filer.right(4) == ".etx" || filer.right(4) == ".ETX" || filer.right(4) == ".etx" || filer.right(4) == ".ETX" || filer.right(4) == ".zip" || filer.right(4) == ".ZIP" ) { QFileInfo zipFile( filer); QString s_fileName = zipFile.fileName(); QString cmd; if( s_fileName.right(4) == ".zip") { // unzip that sucker.... s_fileName = s_fileName.left( s_fileName.length() - 4); if( chdir((const char*)local_library.latin1())!=0) qDebug("chdir failed.");// QString cmd = "gunzip -d " + filer + " -d " + local_library; cmd = "gunzip -S .zip " + filer; fileName = local_library + s_fileName + ".txt"; system( cmd); } // this renames the .txt to .etx!! else /*if( s_fileName.right(4) == ".txt" || if( s_fileName.right(4) == ".TXT"))*/ { // qDebug("Filename is "+fileName); s_fileName = fileName; s_fileName.replace( s_fileName.length()-3,3,"gtn");// s_fileName.replace( s_fileName.length()-3,3,"etx"); rename(fileName.latin1(),s_fileName.latin1()); fileName = s_fileName; // qDebug("Filename is now "+fileName); } } else fileName = str; FindTitle(fileName); QFileInfo fi( fileName); name_file = fi.fileName(); name_file = name_file.left(name_file.length() - 4); qDebug("Setting doclink"); DocLnk lnk; qDebug("name is " + name_file); lnk.setName(name_file); //sets file name qDebug("Title is "+title); lnk.setComment(title); QListBox_1->clear(); getTitles(); qDebug("Filename is "+fileName); lnk.setFile(fileName); //sets File property lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D lnk.setExec(fileName); lnk.setIcon("gutenbrowser/Gutenbrowser"); if(!lnk.writeLink()) qDebug("Writing doclink did not work"); } // end of for each file name.... OpenFileButton->setDown(FALSE); } /* find the title in the config file */ bool OpenEtext::FindTitle( QString filename) { Config config("Gutenbrowser"); config.setGroup( "Files" ); QString s_numofFiles = config.readEntry("NumberOfFiles", "0"); int i_numofFiles = s_numofFiles.toInt(); QFileInfo fi(filename); name = fi.fileName(); qDebug("filename to open is " + name); QFile indexLib( filename); bool findCheck = FALSE; // int Titlenumber=0; if ( indexLib.open( IO_ReadOnly) ) { qDebug("file opened successfully"); QTextStream indexStream( &indexLib ); QString target = "Project Gutenberg Etext of"; QString target2 = "Project Gutenberg Etext"; QString target3 = "Project Gutenberg's Etext of"; QString target4 = "Project Gutenberg's Etext"; QString indexLine; while ( !indexStream.eof() ) { // until end of file.. indexLine = indexStream.readLine(); if( indexLine.find(target, 0, TRUE) > -1 && !findCheck) {findCheck = TRUE; title = indexLine.mid( indexLine.find(target, 0, TRUE) + (target.length()) , indexLine.find("\r", 0, TRUE)); title = title.left( title.find( "*",0, TRUE)); title = title.stripWhiteSpace (); // qDebug("Found the title 1 and it is %s", title.latin1()); // QListBox_1->insertItem ( title); } if( indexLine.find( target2, 0, TRUE) > -1 && !findCheck) { findCheck = TRUE; title = indexLine.mid( indexLine.find( target2, 0, TRUE ) + ( target2.length()) , indexLine.find("\r", 0, TRUE) ); title = title.left( title.find( "*",0, TRUE)); title = title.stripWhiteSpace (); // qDebug("Found the title 2 and it is %s", title.latin1()); // QListBox_1->insertItem ( title); } if( indexLine.find( target3, 0, TRUE) > -1 && !findCheck) { findCheck = TRUE; title = indexLine.mid( indexLine.find( target3, 0, TRUE) + ( target3.length()) , indexLine.find("\r", 0, TRUE)); title = title.left( title.find( "*",0, TRUE)); title = title.stripWhiteSpace (); // qDebug("Found the title 3 and it is %s", title.latin1()); } if( indexLine.find( target4, 0, TRUE) > -1 && !findCheck) { findCheck = TRUE; title = indexLine.mid( indexLine.find( target4, 0, TRUE) + ( target4.length()) , indexLine.find("\r", 0, TRUE)); title = title.left( title.find( "*",0, TRUE)); title = title.stripWhiteSpace (); // qDebug("Found the title 4 and it is %s", title.latin1()); } } //endof file indexLib.close(); if( !findCheck || title.length() < 2) { qDebug("Trying hard to find title from GUTINDEX.ALL"); title = titleFromLibrary( filename); findCheck = TRUE; } if ( checkConf() == false && findCheck == TRUE) { config.setGroup( "Files"); config.writeEntry("NumberOfFiles",i_numofFiles + 1 ); QString interger; interger.setNum( i_numofFiles +1); config.writeEntry(interger, filename); config.setGroup( "Titles" ); for (int i = 1; i <= i_numofFiles; i++) { //find dup titles in config file QString temp; temp.setNum(i); config.setGroup( "Files" ); QString ramble = config.readEntry(temp, "" ); config.setGroup( "Titles" ); QString title1 = config.readEntry(ramble, ""); if(title1==title) title+="1"; i= i_numofFiles+1; } if(title.length()<3) { // qDebug("title is empty"); title="Unknown"; } config.writeEntry( filename,title); } } else { QString sMsg; sMsg = "Error opening library file: "+filename; printf( sMsg+"\n"); } return true; } QString OpenEtext::titleFromLibrary( QString fileName) { QFile indexLib( local_index); QString target; int find1 = fileName.findRev("/",-1,TRUE) + 1; int find2 = fileName.findRev(".gtn",-1,TRUE) - find1; if(find2==-1-find1) int find2 = fileName.findRev(".etx",-1,TRUE) - find1; else if(find2==-1-find1) int find2 = fileName.findRev(".txt",-1,TRUE) - find1; target = fileName.mid( find1, find2 ); QString checker = target.right(1); bool ok; checker.toInt( &ok,10); if( ok) { target = target.left( target.length()-1); checker = target.right(1); ok = FALSE; checker.toInt( &ok,10); if( ok) { target = target.left( target.length()-1); } } if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully QTextStream indexStream( &indexLib ); QString indexLine; bool findCheck = FALSE; while ( !indexStream.atEnd() ) { // until end of file.. indexLine = indexStream.readLine(); if( indexLine.find( target,0,FALSE) > 0 ) { findCheck = TRUE; title = indexLine.mid( 9, 50); // title = indexLine.mid( 26, indexLine.length() ); title = title.stripWhiteSpace (); // qDebug("Finally Found the title and it is\n %s", title.latin1()); // QListBox_1->insertItem ( title); } } //end while loop } else qDebug("Error opening library index "+ local_index); return title; } bool OpenEtext::checkConf() { QString file = fileName; Config config("Gutenbrowser"); 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); config.setGroup( "Files"); QString ramble = config.readEntry(temp, "" ); if(ramble == file ) { return true; } } return false; } void OpenEtext::remove() { title_text = QListBox_1->text( QListBox_1->currentItem() ); title_text=title_text.stripWhiteSpace(); QString msg ="<p>Do you really want to REMOVE\n" +title_text +"?\nThis will not delete the file.</P>"; switch( QMessageBox::information( this, (tr("Remove Etext")), (tr(msg)), (tr("&Yes")), (tr("&Cancel")), 0 )){ case 0: // Yes clicked, removeSelection(); QListBox_1->clear(); getTitles(); break; case 1: // Cancel break; }; } /* this removes selected title entry*/ void OpenEtext::removeSelection() { Config config("Gutenbrowser"); config.setGroup( "Files" ); s_numofFiles = config.readEntry("NumberOfFiles", "0"); int rem=0; int i_numofFiles = s_numofFiles.toInt(); QString fileNum2; QString fileNum; for (int i = 1; i <= i_numofFiles; i++) { fileNum.setNum(i); config.setGroup( "Files" ); QString s_filename = config.readEntry(fileNum, "" ); config.setGroup( "Titles" ); QString file_title = config.readEntry( s_filename, ""); if(title_text == file_title) { rem=i; //qDebug("file title to remove is "+file_title); selFile = s_filename; config.removeEntry( s_filename); //removes file=title } } config.setGroup( "Files" ); for(int fg = rem; fg < i_numofFiles ; fg++ ) { //this rewrites Files number entry fileNum.setNum(fg); fileNum2.setNum( fg + 1); QString s_filename2 = config.readEntry(fileNum2, "" ); if (!s_filename2.isEmpty()) { config.writeEntry(fileNum, s_filename2 ); } } config.writeEntry("NumberOfFiles", i_numofFiles - 1 ); config.removeEntry(fileNum2); // remFile(); } /* removes file title name from list and config file*/ void OpenEtext::remFile() { Config config("Gutenbrowser"); config.setGroup( "Files" ); QString remFile; s_numofFiles = config.readEntry("NumberOfFiles", "0"); int i_numofFiles = s_numofFiles.toInt(); for (int i = 1; i <= i_numofFiles; i++) { QString fileNum; fileNum.setNum(i); QString s_filename = config.readEntry(fileNum, "" ); if( s_filename == selFile) { config.removeEntry(selFile); for(int fg = i_numofFiles - i; fg < i_numofFiles ; fg++ ) { //this rewrites Files number entry QString fileNum2; fileNum2.setNum( fg + 1); QString s_filename2 = config.readEntry(fileNum2, "" ); if (!s_filename2.isEmpty()) { config.writeEntry(fileNum, s_filename2 ); } } } } config.writeEntry("NumberOfFiles", i_numofFiles - 1 ); config.removeEntry(s_numofFiles); QListBox_1->triggerUpdate(true); } /* sorts the list*/ void OpenEtext::scan() { QListBox_1->sort(TRUE); QListBox_1->triggerUpdate(true); } void OpenEtext::editTitle() { int currentItem=QListBox_1->currentItem(); QString title_text = QListBox_1->text( currentItem); //qDebug("Selected "+title_text); Config config("Gutenbrowser"); config.setGroup( "Files" ); 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); if(title_text == file_title ) { selFile = s_filename; //qDebug("Edit: "+ file_title ); i=i_numofFiles+1; Edit_Title *titleEdit; titleEdit = new Edit_Title(this,file_title ,TRUE); if(titleEdit->exec() !=0) { //qDebug(titleEdit->newTitle); config.writeEntry( s_filename, titleEdit->newTitle); QListBox_1->removeItem(currentItem); QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), titleEdit->newTitle, currentItem); } } } // getTitles(); QListBox_1->triggerUpdate(true); } diff --git a/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.pro b/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.pro index e34e922..5c1d0c4 100644 --- a/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.pro +++ b/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.pro @@ -1,45 +1,44 @@ TEMPLATE = app -CONFIG += qt warn_on release quick-app -#CONFIG += qt warn_on release qpp +CONFIG += qt warn_on quick-app HEADERS = LibraryDialog.h \ SearchDialog.h \ SearchResults.h \ helpme.h \ multiline_ex.h \ openetext.h \ editTitle.h \ fontDialog.h \ optionsDialog.h \ helpwindow.h \ output.h \ NetworkDialog.h \ gutenbrowser.h \ resource.h SOURCES = LibraryDialog.cpp \ LibraryDialogData.cpp \ SearchDialog.cpp \ SearchResults.cpp \ browserDialog.cpp \ helpme.cpp \ multiline_ex.cpp \ fontDialog.cpp \ openetext.cpp \ openetextdata.cpp \ editTitle.cpp \ ftpsitedlg.cpp \ optionsDialog.cpp \ optionsDialogData.cpp \ helpwindow.cpp \ output.cpp \ NetworkDialog.cpp \ gutenbrowserData.cpp \ gutenbrowser.cpp \ main.cpp TARGET = gutenbrowser INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include DESTDIR = $(OPIEDIR)/bin -LIBS += -lqpe -lpthread -lftplib -lopie +LIBS += -lqpe -lpthread -lftplib -lopiecore2 -lopieui2 include ( $(OPIEDIR)/include.pro ) |