summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/openetext.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/openetext.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/openetext.cpp174
1 files changed, 83 insertions, 91 deletions
diff --git a/noncore/apps/opie-gutenbrowser/openetext.cpp b/noncore/apps/opie-gutenbrowser/openetext.cpp
index 0267416..a5d855d 100644
--- a/noncore/apps/opie-gutenbrowser/openetext.cpp
+++ b/noncore/apps/opie-gutenbrowser/openetext.cpp
@@ -59,4 +59,3 @@ void OpenEtext::getTitles()
s_numofFiles = config.readEntry("NumberOfFiles", "0");
- QLabel_1->setText( tr(
- s_numofFiles+" etexts in your library."));
+ QLabel_1->setText( tr( s_numofFiles+" etexts in your library." ) );
int i_numofFiles = s_numofFiles.toInt();
@@ -70,3 +69,8 @@ void OpenEtext::getTitles()
if( !title.isEmpty()) {
- QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), title, -1);
+ QListBox_1->insertItem ( QPixmap(
+ QPEApplication::qpeDir() +
+ "pics/gutenbrowser/gutenbrowser_sm.png"
+ ),
+ title,
+ -1);
}
@@ -102,4 +106,5 @@ void OpenEtext::select_title(int index )
-/*
- This function imports already existing etexts into the local library list*/
+/*!
+ * This function imports already existing etexts into the local library list
+ */
void OpenEtext::open()
@@ -115,10 +120,2 @@ OpenFileButton->setDown(TRUE);
-// 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");
@@ -136,28 +133,16 @@ OpenFileButton->setDown(TRUE);
- if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) {
- filer = str;
-
- odebug << "Open file: "+str << oendl;
-
- // 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" ) {
+ if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) {
+ filer = str;
+
+ odebug << "Open file: "+str << oendl;
+
+ 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);
@@ -166,6 +151,6 @@ OpenFileButton->setDown(TRUE);
- if( s_fileName.right(4) == ".zip") { // unzip that sucker....
+ if( s_fileName.right(4) == ".zip") { // unzip the file
s_fileName = s_fileName.left( s_fileName.length() - 4);
if( chdir((const char*)local_library.latin1())!=0)
- odebug << "chdir failed." << oendl; // QString cmd = "gunzip -d " + filer + " -d " + local_library;
+ odebug << "chdir failed." << oendl;
cmd = "gunzip -S .zip " + filer;
@@ -173,14 +158,14 @@ OpenFileButton->setDown(TRUE);
system( cmd);
- }
-// this renames the .txt to .etx!!
- else /*if( s_fileName.right(4) == ".txt" || if( s_fileName.right(4) == ".TXT"))*/ {
-// odebug << "Filename is "+fileName << oendl;
+ } else { // else rename .txt to .etx
+ // odebug << "Filename is "+fileName << oendl;
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());
+ s_fileName.replace( s_fileName.length()-3,3,"gtn");
+ if (rename(fileName.latin1(),s_fileName.latin1()) == -1)
+ owarn << "Rename of " << fileName.latin1() << " to "
+ << s_fileName.latin1() << " failed" << oendl;
fileName = s_fileName;
-// odebug << "Filename is now "+fileName << oendl;
+ // odebug << "Filename is now "+fileName << oendl;
}
} else
- fileName = str;
+ fileName = str;
@@ -203,3 +188,6 @@ OpenFileButton->setDown(TRUE);
lnk.setFile(fileName); //sets File property
- lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
+ // @bug This is probably not a registered MIME type. Perhaps we should
+ // set a valid MIME type here instead. Or maybe register .etx as a
+ // Gutenberge etext?
+ lnk.setType("guten/plain");
lnk.setExec(fileName);
@@ -210,3 +198,3 @@ OpenFileButton->setDown(TRUE);
} // end of for each file name....
- OpenFileButton->setDown(FALSE);
+ OpenFileButton->setDown(FALSE);
}
@@ -226,7 +214,6 @@ bool OpenEtext::FindTitle( QString filename)
QFile indexLib( filename);
- bool findCheck = FALSE;
- // int Titlenumber=0;
+ bool findCheck = FALSE;
if ( indexLib.open( IO_ReadOnly) ) {
- odebug << "file opened successfully" << oendl;
+ odebug << "file opened successfully" << oendl;
QTextStream indexStream( &indexLib );
@@ -238,3 +225,3 @@ bool OpenEtext::FindTitle( QString filename)
while ( !indexStream.eof() ) {
- // until end of file..
+ // until end of file..
indexLine = indexStream.readLine();
@@ -245,3 +232,3 @@ bool OpenEtext::FindTitle( QString filename)
// odebug << "Found the title 1 and it is " << title << "" << oendl;
-// QListBox_1->insertItem ( title);
+// QListBox_1->insertItem ( title);
}
@@ -252,4 +239,4 @@ bool OpenEtext::FindTitle( QString filename)
title = title.stripWhiteSpace ();
-// odebug << "Found the title 2 and it is " << title << "" << oendl;
-// QListBox_1->insertItem ( title);
+// odebug << "Found the title 2 and it is " << title << "" << oendl;
+// QListBox_1->insertItem ( title);
}
@@ -279,3 +266,2 @@ bool OpenEtext::FindTitle( QString filename)
if ( checkConf() == false && findCheck == TRUE) {
-
config.setGroup( "Files");
@@ -317,6 +303,6 @@ QString OpenEtext::titleFromLibrary( QString fileName)
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;
+ if(find2== (-1-find1))
+ find2 = fileName.findRev(".etx",-1,TRUE) - find1;
+ else if(find2==(-1-find1))
+ find2 = fileName.findRev(".txt",-1,TRUE) - find1;
@@ -336,3 +322,3 @@ QString OpenEtext::titleFromLibrary( QString fileName)
if ( indexLib.open( IO_ReadOnly) ) {
- // file opened successfully
+ // file opened successfully
QTextStream indexStream( &indexLib );
@@ -340,3 +326,3 @@ QString OpenEtext::titleFromLibrary( QString fileName)
bool findCheck = FALSE;
- while ( !indexStream.atEnd() ) { // until end of file..
+ while ( !indexStream.atEnd() ) { // until end of file..
indexLine = indexStream.readLine();
@@ -346,6 +332,5 @@ QString OpenEtext::titleFromLibrary( QString fileName)
title = indexLine.mid( 9, 50);
-// title = indexLine.mid( 26, indexLine.length() );
title = title.stripWhiteSpace ();
// odebug << "Finally Found the title and it is\n " << title << "" << oendl;
-// QListBox_1->insertItem ( title);
+// QListBox_1->insertItem ( title);
}
@@ -354,3 +339,3 @@ QString OpenEtext::titleFromLibrary( QString fileName)
else
- odebug << "Error opening library index "+ local_index << oendl;
+ odebug << "Error opening library index "+ local_index << oendl;
return title;
@@ -383,6 +368,8 @@ void OpenEtext::remove()
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 )){
+ 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,
@@ -392,9 +379,10 @@ void OpenEtext::remove()
break;
- case 1: // Cancel
- break;
- };
+ case 1:
+ default:
+ }
}
-/*
- this removes selected title entry*/
+/*!
+ * This removes selected title entry
+ */
void OpenEtext::removeSelection()
@@ -419,3 +407,3 @@ void OpenEtext::removeSelection()
rem=i;
-//odebug << "file title to remove is "+file_title << oendl;
+ //odebug << "file title to remove is "+file_title << oendl;
selFile = s_filename;
@@ -438,7 +426,7 @@ void OpenEtext::removeSelection()
config.removeEntry(fileNum2);
-// remFile();
}
-/*
- removes file title name from list and config file*/
+/*!
+ * Removes file title name from list and config file
+ */
void OpenEtext::remFile()
@@ -463,5 +451,4 @@ void OpenEtext::remFile()
- if (!s_filename2.isEmpty()) {
+ if (!s_filename2.isEmpty())
config.writeEntry(fileNum, s_filename2 );
- }
}
@@ -475,4 +462,5 @@ void OpenEtext::remFile()
-/*
-sorts the list*/
+/*!
+ * Sorts the list
+ */
void OpenEtext::scan() {
@@ -487,3 +475,3 @@ void OpenEtext::editTitle() {
QString title_text = QListBox_1->text( currentItem);
-//odebug << "Selected "+title_text << oendl;
+ //odebug << "Selected "+title_text << oendl;
@@ -501,6 +489,6 @@ void OpenEtext::editTitle() {
QString file_title = config.readEntry( s_filename, "");
-//odebug << "file_title is "+file_title << oendl;
+ //odebug << "file_title is "+file_title << oendl;
if(title_text == file_title ) {
selFile = s_filename;
-//odebug << "Edit: "+ file_title << oendl;
+ //odebug << "Edit: "+ file_title << oendl;
i=i_numofFiles+1;
@@ -509,6 +497,10 @@ void OpenEtext::editTitle() {
if(titleEdit->exec() !=0) {
-//odebug << titleEdit->newTitle << oendl;
+ //odebug << titleEdit->newTitle << oendl;
config.writeEntry( s_filename, titleEdit->newTitle);
QListBox_1->removeItem(currentItem);
- QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), titleEdit->newTitle, currentItem);
+ QListBox_1->insertItem (
+ QPixmap( QPEApplication::qpeDir()+
+ "pics/gutenbrowser/gutenbrowser_sm.png"),
+ titleEdit->newTitle, currentItem
+ );
}
@@ -517,3 +509,3 @@ void OpenEtext::editTitle() {
-// getTitles();
+ //getTitles();
QListBox_1->triggerUpdate(true);