summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp38
1 files changed, 27 insertions, 11 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index c037d0d..f173ecc 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -93,16 +93,12 @@ namespace {
93 const QString& name, int a_iconsize, bool isDir) 93 const QString& name, int a_iconsize, bool isDir)
94 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), 94 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ),
95 m_noInfo( false ),m_textOnly(false),m_Pixset(false) 95 m_noInfo( false ),m_textOnly(false),m_Pixset(false)
96 { 96 {
97 m_iconsize = a_iconsize; 97 m_iconsize = a_iconsize;
98 if ( isDir ) { 98 if ( isDir ) {
99 if (_dirPix && _dirPix->width()!=m_iconsize) {
100 delete _dirPix;
101 _dirPix = 0;
102 }
103 if (!_dirPix ) { 99 if (!_dirPix ) {
104 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); 100 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
105 } 101 }
106 } else { 102 } else {
107 if (!_unkPix ) { 103 if (!_unkPix ) {
108 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); 104 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
@@ -110,16 +106,12 @@ namespace {
110 } 106 }
111 check_pix(); 107 check_pix();
112 } 108 }
113 109
114 inline void IconViewItem::check_pix()const 110 inline void IconViewItem::check_pix()const
115 { 111 {
116 if (_cpyPix && _cpyPix->width()!=m_iconsize) {
117 delete _cpyPix;
118 _cpyPix = 0;
119 }
120 if (_dirPix && _dirPix->width()>m_iconsize) { 112 if (_dirPix && _dirPix->width()>m_iconsize) {
121 QPixmap*Pix = new QPixmap(*_dirPix); 113 QPixmap*Pix = new QPixmap(*_dirPix);
122 Pix->resize(m_iconsize,m_iconsize); 114 Pix->resize(m_iconsize,m_iconsize);
123 delete _dirPix; 115 delete _dirPix;
124 _dirPix = Pix; 116 _dirPix = Pix;
125 } 117 }
@@ -420,15 +412,27 @@ void PIconView::loadViews() {
420void PIconView::resetView() { 412void PIconView::resetView() {
421 m_internalReset = true; 413 m_internalReset = true;
422 // Also invalidate the cache. We can't cancel the operations anyway 414 // Also invalidate the cache. We can't cancel the operations anyway
423 g_stringPix.clear(); 415 g_stringPix.clear();
424 g_stringInf.clear(); 416 g_stringInf.clear();
425 if (m_mode>1) { 417 if (m_mode>1) {
418 int osize = m_iconsize;
426 m_iconsize = m_cfg->readNumEntry("iconsize", 32); 419 m_iconsize = m_cfg->readNumEntry("iconsize", 32);
427 if (m_iconsize<12)m_iconsize = 12; 420 if (m_iconsize<12)m_iconsize = 12;
428 if (m_iconsize>64)m_iconsize = 64; 421 if (m_iconsize>64)m_iconsize = 64;
422 if (osize != m_iconsize) {
423 if (_dirPix){
424 delete _dirPix;
425 _dirPix = 0;
426 }
427 if (_cpyPix){
428 delete _cpyPix;
429 _cpyPix = 0;
430 }
431 calculateGrid();
432 }
429 } else { 433 } else {
430 m_iconsize = 64; 434 m_iconsize = 64;
431 } 435 }
432 slotViewChanged(m_views->currentItem()); 436 slotViewChanged(m_views->currentItem());
433 m_internalReset = false; 437 m_internalReset = false;
434} 438}
@@ -804,13 +808,20 @@ void PIconView::slotChangeMode( int mode ) {
804 m_iconsize = 64; 808 m_iconsize = 64;
805 } else { 809 } else {
806 m_iconsize = m_cfg->readNumEntry("iconsize", 32); 810 m_iconsize = m_cfg->readNumEntry("iconsize", 32);
807 if (m_iconsize<12)m_iconsize = 12; 811 if (m_iconsize<12)m_iconsize = 12;
808 if (m_iconsize>64)m_iconsize = 64; 812 if (m_iconsize>64)m_iconsize = 64;
809 } 813 }
810 814 if (_dirPix){
815 delete _dirPix;
816 _dirPix = 0;
817 }
818 if (_cpyPix){
819 delete _cpyPix;
820 _cpyPix = 0;
821 }
811 calculateGrid(); 822 calculateGrid();
812 slotReloadDir(); 823 slotReloadDir();
813 } 824 }
814} 825}
815 826
816 827
@@ -839,27 +850,32 @@ void PIconView::calculateGrid(QResizeEvent* re)
839 case 3: 850 case 3:
840 case 1: 851 case 1:
841 default: 852 default:
842 pos = QIconView::Right; 853 pos = QIconView::Right;
843 break; 854 break;
844 } 855 }
856 int cache = 0;
845 m_view->setItemTextPos( pos ); 857 m_view->setItemTextPos( pos );
846 switch (m_mode) { 858 switch (m_mode) {
847 case 2: 859 case 2:
860 m_view->setSpacing(2);
848 m_view->setGridX(m_iconsize); 861 m_view->setGridX(m_iconsize);
849 m_view->setGridY(-1); 862 m_view->setGridY(-1);
850 PPixmapCache::self()->setMaxImages(40); 863 cache = (int)((double)64/(double)m_iconsize*40.0);
864 odebug << "cache size: " << cache << oendl;
865 PPixmapCache::self()->setMaxImages(cache);
851 break; 866 break;
852 case 3: 867 case 3:
868 m_view->setSpacing(10);
853 m_view->setGridX( fontMetrics().width("testimage.jpg")+20); 869 m_view->setGridX( fontMetrics().width("testimage.jpg")+20);
854 m_view->setGridY(8); 870 m_view->setGridY(8);
855 PPixmapCache::self()->setMaxImages(2); 871 PPixmapCache::self()->setMaxImages(2);
856 break; 872 break;
857 case 1: 873 case 1:
858 default: 874 default:
875 m_view->setSpacing(10);
859 m_view->setGridX( viewerWidth-3*m_view->spacing()); 876 m_view->setGridX( viewerWidth-3*m_view->spacing());
860 m_view->setGridY( fontMetrics().height()*2+40 ); 877 m_view->setGridY( fontMetrics().height()*2+40 );
861 PPixmapCache::self()->setMaxImages(20); 878 PPixmapCache::self()->setMaxImages(20);
862 break; 879 break;
863 } 880 }
864 m_view->setSpacing(10);
865} 881}