Diffstat (limited to 'noncore/settings/aqpkg/networkpkgmgr.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 97 |
1 files changed, 73 insertions, 24 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 0bc01df..318b26d 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp | |||
@@ -39,6 +39,7 @@ using namespace std; | |||
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 | 43 | ||
43 | #include "global.h" | 44 | #include "global.h" |
44 | 45 | ||
@@ -47,6 +48,14 @@ NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget | |||
47 | { | 48 | { |
48 | dataMgr = dataManager; | 49 | dataMgr = dataManager; |
49 | 50 | ||
51 | #ifdef QWS | ||
52 | // read download directory from config file | ||
53 | Config cfg( "aqpkg" ); | ||
54 | cfg.setGroup( "settings" ); | ||
55 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | ||
56 | #endif | ||
57 | |||
58 | |||
50 | initGui(); | 59 | initGui(); |
51 | setupConnections(); | 60 | setupConnections(); |
52 | 61 | ||
@@ -80,7 +89,7 @@ void NetworkPackageManager :: updateData() | |||
80 | for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) | 89 | for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) |
81 | { | 90 | { |
82 | serversList->insertItem( it->getServerName() ); | 91 | serversList->insertItem( it->getServerName() ); |
83 | if ( it->getServerName() == dataMgr->getActiveServer() ) | 92 | if ( it->getServerName() == currentlySelectedServer ) |
84 | activeItem = i; | 93 | activeItem = i; |
85 | } | 94 | } |
86 | 95 | ||
@@ -106,6 +115,22 @@ void NetworkPackageManager :: initGui() | |||
106 | hbox1->addWidget( l ); | 115 | hbox1->addWidget( l ); |
107 | hbox1->addWidget( serversList ); | 116 | hbox1->addWidget( serversList ); |
108 | 117 | ||
118 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); | ||
119 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); | ||
120 | |||
121 | char text[2]; | ||
122 | text[1] = '\0'; | ||
123 | for ( int i = 0 ; i < 26 ; ++i ) | ||
124 | { | ||
125 | text[0] = 'A' + i; | ||
126 | LetterPushButton *b = new LetterPushButton( text, this ); | ||
127 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | ||
128 | if ( i < 16 ) | ||
129 | hbox3->addWidget( b ); | ||
130 | else | ||
131 | hbox4->addWidget( b ); | ||
132 | } | ||
133 | |||
109 | vbox->addWidget( packagesList ); | 134 | vbox->addWidget( packagesList ); |
110 | packagesList->addColumn( "Packages" ); | 135 | packagesList->addColumn( "Packages" ); |
111 | 136 | ||
@@ -140,8 +165,17 @@ void NetworkPackageManager :: serverSelected( int ) | |||
140 | 165 | ||
141 | // display packages | 166 | // display packages |
142 | QString serverName = serversList->currentText(); | 167 | QString serverName = serversList->currentText(); |
168 | currentlySelectedServer = serverName; | ||
169 | |||
170 | #ifdef QWS | ||
171 | // read download directory from config file | ||
172 | Config cfg( "aqpkg" ); | ||
173 | cfg.setGroup( "settings" ); | ||
174 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | ||
175 | #endif | ||
176 | |||
143 | Server *s = dataMgr->getServer( serverName ); | 177 | Server *s = dataMgr->getServer( serverName ); |
144 | dataMgr->setActiveServer( serverName ); | 178 | // dataMgr->setActiveServer( serverName ); |
145 | 179 | ||
146 | vector<Package> &list = s->getPackageList(); | 180 | vector<Package> &list = s->getPackageList(); |
147 | vector<Package>::iterator it; | 181 | vector<Package>::iterator it; |
@@ -206,8 +240,7 @@ void NetworkPackageManager :: updateServer() | |||
206 | // Update the current server | 240 | // Update the current server |
207 | // Display dialog | 241 | // Display dialog |
208 | ProgressDlg *dlg = new ProgressDlg( this ); | 242 | ProgressDlg *dlg = new ProgressDlg( this ); |
209 | QString status = "Updating package list for "; | 243 | QString status = "Updating package lists..."; |
210 | status += serverName; | ||
211 | dlg->show(); | 244 | dlg->show(); |
212 | dlg->setText( status ); | 245 | dlg->setText( status ); |
213 | 246 | ||
@@ -216,11 +249,11 @@ void NetworkPackageManager :: updateServer() | |||
216 | // First, write out ipkg_conf file so that ipkg can use it | 249 | // First, write out ipkg_conf file so that ipkg can use it |
217 | dataMgr->writeOutIpkgConf(); | 250 | dataMgr->writeOutIpkgConf(); |
218 | 251 | ||
219 | if ( serverName == LOCAL_SERVER ) | 252 | // if ( serverName == LOCAL_SERVER ) |
220 | ; | 253 | // ; |
221 | else if ( serverName == LOCAL_IPKGS ) | 254 | // else if ( serverName == LOCAL_IPKGS ) |
222 | ; | 255 | // ; |
223 | else | 256 | // else |
224 | { | 257 | { |
225 | QString option = "update"; | 258 | QString option = "update"; |
226 | QString dummy = ""; | 259 | QString dummy = ""; |
@@ -302,10 +335,11 @@ void NetworkPackageManager :: downloadPackage() | |||
302 | Ipkg ipkg; | 335 | Ipkg ipkg; |
303 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 336 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
304 | 337 | ||
305 | QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | ||
306 | ipkg.setOption( "download" ); | 338 | ipkg.setOption( "download" ); |
307 | ipkg.setRuntimeDirectory( dir ); | 339 | ipkg.setRuntimeDirectory( dir ); |
308 | do | 340 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
341 | item != 0 ; | ||
342 | item = (QCheckListItem *)item->nextSibling() ) | ||
309 | { | 343 | { |
310 | if ( item->isOn() ) | 344 | if ( item->isOn() ) |
311 | { | 345 | { |
@@ -321,14 +355,13 @@ void NetworkPackageManager :: downloadPackage() | |||
321 | ipkg.setPackage( name ); | 355 | ipkg.setPackage( name ); |
322 | ipkg.runIpkg( ); | 356 | ipkg.runIpkg( ); |
323 | } | 357 | } |
324 | 358 | } | |
325 | item = (QCheckListItem *)item->nextSibling(); | ||
326 | } while ( item ); | ||
327 | } | 359 | } |
328 | else if ( download->text() == "Remove" ) | 360 | else if ( download->text() == "Remove" ) |
329 | { | 361 | { |
330 | QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 362 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
331 | do | 363 | item != 0 ; |
364 | item = (QCheckListItem *)item->nextSibling() ) | ||
332 | { | 365 | { |
333 | if ( item->isOn() ) | 366 | if ( item->isOn() ) |
334 | { | 367 | { |
@@ -345,8 +378,7 @@ void NetworkPackageManager :: downloadPackage() | |||
345 | QFile f( p->getFilename() ); | 378 | QFile f( p->getFilename() ); |
346 | f.remove(); | 379 | f.remove(); |
347 | } | 380 | } |
348 | item = (QCheckListItem *)item->nextSibling(); | 381 | } |
349 | } while ( item ); | ||
350 | } | 382 | } |
351 | 383 | ||
352 | dataMgr->reloadServerData( LOCAL_IPKGS ); | 384 | dataMgr->reloadServerData( LOCAL_IPKGS ); |
@@ -357,7 +389,7 @@ void NetworkPackageManager :: downloadPackage() | |||
357 | void NetworkPackageManager :: applyChanges() | 389 | void NetworkPackageManager :: applyChanges() |
358 | { | 390 | { |
359 | // Disable buttons to stop silly people clicking lots on them :) | 391 | // Disable buttons to stop silly people clicking lots on them :) |
360 | 392 | ||
361 | // First, write out ipkg_conf file so that ipkg can use it | 393 | // First, write out ipkg_conf file so that ipkg can use it |
362 | dataMgr->writeOutIpkgConf(); | 394 | dataMgr->writeOutIpkgConf(); |
363 | 395 | ||
@@ -365,17 +397,16 @@ void NetworkPackageManager :: applyChanges() | |||
365 | // deal with it | 397 | // deal with it |
366 | 398 | ||
367 | vector<QString> workingPackages; | 399 | vector<QString> workingPackages; |
368 | QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 400 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
369 | do | 401 | item != 0 ; |
402 | item = (QCheckListItem *)item->nextSibling() ) | ||
370 | { | 403 | { |
371 | if ( item->isOn() ) | 404 | if ( item->isOn() ) |
372 | { | 405 | { |
373 | QString p = dealWithItem( item ); | 406 | QString p = dealWithItem( item ); |
374 | workingPackages.push_back( p ); | 407 | workingPackages.push_back( p ); |
375 | } | 408 | } |
376 | 409 | } | |
377 | item = (QCheckListItem *)item->nextSibling(); | ||
378 | } while ( item ); | ||
379 | 410 | ||
380 | // do the stuff | 411 | // do the stuff |
381 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); | 412 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); |
@@ -451,3 +482,21 @@ void NetworkPackageManager :: displayText( const QString &t ) | |||
451 | { | 482 | { |
452 | cout << t << endl; | 483 | cout << t << endl; |
453 | } | 484 | } |
485 | |||
486 | |||
487 | void NetworkPackageManager :: letterPushed( QString t ) | ||
488 | { | ||
489 | QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | ||
490 | do | ||
491 | { | ||
492 | if ( item->text().lower().startsWith( t.lower() ) ) | ||
493 | { | ||
494 | cout << "Found - item->text()" << endl; | ||
495 | packagesList->setSelected( item, true ); | ||
496 | packagesList->ensureItemVisible( item ); | ||
497 | break; | ||
498 | } | ||
499 | |||
500 | item = (QCheckListItem *)item->nextSibling(); | ||
501 | } while ( item ); | ||
502 | } | ||