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
@@ -12,64 +12,68 @@
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;
@@ -290,64 +294,70 @@ void InstallDlgImpl :: installSelected()
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 );