Diffstat (limited to 'noncore/graphics/opie-eye/gui/iconview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 652acc9..7196aba 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -32,25 +32,24 @@ | |||
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qstyle.h> | 33 | #include <qstyle.h> |
34 | 34 | ||
35 | 35 | ||
36 | using Opie::Core::OKeyConfigItem; | 36 | using Opie::Core::OKeyConfigItem; |
37 | 37 | ||
38 | /* | 38 | /* |
39 | * The Icons, Request Cache and IconViewItem for the IconView | 39 | * The Icons, Request Cache and IconViewItem for the IconView |
40 | */ | 40 | */ |
41 | namespace { | 41 | namespace { |
42 | static QPixmap* _dirPix = 0; | 42 | static QPixmap* _dirPix = 0; |
43 | static QPixmap* _unkPix = 0; | 43 | static QPixmap* _unkPix = 0; |
44 | static QPixmap* _picPix = 0; | ||
45 | static QPixmap* _emptyPix = 0; | 44 | static QPixmap* _emptyPix = 0; |
46 | class IconViewItem : public QIconViewItem { | 45 | class IconViewItem : public QIconViewItem { |
47 | public: | 46 | public: |
48 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); | 47 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); |
49 | QPixmap* pixmap()const; | 48 | QPixmap* pixmap()const; |
50 | QString path()const { return m_path; } | 49 | QString path()const { return m_path; } |
51 | bool isDir()const { return m_isDir; } | 50 | bool isDir()const { return m_isDir; } |
52 | void setText( const QString& ); | 51 | void setText( const QString& ); |
53 | bool textOnly()const{return m_textOnly;} | 52 | bool textOnly()const{return m_textOnly;} |
54 | void setTextOnly(bool how){m_textOnly=how;} | 53 | void setTextOnly(bool how){m_textOnly=how;} |
55 | /* just for starting recalc of item rect! */ | 54 | /* just for starting recalc of item rect! */ |
56 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); | 55 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); |
@@ -89,30 +88,30 @@ namespace { | |||
89 | 88 | ||
90 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 89 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
91 | const QString& name, bool isDir ) | 90 | const QString& name, bool isDir ) |
92 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 91 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
93 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) | 92 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) |
94 | { | 93 | { |
95 | if ( isDir && !_dirPix ) | 94 | if ( isDir && !_dirPix ) |
96 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | 95 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); |
97 | else if ( !isDir && !_unkPix ) | 96 | else if ( !isDir && !_unkPix ) |
98 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 97 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); |
99 | } | 98 | } |
100 | 99 | ||
101 | inline void IconViewItem::setPixmap( const QPixmap & icon, bool recalc, bool redraw) | 100 | inline void IconViewItem::setPixmap( const QPixmap & , bool, bool ) |
102 | { | 101 | { |
103 | m_Pixset = true; | 102 | m_Pixset = true; |
104 | calcRect(text()); | 103 | calcRect(text()); |
105 | } | 104 | } |
106 | inline void IconViewItem::setPixmap( const QPixmap & icon) | 105 | inline void IconViewItem::setPixmap( const QPixmap & ) |
107 | { | 106 | { |
108 | m_Pixset = true; | 107 | m_Pixset = true; |
109 | calcRect(text()); | 108 | calcRect(text()); |
110 | } | 109 | } |
111 | 110 | ||
112 | inline QPixmap* IconViewItem::pixmap()const { | 111 | inline QPixmap* IconViewItem::pixmap()const { |
113 | // owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() | 112 | // owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() |
114 | // << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() | 113 | // << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() |
115 | // << " " << iconView()->contentsY() << oendl; | 114 | // << " " << iconView()->contentsY() << oendl; |
116 | 115 | ||
117 | if (textOnly()&&!m_isDir) { | 116 | if (textOnly()&&!m_isDir) { |
118 | if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); | 117 | if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); |
@@ -244,28 +243,25 @@ void PIconView::initKeys() { | |||
244 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | 243 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), |
245 | this, SLOT(slotImageInfo()) ) ); | 244 | this, SLOT(slotImageInfo()) ) ); |
246 | m_viewManager->load(); | 245 | m_viewManager->load(); |
247 | m_viewManager->handleWidget( m_view ); | 246 | m_viewManager->handleWidget( m_view ); |
248 | } | 247 | } |
249 | 248 | ||
250 | 249 | ||
251 | /* | 250 | /* |
252 | * change one dir up | 251 | * change one dir up |
253 | */ | 252 | */ |
254 | void PIconView::slotDirUp() | 253 | void PIconView::slotDirUp() |
255 | { | 254 | { |
256 | if (m_path.isEmpty()) return; | 255 | slotChangeDir( currentView()->dirLister()->dirUp( m_path ) ); |
257 | QDir dir( m_path ); | ||
258 | dir.cdUp(); | ||
259 | slotChangeDir( dir.absPath() ); | ||
260 | } | 256 | } |
261 | 257 | ||
262 | /* | 258 | /* |
263 | * change the dir | 259 | * change the dir |
264 | */ | 260 | */ |
265 | void PIconView::slotChangeDir(const QString& path) { | 261 | void PIconView::slotChangeDir(const QString& path) { |
266 | if ( !currentView() ) | 262 | if ( !currentView() ) |
267 | return; | 263 | return; |
268 | 264 | ||
269 | PDirLister *lister = currentView()->dirLister(); | 265 | PDirLister *lister = currentView()->dirLister(); |
270 | if (!lister ) | 266 | if (!lister ) |
271 | return; | 267 | return; |
@@ -370,47 +366,54 @@ void PIconView::resetView() { | |||
370 | *swicth view reloadDir and connect signals | 366 | *swicth view reloadDir and connect signals |
371 | */ | 367 | */ |
372 | void PIconView::slotViewChanged( int i) { | 368 | void PIconView::slotViewChanged( int i) { |
373 | if (!m_views->count() ) { | 369 | if (!m_views->count() ) { |
374 | setCurrentView( 0l); | 370 | setCurrentView( 0l); |
375 | return; | 371 | return; |
376 | } | 372 | } |
377 | 373 | ||
378 | PDirView* cur = currentView(); | 374 | PDirView* cur = currentView(); |
379 | if (cur) delete cur; | 375 | if (cur) delete cur; |
380 | QString str = m_views->text(i); | 376 | QString str = m_views->text(i); |
381 | ViewMap* map = viewMap(); | 377 | ViewMap* map = viewMap(); |
382 | if (!map) {setCurrentView(0l); return;} | 378 | if (!map) { |
379 | setCurrentView(0l); | ||
380 | return; | ||
381 | } | ||
382 | |||
383 | if (map->find(str) == map->end()) { | 383 | if (map->find(str) == map->end()) { |
384 | owarn << "Key not found" << oendl; | 384 | owarn << "Key not found" << oendl; |
385 | setCurrentView(0l); return; | 385 | setCurrentView(0l); |
386 | return; | ||
386 | } | 387 | } |
388 | |||
387 | m_cfg->writeEntry("LastView",str); | 389 | m_cfg->writeEntry("LastView",str); |
388 | m_cfg->write(); | 390 | m_cfg->write(); |
389 | cur = (*(*map)[str])(*m_cfg); | 391 | cur = (*(*map)[str])(*m_cfg); |
390 | setCurrentView( cur ); | 392 | setCurrentView( cur ); |
391 | 393 | ||
392 | /* connect to the signals of the lister */ | 394 | /* connect to the signals of the lister */ |
393 | PDirLister* lis = cur->dirLister(); | 395 | PDirLister* lis = cur->dirLister(); |
394 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 396 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
395 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 397 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
396 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 398 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
397 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 399 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
398 | connect(lis, SIGNAL(sig_start()), | 400 | connect(lis, SIGNAL(sig_start()), |
399 | this, SLOT(slotStart())); | 401 | this, SLOT(slotStart())); |
400 | connect(lis, SIGNAL(sig_end()) , | 402 | connect(lis, SIGNAL(sig_end()) , |
401 | this, SLOT(slotEnd()) ); | 403 | this, SLOT(slotEnd()) ); |
402 | 404 | ||
403 | 405 | ||
404 | /* reload now */ | 406 | /* reload now with default Path*/ |
407 | m_path = lis->defaultPath(); | ||
405 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 408 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
406 | } | 409 | } |
407 | 410 | ||
408 | 411 | ||
409 | void PIconView::slotReloadDir() { | 412 | void PIconView::slotReloadDir() { |
410 | slotChangeDir( m_path ); | 413 | slotChangeDir( m_path ); |
411 | } | 414 | } |
412 | 415 | ||
413 | 416 | ||
414 | /* | 417 | /* |
415 | * add files and folders | 418 | * add files and folders |
416 | */ | 419 | */ |