author | alwin <alwin> | 2004-04-21 18:31:44 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-21 18:31:44 (UTC) |
commit | 81cd1a4a916fb00b6c8867bdc1d945db155b12c0 (patch) (side-by-side diff) | |
tree | ce302c254c8c2160a86ffc0a5abe6cfd51fd33b3 | |
parent | ac414fa3802b471857bc84ecdd0d37200541b0a7 (diff) | |
download | opie-81cd1a4a916fb00b6c8867bdc1d945db155b12c0.zip opie-81cd1a4a916fb00b6c8867bdc1d945db155b12c0.tar.gz opie-81cd1a4a916fb00b6c8867bdc1d945db155b12c0.tar.bz2 |
- added DocView mode
- fixed a bug in iconview and some small fixes more
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 31 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 3 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/iface/dirlister.h | 3 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/dir/dir_ifacceinfo.h | 4 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/dir/dir_lister.cpp | 7 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/dir/dir_lister.h | 3 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_dirview.cpp | 28 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_dirview.h | 24 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_ifaceinfo.cpp | 57 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_ifaceinfo.h | 21 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_lister.cpp | 148 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_lister.h | 42 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/phunk_view.pro | 8 |
13 files changed, 362 insertions, 17 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 660c4fa..087db30 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp @@ -300,160 +300,170 @@ 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(); 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(); 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() ) ); + m_views->insertItem( 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; + if (cur) delete cur; QString str = m_views->text(i); - cur = (*(*viewMap())[str])(*m_cfg); + ViewMap* map = viewMap(); + if (!map) {setCurrentView(0l); return;} + if (map->find(str) == map->end()) { + owarn << "Key not found" << oendl; + setCurrentView(0l); return; + } + cur = (*(*map)[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& )), this, SLOT( slotThumbInfo(const QString&, const QString&))); connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), this, SLOT(slotThumbNail(const QString&, const QPixmap&))); connect(lis, SIGNAL(sig_start()), this, SLOT(slotStart())); connect(lis, SIGNAL(sig_end()) , this, SLOT(slotEnd()) ); /* reload now */ QTimer::singleShot( 0, this, SLOT(slotReloadDir())); } void PIconView::slotReloadDir() { slotChangeDir( m_path ); } /* * add files and folders */ void PIconView::addFolders( const QStringList& lst) { QStringList::ConstIterator it; IconViewItem * _iv; for(it=lst.begin(); it != lst.end(); ++it ) { _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); if (m_mode==3) _iv->setTextOnly(true); } } void PIconView::addFiles( const QStringList& lst) { QStringList::ConstIterator it; IconViewItem * _iv; QPixmap*m_pix = 0; + QString pre = ""; + if (!m_path.isEmpty()) { + pre = m_path+"/"; + } for (it=lst.begin(); it!= lst.end(); ++it ) { - m_pix = PPixmapCache::self()->cachedImage( m_path+"/"+(*it), 64, 64 ); - _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); + m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 ); + _iv = new IconViewItem( m_view, pre+(*it), (*it) ); if (m_mode==3) { _iv->setTextOnly(true); _iv->setPixmap(QPixmap()); } else { if (m_pix) _iv->setPixmap(*m_pix); } } } /* * user clicked on the item. Change dir or view */ void PIconView::slotClicked(QIconViewItem* _it) { if(!_it ) return; IconViewItem* it = static_cast<IconViewItem*>(_it); if( it->isDir() ) slotChangeDir( it->path() ); else // view image slotShowImage(); } /* * got thumb info add to the cache if items is visible * we later need update after processing of slave is done */ void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { IconViewItem* item = g_stringInf[_path]; if (!item ) return; if (m_mode == 2) { return; } if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), m_view->contentsWidth(), m_view->contentsHeight() ) ) ) m_updatet = true; item->setText( str ); g_stringInf.remove( _path ); } /* * got thumbnail and see if it is visible so we need to update later */ void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { @@ -498,120 +508,121 @@ void PIconView::slotBeam() { 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 (name.isEmpty()) return; if (isDir) return; /* if we got a name we have a next item */ m_view->setCurrentItem(m_view->currentItem()->nextItem()); slotShowImage(name); } void PIconView::slotShowPrev() { bool isDir = false; QString name = prevFileName(isDir); if (name.isEmpty()) return; if (isDir) return; /* if we got a name we have a prev item */ m_view->setCurrentItem(m_view->currentItem()->prevItem()); 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 ); + PDirLister *lister = currentView()->dirLister(); + QString r_name = lister->nameToFname(name); + emit sig_display( r_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 ); + PDirLister *lister = currentView()->dirLister(); + QString r_name = lister->nameToFname(name); + emit sig_showInfo(r_name ); } void PIconView::slotChangeMode( int mode ) { if ( mode >= 1 && mode <= 3 ) m_mode = mode; m_cfg->writeEntry("ListViewMode", m_mode); calculateGrid(); slotReloadDir(); } void PIconView::resizeEvent( QResizeEvent* re ) { QVBox::resizeEvent( re ); calculateGrid(); } void PIconView::calculateGrid() { - odebug << "Calc grid: x=" << m_view->gridX() << " y=" << m_view->gridY() << oendl; - odebug << "Size of view: " << m_view->size() << oendl; int dw = QApplication::desktop()->width(); int viewerWidth = dw-style().scrollBarExtent().width(); 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 ); switch (m_mode) { case 2: m_view->setGridX(50); m_view->setGridY(20); PPixmapCache::self()->setMaxImages(40); break; case 3: m_view->setGridX( fontMetrics().width("testimage.jpg")+20); m_view->setGridY(8); PPixmapCache::self()->setMaxImages(2); break; case 1: default: m_view->setGridX( viewerWidth-3*m_view->spacing()); m_view->setGridY( fontMetrics().height()*2+40 ); PPixmapCache::self()->setMaxImages(20); break; } } diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 58f02ef..058fca0 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -1,85 +1,86 @@ /* * GPLv2 zecke@handhelds.org * No WArranty... */ #include "mainwindow.h" #include "imageview.h" #include "iconview.h" #include "filesystem.h" #include "imageinfoui.h" #include "viewmodebutton.h" #include <iface/ifaceinfo.h> #include <iface/dirview.h> #include <opie2/odebug.h> #include <opie2/owidgetstack.h> #include <opie2/oapplicationfactory.h> #include <opie2/otabwidget.h> #include <opie2/okeyconfigwidget.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/ir.h> #include <qpe/applnk.h> #include <qtoolbar.h> #include <qtoolbutton.h> #include <qlayout.h> #include <qdialog.h> #include <qmap.h> #include <qtimer.h> #include <qframe.h> -OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) +//OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) +OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) { setCaption( QObject::tr("Opie Eye Caramba" ) ); m_cfg = new Opie::Core::OConfig("phunkview"); m_cfg->setGroup("Zecke_view" ); tFrame = 0; // qDebug( "Process-wide OApplication object @ %0x", oApp ); /* * Initialize ToolBar and IconView * And Connect Them */ QToolBar *bar = new QToolBar( this ); bar->setHorizontalStretchable( true ); setToolBarsMovable( false ); m_stack = new Opie::Ui::OWidgetStack( this ); setCentralWidget( m_stack ); m_view = new PIconView( m_stack, m_cfg ); m_stack->addWidget( m_view, IconView ); m_stack->raiseWidget( IconView ); connect(m_view, SIGNAL(sig_display(const QString&)), this, SLOT(slotDisplay(const QString&))); connect(m_view, SIGNAL(sig_showInfo(const QString&)), this, SLOT(slotShowInfo(const QString&)) ); m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); upButton = new QToolButton( bar ); upButton->setIconSet( Resource::loadIconSet( "up" ) ); connect( upButton, SIGNAL(clicked()), m_view, SLOT(slotDirUp()) ); fsButton = new PFileSystem( bar ); connect( fsButton, SIGNAL( changeDir( const QString& ) ), m_view, SLOT(slotChangeDir( const QString& ) ) ); QToolButton*btn = new QToolButton( bar ); btn->setIconSet( Resource::loadIconSet( "edit" ) ); connect( btn, SIGNAL(clicked()), m_view, SLOT(slotRename()) ); if ( Ir::supported() ) { btn = new QToolButton( bar ); btn->setIconSet( Resource::loadIconSet( "beam" ) ); connect( btn, SIGNAL(clicked()), diff --git a/noncore/graphics/opie-eye/iface/dirlister.h b/noncore/graphics/opie-eye/iface/dirlister.h index fcc55ec..9c7b2a9 100644 --- a/noncore/graphics/opie-eye/iface/dirlister.h +++ b/noncore/graphics/opie-eye/iface/dirlister.h @@ -1,47 +1,48 @@ /* * GPLv2 zecke@handhelds.org * No WArranty... */ #ifndef PHUNK_DIR_LISTER_H #define PHUNK_DIR_LISTER_H #include <qobject.h> #include <qstring.h> #include <qstringlist.h> class PDirLister : public QObject { Q_OBJECT public: enum Factor { Width, Height, None }; PDirLister( const char* name ); virtual QString defaultPath()const = 0; virtual QString setStartPath( const QString& ) = 0; virtual QString currentPath()const = 0; virtual QStringList folders()const = 0; virtual QStringList files()const = 0; public slots: virtual void deleteImage( const QString& ) = 0; virtual void imageInfo( const QString&) = 0; virtual void fullImageInfo( const QString& ) = 0; virtual void thumbNail( const QString&, int max_wid, int max_h ) = 0; virtual QImage image( const QString&, Factor, int max = 0) = 0; + virtual QString nameToFname(const QString&name)const = 0; signals: void sig_dirchanged(); void sig_filechanged(); void sig_start(); void sig_end(); // If this app ever happens to get multithreaded... void sig_thumbInfo( const QString&, const QString& ); void sig_fullInfo( const QString&, const QString& ); void sig_thumbNail( const QString&, const QPixmap& ); protected: - ~PDirLister(); + virtual ~PDirLister(); }; #endif diff --git a/noncore/graphics/opie-eye/impl/dir/dir_ifacceinfo.h b/noncore/graphics/opie-eye/impl/dir/dir_ifacceinfo.h index 8c6262f..c919dde 100644 --- a/noncore/graphics/opie-eye/impl/dir/dir_ifacceinfo.h +++ b/noncore/graphics/opie-eye/impl/dir/dir_ifacceinfo.h @@ -1,21 +1,21 @@ /* * GPLv2 * zecke@handhelds.org */ #ifndef DIR_IFACE_INFO_H #define DIR_IFACE_INFO_H -#include <iface/ifaceinfo.h>s +#include <iface/ifaceinfo.h> class DirInterfaceInfo : public PInterfaceInfo { public: DirInterfaceInfo(); - ~DirInterfaceInfo(); + virtual ~DirInterfaceInfo(); QString name()const; QWidget* configWidget(const Config&); void writeConfig( QWidget* wid, Config& ); }; #endif diff --git a/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp b/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp index 16758d7..3717297 100644 --- a/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp +++ b/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp @@ -1,97 +1,102 @@ /* * GPLv2 zecke@handhelds.org */ #include "dir_lister.h" #include <lib/slavemaster.h> /* OPIE */ #include <opie2/odebug.h> #include <qpe/config.h> #include <qpe/qpeapplication.h> using namespace Opie::Core; /* QT */ #include <qdir.h> #include <qfileinfo.h> Dir_DirLister::Dir_DirLister( bool list ) : PDirLister( "dir_dir_lister" ) { m_allFiles = list; - owarn << "All Files " << m_allFiles << "" << oendl; + owarn << "All Files " << m_allFiles << "" << oendl; SlaveMaster* master = SlaveMaster::self(); connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)), this, SIGNAL(sig_thumbInfo(const QString&, const QString&)) ); connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), this, SIGNAL(sig_fullInfo(const QString&, const QString&)) ); connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), this, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)) ); } QString Dir_DirLister::defaultPath()const { return QPEApplication::documentDir(); } QString Dir_DirLister::setStartPath( const QString& path ) { m_currentDir.cd( path ); if (!m_currentDir.exists() ) m_currentDir.cd(defaultPath()); return m_currentDir.absPath(); } QString Dir_DirLister::currentPath()const { return m_currentDir.absPath(); } QStringList Dir_DirLister::folders()const { return m_currentDir.entryList( QDir::Dirs ); } QStringList Dir_DirLister::files()const { if ( m_allFiles ) return m_currentDir.entryList( QDir::Files ); else { QStringList out; QStringList list = m_currentDir.entryList( QDir::Files | QDir::Readable ); for (QStringList::Iterator it = list.begin(); it != list.end();++it ) { QFileInfo inf( *it ); QString ext = inf.extension(false).lower(); if( ext == QString::fromLatin1("jpg") || ext == QString::fromLatin1("jpeg" ) || ext == QString::fromLatin1("png" ) || ext == QString::fromLatin1("bmp" ) || ext == QString::fromLatin1("gif" ) ) out.append( *it ); } return out; } } void Dir_DirLister::deleteImage( const QString& fl) { QFile::remove( fl ); } void Dir_DirLister::thumbNail( const QString& str, int w, int h) { SlaveMaster::self()->thumbNail( str, w, h ); } QImage Dir_DirLister::image( const QString& str, Factor f, int m) { return SlaveMaster::self()->image( str, f, m ); } void Dir_DirLister::imageInfo( const QString& str) { SlaveMaster::self()->thumbInfo( str ); } void Dir_DirLister::fullImageInfo( const QString& str) { SlaveMaster::self()->imageInfo( str ); } + +QString Dir_DirLister::nameToFname(const QString&name)const +{ + return name; +} diff --git a/noncore/graphics/opie-eye/impl/dir/dir_lister.h b/noncore/graphics/opie-eye/impl/dir/dir_lister.h index fc63bb0..d6ca6c0 100644 --- a/noncore/graphics/opie-eye/impl/dir/dir_lister.h +++ b/noncore/graphics/opie-eye/impl/dir/dir_lister.h @@ -1,34 +1,37 @@ /* * GPLv2 zecke@handhelds.org */ #ifndef DIR_LISTER_INTERFACE_LISTER_H #define DIR_LISTER_INTERFACE_LISTER_H #include <qdir.h> #include <iface/dirlister.h> class Config; class Dir_DirLister : public PDirLister { + Q_OBJECT public: Dir_DirLister( bool ); + virtual ~Dir_DirLister(){} QString defaultPath()const; QString setStartPath( const QString& ); QString currentPath()const; QStringList folders()const; QStringList files()const; void deleteImage( const QString& ); void thumbNail( const QString&, int, int ); QImage image( const QString&, Factor, int ); void imageInfo( const QString& ); void fullImageInfo( const QString& ); + virtual QString nameToFname(const QString&name)const; private: bool m_allFiles; QDir m_currentDir; }; #endif diff --git a/noncore/graphics/opie-eye/impl/doc/doc_dirview.cpp b/noncore/graphics/opie-eye/impl/doc/doc_dirview.cpp new file mode 100644 index 0000000..0d6e25f --- a/dev/null +++ b/noncore/graphics/opie-eye/impl/doc/doc_dirview.cpp @@ -0,0 +1,28 @@ +#include "doc_lister.h" +#include "doc_ifaceinfo.h" +#include "doc_dirview.h" + +PHUNK_VIEW_INTERFACE("Document View", Doc_DirView ); + + +Doc_DirView::Doc_DirView( const Config& cfg) + : PDirView(cfg) +{ + m_lister = 0; + m_info = 0; +} + +Doc_DirView::~Doc_DirView() { +} + +PInterfaceInfo* Doc_DirView::interfaceInfo()const{ + if (!m_info ) + m_info =new DocInterfaceInfo; + return m_info; +} + +PDirLister* Doc_DirView::dirLister()const{ + if (!m_lister ) + m_lister = new Doc_DirLister(); + return m_lister; +} diff --git a/noncore/graphics/opie-eye/impl/doc/doc_dirview.h b/noncore/graphics/opie-eye/impl/doc/doc_dirview.h new file mode 100644 index 0000000..3a2fd71 --- a/dev/null +++ b/noncore/graphics/opie-eye/impl/doc/doc_dirview.h @@ -0,0 +1,24 @@ +/* + * GPLv2 only zecke@handhelds.org + */ + +#ifndef DOC_DIR_VIEW_H +#define DOC_DIR_VIEW_H + +#include <iface/dirview.h> + + +struct Doc_DirView : public PDirView { + Doc_DirView( const Config& ); + ~Doc_DirView(); + + PInterfaceInfo* interfaceInfo()const; + PDirLister* dirLister()const; +private: + bool m_cfg : 1; + mutable PDirLister* m_lister; + mutable PInterfaceInfo *m_info; +}; + + +#endif diff --git a/noncore/graphics/opie-eye/impl/doc/doc_ifaceinfo.cpp b/noncore/graphics/opie-eye/impl/doc/doc_ifaceinfo.cpp new file mode 100644 index 0000000..a6d6f3c --- a/dev/null +++ b/noncore/graphics/opie-eye/impl/doc/doc_ifaceinfo.cpp @@ -0,0 +1,57 @@ +/* + * GPLv2 + * zecke@handhelds.org + */ + +#include "doc_ifaceinfo.h" + +/* OPIE */ +#include <opie2/odebug.h> +#include <qpe/config.h> +using namespace Opie::Core; + +/* QT */ +#include <qwidget.h> +#include <qcheckbox.h> +#include <qhbox.h> +#include <qlabel.h> + +#if 0 +namespace { + class DirImageWidget : public QHBox { + public: + DirImageWidget() { + chkbox = new QCheckBox( QObject::tr("Show all files"), this ); + } + ~DirImageWidget() {} + QCheckBox* chkbox; + }; +} +#endif + +DocInterfaceInfo::DocInterfaceInfo() { +} +DocInterfaceInfo::~DocInterfaceInfo() { +} + +QString DocInterfaceInfo::name()const { + return QString::fromLatin1(QObject::tr("DocView" )); +} + +QWidget* DocInterfaceInfo::configWidget(const Config& cfg) { +#if 0 + DirImageWidget* wid = new DirImageWidget(); + wid->chkbox->setChecked( cfg.readBoolEntry("Dir_Check_All_Files", true) ); + + return wid; +#endif + return 0L; +} + +void DocInterfaceInfo::writeConfig( QWidget* , Config& ) { +#if 0 + owarn << "Write Config" << oendl; + DirImageWidget* wid = static_cast<DirImageWidget*>(_wid); + cfg.writeEntry("Dir_Check_All_Files", wid->chkbox->isChecked() ); +#endif +} diff --git a/noncore/graphics/opie-eye/impl/doc/doc_ifaceinfo.h b/noncore/graphics/opie-eye/impl/doc/doc_ifaceinfo.h new file mode 100644 index 0000000..73986c9 --- a/dev/null +++ b/noncore/graphics/opie-eye/impl/doc/doc_ifaceinfo.h @@ -0,0 +1,21 @@ +/* + * GPLv2 + * zecke@handhelds.org + */ + +#ifndef DOC_IFACE_INFO_H +#define DOC_IFACE_INFO_H + +#include <iface/ifaceinfo.h> + +class DocInterfaceInfo : public PInterfaceInfo { +public: + DocInterfaceInfo(); + virtual ~DocInterfaceInfo(); + + QString name()const; + QWidget* configWidget(const Config&); + void writeConfig( QWidget* wid, Config& ); +}; + +#endif diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp new file mode 100644 index 0000000..f695a76 --- a/dev/null +++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp @@ -0,0 +1,148 @@ +/* + * GPLv2 zecke@handhelds.org + */ + +#include "doc_lister.h" + +#include <lib/slavemaster.h> + +/* OPIE */ +#include <opie2/odebug.h> +#include <qpe/config.h> +#include <qpe/qpeapplication.h> +#include <qpe/applnk.h> + +using namespace Opie::Core; + +/* QT */ +#include <qdir.h> +#include <qfileinfo.h> + +Doc_DirLister::Doc_DirLister() + : PDirLister( "doc_dir_lister" ) +{ + SlaveMaster* master = SlaveMaster::self(); + connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); + connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); + connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)), + this, SLOT(slotThumbInfo(const QString&, const QString&)) ); + connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), + this, SLOT(slotFullInfo(const QString&, const QString&)) ); + connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), + this, SLOT(slotThumbNail(const QString&, const QPixmap&)) ); + +} + +QString Doc_DirLister::defaultPath()const { + return ""; QPEApplication::documentDir(); +} + +QString Doc_DirLister::setStartPath( const QString& path ) { + m_namemap.clear(); + m_out.clear(); + static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); + owarn << "Set start path" << oendl; + DocLnkSet ds; + Global::findDocuments(&ds,Mtype_str); + QListIterator<DocLnk> dit(ds.children()); + for( ; dit.current(); ++dit) { + owarn << (*dit)->file() << oendl; + m_namemap[(*dit)->name()]=(*dit)->file(); + m_filemap[(*dit)->file()]=(*dit)->name(); + m_out.append((*dit)->name()); + } + owarn << "Set start path end" << oendl; + return ""; +} + +QString Doc_DirLister::currentPath()const { + return ""; +} + + +QStringList Doc_DirLister::folders()const { + return QStringList(); +} + +QStringList Doc_DirLister::files()const { + return m_out; +} + +void Doc_DirLister::deleteImage( const QString& ) { +} + +void Doc_DirLister::thumbNail( const QString& str, int w, int h) { + if (m_namemap.find(str)==m_namemap.end()) { + owarn << "Item " << str << " not found" << oendl; + return; + } + QString fname = m_namemap[str]; + SlaveMaster::self()->thumbNail( fname, w, h ); +} + +QImage Doc_DirLister::image( const QString& str, Factor f, int m) { + if (m_namemap.find(str)==m_namemap.end()) { + owarn << "Item " << str << " not found" << oendl; + return QImage(); + } + QString fname = m_namemap[str]; + return SlaveMaster::self()->image( fname, f, m ); +} + +void Doc_DirLister::imageInfo( const QString& str) { + if (m_namemap.find(str)==m_namemap.end()) { + owarn << "Item " << str << " not found" << oendl; + return; + } + QString fname = m_namemap[str]; + owarn << "Image info: " << fname << oendl; + SlaveMaster::self()->thumbInfo( fname ); +} + +void Doc_DirLister::fullImageInfo( const QString& str) { + if (m_namemap.find(str)==m_namemap.end()) { + owarn << "Item " << str << " not found" << oendl; + return; + } + QString fname = m_namemap[str]; + SlaveMaster::self()->imageInfo( fname ); +} + +void Doc_DirLister::slotFullInfo(const QString&f, const QString&t) +{ + if (m_filemap.find(f)==m_filemap.end()) { + owarn << "Item " << f << " not found" << oendl; + return; + } + QString name = m_filemap[f]; + emit sig_fullInfo(name, t); +} + +void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t) +{ + if (m_filemap.find(f)==m_filemap.end()) { + owarn << "Item " << f << " not found" << oendl; + return; + } + QString name = m_filemap[f]; + emit sig_thumbInfo(name, t); +} + +void Doc_DirLister::slotThumbNail(const QString&f, const QPixmap&p) +{ + if (m_filemap.find(f)==m_filemap.end()) { + owarn << "Item " << f << " not found" << oendl; + return; + } + QString name = m_filemap[f]; + emit sig_thumbNail(name, p); +} + +QString Doc_DirLister::nameToFname(const QString&name)const +{ + if (m_namemap.find(name)==m_namemap.end()) { + owarn << "Item " << name << " not found" << oendl; + return QString::null; + } + return m_namemap[name]; +} diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.h b/noncore/graphics/opie-eye/impl/doc/doc_lister.h new file mode 100644 index 0000000..d89b579 --- a/dev/null +++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.h @@ -0,0 +1,42 @@ +/* + * GPLv2 zecke@handhelds.org + */ + +#ifndef DOC_LISTER_INTERFACE_LISTER_H +#define DOC_LISTER_INTERFACE_LISTER_H + +#include <iface/dirlister.h> + +#include <qstring.h> +#include <qmap.h> + +class Config; +class Doc_DirLister : public PDirLister { + Q_OBJECT +public: + Doc_DirLister(); + virtual ~Doc_DirLister(){} + + QString defaultPath()const; + QString setStartPath( const QString& ); + QString currentPath()const; + QStringList folders()const; + QStringList files()const; + + void deleteImage( const QString& ); + void thumbNail( const QString&, int, int ); + QImage image( const QString&, Factor, int ); + void imageInfo( const QString& ); + void fullImageInfo( const QString& ); + virtual QString nameToFname(const QString&name)const; + +private: + QMap<QString,QString> m_namemap,m_filemap; + QStringList m_out; +protected slots: + virtual void slotFullInfo(const QString&, const QString&); + virtual void slotThumbInfo(const QString&, const QString&); + virtual void slotThumbNail(const QString&, const QPixmap&); +}; + +#endif diff --git a/noncore/graphics/opie-eye/phunk_view.pro b/noncore/graphics/opie-eye/phunk_view.pro index 57e69b6..0a57a0f 100644 --- a/noncore/graphics/opie-eye/phunk_view.pro +++ b/noncore/graphics/opie-eye/phunk_view.pro @@ -1,40 +1,44 @@ CONFIG += qt warn_on quick-app DESTDIR = $(OPIEDIR)/bin TEMPLATE = app TARGET = opie-eye # the name of the resulting object HEADERS = gui/iconview.h gui/filesystem.h gui/mainwindow.h \ lib/imagecache.h impl/dir/dir_dirview.h \ iface/dirview.h iface/dirlister.h iface/ifaceinfo.h \ impl/dir/dir_lister.h impl/dir/dir_ifaceinfo.h \ lib/slavemaster.h \ iface/slaveiface.h \ gui/imageinfoui.h \ gui/imageview.h \ - gui/viewmodebutton.h + gui/viewmodebutton.h \ + impl/doc/doc_lister.h impl/doc/doc_dirview.h \ + impl/doc/doc_ifaceinfo.h # A list header files SOURCES = gui/iconview.cpp gui/filesystem.cpp gui/mainwindow.cpp \ lib/imagecache.cpp lib/viewmap.cpp \ impl/dir/dir_dirview.cpp iface/dirlister.cpp \ iface/dirview.cpp impl/dir/dir_lister.cpp \ impl/dir/dir_ifaceinfo.cpp lib/slavemaster.cpp \ gui/imageinfoui.cpp \ gui/imageview.cpp \ - gui/viewmodebutton.cpp + gui/viewmodebutton.cpp \ + impl/doc/doc_lister.cpp impl/doc/doc_dirview.cpp \ + impl/doc/doc_ifaceinfo.cpp # A list of source files INTERFACES = # list of ui files INCLUDEPATH += . $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopiecore2 -lopieui2 -lopiemm2 include ( $(OPIEDIR)/include.pro ) |