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 | |||
@@ -1,771 +1,806 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | networkpkgmgr.cpp - description | 2 | networkpkgmgr.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 <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 ) ) |
131 | { | 131 | { |
132 | item->setOn( true ); | 132 | item->setOn( true ); |
133 | break; | 133 | break; |
134 | } | 134 | } |
135 | } | 135 | } |
136 | } | 136 | } |
137 | 137 | ||
138 | 138 | ||
139 | void NetworkPackageManager :: initGui() | 139 | void NetworkPackageManager :: initGui() |
140 | { | 140 | { |
141 | QLabel *l = new QLabel( "Servers", this ); | 141 | QLabel *l = new QLabel( "Servers", this ); |
142 | serversList = new QComboBox( this ); | 142 | serversList = new QComboBox( this ); |
143 | packagesList = new QListView( this ); | 143 | packagesList = new QListView( this ); |
144 | update = new QPushButton( "Refresh Lists", this ); | 144 | update = new QPushButton( "Refresh Lists", this ); |
145 | download = new QPushButton( "Download", this ); | 145 | download = new QPushButton( "Download", this ); |
146 | upgrade = new QPushButton( "Upgrade", this ); | 146 | upgrade = new QPushButton( "Upgrade", this ); |
147 | apply = new QPushButton( "Apply", this ); | 147 | apply = new QPushButton( "Apply", this ); |
148 | 148 | ||
149 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); | 149 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); |
150 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); | 150 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); |
151 | hbox1->addWidget( l ); | 151 | hbox1->addWidget( l ); |
152 | hbox1->addWidget( serversList ); | 152 | hbox1->addWidget( serversList ); |
153 | 153 | ||
154 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); | 154 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); |
155 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); | 155 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); |
156 | 156 | ||
157 | 157 | ||
158 | if ( showJumpTo ) | 158 | if ( showJumpTo ) |
159 | { | 159 | { |
160 | char text[2]; | 160 | char text[2]; |
161 | text[1] = '\0'; | 161 | text[1] = '\0'; |
162 | for ( int i = 0 ; i < 26 ; ++i ) | 162 | for ( int i = 0 ; i < 26 ; ++i ) |
163 | { | 163 | { |
164 | text[0] = 'A' + i; | 164 | text[0] = 'A' + i; |
165 | LetterPushButton *b = new LetterPushButton( text, this ); | 165 | LetterPushButton *b = new LetterPushButton( text, this ); |
166 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | 166 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); |
167 | if ( i < 13 ) | 167 | if ( i < 13 ) |
168 | hbox3->addWidget( b ); | 168 | hbox3->addWidget( b ); |
169 | else | 169 | else |
170 | hbox4->addWidget( b ); | 170 | hbox4->addWidget( b ); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | vbox->addWidget( packagesList ); | 174 | vbox->addWidget( packagesList ); |
175 | packagesList->addColumn( "Packages" ); | 175 | packagesList->addColumn( "Packages" ); |
176 | 176 | ||
177 | QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); | 177 | QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); |
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 | { |
277 | if ( it->isInstalled() ) | 294 | if ( it->isInstalled() ) |
278 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); | 295 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); |
279 | } | 296 | } |
280 | } | 297 | } |
281 | packagesList->insertItem( item ); | 298 | packagesList->insertItem( item ); |
282 | } | 299 | } |
283 | 300 | ||
284 | // If the local server or the local ipkgs server disable the download button | 301 | // If the local server or the local ipkgs server disable the download button |
285 | if ( serverName == LOCAL_SERVER ) | 302 | if ( serverName == LOCAL_SERVER ) |
286 | { | 303 | { |
287 | upgrade->setEnabled( false ); | 304 | upgrade->setEnabled( false ); |
288 | download->setText( "Install Remote" ); | 305 | download->setText( "Install Remote" ); |
289 | download->setEnabled( true ); | 306 | download->setEnabled( true ); |
290 | } | 307 | } |
291 | else if ( serverName == LOCAL_IPKGS ) | 308 | else if ( serverName == LOCAL_IPKGS ) |
292 | { | 309 | { |
293 | upgrade->setEnabled( false ); | 310 | upgrade->setEnabled( false ); |
294 | download->setEnabled( true ); | 311 | download->setEnabled( true ); |
295 | download->setText( "Remove" ); | 312 | download->setText( "Remove" ); |
296 | } | 313 | } |
297 | else | 314 | else |
298 | { | 315 | { |
299 | upgrade->setEnabled( true ); | 316 | upgrade->setEnabled( true ); |
300 | download->setEnabled( true ); | 317 | download->setEnabled( true ); |
301 | download->setText( "Download" ); | 318 | download->setText( "Download" ); |
302 | } | 319 | } |
303 | } | 320 | } |
304 | 321 | ||
305 | void NetworkPackageManager :: updateServer() | 322 | void NetworkPackageManager :: updateServer() |
306 | { | 323 | { |
307 | QString serverName = serversList->currentText(); | 324 | QString serverName = serversList->currentText(); |
308 | 325 | ||
309 | // Update the current server | 326 | // Update the current server |
310 | // Display dialog | 327 | // Display dialog |
311 | // ProgressDlg *progDlg = new ProgressDlg( this ); | 328 | // ProgressDlg *progDlg = new ProgressDlg( this ); |
312 | // QString status = "Updating package lists..."; | 329 | // QString status = "Updating package lists..."; |
313 | // progDlg->show(); | 330 | // progDlg->show(); |
314 | // progDlg->setText( status ); | 331 | // progDlg->setText( status ); |
315 | 332 | ||
316 | // Disable buttons to stop silly people clicking lots on them :) | 333 | // Disable buttons to stop silly people clicking lots on them :) |
317 | 334 | ||
318 | // First, write out ipkg_conf file so that ipkg can use it | 335 | // First, write out ipkg_conf file so that ipkg can use it |
319 | dataMgr->writeOutIpkgConf(); | 336 | dataMgr->writeOutIpkgConf(); |
320 | 337 | ||
321 | Ipkg ipkg; | 338 | Ipkg ipkg; |
322 | ipkg.setOption( "update" ); | 339 | ipkg.setOption( "update" ); |
323 | 340 | ||
324 | InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); | 341 | InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); |
325 | dlg.showDlg(); | 342 | dlg.showDlg(); |
326 | 343 | ||
327 | // Reload data | 344 | // Reload data |
328 | dataMgr->reloadServerData(); | 345 | dataMgr->reloadServerData(); |
329 | serverSelected(-1); | 346 | serverSelected(-1); |
330 | // delete progDlg; | 347 | // delete progDlg; |
331 | } | 348 | } |
332 | 349 | ||
333 | void NetworkPackageManager :: upgradePackages() | 350 | void NetworkPackageManager :: upgradePackages() |
334 | { | 351 | { |
335 | // We're gonna do an upgrade of all packages | 352 | // We're gonna do an upgrade of all packages |
336 | // First warn user that this isn't recommended | 353 | // First warn user that this isn't recommended |
337 | QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; | 354 | QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; |
338 | QMessageBox warn("Warning", text, QMessageBox::Warning, | 355 | QMessageBox warn("Warning", text, QMessageBox::Warning, |
339 | QMessageBox::Yes, | 356 | QMessageBox::Yes, |
340 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 357 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
341 | 0, this ); | 358 | 0, this ); |
342 | warn.adjustSize(); | 359 | warn.adjustSize(); |
343 | 360 | ||
344 | if ( warn.exec() == QMessageBox::Yes ) | 361 | if ( warn.exec() == QMessageBox::Yes ) |
345 | { | 362 | { |
346 | // First, write out ipkg_conf file so that ipkg can use it | 363 | // First, write out ipkg_conf file so that ipkg can use it |
347 | dataMgr->writeOutIpkgConf(); | 364 | dataMgr->writeOutIpkgConf(); |
348 | 365 | ||
349 | // Now run upgrade | 366 | // Now run upgrade |
350 | Ipkg ipkg; | 367 | Ipkg ipkg; |
351 | ipkg.setOption( "upgrade" ); | 368 | ipkg.setOption( "upgrade" ); |
352 | 369 | ||
353 | InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); | 370 | InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); |
354 | dlg.showDlg(); | 371 | dlg.showDlg(); |
355 | 372 | ||
356 | // Reload data | 373 | // Reload data |
357 | dataMgr->reloadServerData(); | 374 | dataMgr->reloadServerData(); |
358 | serverSelected(-1); | 375 | serverSelected(-1); |
359 | } | 376 | } |
360 | } | 377 | } |
361 | 378 | ||
362 | 379 | ||
363 | void NetworkPackageManager :: downloadPackage() | 380 | void NetworkPackageManager :: downloadPackage() |
364 | { | 381 | { |
365 | bool doUpdate = true; | 382 | bool doUpdate = true; |
366 | if ( download->text() == "Download" ) | 383 | if ( download->text() == "Download" ) |
367 | { | 384 | { |
368 | // See if any packages are selected | 385 | // See if any packages are selected |
369 | bool found = false; | 386 | bool found = false; |
370 | if ( serversList->currentText() != LOCAL_SERVER ) | 387 | if ( serversList->currentText() != LOCAL_SERVER ) |
371 | { | 388 | { |
372 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 389 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
373 | item != 0 && !found; | 390 | item != 0 && !found; |
374 | item = (QCheckListItem *)item->nextSibling() ) | 391 | item = (QCheckListItem *)item->nextSibling() ) |
375 | { | 392 | { |
376 | if ( item->isOn() ) | 393 | if ( item->isOn() ) |
377 | found = true; | 394 | found = true; |
378 | } | 395 | } |
379 | } | 396 | } |
380 | 397 | ||
381 | // If user selected some packages then download the and store the locally | 398 | // If user selected some packages then download the and store the locally |
382 | // otherwise, display dialog asking user what package to download from an http server | 399 | // otherwise, display dialog asking user what package to download from an http server |
383 | // and whether to install it | 400 | // and whether to install it |
384 | if ( found ) | 401 | if ( found ) |
385 | downloadSelectedPackages(); | 402 | downloadSelectedPackages(); |
386 | else | 403 | else |
387 | downloadRemotePackage(); | 404 | downloadRemotePackage(); |
388 | 405 | ||
389 | } | 406 | } |
390 | else if ( download->text() == "Remove" ) | 407 | else if ( download->text() == "Remove" ) |
391 | { | 408 | { |
392 | doUpdate = false; | 409 | doUpdate = false; |
393 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 410 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
394 | item != 0 ; | 411 | item != 0 ; |
395 | item = (QCheckListItem *)item->nextSibling() ) | 412 | item = (QCheckListItem *)item->nextSibling() ) |
396 | { | 413 | { |
397 | if ( item->isOn() ) | 414 | if ( item->isOn() ) |
398 | { | 415 | { |
399 | QString name = item->text(); | 416 | QString name = item->text(); |
400 | int pos = name.find( "*" ); | 417 | int pos = name.find( "*" ); |
401 | name.truncate( pos ); | 418 | name.truncate( pos ); |
402 | 419 | ||
403 | // if (there is a (installed), remove it | 420 | // if (there is a (installed), remove it |
404 | pos = name.find( "(installed)" ); | 421 | pos = name.find( "(installed)" ); |
405 | if ( pos > 0 ) | 422 | if ( pos > 0 ) |
406 | name.truncate( pos - 1 ); | 423 | name.truncate( pos - 1 ); |
407 | 424 | ||
408 | Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); | 425 | Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); |
409 | 426 | ||
410 | QString msgtext; | 427 | QString msgtext; |
411 | msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() ); | 428 | msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() ); |
412 | if ( QMessageBox::information( this, "Are you sure?", | 429 | if ( QMessageBox::information( this, "Are you sure?", |
413 | msgtext, "No", "Yes" ) == 1 ) | 430 | msgtext, "No", "Yes" ) == 1 ) |
414 | { | 431 | { |
415 | doUpdate = true; | 432 | doUpdate = true; |
416 | QFile f( p->getFilename() ); | 433 | QFile f( p->getFilename() ); |
417 | f.remove(); | 434 | f.remove(); |
418 | } | 435 | } |
419 | } | 436 | } |
420 | } | 437 | } |
421 | } | 438 | } |
422 | 439 | ||
423 | if ( doUpdate ) | 440 | if ( doUpdate ) |
424 | { | 441 | { |
425 | dataMgr->reloadServerData(); | 442 | dataMgr->reloadServerData(); |
426 | serverSelected( -1 ); | 443 | serverSelected( -1 ); |
427 | } | 444 | } |
428 | } | 445 | } |
429 | 446 | ||
430 | void NetworkPackageManager :: downloadSelectedPackages() | 447 | void NetworkPackageManager :: downloadSelectedPackages() |
431 | { | 448 | { |
432 | // First, write out ipkg_conf file so that ipkg can use it | 449 | // First, write out ipkg_conf file so that ipkg can use it |
433 | dataMgr->writeOutIpkgConf(); | 450 | dataMgr->writeOutIpkgConf(); |
434 | 451 | ||
435 | // Display dialog to user asking where to download the files to | 452 | // Display dialog to user asking where to download the files to |
436 | bool ok = FALSE; | 453 | bool ok = FALSE; |
437 | QString dir = ""; | 454 | QString dir = ""; |
438 | #ifdef QWS | 455 | #ifdef QWS |
439 | // read download directory from config file | 456 | // read download directory from config file |
440 | Config cfg( "aqpkg" ); | 457 | Config cfg( "aqpkg" ); |
441 | cfg.setGroup( "settings" ); | 458 | cfg.setGroup( "settings" ); |
442 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 459 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
443 | #endif | 460 | #endif |
444 | 461 | ||
445 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 462 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
446 | if ( ok && !text.isEmpty() ) | 463 | if ( ok && !text.isEmpty() ) |
447 | dir = text; // user entered something and pressed ok | 464 | dir = text; // user entered something and pressed ok |
448 | else | 465 | else |
449 | return; // user entered nothing or pressed cancel | 466 | return; // user entered nothing or pressed cancel |
450 | 467 | ||
451 | #ifdef QWS | 468 | #ifdef QWS |
452 | // Store download directory in config file | 469 | // Store download directory in config file |
453 | cfg.writeEntry( "downloadDir", dir ); | 470 | cfg.writeEntry( "downloadDir", dir ); |
454 | #endif | 471 | #endif |
455 | 472 | ||
456 | // Get starting directory | 473 | // Get starting directory |
457 | char initDir[PATH_MAX]; | 474 | char initDir[PATH_MAX]; |
458 | getcwd( initDir, PATH_MAX ); | 475 | getcwd( initDir, PATH_MAX ); |
459 | 476 | ||
460 | // Download each package | 477 | // Download each package |
461 | Ipkg ipkg; | 478 | Ipkg ipkg; |
462 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 479 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
463 | 480 | ||
464 | ipkg.setOption( "download" ); | 481 | ipkg.setOption( "download" ); |
465 | ipkg.setRuntimeDirectory( dir ); | 482 | ipkg.setRuntimeDirectory( dir ); |
466 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 483 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
467 | item != 0 ; | 484 | item != 0 ; |
468 | item = (QCheckListItem *)item->nextSibling() ) | 485 | item = (QCheckListItem *)item->nextSibling() ) |
469 | { | 486 | { |
470 | if ( item->isOn() ) | 487 | if ( item->isOn() ) |
471 | { | 488 | { |
472 | QString name = item->text(); | 489 | QString name = item->text(); |
473 | int pos = name.find( "*" ); | 490 | int pos = name.find( "*" ); |
474 | name.truncate( pos ); | 491 | name.truncate( pos ); |
475 | 492 | ||
476 | // if (there is a (installed), remove it | 493 | // if (there is a (installed), remove it |
477 | pos = name.find( "(installed)" ); | 494 | pos = name.find( "(installed)" ); |
478 | if ( pos > 0 ) | 495 | if ( pos > 0 ) |
479 | name.truncate( pos - 1 ); | 496 | name.truncate( pos - 1 ); |
480 | 497 | ||
481 | ipkg.setPackage( name ); | 498 | ipkg.setPackage( name ); |
482 | ipkg.runIpkg( ); | 499 | ipkg.runIpkg( ); |
483 | } | 500 | } |
484 | } | 501 | } |
485 | } | 502 | } |
486 | 503 | ||
487 | void NetworkPackageManager :: downloadRemotePackage() | 504 | void NetworkPackageManager :: downloadRemotePackage() |
488 | { | 505 | { |
489 | // Display dialog | 506 | // Display dialog |
490 | bool ok; | 507 | bool ok; |
491 | QString package = InputDialog::getText( "Install Remote Package", tr( "Enter package location" ), "http://", &ok, this ); | 508 | QString package = InputDialog::getText( "Install Remote Package", tr( "Enter package location" ), "http://", &ok, this ); |
492 | if ( !ok || package.isEmpty() ) | 509 | if ( !ok || package.isEmpty() ) |
493 | return; | 510 | return; |
494 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); | 511 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); |
495 | // if ( dlg.exec() == QDialog::Rejected ) | 512 | // if ( dlg.exec() == QDialog::Rejected ) |
496 | // return; | 513 | // return; |
497 | 514 | ||
498 | // grab details from dialog | 515 | // grab details from dialog |
499 | // QString package = dlg.getPackageLocation(); | 516 | // QString package = dlg.getPackageLocation(); |
500 | 517 | ||
501 | InstallData item; | 518 | InstallData item; |
502 | item.option = "I"; | 519 | item.option = "I"; |
503 | item.packageName = package; | 520 | item.packageName = package; |
504 | vector<InstallData> workingPackages; | 521 | vector<InstallData> workingPackages; |
505 | workingPackages.push_back( item ); | 522 | workingPackages.push_back( item ); |
506 | 523 | ||
507 | InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true ); | 524 | InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true ); |
508 | dlg2.showDlg(); | 525 | dlg2.showDlg(); |
509 | 526 | ||
510 | // Reload data | 527 | // Reload data |
511 | dataMgr->reloadServerData(); | 528 | dataMgr->reloadServerData(); |
512 | serverSelected(-1); | 529 | serverSelected(-1); |
513 | 530 | ||
514 | #ifdef QWS | 531 | #ifdef QWS |
515 | // Finally let the main system update itself | 532 | // Finally let the main system update itself |
516 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 533 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
517 | QString lf = QString::null; | 534 | QString lf = QString::null; |
518 | e << lf; | 535 | e << lf; |
519 | #endif | 536 | #endif |
520 | } | 537 | } |
521 | 538 | ||
522 | 539 | ||
523 | void NetworkPackageManager :: applyChanges() | 540 | void NetworkPackageManager :: applyChanges() |
524 | { | 541 | { |
525 | stickyOption = ""; | 542 | stickyOption = ""; |
526 | 543 | ||
527 | // First, write out ipkg_conf file so that ipkg can use it | 544 | // First, write out ipkg_conf file so that ipkg can use it |
528 | dataMgr->writeOutIpkgConf(); | 545 | dataMgr->writeOutIpkgConf(); |
529 | 546 | ||
530 | // Now for each selected item | 547 | // Now for each selected item |
531 | // deal with it | 548 | // deal with it |
532 | 549 | ||
533 | vector<InstallData> workingPackages; | 550 | vector<InstallData> workingPackages; |
534 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 551 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
535 | item != 0 ; | 552 | item != 0 ; |
536 | item = (QCheckListItem *)item->nextSibling() ) | 553 | item = (QCheckListItem *)item->nextSibling() ) |
537 | { | 554 | { |
538 | if ( item->isOn() ) | 555 | if ( item->isOn() ) |
539 | { | 556 | { |
540 | InstallData data = dealWithItem( item ); | 557 | InstallData data = dealWithItem( item ); |
541 | workingPackages.push_back( data ); | 558 | workingPackages.push_back( data ); |
542 | } | 559 | } |
543 | } | 560 | } |
544 | 561 | ||
545 | if ( workingPackages.size() == 0 ) | 562 | if ( workingPackages.size() == 0 ) |
546 | { | 563 | { |
547 | // Nothing to do | 564 | // Nothing to do |
548 | QMessageBox::information( this, "Nothing to do", | 565 | QMessageBox::information( this, "Nothing to do", |
549 | "No packages selected", "OK" ); | 566 | "No packages selected", "OK" ); |
550 | 567 | ||
551 | return; | 568 | return; |
552 | } | 569 | } |
553 | 570 | ||
554 | // do the stuff | 571 | // do the stuff |
555 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); | 572 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); |
556 | dlg.showDlg(); | 573 | dlg.showDlg(); |
557 | 574 | ||
558 | // Reload data | 575 | // Reload data |
559 | dataMgr->reloadServerData(); | 576 | dataMgr->reloadServerData(); |
560 | serverSelected(-1); | 577 | serverSelected(-1); |
561 | 578 | ||
562 | #ifdef QWS | 579 | #ifdef QWS |
563 | // Finally let the main system update itself | 580 | // Finally let the main system update itself |
564 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 581 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
565 | QString lf = QString::null; | 582 | QString lf = QString::null; |
566 | e << lf; | 583 | e << lf; |
567 | #endif | 584 | #endif |
568 | } | 585 | } |
569 | 586 | ||
570 | // decide what to do - either remove, upgrade or install | 587 | // decide what to do - either remove, upgrade or install |
571 | // Current rules: | 588 | // Current rules: |
572 | // If not installed - install | 589 | // If not installed - install |
573 | // If installed and different version available - upgrade | 590 | // If installed and different version available - upgrade |
574 | // If installed and version up to date - remove | 591 | // If installed and version up to date - remove |
575 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | 592 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) |
576 | { | 593 | { |
577 | QString name = item->text(); | 594 | QString name = item->text(); |
578 | int pos = name.find( "*" ); | 595 | int pos = name.find( "*" ); |
579 | name.truncate( pos ); | 596 | name.truncate( pos ); |
580 | 597 | ||
581 | // if (there is a (installed), remove it | 598 | // if (there is a (installed), remove it |
582 | pos = name.find( "(installed)" ); | 599 | pos = name.find( "(installed)" ); |
583 | if ( pos > 0 ) | 600 | if ( pos > 0 ) |
584 | name.truncate( pos - 1 ); | 601 | name.truncate( pos - 1 ); |
585 | 602 | ||
586 | // Get package | 603 | // Get package |
587 | Server *s = dataMgr->getServer( serversList->currentText() ); | 604 | Server *s = dataMgr->getServer( serversList->currentText() ); |
588 | Package *p = s->getPackage( name ); | 605 | Package *p = s->getPackage( name ); |
589 | 606 | ||
590 | // If the package has a filename then it is a local file | 607 | // If the package has a filename then it is a local file |
591 | if ( p->isPackageStoredLocally() ) | 608 | if ( p->isPackageStoredLocally() ) |
592 | name = p->getFilename(); | 609 | name = p->getFilename(); |
593 | 610 | ||
594 | QString option; | 611 | QString option; |
595 | QString dest = "root"; | 612 | QString dest = "root"; |
596 | if ( !p->isInstalled() ) | 613 | if ( !p->isInstalled() ) |
597 | { | 614 | { |
598 | InstallData item; | 615 | InstallData item; |
599 | item.option = "I"; | 616 | item.option = "I"; |
600 | item.packageName = name; | 617 | item.packageName = name; |
601 | return item; | 618 | return item; |
602 | } | 619 | } |
603 | else | 620 | else |
604 | { | 621 | { |
605 | InstallData item; | 622 | InstallData item; |
606 | item.option = "D"; | 623 | item.option = "D"; |
607 | if ( !p->isPackageStoredLocally() ) | 624 | if ( !p->isPackageStoredLocally() ) |
608 | item.packageName = p->getInstalledPackageName(); | 625 | item.packageName = p->getInstalledPackageName(); |
609 | else | 626 | else |
610 | item.packageName = name; | 627 | item.packageName = name; |
611 | 628 | ||
612 | if ( p->getInstalledTo() ) | 629 | if ( p->getInstalledTo() ) |
613 | { | 630 | { |
614 | item.destination = p->getInstalledTo(); | 631 | item.destination = p->getInstalledTo(); |
615 | cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; | 632 | cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; |
616 | cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; | 633 | cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; |
617 | } | 634 | } |
618 | else | 635 | else |
619 | { | 636 | { |
620 | item.destination = p->getLocalPackage()->getInstalledTo(); | 637 | item.destination = p->getLocalPackage()->getInstalledTo(); |
621 | } | 638 | } |
622 | 639 | ||
623 | // Now see if version is newer or not | 640 | // Now see if version is newer or not |
624 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | 641 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
625 | 642 | ||
626 | // If the version requested is older and user selected a local ipk file, then reinstall the file | 643 | // If the version requested is older and user selected a local ipk file, then reinstall the file |
627 | if ( p->isPackageStoredLocally() && val == -1 ) | 644 | if ( p->isPackageStoredLocally() && val == -1 ) |
628 | val = 0; | 645 | val = 0; |
629 | 646 | ||
630 | if ( val == -2 ) | 647 | if ( val == -2 ) |
631 | { | 648 | { |
632 | // Error - should handle | 649 | // Error - should handle |
633 | } | 650 | } |
634 | else if ( val == -1 ) | 651 | else if ( val == -1 ) |
635 | { | 652 | { |
636 | // Version available is older - remove only | 653 | // Version available is older - remove only |
637 | item.option = "D"; | 654 | item.option = "D"; |
638 | } | 655 | } |
639 | else | 656 | else |
640 | { | 657 | { |
641 | QString caption; | 658 | QString caption; |
642 | QString text; | 659 | QString text; |
643 | QString secondButton; | 660 | QString secondButton; |
644 | QString secondOption; | 661 | QString secondOption; |
645 | if ( val == 0 ) | 662 | if ( val == 0 ) |
646 | { | 663 | { |
647 | // Version available is the same - option to remove or reinstall | 664 | // Version available is the same - option to remove or reinstall |
648 | caption = "Do you wish to remove or reinstall\n%s?"; | 665 | caption = "Do you wish to remove or reinstall\n%s?"; |
649 | text = "Remove or ReInstall"; | 666 | text = "Remove or ReInstall"; |
650 | secondButton = "ReInstall"; | 667 | secondButton = "ReInstall"; |
651 | secondOption = "R"; | 668 | secondOption = "R"; |
652 | } | 669 | } |
653 | else if ( val == 1 ) | 670 | else if ( val == 1 ) |
654 | { | 671 | { |
655 | // Version available is newer - option to remove or upgrade | 672 | // Version available is newer - option to remove or upgrade |
656 | caption = "Do you wish to remove or upgrade\n%s?"; | 673 | caption = "Do you wish to remove or upgrade\n%s?"; |
657 | text = "Remove or Upgrade"; | 674 | text = "Remove or Upgrade"; |
658 | secondButton = "Upgrade"; | 675 | secondButton = "Upgrade"; |
659 | secondOption = "U"; | 676 | secondOption = "U"; |
660 | } | 677 | } |
661 | 678 | ||
662 | // Sticky option not implemented yet, but will eventually allow | 679 | // Sticky option not implemented yet, but will eventually allow |
663 | // the user to say something like 'remove all' | 680 | // the user to say something like 'remove all' |
664 | if ( stickyOption == "" ) | 681 | if ( stickyOption == "" ) |
665 | { | 682 | { |
666 | QString msgtext; | 683 | QString msgtext; |
667 | msgtext.sprintf( caption, (const char *)name ); | 684 | msgtext.sprintf( caption, (const char *)name ); |
668 | switch( QMessageBox::information( this, text, | 685 | switch( QMessageBox::information( this, text, |
669 | msgtext, "Remove", secondButton ) ) | 686 | msgtext, "Remove", secondButton ) ) |
670 | { | 687 | { |
671 | case 0: // Try again or Enter | 688 | case 0: // Try again or Enter |
672 | // option 0 = Remove | 689 | // option 0 = Remove |
673 | item.option = "D"; | 690 | item.option = "D"; |
674 | break; | 691 | break; |
675 | case 1: // Quit or Escape | 692 | case 1: // Quit or Escape |
676 | item.option = secondOption; | 693 | item.option = secondOption; |
677 | break; | 694 | break; |
678 | } | 695 | } |
679 | } | 696 | } |
680 | else | 697 | else |
681 | { | 698 | { |
682 | // item.option = stickyOption; | 699 | // item.option = stickyOption; |
683 | } | 700 | } |
684 | } | 701 | } |
685 | 702 | ||
686 | 703 | ||
687 | // Check if we are reinstalling the same version | 704 | // Check if we are reinstalling the same version |
688 | if ( item.option != "R" ) | 705 | if ( item.option != "R" ) |
689 | item.recreateLinks = true; | 706 | item.recreateLinks = true; |
690 | else | 707 | else |
691 | item.recreateLinks = false; | 708 | item.recreateLinks = false; |
692 | 709 | ||
693 | // User hit cancel (on dlg - assume remove) | 710 | // User hit cancel (on dlg - assume remove) |
694 | return item; | 711 | return item; |
695 | } | 712 | } |
696 | } | 713 | } |
697 | 714 | ||
698 | void NetworkPackageManager :: displayText( const QString &t ) | 715 | void NetworkPackageManager :: displayText( const QString &t ) |
699 | { | 716 | { |
700 | cout << t << endl; | 717 | cout << t << endl; |
701 | } | 718 | } |
702 | 719 | ||
703 | 720 | ||
704 | void NetworkPackageManager :: letterPushed( QString t ) | 721 | void NetworkPackageManager :: letterPushed( QString t ) |
705 | { | 722 | { |
706 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 723 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
707 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 724 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
708 | if ( packagesList->firstChild() == 0 ) | 725 | if ( packagesList->firstChild() == 0 ) |
709 | return; | 726 | return; |
710 | 727 | ||
711 | QCheckListItem *item; | 728 | QCheckListItem *item; |
712 | if ( start == 0 ) | 729 | if ( start == 0 ) |
713 | { | 730 | { |
714 | item = (QCheckListItem *)packagesList->firstChild(); | 731 | item = (QCheckListItem *)packagesList->firstChild(); |
715 | start = top; | 732 | start = top; |
716 | } | 733 | } |
717 | else | 734 | else |
718 | item = (QCheckListItem *)start->nextSibling(); | 735 | item = (QCheckListItem *)start->nextSibling(); |
719 | 736 | ||
720 | if ( item == 0 ) | 737 | if ( item == 0 ) |
721 | item = (QCheckListItem *)packagesList->firstChild(); | 738 | item = (QCheckListItem *)packagesList->firstChild(); |
722 | do | 739 | do |
723 | { | 740 | { |
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 |