Diffstat (limited to 'noncore/graphics/opie-eye/gui/iconview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 61 |
1 files changed, 41 insertions, 20 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index de2cdf0..4ced52d 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -32,15 +32,18 @@ | |||
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qstyle.h> | 33 | #include <qstyle.h> |
34 | 34 | ||
35 | 35 | ||
36 | using Opie::Ui::OKeyConfigItem; | 36 | using Opie::Ui::OKeyConfigItem; |
37 | 37 | ||
38 | /* | ||
39 | * The Icons, Request Cache and IconViewItem for the IconView | ||
40 | */ | ||
38 | namespace { | 41 | namespace { |
39 | QPixmap* _dirPix = 0; | 42 | static QPixmap* _dirPix = 0; |
40 | QPixmap* _unkPix = 0; | 43 | static QPixmap* _unkPix = 0; |
41 | class IconViewItem : public QIconViewItem { | 44 | class IconViewItem : public QIconViewItem { |
42 | public: | 45 | public: |
43 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); | 46 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); |
44 | QPixmap* pixmap()const; | 47 | QPixmap* pixmap()const; |
45 | QString path()const { return m_path; } | 48 | QString path()const { return m_path; } |
46 | bool isDir()const { return m_isDir; } | 49 | bool isDir()const { return m_isDir; } |
@@ -56,14 +59,14 @@ namespace { | |||
56 | 59 | ||
57 | 60 | ||
58 | /* | 61 | /* |
59 | * If we request an Image or String | 62 | * If we request an Image or String |
60 | * we add it to the map | 63 | * we add it to the map |
61 | */ | 64 | */ |
62 | QMap<QString, IconViewItem*> g_stringInf; | 65 | static QMap<QString, IconViewItem*> g_stringInf; |
63 | QMap<QString, IconViewItem*> g_stringPix; | 66 | static QMap<QString, IconViewItem*> g_stringPix; |
64 | 67 | ||
65 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 68 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
66 | const QString& name, bool isDir ) | 69 | const QString& name, bool isDir ) |
67 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 70 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
68 | m_noInfo( false ) | 71 | m_noInfo( false ) |
69 | { | 72 | { |
@@ -98,12 +101,16 @@ namespace { | |||
98 | m_noInfo = true; | 101 | m_noInfo = true; |
99 | QIconViewItem::setText( text ); | 102 | QIconViewItem::setText( text ); |
100 | } | 103 | } |
101 | } | 104 | } |
102 | 105 | ||
103 | 106 | ||
107 | /* | ||
108 | * Set up the GUI.. initialize the slave set up gui | ||
109 | * and also load a dir | ||
110 | */ | ||
104 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 111 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
105 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) | 112 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) |
106 | { | 113 | { |
107 | { | 114 | { |
108 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 115 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
109 | } | 116 | } |
@@ -133,24 +140,32 @@ PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | |||
133 | initKeys(); | 140 | initKeys(); |
134 | 141 | ||
135 | loadViews(); | 142 | loadViews(); |
136 | slotViewChanged( m_views->currentItem() ); | 143 | slotViewChanged( m_views->currentItem() ); |
137 | } | 144 | } |
138 | 145 | ||
146 | /* | ||
147 | * Unref the slave and save the keyboard manager | ||
148 | */ | ||
139 | PIconView::~PIconView() { | 149 | PIconView::~PIconView() { |
140 | { | 150 | { |
141 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 151 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
142 | } | 152 | } |
143 | m_viewManager->save(); | 153 | m_viewManager->save(); |
144 | delete m_viewManager; | 154 | delete m_viewManager; |
145 | } | 155 | } |
146 | 156 | ||
147 | Opie::Ui::OKeyConfigManager* PIconView::manager() { | 157 | Opie::Ui::OKeyConfigManager* PIconView::manager() { |
148 | return m_viewManager; | 158 | return m_viewManager; |
149 | } | 159 | } |
150 | 160 | ||
161 | |||
162 | /* | ||
163 | * init the KeyBoard Shortcuts | ||
164 | * called from the c'tor | ||
165 | */ | ||
151 | void PIconView::initKeys() { | 166 | void PIconView::initKeys() { |
152 | Opie::Ui::OKeyPair::List lst; | 167 | Opie::Ui::OKeyPair::List lst; |
153 | lst.append( Opie::Ui::OKeyPair::upArrowKey() ); | 168 | lst.append( Opie::Ui::OKeyPair::upArrowKey() ); |
154 | lst.append( Opie::Ui::OKeyPair::downArrowKey() ); | 169 | lst.append( Opie::Ui::OKeyPair::downArrowKey() ); |
155 | lst.append( Opie::Ui::OKeyPair::leftArrowKey() ); | 170 | lst.append( Opie::Ui::OKeyPair::leftArrowKey() ); |
156 | lst.append( Opie::Ui::OKeyPair::rightArrowKey() ); | 171 | lst.append( Opie::Ui::OKeyPair::rightArrowKey() ); |
@@ -175,19 +190,26 @@ void PIconView::initKeys() { | |||
175 | Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | 190 | Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ), |
176 | this, SLOT(slotImageInfo()) ) ); | 191 | this, SLOT(slotImageInfo()) ) ); |
177 | m_viewManager->load(); | 192 | m_viewManager->load(); |
178 | m_viewManager->handleWidget( m_view ); | 193 | m_viewManager->handleWidget( m_view ); |
179 | } | 194 | } |
180 | 195 | ||
196 | |||
197 | /* | ||
198 | * change one dir up | ||
199 | */ | ||
181 | void PIconView::slotDirUp() { | 200 | void PIconView::slotDirUp() { |
182 | QDir dir( m_path ); | 201 | QDir dir( m_path ); |
183 | dir.cdUp(); | 202 | dir.cdUp(); |
184 | slotChangeDir( dir.absPath() ); | 203 | slotChangeDir( dir.absPath() ); |
185 | 204 | ||
186 | } | 205 | } |
187 | 206 | ||
207 | /* | ||
208 | * change the dir | ||
209 | */ | ||
188 | void PIconView::slotChangeDir(const QString& path) { | 210 | void PIconView::slotChangeDir(const QString& path) { |
189 | if ( !currentView() ) | 211 | if ( !currentView() ) |
190 | return; | 212 | return; |
191 | 213 | ||
192 | PDirLister *lister = currentView()->dirLister(); | 214 | PDirLister *lister = currentView()->dirLister(); |
193 | if (!lister ) | 215 | if (!lister ) |
@@ -281,15 +303,15 @@ void PIconView::slotReloadDir() { | |||
281 | } | 303 | } |
282 | 304 | ||
283 | 305 | ||
284 | void PIconView::addFolders( const QStringList& lst) { | 306 | void PIconView::addFolders( const QStringList& lst) { |
285 | QStringList::ConstIterator it; | 307 | QStringList::ConstIterator it; |
286 | 308 | ||
287 | for(it=lst.begin(); it != lst.end(); ++it ) { | 309 | for(it=lst.begin(); it != lst.end(); ++it ) |
288 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); | 310 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); |
289 | } | 311 | |
290 | 312 | ||
291 | } | 313 | } |
292 | 314 | ||
293 | void PIconView::addFiles( const QStringList& lst) { | 315 | void PIconView::addFiles( const QStringList& lst) { |
294 | QStringList::ConstIterator it; | 316 | QStringList::ConstIterator it; |
295 | for (it=lst.begin(); it!= lst.end(); ++it ) | 317 | for (it=lst.begin(); it!= lst.end(); ++it ) |
@@ -302,13 +324,13 @@ void PIconView::slotClicked(QIconViewItem* _it) { | |||
302 | return; | 324 | return; |
303 | 325 | ||
304 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 326 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
305 | if( it->isDir() ) | 327 | if( it->isDir() ) |
306 | slotChangeDir( it->path() ); | 328 | slotChangeDir( it->path() ); |
307 | else // view image | 329 | else // view image |
308 | ; | 330 | slotShowImage(); |
309 | } | 331 | } |
310 | 332 | ||
311 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 333 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
312 | IconViewItem* item = g_stringInf[_path]; | 334 | IconViewItem* item = g_stringInf[_path]; |
313 | if (!item ) | 335 | if (!item ) |
314 | return; | 336 | return; |
@@ -357,40 +379,39 @@ void PIconView::slotBeam() { | |||
357 | void PIconView::slotBeamDone( Ir* ir) { | 379 | void PIconView::slotBeamDone( Ir* ir) { |
358 | delete ir; | 380 | delete ir; |
359 | } | 381 | } |
360 | 382 | ||
361 | void PIconView::slotStart() { | 383 | void PIconView::slotStart() { |
362 | m_view->viewport()->setUpdatesEnabled( false ); | 384 | m_view->viewport()->setUpdatesEnabled( false ); |
363 | qWarning( "Sig Start" ); | ||
364 | } | 385 | } |
365 | 386 | ||
366 | void PIconView::slotEnd() { | 387 | void PIconView::slotEnd() { |
367 | qWarning( "SLot End" ); | ||
368 | if ( m_updatet ) | 388 | if ( m_updatet ) |
369 | m_view->arrangeItemsInGrid( ); | 389 | m_view->arrangeItemsInGrid( ); |
370 | m_view->viewport()->setUpdatesEnabled( true ); | 390 | m_view->viewport()->setUpdatesEnabled( true ); |
371 | m_updatet = false; | 391 | m_updatet = false; |
372 | } | 392 | } |
373 | 393 | ||
374 | void PIconView::slotShowImage() { | 394 | void PIconView::slotShowImage() |
375 | qDebug("image show"); | 395 | { |
396 | qWarning( "SLotShowImage" ); | ||
376 | bool isDir = false; | 397 | bool isDir = false; |
377 | QString name = currentFileName(isDir); | 398 | QString name = currentFileName(isDir); |
378 | if (isDir) return; | 399 | if (isDir) return; |
379 | ImageDlg dlg(name); | ||
380 | QPEApplication::execDialog(&dlg); | ||
381 | } | ||
382 | void PIconView::slotShowImage( const QString& ) { | ||
383 | 400 | ||
401 | slotShowImage( name ); | ||
402 | } | ||
403 | void PIconView::slotShowImage( const QString& name) { | ||
404 | emit sig_display( name ); | ||
384 | } | 405 | } |
385 | void PIconView::slotImageInfo() { | 406 | void PIconView::slotImageInfo() { |
386 | qDebug("image info"); | 407 | qWarning( "SlotImageInfo" ); |
387 | bool isDir = false; | 408 | bool isDir = false; |
388 | QString name = currentFileName(isDir); | 409 | QString name = currentFileName(isDir); |
389 | if (isDir) return; | 410 | if (isDir) return; |
390 | infoDlg dlg(name); | ||
391 | QPEApplication::execDialog(&dlg); | ||
392 | } | ||
393 | 411 | ||
394 | void PIconView::slotImageInfo( const QString& ) { | 412 | slotImageInfo( name ); |
413 | } | ||
395 | 414 | ||
415 | void PIconView::slotImageInfo( const QString& name) { | ||
416 | emit sig_showInfo( name ); | ||
396 | } | 417 | } |