-rw-r--r-- | noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | 185 |
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 | |||
@@ -566,55 +566,58 @@ bool LibraryDialog::httpDownload() | |||
566 | } | 566 | } |
567 | 567 | ||
568 | void LibraryDialog::cancelIt() | 568 | void LibraryDialog::cancelIt() |
569 | { | 569 | { |
570 | saveConfig(); | 570 | saveConfig(); |
571 | 571 | ||
572 | DlglistItemNumber = ""; | 572 | DlglistItemNumber = ""; |
573 | this->reject(); | 573 | this->reject(); |
574 | } | 574 | } |
575 | 575 | ||
576 | bool LibraryDialog::setTitle() | 576 | bool 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 | ||
612 | void LibraryDialog::saveConfig() | 615 | void LibraryDialog::saveConfig() |
613 | { | 616 | { |
614 | Config config("Gutenbrowser"); | 617 | Config config("Gutenbrowser"); |
615 | if( httpBox->isChecked() == TRUE) { | 618 | if( httpBox->isChecked() == TRUE) { |
616 | checked = 1; | 619 | checked = 1; |
617 | config.setGroup( "Proxy" ); | 620 | config.setGroup( "Proxy" ); |
618 | config.writeEntry("IsChecked", "TRUE"); | 621 | config.writeEntry("IsChecked", "TRUE"); |
619 | } else { | 622 | } else { |
620 | checked = 0; | 623 | checked = 0; |
@@ -736,27 +739,29 @@ void LibraryDialog::onButtonSearch() | |||
736 | } | 739 | } |
737 | 740 | ||
738 | tabWidget->setCurrentPage( curTab); | 741 | tabWidget->setCurrentPage( curTab); |
739 | 742 | ||
740 | Searchlist.sort(); | 743 | Searchlist.sort(); |
741 | SearchResultsDlg* SearchResultsDialog; | 744 | SearchResultsDlg* SearchResultsDialog; |
742 | SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); | 745 | SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); |
743 | 746 | ||
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; |
755 | QString tester; | 760 | QString tester; |
756 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { | 761 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { |
757 | texter.sprintf("%s \n",(*it).latin1()); | 762 | texter.sprintf("%s \n",(*it).latin1()); |
758 | // odebug << texter << oendl; | 763 | // odebug << texter << oendl; |
759 | if( tester!=texter) | 764 | if( tester!=texter) |
760 | parseSearchResults( texter); | 765 | parseSearchResults( texter); |
761 | tester = texter; | 766 | tester = texter; |
762 | } | 767 | } |
@@ -919,82 +924,82 @@ void LibraryDialog::comboSelect(int index) | |||
919 | ListView4->sort(); | 924 | ListView4->sort(); |
920 | ListView5->sort(); | 925 | ListView5->sort(); |
921 | 926 | ||
922 | // ListView1->triggerUpdate(); | 927 | // ListView1->triggerUpdate(); |
923 | // ListView2->triggerUpdate(); | 928 | // ListView2->triggerUpdate(); |
924 | // ListView3->triggerUpdate(); | 929 | // ListView3->triggerUpdate(); |
925 | // ListView4->triggerUpdate(); | 930 | // ListView4->triggerUpdate(); |
926 | // ListView5->triggerUpdate(); | 931 | // ListView5->triggerUpdate(); |
927 | } | 932 | } |
928 | 933 | ||
929 | void LibraryDialog::newList() | 934 | void 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 | ||
991 | bool LibraryDialog::moreInfo() | 996 | bool LibraryDialog::moreInfo() |
992 | { | 997 | { |
993 | 998 | ||
994 | QListViewItem * item; | 999 | QListViewItem * item; |
995 | item = 0; | 1000 | item = 0; |
996 | QString titleString; | 1001 | QString titleString; |
997 | item = ListView1->currentItem(); | 1002 | item = ListView1->currentItem(); |
998 | if( item != 0) { | 1003 | if( item != 0) { |
999 | titleString = item->text(0); | 1004 | titleString = item->text(0); |
1000 | ListView1->clearSelection(); | 1005 | ListView1->clearSelection(); |