author | zecke <zecke> | 2004-07-24 18:46:24 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-07-24 18:46:24 (UTC) |
commit | 69df55bd0b74c7e59ff40390e2f1d902f882491f (patch) (unidiff) | |
tree | efb617312c1e77ca3990487d727bd283516a2702 | |
parent | 5a8963dff615da61611f5cc4bf410e7a6eeef55b (diff) | |
download | opie-69df55bd0b74c7e59ff40390e2f1d902f882491f.zip opie-69df55bd0b74c7e59ff40390e2f1d902f882491f.tar.gz opie-69df55bd0b74c7e59ff40390e2f1d902f882491f.tar.bz2 |
Try to get the Keyup Event inside the IconView to not 'move'
forward later.
Long Return press triggers autorepeat
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 19 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 211314b..652acc9 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -1,646 +1,665 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "iconview.h" | 6 | #include "iconview.h" |
7 | 7 | ||
8 | #include <lib/imagecache.h> | 8 | #include <lib/imagecache.h> |
9 | #include <gui/imageinfoui.h> | 9 | #include <gui/imageinfoui.h> |
10 | 10 | ||
11 | #include <iface/dirview.h> | 11 | #include <iface/dirview.h> |
12 | #include <iface/dirlister.h> | 12 | #include <iface/dirlister.h> |
13 | 13 | ||
14 | #include <opie2/oconfig.h> | 14 | #include <opie2/oconfig.h> |
15 | #include <opie2/okeyconfigwidget.h> | 15 | #include <opie2/okeyconfigwidget.h> |
16 | #include <opie2/odebug.h> | 16 | #include <opie2/odebug.h> |
17 | #include <opie2/oimagescrollview.h> | 17 | #include <opie2/oimagescrollview.h> |
18 | 18 | ||
19 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
20 | #include <qpe/qpemessagebox.h> | 20 | #include <qpe/qpemessagebox.h> |
21 | #include <qpe/ir.h> | 21 | #include <qpe/ir.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | 24 | ||
25 | #include <qiconview.h> | 25 | #include <qiconview.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qhbox.h> | 27 | #include <qhbox.h> |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | #include <qmainwindow.h> | 31 | #include <qmainwindow.h> |
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 | static QPixmap* _picPix = 0; |
45 | static QPixmap* _emptyPix = 0; | 45 | static QPixmap* _emptyPix = 0; |
46 | class IconViewItem : public QIconViewItem { | 46 | class IconViewItem : public QIconViewItem { |
47 | public: | 47 | public: |
48 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); | 48 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); |
49 | QPixmap* pixmap()const; | 49 | QPixmap* pixmap()const; |
50 | QString path()const { return m_path; } | 50 | QString path()const { return m_path; } |
51 | bool isDir()const { return m_isDir; } | 51 | bool isDir()const { return m_isDir; } |
52 | void setText( const QString& ); | 52 | void setText( const QString& ); |
53 | bool textOnly()const{return m_textOnly;} | 53 | bool textOnly()const{return m_textOnly;} |
54 | void setTextOnly(bool how){m_textOnly=how;} | 54 | void setTextOnly(bool how){m_textOnly=how;} |
55 | /* just for starting recalc of item rect! */ | 55 | /* just for starting recalc of item rect! */ |
56 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); | 56 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); |
57 | /* just for starting recalc of item rect! */ | 57 | /* just for starting recalc of item rect! */ |
58 | virtual void setPixmap( const QPixmap & icon); | 58 | virtual void setPixmap( const QPixmap & icon); |
59 | 59 | ||
60 | protected: | 60 | protected: |
61 | mutable QPixmap* m_pix; | 61 | mutable QPixmap* m_pix; |
62 | 62 | ||
63 | private: | 63 | private: |
64 | QString m_path; | 64 | QString m_path; |
65 | bool m_isDir : 1; | 65 | bool m_isDir : 1; |
66 | bool m_noInfo :1; | 66 | bool m_noInfo :1; |
67 | bool m_textOnly:1; | 67 | bool m_textOnly:1; |
68 | bool m_NameOnly:1; | 68 | bool m_NameOnly:1; |
69 | bool m_Pixset:1; | 69 | bool m_Pixset:1; |
70 | }; | 70 | }; |
71 | class TextViewItem : public IconViewItem { | 71 | class TextViewItem : public IconViewItem { |
72 | TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | 72 | TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); |
73 | QPixmap *pixmap()const; | 73 | QPixmap *pixmap()const; |
74 | void setText( const QString& ); | 74 | void setText( const QString& ); |
75 | }; | 75 | }; |
76 | class ThumbViewItem : public IconViewItem { | 76 | class ThumbViewItem : public IconViewItem { |
77 | ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | 77 | ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); |
78 | QPixmap *pixmap()const; | 78 | QPixmap *pixmap()const; |
79 | void setText( const QString& ); | 79 | void setText( const QString& ); |
80 | }; | 80 | }; |
81 | 81 | ||
82 | 82 | ||
83 | /* | 83 | /* |
84 | * If we request an Image or String | 84 | * If we request an Image or String |
85 | * we add it to the map | 85 | * we add it to the map |
86 | */ | 86 | */ |
87 | static QMap<QString, IconViewItem*> g_stringInf; | 87 | static QMap<QString, IconViewItem*> g_stringInf; |
88 | static QMap<QString, IconViewItem*> g_stringPix; | 88 | static QMap<QString, IconViewItem*> g_stringPix; |
89 | 89 | ||
90 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 90 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
91 | const QString& name, bool isDir ) | 91 | const QString& name, bool isDir ) |
92 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 92 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
93 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) | 93 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) |
94 | { | 94 | { |
95 | if ( isDir && !_dirPix ) | 95 | if ( isDir && !_dirPix ) |
96 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | 96 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); |
97 | else if ( !isDir && !_unkPix ) | 97 | else if ( !isDir && !_unkPix ) |
98 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 98 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); |
99 | } | 99 | } |
100 | 100 | ||
101 | inline void IconViewItem::setPixmap( const QPixmap & icon, bool recalc, bool redraw) | 101 | inline void IconViewItem::setPixmap( const QPixmap & icon, bool recalc, bool redraw) |
102 | { | 102 | { |
103 | m_Pixset = true; | 103 | m_Pixset = true; |
104 | calcRect(text()); | 104 | calcRect(text()); |
105 | } | 105 | } |
106 | inline void IconViewItem::setPixmap( const QPixmap & icon) | 106 | inline void IconViewItem::setPixmap( const QPixmap & icon) |
107 | { | 107 | { |
108 | m_Pixset = true; | 108 | m_Pixset = true; |
109 | calcRect(text()); | 109 | calcRect(text()); |
110 | } | 110 | } |
111 | 111 | ||
112 | inline QPixmap* IconViewItem::pixmap()const { | 112 | inline QPixmap* IconViewItem::pixmap()const { |
113 | // owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() | 113 | // owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() |
114 | // << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() | 114 | // << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() |
115 | // << " " << iconView()->contentsY() << oendl; | 115 | // << " " << iconView()->contentsY() << oendl; |
116 | 116 | ||
117 | if (textOnly()&&!m_isDir) { | 117 | if (textOnly()&&!m_isDir) { |
118 | if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); | 118 | if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); |
119 | return _emptyPix; | 119 | return _emptyPix; |
120 | } | 120 | } |
121 | if ( m_isDir ) | 121 | if ( m_isDir ) |
122 | return _dirPix; | 122 | return _dirPix; |
123 | else{ | 123 | else{ |
124 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { | 124 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { |
125 | currentView()->dirLister()->imageInfo( m_path ); | 125 | currentView()->dirLister()->imageInfo( m_path ); |
126 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); | 126 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); |
127 | } | 127 | } |
128 | 128 | ||
129 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); | 129 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); |
130 | if (!m_pix && !g_stringPix.contains( m_path )) { | 130 | if (!m_pix && !g_stringPix.contains( m_path )) { |
131 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); | 131 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); |
132 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); | 132 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); |
133 | } | 133 | } |
134 | return m_pix ? m_pix : _unkPix; | 134 | return m_pix ? m_pix : _unkPix; |
135 | } | 135 | } |
136 | } | 136 | } |
137 | inline void IconViewItem::setText( const QString& str ) { | 137 | inline void IconViewItem::setText( const QString& str ) { |
138 | QString text = QIconViewItem::text()+"\n"+str; | 138 | QString text = QIconViewItem::text()+"\n"+str; |
139 | m_noInfo = true; | 139 | m_noInfo = true; |
140 | QIconViewItem::setText( text ); | 140 | QIconViewItem::setText( text ); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | /* | 145 | /* |
146 | * Set up the GUI.. initialize the slave set up gui | 146 | * Set up the GUI.. initialize the slave set up gui |
147 | * and also load a dir | 147 | * and also load a dir |
148 | */ | 148 | */ |
149 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 149 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
150 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) | 150 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) |
151 | { | 151 | { |
152 | { | 152 | { |
153 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 153 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
154 | } | 154 | } |
155 | m_path = QDir::homeDirPath(); | 155 | m_path = QDir::homeDirPath(); |
156 | m_mode = 0; | 156 | m_mode = 0; |
157 | 157 | ||
158 | QHBox *hbox = new QHBox( this ); | 158 | QHBox *hbox = new QHBox( this ); |
159 | QLabel* lbl = new QLabel( hbox ); | 159 | QLabel* lbl = new QLabel( hbox ); |
160 | lbl->setText( tr("View as" ) ); | 160 | lbl->setText( tr("View as" ) ); |
161 | 161 | ||
162 | m_views = new QComboBox( hbox, "View As" ); | 162 | m_views = new QComboBox( hbox, "View As" ); |
163 | 163 | ||
164 | m_view= new QIconView( this ); | 164 | m_view= new QIconView( this ); |
165 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), | 165 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), |
166 | this, SLOT(slotClicked(QIconViewItem*)) ); | 166 | this, SLOT(slotClicked(QIconViewItem*)) ); |
167 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), | 167 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), |
168 | this, SLOT(slotClicked(QIconViewItem*)) ); | 168 | this, SLOT(slotClicked(QIconViewItem*)) ); |
169 | 169 | ||
170 | m_view->setArrangement( QIconView::LeftToRight ); | 170 | m_view->setArrangement( QIconView::LeftToRight ); |
171 | 171 | ||
172 | m_mode = m_cfg->readNumEntry("ListViewMode", 1); | 172 | m_mode = m_cfg->readNumEntry("ListViewMode", 1); |
173 | QString lastView = m_cfg->readEntry("LastView",""); | 173 | QString lastView = m_cfg->readEntry("LastView",""); |
174 | 174 | ||
175 | if (m_mode < 1 || m_mode>3) m_mode = 1; | 175 | if (m_mode < 1 || m_mode>3) m_mode = 1; |
176 | 176 | ||
177 | m_view->setItemTextPos( QIconView::Right ); | 177 | m_view->setItemTextPos( QIconView::Right ); |
178 | 178 | ||
179 | calculateGrid(); | 179 | calculateGrid(); |
180 | 180 | ||
181 | initKeys(); | 181 | initKeys(); |
182 | 182 | ||
183 | loadViews(); | 183 | loadViews(); |
184 | int cc=0; | 184 | int cc=0; |
185 | for (; cc<m_views->count();++cc) { | 185 | for (; cc<m_views->count();++cc) { |
186 | if (m_views->text(cc)==lastView) { | 186 | if (m_views->text(cc)==lastView) { |
187 | break; | 187 | break; |
188 | } | 188 | } |
189 | } | 189 | } |
190 | if (cc<m_views->count()) { | 190 | if (cc<m_views->count()) { |
191 | m_views->setCurrentItem(cc); | 191 | m_views->setCurrentItem(cc); |
192 | slotViewChanged(cc); | 192 | slotViewChanged(cc); |
193 | } else { | 193 | } else { |
194 | slotViewChanged(m_views->currentItem()); | 194 | slotViewChanged(m_views->currentItem()); |
195 | } | 195 | } |
196 | connect( m_views, SIGNAL(activated(int)), | 196 | connect( m_views, SIGNAL(activated(int)), |
197 | this, SLOT(slotViewChanged(int)) ); | 197 | this, SLOT(slotViewChanged(int)) ); |
198 | } | 198 | } |
199 | 199 | ||
200 | /* | 200 | /* |
201 | * Unref the slave and save the keyboard manager | 201 | * Unref the slave and save the keyboard manager |
202 | */ | 202 | */ |
203 | PIconView::~PIconView() { | 203 | PIconView::~PIconView() { |
204 | { | 204 | { |
205 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 205 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
206 | } | 206 | } |
207 | m_viewManager->save(); | 207 | m_viewManager->save(); |
208 | delete m_viewManager; | 208 | delete m_viewManager; |
209 | } | 209 | } |
210 | 210 | ||
211 | Opie::Core::OKeyConfigManager* PIconView::manager() { | 211 | Opie::Core::OKeyConfigManager* PIconView::manager() { |
212 | return m_viewManager; | 212 | return m_viewManager; |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | /* | 216 | /* |
217 | * init the KeyBoard Shortcuts | 217 | * init the KeyBoard Shortcuts |
218 | * called from the c'tor | 218 | * called from the c'tor |
219 | */ | 219 | */ |
220 | void PIconView::initKeys() { | 220 | void PIconView::initKeys() { |
221 | Opie::Core::OKeyPair::List lst; | 221 | Opie::Core::OKeyPair::List lst; |
222 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 222 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
223 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 223 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
224 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 224 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
225 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 225 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
226 | lst.append( Opie::Core::OKeyPair::returnKey() ); | 226 | lst.append( Opie::Core::OKeyPair::returnKey() ); |
227 | 227 | ||
228 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", | 228 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", |
229 | lst, false,this, "keyconfig name" ); | 229 | lst, false,this, "keyconfig name" ); |
230 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", | 230 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", |
231 | Resource::loadPixmap("beam"), BeamItem, | 231 | Resource::loadPixmap("beam"), BeamItem, |
232 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), | 232 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), |
233 | this, SLOT(slotBeam())) ); | 233 | this, SLOT(slotBeam())) ); |
234 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", | 234 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", |
235 | Resource::loadPixmap("trash"), DeleteItem, | 235 | Resource::loadPixmap("trash"), DeleteItem, |
236 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), | 236 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), |
237 | this, SLOT(slotTrash())) ); | 237 | this, SLOT(slotTrash())) ); |
238 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", | 238 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", |
239 | Resource::loadPixmap("1to1"), ViewItem, | 239 | Resource::loadPixmap("1to1"), ViewItem, |
240 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), | 240 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), |
241 | this, SLOT(slotShowImage()))); | 241 | this, SLOT(slotShowImage()))); |
242 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", | 242 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", |
243 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, | 243 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, |
244 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | 244 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), |
245 | this, SLOT(slotImageInfo()) ) ); | 245 | this, SLOT(slotImageInfo()) ) ); |
246 | m_viewManager->load(); | 246 | m_viewManager->load(); |
247 | m_viewManager->handleWidget( m_view ); | 247 | m_viewManager->handleWidget( m_view ); |
248 | } | 248 | } |
249 | 249 | ||
250 | 250 | ||
251 | /* | 251 | /* |
252 | * change one dir up | 252 | * change one dir up |
253 | */ | 253 | */ |
254 | void PIconView::slotDirUp() | 254 | void PIconView::slotDirUp() |
255 | { | 255 | { |
256 | if (m_path.isEmpty()) return; | 256 | if (m_path.isEmpty()) return; |
257 | QDir dir( m_path ); | 257 | QDir dir( m_path ); |
258 | dir.cdUp(); | 258 | dir.cdUp(); |
259 | slotChangeDir( dir.absPath() ); | 259 | slotChangeDir( dir.absPath() ); |
260 | } | 260 | } |
261 | 261 | ||
262 | /* | 262 | /* |
263 | * change the dir | 263 | * change the dir |
264 | */ | 264 | */ |
265 | void PIconView::slotChangeDir(const QString& path) { | 265 | void PIconView::slotChangeDir(const QString& path) { |
266 | if ( !currentView() ) | 266 | if ( !currentView() ) |
267 | return; | 267 | return; |
268 | 268 | ||
269 | PDirLister *lister = currentView()->dirLister(); | 269 | PDirLister *lister = currentView()->dirLister(); |
270 | if (!lister ) | 270 | if (!lister ) |
271 | return; | 271 | return; |
272 | 272 | ||
273 | /* | 273 | /* |
274 | * Say what we want and take what we get | 274 | * Say what we want and take what we get |
275 | */ | 275 | */ |
276 | lister->setStartPath( path ); | 276 | lister->setStartPath( path ); |
277 | m_path = lister->currentPath(); | 277 | m_path = lister->currentPath(); |
278 | 278 | ||
279 | m_view->viewport()->setUpdatesEnabled( false ); | 279 | m_view->viewport()->setUpdatesEnabled( false ); |
280 | m_view->clear(); | 280 | m_view->clear(); |
281 | 281 | ||
282 | /* | 282 | /* |
283 | * add files and folders | 283 | * add files and folders |
284 | */ | 284 | */ |
285 | addFolders( lister->folders() ); | 285 | addFolders( lister->folders() ); |
286 | addFiles( lister->files() ); | 286 | addFiles( lister->files() ); |
287 | m_view->viewport()->setUpdatesEnabled( true ); | 287 | m_view->viewport()->setUpdatesEnabled( true ); |
288 | 288 | ||
289 | // Also invalidate the cache. We can't cancel the operations anyway | 289 | // Also invalidate the cache. We can't cancel the operations anyway |
290 | g_stringPix.clear(); | 290 | g_stringPix.clear(); |
291 | g_stringInf.clear(); | 291 | g_stringInf.clear(); |
292 | 292 | ||
293 | // looks ugly | 293 | // looks ugly |
294 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); | 294 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); |
295 | } | 295 | } |
296 | 296 | ||
297 | /** | 297 | /** |
298 | * get the current file name | 298 | * get the current file name |
299 | * @param isDir see if this is a dir or real file | 299 | * @param isDir see if this is a dir or real file |
300 | */ | 300 | */ |
301 | QString PIconView::currentFileName(bool &isDir)const { | 301 | QString PIconView::currentFileName(bool &isDir)const { |
302 | isDir = false; | 302 | isDir = false; |
303 | QIconViewItem* _it = m_view->currentItem(); | 303 | QIconViewItem* _it = m_view->currentItem(); |
304 | if ( !_it ) | 304 | if ( !_it ) |
305 | return QString::null; | 305 | return QString::null; |
306 | 306 | ||
307 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 307 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
308 | isDir = it->isDir(); | 308 | isDir = it->isDir(); |
309 | return it->path(); | 309 | return it->path(); |
310 | } | 310 | } |
311 | 311 | ||
312 | QString PIconView::nextFileName(bool &isDir)const | 312 | QString PIconView::nextFileName(bool &isDir)const |
313 | { | 313 | { |
314 | isDir = false; | 314 | isDir = false; |
315 | QIconViewItem* _it1 = m_view->currentItem(); | 315 | QIconViewItem* _it1 = m_view->currentItem(); |
316 | if ( !_it1 ) | 316 | if ( !_it1 ) |
317 | return QString::null; | 317 | return QString::null; |
318 | QIconViewItem* _it = _it1->nextItem(); | 318 | QIconViewItem* _it = _it1->nextItem(); |
319 | if ( !_it ) | 319 | if ( !_it ) |
320 | return QString::null; | 320 | return QString::null; |
321 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 321 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
322 | isDir = it->isDir(); | 322 | isDir = it->isDir(); |
323 | return it->path(); | 323 | return it->path(); |
324 | } | 324 | } |
325 | 325 | ||
326 | QString PIconView::prevFileName(bool &isDir)const{ | 326 | QString PIconView::prevFileName(bool &isDir)const{ |
327 | isDir = false; | 327 | isDir = false; |
328 | QIconViewItem* _it = m_view->currentItem(); | 328 | QIconViewItem* _it = m_view->currentItem(); |
329 | if ( !_it ) | 329 | if ( !_it ) |
330 | return QString::null; | 330 | return QString::null; |
331 | _it = _it->prevItem(); | 331 | _it = _it->prevItem(); |
332 | if ( !_it ) | 332 | if ( !_it ) |
333 | return QString::null; | 333 | return QString::null; |
334 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 334 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
335 | isDir = it->isDir(); | 335 | isDir = it->isDir(); |
336 | return it->path(); | 336 | return it->path(); |
337 | } | 337 | } |
338 | 338 | ||
339 | void PIconView::slotTrash() { | 339 | void PIconView::slotTrash() { |
340 | bool isDir; | 340 | bool isDir; |
341 | QString pa = currentFileName( isDir ); | 341 | QString pa = currentFileName( isDir ); |
342 | if ( isDir && pa.isEmpty() ) | 342 | if ( isDir && pa.isEmpty() ) |
343 | return; | 343 | return; |
344 | 344 | ||
345 | if (!QPEMessageBox::confirmDelete( this, | 345 | if (!QPEMessageBox::confirmDelete( this, |
346 | tr("Delete Image" ), | 346 | tr("Delete Image" ), |
347 | tr("the Image %1" ).arg(pa))) | 347 | tr("the Image %1" ).arg(pa))) |
348 | return | 348 | return |
349 | 349 | ||
350 | 350 | ||
351 | currentView()->dirLister()->deleteImage( pa ); | 351 | currentView()->dirLister()->deleteImage( pa ); |
352 | delete m_view->currentItem(); | 352 | delete m_view->currentItem(); |
353 | } | 353 | } |
354 | 354 | ||
355 | /* | 355 | /* |
356 | * see what views are available | 356 | * see what views are available |
357 | */ | 357 | */ |
358 | void PIconView::loadViews() { | 358 | void PIconView::loadViews() { |
359 | ViewMap::Iterator it; | 359 | ViewMap::Iterator it; |
360 | ViewMap* map = viewMap(); | 360 | ViewMap* map = viewMap(); |
361 | for ( it = map->begin(); it != map->end(); ++it ) | 361 | for ( it = map->begin(); it != map->end(); ++it ) |
362 | m_views->insertItem( it.key() ); | 362 | m_views->insertItem( it.key() ); |
363 | } | 363 | } |
364 | 364 | ||
365 | void PIconView::resetView() { | 365 | void PIconView::resetView() { |
366 | slotViewChanged(m_views->currentItem()); | 366 | slotViewChanged(m_views->currentItem()); |
367 | } | 367 | } |
368 | 368 | ||
369 | /* | 369 | /* |
370 | *swicth view reloadDir and connect signals | 370 | *swicth view reloadDir and connect signals |
371 | */ | 371 | */ |
372 | void PIconView::slotViewChanged( int i) { | 372 | void PIconView::slotViewChanged( int i) { |
373 | if (!m_views->count() ) { | 373 | if (!m_views->count() ) { |
374 | setCurrentView( 0l); | 374 | setCurrentView( 0l); |
375 | return; | 375 | return; |
376 | } | 376 | } |
377 | 377 | ||
378 | PDirView* cur = currentView(); | 378 | PDirView* cur = currentView(); |
379 | if (cur) delete cur; | 379 | if (cur) delete cur; |
380 | QString str = m_views->text(i); | 380 | QString str = m_views->text(i); |
381 | ViewMap* map = viewMap(); | 381 | ViewMap* map = viewMap(); |
382 | if (!map) {setCurrentView(0l); return;} | 382 | if (!map) {setCurrentView(0l); return;} |
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); return; |
386 | } | 386 | } |
387 | m_cfg->writeEntry("LastView",str); | 387 | m_cfg->writeEntry("LastView",str); |
388 | m_cfg->write(); | 388 | m_cfg->write(); |
389 | cur = (*(*map)[str])(*m_cfg); | 389 | cur = (*(*map)[str])(*m_cfg); |
390 | setCurrentView( cur ); | 390 | setCurrentView( cur ); |
391 | 391 | ||
392 | /* connect to the signals of the lister */ | 392 | /* connect to the signals of the lister */ |
393 | PDirLister* lis = cur->dirLister(); | 393 | PDirLister* lis = cur->dirLister(); |
394 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 394 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
395 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 395 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
396 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 396 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
397 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 397 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
398 | connect(lis, SIGNAL(sig_start()), | 398 | connect(lis, SIGNAL(sig_start()), |
399 | this, SLOT(slotStart())); | 399 | this, SLOT(slotStart())); |
400 | connect(lis, SIGNAL(sig_end()) , | 400 | connect(lis, SIGNAL(sig_end()) , |
401 | this, SLOT(slotEnd()) ); | 401 | this, SLOT(slotEnd()) ); |
402 | 402 | ||
403 | 403 | ||
404 | /* reload now */ | 404 | /* reload now */ |
405 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 405 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
406 | } | 406 | } |
407 | 407 | ||
408 | 408 | ||
409 | void PIconView::slotReloadDir() { | 409 | void PIconView::slotReloadDir() { |
410 | slotChangeDir( m_path ); | 410 | slotChangeDir( m_path ); |
411 | } | 411 | } |
412 | 412 | ||
413 | 413 | ||
414 | /* | 414 | /* |
415 | * add files and folders | 415 | * add files and folders |
416 | */ | 416 | */ |
417 | void PIconView::addFolders( const QStringList& lst) { | 417 | void PIconView::addFolders( const QStringList& lst) { |
418 | QStringList::ConstIterator it; | 418 | QStringList::ConstIterator it; |
419 | IconViewItem * _iv; | 419 | IconViewItem * _iv; |
420 | 420 | ||
421 | for(it=lst.begin(); it != lst.end(); ++it ) { | 421 | for(it=lst.begin(); it != lst.end(); ++it ) { |
422 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); | 422 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); |
423 | if (m_mode==3) _iv->setTextOnly(true); | 423 | if (m_mode==3) _iv->setTextOnly(true); |
424 | } | 424 | } |
425 | } | 425 | } |
426 | 426 | ||
427 | void PIconView::addFiles( const QStringList& lst) { | 427 | void PIconView::addFiles( const QStringList& lst) { |
428 | QStringList::ConstIterator it; | 428 | QStringList::ConstIterator it; |
429 | IconViewItem * _iv; | 429 | IconViewItem * _iv; |
430 | QPixmap*m_pix = 0; | 430 | QPixmap*m_pix = 0; |
431 | QString pre = ""; | 431 | QString pre = ""; |
432 | if (!m_path.isEmpty()) { | 432 | if (!m_path.isEmpty()) { |
433 | pre = m_path+"/"; | 433 | pre = m_path+"/"; |
434 | } | 434 | } |
435 | for (it=lst.begin(); it!= lst.end(); ++it ) { | 435 | for (it=lst.begin(); it!= lst.end(); ++it ) { |
436 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 ); | 436 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 ); |
437 | _iv = new IconViewItem( m_view, pre+(*it), (*it) ); | 437 | _iv = new IconViewItem( m_view, pre+(*it), (*it) ); |
438 | if (m_mode==3) { | 438 | if (m_mode==3) { |
439 | _iv->setTextOnly(true); | 439 | _iv->setTextOnly(true); |
440 | _iv->setPixmap(QPixmap()); | 440 | _iv->setPixmap(QPixmap()); |
441 | |||
442 | |||
443 | |||
441 | } else { | 444 | } else { |
442 | if (m_pix) _iv->setPixmap(*m_pix); | 445 | if (m_pix) _iv->setPixmap(*m_pix); |
443 | } | 446 | } |
444 | } | 447 | } |
445 | 448 | ||
446 | } | 449 | } |
447 | 450 | ||
448 | /* | 451 | /* |
449 | * user clicked on the item. Change dir or view | 452 | * user clicked on the item. Change dir or view |
450 | */ | 453 | */ |
451 | void PIconView::slotClicked(QIconViewItem* _it) { | 454 | void PIconView::slotClicked(QIconViewItem* _it) { |
452 | if(!_it ) | 455 | if(!_it ) |
453 | return; | 456 | return; |
454 | 457 | ||
455 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 458 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
456 | if( it->isDir() ) | 459 | if( it->isDir() ) |
457 | slotChangeDir( it->path() ); | 460 | slotChangeDir( it->path() ); |
458 | else // view image | 461 | else // view image |
459 | slotShowImage(); | 462 | slotShowImage(); |
460 | } | 463 | } |
461 | 464 | ||
462 | /* | 465 | /* |
466 | * Return was pressed. which is triggered by the keydown | ||
467 | * handler. The problem is that the key up will be handled | ||
468 | * by the ImageDisplayer and goes to the next image | ||
469 | */ | ||
470 | void PIconView::slotRetrun( QIconViewItem *_it ) { | ||
471 | if(!_it ) | ||
472 | return; | ||
473 | |||
474 | IconViewItem* it = static_cast<IconViewItem*>(_it); | ||
475 | if( it->isDir() ) | ||
476 | slotChangeDir( it->path() ); | ||
477 | else | ||
478 | QTimer::singleShot(0, this, SLOT(slotShowImage()) ); | ||
479 | } | ||
480 | |||
481 | /* | ||
463 | * got thumb info add to the cache if items is visible | 482 | * got thumb info add to the cache if items is visible |
464 | * we later need update after processing of slave is done | 483 | * we later need update after processing of slave is done |
465 | */ | 484 | */ |
466 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 485 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
467 | IconViewItem* item = g_stringInf[_path]; | 486 | IconViewItem* item = g_stringInf[_path]; |
468 | if (!item ) | 487 | if (!item ) |
469 | return; | 488 | return; |
470 | 489 | ||
471 | if (m_mode == 2) { | 490 | if (m_mode == 2) { |
472 | return; | 491 | return; |
473 | } | 492 | } |
474 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 493 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
475 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 494 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
476 | m_updatet = true; | 495 | m_updatet = true; |
477 | 496 | ||
478 | item->setText( str ); | 497 | item->setText( str ); |
479 | g_stringInf.remove( _path ); | 498 | g_stringInf.remove( _path ); |
480 | } | 499 | } |
481 | 500 | ||
482 | /* | 501 | /* |
483 | * got thumbnail and see if it is visible so we need to update later | 502 | * got thumbnail and see if it is visible so we need to update later |
484 | */ | 503 | */ |
485 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | 504 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { |
486 | IconViewItem* item = g_stringPix[_path]; | 505 | IconViewItem* item = g_stringPix[_path]; |
487 | if (!item ) | 506 | if (!item ) |
488 | return; | 507 | return; |
489 | 508 | ||
490 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 509 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
491 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 510 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
492 | m_updatet = true; | 511 | m_updatet = true; |
493 | 512 | ||
494 | if (pix.width()>0) { | 513 | if (pix.width()>0) { |
495 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); | 514 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); |
496 | item->setPixmap(pix,true); | 515 | item->setPixmap(pix,true); |
497 | } else { | 516 | } else { |
498 | PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), 64, 64 ); | 517 | PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), 64, 64 ); |
499 | } | 518 | } |
500 | g_stringPix.remove( _path ); | 519 | g_stringPix.remove( _path ); |
501 | } | 520 | } |
502 | 521 | ||
503 | 522 | ||
504 | /* | 523 | /* |
505 | * FIXME rename | 524 | * FIXME rename |
506 | */ | 525 | */ |
507 | void PIconView::slotRename() { | 526 | void PIconView::slotRename() { |
508 | 527 | ||
509 | } | 528 | } |
510 | 529 | ||
511 | 530 | ||
512 | /* | 531 | /* |
513 | * BEAM the current file | 532 | * BEAM the current file |
514 | */ | 533 | */ |
515 | void PIconView::slotBeam() { | 534 | void PIconView::slotBeam() { |
516 | bool isDir; | 535 | bool isDir; |
517 | QString pa = currentFileName( isDir ); | 536 | QString pa = currentFileName( isDir ); |
518 | if ( isDir && pa.isEmpty() ) | 537 | if ( isDir && pa.isEmpty() ) |
519 | return; | 538 | return; |
520 | 539 | ||
521 | Ir* ir = new Ir( this ); | 540 | Ir* ir = new Ir( this ); |
522 | connect( ir, SIGNAL(done(Ir*)), | 541 | connect( ir, SIGNAL(done(Ir*)), |
523 | this, SLOT(slotBeamDone(Ir*))); | 542 | this, SLOT(slotBeamDone(Ir*))); |
524 | ir->send(pa, tr( "Image" ) ); | 543 | ir->send(pa, tr( "Image" ) ); |
525 | } | 544 | } |
526 | 545 | ||
527 | /* | 546 | /* |
528 | * BEAM done clean up | 547 | * BEAM done clean up |
529 | */ | 548 | */ |
530 | void PIconView::slotBeamDone( Ir* ir) { | 549 | void PIconView::slotBeamDone( Ir* ir) { |
531 | delete ir; | 550 | delete ir; |
532 | } | 551 | } |
533 | 552 | ||
534 | void PIconView::slotStart() { | 553 | void PIconView::slotStart() { |
535 | m_view->viewport()->setUpdatesEnabled( false ); | 554 | m_view->viewport()->setUpdatesEnabled( false ); |
536 | } | 555 | } |
537 | 556 | ||
538 | void PIconView::slotEnd() { | 557 | void PIconView::slotEnd() { |
539 | if ( m_updatet ) | 558 | if ( m_updatet ) |
540 | m_view->arrangeItemsInGrid( ); | 559 | m_view->arrangeItemsInGrid( ); |
541 | m_view->viewport()->setUpdatesEnabled( true ); | 560 | m_view->viewport()->setUpdatesEnabled( true ); |
542 | m_updatet = false; | 561 | m_updatet = false; |
543 | } | 562 | } |
544 | 563 | ||
545 | void PIconView::slotShowNext() | 564 | void PIconView::slotShowNext() |
546 | { | 565 | { |
547 | bool isDir = false; | 566 | bool isDir = false; |
548 | QString name = nextFileName(isDir); | 567 | QString name = nextFileName(isDir); |
549 | if (name.isEmpty()) return; | 568 | if (name.isEmpty()) return; |
550 | if (isDir) return; | 569 | if (isDir) return; |
551 | /* if we got a name we have a next item */ | 570 | /* if we got a name we have a next item */ |
552 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 571 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
553 | slotShowImage(name); | 572 | slotShowImage(name); |
554 | } | 573 | } |
555 | 574 | ||
556 | void PIconView::slotShowPrev() | 575 | void PIconView::slotShowPrev() |
557 | { | 576 | { |
558 | bool isDir = false; | 577 | bool isDir = false; |
559 | QString name = prevFileName(isDir); | 578 | QString name = prevFileName(isDir); |
560 | if (name.isEmpty()) return; | 579 | if (name.isEmpty()) return; |
561 | if (isDir) return; | 580 | if (isDir) return; |
562 | /* if we got a name we have a prev item */ | 581 | /* if we got a name we have a prev item */ |
563 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 582 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
564 | slotShowImage(name); | 583 | slotShowImage(name); |
565 | } | 584 | } |
566 | 585 | ||
567 | void PIconView::slotShowImage() | 586 | void PIconView::slotShowImage() |
568 | { | 587 | { |
569 | bool isDir = false; | 588 | bool isDir = false; |
570 | QString name = currentFileName(isDir); | 589 | QString name = currentFileName(isDir); |
571 | if (isDir) return; | 590 | if (isDir) return; |
572 | slotShowImage( name ); | 591 | slotShowImage( name ); |
573 | } | 592 | } |
574 | void PIconView::slotShowImage( const QString& name) { | 593 | void PIconView::slotShowImage( const QString& name) { |
575 | PDirLister *lister = currentView()->dirLister(); | 594 | PDirLister *lister = currentView()->dirLister(); |
576 | QString r_name = lister->nameToFname(name); | 595 | QString r_name = lister->nameToFname(name); |
577 | emit sig_display( r_name ); | 596 | emit sig_display( r_name ); |
578 | } | 597 | } |
579 | void PIconView::slotImageInfo() { | 598 | void PIconView::slotImageInfo() { |
580 | bool isDir = false; | 599 | bool isDir = false; |
581 | QString name = currentFileName(isDir); | 600 | QString name = currentFileName(isDir); |
582 | if (isDir) return; | 601 | if (isDir) return; |
583 | 602 | ||
584 | slotImageInfo( name ); | 603 | slotImageInfo( name ); |
585 | } | 604 | } |
586 | 605 | ||
587 | void PIconView::slotImageInfo( const QString& name) { | 606 | void PIconView::slotImageInfo( const QString& name) { |
588 | PDirLister *lister = currentView()->dirLister(); | 607 | PDirLister *lister = currentView()->dirLister(); |
589 | QString r_name = lister->nameToFname(name); | 608 | QString r_name = lister->nameToFname(name); |
590 | emit sig_showInfo(r_name ); | 609 | emit sig_showInfo(r_name ); |
591 | } | 610 | } |
592 | 611 | ||
593 | 612 | ||
594 | void PIconView::slotChangeMode( int mode ) { | 613 | void PIconView::slotChangeMode( int mode ) { |
595 | if ( mode >= 1 && mode <= 3 ) | 614 | if ( mode >= 1 && mode <= 3 ) |
596 | m_mode = mode; | 615 | m_mode = mode; |
597 | 616 | ||
598 | m_cfg->writeEntry("ListViewMode", m_mode); | 617 | m_cfg->writeEntry("ListViewMode", m_mode); |
599 | /* performance! */ | 618 | /* performance! */ |
600 | m_view->clear(); | 619 | m_view->clear(); |
601 | calculateGrid(); | 620 | calculateGrid(); |
602 | slotReloadDir(); | 621 | slotReloadDir(); |
603 | } | 622 | } |
604 | 623 | ||
605 | 624 | ||
606 | void PIconView::resizeEvent( QResizeEvent* re ) { | 625 | void PIconView::resizeEvent( QResizeEvent* re ) { |
607 | QVBox::resizeEvent( re ); | 626 | QVBox::resizeEvent( re ); |
608 | calculateGrid(); | 627 | calculateGrid(); |
609 | } | 628 | } |
610 | 629 | ||
611 | 630 | ||
612 | void PIconView::calculateGrid() { | 631 | void PIconView::calculateGrid() { |
613 | int dw = QApplication::desktop()->width(); | 632 | int dw = QApplication::desktop()->width(); |
614 | int viewerWidth = dw-style().scrollBarExtent().width(); | 633 | int viewerWidth = dw-style().scrollBarExtent().width(); |
615 | 634 | ||
616 | QIconView::ItemTextPos pos; | 635 | QIconView::ItemTextPos pos; |
617 | switch( m_mode ) { | 636 | switch( m_mode ) { |
618 | case 2: | 637 | case 2: |
619 | pos = QIconView::Bottom; | 638 | pos = QIconView::Bottom; |
620 | break; | 639 | break; |
621 | case 3: | 640 | case 3: |
622 | case 1: | 641 | case 1: |
623 | default: | 642 | default: |
624 | pos = QIconView::Right; | 643 | pos = QIconView::Right; |
625 | break; | 644 | break; |
626 | } | 645 | } |
627 | m_view->setItemTextPos( pos ); | 646 | m_view->setItemTextPos( pos ); |
628 | switch (m_mode) { | 647 | switch (m_mode) { |
629 | case 2: | 648 | case 2: |
630 | m_view->setGridX(50); | 649 | m_view->setGridX(50); |
631 | m_view->setGridY(20); | 650 | m_view->setGridY(20); |
632 | PPixmapCache::self()->setMaxImages(40); | 651 | PPixmapCache::self()->setMaxImages(40); |
633 | break; | 652 | break; |
634 | case 3: | 653 | case 3: |
635 | m_view->setGridX( fontMetrics().width("testimage.jpg")+20); | 654 | m_view->setGridX( fontMetrics().width("testimage.jpg")+20); |
636 | m_view->setGridY(8); | 655 | m_view->setGridY(8); |
637 | PPixmapCache::self()->setMaxImages(2); | 656 | PPixmapCache::self()->setMaxImages(2); |
638 | break; | 657 | break; |
639 | case 1: | 658 | case 1: |
640 | default: | 659 | default: |
641 | m_view->setGridX( viewerWidth-3*m_view->spacing()); | 660 | m_view->setGridX( viewerWidth-3*m_view->spacing()); |
642 | m_view->setGridY( fontMetrics().height()*2+40 ); | 661 | m_view->setGridY( fontMetrics().height()*2+40 ); |
643 | PPixmapCache::self()->setMaxImages(20); | 662 | PPixmapCache::self()->setMaxImages(20); |
644 | break; | 663 | break; |
645 | } | 664 | } |
646 | } | 665 | } |
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h index 14ad168..a424c5c 100644 --- a/noncore/graphics/opie-eye/gui/iconview.h +++ b/noncore/graphics/opie-eye/gui/iconview.h | |||
@@ -1,95 +1,96 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #ifndef PHUNK_ICON_VIEW_H | 6 | #ifndef PHUNK_ICON_VIEW_H |
7 | #define PHUNK_ICON_VIEW_H | 7 | #define PHUNK_ICON_VIEW_H |
8 | 8 | ||
9 | #include <qvbox.h> | 9 | #include <qvbox.h> |
10 | 10 | ||
11 | 11 | ||
12 | class QIconView; | 12 | class QIconView; |
13 | class QIconViewItem; | 13 | class QIconViewItem; |
14 | class QComboBox; | 14 | class QComboBox; |
15 | class PIconViewItem; | 15 | class PIconViewItem; |
16 | class PDirLister; | 16 | class PDirLister; |
17 | class Ir; | 17 | class Ir; |
18 | 18 | ||
19 | namespace Opie { | 19 | namespace Opie { |
20 | namespace Core{ | 20 | namespace Core{ |
21 | class OConfig; | 21 | class OConfig; |
22 | class OKeyConfigManager; | 22 | class OKeyConfigManager; |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | class PIconView : public QVBox { | 26 | class PIconView : public QVBox { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | friend class PIconViewItem; | 28 | friend class PIconViewItem; |
29 | enum ActionIds { | 29 | enum ActionIds { |
30 | BeamItem, DeleteItem, ViewItem, InfoItem | 30 | BeamItem, DeleteItem, ViewItem, InfoItem |
31 | }; | 31 | }; |
32 | public: | 32 | public: |
33 | PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); | 33 | PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); |
34 | ~PIconView(); | 34 | ~PIconView(); |
35 | void resetView(); | 35 | void resetView(); |
36 | Opie::Core::OKeyConfigManager* manager(); | 36 | Opie::Core::OKeyConfigManager* manager(); |
37 | 37 | ||
38 | signals: | 38 | signals: |
39 | void sig_showInfo( const QString& ); | 39 | void sig_showInfo( const QString& ); |
40 | void sig_display( const QString& ); | 40 | void sig_display( const QString& ); |
41 | 41 | ||
42 | public slots: | 42 | public slots: |
43 | virtual void slotShowNext(); | 43 | virtual void slotShowNext(); |
44 | virtual void slotShowPrev(); | 44 | virtual void slotShowPrev(); |
45 | 45 | ||
46 | protected: | 46 | protected: |
47 | void resizeEvent( QResizeEvent* ); | 47 | void resizeEvent( QResizeEvent* ); |
48 | 48 | ||
49 | private: | 49 | private: |
50 | void initKeys(); | 50 | void initKeys(); |
51 | QString currentFileName(bool &isDir)const; | 51 | QString currentFileName(bool &isDir)const; |
52 | QString nextFileName(bool &isDir)const; | 52 | QString nextFileName(bool &isDir)const; |
53 | QString prevFileName(bool &isDir)const; | 53 | QString prevFileName(bool &isDir)const; |
54 | void loadViews(); | 54 | void loadViews(); |
55 | void calculateGrid(); | 55 | void calculateGrid(); |
56 | 56 | ||
57 | private slots: | 57 | private slots: |
58 | void slotDirUp(); | 58 | void slotDirUp(); |
59 | void slotChangeDir(const QString&); | 59 | void slotChangeDir(const QString&); |
60 | void slotTrash(); | 60 | void slotTrash(); |
61 | void slotViewChanged( int ); | 61 | void slotViewChanged( int ); |
62 | void slotReloadDir(); | 62 | void slotReloadDir(); |
63 | void slotRename(); | 63 | void slotRename(); |
64 | void slotBeam(); | 64 | void slotBeam(); |
65 | void slotBeamDone( Ir* ); | 65 | void slotBeamDone( Ir* ); |
66 | 66 | ||
67 | void slotShowImage(); | 67 | void slotShowImage(); |
68 | void slotShowImage( const QString& ); | 68 | void slotShowImage( const QString& ); |
69 | void slotImageInfo(); | 69 | void slotImageInfo(); |
70 | void slotImageInfo( const QString& ); | 70 | void slotImageInfo( const QString& ); |
71 | 71 | ||
72 | void slotStart(); | 72 | void slotStart(); |
73 | void slotEnd(); | 73 | void slotEnd(); |
74 | 74 | ||
75 | /* for performance reasons make it inline in the future */ | 75 | /* for performance reasons make it inline in the future */ |
76 | void addFolders( const QStringList& ); | 76 | void addFolders( const QStringList& ); |
77 | void addFiles( const QStringList& ); | 77 | void addFiles( const QStringList& ); |
78 | void slotClicked(QIconViewItem* ); | 78 | void slotClicked(QIconViewItem* ); |
79 | void slotRetrun(QIconViewItem* ); | ||
79 | 80 | ||
80 | /**/ | 81 | /**/ |
81 | void slotThumbInfo(const QString&, const QString&); | 82 | void slotThumbInfo(const QString&, const QString&); |
82 | void slotThumbNail(const QString&, const QPixmap&); | 83 | void slotThumbNail(const QString&, const QPixmap&); |
83 | 84 | ||
84 | void slotChangeMode( int ); | 85 | void slotChangeMode( int ); |
85 | private: | 86 | private: |
86 | Opie::Core::OKeyConfigManager *m_viewManager; | 87 | Opie::Core::OKeyConfigManager *m_viewManager; |
87 | Opie::Core::OConfig *m_cfg; | 88 | Opie::Core::OConfig *m_cfg; |
88 | QComboBox* m_views; | 89 | QComboBox* m_views; |
89 | QIconView* m_view; | 90 | QIconView* m_view; |
90 | QString m_path; | 91 | QString m_path; |
91 | bool m_updatet : 1; | 92 | bool m_updatet : 1; |
92 | int m_mode; | 93 | int m_mode; |
93 | }; | 94 | }; |
94 | 95 | ||
95 | #endif | 96 | #endif |