-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 80 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 41 |
2 files changed, 91 insertions, 30 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 7231bfb..039f53f 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -39,27 +39,35 @@ using Opie::Core::OKeyConfigItem; | |||
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; | 44 | static QPixmap* _picPix = 0; |
45 | static QPixmap* _emptyPix = 0; | ||
45 | class IconViewItem : public QIconViewItem { | 46 | class IconViewItem : public QIconViewItem { |
46 | public: | 47 | public: |
47 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); | 48 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); |
48 | QPixmap* pixmap()const; | 49 | QPixmap* pixmap()const; |
49 | QString path()const { return m_path; } | 50 | QString path()const { return m_path; } |
50 | bool isDir()const { return m_isDir; } | 51 | bool isDir()const { return m_isDir; } |
51 | void setText( const QString& ); | 52 | void setText( const QString& ); |
53 | bool textOnly()const{return m_textOnly;} | ||
54 | void setTextOnly(bool how){m_textOnly=how;} | ||
55 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); | ||
56 | virtual void setPixmap( const QPixmap & icon); | ||
52 | 57 | ||
53 | protected: | 58 | protected: |
54 | mutable QPixmap* m_pix; | 59 | mutable QPixmap* m_pix; |
55 | 60 | ||
56 | private: | 61 | private: |
57 | QString m_path; | 62 | QString m_path; |
58 | bool m_isDir : 1; | 63 | bool m_isDir : 1; |
59 | bool m_noInfo :1; | 64 | bool m_noInfo :1; |
65 | bool m_textOnly:1; | ||
66 | bool m_NameOnly:1; | ||
67 | bool m_Pixset:1; | ||
60 | }; | 68 | }; |
61 | class TextViewItem : public IconViewItem { | 69 | class TextViewItem : public IconViewItem { |
62 | TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | 70 | TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); |
63 | QPixmap *pixmap()const; | 71 | QPixmap *pixmap()const; |
64 | void setText( const QString& ); | 72 | void setText( const QString& ); |
65 | }; | 73 | }; |
@@ -77,37 +85,56 @@ namespace { | |||
77 | static QMap<QString, IconViewItem*> g_stringInf; | 85 | static QMap<QString, IconViewItem*> g_stringInf; |
78 | static QMap<QString, IconViewItem*> g_stringPix; | 86 | static QMap<QString, IconViewItem*> g_stringPix; |
79 | 87 | ||
80 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 88 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
81 | const QString& name, bool isDir ) | 89 | const QString& name, bool isDir ) |
82 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 90 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
83 | m_noInfo( false ) | 91 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) |
84 | { | 92 | { |
85 | if ( isDir && !_dirPix ) | 93 | if ( isDir && !_dirPix ) |
86 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | 94 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); |
87 | else if ( !isDir && !_unkPix ) | 95 | else if ( !isDir && !_unkPix ) |
88 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 96 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); |
89 | } | 97 | } |
98 | |||
99 | inline void IconViewItem::setPixmap( const QPixmap & icon, bool recalc, bool redraw) | ||
100 | { | ||
101 | m_Pixset = true; | ||
102 | QIconViewItem::setPixmap(icon,recalc,redraw); | ||
103 | } | ||
104 | inline void IconViewItem::setPixmap( const QPixmap & icon) | ||
105 | { | ||
106 | m_Pixset = true; | ||
107 | QIconViewItem::setPixmap(icon); | ||
108 | } | ||
109 | |||
90 | inline QPixmap* IconViewItem::pixmap()const { | 110 | inline QPixmap* IconViewItem::pixmap()const { |
91 | // qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", | 111 | // qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", |
92 | // rect().x(),rect().y(),rect().width(),rect().height(), | 112 | // rect().x(),rect().y(),rect().width(),rect().height(), |
93 | // iconView()->contentsX(), iconView()->contentsY()); | 113 | // iconView()->contentsX(), iconView()->contentsY()); |
94 | 114 | ||
115 | if (textOnly()&&!m_isDir) { | ||
116 | if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); | ||
117 | return _emptyPix; | ||
118 | } | ||
95 | if ( m_isDir ) | 119 | if ( m_isDir ) |
96 | return _dirPix; | 120 | return _dirPix; |
97 | else{ | 121 | else{ |
98 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { | 122 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { |
99 | currentView()->dirLister()->imageInfo( m_path ); | 123 | currentView()->dirLister()->imageInfo( m_path ); |
100 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); | 124 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); |
101 | } | 125 | } |
102 | 126 | ||
103 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); | 127 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); |
104 | if ( !m_pix && !g_stringPix.contains( m_path )) { | 128 | if (!m_pix && !g_stringPix.contains( m_path )&&!m_Pixset) { |
105 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); | 129 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); |
106 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); | 130 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); |
107 | } | 131 | } |
132 | if (m_Pixset) { | ||
133 | return QIconViewItem::pixmap(); | ||
134 | } | ||
108 | return m_pix ? m_pix : _unkPix; | 135 | return m_pix ? m_pix : _unkPix; |
109 | } | 136 | } |
110 | } | 137 | } |
111 | inline void IconViewItem::setText( const QString& str ) { | 138 | inline void IconViewItem::setText( const QString& str ) { |
112 | QString text = QIconViewItem::text()+"\n"+str; | 139 | QString text = QIconViewItem::text()+"\n"+str; |
113 | m_noInfo = true; | 140 | m_noInfo = true; |
@@ -364,23 +391,30 @@ void PIconView::slotReloadDir() { | |||
364 | 391 | ||
365 | /* | 392 | /* |
366 | * add files and folders | 393 | * add files and folders |
367 | */ | 394 | */ |
368 | void PIconView::addFolders( const QStringList& lst) { | 395 | void PIconView::addFolders( const QStringList& lst) { |
369 | QStringList::ConstIterator it; | 396 | QStringList::ConstIterator it; |
397 | IconViewItem * _iv; | ||
370 | 398 | ||
371 | for(it=lst.begin(); it != lst.end(); ++it ) | 399 | for(it=lst.begin(); it != lst.end(); ++it ) { |
372 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); | 400 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); |
373 | 401 | if (m_mode==3) _iv->setTextOnly(true); | |
374 | 402 | } | |
375 | } | 403 | } |
376 | 404 | ||
377 | void PIconView::addFiles( const QStringList& lst) { | 405 | void PIconView::addFiles( const QStringList& lst) { |
378 | QStringList::ConstIterator it; | 406 | QStringList::ConstIterator it; |
379 | for (it=lst.begin(); it!= lst.end(); ++it ) | 407 | IconViewItem * _iv; |
380 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); | 408 | QPixmap*m_pix = 0; |
409 | for (it=lst.begin(); it!= lst.end(); ++it ) { | ||
410 | m_pix = PPixmapCache::self()->cachedImage( m_path+"/"+(*it), 64, 64 ); | ||
411 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); | ||
412 | if (m_mode==3) _iv->setTextOnly(true); | ||
413 | if (m_pix) _iv->setPixmap(*m_pix); | ||
414 | } | ||
381 | 415 | ||
382 | } | 416 | } |
383 | 417 | ||
384 | /* | 418 | /* |
385 | * user clicked on the item. Change dir or view | 419 | * user clicked on the item. Change dir or view |
386 | */ | 420 | */ |
@@ -401,12 +435,15 @@ void PIconView::slotClicked(QIconViewItem* _it) { | |||
401 | */ | 435 | */ |
402 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 436 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
403 | IconViewItem* item = g_stringInf[_path]; | 437 | IconViewItem* item = g_stringInf[_path]; |
404 | if (!item ) | 438 | if (!item ) |
405 | return; | 439 | return; |
406 | 440 | ||
441 | if (m_mode == 2) { | ||
442 | return; | ||
443 | } | ||
407 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 444 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
408 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 445 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
409 | m_updatet = true; | 446 | m_updatet = true; |
410 | 447 | ||
411 | item->setText( str ); | 448 | item->setText( str ); |
412 | g_stringInf.remove( _path ); | 449 | g_stringInf.remove( _path ); |
@@ -421,16 +458,18 @@ void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | |||
421 | return; | 458 | return; |
422 | 459 | ||
423 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 460 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
424 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 461 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
425 | m_updatet = true; | 462 | m_updatet = true; |
426 | 463 | ||
427 | if (pix.width()>0) | 464 | if (pix.width()>0) { |
428 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); | 465 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); |
429 | 466 | item->setPixmap(pix,true); | |
430 | 467 | } else { | |
468 | PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), 64, 64 ); | ||
469 | } | ||
431 | g_stringPix.remove( _path ); | 470 | g_stringPix.remove( _path ); |
432 | } | 471 | } |
433 | 472 | ||
434 | 473 | ||
435 | /* | 474 | /* |
436 | * FIXME rename | 475 | * FIXME rename |
@@ -545,8 +584,25 @@ void PIconView::resizeEvent( QResizeEvent* re ) { | |||
545 | QVBox::resizeEvent( re ); | 584 | QVBox::resizeEvent( re ); |
546 | calculateGrid(); | 585 | calculateGrid(); |
547 | } | 586 | } |
548 | 587 | ||
549 | 588 | ||
550 | void PIconView::calculateGrid() { | 589 | void PIconView::calculateGrid() { |
551 | 590 | odebug << "Calc grid: x=" << m_view->gridX() << " y=" << m_view->gridY() << oendl; | |
591 | odebug << "Size of view: " << m_view->size() << oendl; | ||
592 | |||
593 | switch (m_mode) { | ||
594 | case 2: | ||
595 | m_view->setGridX(80); | ||
596 | m_view->setGridY(80); | ||
597 | break; | ||
598 | case 3: | ||
599 | m_view->setGridX(m_view->width()); | ||
600 | m_view->setGridY(8); | ||
601 | break; | ||
602 | case 1: | ||
603 | default: | ||
604 | m_view->setGridX(m_view->width()); | ||
605 | m_view->setGridY(80); | ||
606 | break; | ||
607 | } | ||
552 | } | 608 | } |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 5ba4c8e..4852bf6 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -102,27 +102,26 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | |||
102 | 102 | ||
103 | 103 | ||
104 | 104 | ||
105 | prevButton = new QToolButton(bar); | 105 | prevButton = new QToolButton(bar); |
106 | prevButton->setIconSet( Resource::loadIconSet( "back" ) ); | 106 | prevButton->setIconSet( Resource::loadIconSet( "back" ) ); |
107 | connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev())); | 107 | connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev())); |
108 | prevButton->hide(); | ||
109 | 108 | ||
110 | nextButton = new QToolButton(bar); | 109 | nextButton = new QToolButton(bar); |
111 | nextButton->setIconSet( Resource::loadIconSet( "forward" ) ); | 110 | nextButton->setIconSet( Resource::loadIconSet( "forward" ) ); |
112 | connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext())); | 111 | connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext())); |
113 | nextButton->hide(); | ||
114 | 112 | ||
115 | rotateButton = new QToolButton(bar); | 113 | rotateButton = new QToolButton(bar); |
116 | rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); | 114 | rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); |
117 | rotateButton->setToggleButton(true); | 115 | rotateButton->setToggleButton(true); |
118 | 116 | ||
119 | odebug << "Mode = " << m_stack->mode() << oendl; | ||
120 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 117 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
121 | rotateButton->setOn(true); | 118 | rotateButton->setOn(true); |
122 | autoRotate = true; | 119 | autoRotate = true; |
120 | prevButton->hide(); | ||
121 | nextButton->hide(); | ||
123 | } else { | 122 | } else { |
124 | rotateButton->setOn(false); | 123 | rotateButton->setOn(false); |
125 | autoRotate = false; | 124 | autoRotate = false; |
126 | } | 125 | } |
127 | 126 | ||
128 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); | 127 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); |
@@ -296,30 +295,34 @@ void PMainWindow::initDisp() { | |||
296 | */ | 295 | */ |
297 | void PMainWindow::slotShowInfo( const QString& inf ) { | 296 | void PMainWindow::slotShowInfo( const QString& inf ) { |
298 | if ( !m_info ) { | 297 | if ( !m_info ) { |
299 | initInfo(); | 298 | initInfo(); |
300 | } | 299 | } |
301 | m_info->setPath( inf ); | 300 | m_info->setPath( inf ); |
302 | prevButton->hide(); | 301 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
303 | nextButton->hide(); | 302 | prevButton->hide(); |
304 | upButton->hide(); | 303 | nextButton->hide(); |
305 | fsButton->hide(); | 304 | upButton->hide(); |
306 | viewModeButton->hide(); | 305 | fsButton->hide(); |
306 | viewModeButton->hide(); | ||
307 | } | ||
307 | m_stack->raiseWidget( ImageInfo ); | 308 | m_stack->raiseWidget( ImageInfo ); |
308 | } | 309 | } |
309 | 310 | ||
310 | void PMainWindow::slotDisplay( const QString& inf ) { | 311 | void PMainWindow::slotDisplay( const QString& inf ) { |
311 | if ( !m_disp ) { | 312 | if ( !m_disp ) { |
312 | initDisp(); | 313 | initDisp(); |
313 | } | 314 | } |
314 | m_disp->setImage( inf ); | 315 | m_disp->setImage( inf ); |
315 | prevButton->show(); | 316 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
316 | nextButton->show(); | 317 | prevButton->show(); |
317 | upButton->hide(); | 318 | nextButton->show(); |
318 | fsButton->hide(); | 319 | upButton->hide(); |
319 | viewModeButton->hide(); | 320 | fsButton->hide(); |
321 | viewModeButton->hide(); | ||
322 | } | ||
320 | m_stack->raiseWidget( ImageDisplay ); | 323 | m_stack->raiseWidget( ImageDisplay ); |
321 | } | 324 | } |
322 | 325 | ||
323 | void PMainWindow::slotReturn() { | 326 | void PMainWindow::slotReturn() { |
324 | raiseIconView(); | 327 | raiseIconView(); |
325 | } | 328 | } |
@@ -338,17 +341,19 @@ void PMainWindow::closeEvent( QCloseEvent* ev ) { | |||
338 | } | 341 | } |
339 | ev->accept(); | 342 | ev->accept(); |
340 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); | 343 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); |
341 | } | 344 | } |
342 | 345 | ||
343 | void PMainWindow::raiseIconView() { | 346 | void PMainWindow::raiseIconView() { |
344 | prevButton->hide(); | 347 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
345 | nextButton->hide(); | 348 | prevButton->hide(); |
346 | upButton->show(); | 349 | nextButton->hide(); |
347 | fsButton->show(); | 350 | upButton->show(); |
348 | viewModeButton->show(); | 351 | fsButton->show(); |
352 | viewModeButton->show(); | ||
353 | } | ||
349 | m_stack->raiseWidget( IconView ); | 354 | m_stack->raiseWidget( IconView ); |
350 | } | 355 | } |
351 | 356 | ||
352 | void PMainWindow::setDocument( const QString& showImg ) { | 357 | void PMainWindow::setDocument( const QString& showImg ) { |
353 | QString file = showImg; | 358 | QString file = showImg; |
354 | DocLnk lnk(showImg); | 359 | DocLnk lnk(showImg); |