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 | |||
@@ -377,150 +377,169 @@ void PIconView::slotViewChanged( int i) { | |||
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 | ||
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 | |||
@@ -15,81 +15,82 @@ 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 |