Diffstat (limited to 'noncore/settings/aqpkg/networkpkgmgr.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index ee37157..91afe02 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp | |||
@@ -56,27 +56,24 @@ NetworkPackageManager::NetworkPackageManager( QWidget *parent, const char *name | |||
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 | categoryFilterEnabled = false; | 65 | categoryFilterEnabled = false; |
66 | 66 | ||
67 | initGui(); | 67 | initGui(); |
68 | setupConnections(); | ||
69 | |||
70 | //updateData(); | ||
71 | } | 68 | } |
72 | 69 | ||
73 | NetworkPackageManager::~NetworkPackageManager() | 70 | NetworkPackageManager::~NetworkPackageManager() |
74 | { | 71 | { |
75 | } | 72 | } |
76 | 73 | ||
77 | void NetworkPackageManager :: setDataManager( DataManager *dm ) | 74 | void NetworkPackageManager :: setDataManager( DataManager *dm ) |
78 | { | 75 | { |
79 | dataMgr = dm; | 76 | dataMgr = dm; |
80 | } | 77 | } |
81 | 78 | ||
82 | void NetworkPackageManager :: updateData() | 79 | void NetworkPackageManager :: updateData() |
@@ -138,29 +135,27 @@ void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) | |||
138 | { | 135 | { |
139 | item->setOn( true ); | 136 | item->setOn( true ); |
140 | break; | 137 | break; |
141 | } | 138 | } |
142 | } | 139 | } |
143 | } | 140 | } |
144 | 141 | ||
145 | 142 | ||
146 | void NetworkPackageManager :: initGui() | 143 | void NetworkPackageManager :: initGui() |
147 | { | 144 | { |
148 | QLabel *l = new QLabel( tr( "Servers" ), this ); | 145 | QLabel *l = new QLabel( tr( "Servers" ), this ); |
149 | serversList = new QComboBox( this ); | 146 | serversList = new QComboBox( this ); |
147 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); | ||
148 | |||
150 | packagesList = new QListView( this ); | 149 | packagesList = new QListView( this ); |
151 | update = new QPushButton( tr( "Refresh Lists" ), this ); | ||
152 | download = new QPushButton( tr( "Download" ), this ); | ||
153 | upgrade = new QPushButton( tr( "Upgrade" ), this ); | ||
154 | apply = new QPushButton( tr( "Apply" ), this ); | ||
155 | 150 | ||
156 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1 ); | 151 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1 ); |
157 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | 152 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); |
158 | hbox1->addWidget( l ); | 153 | hbox1->addWidget( l ); |
159 | hbox1->addWidget( serversList ); | 154 | hbox1->addWidget( serversList ); |
160 | 155 | ||
161 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 ); | 156 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 ); |
162 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 ); | 157 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 ); |
163 | 158 | ||
164 | 159 | ||
165 | if ( showJumpTo ) | 160 | if ( showJumpTo ) |
166 | { | 161 | { |
@@ -171,39 +166,26 @@ void NetworkPackageManager :: initGui() | |||
171 | text[0] = 'A' + i; | 166 | text[0] = 'A' + i; |
172 | LetterPushButton *b = new LetterPushButton( text, this ); | 167 | LetterPushButton *b = new LetterPushButton( text, this ); |
173 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | 168 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); |
174 | if ( i < 13 ) | 169 | if ( i < 13 ) |
175 | hbox3->addWidget( b ); | 170 | hbox3->addWidget( b ); |
176 | else | 171 | else |
177 | hbox4->addWidget( b ); | 172 | hbox4->addWidget( b ); |
178 | } | 173 | } |
179 | } | 174 | } |
180 | 175 | ||
181 | vbox->addWidget( packagesList ); | 176 | vbox->addWidget( packagesList ); |
182 | packagesList->addColumn( tr( "Packages" ) ); | 177 | packagesList->addColumn( tr( "Packages" ) ); |
183 | 178 | ||
184 | QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1 ); | 179 | downloadEnabled = TRUE; |
185 | hbox2->addWidget( update ); | ||
186 | hbox2->addWidget( download ); | ||
187 | hbox2->addWidget( upgrade ); | ||
188 | hbox2->addWidget( apply ); | ||
189 | } | ||
190 | |||
191 | void NetworkPackageManager :: setupConnections() | ||
192 | { | ||
193 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); | ||
194 | connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); | ||
195 | connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); | ||
196 | connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); | ||
197 | connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); | ||
198 | } | 180 | } |
199 | 181 | ||
200 | void NetworkPackageManager :: serverSelected( int index ) | 182 | void NetworkPackageManager :: serverSelected( int index ) |
201 | { | 183 | { |
202 | serverSelected( index, TRUE ); | 184 | serverSelected( index, TRUE ); |
203 | } | 185 | } |
204 | 186 | ||
205 | void NetworkPackageManager :: serverSelected( int, bool raiseProgress ) | 187 | void NetworkPackageManager :: serverSelected( int, bool raiseProgress ) |
206 | { | 188 | { |
207 | // display packages | 189 | // display packages |
208 | QString serverName = serversList->currentText(); | 190 | QString serverName = serversList->currentText(); |
209 | currentlySelectedServer = serverName; | 191 | currentlySelectedServer = serverName; |
@@ -331,40 +313,38 @@ void NetworkPackageManager :: serverSelected( int, bool raiseProgress ) | |||
331 | { | 313 | { |
332 | if ( it->isInstalled() ) | 314 | if ( it->isInstalled() ) |
333 | new QCheckListItem( item, QString( tr( "V. Installed - " ) ) + it->getInstalledVersion() ); | 315 | new QCheckListItem( item, QString( tr( "V. Installed - " ) ) + it->getInstalledVersion() ); |
334 | } | 316 | } |
335 | } | 317 | } |
336 | 318 | ||
337 | packagesList->insertItem( item ); | 319 | packagesList->insertItem( item ); |
338 | } | 320 | } |
339 | 321 | ||
340 | // If the local server or the local ipkgs server disable the download button | 322 | // If the local server or the local ipkgs server disable the download button |
341 | if ( serverName == LOCAL_SERVER ) | 323 | if ( serverName == LOCAL_SERVER ) |
342 | { | 324 | { |
343 | upgrade->setEnabled( false ); | 325 | downloadEnabled = TRUE; |
344 | download->setText( tr( "Download" ) ); | 326 | emit appEnableUpgrade( FALSE ); |
345 | download->setEnabled( true ); | ||
346 | } | 327 | } |
347 | else if ( serverName == LOCAL_IPKGS ) | 328 | else if ( serverName == LOCAL_IPKGS ) |
348 | { | 329 | { |
349 | upgrade->setEnabled( false ); | 330 | downloadEnabled = FALSE; |
350 | download->setEnabled( true ); | 331 | emit appEnableUpgrade( FALSE ); |
351 | download->setText( tr( "Remove" ) ); | ||
352 | } | 332 | } |
353 | else | 333 | else |
354 | { | 334 | { |
355 | upgrade->setEnabled( true ); | 335 | downloadEnabled = TRUE; |
356 | download->setEnabled( true ); | 336 | emit appEnableUpgrade( TRUE ); |
357 | download->setText( tr( "Download" ) ); | ||
358 | } | 337 | } |
338 | emit appEnableDownload( downloadEnabled ); | ||
359 | 339 | ||
360 | // Display this widget once everything is done | 340 | // Display this widget once everything is done |
361 | if ( doProgress && raiseProgress ) | 341 | if ( doProgress && raiseProgress ) |
362 | { | 342 | { |
363 | emit appRaiseMainWidget(); | 343 | emit appRaiseMainWidget(); |
364 | } | 344 | } |
365 | } | 345 | } |
366 | 346 | ||
367 | void NetworkPackageManager :: updateServer() | 347 | void NetworkPackageManager :: updateServer() |
368 | { | 348 | { |
369 | QString serverName = serversList->currentText(); | 349 | QString serverName = serversList->currentText(); |
370 | 350 | ||
@@ -412,49 +392,49 @@ void NetworkPackageManager :: upgradePackages() | |||
412 | dlg.showDlg(); | 392 | dlg.showDlg(); |
413 | 393 | ||
414 | // Reload data | 394 | // Reload data |
415 | dataMgr->reloadServerData(); | 395 | dataMgr->reloadServerData(); |
416 | serverSelected(-1); | 396 | serverSelected(-1); |
417 | } | 397 | } |
418 | } | 398 | } |
419 | 399 | ||
420 | 400 | ||
421 | void NetworkPackageManager :: downloadPackage() | 401 | void NetworkPackageManager :: downloadPackage() |
422 | { | 402 | { |
423 | bool doUpdate = true; | 403 | bool doUpdate = true; |
424 | if ( download->text() == tr( "Download" ) ) | 404 | if ( downloadEnabled ) |
425 | { | 405 | { |
426 | // See if any packages are selected | 406 | // See if any packages are selected |
427 | bool found = false; | 407 | bool found = false; |
428 | if ( serversList->currentText() != LOCAL_SERVER ) | 408 | if ( serversList->currentText() != LOCAL_SERVER ) |
429 | { | 409 | { |
430 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 410 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
431 | item != 0 && !found; | 411 | item != 0 && !found; |
432 | item = (QCheckListItem *)item->nextSibling() ) | 412 | item = (QCheckListItem *)item->nextSibling() ) |
433 | { | 413 | { |
434 | if ( item->isOn() ) | 414 | if ( item->isOn() ) |
435 | found = true; | 415 | found = true; |
436 | } | 416 | } |
437 | } | 417 | } |
438 | 418 | ||
439 | // If user selected some packages then download the and store the locally | 419 | // If user selected some packages then download the and store the locally |
440 | // otherwise, display dialog asking user what package to download from an http server | 420 | // otherwise, display dialog asking user what package to download from an http server |
441 | // and whether to install it | 421 | // and whether to install it |
442 | if ( found ) | 422 | if ( found ) |
443 | downloadSelectedPackages(); | 423 | downloadSelectedPackages(); |
444 | else | 424 | else |
445 | downloadRemotePackage(); | 425 | downloadRemotePackage(); |
446 | 426 | ||
447 | } | 427 | } |
448 | else if ( download->text() == tr( "Remove" ) ) | 428 | else |
449 | { | 429 | { |
450 | doUpdate = false; | 430 | doUpdate = false; |
451 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 431 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
452 | item != 0 ; | 432 | item != 0 ; |
453 | item = (QCheckListItem *)item->nextSibling() ) | 433 | item = (QCheckListItem *)item->nextSibling() ) |
454 | { | 434 | { |
455 | if ( item->isOn() ) | 435 | if ( item->isOn() ) |
456 | { | 436 | { |
457 | QString name = item->text(); | 437 | QString name = item->text(); |
458 | int pos = name.find( "*" ); | 438 | int pos = name.find( "*" ); |
459 | name.truncate( pos ); | 439 | name.truncate( pos ); |
460 | 440 | ||