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 | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 2a49786..a06844a 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -32,39 +32,51 @@ | |||
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; | ||
44 | class IconViewItem : public QIconViewItem { | 45 | class IconViewItem : public QIconViewItem { |
45 | public: | 46 | public: |
46 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); | 47 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); |
47 | QPixmap* pixmap()const; | 48 | QPixmap* pixmap()const; |
48 | QString path()const { return m_path; } | 49 | QString path()const { return m_path; } |
49 | bool isDir()const { return m_isDir; } | 50 | bool isDir()const { return m_isDir; } |
50 | void setText( const QString& ); | 51 | void setText( const QString& ); |
51 | 52 | ||
53 | protected: | ||
54 | mutable QPixmap* m_pix; | ||
52 | 55 | ||
53 | private: | 56 | private: |
54 | mutable QPixmap* m_pix; | ||
55 | QString m_path; | 57 | QString m_path; |
56 | bool m_isDir : 1; | 58 | bool m_isDir : 1; |
57 | bool m_noInfo :1; | 59 | bool m_noInfo :1; |
58 | }; | 60 | }; |
61 | class TextViewItem : public IconViewItem { | ||
62 | TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | ||
63 | QPixmap *pixmap()const; | ||
64 | void setText( const QString& ); | ||
65 | }; | ||
66 | class ThumbViewItem : public IconViewItem { | ||
67 | ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | ||
68 | QPixmap *pixmap()const; | ||
69 | void setText( const QString& ); | ||
70 | }; | ||
59 | 71 | ||
60 | 72 | ||
61 | /* | 73 | /* |
62 | * If we request an Image or String | 74 | * If we request an Image or String |
63 | * we add it to the map | 75 | * we add it to the map |
64 | */ | 76 | */ |
65 | static QMap<QString, IconViewItem*> g_stringInf; | 77 | static QMap<QString, IconViewItem*> g_stringInf; |
66 | static QMap<QString, IconViewItem*> g_stringPix; | 78 | static QMap<QString, IconViewItem*> g_stringPix; |
67 | 79 | ||
68 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 80 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
69 | const QString& name, bool isDir ) | 81 | const QString& name, bool isDir ) |
70 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 82 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
@@ -106,24 +118,25 @@ namespace { | |||
106 | 118 | ||
107 | /* | 119 | /* |
108 | * Set up the GUI.. initialize the slave set up gui | 120 | * Set up the GUI.. initialize the slave set up gui |
109 | * and also load a dir | 121 | * and also load a dir |
110 | */ | 122 | */ |
111 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 123 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
112 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) | 124 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) |
113 | { | 125 | { |
114 | { | 126 | { |
115 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 127 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
116 | } | 128 | } |
117 | m_path = QDir::homeDirPath(); | 129 | m_path = QDir::homeDirPath(); |
130 | m_mode = 0; | ||
118 | 131 | ||
119 | QHBox *hbox = new QHBox( this ); | 132 | QHBox *hbox = new QHBox( this ); |
120 | QLabel* lbl = new QLabel( hbox ); | 133 | QLabel* lbl = new QLabel( hbox ); |
121 | lbl->setText( tr("View as" ) ); | 134 | lbl->setText( tr("View as" ) ); |
122 | 135 | ||
123 | m_views = new QComboBox( hbox, "View As" ); | 136 | m_views = new QComboBox( hbox, "View As" ); |
124 | connect( m_views, SIGNAL(activated(int)), | 137 | connect( m_views, SIGNAL(activated(int)), |
125 | this, SLOT(slotViewChanged(int)) ); | 138 | this, SLOT(slotViewChanged(int)) ); |
126 | 139 | ||
127 | m_view= new QIconView( this ); | 140 | m_view= new QIconView( this ); |
128 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), | 141 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), |
129 | this, SLOT(slotClicked(QIconViewItem*)) ); | 142 | this, SLOT(slotClicked(QIconViewItem*)) ); |
@@ -446,12 +459,33 @@ void PIconView::slotShowImage( const QString& name) { | |||
446 | } | 459 | } |
447 | void PIconView::slotImageInfo() { | 460 | void PIconView::slotImageInfo() { |
448 | bool isDir = false; | 461 | bool isDir = false; |
449 | QString name = currentFileName(isDir); | 462 | QString name = currentFileName(isDir); |
450 | if (isDir) return; | 463 | if (isDir) return; |
451 | 464 | ||
452 | slotImageInfo( name ); | 465 | slotImageInfo( name ); |
453 | } | 466 | } |
454 | 467 | ||
455 | void PIconView::slotImageInfo( const QString& name) { | 468 | void PIconView::slotImageInfo( const QString& name) { |
456 | emit sig_showInfo( name ); | 469 | emit sig_showInfo( name ); |
457 | } | 470 | } |
471 | |||
472 | |||
473 | void PIconView::slotChangeMode( int mode ) { | ||
474 | if ( mode >= 0 && mode <= 3 ) | ||
475 | m_mode = mode; | ||
476 | |||
477 | QIconView::ItemTextPos pos; | ||
478 | switch( m_mode ) { | ||
479 | case 1: | ||
480 | pos = QIconView::Bottom; | ||
481 | break; | ||
482 | case 2: | ||
483 | case 0: | ||
484 | default: | ||
485 | pos = QIconView::Right; | ||
486 | break; | ||
487 | } | ||
488 | m_view->setItemTextPos( pos ); | ||
489 | |||
490 | slotReloadDir(); | ||
491 | } | ||