author | alwin <alwin> | 2004-04-19 09:16:15 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-19 09:16:15 (UTC) |
commit | e3ca538f7ce2e7b7df2f29f263778acc342d51db (patch) (unidiff) | |
tree | cb3e3c769ae12542d24eff7d17168635ddef65af /noncore/graphics/opie-eye/lib | |
parent | 0b59a16b5a5a179c46ddb3f8c585dbca59b2826e (diff) | |
download | opie-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 (limited to 'noncore/graphics/opie-eye/lib') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/lib/imagecache.cpp | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/lib/imagecache.h | 5 |
2 files changed, 11 insertions, 0 deletions
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 | |||
@@ -53,24 +53,30 @@ void PImageCache::insertImage( const QString& _path, const QImage* img, int or | |||
53 | 53 | ||
54 | 54 | ||
55 | PPixmapCache::PPixmapCache() { | 55 | PPixmapCache::PPixmapCache() { |
56 | /* | 56 | /* |
57 | * 20 64x64 16 bit images | 57 | * 20 64x64 16 bit images |
58 | */ | 58 | */ |
59 | setMaxCost( 64*64*QPixmap::defaultDepth()/8*20 ); | 59 | setMaxCost( 64*64*QPixmap::defaultDepth()/8*20 ); |
60 | } | 60 | } |
61 | 61 | ||
62 | PPixmapCache::~PPixmapCache() { | 62 | PPixmapCache::~PPixmapCache() { |
63 | } | 63 | } |
64 | 64 | ||
65 | void PPixmapCache::setMaxImages(unsigned int aMax) | ||
66 | { | ||
67 | m_MaxImages = aMax; | ||
68 | setMaxCost( 64*64*QPixmap::defaultDepth()/8*m_MaxImages); | ||
69 | } | ||
70 | |||
65 | PPixmapCache* PPixmapCache::self() { | 71 | PPixmapCache* PPixmapCache::self() { |
66 | if ( !_pxmCache ) | 72 | if ( !_pxmCache ) |
67 | _pxmCache = new PPixmapCache; | 73 | _pxmCache = new PPixmapCache; |
68 | 74 | ||
69 | return _pxmCache; | 75 | return _pxmCache; |
70 | } | 76 | } |
71 | 77 | ||
72 | QPixmap* PPixmapCache::cachedImage( const QString& _path, int width, int height ) { | 78 | QPixmap* PPixmapCache::cachedImage( const QString& _path, int width, int height ) { |
73 | QString path = QString( "%1_%2:" ).arg( width ).arg( height ); | 79 | QString path = QString( "%1_%2:" ).arg( width ).arg( height ); |
74 | path += _path; | 80 | path += _path; |
75 | 81 | ||
76 | QPixmap* pxm = find( path ); | 82 | QPixmap* pxm = find( path ); |
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 | |||
@@ -19,28 +19,33 @@ private: | |||
19 | public: | 19 | public: |
20 | static PImageCache *self(); | 20 | static PImageCache *self(); |
21 | QImage* cachedImage( const QString& path, int orientation = 3, int max = 0); //const; | 21 | QImage* cachedImage( const QString& path, int orientation = 3, int max = 0); //const; |
22 | void insertImage( const QString& path, const QImage &, int orien = 3, int max = 0); | 22 | void insertImage( const QString& path, const QImage &, int orien = 3, int max = 0); |
23 | void insertImage( const QString& path, const QImage *, int orien=3, int max = 0 ); | 23 | void insertImage( const QString& path, const QImage *, int orien=3, int max = 0 ); |
24 | }; | 24 | }; |
25 | 25 | ||
26 | 26 | ||
27 | class PPixmapCache : public QCache<QPixmap> { | 27 | class PPixmapCache : public QCache<QPixmap> { |
28 | private: | 28 | private: |
29 | PPixmapCache(); | 29 | PPixmapCache(); |
30 | ~PPixmapCache(); | 30 | ~PPixmapCache(); |
31 | |||
32 | unsigned int m_MaxImages; | ||
33 | |||
31 | public: | 34 | public: |
32 | static PPixmapCache *self(); | 35 | static PPixmapCache *self(); |
33 | QPixmap* cachedImage( const QString& path, int width, int height ); | 36 | QPixmap* cachedImage( const QString& path, int width, int height ); |
34 | void insertImage( const QString& path, const QPixmap &, int width, int height ); | 37 | void insertImage( const QString& path, const QPixmap &, int width, int height ); |
35 | void insertImage( const QString& path, const QPixmap *, int width, int height ); | 38 | void insertImage( const QString& path, const QPixmap *, int width, int height ); |
39 | void setMaxImages(unsigned int aMax); | ||
40 | unsigned int maxImages()const{return m_MaxImages;} | ||
36 | }; | 41 | }; |
37 | 42 | ||
38 | inline void PPixmapCache::insertImage( const QString& path, const QPixmap& p, int width, int height ) { | 43 | inline void PPixmapCache::insertImage( const QString& path, const QPixmap& p, int width, int height ) { |
39 | insertImage( path, new QPixmap( p ), width, height ); | 44 | insertImage( path, new QPixmap( p ), width, height ); |
40 | } | 45 | } |
41 | 46 | ||
42 | inline void PImageCache::insertImage( const QString& path, const QImage& p, int width, int height ) { | 47 | inline void PImageCache::insertImage( const QString& path, const QImage& p, int width, int height ) { |
43 | insertImage( path, new QImage( p ), width, height ); | 48 | insertImage( path, new QImage( p ), width, height ); |
44 | } | 49 | } |
45 | 50 | ||
46 | #endif | 51 | #endif |