author | drw <drw> | 2003-02-06 01:19:25 (UTC) |
---|---|---|
committer | drw <drw> | 2003-02-06 01:19:25 (UTC) |
commit | 79588befde53765db0a92977c6890a4d226096e7 (patch) (unidiff) | |
tree | 83b6dd14c49733b9759fad04147bf0bee50793fe /noncore/settings/aqpkg/installdlgimpl.cpp | |
parent | bbb3690f12191763a407e6a0edd521113b3c25ac (diff) | |
download | opie-79588befde53765db0a92977c6890a4d226096e7.zip opie-79588befde53765db0a92977c6890a4d226096e7.tar.gz opie-79588befde53765db0a92977c6890a4d226096e7.tar.bz2 |
Change all vector<> to QList<>. First step in removing dependency on libstdc++.
Diffstat (limited to 'noncore/settings/aqpkg/installdlgimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 84 |
1 files changed, 47 insertions, 37 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 | |||
@@ -1,345 +1,355 @@ | |||
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 | ||
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" ); |
60 | 59 | ||
61 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) | 60 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) |
62 | flags = cfg.readNumEntry( "installFlags", 0 ); | 61 | flags = cfg.readNumEntry( "installFlags", 0 ); |
63 | #else | 62 | #else |
64 | flags = 0; | 63 | flags = 0; |
65 | #endif | 64 | #endif |
66 | 65 | ||
67 | // Output text is read only | 66 | // Output text is read only |
68 | output->setReadOnly( true ); | 67 | output->setReadOnly( true ); |
69 | //QFont f( "helvetica" ); | 68 | //QFont f( "helvetica" ); |
70 | //f.setPointSize( 10 ); | 69 | //f.setPointSize( 10 ); |
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 ) |
122 | : QWidget( 0, 0, 0 ) | 128 | : QWidget( 0, 0, 0 ) |
123 | { | 129 | { |
124 | setCaption( title ); | 130 | setCaption( title ); |
125 | init( FALSE ); | 131 | init( FALSE ); |
126 | pIpkg = ipkg; | 132 | pIpkg = ipkg; |
127 | output->setText( initialText ); | 133 | output->setText( initialText ); |
128 | } | 134 | } |
129 | 135 | ||
130 | 136 | ||
131 | InstallDlgImpl::~InstallDlgImpl() | 137 | InstallDlgImpl::~InstallDlgImpl() |
132 | { | 138 | { |
133 | if ( pIpkg ) | 139 | if ( pIpkg ) |
134 | delete pIpkg; | 140 | delete pIpkg; |
135 | } | 141 | } |
136 | 142 | ||
137 | void InstallDlgImpl :: init( bool displayextrainfo ) | 143 | void InstallDlgImpl :: init( bool displayextrainfo ) |
138 | { | 144 | { |
139 | QGridLayout *layout = new QGridLayout( this ); | 145 | QGridLayout *layout = new QGridLayout( this ); |
140 | layout->setSpacing( 4 ); | 146 | layout->setSpacing( 4 ); |
141 | layout->setMargin( 4 ); | 147 | layout->setMargin( 4 ); |
142 | 148 | ||
143 | if ( displayextrainfo ) | 149 | if ( displayextrainfo ) |
144 | { | 150 | { |
145 | QLabel *label = new QLabel( tr( "Destination" ), this ); | 151 | QLabel *label = new QLabel( tr( "Destination" ), this ); |
146 | layout->addWidget( label, 0, 0 ); | 152 | layout->addWidget( label, 0, 0 ); |
147 | destination = new QComboBox( FALSE, this ); | 153 | destination = new QComboBox( FALSE, this ); |
148 | layout->addWidget( destination, 0, 1 ); | 154 | layout->addWidget( destination, 0, 1 ); |
149 | connect( destination, SIGNAL( highlighted( const QString & ) ), | 155 | connect( destination, SIGNAL( highlighted( const QString & ) ), |
150 | this, SLOT( displayAvailableSpace( const QString & ) ) ); | 156 | this, SLOT( displayAvailableSpace( const QString & ) ) ); |
151 | 157 | ||
152 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); | 158 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); |
153 | layout->addWidget( label2, 1, 0 ); | 159 | layout->addWidget( label2, 1, 0 ); |
154 | txtAvailableSpace = new QLabel( "", this ); | 160 | txtAvailableSpace = new QLabel( "", this ); |
155 | layout->addWidget( txtAvailableSpace, 1, 1 ); | 161 | layout->addWidget( txtAvailableSpace, 1, 1 ); |
156 | } | 162 | } |
157 | else | 163 | else |
158 | { | 164 | { |
159 | destination = 0x0; | 165 | destination = 0x0; |
160 | txtAvailableSpace = 0x0; | 166 | txtAvailableSpace = 0x0; |
161 | } | 167 | } |
162 | 168 | ||
163 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | 169 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); |
164 | GroupBox2->layout()->setSpacing( 0 ); | 170 | GroupBox2->layout()->setSpacing( 0 ); |
165 | GroupBox2->layout()->setMargin( 4 ); | 171 | GroupBox2->layout()->setMargin( 4 ); |
166 | 172 | ||
167 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); | 173 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); |
168 | output = new QMultiLineEdit( GroupBox2 ); | 174 | output = new QMultiLineEdit( GroupBox2 ); |
169 | GroupBox2Layout->addWidget( output ); | 175 | GroupBox2Layout->addWidget( output ); |
170 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); | 176 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); |
171 | 177 | ||
172 | btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); | 178 | btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); |
173 | layout->addWidget( btnInstall, 3, 0 ); | 179 | layout->addWidget( btnInstall, 3, 0 ); |
174 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); | 180 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); |
175 | 181 | ||
176 | btnOptions = new QPushButton( Resource::loadPixmap( "aqpkg/config" ), tr( "Options" ), this ); | 182 | btnOptions = new QPushButton( Resource::loadPixmap( "aqpkg/config" ), tr( "Options" ), this ); |
177 | layout->addWidget( btnOptions, 3, 1 ); | 183 | layout->addWidget( btnOptions, 3, 1 ); |
178 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); | 184 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); |
179 | } | 185 | } |
180 | 186 | ||
181 | void InstallDlgImpl :: optionsSelected() | 187 | void InstallDlgImpl :: optionsSelected() |
182 | { | 188 | { |
183 | InstallOptionsDlgImpl opt( flags, this, "Option", true ); | 189 | InstallOptionsDlgImpl opt( flags, this, "Option", true ); |
184 | opt.exec(); | 190 | opt.exec(); |
185 | 191 | ||
186 | // set options selected from dialog | 192 | // set options selected from dialog |
187 | flags = opt.getFlags(); | 193 | flags = opt.getFlags(); |
188 | 194 | ||
189 | #ifdef QWS | 195 | #ifdef QWS |
190 | Config cfg( "aqpkg" ); | 196 | Config cfg( "aqpkg" ); |
191 | cfg.setGroup( "settings" ); | 197 | cfg.setGroup( "settings" ); |
192 | cfg.writeEntry( "installFlags", flags ); | 198 | cfg.writeEntry( "installFlags", flags ); |
193 | #endif | 199 | #endif |
194 | } | 200 | } |
195 | 201 | ||
196 | void InstallDlgImpl :: installSelected() | 202 | void InstallDlgImpl :: installSelected() |
197 | { | 203 | { |
198 | if ( btnInstall->text() == tr( "Abort" ) ) | 204 | if ( btnInstall->text() == tr( "Abort" ) ) |
199 | { | 205 | { |
200 | if ( pIpkg ) | 206 | if ( pIpkg ) |
201 | { | 207 | { |
202 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); | 208 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); |
203 | pIpkg->abort(); | 209 | pIpkg->abort(); |
204 | displayText( tr( "**** Process Aborted ****" ) ); | 210 | displayText( tr( "**** Process Aborted ****" ) ); |
205 | } | 211 | } |
206 | 212 | ||
207 | btnInstall->setText( tr( "Close" ) ); | 213 | btnInstall->setText( tr( "Close" ) ); |
208 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); | 214 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); |
209 | return; | 215 | return; |
210 | } | 216 | } |
211 | else if ( btnInstall->text() == tr( "Close" ) ) | 217 | else if ( btnInstall->text() == tr( "Close" ) ) |
212 | { | 218 | { |
213 | emit reloadData( this ); | 219 | emit reloadData( this ); |
214 | return; | 220 | return; |
215 | } | 221 | } |
216 | 222 | ||
217 | // Disable buttons | 223 | // Disable buttons |
218 | btnOptions->setEnabled( false ); | 224 | btnOptions->setEnabled( false ); |
219 | // btnInstall->setEnabled( false ); | 225 | // btnInstall->setEnabled( false ); |
220 | 226 | ||
221 | btnInstall->setText( tr( "Abort" ) ); | 227 | btnInstall->setText( tr( "Abort" ) ); |
222 | btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); | 228 | btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); |
223 | if ( pIpkg ) | 229 | if ( pIpkg ) |
224 | { | 230 | { |
225 | output->setText( "" ); | 231 | output->setText( "" ); |
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 | ||
239 | #ifdef QWS | 245 | #ifdef QWS |
240 | // Save settings | 246 | // Save settings |
241 | Config cfg( "aqpkg" ); | 247 | Config cfg( "aqpkg" ); |
242 | cfg.setGroup( "settings" ); | 248 | cfg.setGroup( "settings" ); |
243 | cfg.writeEntry( "dest", dest ); | 249 | cfg.writeEntry( "dest", dest ); |
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; |
295 | pIpkg = 0; | 306 | pIpkg = 0; |
296 | } | 307 | } |
297 | 308 | ||
298 | btnOptions->setEnabled( true ); | 309 | btnOptions->setEnabled( true ); |
299 | // btnInstall->setEnabled( true ); | 310 | // btnInstall->setEnabled( true ); |
300 | btnInstall->setText( tr( "Close" ) ); | 311 | btnInstall->setText( tr( "Close" ) ); |
301 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); | 312 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); |
302 | 313 | ||
303 | if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) | 314 | if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) |
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; |
326 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) | 336 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) |
327 | { | 337 | { |
328 | long mult = blockSize / 1024; | 338 | long mult = blockSize / 1024; |
329 | long div = 1024 / blockSize; | 339 | long div = 1024 / blockSize; |
330 | 340 | ||
331 | if ( !mult ) mult = 1; | 341 | if ( !mult ) mult = 1; |
332 | if ( !div ) div = 1; | 342 | if ( !div ) div = 1; |
333 | // long total = totalBlocks * mult / div; | 343 | // long total = totalBlocks * mult / div; |
334 | long avail = availBlocks * mult / div; | 344 | long avail = availBlocks * mult / div; |
335 | // long used = total - avail; | 345 | // long used = total - avail; |
336 | 346 | ||
337 | space.sprintf( "%ld Kb", avail ); | 347 | space.sprintf( "%ld Kb", avail ); |
338 | } | 348 | } |
339 | else | 349 | else |
340 | space = tr( "Unknown" ); | 350 | space = tr( "Unknown" ); |
341 | 351 | ||
342 | if ( txtAvailableSpace ) | 352 | if ( txtAvailableSpace ) |
343 | txtAvailableSpace->setText( space ); | 353 | txtAvailableSpace->setText( space ); |
344 | } | 354 | } |
345 | 355 | ||