author | alwin <alwin> | 2004-11-10 23:42:14 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-11-10 23:42:14 (UTC) |
commit | 79060b829e9231cddc0acfe2dd2b7da3f13dfbc4 (patch) (unidiff) | |
tree | 0e7a6a344bfce1aaf76bedd939a9765014f6ec09 /noncore/graphics/opie-eye/impl/doc/doc_lister.cpp | |
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/doc/doc_lister.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_lister.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
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 | |||
@@ -12,6 +12,9 @@ | |||
12 | #include <qpe/qpeapplication.h> | 12 | #include <qpe/qpeapplication.h> |
13 | #include <qpe/applnk.h> | 13 | #include <qpe/applnk.h> |
14 | 14 | ||
15 | #include <qtopia/private/categories.h> | ||
16 | #include <qtopia/categoryselect.h> | ||
17 | |||
15 | using namespace Opie::Core; | 18 | using namespace Opie::Core; |
16 | 19 | ||
17 | /* QT */ | 20 | /* QT */ |
@@ -22,6 +25,7 @@ Doc_DirLister::Doc_DirLister() | |||
22 | : PDirLister( "doc_dir_lister" ) | 25 | : PDirLister( "doc_dir_lister" ) |
23 | { | 26 | { |
24 | /* connect the signals */ | 27 | /* connect the signals */ |
28 | m_catFilter = 0; | ||
25 | SlaveMaster* master = SlaveMaster::self(); | 29 | SlaveMaster* master = SlaveMaster::self(); |
26 | connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); | 30 | connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); |
27 | connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); | 31 | connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); |
@@ -40,6 +44,15 @@ QString Doc_DirLister::defaultPath()const { | |||
40 | return QString::null; | 44 | return QString::null; |
41 | } | 45 | } |
42 | 46 | ||
47 | bool Doc_DirLister::matchCat(const AppLnk* app) | ||
48 | { | ||
49 | if (!app) return false; | ||
50 | if (m_catFilter==0 || app->categories().contains(m_catFilter) || m_catFilter == -1 && app->categories().count() == 0 ) { | ||
51 | return true; | ||
52 | } | ||
53 | return false; | ||
54 | } | ||
55 | |||
43 | QString Doc_DirLister::setStartPath(const QString&) { | 56 | QString Doc_DirLister::setStartPath(const QString&) { |
44 | static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); | 57 | static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); |
45 | if (m_namemap.isEmpty()) { | 58 | if (m_namemap.isEmpty()) { |
@@ -47,7 +60,8 @@ QString Doc_DirLister::setStartPath(const QString&) { | |||
47 | Global::findDocuments(&ds,Mtype_str); | 60 | Global::findDocuments(&ds,Mtype_str); |
48 | QListIterator<DocLnk> dit(ds.children()); | 61 | QListIterator<DocLnk> dit(ds.children()); |
49 | for( ; dit.current(); ++dit) { | 62 | for( ; dit.current(); ++dit) { |
50 | // if (! (*dit)->isValid()) continue; | 63 | if (! (*dit)->isValid()) continue; |
64 | if (!matchCat((*dit))) continue; | ||
51 | m_namemap[(*dit)->name()]=(*dit)->file(); | 65 | m_namemap[(*dit)->name()]=(*dit)->file(); |
52 | m_filemap[(*dit)->file()]=(*dit)->name(); | 66 | m_filemap[(*dit)->file()]=(*dit)->name(); |
53 | } | 67 | } |
@@ -147,3 +161,28 @@ QString Doc_DirLister::nameToFname(const QString&name)const | |||
147 | QString Doc_DirLister::dirUp( const QString& p ) const{ | 161 | QString Doc_DirLister::dirUp( const QString& p ) const{ |
148 | return p; | 162 | return p; |
149 | } | 163 | } |
164 | |||
165 | QWidget* Doc_DirLister::widget(QWidget*parent) | ||
166 | { | ||
167 | CategorySelect * catmb = new CategorySelect(parent); | ||
168 | Categories cats( 0 ); | ||
169 | cats.load( categoryFileName() ); | ||
170 | QArray<int> vl( 0 ); | ||
171 | catmb->setCategories( vl, "Document View", // No tr | ||
172 | "Document View" ); | ||
173 | catmb->setRemoveCategoryEdit( TRUE ); | ||
174 | catmb->setAllCategories( TRUE ); | ||
175 | connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); | ||
176 | catmb->setCurrentCategory(-2); | ||
177 | return catmb; | ||
178 | } | ||
179 | |||
180 | void Doc_DirLister::showCategory(int which) | ||
181 | { | ||
182 | Categories cat; | ||
183 | cat.load( categoryFileName() ); | ||
184 | m_catFilter = which==-2?0:which; | ||
185 | m_namemap.clear(); | ||
186 | setStartPath(""); | ||
187 | emit sig_reloadDir(); | ||
188 | } | ||