author | alwin <alwin> | 2004-11-12 15:57:59 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-11-12 15:57:59 (UTC) |
commit | e1ed329d0b8be10ac6e019d37b82afcf21990691 (patch) (unidiff) | |
tree | 0c84e2c4fd062487932de9add39a083da194cca0 /noncore/graphics/opie-eye/impl | |
parent | de558d6f0bc31f58ffaa894a0236f0d9cb5d73e0 (diff) | |
download | opie-e1ed329d0b8be10ac6e019d37b82afcf21990691.zip opie-e1ed329d0b8be10ac6e019d37b82afcf21990691.tar.gz opie-e1ed329d0b8be10ac6e019d37b82afcf21990691.tar.bz2 |
- fixed a bug in docview-lister: different files may have same docview
name. So mapping filenames to docname isn't usefull.
- when opie-eye is started from doctab closing the imagewindow
closes the application
- when a doc-link is changed while opie-eye is running it get the
changes, too.
Diffstat (limited to 'noncore/graphics/opie-eye/impl') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_lister.cpp | 129 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_lister.h | 8 |
2 files changed, 76 insertions, 61 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 | |||
@@ -12,4 +12,5 @@ | |||
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> |
@@ -21,4 +22,5 @@ using namespace Opie::Core; | |||
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() |
@@ -36,8 +38,12 @@ Doc_DirLister::Doc_DirLister() | |||
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 | ||
@@ -46,5 +52,5 @@ QString Doc_DirLister::defaultPath()const { | |||
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; |
@@ -57,20 +63,13 @@ bool Doc_DirLister::matchCat(const AppLnk* app) | |||
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 | } |
@@ -83,7 +82,11 @@ QStringList Doc_DirLister::folders()const { | |||
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; |
@@ -94,69 +97,40 @@ void Doc_DirLister::deleteImage( const QString& ) | |||
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 | ||
@@ -183,6 +157,45 @@ 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 | } | ||
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.h b/noncore/graphics/opie-eye/impl/doc/doc_lister.h index 403241c..3f8825f 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_lister.h +++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.h | |||
@@ -15,4 +15,5 @@ | |||
15 | class Config; | 15 | class Config; |
16 | class AppLnk; | 16 | class AppLnk; |
17 | class QCopChannel; | ||
17 | 18 | ||
18 | class Doc_DirLister : public PDirLister { | 19 | class Doc_DirLister : public PDirLister { |
@@ -20,5 +21,5 @@ class Doc_DirLister : public PDirLister { | |||
20 | public: | 21 | public: |
21 | Doc_DirLister(); | 22 | Doc_DirLister(); |
22 | virtual ~Doc_DirLister(){} | 23 | virtual ~Doc_DirLister(); |
23 | 24 | ||
24 | QString defaultPath()const; | 25 | QString defaultPath()const; |
@@ -38,7 +39,6 @@ public: | |||
38 | 39 | ||
39 | private: | 40 | private: |
40 | QMap<QString,QString> m_namemap,m_filemap; | ||
41 | int m_catFilter; | 41 | int m_catFilter; |
42 | bool matchCat(const AppLnk* app); | 42 | bool matchCat(const AppLnk* app)const; |
43 | bool m_docreads; | 43 | bool m_docreads; |
44 | DocLnkSet m_ds; | 44 | DocLnkSet m_ds; |
@@ -49,4 +49,6 @@ protected slots: | |||
49 | virtual void slotThumbNail(const QString&, const QPixmap&); | 49 | virtual void slotThumbNail(const QString&, const QPixmap&); |
50 | virtual void showCategory(int); | 50 | virtual void showCategory(int); |
51 | void systemMsg(const QCString &, const QByteArray &); | ||
52 | QCopChannel *syschannel; | ||
51 | }; | 53 | }; |
52 | 54 | ||