-rw-r--r-- | noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp index 3b540c5..58babe9 100644 --- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | |||
@@ -547,523 +547,523 @@ bool LibraryDialog::httpDownload() | |||
547 | QString httpName = proxy_http + "/"+Edir; | 547 | QString httpName = proxy_http + "/"+Edir; |
548 | // progressBar->setProgress( i); | 548 | // progressBar->setProgress( i); |
549 | i++; | 549 | i++; |
550 | if ( brow != "Konq") { /////////// use lynx | 550 | if ( brow != "Konq") { /////////// use lynx |
551 | // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name; | 551 | // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name; |
552 | // system(cmd); | 552 | // system(cmd); |
553 | } else { //////////// use KFM | 553 | } else { //////////// use KFM |
554 | // KFM::download( httpName, file_name); | 554 | // KFM::download( httpName, file_name); |
555 | } | 555 | } |
556 | i++; | 556 | i++; |
557 | QFile tmp( file_name); | 557 | QFile tmp( file_name); |
558 | QString str; | 558 | QString str; |
559 | if (tmp.open(IO_ReadOnly)) { | 559 | if (tmp.open(IO_ReadOnly)) { |
560 | QTextStream t( &tmp ); // use a text stream | 560 | QTextStream t( &tmp ); // use a text stream |
561 | while ( !t.eof()) { | 561 | while ( !t.eof()) { |
562 | QString s = t.readLine(); | 562 | QString s = t.readLine(); |
563 | if (s.contains( NewlistItemFile, false) && (s.contains(".txt")) ) { | 563 | if (s.contains( NewlistItemFile, false) && (s.contains(".txt")) ) { |
564 | str = s.mid( s.find( ".txt\">"+NewlistItemFile, 0, true)+6, (s.find( ".txt</A>", 0, true) + 4) - ( s.find( ".txt\">"+NewlistItemFile, 0, true)+6 ) ); | 564 | str = s.mid( s.find( ".txt\">"+NewlistItemFile, 0, true)+6, (s.find( ".txt</A>", 0, true) + 4) - ( s.find( ".txt\">"+NewlistItemFile, 0, true)+6 ) ); |
565 | httpName += "/" + str; | 565 | httpName += "/" + str; |
566 | } | 566 | } |
567 | } //end of while loop | 567 | } //end of while loop |
568 | } | 568 | } |
569 | tmp.close(); | 569 | tmp.close(); |
570 | m_getFilePath = local_library + str; | 570 | m_getFilePath = local_library + str; |
571 | i++; | 571 | i++; |
572 | if ( brow != "KFM"){ ///////// use lynx | 572 | if ( brow != "KFM"){ ///////// use lynx |
573 | QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; | 573 | QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; |
574 | // QMessageBox::message("Error", cmd); | 574 | // QMessageBox::message("Error", cmd); |
575 | system(cmd); | 575 | system(cmd); |
576 | } else { ////////// use KFM | 576 | } else { ////////// use KFM |
577 | // KFM::download( httpName, m_getFilePath); | 577 | // KFM::download( httpName, m_getFilePath); |
578 | } | 578 | } |
579 | i++; | 579 | i++; |
580 | #endif | 580 | #endif |
581 | return false; | 581 | return false; |
582 | } | 582 | } |
583 | 583 | ||
584 | void LibraryDialog::cancelIt() | 584 | void LibraryDialog::cancelIt() |
585 | { | 585 | { |
586 | saveConfig(); | 586 | saveConfig(); |
587 | 587 | ||
588 | DlglistItemNumber = ""; | 588 | DlglistItemNumber = ""; |
589 | this->reject(); | 589 | this->reject(); |
590 | } | 590 | } |
591 | 591 | ||
592 | bool LibraryDialog::setTitle() | 592 | bool LibraryDialog::setTitle() |
593 | { | 593 | { |
594 | Config config("Gutenbrowser"); | 594 | Config config("Gutenbrowser"); |
595 | //odebug << "setting title" << oendl; | 595 | //odebug << "setting title" << oendl; |
596 | //odebug << DlglistItemTitle << oendl; | 596 | //odebug << DlglistItemTitle << oendl; |
597 | 597 | ||
598 | if( DlglistItemTitle.find("[",0,true) != -1) | 598 | if( DlglistItemTitle.find("[",0,true) != -1) |
599 | DlglistItemTitle.replace(DlglistItemTitle.find("[",0,true),1, "(" ); | 599 | DlglistItemTitle.replace(DlglistItemTitle.find("[",0,true),1, "(" ); |
600 | if( DlglistItemTitle.find("]",0,true) !=-1) | 600 | if( DlglistItemTitle.find("]",0,true) !=-1) |
601 | DlglistItemTitle.replace(DlglistItemTitle.find("]",0,true),1, ")" ); | 601 | DlglistItemTitle.replace(DlglistItemTitle.find("]",0,true),1, ")" ); |
602 | //odebug << "Title being set is "+DlglistItemTitle << oendl; | 602 | //odebug << "Title being set is "+DlglistItemTitle << oendl; |
603 | int test = 0; | 603 | int test = 0; |
604 | QString ramble, temp; | 604 | QString ramble, temp; |
605 | config.setGroup("Files"); | 605 | config.setGroup("Files"); |
606 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 606 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
607 | int i_numofFiles = s_numofFiles.toInt(); | 607 | int i_numofFiles = s_numofFiles.toInt(); |
608 | for ( int i = 0; i <= i_numofFiles; i++){ | 608 | for ( int i = 0; i <= i_numofFiles; i++){ |
609 | temp.setNum( i); | 609 | temp.setNum( i); |
610 | ramble = config.readEntry( temp, "" ); | 610 | ramble = config.readEntry( temp, "" ); |
611 | if( strcmp( ramble, File_Name) == 0){ | 611 | if( strcmp( ramble, File_Name) == 0){ |
612 | test = 1; | 612 | test = 1; |
613 | } | 613 | } |
614 | } | 614 | } |
615 | 615 | ||
616 | if(test == 0 ) { | 616 | if(test == 0 ) { |
617 | 617 | ||
618 | config.setGroup("Files"); | 618 | config.setGroup("Files"); |
619 | config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); | 619 | config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); |
620 | QString interger; | 620 | QString interger; |
621 | interger.setNum( i_numofFiles +1); | 621 | interger.setNum( i_numofFiles +1); |
622 | config.writeEntry( interger, File_Name); | 622 | config.writeEntry( interger, File_Name); |
623 | config.setGroup( "Titles" ); | 623 | config.setGroup( "Titles" ); |
624 | config.writeEntry( File_Name, DlglistItemTitle); | 624 | config.writeEntry( File_Name, DlglistItemTitle); |
625 | } | 625 | } |
626 | test = 0; | 626 | test = 0; |
627 | return true; | 627 | return true; |
628 | } | 628 | } |
629 | 629 | ||
630 | 630 | ||
631 | void LibraryDialog::saveConfig() | 631 | void LibraryDialog::saveConfig() |
632 | { | 632 | { |
633 | Config config("Gutenbrowser"); | 633 | Config config("Gutenbrowser"); |
634 | if( httpBox->isChecked() == true) { | 634 | if( httpBox->isChecked() == true) { |
635 | checked = 1; | 635 | checked = 1; |
636 | config.setGroup( "Proxy" ); | 636 | config.setGroup( "Proxy" ); |
637 | config.writeEntry("IsChecked", "true"); | 637 | config.writeEntry("IsChecked", "true"); |
638 | } else { | 638 | } else { |
639 | checked = 0; | 639 | checked = 0; |
640 | config.setGroup( "Proxy" ); | 640 | config.setGroup( "Proxy" ); |
641 | config.writeEntry("IsChecked", "false"); | 641 | config.writeEntry("IsChecked", "false"); |
642 | } | 642 | } |
643 | if (authBox->isChecked() == true) { | 643 | if (authBox->isChecked() == true) { |
644 | config.setGroup("SortAuth"); | 644 | config.setGroup("SortAuth"); |
645 | config.writeEntry("authSort", "true"); | 645 | config.writeEntry("authSort", "true"); |
646 | } else { | 646 | } else { |
647 | config.setGroup("SortAuth"); | 647 | config.setGroup("SortAuth"); |
648 | config.writeEntry("authSort", "false"); | 648 | config.writeEntry("authSort", "false"); |
649 | } | 649 | } |
650 | // config.write(); | 650 | // config.write(); |
651 | } | 651 | } |
652 | 652 | ||
653 | /* | 653 | /* |
654 | searches library index for user word*/ | 654 | searches library index for user word*/ |
655 | void LibraryDialog::onButtonSearch() | 655 | void LibraryDialog::onButtonSearch() |
656 | { | 656 | { |
657 | ListView1->clearSelection(); | 657 | ListView1->clearSelection(); |
658 | ListView2->clearSelection(); | 658 | ListView2->clearSelection(); |
659 | ListView3->clearSelection(); | 659 | ListView3->clearSelection(); |
660 | ListView4->clearSelection(); | 660 | ListView4->clearSelection(); |
661 | ListView5->clearSelection(); | 661 | ListView5->clearSelection(); |
662 | 662 | ||
663 | int curTab = tabWidget->currentPageIndex(); | 663 | int curTab = tabWidget->currentPageIndex(); |
664 | SearchDialog* searchDlg; | 664 | SearchDialog* searchDlg; |
665 | 665 | ||
666 | // if( resultsList) | 666 | // if( resultsList) |
667 | searchDlg = new SearchDialog( this, "Library Search", true); | 667 | searchDlg = new SearchDialog( this, "Library Search", true); |
668 | searchDlg->setCaption( tr( "Library Search" ) ); | 668 | searchDlg->setCaption( tr( "Library Search" ) ); |
669 | searchDlg->setLabel( "- author or title"); | 669 | searchDlg->setLabel( "- author or title"); |
670 | 670 | ||
671 | QString resultString; | 671 | QString resultString; |
672 | 672 | ||
673 | int i_berger = 0; | 673 | int i_berger = 0; |
674 | if( searchDlg->exec() != 0 ) { | 674 | if( searchDlg->exec() != 0 ) { |
675 | QString searcherStr = searchDlg->get_text(); | 675 | QString searcherStr = searchDlg->get_text(); |
676 | int fluff = 0; | 676 | int fluff = 0; |
677 | 677 | ||
678 | // int tabPage = tabWidget->currentPageIndex(); | 678 | // int tabPage = tabWidget->currentPageIndex(); |
679 | // TODO ititerate here... struct<listViews>?? | 679 | // TODO ititerate here... struct<listViews>?? |
680 | 680 | ||
681 | QListViewItemIterator it1( ListView1 ); | 681 | QListViewItemIterator it1( ListView1 ); |
682 | QListViewItemIterator it2( ListView2 ); | 682 | QListViewItemIterator it2( ListView2 ); |
683 | QListViewItemIterator it3( ListView3 ); | 683 | QListViewItemIterator it3( ListView3 ); |
684 | QListViewItemIterator it4( ListView4 ); | 684 | QListViewItemIterator it4( ListView4 ); |
685 | QListViewItemIterator it5( ListView5 ); | 685 | QListViewItemIterator it5( ListView5 ); |
686 | 686 | ||
687 | //// this is really pitiful work, | 687 | //// this is really pitiful work, |
688 | /////// | 688 | /////// |
689 | bool cS; | 689 | bool cS; |
690 | if( searchDlg->caseSensitiveCheckBox->isChecked()) | 690 | if( searchDlg->caseSensitiveCheckBox->isChecked()) |
691 | cS=true; //case sensitive | 691 | cS=true; //case sensitive |
692 | else | 692 | else |
693 | cS=false; | 693 | cS=false; |
694 | 694 | ||
695 | if(fluff==0) { | 695 | if(fluff==0) { |
696 | for ( ; it1.current(); ++it1 ) { | 696 | for ( ; it1.current(); ++it1 ) { |
697 | resultString = ( it1.current() )->text(0); | 697 | resultString = ( it1.current() )->text(0); |
698 | resultString += (" : "); | 698 | resultString += (" : "); |
699 | resultString += ( it1.current() )->text(2); | 699 | resultString += ( it1.current() )->text(2); |
700 | resultString += (" : "); | 700 | resultString += (" : "); |
701 | resultString += ( it1.current() )->text(3); | 701 | resultString += ( it1.current() )->text(3); |
702 | if( resultString.find( searcherStr, 0, cS) != -1) | 702 | if( resultString.find( searcherStr, 0, cS) != -1) |
703 | { | 703 | { |
704 | Searchlist.append( resultString); | 704 | Searchlist.append( resultString); |
705 | } | 705 | } |
706 | } | 706 | } |
707 | } | 707 | } |
708 | if(fluff==0) {// search routine here | 708 | if(fluff==0) {// search routine here |
709 | for ( ; it2.current(); ++it2 ) { | 709 | for ( ; it2.current(); ++it2 ) { |
710 | resultString = ( it2.current() )->text(0); | 710 | resultString = ( it2.current() )->text(0); |
711 | resultString += (" : "); | 711 | resultString += (" : "); |
712 | resultString += ( it2.current() )->text(2); | 712 | resultString += ( it2.current() )->text(2); |
713 | resultString += (" : "); | 713 | resultString += (" : "); |
714 | resultString += ( it2.current() )->text(3); | 714 | resultString += ( it2.current() )->text(3); |
715 | if( resultString.find( searcherStr, 0, cS) != -1) { | 715 | if( resultString.find( searcherStr, 0, cS) != -1) { |
716 | Searchlist.append( resultString); | 716 | Searchlist.append( resultString); |
717 | } | 717 | } |
718 | } | 718 | } |
719 | } | 719 | } |
720 | if(fluff==0) {// search routine here | 720 | if(fluff==0) {// search routine here |
721 | for ( ; it3.current(); ++it3 ) { | 721 | for ( ; it3.current(); ++it3 ) { |
722 | resultString = ( it3.current() )->text(0); | 722 | resultString = ( it3.current() )->text(0); |
723 | resultString += (" : "); | 723 | resultString += (" : "); |
724 | resultString += ( it3.current() )->text(2); | 724 | resultString += ( it3.current() )->text(2); |
725 | resultString += (" : "); | 725 | resultString += (" : "); |
726 | resultString += ( it3.current() )->text(3); | 726 | resultString += ( it3.current() )->text(3); |
727 | 727 | ||
728 | if( resultString.find( searcherStr, 0, cS) != -1) { | 728 | if( resultString.find( searcherStr, 0, cS) != -1) { |
729 | Searchlist.append( resultString); | 729 | Searchlist.append( resultString); |
730 | } | 730 | } |
731 | } | 731 | } |
732 | } | 732 | } |
733 | if(fluff==0) { | 733 | if(fluff==0) { |
734 | // search routine here | 734 | // search routine here |
735 | for ( ; it4.current(); ++it4 ) { | 735 | for ( ; it4.current(); ++it4 ) { |
736 | resultString = ( it4.current() )->text(0); | 736 | resultString = ( it4.current() )->text(0); |
737 | resultString += (" : "); | 737 | resultString += (" : "); |
738 | resultString += ( it4.current() )->text(2); | 738 | resultString += ( it4.current() )->text(2); |
739 | resultString += (" : "); | 739 | resultString += (" : "); |
740 | resultString += ( it4.current() )->text(3); | 740 | resultString += ( it4.current() )->text(3); |
741 | if( resultString.find( searcherStr, 0, cS) != -1) { | 741 | if( resultString.find( searcherStr, 0, cS) != -1) { |
742 | Searchlist.append( resultString); | 742 | Searchlist.append( resultString); |
743 | } | 743 | } |
744 | } | 744 | } |
745 | } | 745 | } |
746 | if(fluff==0) { // search routine here | 746 | if(fluff==0) { // search routine here |
747 | for ( ; it5.current(); ++it5 ) { | 747 | for ( ; it5.current(); ++it5 ) { |
748 | resultString = ( it5.current() )->text(0); | 748 | resultString = ( it5.current() )->text(0); |
749 | resultString += (" : "); | 749 | resultString += (" : "); |
750 | resultString += ( it5.current() )->text(2); | 750 | resultString += ( it5.current() )->text(2); |
751 | resultString += (" : "); | 751 | resultString += (" : "); |
752 | resultString += ( it5.current() )->text(3); | 752 | resultString += ( it5.current() )->text(3); |
753 | if( resultString.find( searcherStr, 0, cS) != -1) { | 753 | if( resultString.find( searcherStr, 0, cS) != -1) { |
754 | Searchlist.append( resultString); | 754 | Searchlist.append( resultString); |
755 | } | 755 | } |
756 | } | 756 | } |
757 | } | 757 | } |
758 | 758 | ||
759 | tabWidget->setCurrentPage( curTab); | 759 | tabWidget->setCurrentPage( curTab); |
760 | 760 | ||
761 | Searchlist.sort(); | 761 | Searchlist.sort(); |
762 | SearchResultsDlg* SearchResultsDialog; | 762 | SearchResultsDlg* SearchResultsDialog; |
763 | SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); | 763 | SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); |
764 | 764 | ||
765 | SearchResultsDialog->showMaximized(); | 765 | SearchResultsDialog->showMaximized(); |
766 | if( SearchResultsDialog->exec() != 0) { | 766 | if( SearchResultsDialog->exec() != 0) { |
767 | texter = SearchResultsDialog->selText; | 767 | texter = SearchResultsDialog->selText; |
768 | // //odebug << texter << oendl; | 768 | // //odebug << texter << oendl; |
769 | resultLs = SearchResultsDialog->resultsList; | 769 | resultLs = SearchResultsDialog->resultsList; |
770 | i_berger = 1; | 770 | i_berger = 1; |
771 | } else { | 771 | } else { |
772 | resultLs.clear(); | 772 | resultLs.clear(); |
773 | } | 773 | } |
774 | Searchlist.clear(); | 774 | Searchlist.clear(); |
775 | 775 | ||
776 | // if(SearchResultsDialog) | 776 | // if(SearchResultsDialog) |
777 | // delete SearchResultsDialog; | 777 | // delete SearchResultsDialog; |
778 | QString tester; | 778 | QString tester; |
779 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { | 779 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { |
780 | texter.sprintf("%s \n",(*it).latin1()); | 780 | texter.sprintf("%s \n",(*it).latin1()); |
781 | // //odebug << texter << oendl; | 781 | // //odebug << texter << oendl; |
782 | if( tester!=texter) | 782 | if( tester!=texter) |
783 | parseSearchResults( texter); | 783 | parseSearchResults( texter); |
784 | tester = texter; | 784 | tester = texter; |
785 | } | 785 | } |
786 | if(searchDlg) | 786 | if(searchDlg) |
787 | delete searchDlg; | 787 | delete searchDlg; |
788 | } | 788 | } |
789 | if(checkBox->isChecked() ) { | 789 | if(checkBox->isChecked() ) { |
790 | accept(); | 790 | accept(); |
791 | } else { | 791 | } else { |
792 | setActiveWindow(); | 792 | setActiveWindow(); |
793 | } | 793 | } |
794 | } | 794 | } |
795 | 795 | ||
796 | /* | 796 | /* |
797 | splits the result string and calls download for the current search result*/ | 797 | splits the result string and calls download for the current search result*/ |
798 | void LibraryDialog::parseSearchResults( QString resultStr) | 798 | void LibraryDialog::parseSearchResults( QString resultStr) |
799 | { | 799 | { |
800 | int stringLeng = resultStr.length(); | 800 | int stringLeng = resultStr.length(); |
801 | 801 | ||
802 | QString my; | 802 | QString my; |
803 | my.setNum( stringLeng, 10); | 803 | my.setNum( stringLeng, 10); |
804 | 804 | ||
805 | if( resultStr.length() > 2 && resultStr.length() < 130) { | 805 | if( resultStr.length() > 2 && resultStr.length() < 130) { |
806 | 806 | ||
807 | int titleInt = resultStr.find( " : ", 0, true); | 807 | int titleInt = resultStr.find( " : ", 0, true); |
808 | DlglistItemTitle = resultStr.left( titleInt); | 808 | DlglistItemTitle = resultStr.left( titleInt); |
809 | 809 | ||
810 | int yearInt = resultStr.find( " : ", titleInt+3, true); | 810 | int yearInt = resultStr.find( " : ", titleInt+3, true); |
811 | 811 | ||
812 | DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); | 812 | DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); |
813 | 813 | ||
814 | DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); | 814 | DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); |
815 | DlglistItemFile = DlglistItemFile.left( DlglistItemFile.length() - 2); | 815 | DlglistItemFile = DlglistItemFile.left( DlglistItemFile.length() - 2); |
816 | 816 | ||
817 | cleanStrings(); | 817 | cleanStrings(); |
818 | 818 | ||
819 | if(DlglistItemFile.left(1) == "/") | 819 | if(DlglistItemFile.left(1) == "/") |
820 | DlglistItemFile = DlglistItemFile.right( DlglistItemFile.length() - 1); | 820 | DlglistItemFile = DlglistItemFile.right( DlglistItemFile.length() - 1); |
821 | 821 | ||
822 | 822 | ||
823 | if(DlglistItemFile.toInt() > 10000 ) { | 823 | if(DlglistItemFile.toInt() > 10000 ) { |
824 | // new directory sturcture | 824 | // new directory sturcture |
825 | download_newEtext(); //) | 825 | download_newEtext(); //) |
826 | } else { | 826 | } else { |
827 | download_Etext(); //) | 827 | download_Etext(); //) |
828 | } | 828 | } |
829 | } | 829 | } |
830 | } | 830 | } |
831 | 831 | ||
832 | void LibraryDialog::sort() | 832 | void LibraryDialog::sort() |
833 | { | 833 | { |
834 | 834 | ||
835 | } | 835 | } |
836 | 836 | ||
837 | /* | 837 | /* |
838 | Downloads the current selected listitem*/ | 838 | Downloads the current selected listitem*/ |
839 | bool LibraryDialog::getItem(QListViewItem *it) | 839 | bool LibraryDialog::getItem(QListViewItem *it) |
840 | { | 840 | { |
841 | // //odebug << "selected getItem" << oendl; | 841 | // //odebug << "selected getItem" << oendl; |
842 | 842 | ||
843 | // DlglistItemNumber = it->text(0); | 843 | // DlglistItemNumber = it->text(0); |
844 | DlglistItemTitle = it->text(0); | 844 | DlglistItemTitle = it->text(0); |
845 | DlglistItemYear = it->text(2); | 845 | DlglistItemYear = it->text(2); |
846 | DlglistItemFile = it->text(3); | 846 | DlglistItemFile = it->text(3); |
847 | 847 | ||
848 | if(download_Etext()) { | 848 | if(download_Etext()) { |
849 | if(i_binary == 1) { | 849 | if(i_binary == 1) { |
850 | } | 850 | } |
851 | } | 851 | } |
852 | return true; | 852 | return true; |
853 | } | 853 | } |
854 | 854 | ||
855 | /* | 855 | /* |
856 | download button is pushed so we get the current items to download*/ | 856 | download button is pushed so we get the current items to download*/ |
857 | bool LibraryDialog::onButtonDownload() | 857 | bool LibraryDialog::onButtonDownload() |
858 | { | 858 | { |
859 | // //odebug << "selected onButtonDownloadz" << oendl; | 859 | // //odebug << "selected onButtonDownloadz" << oendl; |
860 | 860 | ||
861 | QListViewItemIterator it1( ListView1 ); | 861 | QListViewItemIterator it1( ListView1 ); |
862 | QListViewItemIterator it2( ListView2 ); | 862 | QListViewItemIterator it2( ListView2 ); |
863 | QListViewItemIterator it3( ListView3 ); | 863 | QListViewItemIterator it3( ListView3 ); |
864 | QListViewItemIterator it4( ListView4 ); | 864 | QListViewItemIterator it4( ListView4 ); |
865 | QListViewItemIterator it5( ListView5 ); | 865 | QListViewItemIterator it5( ListView5 ); |
866 | 866 | ||
867 | // iterate through all items of the listview | 867 | // iterate through all items of the listview |
868 | for ( ; it1.current(); ++it1 ) { | 868 | for ( ; it1.current(); ++it1 ) { |
869 | if ( it1.current()->isSelected() ) | 869 | if ( it1.current()->isSelected() ) |
870 | getItem(it1.current()); | 870 | getItem(it1.current()); |
871 | it1.current()->setSelected(false); | 871 | it1.current()->setSelected(false); |
872 | } | 872 | } |
873 | for ( ; it2.current(); ++it2 ) { | 873 | for ( ; it2.current(); ++it2 ) { |
874 | if ( it2.current()->isSelected() ) | 874 | if ( it2.current()->isSelected() ) |
875 | getItem(it2.current()); | 875 | getItem(it2.current()); |
876 | it2.current()->setSelected(false); | 876 | it2.current()->setSelected(false); |
877 | } | 877 | } |
878 | for ( ; it3.current(); ++it3 ) { | 878 | for ( ; it3.current(); ++it3 ) { |
879 | if ( it3.current()->isSelected() ) | 879 | if ( it3.current()->isSelected() ) |
880 | getItem(it3.current()); | 880 | getItem(it3.current()); |
881 | it3.current()->setSelected(false); | 881 | it3.current()->setSelected(false); |
882 | } | 882 | } |
883 | for ( ; it4.current(); ++it4 ) { | 883 | for ( ; it4.current(); ++it4 ) { |
884 | if ( it4.current()->isSelected() ) | 884 | if ( it4.current()->isSelected() ) |
885 | getItem(it4.current()); | 885 | getItem(it4.current()); |
886 | it4.current()->setSelected(false); | 886 | it4.current()->setSelected(false); |
887 | } | 887 | } |
888 | for ( ; it5.current(); ++it5 ) { | 888 | for ( ; it5.current(); ++it5 ) { |
889 | if ( it5.current()->isSelected() ) | 889 | if ( it5.current()->isSelected() ) |
890 | getItem(it5.current()); | 890 | getItem(it5.current()); |
891 | it5.current()->setSelected(false); | 891 | it5.current()->setSelected(false); |
892 | } | 892 | } |
893 | return true; | 893 | return true; |
894 | } | 894 | } |
895 | 895 | ||
896 | 896 | ||
897 | /* | 897 | /* |
898 | handles the sorting combo box */ | 898 | handles the sorting combo box */ |
899 | void LibraryDialog::comboSelect(int index) | 899 | void LibraryDialog::comboSelect(int index) |
900 | { | 900 | { |
901 | // //odebug << "we are sorting" << oendl; | 901 | // //odebug << "we are sorting" << oendl; |
902 | ListView1->setSorting( index, true); | 902 | ListView1->setSorting( index, true); |
903 | ListView2->setSorting( index, true); | 903 | ListView2->setSorting( index, true); |
904 | ListView3->setSorting( index, true); | 904 | ListView3->setSorting( index, true); |
905 | ListView4->setSorting( index, true); | 905 | ListView4->setSorting( index, true); |
906 | ListView5->setSorting( index, true); | 906 | ListView5->setSorting( index, true); |
907 | 907 | ||
908 | ListView1->sort(); | 908 | ListView1->sort(); |
909 | ListView2->sort(); | 909 | ListView2->sort(); |
910 | ListView3->sort(); | 910 | ListView3->sort(); |
911 | ListView4->sort(); | 911 | ListView4->sort(); |
912 | ListView5->sort(); | 912 | ListView5->sort(); |
913 | 913 | ||
914 | // ListView1->triggerUpdate(); | 914 | // ListView1->triggerUpdate(); |
915 | // ListView2->triggerUpdate(); | 915 | // ListView2->triggerUpdate(); |
916 | // ListView3->triggerUpdate(); | 916 | // ListView3->triggerUpdate(); |
917 | // ListView4->triggerUpdate(); | 917 | // ListView4->triggerUpdate(); |
918 | // ListView5->triggerUpdate(); | 918 | // ListView5->triggerUpdate(); |
919 | } | 919 | } |
920 | 920 | ||
921 | void LibraryDialog::newList() | 921 | void LibraryDialog::newList() |
922 | { | 922 | { |
923 | if(indexLoaded) { | 923 | if(indexLoaded) { |
924 | onButtonDownload(); | 924 | onButtonDownload(); |
925 | } else { | 925 | } else { |
926 | Output *outDlg; | 926 | Output *outDlg; |
927 | buttonNewList->setDown(true); | 927 | buttonNewList->setDown(true); |
928 | //odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl; | 928 | //odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl; |
929 | QString gutenindex1 = local_library + "/GUTINDEX.ALL"; | 929 | QString gutenindex1 = local_library + "/GUTINDEX.ALL"; |
930 | 930 | ||
931 | QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; | 931 | QString cmd="wget -O " + gutenindex1 + " http://www.gutenberg.org/dirs/GUTINDEX.ALL 2>&1"; |
932 | 932 | ||
933 | int result = QMessageBox::warning( this,"Download" | 933 | int result = QMessageBox::warning( this,"Download" |
934 | ,"<p>Ok to use /'wget/' to download a new library list?</P>" | 934 | ,"<p>Ok to use /'wget/' to download a new library list?</P>" |
935 | ,"Yes","No",0,0,1); | 935 | ,"Yes","No",0,0,1); |
936 | qApp->processEvents(); | 936 | qApp->processEvents(); |
937 | if(result == 0) { | 937 | if(result == 0) { |
938 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),true); | 938 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),true); |
939 | outDlg->showMaximized(); | 939 | outDlg->showMaximized(); |
940 | outDlg->show(); | 940 | outDlg->show(); |
941 | qApp->processEvents(); | 941 | qApp->processEvents(); |
942 | FILE *fp; | 942 | FILE *fp; |
943 | char line[130]; | 943 | char line[130]; |
944 | outDlg->OutputEdit->append( tr("Running wget") ); | 944 | outDlg->OutputEdit->append( tr("Running wget") ); |
945 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,false); | 945 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,false); |
946 | sleep(1); | 946 | sleep(1); |
947 | fp = popen( (const char *) cmd, "r"); | 947 | fp = popen( (const char *) cmd, "r"); |
948 | if ( !fp ) { | 948 | if ( !fp ) { |
949 | } else { | 949 | } else { |
950 | //odebug << "Issuing the command\n"+cmd << oendl; | 950 | //odebug << "Issuing the command\n"+cmd << oendl; |
951 | // system(cmd); | 951 | // system(cmd); |
952 | while ( fgets( line, sizeof line, fp)) { | 952 | while ( fgets( line, sizeof line, fp)) { |
953 | outDlg->OutputEdit->append(line); | 953 | outDlg->OutputEdit->append(line); |
954 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,false); | 954 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,false); |
955 | } | 955 | } |
956 | pclose(fp); | 956 | pclose(fp); |
957 | outDlg->OutputEdit->append("Finished downloading\n"); | 957 | outDlg->OutputEdit->append("Finished downloading\n"); |
958 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,false); | 958 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,false); |
959 | qApp->processEvents(); | 959 | qApp->processEvents(); |
960 | 960 | ||
961 | // if( QFile(gutenindex1).exists() ) { | 961 | // if( QFile(gutenindex1).exists() ) { |
962 | // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; | 962 | // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
963 | // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) | 963 | // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) |
964 | // //odebug << "renaming error" << oendl; | 964 | // //odebug << "renaming error" << oendl; |
965 | // } | 965 | // } |
966 | 966 | ||
967 | } | 967 | } |
968 | // outDlg->close(); | 968 | // outDlg->close(); |
969 | FindLibrary(); | 969 | FindLibrary(); |
970 | if(outDlg) delete outDlg; | 970 | if(outDlg) delete outDlg; |
971 | } | 971 | } |
972 | buttonNewList->setDown(false); | 972 | buttonNewList->setDown(false); |
973 | 973 | ||
974 | // if(outDlg) | 974 | // if(outDlg) |
975 | // delete outDlg; | 975 | // delete outDlg; |
976 | } | 976 | } |
977 | } | 977 | } |
978 | 978 | ||
979 | bool LibraryDialog::moreInfo() | 979 | bool LibraryDialog::moreInfo() |
980 | { | 980 | { |
981 | 981 | ||
982 | QListViewItem * item; | 982 | QListViewItem * item; |
983 | item = 0; | 983 | item = 0; |
984 | QString titleString; | 984 | QString titleString; |
985 | item = ListView1->currentItem(); | 985 | item = ListView1->currentItem(); |
986 | if( item != 0) { | 986 | if( item != 0) { |
987 | titleString = item->text(0); | 987 | titleString = item->text(0); |
988 | ListView1->clearSelection(); | 988 | ListView1->clearSelection(); |
989 | item = 0; | 989 | item = 0; |
990 | } | 990 | } |
991 | if( item == 0) | 991 | if( item == 0) |
992 | item = ListView2->currentItem(); | 992 | item = ListView2->currentItem(); |
993 | if( item != 0) { | 993 | if( item != 0) { |
994 | titleString = item->text(0); | 994 | titleString = item->text(0); |
995 | ListView2->clearSelection(); | 995 | ListView2->clearSelection(); |
996 | item = 0; | 996 | item = 0; |
997 | } | 997 | } |
998 | if( item == 0) | 998 | if( item == 0) |
999 | item = ListView3->currentItem(); | 999 | item = ListView3->currentItem(); |
1000 | if( item != 0) { | 1000 | if( item != 0) { |
1001 | titleString = item->text(0); | 1001 | titleString = item->text(0); |
1002 | ListView3->clearSelection(); | 1002 | ListView3->clearSelection(); |
1003 | item = 0; | 1003 | item = 0; |
1004 | } | 1004 | } |
1005 | if( item == 0) | 1005 | if( item == 0) |
1006 | item = ListView4->currentItem(); | 1006 | item = ListView4->currentItem(); |
1007 | if( item != 0) { | 1007 | if( item != 0) { |
1008 | titleString = item->text(0); | 1008 | titleString = item->text(0); |
1009 | ListView4->clearSelection(); | 1009 | ListView4->clearSelection(); |
1010 | item = 0; | 1010 | item = 0; |
1011 | } | 1011 | } |
1012 | if( item == 0) | 1012 | if( item == 0) |
1013 | item = ListView5->currentItem(); | 1013 | item = ListView5->currentItem(); |
1014 | if( item != 0) { | 1014 | if( item != 0) { |
1015 | titleString = item->text(0); | 1015 | titleString = item->text(0); |
1016 | ListView5->clearSelection(); | 1016 | ListView5->clearSelection(); |
1017 | item = 0; | 1017 | item = 0; |
1018 | } | 1018 | } |
1019 | item=0; | 1019 | item=0; |
1020 | if(titleString.length()>2) { | 1020 | if(titleString.length()>2) { |
1021 | //odebug << "Title is "+titleString << oendl; | 1021 | //odebug << "Title is "+titleString << oendl; |
1022 | titleString.replace( QRegExp("\\s"), "%20"); | 1022 | titleString.replace( QRegExp("\\s"), "%20"); |
1023 | titleString.replace( QRegExp("'"), "%20"); | 1023 | titleString.replace( QRegExp("'"), "%20"); |
1024 | titleString.replace( QRegExp("\""), "%20"); | 1024 | titleString.replace( QRegExp("\""), "%20"); |
1025 | titleString.replace( QRegExp("&"), "%20"); | 1025 | titleString.replace( QRegExp("&"), "%20"); |
1026 | QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search"; | 1026 | QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search"; |
1027 | cmd="opera "+cmd; | 1027 | cmd="opera "+cmd; |
1028 | system(cmd); | 1028 | system(cmd); |
1029 | } else | 1029 | } else |
1030 | QMessageBox::message( "Note","<p>If you select a title, this will search google.com for that title.</p>"); | 1030 | QMessageBox::message( "Note","<p>If you select a title, this will search google.com for that title.</p>"); |
1031 | return true; | 1031 | return true; |
1032 | 1032 | ||
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | /* | 1035 | /* |
1036 | This loads the library Index*/ | 1036 | This loads the library Index*/ |
1037 | void LibraryDialog::FindLibrary() | 1037 | void LibraryDialog::FindLibrary() |
1038 | { | 1038 | { |
1039 | buttonLibrary->setDown(true); | 1039 | buttonLibrary->setDown(true); |
1040 | 1040 | ||
1041 | qApp->processEvents(); | 1041 | qApp->processEvents(); |
1042 | if( QFile( new_index).exists() /* && this->isHidden() */) { | 1042 | if( QFile( new_index).exists() /* && this->isHidden() */) { |
1043 | newindexLib.setName( new_index); | 1043 | newindexLib.setName( new_index); |
1044 | indexLib.setName( new_index); | 1044 | indexLib.setName( new_index); |
1045 | //odebug << "index file is "+ new_index << oendl; | 1045 | //odebug << "index file is "+ new_index << oendl; |
1046 | Newlibrary(); | 1046 | Newlibrary(); |
1047 | } else { | 1047 | } else { |
1048 | newindexLib.setName( old_index); | 1048 | newindexLib.setName( old_index); |
1049 | indexLib.setName( old_index); | 1049 | indexLib.setName( old_index); |
1050 | //odebug << "new index nameis "+ old_index << oendl; | 1050 | //odebug << "new index nameis "+ old_index << oendl; |
1051 | Library(); | 1051 | Library(); |
1052 | } | 1052 | } |
1053 | indexLoaded=true; | 1053 | indexLoaded=true; |
1054 | buttonSearch->setEnabled(true); | 1054 | buttonSearch->setEnabled(true); |
1055 | moreInfoButton->setEnabled(true); | 1055 | moreInfoButton->setEnabled(true); |
1056 | 1056 | ||
1057 | buttonLibrary->setDown(false); | 1057 | buttonLibrary->setDown(false); |
1058 | buttonNewList->setText("Download"); | 1058 | buttonNewList->setText("Download"); |
1059 | qApp->processEvents(); | 1059 | qApp->processEvents(); |
1060 | 1060 | ||
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | void LibraryDialog::cleanStrings() { | 1063 | void LibraryDialog::cleanStrings() { |
1064 | year = year.stripWhiteSpace(); | 1064 | year = year.stripWhiteSpace(); |
1065 | file = file.stripWhiteSpace(); | 1065 | file = file.stripWhiteSpace(); |
1066 | title = title.stripWhiteSpace(); | 1066 | title = title.stripWhiteSpace(); |
1067 | number = number.stripWhiteSpace(); | 1067 | number = number.stripWhiteSpace(); |
1068 | 1068 | ||
1069 | } | 1069 | } |
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp index e639d4d..733db17 100644 --- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp +++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | |||
@@ -1,769 +1,769 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | gutenbrowser.cpp - description | 2 | gutenbrowser.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Jul 24 22:33:12 MDT 2000 | 4 | begin : Mon Jul 24 22:33:12 MDT 2000 |
5 | copyright : (C) 2000 -2004 by llornkcor | 5 | copyright : (C) 2000 -2004 by llornkcor |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | // http search | 12 | // http search |
13 | // http://digital.library.upenn.edu/books/authors.html | 13 | // http://digital.library.upenn.edu/books/authors.html |
14 | // http://digital.library.upenn.edu/books/titles.html | 14 | // http://digital.library.upenn.edu/books/titles.html |
15 | // ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL | 15 | // ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL |
16 | // donate@gutenberg.net | 16 | // donate@gutenberg.net |
17 | 17 | ||
18 | 18 | ||
19 | #include "editTitle.h" | 19 | #include "editTitle.h" |
20 | #include "gutenbrowser.h" | 20 | #include "gutenbrowser.h" |
21 | #include "LibraryDialog.h" | 21 | #include "LibraryDialog.h" |
22 | //#include "bookmarksdlg.h" | 22 | //#include "bookmarksdlg.h" |
23 | #include "optionsDialog.h" | 23 | #include "optionsDialog.h" |
24 | #include "helpme.h" | 24 | #include "helpme.h" |
25 | #include "NetworkDialog.h" | 25 | #include "NetworkDialog.h" |
26 | 26 | ||
27 | #include "openetext.h" | 27 | #include "openetext.h" |
28 | #include "output.h" | 28 | #include "output.h" |
29 | 29 | ||
30 | /* OPIE */ | 30 | /* OPIE */ |
31 | #include <opie2/odebug.h> | 31 | #include <opie2/odebug.h> |
32 | #include <opie2/oresource.h> | 32 | #include <opie2/oresource.h> |
33 | 33 | ||
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/fontdatabase.h> | 35 | #include <qpe/fontdatabase.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
38 | #include <qpe/mimetype.h> | 38 | #include <qpe/mimetype.h> |
39 | #include <qpe/applnk.h> | 39 | #include <qpe/applnk.h> |
40 | 40 | ||
41 | /* QT */ | 41 | /* QT */ |
42 | #include <qregexp.h> | 42 | #include <qregexp.h> |
43 | #include <qregion.h> | 43 | #include <qregion.h> |
44 | #include <qpaintdevicemetrics.h> | 44 | #include <qpaintdevicemetrics.h> |
45 | #include <qvaluelist.h> | 45 | #include <qvaluelist.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qclipboard.h> | 47 | #include <qclipboard.h> |
48 | #include <qpainter.h> | 48 | #include <qpainter.h> |
49 | #include <qpalette.h> | 49 | #include <qpalette.h> |
50 | #include <qobjectlist.h> | 50 | #include <qobjectlist.h> |
51 | #include <qfontdialog.h> | 51 | #include <qfontdialog.h> |
52 | #include <qtextview.h> | 52 | #include <qtextview.h> |
53 | #include <qbrush.h> | 53 | #include <qbrush.h> |
54 | #include <qfile.h> | 54 | #include <qfile.h> |
55 | #include <qfontinfo.h> | 55 | #include <qfontinfo.h> |
56 | #include <qscrollview.h> | 56 | #include <qscrollview.h> |
57 | #include <qpoint.h> | 57 | #include <qpoint.h> |
58 | 58 | ||
59 | /* STD */ | 59 | /* STD */ |
60 | #include <stdio.h> | 60 | #include <stdio.h> |
61 | #include <stdlib.h> | 61 | #include <stdlib.h> |
62 | #include <unistd.h> | 62 | #include <unistd.h> |
63 | #include <sys/stat.h> | 63 | #include <sys/stat.h> |
64 | #include <fcntl.h> | 64 | #include <fcntl.h> |
65 | #include <errno.h> | 65 | #include <errno.h> |
66 | 66 | ||
67 | static const int nfontsizes = 9; | 67 | static const int nfontsizes = 9; |
68 | static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; | 68 | static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; |
69 | 69 | ||
70 | #ifdef NOQUICKLAUNCH | 70 | #ifdef NOQUICKLAUNCH |
71 | Gutenbrowser::Gutenbrowser() | 71 | Gutenbrowser::Gutenbrowser() |
72 | Gutenbrowser(); | 72 | Gutenbrowser(); |
73 | #else | 73 | #else |
74 | Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) | 74 | Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) |
75 | #endif | 75 | #endif |
76 | : QMainWindow() | 76 | : QMainWindow() |
77 | { | 77 | { |
78 | // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 78 | // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
79 | // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); | 79 | // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); |
80 | // e << ""; | 80 | // e << ""; |
81 | // QPEApplication::grabKeyboard(); | 81 | // QPEApplication::grabKeyboard(); |
82 | showMainList=TRUE; | 82 | showMainList=TRUE; |
83 | working=false; | 83 | working=false; |
84 | this->setUpdatesEnabled(TRUE); | 84 | this->setUpdatesEnabled(TRUE); |
85 | // #ifndef Q_WS_QWS | 85 | // #ifndef Q_WS_QWS |
86 | QString msg; | 86 | QString msg; |
87 | msg="You have now entered unto gutenbrowser,\n"; | 87 | msg="You have now entered unto gutenbrowser,\n"; |
88 | msg+="make your self at home, sit back, relax and read something great.\n"; | 88 | msg+="make your self at home, sit back, relax and read something great.\n"; |
89 | 89 | ||
90 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; | 90 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; |
91 | setCaption("Gutenbrowser");// Embedded " VERSION); | 91 | setCaption("Gutenbrowser");// Embedded " VERSION); |
92 | this->setUpdatesEnabled(TRUE); | 92 | this->setUpdatesEnabled(TRUE); |
93 | 93 | ||
94 | // bool firstTime=FALSE; | 94 | // bool firstTime=FALSE; |
95 | topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); | 95 | topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); |
96 | 96 | ||
97 | menu = new QHBoxLayout(-1,"menu"); | 97 | menu = new QHBoxLayout(-1,"menu"); |
98 | buttons2 = new QHBoxLayout(-1,"buttons2"); | 98 | buttons2 = new QHBoxLayout(-1,"buttons2"); |
99 | edits = new QHBoxLayout(-1,"edits"); | 99 | edits = new QHBoxLayout(-1,"edits"); |
100 | 100 | ||
101 | useSplitter=TRUE; | 101 | useSplitter=TRUE; |
102 | 102 | ||
103 | initConfig(); | 103 | initConfig(); |
104 | initMenuBar(); | 104 | initMenuBar(); |
105 | initButtonBar(); | 105 | initButtonBar(); |
106 | initStatusBar(); | 106 | initStatusBar(); |
107 | initView(); | 107 | initView(); |
108 | initSlots(); | 108 | initSlots(); |
109 | qDebug("init finished"); | 109 | qDebug("init finished"); |
110 | QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); | 110 | QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); |
111 | 111 | ||
112 | connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), | 112 | connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), |
113 | this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); | 113 | this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); |
114 | if( useIcons) | 114 | if( useIcons) |
115 | toggleButtonIcons( TRUE); | 115 | toggleButtonIcons( TRUE); |
116 | else | 116 | else |
117 | toggleButtonIcons( FALSE); | 117 | toggleButtonIcons( FALSE); |
118 | 118 | ||
119 | enableButtons(false); | 119 | enableButtons(false); |
120 | 120 | ||
121 | Config config("Gutenbrowser"); // populate menubuttonlist | 121 | Config config("Gutenbrowser"); // populate menubuttonlist |
122 | config.setGroup("General"); | 122 | config.setGroup("General"); |
123 | 123 | ||
124 | config.setGroup( "Files" ); | 124 | config.setGroup( "Files" ); |
125 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 125 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
126 | int i_numofFiles = s_numofFiles.toInt(); | 126 | int i_numofFiles = s_numofFiles.toInt(); |
127 | 127 | ||
128 | QString tempFileName; | 128 | QString tempFileName; |
129 | 129 | ||
130 | for (int i = 0; i <= i_numofFiles; i++) { | 130 | for (int i = 0; i <= i_numofFiles; i++) { |
131 | // tempFileName.setNum(i); | 131 | // tempFileName.setNum(i); |
132 | config.setGroup( "Files" ); | 132 | config.setGroup( "Files" ); |
133 | QString ramble = config.readEntry( QString::number(i), "" ); | 133 | QString ramble = config.readEntry( QString::number(i), "" ); |
134 | 134 | ||
135 | config.setGroup( "Titles" ); | 135 | config.setGroup( "Titles" ); |
136 | QString tempTitle = config.readEntry( ramble, ""); | 136 | QString tempTitle = config.readEntry( ramble, ""); |
137 | config.setGroup( tempTitle); | 137 | config.setGroup( tempTitle); |
138 | int index = config.readNumEntry( "LineNumber", -1 ); | 138 | int index = config.readNumEntry( "LineNumber", -1 ); |
139 | if( index != -1) { | 139 | if( index != -1) { |
140 | odebug << tempTitle << oendl; | 140 | odebug << tempTitle << oendl; |
141 | if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle); | 141 | if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | QString gutenIndex = local_library + "/GUTINDEX.ALL"; | 145 | QString gutenIndex = local_library + "/GUTINDEX.ALL"; |
146 | qDebug("gutenindex "+gutenIndex ); | 146 | qDebug("gutenindex "+gutenIndex ); |
147 | 147 | ||
148 | if( QFile( gutenIndex).exists() ) { | 148 | if( QFile( gutenIndex).exists() ) { |
149 | indexLib.setName( gutenIndex); | 149 | indexLib.setName( gutenIndex); |
150 | } else { | 150 | } else { |
151 | QString localLibIndexFile = local_library + "/PGWHOLE.TXT"; | 151 | QString localLibIndexFile = local_library + "/PGWHOLE.TXT"; |
152 | // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; | 152 | // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; |
153 | newindexLib.setName( localLibIndexFile); | 153 | newindexLib.setName( localLibIndexFile); |
154 | } | 154 | } |
155 | qDebug("attempting new library"); | 155 | qDebug("attempting new library"); |
156 | LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); | 156 | LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); |
157 | loadCheck = false; | 157 | loadCheck = false; |
158 | chdir(local_library); | 158 | chdir(local_library); |
159 | if(!showMainList) { | 159 | if(!showMainList) { |
160 | Lview->setFocus(); | 160 | Lview->setFocus(); |
161 | // if(firstTime) | 161 | // if(firstTime) |
162 | // Bookmark(); | 162 | // Bookmark(); |
163 | for (int i=1;i< qApp->argc();i++) { | 163 | for (int i=1;i< qApp->argc();i++) { |
164 | qDebug("Suppose we open somethin"); | 164 | qDebug("Suppose we open somethin"); |
165 | if(!load(qApp->argv()[i])) return; | 165 | if(!load(qApp->argv()[i])) return; |
166 | } | 166 | } |
167 | } else { | 167 | } else { |
168 | fillWithTitles(); | 168 | fillWithTitles(); |
169 | mainList->setFocus(); | 169 | mainList->setFocus(); |
170 | // mainList->setCurrentItem(0); | 170 | // mainList->setCurrentItem(0); |
171 | 171 | ||
172 | } | 172 | } |
173 | writeConfig(); | 173 | writeConfig(); |
174 | QTimer::singleShot( 250, this, SLOT(hideView()) ); | 174 | QTimer::singleShot( 250, this, SLOT(hideView()) ); |
175 | } //end init | 175 | } //end init |
176 | 176 | ||
177 | Gutenbrowser::~Gutenbrowser() { | 177 | Gutenbrowser::~Gutenbrowser() { |
178 | // QPEApplication::grabKeyboard(); | 178 | // QPEApplication::grabKeyboard(); |
179 | // QPEApplication::ungrabKeyboard(); | 179 | // QPEApplication::ungrabKeyboard(); |
180 | odebug << "Exit" << oendl; | 180 | odebug << "Exit" << oendl; |
181 | } | 181 | } |
182 | 182 | ||
183 | /* | 183 | /* |
184 | Google.com search */ | 184 | Google.com search */ |
185 | void Gutenbrowser::InfoBarClick() { | 185 | void Gutenbrowser::InfoBarClick() { |
186 | QString text; | 186 | QString text; |
187 | if( Lview->hasSelectedText()) { | 187 | if( Lview->hasSelectedText()) { |
188 | Lview->copy(); | 188 | Lview->copy(); |
189 | QClipboard *cb = QApplication::clipboard(); | 189 | QClipboard *cb = QApplication::clipboard(); |
190 | text = cb->text(); | 190 | text = cb->text(); |
191 | } else { | 191 | } else { |
192 | // text=title; | 192 | // text=title; |
193 | text=this->caption(); | 193 | text=this->caption(); |
194 | } | 194 | } |
195 | searchGoogle(text); | 195 | searchGoogle(text); |
196 | } | 196 | } |
197 | 197 | ||
198 | /* | 198 | /* |
199 | download http with wget or preferred browser */ | 199 | download http with wget or preferred browser */ |
200 | void Gutenbrowser::goGetit( const QString &url, bool showMsg) { | 200 | void Gutenbrowser::goGetit( const QString &url, bool showMsg) { |
201 | QString cmd; | 201 | QString cmd; |
202 | qApp->processEvents(); | 202 | qApp->processEvents(); |
203 | 203 | ||
204 | QString filename = local_library + "/GUTINDEX.ALL"; | 204 | QString filename = local_library + "/GUTINDEX.ALL"; |
205 | // QString filename = old_index; | 205 | // QString filename = old_index; |
206 | 206 | ||
207 | // filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); | 207 | // filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); |
208 | 208 | ||
209 | Config cfg("Gutenbrowser"); | 209 | Config cfg("Gutenbrowser"); |
210 | cfg.setGroup("FTPsite"); | 210 | cfg.setGroup("FTPsite"); |
211 | ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org"); | 211 | ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org"); |
212 | ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg"); | 212 | ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg"); |
213 | 213 | ||
214 | // Config config("Gutenbrowser"); | 214 | // Config config("Gutenbrowser"); |
215 | // config.setGroup( "Browser" ); | 215 | // config.setGroup( "Browser" ); |
216 | // QString brow = config.readEntry("Preferred", "Opera"); | 216 | // QString brow = config.readEntry("Preferred", "Opera"); |
217 | // //odebug << "Preferred browser is "+brow << oendl; | 217 | // //odebug << "Preferred browser is "+brow << oendl; |
218 | if(!showMsg) { //if we just get the gutenindex.all | 218 | if(!showMsg) { //if we just get the gutenindex.all |
219 | // QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; | 219 | // QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; |
220 | cmd="wget -O " + filename +" " + url+" 2>&1" ; | 220 | cmd="wget -O " + filename +" " + url+" 2>&1" ; |
221 | chdir(local_library); | 221 | chdir(local_library); |
222 | // //odebug << "Issuing the system command: " << cmd << "" << oendl; | 222 | // //odebug << "Issuing the system command: " << cmd << "" << oendl; |
223 | 223 | ||
224 | Output *outDlg; | 224 | Output *outDlg; |
225 | 225 | ||
226 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); | 226 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); |
227 | 227 | ||
228 | outDlg->showMaximized(); | 228 | outDlg->showMaximized(); |
229 | outDlg->show(); | 229 | outDlg->show(); |
230 | qApp->processEvents(); | 230 | qApp->processEvents(); |
231 | FILE *fp; | 231 | FILE *fp; |
232 | char line[130]; | 232 | char line[130]; |
233 | outDlg->OutputEdit->append( tr("Running wget") ); | 233 | outDlg->OutputEdit->append( tr("Running wget") ); |
234 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 234 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
235 | sleep(1); | 235 | sleep(1); |
236 | fp = popen( (const char *) cmd, "r"); | 236 | fp = popen( (const char *) cmd, "r"); |
237 | if ( !fp ) { | 237 | if ( !fp ) { |
238 | } else { | 238 | } else { |
239 | //odebug << "Issuing the command\n"+cmd << oendl; | 239 | //odebug << "Issuing the command\n"+cmd << oendl; |
240 | // system(cmd); | 240 | // system(cmd); |
241 | while ( fgets( line, sizeof line, fp)) { | 241 | while ( fgets( line, sizeof line, fp)) { |
242 | outDlg->OutputEdit->append(line); | 242 | outDlg->OutputEdit->append(line); |
243 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 243 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
244 | } | 244 | } |
245 | pclose(fp); | 245 | pclose(fp); |
246 | outDlg->OutputEdit->append("Finished downloading\n"); | 246 | outDlg->OutputEdit->append("Finished downloading\n"); |
247 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 247 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
248 | qApp->processEvents(); | 248 | qApp->processEvents(); |
249 | 249 | ||
250 | } | 250 | } |
251 | outDlg->close(); | 251 | outDlg->close(); |
252 | 252 | ||
253 | if(outDlg) | 253 | if(outDlg) |
254 | delete outDlg; | 254 | delete outDlg; |
255 | } else { | 255 | } else { |
256 | if( brow == "Konq") { | 256 | if( brow == "Konq") { |
257 | cmd = "konqueror "+url+" &"; | 257 | cmd = "konqueror "+url+" &"; |
258 | } | 258 | } |
259 | if( brow == "Opera") { //for desktop testing | 259 | if( brow == "Opera") { //for desktop testing |
260 | cmd = "opera "+url+" &"; | 260 | cmd = "opera "+url+" &"; |
261 | } | 261 | } |
262 | // if( brow == "Opera") { // on Zaurus | 262 | // if( brow == "Opera") { // on Zaurus |
263 | // cmd = "operagui "+url+" &"; | 263 | // cmd = "operagui "+url+" &"; |
264 | // } | 264 | // } |
265 | if( brow == "Mozilla") { | 265 | if( brow == "Mozilla") { |
266 | cmd = "mozilla "+url+" &"; | 266 | cmd = "mozilla "+url+" &"; |
267 | } | 267 | } |
268 | if( brow == "Netscape") { | 268 | if( brow == "Netscape") { |
269 | cmd = "netscape "+url+" &"; | 269 | cmd = "netscape "+url+" &"; |
270 | } | 270 | } |
271 | if(brow == "wget") { | 271 | if(brow == "wget") { |
272 | // cmd="wget -q "+url+" &"; | 272 | // cmd="wget -q "+url+" &"; |
273 | QString tempHtml=local_library+"webster.html"; | 273 | QString tempHtml=local_library+"webster.html"; |
274 | cmd="wget -O "+tempHtml+" -q "+url; | 274 | cmd="wget -O "+tempHtml+" -q "+url; |
275 | } | 275 | } |
276 | 276 | ||
277 | chdir(local_library); | 277 | chdir(local_library); |
278 | // //odebug << "Issuing the sys command: " << cmd << "" << oendl; | 278 | // //odebug << "Issuing the sys command: " << cmd << "" << oendl; |
279 | system(cmd); | 279 | system(cmd); |
280 | } | 280 | } |
281 | } | 281 | } |
282 | 282 | ||
283 | void Gutenbrowser::toggleButtonIcons( bool useEm) { | 283 | void Gutenbrowser::toggleButtonIcons( bool useEm) { |
284 | QString pixDir; | 284 | QString pixDir; |
285 | if(useEm) | 285 | if(useEm) |
286 | useEm=TRUE; | 286 | useEm=TRUE; |
287 | pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; | 287 | pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; |
288 | odebug << "Docdir is "+QPEApplication::documentDir() << oendl; | 288 | odebug << "Docdir is "+QPEApplication::documentDir() << oendl; |
289 | 289 | ||
290 | if( useIcons && QDir( pixDir).exists() ) { | 290 | if( useIcons && QDir( pixDir).exists() ) { |
291 | LibraryButton->setPixmap( Opie::Core::OResource::loadPixmap("home", Opie::Core::OResource::SmallIcon ) ); | 291 | LibraryButton->setPixmap( Opie::Core::OResource::loadPixmap("home", Opie::Core::OResource::SmallIcon ) ); |
292 | OpenButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/openbook", Opie::Core::OResource::SmallIcon )); | 292 | OpenButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/openbook", Opie::Core::OResource::SmallIcon )); |
293 | ForwardButton->setPixmap( Opie::Core::OResource::loadPixmap("forward", Opie::Core::OResource::SmallIcon )); | 293 | ForwardButton->setPixmap( Opie::Core::OResource::loadPixmap("forward", Opie::Core::OResource::SmallIcon )); |
294 | BackButton->setPixmap( Opie::Core::OResource::loadPixmap("back", Opie::Core::OResource::SmallIcon ) ); | 294 | BackButton->setPixmap( Opie::Core::OResource::loadPixmap("back", Opie::Core::OResource::SmallIcon ) ); |
295 | SearchButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/search", Opie::Core::OResource::SmallIcon ) ); | 295 | SearchButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/search", Opie::Core::OResource::SmallIcon ) ); |
296 | lastBmkButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/bookmark_folder", Opie::Core::OResource::SmallIcon )); | 296 | lastBmkButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/bookmark_folder", Opie::Core::OResource::SmallIcon )); |
297 | setBookmarkButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/bookmark", Opie::Core::OResource::SmallIcon ) ); | 297 | setBookmarkButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/bookmark", Opie::Core::OResource::SmallIcon ) ); |
298 | dictionaryButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/spellcheck", Opie::Core::OResource::SmallIcon ) ); | 298 | dictionaryButton->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/spellcheck", Opie::Core::OResource::SmallIcon ) ); |
299 | InfoBar->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/google", Opie::Core::OResource::SmallIcon )); | 299 | InfoBar->setPixmap( Opie::Core::OResource::loadPixmap("gutenbrowser/google", Opie::Core::OResource::SmallIcon )); |
300 | } | 300 | } |
301 | } | 301 | } |
302 | 302 | ||
303 | 303 | ||
304 | bool Gutenbrowser::queryExit() | 304 | bool Gutenbrowser::queryExit() |
305 | { | 305 | { |
306 | int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?", | 306 | int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?", |
307 | QMessageBox::Ok, QMessageBox::Cancel); | 307 | QMessageBox::Ok, QMessageBox::Cancel); |
308 | if (exit==1) { | 308 | if (exit==1) { |
309 | writeConfig(); | 309 | writeConfig(); |
310 | qApp->quit(); | 310 | qApp->quit(); |
311 | } else { | 311 | } else { |
312 | }; | 312 | }; |
313 | return (exit==1); | 313 | return (exit==1); |
314 | } | 314 | } |
315 | 315 | ||
316 | // SLOT IMPLEMENTATION | 316 | // SLOT IMPLEMENTATION |
317 | 317 | ||
318 | void Gutenbrowser::slotFilePrint() { | 318 | void Gutenbrowser::slotFilePrint() { |
319 | } | 319 | } |
320 | 320 | ||
321 | void Gutenbrowser::ByeBye() { | 321 | void Gutenbrowser::ByeBye() { |
322 | if (b_queryExit) | 322 | if (b_queryExit) |
323 | queryExit(); | 323 | queryExit(); |
324 | else { | 324 | else { |
325 | // writeConfig(); | 325 | // writeConfig(); |
326 | qApp->quit(); | 326 | qApp->quit(); |
327 | } | 327 | } |
328 | } | 328 | } |
329 | 329 | ||
330 | void Gutenbrowser::HelpBtn() { | 330 | void Gutenbrowser::HelpBtn() { |
331 | HelpMe* HelpDlg; | 331 | HelpMe* HelpDlg; |
332 | HelpDlg = new HelpMe( this, "Help Dialog"); | 332 | HelpDlg = new HelpMe( this, "Help Dialog"); |
333 | HelpDlg->showMaximized(); | 333 | HelpDlg->showMaximized(); |
334 | } | 334 | } |
335 | 335 | ||
336 | void Gutenbrowser::DownloadIndex() { | 336 | void Gutenbrowser::DownloadIndex() { |
337 | #ifndef Q_WS_QWS | 337 | #ifndef Q_WS_QWS |
338 | { | 338 | { |
339 | switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")), | 339 | switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")), |
340 | (tr("Do you want to download the newest\n" | 340 | (tr("Do you want to download the newest\n" |
341 | "Project Gutenberg Library Index?\n" | 341 | "Project Gutenberg Library Index?\n" |
342 | "or select an ftp site?\n")), | 342 | "or select an ftp site?\n")), |
343 | (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) ) | 343 | (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) ) |
344 | { | 344 | { |
345 | case 0: // index clicked, | 345 | case 0: // index clicked, |
346 | downloadLibIndex(); | 346 | downloadLibIndex(); |
347 | break; | 347 | break; |
348 | 348 | ||
349 | case 1: // ftp selected | 349 | case 1: // ftp selected |
350 | downloadFtpList(); | 350 | downloadFtpList(); |
351 | break; | 351 | break; |
352 | 352 | ||
353 | case 2: // Cancel | 353 | case 2: // Cancel |
354 | break; | 354 | break; |
355 | }; | 355 | }; |
356 | } | 356 | } |
357 | #endif | 357 | #endif |
358 | } // end DownloadIndex | 358 | } // end DownloadIndex |
359 | 359 | ||
360 | 360 | ||
361 | void Gutenbrowser::downloadFtpList() { | 361 | void Gutenbrowser::downloadFtpList() { |
362 | // QString cmd="wget http://www.promo.net/pg/list.html"); | 362 | // QString cmd="wget http://www.promo.net/pg/list.html"); |
363 | //system(cmd); | 363 | //system(cmd); |
364 | qApp->processEvents(); | 364 | qApp->processEvents(); |
365 | optionsDialog* optDlg; | 365 | optionsDialog* optDlg; |
366 | optDlg = new optionsDialog( this,"Options_Dlg", true); | 366 | optDlg = new optionsDialog( this,"Options_Dlg", true); |
367 | optDlg->getSite(); | 367 | optDlg->getSite(); |
368 | if(optDlg) | 368 | if(optDlg) |
369 | delete optDlg; | 369 | delete optDlg; |
370 | } | 370 | } |
371 | 371 | ||
372 | 372 | ||
373 | void Gutenbrowser::downloadLibIndex() { | 373 | void Gutenbrowser::downloadLibIndex() { |
374 | // QString dwmloader = local_library + "pgwhole.zip"; | 374 | // QString dwmloader = local_library + "pgwhole.zip"; |
375 | // QString cmd = "lynx -source http://www.gutenberg.net/pgwhole.zip | cat >> " + dwmloader; | 375 | // QString cmd = "lynx -source http://www.gutenberg.net/pgwhole.zip | cat >> " + dwmloader; |
376 | // system(cmd); | 376 | // system(cmd); |
377 | 377 | ||
378 | // QString outputFile= local_library+ "GUTINDEX.ALL"; | 378 | // QString outputFile= local_library+ "GUTINDEX.ALL"; |
379 | // config.setGroup( "FTPsite" ); // ftp server config | 379 | // config.setGroup( "FTPsite" ); // ftp server config |
380 | // ftp_host=config.readEntry("SiteName", ""); | 380 | // ftp_host=config.readEntry("SiteName", ""); |
381 | // ftp_base_dir= config.readEntry("base", ""); | 381 | // ftp_base_dir= config.readEntry("base", ""); |
382 | // QString networkUrl= "ftp://"+ftp_host+ftp_base_dir+"/GUTINDEX.ALL"; | 382 | // QString networkUrl= "ftp://"+ftp_host+ftp_base_dir+"/GUTINDEX.ALL"; |
383 | QDir dir( local_library); | 383 | QDir dir( local_library); |
384 | dir.cd("", TRUE); | 384 | dir.cd("", TRUE); |
385 | goGetit( "http://sailor.gutenberg.org/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3 | 385 | goGetit( "http://www.gutenberg.org/dirs/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3 |
386 | // goGetit( "http://www.gutenberg.net/pgwhole.zip", true); // until ghttp works on binaries -qt3 | 386 | // goGetit( "http://www.gutenberg.net/pgwhole.zip", true); // until ghttp works on binaries -qt3 |
387 | // NetworkDialog *NetworkDlg; | 387 | // NetworkDialog *NetworkDlg; |
388 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, outputFile ); | 388 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, outputFile ); |
389 | // if( NetworkDlg->exec() != 0 ) | 389 | // if( NetworkDlg->exec() != 0 ) |
390 | // { // use new, improved, *INSTANT* network-dialog-file-getterer | 390 | // { // use new, improved, *INSTANT* network-dialog-file-getterer |
391 | //// QMessageBox::message("Note",""); | 391 | //// QMessageBox::message("Note",""); |
392 | // } | 392 | // } |
393 | // if(NetworkDlg) | 393 | // if(NetworkDlg) |
394 | // delete NetworkDlg; | 394 | // delete NetworkDlg; |
395 | } | 395 | } |
396 | 396 | ||
397 | 397 | ||
398 | void Gutenbrowser::PrintBtn() { | 398 | void Gutenbrowser::PrintBtn() { |
399 | } | 399 | } |
400 | 400 | ||
401 | void Gutenbrowser::SearchBtn() { | 401 | void Gutenbrowser::SearchBtn() { |
402 | if( loadCheck) { | 402 | if( loadCheck) { |
403 | odebug << "loadCheck: we have a loaded doc" << oendl; | 403 | odebug << "loadCheck: we have a loaded doc" << oendl; |
404 | Search(); | 404 | Search(); |
405 | } | 405 | } |
406 | // else | 406 | // else |
407 | // QMessageBox::message("Note","Sorry, can't search. No etext is loaded"); | 407 | // QMessageBox::message("Note","Sorry, can't search. No etext is loaded"); |
408 | } | 408 | } |
409 | 409 | ||
410 | 410 | ||
411 | void Gutenbrowser::ForwardBtn() { | 411 | void Gutenbrowser::ForwardBtn() { |
412 | 412 | ||
413 | if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) { | 413 | if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) { |
414 | 414 | ||
415 | QString s; | 415 | QString s; |
416 | QString insertString; | 416 | QString insertString; |
417 | int pageSize= Lview->PageSize(); | 417 | int pageSize= Lview->PageSize(); |
418 | Lview->clear(); | 418 | Lview->clear(); |
419 | 419 | ||
420 | for(int fd=0; fd < pageSize - 1;fd++) { | 420 | for(int fd=0; fd < pageSize - 1;fd++) { |
421 | f.readLine(s, 256); | 421 | f.readLine(s, 256); |
422 | if(useWrap) | 422 | if(useWrap) |
423 | s.replace(QRegExp("\n"),""); | 423 | s.replace(QRegExp("\n"),""); |
424 | insertString+=s; | 424 | insertString+=s; |
425 | Lview->insertLine( s, -1); | 425 | Lview->insertLine( s, -1); |
426 | // odebug << s << oendl; | 426 | // odebug << s << oendl; |
427 | currentLine++; | 427 | currentLine++; |
428 | } | 428 | } |
429 | // Lview->insertAt( insertString,0,0, FALSE); | 429 | // Lview->insertAt( insertString,0,0, FALSE); |
430 | currentFilePos = f.at(); | 430 | currentFilePos = f.at(); |
431 | // if( i_pageNum != pages) { | 431 | // if( i_pageNum != pages) { |
432 | // Lview->MultiLine_Ex::pageDown( FALSE); | 432 | // Lview->MultiLine_Ex::pageDown( FALSE); |
433 | i_pageNum++; | 433 | i_pageNum++; |
434 | pageStopArray.resize(i_pageNum + 1); | 434 | pageStopArray.resize(i_pageNum + 1); |
435 | // int length = Lview->length(); | 435 | // int length = Lview->length(); |
436 | 436 | ||
437 | pageStopArray[i_pageNum ] = currentFilePos; | 437 | pageStopArray[i_pageNum ] = currentFilePos; |
438 | odebug << currentFilePos << " current page is number " << i_pageNum | 438 | odebug << currentFilePos << " current page is number " << i_pageNum |
439 | << ", pagesize " << pageSize << ", length " << Lview->length() | 439 | << ", pagesize " << pageSize << ", length " << Lview->length() |
440 | << ", current " << pageStopArray[i_pageNum] << oendl; | 440 | << ", current " << pageStopArray[i_pageNum] << oendl; |
441 | setStatus(); | 441 | setStatus(); |
442 | // Lview->setCursorPosition( 0, 0, FALSE); | 442 | // Lview->setCursorPosition( 0, 0, FALSE); |
443 | // } | 443 | // } |
444 | 444 | ||
445 | } else { | 445 | } else { |
446 | odebug << "bal" << oendl; | 446 | odebug << "bal" << oendl; |
447 | // if( i_pageNum != pages) { | 447 | // if( i_pageNum != pages) { |
448 | 448 | ||
449 | // // int newTop = Lview->Top(); | 449 | // // int newTop = Lview->Top(); |
450 | // // if(Lview->lastRow() > i) | 450 | // // if(Lview->lastRow() > i) |
451 | // Lview->ScrollUp(1); | 451 | // Lview->ScrollUp(1); |
452 | // // i_pageNum++; | 452 | // // i_pageNum++; |
453 | // setStatus(); | 453 | // setStatus(); |
454 | // Lview->setCursorPosition( Lview->Top(), 0, FALSE); | 454 | // Lview->setCursorPosition( Lview->Top(), 0, FALSE); |
455 | 455 | ||
456 | // } | 456 | // } |
457 | 457 | ||
458 | } | 458 | } |
459 | Lview->setFocus(); | 459 | Lview->setFocus(); |
460 | 460 | ||
461 | odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl; | 461 | odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl; |
462 | } | 462 | } |
463 | 463 | ||
464 | 464 | ||
465 | void Gutenbrowser::BackBtn() { | 465 | void Gutenbrowser::BackBtn() { |
466 | if( i_pageNum > 0) { | 466 | if( i_pageNum > 0) { |
467 | int pageSize= Lview->PageSize(); | 467 | int pageSize= Lview->PageSize(); |
468 | // int length=Lview->length(); | 468 | // int length=Lview->length(); |
469 | 469 | ||
470 | i_pageNum--; | 470 | i_pageNum--; |
471 | currentFilePos = f.at(); | 471 | currentFilePos = f.at(); |
472 | 472 | ||
473 | odebug << currentFilePos << " move back to " << pageStopArray[i_pageNum - 1 ] | 473 | odebug << currentFilePos << " move back to " << pageStopArray[i_pageNum - 1 ] |
474 | << ", current page number " << i_pageNum | 474 | << ", current page number " << i_pageNum |
475 | << ", " << pageSize << ", length " << Lview->length() << oendl; | 475 | << ", " << pageSize << ", length " << Lview->length() << oendl; |
476 | 476 | ||
477 | if( i_pageNum < 2) { | 477 | if( i_pageNum < 2) { |
478 | f.at( 0); | 478 | f.at( 0); |
479 | } else { | 479 | } else { |
480 | if(!f.at( pageStopArray[i_pageNum - 1] )) | 480 | if(!f.at( pageStopArray[i_pageNum - 1] )) |
481 | odebug << "File positioned backward did not work" << oendl; | 481 | odebug << "File positioned backward did not work" << oendl; |
482 | } | 482 | } |
483 | QString s; | 483 | QString s; |
484 | // int sizeLine=0; | 484 | // int sizeLine=0; |
485 | Lview->clear(); | 485 | Lview->clear(); |
486 | // QString insertString; | 486 | // QString insertString; |
487 | 487 | ||
488 | for(int fd = 0; fd < pageSize ;fd++) { | 488 | for(int fd = 0; fd < pageSize ;fd++) { |
489 | // Lview->removeLine( Lview->PageSize() ); | 489 | // Lview->removeLine( Lview->PageSize() ); |
490 | f.readLine(s, 256); | 490 | f.readLine(s, 256); |
491 | if(useWrap) | 491 | if(useWrap) |
492 | s.replace(QRegExp("\n"),""); | 492 | s.replace(QRegExp("\n"),""); |
493 | currentLine++; | 493 | currentLine++; |
494 | // insertString+=s; | 494 | // insertString+=s; |
495 | Lview->insertLine( s, -1); | 495 | Lview->insertLine( s, -1); |
496 | } | 496 | } |
497 | 497 | ||
498 | // Lview->insertAt( insertString,0,0, FALSE); | 498 | // Lview->insertAt( insertString,0,0, FALSE); |
499 | 499 | ||
500 | if( !BackButton->autoRepeat() && !BackButton->isDown()) { | 500 | if( !BackButton->autoRepeat() && !BackButton->isDown()) { |
501 | QString topR; | 501 | QString topR; |
502 | QString lastR; | 502 | QString lastR; |
503 | QString pageR; | 503 | QString pageR; |
504 | // int sizer = Lview->lastRow() - Lview->topRow(); | 504 | // int sizer = Lview->lastRow() - Lview->topRow(); |
505 | // int i_topRow = Lview->topRow(); | 505 | // int i_topRow = Lview->topRow(); |
506 | if( i_pageNum < 1) | 506 | if( i_pageNum < 1) |
507 | i_pageNum = 1; | 507 | i_pageNum = 1; |
508 | setCaption(QString::number(i_pageNum)); | 508 | setCaption(QString::number(i_pageNum)); |
509 | } else { | 509 | } else { |
510 | // int newTop = Lview->Top(); | 510 | // int newTop = Lview->Top(); |
511 | // if(Lview->lastRow() > i) | 511 | // if(Lview->lastRow() > i) |
512 | Lview->MultiLine_Ex::pageUp( FALSE); | 512 | Lview->MultiLine_Ex::pageUp( FALSE); |
513 | // Lview->ScrollDown(1); | 513 | // Lview->ScrollDown(1); |
514 | // i_pageNum--; | 514 | // i_pageNum--; |
515 | if( i_pageNum < 1) | 515 | if( i_pageNum < 1) |
516 | i_pageNum = 1; | 516 | i_pageNum = 1; |
517 | setStatus(); | 517 | setStatus(); |
518 | // Lview->setCursorPosition( Lview->Top(), 0, FALSE); | 518 | // Lview->setCursorPosition( Lview->Top(), 0, FALSE); |
519 | 519 | ||
520 | } | 520 | } |
521 | } | 521 | } |
522 | Lview->setFocus(); | 522 | Lview->setFocus(); |
523 | } | 523 | } |
524 | 524 | ||
525 | void Gutenbrowser::doBeginBtn() { | 525 | void Gutenbrowser::doBeginBtn() { |
526 | if(loadCheck) { | 526 | if(loadCheck) { |
527 | qApp->processEvents(); | 527 | qApp->processEvents(); |
528 | BeginBtn(); | 528 | BeginBtn(); |
529 | } | 529 | } |
530 | } | 530 | } |
531 | 531 | ||
532 | // moves text to the very top = 0 | 532 | // moves text to the very top = 0 |
533 | void Gutenbrowser::TopBtn() { | 533 | void Gutenbrowser::TopBtn() { |
534 | 534 | ||
535 | if(loadCheck) { | 535 | if(loadCheck) { |
536 | if( i_pageNum != 0) { | 536 | if( i_pageNum != 0) { |
537 | odebug << "top" << oendl; | 537 | odebug << "top" << oendl; |
538 | qApp->processEvents(); | 538 | qApp->processEvents(); |
539 | currentLine = 0; | 539 | currentLine = 0; |
540 | i_pageNum = 1; | 540 | i_pageNum = 1; |
541 | int pageSize = Lview->PageSize() ; | 541 | int pageSize = Lview->PageSize() ; |
542 | Lview->clear(); | 542 | Lview->clear(); |
543 | QString s; | 543 | QString s; |
544 | f.at(0); | 544 | f.at(0); |
545 | for(int fd=0; fd < pageSize ;fd++) { | 545 | for(int fd=0; fd < pageSize ;fd++) { |
546 | f.readLine(s, 256); | 546 | f.readLine(s, 256); |
547 | if(useWrap) | 547 | if(useWrap) |
548 | s.replace(QRegExp("\n"),""); | 548 | s.replace(QRegExp("\n"),""); |
549 | Lview->insertLine(s ,-1); | 549 | Lview->insertLine(s ,-1); |
550 | currentLine++; | 550 | currentLine++; |
551 | } | 551 | } |
552 | // Lview->setCursorPosition( 0,0, FALSE); | 552 | // Lview->setCursorPosition( 0,0, FALSE); |
553 | i_pageNum=1; | 553 | i_pageNum=1; |
554 | setStatus(); | 554 | setStatus(); |
555 | } | 555 | } |
556 | Lview->setFocus(); | 556 | Lview->setFocus(); |
557 | } | 557 | } |
558 | } | 558 | } |
559 | 559 | ||
560 | //moves text to the start of the EText | 560 | //moves text to the start of the EText |
561 | void Gutenbrowser::BeginBtn() { | 561 | void Gutenbrowser::BeginBtn() { |
562 | i_pageNum = 1; | 562 | i_pageNum = 1; |
563 | currentLine = 0; | 563 | currentLine = 0; |
564 | QString s_pattern="*END*THE SMALL PRINT"; | 564 | QString s_pattern="*END*THE SMALL PRINT"; |
565 | QString sPattern2 = "*END THE SMALL PRINT"; | 565 | QString sPattern2 = "*END THE SMALL PRINT"; |
566 | 566 | ||
567 | int pageSize = Lview->PageSize(); | 567 | int pageSize = Lview->PageSize(); |
568 | Lview->clear(); | 568 | Lview->clear(); |
569 | 569 | ||
570 | // int lines = Lview->numLines(); | 570 | // int lines = Lview->numLines(); |
571 | int pos = 0;//, i = 0; | 571 | int pos = 0;//, i = 0; |
572 | int i_topRow = Lview->topRow(); | 572 | int i_topRow = Lview->topRow(); |
573 | 573 | ||
574 | QString LeftText;// = Lview->text(); | 574 | QString LeftText;// = Lview->text(); |
575 | 575 | ||
576 | // int linesPerPage = Lview->lastRow() - Lview->topRow(); | 576 | // int linesPerPage = Lview->lastRow() - Lview->topRow(); |
577 | // int pages = (( linesPerPage / Lview->editSize() ) ) +1; | 577 | // int pages = (( linesPerPage / Lview->editSize() ) ) +1; |
578 | // int pageN = 0; | 578 | // int pageN = 0; |
579 | i_pageNum = 1; | 579 | i_pageNum = 1; |
580 | int lastPage=1; | 580 | int lastPage=1; |
581 | int lineNo=0; | 581 | int lineNo=0; |
582 | QString s; | 582 | QString s; |
583 | f.at( 0); | 583 | f.at( 0); |
584 | 584 | ||
585 | while ( !f.atEnd() ) { | 585 | while ( !f.atEnd() ) { |
586 | f.readLine(s, 256); | 586 | f.readLine(s, 256); |
587 | lineNo++; | 587 | lineNo++; |
588 | LeftText = s; | 588 | LeftText = s; |
589 | currentFilePos = f.at(); | 589 | currentFilePos = f.at(); |
590 | 590 | ||
591 | i_pageNum = lineNo/pageSize; | 591 | i_pageNum = lineNo/pageSize; |
592 | if(lastPage < i_pageNum) { | 592 | if(lastPage < i_pageNum) { |
593 | pageStopArray.resize(i_pageNum + 1); | 593 | pageStopArray.resize(i_pageNum + 1); |
594 | pageStopArray[i_pageNum ] = currentFilePos; | 594 | pageStopArray[i_pageNum ] = currentFilePos; |
595 | // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; | 595 | // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; |
596 | } | 596 | } |
597 | // lastPage = i_pageNum; | 597 | // lastPage = i_pageNum; |
598 | if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) { | 598 | if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) { |
599 | odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; | 599 | odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; |
600 | break; | 600 | break; |
601 | } | 601 | } |
602 | } | 602 | } |
603 | if(f.atEnd()) //in case we didnt find anything, we need to show something | 603 | if(f.atEnd()) //in case we didnt find anything, we need to show something |
604 | f.at(0); | 604 | f.at(0); |
605 | Lview->clear(); | 605 | Lview->clear(); |
606 | for(int fd=0; fd < pageSize - 1;fd++) { | 606 | for(int fd=0; fd < pageSize - 1;fd++) { |
607 | f.readLine(s, 256); | 607 | f.readLine(s, 256); |
608 | if(useWrap) | 608 | if(useWrap) |
609 | s.replace(QRegExp("\n"),""); | 609 | s.replace(QRegExp("\n"),""); |
610 | Lview->insertLine( s, -1); | 610 | Lview->insertLine( s, -1); |
611 | currentLine++; | 611 | currentLine++; |
612 | } | 612 | } |
613 | 613 | ||
614 | i_pageNum = lineNo/pageSize; | 614 | i_pageNum = lineNo/pageSize; |
615 | pageStopArray.resize(i_pageNum + 1); | 615 | pageStopArray.resize(i_pageNum + 1); |
616 | // int length = Lview->length(); | 616 | // int length = Lview->length(); |
617 | 617 | ||
618 | qApp->processEvents(); | 618 | qApp->processEvents(); |
619 | 619 | ||
620 | if( pos > i_topRow ) { | 620 | if( pos > i_topRow ) { |
621 | // Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE); | 621 | // Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE); |
622 | } else { | 622 | } else { |
623 | // Lview->setCursorPosition( pos+2 , 0, FALSE ); | 623 | // Lview->setCursorPosition( pos+2 , 0, FALSE ); |
624 | } | 624 | } |
625 | 625 | ||
626 | Lview->deselect(); | 626 | Lview->deselect(); |
627 | // AdjustStatus(); | 627 | // AdjustStatus(); |
628 | Lview->setFocus(); | 628 | Lview->setFocus(); |
629 | } | 629 | } |
630 | 630 | ||
631 | /* | 631 | /* |
632 | sets the current page and place as a bookmark*/ | 632 | sets the current page and place as a bookmark*/ |
633 | void Gutenbrowser::setBookmark() { | 633 | void Gutenbrowser::setBookmark() { |
634 | int eexit=QMessageBox::information(this, "Note", | 634 | int eexit=QMessageBox::information(this, "Note", |
635 | "Do you really want to \nset this bookmark?." | 635 | "Do you really want to \nset this bookmark?." |
636 | ,QMessageBox::Yes, QMessageBox::No); | 636 | ,QMessageBox::Yes, QMessageBox::No); |
637 | if (eexit== 3) { | 637 | if (eexit== 3) { |
638 | 638 | ||
639 | currentFilePos = f.at(); | 639 | currentFilePos = f.at(); |
640 | 640 | ||
641 | Config cfg("Gutenbrowser"); | 641 | Config cfg("Gutenbrowser"); |
642 | cfg.setGroup("General"); | 642 | cfg.setGroup("General"); |
643 | file_name = cfg.readEntry("Current",""); | 643 | file_name = cfg.readEntry("Current",""); |
644 | qApp->processEvents(); | 644 | qApp->processEvents(); |
645 | odebug << "Setting book mark "+file_name << oendl; | 645 | odebug << "Setting book mark "+file_name << oendl; |
646 | 646 | ||
647 | cfg.setGroup("Titles"); | 647 | cfg.setGroup("Titles"); |
648 | title = cfg.readEntry(file_name,""); | 648 | title = cfg.readEntry(file_name,""); |
649 | odebug << "title is "+ title << oendl; | 649 | odebug << "title is "+ title << oendl; |
650 | 650 | ||
651 | cfg.setGroup( "Bookmarks" ); | 651 | cfg.setGroup( "Bookmarks" ); |
652 | 652 | ||
653 | cfg.writeEntry("File Name",file_name); | 653 | cfg.writeEntry("File Name",file_name); |
654 | cfg.writeEntry("Page Number",QString::number(i_pageNum) ); | 654 | cfg.writeEntry("Page Number",QString::number(i_pageNum) ); |
655 | cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); | 655 | cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); |
656 | cfg.writeEntry("Title", title); | 656 | cfg.writeEntry("Title", title); |
657 | 657 | ||
658 | int row = Lview->topRow();// Lview->Top(); | 658 | int row = Lview->topRow();// Lview->Top(); |
659 | cfg.writeEntry("LineNumber",QString::number(row) ); | 659 | cfg.writeEntry("LineNumber",QString::number(row) ); |
660 | 660 | ||
661 | cfg.setGroup(title); | 661 | cfg.setGroup(title); |
662 | cfg.writeEntry("File Name",file_name); | 662 | cfg.writeEntry("File Name",file_name); |
663 | cfg.writeEntry( "LineNumber", QString::number( row)); | 663 | cfg.writeEntry( "LineNumber", QString::number( row)); |
664 | cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); | 664 | cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); |
665 | cfg.writeEntry( "Page Number", QString::number( i_pageNum) ); | 665 | cfg.writeEntry( "Page Number", QString::number( i_pageNum) ); |
666 | cfg.write(); | 666 | cfg.write(); |
667 | bookmarksMenu->insertItem( title); | 667 | bookmarksMenu->insertItem( title); |
668 | } | 668 | } |
669 | } //end setBookmark | 669 | } //end setBookmark |
670 | 670 | ||
671 | 671 | ||
672 | /* goes to last set bookmark*/ | 672 | /* goes to last set bookmark*/ |
673 | void Gutenbrowser::Bookmark( int itemId) { | 673 | void Gutenbrowser::Bookmark( int itemId) { |
674 | 674 | ||
675 | // qApp->processEvents(); | 675 | // qApp->processEvents(); |
676 | Config config("Gutenbrowser"); | 676 | Config config("Gutenbrowser"); |
677 | config.setGroup( "Bookmarks" ); | 677 | config.setGroup( "Bookmarks" ); |
678 | 678 | ||
679 | odebug << "<<<<<< " << Lview->PageSize() << ", " << Lview->lastRow() - Lview->topRow() << "" << oendl; | 679 | odebug << "<<<<<< " << Lview->PageSize() << ", " << Lview->lastRow() - Lview->topRow() << "" << oendl; |
680 | 680 | ||
681 | QString itemString; | 681 | QString itemString; |
682 | 682 | ||
683 | odebug << "menu item " << itemId << "" << oendl; | 683 | odebug << "menu item " << itemId << "" << oendl; |
684 | QString tempTitle; | 684 | QString tempTitle; |
685 | QString s_Bmrkrow; | 685 | QString s_Bmrkrow; |
686 | QString s_pageNum; | 686 | QString s_pageNum; |
687 | int Bmrkrow=0; | 687 | int Bmrkrow=0; |
688 | int bookmarkPosition = 0; | 688 | int bookmarkPosition = 0; |
689 | 689 | ||
690 | // qApp->processEvents(); | 690 | // qApp->processEvents(); |
691 | config.setGroup( "Bookmarks" ); | 691 | config.setGroup( "Bookmarks" ); |
692 | title = config.readEntry("Title", ""); | 692 | title = config.readEntry("Title", ""); |
693 | file_name = config.readEntry("File Name", ""); | 693 | file_name = config.readEntry("File Name", ""); |
694 | i_pageNum = config.readNumEntry("Page Number", 0); | 694 | i_pageNum = config.readNumEntry("Page Number", 0); |
695 | bookmarkPosition = config.readNumEntry( "PagePosition",0); | 695 | bookmarkPosition = config.readNumEntry( "PagePosition",0); |
696 | Bmrkrow = config.readNumEntry("LineNumber",0); | 696 | Bmrkrow = config.readNumEntry("LineNumber",0); |
697 | if( !file_name.contains("/")) { | 697 | if( !file_name.contains("/")) { |
698 | file_name = local_library + file_name; | 698 | file_name = local_library + file_name; |
699 | } | 699 | } |
700 | 700 | ||
701 | // getTitle(file_name); | 701 | // getTitle(file_name); |
702 | // qApp->processEvents(); | 702 | // qApp->processEvents(); |
703 | // Lview->setFocus(); | 703 | // Lview->setFocus(); |
704 | this->setFocus(); | 704 | this->setFocus(); |
705 | 705 | ||
706 | Lview->clear(); | 706 | Lview->clear(); |
707 | 707 | ||
708 | if(!load(file_name)) return; | 708 | if(!load(file_name)) return; |
709 | 709 | ||
710 | int pageSize = Lview->PageSize(); | 710 | int pageSize = Lview->PageSize(); |
711 | f.at(0); | 711 | f.at(0); |
712 | // Lview->clear(); | 712 | // Lview->clear(); |
713 | QString s; | 713 | QString s; |
714 | int lineNo=0; | 714 | int lineNo=0; |
715 | int lastPage=1; | 715 | int lastPage=1; |
716 | while ( !f.atEnd() ) { | 716 | while ( !f.atEnd() ) { |
717 | f.readLine(s, 256); | 717 | f.readLine(s, 256); |
718 | lineNo++; | 718 | lineNo++; |
719 | currentFilePos = f.at(); | 719 | currentFilePos = f.at(); |
720 | 720 | ||
721 | i_pageNum = lineNo/pageSize; | 721 | i_pageNum = lineNo/pageSize; |
722 | if(lastPage < i_pageNum) { | 722 | if(lastPage < i_pageNum) { |
723 | pageStopArray.resize(i_pageNum + 1); | 723 | pageStopArray.resize(i_pageNum + 1); |
724 | pageStopArray[i_pageNum ] = currentFilePos; | 724 | pageStopArray[i_pageNum ] = currentFilePos; |
725 | // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; | 725 | // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; |
726 | } | 726 | } |
727 | if(currentFilePos == bookmarkPosition) | 727 | if(currentFilePos == bookmarkPosition) |
728 | break; | 728 | break; |
729 | } | 729 | } |
730 | if(f.atEnd()) | 730 | if(f.atEnd()) |
731 | f.at(0); | 731 | f.at(0); |
732 | else | 732 | else |
733 | f.at( bookmarkPosition); | 733 | f.at( bookmarkPosition); |
734 | 734 | ||
735 | for(int fd=0; fd < pageSize - 1;fd++) { | 735 | for(int fd=0; fd < pageSize - 1;fd++) { |
736 | f.readLine(s, 256); | 736 | f.readLine(s, 256); |
737 | lineNo++; | 737 | lineNo++; |
738 | if(useWrap) | 738 | if(useWrap) |
739 | s.replace(QRegExp("\n"),""); | 739 | s.replace(QRegExp("\n"),""); |
740 | Lview->insertLine( s, -1); | 740 | Lview->insertLine( s, -1); |
741 | currentLine++; | 741 | currentLine++; |
742 | } | 742 | } |
743 | 743 | ||
744 | i_pageNum = lineNo/pageSize; | 744 | i_pageNum = lineNo/pageSize; |
745 | pageStopArray.resize(i_pageNum + 1); | 745 | pageStopArray.resize(i_pageNum + 1); |
746 | 746 | ||
747 | if(showMainList) { | 747 | if(showMainList) { |
748 | showMainList=FALSE; | 748 | showMainList=FALSE; |
749 | mainList->hide(); | 749 | mainList->hide(); |
750 | Lview->show(); | 750 | Lview->show(); |
751 | // qApp->processEvents(); | 751 | // qApp->processEvents(); |
752 | } | 752 | } |
753 | 753 | ||
754 | odebug << "bookmark loaded" << oendl; | 754 | odebug << "bookmark loaded" << oendl; |
755 | setCaption(title); | 755 | setCaption(title); |
756 | } | 756 | } |
757 | 757 | ||
758 | 758 | ||
759 | bool Gutenbrowser::load( const char *fileName) { | 759 | bool Gutenbrowser::load( const char *fileName) { |
760 | 760 | ||
761 | // QCopEnvelope ( "QPE/System", "busy()" ); | 761 | // QCopEnvelope ( "QPE/System", "busy()" ); |
762 | odebug << "Title is already set as "+title << oendl; | 762 | odebug << "Title is already set as "+title << oendl; |
763 | odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl; | 763 | odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl; |
764 | // pointSize = Lview->fontInfo().pointSize(); | 764 | // pointSize = Lview->fontInfo().pointSize(); |
765 | // odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl; | 765 | // odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl; |
766 | if( Lview->PageSize() < 4) { | 766 | if( Lview->PageSize() < 4) { |
767 | 767 | ||
768 | //Lview->setMaximumHeight( sizeHint().height() ); | 768 | //Lview->setMaximumHeight( sizeHint().height() ); |
769 | Lview->setMinimumHeight( sizeHint().height() ); | 769 | Lview->setMinimumHeight( sizeHint().height() ); |