Diffstat (limited to 'noncore/settings/aqpkg/installdlgimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 82 |
1 files changed, 46 insertions, 36 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index 19fe46a..9339086 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp | |||
@@ -38,22 +38,21 @@ | |||
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 | ||
44 | InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title ) | 44 | InstallDlgImpl::InstallDlgImpl( QList<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; | ||
54 | 53 | ||
55 | QString defaultDest = "root"; | 54 | QString defaultDest = "root"; |
56 | #ifdef QWS | 55 | #ifdef QWS |
57 | Config cfg( "aqpkg" ); | 56 | Config cfg( "aqpkg" ); |
58 | cfg.setGroup( "settings" ); | 57 | cfg.setGroup( "settings" ); |
59 | defaultDest = cfg.readEntry( "dest", "root" ); | 58 | defaultDest = cfg.readEntry( "dest", "root" ); |
@@ -71,51 +70,58 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d | |||
71 | //output->setFont( f ); | 70 | //output->setFont( f ); |
72 | 71 | ||
73 | 72 | ||
74 | // setup destination data | 73 | // setup destination data |
75 | int defIndex = 0; | 74 | int defIndex = 0; |
76 | int i; | 75 | int i; |
77 | for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i ) | 76 | QListIterator<Destination> dit( dataMgr->getDestinationList() ); |
77 | for ( i = 0; dit.current(); ++dit, ++i ) | ||
78 | { | 78 | { |
79 | destination->insertItem( dit->getDestinationName() ); | 79 | destination->insertItem( dit.current()->getDestinationName() ); |
80 | if ( dit->getDestinationName() == defaultDest ) | 80 | if ( dit.current()->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 | QListIterator<InstallData> it( packageList ); |
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.current(); ++it ) |
92 | { | 92 | { |
93 | InstallData item = *it; | 93 | InstallData *item = it.current(); |
94 | if ( item.option == "I" ) | 94 | InstallData *newitem = new InstallData(); |
95 | |||
96 | newitem->option = item->option; | ||
97 | newitem->packageName = item->packageName; | ||
98 | newitem->destination = item->destination; | ||
99 | newitem->recreateLinks = item->recreateLinks; | ||
100 | |||
101 | if ( item->option == "I" ) | ||
95 | { | 102 | { |
96 | installList.push_back( item ); | 103 | installList.append( newitem ); |
97 | install.append( QString( " %1\n" ).arg( item.packageName ) ); | 104 | install.append( QString( " %1\n" ).arg( item->packageName ) ); |
98 | } | 105 | } |
99 | else if ( item.option == "D" ) | 106 | else if ( item->option == "D" ) |
100 | { | 107 | { |
101 | removeList.push_back( item ); | 108 | removeList.append( newitem ); |
102 | remove.append( QString( " %1\n" ).arg( item.packageName ) ); | 109 | remove.append( QString( " %1\n" ).arg( item->packageName ) ); |
103 | } | 110 | } |
104 | else if ( item.option == "U" || item.option == "R" ) | 111 | else if ( item->option == "U" || item->option == "R" ) |
105 | { | 112 | { |
106 | updateList.push_back( item ); | 113 | updateList.append( newitem ); |
107 | QString type; | 114 | QString type; |
108 | if ( item.option == "R" ) | 115 | if ( item->option == "R" ) |
109 | type = tr( "(ReInstall)" ); | 116 | type = tr( "(ReInstall)" ); |
110 | else | 117 | else |
111 | type = tr( "(Upgrade)" ); | 118 | type = tr( "(Upgrade)" ); |
112 | upgrade.append( QString( " %1 %2\n" ).arg( item.packageName ).arg( type ) ); | 119 | upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); |
113 | } | 120 | } |
114 | } | 121 | } |
115 | |||
116 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); | 122 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); |
117 | 123 | ||
118 | displayAvailableSpace( destination->currentText() ); | 124 | displayAvailableSpace( destination->currentText() ); |
119 | } | 125 | } |
120 | 126 | ||
121 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) | 127 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) |
@@ -226,13 +232,13 @@ void InstallDlgImpl :: installSelected() | |||
226 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 232 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
227 | pIpkg->runIpkg(); | 233 | pIpkg->runIpkg(); |
228 | } | 234 | } |
229 | else | 235 | else |
230 | { | 236 | { |
231 | output->setText( "" ); | 237 | output->setText( "" ); |
232 | vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() ); | 238 | Destination *d = dataMgr->getDestination( destination->currentText() ); |
233 | QString dest = d->getDestinationName(); | 239 | QString dest = d->getDestinationName(); |
234 | QString destDir = d->getDestinationPath(); | 240 | QString destDir = d->getDestinationPath(); |
235 | int instFlags = flags; | 241 | int instFlags = flags; |
236 | if ( d->linkToRoot() ) | 242 | if ( d->linkToRoot() ) |
237 | instFlags |= MAKE_LINKS; | 243 | instFlags |= MAKE_LINKS; |
238 | 244 | ||
@@ -244,51 +250,56 @@ void InstallDlgImpl :: installSelected() | |||
244 | #endif | 250 | #endif |
245 | 251 | ||
246 | pIpkg = new Ipkg; | 252 | pIpkg = new Ipkg; |
247 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 253 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
248 | 254 | ||
249 | // First run through the remove list, then the install list then the upgrade list | 255 | // First run through the remove list, then the install list then the upgrade list |
250 | vector<InstallData>::iterator it; | ||
251 | pIpkg->setOption( "remove" ); | 256 | pIpkg->setOption( "remove" ); |
252 | for ( it = removeList.begin() ; it != removeList.end() ; ++it ) | 257 | QListIterator<InstallData> it( removeList ); |
258 | InstallData *idata; | ||
259 | for ( ; it.current(); ++it ) | ||
253 | { | 260 | { |
254 | pIpkg->setDestination( it->destination->getDestinationName() ); | 261 | idata = it.current(); |
255 | pIpkg->setDestinationDir( it->destination->getDestinationPath() ); | 262 | pIpkg->setDestination( idata->destination->getDestinationName() ); |
256 | pIpkg->setPackage( it->packageName ); | 263 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); |
264 | pIpkg->setPackage( idata->packageName ); | ||
257 | 265 | ||
258 | int tmpFlags = flags; | 266 | int tmpFlags = flags; |
259 | if ( it->destination->linkToRoot() ) | 267 | if ( idata->destination->linkToRoot() ) |
260 | tmpFlags |= MAKE_LINKS; | 268 | tmpFlags |= MAKE_LINKS; |
261 | 269 | ||
262 | pIpkg->setFlags( tmpFlags ); | 270 | pIpkg->setFlags( tmpFlags ); |
263 | pIpkg->runIpkg(); | 271 | pIpkg->runIpkg(); |
264 | } | 272 | } |
265 | 273 | ||
266 | pIpkg->setOption( "install" ); | 274 | pIpkg->setOption( "install" ); |
267 | pIpkg->setDestination( dest ); | 275 | pIpkg->setDestination( dest ); |
268 | pIpkg->setDestinationDir( destDir ); | 276 | pIpkg->setDestinationDir( destDir ); |
269 | pIpkg->setFlags( instFlags ); | 277 | pIpkg->setFlags( instFlags ); |
270 | for ( it = installList.begin() ; it != installList.end() ; ++it ) | 278 | QListIterator<InstallData> it2( installList ); |
279 | for ( ; it2.current(); ++it2 ) | ||
271 | { | 280 | { |
272 | pIpkg->setPackage( it->packageName ); | 281 | pIpkg->setPackage( it2.current()->packageName ); |
273 | pIpkg->runIpkg(); | 282 | pIpkg->runIpkg(); |
274 | } | 283 | } |
275 | 284 | ||
276 | flags |= FORCE_REINSTALL; | 285 | flags |= FORCE_REINSTALL; |
277 | for ( it = updateList.begin() ; it != updateList.end() ; ++it ) | 286 | QListIterator<InstallData> it3( updateList ); |
287 | for ( ; it3.current() ; ++it3 ) | ||
278 | { | 288 | { |
279 | if ( it->option == "R" ) | 289 | idata = it3.current(); |
290 | if ( idata->option == "R" ) | ||
280 | pIpkg->setOption( "reinstall" ); | 291 | pIpkg->setOption( "reinstall" ); |
281 | else | 292 | else |
282 | pIpkg->setOption( "upgrade" ); | 293 | pIpkg->setOption( "upgrade" ); |
283 | pIpkg->setDestination( it->destination->getDestinationName() ); | 294 | pIpkg->setDestination( idata->destination->getDestinationName() ); |
284 | pIpkg->setDestinationDir( it->destination->getDestinationPath() ); | 295 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); |
285 | pIpkg->setPackage( it->packageName ); | 296 | pIpkg->setPackage( idata->packageName ); |
286 | 297 | ||
287 | int tmpFlags = flags; | 298 | int tmpFlags = flags; |
288 | if ( it->destination->linkToRoot() && it->recreateLinks ) | 299 | if ( idata->destination->linkToRoot() && idata->recreateLinks ) |
289 | tmpFlags |= MAKE_LINKS; | 300 | tmpFlags |= MAKE_LINKS; |
290 | pIpkg->setFlags( tmpFlags ); | 301 | pIpkg->setFlags( tmpFlags ); |
291 | pIpkg->runIpkg(); | 302 | pIpkg->runIpkg(); |
292 | } | 303 | } |
293 | 304 | ||
294 | delete pIpkg; | 305 | delete pIpkg; |
@@ -304,22 +315,21 @@ void InstallDlgImpl :: installSelected() | |||
304 | displayAvailableSpace( destination->currentText() ); | 315 | displayAvailableSpace( destination->currentText() ); |
305 | } | 316 | } |
306 | 317 | ||
307 | 318 | ||
308 | void InstallDlgImpl :: displayText(const QString &text ) | 319 | void InstallDlgImpl :: displayText(const QString &text ) |
309 | { | 320 | { |
310 | //output->setText( QString( "%1\n%2" ).arg( output->text() ).arg( text ) ); | ||
311 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); | 321 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); |
312 | output->setText( newtext ); | 322 | output->setText( newtext ); |
313 | output->setCursorPosition( output->numLines(), 0 ); | 323 | output->setCursorPosition( output->numLines(), 0 ); |
314 | } | 324 | } |
315 | 325 | ||
316 | 326 | ||
317 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) | 327 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) |
318 | { | 328 | { |
319 | vector<Destination>::iterator d = dataMgr->getDestination( text ); | 329 | Destination *d = dataMgr->getDestination( text ); |
320 | QString destDir = d->getDestinationPath(); | 330 | QString destDir = d->getDestinationPath(); |
321 | 331 | ||
322 | long blockSize = 0; | 332 | long blockSize = 0; |
323 | long totalBlocks = 0; | 333 | long totalBlocks = 0; |
324 | long availBlocks = 0; | 334 | long availBlocks = 0; |
325 | QString space; | 335 | QString space; |