[KimDaBa] Speeding up scrolling
Robert L Krawitz
rlk at alum.mit.edu
Tue Jan 11 03:33:59 GMT 2005
Just as an experiment, I tried deleting all low priority requests
whenever the viewport is scrolled. Scrolling is much faster. This
isn't entirely right, because if you scroll slowly (rather than full
pages at a time) some of the images never do get displayed, but it
suggests a way we might proceed. The code looks like this:
--- imagemanager.cpp~ 2005-01-08 18:53:55.000000000 -0500
+++ imagemanager.cpp 2005-01-10 22:24:19.709073392 -0500
@@ -220,7 +220,9 @@
LoadInfo key = it.key();
ImageClient* data = it.data();
++it; // We need to increase it before removing the element.
- if ( data == client && ( action == StopAll || !key.priority() ) )
+ if ( action == StopAllLoads ||
+ ( action == StopAllNonPriorityLoads && !key.priority() ) ||
+ ( data == client && ( action == StopAll || !key.priority() ) ) )
_clientMap.remove( key );
}
@@ -229,7 +231,9 @@
for( QValueList<LoadInfo>::Iterator it = _loadList.begin(); it != _loadList.end(); ) {
LoadInfo li = *it;
++it;
- if ( li.client() == client && ( action == StopAll || !li.priority() ) )
+ if ( action == StopAllLoads ||
+ ( action == StopAllNonPriorityLoads && !li.priority() ) ||
+ ( li.client() == client && ( action == StopAll || !li.priority() ) ) )
_loadList.remove( li );
}
_lock->unlock();
--- imagemanager.h~ 2005-01-08 18:53:02.000000000 -0500
+++ imagemanager.h 2005-01-10 22:14:51.613567110 -0500
@@ -86,7 +86,8 @@
Q_OBJECT
public:
- enum StopAction { StopAll, StopOnlyNonPriorityLoads };
+ enum StopAction { StopAll, StopOnlyNonPriorityLoads,
+ StopAllLoads, StopAllNonPriorityLoads };
void load( const QString& fileName, ImageClient* client, int angle, int width, int height,
bool cache, bool priority );
--- thumbnailview.cpp~ 2005-01-02 15:38:10.000000000 -0500
+++ thumbnailview.cpp 2005-01-10 22:23:47.545160969 -0500
@@ -33,6 +33,7 @@
#include <qpainter.h>
#include "imagedaterange.h"
#include "imageinfo.h"
+#include "imagemanager.h"
ThumbNailView* ThumbNailView::_instance = 0;
@@ -323,6 +324,7 @@
{
if ( _blockMoveSignals )
return;
+ ImageManager::instance()->stop(NULL, ImageManager::StopAllNonPriorityLoads);
QIconViewItem* item = findFirstVisibleItem( QRect( contentsX(), contentsY(), width(), height() ) );
if ( item ) {
--
Robert Krawitz <rlk at alum.mit.edu>
Tall Clubs International -- http://www.tall.org/ or 1-888-IM-TALL-2
Member of the League for Programming Freedom -- mail lpf at uunet.uu.net
Project lead for Gimp Print -- http://gimp-print.sourceforge.net
"Linux doesn't dictate how I work, I dictate how Linux works."
--Eric Crampton
More information about the Kphotoalbum
mailing list