author | andyq <andyq> | 2002-10-16 21:25:25 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-10-16 21:25:25 (UTC) |
commit | bf58f7bc221ba10f6681d9a1a5193bd208d9920e (patch) (unidiff) | |
tree | ba87cbc5c490b60e6c447eadded833408d829438 | |
parent | 6c5cf5e778ce7cce306b5e02c1ce66a536d3a11c (diff) | |
download | opie-bf58f7bc221ba10f6681d9a1a5193bd208d9920e.zip opie-bf58f7bc221ba10f6681d9a1a5193bd208d9920e.tar.gz opie-bf58f7bc221ba10f6681d9a1a5193bd208d9920e.tar.bz2 |
Now allows for multiple servers active
Added basic search facility (lots of buttons)
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 95 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.h | 2 |
2 files changed, 74 insertions, 23 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 ); |
@@ -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 | } | ||
diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h index 8a88b35..0ae64a6 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.h +++ b/noncore/settings/aqpkg/networkpkgmgr.h | |||
@@ -50,6 +50,7 @@ private: | |||
50 | QPushButton *apply; | 50 | QPushButton *apply; |
51 | 51 | ||
52 | ProgressDlg *progressDlg; | 52 | ProgressDlg *progressDlg; |
53 | QString currentlySelectedServer; | ||
53 | 54 | ||
54 | int timerId; | 55 | int timerId; |
55 | 56 | ||
@@ -67,6 +68,7 @@ public slots: | |||
67 | void downloadPackage(); | 68 | void downloadPackage(); |
68 | void updateServer(); | 69 | void updateServer(); |
69 | void displayText( const QString &t ); | 70 | void displayText( const QString &t ); |
71 | void letterPushed( QString t ); | ||
70 | }; | 72 | }; |
71 | 73 | ||
72 | #endif | 74 | #endif |