author | andyq <andyq> | 2002-11-11 22:13:45 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-11-11 22:13:45 (UTC) |
commit | 99232d320496b78e92f9bd9a3c1af064940592a6 (patch) (unidiff) | |
tree | d41bc5235f2d4a62d8c3f4a8a9811116920acc81 | |
parent | 503bb111313dfb62ee6341069a75dad56bbd47bf (diff) | |
download | opie-99232d320496b78e92f9bd9a3c1af064940592a6.zip opie-99232d320496b78e92f9bd9a3c1af064940592a6.tar.gz opie-99232d320496b78e92f9bd9a3c1af064940592a6.tar.bz2 |
Fixed a bug where you couldn't download from installed pgks view
and another where buttons looked crap
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index d43c6ac..188f90d 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp | |||
@@ -1,806 +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 | ||
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | showUninstalledPkgs = false; | 62 | showUninstalledPkgs = false; |
63 | showInstalledPkgs = false; | 63 | showInstalledPkgs = false; |
64 | showUpgradedPkgs = false; | 64 | showUpgradedPkgs = false; |
65 | 65 | ||
66 | 66 | ||
67 | initGui(); | 67 | initGui(); |
68 | setupConnections(); | 68 | setupConnections(); |
69 | 69 | ||
70 | updateData(); | 70 | updateData(); |
71 | } | 71 | } |
72 | 72 | ||
73 | NetworkPackageManager::~NetworkPackageManager() | 73 | NetworkPackageManager::~NetworkPackageManager() |
74 | { | 74 | { |
75 | } | 75 | } |
76 | 76 | ||
77 | void NetworkPackageManager :: timerEvent ( QTimerEvent * ) | 77 | void NetworkPackageManager :: timerEvent ( QTimerEvent * ) |
78 | { | 78 | { |
79 | killTimer( timerId ); | 79 | killTimer( timerId ); |
80 | 80 | ||
81 | // Add server names to listbox | 81 | // Add server names to listbox |
82 | updateData(); | 82 | updateData(); |
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 | // Apply show only uninstalled packages filter | 226 | // Apply show only uninstalled packages filter |
227 | if ( showUninstalledPkgs && it->isInstalled() ) | 227 | if ( showUninstalledPkgs && it->isInstalled() ) |
228 | continue; | 228 | continue; |
229 | 229 | ||
230 | // Apply show only installed packages filter | 230 | // Apply show only installed packages filter |
231 | if ( showInstalledPkgs && !it->isInstalled() ) | 231 | if ( showInstalledPkgs && !it->isInstalled() ) |
232 | continue; | 232 | continue; |
233 | 233 | ||
234 | // Apply show only new installed packages filter | 234 | // Apply show only new installed packages filter |
235 | if ( showUpgradedPkgs ) | 235 | if ( showUpgradedPkgs ) |
236 | { | 236 | { |
237 | if ( !it->isInstalled() || | 237 | if ( !it->isInstalled() || |
238 | compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) | 238 | compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) |
239 | continue; | 239 | continue; |
240 | } | 240 | } |
241 | 241 | ||
242 | // If the local server, only display installed packages | 242 | // If the local server, only display installed packages |
243 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) | 243 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) |
244 | continue; | 244 | continue; |
245 | 245 | ||
246 | 246 | ||
247 | text += it->getPackageName(); | 247 | text += it->getPackageName(); |
248 | if ( it->isInstalled() ) | 248 | if ( it->isInstalled() ) |
249 | { | 249 | { |
250 | text += " (installed)"; | 250 | text += " (installed)"; |
251 | 251 | ||
252 | // 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 * |
253 | if ( it->getVersion() != it->getInstalledVersion() ) | 253 | if ( it->getVersion() != it->getInstalledVersion() ) |
254 | { | 254 | { |
255 | 255 | ||
256 | if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) | 256 | if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) |
257 | text += "*"; | 257 | text += "*"; |
258 | } | 258 | } |
259 | } | 259 | } |
260 | 260 | ||
261 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); | 261 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); |
262 | 262 | ||
263 | if ( it->isInstalled() ) | 263 | if ( it->isInstalled() ) |
264 | { | 264 | { |
265 | QString destName = ""; | 265 | QString destName = ""; |
266 | if ( it->getLocalPackage() ) | 266 | if ( it->getLocalPackage() ) |
267 | { | 267 | { |
268 | if ( it->getLocalPackage()->getInstalledTo() ) | 268 | if ( it->getLocalPackage()->getInstalledTo() ) |
269 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); | 269 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); |
270 | } | 270 | } |
271 | else | 271 | else |
272 | { | 272 | { |
273 | if ( it->getInstalledTo() ) | 273 | if ( it->getInstalledTo() ) |
274 | destName = it->getInstalledTo()->getDestinationName(); | 274 | destName = it->getInstalledTo()->getDestinationName(); |
275 | } | 275 | } |
276 | if ( destName != "" ) | 276 | if ( destName != "" ) |
277 | new QCheckListItem( item, QString( "Installed To - " ) + destName ); | 277 | new QCheckListItem( item, QString( "Installed To - " ) + destName ); |
278 | } | 278 | } |
279 | 279 | ||
280 | if ( !it->isPackageStoredLocally() ) | 280 | if ( !it->isPackageStoredLocally() ) |
281 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); | 281 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); |
282 | else | 282 | else |
283 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); | 283 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); |
284 | 284 | ||
285 | if ( serverName == LOCAL_SERVER ) | 285 | if ( serverName == LOCAL_SERVER ) |
286 | { | 286 | { |
287 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() ); | 287 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() ); |
288 | } | 288 | } |
289 | else | 289 | else |
290 | { | 290 | { |
291 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); | 291 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); |
292 | if ( it->getLocalPackage() ) | 292 | if ( it->getLocalPackage() ) |
293 | { | 293 | { |
294 | if ( it->isInstalled() ) | 294 | if ( it->isInstalled() ) |
295 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); | 295 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | packagesList->insertItem( item ); | 298 | packagesList->insertItem( item ); |
299 | } | 299 | } |
300 | 300 | ||
301 | // 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 |
302 | if ( serverName == LOCAL_SERVER ) | 302 | if ( serverName == LOCAL_SERVER ) |
303 | { | 303 | { |
304 | upgrade->setEnabled( false ); | 304 | upgrade->setEnabled( false ); |
305 | download->setText( "Install Remote" ); | 305 | download->setText( "Download" ); |
306 | download->setEnabled( true ); | 306 | download->setEnabled( true ); |
307 | } | 307 | } |
308 | else if ( serverName == LOCAL_IPKGS ) | 308 | else if ( serverName == LOCAL_IPKGS ) |
309 | { | 309 | { |
310 | upgrade->setEnabled( false ); | 310 | upgrade->setEnabled( false ); |
311 | download->setEnabled( true ); | 311 | download->setEnabled( true ); |
312 | download->setText( "Remove" ); | 312 | download->setText( "Remove" ); |
313 | } | 313 | } |
314 | else | 314 | else |
315 | { | 315 | { |
316 | upgrade->setEnabled( true ); | 316 | upgrade->setEnabled( true ); |
317 | download->setEnabled( true ); | 317 | download->setEnabled( true ); |
318 | download->setText( "Download" ); | 318 | download->setText( "Download" ); |
319 | } | 319 | } |
320 | } | 320 | } |
321 | 321 | ||
322 | void NetworkPackageManager :: updateServer() | 322 | void NetworkPackageManager :: updateServer() |
323 | { | 323 | { |
324 | QString serverName = serversList->currentText(); | 324 | QString serverName = serversList->currentText(); |
325 | 325 | ||
326 | // Update the current server | 326 | // Update the current server |
327 | // Display dialog | 327 | // Display dialog |
328 | // ProgressDlg *progDlg = new ProgressDlg( this ); | 328 | // ProgressDlg *progDlg = new ProgressDlg( this ); |
329 | // QString status = "Updating package lists..."; | 329 | // QString status = "Updating package lists..."; |
330 | // progDlg->show(); | 330 | // progDlg->show(); |
331 | // progDlg->setText( status ); | 331 | // progDlg->setText( status ); |
332 | 332 | ||
333 | // Disable buttons to stop silly people clicking lots on them :) | 333 | // Disable buttons to stop silly people clicking lots on them :) |
334 | 334 | ||
335 | // 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 |
336 | dataMgr->writeOutIpkgConf(); | 336 | dataMgr->writeOutIpkgConf(); |
337 | 337 | ||
338 | Ipkg ipkg; | 338 | Ipkg ipkg; |
339 | ipkg.setOption( "update" ); | 339 | ipkg.setOption( "update" ); |
340 | 340 | ||
341 | InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); | 341 | InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); |
342 | dlg.showDlg(); | 342 | dlg.showDlg(); |
343 | 343 | ||
344 | // Reload data | 344 | // Reload data |
345 | dataMgr->reloadServerData(); | 345 | dataMgr->reloadServerData(); |
346 | serverSelected(-1); | 346 | serverSelected(-1); |
347 | // delete progDlg; | 347 | // delete progDlg; |
348 | } | 348 | } |
349 | 349 | ||
350 | void NetworkPackageManager :: upgradePackages() | 350 | void NetworkPackageManager :: upgradePackages() |
351 | { | 351 | { |
352 | // We're gonna do an upgrade of all packages | 352 | // We're gonna do an upgrade of all packages |
353 | // First warn user that this isn't recommended | 353 | // First warn user that this isn't recommended |
354 | 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"; |
355 | QMessageBox warn("Warning", text, QMessageBox::Warning, | 355 | QMessageBox warn("Warning", text, QMessageBox::Warning, |
356 | QMessageBox::Yes, | 356 | QMessageBox::Yes, |
357 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 357 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
358 | 0, this ); | 358 | 0, this ); |
359 | warn.adjustSize(); | 359 | warn.adjustSize(); |
360 | 360 | ||
361 | if ( warn.exec() == QMessageBox::Yes ) | 361 | if ( warn.exec() == QMessageBox::Yes ) |
362 | { | 362 | { |
363 | // 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 |
364 | dataMgr->writeOutIpkgConf(); | 364 | dataMgr->writeOutIpkgConf(); |
365 | 365 | ||
366 | // Now run upgrade | 366 | // Now run upgrade |
367 | Ipkg ipkg; | 367 | Ipkg ipkg; |
368 | ipkg.setOption( "upgrade" ); | 368 | ipkg.setOption( "upgrade" ); |
369 | 369 | ||
370 | InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); | 370 | InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); |
371 | dlg.showDlg(); | 371 | dlg.showDlg(); |
372 | 372 | ||
373 | // Reload data | 373 | // Reload data |
374 | dataMgr->reloadServerData(); | 374 | dataMgr->reloadServerData(); |
375 | serverSelected(-1); | 375 | serverSelected(-1); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | void NetworkPackageManager :: downloadPackage() | 380 | void NetworkPackageManager :: downloadPackage() |
381 | { | 381 | { |
382 | bool doUpdate = true; | 382 | bool doUpdate = true; |
383 | if ( download->text() == "Download" ) | 383 | if ( download->text() == "Download" ) |
384 | { | 384 | { |
385 | // See if any packages are selected | 385 | // See if any packages are selected |
386 | bool found = false; | 386 | bool found = false; |
387 | if ( serversList->currentText() != LOCAL_SERVER ) | 387 | if ( serversList->currentText() != LOCAL_SERVER ) |
388 | { | 388 | { |
389 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 389 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
390 | item != 0 && !found; | 390 | item != 0 && !found; |
391 | item = (QCheckListItem *)item->nextSibling() ) | 391 | item = (QCheckListItem *)item->nextSibling() ) |
392 | { | 392 | { |
393 | if ( item->isOn() ) | 393 | if ( item->isOn() ) |
394 | found = true; | 394 | found = true; |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | // 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 |
399 | // 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 |
400 | // and whether to install it | 400 | // and whether to install it |
401 | if ( found ) | 401 | if ( found ) |
402 | downloadSelectedPackages(); | 402 | downloadSelectedPackages(); |
403 | else | 403 | else |
404 | downloadRemotePackage(); | 404 | downloadRemotePackage(); |
405 | 405 | ||
406 | } | 406 | } |
407 | else if ( download->text() == "Remove" ) | 407 | else if ( download->text() == "Remove" ) |
408 | { | 408 | { |
409 | doUpdate = false; | 409 | doUpdate = false; |
410 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 410 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
411 | item != 0 ; | 411 | item != 0 ; |
412 | item = (QCheckListItem *)item->nextSibling() ) | 412 | item = (QCheckListItem *)item->nextSibling() ) |
413 | { | 413 | { |
414 | if ( item->isOn() ) | 414 | if ( item->isOn() ) |
415 | { | 415 | { |
416 | QString name = item->text(); | 416 | QString name = item->text(); |
417 | int pos = name.find( "*" ); | 417 | int pos = name.find( "*" ); |
418 | name.truncate( pos ); | 418 | name.truncate( pos ); |
419 | 419 | ||
420 | // if (there is a (installed), remove it | 420 | // if (there is a (installed), remove it |
421 | pos = name.find( "(installed)" ); | 421 | pos = name.find( "(installed)" ); |
422 | if ( pos > 0 ) | 422 | if ( pos > 0 ) |
423 | name.truncate( pos - 1 ); | 423 | name.truncate( pos - 1 ); |
424 | 424 | ||
425 | Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); | 425 | Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); |
426 | 426 | ||
427 | QString msgtext; | 427 | QString msgtext; |
428 | 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() ); |
429 | if ( QMessageBox::information( this, "Are you sure?", | 429 | if ( QMessageBox::information( this, "Are you sure?", |
430 | msgtext, "No", "Yes" ) == 1 ) | 430 | msgtext, "No", "Yes" ) == 1 ) |
431 | { | 431 | { |
432 | doUpdate = true; | 432 | doUpdate = true; |
433 | QFile f( p->getFilename() ); | 433 | QFile f( p->getFilename() ); |
434 | f.remove(); | 434 | f.remove(); |
435 | } | 435 | } |
436 | } | 436 | } |
437 | } | 437 | } |
438 | } | 438 | } |
439 | 439 | ||
440 | if ( doUpdate ) | 440 | if ( doUpdate ) |
441 | { | 441 | { |
442 | dataMgr->reloadServerData(); | 442 | dataMgr->reloadServerData(); |
443 | serverSelected( -1 ); | 443 | serverSelected( -1 ); |
444 | } | 444 | } |
445 | } | 445 | } |
446 | 446 | ||
447 | void NetworkPackageManager :: downloadSelectedPackages() | 447 | void NetworkPackageManager :: downloadSelectedPackages() |
448 | { | 448 | { |
449 | // 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 |
450 | dataMgr->writeOutIpkgConf(); | 450 | dataMgr->writeOutIpkgConf(); |
451 | 451 | ||
452 | // Display dialog to user asking where to download the files to | 452 | // Display dialog to user asking where to download the files to |
453 | bool ok = FALSE; | 453 | bool ok = FALSE; |
454 | QString dir = ""; | 454 | QString dir = ""; |
455 | #ifdef QWS | 455 | #ifdef QWS |
456 | // read download directory from config file | 456 | // read download directory from config file |
457 | Config cfg( "aqpkg" ); | 457 | Config cfg( "aqpkg" ); |
458 | cfg.setGroup( "settings" ); | 458 | cfg.setGroup( "settings" ); |
459 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 459 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
460 | #endif | 460 | #endif |
461 | 461 | ||
462 | 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 ); |
463 | if ( ok && !text.isEmpty() ) | 463 | if ( ok && !text.isEmpty() ) |
464 | dir = text; // user entered something and pressed ok | 464 | dir = text; // user entered something and pressed ok |
465 | else | 465 | else |
466 | return; // user entered nothing or pressed cancel | 466 | return; // user entered nothing or pressed cancel |
467 | 467 | ||
468 | #ifdef QWS | 468 | #ifdef QWS |
469 | // Store download directory in config file | 469 | // Store download directory in config file |
470 | cfg.writeEntry( "downloadDir", dir ); | 470 | cfg.writeEntry( "downloadDir", dir ); |
471 | #endif | 471 | #endif |
472 | 472 | ||
473 | // Get starting directory | 473 | // Get starting directory |
474 | char initDir[PATH_MAX]; | 474 | char initDir[PATH_MAX]; |
475 | getcwd( initDir, PATH_MAX ); | 475 | getcwd( initDir, PATH_MAX ); |
476 | 476 | ||
477 | // Download each package | 477 | // Download each package |
478 | Ipkg ipkg; | 478 | Ipkg ipkg; |
479 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 479 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
480 | 480 | ||
481 | ipkg.setOption( "download" ); | 481 | ipkg.setOption( "download" ); |
482 | ipkg.setRuntimeDirectory( dir ); | 482 | ipkg.setRuntimeDirectory( dir ); |
483 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 483 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
484 | item != 0 ; | 484 | item != 0 ; |
485 | item = (QCheckListItem *)item->nextSibling() ) | 485 | item = (QCheckListItem *)item->nextSibling() ) |
486 | { | 486 | { |
487 | if ( item->isOn() ) | 487 | if ( item->isOn() ) |
488 | { | 488 | { |
489 | QString name = item->text(); | 489 | QString name = item->text(); |
490 | int pos = name.find( "*" ); | 490 | int pos = name.find( "*" ); |
491 | name.truncate( pos ); | 491 | name.truncate( pos ); |
492 | 492 | ||
493 | // if (there is a (installed), remove it | 493 | // if (there is a (installed), remove it |
494 | pos = name.find( "(installed)" ); | 494 | pos = name.find( "(installed)" ); |
495 | if ( pos > 0 ) | 495 | if ( pos > 0 ) |
496 | name.truncate( pos - 1 ); | 496 | name.truncate( pos - 1 ); |
497 | 497 | ||
498 | ipkg.setPackage( name ); | 498 | ipkg.setPackage( name ); |
499 | ipkg.runIpkg( ); | 499 | ipkg.runIpkg( ); |
500 | } | 500 | } |
501 | } | 501 | } |
502 | } | 502 | } |
503 | 503 | ||
504 | void NetworkPackageManager :: downloadRemotePackage() | 504 | void NetworkPackageManager :: downloadRemotePackage() |
505 | { | 505 | { |
506 | // Display dialog | 506 | // Display dialog |
507 | bool ok; | 507 | bool ok; |
508 | 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 ); |
509 | if ( !ok || package.isEmpty() ) | 509 | if ( !ok || package.isEmpty() ) |
510 | return; | 510 | return; |
511 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); | 511 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); |
512 | // if ( dlg.exec() == QDialog::Rejected ) | 512 | // if ( dlg.exec() == QDialog::Rejected ) |
513 | // return; | 513 | // return; |
514 | 514 | ||
515 | // grab details from dialog | 515 | // grab details from dialog |
516 | // QString package = dlg.getPackageLocation(); | 516 | // QString package = dlg.getPackageLocation(); |
517 | 517 | ||
518 | InstallData item; | 518 | InstallData item; |
519 | item.option = "I"; | 519 | item.option = "I"; |
520 | item.packageName = package; | 520 | item.packageName = package; |
521 | vector<InstallData> workingPackages; | 521 | vector<InstallData> workingPackages; |
522 | workingPackages.push_back( item ); | 522 | workingPackages.push_back( item ); |
523 | 523 | ||
524 | InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true ); | 524 | InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true ); |
525 | dlg2.showDlg(); | 525 | dlg2.showDlg(); |
526 | 526 | ||
527 | // Reload data | 527 | // Reload data |
528 | dataMgr->reloadServerData(); | 528 | dataMgr->reloadServerData(); |
529 | serverSelected(-1); | 529 | serverSelected(-1); |
530 | 530 | ||
531 | #ifdef QWS | 531 | #ifdef QWS |
532 | // Finally let the main system update itself | 532 | // Finally let the main system update itself |
533 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 533 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
534 | QString lf = QString::null; | 534 | QString lf = QString::null; |
535 | e << lf; | 535 | e << lf; |
536 | #endif | 536 | #endif |
537 | } | 537 | } |
538 | 538 | ||
539 | 539 | ||
540 | void NetworkPackageManager :: applyChanges() | 540 | void NetworkPackageManager :: applyChanges() |
541 | { | 541 | { |
542 | stickyOption = ""; | 542 | stickyOption = ""; |
543 | 543 | ||
544 | // 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 |
545 | dataMgr->writeOutIpkgConf(); | 545 | dataMgr->writeOutIpkgConf(); |
546 | 546 | ||
547 | // Now for each selected item | 547 | // Now for each selected item |
548 | // deal with it | 548 | // deal with it |
549 | 549 | ||
550 | vector<InstallData> workingPackages; | 550 | vector<InstallData> workingPackages; |
551 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 551 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
552 | item != 0 ; | 552 | item != 0 ; |
553 | item = (QCheckListItem *)item->nextSibling() ) | 553 | item = (QCheckListItem *)item->nextSibling() ) |
554 | { | 554 | { |
555 | if ( item->isOn() ) | 555 | if ( item->isOn() ) |
556 | { | 556 | { |
557 | InstallData data = dealWithItem( item ); | 557 | InstallData data = dealWithItem( item ); |
558 | workingPackages.push_back( data ); | 558 | workingPackages.push_back( data ); |
559 | } | 559 | } |
560 | } | 560 | } |
561 | 561 | ||
562 | if ( workingPackages.size() == 0 ) | 562 | if ( workingPackages.size() == 0 ) |
563 | { | 563 | { |
564 | // Nothing to do | 564 | // Nothing to do |
565 | QMessageBox::information( this, "Nothing to do", | 565 | QMessageBox::information( this, "Nothing to do", |
566 | "No packages selected", "OK" ); | 566 | "No packages selected", "OK" ); |
567 | 567 | ||
568 | return; | 568 | return; |
569 | } | 569 | } |
570 | 570 | ||
571 | // do the stuff | 571 | // do the stuff |
572 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); | 572 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); |
573 | dlg.showDlg(); | 573 | dlg.showDlg(); |
574 | 574 | ||
575 | // Reload data | 575 | // Reload data |
576 | dataMgr->reloadServerData(); | 576 | dataMgr->reloadServerData(); |
577 | serverSelected(-1); | 577 | serverSelected(-1); |
578 | 578 | ||
579 | #ifdef QWS | 579 | #ifdef QWS |
580 | // Finally let the main system update itself | 580 | // Finally let the main system update itself |
581 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 581 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
582 | QString lf = QString::null; | 582 | QString lf = QString::null; |
583 | e << lf; | 583 | e << lf; |
584 | #endif | 584 | #endif |
585 | } | 585 | } |
586 | 586 | ||
587 | // decide what to do - either remove, upgrade or install | 587 | // decide what to do - either remove, upgrade or install |
588 | // Current rules: | 588 | // Current rules: |
589 | // If not installed - install | 589 | // If not installed - install |
590 | // If installed and different version available - upgrade | 590 | // If installed and different version available - upgrade |
591 | // If installed and version up to date - remove | 591 | // If installed and version up to date - remove |
592 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | 592 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) |
593 | { | 593 | { |
594 | QString name = item->text(); | 594 | QString name = item->text(); |
595 | int pos = name.find( "*" ); | 595 | int pos = name.find( "*" ); |
596 | name.truncate( pos ); | 596 | name.truncate( pos ); |
597 | 597 | ||
598 | // if (there is a (installed), remove it | 598 | // if (there is a (installed), remove it |
599 | pos = name.find( "(installed)" ); | 599 | pos = name.find( "(installed)" ); |
600 | if ( pos > 0 ) | 600 | if ( pos > 0 ) |
601 | name.truncate( pos - 1 ); | 601 | name.truncate( pos - 1 ); |
602 | 602 | ||
603 | // Get package | 603 | // Get package |
604 | Server *s = dataMgr->getServer( serversList->currentText() ); | 604 | Server *s = dataMgr->getServer( serversList->currentText() ); |
605 | Package *p = s->getPackage( name ); | 605 | Package *p = s->getPackage( name ); |
606 | 606 | ||
607 | // 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 |
608 | if ( p->isPackageStoredLocally() ) | 608 | if ( p->isPackageStoredLocally() ) |
609 | name = p->getFilename(); | 609 | name = p->getFilename(); |
610 | 610 | ||
611 | QString option; | 611 | QString option; |
612 | QString dest = "root"; | 612 | QString dest = "root"; |
613 | if ( !p->isInstalled() ) | 613 | if ( !p->isInstalled() ) |
614 | { | 614 | { |
615 | InstallData item; | 615 | InstallData item; |
616 | item.option = "I"; | 616 | item.option = "I"; |
617 | item.packageName = name; | 617 | item.packageName = name; |
618 | return item; | 618 | return item; |
619 | } | 619 | } |
620 | else | 620 | else |
621 | { | 621 | { |
622 | InstallData item; | 622 | InstallData item; |
623 | item.option = "D"; | 623 | item.option = "D"; |
624 | if ( !p->isPackageStoredLocally() ) | 624 | if ( !p->isPackageStoredLocally() ) |
625 | item.packageName = p->getInstalledPackageName(); | 625 | item.packageName = p->getInstalledPackageName(); |
626 | else | 626 | else |
627 | item.packageName = name; | 627 | item.packageName = name; |
628 | 628 | ||
629 | if ( p->getInstalledTo() ) | 629 | if ( p->getInstalledTo() ) |
630 | { | 630 | { |
631 | item.destination = p->getInstalledTo(); | 631 | item.destination = p->getInstalledTo(); |
632 | cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; | 632 | cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; |
633 | cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; | 633 | cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; |
634 | } | 634 | } |
635 | else | 635 | else |
636 | { | 636 | { |
637 | item.destination = p->getLocalPackage()->getInstalledTo(); | 637 | item.destination = p->getLocalPackage()->getInstalledTo(); |
638 | } | 638 | } |
639 | 639 | ||
640 | // Now see if version is newer or not | 640 | // Now see if version is newer or not |
641 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | 641 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
642 | 642 | ||
643 | // 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 |
644 | if ( p->isPackageStoredLocally() && val == -1 ) | 644 | if ( p->isPackageStoredLocally() && val == -1 ) |
645 | val = 0; | 645 | val = 0; |
646 | 646 | ||
647 | if ( val == -2 ) | 647 | if ( val == -2 ) |
648 | { | 648 | { |
649 | // Error - should handle | 649 | // Error - should handle |
650 | } | 650 | } |
651 | else if ( val == -1 ) | 651 | else if ( val == -1 ) |
652 | { | 652 | { |
653 | // Version available is older - remove only | 653 | // Version available is older - remove only |
654 | item.option = "D"; | 654 | item.option = "D"; |
655 | } | 655 | } |
656 | else | 656 | else |
657 | { | 657 | { |
658 | QString caption; | 658 | QString caption; |
659 | QString text; | 659 | QString text; |
660 | QString secondButton; | 660 | QString secondButton; |
661 | QString secondOption; | 661 | QString secondOption; |
662 | if ( val == 0 ) | 662 | if ( val == 0 ) |
663 | { | 663 | { |
664 | // Version available is the same - option to remove or reinstall | 664 | // Version available is the same - option to remove or reinstall |
665 | caption = "Do you wish to remove or reinstall\n%s?"; | 665 | caption = "Do you wish to remove or reinstall\n%s?"; |
666 | text = "Remove or ReInstall"; | 666 | text = "Remove or ReInstall"; |
667 | secondButton = "ReInstall"; | 667 | secondButton = "ReInstall"; |
668 | secondOption = "R"; | 668 | secondOption = "R"; |
669 | } | 669 | } |
670 | else if ( val == 1 ) | 670 | else if ( val == 1 ) |
671 | { | 671 | { |
672 | // Version available is newer - option to remove or upgrade | 672 | // Version available is newer - option to remove or upgrade |
673 | caption = "Do you wish to remove or upgrade\n%s?"; | 673 | caption = "Do you wish to remove or upgrade\n%s?"; |
674 | text = "Remove or Upgrade"; | 674 | text = "Remove or Upgrade"; |
675 | secondButton = "Upgrade"; | 675 | secondButton = "Upgrade"; |
676 | secondOption = "U"; | 676 | secondOption = "U"; |
677 | } | 677 | } |
678 | 678 | ||
679 | // Sticky option not implemented yet, but will eventually allow | 679 | // Sticky option not implemented yet, but will eventually allow |
680 | // the user to say something like 'remove all' | 680 | // the user to say something like 'remove all' |
681 | if ( stickyOption == "" ) | 681 | if ( stickyOption == "" ) |
682 | { | 682 | { |
683 | QString msgtext; | 683 | QString msgtext; |
684 | msgtext.sprintf( caption, (const char *)name ); | 684 | msgtext.sprintf( caption, (const char *)name ); |
685 | switch( QMessageBox::information( this, text, | 685 | switch( QMessageBox::information( this, text, |
686 | msgtext, "Remove", secondButton ) ) | 686 | msgtext, "Remove", secondButton ) ) |
687 | { | 687 | { |
688 | case 0: // Try again or Enter | 688 | case 0: // Try again or Enter |
689 | // option 0 = Remove | 689 | // option 0 = Remove |
690 | item.option = "D"; | 690 | item.option = "D"; |
691 | break; | 691 | break; |
692 | case 1: // Quit or Escape | 692 | case 1: // Quit or Escape |
693 | item.option = secondOption; | 693 | item.option = secondOption; |
694 | break; | 694 | break; |
695 | } | 695 | } |
696 | } | 696 | } |
697 | else | 697 | else |
698 | { | 698 | { |
699 | // item.option = stickyOption; | 699 | // item.option = stickyOption; |
700 | } | 700 | } |
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | // Check if we are reinstalling the same version | 704 | // Check if we are reinstalling the same version |
705 | if ( item.option != "R" ) | 705 | if ( item.option != "R" ) |
706 | item.recreateLinks = true; | 706 | item.recreateLinks = true; |
707 | else | 707 | else |
708 | item.recreateLinks = false; | 708 | item.recreateLinks = false; |
709 | 709 | ||
710 | // User hit cancel (on dlg - assume remove) | 710 | // User hit cancel (on dlg - assume remove) |
711 | return item; | 711 | return item; |
712 | } | 712 | } |
713 | } | 713 | } |
714 | 714 | ||
715 | void NetworkPackageManager :: displayText( const QString &t ) | 715 | void NetworkPackageManager :: displayText( const QString &t ) |
716 | { | 716 | { |
717 | cout << t << endl; | 717 | cout << t << endl; |
718 | } | 718 | } |
719 | 719 | ||
720 | 720 | ||
721 | void NetworkPackageManager :: letterPushed( QString t ) | 721 | void NetworkPackageManager :: letterPushed( QString t ) |
722 | { | 722 | { |
723 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 723 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
724 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 724 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
725 | if ( packagesList->firstChild() == 0 ) | 725 | if ( packagesList->firstChild() == 0 ) |
726 | return; | 726 | return; |
727 | 727 | ||
728 | QCheckListItem *item; | 728 | QCheckListItem *item; |
729 | if ( start == 0 ) | 729 | if ( start == 0 ) |
730 | { | 730 | { |
731 | item = (QCheckListItem *)packagesList->firstChild(); | 731 | item = (QCheckListItem *)packagesList->firstChild(); |
732 | start = top; | 732 | start = top; |
733 | } | 733 | } |
734 | else | 734 | else |
735 | item = (QCheckListItem *)start->nextSibling(); | 735 | item = (QCheckListItem *)start->nextSibling(); |
736 | 736 | ||
737 | if ( item == 0 ) | 737 | if ( item == 0 ) |
738 | item = (QCheckListItem *)packagesList->firstChild(); | 738 | item = (QCheckListItem *)packagesList->firstChild(); |
739 | do | 739 | do |
740 | { | 740 | { |
741 | if ( item->text().lower().startsWith( t.lower() ) ) | 741 | if ( item->text().lower().startsWith( t.lower() ) ) |
742 | { | 742 | { |
743 | packagesList->setSelected( item, true ); | 743 | packagesList->setSelected( item, true ); |
744 | packagesList->ensureItemVisible( item ); | 744 | packagesList->ensureItemVisible( item ); |
745 | break; | 745 | break; |
746 | } | 746 | } |
747 | 747 | ||
748 | item = (QCheckListItem *)item->nextSibling(); | 748 | item = (QCheckListItem *)item->nextSibling(); |
749 | if ( !item ) | 749 | if ( !item ) |
750 | item = (QCheckListItem *)packagesList->firstChild(); | 750 | item = (QCheckListItem *)packagesList->firstChild(); |
751 | } while ( item != start); | 751 | } while ( item != start); |
752 | } | 752 | } |
753 | 753 | ||
754 | 754 | ||
755 | void NetworkPackageManager :: searchForPackage( bool findNext ) | 755 | void NetworkPackageManager :: searchForPackage( bool findNext ) |
756 | { | 756 | { |
757 | bool ok = false; | 757 | bool ok = false; |
758 | if ( !findNext || lastSearchText.isEmpty() ) | 758 | if ( !findNext || lastSearchText.isEmpty() ) |
759 | 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(); |
760 | else | 760 | else |
761 | ok = true; | 761 | ok = true; |
762 | 762 | ||
763 | if ( ok && !lastSearchText.isEmpty() ) | 763 | if ( ok && !lastSearchText.isEmpty() ) |
764 | { | 764 | { |
765 | cout << "searching for " << lastSearchText << endl; | 765 | cout << "searching for " << lastSearchText << endl; |
766 | // look through package list for text startng at current position | 766 | // look through package list for text startng at current position |
767 | vector<InstallData> workingPackages; | 767 | vector<InstallData> workingPackages; |
768 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 768 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
769 | if ( start != 0 ) | 769 | if ( start != 0 ) |
770 | start = (QCheckListItem *)start->nextSibling(); | 770 | start = (QCheckListItem *)start->nextSibling(); |
771 | 771 | ||
772 | if ( start == 0 ) | 772 | if ( start == 0 ) |
773 | start = (QCheckListItem *)packagesList->firstChild(); | 773 | start = (QCheckListItem *)packagesList->firstChild(); |
774 | 774 | ||
775 | for ( QCheckListItem *item = start; item != 0 ; | 775 | for ( QCheckListItem *item = start; item != 0 ; |
776 | item = (QCheckListItem *)item->nextSibling() ) | 776 | item = (QCheckListItem *)item->nextSibling() ) |
777 | { | 777 | { |
778 | cout << "checking " << item->text().lower() << endl; | 778 | cout << "checking " << item->text().lower() << endl; |
779 | if ( item->text().lower().find( lastSearchText ) != -1 ) | 779 | if ( item->text().lower().find( lastSearchText ) != -1 ) |
780 | { | 780 | { |
781 | cout << "matched " << item->text() << endl; | 781 | cout << "matched " << item->text() << endl; |
782 | packagesList->ensureItemVisible( item ); | 782 | packagesList->ensureItemVisible( item ); |
783 | packagesList->setCurrentItem( item ); | 783 | packagesList->setCurrentItem( item ); |
784 | break; | 784 | break; |
785 | } | 785 | } |
786 | } | 786 | } |
787 | } | 787 | } |
788 | } | 788 | } |
789 | 789 | ||
790 | void NetworkPackageManager :: showOnlyUninstalledPackages( bool val ) | 790 | void NetworkPackageManager :: showOnlyUninstalledPackages( bool val ) |
791 | { | 791 | { |
792 | showUninstalledPkgs = val; | 792 | showUninstalledPkgs = val; |
793 | serverSelected( -1 ); | 793 | serverSelected( -1 ); |
794 | } | 794 | } |
795 | 795 | ||
796 | void NetworkPackageManager :: showOnlyInstalledPackages( bool val ) | 796 | void NetworkPackageManager :: showOnlyInstalledPackages( bool val ) |
797 | { | 797 | { |
798 | showInstalledPkgs = val; | 798 | showInstalledPkgs = val; |
799 | serverSelected( -1 ); | 799 | serverSelected( -1 ); |
800 | } | 800 | } |
801 | 801 | ||
802 | void NetworkPackageManager :: showUpgradedPackages( bool val ) | 802 | void NetworkPackageManager :: showUpgradedPackages( bool val ) |
803 | { | 803 | { |
804 | showUpgradedPkgs = val; | 804 | showUpgradedPkgs = val; |
805 | serverSelected( -1 ); | 805 | serverSelected( -1 ); |
806 | } | 806 | } |