summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
index 9858188..6c246e97 100644
--- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
@@ -677,210 +677,211 @@ void LibraryDialog::saveConfig()
677 } 677 }
678 // config.write(); 678 // config.write();
679} 679}
680 680
681/* 681/*
682 searches library index for user word*/ 682 searches library index for user word*/
683void LibraryDialog::onButtonSearch() 683void LibraryDialog::onButtonSearch()
684{ 684{
685 ListView1->clearSelection(); 685 ListView1->clearSelection();
686 ListView2->clearSelection(); 686 ListView2->clearSelection();
687 ListView3->clearSelection(); 687 ListView3->clearSelection();
688 ListView4->clearSelection(); 688 ListView4->clearSelection();
689 ListView5->clearSelection(); 689 ListView5->clearSelection();
690 690
691 int curTab = tabWidget->currentPageIndex(); 691 int curTab = tabWidget->currentPageIndex();
692 SearchDialog* searchDlg; 692 SearchDialog* searchDlg;
693 693
694 // if( resultsList) 694 // if( resultsList)
695 searchDlg = new SearchDialog( this, "Library Search", true); 695 searchDlg = new SearchDialog( this, "Library Search", true);
696 searchDlg->setCaption( tr( "Library Search" ) ); 696 searchDlg->setCaption( tr( "Library Search" ) );
697 searchDlg->setLabel( "- author or title"); 697 searchDlg->setLabel( "- author or title");
698 698
699 QString resultString; 699 QString resultString;
700 700
701 int i_berger = 0; 701 int i_berger = 0;
702 if( searchDlg->exec() != 0 ) { 702 if( searchDlg->exec() != 0 ) {
703 QString searcherStr = searchDlg->get_text(); 703 QString searcherStr = searchDlg->get_text();
704 int fluff = 0; 704 int fluff = 0;
705 705
706 bool cS; 706 bool cS;
707 if( searchDlg->caseSensitiveCheckBox->isChecked()) 707 if( searchDlg->caseSensitiveCheckBox->isChecked())
708 cS = true; //case sensitive 708 cS = true; //case sensitive
709 else 709 else
710 cS = false; 710 cS = false;
711 711
712 etext etextStruct; 712 etext etextStruct;
713 QValueList<etext>::Iterator it; 713 QValueList<etext>::Iterator it;
714 714
715 for( it = etextLibrary.begin(); it != etextLibrary.end(); ++it ) { 715 for( it = etextLibrary.begin(); it != etextLibrary.end(); ++it ) {
716 QString tempTitle = (*it).title; 716 QString tempTitle = (*it).title;
717 QString tempAuthor = (*it).author; 717 QString tempAuthor = (*it).author;
718 QString tempFile = (*it).file; 718 QString tempFile = (*it).file;
719 QString tempYear = (*it).year; 719 QString tempYear = (*it).year;
720 if(tempTitle.find( searcherStr, 0, cS) != -1 720 if(tempTitle.find( searcherStr, 0, cS) != -1
721 || tempAuthor.find( searcherStr, 0, cS) != -1) { 721 || tempAuthor.find( searcherStr, 0, cS) != -1) {
722 qWarning(tempTitle); 722 qWarning(tempTitle);
723 Searchlist.append( tempTitle + " : " + tempYear + " : " + tempFile); 723 Searchlist.append( tempTitle + " : " + tempYear + " : " + tempFile);
724 } 724 }
725 } 725 }
726 726
727 727
728 tabWidget->setCurrentPage( curTab); 728 tabWidget->setCurrentPage( curTab);
729 729
730 Searchlist.sort(); 730 Searchlist.sort();
731 SearchResultsDlg* SearchResultsDialog; 731 SearchResultsDlg* SearchResultsDialog;
732 SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); 732 SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist);
733 733
734 SearchResultsDialog->showMaximized(); 734 SearchResultsDialog->showMaximized();
735 if( SearchResultsDialog->exec() != 0) { 735 if( SearchResultsDialog->exec() != 0) {
736 texter = SearchResultsDialog->selText; 736 texter = SearchResultsDialog->selText;
737 // //odebug << texter << oendl; 737 // //odebug << texter << oendl;
738 resultLs = SearchResultsDialog->resultsList; 738 resultLs = SearchResultsDialog->resultsList;
739 i_berger = 1; 739 i_berger = 1;
740 } else { 740 } else {
741 resultLs.clear(); 741 resultLs.clear();
742 } 742 }
743 Searchlist.clear(); 743 Searchlist.clear();
744 744
745 QString tester; 745 QString tester;
746 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { 746 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) {
747 texter.sprintf("%s \n",(*it).latin1()); 747 texter.sprintf("%s \n",(*it).latin1());
748 // //odebug << texter << oendl; 748 // //odebug << texter << oendl;
749 if( tester!=texter) 749 if( tester!=texter)
750 parseSearchResults( texter); 750 parseSearchResults( texter);
751 tester = texter; 751 tester = texter;
752 } 752 }
753 if(searchDlg) 753 if(searchDlg)
754 delete searchDlg; 754 delete searchDlg;
755 } 755 }
756 if(checkBox->isChecked() ) { 756 if(checkBox->isChecked() ) {
757 accept(); 757 accept();
758 } else { 758 } else {
759 setActiveWindow(); 759 setActiveWindow();
760 } 760 }
761} 761}
762 762
763/* 763/*
764 splits the result string and calls download for the current search result*/ 764 splits the result string and calls download for the current search result*/
765void LibraryDialog::parseSearchResults( QString resultStr) 765void LibraryDialog::parseSearchResults( QString resultStr)
766{ 766{
767 int stringLeng = resultStr.length(); 767 int stringLeng = resultStr.length();
768 768
769 QString my; 769 QString my;
770 my.setNum( stringLeng, 10); 770 my.setNum( stringLeng, 10);
771 771
772 if( resultStr.length() > 2 && resultStr.length() < 130) { 772 if( resultStr.length() > 2 && resultStr.length() < 130) {
773 QStringList token = QStringList::split(" : ", resultStr);
773 774
774 int titleInt = resultStr.find( " : ", 0, true); 775 DlglistItemTitle = token[0];
775 DlglistItemTitle = resultStr.left( titleInt); 776 DlglistItemTitle = DlglistItemTitle.stripWhiteSpace();
776 777
777 int yearInt = resultStr.find( " : ", titleInt+3, true); 778 DlglistItemYear = token[1];
778 779 DlglistItemYear = DlglistItemYear.stripWhiteSpace();
779 DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); 780
780 781 DlglistItemFile = token[2];
781 DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); 782
782 DlglistItemFile = DlglistItemFile.left( DlglistItemFile.length() - 2); 783 DlglistItemFile = DlglistItemFile.stripWhiteSpace();
783 784
784 cleanStrings(); 785// qWarning(DlglistItemYear);
786
785 787
786 if(DlglistItemFile.left(1) == "/") 788 if(DlglistItemFile.left(1) == "/")
787 DlglistItemFile = DlglistItemFile.right( DlglistItemFile.length() - 1); 789 DlglistItemFile = DlglistItemFile.right( DlglistItemFile.length() - 1);
788 790
789 791 if(DlglistItemFile.toInt() > 10000 || DlglistItemYear == "1980" ) {
790 if(DlglistItemFile.toInt() > 10000 || yearInt == 1980 ) {
791 // new directory sturcture 792 // new directory sturcture
792 download_newEtext(); //) 793 download_newEtext(); //)
793 } else { 794 } else {
794 download_Etext(); //) 795 download_Etext(); //)
795 } 796 }
796 } 797 }
797} 798}
798 799
799void LibraryDialog::sortLists(int index) 800void LibraryDialog::sortLists(int index)
800{ 801{
801 802
802 ListView1->setSorting(index); 803 ListView1->setSorting(index);
803 ListView2->setSorting(index); 804 ListView2->setSorting(index);
804 ListView3->setSorting(index); 805 ListView3->setSorting(index);
805 ListView4->setSorting(index); 806 ListView4->setSorting(index);
806 ListView5->setSorting(index); 807 ListView5->setSorting(index);
807 ListView1->sort(); 808 ListView1->sort();
808 ListView2->sort(); 809 ListView2->sort();
809 ListView3->sort(); 810 ListView3->sort();
810 ListView4->sort(); 811 ListView4->sort();
811 ListView5->sort(); 812 ListView5->sort();
812} 813}
813 814
814/* 815/*
815 Downloads the current selected listitem*/ 816 Downloads the current selected listitem*/
816bool LibraryDialog::getItem(QListViewItem *it) 817bool LibraryDialog::getItem(QListViewItem *it)
817{ 818{
818 // //odebug << "selected getItem" << oendl; 819 // //odebug << "selected getItem" << oendl;
819 820
820 // DlglistItemNumber = it->text(0); 821 // DlglistItemNumber = it->text(0);
821 DlglistItemTitle = it->text(0); 822 DlglistItemTitle = it->text(0);
822 DlglistItemYear = it->text(2); 823 DlglistItemYear = it->text(2);
823 DlglistItemFile = it->text(3); 824 DlglistItemFile = it->text(3);
824 825
825 if(download_Etext()) { 826 if(download_Etext()) {
826 if(i_binary == 1) { 827 if(i_binary == 1) {
827 } 828 }
828 } 829 }
829 return true; 830 return true;
830} 831}
831 832
832/* 833/*
833 download button is pushed so we get the current items to download*/ 834 download button is pushed so we get the current items to download*/
834bool LibraryDialog::onButtonDownload() 835bool LibraryDialog::onButtonDownload()
835{ 836{
836 // //odebug << "selected onButtonDownloadz" << oendl; 837 // //odebug << "selected onButtonDownloadz" << oendl;
837 838
838 QListViewItemIterator it1( ListView1 ); 839 QListViewItemIterator it1( ListView1 );
839 QListViewItemIterator it2( ListView2 ); 840 QListViewItemIterator it2( ListView2 );
840 QListViewItemIterator it3( ListView3 ); 841 QListViewItemIterator it3( ListView3 );
841 QListViewItemIterator it4( ListView4 ); 842 QListViewItemIterator it4( ListView4 );
842 QListViewItemIterator it5( ListView5 ); 843 QListViewItemIterator it5( ListView5 );
843 844
844 // iterate through all items of the listview 845 // iterate through all items of the listview
845 for ( ; it1.current(); ++it1 ) { 846 for ( ; it1.current(); ++it1 ) {
846 if ( it1.current()->isSelected() ) 847 if ( it1.current()->isSelected() )
847 getItem(it1.current()); 848 getItem(it1.current());
848 it1.current()->setSelected(false); 849 it1.current()->setSelected(false);
849 } 850 }
850 for ( ; it2.current(); ++it2 ) { 851 for ( ; it2.current(); ++it2 ) {
851 if ( it2.current()->isSelected() ) 852 if ( it2.current()->isSelected() )
852 getItem(it2.current()); 853 getItem(it2.current());
853 it2.current()->setSelected(false); 854 it2.current()->setSelected(false);
854 } 855 }
855 for ( ; it3.current(); ++it3 ) { 856 for ( ; it3.current(); ++it3 ) {
856 if ( it3.current()->isSelected() ) 857 if ( it3.current()->isSelected() )
857 getItem(it3.current()); 858 getItem(it3.current());
858 it3.current()->setSelected(false); 859 it3.current()->setSelected(false);
859 } 860 }
860 for ( ; it4.current(); ++it4 ) { 861 for ( ; it4.current(); ++it4 ) {
861 if ( it4.current()->isSelected() ) 862 if ( it4.current()->isSelected() )
862 getItem(it4.current()); 863 getItem(it4.current());
863 it4.current()->setSelected(false); 864 it4.current()->setSelected(false);
864 } 865 }
865 for ( ; it5.current(); ++it5 ) { 866 for ( ; it5.current(); ++it5 ) {
866 if ( it5.current()->isSelected() ) 867 if ( it5.current()->isSelected() )
867 getItem(it5.current()); 868 getItem(it5.current());
868 it5.current()->setSelected(false); 869 it5.current()->setSelected(false);
869 } 870 }
870 return true; 871 return true;
871} 872}
872 873
873 874
874/* 875/*
875 handles the sorting combo box */ 876 handles the sorting combo box */
876void LibraryDialog::comboSelect(int index) 877void LibraryDialog::comboSelect(int index)
877{ 878{
878 // //odebug << "we are sorting" << oendl; 879 // //odebug << "we are sorting" << oendl;
879 ListView1->setSorting( index, true); 880 ListView1->setSorting( index, true);
880 ListView2->setSorting( index, true); 881 ListView2->setSorting( index, true);
881 ListView3->setSorting( index, true); 882 ListView3->setSorting( index, true);
882 ListView4->setSorting( index, true); 883 ListView4->setSorting( index, true);
883 ListView5->setSorting( index, true); 884 ListView5->setSorting( index, true);
884 885
885 ListView1->sort(); 886 ListView1->sort();
886 ListView2->sort(); 887 ListView2->sort();