summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-02-18 18:28:18 (UTC)
committer kergoth <kergoth>2003-02-18 18:28:18 (UTC)
commit50f0a50a14f87960cf9492d01aeed5a56a6dca06 (patch) (unidiff)
tree4c922e0fbdc815aba671c09975e56d77140b2c30
parentf8226f95152e53948b064303b5dc6513ece222aa (diff)
downloadopie-50f0a50a14f87960cf9492d01aeed5a56a6dca06.zip
opie-50f0a50a14f87960cf9492d01aeed5a56a6dca06.tar.gz
opie-50f0a50a14f87960cf9492d01aeed5a56a6dca06.tar.bz2
Use a max line count on the QMultiLineEdit used for ipkg output, as users have reported performance issues when the line count gets huge.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index 9339086..1f0bb5f 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -1,355 +1,365 @@
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 {
45 MAXLINES = 100,
46};
47
44InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title ) 48InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title )
45 : QWidget( 0, 0, 0 ) 49 : QWidget( 0, 0, 0 )
46{ 50{
47 setCaption( title ); 51 setCaption( title );
48 init( TRUE ); 52 init( TRUE );
49 53
50 pIpkg = 0; 54 pIpkg = 0;
51 upgradePackages = false; 55 upgradePackages = false;
52 dataMgr = dataManager; 56 dataMgr = dataManager;
53 57
54 QString defaultDest = "root"; 58 QString defaultDest = "root";
55#ifdef QWS 59#ifdef QWS
56 Config cfg( "aqpkg" ); 60 Config cfg( "aqpkg" );
57 cfg.setGroup( "settings" ); 61 cfg.setGroup( "settings" );
58 defaultDest = cfg.readEntry( "dest", "root" ); 62 defaultDest = cfg.readEntry( "dest", "root" );
59 63
60 // 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)
61 flags = cfg.readNumEntry( "installFlags", 0 ); 65 flags = cfg.readNumEntry( "installFlags", 0 );
62#else 66#else
63 flags = 0; 67 flags = 0;
64#endif 68#endif
65 69
66 // Output text is read only 70 // Output text is read only
67 output->setReadOnly( true ); 71 output->setReadOnly( true );
68 //QFont f( "helvetica" ); 72 //QFont f( "helvetica" );
69 //f.setPointSize( 10 ); 73 //f.setPointSize( 10 );
70 //output->setFont( f ); 74 //output->setFont( f );
71 75
72 76
73 // setup destination data 77 // setup destination data
74 int defIndex = 0; 78 int defIndex = 0;
75 int i; 79 int i;
76 QListIterator<Destination> dit( dataMgr->getDestinationList() ); 80 QListIterator<Destination> dit( dataMgr->getDestinationList() );
77 for ( i = 0; dit.current(); ++dit, ++i ) 81 for ( i = 0; dit.current(); ++dit, ++i )
78 { 82 {
79 destination->insertItem( dit.current()->getDestinationName() ); 83 destination->insertItem( dit.current()->getDestinationName() );
80 if ( dit.current()->getDestinationName() == defaultDest ) 84 if ( dit.current()->getDestinationName() == defaultDest )
81 defIndex = i; 85 defIndex = i;
82 } 86 }
83 87
84 destination->setCurrentItem( defIndex ); 88 destination->setCurrentItem( defIndex );
85 89
86 QListIterator<InstallData> it( packageList ); 90 QListIterator<InstallData> it( packageList );
87 // setup package data 91 // setup package data
88 QString remove = tr( "Remove\n" ); 92 QString remove = tr( "Remove\n" );
89 QString install = tr( "Install\n" ); 93 QString install = tr( "Install\n" );
90 QString upgrade = tr( "Upgrade\n" ); 94 QString upgrade = tr( "Upgrade\n" );
91 for ( ; it.current(); ++it ) 95 for ( ; it.current(); ++it )
92 { 96 {
93 InstallData *item = it.current(); 97 InstallData *item = it.current();
94 InstallData *newitem = new InstallData(); 98 InstallData *newitem = new InstallData();
95 99
96 newitem->option = item->option; 100 newitem->option = item->option;
97 newitem->packageName = item->packageName; 101 newitem->packageName = item->packageName;
98 newitem->destination = item->destination; 102 newitem->destination = item->destination;
99 newitem->recreateLinks = item->recreateLinks; 103 newitem->recreateLinks = item->recreateLinks;
100 104
101 if ( item->option == "I" ) 105 if ( item->option == "I" )
102 { 106 {
103 installList.append( newitem ); 107 installList.append( newitem );
104 install.append( QString( " %1\n" ).arg( item->packageName ) ); 108 install.append( QString( " %1\n" ).arg( item->packageName ) );
105 } 109 }
106 else if ( item->option == "D" ) 110 else if ( item->option == "D" )
107 { 111 {
108 removeList.append( newitem ); 112 removeList.append( newitem );
109 remove.append( QString( " %1\n" ).arg( item->packageName ) ); 113 remove.append( QString( " %1\n" ).arg( item->packageName ) );
110 } 114 }
111 else if ( item->option == "U" || item->option == "R" ) 115 else if ( item->option == "U" || item->option == "R" )
112 { 116 {
113 updateList.append( newitem ); 117 updateList.append( newitem );
114 QString type; 118 QString type;
115 if ( item->option == "R" ) 119 if ( item->option == "R" )
116 type = tr( "(ReInstall)" ); 120 type = tr( "(ReInstall)" );
117 else 121 else
118 type = tr( "(Upgrade)" ); 122 type = tr( "(Upgrade)" );
119 upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); 123 upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) );
120 } 124 }
121 } 125 }
122 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 ) );
123 127
124 displayAvailableSpace( destination->currentText() ); 128 displayAvailableSpace( destination->currentText() );
125} 129}
126 130
127InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) 131InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title )
128 : QWidget( 0, 0, 0 ) 132 : QWidget( 0, 0, 0 )
129{ 133{
130 setCaption( title ); 134 setCaption( title );
131 init( FALSE ); 135 init( FALSE );
132 pIpkg = ipkg; 136 pIpkg = ipkg;
133 output->setText( initialText ); 137 output->setText( initialText );
134} 138}
135 139
136 140
137InstallDlgImpl::~InstallDlgImpl() 141InstallDlgImpl::~InstallDlgImpl()
138{ 142{
139 if ( pIpkg ) 143 if ( pIpkg )
140 delete pIpkg; 144 delete pIpkg;
141} 145}
142 146
143void InstallDlgImpl :: init( bool displayextrainfo ) 147void InstallDlgImpl :: init( bool displayextrainfo )
144{ 148{
145 QGridLayout *layout = new QGridLayout( this ); 149 QGridLayout *layout = new QGridLayout( this );
146 layout->setSpacing( 4 ); 150 layout->setSpacing( 4 );
147 layout->setMargin( 4 ); 151 layout->setMargin( 4 );
148 152
149 if ( displayextrainfo ) 153 if ( displayextrainfo )
150 { 154 {
151 QLabel *label = new QLabel( tr( "Destination" ), this ); 155 QLabel *label = new QLabel( tr( "Destination" ), this );
152 layout->addWidget( label, 0, 0 ); 156 layout->addWidget( label, 0, 0 );
153 destination = new QComboBox( FALSE, this ); 157 destination = new QComboBox( FALSE, this );
154 layout->addWidget( destination, 0, 1 ); 158 layout->addWidget( destination, 0, 1 );
155 connect( destination, SIGNAL( highlighted( const QString & ) ), 159 connect( destination, SIGNAL( highlighted( const QString & ) ),
156 this, SLOT( displayAvailableSpace( const QString & ) ) ); 160 this, SLOT( displayAvailableSpace( const QString & ) ) );
157 161
158 QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); 162 QLabel *label2 = new QLabel( tr( "Space Avail" ), this );
159 layout->addWidget( label2, 1, 0 ); 163 layout->addWidget( label2, 1, 0 );
160 txtAvailableSpace = new QLabel( "", this ); 164 txtAvailableSpace = new QLabel( "", this );
161 layout->addWidget( txtAvailableSpace, 1, 1 ); 165 layout->addWidget( txtAvailableSpace, 1, 1 );
162 } 166 }
163 else 167 else
164 { 168 {
165 destination = 0x0; 169 destination = 0x0;
166 txtAvailableSpace = 0x0; 170 txtAvailableSpace = 0x0;
167 } 171 }
168 172
169 QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); 173 QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
170 GroupBox2->layout()->setSpacing( 0 ); 174 GroupBox2->layout()->setSpacing( 0 );
171 GroupBox2->layout()->setMargin( 4 ); 175 GroupBox2->layout()->setMargin( 4 );
172 176
173 QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); 177 QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() );
174 output = new QMultiLineEdit( GroupBox2 ); 178 output = new QMultiLineEdit( GroupBox2 );
175 GroupBox2Layout->addWidget( output ); 179 GroupBox2Layout->addWidget( output );
176 layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); 180 layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 );
177 181
178 btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); 182 btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this );
179 layout->addWidget( btnInstall, 3, 0 ); 183 layout->addWidget( btnInstall, 3, 0 );
180 connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); 184 connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) );
181 185
182 btnOptions = new QPushButton( Resource::loadPixmap( "aqpkg/config" ), tr( "Options" ), this ); 186 btnOptions = new QPushButton( Resource::loadPixmap( "aqpkg/config" ), tr( "Options" ), this );
183 layout->addWidget( btnOptions, 3, 1 ); 187 layout->addWidget( btnOptions, 3, 1 );
184 connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); 188 connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) );
185} 189}
186 190
187void InstallDlgImpl :: optionsSelected() 191void InstallDlgImpl :: optionsSelected()
188{ 192{
189 InstallOptionsDlgImpl opt( flags, this, "Option", true ); 193 InstallOptionsDlgImpl opt( flags, this, "Option", true );
190 opt.exec(); 194 opt.exec();
191 195
192 // set options selected from dialog 196 // set options selected from dialog
193 flags = opt.getFlags(); 197 flags = opt.getFlags();
194 198
195#ifdef QWS 199#ifdef QWS
196 Config cfg( "aqpkg" ); 200 Config cfg( "aqpkg" );
197 cfg.setGroup( "settings" ); 201 cfg.setGroup( "settings" );
198 cfg.writeEntry( "installFlags", flags ); 202 cfg.writeEntry( "installFlags", flags );
199#endif 203#endif
200} 204}
201 205
202void InstallDlgImpl :: installSelected() 206void InstallDlgImpl :: installSelected()
203{ 207{
204 if ( btnInstall->text() == tr( "Abort" ) ) 208 if ( btnInstall->text() == tr( "Abort" ) )
205 { 209 {
206 if ( pIpkg ) 210 if ( pIpkg )
207 { 211 {
208 displayText( tr( "\n**** User Clicked ABORT ***" ) ); 212 displayText( tr( "\n**** User Clicked ABORT ***" ) );
209 pIpkg->abort(); 213 pIpkg->abort();
210 displayText( tr( "**** Process Aborted ****" ) ); 214 displayText( tr( "**** Process Aborted ****" ) );
211 } 215 }
212 216
213 btnInstall->setText( tr( "Close" ) ); 217 btnInstall->setText( tr( "Close" ) );
214 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); 218 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
215 return; 219 return;
216 } 220 }
217 else if ( btnInstall->text() == tr( "Close" ) ) 221 else if ( btnInstall->text() == tr( "Close" ) )
218 { 222 {
219 emit reloadData( this ); 223 emit reloadData( this );
220 return; 224 return;
221 } 225 }
222 226
223 // Disable buttons 227 // Disable buttons
224 btnOptions->setEnabled( false ); 228 btnOptions->setEnabled( false );
225// btnInstall->setEnabled( false ); 229// btnInstall->setEnabled( false );
226 230
227 btnInstall->setText( tr( "Abort" ) ); 231 btnInstall->setText( tr( "Abort" ) );
228 btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); 232 btnInstall->setIconSet( Resource::loadPixmap( "close" ) );
229 if ( pIpkg ) 233 if ( pIpkg )
230 { 234 {
231 output->setText( "" ); 235 output->setText( "" );
232 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 236 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
233 pIpkg->runIpkg(); 237 pIpkg->runIpkg();
234 } 238 }
235 else 239 else
236 { 240 {
237 output->setText( "" ); 241 output->setText( "" );
238 Destination *d = dataMgr->getDestination( destination->currentText() ); 242 Destination *d = dataMgr->getDestination( destination->currentText() );
239 QString dest = d->getDestinationName(); 243 QString dest = d->getDestinationName();
240 QString destDir = d->getDestinationPath(); 244 QString destDir = d->getDestinationPath();
241 int instFlags = flags; 245 int instFlags = flags;
242 if ( d->linkToRoot() ) 246 if ( d->linkToRoot() )
243 instFlags |= MAKE_LINKS; 247 instFlags |= MAKE_LINKS;
244 248
245#ifdef QWS 249#ifdef QWS
246 // Save settings 250 // Save settings
247 Config cfg( "aqpkg" ); 251 Config cfg( "aqpkg" );
248 cfg.setGroup( "settings" ); 252 cfg.setGroup( "settings" );
249 cfg.writeEntry( "dest", dest ); 253 cfg.writeEntry( "dest", dest );
250#endif 254#endif
251 255
252 pIpkg = new Ipkg; 256 pIpkg = new Ipkg;
253 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 257 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
254 258
255 // First run through the remove list, then the install list then the upgrade list 259 // First run through the remove list, then the install list then the upgrade list
256 pIpkg->setOption( "remove" ); 260 pIpkg->setOption( "remove" );
257 QListIterator<InstallData> it( removeList ); 261 QListIterator<InstallData> it( removeList );
258 InstallData *idata; 262 InstallData *idata;
259 for ( ; it.current(); ++it ) 263 for ( ; it.current(); ++it )
260 { 264 {
261 idata = it.current(); 265 idata = it.current();
262 pIpkg->setDestination( idata->destination->getDestinationName() ); 266 pIpkg->setDestination( idata->destination->getDestinationName() );
263 pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); 267 pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
264 pIpkg->setPackage( idata->packageName ); 268 pIpkg->setPackage( idata->packageName );
265 269
266 int tmpFlags = flags; 270 int tmpFlags = flags;
267 if ( idata->destination->linkToRoot() ) 271 if ( idata->destination->linkToRoot() )
268 tmpFlags |= MAKE_LINKS; 272 tmpFlags |= MAKE_LINKS;
269 273
270 pIpkg->setFlags( tmpFlags ); 274 pIpkg->setFlags( tmpFlags );
271 pIpkg->runIpkg(); 275 pIpkg->runIpkg();
272 } 276 }
273 277
274 pIpkg->setOption( "install" ); 278 pIpkg->setOption( "install" );
275 pIpkg->setDestination( dest ); 279 pIpkg->setDestination( dest );
276 pIpkg->setDestinationDir( destDir ); 280 pIpkg->setDestinationDir( destDir );
277 pIpkg->setFlags( instFlags ); 281 pIpkg->setFlags( instFlags );
278 QListIterator<InstallData> it2( installList ); 282 QListIterator<InstallData> it2( installList );
279 for ( ; it2.current(); ++it2 ) 283 for ( ; it2.current(); ++it2 )
280 { 284 {
281 pIpkg->setPackage( it2.current()->packageName ); 285 pIpkg->setPackage( it2.current()->packageName );
282 pIpkg->runIpkg(); 286 pIpkg->runIpkg();
283 } 287 }
284 288
285 flags |= FORCE_REINSTALL; 289 flags |= FORCE_REINSTALL;
286 QListIterator<InstallData> it3( updateList ); 290 QListIterator<InstallData> it3( updateList );
287 for ( ; it3.current() ; ++it3 ) 291 for ( ; it3.current() ; ++it3 )
288 { 292 {
289 idata = it3.current(); 293 idata = it3.current();
290 if ( idata->option == "R" ) 294 if ( idata->option == "R" )
291 pIpkg->setOption( "reinstall" ); 295 pIpkg->setOption( "reinstall" );
292 else 296 else
293 pIpkg->setOption( "upgrade" ); 297 pIpkg->setOption( "upgrade" );
294 pIpkg->setDestination( idata->destination->getDestinationName() ); 298 pIpkg->setDestination( idata->destination->getDestinationName() );
295 pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); 299 pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
296 pIpkg->setPackage( idata->packageName ); 300 pIpkg->setPackage( idata->packageName );
297 301
298 int tmpFlags = flags; 302 int tmpFlags = flags;
299 if ( idata->destination->linkToRoot() && idata->recreateLinks ) 303 if ( idata->destination->linkToRoot() && idata->recreateLinks )
300 tmpFlags |= MAKE_LINKS; 304 tmpFlags |= MAKE_LINKS;
301 pIpkg->setFlags( tmpFlags ); 305 pIpkg->setFlags( tmpFlags );
302 pIpkg->runIpkg(); 306 pIpkg->runIpkg();
303 } 307 }
304 308
305 delete pIpkg; 309 delete pIpkg;
306 pIpkg = 0; 310 pIpkg = 0;
307 } 311 }
308 312
309 btnOptions->setEnabled( true ); 313 btnOptions->setEnabled( true );
310// btnInstall->setEnabled( true ); 314// btnInstall->setEnabled( true );
311 btnInstall->setText( tr( "Close" ) ); 315 btnInstall->setText( tr( "Close" ) );
312 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); 316 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
313 317
314 if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) 318 if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
315 displayAvailableSpace( destination->currentText() ); 319 displayAvailableSpace( destination->currentText() );
316} 320}
317 321
318 322
319void InstallDlgImpl :: displayText(const QString &text ) 323void InstallDlgImpl :: displayText(const QString &text )
320{ 324{
321 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); 325 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text );
326
327 /* Set a max line count for the QMultiLineEdit, as users have reported
328 * performance issues when line count gets extreme.
329 */
330 if(output->numLines() >= MAXLINES)
331 output->removeLine(0);
322 output->setText( newtext ); 332 output->setText( newtext );
323 output->setCursorPosition( output->numLines(), 0 ); 333 output->setCursorPosition( output->numLines(), 0 );
324} 334}
325 335
326 336
327void InstallDlgImpl :: displayAvailableSpace( const QString &text ) 337void InstallDlgImpl :: displayAvailableSpace( const QString &text )
328{ 338{
329 Destination *d = dataMgr->getDestination( text ); 339 Destination *d = dataMgr->getDestination( text );
330 QString destDir = d->getDestinationPath(); 340 QString destDir = d->getDestinationPath();
331 341
332 long blockSize = 0; 342 long blockSize = 0;
333 long totalBlocks = 0; 343 long totalBlocks = 0;
334 long availBlocks = 0; 344 long availBlocks = 0;
335 QString space; 345 QString space;
336 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) 346 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) )
337 { 347 {
338 long mult = blockSize / 1024; 348 long mult = blockSize / 1024;
339 long div = 1024 / blockSize; 349 long div = 1024 / blockSize;
340 350
341 if ( !mult ) mult = 1; 351 if ( !mult ) mult = 1;
342 if ( !div ) div = 1; 352 if ( !div ) div = 1;
343// long total = totalBlocks * mult / div; 353// long total = totalBlocks * mult / div;
344 long avail = availBlocks * mult / div; 354 long avail = availBlocks * mult / div;
345// long used = total - avail; 355// long used = total - avail;
346 356
347 space.sprintf( "%ld Kb", avail ); 357 space.sprintf( "%ld Kb", avail );
348 } 358 }
349 else 359 else
350 space = tr( "Unknown" ); 360 space = tr( "Unknown" );
351 361
352 if ( txtAvailableSpace ) 362 if ( txtAvailableSpace )
353 txtAvailableSpace->setText( space ); 363 txtAvailableSpace->setText( space );
354} 364}
355 365