-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_lister.cpp | 11 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_lister.h | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp index d60149f..e43baed 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp +++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp | |||
@@ -1,159 +1,162 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include "doc_lister.h" | 5 | #include "doc_lister.h" |
6 | 6 | ||
7 | #include <lib/slavemaster.h> | 7 | #include <lib/slavemaster.h> |
8 | 8 | ||
9 | /* OPIE */ | 9 | /* OPIE */ |
10 | #include <opie2/odebug.h> | 10 | #include <opie2/odebug.h> |
11 | #include <qpe/config.h> | 11 | #include <qpe/config.h> |
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> | 15 | #include <qtopia/private/categories.h> |
16 | #include <qtopia/categoryselect.h> | 16 | #include <qtopia/categoryselect.h> |
17 | 17 | ||
18 | using namespace Opie::Core; | 18 | using namespace Opie::Core; |
19 | 19 | ||
20 | /* QT */ | 20 | /* QT */ |
21 | #include <qdir.h> | 21 | #include <qdir.h> |
22 | #include <qfileinfo.h> | 22 | #include <qfileinfo.h> |
23 | 23 | ||
24 | Doc_DirLister::Doc_DirLister() | 24 | Doc_DirLister::Doc_DirLister() |
25 | : PDirLister( "doc_dir_lister" ) | 25 | : PDirLister( "doc_dir_lister" ) |
26 | { | 26 | { |
27 | /* connect the signals */ | 27 | /* connect the signals */ |
28 | m_catFilter = 0; | 28 | m_catFilter = 0; |
29 | SlaveMaster* master = SlaveMaster::self(); | 29 | SlaveMaster* master = SlaveMaster::self(); |
30 | connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); | 30 | connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); |
31 | connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); | 31 | connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); |
32 | connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)), | 32 | connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)), |
33 | this, SLOT(slotThumbInfo(const QString&, const QString&)) ); | 33 | this, SLOT(slotThumbInfo(const QString&, const QString&)) ); |
34 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), | 34 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), |
35 | this, SLOT(slotFullInfo(const QString&, const QString&)) ); | 35 | this, SLOT(slotFullInfo(const QString&, const QString&)) ); |
36 | connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), | 36 | connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), |
37 | this, SLOT(slotThumbNail(const QString&, const QPixmap&)) ); | 37 | this, SLOT(slotThumbNail(const QString&, const QPixmap&)) ); |
38 | 38 | ||
39 | m_namemap.clear(); | 39 | m_namemap.clear(); |
40 | m_filemap.clear(); | 40 | m_filemap.clear(); |
41 | m_docreads = false; | ||
41 | } | 42 | } |
42 | 43 | ||
43 | QString Doc_DirLister::defaultPath()const { | 44 | QString Doc_DirLister::defaultPath()const { |
44 | return QString::null; | 45 | return QString::null; |
45 | } | 46 | } |
46 | 47 | ||
47 | bool Doc_DirLister::matchCat(const AppLnk* app) | 48 | bool Doc_DirLister::matchCat(const AppLnk* app) |
48 | { | 49 | { |
49 | if (!app) return false; | 50 | if (!app) return false; |
50 | if (m_catFilter==0 || app->categories().contains(m_catFilter) || m_catFilter == -1 && app->categories().count() == 0 ) { | 51 | if (m_catFilter==0 || app->categories().contains(m_catFilter) || m_catFilter == -1 && app->categories().count() == 0 ) { |
51 | return true; | 52 | return true; |
52 | } | 53 | } |
53 | return false; | 54 | return false; |
54 | } | 55 | } |
55 | 56 | ||
56 | QString Doc_DirLister::setStartPath(const QString&) { | 57 | QString Doc_DirLister::setStartPath(const QString&) { |
57 | static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); | 58 | static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); |
58 | if (m_namemap.isEmpty()) { | 59 | if (m_namemap.isEmpty()) { |
59 | DocLnkSet ds; | 60 | if (!m_docreads) { |
60 | Global::findDocuments(&ds,Mtype_str); | 61 | Global::findDocuments(&m_ds,Mtype_str); |
61 | QListIterator<DocLnk> dit(ds.children()); | 62 | m_docreads = true; |
63 | } | ||
64 | QListIterator<DocLnk> dit(m_ds.children()); | ||
62 | for( ; dit.current(); ++dit) { | 65 | for( ; dit.current(); ++dit) { |
63 | if (! (*dit)->isValid()) continue; | 66 | // if (! (*dit)->isValid()) continue; |
64 | if (!matchCat((*dit))) continue; | 67 | if (!matchCat((*dit))) continue; |
65 | m_namemap[(*dit)->name()]=(*dit)->file(); | 68 | m_namemap[(*dit)->name()]=(*dit)->file(); |
66 | m_filemap[(*dit)->file()]=(*dit)->name(); | 69 | m_filemap[(*dit)->file()]=(*dit)->name(); |
67 | } | 70 | } |
68 | } | 71 | } |
69 | return QString::null; | 72 | return QString::null; |
70 | } | 73 | } |
71 | 74 | ||
72 | QString Doc_DirLister::currentPath()const { | 75 | QString Doc_DirLister::currentPath()const { |
73 | return QString::null; | 76 | return QString::null; |
74 | } | 77 | } |
75 | 78 | ||
76 | 79 | ||
77 | QStringList Doc_DirLister::folders()const { | 80 | QStringList Doc_DirLister::folders()const { |
78 | return QStringList(); | 81 | return QStringList(); |
79 | } | 82 | } |
80 | 83 | ||
81 | QStringList Doc_DirLister::files()const { | 84 | QStringList Doc_DirLister::files()const { |
82 | QStringList out; | 85 | QStringList out; |
83 | QMap<QString,QString>::ConstIterator it; | 86 | QMap<QString,QString>::ConstIterator it; |
84 | for (it = m_namemap.begin();it != m_namemap.end();++it) { | 87 | for (it = m_namemap.begin();it != m_namemap.end();++it) { |
85 | out.append(it.key()); | 88 | out.append(it.key()); |
86 | } | 89 | } |
87 | return out; | 90 | return out; |
88 | } | 91 | } |
89 | 92 | ||
90 | void Doc_DirLister::deleteImage( const QString& ) | 93 | void Doc_DirLister::deleteImage( const QString& ) |
91 | { | 94 | { |
92 | } | 95 | } |
93 | 96 | ||
94 | void Doc_DirLister::thumbNail( const QString& str, int w, int h) { | 97 | void Doc_DirLister::thumbNail( const QString& str, int w, int h) { |
95 | if (m_namemap.find(str)==m_namemap.end()) { | 98 | if (m_namemap.find(str)==m_namemap.end()) { |
96 | return; | 99 | return; |
97 | } | 100 | } |
98 | QString fname = m_namemap[str]; | 101 | QString fname = m_namemap[str]; |
99 | SlaveMaster::self()->thumbNail( fname, w, h ); | 102 | SlaveMaster::self()->thumbNail( fname, w, h ); |
100 | } | 103 | } |
101 | 104 | ||
102 | QImage Doc_DirLister::image( const QString& str, Factor f, int m) { | 105 | QImage Doc_DirLister::image( const QString& str, Factor f, int m) { |
103 | if (m_namemap.find(str)==m_namemap.end()) { | 106 | if (m_namemap.find(str)==m_namemap.end()) { |
104 | return QImage(); | 107 | return QImage(); |
105 | } | 108 | } |
106 | QString fname = m_namemap[str]; | 109 | QString fname = m_namemap[str]; |
107 | return SlaveMaster::self()->image( fname, f, m ); | 110 | return SlaveMaster::self()->image( fname, f, m ); |
108 | } | 111 | } |
109 | 112 | ||
110 | void Doc_DirLister::imageInfo( const QString& str) { | 113 | void Doc_DirLister::imageInfo( const QString& str) { |
111 | if (m_namemap.find(str)==m_namemap.end()) { | 114 | if (m_namemap.find(str)==m_namemap.end()) { |
112 | return; | 115 | return; |
113 | } | 116 | } |
114 | QString fname = m_namemap[str]; | 117 | QString fname = m_namemap[str]; |
115 | SlaveMaster::self()->thumbInfo( fname ); | 118 | SlaveMaster::self()->thumbInfo( fname ); |
116 | } | 119 | } |
117 | 120 | ||
118 | void Doc_DirLister::fullImageInfo( const QString& str) { | 121 | void Doc_DirLister::fullImageInfo( const QString& str) { |
119 | if (m_namemap.find(str)==m_namemap.end()) { | 122 | if (m_namemap.find(str)==m_namemap.end()) { |
120 | return; | 123 | return; |
121 | } | 124 | } |
122 | QString fname = m_namemap[str]; | 125 | QString fname = m_namemap[str]; |
123 | SlaveMaster::self()->imageInfo( fname ); | 126 | SlaveMaster::self()->imageInfo( fname ); |
124 | } | 127 | } |
125 | 128 | ||
126 | void Doc_DirLister::slotFullInfo(const QString&f, const QString&t) | 129 | void Doc_DirLister::slotFullInfo(const QString&f, const QString&t) |
127 | { | 130 | { |
128 | if (m_filemap.find(f)==m_filemap.end()) { | 131 | if (m_filemap.find(f)==m_filemap.end()) { |
129 | return; | 132 | return; |
130 | } | 133 | } |
131 | QString name = m_filemap[f]; | 134 | QString name = m_filemap[f]; |
132 | emit sig_fullInfo(name, t); | 135 | emit sig_fullInfo(name, t); |
133 | } | 136 | } |
134 | 137 | ||
135 | void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t) | 138 | void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t) |
136 | { | 139 | { |
137 | if (m_filemap.find(f)==m_filemap.end()) { | 140 | if (m_filemap.find(f)==m_filemap.end()) { |
138 | return; | 141 | return; |
139 | } | 142 | } |
140 | QString name = m_filemap[f]; | 143 | QString name = m_filemap[f]; |
141 | emit sig_thumbInfo(name, t); | 144 | emit sig_thumbInfo(name, t); |
142 | } | 145 | } |
143 | 146 | ||
144 | void Doc_DirLister::slotThumbNail(const QString&f, const QPixmap&p) | 147 | void Doc_DirLister::slotThumbNail(const QString&f, const QPixmap&p) |
145 | { | 148 | { |
146 | if (m_filemap.find(f)==m_filemap.end()) { | 149 | if (m_filemap.find(f)==m_filemap.end()) { |
147 | return; | 150 | return; |
148 | } | 151 | } |
149 | QString name = m_filemap[f]; | 152 | QString name = m_filemap[f]; |
150 | emit sig_thumbNail(name, p); | 153 | emit sig_thumbNail(name, p); |
151 | } | 154 | } |
152 | 155 | ||
153 | QString Doc_DirLister::nameToFname(const QString&name)const | 156 | QString Doc_DirLister::nameToFname(const QString&name)const |
154 | { | 157 | { |
155 | if (m_namemap.find(name)==m_namemap.end()) { | 158 | if (m_namemap.find(name)==m_namemap.end()) { |
156 | return QString::null; | 159 | return QString::null; |
157 | } | 160 | } |
158 | return m_namemap[name]; | 161 | return m_namemap[name]; |
159 | } | 162 | } |
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.h b/noncore/graphics/opie-eye/impl/doc/doc_lister.h index e148ac0..403241c 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_lister.h +++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.h | |||
@@ -1,49 +1,53 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef DOC_LISTER_INTERFACE_LISTER_H | 5 | #ifndef DOC_LISTER_INTERFACE_LISTER_H |
6 | #define DOC_LISTER_INTERFACE_LISTER_H | 6 | #define DOC_LISTER_INTERFACE_LISTER_H |
7 | 7 | ||
8 | #include <iface/dirlister.h> | 8 | #include <iface/dirlister.h> |
9 | 9 | ||
10 | #include <qpe/applnk.h> | ||
11 | |||
10 | #include <qstring.h> | 12 | #include <qstring.h> |
11 | #include <qmap.h> | 13 | #include <qmap.h> |
12 | 14 | ||
13 | class Config; | 15 | class Config; |
14 | class AppLnk; | 16 | class AppLnk; |
15 | 17 | ||
16 | class Doc_DirLister : public PDirLister { | 18 | class Doc_DirLister : public PDirLister { |
17 | Q_OBJECT | 19 | Q_OBJECT |
18 | public: | 20 | public: |
19 | Doc_DirLister(); | 21 | Doc_DirLister(); |
20 | virtual ~Doc_DirLister(){} | 22 | virtual ~Doc_DirLister(){} |
21 | 23 | ||
22 | QString defaultPath()const; | 24 | QString defaultPath()const; |
23 | QString setStartPath( const QString& ); | 25 | QString setStartPath( const QString& ); |
24 | QString currentPath()const; | 26 | QString currentPath()const; |
25 | QStringList folders()const; | 27 | QStringList folders()const; |
26 | QStringList files()const; | 28 | QStringList files()const; |
27 | 29 | ||
28 | void deleteImage( const QString& ); | 30 | void deleteImage( const QString& ); |
29 | void thumbNail( const QString&, int, int ); | 31 | void thumbNail( const QString&, int, int ); |
30 | QImage image( const QString&, Factor, int ); | 32 | QImage image( const QString&, Factor, int ); |
31 | void imageInfo( const QString& ); | 33 | void imageInfo( const QString& ); |
32 | void fullImageInfo( const QString& ); | 34 | void fullImageInfo( const QString& ); |
33 | virtual QString nameToFname(const QString&name)const; | 35 | virtual QString nameToFname(const QString&name)const; |
34 | QString dirUp( const QString& )const; | 36 | QString dirUp( const QString& )const; |
35 | QWidget* widget(QWidget*parent); | 37 | QWidget* widget(QWidget*parent); |
36 | 38 | ||
37 | private: | 39 | private: |
38 | QMap<QString,QString> m_namemap,m_filemap; | 40 | QMap<QString,QString> m_namemap,m_filemap; |
39 | int m_catFilter; | 41 | int m_catFilter; |
40 | bool matchCat(const AppLnk* app); | 42 | bool matchCat(const AppLnk* app); |
43 | bool m_docreads; | ||
44 | DocLnkSet m_ds; | ||
41 | 45 | ||
42 | protected slots: | 46 | protected slots: |
43 | virtual void slotFullInfo(const QString&, const QString&); | 47 | virtual void slotFullInfo(const QString&, const QString&); |
44 | virtual void slotThumbInfo(const QString&, const QString&); | 48 | virtual void slotThumbInfo(const QString&, const QString&); |
45 | virtual void slotThumbNail(const QString&, const QPixmap&); | 49 | virtual void slotThumbNail(const QString&, const QPixmap&); |
46 | virtual void showCategory(int); | 50 | virtual void showCategory(int); |
47 | }; | 51 | }; |
48 | 52 | ||
49 | #endif | 53 | #endif |