summaryrefslogtreecommitdiff
authordrw <drw>2003-03-19 02:48:27 (UTC)
committer drw <drw>2003-03-19 02:48:27 (UTC)
commitf35989ef21fb5a27ebe6f6924ee2cc601318c1b8 (patch) (unidiff)
treef169286f925c01758d1456027eb43743bb0cd162
parent06ddd131a6f33d341290617e71a14006fc9957a1 (diff)
downloadopie-f35989ef21fb5a27ebe6f6924ee2cc601318c1b8.zip
opie-f35989ef21fb5a27ebe6f6924ee2cc601318c1b8.tar.gz
opie-f35989ef21fb5a27ebe6f6924ee2cc601318c1b8.tar.bz2
Fix for bug #741
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp3
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.h6
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp29
-rw-r--r--noncore/settings/aqpkg/mainwin.h3
4 files changed, 33 insertions, 8 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index 1f0bb5f..2bb8b4d 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -1,365 +1,366 @@
1/*************************************************************************** 1/***************************************************************************
2 installdlgimpl.cpp - description 2 installdlgimpl.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 2002 4 begin : Mon Aug 26 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 <stdio.h> 18#include <stdio.h>
19 19
20#ifdef QWS 20#ifdef QWS
21#include <qpe/config.h> 21#include <qpe/config.h>
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/storage.h> 24#include <qpe/storage.h>
25#endif 25#endif
26 26
27#include <qcheckbox.h> 27#include <qcheckbox.h>
28#include <qcombobox.h> 28#include <qcombobox.h>
29#include <qdialog.h> 29#include <qdialog.h>
30#include <qgroupbox.h> 30#include <qgroupbox.h>
31#include <qmultilineedit.h> 31#include <qmultilineedit.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qlayout.h> 33#include <qlayout.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35 35
36#include "datamgr.h" 36#include "datamgr.h"
37#include "destination.h" 37#include "destination.h"
38#include "instoptionsimpl.h" 38#include "instoptionsimpl.h"
39#include "installdlgimpl.h" 39#include "installdlgimpl.h"
40#include "ipkg.h" 40#include "ipkg.h"
41#include "utils.h" 41#include "utils.h"
42#include "global.h" 42#include "global.h"
43 43
44enum { 44enum {
45 MAXLINES = 100, 45 MAXLINES = 100,
46}; 46};
47 47
48InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title ) 48InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title )
49 : QWidget( 0, 0, 0 ) 49 : QWidget( 0, 0, 0 )
50{ 50{
51 setCaption( title ); 51 setCaption( title );
52 init( TRUE ); 52 init( TRUE );
53 53
54 pIpkg = 0; 54 pIpkg = 0;
55 upgradePackages = false; 55 upgradePackages = false;
56 dataMgr = dataManager; 56 dataMgr = dataManager;
57 57
58 QString defaultDest = "root"; 58 QString defaultDest = "root";
59#ifdef QWS 59#ifdef QWS
60 Config cfg( "aqpkg" ); 60 Config cfg( "aqpkg" );
61 cfg.setGroup( "settings" ); 61 cfg.setGroup( "settings" );
62 defaultDest = cfg.readEntry( "dest", "root" ); 62 defaultDest = cfg.readEntry( "dest", "root" );
63 63
64 // Grab flags - Turn MAKE_LINKS on by default (if no flags found) 64 // Grab flags - Turn MAKE_LINKS on by default (if no flags found)
65 flags = cfg.readNumEntry( "installFlags", 0 ); 65 flags = cfg.readNumEntry( "installFlags", 0 );
66#else 66#else
67 flags = 0; 67 flags = 0;
68#endif 68#endif
69 69
70 // Output text is read only 70 // Output text is read only
71 output->setReadOnly( true ); 71 output->setReadOnly( true );
72 //QFont f( "helvetica" ); 72 //QFont f( "helvetica" );
73 //f.setPointSize( 10 ); 73 //f.setPointSize( 10 );
74 //output->setFont( f ); 74 //output->setFont( f );
75 75
76 76
77 // setup destination data 77 // setup destination data
78 int defIndex = 0; 78 int defIndex = 0;
79 int i; 79 int i;
80 QListIterator<Destination> dit( dataMgr->getDestinationList() ); 80 QListIterator<Destination> dit( dataMgr->getDestinationList() );
81 for ( i = 0; dit.current(); ++dit, ++i ) 81 for ( i = 0; dit.current(); ++dit, ++i )
82 { 82 {
83 destination->insertItem( dit.current()->getDestinationName() ); 83 destination->insertItem( dit.current()->getDestinationName() );
84 if ( dit.current()->getDestinationName() == defaultDest ) 84 if ( dit.current()->getDestinationName() == defaultDest )
85 defIndex = i; 85 defIndex = i;
86 } 86 }
87 87
88 destination->setCurrentItem( defIndex ); 88 destination->setCurrentItem( defIndex );
89 89
90 QListIterator<InstallData> it( packageList ); 90 QListIterator<InstallData> it( packageList );
91 // setup package data 91 // setup package data
92 QString remove = tr( "Remove\n" ); 92 QString remove = tr( "Remove\n" );
93 QString install = tr( "Install\n" ); 93 QString install = tr( "Install\n" );
94 QString upgrade = tr( "Upgrade\n" ); 94 QString upgrade = tr( "Upgrade\n" );
95 for ( ; it.current(); ++it ) 95 for ( ; it.current(); ++it )
96 { 96 {
97 InstallData *item = it.current(); 97 InstallData *item = it.current();
98 InstallData *newitem = new InstallData(); 98 InstallData *newitem = new InstallData();
99 99
100 newitem->option = item->option; 100 newitem->option = item->option;
101 newitem->packageName = item->packageName; 101 newitem->packageName = item->packageName;
102 newitem->destination = item->destination; 102 newitem->destination = item->destination;
103 newitem->recreateLinks = item->recreateLinks; 103 newitem->recreateLinks = item->recreateLinks;
104 104
105 if ( item->option == "I" ) 105 if ( item->option == "I" )
106 { 106 {
107 installList.append( newitem ); 107 installList.append( newitem );
108 install.append( QString( " %1\n" ).arg( item->packageName ) ); 108 install.append( QString( " %1\n" ).arg( item->packageName ) );
109 } 109 }
110 else if ( item->option == "D" ) 110 else if ( item->option == "D" )
111 { 111 {
112 removeList.append( newitem ); 112 removeList.append( newitem );
113 remove.append( QString( " %1\n" ).arg( item->packageName ) ); 113 remove.append( QString( " %1\n" ).arg( item->packageName ) );
114 } 114 }
115 else if ( item->option == "U" || item->option == "R" ) 115 else if ( item->option == "U" || item->option == "R" )
116 { 116 {
117 updateList.append( newitem ); 117 updateList.append( newitem );
118 QString type; 118 QString type;
119 if ( item->option == "R" ) 119 if ( item->option == "R" )
120 type = tr( "(ReInstall)" ); 120 type = tr( "(ReInstall)" );
121 else 121 else
122 type = tr( "(Upgrade)" ); 122 type = tr( "(Upgrade)" );
123 upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); 123 upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) );
124 } 124 }
125 } 125 }
126 output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); 126 output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
127 127
128 displayAvailableSpace( destination->currentText() ); 128 displayAvailableSpace( destination->currentText() );
129} 129}
130 130
131InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) 131InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title )
132 : QWidget( 0, 0, 0 ) 132 : QWidget( 0, 0, 0 )
133{ 133{
134 setCaption( title ); 134 setCaption( title );
135 init( FALSE ); 135 init( FALSE );
136 pIpkg = ipkg; 136 pIpkg = ipkg;
137 output->setText( initialText ); 137 output->setText( initialText );
138} 138}
139 139
140 140
141InstallDlgImpl::~InstallDlgImpl() 141InstallDlgImpl::~InstallDlgImpl()
142{ 142{
143 if ( pIpkg ) 143 if ( pIpkg )
144 delete pIpkg; 144 delete pIpkg;
145} 145}
146 146
147void InstallDlgImpl :: init( bool displayextrainfo ) 147void InstallDlgImpl :: init( bool displayextrainfo )
148{ 148{
149 QGridLayout *layout = new QGridLayout( this ); 149 QGridLayout *layout = new QGridLayout( this );
150 layout->setSpacing( 4 ); 150 layout->setSpacing( 4 );
151 layout->setMargin( 4 ); 151 layout->setMargin( 4 );
152 152
153 if ( displayextrainfo ) 153 if ( displayextrainfo )
154 { 154 {
155 QLabel *label = new QLabel( tr( "Destination" ), this ); 155 QLabel *label = new QLabel( tr( "Destination" ), this );
156 layout->addWidget( label, 0, 0 ); 156 layout->addWidget( label, 0, 0 );
157 destination = new QComboBox( FALSE, this ); 157 destination = new QComboBox( FALSE, this );
158 layout->addWidget( destination, 0, 1 ); 158 layout->addWidget( destination, 0, 1 );
159 connect( destination, SIGNAL( highlighted( const QString & ) ), 159 connect( destination, SIGNAL( highlighted( const QString & ) ),
160 this, SLOT( displayAvailableSpace( const QString & ) ) ); 160 this, SLOT( displayAvailableSpace( const QString & ) ) );
161 161
162 QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); 162 QLabel *label2 = new QLabel( tr( "Space Avail" ), this );
163 layout->addWidget( label2, 1, 0 ); 163 layout->addWidget( label2, 1, 0 );
164 txtAvailableSpace = new QLabel( "", this ); 164 txtAvailableSpace = new QLabel( "", this );
165 layout->addWidget( txtAvailableSpace, 1, 1 ); 165 layout->addWidget( txtAvailableSpace, 1, 1 );
166 } 166 }
167 else 167 else
168 { 168 {
169 destination = 0x0; 169 destination = 0x0;
170 txtAvailableSpace = 0x0; 170 txtAvailableSpace = 0x0;
171 } 171 }
172 172
173 QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); 173 QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
174 GroupBox2->layout()->setSpacing( 0 ); 174 GroupBox2->layout()->setSpacing( 0 );
175 GroupBox2->layout()->setMargin( 4 ); 175 GroupBox2->layout()->setMargin( 4 );
176 176
177 QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); 177 QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() );
178 output = new QMultiLineEdit( GroupBox2 ); 178 output = new QMultiLineEdit( GroupBox2 );
179 GroupBox2Layout->addWidget( output ); 179 GroupBox2Layout->addWidget( output );
180 layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); 180 layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 );
181 181
182 btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); 182 btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this );
183 layout->addWidget( btnInstall, 3, 0 ); 183 layout->addWidget( btnInstall, 3, 0 );
184 connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); 184 connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) );
185 185
186 btnOptions = new QPushButton( Resource::loadPixmap( "aqpkg/config" ), tr( "Options" ), this ); 186 btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this );
187 layout->addWidget( btnOptions, 3, 1 ); 187 layout->addWidget( btnOptions, 3, 1 );
188 connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); 188 connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) );
189} 189}
190 190
191void InstallDlgImpl :: optionsSelected() 191void InstallDlgImpl :: optionsSelected()
192{ 192{
193 InstallOptionsDlgImpl opt( flags, this, "Option", true ); 193 InstallOptionsDlgImpl opt( flags, this, "Option", true );
194 opt.exec(); 194 opt.exec();
195 195
196 // set options selected from dialog 196 // set options selected from dialog
197 flags = opt.getFlags(); 197 flags = opt.getFlags();
198 198
199#ifdef QWS 199#ifdef QWS
200 Config cfg( "aqpkg" ); 200 Config cfg( "aqpkg" );
201 cfg.setGroup( "settings" ); 201 cfg.setGroup( "settings" );
202 cfg.writeEntry( "installFlags", flags ); 202 cfg.writeEntry( "installFlags", flags );
203#endif 203#endif
204} 204}
205 205
206void InstallDlgImpl :: installSelected() 206void InstallDlgImpl :: installSelected()
207{ 207{
208 if ( btnInstall->text() == tr( "Abort" ) ) 208 if ( btnInstall->text() == tr( "Abort" ) )
209 { 209 {
210 if ( pIpkg ) 210 if ( pIpkg )
211 { 211 {
212 displayText( tr( "\n**** User Clicked ABORT ***" ) ); 212 displayText( tr( "\n**** User Clicked ABORT ***" ) );
213 pIpkg->abort(); 213 pIpkg->abort();
214 displayText( tr( "**** Process Aborted ****" ) ); 214 displayText( tr( "**** Process Aborted ****" ) );
215 } 215 }
216 216
217 btnInstall->setText( tr( "Close" ) ); 217 btnInstall->setText( tr( "Close" ) );
218 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); 218 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
219 return; 219 return;
220 } 220 }
221 else if ( btnInstall->text() == tr( "Close" ) ) 221 else if ( btnInstall->text() == tr( "Close" ) )
222 { 222 {
223 emit reloadData( this ); 223 emit reloadData( this );
224 return; 224 return;
225 } 225 }
226 226
227 // Disable buttons 227 // Disable buttons
228 btnOptions->setEnabled( false ); 228 btnOptions->setEnabled( false );
229// btnInstall->setEnabled( false ); 229// btnInstall->setEnabled( false );
230 230
231 btnInstall->setText( tr( "Abort" ) ); 231 btnInstall->setText( tr( "Abort" ) );
232 btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); 232 btnInstall->setIconSet( Resource::loadPixmap( "close" ) );
233
233 if ( pIpkg ) 234 if ( pIpkg )
234 { 235 {
235 output->setText( "" ); 236 output->setText( "" );
236 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 237 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
237 pIpkg->runIpkg(); 238 pIpkg->runIpkg();
238 } 239 }
239 else 240 else
240 { 241 {
241 output->setText( "" ); 242 output->setText( "" );
242 Destination *d = dataMgr->getDestination( destination->currentText() ); 243 Destination *d = dataMgr->getDestination( destination->currentText() );
243 QString dest = d->getDestinationName(); 244 QString dest = d->getDestinationName();
244 QString destDir = d->getDestinationPath(); 245 QString destDir = d->getDestinationPath();
245 int instFlags = flags; 246 int instFlags = flags;
246 if ( d->linkToRoot() ) 247 if ( d->linkToRoot() )
247 instFlags |= MAKE_LINKS; 248 instFlags |= MAKE_LINKS;
248 249
249#ifdef QWS 250#ifdef QWS
250 // Save settings 251 // Save settings
251 Config cfg( "aqpkg" ); 252 Config cfg( "aqpkg" );
252 cfg.setGroup( "settings" ); 253 cfg.setGroup( "settings" );
253 cfg.writeEntry( "dest", dest ); 254 cfg.writeEntry( "dest", dest );
254#endif 255#endif
255 256
256 pIpkg = new Ipkg; 257 pIpkg = new Ipkg;
257 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 258 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
258 259
259 // First run through the remove list, then the install list then the upgrade list 260 // First run through the remove list, then the install list then the upgrade list
260 pIpkg->setOption( "remove" ); 261 pIpkg->setOption( "remove" );
261 QListIterator<InstallData> it( removeList ); 262 QListIterator<InstallData> it( removeList );
262 InstallData *idata; 263 InstallData *idata;
263 for ( ; it.current(); ++it ) 264 for ( ; it.current(); ++it )
264 { 265 {
265 idata = it.current(); 266 idata = it.current();
266 pIpkg->setDestination( idata->destination->getDestinationName() ); 267 pIpkg->setDestination( idata->destination->getDestinationName() );
267 pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); 268 pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
268 pIpkg->setPackage( idata->packageName ); 269 pIpkg->setPackage( idata->packageName );
269 270
270 int tmpFlags = flags; 271 int tmpFlags = flags;
271 if ( idata->destination->linkToRoot() ) 272 if ( idata->destination->linkToRoot() )
272 tmpFlags |= MAKE_LINKS; 273 tmpFlags |= MAKE_LINKS;
273 274
274 pIpkg->setFlags( tmpFlags ); 275 pIpkg->setFlags( tmpFlags );
275 pIpkg->runIpkg(); 276 pIpkg->runIpkg();
276 } 277 }
277 278
278 pIpkg->setOption( "install" ); 279 pIpkg->setOption( "install" );
279 pIpkg->setDestination( dest ); 280 pIpkg->setDestination( dest );
280 pIpkg->setDestinationDir( destDir ); 281 pIpkg->setDestinationDir( destDir );
281 pIpkg->setFlags( instFlags ); 282 pIpkg->setFlags( instFlags );
282 QListIterator<InstallData> it2( installList ); 283 QListIterator<InstallData> it2( installList );
283 for ( ; it2.current(); ++it2 ) 284 for ( ; it2.current(); ++it2 )
284 { 285 {
285 pIpkg->setPackage( it2.current()->packageName ); 286 pIpkg->setPackage( it2.current()->packageName );
286 pIpkg->runIpkg(); 287 pIpkg->runIpkg();
287 } 288 }
288 289
289 flags |= FORCE_REINSTALL; 290 flags |= FORCE_REINSTALL;
290 QListIterator<InstallData> it3( updateList ); 291 QListIterator<InstallData> it3( updateList );
291 for ( ; it3.current() ; ++it3 ) 292 for ( ; it3.current() ; ++it3 )
292 { 293 {
293 idata = it3.current(); 294 idata = it3.current();
294 if ( idata->option == "R" ) 295 if ( idata->option == "R" )
295 pIpkg->setOption( "reinstall" ); 296 pIpkg->setOption( "reinstall" );
296 else 297 else
297 pIpkg->setOption( "upgrade" ); 298 pIpkg->setOption( "upgrade" );
298 pIpkg->setDestination( idata->destination->getDestinationName() ); 299 pIpkg->setDestination( idata->destination->getDestinationName() );
299 pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); 300 pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
300 pIpkg->setPackage( idata->packageName ); 301 pIpkg->setPackage( idata->packageName );
301 302
302 int tmpFlags = flags; 303 int tmpFlags = flags;
303 if ( idata->destination->linkToRoot() && idata->recreateLinks ) 304 if ( idata->destination->linkToRoot() && idata->recreateLinks )
304 tmpFlags |= MAKE_LINKS; 305 tmpFlags |= MAKE_LINKS;
305 pIpkg->setFlags( tmpFlags ); 306 pIpkg->setFlags( tmpFlags );
306 pIpkg->runIpkg(); 307 pIpkg->runIpkg();
307 } 308 }
308 309
309 delete pIpkg; 310 delete pIpkg;
310 pIpkg = 0; 311 pIpkg = 0;
311 } 312 }
312 313
313 btnOptions->setEnabled( true ); 314 btnOptions->setEnabled( true );
314// btnInstall->setEnabled( true ); 315// btnInstall->setEnabled( true );
315 btnInstall->setText( tr( "Close" ) ); 316 btnInstall->setText( tr( "Close" ) );
316 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); 317 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
317 318
318 if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) 319 if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
319 displayAvailableSpace( destination->currentText() ); 320 displayAvailableSpace( destination->currentText() );
320} 321}
321 322
322 323
323void InstallDlgImpl :: displayText(const QString &text ) 324void InstallDlgImpl :: displayText(const QString &text )
324{ 325{
325 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); 326 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text );
326 327
327 /* Set a max line count for the QMultiLineEdit, as users have reported 328 /* Set a max line count for the QMultiLineEdit, as users have reported
328 * performance issues when line count gets extreme. 329 * performance issues when line count gets extreme.
329 */ 330 */
330 if(output->numLines() >= MAXLINES) 331 if(output->numLines() >= MAXLINES)
331 output->removeLine(0); 332 output->removeLine(0);
332 output->setText( newtext ); 333 output->setText( newtext );
333 output->setCursorPosition( output->numLines(), 0 ); 334 output->setCursorPosition( output->numLines(), 0 );
334} 335}
335 336
336 337
337void InstallDlgImpl :: displayAvailableSpace( const QString &text ) 338void InstallDlgImpl :: displayAvailableSpace( const QString &text )
338{ 339{
339 Destination *d = dataMgr->getDestination( text ); 340 Destination *d = dataMgr->getDestination( text );
340 QString destDir = d->getDestinationPath(); 341 QString destDir = d->getDestinationPath();
341 342
342 long blockSize = 0; 343 long blockSize = 0;
343 long totalBlocks = 0; 344 long totalBlocks = 0;
344 long availBlocks = 0; 345 long availBlocks = 0;
345 QString space; 346 QString space;
346 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) 347 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) )
347 { 348 {
348 long mult = blockSize / 1024; 349 long mult = blockSize / 1024;
349 long div = 1024 / blockSize; 350 long div = 1024 / blockSize;
350 351
351 if ( !mult ) mult = 1; 352 if ( !mult ) mult = 1;
352 if ( !div ) div = 1; 353 if ( !div ) div = 1;
353// long total = totalBlocks * mult / div; 354// long total = totalBlocks * mult / div;
354 long avail = availBlocks * mult / div; 355 long avail = availBlocks * mult / div;
355// long used = total - avail; 356// long used = total - avail;
356 357
357 space.sprintf( "%ld Kb", avail ); 358 space.sprintf( "%ld Kb", avail );
358 } 359 }
359 else 360 else
360 space = tr( "Unknown" ); 361 space = tr( "Unknown" );
361 362
362 if ( txtAvailableSpace ) 363 if ( txtAvailableSpace )
363 txtAvailableSpace->setText( space ); 364 txtAvailableSpace->setText( space );
364} 365}
365 366
diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h
index d7509bb..c30963e 100644
--- a/noncore/settings/aqpkg/installdlgimpl.h
+++ b/noncore/settings/aqpkg/installdlgimpl.h
@@ -1,85 +1,85 @@
1/*************************************************************************** 1/***************************************************************************
2 installdlgimpl.h - description 2 installdlgimpl.h - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 2002 4 begin : Mon Aug 26 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#ifndef INSTALLDLGIMPL_H 17#ifndef INSTALLDLGIMPL_H
18#define INSTALLDLGIMPL_H 18#define INSTALLDLGIMPL_H
19 19
20using namespace std; 20using namespace std;
21 21
22#include <qlist.h> 22#include <qlist.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qwidget.h> 24#include <qwidget.h>
25 25
26class QComboBox; 26class QComboBox;
27class QLabel; 27class QLabel;
28class QMultiLineEdit; 28class QMultiLineEdit;
29class QPushButton; 29class QPushButton;
30 30
31class DataManager; 31class DataManager;
32class Destination; 32class Destination;
33class Ipkg; 33class Ipkg;
34 34
35class InstallData 35class InstallData
36{ 36{
37public: 37public:
38 QString option; // I - install, D - delete, R- reinstall U - upgrade 38 QString option; // I - install, D - delete, R- reinstall U - upgrade
39 QString packageName; 39 QString packageName;
40 Destination *destination; 40 Destination *destination;
41 bool recreateLinks; 41 bool recreateLinks;
42}; 42};
43 43
44class InstallDlgImpl : public QWidget 44class InstallDlgImpl : public QWidget
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47public: 47public:
48 InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 ); 48 InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 );
49 InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 ); 49 InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 );
50 ~InstallDlgImpl(); 50 ~InstallDlgImpl();
51 51
52 bool upgradeServer( QString &server ); 52 bool upgradeServer( QString &server );
53 53
54protected: 54protected:
55 55
56private: 56private:
57 DataManager *dataMgr; 57 DataManager *dataMgr;
58 QList<InstallData> installList; 58 QList<InstallData> installList;
59 QList<InstallData> removeList; 59 QList<InstallData> removeList;
60 QList<InstallData> updateList; 60 QList<InstallData> updateList;
61 int flags; 61 int flags;
62 Ipkg *pIpkg; 62 Ipkg *pIpkg;
63 bool upgradePackages; 63 bool upgradePackages;
64 64
65 QComboBox *destination; 65 QComboBox *destination;
66 QPushButton *btnInstall; 66 QPushButton *btnInstall;
67 QPushButton *btnOptions; 67 QPushButton *btnOptions;
68 QMultiLineEdit *output; 68 QMultiLineEdit *output;
69 QLabel *txtAvailableSpace; 69 QLabel *txtAvailableSpace;
70 70
71 void init( bool ); 71 void init( bool );
72 72
73 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); 73 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags );
74 74
75signals: 75signals:
76 void reloadData( InstallDlgImpl * ); 76 void reloadData( InstallDlgImpl * );
77 77
78public slots: 78public slots:
79 void optionsSelected(); 79 void optionsSelected();
80 void installSelected(); 80 void installSelected();
81 void displayText(const QString &text ); 81 void displayText(const QString &text );
82 void displayAvailableSpace( const QString &text); 82 void displayAvailableSpace( const QString &text);
83}; 83};
84 84
85#endif 85#endif
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index dfe6d9c..7fa311d 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -1,1170 +1,1191 @@
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 <linux/limits.h> 18#include <linux/limits.h>
19#include <unistd.h> 19#include <unistd.h>
20 20
21#include <qpe/qcopenvelope_qws.h> 21#include <qpe/qcopenvelope_qws.h>
22#include <qpe/qpemenubar.h> 22#include <qpe/qpemenubar.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/qpetoolbar.h> 24#include <qpe/qpetoolbar.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27 27
28#include <qaction.h> 28#include <qaction.h>
29#include <qcombobox.h> 29#include <qcombobox.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qlineedit.h> 33#include <qlineedit.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qmenubar.h> 35#include <qmenubar.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qpopupmenu.h> 37#include <qpopupmenu.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qtimer.h> 39#include <qtimer.h>
40#include <qwhatsthis.h> 40#include <qwhatsthis.h>
41#include <qwidgetstack.h> 41#include <qwidgetstack.h>
42 42
43#include "categoryfilterimpl.h" 43#include "categoryfilterimpl.h"
44#include "datamgr.h" 44#include "datamgr.h"
45#include "global.h" 45#include "global.h"
46#include "inputdlg.h" 46#include "inputdlg.h"
47#include "ipkg.h" 47#include "ipkg.h"
48#include "installdlgimpl.h" 48#include "installdlgimpl.h"
49#include "letterpushbutton.h" 49#include "letterpushbutton.h"
50#include "mainwin.h" 50#include "mainwin.h"
51#include "settingsimpl.h" 51#include "settingsimpl.h"
52#include "utils.h" 52#include "utils.h"
53 53
54extern int compareVersions( const char *v1, const char *v2 ); 54extern int compareVersions( const char *v1, const char *v2 );
55 55
56MainWindow :: MainWindow() 56MainWindow :: MainWindow()
57 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) 57 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
58{ 58{
59 setCaption( tr( "AQPkg - Package Manager" ) ); 59 setCaption( tr( "AQPkg - Package Manager" ) );
60 60
61 // Create UI widgets 61 // Create UI widgets
62 initMainWidget(); 62 initMainWidget();
63 initProgressWidget(); 63 initProgressWidget();
64 64
65 // Build menu and tool bars 65 // Build menu and tool bars
66 setToolBarsMovable( FALSE ); 66 setToolBarsMovable( FALSE );
67 67
68 QPEToolBar *bar = new QPEToolBar( this ); 68 QPEToolBar *bar = new QPEToolBar( this );
69 bar->setHorizontalStretchable( TRUE ); 69 bar->setHorizontalStretchable( TRUE );
70 QPEMenuBar *mb = new QPEMenuBar( bar ); 70 QPEMenuBar *mb = new QPEMenuBar( bar );
71 mb->setMargin( 0 ); 71 mb->setMargin( 0 );
72 bar = new QPEToolBar( this ); 72 bar = new QPEToolBar( this );
73 73
74 // Find toolbar 74 // Find toolbar
75 findBar = new QPEToolBar( this ); 75 findBar = new QPEToolBar( this );
76 addToolBar( findBar, QMainWindow::Top, true ); 76 addToolBar( findBar, QMainWindow::Top, true );
77 findBar->setHorizontalStretchable( true ); 77 findBar->setHorizontalStretchable( true );
78 findEdit = new QLineEdit( findBar ); 78 findEdit = new QLineEdit( findBar );
79 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); 79 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) );
80 findBar->setStretchableWidget( findEdit ); 80 findBar->setStretchableWidget( findEdit );
81 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); 81 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) );
82 82
83 // Quick jump toolbar 83 // Quick jump toolbar
84 jumpBar = new QPEToolBar( this ); 84 jumpBar = new QPEToolBar( this );
85 addToolBar( jumpBar, QMainWindow::Top, true ); 85 addToolBar( jumpBar, QMainWindow::Top, true );
86 jumpBar->setHorizontalStretchable( true ); 86 jumpBar->setHorizontalStretchable( true );
87 QWidget *w = new QWidget( jumpBar ); 87 QWidget *w = new QWidget( jumpBar );
88 jumpBar->setStretchableWidget( w ); 88 jumpBar->setStretchableWidget( w );
89 89
90 QGridLayout *layout = new QGridLayout( w ); 90 QGridLayout *layout = new QGridLayout( w );
91 91
92 char text[2]; 92 char text[2];
93 text[1] = '\0'; 93 text[1] = '\0';
94 for ( int i = 0 ; i < 26 ; ++i ) 94 for ( int i = 0 ; i < 26 ; ++i )
95 { 95 {
96 text[0] = 'A' + i; 96 text[0] = 'A' + i;
97 LetterPushButton *b = new LetterPushButton( text, w ); 97 LetterPushButton *b = new LetterPushButton( text, w );
98 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 98 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
99 layout->addWidget( b, i / 13, i % 13); 99 layout->addWidget( b, i / 13, i % 13);
100 } 100 }
101 101
102 QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); 102 QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 );
103 a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); 103 a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) );
104 connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); 104 connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) );
105 a->addTo( jumpBar ); 105 a->addTo( jumpBar );
106 jumpBar->hide(); 106 jumpBar->hide();
107 107
108 // Packages menu 108 // Packages menu
109 QPopupMenu *popup = new QPopupMenu( this ); 109 QPopupMenu *popup = new QPopupMenu( this );
110 110
111 a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); 111 a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 );
112 a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); 112 a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
113 connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); 113 connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) );
114 a->addTo( popup ); 114 a->addTo( popup );
115 a->addTo( bar ); 115 a->addTo( bar );
116 116
117 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); 117 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 );
118 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); 118 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
119 connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); 119 connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) );
120 actionUpgrade->addTo( popup ); 120 actionUpgrade->addTo( popup );
121 actionUpgrade->addTo( bar ); 121 actionUpgrade->addTo( bar );
122 122
123 iconDownload = Resource::loadPixmap( "aqpkg/download" ); 123 iconDownload = Resource::loadPixmap( "aqpkg/download" );
124 iconRemove = Resource::loadPixmap( "aqpkg/remove" ); 124 iconRemove = Resource::loadPixmap( "aqpkg/remove" );
125 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); 125 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
126 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 126 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
127 connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); 127 connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) );
128 actionDownload->addTo( popup ); 128 actionDownload->addTo( popup );
129 actionDownload->addTo( bar ); 129 actionDownload->addTo( bar );
130 130
131 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); 131 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 );
132 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); 132 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
133 connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); 133 connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) );
134 a->addTo( popup ); 134 a->addTo( popup );
135 a->addTo( bar ); 135 a->addTo( bar );
136 136
137 mb->insertItem( tr( "Actions" ), popup ); 137 mb->insertItem( tr( "Actions" ), popup );
138 138
139 // View menu 139 // View menu
140 popup = new QPopupMenu( this ); 140 popup = new QPopupMenu( this );
141 141
142 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); 142 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
143 actionUninstalled->setToggleAction( TRUE ); 143 actionUninstalled->setToggleAction( TRUE );
144 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); 144 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
145 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); 145 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) );
146 actionUninstalled->addTo( popup ); 146 actionUninstalled->addTo( popup );
147 147
148 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); 148 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
149 actionInstalled->setToggleAction( TRUE ); 149 actionInstalled->setToggleAction( TRUE );
150 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); 150 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
151 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); 151 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) );
152 actionInstalled->addTo( popup ); 152 actionInstalled->addTo( popup );
153 153
154 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); 154 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
155 actionUpdated->setToggleAction( TRUE ); 155 actionUpdated->setToggleAction( TRUE );
156 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); 156 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
157 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); 157 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) );
158 actionUpdated->addTo( popup ); 158 actionUpdated->addTo( popup );
159 159
160 popup->insertSeparator(); 160 popup->insertSeparator();
161 161
162 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); 162 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 );
163 actionFilter->setToggleAction( TRUE ); 163 actionFilter->setToggleAction( TRUE );
164 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); 164 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) );
165 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); 165 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) );
166 actionFilter->addTo( popup ); 166 actionFilter->addTo( popup );
167 167
168 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); 168 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 );
169 a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); 169 a->setWhatsThis( tr( "Click here to change package category to used filter." ) );
170 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); 170 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) );
171 a->addTo( popup ); 171 a->addTo( popup );
172 172
173 popup->insertSeparator(); 173 popup->insertSeparator();
174 174
175 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 175 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
176 a->setWhatsThis( tr( "Click here to search for text in package names." ) ); 176 a->setWhatsThis( tr( "Click here to search for text in package names." ) );
177 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); 177 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) );
178 a->addTo( popup ); 178 a->addTo( popup );
179 179
180 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); 180 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
181 actionFindNext->setEnabled( FALSE ); 181 actionFindNext->setEnabled( FALSE );
182 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); 182 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
183 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); 183 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) );
184 actionFindNext->addTo( popup ); 184 actionFindNext->addTo( popup );
185 actionFindNext->addTo( findBar ); 185 actionFindNext->addTo( findBar );
186 186
187 187
188 popup->insertSeparator(); 188 popup->insertSeparator();
189 189
190 a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); 190 a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 );
191 a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); 191 a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) );
192 connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); 192 connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) );
193 a->addTo( popup ); 193 a->addTo( popup );
194 194
195 mb->insertItem( tr( "View" ), popup ); 195 mb->insertItem( tr( "View" ), popup );
196 196
197 197
198 // Options menu 198 // Options menu
199 popup = new QPopupMenu( this ); 199 popup = new QPopupMenu( this );
200 200
201 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); 201 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
202 a->setWhatsThis( tr( "Click here to configure this application." ) ); 202 a->setWhatsThis( tr( "Click here to configure this application." ) );
203 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); 203 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) );
204 a->addTo( popup ); 204 a->addTo( popup );
205 205
206 mb->insertItem( tr( "Options" ), popup ); 206 mb->insertItem( tr( "Options" ), popup );
207 207
208 // Finish find toolbar creation 208 // Finish find toolbar creation
209 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 209 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
210 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); 210 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) );
211 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); 211 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) );
212 a->addTo( findBar ); 212 a->addTo( findBar );
213 findBar->hide(); 213 findBar->hide();
214 214
215 // Create widget stack and add UI widgets 215 // Create widget stack and add UI widgets
216 stack = new QWidgetStack( this ); 216 stack = new QWidgetStack( this );
217 stack->addWidget( progressWindow, 2 ); 217 stack->addWidget( progressWindow, 2 );
218 stack->addWidget( networkPkgWindow, 1 ); 218 stack->addWidget( networkPkgWindow, 1 );
219 setCentralWidget( stack ); 219 setCentralWidget( stack );
220 stack->raiseWidget( progressWindow ); 220 stack->raiseWidget( progressWindow );
221 221
222 // Delayed call to finish initialization 222 // Delayed call to finish initialization
223 QTimer::singleShot( 100, this, SLOT( init() ) ); 223 QTimer::singleShot( 100, this, SLOT( init() ) );
224} 224}
225 225
226MainWindow :: ~MainWindow() 226MainWindow :: ~MainWindow()
227{ 227{
228 delete mgr; 228 delete mgr;
229} 229}
230 230
231void MainWindow :: initMainWidget() 231void MainWindow :: initMainWidget()
232{ 232{
233 networkPkgWindow = new QWidget( this ); 233 networkPkgWindow = new QWidget( this );
234 234
235 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); 235 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow );
236 236
237 serversList = new QComboBox( networkPkgWindow ); 237 serversList = new QComboBox( networkPkgWindow );
238 connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) ); 238 connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) );
239 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); 239 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) );
240 240
241 installedIcon = Resource::loadPixmap( "installed" ); 241 installedIcon = Resource::loadPixmap( "installed" );
242 updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); 242 updatedIcon = Resource::loadPixmap( "aqpkg/updated" );
243 243
244 packagesList = new QListView( networkPkgWindow ); 244 packagesList = new QListView( networkPkgWindow );
245 packagesList->addColumn( tr( "Packages" ), 225 ); 245 packagesList->addColumn( tr( "Packages" ), 225 );
246 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." ) ); 246 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." ) );
247 247
248 QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); 248 QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 );
249 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); 249 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 );
250 hbox1->addWidget( l ); 250 hbox1->addWidget( l );
251 hbox1->addWidget( serversList ); 251 hbox1->addWidget( serversList );
252 252
253 vbox->addWidget( packagesList ); 253 vbox->addWidget( packagesList );
254 254
255 downloadEnabled = TRUE; 255 downloadEnabled = TRUE;
256} 256}
257 257
258void MainWindow :: initProgressWidget() 258void MainWindow :: initProgressWidget()
259{ 259{
260 progressWindow = new QWidget( this ); 260 progressWindow = new QWidget( this );
261 261
262 QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); 262 QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 );
263 263
264 m_status = new QLabel( progressWindow ); 264 m_status = new QLabel( progressWindow );
265 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); 265 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
266 layout->addWidget( m_status ); 266 layout->addWidget( m_status );
267 267
268 m_progress = new QProgressBar( progressWindow ); 268 m_progress = new QProgressBar( progressWindow );
269 layout->addWidget( m_progress ); 269 layout->addWidget( m_progress );
270} 270}
271 271
272void MainWindow :: init() 272void MainWindow :: init()
273{ 273{
274#ifdef QWS 274#ifdef QWS
275 // read download directory from config file 275 // read download directory from config file
276 Config cfg( "aqpkg" ); 276 Config cfg( "aqpkg" );
277 cfg.setGroup( "settings" ); 277 cfg.setGroup( "settings" );
278 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 278 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
279// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 279// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
280 280
281#endif 281#endif
282 282
283 stack->raiseWidget( progressWindow ); 283 stack->raiseWidget( progressWindow );
284 284
285 mgr = new DataManager(); 285 mgr = new DataManager();
286 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); 286 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) );
287 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), 287 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
288 this, SLOT( setProgressMessage( const QString & ) ) ); 288 this, SLOT( setProgressMessage( const QString & ) ) );
289 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); 289 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) );
290 mgr->loadServers(); 290 mgr->loadServers();
291 291
292 showUninstalledPkgs = false; 292 showUninstalledPkgs = false;
293 showInstalledPkgs = false; 293 showInstalledPkgs = false;
294 showUpgradedPkgs = false; 294 showUpgradedPkgs = false;
295 categoryFilterEnabled = false; 295 categoryFilterEnabled = false;
296 296
297 updateData(); 297 updateData();
298 298
299 stack->raiseWidget( networkPkgWindow ); 299 stack->raiseWidget( networkPkgWindow );
300} 300}
301/* 301/*
302void MainWindow :: setDocument( const QString &doc ) 302void MainWindow :: setDocument( const QString &doc )
303{ 303{
304 // Remove path from package 304 // Remove path from package
305 QString package = Utils::getPackageNameFromIpkFilename( doc ); 305 QString package = Utils::getPackageNameFromIpkFilename( doc );
306// std::cout << "Selecting package " << package << std::endl; 306// std::cout << "Selecting package " << package << std::endl;
307 307
308 // First select local server 308 // First select local server
309 for ( int i = 0 ; i < serversList->count() ; ++i ) 309 for ( int i = 0 ; i < serversList->count() ; ++i )
310 { 310 {
311 if ( serversList->text( i ) == LOCAL_IPKGS ) 311 if ( serversList->text( i ) == LOCAL_IPKGS )
312 { 312 {
313 serversList->setCurrentItem( i ); 313 serversList->setCurrentItem( i );
314 break; 314 break;
315 } 315 }
316 } 316 }
317 serverSelected( 0 ); 317 serverSelected( 0 );
318 318
319 // Now set the check box of the selected package 319 // Now set the check box of the selected package
320 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 320 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
321 item != 0 ; 321 item != 0 ;
322 item = (QCheckListItem *)item->nextSibling() ) 322 item = (QCheckListItem *)item->nextSibling() )
323 { 323 {
324 if ( item->text().startsWith( package ) ) 324 if ( item->text().startsWith( package ) )
325 { 325 {
326 item->setOn( true ); 326 item->setOn( true );
327 break; 327 break;
328 } 328 }
329 } 329 }
330} 330}
331*/ 331*/
332void MainWindow :: displaySettings() 332void MainWindow :: displaySettings()
333{ 333{
334 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 334 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
335 if ( dlg->showDlg() ) 335 if ( dlg->showDlg() )
336 { 336 {
337 stack->raiseWidget( progressWindow ); 337 stack->raiseWidget( progressWindow );
338 updateData(); 338 updateData();
339 stack->raiseWidget( networkPkgWindow ); 339 stack->raiseWidget( networkPkgWindow );
340 } 340 }
341 delete dlg; 341 delete dlg;
342} 342}
343
344void MainWindow :: closeEvent( QCloseEvent *e )
345{
346 // If install dialog is visible, return to main view, otherwise close app
347 QWidget *widget = stack->visibleWidget();
348
349 if ( widget != networkPkgWindow && widget != progressWindow )
350 {
351 if ( widget ) delete widget;
352 stack->raiseWidget( networkPkgWindow );
353 e->ignore();
354 }
355 else
356 {
357 e->accept();
358 }
359}
343 360
344void MainWindow :: displayFindBar() 361void MainWindow :: displayFindBar()
345{ 362{
346 findBar->show(); 363 findBar->show();
347 findEdit->setFocus(); 364 findEdit->setFocus();
348} 365}
349 366
350void MainWindow :: displayJumpBar() 367void MainWindow :: displayJumpBar()
351{ 368{
352 jumpBar->show(); 369 jumpBar->show();
353} 370}
354 371
355void MainWindow :: repeatFind() 372void MainWindow :: repeatFind()
356{ 373{
357 searchForPackage( findEdit->text() ); 374 searchForPackage( findEdit->text() );
358} 375}
359 376
360void MainWindow :: findPackage( const QString &text ) 377void MainWindow :: findPackage( const QString &text )
361{ 378{
362 actionFindNext->setEnabled( !text.isEmpty() ); 379 actionFindNext->setEnabled( !text.isEmpty() );
363 searchForPackage( text ); 380 searchForPackage( text );
364} 381}
365 382
366void MainWindow :: hideFindBar() 383void MainWindow :: hideFindBar()
367{ 384{
368 findBar->hide(); 385 findBar->hide();
369} 386}
370 387
371void MainWindow :: hideJumpBar() 388void MainWindow :: hideJumpBar()
372{ 389{
373 jumpBar->hide(); 390 jumpBar->hide();
374} 391}
375 392
376void MainWindow :: filterUninstalledPackages() 393void MainWindow :: filterUninstalledPackages()
377{ 394{
378 showUninstalledPkgs = actionUninstalled->isOn(); 395 showUninstalledPkgs = actionUninstalled->isOn();
379 if ( showUninstalledPkgs ) 396 if ( showUninstalledPkgs )
380 { 397 {
381 showInstalledPkgs = FALSE; 398 showInstalledPkgs = FALSE;
382 showUpgradedPkgs = FALSE; 399 showUpgradedPkgs = FALSE;
383 } 400 }
384 serverSelected( -1 ); 401 serverSelected( -1 );
385 402
386 actionInstalled->setOn( FALSE ); 403 actionInstalled->setOn( FALSE );
387 actionUpdated->setOn( FALSE ); 404 actionUpdated->setOn( FALSE );
388} 405}
389 406
390void MainWindow :: filterInstalledPackages() 407void MainWindow :: filterInstalledPackages()
391{ 408{
392 showInstalledPkgs = actionInstalled->isOn(); 409 showInstalledPkgs = actionInstalled->isOn();
393 if ( showInstalledPkgs ) 410 if ( showInstalledPkgs )
394 { 411 {
395 showUninstalledPkgs = FALSE; 412 showUninstalledPkgs = FALSE;
396 showUpgradedPkgs = FALSE; 413 showUpgradedPkgs = FALSE;
397 } 414 }
398 serverSelected( -1 ); 415 serverSelected( -1 );
399 416
400 actionUninstalled->setOn( FALSE ); 417 actionUninstalled->setOn( FALSE );
401 actionUpdated->setOn( FALSE ); 418 actionUpdated->setOn( FALSE );
402} 419}
403 420
404void MainWindow :: filterUpgradedPackages() 421void MainWindow :: filterUpgradedPackages()
405{ 422{
406 showUpgradedPkgs = actionUpdated->isOn(); 423 showUpgradedPkgs = actionUpdated->isOn();
407 if ( showUpgradedPkgs ) 424 if ( showUpgradedPkgs )
408 { 425 {
409 showUninstalledPkgs = FALSE; 426 showUninstalledPkgs = FALSE;
410 showInstalledPkgs = FALSE; 427 showInstalledPkgs = FALSE;
411 } 428 }
412 serverSelected( -1 ); 429 serverSelected( -1 );
413 430
414 actionUninstalled->setOn( FALSE ); 431 actionUninstalled->setOn( FALSE );
415 actionInstalled->setOn( FALSE ); 432 actionInstalled->setOn( FALSE );
416} 433}
417 434
418bool MainWindow :: setFilterCategory() 435bool MainWindow :: setFilterCategory()
419{ 436{
420 // Get categories; 437 // Get categories;
421 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); 438 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this );
422 if ( dlg.exec() == QDialog::Accepted ) 439 if ( dlg.exec() == QDialog::Accepted )
423 { 440 {
424 categoryFilter = dlg.getSelectedFilter(); 441 categoryFilter = dlg.getSelectedFilter();
425 442
426 if ( categoryFilter == "" ) 443 if ( categoryFilter == "" )
427 return false; 444 return false;
428 445
429 categoryFilterEnabled = true; 446 categoryFilterEnabled = true;
430 serverSelected( -1 ); 447 serverSelected( -1 );
431 actionFilter->setOn( TRUE ); 448 actionFilter->setOn( TRUE );
432 return true; 449 return true;
433 } 450 }
434 451
435 return false; 452 return false;
436} 453}
437 454
438void MainWindow :: filterCategory() 455void MainWindow :: filterCategory()
439{ 456{
440 if ( !actionFilter->isOn() ) 457 if ( !actionFilter->isOn() )
441 { 458 {
442 filterByCategory( FALSE ); 459 filterByCategory( FALSE );
443 } 460 }
444 else 461 else
445 { 462 {
446 actionFilter->setOn( filterByCategory( TRUE ) ); 463 actionFilter->setOn( filterByCategory( TRUE ) );
447 } 464 }
448} 465}
449 466
450bool MainWindow :: filterByCategory( bool val ) 467bool MainWindow :: filterByCategory( bool val )
451{ 468{
452 if ( val ) 469 if ( val )
453 { 470 {
454 if ( categoryFilter == "" ) 471 if ( categoryFilter == "" )
455 { 472 {
456 if ( !setFilterCategory() ) 473 if ( !setFilterCategory() )
457 return false; 474 return false;
458 } 475 }
459 476
460 categoryFilterEnabled = true; 477 categoryFilterEnabled = true;
461 serverSelected( -1 ); 478 serverSelected( -1 );
462 return true; 479 return true;
463 } 480 }
464 else 481 else
465 { 482 {
466 // Turn off filter 483 // Turn off filter
467 categoryFilterEnabled = false; 484 categoryFilterEnabled = false;
468 serverSelected( -1 ); 485 serverSelected( -1 );
469 return false; 486 return false;
470 } 487 }
471} 488}
472 489
473void MainWindow :: raiseMainWidget() 490void MainWindow :: raiseMainWidget()
474{ 491{
475 stack->raiseWidget( networkPkgWindow ); 492 stack->raiseWidget( networkPkgWindow );
476} 493}
477 494
478void MainWindow :: raiseProgressWidget() 495void MainWindow :: raiseProgressWidget()
479{ 496{
480 stack->raiseWidget( progressWindow ); 497 stack->raiseWidget( progressWindow );
481} 498}
482 499
483void MainWindow :: enableUpgrade( bool enabled ) 500void MainWindow :: enableUpgrade( bool enabled )
484{ 501{
485 actionUpgrade->setEnabled( enabled ); 502 actionUpgrade->setEnabled( enabled );
486} 503}
487 504
488void MainWindow :: enableDownload( bool enabled ) 505void MainWindow :: enableDownload( bool enabled )
489{ 506{
490 if ( enabled ) 507 if ( enabled )
491 { 508 {
492 actionDownload->setIconSet( iconDownload ); 509 actionDownload->setIconSet( iconDownload );
493 actionDownload->setText( tr( "Download" ) ); 510 actionDownload->setText( tr( "Download" ) );
494 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 511 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
495 } 512 }
496 else 513 else
497 { 514 {
498 actionDownload->setIconSet( iconRemove ); 515 actionDownload->setIconSet( iconRemove );
499 actionDownload->setText( tr( "Remove" ) ); 516 actionDownload->setText( tr( "Remove" ) );
500 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); 517 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) );
501 } 518 }
502} 519}
503 520
504void MainWindow :: setProgressSteps( int numsteps ) 521void MainWindow :: setProgressSteps( int numsteps )
505{ 522{
506 m_progress->setTotalSteps( numsteps ); 523 m_progress->setTotalSteps( numsteps );
507} 524}
508 525
509void MainWindow :: setProgressMessage( const QString &msg ) 526void MainWindow :: setProgressMessage( const QString &msg )
510{ 527{
511 m_status->setText( msg ); 528 m_status->setText( msg );
512} 529}
513 530
514void MainWindow :: updateProgress( int progress ) 531void MainWindow :: updateProgress( int progress )
515{ 532{
516 m_progress->setProgress( progress ); 533 m_progress->setProgress( progress );
517} 534}
518 535
519void MainWindow :: updateData() 536void MainWindow :: updateData()
520{ 537{
521 m_progress->setTotalSteps( mgr->getServerList().count() ); 538 m_progress->setTotalSteps( mgr->getServerList().count() );
522 539
523 serversList->clear(); 540 serversList->clear();
524 packagesList->clear(); 541 packagesList->clear();
525 542
526 int activeItem = -1; 543 int activeItem = -1;
527 int i = 0; 544 int i = 0;
528 QString serverName; 545 QString serverName;
529 546
530 QListIterator<Server> it( mgr->getServerList() ); 547 QListIterator<Server> it( mgr->getServerList() );
531 Server *server; 548 Server *server;
532 549
533 for ( ; it.current(); ++it, ++i ) 550 for ( ; it.current(); ++it, ++i )
534 { 551 {
535 server = it.current(); 552 server = it.current();
536 serverName = server->getServerName(); 553 serverName = server->getServerName();
537 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); 554 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) );
538 m_progress->setProgress( i ); 555 m_progress->setProgress( i );
539 qApp->processEvents(); 556 qApp->processEvents();
540 557
541// cout << "Adding " << it->getServerName() << " to combobox" << endl; 558// cout << "Adding " << it->getServerName() << " to combobox" << endl;
542 if ( !server->isServerActive() ) 559 if ( !server->isServerActive() )
543 { 560 {
544// cout << serverName << " is not active" << endl; 561// cout << serverName << " is not active" << endl;
545 i--; 562 i--;
546 continue; 563 continue;
547 } 564 }
548 565
549 serversList->insertItem( serverName ); 566 serversList->insertItem( serverName );
550 if ( serverName == currentlySelectedServer ) 567 if ( serverName == currentlySelectedServer )
551 activeItem = i; 568 activeItem = i;
552 } 569 }
553 570
554 // set selected server to be active server 571 // set selected server to be active server
555 if ( activeItem != -1 ) 572 if ( activeItem != -1 )
556 serversList->setCurrentItem( activeItem ); 573 serversList->setCurrentItem( activeItem );
557 serverSelected( 0, FALSE ); 574 serverSelected( 0, FALSE );
558} 575}
559 576
560void MainWindow :: serverSelected( int index ) 577void MainWindow :: serverSelected( int index )
561{ 578{
562 serverSelected( index, TRUE ); 579 serverSelected( index, TRUE );
563} 580}
564 581
565void MainWindow :: serverSelected( int, bool raiseProgress ) 582void MainWindow :: serverSelected( int, bool raiseProgress )
566{ 583{
567 QPixmap nullIcon( installedIcon.size() ); 584 QPixmap nullIcon( installedIcon.size() );
568 nullIcon.fill( colorGroup().base() ); 585 nullIcon.fill( colorGroup().base() );
569 586
570 // display packages 587 // display packages
571 QString serverName = serversList->currentText(); 588 QString serverName = serversList->currentText();
572 currentlySelectedServer = serverName; 589 currentlySelectedServer = serverName;
573 590
574 Server *s = mgr->getServer( serverName ); 591 Server *s = mgr->getServer( serverName );
575 592
576 QList<Package> &list = s->getPackageList(); 593 QList<Package> &list = s->getPackageList();
577 QListIterator<Package> it( list ); 594 QListIterator<Package> it( list );
578 595
579 // Display progress widget while loading list 596 // Display progress widget while loading list
580 bool doProgress = ( list.count() > 200 ); 597 bool doProgress = ( list.count() > 200 );
581 if ( doProgress ) 598 if ( doProgress )
582 { 599 {
583 if ( raiseProgress ) 600 if ( raiseProgress )
584 { 601 {
585 stack->raiseWidget( progressWindow ); 602 stack->raiseWidget( progressWindow );
586 } 603 }
587 m_progress->setTotalSteps( list.count() ); 604 m_progress->setTotalSteps( list.count() );
588 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); 605 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
589 } 606 }
590 607
591 packagesList->clear(); 608 packagesList->clear();
592 609
593#ifdef QWS 610#ifdef QWS
594 // read download directory from config file 611 // read download directory from config file
595 Config cfg( "aqpkg" ); 612 Config cfg( "aqpkg" );
596 cfg.setGroup( "settings" ); 613 cfg.setGroup( "settings" );
597 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 614 cfg.writeEntry( "selectedServer", currentlySelectedServer );
598#endif 615#endif
599 616
600 int i = 0; 617 int i = 0;
601 Package *package; 618 Package *package;
602 for ( ; it.current(); ++it ) 619 for ( ; it.current(); ++it )
603 { 620 {
604 // Update progress after every 100th package (arbitrary value, seems to give good balance) 621 // Update progress after every 100th package (arbitrary value, seems to give good balance)
605 i++; 622 i++;
606 if ( ( i % 100 ) == 0 ) 623 if ( ( i % 100 ) == 0 )
607 { 624 {
608 if ( doProgress ) 625 if ( doProgress )
609 { 626 {
610 m_progress->setProgress( i ); 627 m_progress->setProgress( i );
611 } 628 }
612 qApp->processEvents(); 629 qApp->processEvents();
613 } 630 }
614 631
615 QString text = ""; 632 QString text = "";
616 633
617 package = it.current(); 634 package = it.current();
618 635
619 // Apply show only uninstalled packages filter 636 // Apply show only uninstalled packages filter
620 if ( showUninstalledPkgs && package->isInstalled() ) 637 if ( showUninstalledPkgs && package->isInstalled() )
621 continue; 638 continue;
622 639
623 // Apply show only installed packages filter 640 // Apply show only installed packages filter
624 if ( showInstalledPkgs && !package->isInstalled() ) 641 if ( showInstalledPkgs && !package->isInstalled() )
625 continue; 642 continue;
626 643
627 // Apply show only new installed packages filter 644 // Apply show only new installed packages filter
628 if ( showUpgradedPkgs ) 645 if ( showUpgradedPkgs )
629 { 646 {
630 if ( !package->isInstalled() || 647 if ( !package->isInstalled() ||
631 compareVersions( package->getInstalledVersion(), package->getVersion() ) != 1 ) 648 compareVersions( package->getInstalledVersion(), package->getVersion() ) != 1 )
632 continue; 649 continue;
633 } 650 }
634 651
635 // Apply the section filter 652 // Apply the section filter
636 if ( categoryFilterEnabled && categoryFilter != "" ) 653 if ( categoryFilterEnabled && categoryFilter != "" )
637 { 654 {
638 if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) 655 if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 )
639 continue; 656 continue;
640 } 657 }
641 658
642 // If the local server, only display installed packages 659 // If the local server, only display installed packages
643 if ( serverName == LOCAL_SERVER && !package->isInstalled() ) 660 if ( serverName == LOCAL_SERVER && !package->isInstalled() )
644 continue; 661 continue;
645 662
646 663
647 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), 664 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(),
648 QCheckListItem::CheckBox ); 665 QCheckListItem::CheckBox );
649 666
650 if ( package->isInstalled() ) 667 if ( package->isInstalled() )
651 { 668 {
652 // If a different version of package is available, show update available icon 669 // If a different version of package is available, show update available icon
653 // Otherwise, show installed icon 670 // Otherwise, show installed icon
654 if ( package->getVersion() != package->getInstalledVersion() && 671 if ( package->getVersion() != package->getInstalledVersion() &&
655 compareVersions( package->getInstalledVersion(), package->getVersion() ) == 1) 672 compareVersions( package->getInstalledVersion(), package->getVersion() ) == 1)
656 { 673 {
657 674
658 item->setPixmap( 0, updatedIcon ); 675 item->setPixmap( 0, updatedIcon );
659 } 676 }
660 else 677 else
661 { 678 {
662 item->setPixmap( 0, installedIcon ); 679 item->setPixmap( 0, installedIcon );
663 } 680 }
664 681
665 QString destName = ""; 682 QString destName = "";
666 if ( package->getLocalPackage() ) 683 if ( package->getLocalPackage() )
667 { 684 {
668 if ( package->getLocalPackage()->getInstalledTo() ) 685 if ( package->getLocalPackage()->getInstalledTo() )
669 destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); 686 destName = package->getLocalPackage()->getInstalledTo()->getDestinationName();
670 } 687 }
671 else 688 else
672 { 689 {
673 if ( package->getInstalledTo() ) 690 if ( package->getInstalledTo() )
674 destName = package->getInstalledTo()->getDestinationName(); 691 destName = package->getInstalledTo()->getDestinationName();
675 } 692 }
676 if ( destName != "" ) 693 if ( destName != "" )
677 new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); 694 new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) );
678 } 695 }
679 else 696 else
680 { 697 {
681 item->setPixmap( 0, nullIcon ); 698 item->setPixmap( 0, nullIcon );
682 } 699 }
683 700
684 if ( !package->isPackageStoredLocally() ) 701 if ( !package->isPackageStoredLocally() )
685 { 702 {
686 new QCheckListItem( item, QString( tr( "Description - %1" ).arg( package->getDescription() ) ) ); 703 new QCheckListItem( item, QString( tr( "Description - %1" ).arg( package->getDescription() ) ) );
687 new QCheckListItem( item, QString( tr( "Size - %1" ).arg( package->getPackageSize() ) ) ); 704 new QCheckListItem( item, QString( tr( "Size - %1" ).arg( package->getPackageSize() ) ) );
688 new QCheckListItem( item, QString( tr( "Section - %1" ).arg( package->getSection() ) ) ); 705 new QCheckListItem( item, QString( tr( "Section - %1" ).arg( package->getSection() ) ) );
689 } 706 }
690 else 707 else
691 new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( package->getFilename() ) ) ); 708 new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( package->getFilename() ) ) );
692 709
693 if ( serverName == LOCAL_SERVER ) 710 if ( serverName == LOCAL_SERVER )
694 { 711 {
695 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getVersion() ) ) ); 712 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getVersion() ) ) );
696 } 713 }
697 else 714 else
698 { 715 {
699 new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( package->getVersion() ) ) ); 716 new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( package->getVersion() ) ) );
700 if ( package->getLocalPackage() ) 717 if ( package->getLocalPackage() )
701 { 718 {
702 if ( package->isInstalled() ) 719 if ( package->isInstalled() )
703 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getInstalledVersion() ) ) ); 720 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getInstalledVersion() ) ) );
704 } 721 }
705 } 722 }
706 723
707 packagesList->insertItem( item ); 724 packagesList->insertItem( item );
708 } 725 }
709 726
710 // If the local server or the local ipkgs server disable the download button 727 // If the local server or the local ipkgs server disable the download button
711 if ( serverName == LOCAL_SERVER ) 728 if ( serverName == LOCAL_SERVER )
712 { 729 {
713 downloadEnabled = TRUE; 730 downloadEnabled = TRUE;
714 actionUpgrade->setEnabled( FALSE ); 731 actionUpgrade->setEnabled( FALSE );
715 } 732 }
716 else if ( serverName == LOCAL_IPKGS ) 733 else if ( serverName == LOCAL_IPKGS )
717 { 734 {
718 downloadEnabled = FALSE; 735 downloadEnabled = FALSE;
719 actionUpgrade->setEnabled( FALSE ); 736 actionUpgrade->setEnabled( FALSE );
720 } 737 }
721 else 738 else
722 { 739 {
723 downloadEnabled = TRUE; 740 downloadEnabled = TRUE;
724 actionUpgrade->setEnabled( TRUE ); 741 actionUpgrade->setEnabled( TRUE );
725 } 742 }
726 enableDownload( downloadEnabled ); 743 enableDownload( downloadEnabled );
727 744
728 // Display this widget once everything is done 745 // Display this widget once everything is done
729 if ( doProgress && raiseProgress ) 746 if ( doProgress && raiseProgress )
730 { 747 {
731 stack->raiseWidget( networkPkgWindow ); 748 stack->raiseWidget( networkPkgWindow );
732 } 749 }
733} 750}
734 751
735void MainWindow :: searchForPackage( const QString &text ) 752void MainWindow :: searchForPackage( const QString &text )
736{ 753{
737 if ( !text.isEmpty() ) 754 if ( !text.isEmpty() )
738 { 755 {
739// cout << "searching for " << text << endl; 756// cout << "searching for " << text << endl;
740 // look through package list for text startng at current position 757 // look through package list for text startng at current position
741// vector<InstallData> workingPackages; 758// vector<InstallData> workingPackages;
742 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 759 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
743// if ( start != 0 ) 760// if ( start != 0 )
744// start = (QCheckListItem *)start->nextSibling(); 761// start = (QCheckListItem *)start->nextSibling();
745 762
746 if ( start == 0 ) 763 if ( start == 0 )
747 start = (QCheckListItem *)packagesList->firstChild(); 764 start = (QCheckListItem *)packagesList->firstChild();
748 765
749 for ( QCheckListItem *item = start; item != 0 ; 766 for ( QCheckListItem *item = start; item != 0 ;
750 item = (QCheckListItem *)item->nextSibling() ) 767 item = (QCheckListItem *)item->nextSibling() )
751 { 768 {
752// cout << "checking " << item->text().lower() << endl; 769// cout << "checking " << item->text().lower() << endl;
753 if ( item->text().lower().find( text ) != -1 ) 770 if ( item->text().lower().find( text ) != -1 )
754 { 771 {
755// cout << "matched " << item->text() << endl; 772// cout << "matched " << item->text() << endl;
756 packagesList->ensureItemVisible( item ); 773 packagesList->ensureItemVisible( item );
757 packagesList->setCurrentItem( item ); 774 packagesList->setCurrentItem( item );
758 break; 775 break;
759 } 776 }
760 } 777 }
761 } 778 }
762} 779}
763 780
764void MainWindow :: updateServer() 781void MainWindow :: updateServer()
765{ 782{
766 QString serverName = serversList->currentText(); 783 QString serverName = serversList->currentText();
767 784
768 // Update the current server 785 // Update the current server
769 // Display dialog 786 // Display dialog
770 787
771 // Disable buttons to stop silly people clicking lots on them :) 788 // Disable buttons to stop silly people clicking lots on them :)
772 789
773 // First, write out ipkg_conf file so that ipkg can use it 790 // First, write out ipkg_conf file so that ipkg can use it
774 mgr->writeOutIpkgConf(); 791 mgr->writeOutIpkgConf();
775 792
776 Ipkg *ipkg = new Ipkg; 793 Ipkg *ipkg = new Ipkg;
777 ipkg->setOption( "update" ); 794 ipkg->setOption( "update" );
778 795
779 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), 796 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ),
780 tr( "Update lists" ) ); 797 tr( "Update lists" ) );
781 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 798 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
782 dlg->showMaximized(); 799 stack->addWidget( dlg, 3 );
800 stack->raiseWidget( dlg );
783 801
784// delete progDlg; 802// delete progDlg;
785} 803}
786 804
787void MainWindow :: upgradePackages() 805void MainWindow :: upgradePackages()
788{ 806{
789 // We're gonna do an upgrade of all packages 807 // We're gonna do an upgrade of all packages
790 // First warn user that this isn't recommended 808 // First warn user that this isn't recommended
791 // TODO - ODevice???? 809 // TODO - ODevice????
792 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); 810 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
793 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, 811 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
794 QMessageBox::Yes, 812 QMessageBox::Yes,
795 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 813 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
796 0, this ); 814 0, this );
797 warn.adjustSize(); 815 warn.adjustSize();
798 816
799 if ( warn.exec() == QMessageBox::Yes ) 817 if ( warn.exec() == QMessageBox::Yes )
800 { 818 {
801 // First, write out ipkg_conf file so that ipkg can use it 819 // First, write out ipkg_conf file so that ipkg can use it
802 mgr->writeOutIpkgConf(); 820 mgr->writeOutIpkgConf();
803 821
804 // Now run upgrade 822 // Now run upgrade
805 Ipkg *ipkg = new Ipkg; 823 Ipkg *ipkg = new Ipkg;
806 ipkg->setOption( "upgrade" ); 824 ipkg->setOption( "upgrade" );
807 825
808 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), 826 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ),
809 tr ( "Upgrade" ) ); 827 tr ( "Upgrade" ) );
810 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 828 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
811 dlg->showMaximized(); 829 stack->addWidget( dlg, 3 );
830 stack->raiseWidget( dlg );
812 } 831 }
813} 832}
814 833
815void MainWindow :: downloadPackage() 834void MainWindow :: downloadPackage()
816{ 835{
817 bool doUpdate = true; 836 bool doUpdate = true;
818 if ( downloadEnabled ) 837 if ( downloadEnabled )
819 { 838 {
820 // See if any packages are selected 839 // See if any packages are selected
821 bool found = false; 840 bool found = false;
822 if ( serversList->currentText() != LOCAL_SERVER ) 841 if ( serversList->currentText() != LOCAL_SERVER )
823 { 842 {
824 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 843 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
825 item != 0 && !found; 844 item != 0 && !found;
826 item = (QCheckListItem *)item->nextSibling() ) 845 item = (QCheckListItem *)item->nextSibling() )
827 { 846 {
828 if ( item->isOn() ) 847 if ( item->isOn() )
829 found = true; 848 found = true;
830 } 849 }
831 } 850 }
832 851
833 // If user selected some packages then download the and store the locally 852 // If user selected some packages then download the and store the locally
834 // otherwise, display dialog asking user what package to download from an http server 853 // otherwise, display dialog asking user what package to download from an http server
835 // and whether to install it 854 // and whether to install it
836 if ( found ) 855 if ( found )
837 downloadSelectedPackages(); 856 downloadSelectedPackages();
838 else 857 else
839 downloadRemotePackage(); 858 downloadRemotePackage();
840 859
841 } 860 }
842 else 861 else
843 { 862 {
844 doUpdate = false; 863 doUpdate = false;
845 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 864 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
846 item != 0 ; 865 item != 0 ;
847 item = (QCheckListItem *)item->nextSibling() ) 866 item = (QCheckListItem *)item->nextSibling() )
848 { 867 {
849 if ( item->isOn() ) 868 if ( item->isOn() )
850 { 869 {
851 QString name = item->text(); 870 QString name = item->text();
852 int pos = name.find( "*" ); 871 int pos = name.find( "*" );
853 name.truncate( pos ); 872 name.truncate( pos );
854 873
855 // if (there is a (installed), remove it 874 // if (there is a (installed), remove it
856 pos = name.find( "(installed)" ); 875 pos = name.find( "(installed)" );
857 if ( pos > 0 ) 876 if ( pos > 0 )
858 name.truncate( pos - 1 ); 877 name.truncate( pos - 1 );
859 878
860 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); 879 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name );
861 880
862 QString msgtext; 881 QString msgtext;
863 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); 882 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
864 if ( QMessageBox::information( this, tr( "Are you sure?" ), 883 if ( QMessageBox::information( this, tr( "Are you sure?" ),
865 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) 884 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
866 { 885 {
867 doUpdate = true; 886 doUpdate = true;
868 QFile f( p->getFilename() ); 887 QFile f( p->getFilename() );
869 f.remove(); 888 f.remove();
870 } 889 }
871 } 890 }
872 } 891 }
873 } 892 }
874 893
875 if ( doUpdate ) 894 if ( doUpdate )
876 { 895 {
877 reloadData( 0x0 ); 896 reloadData( 0x0 );
878 } 897 }
879} 898}
880 899
881void MainWindow :: downloadSelectedPackages() 900void MainWindow :: downloadSelectedPackages()
882{ 901{
883 // First, write out ipkg_conf file so that ipkg can use it 902 // First, write out ipkg_conf file so that ipkg can use it
884 mgr->writeOutIpkgConf(); 903 mgr->writeOutIpkgConf();
885 904
886 // Display dialog to user asking where to download the files to 905 // Display dialog to user asking where to download the files to
887 bool ok = FALSE; 906 bool ok = FALSE;
888 QString dir = ""; 907 QString dir = "";
889#ifdef QWS 908#ifdef QWS
890 // read download directory from config file 909 // read download directory from config file
891 Config cfg( "aqpkg" ); 910 Config cfg( "aqpkg" );
892 cfg.setGroup( "settings" ); 911 cfg.setGroup( "settings" );
893 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 912 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
894#endif 913#endif
895 914
896 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 915 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
897 if ( ok && !text.isEmpty() ) 916 if ( ok && !text.isEmpty() )
898 dir = text; // user entered something and pressed ok 917 dir = text; // user entered something and pressed ok
899 else 918 else
900 return; // user entered nothing or pressed cancel 919 return; // user entered nothing or pressed cancel
901 920
902#ifdef QWS 921#ifdef QWS
903 // Store download directory in config file 922 // Store download directory in config file
904 cfg.writeEntry( "downloadDir", dir ); 923 cfg.writeEntry( "downloadDir", dir );
905#endif 924#endif
906 925
907 // Get starting directory 926 // Get starting directory
908 char initDir[PATH_MAX]; 927 char initDir[PATH_MAX];
909 getcwd( initDir, PATH_MAX ); 928 getcwd( initDir, PATH_MAX );
910 929
911 // Download each package 930 // Download each package
912 Ipkg ipkg; 931 Ipkg ipkg;
913 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 932 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
914 933
915 ipkg.setOption( "download" ); 934 ipkg.setOption( "download" );
916 ipkg.setRuntimeDirectory( dir ); 935 ipkg.setRuntimeDirectory( dir );
917 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 936 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
918 item != 0 ; 937 item != 0 ;
919 item = (QCheckListItem *)item->nextSibling() ) 938 item = (QCheckListItem *)item->nextSibling() )
920 { 939 {
921 if ( item->isOn() ) 940 if ( item->isOn() )
922 { 941 {
923 ipkg.setPackage( item->text() ); 942 ipkg.setPackage( item->text() );
924 ipkg.runIpkg( ); 943 ipkg.runIpkg( );
925 } 944 }
926 } 945 }
927} 946}
928 947
929void MainWindow :: downloadRemotePackage() 948void MainWindow :: downloadRemotePackage()
930{ 949{
931 // Display dialog 950 // Display dialog
932 bool ok; 951 bool ok;
933 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); 952 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
934 if ( !ok || package.isEmpty() ) 953 if ( !ok || package.isEmpty() )
935 return; 954 return;
936// DownloadRemoteDlgImpl dlg( this, "Install", true ); 955// DownloadRemoteDlgImpl dlg( this, "Install", true );
937// if ( dlg.exec() == QDialog::Rejected ) 956// if ( dlg.exec() == QDialog::Rejected )
938// return; 957// return;
939 958
940 // grab details from dialog 959 // grab details from dialog
941// QString package = dlg.getPackageLocation(); 960// QString package = dlg.getPackageLocation();
942 961
943 InstallData *item = new InstallData(); 962 InstallData *item = new InstallData();
944 item->option = "I"; 963 item->option = "I";
945 item->packageName = package; 964 item->packageName = package;
946 QList<InstallData> workingPackages; 965 QList<InstallData> workingPackages;
947 workingPackages.setAutoDelete( TRUE ); 966 workingPackages.setAutoDelete( TRUE );
948 workingPackages.append( item ); 967 workingPackages.append( item );
949 968
950 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); 969 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) );
951 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 970 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
952 dlg->showMaximized(); 971 stack->addWidget( dlg, 3 );
972 stack->raiseWidget( dlg );
953} 973}
954 974
955 975
956void MainWindow :: applyChanges() 976void MainWindow :: applyChanges()
957{ 977{
958 stickyOption = ""; 978 stickyOption = "";
959 979
960 // First, write out ipkg_conf file so that ipkg can use it 980 // First, write out ipkg_conf file so that ipkg can use it
961 mgr->writeOutIpkgConf(); 981 mgr->writeOutIpkgConf();
962 982
963 // Now for each selected item 983 // Now for each selected item
964 // deal with it 984 // deal with it
965 985
966 QList<InstallData> workingPackages; 986 QList<InstallData> workingPackages;
967 workingPackages.setAutoDelete( TRUE ); 987 workingPackages.setAutoDelete( TRUE );
968 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 988 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
969 item != 0 ; 989 item != 0 ;
970 item = (QCheckListItem *)item->nextSibling() ) 990 item = (QCheckListItem *)item->nextSibling() )
971 { 991 {
972 if ( item->isOn() ) 992 if ( item->isOn() )
973 { 993 {
974 workingPackages.append( dealWithItem( item ) ); 994 workingPackages.append( dealWithItem( item ) );
975 } 995 }
976 } 996 }
977 997
978 if ( workingPackages.count() == 0 ) 998 if ( workingPackages.count() == 0 )
979 { 999 {
980 // Nothing to do 1000 // Nothing to do
981 QMessageBox::information( this, tr( "Nothing to do" ), 1001 QMessageBox::information( this, tr( "Nothing to do" ),
982 tr( "No packages selected" ), tr( "OK" ) ); 1002 tr( "No packages selected" ), tr( "OK" ) );
983 1003
984 return; 1004 return;
985 } 1005 }
986 1006
987 // do the stuff 1007 // do the stuff
988 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); 1008 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) );
989 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 1009 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
990 dlg->showMaximized(); 1010 stack->addWidget( dlg, 3 );
1011 stack->raiseWidget( dlg );
991} 1012}
992 1013
993// decide what to do - either remove, upgrade or install 1014// decide what to do - either remove, upgrade or install
994// Current rules: 1015// Current rules:
995// If not installed - install 1016// If not installed - install
996// If installed and different version available - upgrade 1017// If installed and different version available - upgrade
997// If installed and version up to date - remove 1018// If installed and version up to date - remove
998InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) 1019InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
999{ 1020{
1000 QString name = item->text(); 1021 QString name = item->text();
1001 1022
1002 // Get package 1023 // Get package
1003 Server *s = mgr->getServer( serversList->currentText() ); 1024 Server *s = mgr->getServer( serversList->currentText() );
1004 Package *p = s->getPackage( name ); 1025 Package *p = s->getPackage( name );
1005 1026
1006 // If the package has a filename then it is a local file 1027 // If the package has a filename then it is a local file
1007 if ( p->isPackageStoredLocally() ) 1028 if ( p->isPackageStoredLocally() )
1008 name = p->getFilename(); 1029 name = p->getFilename();
1009 1030
1010 QString option; 1031 QString option;
1011 QString dest = "root"; 1032 QString dest = "root";
1012 if ( !p->isInstalled() ) 1033 if ( !p->isInstalled() )
1013 { 1034 {
1014 InstallData *newitem = new InstallData();; 1035 InstallData *newitem = new InstallData();;
1015 newitem->option = "I"; 1036 newitem->option = "I";
1016 newitem->packageName = name; 1037 newitem->packageName = name;
1017 return newitem; 1038 return newitem;
1018 } 1039 }
1019 else 1040 else
1020 { 1041 {
1021 InstallData *newitem = new InstallData();; 1042 InstallData *newitem = new InstallData();;
1022 newitem->option = "D"; 1043 newitem->option = "D";
1023 if ( !p->isPackageStoredLocally() ) 1044 if ( !p->isPackageStoredLocally() )
1024 newitem->packageName = p->getInstalledPackageName(); 1045 newitem->packageName = p->getInstalledPackageName();
1025 else 1046 else
1026 newitem->packageName = name; 1047 newitem->packageName = name;
1027 1048
1028 if ( p->getInstalledTo() ) 1049 if ( p->getInstalledTo() )
1029 { 1050 {
1030 newitem->destination = p->getInstalledTo(); 1051 newitem->destination = p->getInstalledTo();
1031// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; 1052// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
1032// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; 1053// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
1033 } 1054 }
1034 else 1055 else
1035 { 1056 {
1036 newitem->destination = p->getLocalPackage()->getInstalledTo(); 1057 newitem->destination = p->getLocalPackage()->getInstalledTo();
1037 } 1058 }
1038 1059
1039 // Now see if version is newer or not 1060 // Now see if version is newer or not
1040 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 1061 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
1041 1062
1042 // If the version requested is older and user selected a local ipk file, then reinstall the file 1063 // If the version requested is older and user selected a local ipk file, then reinstall the file
1043 if ( p->isPackageStoredLocally() && val == -1 ) 1064 if ( p->isPackageStoredLocally() && val == -1 )
1044 val = 0; 1065 val = 0;
1045 1066
1046 if ( val == -2 ) 1067 if ( val == -2 )
1047 { 1068 {
1048 // Error - should handle 1069 // Error - should handle
1049 } 1070 }
1050 else if ( val == -1 ) 1071 else if ( val == -1 )
1051 { 1072 {
1052 // Version available is older - remove only 1073 // Version available is older - remove only
1053 newitem->option = "D"; 1074 newitem->option = "D";
1054 } 1075 }
1055 else 1076 else
1056 { 1077 {
1057 QString caption; 1078 QString caption;
1058 QString text; 1079 QString text;
1059 QString secondButton; 1080 QString secondButton;
1060 QString secondOption; 1081 QString secondOption;
1061 if ( val == 0 ) 1082 if ( val == 0 )
1062 { 1083 {
1063 // Version available is the same - option to remove or reinstall 1084 // Version available is the same - option to remove or reinstall
1064 caption = tr( "Do you wish to remove or reinstall\n%1?" ); 1085 caption = tr( "Do you wish to remove or reinstall\n%1?" );
1065 text = tr( "Remove or ReInstall" ); 1086 text = tr( "Remove or ReInstall" );
1066 secondButton = tr( "ReInstall" ); 1087 secondButton = tr( "ReInstall" );
1067 secondOption = tr( "R" ); 1088 secondOption = tr( "R" );
1068 } 1089 }
1069 else if ( val == 1 ) 1090 else if ( val == 1 )
1070 { 1091 {
1071 // Version available is newer - option to remove or upgrade 1092 // Version available is newer - option to remove or upgrade
1072 caption = tr( "Do you wish to remove or upgrade\n%1?" ); 1093 caption = tr( "Do you wish to remove or upgrade\n%1?" );
1073 text = tr( "Remove or Upgrade" ); 1094 text = tr( "Remove or Upgrade" );
1074 secondButton = tr( "Upgrade" ); 1095 secondButton = tr( "Upgrade" );
1075 secondOption = tr( "U" ); 1096 secondOption = tr( "U" );
1076 } 1097 }
1077 1098
1078 // Sticky option not implemented yet, but will eventually allow 1099 // Sticky option not implemented yet, but will eventually allow
1079 // the user to say something like 'remove all' 1100 // the user to say something like 'remove all'
1080 if ( stickyOption == "" ) 1101 if ( stickyOption == "" )
1081 { 1102 {
1082 QString msgtext; 1103 QString msgtext;
1083 msgtext = caption.arg( ( const char * )name ); 1104 msgtext = caption.arg( ( const char * )name );
1084 switch( QMessageBox::information( this, text, 1105 switch( QMessageBox::information( this, text,
1085 msgtext, tr( "Remove" ), secondButton ) ) 1106 msgtext, tr( "Remove" ), secondButton ) )
1086 { 1107 {
1087 case 0: // Try again or Enter 1108 case 0: // Try again or Enter
1088 // option 0 = Remove 1109 // option 0 = Remove
1089 newitem->option = "D"; 1110 newitem->option = "D";
1090 break; 1111 break;
1091 case 1: // Quit or Escape 1112 case 1: // Quit or Escape
1092 newitem->option = secondOption; 1113 newitem->option = secondOption;
1093 break; 1114 break;
1094 } 1115 }
1095 } 1116 }
1096 else 1117 else
1097 { 1118 {
1098// newitem->option = stickyOption; 1119// newitem->option = stickyOption;
1099 } 1120 }
1100 } 1121 }
1101 1122
1102 1123
1103 // Check if we are reinstalling the same version 1124 // Check if we are reinstalling the same version
1104 if ( newitem->option != "R" ) 1125 if ( newitem->option != "R" )
1105 newitem->recreateLinks = true; 1126 newitem->recreateLinks = true;
1106 else 1127 else
1107 newitem->recreateLinks = false; 1128 newitem->recreateLinks = false;
1108 1129
1109 // User hit cancel (on dlg - assume remove) 1130 // User hit cancel (on dlg - assume remove)
1110 return newitem; 1131 return newitem;
1111 } 1132 }
1112} 1133}
1113 1134
1114void MainWindow :: reloadData( InstallDlgImpl *dlg ) 1135void MainWindow :: reloadData( InstallDlgImpl *dlg )
1115{ 1136{
1116 stack->raiseWidget( progressWindow ); 1137 stack->raiseWidget( progressWindow );
1117 1138
1118 if ( dlg ) 1139 if ( dlg )
1119 { 1140 {
1120 dlg->close(); 1141 dlg->close();
1121 delete dlg; 1142 delete dlg;
1122 } 1143 }
1123 1144
1124 mgr->reloadServerData(); 1145 mgr->reloadServerData();
1125 serverSelected( -1, FALSE ); 1146 serverSelected( -1, FALSE );
1126 1147
1127#ifdef QWS 1148#ifdef QWS
1128 m_status->setText( tr( "Updating Launcher..." ) ); 1149 m_status->setText( tr( "Updating Launcher..." ) );
1129 1150
1130 // Finally let the main system update itself 1151 // Finally let the main system update itself
1131 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 1152 QCopEnvelope e("QPE/System", "linkChanged(QString)");
1132 QString lf = QString::null; 1153 QString lf = QString::null;
1133 e << lf; 1154 e << lf;
1134#endif 1155#endif
1135 1156
1136 stack->raiseWidget( networkPkgWindow ); 1157 stack->raiseWidget( networkPkgWindow );
1137} 1158}
1138 1159
1139void MainWindow :: letterPushed( QString t ) 1160void MainWindow :: letterPushed( QString t )
1140{ 1161{
1141 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); 1162 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
1142 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 1163 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
1143 if ( packagesList->firstChild() == 0 ) 1164 if ( packagesList->firstChild() == 0 )
1144 return; 1165 return;
1145 1166
1146 QCheckListItem *item; 1167 QCheckListItem *item;
1147 if ( start == 0 ) 1168 if ( start == 0 )
1148 { 1169 {
1149 item = (QCheckListItem *)packagesList->firstChild(); 1170 item = (QCheckListItem *)packagesList->firstChild();
1150 start = top; 1171 start = top;
1151 } 1172 }
1152 else 1173 else
1153 item = (QCheckListItem *)start->nextSibling(); 1174 item = (QCheckListItem *)start->nextSibling();
1154 1175
1155 if ( item == 0 ) 1176 if ( item == 0 )
1156 item = (QCheckListItem *)packagesList->firstChild(); 1177 item = (QCheckListItem *)packagesList->firstChild();
1157 do 1178 do
1158 { 1179 {
1159 if ( item->text().lower().startsWith( t.lower() ) ) 1180 if ( item->text().lower().startsWith( t.lower() ) )
1160 { 1181 {
1161 packagesList->setSelected( item, true ); 1182 packagesList->setSelected( item, true );
1162 packagesList->ensureItemVisible( item ); 1183 packagesList->ensureItemVisible( item );
1163 break; 1184 break;
1164 } 1185 }
1165 1186
1166 item = (QCheckListItem *)item->nextSibling(); 1187 item = (QCheckListItem *)item->nextSibling();
1167 if ( !item ) 1188 if ( !item )
1168 item = (QCheckListItem *)packagesList->firstChild(); 1189 item = (QCheckListItem *)packagesList->firstChild();
1169 } while ( item != start); 1190 } while ( item != start);
1170} 1191}
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index d75e5d2..b2de871 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -1,136 +1,139 @@
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 <qpixmap.h> 22#include <qpixmap.h>
23 23
24class DataManager; 24class DataManager;
25class InstallData; 25class InstallData;
26class InstallDlgImpl; 26class InstallDlgImpl;
27 27
28class QAction; 28class QAction;
29class QCheckListItem; 29class QCheckListItem;
30class QComboBox; 30class QComboBox;
31class QLabel; 31class QLabel;
32class QLineEdit; 32class QLineEdit;
33class QListView; 33class QListView;
34class QPEToolBar; 34class QPEToolBar;
35class QProgressBar; 35class QProgressBar;
36class QWidgetStack; 36class QWidgetStack;
37 37
38class MainWindow :public QMainWindow 38class MainWindow :public QMainWindow
39{ 39{
40 Q_OBJECT 40 Q_OBJECT
41public: 41public:
42 42
43 MainWindow(); 43 MainWindow();
44 ~MainWindow(); 44 ~MainWindow();
45 45
46protected:
47 void closeEvent( QCloseEvent* e );
48
46private: 49private:
47 DataManager *mgr; 50 DataManager *mgr;
48 51
49 QWidgetStack *stack; 52 QWidgetStack *stack;
50 53
51 QPEToolBar *findBar; 54 QPEToolBar *findBar;
52 QPEToolBar *jumpBar; 55 QPEToolBar *jumpBar;
53 QLineEdit *findEdit; 56 QLineEdit *findEdit;
54 QAction *actionFindNext; 57 QAction *actionFindNext;
55 QAction *actionFilter; 58 QAction *actionFilter;
56 QAction *actionUpgrade; 59 QAction *actionUpgrade;
57 QAction *actionDownload; 60 QAction *actionDownload;
58 QAction *actionUninstalled; 61 QAction *actionUninstalled;
59 QAction *actionInstalled; 62 QAction *actionInstalled;
60 QAction *actionUpdated; 63 QAction *actionUpdated;
61 64
62 QPixmap iconDownload; 65 QPixmap iconDownload;
63 QPixmap iconRemove; 66 QPixmap iconRemove;
64 67
65 int mnuShowUninstalledPkgsId; 68 int mnuShowUninstalledPkgsId;
66 int mnuShowInstalledPkgsId; 69 int mnuShowInstalledPkgsId;
67 int mnuShowUpgradedPkgsId; 70 int mnuShowUpgradedPkgsId;
68 int mnuFilterByCategory; 71 int mnuFilterByCategory;
69 int mnuSetFilterCategory; 72 int mnuSetFilterCategory;
70 73
71 // Main package list widget 74 // Main package list widget
72 QWidget *networkPkgWindow; 75 QWidget *networkPkgWindow;
73 QComboBox *serversList; 76 QComboBox *serversList;
74 QListView *packagesList; 77 QListView *packagesList;
75 QPixmap installedIcon; 78 QPixmap installedIcon;
76 QPixmap updatedIcon; 79 QPixmap updatedIcon;
77 QString currentlySelectedServer; 80 QString currentlySelectedServer;
78 QString categoryFilter; 81 QString categoryFilter;
79 QString stickyOption; 82 QString stickyOption;
80 83
81 bool categoryFilterEnabled; 84 bool categoryFilterEnabled;
82 bool showJumpTo; 85 bool showJumpTo;
83 bool showUninstalledPkgs; 86 bool showUninstalledPkgs;
84 bool showInstalledPkgs; 87 bool showInstalledPkgs;
85 bool showUpgradedPkgs; 88 bool showUpgradedPkgs;
86 bool downloadEnabled; 89 bool downloadEnabled;
87 90
88 void initMainWidget(); 91 void initMainWidget();
89 void updateData(); 92 void updateData();
90 void serverSelected( int index, bool showProgress ); 93 void serverSelected( int index, bool showProgress );
91 void searchForPackage( const QString & ); 94 void searchForPackage( const QString & );
92 bool filterByCategory( bool val ); 95 bool filterByCategory( bool val );
93 void downloadSelectedPackages(); 96 void downloadSelectedPackages();
94 void downloadRemotePackage(); 97 void downloadRemotePackage();
95 InstallData *dealWithItem( QCheckListItem *item ); 98 InstallData *dealWithItem( QCheckListItem *item );
96 99
97 // Progress widget 100 // Progress widget
98 QWidget *progressWindow; 101 QWidget *progressWindow;
99 QLabel *m_status; 102 QLabel *m_status;
100 QProgressBar *m_progress; 103 QProgressBar *m_progress;
101 104
102 void initProgressWidget(); 105 void initProgressWidget();
103 106
104public slots: 107public slots:
105// void setDocument( const QString &doc ); 108// void setDocument( const QString &doc );
106 void displayFindBar(); 109 void displayFindBar();
107 void displayJumpBar(); 110 void displayJumpBar();
108 void repeatFind(); 111 void repeatFind();
109 void findPackage( const QString & ); 112 void findPackage( const QString & );
110 void hideFindBar(); 113 void hideFindBar();
111 void hideJumpBar(); 114 void hideJumpBar();
112 void displaySettings(); 115 void displaySettings();
113 void filterUninstalledPackages(); 116 void filterUninstalledPackages();
114 void filterInstalledPackages(); 117 void filterInstalledPackages();
115 void filterUpgradedPackages(); 118 void filterUpgradedPackages();
116 void filterCategory(); 119 void filterCategory();
117 bool setFilterCategory(); 120 bool setFilterCategory();
118 void raiseMainWidget(); 121 void raiseMainWidget();
119 void raiseProgressWidget(); 122 void raiseProgressWidget();
120 void enableUpgrade( bool ); 123 void enableUpgrade( bool );
121 void enableDownload( bool ); 124 void enableDownload( bool );
122 void reloadData( InstallDlgImpl * ); 125 void reloadData( InstallDlgImpl * );
123 126
124private slots: 127private slots:
125 void init(); 128 void init();
126 void setProgressSteps( int ); 129 void setProgressSteps( int );
127 void setProgressMessage( const QString & ); 130 void setProgressMessage( const QString & );
128 void updateProgress( int ); 131 void updateProgress( int );
129 void serverSelected( int index ); 132 void serverSelected( int index );
130 void updateServer(); 133 void updateServer();
131 void upgradePackages(); 134 void upgradePackages();
132 void downloadPackage(); 135 void downloadPackage();
133 void applyChanges(); 136 void applyChanges();
134 void letterPushed( QString t ); 137 void letterPushed( QString t );
135}; 138};
136#endif 139#endif