-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 38 |
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 @@ -91,37 +91,29 @@ namespace { IconViewItem::IconViewItem( QIconView* view,const QString& path, const QString& name, int a_iconsize, bool isDir) : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), m_noInfo( false ),m_textOnly(false),m_Pixset(false) { m_iconsize = a_iconsize; if ( isDir ) { - if (_dirPix && _dirPix->width()!=m_iconsize) { - delete _dirPix; - _dirPix = 0; - } if (!_dirPix ) { _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); } } else { if (!_unkPix ) { _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); } } check_pix(); } inline void IconViewItem::check_pix()const { - if (_cpyPix && _cpyPix->width()!=m_iconsize) { - delete _cpyPix; - _cpyPix = 0; - } if (_dirPix && _dirPix->width()>m_iconsize) { QPixmap*Pix = new QPixmap(*_dirPix); Pix->resize(m_iconsize,m_iconsize); delete _dirPix; _dirPix = Pix; } if (!_cpyPix && _unkPix) { if (_unkPix->width()>=m_iconsize) { @@ -418,19 +410,31 @@ void PIconView::loadViews() { } void PIconView::resetView() { m_internalReset = true; // Also invalidate the cache. We can't cancel the operations anyway g_stringPix.clear(); g_stringInf.clear(); if (m_mode>1) { + int osize = m_iconsize; m_iconsize = m_cfg->readNumEntry("iconsize", 32); if (m_iconsize<12)m_iconsize = 12; if (m_iconsize>64)m_iconsize = 64; + if (osize != m_iconsize) { + if (_dirPix){ + delete _dirPix; + _dirPix = 0; + } + if (_cpyPix){ + delete _cpyPix; + _cpyPix = 0; + } + calculateGrid(); + } } else { m_iconsize = 64; } slotViewChanged(m_views->currentItem()); m_internalReset = false; } /* @@ -802,17 +806,24 @@ void PIconView::slotChangeMode( int mode ) { } if (m_mode==1) { m_iconsize = 64; } else { m_iconsize = m_cfg->readNumEntry("iconsize", 32); if (m_iconsize<12)m_iconsize = 12; if (m_iconsize>64)m_iconsize = 64; } - + if (_dirPix){ + delete _dirPix; + _dirPix = 0; + } + if (_cpyPix){ + delete _cpyPix; + _cpyPix = 0; + } calculateGrid(); slotReloadDir(); } } void PIconView::resizeEvent( QResizeEvent* re ) { calculateGrid(re); @@ -837,29 +848,34 @@ void PIconView::calculateGrid(QResizeEvent* re) pos = QIconView::Bottom; break; case 3: case 1: default: pos = QIconView::Right; break; } + int cache = 0; m_view->setItemTextPos( pos ); switch (m_mode) { case 2: + m_view->setSpacing(2); m_view->setGridX(m_iconsize); m_view->setGridY(-1); - PPixmapCache::self()->setMaxImages(40); + cache = (int)((double)64/(double)m_iconsize*40.0); + odebug << "cache size: " << cache << oendl; + PPixmapCache::self()->setMaxImages(cache); break; case 3: + m_view->setSpacing(10); m_view->setGridX( fontMetrics().width("testimage.jpg")+20); m_view->setGridY(8); PPixmapCache::self()->setMaxImages(2); break; case 1: default: + m_view->setSpacing(10); m_view->setGridX( viewerWidth-3*m_view->spacing()); m_view->setGridY( fontMetrics().height()*2+40 ); PPixmapCache::self()->setMaxImages(20); break; } - m_view->setSpacing(10); } |