-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 11 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.h | 1 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 16 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.h | 3 |
4 files changed, 22 insertions, 9 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 0b5a5eb..3c72f2b 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -1,104 +1,111 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | mainwin.cpp - description | 2 | mainwin.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 <qmenubar.h> | 18 | #include <qmenubar.h> |
19 | #include <qpopupmenu.h> | 19 | #include <qpopupmenu.h> |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | 21 | ||
22 | #include "mainwin.h" | 22 | #include "mainwin.h" |
23 | #include "datamgr.h" | 23 | #include "datamgr.h" |
24 | #include "networkpkgmgr.h" | 24 | #include "networkpkgmgr.h" |
25 | #include "settingsimpl.h" | 25 | #include "settingsimpl.h" |
26 | #include "helpwindow.h" | 26 | #include "helpwindow.h" |
27 | #include "utils.h" | 27 | #include "utils.h" |
28 | #include "global.h" | 28 | #include "global.h" |
29 | 29 | ||
30 | MainWindow :: MainWindow( QWidget *p, char *name ) | 30 | MainWindow :: MainWindow( QWidget *p, char *name ) |
31 | :QMainWindow( p, name ) | 31 | :QMainWindow( p, name ) |
32 | { | 32 | { |
33 | #ifdef QWS | 33 | #ifdef QWS |
34 | showMaximized(); | 34 | showMaximized(); |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | setCaption( "AQPkg - Package Manager" ); | 37 | setCaption( "AQPkg - Package Manager" ); |
38 | 38 | ||
39 | // Create our menu | 39 | // Create our menu |
40 | QPopupMenu *help = new QPopupMenu( this ); | 40 | QPopupMenu *help = new QPopupMenu( this ); |
41 | |||
41 | help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_H ); | 42 | help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_H ); |
42 | help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); | 43 | help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); |
43 | 44 | ||
44 | QPopupMenu *settings = new QPopupMenu( this ); | 45 | QPopupMenu *settings = new QPopupMenu( this ); |
45 | settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); | 46 | settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); |
46 | 47 | ||
47 | QPopupMenu *edit = new QPopupMenu( this ); | 48 | QPopupMenu *edit = new QPopupMenu( this ); |
48 | edit->insertItem( "&Search", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_F ); | 49 | edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_F ); |
50 | edit->insertItem( "&Find Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_R ); | ||
49 | 51 | ||
50 | // Create the main menu | 52 | // Create the main menu |
51 | QMenuBar *menu = menuBar(); //new QMenuBar( this ); | 53 | QMenuBar *menu = menuBar(); //new QMenuBar( this ); |
52 | menu->insertItem( "&Settings", settings ); | 54 | menu->insertItem( "&Settings", settings ); |
53 | menu->insertItem( "&Edit", edit ); | 55 | menu->insertItem( "&Edit", edit ); |
54 | menu->insertItem( "&Help", help ); | 56 | menu->insertItem( "&Help", help ); |
55 | 57 | ||
56 | mgr = new DataManager(); | 58 | mgr = new DataManager(); |
57 | mgr->loadServers(); | 59 | mgr->loadServers(); |
58 | 60 | ||
59 | stack = new QWidgetStack( this ); | 61 | stack = new QWidgetStack( this ); |
60 | 62 | ||
61 | networkPkgWindow = new NetworkPackageManager( mgr, stack ); | 63 | networkPkgWindow = new NetworkPackageManager( mgr, stack ); |
62 | stack->addWidget( networkPkgWindow, 1 ); | 64 | stack->addWidget( networkPkgWindow, 1 ); |
63 | 65 | ||
64 | setCentralWidget( stack ); | 66 | setCentralWidget( stack ); |
65 | stack->raiseWidget( networkPkgWindow ); | 67 | stack->raiseWidget( networkPkgWindow ); |
66 | } | 68 | } |
67 | 69 | ||
68 | MainWindow :: ~MainWindow() | 70 | MainWindow :: ~MainWindow() |
69 | { | 71 | { |
70 | delete networkPkgWindow; | 72 | delete networkPkgWindow; |
71 | } | 73 | } |
72 | 74 | ||
73 | void MainWindow :: setDocument( const QString &doc ) | 75 | void MainWindow :: setDocument( const QString &doc ) |
74 | { | 76 | { |
75 | // Remove path from package | 77 | // Remove path from package |
76 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 78 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
77 | cout << "Selecting package " << package << endl; | 79 | cout << "Selecting package " << package << endl; |
78 | networkPkgWindow->selectLocalPackage( package ); | 80 | networkPkgWindow->selectLocalPackage( package ); |
79 | } | 81 | } |
80 | 82 | ||
81 | void MainWindow :: displaySettings() | 83 | void MainWindow :: displaySettings() |
82 | { | 84 | { |
83 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 85 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
84 | if ( dlg->showDlg( 0 ) ) | 86 | if ( dlg->showDlg( 0 ) ) |
85 | networkPkgWindow->updateData(); | 87 | networkPkgWindow->updateData(); |
86 | delete dlg; | 88 | delete dlg; |
87 | } | 89 | } |
88 | 90 | ||
89 | void MainWindow :: displayHelp() | 91 | void MainWindow :: displayHelp() |
90 | { | 92 | { |
91 | HelpWindow *dlg = new HelpWindow( this ); | 93 | HelpWindow *dlg = new HelpWindow( this ); |
92 | dlg->exec(); | 94 | dlg->exec(); |
93 | delete dlg; | 95 | delete dlg; |
94 | } | 96 | } |
95 | 97 | ||
96 | void MainWindow :: searchForPackage() | 98 | void MainWindow :: searchForPackage() |
97 | { | 99 | { |
98 | networkPkgWindow->searchForPackage(); | 100 | networkPkgWindow->searchForPackage( false ); |
101 | } | ||
102 | |||
103 | void MainWindow :: repeatSearchForPackage() | ||
104 | { | ||
105 | networkPkgWindow->searchForPackage( true ); | ||
99 | } | 106 | } |
100 | 107 | ||
101 | void MainWindow :: displayAbout() | 108 | void MainWindow :: displayAbout() |
102 | { | 109 | { |
103 | QMessageBox::about( this, "About AQPkg", VERSION_TEXT ); | 110 | QMessageBox::about( this, "About AQPkg", VERSION_TEXT ); |
104 | } | 111 | } |
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index 9fa0eca..267233f 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h | |||
@@ -1,49 +1,50 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | mainwin.h - description | 2 | mainwin.h - 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 | #ifndef MAINWIN_H | 18 | #ifndef MAINWIN_H |
19 | #define MAINWIN_H | 19 | #define MAINWIN_H |
20 | 20 | ||
21 | #include <qmainwindow.h> | 21 | #include <qmainwindow.h> |
22 | #include <qwidgetstack.h> | 22 | #include <qwidgetstack.h> |
23 | 23 | ||
24 | 24 | ||
25 | class NetworkPackageManager; | 25 | class NetworkPackageManager; |
26 | class DataManager; | 26 | class DataManager; |
27 | 27 | ||
28 | class MainWindow :public QMainWindow | 28 | class MainWindow :public QMainWindow |
29 | { | 29 | { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | public: | 31 | public: |
32 | 32 | ||
33 | MainWindow( QWidget *p = 0, char *name = 0 ); | 33 | MainWindow( QWidget *p = 0, char *name = 0 ); |
34 | ~MainWindow(); | 34 | ~MainWindow(); |
35 | 35 | ||
36 | private: | 36 | private: |
37 | DataManager *mgr; | 37 | DataManager *mgr; |
38 | 38 | ||
39 | QWidgetStack *stack; | 39 | QWidgetStack *stack; |
40 | NetworkPackageManager *networkPkgWindow; | 40 | NetworkPackageManager *networkPkgWindow; |
41 | 41 | ||
42 | public slots: | 42 | public slots: |
43 | void setDocument( const QString &doc ); | 43 | void setDocument( const QString &doc ); |
44 | void displayHelp(); | 44 | void displayHelp(); |
45 | void searchForPackage(); | 45 | void searchForPackage(); |
46 | void repeatSearchForPackage(); | ||
46 | void displayAbout(); | 47 | void displayAbout(); |
47 | void displaySettings(); | 48 | void displaySettings(); |
48 | }; | 49 | }; |
49 | #endif | 50 | #endif |
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 78d3df5..a058285 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp | |||
@@ -294,414 +294,418 @@ void NetworkPackageManager :: serverSelected( int ) | |||
294 | download->setEnabled( true ); | 294 | download->setEnabled( true ); |
295 | download->setText( "Remove" ); | 295 | download->setText( "Remove" ); |
296 | } | 296 | } |
297 | else | 297 | else |
298 | { | 298 | { |
299 | upgrade->setEnabled( true ); | 299 | upgrade->setEnabled( true ); |
300 | download->setEnabled( true ); | 300 | download->setEnabled( true ); |
301 | download->setText( "Download" ); | 301 | download->setText( "Download" ); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | 304 | ||
305 | void NetworkPackageManager :: updateServer() | 305 | void NetworkPackageManager :: updateServer() |
306 | { | 306 | { |
307 | QString serverName = serversList->currentText(); | 307 | QString serverName = serversList->currentText(); |
308 | 308 | ||
309 | // Update the current server | 309 | // Update the current server |
310 | // Display dialog | 310 | // Display dialog |
311 | // ProgressDlg *progDlg = new ProgressDlg( this ); | 311 | // ProgressDlg *progDlg = new ProgressDlg( this ); |
312 | // QString status = "Updating package lists..."; | 312 | // QString status = "Updating package lists..."; |
313 | // progDlg->show(); | 313 | // progDlg->show(); |
314 | // progDlg->setText( status ); | 314 | // progDlg->setText( status ); |
315 | 315 | ||
316 | // Disable buttons to stop silly people clicking lots on them :) | 316 | // Disable buttons to stop silly people clicking lots on them :) |
317 | 317 | ||
318 | // First, write out ipkg_conf file so that ipkg can use it | 318 | // First, write out ipkg_conf file so that ipkg can use it |
319 | dataMgr->writeOutIpkgConf(); | 319 | dataMgr->writeOutIpkgConf(); |
320 | 320 | ||
321 | Ipkg ipkg; | 321 | Ipkg ipkg; |
322 | ipkg.setOption( "update" ); | 322 | ipkg.setOption( "update" ); |
323 | 323 | ||
324 | InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); | 324 | InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); |
325 | dlg.showDlg(); | 325 | dlg.showDlg(); |
326 | 326 | ||
327 | // Reload data | 327 | // Reload data |
328 | dataMgr->reloadServerData(); | 328 | dataMgr->reloadServerData(); |
329 | serverSelected(-1); | 329 | serverSelected(-1); |
330 | // delete progDlg; | 330 | // delete progDlg; |
331 | } | 331 | } |
332 | 332 | ||
333 | void NetworkPackageManager :: upgradePackages() | 333 | void NetworkPackageManager :: upgradePackages() |
334 | { | 334 | { |
335 | // We're gonna do an upgrade of all packages | 335 | // We're gonna do an upgrade of all packages |
336 | // First warn user that this isn't recommended | 336 | // First warn user that this isn't recommended |
337 | QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; | 337 | QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; |
338 | QMessageBox warn("Warning", text, QMessageBox::Warning, | 338 | QMessageBox warn("Warning", text, QMessageBox::Warning, |
339 | QMessageBox::Yes, | 339 | QMessageBox::Yes, |
340 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 340 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
341 | 0, this ); | 341 | 0, this ); |
342 | warn.adjustSize(); | 342 | warn.adjustSize(); |
343 | 343 | ||
344 | if ( warn.exec() == QMessageBox::Yes ) | 344 | if ( warn.exec() == QMessageBox::Yes ) |
345 | { | 345 | { |
346 | // First, write out ipkg_conf file so that ipkg can use it | 346 | // First, write out ipkg_conf file so that ipkg can use it |
347 | dataMgr->writeOutIpkgConf(); | 347 | dataMgr->writeOutIpkgConf(); |
348 | 348 | ||
349 | // Now run upgrade | 349 | // Now run upgrade |
350 | Ipkg ipkg; | 350 | Ipkg ipkg; |
351 | ipkg.setOption( "upgrade" ); | 351 | ipkg.setOption( "upgrade" ); |
352 | 352 | ||
353 | InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); | 353 | InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); |
354 | dlg.showDlg(); | 354 | dlg.showDlg(); |
355 | 355 | ||
356 | // Reload data | 356 | // Reload data |
357 | dataMgr->reloadServerData(); | 357 | dataMgr->reloadServerData(); |
358 | serverSelected(-1); | 358 | serverSelected(-1); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | 361 | ||
362 | 362 | ||
363 | void NetworkPackageManager :: downloadPackage() | 363 | void NetworkPackageManager :: downloadPackage() |
364 | { | 364 | { |
365 | bool doUpdate = true; | 365 | bool doUpdate = true; |
366 | if ( download->text() == "Download" ) | 366 | if ( download->text() == "Download" ) |
367 | { | 367 | { |
368 | // First, write out ipkg_conf file so that ipkg can use it | 368 | // First, write out ipkg_conf file so that ipkg can use it |
369 | dataMgr->writeOutIpkgConf(); | 369 | dataMgr->writeOutIpkgConf(); |
370 | 370 | ||
371 | // Display dialog to user asking where to download the files to | 371 | // Display dialog to user asking where to download the files to |
372 | bool ok = FALSE; | 372 | bool ok = FALSE; |
373 | QString dir = ""; | 373 | QString dir = ""; |
374 | #ifdef QWS | 374 | #ifdef QWS |
375 | // read download directory from config file | 375 | // read download directory from config file |
376 | Config cfg( "aqpkg" ); | 376 | Config cfg( "aqpkg" ); |
377 | cfg.setGroup( "settings" ); | 377 | cfg.setGroup( "settings" ); |
378 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 378 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
379 | #endif | 379 | #endif |
380 | 380 | ||
381 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 381 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
382 | if ( ok && !text.isEmpty() ) | 382 | if ( ok && !text.isEmpty() ) |
383 | dir = text; // user entered something and pressed ok | 383 | dir = text; // user entered something and pressed ok |
384 | else | 384 | else |
385 | return; // user entered nothing or pressed cancel | 385 | return; // user entered nothing or pressed cancel |
386 | 386 | ||
387 | #ifdef QWS | 387 | #ifdef QWS |
388 | // Store download directory in config file | 388 | // Store download directory in config file |
389 | cfg.writeEntry( "downloadDir", dir ); | 389 | cfg.writeEntry( "downloadDir", dir ); |
390 | #endif | 390 | #endif |
391 | 391 | ||
392 | // Get starting directory | 392 | // Get starting directory |
393 | char initDir[PATH_MAX]; | 393 | char initDir[PATH_MAX]; |
394 | getcwd( initDir, PATH_MAX ); | 394 | getcwd( initDir, PATH_MAX ); |
395 | 395 | ||
396 | // Download each package | 396 | // Download each package |
397 | Ipkg ipkg; | 397 | Ipkg ipkg; |
398 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 398 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
399 | 399 | ||
400 | ipkg.setOption( "download" ); | 400 | ipkg.setOption( "download" ); |
401 | ipkg.setRuntimeDirectory( dir ); | 401 | ipkg.setRuntimeDirectory( dir ); |
402 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 402 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
403 | item != 0 ; | 403 | item != 0 ; |
404 | item = (QCheckListItem *)item->nextSibling() ) | 404 | item = (QCheckListItem *)item->nextSibling() ) |
405 | { | 405 | { |
406 | if ( item->isOn() ) | 406 | if ( item->isOn() ) |
407 | { | 407 | { |
408 | QString name = item->text(); | 408 | QString name = item->text(); |
409 | int pos = name.find( "*" ); | 409 | int pos = name.find( "*" ); |
410 | name.truncate( pos ); | 410 | name.truncate( pos ); |
411 | 411 | ||
412 | // if (there is a (installed), remove it | 412 | // if (there is a (installed), remove it |
413 | pos = name.find( "(installed)" ); | 413 | pos = name.find( "(installed)" ); |
414 | if ( pos > 0 ) | 414 | if ( pos > 0 ) |
415 | name.truncate( pos - 1 ); | 415 | name.truncate( pos - 1 ); |
416 | 416 | ||
417 | ipkg.setPackage( name ); | 417 | ipkg.setPackage( name ); |
418 | ipkg.runIpkg( ); | 418 | ipkg.runIpkg( ); |
419 | } | 419 | } |
420 | } | 420 | } |
421 | } | 421 | } |
422 | else if ( download->text() == "Remove" ) | 422 | else if ( download->text() == "Remove" ) |
423 | { | 423 | { |
424 | doUpdate = false; | 424 | doUpdate = false; |
425 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 425 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
426 | item != 0 ; | 426 | item != 0 ; |
427 | item = (QCheckListItem *)item->nextSibling() ) | 427 | item = (QCheckListItem *)item->nextSibling() ) |
428 | { | 428 | { |
429 | if ( item->isOn() ) | 429 | if ( item->isOn() ) |
430 | { | 430 | { |
431 | QString name = item->text(); | 431 | QString name = item->text(); |
432 | int pos = name.find( "*" ); | 432 | int pos = name.find( "*" ); |
433 | name.truncate( pos ); | 433 | name.truncate( pos ); |
434 | 434 | ||
435 | // if (there is a (installed), remove it | 435 | // if (there is a (installed), remove it |
436 | pos = name.find( "(installed)" ); | 436 | pos = name.find( "(installed)" ); |
437 | if ( pos > 0 ) | 437 | if ( pos > 0 ) |
438 | name.truncate( pos - 1 ); | 438 | name.truncate( pos - 1 ); |
439 | 439 | ||
440 | Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); | 440 | Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); |
441 | 441 | ||
442 | QString msgtext; | 442 | QString msgtext; |
443 | msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() ); | 443 | msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() ); |
444 | if ( QMessageBox::information( this, "Are you sure?", | 444 | if ( QMessageBox::information( this, "Are you sure?", |
445 | msgtext, "No", "Yes" ) == 1 ) | 445 | msgtext, "No", "Yes" ) == 1 ) |
446 | { | 446 | { |
447 | doUpdate = true; | 447 | doUpdate = true; |
448 | QFile f( p->getFilename() ); | 448 | QFile f( p->getFilename() ); |
449 | f.remove(); | 449 | f.remove(); |
450 | } | 450 | } |
451 | } | 451 | } |
452 | } | 452 | } |
453 | } | 453 | } |
454 | 454 | ||
455 | if ( doUpdate ) | 455 | if ( doUpdate ) |
456 | { | 456 | { |
457 | dataMgr->reloadServerData(); | 457 | dataMgr->reloadServerData(); |
458 | serverSelected( -1 ); | 458 | serverSelected( -1 ); |
459 | } | 459 | } |
460 | } | 460 | } |
461 | 461 | ||
462 | 462 | ||
463 | void NetworkPackageManager :: applyChanges() | 463 | void NetworkPackageManager :: applyChanges() |
464 | { | 464 | { |
465 | stickyOption = ""; | 465 | stickyOption = ""; |
466 | 466 | ||
467 | // First, write out ipkg_conf file so that ipkg can use it | 467 | // First, write out ipkg_conf file so that ipkg can use it |
468 | dataMgr->writeOutIpkgConf(); | 468 | dataMgr->writeOutIpkgConf(); |
469 | 469 | ||
470 | // Now for each selected item | 470 | // Now for each selected item |
471 | // deal with it | 471 | // deal with it |
472 | 472 | ||
473 | vector<InstallData> workingPackages; | 473 | vector<InstallData> workingPackages; |
474 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 474 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
475 | item != 0 ; | 475 | item != 0 ; |
476 | item = (QCheckListItem *)item->nextSibling() ) | 476 | item = (QCheckListItem *)item->nextSibling() ) |
477 | { | 477 | { |
478 | if ( item->isOn() ) | 478 | if ( item->isOn() ) |
479 | { | 479 | { |
480 | InstallData data = dealWithItem( item ); | 480 | InstallData data = dealWithItem( item ); |
481 | workingPackages.push_back( data ); | 481 | workingPackages.push_back( data ); |
482 | } | 482 | } |
483 | } | 483 | } |
484 | 484 | ||
485 | if ( workingPackages.size() == 0 ) | 485 | if ( workingPackages.size() == 0 ) |
486 | { | 486 | { |
487 | // Nothing to do | 487 | // Nothing to do |
488 | QMessageBox::information( this, "Nothing to do", | 488 | QMessageBox::information( this, "Nothing to do", |
489 | "No packages selected", "OK" ); | 489 | "No packages selected", "OK" ); |
490 | 490 | ||
491 | return; | 491 | return; |
492 | } | 492 | } |
493 | 493 | ||
494 | // do the stuff | 494 | // do the stuff |
495 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); | 495 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); |
496 | dlg.showDlg(); | 496 | dlg.showDlg(); |
497 | 497 | ||
498 | // Reload data | 498 | // Reload data |
499 | dataMgr->reloadServerData(); | 499 | dataMgr->reloadServerData(); |
500 | serverSelected(-1); | 500 | serverSelected(-1); |
501 | 501 | ||
502 | #ifdef QWS | 502 | #ifdef QWS |
503 | // Finally let the main system update itself | 503 | // Finally let the main system update itself |
504 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 504 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
505 | QString lf = QString::null; | 505 | QString lf = QString::null; |
506 | e << lf; | 506 | e << lf; |
507 | #endif | 507 | #endif |
508 | } | 508 | } |
509 | 509 | ||
510 | // decide what to do - either remove, upgrade or install | 510 | // decide what to do - either remove, upgrade or install |
511 | // Current rules: | 511 | // Current rules: |
512 | // If not installed - install | 512 | // If not installed - install |
513 | // If installed and different version available - upgrade | 513 | // If installed and different version available - upgrade |
514 | // If installed and version up to date - remove | 514 | // If installed and version up to date - remove |
515 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | 515 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) |
516 | { | 516 | { |
517 | QString name = item->text(); | 517 | QString name = item->text(); |
518 | int pos = name.find( "*" ); | 518 | int pos = name.find( "*" ); |
519 | name.truncate( pos ); | 519 | name.truncate( pos ); |
520 | 520 | ||
521 | // if (there is a (installed), remove it | 521 | // if (there is a (installed), remove it |
522 | pos = name.find( "(installed)" ); | 522 | pos = name.find( "(installed)" ); |
523 | if ( pos > 0 ) | 523 | if ( pos > 0 ) |
524 | name.truncate( pos - 1 ); | 524 | name.truncate( pos - 1 ); |
525 | 525 | ||
526 | // Get package | 526 | // Get package |
527 | Server *s = dataMgr->getServer( serversList->currentText() ); | 527 | Server *s = dataMgr->getServer( serversList->currentText() ); |
528 | Package *p = s->getPackage( name ); | 528 | Package *p = s->getPackage( name ); |
529 | 529 | ||
530 | // If the package has a filename then it is a local file | 530 | // If the package has a filename then it is a local file |
531 | if ( p->isPackageStoredLocally() ) | 531 | if ( p->isPackageStoredLocally() ) |
532 | name = p->getFilename(); | 532 | name = p->getFilename(); |
533 | 533 | ||
534 | QString option; | 534 | QString option; |
535 | QString dest = "root"; | 535 | QString dest = "root"; |
536 | if ( !p->isInstalled() ) | 536 | if ( !p->isInstalled() ) |
537 | { | 537 | { |
538 | InstallData item; | 538 | InstallData item; |
539 | item.option = "I"; | 539 | item.option = "I"; |
540 | item.packageName = name; | 540 | item.packageName = name; |
541 | return item; | 541 | return item; |
542 | } | 542 | } |
543 | else | 543 | else |
544 | { | 544 | { |
545 | InstallData item; | 545 | InstallData item; |
546 | item.option = "D"; | 546 | item.option = "D"; |
547 | if ( !p->isPackageStoredLocally() ) | 547 | if ( !p->isPackageStoredLocally() ) |
548 | item.packageName = p->getInstalledPackageName(); | 548 | item.packageName = p->getInstalledPackageName(); |
549 | else | 549 | else |
550 | item.packageName = name; | 550 | item.packageName = name; |
551 | 551 | ||
552 | if ( p->getInstalledTo() ) | 552 | if ( p->getInstalledTo() ) |
553 | { | 553 | { |
554 | item.destination = p->getInstalledTo(); | 554 | item.destination = p->getInstalledTo(); |
555 | cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; | 555 | cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; |
556 | cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; | 556 | cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; |
557 | } | 557 | } |
558 | else | 558 | else |
559 | { | 559 | { |
560 | item.destination = p->getLocalPackage()->getInstalledTo(); | 560 | item.destination = p->getLocalPackage()->getInstalledTo(); |
561 | } | 561 | } |
562 | 562 | ||
563 | // Now see if version is newer or not | 563 | // Now see if version is newer or not |
564 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | 564 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
565 | 565 | ||
566 | // If the version requested is older and user selected a local ipk file, then reinstall the file | 566 | // If the version requested is older and user selected a local ipk file, then reinstall the file |
567 | if ( p->isPackageStoredLocally() && val == -1 ) | 567 | if ( p->isPackageStoredLocally() && val == -1 ) |
568 | val = 0; | 568 | val = 0; |
569 | 569 | ||
570 | if ( val == -2 ) | 570 | if ( val == -2 ) |
571 | { | 571 | { |
572 | // Error - should handle | 572 | // Error - should handle |
573 | } | 573 | } |
574 | else if ( val == -1 ) | 574 | else if ( val == -1 ) |
575 | { | 575 | { |
576 | // Version available is older - remove only | 576 | // Version available is older - remove only |
577 | item.option = "D"; | 577 | item.option = "D"; |
578 | } | 578 | } |
579 | else | 579 | else |
580 | { | 580 | { |
581 | QString caption; | 581 | QString caption; |
582 | QString text; | 582 | QString text; |
583 | QString secondButton; | 583 | QString secondButton; |
584 | QString secondOption; | 584 | QString secondOption; |
585 | if ( val == 0 ) | 585 | if ( val == 0 ) |
586 | { | 586 | { |
587 | // Version available is the same - option to remove or reinstall | 587 | // Version available is the same - option to remove or reinstall |
588 | caption = "Do you wish to remove or reinstall\n%s?"; | 588 | caption = "Do you wish to remove or reinstall\n%s?"; |
589 | text = "Remove or ReInstall"; | 589 | text = "Remove or ReInstall"; |
590 | secondButton = "ReInstall"; | 590 | secondButton = "ReInstall"; |
591 | secondOption = "R"; | 591 | secondOption = "R"; |
592 | } | 592 | } |
593 | else if ( val == 1 ) | 593 | else if ( val == 1 ) |
594 | { | 594 | { |
595 | // Version available is newer - option to remove or upgrade | 595 | // Version available is newer - option to remove or upgrade |
596 | caption = "Do you wish to remove or upgrade\n%s?"; | 596 | caption = "Do you wish to remove or upgrade\n%s?"; |
597 | text = "Remove or Upgrade"; | 597 | text = "Remove or Upgrade"; |
598 | secondButton = "Upgrade"; | 598 | secondButton = "Upgrade"; |
599 | secondOption = "U"; | 599 | secondOption = "U"; |
600 | } | 600 | } |
601 | 601 | ||
602 | // Sticky option not implemented yet, but will eventually allow | 602 | // Sticky option not implemented yet, but will eventually allow |
603 | // the user to say something like 'remove all' | 603 | // the user to say something like 'remove all' |
604 | if ( stickyOption == "" ) | 604 | if ( stickyOption == "" ) |
605 | { | 605 | { |
606 | QString msgtext; | 606 | QString msgtext; |
607 | msgtext.sprintf( caption, (const char *)name ); | 607 | msgtext.sprintf( caption, (const char *)name ); |
608 | switch( QMessageBox::information( this, text, | 608 | switch( QMessageBox::information( this, text, |
609 | msgtext, "Remove", secondButton ) ) | 609 | msgtext, "Remove", secondButton ) ) |
610 | { | 610 | { |
611 | case 0: // Try again or Enter | 611 | case 0: // Try again or Enter |
612 | // option 0 = Remove | 612 | // option 0 = Remove |
613 | item.option = "D"; | 613 | item.option = "D"; |
614 | break; | 614 | break; |
615 | case 1: // Quit or Escape | 615 | case 1: // Quit or Escape |
616 | item.option = secondOption; | 616 | item.option = secondOption; |
617 | break; | 617 | break; |
618 | } | 618 | } |
619 | } | 619 | } |
620 | else | 620 | else |
621 | { | 621 | { |
622 | // item.option = stickyOption; | 622 | // item.option = stickyOption; |
623 | } | 623 | } |
624 | } | 624 | } |
625 | 625 | ||
626 | 626 | ||
627 | // Check if we are reinstalling the same version | 627 | // Check if we are reinstalling the same version |
628 | if ( item.option != "R" ) | 628 | if ( item.option != "R" ) |
629 | item.recreateLinks = true; | 629 | item.recreateLinks = true; |
630 | else | 630 | else |
631 | item.recreateLinks = false; | 631 | item.recreateLinks = false; |
632 | 632 | ||
633 | // User hit cancel (on dlg - assume remove) | 633 | // User hit cancel (on dlg - assume remove) |
634 | return item; | 634 | return item; |
635 | } | 635 | } |
636 | } | 636 | } |
637 | 637 | ||
638 | void NetworkPackageManager :: displayText( const QString &t ) | 638 | void NetworkPackageManager :: displayText( const QString &t ) |
639 | { | 639 | { |
640 | cout << t << endl; | 640 | cout << t << endl; |
641 | } | 641 | } |
642 | 642 | ||
643 | 643 | ||
644 | void NetworkPackageManager :: letterPushed( QString t ) | 644 | void NetworkPackageManager :: letterPushed( QString t ) |
645 | { | 645 | { |
646 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 646 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
647 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 647 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
648 | if ( packagesList->firstChild() == 0 ) | 648 | if ( packagesList->firstChild() == 0 ) |
649 | return; | 649 | return; |
650 | 650 | ||
651 | QCheckListItem *item; | 651 | QCheckListItem *item; |
652 | if ( start == 0 ) | 652 | if ( start == 0 ) |
653 | { | 653 | { |
654 | item = (QCheckListItem *)packagesList->firstChild(); | 654 | item = (QCheckListItem *)packagesList->firstChild(); |
655 | start = top; | 655 | start = top; |
656 | } | 656 | } |
657 | else | 657 | else |
658 | item = (QCheckListItem *)start->nextSibling(); | 658 | item = (QCheckListItem *)start->nextSibling(); |
659 | 659 | ||
660 | if ( item == 0 ) | 660 | if ( item == 0 ) |
661 | item = (QCheckListItem *)packagesList->firstChild(); | 661 | item = (QCheckListItem *)packagesList->firstChild(); |
662 | do | 662 | do |
663 | { | 663 | { |
664 | if ( item->text().lower().startsWith( t.lower() ) ) | 664 | if ( item->text().lower().startsWith( t.lower() ) ) |
665 | { | 665 | { |
666 | packagesList->setSelected( item, true ); | 666 | packagesList->setSelected( item, true ); |
667 | packagesList->ensureItemVisible( item ); | 667 | packagesList->ensureItemVisible( item ); |
668 | break; | 668 | break; |
669 | } | 669 | } |
670 | 670 | ||
671 | item = (QCheckListItem *)item->nextSibling(); | 671 | item = (QCheckListItem *)item->nextSibling(); |
672 | if ( !item ) | 672 | if ( !item ) |
673 | item = (QCheckListItem *)packagesList->firstChild(); | 673 | item = (QCheckListItem *)packagesList->firstChild(); |
674 | } while ( item != start); | 674 | } while ( item != start); |
675 | } | 675 | } |
676 | 676 | ||
677 | 677 | ||
678 | void NetworkPackageManager :: searchForPackage() | 678 | void NetworkPackageManager :: searchForPackage( bool findNext ) |
679 | { | 679 | { |
680 | bool ok = FALSE; | 680 | bool ok = false; |
681 | QString searchText = InputDialog::getText( "Search for package", "Enter package to search for", QString::null, &ok, this ).lower(); | 681 | if ( !findNext || lastSearchText.isEmpty() ) |
682 | if ( ok && !searchText.isEmpty() ) | 682 | lastSearchText = InputDialog::getText( "Search for package", "Enter package to search for", lastSearchText, &ok, this ).lower(); |
683 | else | ||
684 | ok = true; | ||
685 | |||
686 | if ( ok && !lastSearchText.isEmpty() ) | ||
683 | { | 687 | { |
684 | cout << "searching for " << searchText << endl; | 688 | cout << "searching for " << lastSearchText << endl; |
685 | // look through package list for text startng at current position | 689 | // look through package list for text startng at current position |
686 | vector<InstallData> workingPackages; | 690 | vector<InstallData> workingPackages; |
687 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 691 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
688 | if ( start != 0 ) | 692 | if ( start != 0 ) |
689 | start = (QCheckListItem *)start->nextSibling(); | 693 | start = (QCheckListItem *)start->nextSibling(); |
690 | 694 | ||
691 | if ( start == 0 ) | 695 | if ( start == 0 ) |
692 | start = (QCheckListItem *)packagesList->firstChild(); | 696 | start = (QCheckListItem *)packagesList->firstChild(); |
693 | 697 | ||
694 | for ( QCheckListItem *item = start; item != 0 ; | 698 | for ( QCheckListItem *item = start; item != 0 ; |
695 | item = (QCheckListItem *)item->nextSibling() ) | 699 | item = (QCheckListItem *)item->nextSibling() ) |
696 | { | 700 | { |
697 | cout << "checking " << item->text().lower() << endl; | 701 | cout << "checking " << item->text().lower() << endl; |
698 | if ( item->text().lower().find( searchText ) != -1 ) | 702 | if ( item->text().lower().find( lastSearchText ) != -1 ) |
699 | { | 703 | { |
700 | cout << "matched " << item->text() << endl; | 704 | cout << "matched " << item->text() << endl; |
701 | packagesList->ensureItemVisible( item ); | 705 | packagesList->ensureItemVisible( item ); |
702 | packagesList->setCurrentItem( item ); | 706 | packagesList->setCurrentItem( item ); |
703 | break; | 707 | break; |
704 | } | 708 | } |
705 | } | 709 | } |
706 | } | 710 | } |
707 | } \ No newline at end of file | 711 | } \ No newline at end of file |
diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h index 3a111ff..20f6e2d 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.h +++ b/noncore/settings/aqpkg/networkpkgmgr.h | |||
@@ -1,78 +1,79 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | networkpkgmgr.h - description | 2 | networkpkgmgr.h - 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 | #ifndef NETWORKPKGMGR_H | 18 | #ifndef NETWORKPKGMGR_H |
19 | #define NETWORKPKGMGR_H | 19 | #define NETWORKPKGMGR_H |
20 | 20 | ||
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | 26 | ||
27 | #include "datamgr.h" | 27 | #include "datamgr.h" |
28 | #include "progressdlg.h" | 28 | #include "progressdlg.h" |
29 | class InstallData; | 29 | class InstallData; |
30 | 30 | ||
31 | /** NetworkPackageManager is the base class of the project */ | 31 | /** NetworkPackageManager is the base class of the project */ |
32 | class NetworkPackageManager : public QWidget | 32 | class NetworkPackageManager : public QWidget |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | /** construtor */ | 36 | /** construtor */ |
37 | NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0); | 37 | NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0); |
38 | /** destructor */ | 38 | /** destructor */ |
39 | ~NetworkPackageManager(); | 39 | ~NetworkPackageManager(); |
40 | 40 | ||
41 | void selectLocalPackage( const QString &pkg ); | 41 | void selectLocalPackage( const QString &pkg ); |
42 | void updateData(); | 42 | void updateData(); |
43 | void searchForPackage(); | 43 | void searchForPackage( bool findNext ); |
44 | private: | 44 | private: |
45 | DataManager *dataMgr; | 45 | DataManager *dataMgr; |
46 | 46 | ||
47 | QComboBox *serversList; | 47 | QComboBox *serversList; |
48 | QListView *packagesList; | 48 | QListView *packagesList; |
49 | QPushButton *update; | 49 | QPushButton *update; |
50 | QPushButton *upgrade; | 50 | QPushButton *upgrade; |
51 | QPushButton *download; | 51 | QPushButton *download; |
52 | QPushButton *apply; | 52 | QPushButton *apply; |
53 | 53 | ||
54 | ProgressDlg *progressDlg; | 54 | ProgressDlg *progressDlg; |
55 | QString currentlySelectedServer; | 55 | QString currentlySelectedServer; |
56 | QString lastSearchText; | ||
56 | 57 | ||
57 | bool showJumpTo; | 58 | bool showJumpTo; |
58 | int timerId; | 59 | int timerId; |
59 | 60 | ||
60 | void timerEvent ( QTimerEvent * ); | 61 | void timerEvent ( QTimerEvent * ); |
61 | 62 | ||
62 | void initGui(); | 63 | void initGui(); |
63 | void setupConnections(); | 64 | void setupConnections(); |
64 | void showProgressDialog( char *initialText ); | 65 | void showProgressDialog( char *initialText ); |
65 | InstallData dealWithItem( QCheckListItem *item ); | 66 | InstallData dealWithItem( QCheckListItem *item ); |
66 | QString stickyOption; | 67 | QString stickyOption; |
67 | 68 | ||
68 | public slots: | 69 | public slots: |
69 | void serverSelected( int index ); | 70 | void serverSelected( int index ); |
70 | void applyChanges(); | 71 | void applyChanges(); |
71 | void upgradePackages(); | 72 | void upgradePackages(); |
72 | void downloadPackage(); | 73 | void downloadPackage(); |
73 | void updateServer(); | 74 | void updateServer(); |
74 | void displayText( const QString &t ); | 75 | void displayText( const QString &t ); |
75 | void letterPushed( QString t ); | 76 | void letterPushed( QString t ); |
76 | }; | 77 | }; |
77 | 78 | ||
78 | #endif | 79 | #endif |