author | alwin <alwin> | 2004-11-10 23:42:14 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-11-10 23:42:14 (UTC) |
commit | 79060b829e9231cddc0acfe2dd2b7da3f13dfbc4 (patch) (side-by-side diff) | |
tree | 0e7a6a344bfce1aaf76bedd939a9765014f6ec09 /noncore/graphics/opie-eye/impl | |
parent | a57e46d9b290712fa1ff106a1be133f4f9751a96 (diff) | |
download | opie-79060b829e9231cddc0acfe2dd2b7da3f13dfbc4.zip opie-79060b829e9231cddc0acfe2dd2b7da3f13dfbc4.tar.gz opie-79060b829e9231cddc0acfe2dd2b7da3f13dfbc4.tar.bz2 |
lister modules can insert special widgets.
doc_dirlister will insert a category select widget
Diffstat (limited to 'noncore/graphics/opie-eye/impl') (more/less context) (ignore whitespace changes)
8 files changed, 69 insertions, 3 deletions
diff --git a/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.cpp b/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.cpp index e55c27a..3f6044f 100644 --- a/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.cpp +++ b/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.cpp @@ -5,24 +5,29 @@ PHUNK_VIEW_INTERFACE( "Digital Camera", DCIM_DirView ); DCIM_DirView::DCIM_DirView( const Config& cfg ) : PDirView( cfg ), m_lister( 0l ), m_info( 0l ) {} DCIM_DirView::~DCIM_DirView() {} PInterfaceInfo* DCIM_DirView::interfaceInfo()const { if ( !m_info ) m_info = new DCIM_InterfaceInfo; return m_info; } PDirLister* DCIM_DirView::dirLister()const { if ( !m_lister ) m_lister = new DCIM_DirLister(); return m_lister; } + +QWidget* DCIM_DirView::widget(QWidget*) +{ + return 0L; +} diff --git a/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.h b/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.h index 7fc38ec..8394b34 100644 --- a/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.h +++ b/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.h @@ -1,26 +1,26 @@ /* * GPLv2 only zecke@handhelds.org */ #ifndef DCIM_DIR_VIEW_H #define DCIM_DIR_VIEW_H #include <iface/dirview.h> /* * Implementation for USB Host Digital Cameras * like my Casio QV 500 and boring Yakumo */ struct DCIM_DirView : public PDirView { DCIM_DirView( const Config& ); ~DCIM_DirView(); PInterfaceInfo* interfaceInfo()const; PDirLister * dirLister ()const; - + virtual QWidget* widget(QWidget*); private: mutable PDirLister *m_lister; mutable PInterfaceInfo *m_info ; }; #endif diff --git a/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp b/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp index fc502d4..9c2c840 100644 --- a/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp +++ b/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp @@ -10,24 +10,29 @@ Dir_DirView::Dir_DirView( const Config& cfg) { m_cfg = cfg.readBoolEntry( "Dir_Check_All_Files", false); m_recursive = cfg.readBoolEntry( "Dir_Check_Recursive_Files", false); m_recursive_depth = cfg.readNumEntry("Dir_Recursive_Files_Depth",10); m_lister = 0; m_info = 0; } Dir_DirView::~Dir_DirView() { } PInterfaceInfo* Dir_DirView::interfaceInfo()const{ if (!m_info ) { m_info = new DirInterfaceInfo; } return m_info; } PDirLister* Dir_DirView::dirLister()const{ if (!m_lister ) { m_lister = new Dir_DirLister(m_cfg,m_recursive,m_recursive_depth); } return m_lister; } + +QWidget* Dir_DirView::widget(QWidget*) +{ + return 0L; +}
\ No newline at end of file diff --git a/noncore/graphics/opie-eye/impl/dir/dir_dirview.h b/noncore/graphics/opie-eye/impl/dir/dir_dirview.h index 89cf6c9..ae53a5c 100644 --- a/noncore/graphics/opie-eye/impl/dir/dir_dirview.h +++ b/noncore/graphics/opie-eye/impl/dir/dir_dirview.h @@ -1,26 +1,27 @@ /* * GPLv2 only zecke@handhelds.org */ #ifndef DIR_DIR_VIEW_H #define DIR_DIR_VIEW_H #include <iface/dirview.h> struct Dir_DirView : public PDirView { Dir_DirView( const Config& ); ~Dir_DirView(); PInterfaceInfo* interfaceInfo()const; PDirLister* dirLister()const; + virtual QWidget* widget(QWidget*); private: bool m_cfg : 1; bool m_recursive:1; int m_recursive_depth; mutable PDirLister* m_lister; mutable PInterfaceInfo *m_info; }; #endif diff --git a/noncore/graphics/opie-eye/impl/doc/doc_dirview.cpp b/noncore/graphics/opie-eye/impl/doc/doc_dirview.cpp index 0d6e25f..2cc897b 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_dirview.cpp +++ b/noncore/graphics/opie-eye/impl/doc/doc_dirview.cpp @@ -5,24 +5,31 @@ 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; } + +QWidget* Doc_DirView::widget(QWidget*parent) +{ + if (!m_lister) + dirLister(); + return m_lister->widget(parent); +} diff --git a/noncore/graphics/opie-eye/impl/doc/doc_dirview.h b/noncore/graphics/opie-eye/impl/doc/doc_dirview.h index 3a2fd71..55ba6f2 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_dirview.h +++ b/noncore/graphics/opie-eye/impl/doc/doc_dirview.h @@ -1,24 +1,26 @@ /* * GPLv2 only zecke@handhelds.org */ #ifndef DOC_DIR_VIEW_H #define DOC_DIR_VIEW_H #include <iface/dirview.h> +class Doc_DirLister; struct Doc_DirView : public PDirView { Doc_DirView( const Config& ); ~Doc_DirView(); PInterfaceInfo* interfaceInfo()const; PDirLister* dirLister()const; + QWidget* widget(QWidget*parent); private: bool m_cfg : 1; - mutable PDirLister* m_lister; + mutable Doc_DirLister* m_lister; mutable PInterfaceInfo *m_info; }; #endif diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp index 722fb95..d60149f 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp +++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp @@ -1,74 +1,88 @@ /* * 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> +#include <qtopia/private/categories.h> +#include <qtopia/categoryselect.h> + using namespace Opie::Core; /* QT */ #include <qdir.h> #include <qfileinfo.h> Doc_DirLister::Doc_DirLister() : PDirLister( "doc_dir_lister" ) { /* connect the signals */ + m_catFilter = 0; 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&)) ); m_namemap.clear(); m_filemap.clear(); } QString Doc_DirLister::defaultPath()const { return QString::null; } +bool Doc_DirLister::matchCat(const AppLnk* app) +{ + if (!app) return false; + if (m_catFilter==0 || app->categories().contains(m_catFilter) || m_catFilter == -1 && app->categories().count() == 0 ) { + return true; + } + return false; +} + QString Doc_DirLister::setStartPath(const QString&) { static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); if (m_namemap.isEmpty()) { DocLnkSet ds; Global::findDocuments(&ds,Mtype_str); QListIterator<DocLnk> dit(ds.children()); for( ; dit.current(); ++dit) { -// if (! (*dit)->isValid()) continue; + if (! (*dit)->isValid()) continue; + if (!matchCat((*dit))) continue; m_namemap[(*dit)->name()]=(*dit)->file(); m_filemap[(*dit)->file()]=(*dit)->name(); } } return QString::null; } QString Doc_DirLister::currentPath()const { return QString::null; } QStringList Doc_DirLister::folders()const { return QStringList(); } QStringList Doc_DirLister::files()const { QStringList out; QMap<QString,QString>::ConstIterator it; for (it = m_namemap.begin();it != m_namemap.end();++it) { out.append(it.key()); } return out; } @@ -126,24 +140,49 @@ void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t) 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()) { 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()) { return QString::null; } return m_namemap[name]; } QString Doc_DirLister::dirUp( const QString& p ) const{ return p; } + +QWidget* Doc_DirLister::widget(QWidget*parent) +{ + CategorySelect * catmb = new CategorySelect(parent); + Categories cats( 0 ); + cats.load( categoryFileName() ); + QArray<int> vl( 0 ); + catmb->setCategories( vl, "Document View", // No tr + "Document View" ); + catmb->setRemoveCategoryEdit( TRUE ); + catmb->setAllCategories( TRUE ); + connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); + catmb->setCurrentCategory(-2); + return catmb; +} + +void Doc_DirLister::showCategory(int which) +{ + Categories cat; + cat.load( categoryFileName() ); + m_catFilter = which==-2?0:which; + m_namemap.clear(); + setStartPath(""); + emit sig_reloadDir(); +} diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.h b/noncore/graphics/opie-eye/impl/doc/doc_lister.h index 5884a35..e148ac0 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_lister.h +++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.h @@ -1,42 +1,49 @@ /* * 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 AppLnk; + 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; QString dirUp( const QString& )const; + QWidget* widget(QWidget*parent); private: QMap<QString,QString> m_namemap,m_filemap; + int m_catFilter; + bool matchCat(const AppLnk* app); + protected slots: virtual void slotFullInfo(const QString&, const QString&); virtual void slotThumbInfo(const QString&, const QString&); virtual void slotThumbNail(const QString&, const QPixmap&); + virtual void showCategory(int); }; #endif |