Diffstat (limited to 'noncore/settings/aqpkg/networkpkgmgr.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 77 |
1 files changed, 34 insertions, 43 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index c209589..b4b6475 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp | |||
@@ -12,30 +12,26 @@ | |||
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 <fstream> | ||
19 | #include <iostream> | ||
20 | using namespace std; | ||
21 | |||
22 | #include <unistd.h> | 18 | #include <unistd.h> |
23 | #include <stdlib.h> | ||
24 | #include <linux/limits.h> | ||
25 | 19 | ||
26 | #ifdef QWS | 20 | #ifdef QWS |
27 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
29 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
24 | #include <qpe/resource.h> | ||
30 | #else | 25 | #else |
31 | #include <qapplication.h> | 26 | #include <qapplication.h> |
32 | #endif | 27 | #endif |
33 | #include <qlabel.h> | 28 | #include <qlabel.h> |
34 | #include <qfile.h> | 29 | #include <qfile.h> |
35 | #include <qmessagebox.h> | 30 | #include <qmessagebox.h> |
31 | #include <qwhatsthis.h> | ||
36 | 32 | ||
37 | #include "datamgr.h" | 33 | #include "datamgr.h" |
38 | #include "networkpkgmgr.h" | 34 | #include "networkpkgmgr.h" |
39 | #include "installdlgimpl.h" | 35 | #include "installdlgimpl.h" |
40 | #include "ipkg.h" | 36 | #include "ipkg.h" |
41 | #include "inputdlg.h" | 37 | #include "inputdlg.h" |
@@ -94,13 +90,13 @@ void NetworkPackageManager :: updateData() | |||
94 | emit progressUpdate( i ); | 90 | emit progressUpdate( i ); |
95 | qApp->processEvents(); | 91 | qApp->processEvents(); |
96 | 92 | ||
97 | // cout << "Adding " << it->getServerName() << " to combobox" << endl; | 93 | // cout << "Adding " << it->getServerName() << " to combobox" << endl; |
98 | if ( !it->isServerActive() ) | 94 | if ( !it->isServerActive() ) |
99 | { | 95 | { |
100 | cout << serverName << " is not active" << endl; | 96 | // cout << serverName << " is not active" << endl; |
101 | i--; | 97 | i--; |
102 | continue; | 98 | continue; |
103 | } | 99 | } |
104 | 100 | ||
105 | serversList->insertItem( serverName ); | 101 | serversList->insertItem( serverName ); |
106 | if ( serverName == currentlySelectedServer ) | 102 | if ( serverName == currentlySelectedServer ) |
@@ -142,14 +138,20 @@ void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) | |||
142 | 138 | ||
143 | void NetworkPackageManager :: initGui() | 139 | void NetworkPackageManager :: initGui() |
144 | { | 140 | { |
145 | QLabel *l = new QLabel( tr( "Servers" ), this ); | 141 | QLabel *l = new QLabel( tr( "Servers" ), this ); |
146 | serversList = new QComboBox( this ); | 142 | serversList = new QComboBox( this ); |
147 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); | 143 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); |
144 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); | ||
145 | |||
146 | installedIcon = Resource::loadPixmap( "aqpkg/installed" ); | ||
147 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); | ||
148 | 148 | ||
149 | packagesList = new QListView( this ); | 149 | packagesList = new QListView( this ); |
150 | packagesList->addColumn( tr( "Packages" ), 225 ); | ||
151 | 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." ) ); | ||
150 | 152 | ||
151 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1 ); | 153 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1 ); |
152 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | 154 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); |
153 | hbox1->addWidget( l ); | 155 | hbox1->addWidget( l ); |
154 | hbox1->addWidget( serversList ); | 156 | hbox1->addWidget( serversList ); |
155 | 157 | ||
@@ -171,24 +173,26 @@ void NetworkPackageManager :: initGui() | |||
171 | else | 173 | else |
172 | hbox4->addWidget( b ); | 174 | hbox4->addWidget( b ); |
173 | } | 175 | } |
174 | } | 176 | } |
175 | 177 | ||
176 | vbox->addWidget( packagesList ); | 178 | vbox->addWidget( packagesList ); |
177 | packagesList->addColumn( tr( "Packages" ) ); | ||
178 | 179 | ||
179 | downloadEnabled = TRUE; | 180 | downloadEnabled = TRUE; |
180 | } | 181 | } |
181 | 182 | ||
182 | void NetworkPackageManager :: serverSelected( int index ) | 183 | void NetworkPackageManager :: serverSelected( int index ) |
183 | { | 184 | { |
184 | serverSelected( index, TRUE ); | 185 | serverSelected( index, TRUE ); |
185 | } | 186 | } |
186 | 187 | ||
187 | void NetworkPackageManager :: serverSelected( int, bool raiseProgress ) | 188 | void NetworkPackageManager :: serverSelected( int, bool raiseProgress ) |
188 | { | 189 | { |
190 | QPixmap nullIcon( installedIcon.size() ); | ||
191 | nullIcon.fill( colorGroup().base() ); | ||
192 | |||
189 | // display packages | 193 | // display packages |
190 | QString serverName = serversList->currentText(); | 194 | QString serverName = serversList->currentText(); |
191 | currentlySelectedServer = serverName; | 195 | currentlySelectedServer = serverName; |
192 | 196 | ||
193 | vector<Server>::iterator s = dataMgr->getServer( serverName ); | 197 | vector<Server>::iterator s = dataMgr->getServer( serverName ); |
194 | 198 | ||
@@ -257,30 +261,29 @@ void NetworkPackageManager :: serverSelected( int, bool raiseProgress ) | |||
257 | 261 | ||
258 | // If the local server, only display installed packages | 262 | // If the local server, only display installed packages |
259 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) | 263 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) |
260 | continue; | 264 | continue; |
261 | 265 | ||
262 | 266 | ||
263 | text.append( it->getPackageName() ); | 267 | QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox ); |
268 | |||
264 | if ( it->isInstalled() ) | 269 | if ( it->isInstalled() ) |
265 | { | 270 | { |
266 | text.append( " (installed)" ); | 271 | // If a different version of package is available, show update available icon |
267 | 272 | // Otherwise, show installed icon | |
268 | // If a different version of package is available, postfix it with an * | 273 | if ( it->getVersion() != it->getInstalledVersion() && |
269 | if ( it->getVersion() != it->getInstalledVersion() ) | 274 | compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1) |
270 | { | 275 | { |
271 | 276 | ||
272 | if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) | 277 | item->setPixmap( 0, updatedIcon ); |
273 | text.append( "*" ); | ||
274 | } | 278 | } |
279 | else | ||
280 | { | ||
281 | item->setPixmap( 0, installedIcon ); | ||
275 | } | 282 | } |
276 | 283 | ||
277 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); | ||
278 | |||
279 | if ( it->isInstalled() ) | ||
280 | { | ||
281 | QString destName = ""; | 284 | QString destName = ""; |
282 | if ( it->getLocalPackage() ) | 285 | if ( it->getLocalPackage() ) |
283 | { | 286 | { |
284 | if ( it->getLocalPackage()->getInstalledTo() ) | 287 | if ( it->getLocalPackage()->getInstalledTo() ) |
285 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); | 288 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); |
286 | } | 289 | } |
@@ -289,12 +292,16 @@ void NetworkPackageManager :: serverSelected( int, bool raiseProgress ) | |||
289 | if ( it->getInstalledTo() ) | 292 | if ( it->getInstalledTo() ) |
290 | destName = it->getInstalledTo()->getDestinationName(); | 293 | destName = it->getInstalledTo()->getDestinationName(); |
291 | } | 294 | } |
292 | if ( destName != "" ) | 295 | if ( destName != "" ) |
293 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); | 296 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); |
294 | } | 297 | } |
298 | else | ||
299 | { | ||
300 | item->setPixmap( 0, nullIcon ); | ||
301 | } | ||
295 | 302 | ||
296 | if ( !it->isPackageStoredLocally() ) | 303 | if ( !it->isPackageStoredLocally() ) |
297 | { | 304 | { |
298 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) ); | 305 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) ); |
299 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) ); | 306 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) ); |
300 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) ); | 307 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) ); |
@@ -505,22 +512,13 @@ void NetworkPackageManager :: downloadSelectedPackages() | |||
505 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 512 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
506 | item != 0 ; | 513 | item != 0 ; |
507 | item = (QCheckListItem *)item->nextSibling() ) | 514 | item = (QCheckListItem *)item->nextSibling() ) |
508 | { | 515 | { |
509 | if ( item->isOn() ) | 516 | if ( item->isOn() ) |
510 | { | 517 | { |
511 | QString name = item->text(); | 518 | ipkg.setPackage( item->text() ); |
512 | int pos = name.find( "*" ); | ||
513 | name.truncate( pos ); | ||
514 | |||
515 | // if (there is a (installed), remove it | ||
516 | pos = name.find( "(installed)" ); | ||
517 | if ( pos > 0 ) | ||
518 | name.truncate( pos - 1 ); | ||
519 | |||
520 | ipkg.setPackage( name ); | ||
521 | ipkg.runIpkg( ); | 519 | ipkg.runIpkg( ); |
522 | } | 520 | } |
523 | } | 521 | } |
524 | } | 522 | } |
525 | 523 | ||
526 | void NetworkPackageManager :: downloadRemotePackage() | 524 | void NetworkPackageManager :: downloadRemotePackage() |
@@ -611,19 +609,12 @@ void NetworkPackageManager :: applyChanges() | |||
611 | // If not installed - install | 609 | // If not installed - install |
612 | // If installed and different version available - upgrade | 610 | // If installed and different version available - upgrade |
613 | // If installed and version up to date - remove | 611 | // If installed and version up to date - remove |
614 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | 612 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) |
615 | { | 613 | { |
616 | QString name = item->text(); | 614 | QString name = item->text(); |
617 | int pos = name.find( "*" ); | ||
618 | name.truncate( pos ); | ||
619 | |||
620 | // if (there is a (installed), remove it | ||
621 | pos = name.find( "(installed)" ); | ||
622 | if ( pos > 0 ) | ||
623 | name.truncate( pos - 1 ); | ||
624 | 615 | ||
625 | // Get package | 616 | // Get package |
626 | vector<Server>::iterator s = dataMgr->getServer( serversList->currentText() ); | 617 | vector<Server>::iterator s = dataMgr->getServer( serversList->currentText() ); |
627 | Package *p = s->getPackage( name ); | 618 | Package *p = s->getPackage( name ); |
628 | 619 | ||
629 | // If the package has a filename then it is a local file | 620 | // If the package has a filename then it is a local file |
@@ -648,14 +639,14 @@ InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | |||
648 | else | 639 | else |
649 | item.packageName = name; | 640 | item.packageName = name; |
650 | 641 | ||
651 | if ( p->getInstalledTo() ) | 642 | if ( p->getInstalledTo() ) |
652 | { | 643 | { |
653 | item.destination = p->getInstalledTo(); | 644 | item.destination = p->getInstalledTo(); |
654 | cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; | 645 | // cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; |
655 | cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; | 646 | // cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; |
656 | } | 647 | } |
657 | else | 648 | else |
658 | { | 649 | { |
659 | item.destination = p->getLocalPackage()->getInstalledTo(); | 650 | item.destination = p->getLocalPackage()->getInstalledTo(); |
660 | } | 651 | } |
661 | 652 | ||
@@ -731,15 +722,15 @@ InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | |||
731 | 722 | ||
732 | // User hit cancel (on dlg - assume remove) | 723 | // User hit cancel (on dlg - assume remove) |
733 | return item; | 724 | return item; |
734 | } | 725 | } |
735 | } | 726 | } |
736 | 727 | ||
737 | void NetworkPackageManager :: displayText( const QString &t ) | 728 | void NetworkPackageManager :: displayText( const QString &/*t*/ ) |
738 | { | 729 | { |
739 | cout << t << endl; | 730 | // cout << t << endl; |
740 | } | 731 | } |
741 | 732 | ||
742 | 733 | ||
743 | void NetworkPackageManager :: letterPushed( QString t ) | 734 | void NetworkPackageManager :: letterPushed( QString t ) |
744 | { | 735 | { |
745 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 736 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
@@ -775,29 +766,29 @@ void NetworkPackageManager :: letterPushed( QString t ) | |||
775 | 766 | ||
776 | 767 | ||
777 | void NetworkPackageManager :: searchForPackage( const QString &text ) | 768 | void NetworkPackageManager :: searchForPackage( const QString &text ) |
778 | { | 769 | { |
779 | if ( !text.isEmpty() ) | 770 | if ( !text.isEmpty() ) |
780 | { | 771 | { |
781 | cout << "searching for " << text << endl; | 772 | // cout << "searching for " << text << endl; |
782 | // look through package list for text startng at current position | 773 | // look through package list for text startng at current position |
783 | vector<InstallData> workingPackages; | 774 | vector<InstallData> workingPackages; |
784 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 775 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
785 | if ( start != 0 ) | 776 | if ( start != 0 ) |
786 | start = (QCheckListItem *)start->nextSibling(); | 777 | start = (QCheckListItem *)start->nextSibling(); |
787 | 778 | ||
788 | if ( start == 0 ) | 779 | if ( start == 0 ) |
789 | start = (QCheckListItem *)packagesList->firstChild(); | 780 | start = (QCheckListItem *)packagesList->firstChild(); |
790 | 781 | ||
791 | for ( QCheckListItem *item = start; item != 0 ; | 782 | for ( QCheckListItem *item = start; item != 0 ; |
792 | item = (QCheckListItem *)item->nextSibling() ) | 783 | item = (QCheckListItem *)item->nextSibling() ) |
793 | { | 784 | { |
794 | cout << "checking " << item->text().lower() << endl; | 785 | // cout << "checking " << item->text().lower() << endl; |
795 | if ( item->text().lower().find( text ) != -1 ) | 786 | if ( item->text().lower().find( text ) != -1 ) |
796 | { | 787 | { |
797 | cout << "matched " << item->text() << endl; | 788 | // cout << "matched " << item->text() << endl; |
798 | packagesList->ensureItemVisible( item ); | 789 | packagesList->ensureItemVisible( item ); |
799 | packagesList->setCurrentItem( item ); | 790 | packagesList->setCurrentItem( item ); |
800 | break; | 791 | break; |
801 | } | 792 | } |
802 | } | 793 | } |
803 | } | 794 | } |