author | kergoth <kergoth> | 2003-02-18 18:28:18 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-02-18 18:28:18 (UTC) |
commit | 50f0a50a14f87960cf9492d01aeed5a56a6dca06 (patch) (unidiff) | |
tree | 4c922e0fbdc815aba671c09975e56d77140b2c30 | |
parent | f8226f95152e53948b064303b5dc6513ece222aa (diff) | |
download | opie-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.
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 10 |
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,107 +1,111 @@ | |||
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 | enum { | ||
45 | MAXLINES = 100, | ||
46 | }; | ||
47 | |||
44 | InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title ) | 48 | InstallDlgImpl::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 | { |
@@ -258,98 +262,104 @@ void InstallDlgImpl :: installSelected() | |||
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 | ||
319 | void InstallDlgImpl :: displayText(const QString &text ) | 323 | void 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 | ||
327 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) | 337 | void 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 | ||