[KPhotoAlbum] Performance issues
Robert L Krawitz
rlk at alum.mit.edu
Sat Feb 11 20:45:54 GMT 2006
From: "Jesper K. Pedersen" <blackie at blackie.dk>
Date: Sat, 11 Feb 2006 14:02:45 -0500
Thanks again for spotting this. I changed the code so it doesn't
use QStringList at all in the thumbnail view, but instead a
QValueVector.
Since you never actually mutate the list, that also makes sense. I
wanted to make a minimal change to the code for purposes of testing it.
On Thursday 09 February 2006 21:46, Robert L Krawitz wrote:
| This change -- which adds a vector in addition to the list for holding
| the thumbnails -- makes the thumbnail view much more responsive.
| Flipping between pages now takes about 2 seconds if the thumbnails
| aren't loaded; if they're already loaded, it's almost instantaneous.
|
|
| [2(rlk)||{!26}<rlk-mobile>/home/rlk/sandbox/kphotoalbum-2006-01-28-noi18n/s
|rc/ThumbnailView] $ diff -u ThumbnailView.h{~,}
| --- ThumbnailView.h~ 2006-01-28 23:38:50.000000000 -0500
| +++ ThumbnailView.h 2006-02-09 21:37:58.000000000 -0500
| @@ -3,6 +3,7 @@
|
| #include <qgridview.h>
| #include <qvaluelist.h>
| +#include <qvaluevector.h>
| #include "imageclient.h"
| #include "set.h"
| #include "ThumbnailToolTip.h"
| @@ -121,6 +122,12 @@
|
| private:
| QStringList _imageList;
| + QValueVector<QString> _imageVector;
| +
| + /**
| + * Reload the value vector
| + */
| + void reloadVector(void);
|
| /**
| * When the user selects a date on the date bar the thumbnail view
| will
| [2(rlk)||{!27}<rlk-mobile>/home/rlk/sandbox/kphotoalbum-2006-01-28-noi18n/s
|rc/ThumbnailView] $ diff -u ThumbnailView.cpp{~,}
| --- ThumbnailView.cpp~ 2006-01-28 23:38:50.000000000 -0500
| +++ ThumbnailView.cpp 2006-02-09 21:40:36.000000000 -0500
| @@ -126,7 +126,14 @@
| painter->drawText( rect, align, title );
| }
|
| -
| +void ThumbnailView::ThumbnailView::reloadVector( void )
| +{
| + _imageVector.clear();
| + _imageVector.reserve(_imageList.count());
| + for( QStringList::Iterator imageIt = _imageList.begin(); imageIt !=
| _imageList.end(); ++imageIt ) + _imageVector.append(*imageIt);
| +}
| +
|
| void ThumbnailView::ThumbnailView::setImageList( const QStringList& list )
| {
| @@ -135,6 +142,8 @@
| else
| _imageList = reverseList( list );
|
| + reloadVector();
| +
| if ( isVisible() ) {
| updateGridSize();
| repaintScreen();
| @@ -148,10 +157,10 @@
| QString ThumbnailView::ThumbnailView::fileNameInCell( int row, int col )
| const {
| uint index = row * numCols() + col;
| - if ( index >= _imageList.count() )
| + if ( index >= _imageVector.count() )
| return QString::null;
| else
| - return _imageList[index];
| + return _imageVector[index];
| }
|
| /**
| @@ -790,14 +799,14 @@
| _leftDrop = fileName;
| int index = _imageList.findIndex( fileName ) -1;
| if ( index != -1 )
| - _rightDrop = _imageList[index];
| + _rightDrop = _imageVector[index];
| }
|
| else {
| _rightDrop = fileName;
| uint index = _imageList.findIndex( fileName ) +1;
| if ( index != _imageList.count() )
| - _leftDrop = _imageList[index];
| + _leftDrop = _imageVector[index];
| }
|
| updateCell( _leftDrop );
| @@ -893,6 +902,9 @@
|
| Options::instance()->setShowNewestFirst( direction == NewestFirst );
| _imageList = reverseList( _imageList );
| +
| + reloadVector();
| +
| if ( !_currentItem.isNull() )
| setCurrentItem( _currentItem );
| repaintScreen();
|
| _______________________________________________
| KPhotoAlbum mailing list
| KPhotoAlbum at mail.kdab.net
| http://mail.kdab.net/mailman/listinfo/kphotoalbum
--
Jesper K. Pedersen | Klarälvdalens Datakonsult
Senior Software Engineer | www.klaralvdalens-datakonsult.se
Prinsensgade 4a st. |
9800 Hjørring | Platform-independent
Denmark | software solutions
More information about the Kphotoalbum
mailing list