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 @@ -38,20 +38,25 @@ 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 );
@@ -110,2 +115,70 @@ void MainWindow :: displayAbout() QMessageBox::about( this, "About AQPkg", VERSION_TEXT );
}
+
+
+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 @@ -37,6 +37,16 @@ private: DataManager *mgr;
+ QMenuBar *menu;
+ QPopupMenu *help;
+ QPopupMenu *settings;
+ QPopupMenu *edit;
+ QPopupMenu *filter;
QWidgetStack *stack;
- NetworkPackageManager *networkPkgWindow;
+
+ NetworkPackageManager *networkPkgWindow;
+
+ int mnuShowUninstalledPkgsId;
+ int mnuShowInstalledPkgsId;
+ int mnuShowUpgradedPkgsId;
public slots:
@@ -47,4 +57,7 @@ public slots: void displayAbout();
void displaySettings();
+ void filterUninstalledPackages();
+ void filterInstalledPackages();
+ void filterUpgradedPackages();
};
#endif
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 @@ -57,5 +57,10 @@ NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); + #endif + + showUninstalledPkgs = false; + showInstalledPkgs = false; + showUpgradedPkgs = false; @@ -64,6 +69,4 @@ NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget updateData(); -// progressDlg = 0; -// timerId = startTimer( 100 ); } @@ -76,9 +79,6 @@ void NetworkPackageManager :: timerEvent ( QTimerEvent * ) killTimer( timerId ); -// showProgressDialog(); // Add server names to listbox updateData(); - -// progressDlg->hide(); } @@ -224,7 +224,24 @@ void NetworkPackageManager :: serverSelected( int ) QString text = ""; - // 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; + text += it->getPackageName(); @@ -770,2 +787,20 @@ 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 @@ -42,4 +42,8 @@ public: void updateData(); void searchForPackage( bool findNext ); + void showOnlyUninstalledPackages( bool val ); + void showOnlyInstalledPackages( bool val ); + void showUpgradedPackages( bool val ); + private: DataManager *dataMgr; @@ -57,4 +61,7 @@ private: bool showJumpTo; + bool showUninstalledPkgs; + bool showInstalledPkgs; + bool showUpgradedPkgs; int timerId; |