summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index 65aaa32..19fe46a 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -1,313 +1,313 @@
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
44InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title = 0 ) 44InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title )
45 : QWidget( 0, 0, 0 ) 45 : QWidget( 0, 0, 0 )
46{ 46{
47 setCaption( title ); 47 setCaption( title );
48 init( TRUE ); 48 init( TRUE );
49 49
50 pIpkg = 0; 50 pIpkg = 0;
51 upgradePackages = false; 51 upgradePackages = false;
52 dataMgr = dataManager; 52 dataMgr = dataManager;
53 vector<Destination>::iterator dit; 53 vector<Destination>::iterator dit;
54 54
55 QString defaultDest = "root"; 55 QString defaultDest = "root";
56#ifdef QWS 56#ifdef QWS
57 Config cfg( "aqpkg" ); 57 Config cfg( "aqpkg" );
58 cfg.setGroup( "settings" ); 58 cfg.setGroup( "settings" );
59 defaultDest = cfg.readEntry( "dest", "root" ); 59 defaultDest = cfg.readEntry( "dest", "root" );
60 60
61 // Grab flags - Turn MAKE_LINKS on by default (if no flags found) 61 // Grab flags - Turn MAKE_LINKS on by default (if no flags found)
62 flags = cfg.readNumEntry( "installFlags", 0 ); 62 flags = cfg.readNumEntry( "installFlags", 0 );
63#else 63#else
64 flags = 0; 64 flags = 0;
65#endif 65#endif
66 66
67 // Output text is read only 67 // Output text is read only
68 output->setReadOnly( true ); 68 output->setReadOnly( true );
69 //QFont f( "helvetica" ); 69 //QFont f( "helvetica" );
70 //f.setPointSize( 10 ); 70 //f.setPointSize( 10 );
71 //output->setFont( f ); 71 //output->setFont( f );
72 72
73 73
74 // setup destination data 74 // setup destination data
75 int defIndex = 0; 75 int defIndex = 0;
76 int i; 76 int i;
77 for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i ) 77 for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i )
78 { 78 {
79 destination->insertItem( dit->getDestinationName() ); 79 destination->insertItem( dit->getDestinationName() );
80 if ( dit->getDestinationName() == defaultDest ) 80 if ( dit->getDestinationName() == defaultDest )
81 defIndex = i; 81 defIndex = i;
82 } 82 }
83 83
84 destination->setCurrentItem( defIndex ); 84 destination->setCurrentItem( defIndex );
85 85
86 vector<InstallData>::iterator it; 86 vector<InstallData>::iterator it;
87 // setup package data 87 // setup package data
88 QString remove = tr( "Remove\n" ); 88 QString remove = tr( "Remove\n" );
89 QString install = tr( "Install\n" ); 89 QString install = tr( "Install\n" );
90 QString upgrade = tr( "Upgrade\n" ); 90 QString upgrade = tr( "Upgrade\n" );
91 for ( it = packageList.begin() ; it != packageList.end() ; ++it ) 91 for ( it = packageList.begin() ; it != packageList.end() ; ++it )
92 { 92 {
93 InstallData item = *it; 93 InstallData item = *it;
94 if ( item.option == "I" ) 94 if ( item.option == "I" )
95 { 95 {
96 installList.push_back( item ); 96 installList.push_back( item );
97 install.append( QString( " %1\n" ).arg( item.packageName ) ); 97 install.append( QString( " %1\n" ).arg( item.packageName ) );
98 } 98 }
99 else if ( item.option == "D" ) 99 else if ( item.option == "D" )
100 { 100 {
101 removeList.push_back( item ); 101 removeList.push_back( item );
102 remove.append( QString( " %1\n" ).arg( item.packageName ) ); 102 remove.append( QString( " %1\n" ).arg( item.packageName ) );
103 } 103 }
104 else if ( item.option == "U" || item.option == "R" ) 104 else if ( item.option == "U" || item.option == "R" )
105 { 105 {
106 updateList.push_back( item ); 106 updateList.push_back( item );
107 QString type; 107 QString type;
108 if ( item.option == "R" ) 108 if ( item.option == "R" )
109 type = tr( "(ReInstall)" ); 109 type = tr( "(ReInstall)" );
110 else 110 else
111 type = tr( "(Upgrade)" ); 111 type = tr( "(Upgrade)" );
112 upgrade.append( QString( " %1 %2\n" ).arg( item.packageName ).arg( type ) ); 112 upgrade.append( QString( " %1 %2\n" ).arg( item.packageName ).arg( type ) );
113 } 113 }
114 } 114 }
115 115
116 output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); 116 output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
117 117
118 displayAvailableSpace( destination->currentText() ); 118 displayAvailableSpace( destination->currentText() );
119} 119}
120 120
121InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 ) 121InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title )
122 : QWidget( 0, 0, 0 ) 122 : QWidget( 0, 0, 0 )
123{ 123{
124 setCaption( title ); 124 setCaption( title );
125 init( FALSE ); 125 init( FALSE );
126 pIpkg = ipkg; 126 pIpkg = ipkg;
127 output->setText( initialText ); 127 output->setText( initialText );
128} 128}
129 129
130 130
131InstallDlgImpl::~InstallDlgImpl() 131InstallDlgImpl::~InstallDlgImpl()
132{ 132{
133 if ( pIpkg ) 133 if ( pIpkg )
134 delete pIpkg; 134 delete pIpkg;
135} 135}
136 136
137void InstallDlgImpl :: init( bool displayextrainfo ) 137void InstallDlgImpl :: init( bool displayextrainfo )
138{ 138{
139 QGridLayout *layout = new QGridLayout( this ); 139 QGridLayout *layout = new QGridLayout( this );
140 layout->setSpacing( 4 ); 140 layout->setSpacing( 4 );
141 layout->setMargin( 4 ); 141 layout->setMargin( 4 );
142 142
143 if ( displayextrainfo ) 143 if ( displayextrainfo )
144 { 144 {
145 QLabel *label = new QLabel( tr( "Destination" ), this ); 145 QLabel *label = new QLabel( tr( "Destination" ), this );
146 layout->addWidget( label, 0, 0 ); 146 layout->addWidget( label, 0, 0 );
147 destination = new QComboBox( FALSE, this ); 147 destination = new QComboBox( FALSE, this );
148 layout->addWidget( destination, 0, 1 ); 148 layout->addWidget( destination, 0, 1 );
149 connect( destination, SIGNAL( highlighted( const QString & ) ), 149 connect( destination, SIGNAL( highlighted( const QString & ) ),
150 this, SLOT( displayAvailableSpace( const QString & ) ) ); 150 this, SLOT( displayAvailableSpace( const QString & ) ) );
151 151
152 QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); 152 QLabel *label2 = new QLabel( tr( "Space Avail" ), this );
153 layout->addWidget( label2, 1, 0 ); 153 layout->addWidget( label2, 1, 0 );
154 txtAvailableSpace = new QLabel( "", this ); 154 txtAvailableSpace = new QLabel( "", this );
155 layout->addWidget( txtAvailableSpace, 1, 1 ); 155 layout->addWidget( txtAvailableSpace, 1, 1 );
156 } 156 }
157 else 157 else
158 { 158 {
159 destination = 0x0; 159 destination = 0x0;
160 txtAvailableSpace = 0x0; 160 txtAvailableSpace = 0x0;
161 } 161 }
162 162
163 QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); 163 QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
164 GroupBox2->layout()->setSpacing( 0 ); 164 GroupBox2->layout()->setSpacing( 0 );
165 GroupBox2->layout()->setMargin( 4 ); 165 GroupBox2->layout()->setMargin( 4 );
166 166
167 QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); 167 QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() );
168 output = new QMultiLineEdit( GroupBox2 ); 168 output = new QMultiLineEdit( GroupBox2 );
169 GroupBox2Layout->addWidget( output ); 169 GroupBox2Layout->addWidget( output );
170 layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); 170 layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 );
171 171
172 btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); 172 btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this );
173 layout->addWidget( btnInstall, 3, 0 ); 173 layout->addWidget( btnInstall, 3, 0 );
174 connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); 174 connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) );
175 175
176 btnOptions = new QPushButton( Resource::loadPixmap( "aqpkg/config" ), tr( "Options" ), this ); 176 btnOptions = new QPushButton( Resource::loadPixmap( "aqpkg/config" ), tr( "Options" ), this );
177 layout->addWidget( btnOptions, 3, 1 ); 177 layout->addWidget( btnOptions, 3, 1 );
178 connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); 178 connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) );
179} 179}
180 180
181void InstallDlgImpl :: optionsSelected() 181void InstallDlgImpl :: optionsSelected()
182{ 182{
183 InstallOptionsDlgImpl opt( flags, this, "Option", true ); 183 InstallOptionsDlgImpl opt( flags, this, "Option", true );
184 opt.exec(); 184 opt.exec();
185 185
186 // set options selected from dialog 186 // set options selected from dialog
187 flags = opt.getFlags(); 187 flags = opt.getFlags();
188 188
189#ifdef QWS 189#ifdef QWS
190 Config cfg( "aqpkg" ); 190 Config cfg( "aqpkg" );
191 cfg.setGroup( "settings" ); 191 cfg.setGroup( "settings" );
192 cfg.writeEntry( "installFlags", flags ); 192 cfg.writeEntry( "installFlags", flags );
193#endif 193#endif
194} 194}
195 195
196void InstallDlgImpl :: installSelected() 196void InstallDlgImpl :: installSelected()
197{ 197{
198 if ( btnInstall->text() == tr( "Abort" ) ) 198 if ( btnInstall->text() == tr( "Abort" ) )
199 { 199 {
200 if ( pIpkg ) 200 if ( pIpkg )
201 { 201 {
202 displayText( tr( "\n**** User Clicked ABORT ***" ) ); 202 displayText( tr( "\n**** User Clicked ABORT ***" ) );
203 pIpkg->abort(); 203 pIpkg->abort();
204 displayText( tr( "**** Process Aborted ****" ) ); 204 displayText( tr( "**** Process Aborted ****" ) );
205 } 205 }
206 206
207 btnInstall->setText( tr( "Close" ) ); 207 btnInstall->setText( tr( "Close" ) );
208 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); 208 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
209 return; 209 return;
210 } 210 }
211 else if ( btnInstall->text() == tr( "Close" ) ) 211 else if ( btnInstall->text() == tr( "Close" ) )
212 { 212 {
213 emit reloadData( this ); 213 emit reloadData( this );
214 return; 214 return;
215 } 215 }
216 216
217 // Disable buttons 217 // Disable buttons
218 btnOptions->setEnabled( false ); 218 btnOptions->setEnabled( false );
219// btnInstall->setEnabled( false ); 219// btnInstall->setEnabled( false );
220 220
221 btnInstall->setText( tr( "Abort" ) ); 221 btnInstall->setText( tr( "Abort" ) );
222 btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); 222 btnInstall->setIconSet( Resource::loadPixmap( "close" ) );
223 if ( pIpkg ) 223 if ( pIpkg )
224 { 224 {
225 output->setText( "" ); 225 output->setText( "" );
226 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 226 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
227 pIpkg->runIpkg(); 227 pIpkg->runIpkg();
228 } 228 }
229 else 229 else
230 { 230 {
231 output->setText( "" ); 231 output->setText( "" );
232 vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() ); 232 vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() );
233 QString dest = d->getDestinationName(); 233 QString dest = d->getDestinationName();
234 QString destDir = d->getDestinationPath(); 234 QString destDir = d->getDestinationPath();
235 int instFlags = flags; 235 int instFlags = flags;
236 if ( d->linkToRoot() ) 236 if ( d->linkToRoot() )
237 instFlags |= MAKE_LINKS; 237 instFlags |= MAKE_LINKS;
238 238
239#ifdef QWS 239#ifdef QWS
240 // Save settings 240 // Save settings
241 Config cfg( "aqpkg" ); 241 Config cfg( "aqpkg" );
242 cfg.setGroup( "settings" ); 242 cfg.setGroup( "settings" );
243 cfg.writeEntry( "dest", dest ); 243 cfg.writeEntry( "dest", dest );
244#endif 244#endif
245 245
246 pIpkg = new Ipkg; 246 pIpkg = new Ipkg;
247 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 247 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
248 248
249 // First run through the remove list, then the install list then the upgrade list 249 // First run through the remove list, then the install list then the upgrade list
250 vector<InstallData>::iterator it; 250 vector<InstallData>::iterator it;
251 pIpkg->setOption( "remove" ); 251 pIpkg->setOption( "remove" );
252 for ( it = removeList.begin() ; it != removeList.end() ; ++it ) 252 for ( it = removeList.begin() ; it != removeList.end() ; ++it )
253 { 253 {
254 pIpkg->setDestination( it->destination->getDestinationName() ); 254 pIpkg->setDestination( it->destination->getDestinationName() );
255 pIpkg->setDestinationDir( it->destination->getDestinationPath() ); 255 pIpkg->setDestinationDir( it->destination->getDestinationPath() );
256 pIpkg->setPackage( it->packageName ); 256 pIpkg->setPackage( it->packageName );
257 257
258 int tmpFlags = flags; 258 int tmpFlags = flags;
259 if ( it->destination->linkToRoot() ) 259 if ( it->destination->linkToRoot() )
260 tmpFlags |= MAKE_LINKS; 260 tmpFlags |= MAKE_LINKS;
261 261
262 pIpkg->setFlags( tmpFlags ); 262 pIpkg->setFlags( tmpFlags );
263 pIpkg->runIpkg(); 263 pIpkg->runIpkg();
264 } 264 }
265 265
266 pIpkg->setOption( "install" ); 266 pIpkg->setOption( "install" );
267 pIpkg->setDestination( dest ); 267 pIpkg->setDestination( dest );
268 pIpkg->setDestinationDir( destDir ); 268 pIpkg->setDestinationDir( destDir );
269 pIpkg->setFlags( instFlags ); 269 pIpkg->setFlags( instFlags );
270 for ( it = installList.begin() ; it != installList.end() ; ++it ) 270 for ( it = installList.begin() ; it != installList.end() ; ++it )
271 { 271 {
272 pIpkg->setPackage( it->packageName ); 272 pIpkg->setPackage( it->packageName );
273 pIpkg->runIpkg(); 273 pIpkg->runIpkg();
274 } 274 }
275 275
276 flags |= FORCE_REINSTALL; 276 flags |= FORCE_REINSTALL;
277 for ( it = updateList.begin() ; it != updateList.end() ; ++it ) 277 for ( it = updateList.begin() ; it != updateList.end() ; ++it )
278 { 278 {
279 if ( it->option == "R" ) 279 if ( it->option == "R" )
280 pIpkg->setOption( "reinstall" ); 280 pIpkg->setOption( "reinstall" );
281 else 281 else
282 pIpkg->setOption( "upgrade" ); 282 pIpkg->setOption( "upgrade" );
283 pIpkg->setDestination( it->destination->getDestinationName() ); 283 pIpkg->setDestination( it->destination->getDestinationName() );
284 pIpkg->setDestinationDir( it->destination->getDestinationPath() ); 284 pIpkg->setDestinationDir( it->destination->getDestinationPath() );
285 pIpkg->setPackage( it->packageName ); 285 pIpkg->setPackage( it->packageName );
286 286
287 int tmpFlags = flags; 287 int tmpFlags = flags;
288 if ( it->destination->linkToRoot() && it->recreateLinks ) 288 if ( it->destination->linkToRoot() && it->recreateLinks )
289 tmpFlags |= MAKE_LINKS; 289 tmpFlags |= MAKE_LINKS;
290 pIpkg->setFlags( tmpFlags ); 290 pIpkg->setFlags( tmpFlags );
291 pIpkg->runIpkg(); 291 pIpkg->runIpkg();
292 } 292 }
293 293
294 delete pIpkg; 294 delete pIpkg;
295 pIpkg = 0; 295 pIpkg = 0;
296 } 296 }
297 297
298 btnOptions->setEnabled( true ); 298 btnOptions->setEnabled( true );
299// btnInstall->setEnabled( true ); 299// btnInstall->setEnabled( true );
300 btnInstall->setText( tr( "Close" ) ); 300 btnInstall->setText( tr( "Close" ) );
301 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); 301 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
302 302
303 if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) 303 if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
304 displayAvailableSpace( destination->currentText() ); 304 displayAvailableSpace( destination->currentText() );
305} 305}
306 306
307 307
308void InstallDlgImpl :: displayText(const QString &text ) 308void InstallDlgImpl :: displayText(const QString &text )
309{ 309{
310 //output->setText( QString( "%1\n%2" ).arg( output->text() ).arg( text ) ); 310 //output->setText( QString( "%1\n%2" ).arg( output->text() ).arg( text ) );
311 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); 311 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text );
312 output->setText( newtext ); 312 output->setText( newtext );
313 output->setCursorPosition( output->numLines(), 0 ); 313 output->setCursorPosition( output->numLines(), 0 );