author | andyq <andyq> | 2002-11-09 15:39:15 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-11-09 15:39:15 (UTC) |
commit | 5ab7af2bb5d98aef639cbc2ca14f630813fd4fe9 (patch) (side-by-side diff) | |
tree | 3a43ab203aa57960151ba11a091aefaebbf1a566 | |
parent | a121ae6e8e6f16ba355e8c86eba2b98792c93091 (diff) | |
download | opie-5ab7af2bb5d98aef639cbc2ca14f630813fd4fe9.zip opie-5ab7af2bb5d98aef639cbc2ca14f630813fd4fe9.tar.gz opie-5ab7af2bb5d98aef639cbc2ca14f630813fd4fe9.tar.bz2 |
Added filter menu - contains 3 filters - show uninstalled packages,
show installed packages and show upgraded packages
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 89 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.h | 15 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 51 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.h | 7 |
4 files changed, 145 insertions, 17 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 3c72f2b..4e9cc12 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -39,18 +39,23 @@ MainWindow :: MainWindow( QWidget *p, char *name ) // Create our menu
- QPopupMenu *help = new QPopupMenu( this );
-
- help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_H );
+ help = new QPopupMenu( this );
+ help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_G );
help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A );
- QPopupMenu *settings = new QPopupMenu( this );
+ settings = new QPopupMenu( this );
settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S );
- QPopupMenu *edit = new QPopupMenu( this );
- edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_F );
- edit->insertItem( "&Find Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_R );
+ edit = new QPopupMenu( this );
+ edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_I );
+ edit->insertItem( "Find &Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_N );
+ filter = new QPopupMenu( this );
+ mnuShowUninstalledPkgsId = filter->insertItem( "Show &Uninstalled Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U );
+ mnuShowInstalledPkgsId = filter->insertItem( "Show In&stalled Packages", this, SLOT(filterInstalledPackages()), Qt::CTRL+Qt::Key_S );
+ mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P );
+
// Create the main menu
- QMenuBar *menu = menuBar(); //new QMenuBar( this );
+ menu = menuBar(); //new QMenuBar( this );
menu->insertItem( "&Settings", settings );
menu->insertItem( "&Edit", edit );
+ menu->insertItem( "&Filter", filter );
menu->insertItem( "&Help", help );
@@ -111 +116,69 @@ void MainWindow :: displayAbout() }
+
+
+void MainWindow :: filterUninstalledPackages()
+{
+ bool val;
+ if ( filter->isItemChecked( mnuShowUninstalledPkgsId ) )
+ {
+ val = false;
+ filter->setItemChecked( mnuShowUninstalledPkgsId, false );
+ }
+ else
+ {
+ val = true;
+ filter->setItemChecked( mnuShowUninstalledPkgsId, true );
+ }
+
+ filter->setItemChecked( mnuShowInstalledPkgsId, false );
+ networkPkgWindow->showOnlyInstalledPackages( false );
+ filter->setItemChecked( mnuShowUpgradedPkgsId, false );
+ networkPkgWindow->showUpgradedPackages( false );
+
+ networkPkgWindow->showOnlyUninstalledPackages( val );
+
+}
+
+void MainWindow :: filterInstalledPackages()
+{
+ bool val;
+ if ( filter->isItemChecked( mnuShowInstalledPkgsId ) )
+ {
+ val = false;
+ filter->setItemChecked( mnuShowInstalledPkgsId, false );
+ }
+ else
+ {
+ val = true;
+ filter->setItemChecked( mnuShowInstalledPkgsId, true );
+ }
+
+ filter->setItemChecked( mnuShowUninstalledPkgsId, false );
+ networkPkgWindow->showOnlyUninstalledPackages( false );
+ filter->setItemChecked( mnuShowUpgradedPkgsId, false );
+ networkPkgWindow->showUpgradedPackages( false );
+
+ networkPkgWindow->showOnlyInstalledPackages( val );
+}
+
+void MainWindow :: filterUpgradedPackages()
+{
+ bool val;
+ if ( filter->isItemChecked( mnuShowUpgradedPkgsId ) )
+ {
+ val = false;
+ filter->setItemChecked( mnuShowUpgradedPkgsId, false );
+ }
+ else
+ {
+ val = true;
+ filter->setItemChecked( mnuShowUpgradedPkgsId, true );
+ }
+
+ filter->setItemChecked( mnuShowUninstalledPkgsId, false );
+ networkPkgWindow->showOnlyUninstalledPackages( false );
+ filter->setItemChecked( mnuShowInstalledPkgsId, false );
+ networkPkgWindow->showOnlyInstalledPackages( false );
+
+ networkPkgWindow->showUpgradedPackages( val );
+}
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index 267233f..7b6e0ba 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h @@ -38,4 +38,14 @@ private: + QMenuBar *menu;
+ QPopupMenu *help;
+ QPopupMenu *settings;
+ QPopupMenu *edit;
+ QPopupMenu *filter;
QWidgetStack *stack;
- NetworkPackageManager *networkPkgWindow;
+
+ NetworkPackageManager *networkPkgWindow;
+
+ int mnuShowUninstalledPkgsId;
+ int mnuShowInstalledPkgsId;
+ int mnuShowUpgradedPkgsId;
@@ -48,2 +58,5 @@ public slots: void displaySettings();
+ void filterUninstalledPackages();
+ void filterInstalledPackages();
+ void filterUpgradedPackages();
};
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 76c7a9c..d43c6ac 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp @@ -58,3 +58,8 @@ NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); + #endif + + showUninstalledPkgs = false; + showInstalledPkgs = false; + showUpgradedPkgs = false; @@ -65,4 +70,2 @@ NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget updateData(); -// progressDlg = 0; -// timerId = startTimer( 100 ); } @@ -77,7 +80,4 @@ void NetworkPackageManager :: timerEvent ( QTimerEvent * ) -// showProgressDialog(); // Add server names to listbox updateData(); - -// progressDlg->hide(); } @@ -225,5 +225,22 @@ void NetworkPackageManager :: serverSelected( int ) - // If the local server, only display installed packages - if ( serverName == LOCAL_SERVER && !it->isInstalled() ) - continue; + // Apply show only uninstalled packages filter + if ( showUninstalledPkgs && it->isInstalled() ) + continue; + + // Apply show only installed packages filter + if ( showInstalledPkgs && !it->isInstalled() ) + continue; + + // Apply show only new installed packages filter + if ( showUpgradedPkgs ) + { + if ( !it->isInstalled() || + compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) + continue; + } + + // If the local server, only display installed packages + if ( serverName == LOCAL_SERVER && !it->isInstalled() ) + continue; + @@ -771 +788,19 @@ void NetworkPackageManager :: searchForPackage( bool findNext ) } + +void NetworkPackageManager :: showOnlyUninstalledPackages( bool val ) +{ + showUninstalledPkgs = val; + serverSelected( -1 ); +} + +void NetworkPackageManager :: showOnlyInstalledPackages( bool val ) +{ + showInstalledPkgs = val; + serverSelected( -1 ); +} + +void NetworkPackageManager :: showUpgradedPackages( bool val ) +{ + showUpgradedPkgs = val; + serverSelected( -1 ); +} diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h index 66a8903..937c9b4 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.h +++ b/noncore/settings/aqpkg/networkpkgmgr.h @@ -43,2 +43,6 @@ public: void searchForPackage( bool findNext ); + void showOnlyUninstalledPackages( bool val ); + void showOnlyInstalledPackages( bool val ); + void showUpgradedPackages( bool val ); + private: @@ -58,2 +62,5 @@ private: bool showJumpTo; + bool showUninstalledPkgs; + bool showInstalledPkgs; + bool showUpgradedPkgs; int timerId; |