-rw-r--r-- | noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | 185 |
1 files changed, 95 insertions, 90 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp index 3c096ed..7426e80 100644 --- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | |||
@@ -450,624 +450,629 @@ bool LibraryDialog::download_Etext() | |||
450 | if( ftp_base_dir.find("=",0,true) ) | 450 | if( ftp_base_dir.find("=",0,true) ) |
451 | ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1); | 451 | ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1); |
452 | 452 | ||
453 | networkUrl= "ftp://"+ftp_host+dir; | 453 | networkUrl= "ftp://"+ftp_host+dir; |
454 | 454 | ||
455 | outputFile=local_library+".guten_temp"; | 455 | outputFile=local_library+".guten_temp"; |
456 | //odebug << "Download file:" << NewlistItemFile << "" << oendl; | 456 | //odebug << "Download file:" << NewlistItemFile << "" << oendl; |
457 | odebug << "Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile << oendl; | 457 | odebug << "Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile << oendl; |
458 | QStringList networkList; | 458 | QStringList networkList; |
459 | networkList.append((const char *)ftp_host); | 459 | networkList.append((const char *)ftp_host); |
460 | networkList.append((const char *)dir); | 460 | networkList.append((const char *)dir); |
461 | networkList.append((const char *)outputFile); | 461 | networkList.append((const char *)outputFile); |
462 | networkList.append((const char *)NewlistItemFile); | 462 | networkList.append((const char *)NewlistItemFile); |
463 | //<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile; | 463 | //<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile; |
464 | 464 | ||
465 | NetworkDialog *NetworkDlg; | 465 | NetworkDialog *NetworkDlg; |
466 | NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList); | 466 | NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList); |
467 | 467 | ||
468 | 468 | ||
469 | if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer | 469 | if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer |
470 | File_Name= NetworkDlg->localFileName; | 470 | File_Name= NetworkDlg->localFileName; |
471 | odebug << "back to Library from Network Dialog" << oendl; | 471 | odebug << "back to Library from Network Dialog" << oendl; |
472 | odebug << "Just downloaded "+NetworkDlg->localFileName << oendl; | 472 | odebug << "Just downloaded "+NetworkDlg->localFileName << oendl; |
473 | 473 | ||
474 | // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found | 474 | // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found |
475 | // QString oldName=File_Name; | 475 | // QString oldName=File_Name; |
476 | // File_Name.replace(0,local_library.length(),downDir); | 476 | // File_Name.replace(0,local_library.length(),downDir); |
477 | // odebug << "File_Name now is "+File_Name << oendl; | 477 | // odebug << "File_Name now is "+File_Name << oendl; |
478 | 478 | ||
479 | // } | 479 | // } |
480 | // rename .txt to .etx | 480 | // rename .txt to .etx |
481 | if(NetworkDlg->successDownload) { | 481 | if(NetworkDlg->successDownload) { |
482 | odebug << "Filename is "+File_Name << oendl; | 482 | odebug << "Filename is "+File_Name << oendl; |
483 | if(File_Name.right(4)==".txt") { | 483 | if(File_Name.right(4)==".txt") { |
484 | QString s_fileName=File_Name; | 484 | QString s_fileName=File_Name; |
485 | s_fileName.replace( s_fileName.length()-3,3,"gtn"); | 485 | s_fileName.replace( s_fileName.length()-3,3,"gtn"); |
486 | // s_fileName.replace( s_fileName.length()-3,3,"etx"); | 486 | // s_fileName.replace( s_fileName.length()-3,3,"etx"); |
487 | rename(File_Name.latin1(),s_fileName.latin1()); | 487 | rename(File_Name.latin1(),s_fileName.latin1()); |
488 | File_Name=s_fileName; | 488 | File_Name=s_fileName; |
489 | 489 | ||
490 | odebug << "Filename is now "+File_Name << oendl; | 490 | odebug << "Filename is now "+File_Name << oendl; |
491 | 491 | ||
492 | } | 492 | } |
493 | if(File_Name.length() > 5 ) { | 493 | if(File_Name.length() > 5 ) { |
494 | setTitle(); | 494 | setTitle(); |
495 | QFileInfo fi(File_Name); | 495 | QFileInfo fi(File_Name); |
496 | QString name_file=fi.fileName(); | 496 | QString name_file=fi.fileName(); |
497 | name_file=name_file.left(name_file.length()-4); | 497 | name_file=name_file.left(name_file.length()-4); |
498 | 498 | ||
499 | odebug << "Setting doclink" << oendl; | 499 | odebug << "Setting doclink" << oendl; |
500 | DocLnk lnk; | 500 | DocLnk lnk; |
501 | odebug << "name is "+name_file << oendl; | 501 | odebug << "name is "+name_file << oendl; |
502 | lnk.setName(name_file); //sets file name | 502 | lnk.setName(name_file); //sets file name |
503 | odebug << "Title is "+DlglistItemTitle << oendl; | 503 | odebug << "Title is "+DlglistItemTitle << oendl; |
504 | lnk.setComment(DlglistItemTitle); | 504 | lnk.setComment(DlglistItemTitle); |
505 | 505 | ||
506 | odebug << "Filename is "+File_Name << oendl; | 506 | odebug << "Filename is "+File_Name << oendl; |
507 | lnk.setFile(File_Name); //sets File property | 507 | lnk.setFile(File_Name); //sets File property |
508 | lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D | 508 | lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D |
509 | lnk.setExec(File_Name); | 509 | lnk.setExec(File_Name); |
510 | lnk.setIcon("gutenbrowser/Gutenbrowser"); | 510 | lnk.setIcon("gutenbrowser/Gutenbrowser"); |
511 | if(!lnk.writeLink()) { | 511 | if(!lnk.writeLink()) { |
512 | odebug << "Writing doclink did not work" << oendl; | 512 | odebug << "Writing doclink did not work" << oendl; |
513 | } else { | 513 | } else { |
514 | } | 514 | } |
515 | } else | 515 | } else |
516 | QMessageBox::message("Note","<p>There was an error with the file</p>"); | 516 | QMessageBox::message("Note","<p>There was an error with the file</p>"); |
517 | } | 517 | } |
518 | } | 518 | } |
519 | return true; | 519 | return true; |
520 | } | 520 | } |
521 | 521 | ||
522 | bool LibraryDialog::httpDownload() | 522 | bool LibraryDialog::httpDownload() |
523 | {// httpDownload | 523 | {// httpDownload |
524 | #ifndef Q_WS_QWS | 524 | #ifndef Q_WS_QWS |
525 | Config config("Gutenbrowser"); | 525 | Config config("Gutenbrowser"); |
526 | config.setGroup( "Browser" ); | 526 | config.setGroup( "Browser" ); |
527 | QString brow = config.readEntry("Preferred", ""); | 527 | QString brow = config.readEntry("Preferred", ""); |
528 | QString file_name = "./.guten_temp"; | 528 | QString file_name = "./.guten_temp"; |
529 | // config.setGroup( "HttpServer" ); | 529 | // config.setGroup( "HttpServer" ); |
530 | // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); | 530 | // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); |
531 | QString httpName = proxy_http + "/"+Edir; | 531 | QString httpName = proxy_http + "/"+Edir; |
532 | // progressBar->setProgress( i); | 532 | // progressBar->setProgress( i); |
533 | i++; | 533 | i++; |
534 | if ( brow != "Konq") { /////////// use lynx | 534 | if ( brow != "Konq") { /////////// use lynx |
535 | // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name; | 535 | // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name; |
536 | // system(cmd); | 536 | // system(cmd); |
537 | } else { //////////// use KFM | 537 | } else { //////////// use KFM |
538 | // KFM::download( httpName, file_name); | 538 | // KFM::download( httpName, file_name); |
539 | } | 539 | } |
540 | i++; | 540 | i++; |
541 | QFile tmp( file_name); | 541 | QFile tmp( file_name); |
542 | QString str; | 542 | QString str; |
543 | if (tmp.open(IO_ReadOnly)) { | 543 | if (tmp.open(IO_ReadOnly)) { |
544 | QTextStream t( &tmp ); // use a text stream | 544 | QTextStream t( &tmp ); // use a text stream |
545 | while ( !t.eof()) { | 545 | while ( !t.eof()) { |
546 | QString s = t.readLine(); | 546 | QString s = t.readLine(); |
547 | if (s.contains( NewlistItemFile, FALSE) && (s.contains(".txt")) ) { | 547 | if (s.contains( NewlistItemFile, FALSE) && (s.contains(".txt")) ) { |
548 | str = s.mid( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6, (s.find( ".txt</A>", 0, TRUE) + 4) - ( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6 ) ); | 548 | str = s.mid( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6, (s.find( ".txt</A>", 0, TRUE) + 4) - ( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6 ) ); |
549 | httpName += "/" + str; | 549 | httpName += "/" + str; |
550 | } | 550 | } |
551 | } //end of while loop | 551 | } //end of while loop |
552 | } | 552 | } |
553 | tmp.close(); | 553 | tmp.close(); |
554 | m_getFilePath = local_library + str; | 554 | m_getFilePath = local_library + str; |
555 | i++; | 555 | i++; |
556 | if ( brow != "KFM"){ ///////// use lynx | 556 | if ( brow != "KFM"){ ///////// use lynx |
557 | QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; | 557 | QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; |
558 | // QMessageBox::message("Error", cmd); | 558 | // QMessageBox::message("Error", cmd); |
559 | system(cmd); | 559 | system(cmd); |
560 | } else { ////////// use KFM | 560 | } else { ////////// use KFM |
561 | // KFM::download( httpName, m_getFilePath); | 561 | // KFM::download( httpName, m_getFilePath); |
562 | } | 562 | } |
563 | i++; | 563 | i++; |
564 | #endif | 564 | #endif |
565 | return false; | 565 | return false; |
566 | } | 566 | } |
567 | 567 | ||
568 | void LibraryDialog::cancelIt() | 568 | void LibraryDialog::cancelIt() |
569 | { | 569 | { |
570 | saveConfig(); | 570 | saveConfig(); |
571 | 571 | ||
572 | DlglistItemNumber = ""; | 572 | DlglistItemNumber = ""; |
573 | this->reject(); | 573 | this->reject(); |
574 | } | 574 | } |
575 | 575 | ||
576 | bool LibraryDialog::setTitle() | 576 | bool LibraryDialog::setTitle() |
577 | { | 577 | { |
578 | Config config("Gutenbrowser"); | 578 | Config config("Gutenbrowser"); |
579 | odebug << "setting title" << oendl; | 579 | odebug << "setting title" << oendl; |
580 | odebug << DlglistItemTitle << oendl; | 580 | odebug << DlglistItemTitle << oendl; |
581 | 581 | ||
582 | if( DlglistItemTitle.find("[",0,TRUE) != -1) | 582 | if( DlglistItemTitle.find("[",0,TRUE) != -1) |
583 | DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" ); | 583 | DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" ); |
584 | if( DlglistItemTitle.find("]",0,TRUE) !=-1) | 584 | if( DlglistItemTitle.find("]",0,TRUE) !=-1) |
585 | DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); | 585 | DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); |
586 | odebug << "Title being set is "+DlglistItemTitle << oendl; | 586 | odebug << "Title being set is "+DlglistItemTitle << oendl; |
587 | int test = 0; | 587 | int test = 0; |
588 | QString ramble, temp; | 588 | QString ramble, temp; |
589 | config.setGroup("Files"); | 589 | config.setGroup("Files"); |
590 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 590 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
591 | int i_numofFiles = s_numofFiles.toInt(); | 591 | int i_numofFiles = s_numofFiles.toInt(); |
592 | for ( int i = 0; i <= i_numofFiles; i++){ | 592 | for ( int i = 0; i <= i_numofFiles; i++){ |
593 | temp.setNum( i); | 593 | temp.setNum( i); |
594 | ramble = config.readEntry( temp, "" ); | 594 | ramble = config.readEntry( temp, "" ); |
595 | if( strcmp( ramble, File_Name) == 0){ | 595 | if( strcmp( ramble, File_Name) == 0){ |
596 | test = 1; | 596 | test = 1; |
597 | } | 597 | } |
598 | } | 598 | } |
599 | |||
600 | if(test == 0 ) { | ||
601 | |||
599 | config.setGroup("Files"); | 602 | config.setGroup("Files"); |
600 | config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); | 603 | config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); |
601 | QString interger; | 604 | QString interger; |
602 | interger.setNum( i_numofFiles +1); | 605 | interger.setNum( i_numofFiles +1); |
603 | config.writeEntry( interger, File_Name); | 606 | config.writeEntry( interger, File_Name); |
604 | config.setGroup( "Titles" ); | 607 | config.setGroup( "Titles" ); |
605 | config.writeEntry( File_Name, DlglistItemTitle); | 608 | config.writeEntry( File_Name, DlglistItemTitle); |
606 | 609 | } | |
607 | test = 0; | 610 | test = 0; |
608 | return true; | 611 | return true; |
609 | } | 612 | } |
610 | 613 | ||
611 | 614 | ||
612 | void LibraryDialog::saveConfig() | 615 | void LibraryDialog::saveConfig() |
613 | { | 616 | { |
614 | Config config("Gutenbrowser"); | 617 | Config config("Gutenbrowser"); |
615 | if( httpBox->isChecked() == TRUE) { | 618 | if( httpBox->isChecked() == TRUE) { |
616 | checked = 1; | 619 | checked = 1; |
617 | config.setGroup( "Proxy" ); | 620 | config.setGroup( "Proxy" ); |
618 | config.writeEntry("IsChecked", "TRUE"); | 621 | config.writeEntry("IsChecked", "TRUE"); |
619 | } else { | 622 | } else { |
620 | checked = 0; | 623 | checked = 0; |
621 | config.setGroup( "Proxy" ); | 624 | config.setGroup( "Proxy" ); |
622 | config.writeEntry("IsChecked", "FALSE"); | 625 | config.writeEntry("IsChecked", "FALSE"); |
623 | } | 626 | } |
624 | if (authBox->isChecked() == TRUE) { | 627 | if (authBox->isChecked() == TRUE) { |
625 | config.setGroup("SortAuth"); | 628 | config.setGroup("SortAuth"); |
626 | config.writeEntry("authSort", "TRUE"); | 629 | config.writeEntry("authSort", "TRUE"); |
627 | } else { | 630 | } else { |
628 | config.setGroup("SortAuth"); | 631 | config.setGroup("SortAuth"); |
629 | config.writeEntry("authSort", "FALSE"); | 632 | config.writeEntry("authSort", "FALSE"); |
630 | } | 633 | } |
631 | // config.write(); | 634 | // config.write(); |
632 | } | 635 | } |
633 | 636 | ||
634 | /* | 637 | /* |
635 | searches library index for user word*/ | 638 | searches library index for user word*/ |
636 | void LibraryDialog::onButtonSearch() | 639 | void LibraryDialog::onButtonSearch() |
637 | { | 640 | { |
638 | ListView1->clearSelection(); | 641 | ListView1->clearSelection(); |
639 | ListView2->clearSelection(); | 642 | ListView2->clearSelection(); |
640 | ListView3->clearSelection(); | 643 | ListView3->clearSelection(); |
641 | ListView4->clearSelection(); | 644 | ListView4->clearSelection(); |
642 | ListView5->clearSelection(); | 645 | ListView5->clearSelection(); |
643 | 646 | ||
644 | int curTab=tabWidget->currentPageIndex(); | 647 | int curTab=tabWidget->currentPageIndex(); |
645 | SearchDialog* searchDlg; | 648 | SearchDialog* searchDlg; |
646 | 649 | ||
647 | // if( resultsList) | 650 | // if( resultsList) |
648 | searchDlg = new SearchDialog( this, "Library Search", TRUE); | 651 | searchDlg = new SearchDialog( this, "Library Search", TRUE); |
649 | searchDlg->setCaption( tr( "Library Search" ) ); | 652 | searchDlg->setCaption( tr( "Library Search" ) ); |
650 | searchDlg->setLabel( "- author or title"); | 653 | searchDlg->setLabel( "- author or title"); |
651 | QString resultString; | 654 | QString resultString; |
652 | int i_berger = 0; | 655 | int i_berger = 0; |
653 | if( searchDlg->exec() != 0 ) { | 656 | if( searchDlg->exec() != 0 ) { |
654 | QString searcherStr = searchDlg->get_text(); | 657 | QString searcherStr = searchDlg->get_text(); |
655 | int fluff=0; | 658 | int fluff=0; |
656 | 659 | ||
657 | // int tabPage = tabWidget->currentPageIndex(); | 660 | // int tabPage = tabWidget->currentPageIndex(); |
658 | // TODO ititerate here... struct<listViews>?? | 661 | // TODO ititerate here... struct<listViews>?? |
659 | 662 | ||
660 | QListViewItemIterator it1( ListView1 ); | 663 | QListViewItemIterator it1( ListView1 ); |
661 | QListViewItemIterator it2( ListView2 ); | 664 | QListViewItemIterator it2( ListView2 ); |
662 | QListViewItemIterator it3( ListView3 ); | 665 | QListViewItemIterator it3( ListView3 ); |
663 | QListViewItemIterator it4( ListView4 ); | 666 | QListViewItemIterator it4( ListView4 ); |
664 | QListViewItemIterator it5( ListView5 ); | 667 | QListViewItemIterator it5( ListView5 ); |
665 | 668 | ||
666 | //// this is really pitiful work, | 669 | //// this is really pitiful work, |
667 | /////// | 670 | /////// |
668 | bool cS; | 671 | bool cS; |
669 | if( searchDlg->caseSensitiveCheckBox->isChecked()) | 672 | if( searchDlg->caseSensitiveCheckBox->isChecked()) |
670 | cS=true; //case sensitive | 673 | cS=true; //case sensitive |
671 | else | 674 | else |
672 | cS=false; | 675 | cS=false; |
673 | 676 | ||
674 | if(fluff==0) { | 677 | if(fluff==0) { |
675 | for ( ; it1.current(); ++it1 ) { | 678 | for ( ; it1.current(); ++it1 ) { |
676 | resultString = ( it1.current() )->text(0); | 679 | resultString = ( it1.current() )->text(0); |
677 | resultString += (" : "); | 680 | resultString += (" : "); |
678 | resultString += ( it1.current() )->text(2); | 681 | resultString += ( it1.current() )->text(2); |
679 | resultString += (" : "); | 682 | resultString += (" : "); |
680 | resultString += ( it1.current() )->text(3); | 683 | resultString += ( it1.current() )->text(3); |
681 | if( resultString.find( searcherStr, 0, cS) != -1) | 684 | if( resultString.find( searcherStr, 0, cS) != -1) |
682 | { | 685 | { |
683 | Searchlist.append( resultString); | 686 | Searchlist.append( resultString); |
684 | } | 687 | } |
685 | } | 688 | } |
686 | } | 689 | } |
687 | if(fluff==0) {// search routine here | 690 | if(fluff==0) {// search routine here |
688 | for ( ; it2.current(); ++it2 ) { | 691 | for ( ; it2.current(); ++it2 ) { |
689 | resultString = ( it2.current() )->text(0); | 692 | resultString = ( it2.current() )->text(0); |
690 | resultString += (" : "); | 693 | resultString += (" : "); |
691 | resultString += ( it2.current() )->text(2); | 694 | resultString += ( it2.current() )->text(2); |
692 | resultString += (" : "); | 695 | resultString += (" : "); |
693 | resultString += ( it2.current() )->text(3); | 696 | resultString += ( it2.current() )->text(3); |
694 | if( resultString.find( searcherStr, 0, cS) != -1) { | 697 | if( resultString.find( searcherStr, 0, cS) != -1) { |
695 | Searchlist.append( resultString); | 698 | Searchlist.append( resultString); |
696 | } | 699 | } |
697 | } | 700 | } |
698 | } | 701 | } |
699 | if(fluff==0) {// search routine here | 702 | if(fluff==0) {// search routine here |
700 | for ( ; it3.current(); ++it3 ) { | 703 | for ( ; it3.current(); ++it3 ) { |
701 | resultString = ( it3.current() )->text(0); | 704 | resultString = ( it3.current() )->text(0); |
702 | resultString += (" : "); | 705 | resultString += (" : "); |
703 | resultString += ( it3.current() )->text(2); | 706 | resultString += ( it3.current() )->text(2); |
704 | resultString += (" : "); | 707 | resultString += (" : "); |
705 | resultString += ( it3.current() )->text(3); | 708 | resultString += ( it3.current() )->text(3); |
706 | 709 | ||
707 | if( resultString.find( searcherStr, 0, cS) != -1) { | 710 | if( resultString.find( searcherStr, 0, cS) != -1) { |
708 | Searchlist.append( resultString); | 711 | Searchlist.append( resultString); |
709 | } | 712 | } |
710 | } | 713 | } |
711 | } | 714 | } |
712 | if(fluff==0) { | 715 | if(fluff==0) { |
713 | // search routine here | 716 | // search routine here |
714 | for ( ; it4.current(); ++it4 ) { | 717 | for ( ; it4.current(); ++it4 ) { |
715 | resultString = ( it4.current() )->text(0); | 718 | resultString = ( it4.current() )->text(0); |
716 | resultString += (" : "); | 719 | resultString += (" : "); |
717 | resultString += ( it4.current() )->text(2); | 720 | resultString += ( it4.current() )->text(2); |
718 | resultString += (" : "); | 721 | resultString += (" : "); |
719 | resultString += ( it4.current() )->text(3); | 722 | resultString += ( it4.current() )->text(3); |
720 | if( resultString.find( searcherStr, 0, cS) != -1) { | 723 | if( resultString.find( searcherStr, 0, cS) != -1) { |
721 | Searchlist.append( resultString); | 724 | Searchlist.append( resultString); |
722 | } | 725 | } |
723 | } | 726 | } |
724 | } | 727 | } |
725 | if(fluff==0) { // search routine here | 728 | if(fluff==0) { // search routine here |
726 | for ( ; it5.current(); ++it5 ) { | 729 | for ( ; it5.current(); ++it5 ) { |
727 | resultString = ( it5.current() )->text(0); | 730 | resultString = ( it5.current() )->text(0); |
728 | resultString += (" : "); | 731 | resultString += (" : "); |
729 | resultString += ( it5.current() )->text(2); | 732 | resultString += ( it5.current() )->text(2); |
730 | resultString += (" : "); | 733 | resultString += (" : "); |
731 | resultString += ( it5.current() )->text(3); | 734 | resultString += ( it5.current() )->text(3); |
732 | if( resultString.find( searcherStr, 0, cS) != -1) { | 735 | if( resultString.find( searcherStr, 0, cS) != -1) { |
733 | Searchlist.append( resultString); | 736 | Searchlist.append( resultString); |
734 | } | 737 | } |
735 | } | 738 | } |
736 | } | 739 | } |
737 | 740 | ||
738 | tabWidget->setCurrentPage( curTab); | 741 | tabWidget->setCurrentPage( curTab); |
739 | 742 | ||
740 | Searchlist.sort(); | 743 | Searchlist.sort(); |
741 | SearchResultsDlg* SearchResultsDialog; | 744 | SearchResultsDlg* SearchResultsDialog; |
742 | SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); | 745 | SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); |
743 | 746 | ||
744 | SearchResultsDialog->showMaximized(); | 747 | SearchResultsDialog->showMaximized(); |
745 | if( SearchResultsDialog->exec() != 0) { | 748 | if( SearchResultsDialog->exec() != 0) { |
746 | texter = SearchResultsDialog->selText; | 749 | texter = SearchResultsDialog->selText; |
747 | // odebug << texter << oendl; | 750 | // odebug << texter << oendl; |
748 | resultLs= SearchResultsDialog->resultsList; | 751 | resultLs = SearchResultsDialog->resultsList; |
749 | i_berger = 1; | 752 | i_berger = 1; |
750 | } | 753 | } else { |
754 | resultLs.clear(); | ||
755 | } | ||
751 | Searchlist.clear(); | 756 | Searchlist.clear(); |
752 | 757 | ||
753 | // if(SearchResultsDialog) | 758 | // if(SearchResultsDialog) |
754 | // delete SearchResultsDialog; | 759 | // delete SearchResultsDialog; |
755 | QString tester; | 760 | QString tester; |
756 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { | 761 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { |
757 | texter.sprintf("%s \n",(*it).latin1()); | 762 | texter.sprintf("%s \n",(*it).latin1()); |
758 | // odebug << texter << oendl; | 763 | // odebug << texter << oendl; |
759 | if( tester!=texter) | 764 | if( tester!=texter) |
760 | parseSearchResults( texter); | 765 | parseSearchResults( texter); |
761 | tester = texter; | 766 | tester = texter; |
762 | } | 767 | } |
763 | if(searchDlg) | 768 | if(searchDlg) |
764 | delete searchDlg; | 769 | delete searchDlg; |
765 | } | 770 | } |
766 | if(checkBox->isChecked() ) { | 771 | if(checkBox->isChecked() ) { |
767 | accept(); | 772 | accept(); |
768 | } else { | 773 | } else { |
769 | setActiveWindow(); | 774 | setActiveWindow(); |
770 | } | 775 | } |
771 | } | 776 | } |
772 | 777 | ||
773 | /* | 778 | /* |
774 | splits the result string and calls download for the current search result*/ | 779 | splits the result string and calls download for the current search result*/ |
775 | void LibraryDialog::parseSearchResults( QString resultStr) | 780 | void LibraryDialog::parseSearchResults( QString resultStr) |
776 | { | 781 | { |
777 | 782 | ||
778 | int stringLeng=resultStr.length(); | 783 | int stringLeng=resultStr.length(); |
779 | QString my; | 784 | QString my; |
780 | my.setNum( stringLeng, 10); | 785 | my.setNum( stringLeng, 10); |
781 | 786 | ||
782 | if( resultStr.length() > 2 && resultStr.length() < 130) { | 787 | if( resultStr.length() > 2 && resultStr.length() < 130) { |
783 | int titleInt = resultStr.find( " : ", 0, TRUE); | 788 | int titleInt = resultStr.find( " : ", 0, TRUE); |
784 | DlglistItemTitle = resultStr.left( titleInt); | 789 | DlglistItemTitle = resultStr.left( titleInt); |
785 | int yearInt = resultStr.find( " : ", titleInt+3, TRUE); | 790 | int yearInt = resultStr.find( " : ", titleInt+3, TRUE); |
786 | DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); | 791 | DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); |
787 | DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); | 792 | DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); |
788 | download_Etext(); | 793 | download_Etext(); |
789 | } | 794 | } |
790 | /* | 795 | /* |
791 | printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/ | 796 | printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/ |
792 | } | 797 | } |
793 | 798 | ||
794 | // bool LibraryDialog::UnzipIt( QString zipFile) { | 799 | // bool LibraryDialog::UnzipIt( QString zipFile) { |
795 | // //////////TODO findsome other way of dealingwithzip files. | 800 | // //////////TODO findsome other way of dealingwithzip files. |
796 | // ///usr/bin/unzip"; | 801 | // ///usr/bin/unzip"; |
797 | // if( QFile::exists( zipFile)) { | 802 | // if( QFile::exists( zipFile)) { |
798 | // // QString thatFile = local_library +"PGWHOLE.TXT"; | 803 | // // QString thatFile = local_library +"PGWHOLE.TXT"; |
799 | // QString cmd; | 804 | // QString cmd; |
800 | // #if defined(_WS_X11_) | 805 | // #if defined(_WS_X11_) |
801 | // cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; | 806 | // cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; |
802 | // #endif | 807 | // #endif |
803 | // #if defined(_WS_WIN_) | 808 | // #if defined(_WS_WIN_) |
804 | // QString temp= QDir::convertSeparators(local_library); | 809 | // QString temp= QDir::convertSeparators(local_library); |
805 | // zipFile=QDir::convertSeparators( zipFile); | 810 | // zipFile=QDir::convertSeparators( zipFile); |
806 | // cmd = temp+"unzip.exe -o " +zipFile/*newestLibraryFile */+" -d " + temp; | 811 | // cmd = temp+"unzip.exe -o " +zipFile/*newestLibraryFile */+" -d " + temp; |
807 | // #endif | 812 | // #endif |
808 | // #ifndef Q_WS_QWS | 813 | // #ifndef Q_WS_QWS |
809 | // // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; | 814 | // // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; |
810 | // cmd = "unzip " + zipFile; | 815 | // cmd = "unzip " + zipFile; |
811 | // #endif | 816 | // #endif |
812 | 817 | ||
813 | // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No); | 818 | // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No); |
814 | // if (exit==QMessageBox::Yes) { | 819 | // if (exit==QMessageBox::Yes) { |
815 | // odebug << "Issuing the command "+cmd << oendl; | 820 | // odebug << "Issuing the command "+cmd << oendl; |
816 | // #if defined(_WS_WIN_) | 821 | // #if defined(_WS_WIN_) |
817 | // WinExec( cmd, SW_HIDE ); | 822 | // WinExec( cmd, SW_HIDE ); |
818 | // #endif | 823 | // #endif |
819 | // #if defined(_WS_X11_) | 824 | // #if defined(_WS_X11_) |
820 | // system( cmd); | 825 | // system( cmd); |
821 | // #endif | 826 | // #endif |
822 | // #ifndef Q_WS_QWS | 827 | // #ifndef Q_WS_QWS |
823 | // system( cmd); | 828 | // system( cmd); |
824 | // #endif | 829 | // #endif |
825 | // // printf("unzip\n"); | 830 | // // printf("unzip\n"); |
826 | // // remove( zipFile /*newestLibraryFile*/); | 831 | // // remove( zipFile /*newestLibraryFile*/); |
827 | // return true; | 832 | // return true; |
828 | // } | 833 | // } |
829 | // else if(exit==QMessageBox::No) { | 834 | // else if(exit==QMessageBox::No) { |
830 | // // printf("unzip\n"); | 835 | // // printf("unzip\n"); |
831 | // return false; | 836 | // return false; |
832 | // } | 837 | // } |
833 | // } else { | 838 | // } else { |
834 | // // QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); | 839 | // // QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); |
835 | // return false; | 840 | // return false; |
836 | // } | 841 | // } |
837 | // return true; | 842 | // return true; |
838 | // } | 843 | // } |
839 | 844 | ||
840 | void LibraryDialog::sort() | 845 | void LibraryDialog::sort() |
841 | { | 846 | { |
842 | 847 | ||
843 | } | 848 | } |
844 | 849 | ||
845 | /* | 850 | /* |
846 | Downloads the current selected listitem*/ | 851 | Downloads the current selected listitem*/ |
847 | bool LibraryDialog::getItem(QListViewItem *it) | 852 | bool LibraryDialog::getItem(QListViewItem *it) |
848 | { | 853 | { |
849 | // odebug << "selected getItem" << oendl; | 854 | // odebug << "selected getItem" << oendl; |
850 | 855 | ||
851 | // DlglistItemNumber = it->text(0); | 856 | // DlglistItemNumber = it->text(0); |
852 | DlglistItemTitle = it->text(0); | 857 | DlglistItemTitle = it->text(0); |
853 | DlglistItemYear = it->text(2); | 858 | DlglistItemYear = it->text(2); |
854 | DlglistItemFile = it->text(3); | 859 | DlglistItemFile = it->text(3); |
855 | 860 | ||
856 | if(download_Etext()) { | 861 | if(download_Etext()) { |
857 | if(i_binary == 1) { | 862 | if(i_binary == 1) { |
858 | } | 863 | } |
859 | } | 864 | } |
860 | return true; | 865 | return true; |
861 | } | 866 | } |
862 | 867 | ||
863 | /* | 868 | /* |
864 | download button is pushed so we get the current items to download*/ | 869 | download button is pushed so we get the current items to download*/ |
865 | bool LibraryDialog::onButtonDownload() | 870 | bool LibraryDialog::onButtonDownload() |
866 | { | 871 | { |
867 | // odebug << "selected onButtonDownloadz" << oendl; | 872 | // odebug << "selected onButtonDownloadz" << oendl; |
868 | 873 | ||
869 | QListViewItemIterator it1( ListView1 ); | 874 | QListViewItemIterator it1( ListView1 ); |
870 | QListViewItemIterator it2( ListView2 ); | 875 | QListViewItemIterator it2( ListView2 ); |
871 | QListViewItemIterator it3( ListView3 ); | 876 | QListViewItemIterator it3( ListView3 ); |
872 | QListViewItemIterator it4( ListView4 ); | 877 | QListViewItemIterator it4( ListView4 ); |
873 | QListViewItemIterator it5( ListView5 ); | 878 | QListViewItemIterator it5( ListView5 ); |
874 | 879 | ||
875 | // iterate through all items of the listview | 880 | // iterate through all items of the listview |
876 | for ( ; it1.current(); ++it1 ) { | 881 | for ( ; it1.current(); ++it1 ) { |
877 | if ( it1.current()->isSelected() ) | 882 | if ( it1.current()->isSelected() ) |
878 | getItem(it1.current()); | 883 | getItem(it1.current()); |
879 | it1.current()->setSelected(FALSE); | 884 | it1.current()->setSelected(FALSE); |
880 | } | 885 | } |
881 | for ( ; it2.current(); ++it2 ) { | 886 | for ( ; it2.current(); ++it2 ) { |
882 | if ( it2.current()->isSelected() ) | 887 | if ( it2.current()->isSelected() ) |
883 | getItem(it2.current()); | 888 | getItem(it2.current()); |
884 | it2.current()->setSelected(FALSE); | 889 | it2.current()->setSelected(FALSE); |
885 | } | 890 | } |
886 | for ( ; it3.current(); ++it3 ) { | 891 | for ( ; it3.current(); ++it3 ) { |
887 | if ( it3.current()->isSelected() ) | 892 | if ( it3.current()->isSelected() ) |
888 | getItem(it3.current()); | 893 | getItem(it3.current()); |
889 | it3.current()->setSelected(FALSE); | 894 | it3.current()->setSelected(FALSE); |
890 | } | 895 | } |
891 | for ( ; it4.current(); ++it4 ) { | 896 | for ( ; it4.current(); ++it4 ) { |
892 | if ( it4.current()->isSelected() ) | 897 | if ( it4.current()->isSelected() ) |
893 | getItem(it4.current()); | 898 | getItem(it4.current()); |
894 | it4.current()->setSelected(FALSE); | 899 | it4.current()->setSelected(FALSE); |
895 | } | 900 | } |
896 | for ( ; it5.current(); ++it5 ) { | 901 | for ( ; it5.current(); ++it5 ) { |
897 | if ( it5.current()->isSelected() ) | 902 | if ( it5.current()->isSelected() ) |
898 | getItem(it5.current()); | 903 | getItem(it5.current()); |
899 | it5.current()->setSelected(FALSE); | 904 | it5.current()->setSelected(FALSE); |
900 | } | 905 | } |
901 | return true; | 906 | return true; |
902 | } | 907 | } |
903 | 908 | ||
904 | 909 | ||
905 | /* | 910 | /* |
906 | handles the sorting combo box */ | 911 | handles the sorting combo box */ |
907 | void LibraryDialog::comboSelect(int index) | 912 | void LibraryDialog::comboSelect(int index) |
908 | { | 913 | { |
909 | // odebug << "we are sorting" << oendl; | 914 | // odebug << "we are sorting" << oendl; |
910 | ListView1->setSorting( index, TRUE); | 915 | ListView1->setSorting( index, TRUE); |
911 | ListView2->setSorting( index, TRUE); | 916 | ListView2->setSorting( index, TRUE); |
912 | ListView3->setSorting( index, TRUE); | 917 | ListView3->setSorting( index, TRUE); |
913 | ListView4->setSorting( index, TRUE); | 918 | ListView4->setSorting( index, TRUE); |
914 | ListView5->setSorting( index, TRUE); | 919 | ListView5->setSorting( index, TRUE); |
915 | 920 | ||
916 | ListView1->sort(); | 921 | ListView1->sort(); |
917 | ListView2->sort(); | 922 | ListView2->sort(); |
918 | ListView3->sort(); | 923 | ListView3->sort(); |
919 | ListView4->sort(); | 924 | ListView4->sort(); |
920 | ListView5->sort(); | 925 | ListView5->sort(); |
921 | 926 | ||
922 | // ListView1->triggerUpdate(); | 927 | // ListView1->triggerUpdate(); |
923 | // ListView2->triggerUpdate(); | 928 | // ListView2->triggerUpdate(); |
924 | // ListView3->triggerUpdate(); | 929 | // ListView3->triggerUpdate(); |
925 | // ListView4->triggerUpdate(); | 930 | // ListView4->triggerUpdate(); |
926 | // ListView5->triggerUpdate(); | 931 | // ListView5->triggerUpdate(); |
927 | } | 932 | } |
928 | 933 | ||
929 | void LibraryDialog::newList() | 934 | void LibraryDialog::newList() |
930 | { | 935 | { |
931 | if(indexLoaded) { | 936 | if(indexLoaded) { |
932 | onButtonDownload(); | 937 | onButtonDownload(); |
933 | } else { | 938 | } else { |
934 | Output *outDlg; | 939 | Output *outDlg; |
935 | buttonNewList->setDown(TRUE); | 940 | buttonNewList->setDown(TRUE); |
936 | QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser"); | 941 | QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser"); |
937 | if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true); | 942 | if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true); |
938 | if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) { | 943 | if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) { |
939 | odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl; | 944 | odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl; |
940 | QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; | 945 | QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
941 | QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; | 946 | QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; |
942 | 947 | ||
943 | int result = QMessageBox::warning( this,"Download" | 948 | int result = QMessageBox::warning( this,"Download" |
944 | ,"<p>Ok to use /'wget/' to download a new library list?</P>" | 949 | ,"<p>Ok to use /'wget/' to download a new library list?</P>" |
945 | ,"Yes","No",0,0,1); | 950 | ,"Yes","No",0,0,1); |
946 | qApp->processEvents(); | 951 | qApp->processEvents(); |
947 | if(result == 0) { | 952 | if(result == 0) { |
948 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); | 953 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); |
949 | outDlg->showMaximized(); | 954 | outDlg->showMaximized(); |
950 | outDlg->show(); | 955 | outDlg->show(); |
951 | qApp->processEvents(); | 956 | qApp->processEvents(); |
952 | FILE *fp; | 957 | FILE *fp; |
953 | char line[130]; | 958 | char line[130]; |
954 | outDlg->OutputEdit->append( tr("Running wget") ); | 959 | outDlg->OutputEdit->append( tr("Running wget") ); |
955 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 960 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
956 | sleep(1); | 961 | sleep(1); |
957 | fp = popen( (const char *) cmd, "r"); | 962 | fp = popen( (const char *) cmd, "r"); |
958 | if ( !fp ) { | 963 | if ( !fp ) { |
959 | } else { | 964 | } else { |
960 | odebug << "Issuing the command\n"+cmd << oendl; | 965 | odebug << "Issuing the command\n"+cmd << oendl; |
961 | // system(cmd); | 966 | // system(cmd); |
962 | while ( fgets( line, sizeof line, fp)) { | 967 | while ( fgets( line, sizeof line, fp)) { |
963 | outDlg->OutputEdit->append(line); | 968 | outDlg->OutputEdit->append(line); |
964 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 969 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
965 | } | 970 | } |
966 | pclose(fp); | 971 | pclose(fp); |
967 | outDlg->OutputEdit->append("Finished downloading\n"); | 972 | outDlg->OutputEdit->append("Finished downloading\n"); |
968 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 973 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
969 | qApp->processEvents(); | 974 | qApp->processEvents(); |
970 | 975 | ||
971 | // if( QFile(gutenindex1).exists() ) { | 976 | // if( QFile(gutenindex1).exists() ) { |
972 | // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; | 977 | // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
973 | // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) | 978 | // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) |
974 | // odebug << "renaming error" << oendl; | 979 | // odebug << "renaming error" << oendl; |
975 | // } | 980 | // } |
976 | 981 | ||
977 | } | 982 | } |
978 | // outDlg->close(); | 983 | // outDlg->close(); |
979 | FindLibrary(); | 984 | FindLibrary(); |
980 | if(outDlg) delete outDlg; | 985 | if(outDlg) delete outDlg; |
981 | } | 986 | } |
982 | buttonNewList->setDown(FALSE); | 987 | buttonNewList->setDown(FALSE); |
983 | } else { | 988 | } else { |
984 | QMessageBox::message("Note","Could not change directories"); | 989 | QMessageBox::message("Note","Could not change directories"); |
985 | } | 990 | } |
986 | // if(outDlg) | 991 | // if(outDlg) |
987 | // delete outDlg; | 992 | // delete outDlg; |
988 | } | 993 | } |
989 | } | 994 | } |
990 | 995 | ||
991 | bool LibraryDialog::moreInfo() | 996 | bool LibraryDialog::moreInfo() |
992 | { | 997 | { |
993 | 998 | ||
994 | QListViewItem * item; | 999 | QListViewItem * item; |
995 | item = 0; | 1000 | item = 0; |
996 | QString titleString; | 1001 | QString titleString; |
997 | item = ListView1->currentItem(); | 1002 | item = ListView1->currentItem(); |
998 | if( item != 0) { | 1003 | if( item != 0) { |
999 | titleString = item->text(0); | 1004 | titleString = item->text(0); |
1000 | ListView1->clearSelection(); | 1005 | ListView1->clearSelection(); |
1001 | item = 0; | 1006 | item = 0; |
1002 | } | 1007 | } |
1003 | if( item == 0) | 1008 | if( item == 0) |
1004 | item = ListView2->currentItem(); | 1009 | item = ListView2->currentItem(); |
1005 | if( item != 0) { | 1010 | if( item != 0) { |
1006 | titleString = item->text(0); | 1011 | titleString = item->text(0); |
1007 | ListView2->clearSelection(); | 1012 | ListView2->clearSelection(); |
1008 | item = 0; | 1013 | item = 0; |
1009 | } | 1014 | } |
1010 | if( item == 0) | 1015 | if( item == 0) |
1011 | item = ListView3->currentItem(); | 1016 | item = ListView3->currentItem(); |
1012 | if( item != 0) { | 1017 | if( item != 0) { |
1013 | titleString = item->text(0); | 1018 | titleString = item->text(0); |
1014 | ListView3->clearSelection(); | 1019 | ListView3->clearSelection(); |
1015 | item = 0; | 1020 | item = 0; |
1016 | } | 1021 | } |
1017 | if( item == 0) | 1022 | if( item == 0) |
1018 | item = ListView4->currentItem(); | 1023 | item = ListView4->currentItem(); |
1019 | if( item != 0) { | 1024 | if( item != 0) { |
1020 | titleString = item->text(0); | 1025 | titleString = item->text(0); |
1021 | ListView4->clearSelection(); | 1026 | ListView4->clearSelection(); |
1022 | item = 0; | 1027 | item = 0; |
1023 | } | 1028 | } |
1024 | if( item == 0) | 1029 | if( item == 0) |
1025 | item = ListView5->currentItem(); | 1030 | item = ListView5->currentItem(); |
1026 | if( item != 0) { | 1031 | if( item != 0) { |
1027 | titleString = item->text(0); | 1032 | titleString = item->text(0); |
1028 | ListView5->clearSelection(); | 1033 | ListView5->clearSelection(); |
1029 | item = 0; | 1034 | item = 0; |
1030 | } | 1035 | } |
1031 | item=0; | 1036 | item=0; |
1032 | if(titleString.length()>2) { | 1037 | if(titleString.length()>2) { |
1033 | odebug << "Title is "+titleString << oendl; | 1038 | odebug << "Title is "+titleString << oendl; |
1034 | titleString.replace( QRegExp("\\s"), "%20"); | 1039 | titleString.replace( QRegExp("\\s"), "%20"); |
1035 | titleString.replace( QRegExp("'"), "%20"); | 1040 | titleString.replace( QRegExp("'"), "%20"); |
1036 | titleString.replace( QRegExp("\""), "%20"); | 1041 | titleString.replace( QRegExp("\""), "%20"); |
1037 | titleString.replace( QRegExp("&"), "%20"); | 1042 | titleString.replace( QRegExp("&"), "%20"); |
1038 | QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search"; | 1043 | QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search"; |
1039 | cmd="opera "+cmd; | 1044 | cmd="opera "+cmd; |
1040 | system(cmd); | 1045 | system(cmd); |
1041 | } else | 1046 | } else |
1042 | QMessageBox::message( "Note","<p>If you select a title, this will search google.com for that title.</p>"); | 1047 | QMessageBox::message( "Note","<p>If you select a title, this will search google.com for that title.</p>"); |
1043 | return true; | 1048 | return true; |
1044 | 1049 | ||
1045 | } | 1050 | } |
1046 | 1051 | ||
1047 | /* | 1052 | /* |
1048 | This loads the library Index*/ | 1053 | This loads the library Index*/ |
1049 | void LibraryDialog::FindLibrary() | 1054 | void LibraryDialog::FindLibrary() |
1050 | { | 1055 | { |
1051 | buttonLibrary->setDown(TRUE); | 1056 | buttonLibrary->setDown(TRUE); |
1052 | 1057 | ||
1053 | qApp->processEvents(); | 1058 | qApp->processEvents(); |
1054 | if( QFile( new_index).exists() /* && this->isHidden() */) { | 1059 | if( QFile( new_index).exists() /* && this->isHidden() */) { |
1055 | newindexLib.setName( new_index); | 1060 | newindexLib.setName( new_index); |
1056 | indexLib.setName( new_index); | 1061 | indexLib.setName( new_index); |
1057 | odebug << "index file is "+ new_index << oendl; | 1062 | odebug << "index file is "+ new_index << oendl; |
1058 | Newlibrary(); | 1063 | Newlibrary(); |
1059 | } else { | 1064 | } else { |
1060 | newindexLib.setName( old_index); | 1065 | newindexLib.setName( old_index); |
1061 | indexLib.setName( old_index); | 1066 | indexLib.setName( old_index); |
1062 | odebug << "new index nameis "+ old_index << oendl; | 1067 | odebug << "new index nameis "+ old_index << oendl; |
1063 | Library(); | 1068 | Library(); |
1064 | } | 1069 | } |
1065 | indexLoaded=true; | 1070 | indexLoaded=true; |
1066 | buttonSearch->setEnabled(TRUE); | 1071 | buttonSearch->setEnabled(TRUE); |
1067 | moreInfoButton->setEnabled(TRUE); | 1072 | moreInfoButton->setEnabled(TRUE); |
1068 | 1073 | ||
1069 | buttonLibrary->setDown(FALSE); | 1074 | buttonLibrary->setDown(FALSE); |
1070 | buttonNewList->setText("Download"); | 1075 | buttonNewList->setText("Download"); |
1071 | qApp->processEvents(); | 1076 | qApp->processEvents(); |
1072 | 1077 | ||
1073 | } | 1078 | } |