summaryrefslogtreecommitdiff
authordrw <drw>2003-01-09 01:27:35 (UTC)
committer drw <drw>2003-01-09 01:27:35 (UTC)
commitc3cfc32f957f8bcbfc8c5c2231b6894c3b94ec94 (patch) (unidiff)
tree4a4158f8635815f7e7401f0e24f5b63b1b51f33e
parentece2fe6c6d61df31a4a2e8799878f5a49a2c529e (diff)
downloadopie-c3cfc32f957f8bcbfc8c5c2231b6894c3b94ec94.zip
opie-c3cfc32f957f8bcbfc8c5c2231b6894c3b94ec94.tar.gz
opie-c3cfc32f957f8bcbfc8c5c2231b6894c3b94ec94.tar.bz2
Updates to main view, menu reorganization, etc.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/main.cpp2
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp216
-rw-r--r--noncore/settings/aqpkg/mainwin.h18
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp46
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h9
5 files changed, 194 insertions, 97 deletions
diff --git a/noncore/settings/aqpkg/main.cpp b/noncore/settings/aqpkg/main.cpp
index 1f8cf42..53c392e 100644
--- a/noncore/settings/aqpkg/main.cpp
+++ b/noncore/settings/aqpkg/main.cpp
@@ -1,65 +1,65 @@
1/*************************************************************************** 1/***************************************************************************
2 main.cpp - description 2 main.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 <iostream> 18#include <iostream>
19using namespace std; 19using namespace std;
20 20
21#ifdef QWS 21#ifdef QWS
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qpe/qcopenvelope_qws.h> 23#include <qpe/qcopenvelope_qws.h>
24#else 24#else
25#include <qapplication.h> 25#include <qapplication.h>
26#endif 26#endif
27 27
28#include <qobjectdefs.h> 28#include <qobjectdefs.h>
29 29
30#include "mainwin.h" 30#include "mainwin.h"
31#include "server.h" 31#include "server.h"
32 32
33#include "global.h" 33#include "global.h"
34 34
35 35
36int main(int argc, char *argv[]) 36int main(int argc, char *argv[])
37{ 37{
38 cout << "Root dir = " << ROOT << endl; 38 cout << "Root dir = " << ROOT << endl;
39#ifdef QWS 39#ifdef QWS
40 QPEApplication a( argc, argv ); 40 QPEApplication a( argc, argv );
41#else 41#else
42 QApplication a( argc, argv ); 42 QApplication a( argc, argv );
43#endif 43#endif
44 44
45#ifdef QWS 45#ifdef QWS
46 // Disable suspend mode 46 // Disable suspend mode
47 cout << "Disabling suspend mode" << endl; 47 cout << "Disabling suspend mode" << endl;
48 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; 48 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend;
49#endif 49#endif
50 50
51 MainWindow *win = new MainWindow(); 51 MainWindow *win = new MainWindow();
52 a.setMainWidget(win); 52 a.setMainWidget(win);
53 win->show(); 53 win->showMaximized();
54 54
55 a.exec(); 55 a.exec();
56 56
57#ifdef QWS 57#ifdef QWS
58 // Reenable suspend mode 58 // Reenable suspend mode
59 cout << "Enabling suspend mode" << endl; 59 cout << "Enabling suspend mode" << endl;
60 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 60 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
61#endif 61#endif
62 #ifdef _DEBUG 62 #ifdef _DEBUG
63 DumpUnfreed(); 63 DumpUnfreed();
64 #endif 64 #endif
65} 65}
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index e577285..4aa83b5 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -1,247 +1,355 @@
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 <iostream> 18#include <iostream>
19using namespace std; 19using namespace std;
20 20
21#include <qpe/qpemenubar.h>
22#include <qpe/qpetoolbar.h>
23#include <qpe/resource.h>
24
25#include <qaction.h>
21#include <qmenubar.h> 26#include <qmenubar.h>
22#include <qmessagebox.h> 27#include <qmessagebox.h>
23#include <qpopupmenu.h> 28#include <qpopupmenu.h>
24#include <qtimer.h> 29#include <qtimer.h>
30#include <qwidgetstack.h>
25 31
26#include "mainwin.h" 32#include "mainwin.h"
27#include "progresswidget.h" 33#include "progresswidget.h"
28#include "datamgr.h" 34#include "datamgr.h"
29#include "networkpkgmgr.h" 35#include "networkpkgmgr.h"
30#include "settingsimpl.h" 36#include "settingsimpl.h"
31#include "helpwindow.h" 37#include "helpwindow.h"
32#include "utils.h" 38#include "utils.h"
33#include "global.h" 39#include "global.h"
34 40
35MainWindow :: MainWindow( QWidget *p, char *name ) 41MainWindow :: MainWindow()
36 :QMainWindow( p, name ) 42 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
37{ 43{
38#ifdef QWS
39 showMaximized();
40#endif
41
42 setCaption( tr( "AQPkg - Package Manager" ) ); 44 setCaption( tr( "AQPkg - Package Manager" ) );
43 45
44 // Create our menu 46 // Create UI widgets
45 help = new QPopupMenu( this ); 47 progressWindow = new ProgressWidget( this );
46 help->insertItem( tr( "General" ), this, SLOT(displayHelp()) ); 48 networkPkgWindow = new NetworkPackageManager( this );
47 help->insertItem( tr( "About" ), this, SLOT(displayAbout()) ); 49
48 50 // Build menu and tool bars
49 settings = new QPopupMenu( this ); 51 setToolBarsMovable( FALSE );
50 settings->insertItem( tr( "Settings" ), this, SLOT(displaySettings()) ); 52
51 53 QPEToolBar *bar = new QPEToolBar( this );
52 edit = new QPopupMenu( this ); 54 bar->setHorizontalStretchable( TRUE );
53 edit->insertItem( tr( "Find" ), this, SLOT(searchForPackage()) ); 55 QPEMenuBar *mb = new QPEMenuBar( bar );
54 edit->insertItem( tr( "Find Next" ), this, SLOT(repeatSearchForPackage()) ); 56 mb->setMargin( 0 );
55 57 bar = new QPEToolBar( this );
56 filter = new QPopupMenu( this ); 58
57 mnuShowUninstalledPkgsId = filter->insertItem( tr( "Show Non-Installed Packages" ), this, SLOT(filterUninstalledPackages()) ); 59 // Packages menu
58 mnuShowInstalledPkgsId = filter->insertItem( tr( "Show Installed Packages" ), this, SLOT(filterInstalledPackages()) ); 60 QPopupMenu *popup = new QPopupMenu( this );
59 mnuShowUpgradedPkgsId = filter->insertItem( tr( "Show Updated Packages" ), this, SLOT(filterUpgradedPackages()) ); 61
60 filter->insertSeparator(); 62 QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 );
61 mnuFilterByCategory = filter->insertItem( tr( "Filter By Category" ), this, SLOT(filterCategory()) ); 63 a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
62 mnuSetFilterCategory = filter->insertItem( tr( "Set Filter Category" ), this, SLOT(setFilterCategory()) ); 64 connect( a, SIGNAL( activated() ), networkPkgWindow, SLOT( updateServer() ) );
63 65 a->addTo( popup );
64 // Create the main menu 66 a->addTo( bar );
65 menu = menuBar(); //new QMenuBar( this ); 67
66 menu->insertItem( tr( "Settings" ), settings ); 68 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 );
67 menu->insertItem( tr( "Edit" ), edit ); 69 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
68 menu->insertItem( tr( "Filter" ), filter ); 70 connect( actionUpgrade, SIGNAL( activated() ), networkPkgWindow, SLOT( upgradePackages() ) );
69 menu->insertItem( tr( "Help" ), help ); 71 actionUpgrade->addTo( popup );
70 72 actionUpgrade->addTo( bar );
71 // Create UI widgets 73
72 stack = new QWidgetStack( this ); 74 iconDownload = Resource::loadPixmap( "aqpkg/download" );
73 75 iconRemove = Resource::loadPixmap( "aqpkg/remove" );
74 progressWindow = new ProgressWidget( stack ); 76 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
75 stack->addWidget( progressWindow, 2 ); 77 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
76 78 connect( actionDownload, SIGNAL( activated() ), networkPkgWindow, SLOT( downloadPackage() ) );
77 networkPkgWindow = new NetworkPackageManager( stack ); 79 actionDownload->addTo( popup );
78 connect( networkPkgWindow, SIGNAL( appRaiseMainWidget() ), this, SLOT( raiseMainWidget() ) ); 80 actionDownload->addTo( bar );
79 connect( networkPkgWindow, SIGNAL( appRaiseProgressWidget() ), this, SLOT( raiseProgressWidget() ) ); 81
80 connect( networkPkgWindow, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) ); 82 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 );
81 connect( networkPkgWindow, SIGNAL( progressSetMessage( const QString & ) ), 83 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
82 progressWindow, SLOT( setMessage( const QString & ) ) ); 84 connect( a, SIGNAL( activated() ), networkPkgWindow, SLOT( applyChanges() ) );
83 connect( networkPkgWindow, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) ); 85 a->addTo( popup );
84 stack->addWidget( networkPkgWindow, 1 ); 86 a->addTo( bar );
85 87
86 setCentralWidget( stack ); 88 mb->insertItem( tr( "Packages" ), popup );
87 stack->raiseWidget( progressWindow ); 89
88 90 // Search menu
89 // Delayed call to finish initialization 91 popup = new QPopupMenu( this );
90 QTimer::singleShot( 100, this, SLOT( init() ) ); 92
91 93 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
94 a->setWhatsThis( tr( "Click here to search for a specific package." ) );
95 connect( a, SIGNAL( activated() ), this, SLOT( searchForPackage() ) );
96 a->addTo( popup );
97
98 a = new QAction( tr( "Find next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
99 a->setWhatsThis( tr( "Click here to search for the next package." ) );
100 connect( a, SIGNAL( activated() ), this, SLOT( repeatSearchForPackage() ) );
101 a->addTo( popup );
102
103 // Show 'quick jump' keypad?
104
105 popup->insertSeparator();
106
107 a = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 );
108 a->setWhatsThis( tr( "Click here to list packages belonging to one category." ) );
109 connect( a, SIGNAL( activated() ), this, SLOT( filterCategory() ) );
110 a->addTo( popup );
111
112 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 );
113 a->setWhatsThis( tr( "Click here to change package category to used filter." ) );
114 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) );
115 a->addTo( popup );
116
117 mb->insertItem( tr( "Search" ), popup );
118
119
120 // View menu
121 popup = new QPopupMenu( this );
122
123 a = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
124 a->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
125 connect( a, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) );
126 a->addTo( popup );
127
128 a = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
129 a->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
130 connect( a, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) );
131 a->addTo( popup );
132
133 a = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
134 a->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
135 connect( a, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) );
136 a->addTo( popup );
137
138 popup->insertSeparator();
139
140 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "aqpkg/config" ), QString::null, 0, this, 0 );
141 a->setWhatsThis( tr( "Click here to configure this application." ) );
142 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) );
143 a->addTo( popup );
144
145 popup->insertSeparator();
146
147 a = new QAction( tr( "Help" ), Resource::loadPixmap( "help_icon" ), QString::null, 0, this, 0 );
148 a->setWhatsThis( tr( "Click here for help." ) );
149 connect( a, SIGNAL( activated() ), this, SLOT( displayHelp() ) );
150 a->addTo( popup );
151
152 a = new QAction( tr( "About" ), Resource::loadPixmap( "UtilsIcon" ), QString::null, 0, this, 0 );
153 a->setWhatsThis( tr( "Click here for software version information." ) );
154 connect( a, SIGNAL( activated() ), this, SLOT( displayAbout() ) );
155 a->addTo( popup );
156
157 mb->insertItem( tr( "View" ), popup );
158
159 // Create widget stack and add UI widgets
160 stack = new QWidgetStack( this );
161 stack->addWidget( progressWindow, 2 );
162 stack->addWidget( networkPkgWindow, 1 );
163 setCentralWidget( stack );
164 stack->raiseWidget( progressWindow );
165
166 // Delayed call to finish initialization
167 QTimer::singleShot( 100, this, SLOT( init() ) );
92} 168}
93 169
94MainWindow :: ~MainWindow() 170MainWindow :: ~MainWindow()
95{ 171{
96 delete mgr; 172 delete mgr;
97} 173}
98 174
99void MainWindow :: init() 175void MainWindow :: init()
100{ 176{
101 stack->raiseWidget( progressWindow ); 177 stack->raiseWidget( progressWindow );
178
102 mgr = new DataManager(); 179 mgr = new DataManager();
103 connect( mgr, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) ); 180 connect( mgr, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) );
104 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), 181 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
105 progressWindow, SLOT( setMessage( const QString & ) ) ); 182 progressWindow, SLOT( setMessage( const QString & ) ) );
106 connect( mgr, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) ); 183 connect( mgr, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) );
107 mgr->loadServers(); 184 mgr->loadServers();
185
108 networkPkgWindow->setDataManager( mgr ); 186 networkPkgWindow->setDataManager( mgr );
109 networkPkgWindow->updateData(); 187 networkPkgWindow->updateData();
188 connect( networkPkgWindow, SIGNAL( appRaiseMainWidget() ), this, SLOT( raiseMainWidget() ) );
189 connect( networkPkgWindow, SIGNAL( appRaiseProgressWidget() ), this, SLOT( raiseProgressWidget() ) );
190 connect( networkPkgWindow, SIGNAL( appEnableUpgrade( bool ) ), this, SLOT( enableUpgrade( bool ) ) );
191 connect( networkPkgWindow, SIGNAL( appEnableDownload( bool ) ), this, SLOT( enableDownload( bool ) ) );
192 connect( networkPkgWindow, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) );
193 connect( networkPkgWindow, SIGNAL( progressSetMessage( const QString & ) ),
194 progressWindow, SLOT( setMessage( const QString & ) ) );
195 connect( networkPkgWindow, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) );
196
110 stack->raiseWidget( networkPkgWindow ); 197 stack->raiseWidget( networkPkgWindow );
111} 198}
112 199
113void MainWindow :: setDocument( const QString &doc ) 200void MainWindow :: setDocument( const QString &doc )
114{ 201{
115 // Remove path from package 202 // Remove path from package
116 QString package = Utils::getPackageNameFromIpkFilename( doc ); 203 QString package = Utils::getPackageNameFromIpkFilename( doc );
117 std::cout << "Selecting package " << package << std::endl; 204 std::cout << "Selecting package " << package << std::endl;
118 networkPkgWindow->selectLocalPackage( package ); 205 networkPkgWindow->selectLocalPackage( package );
119} 206}
120 207
121void MainWindow :: displaySettings() 208void MainWindow :: displaySettings()
122{ 209{
123 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 210 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
124 if ( dlg->showDlg( 0 ) ) 211 if ( dlg->showDlg( 0 ) )
125 networkPkgWindow->updateData(); 212 networkPkgWindow->updateData();
126 delete dlg; 213 delete dlg;
127} 214}
128 215
129void MainWindow :: displayHelp() 216void MainWindow :: displayHelp()
130{ 217{
131 HelpWindow *dlg = new HelpWindow( this ); 218 HelpWindow *dlg = new HelpWindow( this );
132 dlg->exec(); 219 dlg->exec();
133 delete dlg; 220 delete dlg;
134} 221}
135 222
136void MainWindow :: searchForPackage() 223void MainWindow :: searchForPackage()
137{ 224{
138 networkPkgWindow->searchForPackage( false ); 225 networkPkgWindow->searchForPackage( false );
139} 226}
140 227
141void MainWindow :: repeatSearchForPackage() 228void MainWindow :: repeatSearchForPackage()
142{ 229{
143 networkPkgWindow->searchForPackage( true ); 230 networkPkgWindow->searchForPackage( true );
144} 231}
145 232
146void MainWindow :: displayAbout() 233void MainWindow :: displayAbout()
147{ 234{
148 QMessageBox::about( this, tr( "About AQPkg" ), tr( VERSION_TEXT ) ); 235 QMessageBox::about( this, tr( "About AQPkg" ), tr( VERSION_TEXT ) );
149} 236}
150 237
151 238
152void MainWindow :: filterUninstalledPackages() 239void MainWindow :: filterUninstalledPackages()
153{ 240{
154 bool val; 241 bool val;
155 if ( filter->isItemChecked( mnuShowUninstalledPkgsId ) ) 242 if ( filter->isItemChecked( mnuShowUninstalledPkgsId ) )
156 { 243 {
157 val = false; 244 val = false;
158 filter->setItemChecked( mnuShowUninstalledPkgsId, false ); 245 filter->setItemChecked( mnuShowUninstalledPkgsId, false );
159 } 246 }
160 else 247 else
161 { 248 {
162 val = true; 249 val = true;
163 filter->setItemChecked( mnuShowUninstalledPkgsId, true ); 250 filter->setItemChecked( mnuShowUninstalledPkgsId, true );
164 } 251 }
165 252
166 filter->setItemChecked( mnuShowInstalledPkgsId, false ); 253 filter->setItemChecked( mnuShowInstalledPkgsId, false );
167 networkPkgWindow->showOnlyInstalledPackages( false ); 254 networkPkgWindow->showOnlyInstalledPackages( false );
168 filter->setItemChecked( mnuShowUpgradedPkgsId, false ); 255 filter->setItemChecked( mnuShowUpgradedPkgsId, false );
169 networkPkgWindow->showUpgradedPackages( false ); 256 networkPkgWindow->showUpgradedPackages( false );
170 257
171 networkPkgWindow->showOnlyUninstalledPackages( val ); 258 networkPkgWindow->showOnlyUninstalledPackages( val );
172 259
173} 260}
174 261
175void MainWindow :: filterInstalledPackages() 262void MainWindow :: filterInstalledPackages()
176{ 263{
177 bool val; 264 bool val;
178 if ( filter->isItemChecked( mnuShowInstalledPkgsId ) ) 265 if ( filter->isItemChecked( mnuShowInstalledPkgsId ) )
179 { 266 {
180 val = false; 267 val = false;
181 filter->setItemChecked( mnuShowInstalledPkgsId, false ); 268 filter->setItemChecked( mnuShowInstalledPkgsId, false );
182 } 269 }
183 else 270 else
184 { 271 {
185 val = true; 272 val = true;
186 filter->setItemChecked( mnuShowInstalledPkgsId, true ); 273 filter->setItemChecked( mnuShowInstalledPkgsId, true );
187 } 274 }
188 275
189 filter->setItemChecked( mnuShowUninstalledPkgsId, false ); 276 filter->setItemChecked( mnuShowUninstalledPkgsId, false );
190 networkPkgWindow->showOnlyUninstalledPackages( false ); 277 networkPkgWindow->showOnlyUninstalledPackages( false );
191 filter->setItemChecked( mnuShowUpgradedPkgsId, false ); 278 filter->setItemChecked( mnuShowUpgradedPkgsId, false );
192 networkPkgWindow->showUpgradedPackages( false ); 279 networkPkgWindow->showUpgradedPackages( false );
193 280
194 networkPkgWindow->showOnlyInstalledPackages( val ); 281 networkPkgWindow->showOnlyInstalledPackages( val );
195} 282}
196 283
197void MainWindow :: filterUpgradedPackages() 284void MainWindow :: filterUpgradedPackages()
198{ 285{
199 bool val; 286 bool val;
200 if ( filter->isItemChecked( mnuShowUpgradedPkgsId ) ) 287 if ( filter->isItemChecked( mnuShowUpgradedPkgsId ) )
201 { 288 {
202 val = false; 289 val = false;
203 filter->setItemChecked( mnuShowUpgradedPkgsId, false ); 290 filter->setItemChecked( mnuShowUpgradedPkgsId, false );
204 } 291 }
205 else 292 else
206 { 293 {
207 val = true; 294 val = true;
208 filter->setItemChecked( mnuShowUpgradedPkgsId, true ); 295 filter->setItemChecked( mnuShowUpgradedPkgsId, true );
209 } 296 }
210 297
211 filter->setItemChecked( mnuShowUninstalledPkgsId, false ); 298 filter->setItemChecked( mnuShowUninstalledPkgsId, false );
212 networkPkgWindow->showOnlyUninstalledPackages( false ); 299 networkPkgWindow->showOnlyUninstalledPackages( false );
213 filter->setItemChecked( mnuShowInstalledPkgsId, false ); 300 filter->setItemChecked( mnuShowInstalledPkgsId, false );
214 networkPkgWindow->showOnlyInstalledPackages( false ); 301 networkPkgWindow->showOnlyInstalledPackages( false );
215 302
216 networkPkgWindow->showUpgradedPackages( val ); 303 networkPkgWindow->showUpgradedPackages( val );
217} 304}
218 305
219void MainWindow :: setFilterCategory() 306void MainWindow :: setFilterCategory()
220{ 307{
221 if ( networkPkgWindow->setFilterCategory( ) ) 308 if ( networkPkgWindow->setFilterCategory( ) )
222 filter->setItemChecked( mnuFilterByCategory, true ); 309 filter->setItemChecked( mnuFilterByCategory, true );
223} 310}
224 311
225void MainWindow :: filterCategory() 312void MainWindow :: filterCategory()
226{ 313{
227 if ( filter->isItemChecked( mnuFilterByCategory ) ) 314 if ( filter->isItemChecked( mnuFilterByCategory ) )
228 { 315 {
229 networkPkgWindow->filterByCategory( false ); 316 networkPkgWindow->filterByCategory( false );
230 filter->setItemChecked( mnuFilterByCategory, false ); 317 filter->setItemChecked( mnuFilterByCategory, false );
231 } 318 }
232 else 319 else
233 { 320 {
234 if ( networkPkgWindow->filterByCategory( true ) ) 321 if ( networkPkgWindow->filterByCategory( true ) )
235 filter->setItemChecked( mnuFilterByCategory, true ); 322 filter->setItemChecked( mnuFilterByCategory, true );
236 } 323 }
237} 324}
238 325
239void MainWindow :: raiseMainWidget() 326void MainWindow :: raiseMainWidget()
240{ 327{
241 stack->raiseWidget( networkPkgWindow ); 328 stack->raiseWidget( networkPkgWindow );
242} 329}
243 330
244void MainWindow :: raiseProgressWidget() 331void MainWindow :: raiseProgressWidget()
245{ 332{
246 stack->raiseWidget( progressWindow ); 333 stack->raiseWidget( progressWindow );
247} 334}
335
336void MainWindow :: enableUpgrade( bool enabled )
337{
338 actionUpgrade->setEnabled( enabled );
339}
340
341void MainWindow :: enableDownload( bool enabled )
342{
343 if ( enabled )
344 {
345 actionDownload->setIconSet( iconDownload );
346 actionDownload->setText( tr( "Download" ) );
347 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
348 }
349 else
350 {
351 actionDownload->setIconSet( iconRemove );
352 actionDownload->setText( tr( "Remove" ) );
353 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) );
354 }
355}
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index 39799f9..028ef5b 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -1,73 +1,83 @@
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 <qpixmap.h>
23//#include <qwidgetstack.h>
23 24
25class QWidgetStack;
26class QPEToolBar;
27class QAction;
24class ProgressWidget; 28class ProgressWidget;
25class NetworkPackageManager; 29class NetworkPackageManager;
26class DataManager; 30class DataManager;
27 31
28class MainWindow :public QMainWindow 32class MainWindow :public QMainWindow
29{ 33{
30 Q_OBJECT 34 Q_OBJECT
31public: 35public:
32 36
33 MainWindow( QWidget *p = 0, char *name = 0 ); 37 MainWindow();
34 ~MainWindow(); 38 ~MainWindow();
35 39
36private: 40private:
37 DataManager *mgr; 41 DataManager *mgr;
38 42
39 QMenuBar *menu; 43 QMenuBar *menu;
40 QPopupMenu *help; 44 QPopupMenu *help;
41 QPopupMenu *settings; 45 QPopupMenu *settings;
42 QPopupMenu *edit; 46 QPopupMenu *edit;
43 QPopupMenu *filter; 47 QPopupMenu *filter;
44 QWidgetStack *stack; 48 QWidgetStack *stack;
45 49 QAction *actionUpgrade;
50 QAction *actionDownload;
51 QPixmap iconDownload;
52 QPixmap iconRemove;
53
46 NetworkPackageManager *networkPkgWindow; 54 NetworkPackageManager *networkPkgWindow;
47 ProgressWidget *progressWindow; 55 ProgressWidget *progressWindow;
48 56
49 int mnuShowUninstalledPkgsId; 57 int mnuShowUninstalledPkgsId;
50 int mnuShowInstalledPkgsId; 58 int mnuShowInstalledPkgsId;
51 int mnuShowUpgradedPkgsId; 59 int mnuShowUpgradedPkgsId;
52 int mnuFilterByCategory; 60 int mnuFilterByCategory;
53 int mnuSetFilterCategory; 61 int mnuSetFilterCategory;
54 62
55public slots: 63public slots:
56 void setDocument( const QString &doc ); 64 void setDocument( const QString &doc );
57 void displayHelp(); 65 void displayHelp();
58 void searchForPackage(); 66 void searchForPackage();
59 void repeatSearchForPackage(); 67 void repeatSearchForPackage();
60 void displayAbout(); 68 void displayAbout();
61 void displaySettings(); 69 void displaySettings();
62 void filterUninstalledPackages(); 70 void filterUninstalledPackages();
63 void filterInstalledPackages(); 71 void filterInstalledPackages();
64 void filterUpgradedPackages(); 72 void filterUpgradedPackages();
65 void filterCategory(); 73 void filterCategory();
66 void setFilterCategory(); 74 void setFilterCategory();
67 void raiseMainWidget(); 75 void raiseMainWidget();
68 void raiseProgressWidget(); 76 void raiseProgressWidget();
77 void enableUpgrade( bool );
78 void enableDownload( bool );
69 79
70private slots: 80private slots:
71 void init(); 81 void init();
72}; 82};
73#endif 83#endif
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index ee37157..91afe02 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -1,704 +1,684 @@
1/*************************************************************************** 1/***************************************************************************
2 networkpkgmgr.cpp - description 2 networkpkgmgr.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 <fstream> 18#include <fstream>
19#include <iostream> 19#include <iostream>
20using namespace std; 20using namespace std;
21 21
22#include <unistd.h> 22#include <unistd.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <linux/limits.h> 24#include <linux/limits.h>
25 25
26#ifdef QWS 26#ifdef QWS
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qpe/qcopenvelope_qws.h> 28#include <qpe/qcopenvelope_qws.h>
29#include <qpe/config.h> 29#include <qpe/config.h>
30#else 30#else
31#include <qapplication.h> 31#include <qapplication.h>
32#endif 32#endif
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36 36
37#include "datamgr.h" 37#include "datamgr.h"
38#include "networkpkgmgr.h" 38#include "networkpkgmgr.h"
39#include "installdlgimpl.h" 39#include "installdlgimpl.h"
40#include "ipkg.h" 40#include "ipkg.h"
41#include "inputdlg.h" 41#include "inputdlg.h"
42#include "letterpushbutton.h" 42#include "letterpushbutton.h"
43#include "categoryfilterimpl.h" 43#include "categoryfilterimpl.h"
44 44
45#include "global.h" 45#include "global.h"
46 46
47extern int compareVersions( const char *v1, const char *v2 ); 47extern int compareVersions( const char *v1, const char *v2 );
48 48
49NetworkPackageManager::NetworkPackageManager( QWidget *parent, const char *name ) 49NetworkPackageManager::NetworkPackageManager( QWidget *parent, const char *name )
50 : QWidget(parent, name) 50 : QWidget(parent, name)
51{ 51{
52 52
53#ifdef QWS 53#ifdef QWS
54 // read download directory from config file 54 // read download directory from config file
55 Config cfg( "aqpkg" ); 55 Config cfg( "aqpkg" );
56 cfg.setGroup( "settings" ); 56 cfg.setGroup( "settings" );
57 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 57 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
58 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 58 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
59 59
60#endif 60#endif
61 61
62 showUninstalledPkgs = false; 62 showUninstalledPkgs = false;
63 showInstalledPkgs = false; 63 showInstalledPkgs = false;
64 showUpgradedPkgs = false; 64 showUpgradedPkgs = false;
65 categoryFilterEnabled = false; 65 categoryFilterEnabled = false;
66 66
67 initGui(); 67 initGui();
68 setupConnections();
69
70 //updateData();
71} 68}
72 69
73NetworkPackageManager::~NetworkPackageManager() 70NetworkPackageManager::~NetworkPackageManager()
74{ 71{
75} 72}
76 73
77void NetworkPackageManager :: setDataManager( DataManager *dm ) 74void NetworkPackageManager :: setDataManager( DataManager *dm )
78{ 75{
79 dataMgr = dm; 76 dataMgr = dm;
80} 77}
81 78
82void NetworkPackageManager :: updateData() 79void NetworkPackageManager :: updateData()
83{ 80{
84 emit progressSetSteps( dataMgr->getServerList().size() ); 81 emit progressSetSteps( dataMgr->getServerList().size() );
85 82
86 serversList->clear(); 83 serversList->clear();
87 packagesList->clear(); 84 packagesList->clear();
88 85
89 vector<Server>::iterator it; 86 vector<Server>::iterator it;
90 int activeItem = -1; 87 int activeItem = -1;
91 int i; 88 int i;
92 QString serverName; 89 QString serverName;
93 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) 90 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
94 { 91 {
95 serverName = it->getServerName(); 92 serverName = it->getServerName();
96 emit progressSetMessage( tr( "Building server list:\n\t%1" ).arg( serverName ) ); 93 emit progressSetMessage( tr( "Building server list:\n\t%1" ).arg( serverName ) );
97 emit progressUpdate( i ); 94 emit progressUpdate( i );
98 qApp->processEvents(); 95 qApp->processEvents();
99 96
100// cout << "Adding " << it->getServerName() << " to combobox" << endl; 97// cout << "Adding " << it->getServerName() << " to combobox" << endl;
101 if ( !it->isServerActive() ) 98 if ( !it->isServerActive() )
102 { 99 {
103 cout << serverName << " is not active" << endl; 100 cout << serverName << " is not active" << endl;
104 i--; 101 i--;
105 continue; 102 continue;
106 } 103 }
107 104
108 serversList->insertItem( serverName ); 105 serversList->insertItem( serverName );
109 if ( serverName == currentlySelectedServer ) 106 if ( serverName == currentlySelectedServer )
110 activeItem = i; 107 activeItem = i;
111 } 108 }
112 109
113 // set selected server to be active server 110 // set selected server to be active server
114 if ( activeItem != -1 ) 111 if ( activeItem != -1 )
115 serversList->setCurrentItem( activeItem ); 112 serversList->setCurrentItem( activeItem );
116 serverSelected( 0, FALSE ); 113 serverSelected( 0, FALSE );
117} 114}
118 115
119void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) 116void NetworkPackageManager :: selectLocalPackage( const QString &pkg )
120{ 117{
121 // First select local server 118 // First select local server
122 for ( int i = 0 ; i < serversList->count() ; ++i ) 119 for ( int i = 0 ; i < serversList->count() ; ++i )
123 { 120 {
124 if ( serversList->text( i ) == LOCAL_IPKGS ) 121 if ( serversList->text( i ) == LOCAL_IPKGS )
125 { 122 {
126 serversList->setCurrentItem( i ); 123 serversList->setCurrentItem( i );
127 break; 124 break;
128 } 125 }
129 } 126 }
130 serverSelected( 0 ); 127 serverSelected( 0 );
131 128
132 // Now set the check box of the selected package 129 // Now set the check box of the selected package
133 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 130 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
134 item != 0 ; 131 item != 0 ;
135 item = (QCheckListItem *)item->nextSibling() ) 132 item = (QCheckListItem *)item->nextSibling() )
136 { 133 {
137 if ( item->text().startsWith( pkg ) ) 134 if ( item->text().startsWith( pkg ) )
138 { 135 {
139 item->setOn( true ); 136 item->setOn( true );
140 break; 137 break;
141 } 138 }
142 } 139 }
143} 140}
144 141
145 142
146void NetworkPackageManager :: initGui() 143void NetworkPackageManager :: initGui()
147{ 144{
148 QLabel *l = new QLabel( tr( "Servers" ), this ); 145 QLabel *l = new QLabel( tr( "Servers" ), this );
149 serversList = new QComboBox( this ); 146 serversList = new QComboBox( this );
147 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
148
150 packagesList = new QListView( this ); 149 packagesList = new QListView( this );
151 update = new QPushButton( tr( "Refresh Lists" ), this );
152 download = new QPushButton( tr( "Download" ), this );
153 upgrade = new QPushButton( tr( "Upgrade" ), this );
154 apply = new QPushButton( tr( "Apply" ), this );
155 150
156 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1 ); 151 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1 );
157 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); 152 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 );
158 hbox1->addWidget( l ); 153 hbox1->addWidget( l );
159 hbox1->addWidget( serversList ); 154 hbox1->addWidget( serversList );
160 155
161 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 ); 156 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 );
162 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 ); 157 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 );
163 158
164 159
165 if ( showJumpTo ) 160 if ( showJumpTo )
166 { 161 {
167 char text[2]; 162 char text[2];
168 text[1] = '\0'; 163 text[1] = '\0';
169 for ( int i = 0 ; i < 26 ; ++i ) 164 for ( int i = 0 ; i < 26 ; ++i )
170 { 165 {
171 text[0] = 'A' + i; 166 text[0] = 'A' + i;
172 LetterPushButton *b = new LetterPushButton( text, this ); 167 LetterPushButton *b = new LetterPushButton( text, this );
173 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 168 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
174 if ( i < 13 ) 169 if ( i < 13 )
175 hbox3->addWidget( b ); 170 hbox3->addWidget( b );
176 else 171 else
177 hbox4->addWidget( b ); 172 hbox4->addWidget( b );
178 } 173 }
179 } 174 }
180 175
181 vbox->addWidget( packagesList ); 176 vbox->addWidget( packagesList );
182 packagesList->addColumn( tr( "Packages" ) ); 177 packagesList->addColumn( tr( "Packages" ) );
183 178
184 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1 ); 179 downloadEnabled = TRUE;
185 hbox2->addWidget( update );
186 hbox2->addWidget( download );
187 hbox2->addWidget( upgrade );
188 hbox2->addWidget( apply );
189}
190
191void NetworkPackageManager :: setupConnections()
192{
193 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
194 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
195 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
196 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) );
197 connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
198} 180}
199 181
200void NetworkPackageManager :: serverSelected( int index ) 182void NetworkPackageManager :: serverSelected( int index )
201{ 183{
202 serverSelected( index, TRUE ); 184 serverSelected( index, TRUE );
203} 185}
204 186
205void NetworkPackageManager :: serverSelected( int, bool raiseProgress ) 187void NetworkPackageManager :: serverSelected( int, bool raiseProgress )
206{ 188{
207 // display packages 189 // display packages
208 QString serverName = serversList->currentText(); 190 QString serverName = serversList->currentText();
209 currentlySelectedServer = serverName; 191 currentlySelectedServer = serverName;
210 192
211 vector<Server>::iterator s = dataMgr->getServer( serverName ); 193 vector<Server>::iterator s = dataMgr->getServer( serverName );
212 194
213 vector<Package> &list = s->getPackageList(); 195 vector<Package> &list = s->getPackageList();
214 vector<Package>::iterator it; 196 vector<Package>::iterator it;
215 197
216 // Display progress widget while loading list 198 // Display progress widget while loading list
217 bool doProgress = ( list.size() > 200 ); 199 bool doProgress = ( list.size() > 200 );
218 if ( doProgress ) 200 if ( doProgress )
219 { 201 {
220 if ( raiseProgress ) 202 if ( raiseProgress )
221 { 203 {
222 emit appRaiseProgressWidget(); 204 emit appRaiseProgressWidget();
223 } 205 }
224 emit progressSetSteps( list.size() ); 206 emit progressSetSteps( list.size() );
225 emit progressSetMessage( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); 207 emit progressSetMessage( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
226 } 208 }
227 209
228 packagesList->clear(); 210 packagesList->clear();
229 211
230#ifdef QWS 212#ifdef QWS
231 // read download directory from config file 213 // read download directory from config file
232 Config cfg( "aqpkg" ); 214 Config cfg( "aqpkg" );
233 cfg.setGroup( "settings" ); 215 cfg.setGroup( "settings" );
234 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 216 cfg.writeEntry( "selectedServer", currentlySelectedServer );
235#endif 217#endif
236 218
237 int i = 0; 219 int i = 0;
238 for ( it = list.begin() ; it != list.end() ; ++it ) 220 for ( it = list.begin() ; it != list.end() ; ++it )
239 { 221 {
240 // Update progress after every 100th package (arbitrary value, seems to give good balance) 222 // Update progress after every 100th package (arbitrary value, seems to give good balance)
241 i++; 223 i++;
242 if ( ( i % 100 ) == 0 ) 224 if ( ( i % 100 ) == 0 )
243 { 225 {
244 if ( doProgress ) 226 if ( doProgress )
245 { 227 {
246 emit progressUpdate( i ); 228 emit progressUpdate( i );
247 } 229 }
248 qApp->processEvents(); 230 qApp->processEvents();
249 } 231 }
250 232
251 QString text = ""; 233 QString text = "";
252 234
253 // Apply show only uninstalled packages filter 235 // Apply show only uninstalled packages filter
254 if ( showUninstalledPkgs && it->isInstalled() ) 236 if ( showUninstalledPkgs && it->isInstalled() )
255 continue; 237 continue;
256 238
257 // Apply show only installed packages filter 239 // Apply show only installed packages filter
258 if ( showInstalledPkgs && !it->isInstalled() ) 240 if ( showInstalledPkgs && !it->isInstalled() )
259 continue; 241 continue;
260 242
261 // Apply show only new installed packages filter 243 // Apply show only new installed packages filter
262 if ( showUpgradedPkgs ) 244 if ( showUpgradedPkgs )
263 { 245 {
264 if ( !it->isInstalled() || 246 if ( !it->isInstalled() ||
265 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) 247 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 )
266 continue; 248 continue;
267 } 249 }
268 250
269 // Apply the section filter 251 // Apply the section filter
270 if ( categoryFilterEnabled && categoryFilter != "" ) 252 if ( categoryFilterEnabled && categoryFilter != "" )
271 { 253 {
272 if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) 254 if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 )
273 continue; 255 continue;
274 } 256 }
275 257
276 // If the local server, only display installed packages 258 // If the local server, only display installed packages
277 if ( serverName == LOCAL_SERVER && !it->isInstalled() ) 259 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
278 continue; 260 continue;
279 261
280 262
281 text += it->getPackageName(); 263 text += it->getPackageName();
282 if ( it->isInstalled() ) 264 if ( it->isInstalled() )
283 { 265 {
284 text += " (installed)"; 266 text += " (installed)";
285 267
286 // If a different version of package is available, postfix it with an * 268 // If a different version of package is available, postfix it with an *
287 if ( it->getVersion() != it->getInstalledVersion() ) 269 if ( it->getVersion() != it->getInstalledVersion() )
288 { 270 {
289 271
290 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) 272 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 )
291 text += "*"; 273 text += "*";
292 } 274 }
293 } 275 }
294 276
295 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); 277 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
296 278
297 if ( it->isInstalled() ) 279 if ( it->isInstalled() )
298 { 280 {
299 QString destName = ""; 281 QString destName = "";
300 if ( it->getLocalPackage() ) 282 if ( it->getLocalPackage() )
301 { 283 {
302 if ( it->getLocalPackage()->getInstalledTo() ) 284 if ( it->getLocalPackage()->getInstalledTo() )
303 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); 285 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
304 } 286 }
305 else 287 else
306 { 288 {
307 if ( it->getInstalledTo() ) 289 if ( it->getInstalledTo() )
308 destName = it->getInstalledTo()->getDestinationName(); 290 destName = it->getInstalledTo()->getDestinationName();
309 } 291 }
310 if ( destName != "" ) 292 if ( destName != "" )
311 new QCheckListItem( item, QString( tr( "Installed To - " ) ) + destName ); 293 new QCheckListItem( item, QString( tr( "Installed To - " ) ) + destName );
312 } 294 }
313 295
314 if ( !it->isPackageStoredLocally() ) 296 if ( !it->isPackageStoredLocally() )
315 { 297 {
316 new QCheckListItem( item, QString( tr( "Description - " ) ) + it->getDescription() ); 298 new QCheckListItem( item, QString( tr( "Description - " ) ) + it->getDescription() );
317 new QCheckListItem( item, QString( tr( "Size - " ) ) + it->getPackageSize() ); 299 new QCheckListItem( item, QString( tr( "Size - " ) ) + it->getPackageSize() );
318 new QCheckListItem( item, QString( tr( "Section - " ) ) + it->getSection() ); 300 new QCheckListItem( item, QString( tr( "Section - " ) ) + it->getSection() );
319 } 301 }
320 else 302 else
321 new QCheckListItem( item, QString( tr( "Filename - " ) ) + it->getFilename() ); 303 new QCheckListItem( item, QString( tr( "Filename - " ) ) + it->getFilename() );
322 304
323 if ( serverName == LOCAL_SERVER ) 305 if ( serverName == LOCAL_SERVER )
324 { 306 {
325 new QCheckListItem( item, QString( tr( "V. Installed - " ) ) + it->getVersion() ); 307 new QCheckListItem( item, QString( tr( "V. Installed - " ) ) + it->getVersion() );
326 } 308 }
327 else 309 else
328 { 310 {
329 new QCheckListItem( item, QString( tr( "V. Available - " ) ) + it->getVersion() ); 311 new QCheckListItem( item, QString( tr( "V. Available - " ) ) + it->getVersion() );
330 if ( it->getLocalPackage() ) 312 if ( it->getLocalPackage() )
331 { 313 {
332 if ( it->isInstalled() ) 314 if ( it->isInstalled() )
333 new QCheckListItem( item, QString( tr( "V. Installed - " ) ) + it->getInstalledVersion() ); 315 new QCheckListItem( item, QString( tr( "V. Installed - " ) ) + it->getInstalledVersion() );
334 } 316 }
335 } 317 }
336 318
337 packagesList->insertItem( item ); 319 packagesList->insertItem( item );
338 } 320 }
339 321
340 // If the local server or the local ipkgs server disable the download button 322 // If the local server or the local ipkgs server disable the download button
341 if ( serverName == LOCAL_SERVER ) 323 if ( serverName == LOCAL_SERVER )
342 { 324 {
343 upgrade->setEnabled( false ); 325 downloadEnabled = TRUE;
344 download->setText( tr( "Download" ) ); 326 emit appEnableUpgrade( FALSE );
345 download->setEnabled( true );
346 } 327 }
347 else if ( serverName == LOCAL_IPKGS ) 328 else if ( serverName == LOCAL_IPKGS )
348 { 329 {
349 upgrade->setEnabled( false ); 330 downloadEnabled = FALSE;
350 download->setEnabled( true ); 331 emit appEnableUpgrade( FALSE );
351 download->setText( tr( "Remove" ) );
352 } 332 }
353 else 333 else
354 { 334 {
355 upgrade->setEnabled( true ); 335 downloadEnabled = TRUE;
356 download->setEnabled( true ); 336 emit appEnableUpgrade( TRUE );
357 download->setText( tr( "Download" ) );
358 } 337 }
338 emit appEnableDownload( downloadEnabled );
359 339
360 // Display this widget once everything is done 340 // Display this widget once everything is done
361 if ( doProgress && raiseProgress ) 341 if ( doProgress && raiseProgress )
362 { 342 {
363 emit appRaiseMainWidget(); 343 emit appRaiseMainWidget();
364 } 344 }
365} 345}
366 346
367void NetworkPackageManager :: updateServer() 347void NetworkPackageManager :: updateServer()
368{ 348{
369 QString serverName = serversList->currentText(); 349 QString serverName = serversList->currentText();
370 350
371 // Update the current server 351 // Update the current server
372 // Display dialog 352 // Display dialog
373 353
374 // Disable buttons to stop silly people clicking lots on them :) 354 // Disable buttons to stop silly people clicking lots on them :)
375 355
376 // First, write out ipkg_conf file so that ipkg can use it 356 // First, write out ipkg_conf file so that ipkg can use it
377 dataMgr->writeOutIpkgConf(); 357 dataMgr->writeOutIpkgConf();
378 358
379 Ipkg ipkg; 359 Ipkg ipkg;
380 ipkg.setOption( "update" ); 360 ipkg.setOption( "update" );
381 361
382 InstallDlgImpl dlg( &ipkg, tr( "Refreshing server package lists" ), this, tr( "Upgrade" ), true ); 362 InstallDlgImpl dlg( &ipkg, tr( "Refreshing server package lists" ), this, tr( "Upgrade" ), true );
383 dlg.showDlg(); 363 dlg.showDlg();
384 364
385 // Reload data 365 // Reload data
386 dataMgr->reloadServerData(); 366 dataMgr->reloadServerData();
387 serverSelected(-1); 367 serverSelected(-1);
388// delete progDlg; 368// delete progDlg;
389} 369}
390 370
391void NetworkPackageManager :: upgradePackages() 371void NetworkPackageManager :: upgradePackages()
392{ 372{
393 // We're gonna do an upgrade of all packages 373 // We're gonna do an upgrade of all packages
394 // First warn user that this isn't recommended 374 // First warn user that this isn't recommended
395 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); 375 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
396 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, 376 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
397 QMessageBox::Yes, 377 QMessageBox::Yes,
398 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 378 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
399 0, this ); 379 0, this );
400 warn.adjustSize(); 380 warn.adjustSize();
401 381
402 if ( warn.exec() == QMessageBox::Yes ) 382 if ( warn.exec() == QMessageBox::Yes )
403 { 383 {
404 // First, write out ipkg_conf file so that ipkg can use it 384 // First, write out ipkg_conf file so that ipkg can use it
405 dataMgr->writeOutIpkgConf(); 385 dataMgr->writeOutIpkgConf();
406 386
407 // Now run upgrade 387 // Now run upgrade
408 Ipkg ipkg; 388 Ipkg ipkg;
409 ipkg.setOption( "upgrade" ); 389 ipkg.setOption( "upgrade" );
410 390
411 InstallDlgImpl dlg( &ipkg, tr( "Upgrading installed packages" ), this, tr( "Upgrade" ), true ); 391 InstallDlgImpl dlg( &ipkg, tr( "Upgrading installed packages" ), this, tr( "Upgrade" ), true );
412 dlg.showDlg(); 392 dlg.showDlg();
413 393
414 // Reload data 394 // Reload data
415 dataMgr->reloadServerData(); 395 dataMgr->reloadServerData();
416 serverSelected(-1); 396 serverSelected(-1);
417 } 397 }
418} 398}
419 399
420 400
421void NetworkPackageManager :: downloadPackage() 401void NetworkPackageManager :: downloadPackage()
422{ 402{
423 bool doUpdate = true; 403 bool doUpdate = true;
424 if ( download->text() == tr( "Download" ) ) 404 if ( downloadEnabled )
425 { 405 {
426 // See if any packages are selected 406 // See if any packages are selected
427 bool found = false; 407 bool found = false;
428 if ( serversList->currentText() != LOCAL_SERVER ) 408 if ( serversList->currentText() != LOCAL_SERVER )
429 { 409 {
430 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 410 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
431 item != 0 && !found; 411 item != 0 && !found;
432 item = (QCheckListItem *)item->nextSibling() ) 412 item = (QCheckListItem *)item->nextSibling() )
433 { 413 {
434 if ( item->isOn() ) 414 if ( item->isOn() )
435 found = true; 415 found = true;
436 } 416 }
437 } 417 }
438 418
439 // If user selected some packages then download the and store the locally 419 // If user selected some packages then download the and store the locally
440 // otherwise, display dialog asking user what package to download from an http server 420 // otherwise, display dialog asking user what package to download from an http server
441 // and whether to install it 421 // and whether to install it
442 if ( found ) 422 if ( found )
443 downloadSelectedPackages(); 423 downloadSelectedPackages();
444 else 424 else
445 downloadRemotePackage(); 425 downloadRemotePackage();
446 426
447 } 427 }
448 else if ( download->text() == tr( "Remove" ) ) 428 else
449 { 429 {
450 doUpdate = false; 430 doUpdate = false;
451 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 431 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
452 item != 0 ; 432 item != 0 ;
453 item = (QCheckListItem *)item->nextSibling() ) 433 item = (QCheckListItem *)item->nextSibling() )
454 { 434 {
455 if ( item->isOn() ) 435 if ( item->isOn() )
456 { 436 {
457 QString name = item->text(); 437 QString name = item->text();
458 int pos = name.find( "*" ); 438 int pos = name.find( "*" );
459 name.truncate( pos ); 439 name.truncate( pos );
460 440
461 // if (there is a (installed), remove it 441 // if (there is a (installed), remove it
462 pos = name.find( "(installed)" ); 442 pos = name.find( "(installed)" );
463 if ( pos > 0 ) 443 if ( pos > 0 )
464 name.truncate( pos - 1 ); 444 name.truncate( pos - 1 );
465 445
466 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); 446 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
467 447
468 QString msgtext; 448 QString msgtext;
469 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); 449 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
470 if ( QMessageBox::information( this, tr( "Are you sure?" ), 450 if ( QMessageBox::information( this, tr( "Are you sure?" ),
471 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) 451 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
472 { 452 {
473 doUpdate = true; 453 doUpdate = true;
474 QFile f( p->getFilename() ); 454 QFile f( p->getFilename() );
475 f.remove(); 455 f.remove();
476 } 456 }
477 } 457 }
478 } 458 }
479 } 459 }
480 460
481 if ( doUpdate ) 461 if ( doUpdate )
482 { 462 {
483 dataMgr->reloadServerData(); 463 dataMgr->reloadServerData();
484 serverSelected( -1 ); 464 serverSelected( -1 );
485 } 465 }
486} 466}
487 467
488void NetworkPackageManager :: downloadSelectedPackages() 468void NetworkPackageManager :: downloadSelectedPackages()
489{ 469{
490 // First, write out ipkg_conf file so that ipkg can use it 470 // First, write out ipkg_conf file so that ipkg can use it
491 dataMgr->writeOutIpkgConf(); 471 dataMgr->writeOutIpkgConf();
492 472
493 // Display dialog to user asking where to download the files to 473 // Display dialog to user asking where to download the files to
494 bool ok = FALSE; 474 bool ok = FALSE;
495 QString dir = ""; 475 QString dir = "";
496#ifdef QWS 476#ifdef QWS
497 // read download directory from config file 477 // read download directory from config file
498 Config cfg( "aqpkg" ); 478 Config cfg( "aqpkg" );
499 cfg.setGroup( "settings" ); 479 cfg.setGroup( "settings" );
500 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 480 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
501#endif 481#endif
502 482
503 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 483 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
504 if ( ok && !text.isEmpty() ) 484 if ( ok && !text.isEmpty() )
505 dir = text; // user entered something and pressed ok 485 dir = text; // user entered something and pressed ok
506 else 486 else
507 return; // user entered nothing or pressed cancel 487 return; // user entered nothing or pressed cancel
508 488
509#ifdef QWS 489#ifdef QWS
510 // Store download directory in config file 490 // Store download directory in config file
511 cfg.writeEntry( "downloadDir", dir ); 491 cfg.writeEntry( "downloadDir", dir );
512#endif 492#endif
513 493
514 // Get starting directory 494 // Get starting directory
515 char initDir[PATH_MAX]; 495 char initDir[PATH_MAX];
516 getcwd( initDir, PATH_MAX ); 496 getcwd( initDir, PATH_MAX );
517 497
518 // Download each package 498 // Download each package
519 Ipkg ipkg; 499 Ipkg ipkg;
520 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 500 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
521 501
522 ipkg.setOption( "download" ); 502 ipkg.setOption( "download" );
523 ipkg.setRuntimeDirectory( dir ); 503 ipkg.setRuntimeDirectory( dir );
524 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 504 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
525 item != 0 ; 505 item != 0 ;
526 item = (QCheckListItem *)item->nextSibling() ) 506 item = (QCheckListItem *)item->nextSibling() )
527 { 507 {
528 if ( item->isOn() ) 508 if ( item->isOn() )
529 { 509 {
530 QString name = item->text(); 510 QString name = item->text();
531 int pos = name.find( "*" ); 511 int pos = name.find( "*" );
532 name.truncate( pos ); 512 name.truncate( pos );
533 513
534 // if (there is a (installed), remove it 514 // if (there is a (installed), remove it
535 pos = name.find( "(installed)" ); 515 pos = name.find( "(installed)" );
536 if ( pos > 0 ) 516 if ( pos > 0 )
537 name.truncate( pos - 1 ); 517 name.truncate( pos - 1 );
538 518
539 ipkg.setPackage( name ); 519 ipkg.setPackage( name );
540 ipkg.runIpkg( ); 520 ipkg.runIpkg( );
541 } 521 }
542 } 522 }
543} 523}
544 524
545void NetworkPackageManager :: downloadRemotePackage() 525void NetworkPackageManager :: downloadRemotePackage()
546{ 526{
547 // Display dialog 527 // Display dialog
548 bool ok; 528 bool ok;
549 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); 529 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
550 if ( !ok || package.isEmpty() ) 530 if ( !ok || package.isEmpty() )
551 return; 531 return;
552// DownloadRemoteDlgImpl dlg( this, "Install", true ); 532// DownloadRemoteDlgImpl dlg( this, "Install", true );
553// if ( dlg.exec() == QDialog::Rejected ) 533// if ( dlg.exec() == QDialog::Rejected )
554// return; 534// return;
555 535
556 // grab details from dialog 536 // grab details from dialog
557// QString package = dlg.getPackageLocation(); 537// QString package = dlg.getPackageLocation();
558 538
559 InstallData item; 539 InstallData item;
560 item.option = "I"; 540 item.option = "I";
561 item.packageName = package; 541 item.packageName = package;
562 vector<InstallData> workingPackages; 542 vector<InstallData> workingPackages;
563 workingPackages.push_back( item ); 543 workingPackages.push_back( item );
564 544
565 InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true ); 545 InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true );
566 dlg2.showDlg(); 546 dlg2.showDlg();
567 547
568 // Reload data 548 // Reload data
569 dataMgr->reloadServerData(); 549 dataMgr->reloadServerData();
570 serverSelected(-1); 550 serverSelected(-1);
571 551
572#ifdef QWS 552#ifdef QWS
573 // Finally let the main system update itself 553 // Finally let the main system update itself
574 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 554 QCopEnvelope e("QPE/System", "linkChanged(QString)");
575 QString lf = QString::null; 555 QString lf = QString::null;
576 e << lf; 556 e << lf;
577#endif 557#endif
578} 558}
579 559
580 560
581void NetworkPackageManager :: applyChanges() 561void NetworkPackageManager :: applyChanges()
582{ 562{
583 stickyOption = ""; 563 stickyOption = "";
584 564
585 // First, write out ipkg_conf file so that ipkg can use it 565 // First, write out ipkg_conf file so that ipkg can use it
586 dataMgr->writeOutIpkgConf(); 566 dataMgr->writeOutIpkgConf();
587 567
588 // Now for each selected item 568 // Now for each selected item
589 // deal with it 569 // deal with it
590 570
591 vector<InstallData> workingPackages; 571 vector<InstallData> workingPackages;
592 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 572 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
593 item != 0 ; 573 item != 0 ;
594 item = (QCheckListItem *)item->nextSibling() ) 574 item = (QCheckListItem *)item->nextSibling() )
595 { 575 {
596 if ( item->isOn() ) 576 if ( item->isOn() )
597 { 577 {
598 InstallData data = dealWithItem( item ); 578 InstallData data = dealWithItem( item );
599 workingPackages.push_back( data ); 579 workingPackages.push_back( data );
600 } 580 }
601 } 581 }
602 582
603 if ( workingPackages.size() == 0 ) 583 if ( workingPackages.size() == 0 )
604 { 584 {
605 // Nothing to do 585 // Nothing to do
606 QMessageBox::information( this, tr( "Nothing to do" ), 586 QMessageBox::information( this, tr( "Nothing to do" ),
607 tr( "No packages selected" ), tr( "OK" ) ); 587 tr( "No packages selected" ), tr( "OK" ) );
608 588
609 return; 589 return;
610 } 590 }
611 591
612 // do the stuff 592 // do the stuff
613 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); 593 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
614 dlg.showDlg(); 594 dlg.showDlg();
615 595
616 // Reload data 596 // Reload data
617 dataMgr->reloadServerData(); 597 dataMgr->reloadServerData();
618 serverSelected(-1); 598 serverSelected(-1);
619 599
620#ifdef QWS 600#ifdef QWS
621 // Finally let the main system update itself 601 // Finally let the main system update itself
622 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 602 QCopEnvelope e("QPE/System", "linkChanged(QString)");
623 QString lf = QString::null; 603 QString lf = QString::null;
624 e << lf; 604 e << lf;
625#endif 605#endif
626} 606}
627 607
628// decide what to do - either remove, upgrade or install 608// decide what to do - either remove, upgrade or install
629// Current rules: 609// Current rules:
630// If not installed - install 610// If not installed - install
631// If installed and different version available - upgrade 611// If installed and different version available - upgrade
632// If installed and version up to date - remove 612// If installed and version up to date - remove
633InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 613InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )
634{ 614{
635 QString name = item->text(); 615 QString name = item->text();
636 int pos = name.find( "*" ); 616 int pos = name.find( "*" );
637 name.truncate( pos ); 617 name.truncate( pos );
638 618
639 // if (there is a (installed), remove it 619 // if (there is a (installed), remove it
640 pos = name.find( "(installed)" ); 620 pos = name.find( "(installed)" );
641 if ( pos > 0 ) 621 if ( pos > 0 )
642 name.truncate( pos - 1 ); 622 name.truncate( pos - 1 );
643 623
644 // Get package 624 // Get package
645 vector<Server>::iterator s = dataMgr->getServer( serversList->currentText() ); 625 vector<Server>::iterator s = dataMgr->getServer( serversList->currentText() );
646 Package *p = s->getPackage( name ); 626 Package *p = s->getPackage( name );
647 627
648 // If the package has a filename then it is a local file 628 // If the package has a filename then it is a local file
649 if ( p->isPackageStoredLocally() ) 629 if ( p->isPackageStoredLocally() )
650 name = p->getFilename(); 630 name = p->getFilename();
651 631
652 QString option; 632 QString option;
653 QString dest = "root"; 633 QString dest = "root";
654 if ( !p->isInstalled() ) 634 if ( !p->isInstalled() )
655 { 635 {
656 InstallData item; 636 InstallData item;
657 item.option = "I"; 637 item.option = "I";
658 item.packageName = name; 638 item.packageName = name;
659 return item; 639 return item;
660 } 640 }
661 else 641 else
662 { 642 {
663 InstallData item; 643 InstallData item;
664 item.option = "D"; 644 item.option = "D";
665 if ( !p->isPackageStoredLocally() ) 645 if ( !p->isPackageStoredLocally() )
666 item.packageName = p->getInstalledPackageName(); 646 item.packageName = p->getInstalledPackageName();
667 else 647 else
668 item.packageName = name; 648 item.packageName = name;
669 649
670 if ( p->getInstalledTo() ) 650 if ( p->getInstalledTo() )
671 { 651 {
672 item.destination = p->getInstalledTo(); 652 item.destination = p->getInstalledTo();
673 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; 653 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
674 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; 654 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
675 } 655 }
676 else 656 else
677 { 657 {
678 item.destination = p->getLocalPackage()->getInstalledTo(); 658 item.destination = p->getLocalPackage()->getInstalledTo();
679 } 659 }
680 660
681 // Now see if version is newer or not 661 // Now see if version is newer or not
682 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 662 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
683 663
684 // If the version requested is older and user selected a local ipk file, then reinstall the file 664 // If the version requested is older and user selected a local ipk file, then reinstall the file
685 if ( p->isPackageStoredLocally() && val == -1 ) 665 if ( p->isPackageStoredLocally() && val == -1 )
686 val = 0; 666 val = 0;
687 667
688 if ( val == -2 ) 668 if ( val == -2 )
689 { 669 {
690 // Error - should handle 670 // Error - should handle
691 } 671 }
692 else if ( val == -1 ) 672 else if ( val == -1 )
693 { 673 {
694 // Version available is older - remove only 674 // Version available is older - remove only
695 item.option = "D"; 675 item.option = "D";
696 } 676 }
697 else 677 else
698 { 678 {
699 QString caption; 679 QString caption;
700 QString text; 680 QString text;
701 QString secondButton; 681 QString secondButton;
702 QString secondOption; 682 QString secondOption;
703 if ( val == 0 ) 683 if ( val == 0 )
704 { 684 {
diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h
index 6b552ee..efef898 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.h
+++ b/noncore/settings/aqpkg/networkpkgmgr.h
@@ -1,98 +1,97 @@
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 28
29class InstallData; 29class InstallData;
30 30
31/** NetworkPackageManager is the base class of the project */ 31/** NetworkPackageManager is the base class of the project */
32class NetworkPackageManager : public QWidget 32class NetworkPackageManager : public QWidget
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35public: 35public:
36 /** construtor */ 36 /** construtor */
37 NetworkPackageManager( QWidget* parent=0, const char *name=0 ); 37 NetworkPackageManager( QWidget* parent=0, const char *name=0 );
38 /** destructor */ 38 /** destructor */
39 ~NetworkPackageManager(); 39 ~NetworkPackageManager();
40 40
41 void setDataManager( DataManager *dm ); 41 void setDataManager( DataManager *dm );
42 void selectLocalPackage( const QString &pkg ); 42 void selectLocalPackage( const QString &pkg );
43 void updateData(); 43 void updateData();
44 void searchForPackage( bool findNext ); 44 void searchForPackage( bool findNext );
45 void showOnlyUninstalledPackages( bool val ); 45 void showOnlyUninstalledPackages( bool val );
46 void showOnlyInstalledPackages( bool val ); 46 void showOnlyInstalledPackages( bool val );
47 void showUpgradedPackages( bool val ); 47 void showUpgradedPackages( bool val );
48 bool filterByCategory( bool val ); 48 bool filterByCategory( bool val );
49 bool setFilterCategory(); 49 bool setFilterCategory();
50 50
51private: 51private:
52 DataManager *dataMgr; 52 DataManager *dataMgr;
53 53
54 QComboBox *serversList; 54 QComboBox *serversList;
55 QListView *packagesList; 55 QListView *packagesList;
56 QPushButton *update;
57 QPushButton *upgrade;
58 QPushButton *download;
59 QPushButton *apply;
60 56
61 QString currentlySelectedServer; 57 QString currentlySelectedServer;
62 QString lastSearchText; 58 QString lastSearchText;
63 QString categoryFilter; 59 QString categoryFilter;
64 60
65 bool categoryFilterEnabled; 61 bool categoryFilterEnabled;
66 bool showJumpTo; 62 bool showJumpTo;
67 bool showUninstalledPkgs; 63 bool showUninstalledPkgs;
68 bool showInstalledPkgs; 64 bool showInstalledPkgs;
69 bool showUpgradedPkgs; 65 bool showUpgradedPkgs;
70 66
67 bool downloadEnabled;
68
71 void initGui(); 69 void initGui();
72 void setupConnections();
73 void showProgressDialog( char *initialText ); 70 void showProgressDialog( char *initialText );
74 void downloadSelectedPackages(); 71 void downloadSelectedPackages();
75 void downloadRemotePackage(); 72 void downloadRemotePackage();
76 void serverSelected( int index, bool showProgress ); 73 void serverSelected( int index, bool showProgress );
77 74
78 InstallData dealWithItem( QCheckListItem *item ); 75 InstallData dealWithItem( QCheckListItem *item );
79 QString stickyOption; 76 QString stickyOption;
80 77
81signals: 78signals:
82 void appRaiseMainWidget(); 79 void appRaiseMainWidget();
83 void appRaiseProgressWidget(); 80 void appRaiseProgressWidget();
81 void appEnableUpgrade( bool );
82 void appEnableDownload( bool );
84 void progressSetSteps( int ); 83 void progressSetSteps( int );
85 void progressSetMessage( const QString & ); 84 void progressSetMessage( const QString & );
86 void progressUpdate( int ); 85 void progressUpdate( int );
87 86
88public slots: 87public slots:
89 void applyChanges(); 88 void applyChanges();
90 void upgradePackages(); 89 void upgradePackages();
91 void downloadPackage(); 90 void downloadPackage();
92 void updateServer(); 91 void updateServer();
93 void displayText( const QString &t ); 92 void displayText( const QString &t );
94 void letterPushed( QString t ); 93 void letterPushed( QString t );
95 void serverSelected( int index ); 94 void serverSelected( int index );
96}; 95};
97 96
98#endif 97#endif