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 | 13 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 45 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.h | 7 |
4 files changed, 141 insertions, 13 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 @@ -34,28 +34,33 @@ MainWindow :: MainWindow( QWidget *p, char *name ) showMaximized();
#endif
setCaption( "AQPkg - Package Manager" );
// 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 );
mgr = new DataManager();
mgr->loadServers();
stack = new QWidgetStack( this );
@@ -106,6 +111,74 @@ void MainWindow :: repeatSearchForPackage() }
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 @@ -33,18 +33,31 @@ public: MainWindow( QWidget *p = 0, char *name = 0 );
~MainWindow();
private:
DataManager *mgr;
+ QMenuBar *menu;
+ QPopupMenu *help;
+ QPopupMenu *settings;
+ QPopupMenu *edit;
+ QPopupMenu *filter;
QWidgetStack *stack;
+
NetworkPackageManager *networkPkgWindow;
+ int mnuShowUninstalledPkgsId;
+ int mnuShowInstalledPkgsId;
+ int mnuShowUpgradedPkgsId;
+
public slots:
void setDocument( const QString &doc );
void displayHelp();
void searchForPackage();
void repeatSearchForPackage();
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 @@ -53,36 +53,36 @@ NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); + #endif + showUninstalledPkgs = false; + showInstalledPkgs = false; + showUpgradedPkgs = false; + initGui(); setupConnections(); updateData(); -// progressDlg = 0; -// timerId = startTimer( 100 ); } NetworkPackageManager::~NetworkPackageManager() { } void NetworkPackageManager :: timerEvent ( QTimerEvent * ) { killTimer( timerId ); -// showProgressDialog(); // Add server names to listbox updateData(); - -// progressDlg->hide(); } void NetworkPackageManager :: updateData() { serversList->clear(); packagesList->clear(); @@ -220,16 +220,33 @@ void NetworkPackageManager :: serverSelected( int ) vector<Package>::iterator it; for ( it = list.begin() ; it != list.end() ; ++it ) { QString text = ""; + // 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(); if ( it->isInstalled() ) { text += " (installed)"; // If a different version of package is available, postfix it with an * @@ -766,6 +783,24 @@ void NetworkPackageManager :: searchForPackage( bool findNext ) packagesList->setCurrentItem( item ); break; } } } } + +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 @@ -38,12 +38,16 @@ public: /** destructor */ ~NetworkPackageManager(); void selectLocalPackage( const QString &pkg ); void updateData(); void searchForPackage( bool findNext ); + void showOnlyUninstalledPackages( bool val ); + void showOnlyInstalledPackages( bool val ); + void showUpgradedPackages( bool val ); + private: DataManager *dataMgr; QComboBox *serversList; QListView *packagesList; QPushButton *update; @@ -53,12 +57,15 @@ private: ProgressDlg *progressDlg; QString currentlySelectedServer; QString lastSearchText; bool showJumpTo; + bool showUninstalledPkgs; + bool showInstalledPkgs; + bool showUpgradedPkgs; int timerId; void timerEvent ( QTimerEvent * ); void initGui(); void setupConnections(); |