-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 26 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/lib/imagecache.cpp | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/lib/imagecache.h | 5 |
3 files changed, 27 insertions, 10 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 | |||
@@ -49,13 +49,15 @@ namespace { | |||
49 | QPixmap* pixmap()const; | 49 | QPixmap* pixmap()const; |
50 | QString path()const { return m_path; } | 50 | QString path()const { return m_path; } |
51 | bool isDir()const { return m_isDir; } | 51 | bool isDir()const { return m_isDir; } |
52 | void setText( const QString& ); | 52 | void setText( const QString& ); |
53 | bool textOnly()const{return m_textOnly;} | 53 | bool textOnly()const{return m_textOnly;} |
54 | void setTextOnly(bool how){m_textOnly=how;} | 54 | void setTextOnly(bool how){m_textOnly=how;} |
55 | /* just for starting recalc of item rect! */ | ||
55 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); | 56 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); |
57 | /* just for starting recalc of item rect! */ | ||
56 | virtual void setPixmap( const QPixmap & icon); | 58 | virtual void setPixmap( const QPixmap & icon); |
57 | 59 | ||
58 | protected: | 60 | protected: |
59 | mutable QPixmap* m_pix; | 61 | mutable QPixmap* m_pix; |
60 | 62 | ||
61 | private: | 63 | private: |
@@ -96,18 +98,18 @@ namespace { | |||
96 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 98 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); |
97 | } | 99 | } |
98 | 100 | ||
99 | inline void IconViewItem::setPixmap( const QPixmap & icon, bool recalc, bool redraw) | 101 | inline void IconViewItem::setPixmap( const QPixmap & icon, bool recalc, bool redraw) |
100 | { | 102 | { |
101 | m_Pixset = true; | 103 | m_Pixset = true; |
102 | QIconViewItem::setPixmap(icon,recalc,redraw); | 104 | calcRect(text()); |
103 | } | 105 | } |
104 | inline void IconViewItem::setPixmap( const QPixmap & icon) | 106 | inline void IconViewItem::setPixmap( const QPixmap & icon) |
105 | { | 107 | { |
106 | m_Pixset = true; | 108 | m_Pixset = true; |
107 | QIconViewItem::setPixmap(icon); | 109 | calcRect(text()); |
108 | } | 110 | } |
109 | 111 | ||
110 | inline QPixmap* IconViewItem::pixmap()const { | 112 | inline QPixmap* IconViewItem::pixmap()const { |
111 | // qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", | 113 | // qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", |
112 | // rect().x(),rect().y(),rect().width(),rect().height(), | 114 | // rect().x(),rect().y(),rect().width(),rect().height(), |
113 | // iconView()->contentsX(), iconView()->contentsY()); | 115 | // iconView()->contentsX(), iconView()->contentsY()); |
@@ -122,19 +124,16 @@ namespace { | |||
122 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { | 124 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { |
123 | currentView()->dirLister()->imageInfo( m_path ); | 125 | currentView()->dirLister()->imageInfo( m_path ); |
124 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); | 126 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); |
125 | } | 127 | } |
126 | 128 | ||
127 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); | 129 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); |
128 | if (!m_pix && !g_stringPix.contains( m_path )&&!m_Pixset) { | 130 | if (!m_pix && !g_stringPix.contains( m_path )) { |
129 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); | 131 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); |
130 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); | 132 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); |
131 | } | 133 | } |
132 | if (m_Pixset) { | ||
133 | return QIconViewItem::pixmap(); | ||
134 | } | ||
135 | return m_pix ? m_pix : _unkPix; | 134 | return m_pix ? m_pix : _unkPix; |
136 | } | 135 | } |
137 | } | 136 | } |
138 | inline void IconViewItem::setText( const QString& str ) { | 137 | inline void IconViewItem::setText( const QString& str ) { |
139 | QString text = QIconViewItem::text()+"\n"+str; | 138 | QString text = QIconViewItem::text()+"\n"+str; |
140 | m_noInfo = true; | 139 | m_noInfo = true; |
@@ -406,14 +405,18 @@ void PIconView::addFiles( const QStringList& lst) { | |||
406 | QStringList::ConstIterator it; | 405 | QStringList::ConstIterator it; |
407 | IconViewItem * _iv; | 406 | IconViewItem * _iv; |
408 | QPixmap*m_pix = 0; | 407 | QPixmap*m_pix = 0; |
409 | for (it=lst.begin(); it!= lst.end(); ++it ) { | 408 | for (it=lst.begin(); it!= lst.end(); ++it ) { |
410 | m_pix = PPixmapCache::self()->cachedImage( m_path+"/"+(*it), 64, 64 ); | 409 | m_pix = PPixmapCache::self()->cachedImage( m_path+"/"+(*it), 64, 64 ); |
411 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); | 410 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); |
412 | if (m_mode==3) _iv->setTextOnly(true); | 411 | if (m_mode==3) { |
413 | if (m_pix) _iv->setPixmap(*m_pix); | 412 | _iv->setTextOnly(true); |
413 | _iv->setPixmap(QPixmap()); | ||
414 | } else { | ||
415 | if (m_pix) _iv->setPixmap(*m_pix); | ||
416 | } | ||
414 | } | 417 | } |
415 | 418 | ||
416 | } | 419 | } |
417 | 420 | ||
418 | /* | 421 | /* |
419 | * user clicked on the item. Change dir or view | 422 | * user clicked on the item. Change dir or view |
@@ -589,20 +592,23 @@ void PIconView::resizeEvent( QResizeEvent* re ) { | |||
589 | void PIconView::calculateGrid() { | 592 | void PIconView::calculateGrid() { |
590 | odebug << "Calc grid: x=" << m_view->gridX() << " y=" << m_view->gridY() << oendl; | 593 | odebug << "Calc grid: x=" << m_view->gridX() << " y=" << m_view->gridY() << oendl; |
591 | odebug << "Size of view: " << m_view->size() << oendl; | 594 | odebug << "Size of view: " << m_view->size() << oendl; |
592 | 595 | ||
593 | switch (m_mode) { | 596 | switch (m_mode) { |
594 | case 2: | 597 | case 2: |
595 | m_view->setGridX(80); | 598 | m_view->setGridX(50); |
596 | m_view->setGridY(80); | 599 | m_view->setGridY(20); |
600 | PPixmapCache::self()->setMaxImages(40); | ||
597 | break; | 601 | break; |
598 | case 3: | 602 | case 3: |
599 | m_view->setGridX(m_view->width()); | 603 | m_view->setGridX(m_view->width()); |
600 | m_view->setGridY(8); | 604 | m_view->setGridY(8); |
605 | PPixmapCache::self()->setMaxImages(2); | ||
601 | break; | 606 | break; |
602 | case 1: | 607 | case 1: |
603 | default: | 608 | default: |
604 | m_view->setGridX(m_view->width()); | 609 | m_view->setGridX(m_view->width()); |
605 | m_view->setGridY(80); | 610 | m_view->setGridY(80); |
611 | PPixmapCache::self()->setMaxImages(20); | ||
606 | break; | 612 | break; |
607 | } | 613 | } |
608 | } | 614 | } |
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 | |||
@@ -59,12 +59,18 @@ PPixmapCache::PPixmapCache() { | |||
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 | } |
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 | |||
@@ -25,17 +25,22 @@ public: | |||
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 | ||