summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.cpp185
1 files changed, 95 insertions, 90 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
index 3c096ed..7426e80 100644
--- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
@@ -574,39 +574,42 @@ void LibraryDialog::cancelIt()
574} 574}
575 575
576bool LibraryDialog::setTitle() 576bool LibraryDialog::setTitle()
577{ 577{
578 Config config("Gutenbrowser"); 578 Config config("Gutenbrowser");
579 odebug << "setting title" << oendl; 579 odebug << "setting title" << oendl;
580 odebug << DlglistItemTitle << oendl; 580 odebug << DlglistItemTitle << oendl;
581 581
582 if( DlglistItemTitle.find("[",0,TRUE) != -1) 582 if( DlglistItemTitle.find("[",0,TRUE) != -1)
583 DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" ); 583 DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" );
584 if( DlglistItemTitle.find("]",0,TRUE) !=-1) 584 if( DlglistItemTitle.find("]",0,TRUE) !=-1)
585 DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); 585 DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" );
586 odebug << "Title being set is "+DlglistItemTitle << oendl; 586 odebug << "Title being set is "+DlglistItemTitle << oendl;
587 int test = 0; 587 int test = 0;
588 QString ramble, temp; 588 QString ramble, temp;
589 config.setGroup("Files"); 589 config.setGroup("Files");
590 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 590 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
591 int i_numofFiles = s_numofFiles.toInt(); 591 int i_numofFiles = s_numofFiles.toInt();
592 for ( int i = 0; i <= i_numofFiles; i++){ 592 for ( int i = 0; i <= i_numofFiles; i++){
593 temp.setNum( i); 593 temp.setNum( i);
594 ramble = config.readEntry( temp, "" ); 594 ramble = config.readEntry( temp, "" );
595 if( strcmp( ramble, File_Name) == 0){ 595 if( strcmp( ramble, File_Name) == 0){
596 test = 1; 596 test = 1;
597 } 597 }
598 } 598 }
599
600 if(test == 0 ) {
601
599 config.setGroup("Files"); 602 config.setGroup("Files");
600 config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); 603 config.writeEntry( "NumberOfFiles", i_numofFiles +1 );
601 QString interger; 604 QString interger;
602 interger.setNum( i_numofFiles +1); 605 interger.setNum( i_numofFiles +1);
603 config.writeEntry( interger, File_Name); 606 config.writeEntry( interger, File_Name);
604 config.setGroup( "Titles" ); 607 config.setGroup( "Titles" );
605 config.writeEntry( File_Name, DlglistItemTitle); 608 config.writeEntry( File_Name, DlglistItemTitle);
606 609 }
607 test = 0; 610 test = 0;
608 return true; 611 return true;
609} 612}
610 613
611 614
612void LibraryDialog::saveConfig() 615void LibraryDialog::saveConfig()
@@ -744,11 +747,13 @@ void LibraryDialog::onButtonSearch()
744 SearchResultsDialog->showMaximized(); 747 SearchResultsDialog->showMaximized();
745 if( SearchResultsDialog->exec() != 0) { 748 if( SearchResultsDialog->exec() != 0) {
746 texter = SearchResultsDialog->selText; 749 texter = SearchResultsDialog->selText;
747 // odebug << texter << oendl; 750 // odebug << texter << oendl;
748 resultLs= SearchResultsDialog->resultsList; 751 resultLs = SearchResultsDialog->resultsList;
749 i_berger = 1; 752 i_berger = 1;
750 } 753 } else {
754 resultLs.clear();
755 }
751 Searchlist.clear(); 756 Searchlist.clear();
752 757
753 // if(SearchResultsDialog) 758 // if(SearchResultsDialog)
754 // delete SearchResultsDialog; 759 // delete SearchResultsDialog;
@@ -927,66 +932,66 @@ void LibraryDialog::comboSelect(int index)
927} 932}
928 933
929void LibraryDialog::newList() 934void LibraryDialog::newList()
930{ 935{
931 if(indexLoaded) { 936 if(indexLoaded) {
932 onButtonDownload(); 937 onButtonDownload();
933 } else { 938 } else {
934 Output *outDlg; 939 Output *outDlg;
935 buttonNewList->setDown(TRUE); 940 buttonNewList->setDown(TRUE);
936 QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser"); 941 QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser");
937 if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true); 942 if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true);
938 if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) { 943 if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) {
939 odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl; 944 odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl;
940 QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 945 QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
941 QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; 946 QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1";
942 947
943 int result = QMessageBox::warning( this,"Download" 948 int result = QMessageBox::warning( this,"Download"
944 ,"<p>Ok to use /'wget/' to download a new library list?</P>" 949 ,"<p>Ok to use /'wget/' to download a new library list?</P>"
945 ,"Yes","No",0,0,1); 950 ,"Yes","No",0,0,1);
946 qApp->processEvents(); 951 qApp->processEvents();
947 if(result == 0) { 952 if(result == 0) {
948 outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); 953 outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE);
949 outDlg->showMaximized(); 954 outDlg->showMaximized();
950 outDlg->show(); 955 outDlg->show();
951 qApp->processEvents(); 956 qApp->processEvents();
952 FILE *fp; 957 FILE *fp;
953 char line[130]; 958 char line[130];
954 outDlg->OutputEdit->append( tr("Running wget") ); 959 outDlg->OutputEdit->append( tr("Running wget") );
955 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 960 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
956 sleep(1); 961 sleep(1);
957 fp = popen( (const char *) cmd, "r"); 962 fp = popen( (const char *) cmd, "r");
958 if ( !fp ) { 963 if ( !fp ) {
959 } else { 964 } else {
960 odebug << "Issuing the command\n"+cmd << oendl; 965 odebug << "Issuing the command\n"+cmd << oendl;
961 // system(cmd); 966 // system(cmd);
962 while ( fgets( line, sizeof line, fp)) { 967 while ( fgets( line, sizeof line, fp)) {
963 outDlg->OutputEdit->append(line); 968 outDlg->OutputEdit->append(line);
964 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 969 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
965 } 970 }
966 pclose(fp); 971 pclose(fp);
967 outDlg->OutputEdit->append("Finished downloading\n"); 972 outDlg->OutputEdit->append("Finished downloading\n");
968 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 973 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
969 qApp->processEvents(); 974 qApp->processEvents();
970 975
971 // if( QFile(gutenindex1).exists() ) { 976 // if( QFile(gutenindex1).exists() ) {
972 // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 977 // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
973 // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) 978 // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0)
974 // odebug << "renaming error" << oendl; 979 // odebug << "renaming error" << oendl;
975 // } 980 // }
976 981
977 } 982 }
978 // outDlg->close(); 983 // outDlg->close();
979 FindLibrary(); 984 FindLibrary();
980 if(outDlg) delete outDlg; 985 if(outDlg) delete outDlg;
981 } 986 }
982 buttonNewList->setDown(FALSE); 987 buttonNewList->setDown(FALSE);
983 } else { 988 } else {
984 QMessageBox::message("Note","Could not change directories"); 989 QMessageBox::message("Note","Could not change directories");
985 } 990 }
986 // if(outDlg) 991 // if(outDlg)
987 // delete outDlg; 992 // delete outDlg;
988 } 993 }
989} 994}
990 995
991bool LibraryDialog::moreInfo() 996bool LibraryDialog::moreInfo()
992{ 997{