author | alwin <alwin> | 2004-04-15 16:14:56 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-15 16:14:56 (UTC) |
commit | a002be54e33d64e69c7edf2960d5e68a9a0609e4 (patch) (side-by-side diff) | |
tree | c58f7bce41920a86f077d0c371bcf166a03d6489 | |
parent | fd31b11688704c214034a0e28ca7c0a56a6a2988 (diff) | |
download | opie-a002be54e33d64e69c7edf2960d5e68a9a0609e4.zip opie-a002be54e33d64e69c7edf2960d5e68a9a0609e4.tar.gz opie-a002be54e33d64e69c7edf2960d5e68a9a0609e4.tar.bz2 |
previous/next image keys implemented
ToDo: make it via keywidget, this moment the keywidget sends a key twice
(on press and on release)
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 48 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.h | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 25 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.h | 5 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 2 |
5 files changed, 86 insertions, 0 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 5633312..f6e1816 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp @@ -223,96 +223,125 @@ void PIconView::slotDirUp() { */ void PIconView::slotChangeDir(const QString& path) { if ( !currentView() ) return; PDirLister *lister = currentView()->dirLister(); if (!lister ) return; /* * Say what we want and take what we get */ lister->setStartPath( path ); m_path = lister->currentPath(); m_view->viewport()->setUpdatesEnabled( false ); m_view->clear(); /* * add files and folders */ addFolders( lister->folders() ); addFiles( lister->files() ); m_view->viewport()->setUpdatesEnabled( true ); // Also invalidate the cache. We can't cancel the operations anyway g_stringPix.clear(); g_stringInf.clear(); // looks ugly static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); } /** * get the current file name * @param isDir see if this is a dir or real file */ QString PIconView::currentFileName(bool &isDir)const { isDir = false; QIconViewItem* _it = m_view->currentItem(); if ( !_it ) return QString::null; IconViewItem* it = static_cast<IconViewItem*>( _it ); isDir = it->isDir(); return it->path(); } +QString PIconView::nextFileName(bool &isDir)const +{ + isDir = false; + QIconViewItem* _it1 = m_view->currentItem(); + if ( !_it1 ) + return QString::null; + QIconViewItem* _it = _it1->nextItem(); + if ( !_it ) + return QString::null; + IconViewItem* it = static_cast<IconViewItem*>( _it ); + isDir = it->isDir(); + m_view->setCurrentItem(_it); + return it->path(); +} + +QString PIconView::prevFileName(bool &isDir)const{ + isDir = false; + QIconViewItem* _it = m_view->currentItem(); + if ( !_it ) + return QString::null; + _it = _it->prevItem(); + if ( !_it ) + return QString::null; + IconViewItem* it = static_cast<IconViewItem*>( _it ); + isDir = it->isDir(); + m_view->setCurrentItem(_it); + return it->path(); +} + void PIconView::slotTrash() { bool isDir; QString pa = currentFileName( isDir ); if ( isDir && pa.isEmpty() ) return; if (!QPEMessageBox::confirmDelete( this, tr("Delete Image" ), tr("the Image %1" ).arg(pa))) return currentView()->dirLister()->deleteImage( pa ); delete m_view->currentItem(); } /* * see what views are available */ void PIconView::loadViews() { ViewMap::Iterator it; ViewMap* map = viewMap(); for ( it = map->begin(); it != map->end(); ++it ) m_views->insertItem( QObject::tr(it.key() ) ); } void PIconView::resetView() { slotViewChanged(m_views->currentItem()); } /* *swicth view reloadDir and connect signals */ void PIconView::slotViewChanged( int i) { if (!m_views->count() ) { setCurrentView( 0l); return; } PDirView* cur = currentView(); delete cur; QString str = m_views->text(i); cur = (*(*viewMap())[str])(*m_cfg); setCurrentView( cur ); /* connect to the signals of the lister */ PDirLister* lis = cur->dirLister(); connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), @@ -401,96 +430,115 @@ void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); g_stringPix.remove( _path ); } /* * FIXME rename */ void PIconView::slotRename() { } /* * BEAM the current file */ void PIconView::slotBeam() { bool isDir; QString pa = currentFileName( isDir ); if ( isDir && pa.isEmpty() ) return; Ir* ir = new Ir( this ); connect( ir, SIGNAL(done(Ir*)), this, SLOT(slotBeamDone(Ir*))); ir->send(pa, tr( "Image" ) ); } /* * BEAM done clean up */ void PIconView::slotBeamDone( Ir* ir) { delete ir; } void PIconView::slotStart() { m_view->viewport()->setUpdatesEnabled( false ); } void PIconView::slotEnd() { if ( m_updatet ) m_view->arrangeItemsInGrid( ); m_view->viewport()->setUpdatesEnabled( true ); m_updatet = false; } +void PIconView::slotShowNext() +{ + bool isDir = false; + QString name = nextFileName(isDir); + if (isDir) return; + if (name.isEmpty()) return; + odebug << "Show next: " << name << oendl; + slotShowImage(name); +} + +void PIconView::slotShowPrev() +{ + bool isDir = false; + QString name = prevFileName(isDir); + if (isDir) return; + if (name.isEmpty()) return; + slotShowImage(name); +} + void PIconView::slotShowImage() { bool isDir = false; QString name = currentFileName(isDir); if (isDir) return; slotShowImage( name ); } void PIconView::slotShowImage( const QString& name) { emit sig_display( name ); } void PIconView::slotImageInfo() { bool isDir = false; QString name = currentFileName(isDir); if (isDir) return; slotImageInfo( name ); } void PIconView::slotImageInfo( const QString& name) { emit sig_showInfo( name ); } void PIconView::slotChangeMode( int mode ) { if ( mode >= 1 && mode <= 3 ) m_mode = mode; QIconView::ItemTextPos pos; switch( m_mode ) { case 2: pos = QIconView::Bottom; break; case 3: case 1: default: pos = QIconView::Right; break; } m_view->setItemTextPos( pos ); calculateGrid(); slotReloadDir(); } void PIconView::resizeEvent( QResizeEvent* re ) { QVBox::resizeEvent( re ); diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h index 903c4fd..14ad168 100644 --- a/noncore/graphics/opie-eye/gui/iconview.h +++ b/noncore/graphics/opie-eye/gui/iconview.h @@ -1,89 +1,95 @@ /* * GPLv2 zecke@handhelds.org * No WArranty... */ #ifndef PHUNK_ICON_VIEW_H #define PHUNK_ICON_VIEW_H #include <qvbox.h> class QIconView; class QIconViewItem; class QComboBox; class PIconViewItem; class PDirLister; class Ir; namespace Opie { namespace Core{ class OConfig; class OKeyConfigManager; } } class PIconView : public QVBox { Q_OBJECT friend class PIconViewItem; enum ActionIds { BeamItem, DeleteItem, ViewItem, InfoItem }; public: PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); ~PIconView(); void resetView(); Opie::Core::OKeyConfigManager* manager(); signals: void sig_showInfo( const QString& ); void sig_display( const QString& ); +public slots: + virtual void slotShowNext(); + virtual void slotShowPrev(); + protected: void resizeEvent( QResizeEvent* ); private: void initKeys(); QString currentFileName(bool &isDir)const; + QString nextFileName(bool &isDir)const; + QString prevFileName(bool &isDir)const; void loadViews(); void calculateGrid(); private slots: void slotDirUp(); void slotChangeDir(const QString&); void slotTrash(); void slotViewChanged( int ); void slotReloadDir(); void slotRename(); void slotBeam(); void slotBeamDone( Ir* ); void slotShowImage(); void slotShowImage( const QString& ); void slotImageInfo(); void slotImageInfo( const QString& ); void slotStart(); void slotEnd(); /* for performance reasons make it inline in the future */ void addFolders( const QStringList& ); void addFiles( const QStringList& ); void slotClicked(QIconViewItem* ); /**/ void slotThumbInfo(const QString&, const QString&); void slotThumbNail(const QString&, const QPixmap&); void slotChangeMode( int ); private: Opie::Core::OKeyConfigManager *m_viewManager; Opie::Core::OConfig *m_cfg; QComboBox* m_views; QIconView* m_view; QString m_path; bool m_updatet : 1; int m_mode; }; #endif diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index db3ae74..aa2b9bc 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp @@ -5,56 +5,81 @@ #include <opie2/okeyconfigwidget.h> #include <qpe/resource.h> using namespace Opie::Core; ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) : Opie::MM::OImageScrollView(parent,name,fl) { m_viewManager = 0; m_cfg = cfg; initKeys(); } ImageView::~ImageView() { if (m_viewManager) { delete m_viewManager; } } Opie::Core::OKeyConfigManager* ImageView::manager() { if (!m_viewManager) { initKeys(); } return m_viewManager; } void ImageView::initKeys() { odebug << "init imageview keys" << oendl; if (!m_cfg) { m_cfg = new Opie::Core::OConfig("phunkview"); m_cfg->setGroup("image_view_keys" ); } Opie::Core::OKeyPair::List lst; lst.append( Opie::Core::OKeyPair::upArrowKey() ); lst.append( Opie::Core::OKeyPair::downArrowKey() ); lst.append( Opie::Core::OKeyPair::leftArrowKey() ); lst.append( Opie::Core::OKeyPair::rightArrowKey() ); m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", lst, false,this, "image_view_keys" ); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", Resource::loadPixmap("1to1"), ViewInfo, Opie::Core::OKeyPair(Qt::Key_I,Qt::ShiftButton), this, SLOT(slotShowImageInfo()))); +#if 0 + m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Next image"), "nextimage", + Resource::loadPixmap("next"), ViewInfo, + Opie::Core::OKeyPair(Qt::Key_N,0), + this, SLOT(slotDispNext()))); +#endif m_viewManager->handleWidget( this ); m_viewManager->load(); } +void ImageView::keyReleaseEvent(QKeyEvent * e) +{ + if (!e || e->state()!=0) { + return; + } + if (e->key()==Qt::Key_N) slotDispNext(); + if (e->key()==Qt::Key_P) slotDispPrev(); +} + +void ImageView::slotDispNext() +{ + emit dispNext(); +} + +void ImageView::slotDispPrev() +{ + emit dispPrev(); +} + void ImageView::slotShowImageInfo() { emit dispImageInfo(m_lastName); } diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h index 1790c4f..f467f00 100644 --- a/noncore/graphics/opie-eye/gui/imageview.h +++ b/noncore/graphics/opie-eye/gui/imageview.h @@ -1,36 +1,41 @@ #ifndef _IMAGE_VIEW_H #define _IMAGE_VIEW_H #include <opie2/oimagescrollview.h> namespace Opie { namespace Core { class OConfig; class OKeyConfigManager; } } class ImageView:public Opie::MM::OImageScrollView { Q_OBJECT enum ActionIds { ViewInfo }; public: ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name = 0, WFlags fl = 0 ); virtual ~ImageView(); Opie::Core::OKeyConfigManager* manager(); signals: void dispImageInfo(const QString&); + void dispNext(); + void dispPrev(); protected: Opie::Core::OConfig * m_cfg; Opie::Core::OKeyConfigManager*m_viewManager; void initKeys(); protected slots: virtual void slotShowImageInfo(); + virtual void slotDispNext(); + virtual void slotDispPrev(); + virtual void keyReleaseEvent(QKeyEvent * e); }; #endif diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 09f562a..57be247 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -221,96 +221,98 @@ void PMainWindow::slotConfig() { it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); delete it.key(); } if ( act ) { m_view->resetView(); keyWid->save(); m_disp->manager()->save(); m_info->manager()->save(); m_view->manager()->save(); } delete keyWid; } /* * create a new image info component * and detach the current one * we will make the other delete on exit */ template<class T> void PMainWindow::initT( const char* name, T** ptr, int id) { if ( *ptr ) { (*ptr)->disconnect(this, SLOT(slotReturn())); (*ptr)->setDestructiveClose(); m_stack->removeWidget( *ptr ); } *ptr = new T(m_cfg, m_stack, name ); m_stack->addWidget( *ptr, id ); connect(*ptr, SIGNAL(sig_return()), this,SLOT(slotReturn())); } void PMainWindow::initInfo() { initT<imageinfo>( "Image Info", &m_info, ImageInfo ); connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); } void PMainWindow::initDisp() { initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); if (m_disp) { if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { m_disp->setMinimumSize(QApplication::desktop()->size()/2); } m_disp->setAutoScale(autoScale); m_disp->setAutoRotate(autoRotate); m_disp->setShowZoomer(zoomerOn); connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); + connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); + connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); } } /** * With big Screen the plan could be to 'detach' the image * window if visible and to create a ne wone * init* already supports it but I make no use of it for * now. We set filename and raise * * ### FIXME and talk to alwin */ void PMainWindow::slotShowInfo( const QString& inf ) { if ( !m_info ) { initInfo(); } m_info->setPath( inf ); m_stack->raiseWidget( ImageInfo ); } void PMainWindow::slotDisplay( const QString& inf ) { if ( !m_disp ) { initDisp(); } m_disp->setImage( inf ); m_stack->raiseWidget( ImageDisplay ); } void PMainWindow::slotReturn() { raiseIconView(); } void PMainWindow::closeEvent( QCloseEvent* ev ) { /* * return from view * or properly quit */ if ( m_stack->visibleWidget() == m_info || m_stack->visibleWidget() == m_disp ) { raiseIconView(); ev->ignore(); return; } ev->accept(); QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); } void PMainWindow::raiseIconView() { |