summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2005-02-06 04:30:34 (UTC)
committer llornkcor <llornkcor>2005-02-06 04:30:34 (UTC)
commit60a856903eb688b56c61fa787ac26b6be9f6d6c4 (patch) (unidiff)
tree81848a11c6b006ed4b6ac5a036de8402dde8e25d
parente23dd592fc71aa22c449363231eac2f8ebd2a45b (diff)
downloadopie-60a856903eb688b56c61fa787ac26b6be9f6d6c4.zip
opie-60a856903eb688b56c61fa787ac26b6be9f6d6c4.tar.gz
opie-60a856903eb688b56c61fa787ac26b6be9f6d6c4.tar.bz2
fix #1494 - download of file when search is canceled
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
@@ -554,79 +554,82 @@ bool LibraryDialog::httpDownload()
554 m_getFilePath = local_library + str; 554 m_getFilePath = local_library + str;
555 i++; 555 i++;
556 if ( brow != "KFM"){ ///////// use lynx 556 if ( brow != "KFM"){ ///////// use lynx
557 QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; 557 QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath;
558 // QMessageBox::message("Error", cmd); 558 // QMessageBox::message("Error", cmd);
559 system(cmd); 559 system(cmd);
560 } else { ////////// use KFM 560 } else { ////////// use KFM
561 // KFM::download( httpName, m_getFilePath); 561 // KFM::download( httpName, m_getFilePath);
562 } 562 }
563 i++; 563 i++;
564#endif 564#endif
565 return false; 565 return false;
566} 566}
567 567
568void LibraryDialog::cancelIt() 568void LibraryDialog::cancelIt()
569{ 569{
570 saveConfig(); 570 saveConfig();
571 571
572 DlglistItemNumber = ""; 572 DlglistItemNumber = "";
573 this->reject(); 573 this->reject();
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()
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;
621 config.setGroup( "Proxy" ); 624 config.setGroup( "Proxy" );
622 config.writeEntry("IsChecked", "FALSE"); 625 config.writeEntry("IsChecked", "FALSE");
623 } 626 }
624 if (authBox->isChecked() == TRUE) { 627 if (authBox->isChecked() == TRUE) {
625 config.setGroup("SortAuth"); 628 config.setGroup("SortAuth");
626 config.writeEntry("authSort", "TRUE"); 629 config.writeEntry("authSort", "TRUE");
627 } else { 630 } else {
628 config.setGroup("SortAuth"); 631 config.setGroup("SortAuth");
629 config.writeEntry("authSort", "FALSE"); 632 config.writeEntry("authSort", "FALSE");
630 } 633 }
631 // config.write(); 634 // config.write();
632} 635}
@@ -724,51 +727,53 @@ void LibraryDialog::onButtonSearch()
724 } 727 }
725 if(fluff==0) { // search routine here 728 if(fluff==0) { // search routine here
726 for ( ; it5.current(); ++it5 ) { 729 for ( ; it5.current(); ++it5 ) {
727 resultString = ( it5.current() )->text(0); 730 resultString = ( it5.current() )->text(0);
728 resultString += (" : "); 731 resultString += (" : ");
729 resultString += ( it5.current() )->text(2); 732 resultString += ( it5.current() )->text(2);
730 resultString += (" : "); 733 resultString += (" : ");
731 resultString += ( it5.current() )->text(3); 734 resultString += ( it5.current() )->text(3);
732 if( resultString.find( searcherStr, 0, cS) != -1) { 735 if( resultString.find( searcherStr, 0, cS) != -1) {
733 Searchlist.append( resultString); 736 Searchlist.append( resultString);
734 } 737 }
735 } 738 }
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 }
763 if(searchDlg) 768 if(searchDlg)
764 delete searchDlg; 769 delete searchDlg;
765 } 770 }
766 if(checkBox->isChecked() ) { 771 if(checkBox->isChecked() ) {
767 accept(); 772 accept();
768 } else { 773 } else {
769 setActiveWindow(); 774 setActiveWindow();
770 } 775 }
771} 776}
772 777
773 /* 778 /*
774 splits the result string and calls download for the current search result*/ 779 splits the result string and calls download for the current search result*/
@@ -907,106 +912,106 @@ bool LibraryDialog::onButtonDownload()
907void LibraryDialog::comboSelect(int index) 912void LibraryDialog::comboSelect(int index)
908{ 913{
909 // odebug << "we are sorting" << oendl; 914 // odebug << "we are sorting" << oendl;
910 ListView1->setSorting( index, TRUE); 915 ListView1->setSorting( index, TRUE);
911 ListView2->setSorting( index, TRUE); 916 ListView2->setSorting( index, TRUE);
912 ListView3->setSorting( index, TRUE); 917 ListView3->setSorting( index, TRUE);
913 ListView4->setSorting( index, TRUE); 918 ListView4->setSorting( index, TRUE);
914 ListView5->setSorting( index, TRUE); 919 ListView5->setSorting( index, TRUE);
915 920
916 ListView1->sort(); 921 ListView1->sort();
917 ListView2->sort(); 922 ListView2->sort();
918 ListView3->sort(); 923 ListView3->sort();
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
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{
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();
1001 item = 0; 1006 item = 0;
1002 } 1007 }
1003 if( item == 0) 1008 if( item == 0)
1004 item = ListView2->currentItem(); 1009 item = ListView2->currentItem();
1005 if( item != 0) { 1010 if( item != 0) {
1006 titleString = item->text(0); 1011 titleString = item->text(0);
1007 ListView2->clearSelection(); 1012 ListView2->clearSelection();
1008 item = 0; 1013 item = 0;
1009 } 1014 }
1010 if( item == 0) 1015 if( item == 0)
1011 item = ListView3->currentItem(); 1016 item = ListView3->currentItem();
1012 if( item != 0) { 1017 if( item != 0) {