summaryrefslogtreecommitdiff
authordrw <drw>2004-11-16 17:26:28 (UTC)
committer drw <drw>2004-11-16 17:26:28 (UTC)
commit36f98a2f0438edf82e4f326660786207ee46d87d (patch) (unidiff)
treef6413c1a9c281083ba63b952f1ae21c2092d9836
parent43773cc47947f88f48aa7a9f64ff58defff70c83 (diff)
downloadopie-36f98a2f0438edf82e4f326660786207ee46d87d.zip
opie-36f98a2f0438edf82e4f326660786207ee46d87d.tar.gz
opie-36f98a2f0438edf82e4f326660786207ee46d87d.tar.bz2
Fix bug #1464 - correctly reapply filters
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp52
1 files changed, 31 insertions, 21 deletions
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp
index 991cc81..807bddd 100644
--- a/noncore/settings/packagemanager/mainwindow.cpp
+++ b/noncore/settings/packagemanager/mainwindow.cpp
@@ -1,120 +1,120 @@
1/* 1/*
2                This file is part of the OPIE Project 2 This file is part of the OPIE Project
3 3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l. 5 .=l.
6           .>+-= 6 .>+-=
7 _;:,     .>    :=|. This file is free software; you can 7_;:, .> :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.-- : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13    .%`+i>       _;_. 13 .%`+i> _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that 14 .i_,=:_. -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details. 19..}^=.= = ; Public License for more details.
20++=   -.     .`     .: 20++= -. .` .:
21 :     =  ...= . :.=- You should have received a copy of the GNU 21: = ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file; 22-. .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the 23 -_. . . )=. = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc., 24 -- :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330, 25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include "mainwindow.h" 30#include "mainwindow.h"
31#include "installdlg.h" 31#include "installdlg.h"
32#include "filterdlg.h" 32#include "filterdlg.h"
33#include "promptdlg.h" 33#include "promptdlg.h"
34#include "entrydlg.h" 34#include "entrydlg.h"
35#include "packageinfodlg.h" 35#include "packageinfodlg.h"
36 36
37#include <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40 40
41#include <qaction.h> 41#include <qaction.h>
42#include <qdir.h> 42#include <qdir.h>
43#include <qlayout.h> 43#include <qlayout.h>
44#include <qlineedit.h> 44#include <qlineedit.h>
45#include <qmenubar.h> 45#include <qmenubar.h>
46#include <qmessagebox.h> 46#include <qmessagebox.h>
47#include <qpopupmenu.h> 47#include <qpopupmenu.h>
48#include <qtimer.h> 48#include <qtimer.h>
49#include <qtoolbar.h> 49#include <qtoolbar.h>
50#include <qwhatsthis.h> 50#include <qwhatsthis.h>
51 51
52MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) 52MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ )
53 : QMainWindow( parent, name, WStyle_ContextHelp ) 53 : QMainWindow( parent, name, WStyle_ContextHelp )
54 , m_config( "packman" ) 54 , m_config( "packman" )
55 , m_packman( &m_config, this ) 55 , m_packman( &m_config, this )
56 , m_menuBar( this ) 56 , m_menuBar( this )
57 , m_toolBar( this ) 57 , m_toolBar( this )
58 , m_findBar( this ) 58 , m_findBar( this )
59 , m_widgetStack( this ) 59 , m_widgetStack( this )
60 , m_packageList( this ) 60 , m_packageList( this )
61 , m_statusWidget( this ) 61 , m_statusWidget( this )
62 , m_statusText( &m_statusWidget ) 62 , m_statusText( &m_statusWidget )
63 , m_statusBar( &m_statusWidget ) 63 , m_statusBar( &m_statusWidget )
64 , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) 64 , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) )
65 , m_iconInstalled( Resource::loadPixmap( "installed" ) ) 65 , m_iconInstalled( Resource::loadPixmap( "installed" ) )
66 , m_iconNull( m_iconUpdated.size() ) 66 , m_iconNull( m_iconUpdated.size() )
67 , m_filterName( QString::null ) 67 , m_filterName( QString::null )
68 , m_filterServer( QString::null ) 68 , m_filterServer( QString::null )
69 , m_filterDest( QString::null ) 69 , m_filterDest( QString::null )
70 , m_filterStatus( OPackageManager::NotDefined ) 70 , m_filterStatus( OPackageManager::NotDefined )
71 , m_filterCategory( QString::null ) 71 , m_filterCategory( QString::null )
72 72
73{ 73{
74// setCaption( tr( "Package Manager" ) ); 74// setCaption( tr( "Package Manager" ) );
75 75
76 m_iconNull.fill( colorGroup().base() ); 76 m_iconNull.fill( colorGroup().base() );
77 77
78 connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); 78 connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) );
79 79
80 // Initialize widget stack, package list and status widget 80 // Initialize widget stack, package list and status widget
81 initStatusWidget(); 81 initStatusWidget();
82 initPackageList(); 82 initPackageList();
83 83
84 m_widgetStack.addWidget( &m_statusWidget, 2 ); 84 m_widgetStack.addWidget( &m_statusWidget, 2 );
85 m_widgetStack.addWidget( &m_packageList, 1 ); 85 m_widgetStack.addWidget( &m_packageList, 1 );
86 setCentralWidget( &m_widgetStack ); 86 setCentralWidget( &m_widgetStack );
87 87
88 // Initialize remaining user interface items 88 // Initialize remaining user interface items
89 initUI(); 89 initUI();
90 90
91 // Initialize package information 91 // Initialize package information
92 QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) ); 92 QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) );
93} 93}
94 94
95void MainWindow::closeEvent( QCloseEvent *event ) 95void MainWindow::closeEvent( QCloseEvent *event )
96{ 96{
97 // Close app only if either the package or status widgets are currently active 97 // Close app only if either the package or status widgets are currently active
98 bool close = m_widgetStack.visibleWidget() == &m_packageList || 98 bool close = m_widgetStack.visibleWidget() == &m_packageList ||
99 m_widgetStack.visibleWidget() == &m_statusWidget; 99 m_widgetStack.visibleWidget() == &m_statusWidget;
100 if ( close ) 100 if ( close )
101 { 101 {
102 // TODO - write out application configuration settings 102 // TODO - write out application configuration settings
103 103
104 // Write out package manager configuration settings 104 // Write out package manager configuration settings
105 m_packman.saveSettings(); 105 m_packman.saveSettings();
106 event->accept(); 106 event->accept();
107 } 107 }
108 else 108 else
109 { 109 {
110 delete m_widgetStack.visibleWidget(); 110 delete m_widgetStack.visibleWidget();
111 m_widgetStack.raiseWidget( &m_packageList ); 111 m_widgetStack.raiseWidget( &m_packageList );
112 event->ignore(); 112 event->ignore();
113 } 113 }
114} 114}
115 115
116void MainWindow::initPackageList() 116void MainWindow::initPackageList()
117{ 117{
118 m_packageList.addColumn( tr( "Packages" ) ); 118 m_packageList.addColumn( tr( "Packages" ) );
119 QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nTap inside the box at the left to select a package. Tap and hold to view package details." ) ); 119 QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nTap inside the box at the left to select a package. Tap and hold to view package details." ) );
120 QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); 120 QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold );
@@ -438,192 +438,202 @@ void MainWindow::slotApply()
438 if ( package ) 438 if ( package )
439 { 439 {
440 if ( !package->versionInstalled().isNull() ) 440 if ( !package->versionInstalled().isNull() )
441 { 441 {
442 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) 442 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 )
443 { 443 {
444 // Remove/upgrade package 444 // Remove/upgrade package
445 int answer = PromptDlg::ask( tr( "Remove or upgrade" ), 445 int answer = PromptDlg::ask( tr( "Remove or upgrade" ),
446 tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), 446 tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ),
447 tr( "Remove" ), tr( "Upgrade" ), this ); 447 tr( "Remove" ), tr( "Upgrade" ), this );
448 if ( answer == 1 ) // Remove 448 if ( answer == 1 ) // Remove
449 { 449 {
450 if ( !removeList ) 450 if ( !removeList )
451 removeList = new QStringList(); 451 removeList = new QStringList();
452 removeList->append( item->text() ); 452 removeList->append( item->text() );
453 } 453 }
454 else if ( answer == 2 ) // Upgrade 454 else if ( answer == 2 ) // Upgrade
455 { 455 {
456 if ( !upgradeList ) 456 if ( !upgradeList )
457 upgradeList = new QStringList(); 457 upgradeList = new QStringList();
458 upgradeList->append( item->text() ); 458 upgradeList->append( item->text() );
459 } 459 }
460 } 460 }
461 else 461 else
462 { 462 {
463 // Remove/reinstall package 463 // Remove/reinstall package
464 int answer = PromptDlg::ask( tr( "Remove or reinstall" ), 464 int answer = PromptDlg::ask( tr( "Remove or reinstall" ),
465 tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), 465 tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ),
466 tr( "Remove" ), tr( "Reinstall" ), this ); 466 tr( "Remove" ), tr( "Reinstall" ), this );
467 if ( answer == 1 ) // Remove 467 if ( answer == 1 ) // Remove
468 { 468 {
469 if ( !removeList ) 469 if ( !removeList )
470 removeList = new QStringList(); 470 removeList = new QStringList();
471 removeList->append( item->text() ); 471 removeList->append( item->text() );
472 } 472 }
473 else if ( answer == 2 ) // Reinstall 473 else if ( answer == 2 ) // Reinstall
474 { 474 {
475 if ( !installList ) 475 if ( !installList )
476 installList = new QStringList(); 476 installList = new QStringList();
477 installList->append( item->text() ); 477 installList->append( item->text() );
478 } 478 }
479 } 479 }
480 } 480 }
481 else 481 else
482 { 482 {
483 // Install package 483 // Install package
484 if ( !installList ) 484 if ( !installList )
485 installList = new QStringList(); 485 installList = new QStringList();
486 installList->append( item->text() ); 486 installList->append( item->text() );
487 } 487 }
488 } 488 }
489 } 489 }
490 } 490 }
491 491
492 // If nothing is selected, display message and exit 492 // If nothing is selected, display message and exit
493 if ( !removeList && !installList && !upgradeList ) 493 if ( !removeList && !installList && !upgradeList )
494 { 494 {
495 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); 495 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) );
496 return; 496 return;
497 } 497 }
498 498
499 // Send command only if there are packages to process 499 // Send command only if there are packages to process
500 OPackage::Command removeCmd = OPackage::NotDefined; 500 OPackage::Command removeCmd = OPackage::NotDefined;
501 if ( removeList && !removeList->isEmpty() ) 501 if ( removeList && !removeList->isEmpty() )
502 removeCmd = OPackage::Remove; 502 removeCmd = OPackage::Remove;
503 OPackage::Command installCmd = OPackage::NotDefined; 503 OPackage::Command installCmd = OPackage::NotDefined;
504 if ( installList && !installList->isEmpty() ) 504 if ( installList && !installList->isEmpty() )
505 installCmd = OPackage::Install; 505 installCmd = OPackage::Install;
506 OPackage::Command upgradeCmd = OPackage::NotDefined; 506 OPackage::Command upgradeCmd = OPackage::NotDefined;
507 if ( upgradeList && !upgradeList->isEmpty() ) 507 if ( upgradeList && !upgradeList->isEmpty() )
508 upgradeCmd = OPackage::Upgrade; 508 upgradeCmd = OPackage::Upgrade;
509 509
510 // Create package manager output widget 510 // Create package manager output widget
511 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, 511 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true,
512 removeCmd, removeList, 512 removeCmd, removeList,
513 installCmd, installList, 513 installCmd, installList,
514 upgradeCmd, upgradeList ); 514 upgradeCmd, upgradeList );
515 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 515 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
516 516
517 // Display widget 517 // Display widget
518 m_widgetStack.addWidget( dlg, 3 ); 518 m_widgetStack.addWidget( dlg, 3 );
519 m_widgetStack.raiseWidget( dlg ); 519 m_widgetStack.raiseWidget( dlg );
520} 520}
521 521
522void MainWindow::slotCloseDlg() 522void MainWindow::slotCloseDlg()
523{ 523{
524 // Close install dialog 524 // Close install dialog
525 delete m_widgetStack.visibleWidget(); 525 delete m_widgetStack.visibleWidget();
526 526
527 // Reload package list 527 // Reload package list
528 initPackageInfo(); 528 initPackageInfo();
529 529
530 // Update Opie launcher links 530 // Update Opie launcher links
531 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 531 QCopEnvelope e("QPE/System", "linkChanged(QString)");
532 QString lf = QString::null; 532 QString lf = QString::null;
533 e << lf; 533 e << lf;
534
535 // Reapply any filters previously set
536 if ( m_actionShowNotInstalled->isOn() )
537 slotShowNotInstalled();
538 else if ( m_actionShowInstalled->isOn() )
539 slotShowInstalled();
540 else if ( m_actionShowUpdated->isOn() )
541 slotShowUpdated();
542 else if ( m_actionFilter->isOn() )
543 slotFilter( true );
534} 544}
535 545
536void MainWindow::slotConfigure() 546void MainWindow::slotConfigure()
537{ 547{
538 if ( m_packman.configureDlg( false ) ) 548 if ( m_packman.configureDlg( false ) )
539 { 549 {
540 if ( PromptDlg::ask( tr( "Config updated" ), 550 if ( PromptDlg::ask( tr( "Config updated" ),
541 tr( "The configuration has been updated. Do you want to update server and package information now?" ), 551 tr( "The configuration has been updated. Do you want to update server and package information now?" ),
542 tr( "Yes" ), tr( "No" ), this ) == 1 ) 552 tr( "Yes" ), tr( "No" ), this ) == 1 )
543 { 553 {
544 // Update package list and reload package info 554 // Update package list and reload package info
545 slotUpdate(); 555 slotUpdate();
546 } 556 }
547 } 557 }
548} 558}
549 559
550void MainWindow::slotShowNotInstalled() 560void MainWindow::slotShowNotInstalled()
551{ 561{
552 OPackageList *packageList; 562 OPackageList *packageList;
553 if ( m_actionShowNotInstalled->isOn() ) 563 if ( m_actionShowNotInstalled->isOn() )
554 { 564 {
555 m_actionShowInstalled->setOn( false ); 565 m_actionShowInstalled->setOn( false );
556 m_actionShowUpdated->setOn( false ); 566 m_actionShowUpdated->setOn( false );
557 m_actionFilter->setOn( false ); 567 m_actionFilter->setOn( false );
558 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, 568 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
559 OPackageManager::NotInstalled, QString::null ); 569 OPackageManager::NotInstalled, QString::null );
560 } 570 }
561 else 571 else
562 packageList = m_packman.packages(); 572 packageList = m_packman.packages();
563 573
564 if ( packageList ) 574 if ( packageList )
565 { 575 {
566 loadPackageList( packageList, true ); 576 loadPackageList( packageList, true );
567 delete packageList; 577 delete packageList;
568 } 578 }
569} 579}
570 580
571void MainWindow::slotShowInstalled() 581void MainWindow::slotShowInstalled()
572{ 582{
573 OPackageList *packageList; 583 OPackageList *packageList;
574 if ( m_actionShowInstalled->isOn() ) 584 if ( m_actionShowInstalled->isOn() )
575 { 585 {
576 m_actionShowNotInstalled->setOn( false ); 586 m_actionShowNotInstalled->setOn( false );
577 m_actionShowUpdated->setOn( false ); 587 m_actionShowUpdated->setOn( false );
578 m_actionFilter->setOn( false ); 588 m_actionFilter->setOn( false );
579 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, 589 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
580 OPackageManager::Installed, QString::null ); 590 OPackageManager::Installed, QString::null );
581 } 591 }
582 else 592 else
583 packageList = m_packman.packages(); 593 packageList = m_packman.packages();
584 594
585 if ( packageList ) 595 if ( packageList )
586 { 596 {
587 loadPackageList( packageList, true ); 597 loadPackageList( packageList, true );
588 delete packageList; 598 delete packageList;
589 } 599 }
590} 600}
591 601
592void MainWindow::slotShowUpdated() 602void MainWindow::slotShowUpdated()
593{ 603{
594 OPackageList *packageList; 604 OPackageList *packageList;
595 if ( m_actionShowUpdated->isOn() ) 605 if ( m_actionShowUpdated->isOn() )
596 { 606 {
597 m_actionShowInstalled->setOn( false ); 607 m_actionShowInstalled->setOn( false );
598 m_actionShowNotInstalled->setOn( false ); 608 m_actionShowNotInstalled->setOn( false );
599 m_actionFilter->setOn( false ); 609 m_actionFilter->setOn( false );
600 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, 610 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
601 OPackageManager::Updated, QString::null ); 611 OPackageManager::Updated, QString::null );
602 } 612 }
603 else 613 else
604 packageList = m_packman.packages(); 614 packageList = m_packman.packages();
605 615
606 if ( packageList ) 616 if ( packageList )
607 { 617 {
608 loadPackageList( packageList, true ); 618 loadPackageList( packageList, true );
609 delete packageList; 619 delete packageList;
610 } 620 }
611} 621}
612 622
613void MainWindow::slotFilterChange() 623void MainWindow::slotFilterChange()
614{ 624{
615 FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, 625 FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus,
616 m_filterCategory ); 626 m_filterCategory );
617 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) 627 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
618 { 628 {
619 m_filterName = dlg.name(); 629 m_filterName = dlg.name();
620 m_filterServer = dlg.server(); 630 m_filterServer = dlg.server();
621 m_filterDest = dlg.destination(); 631 m_filterDest = dlg.destination();
622 m_filterStatus = dlg.status(); 632 m_filterStatus = dlg.status();
623 m_filterCategory = dlg.category(); 633 m_filterCategory = dlg.category();
624 m_actionFilter->setOn( true ); 634 m_actionFilter->setOn( true );
625 slotFilter( true ); 635 slotFilter( true );
626 } 636 }
627 else 637 else
628 { 638 {
629 m_actionFilter->setOn( false ); 639 m_actionFilter->setOn( false );