author | andyq <andyq> | 2002-11-09 15:39:15 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-11-09 15:39:15 (UTC) |
commit | 5ab7af2bb5d98aef639cbc2ca14f630813fd4fe9 (patch) (unidiff) | |
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 | |||
@@ -1,111 +1,184 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | mainwin.cpp - description | 2 | mainwin.cpp - 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 | #include <qmenubar.h> | 18 | #include <qmenubar.h> |
19 | #include <qpopupmenu.h> | 19 | #include <qpopupmenu.h> |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | 21 | ||
22 | #include "mainwin.h" | 22 | #include "mainwin.h" |
23 | #include "datamgr.h" | 23 | #include "datamgr.h" |
24 | #include "networkpkgmgr.h" | 24 | #include "networkpkgmgr.h" |
25 | #include "settingsimpl.h" | 25 | #include "settingsimpl.h" |
26 | #include "helpwindow.h" | 26 | #include "helpwindow.h" |
27 | #include "utils.h" | 27 | #include "utils.h" |
28 | #include "global.h" | 28 | #include "global.h" |
29 | 29 | ||
30 | MainWindow :: MainWindow( QWidget *p, char *name ) | 30 | MainWindow :: MainWindow( QWidget *p, char *name ) |
31 | :QMainWindow( p, name ) | 31 | :QMainWindow( p, name ) |
32 | { | 32 | { |
33 | #ifdef QWS | 33 | #ifdef QWS |
34 | showMaximized(); | 34 | showMaximized(); |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | setCaption( "AQPkg - Package Manager" ); | 37 | setCaption( "AQPkg - Package Manager" ); |
38 | 38 | ||
39 | // Create our menu | 39 | // Create our menu |
40 | QPopupMenu *help = new QPopupMenu( this ); | 40 | help = new QPopupMenu( this ); |
41 | 41 | help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_G ); | |
42 | help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_H ); | ||
43 | help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); | 42 | help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); |
44 | 43 | ||
45 | QPopupMenu *settings = new QPopupMenu( this ); | 44 | settings = new QPopupMenu( this ); |
46 | settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); | 45 | settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); |
47 | 46 | ||
48 | QPopupMenu *edit = new QPopupMenu( this ); | 47 | edit = new QPopupMenu( this ); |
49 | edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_F ); | 48 | edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_I ); |
50 | edit->insertItem( "&Find Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_R ); | 49 | edit->insertItem( "Find &Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_N ); |
51 | 50 | ||
51 | filter = new QPopupMenu( this ); | ||
52 | mnuShowUninstalledPkgsId = filter->insertItem( "Show &Uninstalled Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U ); | ||
53 | mnuShowInstalledPkgsId = filter->insertItem( "Show In&stalled Packages", this, SLOT(filterInstalledPackages()), Qt::CTRL+Qt::Key_S ); | ||
54 | mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P ); | ||
55 | |||
52 | // Create the main menu | 56 | // Create the main menu |
53 | QMenuBar *menu = menuBar(); //new QMenuBar( this ); | 57 | menu = menuBar(); //new QMenuBar( this ); |
54 | menu->insertItem( "&Settings", settings ); | 58 | menu->insertItem( "&Settings", settings ); |
55 | menu->insertItem( "&Edit", edit ); | 59 | menu->insertItem( "&Edit", edit ); |
60 | menu->insertItem( "&Filter", filter ); | ||
56 | menu->insertItem( "&Help", help ); | 61 | menu->insertItem( "&Help", help ); |
57 | 62 | ||
58 | mgr = new DataManager(); | 63 | mgr = new DataManager(); |
59 | mgr->loadServers(); | 64 | mgr->loadServers(); |
60 | 65 | ||
61 | stack = new QWidgetStack( this ); | 66 | stack = new QWidgetStack( this ); |
62 | 67 | ||
63 | networkPkgWindow = new NetworkPackageManager( mgr, stack ); | 68 | networkPkgWindow = new NetworkPackageManager( mgr, stack ); |
64 | stack->addWidget( networkPkgWindow, 1 ); | 69 | stack->addWidget( networkPkgWindow, 1 ); |
65 | 70 | ||
66 | setCentralWidget( stack ); | 71 | setCentralWidget( stack ); |
67 | stack->raiseWidget( networkPkgWindow ); | 72 | stack->raiseWidget( networkPkgWindow ); |
68 | } | 73 | } |
69 | 74 | ||
70 | MainWindow :: ~MainWindow() | 75 | MainWindow :: ~MainWindow() |
71 | { | 76 | { |
72 | delete networkPkgWindow; | 77 | delete networkPkgWindow; |
73 | } | 78 | } |
74 | 79 | ||
75 | void MainWindow :: setDocument( const QString &doc ) | 80 | void MainWindow :: setDocument( const QString &doc ) |
76 | { | 81 | { |
77 | // Remove path from package | 82 | // Remove path from package |
78 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 83 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
79 | cout << "Selecting package " << package << endl; | 84 | cout << "Selecting package " << package << endl; |
80 | networkPkgWindow->selectLocalPackage( package ); | 85 | networkPkgWindow->selectLocalPackage( package ); |
81 | } | 86 | } |
82 | 87 | ||
83 | void MainWindow :: displaySettings() | 88 | void MainWindow :: displaySettings() |
84 | { | 89 | { |
85 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 90 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
86 | if ( dlg->showDlg( 0 ) ) | 91 | if ( dlg->showDlg( 0 ) ) |
87 | networkPkgWindow->updateData(); | 92 | networkPkgWindow->updateData(); |
88 | delete dlg; | 93 | delete dlg; |
89 | } | 94 | } |
90 | 95 | ||
91 | void MainWindow :: displayHelp() | 96 | void MainWindow :: displayHelp() |
92 | { | 97 | { |
93 | HelpWindow *dlg = new HelpWindow( this ); | 98 | HelpWindow *dlg = new HelpWindow( this ); |
94 | dlg->exec(); | 99 | dlg->exec(); |
95 | delete dlg; | 100 | delete dlg; |
96 | } | 101 | } |
97 | 102 | ||
98 | void MainWindow :: searchForPackage() | 103 | void MainWindow :: searchForPackage() |
99 | { | 104 | { |
100 | networkPkgWindow->searchForPackage( false ); | 105 | networkPkgWindow->searchForPackage( false ); |
101 | } | 106 | } |
102 | 107 | ||
103 | void MainWindow :: repeatSearchForPackage() | 108 | void MainWindow :: repeatSearchForPackage() |
104 | { | 109 | { |
105 | networkPkgWindow->searchForPackage( true ); | 110 | networkPkgWindow->searchForPackage( true ); |
106 | } | 111 | } |
107 | 112 | ||
108 | void MainWindow :: displayAbout() | 113 | void MainWindow :: displayAbout() |
109 | { | 114 | { |
110 | QMessageBox::about( this, "About AQPkg", VERSION_TEXT ); | 115 | QMessageBox::about( this, "About AQPkg", VERSION_TEXT ); |
111 | } | 116 | } |
117 | |||
118 | |||
119 | void MainWindow :: filterUninstalledPackages() | ||
120 | { | ||
121 | bool val; | ||
122 | if ( filter->isItemChecked( mnuShowUninstalledPkgsId ) ) | ||
123 | { | ||
124 | val = false; | ||
125 | filter->setItemChecked( mnuShowUninstalledPkgsId, false ); | ||
126 | } | ||
127 | else | ||
128 | { | ||
129 | val = true; | ||
130 | filter->setItemChecked( mnuShowUninstalledPkgsId, true ); | ||
131 | } | ||
132 | |||
133 | filter->setItemChecked( mnuShowInstalledPkgsId, false ); | ||
134 | networkPkgWindow->showOnlyInstalledPackages( false ); | ||
135 | filter->setItemChecked( mnuShowUpgradedPkgsId, false ); | ||
136 | networkPkgWindow->showUpgradedPackages( false ); | ||
137 | |||
138 | networkPkgWindow->showOnlyUninstalledPackages( val ); | ||
139 | |||
140 | } | ||
141 | |||
142 | void MainWindow :: filterInstalledPackages() | ||
143 | { | ||
144 | bool val; | ||
145 | if ( filter->isItemChecked( mnuShowInstalledPkgsId ) ) | ||
146 | { | ||
147 | val = false; | ||
148 | filter->setItemChecked( mnuShowInstalledPkgsId, false ); | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | val = true; | ||
153 | filter->setItemChecked( mnuShowInstalledPkgsId, true ); | ||
154 | } | ||
155 | |||
156 | filter->setItemChecked( mnuShowUninstalledPkgsId, false ); | ||
157 | networkPkgWindow->showOnlyUninstalledPackages( false ); | ||
158 | filter->setItemChecked( mnuShowUpgradedPkgsId, false ); | ||
159 | networkPkgWindow->showUpgradedPackages( false ); | ||
160 | |||
161 | networkPkgWindow->showOnlyInstalledPackages( val ); | ||
162 | } | ||
163 | |||
164 | void MainWindow :: filterUpgradedPackages() | ||
165 | { | ||
166 | bool val; | ||
167 | if ( filter->isItemChecked( mnuShowUpgradedPkgsId ) ) | ||
168 | { | ||
169 | val = false; | ||
170 | filter->setItemChecked( mnuShowUpgradedPkgsId, false ); | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | val = true; | ||
175 | filter->setItemChecked( mnuShowUpgradedPkgsId, true ); | ||
176 | } | ||
177 | |||
178 | filter->setItemChecked( mnuShowUninstalledPkgsId, false ); | ||
179 | networkPkgWindow->showOnlyUninstalledPackages( false ); | ||
180 | filter->setItemChecked( mnuShowInstalledPkgsId, false ); | ||
181 | networkPkgWindow->showOnlyInstalledPackages( false ); | ||
182 | |||
183 | networkPkgWindow->showUpgradedPackages( val ); | ||
184 | } | ||
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 | |||
@@ -1,50 +1,63 @@ | |||
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 <qwidgetstack.h> | 22 | #include <qwidgetstack.h> |
23 | 23 | ||
24 | 24 | ||
25 | class NetworkPackageManager; | 25 | class NetworkPackageManager; |
26 | class DataManager; | 26 | class DataManager; |
27 | 27 | ||
28 | class MainWindow :public QMainWindow | 28 | class MainWindow :public QMainWindow |
29 | { | 29 | { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | public: | 31 | public: |
32 | 32 | ||
33 | MainWindow( QWidget *p = 0, char *name = 0 ); | 33 | MainWindow( QWidget *p = 0, char *name = 0 ); |
34 | ~MainWindow(); | 34 | ~MainWindow(); |
35 | 35 | ||
36 | private: | 36 | private: |
37 | DataManager *mgr; | 37 | DataManager *mgr; |
38 | 38 | ||
39 | QMenuBar *menu; | ||
40 | QPopupMenu *help; | ||
41 | QPopupMenu *settings; | ||
42 | QPopupMenu *edit; | ||
43 | QPopupMenu *filter; | ||
39 | QWidgetStack *stack; | 44 | QWidgetStack *stack; |
40 | NetworkPackageManager *networkPkgWindow; | 45 | |
46 | NetworkPackageManager *networkPkgWindow; | ||
47 | |||
48 | int mnuShowUninstalledPkgsId; | ||
49 | int mnuShowInstalledPkgsId; | ||
50 | int mnuShowUpgradedPkgsId; | ||
41 | 51 | ||
42 | public slots: | 52 | public slots: |
43 | void setDocument( const QString &doc ); | 53 | void setDocument( const QString &doc ); |
44 | void displayHelp(); | 54 | void displayHelp(); |
45 | void searchForPackage(); | 55 | void searchForPackage(); |
46 | void repeatSearchForPackage(); | 56 | void repeatSearchForPackage(); |
47 | void displayAbout(); | 57 | void displayAbout(); |
48 | void displaySettings(); | 58 | void displaySettings(); |
59 | void filterUninstalledPackages(); | ||
60 | void filterInstalledPackages(); | ||
61 | void filterUpgradedPackages(); | ||
49 | }; | 62 | }; |
50 | #endif | 63 | #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 | |||
@@ -11,120 +11,120 @@ | |||
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 | #include <fstream> | 18 | #include <fstream> |
19 | #include <iostream> | 19 | #include <iostream> |
20 | using namespace std; | 20 | using namespace std; |
21 | 21 | ||
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <linux/limits.h> | 24 | #include <linux/limits.h> |
25 | 25 | ||
26 | #ifdef QWS | 26 | #ifdef QWS |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
29 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
30 | #else | 30 | #else |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | #endif | 32 | #endif |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | 36 | ||
37 | #include "datamgr.h" | 37 | #include "datamgr.h" |
38 | #include "networkpkgmgr.h" | 38 | #include "networkpkgmgr.h" |
39 | #include "installdlgimpl.h" | 39 | #include "installdlgimpl.h" |
40 | #include "ipkg.h" | 40 | #include "ipkg.h" |
41 | #include "inputdlg.h" | 41 | #include "inputdlg.h" |
42 | #include "letterpushbutton.h" | 42 | #include "letterpushbutton.h" |
43 | 43 | ||
44 | #include "global.h" | 44 | #include "global.h" |
45 | 45 | ||
46 | extern int compareVersions( const char *v1, const char *v2 ); | 46 | extern int compareVersions( const char *v1, const char *v2 ); |
47 | 47 | ||
48 | NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) | 48 | NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) |
49 | : QWidget(parent, name) | 49 | : QWidget(parent, name) |
50 | { | 50 | { |
51 | dataMgr = dataManager; | 51 | dataMgr = dataManager; |
52 | 52 | ||
53 | #ifdef QWS | 53 | #ifdef QWS |
54 | // read download directory from config file | 54 | // read download directory from config file |
55 | Config cfg( "aqpkg" ); | 55 | Config cfg( "aqpkg" ); |
56 | cfg.setGroup( "settings" ); | 56 | cfg.setGroup( "settings" ); |
57 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 57 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
58 | showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | 58 | showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); |
59 | |||
59 | #endif | 60 | #endif |
61 | |||
62 | showUninstalledPkgs = false; | ||
63 | showInstalledPkgs = false; | ||
64 | showUpgradedPkgs = false; | ||
60 | 65 | ||
61 | 66 | ||
62 | initGui(); | 67 | initGui(); |
63 | setupConnections(); | 68 | setupConnections(); |
64 | 69 | ||
65 | updateData(); | 70 | updateData(); |
66 | // progressDlg = 0; | ||
67 | // timerId = startTimer( 100 ); | ||
68 | } | 71 | } |
69 | 72 | ||
70 | NetworkPackageManager::~NetworkPackageManager() | 73 | NetworkPackageManager::~NetworkPackageManager() |
71 | { | 74 | { |
72 | } | 75 | } |
73 | 76 | ||
74 | void NetworkPackageManager :: timerEvent ( QTimerEvent * ) | 77 | void NetworkPackageManager :: timerEvent ( QTimerEvent * ) |
75 | { | 78 | { |
76 | killTimer( timerId ); | 79 | killTimer( timerId ); |
77 | 80 | ||
78 | // showProgressDialog(); | ||
79 | // Add server names to listbox | 81 | // Add server names to listbox |
80 | updateData(); | 82 | updateData(); |
81 | |||
82 | // progressDlg->hide(); | ||
83 | } | 83 | } |
84 | 84 | ||
85 | void NetworkPackageManager :: updateData() | 85 | void NetworkPackageManager :: updateData() |
86 | { | 86 | { |
87 | serversList->clear(); | 87 | serversList->clear(); |
88 | packagesList->clear(); | 88 | packagesList->clear(); |
89 | 89 | ||
90 | 90 | ||
91 | vector<Server>::iterator it; | 91 | vector<Server>::iterator it; |
92 | int activeItem = -1; | 92 | int activeItem = -1; |
93 | int i; | 93 | int i; |
94 | for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) | 94 | for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) |
95 | { | 95 | { |
96 | if ( !it->isServerActive() ) | 96 | if ( !it->isServerActive() ) |
97 | { | 97 | { |
98 | i--; | 98 | i--; |
99 | continue; | 99 | continue; |
100 | } | 100 | } |
101 | serversList->insertItem( it->getServerName() ); | 101 | serversList->insertItem( it->getServerName() ); |
102 | if ( it->getServerName() == currentlySelectedServer ) | 102 | if ( it->getServerName() == currentlySelectedServer ) |
103 | activeItem = i; | 103 | activeItem = i; |
104 | } | 104 | } |
105 | 105 | ||
106 | // set selected server to be active server | 106 | // set selected server to be active server |
107 | if ( activeItem != -1 ) | 107 | if ( activeItem != -1 ) |
108 | serversList->setCurrentItem( activeItem ); | 108 | serversList->setCurrentItem( activeItem ); |
109 | serverSelected( 0 ); | 109 | serverSelected( 0 ); |
110 | } | 110 | } |
111 | 111 | ||
112 | void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) | 112 | void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) |
113 | { | 113 | { |
114 | // First select local server | 114 | // First select local server |
115 | for ( int i = 0 ; i < serversList->count() ; ++i ) | 115 | for ( int i = 0 ; i < serversList->count() ; ++i ) |
116 | { | 116 | { |
117 | if ( serversList->text( i ) == LOCAL_IPKGS ) | 117 | if ( serversList->text( i ) == LOCAL_IPKGS ) |
118 | { | 118 | { |
119 | serversList->setCurrentItem( i ); | 119 | serversList->setCurrentItem( i ); |
120 | break; | 120 | break; |
121 | } | 121 | } |
122 | } | 122 | } |
123 | serverSelected( 0 ); | 123 | serverSelected( 0 ); |
124 | 124 | ||
125 | // Now set the check box of the selected package | 125 | // Now set the check box of the selected package |
126 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 126 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
127 | item != 0 ; | 127 | item != 0 ; |
128 | item = (QCheckListItem *)item->nextSibling() ) | 128 | item = (QCheckListItem *)item->nextSibling() ) |
129 | { | 129 | { |
130 | if ( item->text().startsWith( pkg ) ) | 130 | if ( item->text().startsWith( pkg ) ) |
@@ -178,99 +178,116 @@ void NetworkPackageManager :: initGui() | |||
178 | hbox2->addWidget( update ); | 178 | hbox2->addWidget( update ); |
179 | hbox2->addWidget( download ); | 179 | hbox2->addWidget( download ); |
180 | hbox2->addWidget( upgrade ); | 180 | hbox2->addWidget( upgrade ); |
181 | hbox2->addWidget( apply ); | 181 | hbox2->addWidget( apply ); |
182 | } | 182 | } |
183 | 183 | ||
184 | void NetworkPackageManager :: setupConnections() | 184 | void NetworkPackageManager :: setupConnections() |
185 | { | 185 | { |
186 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); | 186 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); |
187 | connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); | 187 | connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); |
188 | connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); | 188 | connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); |
189 | connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); | 189 | connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); |
190 | connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); | 190 | connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); |
191 | } | 191 | } |
192 | 192 | ||
193 | void NetworkPackageManager :: showProgressDialog( char *initialText ) | 193 | void NetworkPackageManager :: showProgressDialog( char *initialText ) |
194 | { | 194 | { |
195 | if ( !progressDlg ) | 195 | if ( !progressDlg ) |
196 | progressDlg = new ProgressDlg( this, "Progress", false ); | 196 | progressDlg = new ProgressDlg( this, "Progress", false ); |
197 | progressDlg->setText( initialText ); | 197 | progressDlg->setText( initialText ); |
198 | progressDlg->show(); | 198 | progressDlg->show(); |
199 | } | 199 | } |
200 | 200 | ||
201 | 201 | ||
202 | void NetworkPackageManager :: serverSelected( int ) | 202 | void NetworkPackageManager :: serverSelected( int ) |
203 | { | 203 | { |
204 | packagesList->clear(); | 204 | packagesList->clear(); |
205 | 205 | ||
206 | // display packages | 206 | // display packages |
207 | QString serverName = serversList->currentText(); | 207 | QString serverName = serversList->currentText(); |
208 | currentlySelectedServer = serverName; | 208 | currentlySelectedServer = serverName; |
209 | 209 | ||
210 | #ifdef QWS | 210 | #ifdef QWS |
211 | // read download directory from config file | 211 | // read download directory from config file |
212 | Config cfg( "aqpkg" ); | 212 | Config cfg( "aqpkg" ); |
213 | cfg.setGroup( "settings" ); | 213 | cfg.setGroup( "settings" ); |
214 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 214 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
215 | #endif | 215 | #endif |
216 | 216 | ||
217 | Server *s = dataMgr->getServer( serverName ); | 217 | Server *s = dataMgr->getServer( serverName ); |
218 | 218 | ||
219 | vector<Package> &list = s->getPackageList(); | 219 | vector<Package> &list = s->getPackageList(); |
220 | vector<Package>::iterator it; | 220 | vector<Package>::iterator it; |
221 | for ( it = list.begin() ; it != list.end() ; ++it ) | 221 | for ( it = list.begin() ; it != list.end() ; ++it ) |
222 | { | 222 | { |
223 | 223 | ||
224 | QString text = ""; | 224 | QString text = ""; |
225 | 225 | ||
226 | // If the local server, only display installed packages | 226 | // Apply show only uninstalled packages filter |
227 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) | 227 | if ( showUninstalledPkgs && it->isInstalled() ) |
228 | continue; | 228 | continue; |
229 | |||
230 | // Apply show only installed packages filter | ||
231 | if ( showInstalledPkgs && !it->isInstalled() ) | ||
232 | continue; | ||
233 | |||
234 | // Apply show only new installed packages filter | ||
235 | if ( showUpgradedPkgs ) | ||
236 | { | ||
237 | if ( !it->isInstalled() || | ||
238 | compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) | ||
239 | continue; | ||
240 | } | ||
241 | |||
242 | // If the local server, only display installed packages | ||
243 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) | ||
244 | continue; | ||
245 | |||
229 | 246 | ||
230 | text += it->getPackageName(); | 247 | text += it->getPackageName(); |
231 | if ( it->isInstalled() ) | 248 | if ( it->isInstalled() ) |
232 | { | 249 | { |
233 | text += " (installed)"; | 250 | text += " (installed)"; |
234 | 251 | ||
235 | // If a different version of package is available, postfix it with an * | 252 | // If a different version of package is available, postfix it with an * |
236 | if ( it->getVersion() != it->getInstalledVersion() ) | 253 | if ( it->getVersion() != it->getInstalledVersion() ) |
237 | { | 254 | { |
238 | 255 | ||
239 | if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) | 256 | if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) |
240 | text += "*"; | 257 | text += "*"; |
241 | } | 258 | } |
242 | } | 259 | } |
243 | 260 | ||
244 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); | 261 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); |
245 | 262 | ||
246 | if ( it->isInstalled() ) | 263 | if ( it->isInstalled() ) |
247 | { | 264 | { |
248 | QString destName = ""; | 265 | QString destName = ""; |
249 | if ( it->getLocalPackage() ) | 266 | if ( it->getLocalPackage() ) |
250 | { | 267 | { |
251 | if ( it->getLocalPackage()->getInstalledTo() ) | 268 | if ( it->getLocalPackage()->getInstalledTo() ) |
252 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); | 269 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); |
253 | } | 270 | } |
254 | else | 271 | else |
255 | { | 272 | { |
256 | if ( it->getInstalledTo() ) | 273 | if ( it->getInstalledTo() ) |
257 | destName = it->getInstalledTo()->getDestinationName(); | 274 | destName = it->getInstalledTo()->getDestinationName(); |
258 | } | 275 | } |
259 | if ( destName != "" ) | 276 | if ( destName != "" ) |
260 | new QCheckListItem( item, QString( "Installed To - " ) + destName ); | 277 | new QCheckListItem( item, QString( "Installed To - " ) + destName ); |
261 | } | 278 | } |
262 | 279 | ||
263 | if ( !it->isPackageStoredLocally() ) | 280 | if ( !it->isPackageStoredLocally() ) |
264 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); | 281 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); |
265 | else | 282 | else |
266 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); | 283 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); |
267 | 284 | ||
268 | if ( serverName == LOCAL_SERVER ) | 285 | if ( serverName == LOCAL_SERVER ) |
269 | { | 286 | { |
270 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() ); | 287 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() ); |
271 | } | 288 | } |
272 | else | 289 | else |
273 | { | 290 | { |
274 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); | 291 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); |
275 | if ( it->getLocalPackage() ) | 292 | if ( it->getLocalPackage() ) |
276 | { | 293 | { |
@@ -724,48 +741,66 @@ void NetworkPackageManager :: letterPushed( QString t ) | |||
724 | if ( item->text().lower().startsWith( t.lower() ) ) | 741 | if ( item->text().lower().startsWith( t.lower() ) ) |
725 | { | 742 | { |
726 | packagesList->setSelected( item, true ); | 743 | packagesList->setSelected( item, true ); |
727 | packagesList->ensureItemVisible( item ); | 744 | packagesList->ensureItemVisible( item ); |
728 | break; | 745 | break; |
729 | } | 746 | } |
730 | 747 | ||
731 | item = (QCheckListItem *)item->nextSibling(); | 748 | item = (QCheckListItem *)item->nextSibling(); |
732 | if ( !item ) | 749 | if ( !item ) |
733 | item = (QCheckListItem *)packagesList->firstChild(); | 750 | item = (QCheckListItem *)packagesList->firstChild(); |
734 | } while ( item != start); | 751 | } while ( item != start); |
735 | } | 752 | } |
736 | 753 | ||
737 | 754 | ||
738 | void NetworkPackageManager :: searchForPackage( bool findNext ) | 755 | void NetworkPackageManager :: searchForPackage( bool findNext ) |
739 | { | 756 | { |
740 | bool ok = false; | 757 | bool ok = false; |
741 | if ( !findNext || lastSearchText.isEmpty() ) | 758 | if ( !findNext || lastSearchText.isEmpty() ) |
742 | lastSearchText = InputDialog::getText( "Search for package", "Enter package to search for", lastSearchText, &ok, this ).lower(); | 759 | lastSearchText = InputDialog::getText( "Search for package", "Enter package to search for", lastSearchText, &ok, this ).lower(); |
743 | else | 760 | else |
744 | ok = true; | 761 | ok = true; |
745 | 762 | ||
746 | if ( ok && !lastSearchText.isEmpty() ) | 763 | if ( ok && !lastSearchText.isEmpty() ) |
747 | { | 764 | { |
748 | cout << "searching for " << lastSearchText << endl; | 765 | cout << "searching for " << lastSearchText << endl; |
749 | // look through package list for text startng at current position | 766 | // look through package list for text startng at current position |
750 | vector<InstallData> workingPackages; | 767 | vector<InstallData> workingPackages; |
751 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 768 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
752 | if ( start != 0 ) | 769 | if ( start != 0 ) |
753 | start = (QCheckListItem *)start->nextSibling(); | 770 | start = (QCheckListItem *)start->nextSibling(); |
754 | 771 | ||
755 | if ( start == 0 ) | 772 | if ( start == 0 ) |
756 | start = (QCheckListItem *)packagesList->firstChild(); | 773 | start = (QCheckListItem *)packagesList->firstChild(); |
757 | 774 | ||
758 | for ( QCheckListItem *item = start; item != 0 ; | 775 | for ( QCheckListItem *item = start; item != 0 ; |
759 | item = (QCheckListItem *)item->nextSibling() ) | 776 | item = (QCheckListItem *)item->nextSibling() ) |
760 | { | 777 | { |
761 | cout << "checking " << item->text().lower() << endl; | 778 | cout << "checking " << item->text().lower() << endl; |
762 | if ( item->text().lower().find( lastSearchText ) != -1 ) | 779 | if ( item->text().lower().find( lastSearchText ) != -1 ) |
763 | { | 780 | { |
764 | cout << "matched " << item->text() << endl; | 781 | cout << "matched " << item->text() << endl; |
765 | packagesList->ensureItemVisible( item ); | 782 | packagesList->ensureItemVisible( item ); |
766 | packagesList->setCurrentItem( item ); | 783 | packagesList->setCurrentItem( item ); |
767 | break; | 784 | break; |
768 | } | 785 | } |
769 | } | 786 | } |
770 | } | 787 | } |
771 | } | 788 | } |
789 | |||
790 | void NetworkPackageManager :: showOnlyUninstalledPackages( bool val ) | ||
791 | { | ||
792 | showUninstalledPkgs = val; | ||
793 | serverSelected( -1 ); | ||
794 | } | ||
795 | |||
796 | void NetworkPackageManager :: showOnlyInstalledPackages( bool val ) | ||
797 | { | ||
798 | showInstalledPkgs = val; | ||
799 | serverSelected( -1 ); | ||
800 | } | ||
801 | |||
802 | void NetworkPackageManager :: showUpgradedPackages( bool val ) | ||
803 | { | ||
804 | showUpgradedPkgs = val; | ||
805 | serverSelected( -1 ); | ||
806 | } | ||
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 | |||
@@ -1,81 +1,88 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | networkpkgmgr.h - description | 2 | networkpkgmgr.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 NETWORKPKGMGR_H | 18 | #ifndef NETWORKPKGMGR_H |
19 | #define NETWORKPKGMGR_H | 19 | #define NETWORKPKGMGR_H |
20 | 20 | ||
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | 26 | ||
27 | #include "datamgr.h" | 27 | #include "datamgr.h" |
28 | #include "progressdlg.h" | 28 | #include "progressdlg.h" |
29 | class InstallData; | 29 | class InstallData; |
30 | 30 | ||
31 | /** NetworkPackageManager is the base class of the project */ | 31 | /** NetworkPackageManager is the base class of the project */ |
32 | class NetworkPackageManager : public QWidget | 32 | class NetworkPackageManager : public QWidget |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | /** construtor */ | 36 | /** construtor */ |
37 | NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0); | 37 | NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0); |
38 | /** destructor */ | 38 | /** destructor */ |
39 | ~NetworkPackageManager(); | 39 | ~NetworkPackageManager(); |
40 | 40 | ||
41 | void selectLocalPackage( const QString &pkg ); | 41 | void selectLocalPackage( const QString &pkg ); |
42 | void updateData(); | 42 | void updateData(); |
43 | void searchForPackage( bool findNext ); | 43 | void searchForPackage( bool findNext ); |
44 | void showOnlyUninstalledPackages( bool val ); | ||
45 | void showOnlyInstalledPackages( bool val ); | ||
46 | void showUpgradedPackages( bool val ); | ||
47 | |||
44 | private: | 48 | private: |
45 | DataManager *dataMgr; | 49 | DataManager *dataMgr; |
46 | 50 | ||
47 | QComboBox *serversList; | 51 | QComboBox *serversList; |
48 | QListView *packagesList; | 52 | QListView *packagesList; |
49 | QPushButton *update; | 53 | QPushButton *update; |
50 | QPushButton *upgrade; | 54 | QPushButton *upgrade; |
51 | QPushButton *download; | 55 | QPushButton *download; |
52 | QPushButton *apply; | 56 | QPushButton *apply; |
53 | 57 | ||
54 | ProgressDlg *progressDlg; | 58 | ProgressDlg *progressDlg; |
55 | QString currentlySelectedServer; | 59 | QString currentlySelectedServer; |
56 | QString lastSearchText; | 60 | QString lastSearchText; |
57 | 61 | ||
58 | bool showJumpTo; | 62 | bool showJumpTo; |
63 | bool showUninstalledPkgs; | ||
64 | bool showInstalledPkgs; | ||
65 | bool showUpgradedPkgs; | ||
59 | int timerId; | 66 | int timerId; |
60 | 67 | ||
61 | void timerEvent ( QTimerEvent * ); | 68 | void timerEvent ( QTimerEvent * ); |
62 | 69 | ||
63 | void initGui(); | 70 | void initGui(); |
64 | void setupConnections(); | 71 | void setupConnections(); |
65 | void showProgressDialog( char *initialText ); | 72 | void showProgressDialog( char *initialText ); |
66 | void downloadSelectedPackages(); | 73 | void downloadSelectedPackages(); |
67 | void downloadRemotePackage(); | 74 | void downloadRemotePackage(); |
68 | InstallData dealWithItem( QCheckListItem *item ); | 75 | InstallData dealWithItem( QCheckListItem *item ); |
69 | QString stickyOption; | 76 | QString stickyOption; |
70 | 77 | ||
71 | public slots: | 78 | public slots: |
72 | void serverSelected( int index ); | 79 | void serverSelected( int index ); |
73 | void applyChanges(); | 80 | void applyChanges(); |
74 | void upgradePackages(); | 81 | void upgradePackages(); |
75 | void downloadPackage(); | 82 | void downloadPackage(); |
76 | void updateServer(); | 83 | void updateServer(); |
77 | void displayText( const QString &t ); | 84 | void displayText( const QString &t ); |
78 | void letterPushed( QString t ); | 85 | void letterPushed( QString t ); |
79 | }; | 86 | }; |
80 | 87 | ||
81 | #endif | 88 | #endif |