Diffstat (limited to 'noncore/settings/aqpkg/mainwin.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 889 |
1 files changed, 853 insertions, 36 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index d79673f..c9963bc 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -14,38 +14,62 @@ | |||
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include <unistd.h> | ||
19 | |||
20 | #include <qpe/qcopenvelope_qws.h> | ||
18 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpeapplication.h> | ||
19 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
24 | #include <qpe/config.h> | ||
20 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
21 | 26 | ||
22 | #include <qaction.h> | 27 | #include <qaction.h> |
28 | #include <qcombobox.h> | ||
29 | #include <qfile.h> | ||
30 | #include <qlabel.h> | ||
31 | #include <qlayout.h> | ||
23 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qlistview.h> | ||
24 | #include <qmenubar.h> | 34 | #include <qmenubar.h> |
25 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
26 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
37 | #include <qprogressbar.h> | ||
27 | #include <qtimer.h> | 38 | #include <qtimer.h> |
28 | #include <qwhatsthis.h> | 39 | #include <qwhatsthis.h> |
29 | #include <qwidgetstack.h> | 40 | #include <qwidgetstack.h> |
30 | 41 | ||
31 | #include "mainwin.h" | 42 | #include "categoryfilterimpl.h" |
32 | #include "progresswidget.h" | ||
33 | #include "datamgr.h" | 43 | #include "datamgr.h" |
34 | #include "networkpkgmgr.h" | 44 | #include "global.h" |
35 | #include "settingsimpl.h" | ||
36 | #include "helpwindow.h" | 45 | #include "helpwindow.h" |
46 | #include "inputdlg.h" | ||
47 | #include "installdlgimpl.h" | ||
48 | #include "letterpushbutton.h" | ||
49 | #include "mainwin.h" | ||
50 | #include "settingsimpl.h" | ||
37 | #include "utils.h" | 51 | #include "utils.h" |
38 | #include "global.h" | 52 | |
53 | extern int compareVersions( const char *v1, const char *v2 ); | ||
39 | 54 | ||
40 | MainWindow :: MainWindow() | 55 | MainWindow :: MainWindow() |
41 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) | 56 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) |
42 | { | 57 | { |
43 | setCaption( tr( "AQPkg - Package Manager" ) ); | 58 | setCaption( tr( "AQPkg - Package Manager" ) ); |
44 | 59 | ||
60 | #ifdef QWS | ||
61 | // read download directory from config file | ||
62 | Config cfg( "aqpkg" ); | ||
63 | cfg.setGroup( "settings" ); | ||
64 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | ||
65 | showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | ||
66 | |||
67 | #endif | ||
68 | |||
45 | // Create UI widgets | 69 | // Create UI widgets |
46 | progressWindow = new ProgressWidget( this ); | 70 | initMainWidget(); |
47 | networkPkgWindow = new NetworkPackageManager( this ); | 71 | initProgressWidget(); |
48 | 72 | ||
49 | // Build menu and tool bars | 73 | // Build menu and tool bars |
50 | setToolBarsMovable( FALSE ); | 74 | setToolBarsMovable( FALSE ); |
51 | 75 | ||
@@ -68,29 +92,29 @@ MainWindow :: MainWindow() | |||
68 | QPopupMenu *popup = new QPopupMenu( this ); | 92 | QPopupMenu *popup = new QPopupMenu( this ); |
69 | 93 | ||
70 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); | 94 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); |
71 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | 95 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); |
72 | connect( a, SIGNAL( activated() ), networkPkgWindow, SLOT( updateServer() ) ); | 96 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); |
73 | a->addTo( popup ); | 97 | a->addTo( popup ); |
74 | a->addTo( bar ); | 98 | a->addTo( bar ); |
75 | 99 | ||
76 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); | 100 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); |
77 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | 101 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); |
78 | connect( actionUpgrade, SIGNAL( activated() ), networkPkgWindow, SLOT( upgradePackages() ) ); | 102 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); |
79 | actionUpgrade->addTo( popup ); | 103 | actionUpgrade->addTo( popup ); |
80 | actionUpgrade->addTo( bar ); | 104 | actionUpgrade->addTo( bar ); |
81 | 105 | ||
82 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); | 106 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); |
83 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); | 107 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); |
84 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 108 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
85 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 109 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
86 | connect( actionDownload, SIGNAL( activated() ), networkPkgWindow, SLOT( downloadPackage() ) ); | 110 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); |
87 | actionDownload->addTo( popup ); | 111 | actionDownload->addTo( popup ); |
88 | actionDownload->addTo( bar ); | 112 | actionDownload->addTo( bar ); |
89 | 113 | ||
90 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); | 114 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); |
91 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | 115 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); |
92 | connect( a, SIGNAL( activated() ), networkPkgWindow, SLOT( applyChanges() ) ); | 116 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); |
93 | a->addTo( popup ); | 117 | a->addTo( popup ); |
94 | a->addTo( bar ); | 118 | a->addTo( bar ); |
95 | 119 | ||
96 | mb->insertItem( tr( "Actions" ), popup ); | 120 | mb->insertItem( tr( "Actions" ), popup ); |
@@ -174,9 +198,8 @@ MainWindow :: MainWindow() | |||
174 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); | 198 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); |
175 | a->addTo( findBar ); | 199 | a->addTo( findBar ); |
176 | findBar->hide(); | 200 | findBar->hide(); |
177 | 201 | ||
178 | |||
179 | // Create widget stack and add UI widgets | 202 | // Create widget stack and add UI widgets |
180 | stack = new QWidgetStack( this ); | 203 | stack = new QWidgetStack( this ); |
181 | stack->addWidget( progressWindow, 2 ); | 204 | stack->addWidget( progressWindow, 2 ); |
182 | stack->addWidget( networkPkgWindow, 1 ); | 205 | stack->addWidget( networkPkgWindow, 1 ); |
@@ -191,29 +214,86 @@ MainWindow :: ~MainWindow() | |||
191 | { | 214 | { |
192 | delete mgr; | 215 | delete mgr; |
193 | } | 216 | } |
194 | 217 | ||
218 | void MainWindow :: initMainWidget() | ||
219 | { | ||
220 | networkPkgWindow = new QWidget( this ); | ||
221 | |||
222 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); | ||
223 | |||
224 | serversList = new QComboBox( networkPkgWindow ); | ||
225 | connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) ); | ||
226 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); | ||
227 | |||
228 | installedIcon = Resource::loadPixmap( "aqpkg/installed" ); | ||
229 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); | ||
230 | |||
231 | packagesList = new QListView( networkPkgWindow ); | ||
232 | packagesList->addColumn( tr( "Packages" ), 225 ); | ||
233 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); | ||
234 | |||
235 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); | ||
236 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | ||
237 | hbox1->addWidget( l ); | ||
238 | hbox1->addWidget( serversList ); | ||
239 | |||
240 | |||
241 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 ); | ||
242 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 ); | ||
243 | |||
244 | if ( showJumpTo ) | ||
245 | { | ||
246 | char text[2]; | ||
247 | text[1] = '\0'; | ||
248 | for ( int i = 0 ; i < 26 ; ++i ) | ||
249 | { | ||
250 | text[0] = 'A' + i; | ||
251 | LetterPushButton *b = new LetterPushButton( text, networkPkgWindow ); | ||
252 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | ||
253 | if ( i < 13 ) | ||
254 | hbox3->addWidget( b ); | ||
255 | else | ||
256 | hbox4->addWidget( b ); | ||
257 | } | ||
258 | } | ||
259 | |||
260 | vbox->addWidget( packagesList ); | ||
261 | |||
262 | downloadEnabled = TRUE; | ||
263 | } | ||
264 | |||
265 | void MainWindow :: initProgressWidget() | ||
266 | { | ||
267 | progressWindow = new QWidget( this ); | ||
268 | |||
269 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); | ||
270 | |||
271 | m_status = new QLabel( progressWindow ); | ||
272 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | ||
273 | layout->addWidget( m_status ); | ||
274 | |||
275 | m_progress = new QProgressBar( progressWindow ); | ||
276 | layout->addWidget( m_progress ); | ||
277 | } | ||
278 | |||
195 | void MainWindow :: init() | 279 | void MainWindow :: init() |
196 | { | 280 | { |
197 | stack->raiseWidget( progressWindow ); | 281 | stack->raiseWidget( progressWindow ); |
198 | 282 | ||
199 | mgr = new DataManager(); | 283 | mgr = new DataManager(); |
200 | connect( mgr, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) ); | 284 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); |
201 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), | 285 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), |
202 | progressWindow, SLOT( setMessage( const QString & ) ) ); | 286 | this, SLOT( setProgressMessage( const QString & ) ) ); |
203 | connect( mgr, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) ); | 287 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); |
204 | mgr->loadServers(); | 288 | mgr->loadServers(); |
205 | 289 | ||
206 | networkPkgWindow->setDataManager( mgr ); | 290 | showUninstalledPkgs = false; |
207 | networkPkgWindow->updateData(); | 291 | showInstalledPkgs = false; |
208 | connect( networkPkgWindow, SIGNAL( appRaiseMainWidget() ), this, SLOT( raiseMainWidget() ) ); | 292 | showUpgradedPkgs = false; |
209 | connect( networkPkgWindow, SIGNAL( appRaiseProgressWidget() ), this, SLOT( raiseProgressWidget() ) ); | 293 | categoryFilterEnabled = false; |
210 | connect( networkPkgWindow, SIGNAL( appEnableUpgrade( bool ) ), this, SLOT( enableUpgrade( bool ) ) ); | 294 | |
211 | connect( networkPkgWindow, SIGNAL( appEnableDownload( bool ) ), this, SLOT( enableDownload( bool ) ) ); | 295 | updateData(); |
212 | connect( networkPkgWindow, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) ); | ||
213 | connect( networkPkgWindow, SIGNAL( progressSetMessage( const QString & ) ), | ||
214 | progressWindow, SLOT( setMessage( const QString & ) ) ); | ||
215 | connect( networkPkgWindow, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) ); | ||
216 | 296 | ||
217 | stack->raiseWidget( networkPkgWindow ); | 297 | stack->raiseWidget( networkPkgWindow ); |
218 | } | 298 | } |
219 | 299 | ||
@@ -221,16 +301,38 @@ void MainWindow :: setDocument( const QString &doc ) | |||
221 | { | 301 | { |
222 | // Remove path from package | 302 | // Remove path from package |
223 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 303 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
224 | // std::cout << "Selecting package " << package << std::endl; | 304 | // std::cout << "Selecting package " << package << std::endl; |
225 | networkPkgWindow->selectLocalPackage( package ); | 305 | |
306 | // First select local server | ||
307 | for ( int i = 0 ; i < serversList->count() ; ++i ) | ||
308 | { | ||
309 | if ( serversList->text( i ) == LOCAL_IPKGS ) | ||
310 | { | ||
311 | serversList->setCurrentItem( i ); | ||
312 | break; | ||
313 | } | ||
314 | } | ||
315 | serverSelected( 0 ); | ||
316 | |||
317 | // Now set the check box of the selected package | ||
318 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | ||
319 | item != 0 ; | ||
320 | item = (QCheckListItem *)item->nextSibling() ) | ||
321 | { | ||
322 | if ( item->text().startsWith( package ) ) | ||
323 | { | ||
324 | item->setOn( true ); | ||
325 | break; | ||
326 | } | ||
327 | } | ||
226 | } | 328 | } |
227 | 329 | ||
228 | void MainWindow :: displaySettings() | 330 | void MainWindow :: displaySettings() |
229 | { | 331 | { |
230 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 332 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
231 | if ( dlg->showDlg( 0 ) ) | 333 | if ( dlg->showDlg( 0 ) ) |
232 | networkPkgWindow->updateData(); | 334 | updateData(); |
233 | delete dlg; | 335 | delete dlg; |
234 | } | 336 | } |
235 | 337 | ||
236 | void MainWindow :: displayHelp() | 338 | void MainWindow :: displayHelp() |
@@ -247,15 +349,15 @@ void MainWindow :: displayFindBar() | |||
247 | } | 349 | } |
248 | 350 | ||
249 | void MainWindow :: repeatFind() | 351 | void MainWindow :: repeatFind() |
250 | { | 352 | { |
251 | networkPkgWindow->searchForPackage( findEdit->text() ); | 353 | searchForPackage( findEdit->text() ); |
252 | } | 354 | } |
253 | 355 | ||
254 | void MainWindow :: findPackage( const QString &text ) | 356 | void MainWindow :: findPackage( const QString &text ) |
255 | { | 357 | { |
256 | actionFindNext->setEnabled( !text.isEmpty() ); | 358 | actionFindNext->setEnabled( !text.isEmpty() ); |
257 | networkPkgWindow->searchForPackage( text ); | 359 | searchForPackage( text ); |
258 | } | 360 | } |
259 | 361 | ||
260 | void MainWindow :: hideFindBar() | 362 | void MainWindow :: hideFindBar() |
261 | { | 363 | { |
@@ -268,42 +370,100 @@ void MainWindow :: displayAbout() | |||
268 | } | 370 | } |
269 | 371 | ||
270 | void MainWindow :: filterUninstalledPackages() | 372 | void MainWindow :: filterUninstalledPackages() |
271 | { | 373 | { |
272 | networkPkgWindow->showOnlyUninstalledPackages( actionUninstalled->isOn() ); | 374 | showUninstalledPkgs = actionUninstalled->isOn(); |
375 | if ( showUninstalledPkgs ) | ||
376 | { | ||
377 | showInstalledPkgs = FALSE; | ||
378 | showUpgradedPkgs = FALSE; | ||
379 | } | ||
380 | serverSelected( -1 ); | ||
381 | |||
273 | actionInstalled->setOn( FALSE ); | 382 | actionInstalled->setOn( FALSE ); |
274 | actionUpdated->setOn( FALSE ); | 383 | actionUpdated->setOn( FALSE ); |
275 | } | 384 | } |
276 | 385 | ||
277 | void MainWindow :: filterInstalledPackages() | 386 | void MainWindow :: filterInstalledPackages() |
278 | { | 387 | { |
388 | showInstalledPkgs = actionInstalled->isOn(); | ||
389 | if ( showInstalledPkgs ) | ||
390 | { | ||
391 | showUninstalledPkgs = FALSE; | ||
392 | showUpgradedPkgs = FALSE; | ||
393 | } | ||
394 | serverSelected( -1 ); | ||
395 | |||
279 | actionUninstalled->setOn( FALSE ); | 396 | actionUninstalled->setOn( FALSE ); |
280 | networkPkgWindow->showOnlyInstalledPackages( actionInstalled->isOn() ); | ||
281 | actionUpdated->setOn( FALSE ); | 397 | actionUpdated->setOn( FALSE ); |
282 | } | 398 | } |
283 | 399 | ||
284 | void MainWindow :: filterUpgradedPackages() | 400 | void MainWindow :: filterUpgradedPackages() |
285 | { | 401 | { |
402 | showUpgradedPkgs = actionUpdated->isOn(); | ||
403 | if ( showUpgradedPkgs ) | ||
404 | { | ||
405 | showUninstalledPkgs = FALSE; | ||
406 | showInstalledPkgs = FALSE; | ||
407 | } | ||
408 | serverSelected( -1 ); | ||
409 | |||
286 | actionUninstalled->setOn( FALSE ); | 410 | actionUninstalled->setOn( FALSE ); |
287 | actionInstalled->setOn( FALSE ); | 411 | actionInstalled->setOn( FALSE ); |
288 | networkPkgWindow->showUpgradedPackages( actionUpdated->isOn() ); | ||
289 | } | 412 | } |
290 | 413 | ||
291 | void MainWindow :: setFilterCategory() | 414 | bool MainWindow :: setFilterCategory() |
415 | { | ||
416 | // Get categories; | ||
417 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); | ||
418 | if ( dlg.exec() == QDialog::Accepted ) | ||
292 | { | 419 | { |
293 | if ( networkPkgWindow->setFilterCategory() ) | 420 | categoryFilter = dlg.getSelectedFilter(); |
421 | |||
422 | if ( categoryFilter == "" ) | ||
423 | return false; | ||
424 | |||
425 | categoryFilterEnabled = true; | ||
426 | serverSelected( -1 ); | ||
294 | actionFilter->setOn( TRUE ); | 427 | actionFilter->setOn( TRUE ); |
428 | return true; | ||
429 | } | ||
430 | |||
431 | return false; | ||
295 | } | 432 | } |
296 | 433 | ||
297 | void MainWindow :: filterCategory() | 434 | void MainWindow :: filterCategory() |
298 | { | 435 | { |
299 | if ( !actionFilter->isOn() ) | 436 | if ( !actionFilter->isOn() ) |
300 | { | 437 | { |
301 | networkPkgWindow->filterByCategory( FALSE ); | 438 | filterByCategory( FALSE ); |
439 | } | ||
440 | else | ||
441 | { | ||
442 | actionFilter->setOn( filterByCategory( TRUE ) ); | ||
443 | } | ||
444 | } | ||
445 | |||
446 | bool MainWindow :: filterByCategory( bool val ) | ||
447 | { | ||
448 | if ( val ) | ||
449 | { | ||
450 | if ( categoryFilter == "" ) | ||
451 | { | ||
452 | if ( !setFilterCategory() ) | ||
453 | return false; | ||
454 | } | ||
455 | |||
456 | categoryFilterEnabled = true; | ||
457 | serverSelected( -1 ); | ||
458 | return true; | ||
302 | } | 459 | } |
303 | else | 460 | else |
304 | { | 461 | { |
305 | actionFilter->setOn( networkPkgWindow->filterByCategory( TRUE ) ); | 462 | // Turn off filter |
463 | categoryFilterEnabled = false; | ||
464 | serverSelected( -1 ); | ||
465 | return false; | ||
306 | } | 466 | } |
307 | } | 467 | } |
308 | 468 | ||
309 | void MainWindow :: raiseMainWidget() | 469 | void MainWindow :: raiseMainWidget() |
@@ -335,4 +495,661 @@ void MainWindow :: enableDownload( bool enabled ) | |||
335 | actionDownload->setText( tr( "Remove" ) ); | 495 | actionDownload->setText( tr( "Remove" ) ); |
336 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); | 496 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); |
337 | } | 497 | } |
338 | } | 498 | } |
499 | |||
500 | void MainWindow :: setProgressSteps( int numsteps ) | ||
501 | { | ||
502 | m_progress->setTotalSteps( numsteps ); | ||
503 | } | ||
504 | |||
505 | void MainWindow :: setProgressMessage( const QString &msg ) | ||
506 | { | ||
507 | m_status->setText( msg ); | ||
508 | } | ||
509 | |||
510 | void MainWindow :: updateProgress( int progress ) | ||
511 | { | ||
512 | m_progress->setProgress( progress ); | ||
513 | } | ||
514 | |||
515 | void MainWindow :: updateData() | ||
516 | { | ||
517 | m_progress->setTotalSteps( mgr->getServerList().size() ); | ||
518 | |||
519 | serversList->clear(); | ||
520 | packagesList->clear(); | ||
521 | |||
522 | vector<Server>::iterator it; | ||
523 | int activeItem = -1; | ||
524 | int i; | ||
525 | QString serverName; | ||
526 | for ( i = 0, it = mgr->getServerList().begin() ; it != mgr->getServerList().end() ; ++it, ++i ) | ||
527 | { | ||
528 | serverName = it->getServerName(); | ||
529 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); | ||
530 | m_progress->setProgress( i ); | ||
531 | qApp->processEvents(); | ||
532 | |||
533 | // cout << "Adding " << it->getServerName() << " to combobox" << endl; | ||
534 | if ( !it->isServerActive() ) | ||
535 | { | ||
536 | // cout << serverName << " is not active" << endl; | ||
537 | i--; | ||
538 | continue; | ||
539 | } | ||
540 | |||
541 | serversList->insertItem( serverName ); | ||
542 | if ( serverName == currentlySelectedServer ) | ||
543 | activeItem = i; | ||
544 | } | ||
545 | |||
546 | // set selected server to be active server | ||
547 | if ( activeItem != -1 ) | ||
548 | serversList->setCurrentItem( activeItem ); | ||
549 | serverSelected( 0, FALSE ); | ||
550 | } | ||
551 | |||
552 | void MainWindow :: serverSelected( int index ) | ||
553 | { | ||
554 | serverSelected( index, TRUE ); | ||
555 | } | ||
556 | |||
557 | void MainWindow :: serverSelected( int, bool raiseProgress ) | ||
558 | { | ||
559 | QPixmap nullIcon( installedIcon.size() ); | ||
560 | nullIcon.fill( colorGroup().base() ); | ||
561 | |||
562 | // display packages | ||
563 | QString serverName = serversList->currentText(); | ||
564 | currentlySelectedServer = serverName; | ||
565 | |||
566 | vector<Server>::iterator s = mgr->getServer( serverName ); | ||
567 | |||
568 | vector<Package> &list = s->getPackageList(); | ||
569 | vector<Package>::iterator it; | ||
570 | |||
571 | // Display progress widget while loading list | ||
572 | bool doProgress = ( list.size() > 200 ); | ||
573 | if ( doProgress ) | ||
574 | { | ||
575 | if ( raiseProgress ) | ||
576 | { | ||
577 | stack->raiseWidget( progressWindow ); | ||
578 | } | ||
579 | m_progress->setTotalSteps( list.size() ); | ||
580 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); | ||
581 | } | ||
582 | |||
583 | packagesList->clear(); | ||
584 | |||
585 | #ifdef QWS | ||
586 | // read download directory from config file | ||
587 | Config cfg( "aqpkg" ); | ||
588 | cfg.setGroup( "settings" ); | ||
589 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | ||
590 | #endif | ||
591 | |||
592 | int i = 0; | ||
593 | for ( it = list.begin() ; it != list.end() ; ++it ) | ||
594 | { | ||
595 | // Update progress after every 100th package (arbitrary value, seems to give good balance) | ||
596 | i++; | ||
597 | if ( ( i % 100 ) == 0 ) | ||
598 | { | ||
599 | if ( doProgress ) | ||
600 | { | ||
601 | m_progress->setProgress( i ); | ||
602 | } | ||
603 | qApp->processEvents(); | ||
604 | } | ||
605 | |||
606 | QString text = ""; | ||
607 | |||
608 | // Apply show only uninstalled packages filter | ||
609 | if ( showUninstalledPkgs && it->isInstalled() ) | ||
610 | continue; | ||
611 | |||
612 | // Apply show only installed packages filter | ||
613 | if ( showInstalledPkgs && !it->isInstalled() ) | ||
614 | continue; | ||
615 | |||
616 | // Apply show only new installed packages filter | ||
617 | if ( showUpgradedPkgs ) | ||
618 | { | ||
619 | if ( !it->isInstalled() || | ||
620 | compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) | ||
621 | continue; | ||
622 | } | ||
623 | |||
624 | // Apply the section filter | ||
625 | if ( categoryFilterEnabled && categoryFilter != "" ) | ||
626 | { | ||
627 | if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) | ||
628 | continue; | ||
629 | } | ||
630 | |||
631 | // If the local server, only display installed packages | ||
632 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) | ||
633 | continue; | ||
634 | |||
635 | |||
636 | QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox ); | ||
637 | |||
638 | if ( it->isInstalled() ) | ||
639 | { | ||
640 | // If a different version of package is available, show update available icon | ||
641 | // Otherwise, show installed icon | ||
642 | if ( it->getVersion() != it->getInstalledVersion() && | ||
643 | compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1) | ||
644 | { | ||
645 | |||
646 | item->setPixmap( 0, updatedIcon ); | ||
647 | } | ||
648 | else | ||
649 | { | ||
650 | item->setPixmap( 0, installedIcon ); | ||
651 | } | ||
652 | |||
653 | QString destName = ""; | ||
654 | if ( it->getLocalPackage() ) | ||
655 | { | ||
656 | if ( it->getLocalPackage()->getInstalledTo() ) | ||
657 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); | ||
658 | } | ||
659 | else | ||
660 | { | ||
661 | if ( it->getInstalledTo() ) | ||
662 | destName = it->getInstalledTo()->getDestinationName(); | ||
663 | } | ||
664 | if ( destName != "" ) | ||
665 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); | ||
666 | } | ||
667 | else | ||
668 | { | ||
669 | item->setPixmap( 0, nullIcon ); | ||
670 | } | ||
671 | |||
672 | if ( !it->isPackageStoredLocally() ) | ||
673 | { | ||
674 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) ); | ||
675 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) ); | ||
676 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) ); | ||
677 | } | ||
678 | else | ||
679 | new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) ); | ||
680 | |||
681 | if ( serverName == LOCAL_SERVER ) | ||
682 | { | ||
683 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) ); | ||
684 | } | ||
685 | else | ||
686 | { | ||
687 | new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) ); | ||
688 | if ( it->getLocalPackage() ) | ||
689 | { | ||
690 | if ( it->isInstalled() ) | ||
691 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) ); | ||
692 | } | ||
693 | } | ||
694 | |||
695 | packagesList->insertItem( item ); | ||
696 | } | ||
697 | |||
698 | // If the local server or the local ipkgs server disable the download button | ||
699 | if ( serverName == LOCAL_SERVER ) | ||
700 | { | ||
701 | downloadEnabled = TRUE; | ||
702 | actionUpgrade->setEnabled( FALSE ); | ||
703 | } | ||
704 | else if ( serverName == LOCAL_IPKGS ) | ||
705 | { | ||
706 | downloadEnabled = FALSE; | ||
707 | actionUpgrade->setEnabled( FALSE ); | ||
708 | } | ||
709 | else | ||
710 | { | ||
711 | downloadEnabled = TRUE; | ||
712 | actionUpgrade->setEnabled( TRUE ); | ||
713 | } | ||
714 | enableDownload( downloadEnabled ); | ||
715 | |||
716 | // Display this widget once everything is done | ||
717 | if ( doProgress && raiseProgress ) | ||
718 | { | ||
719 | stack->raiseWidget( networkPkgWindow ); | ||
720 | } | ||
721 | } | ||
722 | |||
723 | void MainWindow :: searchForPackage( const QString &text ) | ||
724 | { | ||
725 | if ( !text.isEmpty() ) | ||
726 | { | ||
727 | // cout << "searching for " << text << endl; | ||
728 | // look through package list for text startng at current position | ||
729 | vector<InstallData> workingPackages; | ||
730 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | ||
731 | if ( start != 0 ) | ||
732 | start = (QCheckListItem *)start->nextSibling(); | ||
733 | |||
734 | if ( start == 0 ) | ||
735 | start = (QCheckListItem *)packagesList->firstChild(); | ||
736 | |||
737 | for ( QCheckListItem *item = start; item != 0 ; | ||
738 | item = (QCheckListItem *)item->nextSibling() ) | ||
739 | { | ||
740 | // cout << "checking " << item->text().lower() << endl; | ||
741 | if ( item->text().lower().find( text ) != -1 ) | ||
742 | { | ||
743 | // cout << "matched " << item->text() << endl; | ||
744 | packagesList->ensureItemVisible( item ); | ||
745 | packagesList->setCurrentItem( item ); | ||
746 | break; | ||
747 | } | ||
748 | } | ||
749 | } | ||
750 | } | ||
751 | |||
752 | void MainWindow :: updateServer() | ||
753 | { | ||
754 | QString serverName = serversList->currentText(); | ||
755 | |||
756 | // Update the current server | ||
757 | // Display dialog | ||
758 | |||
759 | // Disable buttons to stop silly people clicking lots on them :) | ||
760 | |||
761 | // First, write out ipkg_conf file so that ipkg can use it | ||
762 | mgr->writeOutIpkgConf(); | ||
763 | |||
764 | Ipkg ipkg; | ||
765 | ipkg.setOption( "update" ); | ||
766 | |||
767 | InstallDlgImpl dlg( &ipkg, tr( "Refreshing server package lists" ), this, tr( "Upgrade" ), true ); | ||
768 | dlg.showDlg(); | ||
769 | |||
770 | // Reload data | ||
771 | mgr->reloadServerData(); | ||
772 | serverSelected(-1); | ||
773 | // delete progDlg; | ||
774 | } | ||
775 | |||
776 | void MainWindow :: upgradePackages() | ||
777 | { | ||
778 | // We're gonna do an upgrade of all packages | ||
779 | // First warn user that this isn't recommended | ||
780 | // TODO - ODevice???? | ||
781 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); | ||
782 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, | ||
783 | QMessageBox::Yes, | ||
784 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | ||
785 | 0, this ); | ||
786 | warn.adjustSize(); | ||
787 | |||
788 | if ( warn.exec() == QMessageBox::Yes ) | ||
789 | { | ||
790 | // First, write out ipkg_conf file so that ipkg can use it | ||
791 | mgr->writeOutIpkgConf(); | ||
792 | |||
793 | // Now run upgrade | ||
794 | Ipkg ipkg; | ||
795 | ipkg.setOption( "upgrade" ); | ||
796 | |||
797 | InstallDlgImpl dlg( &ipkg, tr( "Upgrading installed packages" ), this, tr( "Upgrade" ), true ); | ||
798 | dlg.showDlg(); | ||
799 | |||
800 | // Reload data | ||
801 | mgr->reloadServerData(); | ||
802 | serverSelected(-1); | ||
803 | } | ||
804 | } | ||
805 | void MainWindow :: downloadPackage() | ||
806 | { | ||
807 | bool doUpdate = true; | ||
808 | if ( downloadEnabled ) | ||
809 | { | ||
810 | // See if any packages are selected | ||
811 | bool found = false; | ||
812 | if ( serversList->currentText() != LOCAL_SERVER ) | ||
813 | { | ||
814 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | ||
815 | item != 0 && !found; | ||
816 | item = (QCheckListItem *)item->nextSibling() ) | ||
817 | { | ||
818 | if ( item->isOn() ) | ||
819 | found = true; | ||
820 | } | ||
821 | } | ||
822 | |||
823 | // If user selected some packages then download the and store the locally | ||
824 | // otherwise, display dialog asking user what package to download from an http server | ||
825 | // and whether to install it | ||
826 | if ( found ) | ||
827 | downloadSelectedPackages(); | ||
828 | else | ||
829 | downloadRemotePackage(); | ||
830 | |||
831 | } | ||
832 | else | ||
833 | { | ||
834 | doUpdate = false; | ||
835 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | ||
836 | item != 0 ; | ||
837 | item = (QCheckListItem *)item->nextSibling() ) | ||
838 | { | ||
839 | if ( item->isOn() ) | ||
840 | { | ||
841 | QString name = item->text(); | ||
842 | int pos = name.find( "*" ); | ||
843 | name.truncate( pos ); | ||
844 | |||
845 | // if (there is a (installed), remove it | ||
846 | pos = name.find( "(installed)" ); | ||
847 | if ( pos > 0 ) | ||
848 | name.truncate( pos - 1 ); | ||
849 | |||
850 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); | ||
851 | |||
852 | QString msgtext; | ||
853 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); | ||
854 | if ( QMessageBox::information( this, tr( "Are you sure?" ), | ||
855 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) | ||
856 | { | ||
857 | doUpdate = true; | ||
858 | QFile f( p->getFilename() ); | ||
859 | f.remove(); | ||
860 | } | ||
861 | } | ||
862 | } | ||
863 | } | ||
864 | |||
865 | if ( doUpdate ) | ||
866 | { | ||
867 | mgr->reloadServerData(); | ||
868 | serverSelected( -1 ); | ||
869 | } | ||
870 | } | ||
871 | |||
872 | void MainWindow :: downloadSelectedPackages() | ||
873 | { | ||
874 | // First, write out ipkg_conf file so that ipkg can use it | ||
875 | mgr->writeOutIpkgConf(); | ||
876 | |||
877 | // Display dialog to user asking where to download the files to | ||
878 | bool ok = FALSE; | ||
879 | QString dir = ""; | ||
880 | #ifdef QWS | ||
881 | // read download directory from config file | ||
882 | Config cfg( "aqpkg" ); | ||
883 | cfg.setGroup( "settings" ); | ||
884 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | ||
885 | #endif | ||
886 | |||
887 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | ||
888 | if ( ok && !text.isEmpty() ) | ||
889 | dir = text; // user entered something and pressed ok | ||
890 | else | ||
891 | return; // user entered nothing or pressed cancel | ||
892 | |||
893 | #ifdef QWS | ||
894 | // Store download directory in config file | ||
895 | cfg.writeEntry( "downloadDir", dir ); | ||
896 | #endif | ||
897 | |||
898 | // Get starting directory | ||
899 | char initDir[PATH_MAX]; | ||
900 | getcwd( initDir, PATH_MAX ); | ||
901 | |||
902 | // Download each package | ||
903 | Ipkg ipkg; | ||
904 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | ||
905 | |||
906 | ipkg.setOption( "download" ); | ||
907 | ipkg.setRuntimeDirectory( dir ); | ||
908 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | ||
909 | item != 0 ; | ||
910 | item = (QCheckListItem *)item->nextSibling() ) | ||
911 | { | ||
912 | if ( item->isOn() ) | ||
913 | { | ||
914 | ipkg.setPackage( item->text() ); | ||
915 | ipkg.runIpkg( ); | ||
916 | } | ||
917 | } | ||
918 | } | ||
919 | |||
920 | void MainWindow :: downloadRemotePackage() | ||
921 | { | ||
922 | // Display dialog | ||
923 | bool ok; | ||
924 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); | ||
925 | if ( !ok || package.isEmpty() ) | ||
926 | return; | ||
927 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); | ||
928 | // if ( dlg.exec() == QDialog::Rejected ) | ||
929 | // return; | ||
930 | |||
931 | // grab details from dialog | ||
932 | // QString package = dlg.getPackageLocation(); | ||
933 | |||
934 | InstallData item; | ||
935 | item.option = "I"; | ||
936 | item.packageName = package; | ||
937 | vector<InstallData> workingPackages; | ||
938 | workingPackages.push_back( item ); | ||
939 | |||
940 | InstallDlgImpl dlg2( workingPackages, mgr, this, "Install", true ); | ||
941 | dlg2.showDlg(); | ||
942 | |||
943 | // Reload data | ||
944 | mgr->reloadServerData(); | ||
945 | serverSelected(-1); | ||
946 | |||
947 | #ifdef QWS | ||
948 | // Finally let the main system update itself | ||
949 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | ||
950 | QString lf = QString::null; | ||
951 | e << lf; | ||
952 | #endif | ||
953 | } | ||
954 | |||
955 | |||
956 | void MainWindow :: applyChanges() | ||
957 | { | ||
958 | stickyOption = ""; | ||
959 | |||
960 | // First, write out ipkg_conf file so that ipkg can use it | ||
961 | mgr->writeOutIpkgConf(); | ||
962 | |||
963 | // Now for each selected item | ||
964 | // deal with it | ||
965 | |||
966 | vector<InstallData> workingPackages; | ||
967 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | ||
968 | item != 0 ; | ||
969 | item = (QCheckListItem *)item->nextSibling() ) | ||
970 | { | ||
971 | if ( item->isOn() ) | ||
972 | { | ||
973 | InstallData data = dealWithItem( item ); | ||
974 | workingPackages.push_back( data ); | ||
975 | } | ||
976 | } | ||
977 | |||
978 | if ( workingPackages.size() == 0 ) | ||
979 | { | ||
980 | // Nothing to do | ||
981 | QMessageBox::information( this, tr( "Nothing to do" ), | ||
982 | tr( "No packages selected" ), tr( "OK" ) ); | ||
983 | |||
984 | return; | ||
985 | } | ||
986 | |||
987 | // do the stuff | ||
988 | InstallDlgImpl dlg( workingPackages, mgr, this, "Install", true ); | ||
989 | dlg.showDlg(); | ||
990 | |||
991 | // Reload data | ||
992 | mgr->reloadServerData(); | ||
993 | serverSelected(-1); | ||
994 | |||
995 | #ifdef QWS | ||
996 | // Finally let the main system update itself | ||
997 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | ||
998 | QString lf = QString::null; | ||
999 | e << lf; | ||
1000 | #endif | ||
1001 | } | ||
1002 | |||
1003 | // decide what to do - either remove, upgrade or install | ||
1004 | // Current rules: | ||
1005 | // If not installed - install | ||
1006 | // If installed and different version available - upgrade | ||
1007 | // If installed and version up to date - remove | ||
1008 | InstallData MainWindow :: dealWithItem( QCheckListItem *item ) | ||
1009 | { | ||
1010 | QString name = item->text(); | ||
1011 | |||
1012 | // Get package | ||
1013 | vector<Server>::iterator s = mgr->getServer( serversList->currentText() ); | ||
1014 | Package *p = s->getPackage( name ); | ||
1015 | |||
1016 | // If the package has a filename then it is a local file | ||
1017 | if ( p->isPackageStoredLocally() ) | ||
1018 | name = p->getFilename(); | ||
1019 | |||
1020 | QString option; | ||
1021 | QString dest = "root"; | ||
1022 | if ( !p->isInstalled() ) | ||
1023 | { | ||
1024 | InstallData item; | ||
1025 | item.option = "I"; | ||
1026 | item.packageName = name; | ||
1027 | return item; | ||
1028 | } | ||
1029 | else | ||
1030 | { | ||
1031 | InstallData item; | ||
1032 | item.option = "D"; | ||
1033 | if ( !p->isPackageStoredLocally() ) | ||
1034 | item.packageName = p->getInstalledPackageName(); | ||
1035 | else | ||
1036 | item.packageName = name; | ||
1037 | |||
1038 | if ( p->getInstalledTo() ) | ||
1039 | { | ||
1040 | item.destination = p->getInstalledTo(); | ||
1041 | // cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; | ||
1042 | // cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; | ||
1043 | } | ||
1044 | else | ||
1045 | { | ||
1046 | item.destination = p->getLocalPackage()->getInstalledTo(); | ||
1047 | } | ||
1048 | |||
1049 | // Now see if version is newer or not | ||
1050 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | ||
1051 | |||
1052 | // If the version requested is older and user selected a local ipk file, then reinstall the file | ||
1053 | if ( p->isPackageStoredLocally() && val == -1 ) | ||
1054 | val = 0; | ||
1055 | |||
1056 | if ( val == -2 ) | ||
1057 | { | ||
1058 | // Error - should handle | ||
1059 | } | ||
1060 | else if ( val == -1 ) | ||
1061 | { | ||
1062 | // Version available is older - remove only | ||
1063 | item.option = "D"; | ||
1064 | } | ||
1065 | else | ||
1066 | { | ||
1067 | QString caption; | ||
1068 | QString text; | ||
1069 | QString secondButton; | ||
1070 | QString secondOption; | ||
1071 | if ( val == 0 ) | ||
1072 | { | ||
1073 | // Version available is the same - option to remove or reinstall | ||
1074 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); | ||
1075 | text = tr( "Remove or ReInstall" ); | ||
1076 | secondButton = tr( "ReInstall" ); | ||
1077 | secondOption = tr( "R" ); | ||
1078 | } | ||
1079 | else if ( val == 1 ) | ||
1080 | { | ||
1081 | // Version available is newer - option to remove or upgrade | ||
1082 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); | ||
1083 | text = tr( "Remove or Upgrade" ); | ||
1084 | secondButton = tr( "Upgrade" ); | ||
1085 | secondOption = tr( "U" ); | ||
1086 | } | ||
1087 | |||
1088 | // Sticky option not implemented yet, but will eventually allow | ||
1089 | // the user to say something like 'remove all' | ||
1090 | if ( stickyOption == "" ) | ||
1091 | { | ||
1092 | QString msgtext; | ||
1093 | msgtext = caption.arg( ( const char * )name ); | ||
1094 | switch( QMessageBox::information( this, text, | ||
1095 | msgtext, tr( "Remove" ), secondButton ) ) | ||
1096 | { | ||
1097 | case 0: // Try again or Enter | ||
1098 | // option 0 = Remove | ||
1099 | item.option = "D"; | ||
1100 | break; | ||
1101 | case 1: // Quit or Escape | ||
1102 | item.option = secondOption; | ||
1103 | break; | ||
1104 | } | ||
1105 | } | ||
1106 | else | ||
1107 | { | ||
1108 | // item.option = stickyOption; | ||
1109 | } | ||
1110 | } | ||
1111 | |||
1112 | |||
1113 | // Check if we are reinstalling the same version | ||
1114 | if ( item.option != "R" ) | ||
1115 | item.recreateLinks = true; | ||
1116 | else | ||
1117 | item.recreateLinks = false; | ||
1118 | |||
1119 | // User hit cancel (on dlg - assume remove) | ||
1120 | return item; | ||
1121 | } | ||
1122 | } | ||
1123 | |||
1124 | void MainWindow :: letterPushed( QString t ) | ||
1125 | { | ||
1126 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | ||
1127 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | ||
1128 | if ( packagesList->firstChild() == 0 ) | ||
1129 | return; | ||
1130 | |||
1131 | QCheckListItem *item; | ||
1132 | if ( start == 0 ) | ||
1133 | { | ||
1134 | item = (QCheckListItem *)packagesList->firstChild(); | ||
1135 | start = top; | ||
1136 | } | ||
1137 | else | ||
1138 | item = (QCheckListItem *)start->nextSibling(); | ||
1139 | |||
1140 | if ( item == 0 ) | ||
1141 | item = (QCheckListItem *)packagesList->firstChild(); | ||
1142 | do | ||
1143 | { | ||
1144 | if ( item->text().lower().startsWith( t.lower() ) ) | ||
1145 | { | ||
1146 | packagesList->setSelected( item, true ); | ||
1147 | packagesList->ensureItemVisible( item ); | ||
1148 | break; | ||
1149 | } | ||
1150 | |||
1151 | item = (QCheckListItem *)item->nextSibling(); | ||
1152 | if ( !item ) | ||
1153 | item = (QCheckListItem *)packagesList->firstChild(); | ||
1154 | } while ( item != start); | ||
1155 | } | ||