summaryrefslogtreecommitdiff
authoralwin <alwin>2004-04-19 09:16:15 (UTC)
committer alwin <alwin>2004-04-19 09:16:15 (UTC)
commite3ca538f7ce2e7b7df2f29f263778acc342d51db (patch) (side-by-side diff)
treecb3e3c769ae12542d24eff7d17168635ddef65af
parent0b59a16b5a5a179c46ddb3f8c585dbca59b2826e (diff)
downloadopie-e3ca538f7ce2e7b7df2f29f263778acc342d51db.zip
opie-e3ca538f7ce2e7b7df2f29f263778acc342d51db.tar.gz
opie-e3ca538f7ce2e7b7df2f29f263778acc342d51db.tar.bz2
re-enabled the cache as designed.
for that, pixcache has now a method setting the size of cache (parameter count of pix) and it will switched between the different views. setPixmap is overloaded that way, that we don't store the pix inside the item but calling calcRect which is accessing the cached pixmap. voila. Zecke: Should we make a configure item where users can setup how much pix-previews should cache? Should we setup a thumbnail cache like .xvpics?
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp24
-rw-r--r--noncore/graphics/opie-eye/lib/imagecache.cpp6
-rw-r--r--noncore/graphics/opie-eye/lib/imagecache.h5
3 files changed, 26 insertions, 9 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 039f53f..d546b64 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -51,9 +51,11 @@ namespace {
bool isDir()const { return m_isDir; }
void setText( const QString& );
bool textOnly()const{return m_textOnly;}
void setTextOnly(bool how){m_textOnly=how;}
+ /* just for starting recalc of item rect! */
virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE );
+ /* just for starting recalc of item rect! */
virtual void setPixmap( const QPixmap & icon);
protected:
mutable QPixmap* m_pix;
@@ -98,14 +100,14 @@ namespace {
inline void IconViewItem::setPixmap( const QPixmap & icon, bool recalc, bool redraw)
{
m_Pixset = true;
- QIconViewItem::setPixmap(icon,recalc,redraw);
+ calcRect(text());
}
inline void IconViewItem::setPixmap( const QPixmap & icon)
{
m_Pixset = true;
- QIconViewItem::setPixmap(icon);
+ calcRect(text());
}
inline QPixmap* IconViewItem::pixmap()const {
// qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d",
@@ -124,15 +126,12 @@ namespace {
g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
}
m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 );
- if (!m_pix && !g_stringPix.contains( m_path )&&!m_Pixset) {
+ if (!m_pix && !g_stringPix.contains( m_path )) {
currentView()->dirLister()->thumbNail( m_path, 64, 64 );
g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
}
- if (m_Pixset) {
- return QIconViewItem::pixmap();
- }
return m_pix ? m_pix : _unkPix;
}
}
inline void IconViewItem::setText( const QString& str ) {
@@ -408,11 +407,15 @@ void PIconView::addFiles( const QStringList& lst) {
QPixmap*m_pix = 0;
for (it=lst.begin(); it!= lst.end(); ++it ) {
m_pix = PPixmapCache::self()->cachedImage( m_path+"/"+(*it), 64, 64 );
_iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it) );
- if (m_mode==3) _iv->setTextOnly(true);
+ if (m_mode==3) {
+ _iv->setTextOnly(true);
+ _iv->setPixmap(QPixmap());
+ } else {
if (m_pix) _iv->setPixmap(*m_pix);
}
+ }
}
/*
@@ -591,18 +594,21 @@ void PIconView::calculateGrid() {
odebug << "Size of view: " << m_view->size() << oendl;
switch (m_mode) {
case 2:
- m_view->setGridX(80);
- m_view->setGridY(80);
+ m_view->setGridX(50);
+ m_view->setGridY(20);
+ PPixmapCache::self()->setMaxImages(40);
break;
case 3:
m_view->setGridX(m_view->width());
m_view->setGridY(8);
+ PPixmapCache::self()->setMaxImages(2);
break;
case 1:
default:
m_view->setGridX(m_view->width());
m_view->setGridY(80);
+ PPixmapCache::self()->setMaxImages(20);
break;
}
}
diff --git a/noncore/graphics/opie-eye/lib/imagecache.cpp b/noncore/graphics/opie-eye/lib/imagecache.cpp
index 3b74a83..f1042a4 100644
--- a/noncore/graphics/opie-eye/lib/imagecache.cpp
+++ b/noncore/graphics/opie-eye/lib/imagecache.cpp
@@ -61,8 +61,14 @@ PPixmapCache::PPixmapCache() {
PPixmapCache::~PPixmapCache() {
}
+void PPixmapCache::setMaxImages(unsigned int aMax)
+{
+ m_MaxImages = aMax;
+ setMaxCost( 64*64*QPixmap::defaultDepth()/8*m_MaxImages);
+}
+
PPixmapCache* PPixmapCache::self() {
if ( !_pxmCache )
_pxmCache = new PPixmapCache;
diff --git a/noncore/graphics/opie-eye/lib/imagecache.h b/noncore/graphics/opie-eye/lib/imagecache.h
index 076ecd3..939247a 100644
--- a/noncore/graphics/opie-eye/lib/imagecache.h
+++ b/noncore/graphics/opie-eye/lib/imagecache.h
@@ -27,13 +27,18 @@ public:
class PPixmapCache : public QCache<QPixmap> {
private:
PPixmapCache();
~PPixmapCache();
+
+ unsigned int m_MaxImages;
+
public:
static PPixmapCache *self();
QPixmap* cachedImage( const QString& path, int width, int height );
void insertImage( const QString& path, const QPixmap &, int width, int height );
void insertImage( const QString& path, const QPixmap *, int width, int height );
+ void setMaxImages(unsigned int aMax);
+ unsigned int maxImages()const{return m_MaxImages;}
};
inline void PPixmapCache::insertImage( const QString& path, const QPixmap& p, int width, int height ) {
insertImage( path, new QPixmap( p ), width, height );