summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp19
-rw-r--r--noncore/settings/aqpkg/mainwin.h1
2 files changed, 14 insertions, 6 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index 58f6feb..f0e8e48 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -375,784 +375,791 @@ void MainWindow :: repeatFind()
375 375
376void MainWindow :: findPackage( const QString &text ) 376void MainWindow :: findPackage( const QString &text )
377{ 377{
378 actionFindNext->setEnabled( !text.isEmpty() ); 378 actionFindNext->setEnabled( !text.isEmpty() );
379 searchForPackage( text ); 379 searchForPackage( text );
380} 380}
381 381
382void MainWindow :: hideFindBar() 382void MainWindow :: hideFindBar()
383{ 383{
384 findBar->hide(); 384 findBar->hide();
385} 385}
386 386
387void MainWindow :: hideJumpBar() 387void MainWindow :: hideJumpBar()
388{ 388{
389 jumpBar->hide(); 389 jumpBar->hide();
390} 390}
391 391
392void MainWindow :: filterUninstalledPackages() 392void MainWindow :: filterUninstalledPackages()
393{ 393{
394 showUninstalledPkgs = actionUninstalled->isOn(); 394 showUninstalledPkgs = actionUninstalled->isOn();
395 if ( showUninstalledPkgs ) 395 if ( showUninstalledPkgs )
396 { 396 {
397 showInstalledPkgs = FALSE; 397 showInstalledPkgs = FALSE;
398 showUpgradedPkgs = FALSE; 398 showUpgradedPkgs = FALSE;
399 } 399 }
400 serverSelected( -1 ); 400 serverSelected( -1 );
401 401
402 actionInstalled->setOn( FALSE ); 402 actionInstalled->setOn( FALSE );
403 actionUpdated->setOn( FALSE ); 403 actionUpdated->setOn( FALSE );
404} 404}
405 405
406void MainWindow :: filterInstalledPackages() 406void MainWindow :: filterInstalledPackages()
407{ 407{
408 showInstalledPkgs = actionInstalled->isOn(); 408 showInstalledPkgs = actionInstalled->isOn();
409 if ( showInstalledPkgs ) 409 if ( showInstalledPkgs )
410 { 410 {
411 showUninstalledPkgs = FALSE; 411 showUninstalledPkgs = FALSE;
412 showUpgradedPkgs = FALSE; 412 showUpgradedPkgs = FALSE;
413 } 413 }
414 serverSelected( -1 ); 414 serverSelected( -1 );
415 415
416 actionUninstalled->setOn( FALSE ); 416 actionUninstalled->setOn( FALSE );
417 actionUpdated->setOn( FALSE ); 417 actionUpdated->setOn( FALSE );
418} 418}
419 419
420void MainWindow :: filterUpgradedPackages() 420void MainWindow :: filterUpgradedPackages()
421{ 421{
422 showUpgradedPkgs = actionUpdated->isOn(); 422 showUpgradedPkgs = actionUpdated->isOn();
423 if ( showUpgradedPkgs ) 423 if ( showUpgradedPkgs )
424 { 424 {
425 showUninstalledPkgs = FALSE; 425 showUninstalledPkgs = FALSE;
426 showInstalledPkgs = FALSE; 426 showInstalledPkgs = FALSE;
427 } 427 }
428 serverSelected( -1 ); 428 serverSelected( -1 );
429 429
430 actionUninstalled->setOn( FALSE ); 430 actionUninstalled->setOn( FALSE );
431 actionInstalled->setOn( FALSE ); 431 actionInstalled->setOn( FALSE );
432} 432}
433 433
434bool MainWindow :: setFilterCategory() 434bool MainWindow :: setFilterCategory()
435{ 435{
436 // Get categories; 436 // Get categories;
437 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); 437 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this );
438 if ( dlg.exec() == QDialog::Accepted ) 438 if ( dlg.exec() == QDialog::Accepted )
439 { 439 {
440 categoryFilter = dlg.getSelectedFilter(); 440 categoryFilter = dlg.getSelectedFilter();
441 441
442 if ( categoryFilter == "" ) 442 if ( categoryFilter == "" )
443 return false; 443 return false;
444 444
445 categoryFilterEnabled = true; 445 categoryFilterEnabled = true;
446 serverSelected( -1 ); 446 serverSelected( -1 );
447 actionFilter->setOn( TRUE ); 447 actionFilter->setOn( TRUE );
448 return true; 448 return true;
449 } 449 }
450 450
451 return false; 451 return false;
452} 452}
453 453
454void MainWindow :: filterCategory() 454void MainWindow :: filterCategory()
455{ 455{
456 if ( !actionFilter->isOn() ) 456 if ( !actionFilter->isOn() )
457 { 457 {
458 filterByCategory( FALSE ); 458 filterByCategory( FALSE );
459 } 459 }
460 else 460 else
461 { 461 {
462 actionFilter->setOn( filterByCategory( TRUE ) ); 462 actionFilter->setOn( filterByCategory( TRUE ) );
463 } 463 }
464} 464}
465 465
466bool MainWindow :: filterByCategory( bool val ) 466bool MainWindow :: filterByCategory( bool val )
467{ 467{
468 if ( val ) 468 if ( val )
469 { 469 {
470 if ( categoryFilter == "" ) 470 if ( categoryFilter == "" )
471 { 471 {
472 if ( !setFilterCategory() ) 472 if ( !setFilterCategory() )
473 return false; 473 return false;
474 } 474 }
475 475
476 categoryFilterEnabled = true; 476 categoryFilterEnabled = true;
477 serverSelected( -1 ); 477 serverSelected( -1 );
478 return true; 478 return true;
479 } 479 }
480 else 480 else
481 { 481 {
482 // Turn off filter 482 // Turn off filter
483 categoryFilterEnabled = false; 483 categoryFilterEnabled = false;
484 serverSelected( -1 ); 484 serverSelected( -1 );
485 return false; 485 return false;
486 } 486 }
487} 487}
488 488
489void MainWindow :: raiseMainWidget() 489void MainWindow :: raiseMainWidget()
490{ 490{
491 stack->raiseWidget( networkPkgWindow ); 491 stack->raiseWidget( networkPkgWindow );
492} 492}
493 493
494void MainWindow :: raiseProgressWidget() 494void MainWindow :: raiseProgressWidget()
495{ 495{
496 stack->raiseWidget( progressWindow ); 496 stack->raiseWidget( progressWindow );
497} 497}
498 498
499void MainWindow :: enableUpgrade( bool enabled ) 499void MainWindow :: enableUpgrade( bool enabled )
500{ 500{
501 actionUpgrade->setEnabled( enabled ); 501 actionUpgrade->setEnabled( enabled );
502} 502}
503 503
504void MainWindow :: enableDownload( bool enabled ) 504void MainWindow :: enableDownload( bool enabled )
505{ 505{
506 if ( enabled ) 506 if ( enabled )
507 { 507 {
508 actionDownload->setIconSet( iconDownload ); 508 actionDownload->setIconSet( iconDownload );
509 actionDownload->setText( tr( "Download" ) ); 509 actionDownload->setText( tr( "Download" ) );
510 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 510 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
511 } 511 }
512 else 512 else
513 { 513 {
514 actionDownload->setIconSet( iconRemove ); 514 actionDownload->setIconSet( iconRemove );
515 actionDownload->setText( tr( "Remove" ) ); 515 actionDownload->setText( tr( "Remove" ) );
516 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); 516 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) );
517 } 517 }
518} 518}
519 519
520void MainWindow :: setProgressSteps( int numsteps ) 520void MainWindow :: setProgressSteps( int numsteps )
521{ 521{
522 m_progress->setTotalSteps( numsteps ); 522 m_progress->setTotalSteps( numsteps );
523} 523}
524 524
525void MainWindow :: setProgressMessage( const QString &msg ) 525void MainWindow :: setProgressMessage( const QString &msg )
526{ 526{
527 m_status->setText( msg ); 527 m_status->setText( msg );
528} 528}
529 529
530void MainWindow :: updateProgress( int progress ) 530void MainWindow :: updateProgress( int progress )
531{ 531{
532 m_progress->setProgress( progress ); 532 m_progress->setProgress( progress );
533} 533}
534 534
535void MainWindow :: updateData() 535void MainWindow :: updateData()
536{ 536{
537 m_progress->setTotalSteps( mgr->getServerList().count() ); 537 m_progress->setTotalSteps( mgr->getServerList().count() );
538 538
539 serversList->clear(); 539 serversList->clear();
540 packagesList->clear(); 540 packagesList->clear();
541 541
542 int activeItem = -1; 542 int activeItem = -1;
543 int i = 0; 543 int i = 0;
544 QString serverName; 544 QString serverName;
545 545
546 QListIterator<Server> it( mgr->getServerList() ); 546 QListIterator<Server> it( mgr->getServerList() );
547 Server *server; 547 Server *server;
548 548
549 for ( ; it.current(); ++it, ++i ) 549 for ( ; it.current(); ++it, ++i )
550 { 550 {
551 server = it.current(); 551 server = it.current();
552 serverName = server->getServerName(); 552 serverName = server->getServerName();
553 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); 553 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) );
554 m_progress->setProgress( i ); 554 m_progress->setProgress( i );
555 qApp->processEvents(); 555 qApp->processEvents();
556 556
557// cout << "Adding " << it->getServerName() << " to combobox" << endl; 557// cout << "Adding " << it->getServerName() << " to combobox" << endl;
558 if ( !server->isServerActive() ) 558 if ( !server->isServerActive() )
559 { 559 {
560// cout << serverName << " is not active" << endl; 560// cout << serverName << " is not active" << endl;
561 i--; 561 i--;
562 continue; 562 continue;
563 } 563 }
564 564
565 serversList->insertItem( serverName ); 565 serversList->insertItem( serverName );
566 if ( serverName == currentlySelectedServer ) 566 if ( serverName == currentlySelectedServer )
567 activeItem = i; 567 activeItem = i;
568 } 568 }
569 569
570 // set selected server to be active server 570 // set selected server to be active server
571 if ( activeItem != -1 ) 571 if ( activeItem != -1 )
572 serversList->setCurrentItem( activeItem ); 572 serversList->setCurrentItem( activeItem );
573 serverSelected( 0, FALSE ); 573 serverSelected( 0, FALSE );
574} 574}
575 575
576void MainWindow :: serverSelected( int index ) 576void MainWindow :: serverSelected( int index )
577{ 577{
578 serverSelected( index, TRUE ); 578 serverSelected( index, TRUE );
579} 579}
580 580
581void MainWindow :: serverSelected( int, bool raiseProgress ) 581void MainWindow :: serverSelected( int, bool raiseProgress )
582{ 582{
583 QPixmap nullIcon( installedIcon.size() ); 583 QPixmap nullIcon( installedIcon.size() );
584 nullIcon.fill( colorGroup().base() ); 584 nullIcon.fill( colorGroup().base() );
585 585
586 // display packages 586 // display packages
587 QString serverName = serversList->currentText(); 587 QString serverName = serversList->currentText();
588 currentlySelectedServer = serverName; 588 currentlySelectedServer = serverName;
589 589
590 Server *s = mgr->getServer( serverName ); 590 Server *s = mgr->getServer( serverName );
591 591
592 QList<Package> &list = s->getPackageList(); 592 QList<Package> &list = s->getPackageList();
593 QListIterator<Package> it( list ); 593 QListIterator<Package> it( list );
594 594
595 // Display progress widget while loading list 595 // Display progress widget while loading list
596 bool doProgress = ( list.count() > 200 ); 596 bool doProgress = ( list.count() > 200 );
597 if ( doProgress ) 597 if ( doProgress )
598 { 598 {
599 if ( raiseProgress ) 599 if ( raiseProgress )
600 { 600 {
601 stack->raiseWidget( progressWindow ); 601 stack->raiseWidget( progressWindow );
602 } 602 }
603 m_progress->setTotalSteps( list.count() ); 603 m_progress->setTotalSteps( list.count() );
604 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); 604 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
605 } 605 }
606 606
607 packagesList->clear(); 607 packagesList->clear();
608 608
609#ifdef QWS 609#ifdef QWS
610 // read download directory from config file 610 // read download directory from config file
611 Config cfg( "aqpkg" ); 611 Config cfg( "aqpkg" );
612 cfg.setGroup( "settings" ); 612 cfg.setGroup( "settings" );
613 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 613 cfg.writeEntry( "selectedServer", currentlySelectedServer );
614#endif 614#endif
615 615
616 int i = 0; 616 int i = 0;
617 Package *package; 617 Package *package;
618 for ( ; it.current(); ++it ) 618 for ( ; it.current(); ++it )
619 { 619 {
620 // Update progress after every 100th package (arbitrary value, seems to give good balance) 620 // Update progress after every 100th package (arbitrary value, seems to give good balance)
621 i++; 621 i++;
622 if ( ( i % 100 ) == 0 ) 622 if ( ( i % 100 ) == 0 )
623 { 623 {
624 if ( doProgress ) 624 if ( doProgress )
625 { 625 {
626 m_progress->setProgress( i ); 626 m_progress->setProgress( i );
627 } 627 }
628 qApp->processEvents(); 628 qApp->processEvents();
629 } 629 }
630 630
631 QString text = ""; 631 QString text = "";
632 632
633 package = it.current(); 633 package = it.current();
634 634
635 // Apply show only uninstalled packages filter 635 // Apply show only uninstalled packages filter
636 if ( showUninstalledPkgs && package->isInstalled() ) 636 if ( showUninstalledPkgs && package->isInstalled() )
637 continue; 637 continue;
638 638
639 // Apply show only installed packages filter 639 // Apply show only installed packages filter
640 if ( showInstalledPkgs && !package->isInstalled() ) 640 if ( showInstalledPkgs && !package->isInstalled() )
641 continue; 641 continue;
642 642
643 // Apply show only new installed packages filter 643 // Apply show only new installed packages filter
644 if ( showUpgradedPkgs ) 644 if ( showUpgradedPkgs )
645 { 645 {
646 if ( !package->isInstalled() || !package->getNewVersionAvailable() ) 646 if ( !package->isInstalled() || !package->getNewVersionAvailable() )
647 continue; 647 continue;
648 } 648 }
649 649
650 // Apply the section filter 650 // Apply the section filter
651 if ( categoryFilterEnabled && categoryFilter != "" ) 651 if ( categoryFilterEnabled && categoryFilter != "" )
652 { 652 {
653 if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) 653 if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 )
654 continue; 654 continue;
655 } 655 }
656 656
657 // If the local server, only display installed packages 657 // If the local server, only display installed packages
658 if ( serverName == LOCAL_SERVER && !package->isInstalled() ) 658 if ( serverName == LOCAL_SERVER && !package->isInstalled() )
659 continue; 659 continue;
660 660
661 661
662 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), 662 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(),
663 QCheckListItem::CheckBox ); 663 QCheckListItem::CheckBox );
664 664
665 if ( package->isInstalled() ) 665 if ( package->isInstalled() )
666 { 666 {
667 // If a different version of package is available, show update available icon 667 // If a different version of package is available, show update available icon
668 // Otherwise, show installed icon 668 // Otherwise, show installed icon
669 if ( package->getNewVersionAvailable()) 669 if ( package->getNewVersionAvailable())
670 { 670 {
671 671
672 item->setPixmap( 0, updatedIcon ); 672 item->setPixmap( 0, updatedIcon );
673 } 673 }
674 else 674 else
675 { 675 {
676 item->setPixmap( 0, installedIcon ); 676 item->setPixmap( 0, installedIcon );
677 } 677 }
678 } 678 }
679 else 679 else
680 { 680 {
681 item->setPixmap( 0, nullIcon ); 681 item->setPixmap( 0, nullIcon );
682 } 682 }
683 683
684 packagesList->insertItem( item ); 684 packagesList->insertItem( item );
685 } 685 }
686 686
687 // If the local server or the local ipkgs server disable the download button 687 // If the local server or the local ipkgs server disable the download button
688 if ( serverName == LOCAL_SERVER ) 688 if ( serverName == LOCAL_SERVER )
689 { 689 {
690 downloadEnabled = TRUE; 690 downloadEnabled = TRUE;
691 actionUpgrade->setEnabled( FALSE ); 691 actionUpgrade->setEnabled( FALSE );
692 } 692 }
693 else if ( serverName == LOCAL_IPKGS ) 693 else if ( serverName == LOCAL_IPKGS )
694 { 694 {
695 downloadEnabled = FALSE; 695 downloadEnabled = FALSE;
696 actionUpgrade->setEnabled( FALSE ); 696 actionUpgrade->setEnabled( FALSE );
697 } 697 }
698 else 698 else
699 { 699 {
700 downloadEnabled = TRUE; 700 downloadEnabled = TRUE;
701 actionUpgrade->setEnabled( TRUE ); 701 actionUpgrade->setEnabled( TRUE );
702 } 702 }
703 enableDownload( downloadEnabled ); 703 enableDownload( downloadEnabled );
704 704
705 // Display this widget once everything is done 705 // Display this widget once everything is done
706 if ( doProgress && raiseProgress ) 706 if ( doProgress && raiseProgress )
707 { 707 {
708 stack->raiseWidget( networkPkgWindow ); 708 stack->raiseWidget( networkPkgWindow );
709 } 709 }
710} 710}
711 711
712void MainWindow :: searchForPackage( const QString &text ) 712void MainWindow :: searchForPackage( const QString &text )
713{ 713{
714 if ( !text.isEmpty() ) 714 if ( !text.isEmpty() )
715 { 715 {
716// cout << "searching for " << text << endl; 716// cout << "searching for " << text << endl;
717 // look through package list for text startng at current position 717 // look through package list for text startng at current position
718// vector<InstallData> workingPackages; 718// vector<InstallData> workingPackages;
719 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 719 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
720// if ( start != 0 ) 720// if ( start != 0 )
721// start = (QCheckListItem *)start->nextSibling(); 721// start = (QCheckListItem *)start->nextSibling();
722 722
723 if ( start == 0 ) 723 if ( start == 0 )
724 start = (QCheckListItem *)packagesList->firstChild(); 724 start = (QCheckListItem *)packagesList->firstChild();
725 725
726 for ( QCheckListItem *item = start; item != 0 ; 726 for ( QCheckListItem *item = start; item != 0 ;
727 item = (QCheckListItem *)item->nextSibling() ) 727 item = (QCheckListItem *)item->nextSibling() )
728 { 728 {
729// cout << "checking " << item->text().lower() << endl; 729// cout << "checking " << item->text().lower() << endl;
730 if ( item->text().lower().find( text ) != -1 ) 730 if ( item->text().lower().find( text ) != -1 )
731 { 731 {
732// cout << "matched " << item->text() << endl; 732// cout << "matched " << item->text() << endl;
733 packagesList->ensureItemVisible( item ); 733 packagesList->ensureItemVisible( item );
734 packagesList->setCurrentItem( item ); 734 packagesList->setCurrentItem( item );
735 break; 735 break;
736 } 736 }
737 } 737 }
738 } 738 }
739} 739}
740 740
741void MainWindow :: updateServer() 741void MainWindow :: updateServer()
742{ 742{
743 QString serverName = serversList->currentText(); 743 QString serverName = serversList->currentText();
744 744
745 // Update the current server 745 // Update the current server
746 // Display dialog 746 // Display dialog
747 747
748 // Disable buttons to stop silly people clicking lots on them :) 748 // Disable buttons to stop silly people clicking lots on them :)
749 749
750 // First, write out ipkg_conf file so that ipkg can use it 750 // First, write out ipkg_conf file so that ipkg can use it
751 mgr->writeOutIpkgConf(); 751 mgr->writeOutIpkgConf();
752 752
753 Ipkg *ipkg = new Ipkg; 753 Ipkg *ipkg = new Ipkg;
754 ipkg->setOption( "update" ); 754 ipkg->setOption( "update" );
755 755
756 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), 756 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ),
757 tr( "Update lists" ) ); 757 tr( "Update lists" ) );
758 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 758 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
759 reloadDocuments = FALSE;
759 stack->addWidget( dlg, 3 ); 760 stack->addWidget( dlg, 3 );
760 stack->raiseWidget( dlg ); 761 stack->raiseWidget( dlg );
761 762
762// delete progDlg; 763// delete progDlg;
763} 764}
764 765
765void MainWindow :: upgradePackages() 766void MainWindow :: upgradePackages()
766{ 767{
767 // We're gonna do an upgrade of all packages 768 // We're gonna do an upgrade of all packages
768 // First warn user that this isn't recommended 769 // First warn user that this isn't recommended
769 // TODO - ODevice???? 770 // TODO - ODevice????
770 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); 771 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
771 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, 772 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
772 QMessageBox::Yes, 773 QMessageBox::Yes,
773 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 774 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
774 0, this ); 775 0, this );
775 warn.adjustSize(); 776 warn.adjustSize();
776 777
777 if ( warn.exec() == QMessageBox::Yes ) 778 if ( warn.exec() == QMessageBox::Yes )
778 { 779 {
779 // First, write out ipkg_conf file so that ipkg can use it 780 // First, write out ipkg_conf file so that ipkg can use it
780 mgr->writeOutIpkgConf(); 781 mgr->writeOutIpkgConf();
781 782
782 // Now run upgrade 783 // Now run upgrade
783 Ipkg *ipkg = new Ipkg; 784 Ipkg *ipkg = new Ipkg;
784 ipkg->setOption( "upgrade" ); 785 ipkg->setOption( "upgrade" );
785 786
786 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), 787 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ),
787 tr ( "Upgrade" ) ); 788 tr ( "Upgrade" ) );
788 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 789 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
790 reloadDocuments = TRUE;
789 stack->addWidget( dlg, 3 ); 791 stack->addWidget( dlg, 3 );
790 stack->raiseWidget( dlg ); 792 stack->raiseWidget( dlg );
791 } 793 }
792} 794}
793 795
794void MainWindow :: downloadPackage() 796void MainWindow :: downloadPackage()
795{ 797{
796 bool doUpdate = true; 798 bool doUpdate = true;
797 if ( downloadEnabled ) 799 if ( downloadEnabled )
798 { 800 {
799 // See if any packages are selected 801 // See if any packages are selected
800 bool found = false; 802 bool found = false;
801 if ( serversList->currentText() != LOCAL_SERVER ) 803 if ( serversList->currentText() != LOCAL_SERVER )
802 { 804 {
803 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 805 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
804 item != 0 && !found; 806 item != 0 && !found;
805 item = (QCheckListItem *)item->nextSibling() ) 807 item = (QCheckListItem *)item->nextSibling() )
806 { 808 {
807 if ( item->isOn() ) 809 if ( item->isOn() )
808 found = true; 810 found = true;
809 } 811 }
810 } 812 }
811 813
812 // If user selected some packages then download the and store the locally 814 // If user selected some packages then download the and store the locally
813 // otherwise, display dialog asking user what package to download from an http server 815 // otherwise, display dialog asking user what package to download from an http server
814 // and whether to install it 816 // and whether to install it
815 if ( found ) 817 if ( found )
816 downloadSelectedPackages(); 818 downloadSelectedPackages();
817 else 819 else
818 downloadRemotePackage(); 820 downloadRemotePackage();
819 821
820 } 822 }
821 else 823 else
822 { 824 {
823 doUpdate = false; 825 doUpdate = false;
824 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 826 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
825 item != 0 ; 827 item != 0 ;
826 item = (QCheckListItem *)item->nextSibling() ) 828 item = (QCheckListItem *)item->nextSibling() )
827 { 829 {
828 if ( item->isOn() ) 830 if ( item->isOn() )
829 { 831 {
830 QString name = item->text(); 832 QString name = item->text();
831 int pos = name.find( "*" ); 833 int pos = name.find( "*" );
832 name.truncate( pos ); 834 name.truncate( pos );
833 835
834 // if (there is a (installed), remove it 836 // if (there is a (installed), remove it
835 pos = name.find( "(installed)" ); 837 pos = name.find( "(installed)" );
836 if ( pos > 0 ) 838 if ( pos > 0 )
837 name.truncate( pos - 1 ); 839 name.truncate( pos - 1 );
838 840
839 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); 841 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name );
840 842
841 QString msgtext; 843 QString msgtext;
842 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); 844 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
843 if ( QMessageBox::information( this, tr( "Are you sure?" ), 845 if ( QMessageBox::information( this, tr( "Are you sure?" ),
844 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) 846 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
845 { 847 {
846 doUpdate = true; 848 doUpdate = true;
847 QFile f( p->getFilename() ); 849 QFile f( p->getFilename() );
848 f.remove(); 850 f.remove();
849 } 851 }
850 } 852 }
851 } 853 }
852 } 854 }
853 855
854 if ( doUpdate ) 856 if ( doUpdate )
855 { 857 {
856 reloadData( 0x0 ); 858 reloadData( 0x0 );
857 } 859 }
858} 860}
859 861
860void MainWindow :: downloadSelectedPackages() 862void MainWindow :: downloadSelectedPackages()
861{ 863{
862 // First, write out ipkg_conf file so that ipkg can use it 864 // First, write out ipkg_conf file so that ipkg can use it
863 mgr->writeOutIpkgConf(); 865 mgr->writeOutIpkgConf();
864 866
865 // Display dialog to user asking where to download the files to 867 // Display dialog to user asking where to download the files to
866 bool ok = FALSE; 868 bool ok = FALSE;
867 QString dir = ""; 869 QString dir = "";
868#ifdef QWS 870#ifdef QWS
869 // read download directory from config file 871 // read download directory from config file
870 Config cfg( "aqpkg" ); 872 Config cfg( "aqpkg" );
871 cfg.setGroup( "settings" ); 873 cfg.setGroup( "settings" );
872 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 874 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
873#endif 875#endif
874 876
875 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 877 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
876 if ( ok && !text.isEmpty() ) 878 if ( ok && !text.isEmpty() )
877 dir = text; // user entered something and pressed ok 879 dir = text; // user entered something and pressed ok
878 else 880 else
879 return; // user entered nothing or pressed cancel 881 return; // user entered nothing or pressed cancel
880 882
881#ifdef QWS 883#ifdef QWS
882 // Store download directory in config file 884 // Store download directory in config file
883 cfg.writeEntry( "downloadDir", dir ); 885 cfg.writeEntry( "downloadDir", dir );
884#endif 886#endif
885 887
886 // Get starting directory 888 // Get starting directory
887 char initDir[PATH_MAX]; 889 char initDir[PATH_MAX];
888 getcwd( initDir, PATH_MAX ); 890 getcwd( initDir, PATH_MAX );
889 891
890 // Download each package 892 // Download each package
891 Ipkg ipkg; 893 Ipkg ipkg;
892 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 894 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
893 895
894 ipkg.setOption( "download" ); 896 ipkg.setOption( "download" );
895 ipkg.setRuntimeDirectory( dir ); 897 ipkg.setRuntimeDirectory( dir );
896 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 898 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
897 item != 0 ; 899 item != 0 ;
898 item = (QCheckListItem *)item->nextSibling() ) 900 item = (QCheckListItem *)item->nextSibling() )
899 { 901 {
900 if ( item->isOn() ) 902 if ( item->isOn() )
901 { 903 {
902 ipkg.setPackage( item->text() ); 904 ipkg.setPackage( item->text() );
903 ipkg.runIpkg( ); 905 ipkg.runIpkg( );
904 } 906 }
905 } 907 }
906} 908}
907 909
908void MainWindow :: downloadRemotePackage() 910void MainWindow :: downloadRemotePackage()
909{ 911{
910 // Display dialog 912 // Display dialog
911 bool ok; 913 bool ok;
912 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); 914 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
913 if ( !ok || package.isEmpty() ) 915 if ( !ok || package.isEmpty() )
914 return; 916 return;
915// DownloadRemoteDlgImpl dlg( this, "Install", true ); 917// DownloadRemoteDlgImpl dlg( this, "Install", true );
916// if ( dlg.exec() == QDialog::Rejected ) 918// if ( dlg.exec() == QDialog::Rejected )
917// return; 919// return;
918 920
919 // grab details from dialog 921 // grab details from dialog
920// QString package = dlg.getPackageLocation(); 922// QString package = dlg.getPackageLocation();
921 923
922 InstallData *item = new InstallData(); 924 InstallData *item = new InstallData();
923 item->option = "I"; 925 item->option = "I";
924 item->packageName = package; 926 item->packageName = package;
925 QList<InstallData> workingPackages; 927 QList<InstallData> workingPackages;
926 workingPackages.setAutoDelete( TRUE ); 928 workingPackages.setAutoDelete( TRUE );
927 workingPackages.append( item ); 929 workingPackages.append( item );
928 930
929 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); 931 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) );
930 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 932 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
933 reloadDocuments = TRUE;
931 stack->addWidget( dlg, 3 ); 934 stack->addWidget( dlg, 3 );
932 stack->raiseWidget( dlg ); 935 stack->raiseWidget( dlg );
933} 936}
934 937
935 938
936void MainWindow :: applyChanges() 939void MainWindow :: applyChanges()
937{ 940{
938 stickyOption = ""; 941 stickyOption = "";
939 942
940 // First, write out ipkg_conf file so that ipkg can use it 943 // First, write out ipkg_conf file so that ipkg can use it
941 mgr->writeOutIpkgConf(); 944 mgr->writeOutIpkgConf();
942 945
943 // Now for each selected item 946 // Now for each selected item
944 // deal with it 947 // deal with it
945 948
946 QList<InstallData> workingPackages; 949 QList<InstallData> workingPackages;
947 workingPackages.setAutoDelete( TRUE ); 950 workingPackages.setAutoDelete( TRUE );
948 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 951 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
949 item != 0 ; 952 item != 0 ;
950 item = (QCheckListItem *)item->nextSibling() ) 953 item = (QCheckListItem *)item->nextSibling() )
951 { 954 {
952 if ( item->isOn() ) 955 if ( item->isOn() )
953 { 956 {
954 workingPackages.append( dealWithItem( item ) ); 957 workingPackages.append( dealWithItem( item ) );
955 } 958 }
956 } 959 }
957 960
958 if ( workingPackages.count() == 0 ) 961 if ( workingPackages.count() == 0 )
959 { 962 {
960 // Nothing to do 963 // Nothing to do
961 QMessageBox::information( this, tr( "Nothing to do" ), 964 QMessageBox::information( this, tr( "Nothing to do" ),
962 tr( "No packages selected" ), tr( "OK" ) ); 965 tr( "No packages selected" ), tr( "OK" ) );
963 966
964 return; 967 return;
965 } 968 }
966 969
967 // do the stuff 970 // do the stuff
968 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); 971 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) );
969 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 972 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
973 reloadDocuments = TRUE;
970 stack->addWidget( dlg, 3 ); 974 stack->addWidget( dlg, 3 );
971 stack->raiseWidget( dlg ); 975 stack->raiseWidget( dlg );
972} 976}
973 977
974// decide what to do - either remove, upgrade or install 978// decide what to do - either remove, upgrade or install
975// Current rules: 979// Current rules:
976// If not installed - install 980// If not installed - install
977// If installed and different version available - upgrade 981// If installed and different version available - upgrade
978// If installed and version up to date - remove 982// If installed and version up to date - remove
979InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) 983InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
980{ 984{
981 QString name = item->text(); 985 QString name = item->text();
982 986
983 // Get package 987 // Get package
984 Server *s = mgr->getServer( serversList->currentText() ); 988 Server *s = mgr->getServer( serversList->currentText() );
985 Package *p = s->getPackage( name ); 989 Package *p = s->getPackage( name );
986 990
987 // If the package has a filename then it is a local file 991 // If the package has a filename then it is a local file
988 if ( p->isPackageStoredLocally() ) 992 if ( p->isPackageStoredLocally() )
989 name = p->getFilename(); 993 name = p->getFilename();
990 994
991 QString option; 995 QString option;
992 QString dest = "root"; 996 QString dest = "root";
993 if ( !p->isInstalled() ) 997 if ( !p->isInstalled() )
994 { 998 {
995 InstallData *newitem = new InstallData(); 999 InstallData *newitem = new InstallData();
996 newitem->option = "I"; 1000 newitem->option = "I";
997 newitem->packageName = name; 1001 newitem->packageName = name;
998 return newitem; 1002 return newitem;
999 } 1003 }
1000 else 1004 else
1001 { 1005 {
1002 InstallData *newitem = new InstallData(); 1006 InstallData *newitem = new InstallData();
1003 newitem->option = "D"; 1007 newitem->option = "D";
1004 if ( !p->isPackageStoredLocally() ) 1008 if ( !p->isPackageStoredLocally() )
1005 newitem->packageName = p->getInstalledPackageName(); 1009 newitem->packageName = p->getInstalledPackageName();
1006 else 1010 else
1007 newitem->packageName = name; 1011 newitem->packageName = name;
1008 1012
1009 if ( p->getInstalledTo() ) 1013 if ( p->getInstalledTo() )
1010 { 1014 {
1011 newitem->destination = p->getInstalledTo(); 1015 newitem->destination = p->getInstalledTo();
1012// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; 1016// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
1013// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; 1017// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
1014 } 1018 }
1015 else 1019 else
1016 { 1020 {
1017 newitem->destination = p->getLocalPackage()->getInstalledTo(); 1021 newitem->destination = p->getLocalPackage()->getInstalledTo();
1018 } 1022 }
1019 1023
1020 // Now see if version is newer or not 1024 // Now see if version is newer or not
1021 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 1025 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
1022 1026
1023 // If the version requested is older and user selected a local ipk file, then reinstall the file 1027 // If the version requested is older and user selected a local ipk file, then reinstall the file
1024 if ( p->isPackageStoredLocally() && val == -1 ) 1028 if ( p->isPackageStoredLocally() && val == -1 )
1025 val = 0; 1029 val = 0;
1026 1030
1027 if ( val == -2 ) 1031 if ( val == -2 )
1028 { 1032 {
1029 // Error - should handle 1033 // Error - should handle
1030 } 1034 }
1031 else if ( val == -1 ) 1035 else if ( val == -1 )
1032 { 1036 {
1033 // Version available is older - remove only 1037 // Version available is older - remove only
1034 newitem->option = "D"; 1038 newitem->option = "D";
1035 } 1039 }
1036 else 1040 else
1037 { 1041 {
1038 QString caption; 1042 QString caption;
1039 QString text; 1043 QString text;
1040 QString secondButton; 1044 QString secondButton;
1041 QString secondOption; 1045 QString secondOption;
1042 if ( val == 0 ) 1046 if ( val == 0 )
1043 { 1047 {
1044 // Version available is the same - option to remove or reinstall 1048 // Version available is the same - option to remove or reinstall
1045 caption = tr( "Do you wish to remove or reinstall\n%1?" ); 1049 caption = tr( "Do you wish to remove or reinstall\n%1?" );
1046 text = tr( "Remove or ReInstall" ); 1050 text = tr( "Remove or ReInstall" );
1047 secondButton = tr( "ReInstall" ); 1051 secondButton = tr( "ReInstall" );
1048 secondOption = tr( "R" ); 1052 secondOption = tr( "R" );
1049 } 1053 }
1050 else if ( val == 1 ) 1054 else if ( val == 1 )
1051 { 1055 {
1052 // Version available is newer - option to remove or upgrade 1056 // Version available is newer - option to remove or upgrade
1053 caption = tr( "Do you wish to remove or upgrade\n%1?" ); 1057 caption = tr( "Do you wish to remove or upgrade\n%1?" );
1054 text = tr( "Remove or Upgrade" ); 1058 text = tr( "Remove or Upgrade" );
1055 secondButton = tr( "Upgrade" ); 1059 secondButton = tr( "Upgrade" );
1056 secondOption = tr( "U" ); 1060 secondOption = tr( "U" );
1057 } 1061 }
1058 1062
1059 // Sticky option not implemented yet, but will eventually allow 1063 // Sticky option not implemented yet, but will eventually allow
1060 // the user to say something like 'remove all' 1064 // the user to say something like 'remove all'
1061 if ( stickyOption == "" ) 1065 if ( stickyOption == "" )
1062 { 1066 {
1063 QString msgtext; 1067 QString msgtext;
1064 msgtext = caption.arg( ( const char * )name ); 1068 msgtext = caption.arg( ( const char * )name );
1065 switch( QMessageBox::information( this, text, 1069 switch( QMessageBox::information( this, text,
1066 msgtext, tr( "Remove" ), secondButton ) ) 1070 msgtext, tr( "Remove" ), secondButton ) )
1067 { 1071 {
1068 case 0: // Try again or Enter 1072 case 0: // Try again or Enter
1069 // option 0 = Remove 1073 // option 0 = Remove
1070 newitem->option = "D"; 1074 newitem->option = "D";
1071 break; 1075 break;
1072 case 1: // Quit or Escape 1076 case 1: // Quit or Escape
1073 newitem->option = secondOption; 1077 newitem->option = secondOption;
1074 break; 1078 break;
1075 } 1079 }
1076 } 1080 }
1077 else 1081 else
1078 { 1082 {
1079// newitem->option = stickyOption; 1083// newitem->option = stickyOption;
1080 } 1084 }
1081 } 1085 }
1082 1086
1083 1087
1084 // Check if we are reinstalling the same version 1088 // Check if we are reinstalling the same version
1085 if ( newitem->option != "R" ) 1089 if ( newitem->option != "R" )
1086 newitem->recreateLinks = true; 1090 newitem->recreateLinks = true;
1087 else 1091 else
1088 newitem->recreateLinks = false; 1092 newitem->recreateLinks = false;
1089 1093
1090 // User hit cancel (on dlg - assume remove) 1094 // User hit cancel (on dlg - assume remove)
1091 return newitem; 1095 return newitem;
1092 } 1096 }
1093} 1097}
1094 1098
1095void MainWindow :: reloadData( InstallDlgImpl *dlg ) 1099void MainWindow :: reloadData( InstallDlgImpl *dlg )
1096{ 1100{
1097 stack->raiseWidget( progressWindow ); 1101 stack->raiseWidget( progressWindow );
1098 1102
1099 if ( dlg ) 1103 if ( dlg )
1100 { 1104 {
1101 dlg->close(); 1105 dlg->close();
1102 delete dlg; 1106 delete dlg;
1103 } 1107 }
1104 1108
1105 mgr->reloadServerData(); 1109 mgr->reloadServerData();
1106 serverSelected( -1, FALSE ); 1110 serverSelected( -1, FALSE );
1107 1111
1108#ifdef QWS 1112#ifdef QWS
1109 m_status->setText( tr( "Updating Launcher..." ) ); 1113 if ( reloadDocuments )
1110 1114 {
1111 // Finally let the main system update itself 1115 m_status->setText( tr( "Updating Launcher..." ) );
1112 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 1116
1113 QString lf = QString::null; 1117 // Finally let the main system update itself
1114 e << lf; 1118 QCopEnvelope e("QPE/System", "linkChanged(QString)");
1119 QString lf = QString::null;
1120 e << lf;
1121 }
1115#endif 1122#endif
1116 1123
1117 stack->raiseWidget( networkPkgWindow ); 1124 stack->raiseWidget( networkPkgWindow );
1118} 1125}
1119 1126
1120void MainWindow :: letterPushed( QString t ) 1127void MainWindow :: letterPushed( QString t )
1121{ 1128{
1122 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); 1129 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
1123 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 1130 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
1124 if ( packagesList->firstChild() == 0 ) 1131 if ( packagesList->firstChild() == 0 )
1125 return; 1132 return;
1126 1133
1127 QCheckListItem *item; 1134 QCheckListItem *item;
1128 if ( start == 0 ) 1135 if ( start == 0 )
1129 { 1136 {
1130 item = (QCheckListItem *)packagesList->firstChild(); 1137 item = (QCheckListItem *)packagesList->firstChild();
1131 start = top; 1138 start = top;
1132 } 1139 }
1133 else 1140 else
1134 item = (QCheckListItem *)start->nextSibling(); 1141 item = (QCheckListItem *)start->nextSibling();
1135 1142
1136 if ( item == 0 ) 1143 if ( item == 0 )
1137 item = (QCheckListItem *)packagesList->firstChild(); 1144 item = (QCheckListItem *)packagesList->firstChild();
1138 do 1145 do
1139 { 1146 {
1140 if ( item->text().lower().startsWith( t.lower() ) ) 1147 if ( item->text().lower().startsWith( t.lower() ) )
1141 { 1148 {
1142 packagesList->setSelected( item, true ); 1149 packagesList->setSelected( item, true );
1143 packagesList->ensureItemVisible( item ); 1150 packagesList->ensureItemVisible( item );
1144 break; 1151 break;
1145 } 1152 }
1146 1153
1147 item = (QCheckListItem *)item->nextSibling(); 1154 item = (QCheckListItem *)item->nextSibling();
1148 if ( !item ) 1155 if ( !item )
1149 item = (QCheckListItem *)packagesList->firstChild(); 1156 item = (QCheckListItem *)packagesList->firstChild();
1150 } while ( item != start); 1157 } while ( item != start);
1151} 1158}
1152 1159
1153void MainWindow :: slotDisplayPackage( QListViewItem *item ) 1160void MainWindow :: slotDisplayPackage( QListViewItem *item )
1154{ 1161{
1155 QString itemstr( ((QCheckListItem*)item)->text() ); 1162 QString itemstr( ((QCheckListItem*)item)->text() );
1156 PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); 1163 PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) );
1157 p->showMaximized(); 1164 p->showMaximized();
1158} 1165}
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index c4548b1..f95c332 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -1,141 +1,142 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.h - description 2 mainwin.h - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef MAINWIN_H 18#ifndef MAINWIN_H
19#define MAINWIN_H 19#define MAINWIN_H
20 20
21#include <qmainwindow.h> 21#include <qmainwindow.h>
22#include <qpixmap.h> 22#include <qpixmap.h>
23 23
24class DataManager; 24class DataManager;
25class InstallData; 25class InstallData;
26class InstallDlgImpl; 26class InstallDlgImpl;
27 27
28class QAction; 28class QAction;
29class QCheckListItem; 29class QCheckListItem;
30class QComboBox; 30class QComboBox;
31class QLabel; 31class QLabel;
32class QLineEdit; 32class QLineEdit;
33class QListView; 33class QListView;
34class QListViewItem; 34class QListViewItem;
35class QToolBar; 35class QToolBar;
36class QProgressBar; 36class QProgressBar;
37class QWidgetStack; 37class QWidgetStack;
38 38
39class MainWindow :public QMainWindow 39class MainWindow :public QMainWindow
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42public: 42public:
43 43
44 MainWindow(); 44 MainWindow();
45 ~MainWindow(); 45 ~MainWindow();
46 46
47protected: 47protected:
48 void closeEvent( QCloseEvent* e ); 48 void closeEvent( QCloseEvent* e );
49 49
50private: 50private:
51 DataManager *mgr; 51 DataManager *mgr;
52 52
53 QWidgetStack *stack; 53 QWidgetStack *stack;
54 54
55 QToolBar *findBar; 55 QToolBar *findBar;
56 QToolBar *jumpBar; 56 QToolBar *jumpBar;
57 QLineEdit *findEdit; 57 QLineEdit *findEdit;
58 QAction *actionFindNext; 58 QAction *actionFindNext;
59 QAction *actionFilter; 59 QAction *actionFilter;
60 QAction *actionUpgrade; 60 QAction *actionUpgrade;
61 QAction *actionDownload; 61 QAction *actionDownload;
62 QAction *actionUninstalled; 62 QAction *actionUninstalled;
63 QAction *actionInstalled; 63 QAction *actionInstalled;
64 QAction *actionUpdated; 64 QAction *actionUpdated;
65 65
66 QPixmap iconDownload; 66 QPixmap iconDownload;
67 QPixmap iconRemove; 67 QPixmap iconRemove;
68 68
69 int mnuShowUninstalledPkgsId; 69 int mnuShowUninstalledPkgsId;
70 int mnuShowInstalledPkgsId; 70 int mnuShowInstalledPkgsId;
71 int mnuShowUpgradedPkgsId; 71 int mnuShowUpgradedPkgsId;
72 int mnuFilterByCategory; 72 int mnuFilterByCategory;
73 int mnuSetFilterCategory; 73 int mnuSetFilterCategory;
74 74
75 // Main package list widget 75 // Main package list widget
76 QWidget *networkPkgWindow; 76 QWidget *networkPkgWindow;
77 QComboBox *serversList; 77 QComboBox *serversList;
78 QListView *packagesList; 78 QListView *packagesList;
79 QPixmap installedIcon; 79 QPixmap installedIcon;
80 QPixmap updatedIcon; 80 QPixmap updatedIcon;
81 QString currentlySelectedServer; 81 QString currentlySelectedServer;
82 QString categoryFilter; 82 QString categoryFilter;
83 QString stickyOption; 83 QString stickyOption;
84 84
85 bool categoryFilterEnabled; 85 bool categoryFilterEnabled;
86 bool showJumpTo; 86 bool showJumpTo;
87 bool showUninstalledPkgs; 87 bool showUninstalledPkgs;
88 bool showInstalledPkgs; 88 bool showInstalledPkgs;
89 bool showUpgradedPkgs; 89 bool showUpgradedPkgs;
90 bool downloadEnabled; 90 bool downloadEnabled;
91 bool reloadDocuments;
91 92
92 void initMainWidget(); 93 void initMainWidget();
93 void updateData(); 94 void updateData();
94 void serverSelected( int index, bool showProgress ); 95 void serverSelected( int index, bool showProgress );
95 void searchForPackage( const QString & ); 96 void searchForPackage( const QString & );
96 bool filterByCategory( bool val ); 97 bool filterByCategory( bool val );
97 void downloadSelectedPackages(); 98 void downloadSelectedPackages();
98 void downloadRemotePackage(); 99 void downloadRemotePackage();
99 InstallData *dealWithItem( QCheckListItem *item ); 100 InstallData *dealWithItem( QCheckListItem *item );
100 101
101 // Progress widget 102 // Progress widget
102 QWidget *progressWindow; 103 QWidget *progressWindow;
103 QLabel *m_status; 104 QLabel *m_status;
104 QProgressBar *m_progress; 105 QProgressBar *m_progress;
105 106
106 void initProgressWidget(); 107 void initProgressWidget();
107 108
108public slots: 109public slots:
109 void setDocument( const QString &doc ); 110 void setDocument( const QString &doc );
110 void displayFindBar(); 111 void displayFindBar();
111 void displayJumpBar(); 112 void displayJumpBar();
112 void repeatFind(); 113 void repeatFind();
113 void findPackage( const QString & ); 114 void findPackage( const QString & );
114 void hideFindBar(); 115 void hideFindBar();
115 void hideJumpBar(); 116 void hideJumpBar();
116 void displaySettings(); 117 void displaySettings();
117 void filterUninstalledPackages(); 118 void filterUninstalledPackages();
118 void filterInstalledPackages(); 119 void filterInstalledPackages();
119 void filterUpgradedPackages(); 120 void filterUpgradedPackages();
120 void filterCategory(); 121 void filterCategory();
121 bool setFilterCategory(); 122 bool setFilterCategory();
122 void raiseMainWidget(); 123 void raiseMainWidget();
123 void raiseProgressWidget(); 124 void raiseProgressWidget();
124 void enableUpgrade( bool ); 125 void enableUpgrade( bool );
125 void enableDownload( bool ); 126 void enableDownload( bool );
126 void reloadData( InstallDlgImpl * ); 127 void reloadData( InstallDlgImpl * );
127 128
128private slots: 129private slots:
129 void init(); 130 void init();
130 void setProgressSteps( int ); 131 void setProgressSteps( int );
131 void setProgressMessage( const QString & ); 132 void setProgressMessage( const QString & );
132 void updateProgress( int ); 133 void updateProgress( int );
133 void serverSelected( int index ); 134 void serverSelected( int index );
134 void updateServer(); 135 void updateServer();
135 void upgradePackages(); 136 void upgradePackages();
136 void downloadPackage(); 137 void downloadPackage();
137 void applyChanges(); 138 void applyChanges();
138 void letterPushed( QString t ); 139 void letterPushed( QString t );
139 void slotDisplayPackage( QListViewItem * ); 140 void slotDisplayPackage( QListViewItem * );
140}; 141};
141#endif 142#endif