Diffstat (limited to 'noncore/graphics/opie-eye/impl/doc/doc_lister.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_lister.cpp | 129 |
1 files changed, 71 insertions, 58 deletions
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp index f5c711a..8bcf01d 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp +++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp | |||
@@ -11,6 +11,7 @@ | |||
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 | #include <opie2/oglobal.h> | ||
14 | 15 | ||
15 | #include <qtopia/private/categories.h> | 16 | #include <qtopia/private/categories.h> |
16 | #include <qtopia/categoryselect.h> | 17 | #include <qtopia/categoryselect.h> |
@@ -20,6 +21,7 @@ using namespace Opie::Core; | |||
20 | /* QT */ | 21 | /* QT */ |
21 | #include <qdir.h> | 22 | #include <qdir.h> |
22 | #include <qfileinfo.h> | 23 | #include <qfileinfo.h> |
24 | #include <qtopia/qcopenvelope_qws.h> | ||
23 | 25 | ||
24 | Doc_DirLister::Doc_DirLister() | 26 | Doc_DirLister::Doc_DirLister() |
25 | : PDirLister( "doc_dir_lister" ) | 27 | : PDirLister( "doc_dir_lister" ) |
@@ -35,17 +37,21 @@ Doc_DirLister::Doc_DirLister() | |||
35 | this, SLOT(slotFullInfo(const QString&, const QString&)) ); | 37 | this, SLOT(slotFullInfo(const QString&, const QString&)) ); |
36 | connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), | 38 | connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), |
37 | this, SLOT(slotThumbNail(const QString&, const QPixmap&)) ); | 39 | this, SLOT(slotThumbNail(const QString&, const QPixmap&)) ); |
38 | |||
39 | m_namemap.clear(); | ||
40 | m_filemap.clear(); | ||
41 | m_docreads = false; | 40 | m_docreads = false; |
41 | syschannel = new QCopChannel("QPE/System", this); | ||
42 | connect(syschannel, SIGNAL(received(const QCString&,const QByteArray&)), | ||
43 | this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); | ||
44 | } | ||
45 | |||
46 | Doc_DirLister::~Doc_DirLister() | ||
47 | { | ||
42 | } | 48 | } |
43 | 49 | ||
44 | QString Doc_DirLister::defaultPath()const { | 50 | QString Doc_DirLister::defaultPath()const { |
45 | return QString::null; | 51 | return QString::null; |
46 | } | 52 | } |
47 | 53 | ||
48 | bool Doc_DirLister::matchCat(const AppLnk* app) | 54 | bool Doc_DirLister::matchCat(const AppLnk* app)const |
49 | { | 55 | { |
50 | if (!app) return false; | 56 | if (!app) return false; |
51 | if (m_catFilter==0 || app->categories().contains(m_catFilter) || m_catFilter == -1 && app->categories().count() == 0 ) { | 57 | if (m_catFilter==0 || app->categories().contains(m_catFilter) || m_catFilter == -1 && app->categories().count() == 0 ) { |
@@ -56,22 +62,15 @@ bool Doc_DirLister::matchCat(const AppLnk* app) | |||
56 | 62 | ||
57 | QString Doc_DirLister::setStartPath(const QString&) { | 63 | QString Doc_DirLister::setStartPath(const QString&) { |
58 | static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); | 64 | static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); |
59 | if (m_namemap.isEmpty()) { | ||
60 | if (!m_docreads) { | 65 | if (!m_docreads) { |
61 | Global::findDocuments(&m_ds,Mtype_str); | 66 | Global::findDocuments(&m_ds,Mtype_str); |
62 | m_docreads = true; | 67 | m_docreads = true; |
63 | } | 68 | } |
64 | QListIterator<DocLnk> dit(m_ds.children()); | ||
65 | for( ; dit.current(); ++dit) { | ||
66 | if (!matchCat((*dit))) continue; | ||
67 | m_namemap[(*dit)->name()]=(*dit)->file(); | ||
68 | m_filemap[(*dit)->file()]=(*dit)->name(); | ||
69 | } | ||
70 | } | ||
71 | return QString::null; | 69 | return QString::null; |
72 | } | 70 | } |
73 | 71 | ||
74 | QString Doc_DirLister::currentPath()const { | 72 | QString Doc_DirLister::currentPath()const |
73 | { | ||
75 | return QString::null; | 74 | return QString::null; |
76 | } | 75 | } |
77 | 76 | ||
@@ -82,9 +81,13 @@ QStringList Doc_DirLister::folders()const { | |||
82 | 81 | ||
83 | QStringList Doc_DirLister::files()const { | 82 | QStringList Doc_DirLister::files()const { |
84 | QStringList out; | 83 | QStringList out; |
85 | QMap<QString,QString>::ConstIterator it; | 84 | QListIterator<DocLnk> dit(m_ds.children()); |
86 | for (it = m_namemap.begin();it != m_namemap.end();++it) { | 85 | for( ; dit.current(); ++dit) { |
87 | out.append(it.key()); | 86 | if (!matchCat((*dit))) continue; |
87 | QString s = (*dit)->name(); | ||
88 | s+=char(0); | ||
89 | s+=(*dit)->file(); | ||
90 | out.append(s); | ||
88 | } | 91 | } |
89 | return out; | 92 | return out; |
90 | } | 93 | } |
@@ -93,71 +96,42 @@ void Doc_DirLister::deleteImage( const QString& ) | |||
93 | { | 96 | { |
94 | } | 97 | } |
95 | 98 | ||
96 | void Doc_DirLister::thumbNail( const QString& str, int w, int h) { | 99 | void Doc_DirLister::thumbNail( const QString& str, int w, int h) |
97 | if (m_namemap.find(str)==m_namemap.end()) { | 100 | { |
98 | return; | 101 | SlaveMaster::self()->thumbNail( str, w, h ); |
99 | } | ||
100 | QString fname = m_namemap[str]; | ||
101 | SlaveMaster::self()->thumbNail( fname, w, h ); | ||
102 | } | 102 | } |
103 | 103 | ||
104 | QImage Doc_DirLister::image( const QString& str, Factor f, int m) { | 104 | QImage Doc_DirLister::image( const QString& str, Factor f, int m) |
105 | if (m_namemap.find(str)==m_namemap.end()) { | 105 | { |
106 | return QImage(); | 106 | return SlaveMaster::self()->image(str, f, m ); |
107 | } | ||
108 | QString fname = m_namemap[str]; | ||
109 | return SlaveMaster::self()->image( fname, f, m ); | ||
110 | } | 107 | } |
111 | 108 | ||
112 | void Doc_DirLister::imageInfo( const QString& str) { | 109 | void Doc_DirLister::imageInfo( const QString& str) { |
113 | if (m_namemap.find(str)==m_namemap.end()) { | 110 | SlaveMaster::self()->thumbInfo( str ); |
114 | return; | ||
115 | } | ||
116 | QString fname = m_namemap[str]; | ||
117 | SlaveMaster::self()->thumbInfo( fname ); | ||
118 | } | 111 | } |
119 | 112 | ||
120 | void Doc_DirLister::fullImageInfo( const QString& str) { | 113 | void Doc_DirLister::fullImageInfo( const QString& str) { |
121 | if (m_namemap.find(str)==m_namemap.end()) { | 114 | SlaveMaster::self()->imageInfo(str); |
122 | return; | ||
123 | } | ||
124 | QString fname = m_namemap[str]; | ||
125 | SlaveMaster::self()->imageInfo( fname ); | ||
126 | } | 115 | } |
127 | 116 | ||
128 | void Doc_DirLister::slotFullInfo(const QString&f, const QString&t) | 117 | void Doc_DirLister::slotFullInfo(const QString&f, const QString&t) |
129 | { | 118 | { |
130 | if (m_filemap.find(f)==m_filemap.end()) { | 119 | emit sig_fullInfo(f, t); |
131 | return; | ||
132 | } | ||
133 | QString name = m_filemap[f]; | ||
134 | emit sig_fullInfo(name, t); | ||
135 | } | 120 | } |
136 | 121 | ||
137 | void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t) | 122 | void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t) |
138 | { | 123 | { |
139 | if (m_filemap.find(f)==m_filemap.end()) { | 124 | emit sig_thumbInfo(f, t); |
140 | return; | ||
141 | } | ||
142 | QString name = m_filemap[f]; | ||
143 | emit sig_thumbInfo(name, t); | ||
144 | } | 125 | } |
145 | 126 | ||
146 | void Doc_DirLister::slotThumbNail(const QString&f, const QPixmap&p) | 127 | void Doc_DirLister::slotThumbNail(const QString&f, const QPixmap&p) |
147 | { | 128 | { |
148 | if (m_filemap.find(f)==m_filemap.end()) { | 129 | emit sig_thumbNail(f, p); |
149 | return; | ||
150 | } | ||
151 | QString name = m_filemap[f]; | ||
152 | emit sig_thumbNail(name, p); | ||
153 | } | 130 | } |
154 | 131 | ||
155 | QString Doc_DirLister::nameToFname(const QString&name)const | 132 | QString Doc_DirLister::nameToFname(const QString&name)const |
156 | { | 133 | { |
157 | if (m_namemap.find(name)==m_namemap.end()) { | 134 | return name; |
158 | return QString::null; | ||
159 | } | ||
160 | return m_namemap[name]; | ||
161 | } | 135 | } |
162 | 136 | ||
163 | QString Doc_DirLister::dirUp( const QString& p ) const{ | 137 | QString Doc_DirLister::dirUp( const QString& p ) const{ |
@@ -182,7 +156,46 @@ QWidget* Doc_DirLister::widget(QWidget*parent) | |||
182 | void Doc_DirLister::showCategory(int which) | 156 | void Doc_DirLister::showCategory(int which) |
183 | { | 157 | { |
184 | m_catFilter = which==-2?0:which; | 158 | m_catFilter = which==-2?0:which; |
185 | m_namemap.clear(); | ||
186 | setStartPath(""); | 159 | setStartPath(""); |
187 | emit sig_reloadDir(); | 160 | emit sig_reloadDir(); |
188 | } | 161 | } |
162 | |||
163 | void Doc_DirLister::systemMsg(const QCString &msg, const QByteArray &data) | ||
164 | { | ||
165 | if ( msg != "linkChanged(QString)"||!m_docreads) { | ||
166 | return; | ||
167 | } | ||
168 | QString link; | ||
169 | QDataStream stream( data, IO_ReadOnly ); | ||
170 | stream >> link; | ||
171 | odebug << "Doc_DirLister systemMsg -> linkchanged( " << link << " )" << oendl; | ||
172 | if ( link.isNull() || OGlobal::isAppLnkFileName(link) ) { | ||
173 | return; | ||
174 | } | ||
175 | QListIterator<DocLnk> dit(m_ds.children()); | ||
176 | bool must_reload = false; | ||
177 | bool found = false; | ||
178 | while ( dit.current() ) { | ||
179 | DocLnk *doc = dit.current(); | ||
180 | ++dit; | ||
181 | if (doc->linkFile() == link) { | ||
182 | found = true; | ||
183 | DocLnk* dl = new DocLnk(link); | ||
184 | if (dl->fileKnown()) { | ||
185 | // changing | ||
186 | m_ds.add(dl); | ||
187 | } else { | ||
188 | delete dl; | ||
189 | } | ||
190 | if (matchCat(doc) || matchCat(dl)) { | ||
191 | must_reload = true; | ||
192 | } | ||
193 | m_ds.remove( doc ); // remove old link from docLnkSet | ||
194 | delete doc; | ||
195 | } | ||
196 | } | ||
197 | if (must_reload) { | ||
198 | setStartPath(""); | ||
199 | emit sig_reloadDir(); | ||
200 | } | ||
201 | } | ||