author | llornkcor <llornkcor> | 2002-12-20 01:35:01 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-20 01:35:01 (UTC) |
commit | 876e1a4724a7bd75dc642e295de354241096e028 (patch) (unidiff) | |
tree | a37c5dcc9d78e04bb6b859ab89d8cf81e6745087 | |
parent | 5fd6636ba3d94b48dd543887316c47c5388a43c2 (diff) | |
download | opie-876e1a4724a7bd75dc642e295de354241096e028.zip opie-876e1a4724a7bd75dc642e295de354241096e028.tar.gz opie-876e1a4724a7bd75dc642e295de354241096e028.tar.bz2 |
update - sorry it took so long. hope this works correctly
46 files changed, 4580 insertions, 1522 deletions
diff --git a/noncore/apps/opie-reader/Aportis.cpp b/noncore/apps/opie-reader/Aportis.cpp index 1327ff8..b4988da 100644 --- a/noncore/apps/opie-reader/Aportis.cpp +++ b/noncore/apps/opie-reader/Aportis.cpp | |||
@@ -92,3 +92,3 @@ CList<Bkmk>* Aportis::getbkmklist() | |||
92 | 92 | ||
93 | int Aportis::openfile(const char *src) | 93 | int Aportis::OpenFile(const char *src) |
94 | { | 94 | { |
diff --git a/noncore/apps/opie-reader/Aportis.h b/noncore/apps/opie-reader/Aportis.h index 1ca5e73..af1fd3b 100644 --- a/noncore/apps/opie-reader/Aportis.h +++ b/noncore/apps/opie-reader/Aportis.h | |||
@@ -77,2 +77,10 @@ class Aportis : public CExpander, Cpdb { | |||
77 | public: | 77 | public: |
78 | virtual void suspend() | ||
79 | { | ||
80 | CExpander::suspend(fin); | ||
81 | } | ||
82 | virtual void unsuspend() | ||
83 | { | ||
84 | CExpander::unsuspend(fin); | ||
85 | } | ||
78 | virtual void sizes(unsigned long& _file, unsigned long& _text) | 86 | virtual void sizes(unsigned long& _file, unsigned long& _text) |
@@ -85,3 +93,3 @@ public: | |||
85 | Aportis(); | 93 | Aportis(); |
86 | virtual int openfile(const char *src); | 94 | virtual int OpenFile(const char *src); |
87 | virtual int getch(); | 95 | virtual int getch(); |
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp index 30d2881..998601a 100644 --- a/noncore/apps/opie-reader/Bkmks.cpp +++ b/noncore/apps/opie-reader/Bkmks.cpp | |||
@@ -1 +1,2 @@ | |||
1 | #include "name.h" | ||
1 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
@@ -11,2 +12,11 @@ const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned lo | |||
11 | 12 | ||
13 | Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) : m_position(_p) | ||
14 | { | ||
15 | init(_nm, _nmlen, _anno, _annolen, _p); | ||
16 | } | ||
17 | |||
18 | Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p) | ||
19 | { | ||
20 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p); | ||
21 | } | ||
12 | 22 | ||
@@ -14,5 +24,2 @@ Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_ | |||
14 | { | 24 | { |
15 | int len = ustrlen(_nm)+1; | ||
16 | m_name = new tchar[len]; | ||
17 | for (int i = 0; i < len; i++) m_name[i] = _nm[i]; | ||
18 | 25 | ||
@@ -20,4 +27,4 @@ Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_ | |||
20 | { | 27 | { |
21 | m_anno = new tchar[1]; | 28 | tchar t = 0; |
22 | m_anno[0] = 0; | 29 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); |
23 | } | 30 | } |
@@ -25,5 +32,3 @@ Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_ | |||
25 | { | 32 | { |
26 | len = ustrlen(_anno)+1; | 33 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); |
27 | m_anno = new tchar[len]; | ||
28 | for (int i = 0; i < len; i++) m_anno[i] = _anno[i]; | ||
29 | } | 34 | } |
@@ -31,2 +36,28 @@ Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_ | |||
31 | 36 | ||
37 | void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p) | ||
38 | { | ||
39 | m_namelen = _nmlen; | ||
40 | if (m_namelen > 0) | ||
41 | { | ||
42 | m_name = new unsigned char[m_namelen]; | ||
43 | memcpy(m_name, _nm, m_namelen); | ||
44 | } | ||
45 | else | ||
46 | { | ||
47 | m_name = NULL; | ||
48 | } | ||
49 | |||
50 | m_annolen = _annolen; | ||
51 | if (m_annolen > 0) | ||
52 | { | ||
53 | m_anno = new unsigned char[m_annolen]; | ||
54 | memcpy(m_anno, _anno, m_annolen); | ||
55 | } | ||
56 | else | ||
57 | { | ||
58 | m_anno = NULL; | ||
59 | } | ||
60 | m_position = _p; | ||
61 | } | ||
62 | |||
32 | Bkmk::~Bkmk() | 63 | Bkmk::~Bkmk() |
@@ -43,4 +74,4 @@ Bkmk& Bkmk::operator=(const Bkmk& rhs) | |||
43 | { | 74 | { |
44 | delete [] m_name; | 75 | delete [] m_name; |
45 | m_name = NULL; | 76 | m_name = NULL; |
46 | } | 77 | } |
@@ -48,4 +79,4 @@ Bkmk& Bkmk::operator=(const Bkmk& rhs) | |||
48 | { | 79 | { |
49 | delete [] m_anno; | 80 | delete [] m_anno; |
50 | m_anno = NULL; | 81 | m_anno = NULL; |
51 | } | 82 | } |
@@ -53,16 +84,16 @@ Bkmk& Bkmk::operator=(const Bkmk& rhs) | |||
53 | { | 84 | { |
54 | int len = ustrlen(rhs.m_name)+1; | 85 | m_namelen = rhs.m_namelen; |
55 | m_name = new tchar[len]; | 86 | m_name = new unsigned char[m_namelen]; |
56 | for (int i = 0; i < len; i++) m_name[i] = rhs.m_name[i]; | 87 | memcpy(m_name, rhs.m_name, m_namelen); |
57 | } | 88 | } |
58 | else | 89 | else |
59 | m_name = NULL; | 90 | m_name = NULL; |
60 | if (rhs.m_anno != NULL) | 91 | if (rhs.m_anno != NULL) |
61 | { | 92 | { |
62 | int len = ustrlen(rhs.m_anno)+1; | 93 | m_annolen = rhs.m_annolen; |
63 | m_anno = new tchar[len]; | 94 | m_anno = new unsigned char[m_annolen]; |
64 | for (int i = 0; i < len; i++) m_anno[i] = rhs.m_anno[i]; | 95 | memcpy(m_anno, rhs.m_anno, m_annolen); |
65 | } | 96 | } |
66 | else | 97 | else |
67 | m_anno = NULL; | 98 | m_anno = NULL; |
68 | m_position = rhs.m_position; | 99 | m_position = rhs.m_position; |
@@ -73,3 +104,24 @@ bool Bkmk::operator==(const Bkmk& rhs) | |||
73 | { | 104 | { |
74 | return (m_position == rhs.m_position && ustrcmp(m_name,rhs.m_name) == 0); | 105 | return (m_position == rhs.m_position && (rhs.m_namelen == m_namelen) && memcmp(m_name,rhs.m_name,m_namelen) == 0); |
106 | } | ||
107 | |||
108 | void Bkmk::setAnno(unsigned char* t, unsigned short len) | ||
109 | { | ||
110 | if (m_anno != NULL) | ||
111 | { | ||
112 | delete [] m_anno; | ||
113 | m_anno = NULL; | ||
114 | } | ||
115 | if (t != NULL) | ||
116 | { | ||
117 | m_annolen = len; | ||
118 | m_anno = new unsigned char[m_annolen]; | ||
119 | memcpy(m_anno, t, m_annolen); | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | m_annolen = sizeof(tchar); | ||
124 | m_anno = new unsigned char[m_annolen]; | ||
125 | *((tchar*)m_anno) = 0; | ||
126 | } | ||
75 | } | 127 | } |
@@ -80,4 +132,4 @@ void Bkmk::setAnno(tchar* t) | |||
80 | { | 132 | { |
81 | delete [] m_anno; | 133 | delete [] m_anno; |
82 | m_anno = NULL; | 134 | m_anno = NULL; |
83 | } | 135 | } |
@@ -85,11 +137,16 @@ void Bkmk::setAnno(tchar* t) | |||
85 | { | 137 | { |
86 | int len = ustrlen(t)+1; | 138 | unsigned short len = ustrlen(t)+1; |
87 | m_anno = new tchar[len]; | 139 | m_annolen = sizeof(tchar)*len; |
88 | for (int i = 0; i < len; i++) m_anno[i] = t[i]; | 140 | m_anno = new unsigned char[m_annolen]; |
141 | memcpy(m_anno, t, m_annolen); | ||
89 | } | 142 | } |
90 | else | 143 | else |
91 | m_anno = NULL; | 144 | { |
145 | m_annolen = sizeof(tchar); | ||
146 | m_anno = new unsigned char[m_annolen]; | ||
147 | *((tchar*)m_anno) = 0; | ||
148 | } | ||
92 | } | 149 | } |
93 | 150 | ||
94 | BkmkFile::BkmkFile(const char *fnm, bool w ) | 151 | BkmkFile::BkmkFile(const char *fnm, bool w = false) |
95 | : | 152 | : |
@@ -99,3 +156,3 @@ BkmkFile::BkmkFile(const char *fnm, bool w ) | |||
99 | { | 156 | { |
100 | f = fopen(fnm, "wb"); | 157 | f = fopen(fnm, "wb"); |
101 | } | 158 | } |
@@ -103,3 +160,3 @@ BkmkFile::BkmkFile(const char *fnm, bool w ) | |||
103 | { | 160 | { |
104 | f = fopen(fnm, "rb"); | 161 | f = fopen(fnm, "rb"); |
105 | } | 162 | } |
@@ -112,3 +169,3 @@ BkmkFile::~BkmkFile() | |||
112 | 169 | ||
113 | void BkmkFile::write(tchar* nm, tchar* an, const unsigned int& pos) | 170 | void BkmkFile::write(const Bkmk& b) |
114 | { | 171 | { |
@@ -116,9 +173,7 @@ void BkmkFile::write(tchar* nm, tchar* an, const unsigned int& pos) | |||
116 | { | 173 | { |
117 | unsigned short ln = ustrlen(nm); | 174 | fwrite(&b.m_namelen, sizeof(b.m_namelen),1,f); |
118 | fwrite(&ln,sizeof(ln),1,f); | 175 | fwrite(b.m_name,1,b.m_namelen,f); |
119 | fwrite(nm,sizeof(tchar),ln,f); | 176 | fwrite(&b.m_annolen, sizeof(b.m_annolen),1,f); |
120 | ln = ustrlen(an); | 177 | fwrite(b.m_anno,1,b.m_annolen,f); |
121 | fwrite(&ln,sizeof(ln),1,f); | 178 | fwrite(&b.m_position,sizeof(b.m_position),1,f); |
122 | if (ln > 0) fwrite(an,sizeof(tchar),ln,f); | ||
123 | fwrite(&pos,sizeof(pos),1,f); | ||
124 | } | 179 | } |
@@ -126,4 +181,2 @@ void BkmkFile::write(tchar* nm, tchar* an, const unsigned int& pos) | |||
126 | 181 | ||
127 | void BkmkFile::write(const Bkmk& b) { write(b.name(), b.anno(), b.value()); } | ||
128 | |||
129 | void BkmkFile::write(CList<Bkmk>& bl) | 182 | void BkmkFile::write(CList<Bkmk>& bl) |
@@ -132,31 +185,8 @@ void BkmkFile::write(CList<Bkmk>& bl) | |||
132 | { | 185 | { |
133 | fwrite(&magic, sizeof(magic), 1, f); | 186 | fwrite(&magic, sizeof(magic), 1, f); |
134 | for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++) | 187 | for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++) |
135 | { | 188 | { |
136 | write(*i); | 189 | write(*i); |
137 | } | 190 | } |
138 | } | ||
139 | } | ||
140 | |||
141 | Bkmk* BkmkFile::read() | ||
142 | { | ||
143 | Bkmk* b = NULL; | ||
144 | if (f != NULL) | ||
145 | { | ||
146 | unsigned short ln; | ||
147 | if (fread(&ln,sizeof(ln),1,f) == 1) | ||
148 | { | ||
149 | b = new Bkmk; | ||
150 | b->m_name = new tchar[ln+1]; | ||
151 | fread(b->m_name,sizeof(tchar),ln,f); | ||
152 | b->m_name[ln] = 0; | ||
153 | |||
154 | fread(&ln,sizeof(ln),1,f); | ||
155 | b->m_anno = new tchar[ln+1]; | ||
156 | if (ln > 0) fread(b->m_anno,sizeof(tchar),ln,f); | ||
157 | b->m_anno[ln] = 0; | ||
158 | fread(&b->m_position,sizeof(b->m_position),1,f); | ||
159 | } | ||
160 | } | 191 | } |
161 | return b; | ||
162 | } | 192 | } |
@@ -168,22 +198,38 @@ CList<Bkmk>* BkmkFile::readall() | |||
168 | { | 198 | { |
169 | unsigned long newmagic; | 199 | unsigned long newmagic; |
170 | fread(&newmagic, sizeof(newmagic), 1, f); | 200 | fread(&newmagic, sizeof(newmagic), 1, f); |
171 | if (newmagic != magic) | 201 | if ((newmagic & 0xffffff00) != (magic & 0xffffff00)) |
172 | { | 202 | { |
173 | if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of OpieReader\ndid you upgrade from?", "0_4*", "Any other version") == 0) | 203 | if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of " PROGNAME "\ndid you upgrade from?", "0_4*", "Any other version") == 0) |
174 | { | 204 | { |
175 | fseek(f,0,SEEK_SET); | 205 | fseek(f,0,SEEK_SET); |
176 | bl = readall04(); | 206 | bl = readall00(&read05); |
177 | } | 207 | } |
178 | else | 208 | else |
179 | { | 209 | { |
180 | fseek(f,0,SEEK_SET); | 210 | fseek(f,0,SEEK_SET); |
181 | bl = readall03(); | 211 | bl = readall00(&read03); |
182 | } | 212 | } |
183 | isUpgraded = true; | 213 | isUpgraded = true; |
184 | } | 214 | } |
185 | else | 215 | else |
186 | { | 216 | { |
187 | bl = readall04(); | 217 | switch(newmagic & 0xff) |
188 | } | 218 | { |
219 | case 6: | ||
220 | isUpgraded = false; | ||
221 | bl = readall00(read06); | ||
222 | qDebug("Correct version!"); | ||
223 | break; | ||
224 | case 5: | ||
225 | isUpgraded = true; | ||
226 | bl = readall00(read05); | ||
227 | qDebug("Known version!"); | ||
228 | break; | ||
229 | default: | ||
230 | qDebug("Unknown version!"); | ||
231 | isUpgraded = true; | ||
232 | bl = readall00(read05); | ||
233 | } | ||
234 | } | ||
189 | } | 235 | } |
@@ -192,3 +238,3 @@ CList<Bkmk>* BkmkFile::readall() | |||
192 | 238 | ||
193 | CList<Bkmk>* BkmkFile::readall04() | 239 | CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(FILE*)) |
194 | { | 240 | { |
@@ -197,6 +243,6 @@ CList<Bkmk>* BkmkFile::readall04() | |||
197 | { | 243 | { |
198 | Bkmk* b = read(); | 244 | Bkmk* b = (*readfn)(f); |
199 | if (b == NULL) break; | 245 | if (b == NULL) break; |
200 | bl->push_back(*b); | 246 | bl->push_back(*b); |
201 | delete b; | 247 | delete b; |
202 | } | 248 | } |
@@ -205,16 +251,27 @@ CList<Bkmk>* BkmkFile::readall04() | |||
205 | 251 | ||
206 | CList<Bkmk>* BkmkFile::readall03() | 252 | Bkmk* BkmkFile::read03(FILE* f) |
207 | { | 253 | { |
208 | CList<Bkmk>* bl = new CList<Bkmk>; | 254 | Bkmk* b = NULL; |
209 | while (1) | 255 | if (f != NULL) |
210 | { | 256 | { |
211 | Bkmk* b = read03(); | 257 | unsigned short ln; |
212 | if (b == NULL) break; | 258 | if (fread(&ln,sizeof(ln),1,f) == 1) |
213 | bl->push_back(*b); | 259 | { |
214 | delete b; | 260 | tchar* name = new tchar[ln+1]; |
261 | fread(name,sizeof(tchar),ln,f); | ||
262 | name[ln] = 0; | ||
263 | |||
264 | ln = 0; | ||
265 | tchar* anno = new tchar[ln+1]; | ||
266 | anno[ln] = 0; | ||
267 | |||
268 | unsigned int pos; | ||
269 | fread(&pos,sizeof(pos),1,f); | ||
270 | b = new Bkmk(name,anno,pos); | ||
271 | } | ||
215 | } | 272 | } |
216 | return bl; | 273 | return b; |
217 | } | 274 | } |
218 | 275 | ||
219 | Bkmk* BkmkFile::read03() | 276 | Bkmk* BkmkFile::read05(FILE* f) |
220 | { | 277 | { |
@@ -223,16 +280,41 @@ Bkmk* BkmkFile::read03() | |||
223 | { | 280 | { |
224 | unsigned short ln; | 281 | unsigned short ln; |
225 | if (fread(&ln,sizeof(ln),1,f) == 1) | 282 | if (fread(&ln,sizeof(ln),1,f) == 1) |
226 | { | 283 | { |
227 | b = new Bkmk; | 284 | tchar* nm = new tchar[ln+1]; |
228 | b->m_name = new tchar[ln+1]; | 285 | fread(nm,sizeof(tchar),ln,f); |
229 | fread(b->m_name,sizeof(tchar),ln,f); | 286 | nm[ln] = 0; |
230 | b->m_name[ln] = 0; | 287 | fread(&ln,sizeof(ln),1,f); |
288 | tchar* anno = new tchar[ln+1]; | ||
289 | if (ln > 0) fread(anno,sizeof(tchar),ln,f); | ||
290 | anno[ln] = 0; | ||
291 | unsigned int pos; | ||
292 | fread(&pos,sizeof(pos),1,f); | ||
293 | b = new Bkmk(nm,anno,pos); | ||
294 | } | ||
295 | } | ||
296 | return b; | ||
297 | } | ||
231 | 298 | ||
232 | ln = 0; | 299 | Bkmk* BkmkFile::read06(FILE* f) |
233 | b->m_anno = new tchar[ln+1]; | 300 | { |
234 | b->m_anno[ln] = 0; | 301 | Bkmk* b = NULL; |
302 | if (f != NULL) | ||
303 | { | ||
304 | unsigned short ln; | ||
305 | if (fread(&ln,sizeof(ln),1,f) == 1) | ||
306 | { | ||
307 | b = new Bkmk; | ||
308 | b->m_namelen = ln; | ||
309 | b->m_name = new unsigned char[b->m_namelen]; | ||
310 | fread(b->m_name,1,b->m_namelen,f); | ||
235 | 311 | ||
236 | fread(&b->m_position,sizeof(b->m_position),1,f); | 312 | fread(&(b->m_annolen),sizeof(b->m_annolen),1,f); |
237 | } | 313 | if (b->m_annolen > 0) |
314 | { | ||
315 | b->m_anno = new unsigned char[b->m_annolen]; | ||
316 | fread(b->m_anno,1,b->m_annolen,f); | ||
317 | } | ||
318 | fread(&(b->m_position),sizeof(b->m_position),1,f); | ||
319 | } | ||
238 | } | 320 | } |
diff --git a/noncore/apps/opie-reader/Bkmks.h b/noncore/apps/opie-reader/Bkmks.h index b38184a..ee528e4 100644 --- a/noncore/apps/opie-reader/Bkmks.h +++ b/noncore/apps/opie-reader/Bkmks.h | |||
@@ -4,2 +4,3 @@ | |||
4 | #include "config.h" | 4 | #include "config.h" |
5 | #include "Filedata.h" | ||
5 | #include <stdio.h> | 6 | #include <stdio.h> |
@@ -12,7 +13,12 @@ class Bkmk | |||
12 | friend class BkmkFile; | 13 | friend class BkmkFile; |
13 | tchar* m_name; | 14 | unsigned char* m_name; |
14 | tchar* m_anno; | 15 | unsigned short m_namelen; |
16 | unsigned char* m_anno; | ||
17 | unsigned short m_annolen; | ||
15 | unsigned int m_position; | 18 | unsigned int m_position; |
19 | void init(const void*, unsigned short, const void*, unsigned short, unsigned int); | ||
16 | public: | 20 | public: |
17 | Bkmk() : m_name(NULL), m_anno(NULL), m_position(0) {}; | 21 | Bkmk() : m_name(NULL), m_namelen(0), m_anno(NULL), m_annolen(0), m_position(0) {}; |
22 | Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); | ||
23 | Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); | ||
18 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p); | 24 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p); |
@@ -24,4 +30,5 @@ class Bkmk | |||
24 | unsigned int value() const { return m_position; } | 30 | unsigned int value() const { return m_position; } |
25 | tchar *name() const { return m_name; } | 31 | void value(unsigned int _v) { m_position = _v; } |
26 | tchar *anno() const { return m_anno; } | 32 | tchar *name() const { return (tchar*)m_name; } |
33 | tchar *anno() const { return (tchar*)m_anno; } | ||
27 | bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); } | 34 | bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); } |
@@ -30,2 +37,13 @@ class Bkmk | |||
30 | void setAnno(tchar* t); | 37 | void setAnno(tchar* t); |
38 | void setAnno(unsigned char* t, unsigned short len); | ||
39 | unsigned char* filedata() | ||
40 | { | ||
41 | CFiledata fd(anno()); | ||
42 | return m_anno+fd.length(); | ||
43 | } | ||
44 | unsigned short filedatalen() | ||
45 | { | ||
46 | CFiledata fd(anno()); | ||
47 | return m_annolen - fd.length(); | ||
48 | } | ||
31 | }; | 49 | }; |
@@ -39,7 +57,6 @@ class BkmkFile | |||
39 | private: | 57 | private: |
40 | Bkmk* read(); | 58 | static Bkmk* read06(FILE*); |
41 | Bkmk* read03(); | 59 | static Bkmk* read05(FILE*); |
42 | CList<Bkmk>* readall03(); | 60 | static Bkmk* read03(FILE*); |
43 | CList<Bkmk>* readall04(); | 61 | CList<Bkmk>* readall00(Bkmk*(*fn)(FILE*)); |
44 | void write(tchar* nm, tchar* an, const unsigned int& pos); | ||
45 | void write(const Bkmk& b); | 62 | void write(const Bkmk& b); |
diff --git a/noncore/apps/opie-reader/BuffDoc.cpp b/noncore/apps/opie-reader/BuffDoc.cpp index d4541ea..1123960 100644 --- a/noncore/apps/opie-reader/BuffDoc.cpp +++ b/noncore/apps/opie-reader/BuffDoc.cpp | |||
@@ -1 +1,3 @@ | |||
1 | #include "name.h" | ||
2 | |||
1 | #include "BuffDoc.h" | 3 | #include "BuffDoc.h" |
@@ -15,4 +17,4 @@ bool BuffDoc::hyperlink(unsigned int n) | |||
15 | { | 17 | { |
16 | bRet = exp->hyperlink(n); | 18 | bRet = exp->hyperlink(n); |
17 | lastsizes[0] = laststartline = exp->locate(); | 19 | lastsizes[0] = laststartline = exp->locate(); |
18 | } | 20 | } |
@@ -32,4 +34,9 @@ void BuffDoc::locate(unsigned int n) | |||
32 | 34 | ||
33 | bool BuffDoc::getline(CDrawBuffer* buff, int w) | 35 | #define NEWLINEBREAK |
36 | #ifdef NEWLINEBREAK | ||
37 | bool BuffDoc::getline(CDrawBuffer* buff, int wth) | ||
34 | { | 38 | { |
39 | bool moreleft = true; | ||
40 | bool margindone = false; | ||
41 | int w = wth-2*BORDER; | ||
35 | tchar ch = 32; | 42 | tchar ch = 32; |
@@ -39,5 +46,104 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
39 | { | 46 | { |
40 | // (*buff)[0] = '\0'; | 47 | buff->empty(); |
41 | buff->empty(); | 48 | buff->setEof(); |
42 | return false; | 49 | return false; |
50 | } | ||
51 | int len = 0; | ||
52 | if (lastword.length() > 0) | ||
53 | { | ||
54 | *buff = lastword; | ||
55 | cs = lastword.laststyle(); | ||
56 | w -= buff->leftMargin() + buff->rightMargin(); | ||
57 | margindone = true; | ||
58 | len = lastword.length(); | ||
59 | } | ||
60 | else buff->empty(); | ||
61 | lastword.empty(); | ||
62 | unsigned int slen = buff->width(len); | ||
63 | lastispara = false; | ||
64 | while (1) | ||
65 | { | ||
66 | lastsizes[len] = exp->locate(); | ||
67 | getch(ch, cs); | ||
68 | if (ch == UEOF) | ||
69 | { | ||
70 | lastword.empty(); | ||
71 | if (len == 0) | ||
72 | { | ||
73 | buff->setEof(); | ||
74 | moreleft = false; | ||
75 | } | ||
76 | laststartline = exp->locate(); | ||
77 | break; | ||
78 | } | ||
79 | if (ch == 10) | ||
80 | { | ||
81 | lastword.empty(); | ||
82 | lastispara = true; | ||
83 | laststartline = exp->locate(); | ||
84 | break; | ||
85 | } | ||
86 | buff->addch(ch, cs); | ||
87 | len++; | ||
88 | if (!margindone) | ||
89 | { | ||
90 | w -= buff->leftMargin() + buff->rightMargin(); | ||
91 | margindone = true; | ||
92 | } | ||
93 | if ((slen = buff->width(len)) > w) | ||
94 | { | ||
95 | if (ch == ' ' || len == 1) | ||
96 | { | ||
97 | lastword.empty(); | ||
98 | laststartline = exp->locate(); | ||
99 | break; | ||
100 | } | ||
101 | else // should do a backward search for spaces, first. | ||
102 | { | ||
103 | for (int i = len-1; i > 0; i--) | ||
104 | { | ||
105 | if ((*buff)[i] == ' ') | ||
106 | { | ||
107 | (*buff)[len] = 0; | ||
108 | lastword.setright(*buff, i+1); | ||
109 | buff->truncate(i); | ||
110 | (*buff)[i] = '\0'; | ||
111 | laststartline = lastsizes[i+1]; | ||
112 | buff->resize(); | ||
113 | for (int j = 0; j < lastword.length(); j++) | ||
114 | { | ||
115 | lastsizes[j] = lastsizes[j+i+1]; | ||
116 | } | ||
117 | return true; | ||
118 | } | ||
119 | } | ||
120 | laststartline = lastsizes[len-1]; | ||
121 | lastword.setright(*buff, len - 1); | ||
122 | buff->truncate(len-1); | ||
123 | buff->addch('-', cs); | ||
124 | for (int j = 0; j < lastword.length(); j++) | ||
125 | { | ||
126 | lastsizes[j] = lastsizes[j+len]; | ||
127 | } | ||
128 | break; | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | (*buff)[len] = '\0'; | ||
133 | buff->resize(); | ||
134 | return moreleft; | ||
135 | } | ||
136 | #else | ||
137 | bool BuffDoc::getline(CDrawBuffer* buff, int wth) | ||
138 | { | ||
139 | bool margindone = false; | ||
140 | int w = wth-2*BORDER; | ||
141 | tchar ch = 32; | ||
142 | CStyle cs; | ||
143 | buff->empty(); | ||
144 | if (exp == NULL) | ||
145 | { | ||
146 | //(*buff)[0] = '\0'; | ||
147 | buff->empty(); | ||
148 | return false; | ||
43 | } | 149 | } |
@@ -48,2 +154,4 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
48 | cs = lastword.laststyle(); | 154 | cs = lastword.laststyle(); |
155 | w -= buff->leftMargin() + buff->rightMargin(); | ||
156 | margindone = true; | ||
49 | } | 157 | } |
@@ -55,14 +163,24 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
55 | { | 163 | { |
56 | for ( ; len > 0; len--) | 164 | for ( ; len > 1; len--) |
57 | { | 165 | { |
58 | if (buff->width(len) < w) break; | 166 | if (buff->width(len) < w) break; |
59 | } | 167 | } |
60 | // lastword = buff->data() + len - 1; | 168 | // lastword = buff->data() + len - 1; |
61 | laststartline = lastsizes[len-1]; | 169 | laststartline = lastsizes[len-1]; |
62 | lastword.setright(*buff, len - 1); | ||
63 | for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1]; | 170 | for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1]; |
64 | // (*buff)[len-1] = '-'; | 171 | // (*buff)[len-1] = '-'; |
65 | buff->truncate(len-1); | 172 | if (len > 2) |
66 | buff->addch('-', cs); | 173 | { |
67 | (*buff)[len] = '\0'; | 174 | lastword.setright(*buff, len - 1); |
175 | buff->truncate(len-1); | ||
176 | buff->addch('-', cs); | ||
177 | (*buff)[len] = '\0'; | ||
178 | } | ||
179 | |||
180 | else | ||
181 | { | ||
182 | lastword.empty(); | ||
183 | (*buff)[len] = '\0'; | ||
184 | } | ||
185 | buff->resize(); | ||
68 | return true; | 186 | return true; |
@@ -79,2 +197,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
79 | laststartline = exp->locate(); | 197 | laststartline = exp->locate(); |
198 | buff->resize(); | ||
80 | return true; | 199 | return true; |
@@ -90,6 +209,6 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
90 | { | 209 | { |
91 | len++; | 210 | len++; |
92 | buff->addch(ch,cs); | 211 | buff->addch(ch,cs); |
93 | allsizes[len] = exp->locate(); | 212 | allsizes[len] = exp->locate(); |
94 | getch(ch, cs); | 213 | getch(ch, cs); |
95 | } | 214 | } |
@@ -99,2 +218,7 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
99 | buff->addch(' ', cs); | 218 | buff->addch(' ', cs); |
219 | if (!margindone) | ||
220 | { | ||
221 | w -= buff->leftMargin() + buff->rightMargin(); | ||
222 | margindone = true; | ||
223 | } | ||
100 | allsizes[len] = exp->locate(); | 224 | allsizes[len] = exp->locate(); |
@@ -102,4 +226,4 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
102 | { | 226 | { |
103 | lastcheck = len; | 227 | lastcheck = len; |
104 | break; | 228 | break; |
105 | } | 229 | } |
@@ -109,4 +233,12 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
109 | // lastword = buff->data()+lastcheck; | 233 | // lastword = buff->data()+lastcheck; |
110 | lastword.setright(*buff, lastcheck); | 234 | #ifdef WINDOWS |
235 | lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); | ||
236 | { | ||
237 | int i; | ||
238 | for (i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; | ||
239 | } | ||
240 | #else | ||
241 | lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); | ||
111 | for (int i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; | 242 | for (int i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; |
243 | #endif | ||
112 | if (lastcheck > 0) | 244 | if (lastcheck > 0) |
@@ -124,7 +256,15 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
124 | // buff->frig(); | 256 | // buff->frig(); |
125 | return (ch != UEOF); | 257 | buff->resize(); |
258 | if (ch == UEOF && buff->length() == 0) | ||
259 | { | ||
260 | buff->setEof(); | ||
261 | return false; | ||
262 | } | ||
263 | return true; | ||
126 | } | 264 | } |
265 | #endif | ||
127 | 266 | ||
128 | bool BuffDoc::getline(CDrawBuffer* buff, int w, int cw) | 267 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw) |
129 | { | 268 | { |
269 | int w = wth-2*BORDER; | ||
130 | buff->empty(); | 270 | buff->empty(); |
@@ -132,3 +272,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w, int cw) | |||
132 | { | 272 | { |
133 | return false; | 273 | return false; |
134 | } | 274 | } |
@@ -139,6 +279,6 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w, int cw) | |||
139 | { | 279 | { |
140 | getch(ch, cs); | 280 | getch(ch, cs); |
141 | if (ch == '\12' || ch == UEOF) break; | 281 | if (ch == '\12' || ch == UEOF) break; |
142 | buff->addch(ch,cs); | 282 | buff->addch(ch,cs); |
143 | i++; | 283 | i++; |
144 | } | 284 | } |
@@ -146,2 +286,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w, int cw) | |||
146 | laststartline = exp->locate(); | 286 | laststartline = exp->locate(); |
287 | buff->resize(); | ||
147 | return (ch != UEOF); | 288 | return (ch != UEOF); |
@@ -166,5 +307,5 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) | |||
166 | { | 307 | { |
167 | delete exp; | 308 | delete exp; |
168 | exp = NULL; | 309 | exp = NULL; |
169 | return ret; | 310 | return ret; |
170 | } | 311 | } |
@@ -173,5 +314,5 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) | |||
173 | 314 | ||
174 | delete exp; | 315 | delete exp; |
175 | exp = new ztxt; | 316 | exp = new ztxt; |
176 | ret = exp->openfile(src); | 317 | ret = exp->openfile(src); |
177 | } | 318 | } |
@@ -180,35 +321,26 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) | |||
180 | 321 | ||
181 | delete exp; | 322 | delete exp; |
182 | exp = new CPlucker; | 323 | exp = new CPlucker; |
183 | ret = exp->openfile(src); | 324 | ret = exp->openfile(src); |
184 | } | 325 | } |
185 | #ifndef SMALL | ||
186 | if (ret != 0) | 326 | if (ret != 0) |
187 | { | 327 | { |
188 | delete exp; | 328 | delete exp; |
189 | qDebug("Trying ppms"); | 329 | qDebug("Trying ppms"); |
190 | exp = new ppm_expander; | 330 | exp = new ppm_expander; |
191 | ret = exp->openfile(src); | 331 | ret = exp->openfile(src); |
192 | } | 332 | } |
193 | |||
194 | if (ret != 0) | 333 | if (ret != 0) |
195 | { | 334 | { |
196 | delete exp; | 335 | delete exp; |
197 | exp = new Text; | 336 | exp = new Text; |
198 | // qDebug("Trying text"); | 337 | // qDebug("Trying text"); |
199 | ret = exp->openfile(src); | 338 | ret = exp->openfile(src); |
200 | } | 339 | } |
201 | #else | 340 | |
202 | if (ret != 0) | ||
203 | { | ||
204 | delete exp; | ||
205 | exp = new Text; | ||
206 | ret = exp->openfile(src); | ||
207 | } | ||
208 | #endif | ||
209 | if (ret != 0) | 341 | if (ret != 0) |
210 | { | 342 | { |
211 | delete exp; | 343 | delete exp; |
212 | QMessageBox::information(_parent, "OpieReader", "Unknown file compression type","Try another file"); | 344 | QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file"); |
213 | return ret; | 345 | return ret; |
214 | } | 346 | } |
diff --git a/noncore/apps/opie-reader/BuffDoc.h b/noncore/apps/opie-reader/BuffDoc.h index 1aac817..78d8457 100644 --- a/noncore/apps/opie-reader/BuffDoc.h +++ b/noncore/apps/opie-reader/BuffDoc.h | |||
@@ -21,2 +21,23 @@ class BuffDoc | |||
21 | public: | 21 | public: |
22 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | ||
23 | { | ||
24 | if (exp == NULL) | ||
25 | { | ||
26 | data = NULL; | ||
27 | len = 0; | ||
28 | } | ||
29 | else | ||
30 | { | ||
31 | exp->setSaveData(data, len, src, srclen); | ||
32 | } | ||
33 | } | ||
34 | void putSaveData(unsigned char*& src, unsigned short& srclen) | ||
35 | { | ||
36 | if (exp != NULL) | ||
37 | { | ||
38 | exp->putSaveData(src, srclen); | ||
39 | } | ||
40 | } | ||
41 | void suspend() { if (exp != NULL) exp->suspend(); } | ||
42 | void unsuspend() { if (exp != NULL) exp->unsuspend(); } | ||
22 | ~BuffDoc() | 43 | ~BuffDoc() |
@@ -63,6 +84,11 @@ class BuffDoc | |||
63 | } | 84 | } |
85 | QPixmap* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); } | ||
86 | unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); } | ||
87 | unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); } | ||
64 | unsigned int locate() { return (exp == NULL) ? 0 : laststartline; } | 88 | unsigned int locate() { return (exp == NULL) ? 0 : laststartline; } |
65 | unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); } | 89 | unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); } |
90 | void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); } | ||
66 | MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); } | 91 | MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); } |
67 | bool hyperlink(unsigned int n); | 92 | bool hyperlink(unsigned int n); |
93 | size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); } | ||
68 | void locate(unsigned int n); | 94 | void locate(unsigned int n); |
@@ -81,2 +107,6 @@ class BuffDoc | |||
81 | } | 107 | } |
108 | void saveposn(size_t posn) { exp->saveposn(posn); } | ||
109 | bool forward(size_t& loc) { return exp->forward(loc); } | ||
110 | bool back(size_t& loc) { return exp->back(loc); } | ||
111 | bool hasnavigation() { return exp->hasnavigation(); } | ||
82 | }; | 112 | }; |
diff --git a/noncore/apps/opie-reader/CBuffer.cpp b/noncore/apps/opie-reader/CBuffer.cpp index 0780a88..526b25f 100644 --- a/noncore/apps/opie-reader/CBuffer.cpp +++ b/noncore/apps/opie-reader/CBuffer.cpp | |||
@@ -13,3 +13,3 @@ CBufferBase& CBufferBase::assign(const void* sztmp, size_t ms) | |||
13 | 13 | ||
14 | CBufferBase::CBufferBase(size_t ms, size_t n) : len(n), membersize(ms) | 14 | CBufferBase::CBufferBase(size_t ms, size_t n = 16) : len(n), membersize(ms) |
15 | { | 15 | { |
@@ -33,3 +33,3 @@ void* CBufferBase::operator[](int i) | |||
33 | 33 | ||
34 | size_t CBufferBase::bstrlen(unsigned char* _buffer) | 34 | size_t CBufferBase::bstrlen(unsigned char* _buffer = NULL) |
35 | { | 35 | { |
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp index 892456f..ca220e6 100644 --- a/noncore/apps/opie-reader/CDrawBuffer.cpp +++ b/noncore/apps/opie-reader/CDrawBuffer.cpp | |||
@@ -1,2 +1 @@ | |||
1 | |||
2 | #include "CDrawBuffer.h" | #include "CDrawBuffer.h" | |
@@ -5,2 +4,9 @@ | |||
5 | #include <qpainter.h> | 4 | #include <qpainter.h> |
5 | #include <qpixmap.h> | ||
6 | #include "opie.h" | ||
7 | |||
8 | CDrawBuffer::~CDrawBuffer() | ||
9 | { | ||
10 | while (!segs.isEmpty()) segs.erase(0); | ||
11 | } | ||
6 | 12 | ||
@@ -9,9 +15,9 @@ void CDrawBuffer::setright(CDrawBuffer& rhs, int f) | |||
9 | int i; | 15 | int i; |
10 | // qDebug("Trying 1:%d:%s", f, (const char*)toQString(rhs.data())); | ||
11 | len = rhs.len; | 16 | len = rhs.len; |
12 | m_maxstyle = rhs.m_maxstyle; | 17 | fc = rhs.fc; |
13 | m_ascent = rhs.m_ascent; | 18 | m_maxstyle = m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
14 | m_descent = rhs.m_descent; | 19 | while (!segs.isEmpty()) |
15 | m_lineSpacing = rhs.m_lineSpacing; | 20 | { |
16 | while (!segs.isEmpty()) segs.erase(0); | 21 | segs.erase(0); |
22 | } | ||
17 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); ) | 23 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); ) |
@@ -24,2 +30,5 @@ void CDrawBuffer::setright(CDrawBuffer& rhs, int f) | |||
24 | if (st < 0) st = 0; | 30 | if (st < 0) st = 0; |
31 | |||
32 | CStyle _style = next->style; | ||
33 | |||
25 | segs.push_back(textsegment(st,next->style)); | 34 | segs.push_back(textsegment(st,next->style)); |
@@ -30,3 +39,2 @@ void CDrawBuffer::setright(CDrawBuffer& rhs, int f) | |||
30 | len = i; | 39 | len = i; |
31 | // qDebug("Tried 1"); | ||
32 | } | 40 | } |
@@ -42,3 +50,7 @@ CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) | |||
42 | m_lineSpacing = rhs.m_lineSpacing; | 50 | m_lineSpacing = rhs.m_lineSpacing; |
43 | while (!segs.isEmpty()) segs.erase(0); | 51 | m_lineExtraSpacing = rhs.m_lineExtraSpacing; |
52 | while (!segs.isEmpty()) | ||
53 | { | ||
54 | segs.erase(0); | ||
55 | } | ||
44 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) | 56 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) |
@@ -57,3 +69,6 @@ CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) | |||
57 | int i; | 69 | int i; |
58 | while (!segs.isEmpty()) segs.erase(0); | 70 | while (!segs.isEmpty()) |
71 | { | ||
72 | segs.erase(0); | ||
73 | } | ||
59 | segs.push_back(textsegment(0, CStyle())); | 74 | segs.push_back(textsegment(0, CStyle())); |
@@ -69,5 +84,9 @@ void CDrawBuffer::empty() | |||
69 | (*this)[0] = 0; | 84 | (*this)[0] = 0; |
70 | while (!segs.isEmpty()) segs.erase(0); | 85 | while (!segs.isEmpty()) |
86 | { | ||
87 | segs.erase(0); | ||
88 | } | ||
71 | segs.push_back(textsegment(0,CStyle())); | 89 | segs.push_back(textsegment(0,CStyle())); |
72 | m_maxstyle = m_ascent = m_descent = m_lineSpacing = 0; | 90 | m_maxstyle = m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
91 | m_bEof = false; | ||
73 | } | 92 | } |
@@ -78,7 +97,2 @@ void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) | |||
78 | { | 97 | { |
79 | int thissize = fc->getsize(_style); | ||
80 | m_maxstyle = thissize; | ||
81 | m_ascent = fc->ascent(_style); | ||
82 | m_descent = fc->descent(_style); | ||
83 | m_lineSpacing = fc->lineSpacing(_style); | ||
84 | segs.first().start = 0; | 98 | segs.first().start = 0; |
@@ -88,10 +102,2 @@ void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) | |||
88 | { | 102 | { |
89 | int thissize = fc->getsize(_style); | ||
90 | if (thissize > m_maxstyle) | ||
91 | { | ||
92 | m_maxstyle = thissize; | ||
93 | m_ascent = fc->ascent(_style); | ||
94 | m_descent = fc->descent(_style); | ||
95 | m_lineSpacing = fc->lineSpacing(_style); | ||
96 | } | ||
97 | segs.push_back(textsegment(len, _style)); | 103 | segs.push_back(textsegment(len, _style)); |
@@ -122,6 +128,22 @@ int CDrawBuffer::width(int numchars) | |||
122 | CStyle currentstyle = textstart->style; | 128 | CStyle currentstyle = textstart->style; |
123 | QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 129 | if (currentstyle.isPicture()) |
124 | QString str = text.mid(textstart->start, end-textstart->start); | 130 | { |
125 | QFontMetrics fm(f); | 131 | currentx += currentstyle.getPicture()->width(); |
126 | currentx += fm.width(str); | 132 | } |
133 | else | ||
134 | { | ||
135 | if (currentstyle.isMono() && !fc->hasCourier()) | ||
136 | { | ||
137 | int cw = (7*fc->getsize(currentstyle))/10; | ||
138 | currentx += cw*(end-textstart->start); | ||
139 | } | ||
140 | else | ||
141 | { | ||
142 | QFont f(currentstyle.isMono() ? QString("courier") : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | ||
143 | // f.setUnderline(currentstyle.isUnderline()); | ||
144 | QString str = text.mid(textstart->start, end-textstart->start); | ||
145 | QFontMetrics fm(f); | ||
146 | currentx += fm.width(str); | ||
147 | } | ||
148 | } | ||
127 | textstart = textend; | 149 | textstart = textend; |
@@ -132,7 +154,44 @@ int CDrawBuffer::width(int numchars) | |||
132 | 154 | ||
155 | int CDrawBuffer::leftMargin() | ||
156 | { | ||
157 | return (segs.begin()->style.getLeftMargin()*fc->getsize(segs.begin()->style))/6; | ||
158 | } | ||
159 | |||
160 | int CDrawBuffer::rightMargin() | ||
161 | { | ||
162 | return (segs.begin()->style.getRightMargin()*fc->getsize(segs.begin()->style))/6; | ||
163 | } | ||
164 | |||
165 | int CDrawBuffer::offset(int scwidth) | ||
166 | { | ||
167 | int currentx = BORDER; | ||
168 | switch(segs.begin()->style.getJustify()) | ||
169 | { | ||
170 | case m_AlignRight: | ||
171 | { | ||
172 | currentx = scwidth - BORDER - rightMargin() - width(); | ||
173 | } | ||
174 | break; | ||
175 | case m_AlignCentre: | ||
176 | { | ||
177 | currentx = ( | ||
178 | scwidth + | ||
179 | leftMargin() - rightMargin() | ||
180 | - width())/2; | ||
181 | } | ||
182 | break; | ||
183 | case m_AlignJustify: | ||
184 | case m_AlignLeft: | ||
185 | currentx = BORDER + leftMargin(); | ||
186 | break; | ||
187 | } | ||
188 | return currentx; | ||
189 | } | ||
190 | |||
133 | void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth) | 191 | void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth) |
134 | { | 192 | { |
135 | int currentx = 0; | 193 | int currentx = offset(scwidth); |
136 | QString text = toQString(data()); | 194 | QString text = toQString(data()); |
137 | CList<textsegment>::iterator textstart = segs.begin(); | 195 | CList<textsegment>::iterator textstart = segs.begin(); |
196 | /* | ||
138 | StyleType align = textstart->style.getJustify(); | 197 | StyleType align = textstart->style.getJustify(); |
@@ -142,4 +201,3 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int | |||
142 | { | 201 | { |
143 | // int linelength = width(); | 202 | currentx = scwidth - width() - 2*BORDER; |
144 | currentx = scwidth - width(); | ||
145 | } | 203 | } |
@@ -148,4 +206,3 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int | |||
148 | { | 206 | { |
149 | // int linelength = width(); | 207 | currentx = (scwidth - width())/2 - BORDER; |
150 | currentx = (scwidth - width())/2; | ||
151 | } | 208 | } |
@@ -156,2 +213,3 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int | |||
156 | } | 213 | } |
214 | */ | ||
157 | CList<textsegment>::iterator textend = textstart; | 215 | CList<textsegment>::iterator textend = textstart; |
@@ -162,8 +220,23 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int | |||
162 | CStyle currentstyle = textstart->style; | 220 | CStyle currentstyle = textstart->style; |
163 | QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 221 | QFont f((currentstyle.isMono() && fc->hasCourier()) ? QString("courier") : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
222 | //f.setUnderline(currentstyle.isUnderline()); | ||
223 | //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); | ||
164 | _p->setFont(f); | 224 | _p->setFont(f); |
165 | QString str = text.mid(textstart->start, end-textstart->start); | 225 | QString str = text.mid(textstart->start, end-textstart->start); |
166 | _p->setPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue())); | 226 | #ifdef OPIE |
227 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100)); | ||
228 | #else | ||
229 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); | ||
230 | #endif | ||
167 | if (_bMono) | 231 | if (_bMono) |
168 | { | 232 | { |
233 | if (currentstyle.isUnderline()) | ||
234 | { | ||
235 | _p->drawLine( currentx, _y, currentx + str.length()*_charWidth, _y); | ||
236 | } | ||
237 | if (currentstyle.isStrikethru()) | ||
238 | { | ||
239 | int ascent = fc->ascent(currentstyle)/3; | ||
240 | _p->drawLine( currentx, _y-ascent, currentx + str.length()*_charWidth, _y-ascent); | ||
241 | } | ||
169 | for (int i = 0; i < str.length(); i++) | 242 | for (int i = 0; i < str.length(); i++) |
@@ -176,5 +249,49 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int | |||
176 | { | 249 | { |
177 | _p->drawText( currentx, _y, str); | 250 | if (currentstyle.isPicture()) |
178 | QFontMetrics fm(f); | 251 | { |
179 | currentx += fm.width(str); | 252 | int ascent = fc->ascent(currentstyle)/2; |
253 | int yoffset = currentstyle.getPicture()->height()/2 + ascent; | ||
254 | _p->drawPixmap( currentx, _y-yoffset, *(currentstyle.getPicture())); | ||
255 | currentx += currentstyle.getPicture()->width(); | ||
256 | } | ||
257 | else | ||
258 | { | ||
259 | if (currentstyle.isMono() && !fc->hasCourier()) | ||
260 | { | ||
261 | int cw = (7*fc->getsize(currentstyle))/10; | ||
262 | int w = cw*(end-textstart->start); | ||
263 | if (currentstyle.isUnderline()) | ||
264 | { | ||
265 | _p->drawLine( currentx, _y, currentx + w, _y); | ||
266 | } | ||
267 | if (currentstyle.isStrikethru()) | ||
268 | { | ||
269 | int ascent = fc->ascent(currentstyle)/3; | ||
270 | _p->drawLine( currentx, _y-ascent, currentx + w, _y-ascent); | ||
271 | } | ||
272 | QString str = text.mid(textstart->start, end-textstart->start); | ||
273 | |||
274 | for (int i = 0; i < str.length(); i++) | ||
275 | { | ||
276 | _p->drawText( currentx, _y, QString(str[i])); | ||
277 | currentx += cw; | ||
278 | } | ||
279 | } | ||
280 | else | ||
281 | { | ||
282 | QFontMetrics fm(f); | ||
283 | int w = fm.width(str); | ||
284 | if (currentstyle.isUnderline()) | ||
285 | { | ||
286 | _p->drawLine( currentx, _y, currentx + w, _y); | ||
287 | } | ||
288 | if (currentstyle.isStrikethru()) | ||
289 | { | ||
290 | int ascent = fc->ascent(currentstyle)/3; | ||
291 | _p->drawLine( currentx, _y-ascent, currentx + w, _y-ascent); | ||
292 | } | ||
293 | _p->drawText( currentx, _y, str); | ||
294 | currentx += w; | ||
295 | } | ||
296 | } | ||
180 | } | 297 | } |
@@ -182,3 +299,3 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int | |||
182 | } | 299 | } |
183 | while (textend != segs.end()); | 300 | while (textend != segs.end() && textstart->start < length()-1); |
184 | } | 301 | } |
@@ -190,3 +307,3 @@ CStyle CDrawBuffer::laststyle() | |||
190 | 307 | ||
191 | bool CDrawBuffer::isLink(int numchars, size_t& tgt) | 308 | linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt) |
192 | { | 309 | { |
@@ -200,12 +317,63 @@ bool CDrawBuffer::isLink(int numchars, size_t& tgt) | |||
200 | end = (textend != segs.end()) ? textend->start : length(); | 317 | end = (textend != segs.end()) ? textend->start : length(); |
201 | if (numchars >= 0 && end > numchars) | ||
202 | { | ||
203 | end = numchars; | ||
204 | } | ||
205 | currentstyle = textstart->style; | 318 | currentstyle = textstart->style; |
319 | /* | ||
320 | if (currentstyle.isPicture()) qDebug("Passed thru picture"); | ||
321 | if (currentstyle.getLink()) qDebug("Passed thru link"); | ||
322 | qDebug("islink:%d - %d", numchars, end); | ||
323 | */ | ||
206 | textstart = textend; | 324 | textstart = textend; |
207 | } | 325 | } |
208 | while (textend != segs.end() && end != numchars); | 326 | while (textend != segs.end() && end <= numchars); |
209 | tgt = currentstyle.getData(); | 327 | // if (currentstyle.isPicture()) qDebug("Clicked on picture"); |
210 | return currentstyle.getLink(); | 328 | if (currentstyle.getPictureLink()) |
329 | { | ||
330 | tgt = currentstyle.getPictureLinkData(); | ||
331 | return ePicture; | ||
332 | } | ||
333 | if (currentstyle.getLink()) | ||
334 | { | ||
335 | tgt = currentstyle.getData(); | ||
336 | return eLink; | ||
337 | } | ||
338 | return eNone; | ||
339 | } | ||
340 | |||
341 | void CDrawBuffer::resize() | ||
342 | { | ||
343 | int i; | ||
344 | m_maxstyle = m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; | ||
345 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= length(); ) | ||
346 | { | ||
347 | CList<textsegment>::iterator next = iter; | ||
348 | iter++; | ||
349 | int st = next->start; | ||
350 | if (st < 0) st = 0; | ||
351 | |||
352 | CStyle _style = next->style; | ||
353 | |||
354 | int linespacing, ascent, descent, extra; | ||
355 | |||
356 | ascent = fc->ascent(_style); | ||
357 | descent = fc->descent(_style); | ||
358 | linespacing = fc->lineSpacing(_style); | ||
359 | extra = linespacing - ascent - descent; | ||
360 | if (_style.isPicture()) | ||
361 | { | ||
362 | descent = (_style.getPicture()->height()-ascent)/2; | ||
363 | ascent = (_style.getPicture()->height()+ascent)/2; | ||
364 | } | ||
365 | /* | ||
366 | else if (fc != NULL) | ||
367 | { | ||
368 | ascent = fc->ascent(_style); | ||
369 | descent = fc->descent(_style); | ||
370 | linespacing = fc->lineSpacing(_style); | ||
371 | extra = linespacing - ascent - descent; | ||
372 | } | ||
373 | */ | ||
374 | if (ascent > m_ascent) m_ascent = ascent; | ||
375 | if (descent > m_descent) m_descent = descent; | ||
376 | if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; | ||
377 | m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; | ||
378 | } | ||
211 | } | 379 | } |
diff --git a/noncore/apps/opie-reader/CDrawBuffer.h b/noncore/apps/opie-reader/CDrawBuffer.h index 4d3696e..0d8968c 100644 --- a/noncore/apps/opie-reader/CDrawBuffer.h +++ b/noncore/apps/opie-reader/CDrawBuffer.h | |||
@@ -9,2 +9,9 @@ class QPainter; | |||
9 | 9 | ||
10 | enum linkType | ||
11 | { | ||
12 | eNone, | ||
13 | eLink, | ||
14 | ePicture | ||
15 | }; | ||
16 | |||
10 | struct textsegment | 17 | struct textsegment |
@@ -13,3 +20,3 @@ struct textsegment | |||
13 | CStyle style; | 20 | CStyle style; |
14 | textsegment(int _start, CStyle _style) | 21 | textsegment(int _start, const CStyle& _style) |
15 | : | 22 | : |
@@ -26,4 +33,12 @@ class CDrawBuffer : public CBuffer | |||
26 | FontControl* fc; | 33 | FontControl* fc; |
27 | int m_maxstyle, m_ascent, m_descent, m_lineSpacing; | 34 | int m_maxstyle, m_ascent, m_descent, m_lineSpacing, m_lineExtraSpacing; |
35 | bool m_bEof; | ||
36 | CDrawBuffer(const CDrawBuffer&); | ||
37 | CDrawBuffer& operator=(const tchar*sztmp); | ||
28 | public: | 38 | public: |
39 | int leftMargin(); | ||
40 | int rightMargin(); | ||
41 | void setEof() { m_bEof = true; } | ||
42 | bool eof() { return m_bEof; } | ||
43 | CDrawBuffer& operator=(CDrawBuffer&); | ||
29 | CDrawBuffer(FontControl* _fs = NULL) | 44 | CDrawBuffer(FontControl* _fs = NULL) |
@@ -34,2 +49,3 @@ class CDrawBuffer : public CBuffer | |||
34 | } | 49 | } |
50 | ~CDrawBuffer(); | ||
35 | /* | 51 | /* |
@@ -43,5 +59,4 @@ class CDrawBuffer : public CBuffer | |||
43 | int width(int numchars = -1); | 59 | int width(int numchars = -1); |
60 | int offset(int); | ||
44 | void render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scw); | 61 | void render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scw); |
45 | CDrawBuffer& operator=(const tchar*sztmp); | ||
46 | CDrawBuffer& operator=(CDrawBuffer&); | ||
47 | void empty(); | 62 | void empty(); |
@@ -54,5 +69,7 @@ class CDrawBuffer : public CBuffer | |||
54 | int lineSpacing() { return m_lineSpacing; } | 69 | int lineSpacing() { return m_lineSpacing; } |
70 | int lineExtraSpacing() { return m_lineExtraSpacing; } | ||
55 | 71 | ||
56 | // void frig(); | 72 | // void frig(); |
57 | bool isLink(int numchars, size_t& tgt); | 73 | linkType getLinkType(int numchars, size_t& tgt); |
74 | void resize(); | ||
58 | }; | 75 | }; |
diff --git a/noncore/apps/opie-reader/CExpander.h b/noncore/apps/opie-reader/CExpander.h index b1147a6..c281398 100644 --- a/noncore/apps/opie-reader/CExpander.h +++ b/noncore/apps/opie-reader/CExpander.h | |||
@@ -3,2 +3,6 @@ | |||
3 | 3 | ||
4 | #include <unistd.h> | ||
5 | #include <stdio.h> | ||
6 | #include <time.h> | ||
7 | #include <qmessagebox.h> | ||
4 | #include "config.h" | 8 | #include "config.h" |
@@ -6,3 +10,5 @@ | |||
6 | #include "Markups.h" | 10 | #include "Markups.h" |
11 | #include "name.h" | ||
7 | 12 | ||
13 | class QPixmap; | ||
8 | class Bkmk; | 14 | class Bkmk; |
@@ -20,6 +26,22 @@ class CExpander | |||
20 | { | 26 | { |
27 | protected: | ||
28 | size_t m_homepos; | ||
29 | bool m_continuous; | ||
30 | char* fname; | ||
31 | bool bSuspended; | ||
32 | size_t suspos; | ||
33 | time_t sustime; | ||
21 | public: | 34 | public: |
22 | CExpander() {}; | 35 | virtual void suspend() = 0; |
23 | virtual ~CExpander() {}; | 36 | virtual void unsuspend() = 0; |
24 | virtual int openfile(const char *src) = 0; | 37 | size_t getHome() { return m_homepos; } |
38 | CExpander() : m_homepos(0), fname(NULL) {}; | ||
39 | virtual ~CExpander() { if (fname != NULL) delete [] fname; }; | ||
40 | int openfile(const char *src) | ||
41 | { | ||
42 | bSuspended = false; | ||
43 | fname = strdup(src); | ||
44 | return OpenFile(src); | ||
45 | } | ||
46 | virtual int OpenFile(const char *src) = 0; | ||
25 | virtual unsigned int locate() = 0; | 47 | virtual unsigned int locate() = 0; |
@@ -41,2 +63,61 @@ class CExpander | |||
41 | virtual MarkupType PreferredMarkup() = 0; | 63 | virtual MarkupType PreferredMarkup() = 0; |
64 | virtual void saveposn(size_t posn) {} | ||
65 | virtual bool forward(size_t& loc) {} | ||
66 | virtual bool back(size_t& loc) {} | ||
67 | virtual bool hasnavigation() { return false; } | ||
68 | virtual unsigned long startSection() | ||
69 | { | ||
70 | return 0; | ||
71 | } | ||
72 | virtual unsigned long endSection() | ||
73 | { | ||
74 | unsigned long file, text; | ||
75 | sizes(file, text); | ||
76 | return text; | ||
77 | } | ||
78 | virtual QPixmap* getPicture(unsigned long tgt) { return NULL; } | ||
79 | void setContinuous(bool _b) { m_continuous = _b; } | ||
80 | |||
81 | virtual void suspend(FILE*& fin) | ||
82 | { | ||
83 | bSuspended = true; | ||
84 | suspos = ftell(fin); | ||
85 | fclose(fin); | ||
86 | fin = NULL; | ||
87 | sustime = time(NULL); | ||
88 | } | ||
89 | virtual void unsuspend(FILE*& fin) | ||
90 | { | ||
91 | if (bSuspended) | ||
92 | { | ||
93 | bSuspended = false; | ||
94 | int delay = time(NULL) - sustime; | ||
95 | if (delay < 10) sleep(10-delay); | ||
96 | fin = fopen(fname, "rb"); | ||
97 | for (int i = 0; fin == NULL && i < 5; i++) | ||
98 | { | ||
99 | sleep(5); | ||
100 | fin = fopen(fname, "rb"); | ||
101 | } | ||
102 | if (fin == NULL) | ||
103 | { | ||
104 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); | ||
105 | exit(0); | ||
106 | } | ||
107 | suspos = fseek(fin, suspos, SEEK_SET); | ||
108 | } | ||
109 | } | ||
110 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | ||
111 | { | ||
112 | len = srclen; | ||
113 | data = new unsigned char[len]; | ||
114 | memcpy(data, src, len); | ||
115 | } | ||
116 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen) | ||
117 | { | ||
118 | if (srclen != 0) | ||
119 | { | ||
120 | qDebug("Don't know what to do with non-zero save data"); | ||
121 | } | ||
122 | } | ||
42 | }; | 123 | }; |
diff --git a/noncore/apps/opie-reader/CFilter.cpp b/noncore/apps/opie-reader/CFilter.cpp index c17cf61..d5e3116 100644 --- a/noncore/apps/opie-reader/CFilter.cpp +++ b/noncore/apps/opie-reader/CFilter.cpp | |||
@@ -534,3 +534,3 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
534 | case 'c': | 534 | case 'c': |
535 | if (currentstyle.getJustify() == CStyle::m_AlignCentre) | 535 | if (currentstyle.getJustify() == m_AlignCentre) |
536 | { | 536 | { |
@@ -545,3 +545,3 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
545 | case 'r': | 545 | case 'r': |
546 | if (currentstyle.getJustify() == CStyle::m_AlignRight) | 546 | if (currentstyle.getJustify() == m_AlignRight) |
547 | { | 547 | { |
@@ -561 +561,124 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
561 | } | 561 | } |
562 | |||
563 | void OnePara::getch(tchar& ch, CStyle& sty) | ||
564 | { | ||
565 | parent->getch(ch, sty); | ||
566 | if (m_lastchar == 10) | ||
567 | { | ||
568 | while (ch == 10) parent->getch(ch, sty); | ||
569 | } | ||
570 | m_lastchar = ch; | ||
571 | } | ||
572 | |||
573 | #ifdef REPALM | ||
574 | void repalm::getch(tchar& ch, CStyle& sty) | ||
575 | { | ||
576 | parent->getch(ch, sty); | ||
577 | switch (ch) | ||
578 | { | ||
579 | case 0x80: | ||
580 | ch = 0x20ac; | ||
581 | break; | ||
582 | case 0x82: | ||
583 | ch = 0x201a; | ||
584 | break; | ||
585 | case 0x83: | ||
586 | ch = 0x0192; | ||
587 | break; | ||
588 | case 0x84: | ||
589 | ch = 0x201e; | ||
590 | break; | ||
591 | case 0x85: | ||
592 | ch = 0x2026; | ||
593 | break; | ||
594 | case 0x86: | ||
595 | ch = 0x2020; | ||
596 | break; | ||
597 | case 0x87: | ||
598 | ch = 0x2021; | ||
599 | break; | ||
600 | case 0x88: | ||
601 | ch = 0x02c6; | ||
602 | break; | ||
603 | case 0x89: | ||
604 | ch = 0x2030; | ||
605 | break; | ||
606 | case 0x8a: | ||
607 | ch = 0x0160; | ||
608 | break; | ||
609 | case 0x8b: | ||
610 | ch = 0x2039; | ||
611 | break; | ||
612 | case 0x8c: | ||
613 | ch = 0x0152; | ||
614 | break; | ||
615 | /* | ||
616 | case 0x8e: | ||
617 | ch = 0x017d; | ||
618 | break; | ||
619 | */ | ||
620 | case 0x91: | ||
621 | ch = 0x2018; | ||
622 | break; | ||
623 | case 0x92: | ||
624 | ch = 0x2019; | ||
625 | break; | ||
626 | case 0x93: | ||
627 | ch = 0x201c; | ||
628 | break; | ||
629 | case 0x94: | ||
630 | ch = 0x201d; | ||
631 | break; | ||
632 | case 0x95: | ||
633 | ch = 0x2022; | ||
634 | break; | ||
635 | case 0x96: | ||
636 | ch = 0x2013; | ||
637 | break; | ||
638 | case 0x97: | ||
639 | ch = 0x2014; | ||
640 | break; | ||
641 | case 0x98: | ||
642 | ch = 0x02dc; | ||
643 | break; | ||
644 | case 0x99: | ||
645 | ch = 0x2122; | ||
646 | break; | ||
647 | case 0x9a: | ||
648 | ch = 0x0161; | ||
649 | break; | ||
650 | case 0x9b: | ||
651 | ch = 0x203a; | ||
652 | break; | ||
653 | case 0x9c: | ||
654 | ch = 0x0153; | ||
655 | break; | ||
656 | case 0x9e: | ||
657 | ch = 0x017e; | ||
658 | break; | ||
659 | case 0x9f: | ||
660 | ch = 0x0178; | ||
661 | break; | ||
662 | case 0x18: | ||
663 | ch = 0x2026; | ||
664 | break; | ||
665 | case 0x19: | ||
666 | ch = 0x2007; | ||
667 | break; | ||
668 | case 0x8d: | ||
669 | ch = 0x2662; | ||
670 | break; | ||
671 | case 0x8e: | ||
672 | ch = 0x2663; | ||
673 | break; | ||
674 | case 0x8f: | ||
675 | ch = 0x2661; | ||
676 | break; | ||
677 | case 0x90: | ||
678 | ch = 0x2660; | ||
679 | break; | ||
680 | default: | ||
681 | break; | ||
682 | } | ||
683 | } | ||
684 | #endif | ||
diff --git a/noncore/apps/opie-reader/CFilter.h b/noncore/apps/opie-reader/CFilter.h index 8cfd7eb..2d0c30f 100644 --- a/noncore/apps/opie-reader/CFilter.h +++ b/noncore/apps/opie-reader/CFilter.h | |||
@@ -268,2 +268,20 @@ class PeanutFormatter : public CFilter | |||
268 | }; | 268 | }; |
269 | |||
270 | class OnePara : public CFilter | ||
271 | { | ||
272 | tchar m_lastchar; | ||
273 | public: | ||
274 | OnePara() : m_lastchar(0) {} | ||
275 | virtual ~OnePara() {} | ||
276 | virtual void getch(tchar& ch, CStyle& sty); | ||
277 | }; | ||
278 | |||
279 | #ifdef REPALM | ||
280 | class repalm : public CFilter | ||
281 | { | ||
282 | public: | ||
283 | virtual ~repalm() {} | ||
284 | virtual void getch(tchar& ch, CStyle& sty); | ||
285 | }; | ||
286 | #endif | ||
269 | #endif | 287 | #endif |
diff --git a/noncore/apps/opie-reader/Filedata.h b/noncore/apps/opie-reader/Filedata.h new file mode 100644 index 0000000..f920238 --- a/dev/null +++ b/noncore/apps/opie-reader/Filedata.h | |||
@@ -0,0 +1,51 @@ | |||
1 | #ifndef __FILEDATA_H | ||
2 | #define __FILEDATA_H | ||
3 | |||
4 | #include <time.h> | ||
5 | |||
6 | class CFiledata | ||
7 | { | ||
8 | unsigned char* data; | ||
9 | bool m_own; | ||
10 | public: | ||
11 | CFiledata(tchar* d) | ||
12 | { | ||
13 | data = (unsigned char*)d; | ||
14 | m_own = false; | ||
15 | } | ||
16 | CFiledata(time_t dt, tchar* nm) | ||
17 | { | ||
18 | int nlen = ustrlen(nm)+1; | ||
19 | data = new unsigned char[sizeof(time_t)+sizeof(tchar)*nlen]; | ||
20 | *((time_t *)data) = dt; | ||
21 | memcpy(data+sizeof(time_t), nm, sizeof(tchar)*nlen); | ||
22 | m_own = true; | ||
23 | } | ||
24 | ~CFiledata() | ||
25 | { | ||
26 | if (m_own && data != NULL) | ||
27 | { | ||
28 | delete [] data; | ||
29 | qDebug("~Filedata: deleting"); | ||
30 | } | ||
31 | else | ||
32 | { | ||
33 | qDebug("~Filedata: not deleting"); | ||
34 | } | ||
35 | } | ||
36 | tchar* name() const { return (tchar*)(data+sizeof(time_t)); } | ||
37 | time_t date() { return *((time_t *)data); } | ||
38 | void setdate(time_t _t) { *((time_t *)data) = _t; } | ||
39 | unsigned char* content() { return data; } | ||
40 | size_t length() const { return sizeof(time_t)+sizeof(tchar)*(ustrlen(name())+1); } | ||
41 | bool operator==(const CFiledata& rhs) | ||
42 | { | ||
43 | return ((length() == rhs.length()) && (memcmp(data, rhs.data, length()) == 0)); | ||
44 | } | ||
45 | bool samename(const CFiledata& rhs) | ||
46 | { | ||
47 | return (ustrcmp((tchar *)(data+sizeof(time_t)),(tchar *)(rhs.data+sizeof(time_t))) == 0); | ||
48 | } | ||
49 | }; | ||
50 | |||
51 | #endif | ||
diff --git a/noncore/apps/opie-reader/FontControl.cpp b/noncore/apps/opie-reader/FontControl.cpp new file mode 100644 index 0000000..f0ed98b --- a/dev/null +++ b/noncore/apps/opie-reader/FontControl.cpp | |||
@@ -0,0 +1,37 @@ | |||
1 | #include "opie.h" | ||
2 | #include "FontControl.h" | ||
3 | |||
4 | bool FontControl::ChangeFont(QString& n, int tgt) | ||
5 | { | ||
6 | QValueList<int>::Iterator it; | ||
7 | QFontDatabase fdb; | ||
8 | QValueList<int> sizes = fdb.pointSizes(n); | ||
9 | if (sizes.count() == 0) | ||
10 | { | ||
11 | return false; | ||
12 | } | ||
13 | else | ||
14 | { | ||
15 | m_fontname = n; | ||
16 | m_maxsize = sizes.count(); | ||
17 | if (m_fontsizes != NULL) delete [] m_fontsizes; | ||
18 | m_fontsizes = new int[m_maxsize]; | ||
19 | uint i = 0; | ||
20 | uint best = 0; | ||
21 | for (it = sizes.begin(); it != sizes.end(); it++) | ||
22 | { | ||
23 | #ifdef OPIE | ||
24 | m_fontsizes[i] = (*it); | ||
25 | #else | ||
26 | m_fontsizes[i] = (*it)/10; | ||
27 | #endif | ||
28 | if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) | ||
29 | { | ||
30 | best = i; | ||
31 | } | ||
32 | i++; | ||
33 | } | ||
34 | m_size = best; | ||
35 | } | ||
36 | return true; | ||
37 | } | ||
diff --git a/noncore/apps/opie-reader/FontControl.h b/noncore/apps/opie-reader/FontControl.h index d427680..02049d0 100644 --- a/noncore/apps/opie-reader/FontControl.h +++ b/noncore/apps/opie-reader/FontControl.h | |||
@@ -13,2 +13,3 @@ class FontControl | |||
13 | int m_maxsize; | 13 | int m_maxsize; |
14 | bool m_hasCourier; | ||
14 | public: | 15 | public: |
@@ -16,3 +17,3 @@ class FontControl | |||
16 | : | 17 | : |
17 | m_fontsizes(NULL) | 18 | m_fontsizes(NULL), m_hasCourier(false) |
18 | { | 19 | { |
@@ -24,2 +25,4 @@ class FontControl | |||
24 | } | 25 | } |
26 | void hasCourier(bool _b) { m_hasCourier = _b; } | ||
27 | bool hasCourier() { return m_hasCourier; } | ||
25 | QString name() { return m_fontname; } | 28 | QString name() { return m_fontname; } |
@@ -28,3 +31,12 @@ class FontControl | |||
28 | { | 31 | { |
29 | return m_fontsizes[m_size+size.getFontSize()]; | 32 | int tgt = m_size+size.getFontSize(); |
33 | if (tgt < 0) | ||
34 | { | ||
35 | tgt = 0; | ||
36 | } | ||
37 | if (tgt >= m_maxsize) | ||
38 | { | ||
39 | tgt = m_maxsize - 1; | ||
40 | } | ||
41 | return m_fontsizes[tgt]; | ||
30 | } | 42 | } |
@@ -88,32 +100,3 @@ class FontControl | |||
88 | } | 100 | } |
89 | bool ChangeFont(QString& n, int tgt) | 101 | bool ChangeFont(QString& n, int tgt); |
90 | { | ||
91 | QValueList<int>::Iterator it; | ||
92 | QFontDatabase fdb; | ||
93 | QValueList<int> sizes = fdb.pointSizes(n); | ||
94 | if (sizes.count() == 0) | ||
95 | { | ||
96 | return false; | ||
97 | } | ||
98 | else | ||
99 | { | ||
100 | m_fontname = n; | ||
101 | m_maxsize = sizes.count(); | ||
102 | if (m_fontsizes != NULL) delete [] m_fontsizes; | ||
103 | m_fontsizes = new int[m_maxsize]; | ||
104 | uint i = 0; | ||
105 | uint best = 0; | ||
106 | for (it = sizes.begin(); it != sizes.end(); it++) | ||
107 | { | ||
108 | m_fontsizes[i] = (*it); | ||
109 | if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) | ||
110 | { | ||
111 | best = i; | ||
112 | } | ||
113 | i++; | ||
114 | } | ||
115 | m_size = best; | ||
116 | } | ||
117 | return true; | ||
118 | } | ||
119 | }; | 102 | }; |
diff --git a/noncore/apps/opie-reader/GraphicWin.h b/noncore/apps/opie-reader/GraphicWin.h new file mode 100644 index 0000000..31811d2 --- a/dev/null +++ b/noncore/apps/opie-reader/GraphicWin.h | |||
@@ -0,0 +1,65 @@ | |||
1 | #ifndef __GRAPHICWIN_H | ||
2 | #define __GRAPHICWIN_H | ||
3 | |||
4 | #include <qscrollview.h> | ||
5 | #include <qpixmap.h> | ||
6 | #include <qpushbutton.h> | ||
7 | #include <qlayout.h> | ||
8 | |||
9 | class GraphicScroll : public QScrollView | ||
10 | { | ||
11 | Q_OBJECT | ||
12 | QWidget* m_picture; | ||
13 | protected: | ||
14 | void hideEvent( QHideEvent * p) | ||
15 | { | ||
16 | m_picture->setFixedSize(1,1); | ||
17 | } | ||
18 | public: | ||
19 | GraphicScroll( QWidget *parent=0, const char *name=0, WFlags f = 0) | ||
20 | : QScrollView(parent, name, f) | ||
21 | { | ||
22 | m_picture = new QWidget(viewport()); | ||
23 | addChild(m_picture); | ||
24 | } | ||
25 | void setPixmap(QPixmap& pm) | ||
26 | { | ||
27 | m_picture->setFixedSize(pm.size()); | ||
28 | m_picture->setBackgroundPixmap(pm); | ||
29 | } | ||
30 | /* | ||
31 | private slots: | ||
32 | void graphicClose() { emit Close(); } | ||
33 | signals: | ||
34 | void Close(); | ||
35 | */ | ||
36 | |||
37 | }; | ||
38 | |||
39 | |||
40 | class GraphicWin : public QWidget | ||
41 | { | ||
42 | Q_OBJECT | ||
43 | |||
44 | GraphicScroll* m_scroll; | ||
45 | signals: | ||
46 | void Closed(); | ||
47 | private slots: | ||
48 | void slotClosed() { emit Closed(); } | ||
49 | |||
50 | public: | ||
51 | |||
52 | void setPixmap(QPixmap& pm) { m_scroll->setPixmap(pm); } | ||
53 | GraphicWin( QWidget *parent=0, const char *name=0, WFlags f = 0) | ||
54 | : QWidget(parent, name, f) | ||
55 | { | ||
56 | QVBoxLayout* grid = new QVBoxLayout(this); | ||
57 | m_scroll = new GraphicScroll(this); | ||
58 | QPushButton* exitButton = new QPushButton("Close", this); | ||
59 | connect(exitButton, SIGNAL( released() ), this, SLOT( slotClosed() ) ); | ||
60 | grid->addWidget(m_scroll,1); | ||
61 | grid->addWidget(exitButton); | ||
62 | } | ||
63 | }; | ||
64 | |||
65 | #endif | ||
diff --git a/noncore/apps/opie-reader/Navigation.cpp b/noncore/apps/opie-reader/Navigation.cpp new file mode 100644 index 0000000..7b392ba --- a/dev/null +++ b/noncore/apps/opie-reader/Navigation.cpp | |||
@@ -0,0 +1,98 @@ | |||
1 | #include "Navigation.h" | ||
2 | |||
3 | void CNavigation::saveposn(size_t posn) | ||
4 | { | ||
5 | // qDebug("Saved:%u [%u,%u,%u]", posn, historystart, historycurrent, historyend); | ||
6 | historycurrent = historyend = (historycurrent+1)%NAVIGATION_HISTORY_SIZE; | ||
7 | history[historycurrent] = posn; | ||
8 | if (historystart == historyend) historystart = (historystart+1)%NAVIGATION_HISTORY_SIZE; | ||
9 | // qDebug("Saved:%u [%u,%u,%u]", posn, historystart, historycurrent, historyend); | ||
10 | } | ||
11 | |||
12 | bool CNavigation::forward(size_t& loc) | ||
13 | { | ||
14 | if (historycurrent != historyend) | ||
15 | { | ||
16 | historycurrent = (historycurrent + 1)%NAVIGATION_HISTORY_SIZE; | ||
17 | loc = history[historycurrent]; | ||
18 | //qDebug("Forward:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend); | ||
19 | return true; | ||
20 | } | ||
21 | else | ||
22 | { | ||
23 | return false; | ||
24 | } | ||
25 | } | ||
26 | |||
27 | bool CNavigation::back(size_t& loc) | ||
28 | { | ||
29 | if (historyend != historystart) | ||
30 | { | ||
31 | //qDebug("Back:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend); | ||
32 | if (historycurrent == historyend && history[historycurrent] != loc) | ||
33 | { | ||
34 | historyend = (historyend+1) % NAVIGATION_HISTORY_SIZE; | ||
35 | history[historyend] = loc; | ||
36 | } | ||
37 | else | ||
38 | { | ||
39 | size_t sv = historycurrent; | ||
40 | historycurrent = (historycurrent + NAVIGATION_HISTORY_SIZE - 1) % NAVIGATION_HISTORY_SIZE; | ||
41 | if (historycurrent == historystart) | ||
42 | { | ||
43 | historycurrent = sv; | ||
44 | return false; | ||
45 | } | ||
46 | } | ||
47 | loc = history[historycurrent]; | ||
48 | //qDebug("Back:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend); | ||
49 | return true; | ||
50 | } | ||
51 | else | ||
52 | { | ||
53 | return false; | ||
54 | } | ||
55 | } | ||
56 | |||
57 | #include <stdio.h> | ||
58 | |||
59 | void CNavigation::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | ||
60 | { | ||
61 | len = srclen+sizeof(size_t)*(3+NAVIGATION_HISTORY_SIZE); | ||
62 | data = new unsigned char[len]; | ||
63 | unsigned char* p = data; | ||
64 | memcpy(p, src, srclen); | ||
65 | p += srclen; | ||
66 | memcpy(p, &historystart, sizeof(size_t)); | ||
67 | p += sizeof(size_t); | ||
68 | memcpy(p, &historyend, sizeof(size_t)); | ||
69 | p += sizeof(size_t); | ||
70 | memcpy(p, &historycurrent, sizeof(size_t)); | ||
71 | p += sizeof(size_t); | ||
72 | memcpy(p, history, sizeof(size_t)*NAVIGATION_HISTORY_SIZE); | ||
73 | printf("<%u,%u,%u>\n", historystart, historyend, historycurrent); | ||
74 | for (int i = historystart; i <= historyend; i++) | ||
75 | printf("<%u> ", history[i]); | ||
76 | printf("\n"); | ||
77 | } | ||
78 | |||
79 | void CNavigation::putSaveData(unsigned char*& src, unsigned short& srclen) | ||
80 | { | ||
81 | if (srclen >= sizeof(size_t)*(3+NAVIGATION_HISTORY_SIZE)) | ||
82 | { | ||
83 | unsigned char* p = src; | ||
84 | memcpy(&historystart, p, sizeof(size_t)); | ||
85 | p += sizeof(size_t); | ||
86 | memcpy(&historyend, p, sizeof(size_t)); | ||
87 | p += sizeof(size_t); | ||
88 | memcpy(&historycurrent, p, sizeof(size_t)); | ||
89 | p += sizeof(size_t); | ||
90 | memcpy(history, p, sizeof(size_t)*NAVIGATION_HISTORY_SIZE); | ||
91 | src = p + sizeof(size_t)*NAVIGATION_HISTORY_SIZE; | ||
92 | srclen -= sizeof(size_t)*(3+NAVIGATION_HISTORY_SIZE); | ||
93 | } | ||
94 | printf("<%u,%u,%u>\n", historystart, historyend, historycurrent); | ||
95 | for (int i = historystart; i <= historyend; i++) | ||
96 | printf("<%u> ", history[i]); | ||
97 | printf("\n"); | ||
98 | } | ||
diff --git a/noncore/apps/opie-reader/Navigation.h b/noncore/apps/opie-reader/Navigation.h new file mode 100644 index 0000000..57fb006 --- a/dev/null +++ b/noncore/apps/opie-reader/Navigation.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #include <stdlib.h> | ||
2 | |||
3 | const size_t NAVIGATION_HISTORY_SIZE = 32; | ||
4 | |||
5 | class CNavigation | ||
6 | { | ||
7 | size_t history[NAVIGATION_HISTORY_SIZE]; | ||
8 | size_t historystart, historyend, historycurrent; | ||
9 | public: | ||
10 | CNavigation() : historystart(0),historyend(0),historycurrent(0) {} | ||
11 | void saveposn(size_t posn); | ||
12 | bool forward(size_t& loc); | ||
13 | bool back(size_t& loc); | ||
14 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen); | ||
15 | void putSaveData(unsigned char*& src, unsigned short& srclen); | ||
16 | }; | ||
diff --git a/noncore/apps/opie-reader/Palm2QImage.cpp b/noncore/apps/opie-reader/Palm2QImage.cpp new file mode 100644 index 0000000..ef88cc5 --- a/dev/null +++ b/noncore/apps/opie-reader/Palm2QImage.cpp | |||
@@ -0,0 +1,290 @@ | |||
1 | /* -*- mode: c; indent-tabs-mode: nil; -*- */ | ||
2 | #include <stdio.h> | ||
3 | #include <stdlib.h> | ||
4 | #include <string.h> | ||
5 | #include <unistd.h> /* for link */ | ||
6 | #include <sys/types.h> | ||
7 | #include <sys/stat.h> | ||
8 | #include <stdarg.h> | ||
9 | |||
10 | #include <qimage.h> | ||
11 | |||
12 | /***********************************************************************/ | ||
13 | /***********************************************************************/ | ||
14 | /***** *****/ | ||
15 | /***** Code to decode the Palm image format to JPEG *****/ | ||
16 | /***** *****/ | ||
17 | /***********************************************************************/ | ||
18 | /***********************************************************************/ | ||
19 | |||
20 | #define READ_BIGENDIAN_SHORT(p) (((p)[0] << 8)|((p)[1])) | ||
21 | #define READ_BIGENDIAN_LONG(p) (((p)[0] << 24)|((p)[1] << 16)|((p)[2] << 8)|((p)[3])) | ||
22 | |||
23 | #define PALM_IS_COMPRESSED_FLAG 0x8000 | ||
24 | #define PALM_HAS_COLORMAP_FLAG 0x4000 | ||
25 | #define PALM_HAS_TRANSPARENCY_FLAG 0x2000 | ||
26 | #define PALM_DIRECT_COLOR_FLAG 0x0400 | ||
27 | #define PALM_4_BYTE_FIELD_FLAG 0x0200 | ||
28 | |||
29 | #define PALM_COMPRESSION_SCANLINE 0x00 | ||
30 | #define PALM_COMPRESSION_RLE 0x01 | ||
31 | #define PALM_COMPRESSION_PACKBITS 0x02 | ||
32 | #define PALM_COMPRESSION_NONE 0xFF | ||
33 | |||
34 | #define PALM_COLORMAP_SIZE 232 | ||
35 | |||
36 | typedef struct { | ||
37 | unsigned char red; | ||
38 | unsigned char green; | ||
39 | unsigned char blue; | ||
40 | } ColorMapEntry; | ||
41 | |||
42 | static ColorMapEntry Palm8BitColormap[] = { | ||
43 | { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 }, | ||
44 | { 255, 51, 255 }, { 255, 0, 255 }, { 255, 255, 204 }, { 255, 204, 204 }, | ||
45 | { 255, 153, 204 }, { 255, 102, 204 }, { 255, 51, 204 }, { 255, 0, 204 }, | ||
46 | { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 }, | ||
47 | { 255, 51, 153 }, { 255, 0, 153 }, { 204, 255, 255 }, { 204, 204, 255 }, | ||
48 | { 204, 153, 255 }, { 204, 102, 255 }, { 204, 51, 255 }, { 204, 0, 255 }, | ||
49 | { 204, 255, 204 }, { 204, 204, 204 }, { 204, 153, 204 }, { 204, 102, 204 }, | ||
50 | { 204, 51, 204 }, { 204, 0, 204 }, { 204, 255, 153 }, { 204, 204, 153 }, | ||
51 | { 204, 153, 153 }, { 204, 102, 153 }, { 204, 51, 153 }, { 204, 0, 153 }, | ||
52 | { 153, 255, 255 }, { 153, 204, 255 }, { 153, 153, 255 }, { 153, 102, 255 }, | ||
53 | { 153, 51, 255 }, { 153, 0, 255 }, { 153, 255, 204 }, { 153, 204, 204 }, | ||
54 | { 153, 153, 204 }, { 153, 102, 204 }, { 153, 51, 204 }, { 153, 0, 204 }, | ||
55 | { 153, 255, 153 }, { 153, 204, 153 }, { 153, 153, 153 }, { 153, 102, 153 }, | ||
56 | { 153, 51, 153 }, { 153, 0, 153 }, { 102, 255, 255 }, { 102, 204, 255 }, | ||
57 | { 102, 153, 255 }, { 102, 102, 255 }, { 102, 51, 255 }, { 102, 0, 255 }, | ||
58 | { 102, 255, 204 }, { 102, 204, 204 }, { 102, 153, 204 }, { 102, 102, 204 }, | ||
59 | { 102, 51, 204 }, { 102, 0, 204 }, { 102, 255, 153 }, { 102, 204, 153 }, | ||
60 | { 102, 153, 153 }, { 102, 102, 153 }, { 102, 51, 153 }, { 102, 0, 153 }, | ||
61 | { 51, 255, 255 }, { 51, 204, 255 }, { 51, 153, 255 }, { 51, 102, 255 }, | ||
62 | { 51, 51, 255 }, { 51, 0, 255 }, { 51, 255, 204 }, { 51, 204, 204 }, | ||
63 | { 51, 153, 204 }, { 51, 102, 204 }, { 51, 51, 204 }, { 51, 0, 204 }, | ||
64 | { 51, 255, 153 }, { 51, 204, 153 }, { 51, 153, 153 }, { 51, 102, 153 }, | ||
65 | { 51, 51, 153 }, { 51, 0, 153 }, { 0, 255, 255 }, { 0, 204, 255 }, | ||
66 | { 0, 153, 255 }, { 0, 102, 255 }, { 0, 51, 255 }, { 0, 0, 255 }, | ||
67 | { 0, 255, 204 }, { 0, 204, 204 }, { 0, 153, 204 }, { 0, 102, 204 }, | ||
68 | { 0, 51, 204 }, { 0, 0, 204 }, { 0, 255, 153 }, { 0, 204, 153 }, | ||
69 | { 0, 153, 153 }, { 0, 102, 153 }, { 0, 51, 153 }, { 0, 0, 153 }, | ||
70 | { 255, 255, 102 }, { 255, 204, 102 }, { 255, 153, 102 }, { 255, 102, 102 }, | ||
71 | { 255, 51, 102 }, { 255, 0, 102 }, { 255, 255, 51 }, { 255, 204, 51 }, | ||
72 | { 255, 153, 51 }, { 255, 102, 51 }, { 255, 51, 51 }, { 255, 0, 51 }, | ||
73 | { 255, 255, 0 }, { 255, 204, 0 }, { 255, 153, 0 }, { 255, 102, 0 }, | ||
74 | { 255, 51, 0 }, { 255, 0, 0 }, { 204, 255, 102 }, { 204, 204, 102 }, | ||
75 | { 204, 153, 102 }, { 204, 102, 102 }, { 204, 51, 102 }, { 204, 0, 102 }, | ||
76 | { 204, 255, 51 }, { 204, 204, 51 }, { 204, 153, 51 }, { 204, 102, 51 }, | ||
77 | { 204, 51, 51 }, { 204, 0, 51 }, { 204, 255, 0 }, { 204, 204, 0 }, | ||
78 | { 204, 153, 0 }, { 204, 102, 0 }, { 204, 51, 0 }, { 204, 0, 0 }, | ||
79 | { 153, 255, 102 }, { 153, 204, 102 }, { 153, 153, 102 }, { 153, 102, 102 }, | ||
80 | { 153, 51, 102 }, { 153, 0, 102 }, { 153, 255, 51 }, { 153, 204, 51 }, | ||
81 | { 153, 153, 51 }, { 153, 102, 51 }, { 153, 51, 51 }, { 153, 0, 51 }, | ||
82 | { 153, 255, 0 }, { 153, 204, 0 }, { 153, 153, 0 }, { 153, 102, 0 }, | ||
83 | { 153, 51, 0 }, { 153, 0, 0 }, { 102, 255, 102 }, { 102, 204, 102 }, | ||
84 | { 102, 153, 102 }, { 102, 102, 102 }, { 102, 51, 102 }, { 102, 0, 102 }, | ||
85 | { 102, 255, 51 }, { 102, 204, 51 }, { 102, 153, 51 }, { 102, 102, 51 }, | ||
86 | { 102, 51, 51 }, { 102, 0, 51 }, { 102, 255, 0 }, { 102, 204, 0 }, | ||
87 | { 102, 153, 0 }, { 102, 102, 0 }, { 102, 51, 0 }, { 102, 0, 0 }, | ||
88 | { 51, 255, 102 }, { 51, 204, 102 }, { 51, 153, 102 }, { 51, 102, 102 }, | ||
89 | { 51, 51, 102 }, { 51, 0, 102 }, { 51, 255, 51 }, { 51, 204, 51 }, | ||
90 | { 51, 153, 51 }, { 51, 102, 51 }, { 51, 51, 51 }, { 51, 0, 51 }, | ||
91 | { 51, 255, 0 }, { 51, 204, 0 }, { 51, 153, 0 }, { 51, 102, 0 }, | ||
92 | { 51, 51, 0 }, { 51, 0, 0 }, { 0, 255, 102 }, { 0, 204, 102 }, | ||
93 | { 0, 153, 102 }, { 0, 102, 102 }, { 0, 51, 102 }, { 0, 0, 102 }, | ||
94 | { 0, 255, 51 }, { 0, 204, 51 }, { 0, 153, 51 }, { 0, 102, 51 }, | ||
95 | { 0, 51, 51 }, { 0, 0, 51 }, { 0, 255, 0 }, { 0, 204, 0 }, | ||
96 | { 0, 153, 0 }, { 0, 102, 0 }, { 0, 51, 0 }, { 17, 17, 17 }, | ||
97 | { 34, 34, 34 }, { 68, 68, 68 }, { 85, 85, 85 }, { 119, 119, 119 }, | ||
98 | { 136, 136, 136 }, { 170, 170, 170 }, { 187, 187, 187 }, { 221, 221, 221 }, | ||
99 | { 238, 238, 238 }, { 192, 192, 192 }, { 128, 0, 0 }, { 128, 0, 128 }, | ||
100 | { 0, 128, 0 }, { 0, 128, 128 }, { 0, 0, 0 }, { 0, 0, 0 }, | ||
101 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | ||
102 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | ||
103 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | ||
104 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | ||
105 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | ||
106 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }}; | ||
107 | |||
108 | static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }}; | ||
109 | |||
110 | static ColorMapEntry Palm2BitColormap[] = { | ||
111 | { 255, 255, 255 }, { 192, 192, 192 }, { 128, 128, 128 }, { 0, 0, 0 }}; | ||
112 | |||
113 | static ColorMapEntry Palm4BitColormap[] = { | ||
114 | { 255, 255, 255 }, { 238, 238, 238 }, { 221, 221, 221 }, { 204, 204, 204 }, | ||
115 | { 187, 187, 187 }, { 170, 170, 170 }, { 153, 153, 153 }, { 136, 136, 136 }, | ||
116 | { 119, 119, 119 }, { 102, 102, 102 }, { 85, 85, 85 }, { 68, 68, 68 }, | ||
117 | { 51, 51, 51 }, { 34, 34, 34 }, { 17, 17, 17 }, { 0, 0, 0 }}; | ||
118 | |||
119 | QImage* Palm2QImage | ||
120 | (unsigned char *image_bytes_in, int byte_count_in) | ||
121 | { | ||
122 | unsigned int width, height, bytes_per_row, flags, next_depth_offset; | ||
123 | unsigned int bits_per_pixel, version, transparent_index, compression_type, i, j, inval, inbit, mask, incount; | ||
124 | unsigned int palm_red_bits, palm_green_bits, palm_blue_bits; | ||
125 | unsigned char *palm_ptr, *x_ptr, *imagedata, *inbyte, *rowbuf, *lastrow, | ||
126 | *imagedatastart, *palmimage; | ||
127 | ColorMapEntry *colormap; | ||
128 | |||
129 | palmimage = image_bytes_in; | ||
130 | width = READ_BIGENDIAN_SHORT(palmimage + 0); | ||
131 | height = READ_BIGENDIAN_SHORT(palmimage + 2); | ||
132 | bytes_per_row = READ_BIGENDIAN_SHORT(palmimage + 4); | ||
133 | flags = READ_BIGENDIAN_SHORT(palmimage + 6); | ||
134 | bits_per_pixel = palmimage[8]; | ||
135 | version = palmimage[9]; | ||
136 | next_depth_offset = READ_BIGENDIAN_SHORT(palmimage + 10); | ||
137 | transparent_index = palmimage[12]; | ||
138 | compression_type = palmimage[13]; | ||
139 | /* bytes 14 and 15 are reserved by Palm and always 0 */ | ||
140 | |||
141 | #if 0 | ||
142 | qDebug ("Palm image is %dx%d, %d bpp, version %d, flags 0x%x, compression %d", | ||
143 | width, height, bits_per_pixel, version, flags, compression_type); | ||
144 | #endif | ||
145 | |||
146 | if (compression_type == PALM_COMPRESSION_PACKBITS) { | ||
147 | qDebug ("Image uses packbits compression; not yet supported"); | ||
148 | return NULL; | ||
149 | } else if ((compression_type != PALM_COMPRESSION_NONE) && | ||
150 | (compression_type != PALM_COMPRESSION_RLE) && | ||
151 | (compression_type != PALM_COMPRESSION_SCANLINE)) { | ||
152 | qDebug ("Image uses unknown compression, code 0x%x", compression_type); | ||
153 | return NULL; | ||
154 | } | ||
155 | |||
156 | /* as of PalmOS 4.0, there are 6 different kinds of Palm pixmaps: | ||
157 | |||
158 | 1, 2, or 4 bit grayscale | ||
159 | 8-bit StaticColor using the Palm standard colormap | ||
160 | 8-bit PseudoColor using a user-specified colormap | ||
161 | 16-bit DirectColor using 5 bits for red, 6 for green, and 5 for blue | ||
162 | |||
163 | Each of these can be compressed with one of four compression schemes, | ||
164 | "RLE", "Scanline", "PackBits", or none. | ||
165 | |||
166 | We begin by constructing the colormap. | ||
167 | */ | ||
168 | |||
169 | if (flags & PALM_HAS_COLORMAP_FLAG) { | ||
170 | qDebug("Palm images with custom colormaps are not currently supported.\n"); | ||
171 | return NULL; | ||
172 | } else if (bits_per_pixel == 1) { | ||
173 | colormap = Palm1BitColormap; | ||
174 | imagedatastart = palmimage + 16; | ||
175 | } else if (bits_per_pixel == 2) { | ||
176 | colormap = Palm2BitColormap; | ||
177 | imagedatastart = palmimage + 16; | ||
178 | } else if (bits_per_pixel == 4) { | ||
179 | colormap = Palm4BitColormap; | ||
180 | imagedatastart = palmimage + 16; | ||
181 | } else if (bits_per_pixel == 8) { | ||
182 | colormap = Palm8BitColormap; | ||
183 | imagedatastart = palmimage + 16; | ||
184 | } else if (bits_per_pixel == 16 && (flags & PALM_DIRECT_COLOR_FLAG)) { | ||
185 | colormap = NULL; | ||
186 | palm_red_bits = palmimage[16]; | ||
187 | palm_green_bits = palmimage[17]; | ||
188 | palm_blue_bits = palmimage[18]; | ||
189 | if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) { | ||
190 | qDebug("Can't handle this format DirectColor image -- too wide in some color (%d:%d:%d)\n", | ||
191 | palm_red_bits, palm_green_bits, palm_blue_bits); | ||
192 | return NULL; | ||
193 | } | ||
194 | if (bits_per_pixel > (8 * sizeof(unsigned long))) { | ||
195 | qDebug ("Can't handle this format DirectColor image -- too many bits per pixel (%d)\n", | ||
196 | bits_per_pixel); | ||
197 | return NULL; | ||
198 | } | ||
199 | imagedatastart = palmimage + 24; | ||
200 | } else { | ||
201 | qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel); | ||
202 | return NULL; | ||
203 | } | ||
204 | |||
205 | QImage* qimage = new QImage(width, height, 16); | ||
206 | |||
207 | /* row by row, uncompress the Palm image and copy it to the JPEG buffer */ | ||
208 | rowbuf = new unsigned char[bytes_per_row * width]; | ||
209 | lastrow = new unsigned char[bytes_per_row * width]; | ||
210 | |||
211 | for (i=0, palm_ptr = imagedatastart , x_ptr = imagedata; i < height; ++i) { | ||
212 | |||
213 | /* first, uncompress the Palm image */ | ||
214 | if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_RLE)) { | ||
215 | for (j = 0; j < bytes_per_row; ) { | ||
216 | incount = *palm_ptr++; | ||
217 | inval = *palm_ptr++; | ||
218 | memset(rowbuf + j, inval, incount); | ||
219 | j += incount; | ||
220 | } | ||
221 | } else if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_SCANLINE)) { | ||
222 | for (j = 0; j < bytes_per_row; j += 8) { | ||
223 | incount = *palm_ptr++; | ||
224 | inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8; | ||
225 | for (inbit = 0; inbit < inval; inbit += 1) { | ||
226 | if (incount & (1 << (7 - inbit))) | ||
227 | rowbuf[j + inbit] = *palm_ptr++; | ||
228 | else | ||
229 | rowbuf[j + inbit] = lastrow[j + inbit]; | ||
230 | } | ||
231 | } | ||
232 | memcpy (lastrow, rowbuf, bytes_per_row); | ||
233 | } else if (((flags & PALM_IS_COMPRESSED_FLAG) && | ||
234 | (compression_type == PALM_COMPRESSION_NONE)) || | ||
235 | (flags && PALM_IS_COMPRESSED_FLAG) == 0) { | ||
236 | memcpy (rowbuf, palm_ptr, bytes_per_row); | ||
237 | palm_ptr += bytes_per_row; | ||
238 | } | ||
239 | |||
240 | /* next, write it to the GDK bitmap */ | ||
241 | if (colormap) { | ||
242 | mask = (1 << bits_per_pixel) - 1; | ||
243 | for (inbit = 8 - bits_per_pixel, inbyte = rowbuf, j = 0; j < width; ++j) { | ||
244 | inval = ((*inbyte) & (mask << inbit)) >> inbit; | ||
245 | /* correct for oddity of the 8-bit color Palm pixmap... */ | ||
246 | if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231; | ||
247 | /* now lookup the correct color and set the pixel in the GTK bitmap */ | ||
248 | QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue); | ||
249 | qimage->setPixel(j, i, colour); | ||
250 | if (!inbit) { | ||
251 | ++inbyte; | ||
252 | inbit = 8 - bits_per_pixel; | ||
253 | } else { | ||
254 | inbit -= bits_per_pixel; | ||
255 | } | ||
256 | } | ||
257 | } else if (!colormap && | ||
258 | bits_per_pixel == 16) { | ||
259 | for (inbyte = rowbuf, j = 0; j < width; ++j) { | ||
260 | inval = (inbyte[0] << 8) | inbyte[1]; | ||
261 | #if 0 | ||
262 | qDebug ("pixel is %d,%d (%02x:%02x:%02x)", | ||
263 | j, i, | ||
264 | (inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1), | ||
265 | (inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1), | ||
266 | (inval >> 0) & ((1 << palm_blue_bits) - 1)); | ||
267 | #endif | ||
268 | QRgb colour = qRgb( | ||
269 | (inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1), | ||
270 | (inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1), | ||
271 | (inval >> 0) & ((1 << palm_blue_bits) - 1)); | ||
272 | qimage->setPixel(j, i, colour); | ||
273 | inbyte += 2; | ||
274 | } | ||
275 | } | ||
276 | } | ||
277 | |||
278 | delete [] rowbuf; | ||
279 | delete [] lastrow; | ||
280 | |||
281 | return qimage; | ||
282 | } | ||
283 | |||
284 | QPixmap* hRule(int w, int h, unsigned char r, unsigned char g, unsigned char b) | ||
285 | { | ||
286 | // qDebug("hrule [%d, %d]", w, h); | ||
287 | QPixmap* qimage = new QPixmap(w, h); | ||
288 | qimage->fill(QColor(r,g,b)); | ||
289 | return qimage; | ||
290 | } | ||
diff --git a/noncore/apps/opie-reader/Palm2QImage.h b/noncore/apps/opie-reader/Palm2QImage.h new file mode 100644 index 0000000..3ac2d19 --- a/dev/null +++ b/noncore/apps/opie-reader/Palm2QImage.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #include <qimage.h> | ||
2 | #include <qpixmap.h> | ||
3 | |||
4 | QImage* Palm2QImage | ||
5 | (unsigned char *image_bytes_in, int byte_count_in); | ||
6 | |||
7 | QPixmap* hRule(int w, int h, unsigned char r=0, unsigned char g=0, unsigned char b=0); | ||
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp index 7cf08e5..3995ee7 100644 --- a/noncore/apps/opie-reader/QTReader.cpp +++ b/noncore/apps/opie-reader/QTReader.cpp | |||
@@ -24,2 +24,3 @@ | |||
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include "StateData.h" | ||
25 | 26 | ||
@@ -37,3 +38,3 @@ const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; | |||
37 | 38 | ||
38 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : | 39 | QTReader::QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0) : |
39 | QWidget(parent, name, f), | 40 | QWidget(parent, name, f), |
@@ -50,3 +51,5 @@ QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : | |||
50 | m_twotouch(true), | 51 | m_twotouch(true), |
51 | m_touchone(true) | 52 | m_touchone(true), |
53 | bDoUpdates(false), | ||
54 | m_navkeys(true) | ||
52 | { | 55 | { |
@@ -83,2 +86,3 @@ void QTReader::mousePressEvent( QMouseEvent* _e ) | |||
83 | { | 86 | { |
87 | buffdoc.unsuspend(); | ||
84 | if (_e->button() == RightButton) | 88 | if (_e->button() == RightButton) |
@@ -86,5 +90,36 @@ void QTReader::mousePressEvent( QMouseEvent* _e ) | |||
86 | mouseUpOn = false; | 90 | mouseUpOn = false; |
87 | if (_e->y() > height()/2) | 91 | if (buffdoc.hasnavigation()) |
88 | { | 92 | { |
89 | goDown(); | 93 | if (_e->y() > (2*height())/3) |
94 | { | ||
95 | goDown(); | ||
96 | } | ||
97 | else if (_e->y() < height()/3) | ||
98 | { | ||
99 | goUp(); | ||
100 | } | ||
101 | else | ||
102 | { | ||
103 | if (_e->x() < width()/3) | ||
104 | { | ||
105 | size_t target = pagelocate(); | ||
106 | if (buffdoc.back(target)) | ||
107 | { | ||
108 | locate(target); | ||
109 | } | ||
110 | } | ||
111 | else if (_e->x() > (2*width())/3) | ||
112 | { | ||
113 | size_t target = pagelocate(); | ||
114 | if (buffdoc.forward(target)) | ||
115 | { | ||
116 | locate(target); | ||
117 | } | ||
118 | } | ||
119 | else | ||
120 | { | ||
121 | buffdoc.saveposn(pagelocate()); | ||
122 | locate(buffdoc.getHome()); | ||
123 | } | ||
124 | } | ||
90 | } | 125 | } |
@@ -92,3 +127,10 @@ void QTReader::mousePressEvent( QMouseEvent* _e ) | |||
92 | { | 127 | { |
93 | goUp(); | 128 | if (_e->y() > height()/2) |
129 | { | ||
130 | goDown(); | ||
131 | } | ||
132 | else | ||
133 | { | ||
134 | goUp(); | ||
135 | } | ||
94 | } | 136 | } |
@@ -97,3 +139,3 @@ void QTReader::mousePressEvent( QMouseEvent* _e ) | |||
97 | 139 | ||
98 | bool QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt) | 140 | linkType QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt) |
99 | { | 141 | { |
@@ -114,6 +156,7 @@ bool QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t | |||
114 | CDrawBuffer* t = textarray[lineno]; | 156 | CDrawBuffer* t = textarray[lineno]; |
115 | for (i = t->length(); t->width(i) > x; i--); | 157 | x = x - t->offset(width()); |
158 | for (i = t->length(); i >= 0 && t->width(i) > x; i--); | ||
116 | offset = i; | 159 | offset = i; |
117 | } | 160 | } |
118 | return textarray[lineno]->isLink(offset, tgt); | 161 | return textarray[lineno]->getLinkType(offset, tgt); |
119 | } | 162 | } |
@@ -126,4 +169,11 @@ void QTReader::setTwoTouch(bool _b) | |||
126 | 169 | ||
170 | void QTReader::setContinuous(bool _b) | ||
171 | { | ||
172 | buffdoc.unsuspend(); | ||
173 | buffdoc.setContinuous(m_continuousDocument = _b); | ||
174 | } | ||
175 | |||
127 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | 176 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) |
128 | { | 177 | { |
178 | buffdoc.unsuspend(); | ||
129 | if (_e->button() == LeftButton) | 179 | if (_e->button() == LeftButton) |
@@ -143,14 +193,39 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | |||
143 | size_t startpos, startoffset, tgt; | 193 | size_t startpos, startoffset, tgt; |
144 | if (getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt)) | 194 | switch (getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt)) |
145 | { | 195 | { |
146 | if (buffdoc.hyperlink(tgt)) | 196 | case eLink: |
147 | { | 197 | { |
148 | fillbuffer(); | 198 | size_t saveposn = pagelocate(); |
149 | update(); | 199 | if (buffdoc.hyperlink(tgt)) |
200 | { | ||
201 | buffdoc.saveposn(saveposn); | ||
202 | fillbuffer(); | ||
203 | update(); | ||
204 | } | ||
205 | else | ||
206 | { | ||
207 | locate(pagelocate()); | ||
208 | } | ||
209 | return; | ||
150 | } | 210 | } |
151 | else | 211 | case ePicture: |
152 | { | 212 | { |
153 | locate(pagelocate()); | 213 | qDebug("Picture:%x", tgt); |
214 | QPixmap* pm = buffdoc.getPicture(tgt); | ||
215 | if (pm != NULL) | ||
216 | { | ||
217 | emit OnShowPicture(*pm); | ||
218 | delete pm; | ||
219 | } | ||
220 | else | ||
221 | { | ||
222 | locate(pagelocate()); | ||
223 | } | ||
224 | return; | ||
154 | } | 225 | } |
155 | return; | 226 | case eNone: |
227 | break; | ||
228 | default: | ||
229 | qDebug("Unknown linktype"); | ||
230 | return; | ||
156 | } | 231 | } |
@@ -214,2 +289,3 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | |||
214 | int first = 0; | 289 | int first = 0; |
290 | int tgt = _e->x() - t->offset(width()); | ||
215 | while (1) | 291 | while (1) |
@@ -218,3 +294,3 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | |||
218 | while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; | 294 | while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; |
219 | if (t->width(i) > _e->x()) | 295 | if (t->width(i) > tgt) |
220 | { | 296 | { |
@@ -284,4 +360,73 @@ void QTReader::goUp() | |||
284 | 360 | ||
361 | void QTReader::NavUp() | ||
362 | { | ||
363 | buffdoc.unsuspend(); | ||
364 | if (buffdoc.hasnavigation()) | ||
365 | { | ||
366 | /* | ||
367 | size_t target = pagelocate(); | ||
368 | if (buffdoc.back(target)) | ||
369 | { | ||
370 | locate(target); | ||
371 | } | ||
372 | */ | ||
373 | locate(buffdoc.startSection()); | ||
374 | } | ||
375 | else | ||
376 | { | ||
377 | goUp(); | ||
378 | } | ||
379 | } | ||
380 | |||
381 | void QTReader::NavDown() | ||
382 | { | ||
383 | buffdoc.unsuspend(); | ||
384 | if (buffdoc.hasnavigation()) | ||
385 | { | ||
386 | /* | ||
387 | size_t target = pagelocate(); | ||
388 | if (buffdoc.forward(target)) | ||
389 | { | ||
390 | locate(target); | ||
391 | } | ||
392 | */ | ||
393 | dopageup(buffdoc.endSection()); | ||
394 | } | ||
395 | else | ||
396 | { | ||
397 | goDown(); | ||
398 | } | ||
399 | } | ||
400 | |||
401 | void QTReader::zoomin() | ||
402 | { | ||
403 | if (m_fontControl.increasesize()) | ||
404 | { | ||
405 | bool sc = m_autoScroll; | ||
406 | setfont(); | ||
407 | m_autoScroll = false; | ||
408 | locate(pagelocate()); | ||
409 | update(); | ||
410 | m_autoScroll = sc; | ||
411 | if (m_autoScroll) autoscroll(); | ||
412 | } | ||
413 | } | ||
414 | |||
415 | void QTReader::zoomout() | ||
416 | { | ||
417 | if (m_fontControl.decreasesize()) | ||
418 | { | ||
419 | bool sc = m_autoScroll; | ||
420 | m_autoScroll = false; | ||
421 | setfont(); | ||
422 | locate(pagelocate()); | ||
423 | update(); | ||
424 | m_autoScroll = sc; | ||
425 | if (m_autoScroll) autoscroll(); | ||
426 | } | ||
427 | } | ||
428 | |||
285 | void QTReader::keyPressEvent(QKeyEvent* e) | 429 | void QTReader::keyPressEvent(QKeyEvent* e) |
286 | { | 430 | { |
431 | buffdoc.unsuspend(); | ||
287 | switch (e->key()) | 432 | switch (e->key()) |
@@ -359,32 +504,30 @@ void QTReader::keyPressEvent(QKeyEvent* e) | |||
359 | */ | 504 | */ |
360 | case Key_Right: | 505 | case Key_Right: |
361 | { | 506 | { |
362 | e->accept(); | 507 | e->accept(); |
363 | if (m_fontControl.increasesize()) | 508 | if (m_navkeys && buffdoc.hasnavigation()) |
364 | { | 509 | { |
365 | bool sc = m_autoScroll; | 510 | size_t target = pagelocate(); |
366 | setfont(); | 511 | if (buffdoc.forward(target)) |
367 | m_autoScroll = false; | 512 | { |
368 | locate(pagelocate()); | 513 | locate(target); |
369 | update(); | 514 | } |
370 | m_autoScroll = sc; | 515 | } |
371 | if (m_autoScroll) autoscroll(); | 516 | else zoomin(); |
372 | } | ||
373 | } | 517 | } |
374 | break; | 518 | break; |
375 | case Key_Left: | 519 | case Key_Left: |
376 | { | 520 | { |
377 | e->accept(); | 521 | e->accept(); |
378 | if (m_fontControl.decreasesize()) | 522 | if (m_navkeys && buffdoc.hasnavigation()) |
379 | { | 523 | { |
380 | bool sc = m_autoScroll; | 524 | size_t target = pagelocate(); |
381 | m_autoScroll = false; | 525 | if (buffdoc.back(target)) |
382 | setfont(); | 526 | { |
383 | locate(pagelocate()); | 527 | locate(target); |
384 | update(); | 528 | } |
385 | m_autoScroll = sc; | 529 | } |
386 | if (m_autoScroll) autoscroll(); | 530 | else zoomout(); |
387 | } | ||
388 | } | 531 | } |
389 | break; | 532 | break; |
390 | case Key_Space: | 533 | case Key_Space: |
@@ -411,2 +554,4 @@ void QTReader::setautoscroll(bool _sc) | |||
411 | { | 554 | { |
555 | CDrawBuffer* reusebuffer = textarray[numlines]; | ||
556 | if (reusebuffer == NULL || reusebuffer->eof()) return; | ||
412 | m_autoScroll = true; | 557 | m_autoScroll = true; |
@@ -419,2 +564,3 @@ bool QTReader::getline(CDrawBuffer *buff) | |||
419 | { | 564 | { |
565 | buffdoc.unsuspend(); | ||
420 | if (m_bMonoSpaced) | 566 | if (m_bMonoSpaced) |
@@ -461,3 +607,3 @@ void QTReader::doscroll() | |||
461 | { | 607 | { |
462 | textarray[numlines] = new CDrawBuffer; | 608 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
463 | } | 609 | } |
@@ -465,3 +611,3 @@ void QTReader::doscroll() | |||
465 | int ch = getline(textarray[numlines]); | 611 | int ch = getline(textarray[numlines]); |
466 | textarray[numlines-1]->render(&p, height() - textarray[numlines]->descent() - 2, m_bMonoSpaced, m_charWidth, width()); | 612 | textarray[numlines-1]->render(&p, height() - textarray[numlines-1]->descent() - 2, m_bMonoSpaced, m_charWidth, width()); |
467 | mylastpos = locate(); | 613 | mylastpos = locate(); |
@@ -471,3 +617,2 @@ void QTReader::doscroll() | |||
471 | ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); | 617 | ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); |
472 | emit OnRedraw(); | ||
473 | } | 618 | } |
@@ -494,74 +639,66 @@ void QTReader::drawFonts( QPainter *p ) | |||
494 | { | 639 | { |
495 | setfont(); | 640 | if (bDoUpdates) |
496 | if (m_lastwidth != width() || m_lastheight != height()) | 641 | { |
497 | { | 642 | qDebug("How refreshing..."); |
498 | m_lastwidth = width(); | 643 | if (buffdoc.empty()) return; |
499 | m_lastheight = height(); | 644 | setfont(); |
500 | locate(pagelocate()); | 645 | if (m_lastwidth != width()) |
501 | } | 646 | { |
502 | else | 647 | qDebug("Not Optimised %d", m_lastwidth); |
503 | { | 648 | m_lastwidth = width(); |
504 | 649 | m_lastheight = height(); | |
505 | /* | 650 | locate(pagelocate()); |
506 | int sl = screenlines(); | 651 | qDebug("Not Optimised %d", m_lastwidth); |
507 | if (sl < numlines) | 652 | } |
508 | { | 653 | else |
509 | //qDebug("df:<%u,%u>",sl,numlines); | 654 | { |
510 | 655 | if (m_lastheight > height()) | |
511 | size_t newpos = locnarray[sl]; | 656 | { |
512 | CDrawBuffer** nta = new CDrawBuffer*[sl]; | 657 | qDebug("Optimised < %d", numlines); |
513 | size_t* nla = new size_t[sl]; | 658 | int ypos = 0; |
514 | for (int i = 0; i < sl; i++) | 659 | for (int i = 0; i < numlines; i++) |
515 | { | 660 | { |
516 | nta[i] = textarray[i]; | 661 | if ((ypos += textarray[i]->lineSpacing()) > height()) |
517 | nla[i] = locnarray[i]; | 662 | { |
518 | } | 663 | numlines = i; |
519 | for (int i = sl; i < numlines; i++) delete textarray[i]; | 664 | jumpto(locnarray[i+1]); |
520 | delete [] locnarray; | 665 | break; |
521 | delete [] textarray; | 666 | } |
522 | textarray = nta; | 667 | } |
523 | locnarray = nla; | 668 | qDebug("Optimised < %d", numlines); |
524 | numlines = sl; | 669 | m_lastheight = height(); |
525 | jumpto(mylastpos = newpos); | 670 | } |
526 | } | 671 | else if (m_lastheight < height()) |
527 | if (sl > numlines) | 672 | { |
528 | { | 673 | qDebug("Optimised > %d", numlines); |
529 | //qDebug("df:<%u,%u>",sl,numlines); | 674 | int ypos = 0; |
530 | CDrawBuffer** nta = new CDrawBuffer*[sl]; | 675 | for (int i = 0; i <= numlines; i++) |
531 | size_t* nla = new size_t[sl]; | 676 | { |
532 | for (int i = 0; i < numlines; i++) | 677 | ypos += textarray[i]->lineSpacing(); |
533 | { | 678 | } |
534 | nta[i] = textarray[i]; | 679 | fillbuffer(numlines+1, ypos); |
535 | nla[i] = locnarray[i]; | 680 | qDebug("Optimised > %d", numlines); |
536 | } | 681 | m_lastheight = height(); |
537 | if (locate() != mylastpos) jumpto(mylastpos); | 682 | } |
538 | for (int i = numlines; i < sl; i++) | 683 | if (numlines > 0) |
539 | { | 684 | { |
540 | nta[i] = new CDrawBuffer(&m_fontControl); | 685 | int ypos = textarray[0]->ascent(); |
541 | nla[i] = locate(); | 686 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); |
542 | getline(nta[i]); | 687 | for (int i = 1; i < numlines; i++) |
543 | } | 688 | { |
544 | mylastpos = locate(); | 689 | // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; |
545 | delete [] locnarray; | 690 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ |
546 | delete [] textarray; | 691 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; |
547 | textarray = nta; | 692 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); |
548 | locnarray = nla; | 693 | } |
549 | numlines = sl; | ||
550 | } | ||
551 | */ | ||
552 | if (numlines > 0) | ||
553 | { | ||
554 | int ypos = textarray[0]->ascent(); | ||
555 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); | ||
556 | for (int i = 1; i < numlines; i++) | ||
557 | { | ||
558 | ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; | ||
559 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); | ||
560 | |||
561 | } | ||
562 | // mylastpos = locate(); | 694 | // mylastpos = locate(); |
563 | } | 695 | } |
564 | } | 696 | } |
565 | m_scrolldy1 = m_scrolldy2 = 0; | 697 | m_scrolldy1 = m_scrolldy2 = 0; |
566 | emit OnRedraw(); | 698 | emit OnRedraw(); |
699 | } | ||
700 | else | ||
701 | { | ||
702 | qDebug("Not so refreshing..."); | ||
703 | } | ||
567 | } | 704 | } |
@@ -609,2 +746,3 @@ void QTReader::init() | |||
609 | 746 | ||
747 | buffdoc.unsuspend(); | ||
610 | setBackgroundColor( white ); | 748 | setBackgroundColor( white ); |
@@ -620,5 +758,4 @@ void QTReader::init() | |||
620 | // QMessageBox::information(this, "init", m_lastfile, 1); | 758 | // QMessageBox::information(this, "init", m_lastfile, 1); |
621 | m_lastwidth = width(); | ||
622 | m_lastheight = height(); | ||
623 | setfont(); | 759 | setfont(); |
760 | /* | ||
624 | if (!m_lastfile.isEmpty()) | 761 | if (!m_lastfile.isEmpty()) |
@@ -628,2 +765,3 @@ void QTReader::init() | |||
628 | } | 765 | } |
766 | */ | ||
629 | } | 767 | } |
@@ -703,2 +841,3 @@ bool QTReader::locate(unsigned long n) { | |||
703 | //printf("Locate\n"); | 841 | //printf("Locate\n"); |
842 | buffdoc.unsuspend(); | ||
704 | buffdoc.locate(n); | 843 | buffdoc.locate(n); |
@@ -721,2 +860,3 @@ bool QTReader::fillbuffer(int reuse, int ht) | |||
721 | { | 860 | { |
861 | buffdoc.unsuspend(); | ||
722 | if (buffdoc.empty()) return false; | 862 | if (buffdoc.empty()) return false; |
@@ -728,3 +868,3 @@ bool QTReader::fillbuffer(int reuse, int ht) | |||
728 | numlines = reuse; | 868 | numlines = reuse; |
729 | while (ypos < height()) | 869 | while (ypos < height() || numlines < 2) |
730 | { | 870 | { |
@@ -740,3 +880,3 @@ bool QTReader::fillbuffer(int reuse, int ht) | |||
740 | { | 880 | { |
741 | if (numlines - reuse == 1/* && locnarray[0] == buffdoc.locate()*/) | 881 | if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/) |
742 | { | 882 | { |
@@ -763,2 +903,3 @@ void QTReader::dopagedn() | |||
763 | { | 903 | { |
904 | buffdoc.unsuspend(); | ||
764 | int skip = 0, ypos = 0; | 905 | int skip = 0, ypos = 0; |
@@ -770,2 +911,3 @@ void QTReader::dopagedn() | |||
770 | CDrawBuffer* reusebuffer = textarray[numlines]; | 911 | CDrawBuffer* reusebuffer = textarray[numlines]; |
912 | if (reusebuffer != NULL && reusebuffer->eof()) return; | ||
771 | if (reusebuffer != NULL) | 913 | if (reusebuffer != NULL) |
@@ -779,2 +921,3 @@ void QTReader::dopagedn() | |||
779 | textarray[i] = reusebuffer; | 921 | textarray[i] = reusebuffer; |
922 | // reusebuffer->empty(); | ||
780 | locnarray[offset] = locnarray[i]; | 923 | locnarray[offset] = locnarray[i]; |
@@ -793,46 +936,69 @@ void QTReader::dopageup() | |||
793 | { | 936 | { |
937 | buffdoc.unsuspend(); | ||
938 | dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]); | ||
939 | } | ||
940 | |||
941 | void QTReader::dopageup(unsigned int target) | ||
942 | { | ||
943 | buffdoc.unsuspend(); | ||
794 | CBufferFace<CDrawBuffer*> buff; | 944 | CBufferFace<CDrawBuffer*> buff; |
795 | CBufferFace<size_t> loc; | 945 | CBufferFace<size_t> loc; |
796 | unsigned int target = locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]; | ||
797 | 946 | ||
798 | size_t delta; | 947 | size_t delta, guess = 2048; |
799 | if (target < 2048) | 948 | bool ch = true; |
800 | { | 949 | int nbfl, ypos = 0; |
801 | delta = target; | ||
802 | jumpto(0); | ||
803 | } | ||
804 | else | ||
805 | { | ||
806 | delta = 2048; | ||
807 | 950 | ||
808 | jumpto(target - delta); | 951 | while (1) |
809 | 952 | { | |
810 | buff[0] = new CDrawBuffer(&m_fontControl); | 953 | ch = true; |
811 | 954 | nbfl = 0; | |
812 | do | 955 | if (target < guess) |
956 | { | ||
957 | delta = 0; // 0 is a flag to say don't guess any more | ||
958 | jumpto( (m_continuousDocument) ? 0 : buffdoc.startSection() ); | ||
959 | } | ||
960 | else if (!m_continuousDocument && (target - guess < buffdoc.startSection())) | ||
961 | { | ||
962 | delta = 0; // 0 is a flag to say don't guess any more | ||
963 | jumpto(buffdoc.startSection()); | ||
964 | } | ||
965 | else | ||
813 | { | 966 | { |
967 | delta = guess; | ||
814 | 968 | ||
815 | if (!getline(buff[0])) break; | 969 | jumpto(target - delta); |
816 | 970 | ||
817 | if (locate() > target) continue; | 971 | buff[0] = new CDrawBuffer(&m_fontControl); |
972 | |||
973 | do | ||
974 | { | ||
975 | |||
976 | if (!getline(buff[0])) break; | ||
977 | |||
978 | if (locate() > target) break; | ||
979 | } | ||
980 | while (!buffdoc.iseol()); | ||
818 | } | 981 | } |
819 | while (!buffdoc.iseol()); | 982 | |
820 | } | 983 | ypos = 0; |
821 | int nbfl = 0; | 984 | while (locate() < target) |
822 | 985 | { | |
823 | bool ch = true; | 986 | if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); |
824 | int ypos = 0; | 987 | loc[nbfl] = locate(); |
825 | while (locate() < target) | 988 | ch = getline(buff[nbfl]); |
826 | { | 989 | ypos += buff[nbfl]->lineSpacing(); |
827 | if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); | 990 | nbfl++; |
828 | loc[nbfl] = locate(); | 991 | if (!ch) break; |
829 | ch = getline(buff[nbfl]); | 992 | } |
830 | ypos += buff[nbfl]->lineSpacing(); | 993 | if (ypos < height() && (delta != 0)) |
831 | nbfl++; | 994 | { |
832 | if (!ch) break; | 995 | for (int i = 0; i < nbfl; i++) |
833 | } | 996 | { |
834 | if (ypos < height()) | 997 | delete buff[i]; |
835 | { | 998 | buff[i] = NULL; |
836 | locate(0); | 999 | } |
837 | return; | 1000 | guess <<= 1; |
1001 | continue; | ||
1002 | } | ||
1003 | break; | ||
838 | } | 1004 | } |
@@ -847,5 +1013,5 @@ void QTReader::dopageup() | |||
847 | numlines = 0; | 1013 | numlines = 0; |
848 | while (ypos < height() && numlines <= nbfl-2) | 1014 | while (ypos < height() && numlines <= nbfl-1) |
849 | { | 1015 | { |
850 | ypos += buff[nbfl - numlines - 2]->lineSpacing(); | 1016 | ypos += buff[nbfl - numlines - 1]->lineSpacing(); |
851 | numlines++; | 1017 | numlines++; |
@@ -853,4 +1019,5 @@ void QTReader::dopageup() | |||
853 | --numlines; | 1019 | --numlines; |
854 | int offset = nbfl; | 1020 | int offset = nbfl-1; |
855 | offset -= numlines+1; | 1021 | offset -= numlines; |
1022 | ypos = 0; | ||
856 | for (int i = 0; i <= numlines; i++) | 1023 | for (int i = 0; i <= numlines; i++) |
@@ -860,2 +1027,3 @@ void QTReader::dopageup() | |||
860 | locnarray[i] = loc[offset + i]; | 1027 | locnarray[i] = loc[offset + i]; |
1028 | ypos += textarray[i]->lineSpacing(); | ||
861 | } | 1029 | } |
@@ -866,3 +1034,11 @@ void QTReader::dopageup() | |||
866 | 1034 | ||
867 | // --numlines; | 1035 | while (ypos < height()) |
1036 | { | ||
1037 | numlines++; | ||
1038 | locnarray[numlines] = locate(); | ||
1039 | if (textarray[numlines] == NULL) textarray[numlines] = new CDrawBuffer(&m_fontControl); | ||
1040 | if (!getline(textarray[numlines])) break; | ||
1041 | ypos += textarray[numlines]->lineSpacing(); | ||
1042 | } | ||
1043 | |||
868 | mylastpos = locate(); | 1044 | mylastpos = locate(); |
@@ -885,2 +1061,4 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn) | |||
885 | // QMessageBox::information(0, "Opening...", newfile); | 1061 | // QMessageBox::information(0, "Opening...", newfile); |
1062 | m_lastwidth = width(); | ||
1063 | m_lastheight = height(); | ||
886 | if (buffdoc.openfile(this,newfile) == 0) | 1064 | if (buffdoc.openfile(this,newfile) == 0) |
@@ -888,2 +1066,3 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn) | |||
888 | bRC = true; | 1066 | bRC = true; |
1067 | buffdoc.setContinuous(m_continuousDocument); | ||
889 | // qDebug("buffdoc.openfile done"); | 1068 | // qDebug("buffdoc.openfile done"); |
@@ -1014,2 +1193,3 @@ void QTReader::lineUp() | |||
1014 | { | 1193 | { |
1194 | buffdoc.unsuspend(); | ||
1015 | CDrawBuffer* buff = textarray[numlines]; | 1195 | CDrawBuffer* buff = textarray[numlines]; |
@@ -1021,2 +1201,3 @@ void QTReader::lineUp() | |||
1021 | if (target == 0) return; | 1201 | if (target == 0) return; |
1202 | if (!m_continuousDocument && (target == buffdoc.startSection())) return; | ||
1022 | if (buffdoc.hasrandomaccess()) | 1203 | if (buffdoc.hasrandomaccess()) |
@@ -1036,2 +1217,10 @@ void QTReader::lineUp() | |||
1036 | } | 1217 | } |
1218 | else if (!m_continuousDocument && (target - delta < buffdoc.startSection())) | ||
1219 | { | ||
1220 | delta = target-buffdoc.startSection(); | ||
1221 | jumpto(buffdoc.startSection()); | ||
1222 | loc = locate(); | ||
1223 | getline(buff); | ||
1224 | break; | ||
1225 | } | ||
1037 | jumpto(target-delta); | 1226 | jumpto(target-delta); |
@@ -1109 +1298,30 @@ MarkupType QTReader::PreferredMarkup() | |||
1109 | } | 1298 | } |
1299 | |||
1300 | void QTReader::setstate(const statedata& sd) | ||
1301 | { | ||
1302 | bstripcr = sd.bstripcr; | ||
1303 | btextfmt = sd.btextfmt; | ||
1304 | bautofmt = sd.bautofmt; | ||
1305 | bstriphtml = sd.bstriphtml; | ||
1306 | bpeanut = sd.bpeanut; | ||
1307 | bdehyphen = sd.bdehyphen; | ||
1308 | bonespace = sd.bonespace; | ||
1309 | bunindent = sd.bunindent; | ||
1310 | brepara = sd.brepara; | ||
1311 | bdblspce = sd.bdblspce; | ||
1312 | m_bpagemode = sd.m_bpagemode; | ||
1313 | m_navkeys = sd.m_navkeys; | ||
1314 | m_bMonoSpaced = sd.m_bMonoSpaced; | ||
1315 | bremap = sd.bremap; | ||
1316 | bmakebold = sd.bmakebold; | ||
1317 | m_continuousDocument = sd.Continuous; | ||
1318 | #ifdef REPALM | ||
1319 | brepalm = sd.brepalm; | ||
1320 | #endif | ||
1321 | bindenter = sd.bindenter; | ||
1322 | m_encd = sd.m_charpc; | ||
1323 | m_fontname = sd.m_fontname; | ||
1324 | setContinuous(sd.Continuous); | ||
1325 | ChangeFont(sd.m_textsize); | ||
1326 | refresh(); | ||
1327 | } | ||
diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h index 78230b4..3d5f57d 100644 --- a/noncore/apps/opie-reader/QTReader.h +++ b/noncore/apps/opie-reader/QTReader.h | |||
@@ -15,2 +15,4 @@ class QPainter; | |||
15 | class QTimer; | 15 | class QTimer; |
16 | class QPixmap; | ||
17 | class statedata; | ||
16 | 18 | ||
@@ -21,2 +23,3 @@ class QTReader : public QWidget | |||
21 | friend class QTReaderApp; | 23 | friend class QTReaderApp; |
24 | void suspend() { buffdoc.suspend(); } | ||
22 | void drawText(QPainter& p, int x, int y, tchar* text); | 25 | void drawText(QPainter& p, int x, int y, tchar* text); |
@@ -39,3 +42,14 @@ public: | |||
39 | ~QTReader(); | 42 | ~QTReader(); |
43 | void zoomin(); | ||
44 | void zoomout(); | ||
45 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | ||
46 | { | ||
47 | buffdoc.setSaveData(data, len, src, srclen); | ||
48 | } | ||
49 | void putSaveData(unsigned char*& src, unsigned short& srclen) | ||
50 | { | ||
51 | buffdoc.putSaveData(src, srclen); | ||
52 | } | ||
40 | bool empty(); | 53 | bool empty(); |
54 | void setContinuous(bool _b); | ||
41 | void toggle_autoscroll(); | 55 | void toggle_autoscroll(); |
@@ -110,2 +124,14 @@ public: | |||
110 | } | 124 | } |
125 | void setonespace(bool _b) | ||
126 | { | ||
127 | bonespace = _b; | ||
128 | setfilter(getfilter()); | ||
129 | } | ||
130 | #ifdef REPALM | ||
131 | void setrepalm(bool _b) | ||
132 | { | ||
133 | brepalm = _b; | ||
134 | setfilter(getfilter()); | ||
135 | } | ||
136 | #endif | ||
111 | void setstriphtml(bool _b) | 137 | void setstriphtml(bool _b) |
@@ -192,4 +218,8 @@ public: | |||
192 | if (brepara) filt->addfilter(new repara); | 218 | if (brepara) filt->addfilter(new repara); |
219 | if (bonespace) filt->addfilter(new OnePara); | ||
193 | if (bindenter) filt->addfilter(new indenter(bindenter)); | 220 | if (bindenter) filt->addfilter(new indenter(bindenter)); |
194 | if (bdblspce) filt->addfilter(new dblspce); | 221 | if (bdblspce) filt->addfilter(new dblspce); |
222 | #ifdef REPALM | ||
223 | if (brepalm) filt->addfilter(new repalm); | ||
224 | #endif | ||
195 | if (bremap) filt->addfilter(new remap); | 225 | if (bremap) filt->addfilter(new remap); |
@@ -218,5 +248,6 @@ private slots: | |||
218 | bool mouseUpOn; | 248 | bool mouseUpOn; |
219 | bool getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt); | 249 | linkType getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt); |
220 | bool m_twotouch, m_touchone; | 250 | bool m_twotouch, m_touchone; |
221 | size_t m_startpos, m_startoffset; | 251 | size_t m_startpos, m_startoffset; |
252 | void dopageup(unsigned int); | ||
222 | void dopageup(); | 253 | void dopageup(); |
@@ -231,4 +262,7 @@ private slots: | |||
231 | unsigned int numlines; | 262 | unsigned int numlines; |
232 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt; | 263 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace; |
233 | bool m_bpagemode, m_bMonoSpaced; | 264 | #ifdef REPALM |
265 | bool brepalm; | ||
266 | #endif | ||
267 | bool m_bpagemode, m_bMonoSpaced, m_continuousDocument; | ||
234 | unsigned char bindenter; | 268 | unsigned char bindenter; |
@@ -237,2 +271,6 @@ private slots: | |||
237 | public: | 271 | public: |
272 | bool bDoUpdates; | ||
273 | bool m_navkeys; | ||
274 | void NavUp(); | ||
275 | void NavDown(); | ||
238 | int getch() { return buffdoc.getch(); } | 276 | int getch() { return buffdoc.getch(); } |
@@ -243,8 +281,8 @@ private slots: | |||
243 | bool locate(unsigned long n); | 281 | bool locate(unsigned long n); |
244 | void jumpto(unsigned long n) { buffdoc.locate(n); } | 282 | void jumpto(unsigned long n) { buffdoc.unsuspend(); buffdoc.locate(n); } |
245 | unsigned long locate() { return buffdoc.locate(); } | 283 | unsigned long locate() { buffdoc.unsuspend(); return buffdoc.locate(); } |
246 | unsigned long explocate() { return buffdoc.explocate(); } | 284 | unsigned long explocate() { buffdoc.unsuspend(); return buffdoc.explocate(); } |
247 | unsigned long pagelocate() { return locnarray[0]; } | 285 | unsigned long pagelocate() { return locnarray[0]; } |
248 | unsigned long mylastpos; | 286 | unsigned long mylastpos; |
249 | void setfilter(CFilterChain *f) { buffdoc.setfilter(f); locate(pagelocate()); } | 287 | void setfilter(CFilterChain *f) { buffdoc.unsuspend(); buffdoc.setfilter(f); locate(pagelocate()); } |
250 | void restore() { jumpto(mylastpos); } | 288 | void restore() { jumpto(mylastpos); } |
@@ -258,3 +296,3 @@ private slots: | |||
258 | unsigned int screenlines(); | 296 | unsigned int screenlines(); |
259 | void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.sizes(fs,ts); } | 297 | void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.unsuspend(); buffdoc.sizes(fs,ts); } |
260 | static const char *fonts[]; | 298 | static const char *fonts[]; |
@@ -264,2 +302,3 @@ private slots: | |||
264 | QString firstword(); | 302 | QString firstword(); |
303 | void setstate(const statedata& sd); | ||
265 | 304 | ||
@@ -269,2 +308,3 @@ private slots: | |||
269 | void OnActionPressed(); | 308 | void OnActionPressed(); |
309 | void OnShowPicture(QPixmap&); | ||
270 | }; | 310 | }; |
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index 8726df7..2044b1d 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -1,3 +1,3 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. Allrights reserved. |
3 | ** | 3 | ** |
@@ -23,3 +23,6 @@ | |||
23 | #include <qpe/qpemenubar.h> | 23 | #include <qpe/qpemenubar.h> |
24 | #include <qpe/qpetoolbar.h> | 24 | //#include <qpe/qpetoolbar.h> |
25 | #include <qmenubar.h> | ||
26 | #include <qtoolbar.h> | ||
27 | #include <qpe/menubutton.h> | ||
25 | #include <qpe/fontdatabase.h> | 28 | #include <qpe/fontdatabase.h> |
@@ -44,2 +47,3 @@ | |||
44 | #include "QTReader.h" | 47 | #include "QTReader.h" |
48 | #include "GraphicWin.h" | ||
45 | #include "Bkmks.h" | 49 | #include "Bkmks.h" |
@@ -57,2 +61,12 @@ | |||
57 | #include "CDrawBuffer.h" | 61 | #include "CDrawBuffer.h" |
62 | #include "Filedata.h" | ||
63 | #include "opie.h" | ||
64 | #include "name.h" | ||
65 | #include "StateData.h" | ||
66 | |||
67 | #ifdef OPIE | ||
68 | #define PICDIR "opie-reader/" | ||
69 | #else | ||
70 | #define PICDIR | ||
71 | #endif | ||
58 | 72 | ||
@@ -70,5 +84,6 @@ void QTReaderApp::listBkmkFiles() | |||
70 | bkmkselector->clear(); | 84 | bkmkselector->clear(); |
85 | bkmkselector->setText("Cancel"); | ||
71 | int cnt = 0; | 86 | int cnt = 0; |
72 | DIR *d; | 87 | DIR *d; |
73 | d = opendir((const char *)Global::applicationFileName("uqtreader","")); | 88 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); |
74 | 89 | ||
@@ -76,12 +91,12 @@ void QTReaderApp::listBkmkFiles() | |||
76 | { | 91 | { |
77 | struct dirent* de; | 92 | struct dirent* de; |
78 | struct stat buf; | 93 | struct stat buf; |
79 | de = readdir(d); | 94 | de = readdir(d); |
80 | if (de == NULL) break; | 95 | if (de == NULL) break; |
81 | 96 | ||
82 | if (lstat((const char *)Global::applicationFileName("uqtreader",de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 97 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) |
83 | { | 98 | { |
84 | bkmkselector->insertItem(de->d_name); | 99 | bkmkselector->insertItem(de->d_name); |
85 | cnt++; | 100 | cnt++; |
86 | } | 101 | } |
87 | } | 102 | } |
@@ -95,5 +110,13 @@ void QTReaderApp::listBkmkFiles() | |||
95 | if (m_fontVisible) m_fontBar->hide(); | 110 | if (m_fontVisible) m_fontBar->hide(); |
96 | if (regVisible) regBar->hide(); | 111 | if (regVisible) |
97 | if (searchVisible) searchBar->hide(); | 112 | { |
98 | m_nRegAction = cRmBkmkFile; | 113 | Global::hideInputMethod(); |
114 | regBar->hide(); | ||
115 | } | ||
116 | if (searchVisible) | ||
117 | { | ||
118 | Global::hideInputMethod(); | ||
119 | searchBar->hide(); | ||
120 | } | ||
121 | m_nRegAction = cRmBkmkFile; | ||
99 | editorStack->raiseWidget( bkmkselector ); | 122 | editorStack->raiseWidget( bkmkselector ); |
@@ -101,3 +124,3 @@ void QTReaderApp::listBkmkFiles() | |||
101 | else | 124 | else |
102 | QMessageBox::information(this, "OpieReader", "No bookmark files"); | 125 | QMessageBox::information(this, PROGNAME, "No bookmark files"); |
103 | } | 126 | } |
@@ -111,5 +134,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
111 | pBkmklist = NULL; | 134 | pBkmklist = NULL; |
112 | doc = 0; | 135 | pOpenlist = NULL; |
136 | // doc = 0; | ||
113 | 137 | ||
114 | m_fBkmksChanged = false; | 138 | m_fBkmksChanged = false; |
115 | 139 | ||
@@ -117,8 +141,9 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
117 | 141 | ||
118 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; | 142 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; |
119 | setToolBarsMovable( FALSE ); | 143 | setToolBarsMovable( FALSE ); |
120 | 144 | ||
121 | setIcon( Resource::loadPixmap( "opie-reader/uqtreader" ) ); | 145 | setIcon( Resource::loadPixmap( "uqtreader" ) ); |
122 | 146 | ||
123 | QPEToolBar *bar = new QPEToolBar( this ); | 147 | // QPEToolBar *bar = new QPEToolBar( this ); |
148 | QToolBar *bar = new QToolBar( this ); | ||
124 | bar->setHorizontalStretchable( TRUE ); | 149 | bar->setHorizontalStretchable( TRUE ); |
@@ -128,2 +153,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
128 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 153 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
154 | // QMenuBar *mb = new QMenuBar( bar ); | ||
129 | QPopupMenu *file = new QPopupMenu( this ); | 155 | QPopupMenu *file = new QPopupMenu( this ); |
@@ -161,2 +187,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
161 | 187 | ||
188 | m_graphicwin = new GraphicWin(editorStack); | ||
189 | editorStack->addWidget(m_graphicwin, get_unique_id()); | ||
190 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); | ||
191 | |||
162 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); | 192 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); |
@@ -177,2 +207,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
177 | */ | 207 | */ |
208 | qDebug("Reading file list"); | ||
209 | readfilelist(); | ||
178 | 210 | ||
@@ -180,5 +212,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
180 | 212 | ||
213 | reader->bDoUpdates = false; | ||
214 | |||
181 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); | 215 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); |
182 | 216 | ||
183 | Config config( "uqtreader" ); | 217 | qDebug("Reading config"); |
218 | Config config( APPDIR ); | ||
184 | config.setGroup( "View" ); | 219 | config.setGroup( "View" ); |
@@ -191,2 +226,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
191 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 226 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
227 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | ||
192 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 228 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
@@ -200,2 +236,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
200 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 236 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
237 | reader->m_navkeys = config.readBoolEntry( "CursorNavigation", false ); | ||
201 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 238 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); |
@@ -205,4 +242,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
205 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 242 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
243 | #ifdef REPALM | ||
244 | reader->brepalm = config.readBoolEntry( "Repalm", true ); | ||
245 | #endif | ||
206 | reader->bremap = config.readBoolEntry( "Remap", true ); | 246 | reader->bremap = config.readBoolEntry( "Remap", true ); |
207 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | 247 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); |
248 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | ||
208 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 249 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
@@ -217,2 +258,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
217 | 258 | ||
259 | connect( reader, SIGNAL( OnShowPicture(QPixmap&) ), this, SLOT( showgraphic(QPixmap&) ) ); | ||
260 | |||
218 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); | 261 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); |
@@ -227,2 +270,7 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
227 | 270 | ||
271 | a = new QAction( tr( "Close" ), Resource::loadPixmap( "fileclose" ), QString::null, 0, this, 0 ); | ||
272 | connect( a, SIGNAL( activated() ), this, SLOT( fileClose() ) ); | ||
273 | // a->addTo( bar ); | ||
274 | a->addTo( file ); | ||
275 | |||
228 | /* | 276 | /* |
@@ -252,2 +300,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
252 | 300 | ||
301 | m_buttonAction[3] = new QAction( tr( "Fullscreen" ), QString::null, 0, ag, NULL, true ); | ||
302 | |||
253 | ag->addTo(spacemenu); | 303 | ag->addTo(spacemenu); |
@@ -256,10 +306,30 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
256 | 306 | ||
307 | file->insertSeparator(); | ||
308 | |||
309 | ag = new QActionGroup(this); | ||
310 | ag->setExclusive(false); | ||
311 | QPopupMenu *encoding = new QPopupMenu(this); | ||
312 | file->insertItem( tr( "Navigation" ), encoding ); | ||
313 | |||
314 | a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( PICDIR "panel-arrow-down" ), QString::null, 0, ag, 0, true ); | ||
257 | 315 | ||
258 | a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( "opie-reader/panel-arrow-down" ), QString::null, 0, this, 0, true ); | ||
259 | // connect( a, SIGNAL( activated() ), this, SLOT( autoScroll() ) ); | ||
260 | a->setOn(false); | 316 | a->setOn(false); |
261 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); | 317 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); |
262 | file->insertSeparator(); | ||
263 | a->addTo( bar ); | 318 | a->addTo( bar ); |
264 | a->addTo( file ); | 319 | |
320 | a = new QAction( tr( "Jump" ), QString::null, 0, ag, NULL); | ||
321 | connect( a, SIGNAL( activated() ), this, SLOT( jump() ) ); | ||
322 | |||
323 | a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, ag, NULL, true ); | ||
324 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); | ||
325 | a->setOn(reader->m_bpagemode); | ||
326 | |||
327 | a = new QAction( tr( "Set Overlap" ), QString::null, 0, ag, NULL); | ||
328 | connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) ); | ||
329 | |||
330 | a = new QAction( tr( "Use Cursor" ), QString::null, 0, ag, NULL, true ); | ||
331 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( navkeys(bool) ) ); | ||
332 | a->setOn(reader->m_navkeys); | ||
333 | |||
334 | ag->addTo(encoding); | ||
265 | 335 | ||
@@ -274,14 +344,2 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
274 | */ | 344 | */ |
275 | a = new QAction( tr( "Jump" ), QString::null, 0, this, NULL); | ||
276 | connect( a, SIGNAL( activated() ), this, SLOT( jump() ) ); | ||
277 | a->addTo( file ); | ||
278 | |||
279 | a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, this, NULL, true ); | ||
280 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); | ||
281 | a->setOn(reader->m_bpagemode); | ||
282 | a->addTo( file ); | ||
283 | |||
284 | a = new QAction( tr( "Set Overlap" ), QString::null, 0, this, NULL); | ||
285 | connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) ); | ||
286 | a->addTo( file ); | ||
287 | 345 | ||
@@ -300,3 +358,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
300 | ag->setExclusive(false); | 358 | ag->setExclusive(false); |
301 | QPopupMenu *encoding = new QPopupMenu(this); | 359 | encoding = new QPopupMenu(this); |
302 | file->insertItem( tr( "Target" ), encoding ); | 360 | file->insertItem( tr( "Target" ), encoding ); |
@@ -347,2 +405,13 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
347 | 405 | ||
406 | m_fullscreen = false; | ||
407 | a = m_actFullscreen = new QAction( tr( "Fullscreen" ), QString::null, 0, this, NULL, true ); | ||
408 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); | ||
409 | a->setOn(m_fullscreen); | ||
410 | a->addTo( file ); | ||
411 | |||
412 | a = new QAction( tr( "Continuous" ), QString::null, 0, ag, NULL, true ); | ||
413 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setcontinuous(bool) ) ); | ||
414 | a->setOn(reader->m_continuousDocument); | ||
415 | a->addTo( file ); | ||
416 | |||
348 | a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 417 | a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
@@ -397,2 +466,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
397 | 466 | ||
467 | a = new QAction( tr( "Single Space" ), QString::null, 0, ag, NULL, true ); | ||
468 | a->setOn(reader->bonespace); | ||
469 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( onespace(bool) ) ); | ||
470 | |||
398 | a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true ); | 471 | a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true ); |
@@ -418,3 +491,7 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
418 | connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) ); | 491 | connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) ); |
419 | 492 | #ifdef REPALM | |
493 | a = new QAction( tr( "Repalm" ), QString::null, 0, ag, NULL, true ); | ||
494 | a->setOn(reader->brepalm); | ||
495 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( repalm(bool) ) ); | ||
496 | #endif | ||
420 | a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true ); | 497 | a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true ); |
@@ -431,7 +508,11 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
431 | // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); | 508 | // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); |
432 | a = new QAction( tr( "Zoom" ), QString::null, 0, this); | ||
433 | connect( a, SIGNAL( activated() ), this, SLOT( TBDzoom() ) ); | ||
434 | format->insertSeparator(); | 509 | format->insertSeparator(); |
510 | a = new QAction( tr( "Zoom In" ), QString::null, 0, this); | ||
511 | connect( a, SIGNAL( activated() ), this, SLOT( zoomin() ) ); | ||
512 | a->addTo( format ); | ||
513 | a = new QAction( tr( "Zoom Out" ), QString::null, 0, this); | ||
514 | connect( a, SIGNAL( activated() ), this, SLOT( zoomout() ) ); | ||
435 | a->addTo( format ); | 515 | a->addTo( format ); |
436 | // a->addTo( editBar ); | 516 | // a->addTo( editBar ); |
517 | format->insertSeparator(); | ||
437 | 518 | ||
@@ -441,3 +522,2 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
441 | a->setOn(reader->m_bMonoSpaced); | 522 | a->setOn(reader->m_bMonoSpaced); |
442 | format->insertSeparator(); | ||
443 | a->addTo( format ); | 523 | a->addTo( format ); |
@@ -539,6 +619,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
539 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 619 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
540 | this, SLOT( search( const QString& ) ) ); | 620 | this, SLOT( search( const QString& ) ) ); |
541 | #else | 621 | #else |
542 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 622 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
543 | this, SLOT( search( ) ) ); | 623 | this, SLOT( search( ) ) ); |
544 | #endif | 624 | #endif |
@@ -565,3 +645,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
565 | connect( regEdit, SIGNAL( returnPressed( ) ), | 645 | connect( regEdit, SIGNAL( returnPressed( ) ), |
566 | this, SLOT( do_regaction() ) ); | 646 | this, SLOT( do_regaction() ) ); |
567 | 647 | ||
@@ -581,2 +661,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
581 | 661 | ||
662 | qDebug("Font selector"); | ||
582 | m_fontSelector = new QComboBox(false, m_fontBar); | 663 | m_fontSelector = new QComboBox(false, m_fontBar); |
@@ -584,16 +665,16 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
584 | { | 665 | { |
585 | FontDatabase f; | 666 | FontDatabase f; |
586 | QStringList flist = f.families(); | 667 | QStringList flist = f.families(); |
587 | m_fontSelector->insertStringList(flist); | 668 | m_fontSelector->insertStringList(flist); |
588 | 669 | ||
589 | bool realfont = false; | 670 | bool realfont = false; |
590 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 671 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
591 | { | 672 | { |
592 | if (reader->m_fontname == *nm) | 673 | if (reader->m_fontname == *nm) |
593 | { | 674 | { |
594 | realfont = true; | 675 | realfont = true; |
595 | break; | 676 | } |
596 | } | 677 | if (*nm == "courier") reader->m_fontControl.hasCourier(true); |
597 | } | 678 | } |
598 | if (!realfont) reader->m_fontname = flist[0]; | 679 | if (!realfont) reader->m_fontname = flist[0]; |
599 | } // delete the FontDatabase!!! | 680 | } // delete the FontDatabase!!! |
@@ -601,3 +682,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
601 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), | 682 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), |
602 | this, SLOT( do_setfont(const QString&) ) ); | 683 | this, SLOT( do_setfont(const QString&) ) ); |
603 | 684 | ||
@@ -607,15 +688,63 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
607 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), | 688 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), |
608 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); | 689 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); |
609 | |||
610 | 690 | ||
691 | qDebug("Initing"); | ||
611 | reader->init(); | 692 | reader->init(); |
612 | if (!reader->m_lastfile.isEmpty()) | 693 | qDebug("Inited"); |
613 | { | ||
614 | openFile( reader->m_lastfile ); | ||
615 | doc = new DocLnk(reader->m_lastfile); | ||
616 | } | ||
617 | m_EncodingAction[reader->m_encd]->setOn(true); | 694 | m_EncodingAction[reader->m_encd]->setOn(true); |
618 | m_buttonAction[m_spaceTarget]->setOn(true); | 695 | m_buttonAction[m_spaceTarget]->setOn(true); |
696 | qDebug("fonting"); | ||
619 | do_setfont(reader->m_fontname); | 697 | do_setfont(reader->m_fontname); |
620 | } | 698 | if (!reader->m_lastfile.isEmpty()) |
699 | { | ||
700 | qDebug("doclnk"); | ||
701 | //doc = new DocLnk(reader->m_lastfile); | ||
702 | qDebug("doclnk done"); | ||
703 | if (pOpenlist != NULL) | ||
704 | { | ||
705 | |||
706 | /* | ||
707 | int ind = 0; | ||
708 | Bkmk* p = (*pOpenlist)[ind]; | ||
709 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | ||
710 | { | ||
711 | p = (*pOpenlist)[++ind]; | ||
712 | } | ||
713 | */ | ||
714 | Bkmk* p = NULL; | ||
715 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | ||
716 | { | ||
717 | p = iter.pContent(); | ||
718 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) | ||
719 | { | ||
720 | break; | ||
721 | } | ||
722 | qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); | ||
723 | p = NULL; | ||
724 | } | ||
725 | if (p != NULL) | ||
726 | { | ||
727 | qDebug("openfrombkmk"); | ||
728 | openfrombkmk(p); | ||
729 | } | ||
730 | else | ||
731 | { | ||
732 | qDebug("openfile"); | ||
733 | openFile( reader->m_lastfile ); | ||
734 | } | ||
735 | } | ||
736 | else | ||
737 | { | ||
738 | qDebug("Openfile 2"); | ||
739 | if (!reader->m_lastfile.isNull()) | ||
740 | openFile( reader->m_lastfile ); | ||
741 | } | ||
742 | } | ||
743 | qApp->processEvents(); | ||
744 | reader->bDoUpdates = true; | ||
745 | reader->update(); | ||
746 | qDebug("finished update"); | ||
747 | } | ||
748 | |||
749 | void QTReaderApp::suspend() { reader->suspend(); } | ||
621 | 750 | ||
@@ -630,5 +759,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
630 | { | 759 | { |
631 | QString info; | 760 | QString info; |
632 | stream >> info; | 761 | stream >> info; |
633 | QMessageBox::information(this, "OpieReader", info); | 762 | QMessageBox::information(this, PROGNAME, info); |
634 | } | 763 | } |
@@ -636,5 +765,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
636 | { | 765 | { |
637 | QString info; | 766 | QString info; |
638 | stream >> info; | 767 | stream >> info; |
639 | QMessageBox::warning(this, "OpieReader", info); | 768 | QMessageBox::warning(this, PROGNAME, info); |
640 | } | 769 | } |
@@ -644,4 +773,4 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
644 | { | 773 | { |
645 | m_dontSave = true; | 774 | m_dontSave = true; |
646 | close(); | 775 | close(); |
647 | } | 776 | } |
@@ -649,3 +778,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
649 | { | 778 | { |
650 | reader->dopagedn(); | 779 | reader->dopagedn(); |
651 | } | 780 | } |
@@ -653,3 +782,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
653 | { | 782 | { |
654 | reader->dopageup(); | 783 | reader->dopageup(); |
655 | } | 784 | } |
@@ -657,3 +786,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
657 | { | 786 | { |
658 | reader->lineDown(); | 787 | reader->lineDown(); |
659 | } | 788 | } |
@@ -661,3 +790,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
661 | { | 790 | { |
662 | reader->lineUp(); | 791 | reader->lineUp(); |
663 | } | 792 | } |
@@ -665,3 +794,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
665 | { | 794 | { |
666 | showEditTools(); | 795 | showEditTools(); |
667 | } | 796 | } |
@@ -669,5 +798,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
669 | { | 798 | { |
670 | QString info; | 799 | QString info; |
671 | stream >> info; | 800 | stream >> info; |
672 | openFile( info ); | 801 | openFile( info ); |
673 | } | 802 | } |
@@ -675,3 +804,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
675 | { | 804 | { |
676 | showinfo(); | 805 | showinfo(); |
677 | } | 806 | } |
@@ -679,3 +808,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
679 | { | 808 | { |
680 | editMark(); | 809 | editMark(); |
681 | } | 810 | } |
@@ -683,3 +812,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
683 | { | 812 | { |
684 | editCopy(); | 813 | editCopy(); |
685 | } | 814 | } |
@@ -687,5 +816,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
687 | { | 816 | { |
688 | int info; | 817 | int info; |
689 | stream >> info; | 818 | stream >> info; |
690 | autoScroll(info); | 819 | autoScroll(info); |
691 | } | 820 | } |
@@ -693,5 +822,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
693 | { | 822 | { |
694 | int info; | 823 | int info; |
695 | stream >> info; | 824 | stream >> info; |
696 | reader->locate(info); | 825 | reader->locate(info); |
697 | } | 826 | } |
@@ -699,5 +828,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
699 | { | 828 | { |
700 | int info; | 829 | int info; |
701 | stream >> info; | 830 | stream >> info; |
702 | pagemode(info); | 831 | pagemode(info); |
703 | } | 832 | } |
@@ -705,5 +834,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
705 | { | 834 | { |
706 | int info; | 835 | int info; |
707 | stream >> info; | 836 | stream >> info; |
708 | reader->m_overlap = info; | 837 | reader->m_overlap = info; |
709 | } | 838 | } |
@@ -711,5 +840,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
711 | { | 840 | { |
712 | QString info; | 841 | QString info; |
713 | stream >> info; | 842 | stream >> info; |
714 | do_settarget(info); | 843 | do_settarget(info); |
715 | } | 844 | } |
@@ -717,5 +846,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
717 | { | 846 | { |
718 | int info; | 847 | int info; |
719 | stream >> info; | 848 | stream >> info; |
720 | setTwoTouch(info); | 849 | setTwoTouch(info); |
721 | } | 850 | } |
@@ -723,5 +852,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
723 | { | 852 | { |
724 | int info; | 853 | int info; |
725 | stream >> info; | 854 | stream >> info; |
726 | OnAnnotation(info); | 855 | OnAnnotation(info); |
727 | } | 856 | } |
@@ -729,5 +858,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
729 | { | 858 | { |
730 | int info; | 859 | int info; |
731 | stream >> info; | 860 | stream >> info; |
732 | OnDictionary(info); | 861 | OnDictionary(info); |
733 | } | 862 | } |
@@ -735,5 +864,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
735 | { | 864 | { |
736 | int info; | 865 | int info; |
737 | stream >> info; | 866 | stream >> info; |
738 | OnClipboard(info); | 867 | OnClipboard(info); |
739 | } | 868 | } |
@@ -741,20 +870,20 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
741 | { | 870 | { |
742 | QString info; | 871 | QString info; |
743 | stream >> info; | 872 | stream >> info; |
744 | QRegExp arg(info); | 873 | QRegExp arg(info); |
745 | size_t pos = reader->pagelocate(); | 874 | size_t pos = reader->pagelocate(); |
746 | size_t start = pos; | 875 | size_t start = pos; |
747 | CDrawBuffer test(&(reader->m_fontControl)); | 876 | CDrawBuffer test(&(reader->m_fontControl)); |
748 | reader->buffdoc.getline(&test,reader->width()); | 877 | reader->buffdoc.getline(&test,reader->width()); |
749 | while (arg.match(toQString(test.data())) == -1) | 878 | while (arg.match(toQString(test.data())) == -1) |
750 | { | 879 | { |
751 | pos = reader->locate(); | 880 | pos = reader->locate(); |
752 | if (!reader->buffdoc.getline(&test,reader->width())) | 881 | if (!reader->buffdoc.getline(&test,reader->width())) |
753 | { | 882 | { |
754 | QMessageBox::information(this, "OpieReader", QString("Can't find\n")+info); | 883 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); |
755 | pos = start; | 884 | pos = start; |
756 | break; | 885 | break; |
757 | } | 886 | } |
758 | } | 887 | } |
759 | reader->locate(pos); | 888 | reader->locate(pos); |
760 | } | 889 | } |
@@ -762,11 +891,25 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
762 | { | 891 | { |
763 | int info; | 892 | int info; |
764 | stream >> info; | 893 | stream >> info; |
765 | stripcr(info); | 894 | stripcr(info); |
895 | } | ||
896 | else if ( msg == "Layout/Single Space" ) | ||
897 | { | ||
898 | int info; | ||
899 | stream >> info; | ||
900 | onespace(info); | ||
901 | } | ||
902 | #ifdef REPALM | ||
903 | else if ( msg == "Layout/Repalm(int)" ) | ||
904 | { | ||
905 | int info; | ||
906 | stream >> info; | ||
907 | repalm(info); | ||
766 | } | 908 | } |
909 | #endif | ||
767 | else if ( msg == "Markup/Auto(int)" ) | 910 | else if ( msg == "Markup/Auto(int)" ) |
768 | { | 911 | { |
769 | int info; | 912 | int info; |
770 | stream >> info; | 913 | stream >> info; |
771 | autofmt(info); | 914 | autofmt(info); |
772 | } | 915 | } |
@@ -774,5 +917,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
774 | { | 917 | { |
775 | int info; | 918 | int info; |
776 | stream >> info; | 919 | stream >> info; |
777 | textfmt(info); | 920 | textfmt(info); |
778 | } | 921 | } |
@@ -780,5 +923,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
780 | { | 923 | { |
781 | int info; | 924 | int info; |
782 | stream >> info; | 925 | stream >> info; |
783 | striphtml(info); | 926 | striphtml(info); |
784 | } | 927 | } |
@@ -786,5 +929,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
786 | { | 929 | { |
787 | int info; | 930 | int info; |
788 | stream >> info; | 931 | stream >> info; |
789 | peanut(info); | 932 | peanut(info); |
790 | } | 933 | } |
@@ -792,5 +935,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
792 | { | 935 | { |
793 | int info; | 936 | int info; |
794 | stream >> info; | 937 | stream >> info; |
795 | dehyphen(info); | 938 | dehyphen(info); |
796 | } | 939 | } |
@@ -798,5 +941,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
798 | { | 941 | { |
799 | int info; | 942 | int info; |
800 | stream >> info; | 943 | stream >> info; |
801 | unindent(info); | 944 | unindent(info); |
802 | } | 945 | } |
@@ -804,5 +947,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
804 | { | 947 | { |
805 | int info; | 948 | int info; |
806 | stream >> info; | 949 | stream >> info; |
807 | repara(info); | 950 | repara(info); |
808 | } | 951 | } |
@@ -810,5 +953,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
810 | { | 953 | { |
811 | int info; | 954 | int info; |
812 | stream >> info; | 955 | stream >> info; |
813 | dblspce(info); | 956 | dblspce(info); |
814 | } | 957 | } |
@@ -816,6 +959,6 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
816 | { | 959 | { |
817 | int info; | 960 | int info; |
818 | stream >> info; | 961 | stream >> info; |
819 | reader->bindenter = info; | 962 | reader->bindenter = info; |
820 | reader->setfilter(reader->getfilter()); | 963 | reader->setfilter(reader->getfilter()); |
821 | } | 964 | } |
@@ -823,5 +966,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
823 | { | 966 | { |
824 | int info; | 967 | int info; |
825 | stream >> info; | 968 | stream >> info; |
826 | remap(info); | 969 | remap(info); |
827 | } | 970 | } |
@@ -829,5 +972,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
829 | { | 972 | { |
830 | int info; | 973 | int info; |
831 | stream >> info; | 974 | stream >> info; |
832 | embolden(info); | 975 | embolden(info); |
833 | } | 976 | } |
@@ -835,5 +978,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
835 | { | 978 | { |
836 | int info; | 979 | int info; |
837 | stream >> info; | 980 | stream >> info; |
838 | monospace(info); | 981 | monospace(info); |
839 | } | 982 | } |
@@ -841,7 +984,7 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
841 | { | 984 | { |
842 | int info; | 985 | int info; |
843 | stream >> info; | 986 | stream >> info; |
844 | reader->m_charpc = info; | 987 | reader->m_charpc = info; |
845 | reader->setfont(); | 988 | reader->setfont(); |
846 | reader->refresh(); | 989 | reader->refresh(); |
847 | } | 990 | } |
@@ -849,5 +992,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
849 | { | 992 | { |
850 | QString info; | 993 | QString info; |
851 | stream >> info; | 994 | stream >> info; |
852 | reader->setencoding(EncNameToInt(info)); | 995 | reader->setencoding(EncNameToInt(info)); |
853 | } | 996 | } |
@@ -855,7 +998,7 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
855 | { | 998 | { |
856 | QString fontname; | 999 | QString fontname; |
857 | int size; | 1000 | int size; |
858 | stream >> fontname; | 1001 | stream >> fontname; |
859 | stream >> size; | 1002 | stream >> size; |
860 | setfontHelper(fontname, size); | 1003 | setfontHelper(fontname, size); |
861 | } | 1004 | } |
@@ -863,5 +1006,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
863 | { | 1006 | { |
864 | QString info; | 1007 | QString info; |
865 | stream >> info; | 1008 | stream >> info; |
866 | do_autogen(info); | 1009 | do_autogen(info); |
867 | } | 1010 | } |
@@ -873,3 +1016,3 @@ ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) | |||
873 | { | 1016 | { |
874 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; | 1017 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; |
875 | } | 1018 | } |
@@ -878,2 +1021,18 @@ ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) | |||
878 | 1021 | ||
1022 | void QTReaderApp::setfullscreen(bool sfs) | ||
1023 | { | ||
1024 | reader->bDoUpdates = false; | ||
1025 | m_fullscreen = sfs; | ||
1026 | showEditTools(); | ||
1027 | qApp->processEvents(); | ||
1028 | reader->bDoUpdates = true; | ||
1029 | reader->update(); | ||
1030 | } | ||
1031 | |||
1032 | void QTReaderApp::setcontinuous(bool sfs) | ||
1033 | { | ||
1034 | reader->setContinuous(sfs); | ||
1035 | reader->refresh(); | ||
1036 | } | ||
1037 | |||
879 | int QTReaderApp::EncNameToInt(const QString& _enc) | 1038 | int QTReaderApp::EncNameToInt(const QString& _enc) |
@@ -882,3 +1041,3 @@ int QTReaderApp::EncNameToInt(const QString& _enc) | |||
882 | { | 1041 | { |
883 | if (m_EncodingAction[i]->text() == _enc) return i; | 1042 | if (m_EncodingAction[i]->text() == _enc) return i; |
884 | } | 1043 | } |
@@ -912,12 +1071,13 @@ void QTReaderApp::autoScroll(bool _b) | |||
912 | reader->setautoscroll(_b); | 1071 | reader->setautoscroll(_b); |
1072 | setScrollState(reader->m_autoScroll); | ||
913 | } | 1073 | } |
914 | 1074 | ||
915 | void QTReaderApp::TBD() | 1075 | void QTReaderApp::zoomin() |
916 | { | 1076 | { |
917 | QMessageBox::information(this, "OpieReader", "Not yet implemented", 1); | 1077 | reader->zoomin(); |
918 | } | 1078 | } |
919 | 1079 | ||
920 | void QTReaderApp::TBDzoom() | 1080 | void QTReaderApp::zoomout() |
921 | { | 1081 | { |
922 | QMessageBox::information(this, "OpieReader", "Zooming is done interactively\nTry left/right cursor keys", 1); | 1082 | reader->zoomout(); |
923 | } | 1083 | } |
@@ -926,5 +1086,77 @@ void QTReaderApp::clearBkmkList() | |||
926 | { | 1086 | { |
927 | delete pBkmklist; | 1087 | delete pBkmklist; |
928 | pBkmklist = NULL; | 1088 | pBkmklist = NULL; |
929 | m_fBkmksChanged = false; | 1089 | m_fBkmksChanged = false; |
1090 | } | ||
1091 | |||
1092 | void QTReaderApp::fileClose() | ||
1093 | { | ||
1094 | if (pOpenlist != NULL) | ||
1095 | { | ||
1096 | int ind = 0; | ||
1097 | Bkmk* p = (*pOpenlist)[ind]; | ||
1098 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | ||
1099 | { | ||
1100 | p = (*pOpenlist)[++ind]; | ||
1101 | } | ||
1102 | if (p != NULL) pOpenlist->erase(ind); | ||
1103 | switch (QMessageBox::information ( this , PROGNAME, "What do you want to delete?", "Nothing", "Marks", "Marks\nFile", 1, 0 )) | ||
1104 | { | ||
1105 | case 0: | ||
1106 | default: | ||
1107 | break; | ||
1108 | case 2: | ||
1109 | unlink((const char*)reader->m_lastfile); | ||
1110 | case 1: | ||
1111 | unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string)); | ||
1112 | } | ||
1113 | } | ||
1114 | |||
1115 | fileOpen2(); | ||
1116 | } | ||
1117 | |||
1118 | void QTReaderApp::updatefileinfo() | ||
1119 | { | ||
1120 | if (reader->m_string.isNull()) return; | ||
1121 | if (reader->m_lastfile.isNull()) return; | ||
1122 | tchar* nm = fromQString(reader->m_string); | ||
1123 | tchar* fl = fromQString(reader->m_lastfile); | ||
1124 | qDebug("Lastfile:%x", fl); | ||
1125 | bool notadded = true; | ||
1126 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; | ||
1127 | else | ||
1128 | { | ||
1129 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | ||
1130 | { | ||
1131 | if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) | ||
1132 | { | ||
1133 | iter->value(reader->pagelocate()); | ||
1134 | unsigned short dlen; | ||
1135 | unsigned char* data; | ||
1136 | CFiledata fd(iter->anno()); | ||
1137 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | ||
1138 | qDebug("Filedata(1):%u, %u", fd.length(), dlen); | ||
1139 | // getstate(data, dlen); | ||
1140 | iter->setAnno(data, dlen); | ||
1141 | notadded = false; | ||
1142 | delete [] data; | ||
1143 | break; | ||
1144 | } | ||
1145 | } | ||
1146 | } | ||
1147 | qDebug("Added?:%x", notadded); | ||
1148 | if (notadded) | ||
1149 | { | ||
1150 | struct stat fnstat; | ||
1151 | stat((const char *)reader->m_lastfile, &fnstat); | ||
1152 | CFiledata fd(fnstat.st_mtime, fl); | ||
1153 | unsigned short dlen; | ||
1154 | unsigned char* data; | ||
1155 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | ||
1156 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); | ||
1157 | qDebug("Filedata(2):%u, %u", fd.length(), dlen); | ||
1158 | delete [] data; | ||
1159 | } | ||
1160 | delete [] nm; | ||
1161 | delete [] fl; | ||
930 | } | 1162 | } |
@@ -939,12 +1171,20 @@ void QTReaderApp::fileOpen() | |||
939 | */ | 1171 | */ |
1172 | qDebug("fileOpen"); | ||
1173 | // if (!reader->m_lastfile.isEmpty()) | ||
1174 | updatefileinfo(); | ||
1175 | fileOpen2(); | ||
1176 | } | ||
1177 | |||
1178 | void QTReaderApp::fileOpen2() | ||
1179 | { | ||
940 | if (pBkmklist != NULL) | 1180 | if (pBkmklist != NULL) |
941 | { | 1181 | { |
942 | if (m_fBkmksChanged) | 1182 | if (m_fBkmksChanged) |
943 | { | 1183 | { |
944 | if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0) | 1184 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
945 | savebkmks(); | 1185 | savebkmks(); |
946 | } | 1186 | } |
947 | delete pBkmklist; | 1187 | delete pBkmklist; |
948 | pBkmklist = NULL; | 1188 | pBkmklist = NULL; |
949 | m_fBkmksChanged = false; | 1189 | m_fBkmksChanged = false; |
950 | } | 1190 | } |
@@ -955,15 +1195,41 @@ void QTReaderApp::fileOpen() | |||
955 | */ | 1195 | */ |
956 | fileBrowser* fb = new fileBrowser(this,"OpieReader",TRUE, | 1196 | if (pOpenlist != NULL) |
957 | 0, | 1197 | { |
958 | // WStyle_Customize | WStyle_NoBorderEx, | 1198 | m_nRegAction = cOpenFile; |
959 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); | 1199 | listbkmk(pOpenlist, "Browse"); |
1200 | } | ||
1201 | else | ||
1202 | { | ||
1203 | QString fn = usefilebrowser(); | ||
1204 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | ||
1205 | { | ||
1206 | openFile(fn); | ||
1207 | } | ||
1208 | reader->setFocus(); | ||
1209 | } | ||
1210 | } | ||
1211 | |||
1212 | QString QTReaderApp::usefilebrowser() | ||
1213 | { | ||
1214 | fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE, | ||
1215 | 0, | ||
1216 | // WStyle_Customize | WStyle_NoBorderEx, | ||
1217 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); | ||
960 | 1218 | ||
1219 | |||
1220 | QString fn; | ||
961 | if (fb->exec()) | 1221 | if (fb->exec()) |
962 | { | 1222 | { |
963 | QString fn(fb->fileList[0]); | 1223 | fn = fb->fileList[0]; |
964 | // fb->populateList(); | ||
965 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); | ||
966 | } | 1224 | } |
1225 | qDebug("Selected %s", (const char*)fn); | ||
967 | delete fb; | 1226 | delete fb; |
968 | reader->setFocus(); | 1227 | return fn; |
1228 | } | ||
1229 | |||
1230 | void QTReaderApp::showgraphic(QPixmap& pm) | ||
1231 | { | ||
1232 | m_graphicwin->setPixmap(pm); | ||
1233 | editorStack->raiseWidget( m_graphicwin ); | ||
1234 | m_graphicwin->setFocus(); | ||
969 | } | 1235 | } |
@@ -975,3 +1241,3 @@ void QTReaderApp::showinfo() | |||
975 | { | 1241 | { |
976 | QMessageBox::information(this, "OpieReader", "No file loaded", 1); | 1242 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
977 | } | 1243 | } |
@@ -979,11 +1245,11 @@ void QTReaderApp::showinfo() | |||
979 | { | 1245 | { |
980 | reader->sizes(fs,ts); | 1246 | reader->sizes(fs,ts); |
981 | pl = reader->pagelocate(); | 1247 | pl = reader->pagelocate(); |
982 | m_infoWin->setFileSize(fs); | 1248 | m_infoWin->setFileSize(fs); |
983 | m_infoWin->setTextSize(ts); | 1249 | m_infoWin->setTextSize(ts); |
984 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); | 1250 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); |
985 | m_infoWin->setLocation(pl); | 1251 | m_infoWin->setLocation(pl); |
986 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); | 1252 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); |
987 | editorStack->raiseWidget( m_infoWin ); | 1253 | editorStack->raiseWidget( m_infoWin ); |
988 | m_infoWin->setFocus(); | 1254 | m_infoWin->setFocus(); |
989 | } | 1255 | } |
@@ -999,3 +1265,3 @@ void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) | |||
999 | { | 1265 | { |
1000 | buff[i] = name[i].unicode(); | 1266 | buff[i] = name[i].unicode(); |
1001 | } | 1267 | } |
@@ -1005,3 +1271,3 @@ void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) | |||
1005 | { | 1271 | { |
1006 | buff2[i] = text[i].unicode(); | 1272 | buff2[i] = text[i].unicode(); |
1007 | } | 1273 | } |
@@ -1020,11 +1286,11 @@ void QTReaderApp::addAnno(const QString& name, const QString& text) | |||
1020 | { | 1286 | { |
1021 | if (name.isEmpty()) | 1287 | if (name.isEmpty()) |
1022 | { | 1288 | { |
1023 | QMessageBox::information(this, "OpieReader", "Need a name for the bookmark\nPlease try again", 1); | 1289 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); |
1024 | } | 1290 | } |
1025 | else | 1291 | else |
1026 | { | 1292 | { |
1027 | addAnno(name, text, m_annoWin->getPosn()); | 1293 | addAnno(name, text, m_annoWin->getPosn()); |
1028 | } | 1294 | } |
1029 | showEditTools(); | 1295 | showEditTools(); |
1030 | } | 1296 | } |
@@ -1032,24 +1298,24 @@ void QTReaderApp::addAnno(const QString& name, const QString& text) | |||
1032 | { | 1298 | { |
1033 | if (m_annoWin->edited()) | 1299 | if (m_annoWin->edited()) |
1034 | { | 1300 | { |
1035 | CBuffer buff(text.length()+1); | 1301 | CBuffer buff(text.length()+1); |
1036 | int i; | 1302 | int i; |
1037 | for (i = 0; i < text.length(); i++) | 1303 | for (i = 0; i < text.length(); i++) |
1038 | { | 1304 | { |
1039 | buff[i] = text[i].unicode(); | 1305 | buff[i] = text[i].unicode(); |
1040 | } | 1306 | } |
1041 | buff[i] = 0; | 1307 | buff[i] = 0; |
1042 | m_fBkmksChanged = true; | 1308 | m_fBkmksChanged = true; |
1043 | m_anno->setAnno(buff.data()); | 1309 | m_anno->setAnno(buff.data()); |
1044 | } | 1310 | } |
1045 | bool found = findNextBookmark(m_anno->value()+1); | 1311 | bool found = findNextBookmark(m_anno->value()+1); |
1046 | if (found) | 1312 | if (found) |
1047 | { | 1313 | { |
1048 | m_annoWin->setName(toQString(m_anno->name())); | 1314 | m_annoWin->setName(toQString(m_anno->name())); |
1049 | m_annoWin->setAnno(toQString(m_anno->anno())); | 1315 | m_annoWin->setAnno(toQString(m_anno->anno())); |
1050 | } | 1316 | } |
1051 | else | 1317 | else |
1052 | { | 1318 | { |
1053 | showEditTools(); | 1319 | showEditTools(); |
1054 | } | 1320 | } |
1055 | } | 1321 | } |
@@ -1062,11 +1328,11 @@ bool QTReaderApp::findNextBookmark(size_t start) | |||
1062 | { | 1328 | { |
1063 | if (iter->value() >= start) | 1329 | if (iter->value() >= start) |
1064 | { | 1330 | { |
1065 | if (iter->value() < reader->locate()) | 1331 | if (iter->value() < reader->locate()) |
1066 | { | 1332 | { |
1067 | found = true; | 1333 | found = true; |
1068 | m_anno = iter.pContent(); | 1334 | m_anno = iter.pContent(); |
1069 | } | 1335 | } |
1070 | break; | 1336 | break; |
1071 | } | 1337 | } |
1072 | } | 1338 | } |
@@ -1079,3 +1345,3 @@ void QTReaderApp::addanno() | |||
1079 | { | 1345 | { |
1080 | QMessageBox::information(this, "OpieReader", "No file loaded", 1); | 1346 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
1081 | } | 1347 | } |
@@ -1083,8 +1349,9 @@ void QTReaderApp::addanno() | |||
1083 | { | 1349 | { |
1084 | m_annoWin->setName(""); | 1350 | m_annoWin->setName(""); |
1085 | m_annoWin->setAnno(""); | 1351 | m_annoWin->setAnno(""); |
1086 | m_annoWin->setPosn(reader->pagelocate()); | 1352 | m_annoWin->setPosn(reader->pagelocate()); |
1087 | m_annoIsEditing = true; | 1353 | m_annoIsEditing = true; |
1088 | editorStack->raiseWidget( m_annoWin ); | 1354 | editorStack->raiseWidget( m_annoWin ); |
1089 | m_annoWin->setFocus(); | 1355 | Global::showInputMethod(); |
1356 | m_annoWin->setFocus(); | ||
1090 | } | 1357 | } |
@@ -1118,14 +1385,14 @@ void QTReaderApp::editCopy() | |||
1118 | { | 1385 | { |
1119 | QClipboard* cb = QApplication::clipboard(); | 1386 | QClipboard* cb = QApplication::clipboard(); |
1120 | QString text; | 1387 | QString text; |
1121 | int ch; | 1388 | int ch; |
1122 | unsigned long currentpos = reader->pagelocate(); | 1389 | unsigned long currentpos = reader->pagelocate(); |
1123 | unsigned long endpos = reader->locate(); | 1390 | unsigned long endpos = reader->locate(); |
1124 | reader->jumpto(m_savedpos); | 1391 | reader->jumpto(m_savedpos); |
1125 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) | 1392 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) |
1126 | { | 1393 | { |
1127 | text += ch; | 1394 | text += ch; |
1128 | } | 1395 | } |
1129 | cb->setText(text); | 1396 | cb->setText(text); |
1130 | reader->locate(currentpos); | 1397 | reader->locate(currentpos); |
1131 | } | 1398 | } |
@@ -1134,3 +1401,3 @@ void QTReaderApp::pageup() | |||
1134 | { | 1401 | { |
1135 | reader->goUp(); | 1402 | reader->NavUp(); |
1136 | } | 1403 | } |
@@ -1139,3 +1406,3 @@ void QTReaderApp::pagedn() | |||
1139 | { | 1406 | { |
1140 | reader->goDown(); | 1407 | reader->NavDown(); |
1141 | } | 1408 | } |
@@ -1146,2 +1413,12 @@ void QTReaderApp::stripcr(bool _b) | |||
1146 | } | 1413 | } |
1414 | void QTReaderApp::onespace(bool _b) | ||
1415 | { | ||
1416 | reader->setonespace(_b); | ||
1417 | } | ||
1418 | #ifdef REPALM | ||
1419 | void QTReaderApp::repalm(bool _b) | ||
1420 | { | ||
1421 | reader->setrepalm(_b); | ||
1422 | } | ||
1423 | #endif | ||
1147 | void QTReaderApp::remap(bool _b) | 1424 | void QTReaderApp::remap(bool _b) |
@@ -1190,3 +1467,6 @@ void QTReaderApp::pagemode(bool _b) | |||
1190 | } | 1467 | } |
1191 | 1468 | void QTReaderApp::navkeys(bool _b) | |
1469 | { | ||
1470 | reader->m_navkeys = _b; | ||
1471 | } | ||
1192 | void QTReaderApp::monospace(bool _b) | 1472 | void QTReaderApp::monospace(bool _b) |
@@ -1218,4 +1498,4 @@ void QTReaderApp::settarget() | |||
1218 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) | 1498 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) |
1219 | + "/" | 1499 | + "/" |
1220 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); | 1500 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); |
1221 | regEdit->setText(text); | 1501 | regEdit->setText(text); |
@@ -1230,6 +1510,6 @@ void QTReaderApp::do_overlap(const QString& lcn) | |||
1230 | { | 1510 | { |
1231 | reader->m_overlap = ulcn; | 1511 | reader->m_overlap = ulcn; |
1232 | } | 1512 | } |
1233 | else | 1513 | else |
1234 | QMessageBox::information(this, "OpieReader", "Must be a number"); | 1514 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
1235 | } | 1515 | } |
@@ -1242,9 +1522,9 @@ void QTReaderApp::do_mono(const QString& lcn) | |||
1242 | { | 1522 | { |
1243 | reader->m_charpc = ulcn; | 1523 | reader->m_charpc = ulcn; |
1244 | reader->setfont(); | 1524 | reader->setfont(); |
1245 | reader->refresh(); | 1525 | reader->refresh(); |
1246 | // reader->setmono(true); | 1526 | //reader->setmono(true); |
1247 | } | 1527 | } |
1248 | else | 1528 | else |
1249 | QMessageBox::information(this, "OpieReader", "Must be a number"); | 1529 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
1250 | } | 1530 | } |
@@ -1266,2 +1546,3 @@ void QTReaderApp::editFind() | |||
1266 | #endif | 1546 | #endif |
1547 | Global::showInputMethod(); | ||
1267 | searchBar->show(); | 1548 | searchBar->show(); |
@@ -1293,2 +1574,3 @@ void QTReaderApp::findClose() | |||
1293 | searchEdit->setText(""); | 1574 | searchEdit->setText(""); |
1575 | Global::hideInputMethod(); | ||
1294 | searchBar->hide(); | 1576 | searchBar->hide(); |
@@ -1310,2 +1592,3 @@ void QTReaderApp::regClose() | |||
1310 | regBar->hide(); | 1592 | regBar->hide(); |
1593 | Global::hideInputMethod(); | ||
1311 | reader->setFocus(); | 1594 | reader->setFocus(); |
@@ -1320,4 +1603,13 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | |||
1320 | bool ret = true; | 1603 | bool ret = true; |
1604 | unsigned long fs, ts; | ||
1605 | reader->sizes(fs,ts); | ||
1321 | size_t pos = reader->locate(); | 1606 | size_t pos = reader->locate(); |
1322 | reader->buffdoc.getline(&test,reader->width()); | 1607 | reader->buffdoc.getline(&test,reader->width()); |
1608 | pbar->show(); | ||
1609 | pbar->resize(width(), editBar->height()); | ||
1610 | pbar->reset(); | ||
1611 | int lastpc = (100*pos)/ts; | ||
1612 | pbar->setProgress(lastpc); | ||
1613 | qApp->processEvents(); | ||
1614 | reader->setFocus(); | ||
1323 | #ifdef __ISEARCH | 1615 | #ifdef __ISEARCH |
@@ -1333,13 +1625,24 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | |||
1333 | pos = reader->locate(); | 1625 | pos = reader->locate(); |
1626 | unsigned int lcn = reader->locate(); | ||
1627 | int pc = (100*pos)/ts; | ||
1628 | if (pc != lastpc) | ||
1629 | { | ||
1630 | pbar->setProgress(pc); | ||
1631 | qApp->processEvents(); | ||
1632 | reader->setFocus(); | ||
1633 | lastpc = pc; | ||
1634 | } | ||
1635 | |||
1334 | if (!reader->buffdoc.getline(&test,reader->width())) | 1636 | if (!reader->buffdoc.getline(&test,reader->width())) |
1335 | { | 1637 | { |
1336 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 1638 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
1337 | pos = searchStart; | 1639 | pos = searchStart; |
1338 | else | 1640 | else |
1339 | pos = start; | 1641 | pos = start; |
1340 | ret = false; | 1642 | ret = false; |
1341 | findClose(); | 1643 | findClose(); |
1342 | break; | 1644 | break; |
1343 | } | 1645 | } |
1344 | } | 1646 | } |
1647 | pbar->hide(); | ||
1345 | reader->locate(pos); | 1648 | reader->locate(pos); |
@@ -1390,10 +1693,11 @@ void QTReaderApp::openFile( const QString &f ) | |||
1390 | { | 1693 | { |
1391 | openFile(DocLnk(f)); | 1694 | qDebug("File:%s", (const char*)f); |
1392 | } | 1695 | // openFile(DocLnk(f)); |
1393 | 1696 | //} | |
1394 | void QTReaderApp::openFile( const DocLnk &f ) | 1697 | // |
1395 | { | 1698 | //void QTReaderApp::openFile( const DocLnk &f ) |
1699 | //{ | ||
1396 | clear(); | 1700 | clear(); |
1397 | FileManager fm; | 1701 | QFileInfo fm(f); |
1398 | if ( fm.exists( f ) ) | 1702 | if ( fm.exists() ) |
1399 | { | 1703 | { |
@@ -1401,17 +1705,14 @@ void QTReaderApp::openFile( const DocLnk &f ) | |||
1401 | 1705 | ||
1402 | clear(); | 1706 | if (fm.extension( FALSE ) == "desktop") |
1707 | { | ||
1708 | DocLnk d(f); | ||
1709 | QFileInfo fnew(d.file()); | ||
1710 | fm = fnew; | ||
1711 | if (!fm.exists()) return; | ||
1712 | } | ||
1403 | 1713 | ||
1404 | // editorStack->raiseWidget( reader ); | 1714 | clear(); |
1405 | |||
1406 | // reader->setFocus(); | ||
1407 | |||
1408 | // QMessageBox::information(0, "DocLnk", "Begin"); | ||
1409 | doc = new DocLnk(f); | ||
1410 | // QMessageBox::information(0, "DocLnk done", doc->file()); | ||
1411 | // QMessageBox::information(0, "Progress", "Calling setText()"); | ||
1412 | // QMessageBox::information(0, "Progress", "Textset"); | ||
1413 | 1715 | ||
1414 | // updateCaption(); | 1716 | reader->setText(fm.baseName(), fm.absFilePath()); |
1415 | showEditTools(); | 1717 | showEditTools(); |
1416 | reader->setText(doc->name(), doc->file()); | ||
1417 | readbkmks(); | 1718 | readbkmks(); |
@@ -1420,5 +1721,47 @@ void QTReaderApp::openFile( const DocLnk &f ) | |||
1420 | { | 1721 | { |
1421 | QMessageBox::information(this, "OpieReader", "File does not exist"); | 1722 | QMessageBox::information(this, PROGNAME, "File does not exist"); |
1723 | } | ||
1724 | |||
1725 | } | ||
1726 | /* | ||
1727 | void QTReaderApp::resizeEvent(QResizeEvent* e) | ||
1728 | { | ||
1729 | if (m_fullscreen) | ||
1730 | { | ||
1731 | showNormal(); | ||
1732 | showFullScreen(); | ||
1733 | } | ||
1734 | } | ||
1735 | */ | ||
1736 | void QTReaderApp::keyPressEvent(QKeyEvent* e) | ||
1737 | { | ||
1738 | if (m_fullscreen) | ||
1739 | { | ||
1740 | switch(e->key()) | ||
1741 | { | ||
1742 | case Key_Escape: | ||
1743 | m_actFullscreen->setOn(false); | ||
1744 | if (m_fullscreen) | ||
1745 | { | ||
1746 | qDebug("Fullscreen already set - remove this!"); | ||
1747 | } | ||
1748 | else | ||
1749 | { | ||
1750 | m_fullscreen = false; | ||
1751 | reader->bDoUpdates = false; | ||
1752 | showEditTools(); | ||
1753 | qApp->processEvents(); | ||
1754 | reader->bDoUpdates = true; | ||
1755 | reader->update(); | ||
1756 | } | ||
1757 | e->accept(); | ||
1758 | break; | ||
1759 | default: | ||
1760 | e->ignore(); | ||
1761 | } | ||
1762 | } | ||
1763 | else | ||
1764 | { | ||
1765 | e->ignore(); | ||
1422 | } | 1766 | } |
1423 | |||
1424 | } | 1767 | } |
@@ -1427,15 +1770,43 @@ void QTReaderApp::showEditTools() | |||
1427 | { | 1770 | { |
1428 | if ( !doc ) | 1771 | // if ( !doc ) |
1429 | close(); | 1772 | //close(); |
1430 | // fileSelector->hide(); | 1773 | if (m_fullscreen) |
1431 | //tjw menu->show(); | 1774 | { |
1432 | editBar->show(); | 1775 | editBar->hide(); |
1433 | if ( searchVisible ) | 1776 | searchBar->hide(); |
1434 | searchBar->show(); | 1777 | regBar->hide(); |
1435 | if ( regVisible ) | 1778 | Global::hideInputMethod(); |
1436 | regBar->show(); | 1779 | m_fontBar->hide(); |
1437 | if (m_fontVisible) m_fontBar->show(); | 1780 | //showNormal(); |
1438 | 1781 | showFullScreen(); | |
1782 | } | ||
1783 | else | ||
1784 | { | ||
1785 | qDebug("him"); | ||
1786 | Global::hideInputMethod(); | ||
1787 | qDebug("eb"); | ||
1788 | editBar->show(); | ||
1789 | if ( searchVisible ) | ||
1790 | { | ||
1791 | Global::showInputMethod(); | ||
1792 | searchBar->show(); | ||
1793 | } | ||
1794 | if ( regVisible ) | ||
1795 | { | ||
1796 | Global::showInputMethod(); | ||
1797 | regBar->show(); | ||
1798 | } | ||
1799 | if (m_fontVisible) m_fontBar->show(); | ||
1800 | qDebug("sn"); | ||
1801 | showNormal(); | ||
1802 | qDebug("sm"); | ||
1803 | showMaximized(); | ||
1804 | //setCentralWidget(reader); | ||
1805 | } | ||
1806 | |||
1807 | qDebug("uc"); | ||
1439 | updateCaption(); | 1808 | updateCaption(); |
1809 | qDebug("rw"); | ||
1440 | editorStack->raiseWidget( reader ); | 1810 | editorStack->raiseWidget( reader ); |
1811 | qDebug("sf"); | ||
1441 | reader->setFocus(); | 1812 | reader->setFocus(); |
@@ -1446,5 +1817,5 @@ void QTReaderApp::save() | |||
1446 | if ( !doc ) | 1817 | if ( !doc ) |
1447 | return; | 1818 | return; |
1448 | if ( !editor->edited() ) | 1819 | if ( !editor->edited() ) |
1449 | return; | 1820 | return; |
1450 | 1821 | ||
@@ -1454,15 +1825,15 @@ void QTReaderApp::save() | |||
1454 | if ( doc->name().isEmpty() ) { | 1825 | if ( doc->name().isEmpty() ) { |
1455 | unsigned ispace = pt.find( ' ' ); | 1826 | unsigned ispace = pt.find( ' ' ); |
1456 | unsigned ienter = pt.find( '\n' ); | 1827 | unsigned ienter = pt.find( '\n' ); |
1457 | int i = (ispace < ienter) ? ispace : ienter; | 1828 | int i = (ispace < ienter) ? ispace : ienter; |
1458 | QString docname; | 1829 | QString docname; |
1459 | if ( i == -1 ) { | 1830 | if ( i == -1 ) { |
1460 | if ( pt.isEmpty() ) | 1831 | if ( pt.isEmpty() ) |
1461 | docname = "Empty Text"; | 1832 | docname = "Empty Text"; |
1462 | else | 1833 | else |
1463 | docname = pt; | 1834 | docname = pt; |
1464 | } else { | 1835 | } else { |
1465 | docname = pt.left( i ); | 1836 | docname = pt.left( i ); |
1466 | } | 1837 | } |
1467 | doc->setName(docname); | 1838 | doc->setName(docname); |
1468 | } | 1839 | } |
@@ -1475,9 +1846,9 @@ void QTReaderApp::clear() | |||
1475 | { | 1846 | { |
1476 | if (doc != 0) | 1847 | // if (doc != 0) |
1477 | { | 1848 | // { |
1478 | // QMessageBox::information(this, "QTReader", "Deleting doc", 1); | 1849 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); |
1479 | delete doc; | 1850 | //delete doc; |
1480 | // QMessageBox::information(this, "QTReader", "Deleted doc", 1); | 1851 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); |
1481 | doc = 0; | 1852 | //doc = 0; |
1482 | } | 1853 | // } |
1483 | reader->clear(); | 1854 | reader->clear(); |
@@ -1487,10 +1858,10 @@ void QTReaderApp::updateCaption() | |||
1487 | { | 1858 | { |
1488 | if ( !doc ) | 1859 | // if ( !doc ) |
1489 | setCaption( tr("OpieReader") ); | 1860 | //setCaption( tr("QTReader") ); |
1490 | else { | 1861 | // else { |
1491 | QString s = doc->name(); | 1862 | //QString s = doc->name(); |
1492 | if ( s.isEmpty() ) | 1863 | //if ( s.isEmpty() ) |
1493 | s = tr( "Unnamed" ); | 1864 | // s = tr( "Unnamed" ); |
1494 | setCaption( s + " - " + tr("OpieReader") ); | 1865 | setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) ); |
1495 | } | 1866 | // } |
1496 | } | 1867 | } |
@@ -1501,3 +1872,3 @@ void QTReaderApp::setDocument(const QString& fileref) | |||
1501 | //QMessageBox::information(0, "setDocument", fileref); | 1872 | //QMessageBox::information(0, "setDocument", fileref); |
1502 | openFile(DocLnk(fileref)); | 1873 | openFile(fileref); |
1503 | // showEditTools(); | 1874 | // showEditTools(); |
@@ -1507,5 +1878,11 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1507 | { | 1878 | { |
1508 | if (m_dontSave) | 1879 | if (m_fullscreen) |
1509 | { | 1880 | { |
1510 | e->accept(); | 1881 | m_fullscreen = false; |
1882 | showEditTools(); | ||
1883 | e->accept(); | ||
1884 | } | ||
1885 | else if (m_dontSave) | ||
1886 | { | ||
1887 | e->accept(); | ||
1511 | } | 1888 | } |
@@ -1513,37 +1890,40 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1513 | { | 1890 | { |
1514 | if (editorStack->visibleWidget() == reader) | 1891 | if (editorStack->visibleWidget() == reader) |
1515 | { | 1892 | { |
1516 | if (m_fontVisible) | 1893 | if (m_fontVisible) |
1517 | { | 1894 | { |
1518 | m_fontBar->hide(); | 1895 | m_fontBar->hide(); |
1519 | m_fontVisible = false; | 1896 | m_fontVisible = false; |
1520 | } | 1897 | } |
1521 | if (regVisible) | 1898 | if (regVisible) |
1522 | { | 1899 | { |
1523 | regBar->hide(); | 1900 | regBar->hide(); |
1524 | regVisible = false; | 1901 | Global::hideInputMethod(); |
1525 | return; | 1902 | regVisible = false; |
1526 | } | 1903 | return; |
1527 | if (searchVisible) | 1904 | } |
1528 | { | 1905 | if (searchVisible) |
1529 | searchBar->hide(); | 1906 | { |
1530 | searchVisible = false; | 1907 | searchBar->hide(); |
1531 | return; | 1908 | Global::hideInputMethod(); |
1532 | } | 1909 | searchVisible = false; |
1533 | if (m_fBkmksChanged && pBkmklist != NULL) | 1910 | return; |
1534 | { | 1911 | } |
1535 | if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0) | 1912 | if (m_fBkmksChanged && pBkmklist != NULL) |
1536 | savebkmks(); | 1913 | { |
1537 | delete pBkmklist; | 1914 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
1538 | pBkmklist = NULL; | 1915 | savebkmks(); |
1539 | m_fBkmksChanged = false; | 1916 | delete pBkmklist; |
1540 | } | 1917 | pBkmklist = NULL; |
1541 | bFromDocView = FALSE; | 1918 | m_fBkmksChanged = false; |
1542 | saveprefs(); | 1919 | } |
1543 | e->accept(); | 1920 | bFromDocView = FALSE; |
1544 | } | 1921 | updatefileinfo(); |
1545 | else | 1922 | saveprefs(); |
1546 | { | 1923 | e->accept(); |
1547 | showEditTools(); | 1924 | } |
1548 | } | 1925 | else |
1926 | { | ||
1927 | showEditTools(); | ||
1928 | } | ||
1549 | } | 1929 | } |
@@ -1554,3 +1934,3 @@ void QTReaderApp::do_gotomark() | |||
1554 | m_nRegAction = cGotoBkmk; | 1934 | m_nRegAction = cGotoBkmk; |
1555 | listbkmk(); | 1935 | listbkmk(pBkmklist); |
1556 | } | 1936 | } |
@@ -1560,20 +1940,25 @@ void QTReaderApp::do_delmark() | |||
1560 | m_nRegAction = cDelBkmk; | 1940 | m_nRegAction = cDelBkmk; |
1561 | listbkmk(); | 1941 | listbkmk(pBkmklist); |
1562 | } | 1942 | } |
1563 | 1943 | ||
1564 | void QTReaderApp::listbkmk() | 1944 | void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) |
1565 | { | 1945 | { |
1566 | bkmkselector->clear(); | 1946 | bkmkselector->clear(); |
1947 | if (_lab.isNull()) | ||
1948 | bkmkselector->setText("Cancel"); | ||
1949 | else | ||
1950 | bkmkselector->setText(_lab); | ||
1567 | int cnt = 0; | 1951 | int cnt = 0; |
1568 | if (pBkmklist != NULL) | 1952 | if (plist != NULL) |
1569 | { | 1953 | { |
1570 | for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++) | 1954 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) |
1571 | { | 1955 | { |
1572 | #ifdef _UNICODE | 1956 | #ifdef _UNICODE |
1573 | bkmkselector->insertItem(toQString(i->name())); | 1957 | qDebug("Item:%s", (const char*)toQString(i->name())); |
1958 | bkmkselector->insertItem(toQString(i->name())); | ||
1574 | #else | 1959 | #else |
1575 | bkmkselector->insertItem(i->name()); | 1960 | bkmkselector->insertItem(i->name()); |
1576 | #endif | 1961 | #endif |
1577 | cnt++; | 1962 | cnt++; |
1578 | } | 1963 | } |
1579 | } | 1964 | } |
@@ -1584,4 +1969,12 @@ void QTReaderApp::listbkmk() | |||
1584 | if (m_fontVisible) m_fontBar->hide(); | 1969 | if (m_fontVisible) m_fontBar->hide(); |
1585 | if (regVisible) regBar->hide(); | 1970 | if (regVisible) |
1586 | if (searchVisible) searchBar->hide(); | 1971 | { |
1972 | Global::hideInputMethod(); | ||
1973 | regBar->hide(); | ||
1974 | } | ||
1975 | if (searchVisible) | ||
1976 | { | ||
1977 | Global::hideInputMethod(); | ||
1978 | searchBar->hide(); | ||
1979 | } | ||
1587 | editorStack->raiseWidget( bkmkselector ); | 1980 | editorStack->raiseWidget( bkmkselector ); |
@@ -1589,3 +1982,3 @@ void QTReaderApp::listbkmk() | |||
1589 | else | 1982 | else |
1590 | QMessageBox::information(this, "OpieReader", "No bookmarks in memory"); | 1983 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
1591 | } | 1984 | } |
@@ -1602,5 +1995,53 @@ void QTReaderApp::do_regedit() | |||
1602 | // editBar->hide(); | 1995 | // editBar->hide(); |
1996 | reader->bDoUpdates = false; | ||
1997 | qDebug("Showing regbar"); | ||
1603 | regBar->show(); | 1998 | regBar->show(); |
1999 | qDebug("Showing kbd"); | ||
2000 | Global::showInputMethod(); | ||
1604 | regVisible = true; | 2001 | regVisible = true; |
1605 | regEdit->setFocus(); | 2002 | regEdit->setFocus(); |
2003 | qApp->processEvents(); | ||
2004 | reader->bDoUpdates = true; | ||
2005 | reader->update(); | ||
2006 | } | ||
2007 | |||
2008 | bool QTReaderApp::openfrombkmk(Bkmk* bk) | ||
2009 | { | ||
2010 | QString fn = toQString( | ||
2011 | CFiledata(bk->anno()).name() | ||
2012 | ); | ||
2013 | qDebug("fileinfo"); | ||
2014 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | ||
2015 | { | ||
2016 | qDebug("Opening"); | ||
2017 | openFile(fn); | ||
2018 | struct stat fnstat; | ||
2019 | stat((const char *)reader->m_lastfile, &fnstat); | ||
2020 | |||
2021 | if (CFiledata(bk->anno()).date() | ||
2022 | != fnstat.st_mtime) | ||
2023 | { | ||
2024 | CFiledata fd(bk->anno()); | ||
2025 | fd.setdate(fnstat.st_mtime); | ||
2026 | bk->value(0); | ||
2027 | } | ||
2028 | else | ||
2029 | { | ||
2030 | unsigned short svlen = bk->filedatalen(); | ||
2031 | unsigned char* svdata = bk->filedata(); | ||
2032 | reader->putSaveData(svdata, svlen); | ||
2033 | // setstate(svdata, svlen); | ||
2034 | if (svlen != 0) | ||
2035 | { | ||
2036 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); | ||
2037 | } | ||
2038 | qDebug("updating"); | ||
2039 | reader->locate(bk->value()); | ||
2040 | } | ||
2041 | return true; | ||
2042 | } | ||
2043 | else | ||
2044 | { | ||
2045 | return false; | ||
2046 | } | ||
1606 | } | 2047 | } |
@@ -1611,14 +2052,23 @@ void QTReaderApp::gotobkmk(int ind) | |||
1611 | { | 2052 | { |
1612 | case cGotoBkmk: | 2053 | case cOpenFile: |
1613 | reader->locate((*pBkmklist)[ind]->value()); | 2054 | { |
1614 | break; | 2055 | if (!openfrombkmk((*pOpenlist)[ind])) |
1615 | case cDelBkmk: | 2056 | { |
1616 | // qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); | 2057 | pOpenlist->erase(ind); |
1617 | pBkmklist->erase(ind); | 2058 | QMessageBox::information(this, PROGNAME, "Can't find file"); |
1618 | m_fBkmksChanged = true; | 2059 | } |
1619 | // pBkmklist->sort(); | 2060 | } |
1620 | break; | 2061 | break; |
1621 | case cRmBkmkFile: | 2062 | case cGotoBkmk: |
1622 | unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind))); | 2063 | reader->locate((*pBkmklist)[ind]->value()); |
1623 | break; | 2064 | break; |
2065 | case cDelBkmk: | ||
2066 | // qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); | ||
2067 | pBkmklist->erase(ind); | ||
2068 | m_fBkmksChanged = true; | ||
2069 | // pBkmklist->sort(); | ||
2070 | break; | ||
2071 | case cRmBkmkFile: | ||
2072 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); | ||
2073 | break; | ||
1624 | } | 2074 | } |
@@ -1629,2 +2079,7 @@ void QTReaderApp::cancelbkmk() | |||
1629 | { | 2079 | { |
2080 | if (m_nRegAction == cOpenFile) | ||
2081 | { | ||
2082 | QString fn = usefilebrowser(); | ||
2083 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); | ||
2084 | } | ||
1630 | showEditTools(); | 2085 | showEditTools(); |
@@ -1646,5 +2101,5 @@ void QTReaderApp::do_jump(const QString& lcn) | |||
1646 | if (ok) | 2101 | if (ok) |
1647 | reader->locate(ulcn); | 2102 | reader->locate(ulcn); |
1648 | else | 2103 | else |
1649 | QMessageBox::information(this, "OpieReader", "Must be a number"); | 2104 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
1650 | } | 2105 | } |
@@ -1653,3 +2108,5 @@ void QTReaderApp::do_regaction() | |||
1653 | { | 2108 | { |
2109 | reader->bDoUpdates = false; | ||
1654 | regBar->hide(); | 2110 | regBar->hide(); |
2111 | Global::hideInputMethod(); | ||
1655 | regVisible = false; | 2112 | regVisible = false; |
@@ -1658,19 +2115,19 @@ void QTReaderApp::do_regaction() | |||
1658 | case cAutoGen: | 2115 | case cAutoGen: |
1659 | do_autogen(regEdit->text()); | 2116 | do_autogen(regEdit->text()); |
1660 | break; | 2117 | break; |
1661 | case cAddBkmk: | 2118 | case cAddBkmk: |
1662 | do_addbkmk(regEdit->text()); | 2119 | do_addbkmk(regEdit->text()); |
1663 | break; | 2120 | break; |
1664 | case cJump: | 2121 | case cJump: |
1665 | do_jump(regEdit->text()); | 2122 | do_jump(regEdit->text()); |
1666 | break; | 2123 | break; |
1667 | case cMonoSpace: | 2124 | case cMonoSpace: |
1668 | do_mono(regEdit->text()); | 2125 | do_mono(regEdit->text()); |
1669 | break; | 2126 | break; |
1670 | case cOverlap: | 2127 | case cOverlap: |
1671 | do_overlap(regEdit->text()); | 2128 | do_overlap(regEdit->text()); |
1672 | break; | 2129 | break; |
1673 | case cSetTarget: | 2130 | case cSetTarget: |
1674 | do_settarget(regEdit->text()); | 2131 | do_settarget(regEdit->text()); |
1675 | break; | 2132 | break; |
1676 | } | 2133 | } |
@@ -1679,2 +2136,5 @@ void QTReaderApp::do_regaction() | |||
1679 | reader->setFocus(); | 2136 | reader->setFocus(); |
2137 | qApp->processEvents(); | ||
2138 | reader->bDoUpdates = true; | ||
2139 | reader->update(); | ||
1680 | } | 2140 | } |
@@ -1686,5 +2146,5 @@ void QTReaderApp::do_settarget(const QString& _txt) | |||
1686 | { | 2146 | { |
1687 | m_targetapp = ""; | 2147 | m_targetapp = ""; |
1688 | m_targetmsg = ""; | 2148 | m_targetmsg = ""; |
1689 | QMessageBox::information(this, "OpieReader", "Format is\nappname/messagename"); | 2149 | QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); |
1690 | } | 2150 | } |
@@ -1692,4 +2152,4 @@ void QTReaderApp::do_settarget(const QString& _txt) | |||
1692 | { | 2152 | { |
1693 | m_targetapp = _txt.left(ind); | 2153 | m_targetapp = _txt.left(ind); |
1694 | m_targetmsg = _txt.right(_txt.length()-ind-1); | 2154 | m_targetmsg = _txt.right(_txt.length()-ind-1); |
1695 | } | 2155 | } |
@@ -1701,7 +2161,7 @@ void QTReaderApp::setfont() | |||
1701 | { | 2161 | { |
1702 | if (m_fontSelector->text(i) == reader->m_fontname) | 2162 | if (m_fontSelector->text(i) == reader->m_fontname) |
1703 | { | 2163 | { |
1704 | m_fontSelector->setCurrentItem(i); | 2164 | m_fontSelector->setCurrentItem(i); |
1705 | break; | 2165 | break; |
1706 | } | 2166 | } |
1707 | } | 2167 | } |
@@ -1711,3 +2171,3 @@ void QTReaderApp::setfont() | |||
1711 | 2171 | ||
1712 | void QTReaderApp::setfontHelper(const QString& lcn, int size) | 2172 | void QTReaderApp::setfontHelper(const QString& lcn, int size = 0) |
1713 | { | 2173 | { |
@@ -1715,11 +2175,18 @@ void QTReaderApp::setfontHelper(const QString& lcn, int size) | |||
1715 | QFont f(lcn, 10 /*, QFont::Bold*/); | 2175 | QFont f(lcn, 10 /*, QFont::Bold*/); |
2176 | qDebug("bs"); | ||
1716 | bkmkselector->setFont( f ); | 2177 | bkmkselector->setFont( f ); |
2178 | qDebug("re"); | ||
1717 | regEdit->setFont( f ); | 2179 | regEdit->setFont( f ); |
2180 | qDebug("se"); | ||
1718 | searchEdit->setFont( f ); | 2181 | searchEdit->setFont( f ); |
2182 | qDebug("aw"); | ||
1719 | m_annoWin->setFont( f ); | 2183 | m_annoWin->setFont( f ); |
1720 | reader->m_fontname = lcn; | 2184 | reader->m_fontname = lcn; |
2185 | qDebug("cf1"); | ||
1721 | if (!reader->ChangeFont(size)) | 2186 | if (!reader->ChangeFont(size)) |
1722 | { | 2187 | { |
1723 | reader->ChangeFont(size); | 2188 | qDebug("cf2"); |
2189 | reader->ChangeFont(size); | ||
1724 | } | 2190 | } |
2191 | qDebug("ref"); | ||
1725 | reader->refresh(); | 2192 | reader->refresh(); |
@@ -1727,3 +2194,5 @@ void QTReaderApp::setfontHelper(const QString& lcn, int size) | |||
1727 | m_fontVisible = false; | 2194 | m_fontVisible = false; |
1728 | showEditTools(); | 2195 | qDebug("showedit"); |
2196 | if (reader->isVisible()) showEditTools(); | ||
2197 | qDebug("showeditdone"); | ||
1729 | } | 2198 | } |
@@ -1761,5 +2230,5 @@ pbar->resize(width(), editBar->height()); | |||
1761 | pbar->setProgress(pc); | 2230 | pbar->setProgress(pc); |
1762 | qApp->processEvents(); | 2231 | qApp->processEvents(); |
1763 | if (reader->locate() != lcn) reader->jumpto(lcn); | 2232 | if (reader->locate() != lcn) reader->jumpto(lcn); |
1764 | reader->setFocus(); | 2233 | reader->setFocus(); |
1765 | lastpc = pc; | 2234 | lastpc = pc; |
@@ -1772,3 +2241,3 @@ pbar->resize(width(), editBar->height()); | |||
1772 | #endif | 2241 | #endif |
1773 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); | 2242 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); |
1774 | } | 2243 | } |
@@ -1783,3 +2252,3 @@ void QTReaderApp::saveprefs() | |||
1783 | // reader->saveprefs("uqtreader"); | 2252 | // reader->saveprefs("uqtreader"); |
1784 | Config config( "uqtreader" ); | 2253 | Config config( APPDIR ); |
1785 | config.setGroup( "View" ); | 2254 | config.setGroup( "View" ); |
@@ -1793,2 +2262,3 @@ void QTReaderApp::saveprefs() | |||
1793 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 2262 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
2263 | config.writeEntry( "OneSpace", reader->bonespace ); | ||
1794 | config.writeEntry( "Unindent", reader->bunindent ); | 2264 | config.writeEntry( "Unindent", reader->bunindent ); |
@@ -1802,2 +2272,3 @@ void QTReaderApp::saveprefs() | |||
1802 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 2272 | config.writeEntry( "PageMode", reader->m_bpagemode ); |
2273 | config.writeEntry( "CursorNavigation", reader->m_navkeys ); | ||
1803 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 2274 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); |
@@ -1814,2 +2285,5 @@ void QTReaderApp::saveprefs() | |||
1814 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 2285 | config.writeEntry( "SpaceTarget", m_spaceTarget); |
2286 | #ifdef REPALM | ||
2287 | config.writeEntry( "Repalm", reader->brepalm ); | ||
2288 | #endif | ||
1815 | config.writeEntry( "Remap", reader->bremap ); | 2289 | config.writeEntry( "Remap", reader->bremap ); |
@@ -1817,2 +2291,5 @@ void QTReaderApp::saveprefs() | |||
1817 | config.writeEntry( "MakeBold", reader->bmakebold ); | 2291 | config.writeEntry( "MakeBold", reader->bmakebold ); |
2292 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | ||
2293 | |||
2294 | savefilelist(); | ||
1818 | } | 2295 | } |
@@ -1846,14 +2323,14 @@ void info_cb(Fl_Widget* o, void* _data) | |||
1846 | { | 2323 | { |
1847 | 2324 | ||
1848 | infowin = new Fl_Window(160,240); | 2325 | infowin = new Fl_Window(160,240); |
1849 | filename = new Fl_Output(45,5,110,14,"Filename"); | 2326 | filename = new Fl_Output(45,5,110,14,"Filename"); |
1850 | filesize = new Fl_Output(45,25,110,14,"Filesize"); | 2327 | filesize = new Fl_Output(45,25,110,14,"Filesize"); |
1851 | textsize = new Fl_Output(45,45,110,14,"Textsize"); | 2328 | textsize = new Fl_Output(45,45,110,14,"Textsize"); |
1852 | comprat = new CBar(45,65,110,14,"Ratio %"); | 2329 | comprat = new CBar(45,65,110,14,"Ratio %"); |
1853 | posn = new Fl_Output(45,85,110,14,"Location"); | 2330 | posn = new Fl_Output(45,85,110,14,"Location"); |
1854 | frcn = new CBar(45,105,110,14,"% Read"); | 2331 | frcn = new CBar(45,105,110,14,"% Read"); |
1855 | about = new Fl_Multiline_Output(5,125,150,90); | 2332 | about = new Fl_Multiline_Output(5,125,150,90); |
1856 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); | 2333 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); |
1857 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); | 2334 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); |
1858 | infowin->set_modal(); | 2335 | infowin->set_modal(); |
1859 | } | 2336 | } |
@@ -1861,21 +2338,21 @@ void info_cb(Fl_Widget* o, void* _data) | |||
1861 | { | 2338 | { |
1862 | unsigned long fs,ts; | 2339 | unsigned long fs,ts; |
1863 | tchar sz[20]; | 2340 | tchar sz[20]; |
1864 | ((reader_ui *)_data)->input->sizes(fs,ts); | 2341 | ((reader_ui *)_data)->input->sizes(fs,ts); |
1865 | unsigned long pl = ((reader_ui *)_data)->input->locate(); | 2342 | unsigned long pl = ((reader_ui *)_data)->input->locate(); |
1866 | 2343 | ||
1867 | filename->value(((reader_ui *)_data)->g_filename); | 2344 | filename->value(((reader_ui *)_data)->g_filename); |
1868 | 2345 | ||
1869 | sprintf(sz,"%u",fs); | 2346 | sprintf(sz,"%u",fs); |
1870 | filesize->value(sz); | 2347 | filesize->value(sz); |
1871 | 2348 | ||
1872 | sprintf(sz,"%u",ts); | 2349 | sprintf(sz,"%u",ts); |
1873 | textsize->value(sz); | 2350 | textsize->value(sz); |
1874 | 2351 | ||
1875 | comprat->value(100-(100*fs + (ts >> 1))/ts); | 2352 | comprat->value(100-(100*fs + (ts >> 1))/ts); |
1876 | 2353 | ||
1877 | sprintf(sz,"%u",pl); | 2354 | sprintf(sz,"%u",pl); |
1878 | posn->value(sz); | 2355 | posn->value(sz); |
1879 | 2356 | ||
1880 | frcn->value((100*pl + (ts >> 1))/ts); | 2357 | frcn->value((100*pl + (ts >> 1))/ts); |
1881 | } | 2358 | } |
@@ -1889,6 +2366,25 @@ void QTReaderApp::savebkmks() | |||
1889 | { | 2366 | { |
1890 | BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string), true); | 2367 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string), true); |
1891 | bf.write(*pBkmklist); | 2368 | bf.write(*pBkmklist); |
2369 | } | ||
2370 | m_fBkmksChanged = false; | ||
2371 | } | ||
2372 | |||
2373 | void QTReaderApp::readfilelist() | ||
2374 | { | ||
2375 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles")); | ||
2376 | qDebug("Reading open files"); | ||
2377 | pOpenlist = bf.readall(); | ||
2378 | if (pOpenlist != NULL) qDebug("...with success"); | ||
2379 | else qDebug("...without success!"); | ||
2380 | } | ||
2381 | |||
2382 | void QTReaderApp::savefilelist() | ||
2383 | { | ||
2384 | if (pOpenlist != NULL) | ||
2385 | { | ||
2386 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"), true); | ||
2387 | qDebug("Writing open files"); | ||
2388 | bf.write(*pOpenlist); | ||
1892 | } | 2389 | } |
1893 | m_fBkmksChanged = false; | ||
1894 | } | 2390 | } |
@@ -1899,5 +2395,20 @@ void QTReaderApp::readbkmks() | |||
1899 | { | 2395 | { |
1900 | delete pBkmklist; | 2396 | delete pBkmklist; |
2397 | } | ||
2398 | struct stat fnstat; | ||
2399 | struct stat bkstat; | ||
2400 | if ( | ||
2401 | stat((const char *)reader->m_lastfile, &fnstat) == 0 | ||
2402 | && | ||
2403 | stat((const char *)Global::applicationFileName(APPDIR, reader->m_string), &bkstat) == 0 | ||
2404 | ) | ||
2405 | { | ||
2406 | if (bkstat.st_mtime < fnstat.st_mtime) | ||
2407 | { | ||
2408 | unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string)); | ||
2409 | } | ||
1901 | } | 2410 | } |
1902 | BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string)); | 2411 | |
2412 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string)); | ||
2413 | |||
1903 | pBkmklist = bf.readall(); | 2414 | pBkmklist = bf.readall(); |
@@ -1906,6 +2417,6 @@ void QTReaderApp::readbkmks() | |||
1906 | { | 2417 | { |
1907 | pBkmklist = reader->getbkmklist(); | 2418 | pBkmklist = reader->getbkmklist(); |
1908 | } | 2419 | } |
1909 | if (pBkmklist != NULL) | 2420 | if (pBkmklist != NULL) |
1910 | pBkmklist->sort(); | 2421 | pBkmklist->sort(); |
1911 | } | 2422 | } |
@@ -1921,24 +2432,24 @@ void QTReaderApp::do_addbkmk(const QString& text) | |||
1921 | { | 2432 | { |
1922 | if (text.isEmpty()) | 2433 | if (text.isEmpty()) |
1923 | { | 2434 | { |
1924 | QMessageBox::information(this, "OpieReader", "Need a name for the bookmark\nSelect add again", 1); | 2435 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); |
1925 | } | 2436 | } |
1926 | else | 2437 | else |
1927 | { | 2438 | { |
1928 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; | 2439 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; |
1929 | #ifdef _UNICODE | 2440 | #ifdef _UNICODE |
1930 | CBuffer buff; | 2441 | CBuffer buff; |
1931 | int i = 0; | 2442 | int i = 0; |
1932 | for (i = 0; i < text.length(); i++) | 2443 | for (i = 0; i < text.length(); i++) |
1933 | { | 2444 | { |
1934 | buff[i] = text[i].unicode(); | 2445 | buff[i] = text[i].unicode(); |
1935 | } | 2446 | } |
1936 | buff[i] = 0; | 2447 | buff[i] = 0; |
1937 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); | 2448 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); |
1938 | #else | 2449 | #else |
1939 | pBkmklist->push_front(Bkmk((const tchar*)text,reader->pagelocate())); | 2450 | pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); |
1940 | #endif | 2451 | #endif |
1941 | m_fBkmksChanged = true; | 2452 | m_fBkmksChanged = true; |
1942 | pBkmklist->sort(); | 2453 | pBkmklist->sort(); |
1943 | } | 2454 | } |
1944 | } | 2455 | } |
@@ -1949,4 +2460,4 @@ void QTReaderApp::OnRedraw() | |||
1949 | { | 2460 | { |
1950 | bool found = findNextBookmark(reader->pagelocate()); | 2461 | bool found = findNextBookmark(reader->pagelocate()); |
1951 | m_bkmkAvail->setEnabled(found); | 2462 | m_bkmkAvail->setEnabled(found); |
1952 | } | 2463 | } |
@@ -1959,2 +2470,3 @@ void QTReaderApp::showAnnotation() | |||
1959 | m_annoIsEditing = false; | 2470 | m_annoIsEditing = false; |
2471 | Global::showInputMethod(); | ||
1960 | editorStack->raiseWidget( m_annoWin ); | 2472 | editorStack->raiseWidget( m_annoWin ); |
@@ -1969,12 +2481,12 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& | |||
1969 | { | 2481 | { |
1970 | QClipboard* cb = QApplication::clipboard(); | 2482 | QClipboard* cb = QApplication::clipboard(); |
1971 | cb->setText(wrd); | 2483 | cb->setText(wrd); |
1972 | if (wrd.length() > 10) | 2484 | if (wrd.length() > 10) |
1973 | { | 2485 | { |
1974 | Global::statusMessage(wrd.left(8) + ".."); | 2486 | Global::statusMessage(wrd.left(8) + ".."); |
1975 | } | 2487 | } |
1976 | else | 2488 | else |
1977 | { | 2489 | { |
1978 | Global::statusMessage(wrd); | 2490 | Global::statusMessage(wrd); |
1979 | } | 2491 | } |
1980 | } | 2492 | } |
@@ -1982,8 +2494,9 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& | |||
1982 | { | 2494 | { |
1983 | // addAnno(wrd, "Need to be able to edit this", posn); | 2495 | //addAnno(wrd, "Need to be able to edit this", posn); |
1984 | m_annoWin->setName(line); | 2496 | m_annoWin->setName(line); |
1985 | m_annoWin->setAnno(""); | 2497 | m_annoWin->setAnno(""); |
1986 | m_annoWin->setPosn(posn); | 2498 | m_annoWin->setPosn(posn); |
1987 | m_annoIsEditing = true; | 2499 | m_annoIsEditing = true; |
1988 | editorStack->raiseWidget( m_annoWin ); | 2500 | Global::showInputMethod(); |
2501 | editorStack->raiseWidget( m_annoWin ); | ||
1989 | } | 2502 | } |
@@ -1991,7 +2504,7 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& | |||
1991 | { | 2504 | { |
1992 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) | 2505 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) |
1993 | { | 2506 | { |
1994 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); | 2507 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); |
1995 | e << wrd; | 2508 | e << wrd; |
1996 | } | 2509 | } |
1997 | } | 2510 | } |
@@ -2003,23 +2516,28 @@ void QTReaderApp::OnActionPressed() | |||
2003 | { | 2516 | { |
2004 | case cesOpenFile: | 2517 | case cesOpenFile: |
2005 | { | 2518 | { |
2006 | fileOpen(); | 2519 | fileOpen(); |
2007 | } | 2520 | } |
2008 | break; | 2521 | break; |
2009 | case cesAutoScroll: | 2522 | case cesAutoScroll: |
2010 | { | 2523 | { |
2011 | reader->setautoscroll(!reader->m_autoScroll); | 2524 | reader->setautoscroll(!reader->m_autoScroll); |
2012 | setScrollState(reader->m_autoScroll); | 2525 | setScrollState(reader->m_autoScroll); |
2013 | } | 2526 | } |
2014 | break; | 2527 | break; |
2015 | case cesActionMark: | 2528 | case cesActionMark: |
2016 | { | 2529 | { |
2017 | addbkmk(); | 2530 | addbkmk(); |
2018 | } | 2531 | } |
2019 | break; | 2532 | break; |
2020 | default: | 2533 | case cesFullScreen: |
2021 | { | 2534 | { |
2022 | qDebug("Unknown ActionType:%u", m_spaceTarget); | 2535 | m_actFullscreen->setOn(true); |
2023 | } | 2536 | } |
2024 | break; | 2537 | break; |
2538 | default: | ||
2539 | { | ||
2540 | qDebug("Unknown ActionType:%u", m_spaceTarget); | ||
2541 | } | ||
2542 | break; | ||
2025 | } | 2543 | } |
@@ -2029 +2547,60 @@ void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } | |||
2029 | void QTReaderApp::restoreFocus() { reader->setFocus(); } | 2547 | void QTReaderApp::restoreFocus() { reader->setFocus(); } |
2548 | |||
2549 | /* | ||
2550 | void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen) | ||
2551 | { | ||
2552 | unsigned short sdlen; | ||
2553 | memcpy(&sdlen, _sd, sizeof(sdlen)); | ||
2554 | sdlen -= sizeof(sdlen); | ||
2555 | _sd += sizeof(sdlen); | ||
2556 | statedata* sd; | ||
2557 | char* data; | ||
2558 | if (sdlen < sizeof(statedata)+1) | ||
2559 | { | ||
2560 | sdlen = sizeof(statedata)+1; | ||
2561 | } | ||
2562 | data = new char[sdlen]; | ||
2563 | sd = (statedata*)data; | ||
2564 | memcpy(sd, _sd, sdlen); | ||
2565 | data[sdlen] = 0; | ||
2566 | reader->setstate(*sd); | ||
2567 | delete [] data; | ||
2568 | } | ||
2569 | |||
2570 | void QTReaderApp::getstate(unsigned char*& data, unsigned short& len) | ||
2571 | { | ||
2572 | unsigned char* olddata = data; | ||
2573 | unsigned short oldlen = len; | ||
2574 | len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length(); | ||
2575 | data = new unsigned char[len]; | ||
2576 | memcpy(data, olddata, oldlen); | ||
2577 | delete [] olddata; | ||
2578 | memcpy(data+oldlen, &len, sizeof(len)); | ||
2579 | statedata* sd = (statedata*)(data+oldlen+sizeof(unsigned short)); | ||
2580 | |||
2581 | sd->bstripcr = reader->bstripcr; | ||
2582 | sd->btextfmt = reader->btextfmt; | ||
2583 | sd->bautofmt = reader->bautofmt; | ||
2584 | sd->bstriphtml = reader->bstriphtml; | ||
2585 | sd->bpeanut = reader->bpeanut; | ||
2586 | sd->bdehyphen = reader->bdehyphen; | ||
2587 | sd->bonespace = reader->bonespace; | ||
2588 | sd->bunindent = reader->bunindent; | ||
2589 | sd->brepara = reader->brepara; | ||
2590 | sd->bdblspce = reader->bdblspce; | ||
2591 | sd->m_bpagemode = reader->m_bpagemode; | ||
2592 | sd->m_navkeys = reader->m_navkeys; | ||
2593 | sd->m_bMonoSpaced = reader->m_bMonoSpaced; | ||
2594 | sd->bremap = reader->bremap; | ||
2595 | sd->bmakebold = reader->bmakebold; | ||
2596 | sd->Continuous = reader->m_continuousDocument; | ||
2597 | #ifdef REPALM | ||
2598 | sd->brepalm = reader->brepalm; | ||
2599 | #endif | ||
2600 | sd->bindenter = reader->bindenter; | ||
2601 | sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize() | ||
2602 | sd->m_encd = reader->m_encd; | ||
2603 | sd->m_charpc = reader->m_charpc; | ||
2604 | strcpy(sd->m_fontname, reader->m_fontname.latin1()); | ||
2605 | } | ||
2606 | */ | ||
diff --git a/noncore/apps/opie-reader/QTReaderApp.h b/noncore/apps/opie-reader/QTReaderApp.h index 22c57e4..cb33e4a 100644 --- a/noncore/apps/opie-reader/QTReaderApp.h +++ b/noncore/apps/opie-reader/QTReaderApp.h | |||
@@ -25,3 +25,3 @@ | |||
25 | #define MAX_ENCODING 6 | 25 | #define MAX_ENCODING 6 |
26 | #define MAX_ACTIONS 3 | 26 | #define MAX_ACTIONS 4 |
27 | 27 | ||
@@ -41,3 +41,3 @@ class QPopupMenu; | |||
41 | class QToolBar; | 41 | class QToolBar; |
42 | class QPEToolBar; | 42 | //class QPEToolBar; |
43 | class CBkmkSelector; | 43 | class CBkmkSelector; |
@@ -49,2 +49,3 @@ class CDrawBuffer; | |||
49 | class QTReader; | 49 | class QTReader; |
50 | class QPixmap; | ||
50 | 51 | ||
@@ -54,3 +55,4 @@ enum ActionTypes | |||
54 | cesAutoScroll, | 55 | cesAutoScroll, |
55 | cesActionMark | 56 | cesActionMark, |
57 | cesFullScreen | ||
56 | }; | 58 | }; |
@@ -67,2 +69,3 @@ struct searchrecord | |||
67 | class infowin; | 69 | class infowin; |
70 | class GraphicWin; | ||
68 | 71 | ||
@@ -78,3 +81,3 @@ class QTReaderApp : public QMainWindow | |||
78 | ~QTReaderApp(); | 81 | ~QTReaderApp(); |
79 | 82 | void suspend(); | |
80 | void openFile( const QString & ); | 83 | void openFile( const QString & ); |
@@ -85,5 +88,7 @@ class QTReaderApp : public QMainWindow | |||
85 | void setfontHelper(const QString& lcn, int size = 0); | 88 | void setfontHelper(const QString& lcn, int size = 0); |
86 | QAction* m_bkmkAvail; | 89 | QAction* m_bkmkAvail, *m_actFullscreen; |
87 | CAnnoEdit* m_annoWin; | 90 | CAnnoEdit* m_annoWin; |
88 | Bkmk* m_anno; | 91 | Bkmk* m_anno; |
92 | // void resizeEvent(QResizeEvent* e); | ||
93 | void keyPressEvent(QKeyEvent* e); | ||
89 | void closeEvent( QCloseEvent *e ); | 94 | void closeEvent( QCloseEvent *e ); |
@@ -99,2 +104,3 @@ class QTReaderApp : public QMainWindow | |||
99 | bool m_doClipboard; | 104 | bool m_doClipboard; |
105 | bool m_fullscreen; | ||
100 | 106 | ||
@@ -103,2 +109,6 @@ class QTReaderApp : public QMainWindow | |||
103 | private slots: | 109 | private slots: |
110 | void zoomin(); | ||
111 | void zoomout(); | ||
112 | void setfullscreen(bool sfs); | ||
113 | void setcontinuous(bool sfs); | ||
104 | void setTwoTouch(bool _b); | 114 | void setTwoTouch(bool _b); |
@@ -118,2 +128,3 @@ private slots: | |||
118 | void OnWordSelected(const QString&, size_t, const QString&); | 128 | void OnWordSelected(const QString&, size_t, const QString&); |
129 | void showgraphic(QPixmap&); | ||
119 | void addAnno(const QString&, const QString&, size_t); | 130 | void addAnno(const QString&, const QString&, size_t); |
@@ -143,4 +154,2 @@ private slots: | |||
143 | void setDocument(const QString&); | 154 | void setDocument(const QString&); |
144 | void TBD(); | ||
145 | void TBDzoom(); | ||
146 | 155 | ||
@@ -150,2 +159,3 @@ private slots: | |||
150 | void fileOpen(); | 159 | void fileOpen(); |
160 | void fileClose(); | ||
151 | 161 | ||
@@ -168,3 +178,2 @@ private slots: | |||
168 | 178 | ||
169 | void openFile( const DocLnk & ); | ||
170 | void showEditTools(); | 179 | void showEditTools(); |
@@ -172,2 +181,6 @@ private slots: | |||
172 | void stripcr(bool); | 181 | void stripcr(bool); |
182 | void onespace(bool); | ||
183 | #ifdef REPALM | ||
184 | // void repalm(bool); | ||
185 | #endif | ||
173 | void peanut(bool _b); | 186 | void peanut(bool _b); |
@@ -183,2 +196,3 @@ private slots: | |||
183 | void pagemode(bool); | 196 | void pagemode(bool); |
197 | void navkeys(bool); | ||
184 | // void gotobkmk(const QString& bm); | 198 | // void gotobkmk(const QString& bm); |
@@ -194,4 +208,14 @@ private slots: | |||
194 | private: | 208 | private: |
209 | /* | ||
210 | void setstate(unsigned char* _sd, unsigned short _sdlen); | ||
211 | void getstate(unsigned char*& data, unsigned short& len); | ||
212 | */ | ||
213 | void fileOpen2(); | ||
214 | void readfilelist(); | ||
215 | void savefilelist(); | ||
216 | void updatefileinfo(); | ||
217 | bool openfrombkmk(Bkmk*); | ||
195 | QString m_targetapp, m_targetmsg; | 218 | QString m_targetapp, m_targetmsg; |
196 | void listbkmk(); | 219 | void listbkmk(CList<Bkmk>*, const QString& _lab = QString::null); |
220 | QString usefilebrowser(); | ||
197 | void do_regedit(); | 221 | void do_regedit(); |
@@ -225,3 +249,4 @@ private slots: | |||
225 | QComboBox* m_fontSelector; | 249 | QComboBox* m_fontSelector; |
226 | QPEToolBar /* *menu,*/ *editBar; | 250 | // QPEToolBar /* *menu,*/ *editBar; |
251 | QToolBar /* *menu,*/ *editBar; | ||
227 | QFloatBar *searchBar, *regBar/*, *m_fontBar*/; | 252 | QFloatBar *searchBar, *regBar/*, *m_fontBar*/; |
@@ -229,3 +254,2 @@ private slots: | |||
229 | QLineEdit *searchEdit, *regEdit; | 254 | QLineEdit *searchEdit, *regEdit; |
230 | DocLnk *doc; | ||
231 | bool searchVisible; | 255 | bool searchVisible; |
@@ -245,3 +269,5 @@ private slots: | |||
245 | CList<Bkmk>* pBkmklist; | 269 | CList<Bkmk>* pBkmklist; |
270 | CList<Bkmk>* pOpenlist; | ||
246 | infowin* m_infoWin; | 271 | infowin* m_infoWin; |
272 | GraphicWin* m_graphicwin; | ||
247 | QProgressBar* pbar; | 273 | QProgressBar* pbar; |
@@ -262,2 +288,4 @@ const int cOverlap = 7; | |||
262 | const int cSetTarget = 8; | 288 | const int cSetTarget = 8; |
289 | const int cOpenFile = 9; | ||
290 | |||
263 | #endif | 291 | #endif |
diff --git a/noncore/apps/opie-reader/StateData.h b/noncore/apps/opie-reader/StateData.h new file mode 100644 index 0000000..0cb0f07 --- a/dev/null +++ b/noncore/apps/opie-reader/StateData.h | |||
@@ -0,0 +1,32 @@ | |||
1 | #ifndef __STATEDATA_H | ||
2 | #define __STATEDATA_H | ||
3 | |||
4 | struct statedata | ||
5 | { | ||
6 | bool bstripcr/*:1*/; | ||
7 | bool btextfmt/*:1*/; | ||
8 | bool bautofmt/*:1*/; | ||
9 | bool bstriphtml/*:1*/; | ||
10 | bool bpeanut/*:1*/; | ||
11 | bool bdehyphen/*:1*/; | ||
12 | bool bonespace/*:1*/; | ||
13 | bool bunindent/*:1*/; | ||
14 | bool brepara/*:1*/; | ||
15 | bool bdblspce/*:1*/; | ||
16 | bool m_bpagemode/*:1*/; | ||
17 | bool m_navkeys/*:1*/; | ||
18 | bool m_bMonoSpaced/*:1*/; | ||
19 | bool bremap/*:1*/; | ||
20 | bool bmakebold/*:1*/; | ||
21 | bool Continuous/*:1*/; | ||
22 | #ifdef REPALM | ||
23 | bool brepalm/*:1*/; | ||
24 | #endif | ||
25 | int bindenter; | ||
26 | int m_textsize; | ||
27 | int m_encd; | ||
28 | int m_charpc; | ||
29 | char m_fontname[1]; | ||
30 | }; | ||
31 | |||
32 | #endif | ||
diff --git a/noncore/apps/opie-reader/StyleConsts.cpp b/noncore/apps/opie-reader/StyleConsts.cpp new file mode 100644 index 0000000..e111dbd --- a/dev/null +++ b/noncore/apps/opie-reader/StyleConsts.cpp | |||
@@ -0,0 +1,99 @@ | |||
1 | |||
2 | #include <qpixmap.h> | ||
3 | #include "StyleConsts.h" | ||
4 | |||
5 | GraphicLink::~GraphicLink() { delete graphic; } | ||
6 | |||
7 | pmstore::~pmstore() | ||
8 | { | ||
9 | // qDebug("Deleting image"); | ||
10 | delete graphic; | ||
11 | } | ||
12 | |||
13 | CStyle::~CStyle() | ||
14 | { | ||
15 | if (graphic != NULL) | ||
16 | { | ||
17 | if (--(graphic->count) == 0) | ||
18 | { | ||
19 | delete graphic; | ||
20 | } | ||
21 | } | ||
22 | } | ||
23 | |||
24 | CStyle::CStyle(CStyle& rhs) : graphic(NULL) | ||
25 | { | ||
26 | *this = rhs; | ||
27 | } | ||
28 | |||
29 | CStyle::CStyle(const CStyle& rhs) : graphic(NULL) | ||
30 | { | ||
31 | *this = rhs; | ||
32 | } | ||
33 | |||
34 | CStyle& CStyle::operator=(const CStyle& rhs) | ||
35 | { | ||
36 | if (rhs.graphic != NULL) | ||
37 | { | ||
38 | (rhs.graphic->count)++; | ||
39 | if (graphic != NULL) | ||
40 | { | ||
41 | if (--(graphic->count) == 0) | ||
42 | { | ||
43 | delete graphic; | ||
44 | } | ||
45 | } | ||
46 | graphic = rhs.graphic; | ||
47 | } | ||
48 | else | ||
49 | { | ||
50 | if (graphic != NULL) | ||
51 | { | ||
52 | if (--(graphic->count) == 0) | ||
53 | { | ||
54 | delete graphic; | ||
55 | } | ||
56 | graphic = NULL; | ||
57 | } | ||
58 | } | ||
59 | sty = rhs.sty; | ||
60 | return *this; | ||
61 | } | ||
62 | |||
63 | void CStyle::clearPicture() | ||
64 | { | ||
65 | if (graphic != NULL) | ||
66 | { | ||
67 | if (--(graphic->count) == 0) | ||
68 | { | ||
69 | delete graphic; | ||
70 | } | ||
71 | graphic = NULL; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | void CStyle::unset() | ||
76 | { | ||
77 | sty.unset(); | ||
78 | if (graphic != NULL) | ||
79 | { | ||
80 | if (--(graphic->count) == 0) | ||
81 | { | ||
82 | delete graphic; | ||
83 | } | ||
84 | graphic = NULL; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | void CStyle::setPicture(QPixmap* _g, bool il, unsigned long tgt) | ||
89 | { | ||
90 | if (graphic != NULL) | ||
91 | { | ||
92 | if (--(graphic->count) == 0) | ||
93 | { | ||
94 | delete graphic; | ||
95 | } | ||
96 | graphic = NULL; | ||
97 | } | ||
98 | if (_g != NULL) graphic = new pmstore(_g, il, tgt); | ||
99 | } | ||
diff --git a/noncore/apps/opie-reader/StyleConsts.h b/noncore/apps/opie-reader/StyleConsts.h index b6dd861..5aacdf0 100644 --- a/noncore/apps/opie-reader/StyleConsts.h +++ b/noncore/apps/opie-reader/StyleConsts.h | |||
@@ -5,19 +5,42 @@ typedef unsigned short StyleType; | |||
5 | 5 | ||
6 | class CStyle | 6 | #include <stdlib.h> |
7 | #include <qglobal.h> | ||
8 | class QPixmap; | ||
9 | |||
10 | struct GraphicLink | ||
7 | { | 11 | { |
8 | // 15 14 13-5 4 3 2 1 0 | 12 | QPixmap* graphic; |
9 | //bold italic spare align align fs fs fs | 13 | bool isLink; |
10 | static const StyleType m_Bold = 1 << 15; | 14 | unsigned long link; |
11 | static const StyleType m_Italic = 1 << 14; | 15 | GraphicLink(QPixmap* p, bool isLnk, unsigned long tgt) : |
12 | static const StyleType m_FontMask = 7; | 16 | graphic(p), isLink(isLnk), link(tgt) {} |
13 | static const StyleType m_FontBase = 3; | 17 | ~GraphicLink(); |
14 | 18 | }; | |
15 | static const StyleType m_AlignShift = 3; | ||
16 | static const StyleType m_AlignMask = 3 << m_AlignShift; | ||
17 | static const StyleType m_EveryBit = 0xffff; | ||
18 | 19 | ||
20 | struct pmstore | ||
21 | { | ||
22 | unsigned int count; | ||
23 | GraphicLink* graphic; | ||
24 | pmstore(QPixmap* p, bool isLnk, unsigned long tgt) : count(1) | ||
25 | { | ||
26 | graphic = new GraphicLink(p, isLnk, tgt); | ||
27 | } | ||
28 | ~pmstore(); | ||
29 | }; | ||
19 | 30 | ||
20 | StyleType sty; | 31 | enum EalignmentType |
32 | { | ||
33 | m_AlignLeft, | ||
34 | m_AlignRight, | ||
35 | m_AlignCentre, | ||
36 | m_AlignJustify | ||
37 | }; | ||
21 | 38 | ||
22 | void unjustify() { sty &= m_EveryBit ^ m_AlignMask; } | 39 | class CBasicStyle |
40 | { | ||
41 | friend class CStyle; | ||
42 | bool m_bold, | ||
43 | m_italic; | ||
44 | int m_fontsize; | ||
45 | EalignmentType m_align; | ||
23 | unsigned char red, green, blue; | 46 | unsigned char red, green, blue; |
@@ -25,27 +48,20 @@ class CStyle | |||
25 | bool isLink; | 48 | bool isLink; |
26 | public: | 49 | bool m_underline; |
27 | unsigned char Red() { return red; } | 50 | bool m_strikethru; |
28 | unsigned char Green() { return green; } | 51 | bool m_monospaced; |
29 | unsigned char Blue() { return blue; } | 52 | unsigned char m_leftmargin, m_rightmargin; |
30 | void setColour(unsigned char r, unsigned char g, unsigned char b) | 53 | CBasicStyle() |
31 | { | 54 | { |
32 | red = r; | 55 | unset(); |
33 | green = g; | 56 | } |
34 | blue = b; | 57 | bool operator!=(const CBasicStyle& rhs) |
35 | } | 58 | { |
36 | static const StyleType m_AlignLeft = 0; | 59 | return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0); |
37 | static const StyleType m_AlignRight = 1 << m_AlignShift; | 60 | } |
38 | static const StyleType m_AlignCentre = 2 << m_AlignShift; | ||
39 | static const StyleType m_AlignJustify = 3 << m_AlignShift; | ||
40 | CStyle() | ||
41 | : | ||
42 | sty(m_FontBase), | ||
43 | red(0), green(0), blue(0), | ||
44 | data(0), isLink(false) | ||
45 | {} | ||
46 | // CStyle(const int _fs) : sty(m_FontBase+_fs) {} | ||
47 | |||
48 | void unset() | 61 | void unset() |
49 | { | 62 | { |
50 | sty = m_FontBase; | 63 | m_bold = false; |
64 | m_italic = false; | ||
65 | m_fontsize = 0; | ||
66 | m_align = m_AlignLeft; | ||
51 | red = green = blue = 0; | 67 | red = green = blue = 0; |
@@ -53,10 +69,65 @@ class CStyle | |||
53 | isLink = false; | 69 | isLink = false; |
70 | m_underline = false; | ||
71 | m_strikethru = false; | ||
72 | m_leftmargin = 0; | ||
73 | m_rightmargin = 0; | ||
74 | m_monospaced = false; | ||
54 | } | 75 | } |
76 | }; | ||
55 | 77 | ||
56 | void setBold() { sty |= m_Bold; } | 78 | class CStyle |
57 | void setItalic() { sty |= m_Italic; } | 79 | { |
58 | void unsetBold() { sty &= m_EveryBit ^ m_Bold; } | 80 | CBasicStyle sty; |
59 | void unsetItalic() { sty &= m_EveryBit ^ m_Italic; } | 81 | pmstore* graphic; |
60 | bool isBold() { return ((sty & m_Bold) != 0); } | 82 | public: |
61 | bool isItalic() { return ((sty & m_Italic) != 0); } | 83 | bool getPictureLink() |
84 | { | ||
85 | return (graphic != NULL && graphic->graphic->isLink); | ||
86 | } | ||
87 | unsigned long getPictureLinkData() | ||
88 | { | ||
89 | return graphic->graphic->link; | ||
90 | } | ||
91 | void setLeftMargin(unsigned char m) { sty.m_leftmargin = m; } | ||
92 | unsigned char getLeftMargin() { return sty.m_leftmargin; } | ||
93 | void setRightMargin(unsigned char m) { sty.m_rightmargin = m; } | ||
94 | unsigned char getRightMargin() { return sty.m_rightmargin; } | ||
95 | unsigned char Red() { return sty.red; } | ||
96 | unsigned char Green() { return sty.green; } | ||
97 | unsigned char Blue() { return sty.blue; } | ||
98 | void setColour(unsigned char r, unsigned char g, unsigned char b) | ||
99 | { | ||
100 | sty.red = r; | ||
101 | sty.green = g; | ||
102 | sty.blue = b; | ||
103 | } | ||
104 | CStyle() : graphic(NULL) {} | ||
105 | ~CStyle(); | ||
106 | CStyle(CStyle&); | ||
107 | CStyle(const CStyle&); | ||
108 | CStyle& operator=(const CStyle&); | ||
109 | void unset(); | ||
110 | bool isPicture() { return (graphic != NULL); } | ||
111 | void clearPicture(); | ||
112 | void setPicture(QPixmap* _g, bool il=false, unsigned long tgt=0); | ||
113 | QPixmap* getPicture() | ||
114 | { | ||
115 | QPixmap* pm = ((graphic != NULL) ? graphic->graphic->graphic : NULL); | ||
116 | return pm; | ||
117 | } | ||
118 | void setUnderline() { sty.m_underline = true; } | ||
119 | void unsetUnderline() { sty.m_underline = false; } | ||
120 | bool isUnderline() { return sty.m_underline; } | ||
121 | void setStrikethru() { sty.m_strikethru = true; } | ||
122 | void unsetStrikethru() { sty.m_strikethru = false; } | ||
123 | bool isStrikethru() { return sty.m_strikethru; } | ||
124 | void setBold() { sty.m_bold = true; } | ||
125 | void unsetBold() { sty.m_bold = false; } | ||
126 | bool isBold() { return sty.m_bold; } | ||
127 | void setItalic() { sty.m_italic = true; } | ||
128 | void unsetItalic() { sty.m_italic = false; } | ||
129 | bool isItalic() { return sty.m_italic; } | ||
130 | void setMono() { sty.m_monospaced = true; } | ||
131 | void unsetMono() { sty.m_monospaced = false; } | ||
132 | bool isMono() { return sty.m_monospaced; } | ||
62 | 133 | ||
@@ -64,4 +135,3 @@ class CStyle | |||
64 | { | 135 | { |
65 | unjustify(); | 136 | sty.m_align = m_AlignLeft; |
66 | sty |= m_AlignLeft; | ||
67 | } | 137 | } |
@@ -69,4 +139,3 @@ class CStyle | |||
69 | { | 139 | { |
70 | unjustify(); | 140 | sty.m_align = m_AlignRight; |
71 | sty |= m_AlignRight; | ||
72 | } | 141 | } |
@@ -74,4 +143,3 @@ class CStyle | |||
74 | { | 143 | { |
75 | unjustify(); | 144 | sty.m_align = m_AlignCentre; |
76 | sty |= m_AlignCentre; | ||
77 | } | 145 | } |
@@ -79,4 +147,3 @@ class CStyle | |||
79 | { | 147 | { |
80 | unjustify(); | 148 | sty.m_align = m_AlignJustify; |
81 | sty |= m_AlignJustify; | ||
82 | } | 149 | } |
@@ -84,3 +151,3 @@ class CStyle | |||
84 | { | 151 | { |
85 | return sty & m_AlignMask; | 152 | return sty.m_align; |
86 | } | 153 | } |
@@ -89,4 +156,3 @@ class CStyle | |||
89 | { | 156 | { |
90 | sty &= m_EveryBit ^ m_FontMask; | 157 | sty.m_fontsize = _fs; |
91 | sty |= m_FontBase + _fs; | ||
92 | } | 158 | } |
@@ -94,3 +160,3 @@ class CStyle | |||
94 | { | 160 | { |
95 | return (sty & m_FontMask) - m_FontBase; | 161 | return sty.m_fontsize; |
96 | } | 162 | } |
@@ -99,13 +165,11 @@ class CStyle | |||
99 | return | 165 | return |
100 | ( | 166 | ( |
101 | (sty != rhs.sty) || (red != rhs.red) || (green != rhs.green) || | 167 | (sty != rhs.sty) || |
102 | (blue != rhs.blue) || | 168 | (graphic != rhs.graphic) |
103 | (data != rhs.data) || | 169 | ); |
104 | (isLink != rhs.isLink) | 170 | } |
105 | ); | 171 | void setLink(bool _l) { sty.isLink = _l; } |
106 | } | 172 | bool getLink() { return sty.isLink; } |
107 | void setLink(bool _l) { isLink = _l; } | 173 | void setData(unsigned long _d) { sty.data = _d; } |
108 | bool getLink() { return isLink; } | 174 | unsigned long getData() { return sty.data; } |
109 | void setData(unsigned long _d) { data = _d; } | ||
110 | unsigned long getData() { return data; } | ||
111 | }; | 175 | }; |
diff --git a/noncore/apps/opie-reader/Text.h b/noncore/apps/opie-reader/Text.h deleted file mode 100644 index 4c689be..0000000 --- a/noncore/apps/opie-reader/Text.h +++ b/dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | #ifndef __Text_h | ||
2 | #define __Text_h | ||
3 | #include <stdio.h> | ||
4 | #include <sys/stat.h> | ||
5 | #include "CExpander.h" | ||
6 | |||
7 | class Text: public CExpander { | ||
8 | FILE* file; | ||
9 | public: | ||
10 | Text() : file(NULL) {}; | ||
11 | virtual ~Text() { if (file != NULL) fclose(file); } | ||
12 | virtual int openfile(const tchar *src) | ||
13 | { | ||
14 | if (file != NULL) fclose(file); | ||
15 | return ((file = fopen(src,"rb")) == NULL); | ||
16 | } | ||
17 | virtual int getch() { return fgetc(file); } | ||
18 | virtual unsigned int locate() { return ftell(file); } | ||
19 | virtual void locate(unsigned int n) { fseek(file,n,SEEK_SET); } | ||
20 | virtual bool hasrandomaccess() { return true; } | ||
21 | virtual void sizes(unsigned long& _file, unsigned long& _text) | ||
22 | { | ||
23 | struct stat _stat; | ||
24 | fstat(fileno(file),&_stat); | ||
25 | _text = _file = _stat.st_size; | ||
26 | } | ||
27 | }; | ||
28 | #endif | ||
diff --git a/noncore/apps/opie-reader/ZText.h b/noncore/apps/opie-reader/ZText.h index debfe8c..22d3733 100644 --- a/noncore/apps/opie-reader/ZText.h +++ b/noncore/apps/opie-reader/ZText.h | |||
@@ -12,2 +12,31 @@ class Text: public CExpander { | |||
12 | public: | 12 | public: |
13 | virtual void suspend() | ||
14 | { | ||
15 | bSuspended = true; | ||
16 | suspos = gztell(file); | ||
17 | gzclose(file); | ||
18 | file = NULL; | ||
19 | sustime = time(NULL); | ||
20 | } | ||
21 | virtual void unsuspend() | ||
22 | { | ||
23 | if (bSuspended) | ||
24 | { | ||
25 | bSuspended = false; | ||
26 | int delay = time(NULL) - sustime; | ||
27 | if (delay < 10) sleep(10-delay); | ||
28 | file = gzopen(fname, "rb"); | ||
29 | for (int i = 0; file == NULL && i < 5; i++) | ||
30 | { | ||
31 | sleep(5); | ||
32 | file = gzopen(fname, "rb"); | ||
33 | } | ||
34 | if (file == NULL) | ||
35 | { | ||
36 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); | ||
37 | exit(0); | ||
38 | } | ||
39 | suspos = gzseek(file, suspos, SEEK_SET); | ||
40 | } | ||
41 | } | ||
13 | Text() : file(NULL) {}; | 42 | Text() : file(NULL) {}; |
@@ -17,5 +46,5 @@ public: | |||
17 | } | 46 | } |
18 | virtual int openfile(const char *src) | 47 | virtual int OpenFile(const char *src) |
19 | { | 48 | { |
20 | if (file != NULL) gzclose(file); | 49 | if (file != NULL) gzclose(file); |
21 | struct stat _stat; | 50 | struct stat _stat; |
@@ -35,3 +64,3 @@ public: | |||
35 | { | 64 | { |
36 | return cTEXT; | 65 | return cTEXT; |
37 | } | 66 | } |
diff --git a/noncore/apps/opie-reader/cbkmkselector.h b/noncore/apps/opie-reader/cbkmkselector.h index 1a49c5a..1a70048 100644 --- a/noncore/apps/opie-reader/cbkmkselector.h +++ b/noncore/apps/opie-reader/cbkmkselector.h | |||
@@ -11,2 +11,3 @@ class CBkmkSelector : public QWidget | |||
11 | QListBox* bkmkselector; | 11 | QListBox* bkmkselector; |
12 | QPushButton* exitButton; | ||
12 | 13 | ||
@@ -29,3 +30,3 @@ public: | |||
29 | bkmkselector = new QListBox(this, "Bookmarks"); | 30 | bkmkselector = new QListBox(this, "Bookmarks"); |
30 | QPushButton* exitButton = new QPushButton("Cancel", this); | 31 | exitButton = new QPushButton("Cancel", this); |
31 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( slotSelected(int) ) ); | 32 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( slotSelected(int) ) ); |
@@ -39,2 +40,3 @@ public: | |||
39 | QString text(int index) const { return bkmkselector->text(index); } | 40 | QString text(int index) const { return bkmkselector->text(index); } |
41 | void setText(const QString& _l) { exitButton->setText(_l); } | ||
40 | }; | 42 | }; |
diff --git a/noncore/apps/opie-reader/config.h b/noncore/apps/opie-reader/config.h index 5150270..b6281a4 100644 --- a/noncore/apps/opie-reader/config.h +++ b/noncore/apps/opie-reader/config.h | |||
@@ -20,2 +20,6 @@ const int UEOF = -1; | |||
20 | 20 | ||
21 | #define BORDER 2 | ||
22 | |||
23 | //#define _FAST | ||
24 | |||
21 | #endif | 25 | #endif |
diff --git a/noncore/apps/opie-reader/fileBrowser.cpp b/noncore/apps/opie-reader/fileBrowser.cpp index b21d59d..21c970b 100644 --- a/noncore/apps/opie-reader/fileBrowser.cpp +++ b/noncore/apps/opie-reader/fileBrowser.cpp | |||
@@ -41,2 +41,3 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
41 | dirLabel = new QLabel(this, "DirLabel"); | 41 | dirLabel = new QLabel(this, "DirLabel"); |
42 | dirLabel->setAlignment(AlignLeft | AlignVCenter | ExpandTabs | WordBreak); | ||
42 | dirLabel->setText(currentDir.canonicalPath()); | 43 | dirLabel->setText(currentDir.canonicalPath()); |
@@ -49,2 +50,4 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
49 | ListView->setAllColumnsShowFocus( TRUE ); | 50 | ListView->setAllColumnsShowFocus( TRUE ); |
51 | ListView->setColumnWidthMode(0, QListView::Manual); | ||
52 | ListView->setColumnWidthMode(1, QListView::Manual); | ||
50 | 53 | ||
diff --git a/noncore/apps/opie-reader/infowin.cpp b/noncore/apps/opie-reader/infowin.cpp index 7b8f280..30adebf 100644 --- a/noncore/apps/opie-reader/infowin.cpp +++ b/noncore/apps/opie-reader/infowin.cpp | |||
@@ -1 +1,2 @@ | |||
1 | #include "name.h" | ||
1 | #include "infowin.h" | 2 | #include "infowin.h" |
@@ -4,3 +5,3 @@ | |||
4 | 5 | ||
5 | infowin::infowin( QWidget *parent, const char *name, WFlags f) : | 6 | infowin::infowin( QWidget *parent=0, const char *name=0, WFlags f = 0) : |
6 | QWidget(parent, name, f) | 7 | QWidget(parent, name, f) |
@@ -35,3 +36,3 @@ infowin::infowin( QWidget *parent, const char *name, WFlags f) : | |||
35 | char vstr[128]; | 36 | char vstr[128]; |
36 | sprintf(vstr, "QT Reader v%u.%u%c (%s)\nA small e-text reader", MAJOR, BKMKTYPE, MINOR, RELEASE_TYPE); | 37 | sprintf(vstr, PROGNAME " v%u.%u%c (%s)\nA small e-text reader", MAJOR, BKMKTYPE, MINOR, RELEASE_TYPE); |
37 | l = new QLabel(vstr, this); | 38 | l = new QLabel(vstr, this); |
diff --git a/noncore/apps/opie-reader/main.cpp b/noncore/apps/opie-reader/main.cpp index 08f59a8..2440037 100644 --- a/noncore/apps/opie-reader/main.cpp +++ b/noncore/apps/opie-reader/main.cpp | |||
@@ -11,3 +11,7 @@ void handler(int signum) | |||
11 | { | 11 | { |
12 | if (app != NULL) app->saveprefs(); | 12 | if (app != NULL) |
13 | { | ||
14 | app->suspend(); | ||
15 | app->saveprefs(); | ||
16 | } | ||
13 | signal(signum, handler); | 17 | signal(signum, handler); |
diff --git a/noncore/apps/opie-reader/name.h b/noncore/apps/opie-reader/name.h new file mode 100644 index 0000000..d419005 --- a/dev/null +++ b/noncore/apps/opie-reader/name.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef __NAME_H | ||
2 | #define __NAME_H | ||
3 | |||
4 | #define PROGNAME "Opie-Reader" | ||
5 | #define SHORTPROGNAME "Reader" | ||
6 | #define APPDIR "uqtreader" | ||
7 | |||
8 | #endif | ||
diff --git a/noncore/apps/opie-reader/opie-reader.pro b/noncore/apps/opie-reader/opie-reader.pro index 51849a3..139c03a 100644 --- a/noncore/apps/opie-reader/opie-reader.pro +++ b/noncore/apps/opie-reader/opie-reader.pro | |||
@@ -1,58 +1,73 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | HEADERS = Aportis.h \ | 3 | HEADERS = Aportis.h \ |
4 | BuffDoc.h \ | 4 | Bkmks.h \ |
5 | CBuffer.h \ | 5 | BuffDoc.h \ |
6 | CDrawBuffer.h \ | 6 | CAnnoEdit.h \ |
7 | CExpander.h \ | 7 | CBuffer.h \ |
8 | CFilter.h \ | 8 | CDrawBuffer.h \ |
9 | QTReader.h \ | 9 | CEncoding.h \ |
10 | QTReaderApp.h \ | 10 | CExpander.h \ |
11 | ZText.h \ | 11 | CFilter.h \ |
12 | arith.h \ | 12 | Filedata.h \ |
13 | my_list.h \ | 13 | FontControl.h \ |
14 | ppm.h \ | 14 | GraphicWin.h \ |
15 | ppm_expander.h \ | 15 | Markups.h \ |
16 | cbkmkselector.h \ | 16 | Navigation.h \ |
17 | fileBrowser.h \ | 17 | Palm2QImage.h \ |
18 | ztxt.h \ | 18 | QFloatBar.h \ |
19 | QtrListView.h \ | 19 | QTReader.h \ |
20 | infowin.h \ | 20 | QTReaderApp.h \ |
21 | version.h \ | 21 | QtrListView.h \ |
22 | pdb.h \ | 22 | Queue.h \ |
23 | utypes.h \ | 23 | StateData.h \ |
24 | ustring.h \ | 24 | StyleConsts.h \ |
25 | CEncoding.h \ | 25 | ZText.h \ |
26 | CAnnoEdit.h \ | 26 | arith.h \ |
27 | QFloatBar.h \ | 27 | cbkmkselector.h \ |
28 | StyleConsts.h \ | 28 | config.h \ |
29 | FontControl.h \ | 29 | fileBrowser.h \ |
30 | plucker.h \ | 30 | infowin.h \ |
31 | Markups.h \ | 31 | my_list.h \ |
32 | Bkmks.h \ | 32 | name.h \ |
33 | config.h | 33 | opie.h \ |
34 | SOURCES = Aportis.cpp \ | 34 | pdb.h \ |
35 | BuffDoc.cpp \ | 35 | plucker.h \ |
36 | CBuffer.cpp \ | 36 | ppm.h \ |
37 | CDrawBuffer.cpp \ | 37 | ppm_expander.h \ |
38 | QTReader.cpp \ | 38 | ustring.h \ |
39 | QTReaderApp.cpp \ | 39 | utypes.h \ |
40 | arith_d.cpp \ | 40 | version.h \ |
41 | main.cpp \ | 41 | ztxt.h |
42 | ppm.cpp \ | 42 | |
43 | ppm_expander.cpp \ | 43 | SOURCES = Aportis.cpp \ |
44 | ztxt.cpp \ | 44 | Bkmks.cpp \ |
45 | QtrListView.cpp \ | 45 | BuffDoc.cpp \ |
46 | infowin.cpp \ | 46 | CBuffer.cpp \ |
47 | pdb.cpp \ | 47 | CDrawBuffer.cpp \ |
48 | CEncoding.cpp \ | 48 | CEncoding.cpp \ |
49 | CFilter.cpp \ | 49 | CFilter.cpp \ |
50 | plucker.cpp \ | 50 | FontControl.cpp \ |
51 | Bkmks.cpp \ | 51 | Navigation.cpp \ |
52 | fileBrowser.cpp | 52 | Palm2QImage.cpp \ |
53 | DESTDIR = $(OPIEDIR)/bin | 53 | QTReader.cpp \ |
54 | INCLUDEPATH += $(OPIEDIR)/include | 54 | QTReaderApp.cpp \ |
55 | DEPENDPATH += $(OPIEDIR)/include | 55 | QtrListView.cpp \ |
56 | TARGET = reader | 56 | StyleConsts.cpp \ |
57 | LIBS += -lqpe | 57 | arith_d.cpp \ |
58 | fileBrowser.cpp \ | ||
59 | infowin.cpp \ | ||
60 | main.cpp \ | ||
61 | pdb.cpp \ | ||
62 | plucker.cpp \ | ||
63 | ppm.cpp \ | ||
64 | ppm_expander.cpp \ | ||
65 | ztxt.cpp | ||
66 | |||
67 | INTERFACES= | ||
68 | DESTDIR = $(OPIEDIR)/bin | ||
69 | INCLUDEPATH+= $(OPIEDIR)/include | ||
70 | DEPENDPATH+= $(OPIEDIR)/include | ||
71 | TARGET = reader | ||
72 | LIBS += -lqpe | ||
58 | 73 | ||
diff --git a/noncore/apps/opie-reader/opie.h b/noncore/apps/opie-reader/opie.h new file mode 100644 index 0000000..e28c2ab --- a/dev/null +++ b/noncore/apps/opie-reader/opie.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __OPIE_H | ||
2 | #define __OPIE_H | ||
3 | |||
4 | #define OPIE | ||
5 | |||
6 | #endif | ||
diff --git a/noncore/apps/opie-reader/pdb.cpp b/noncore/apps/opie-reader/pdb.cpp index 68b904e..3054424 100644 --- a/noncore/apps/opie-reader/pdb.cpp +++ b/noncore/apps/opie-reader/pdb.cpp | |||
@@ -1,2 +1,5 @@ | |||
1 | #include "pdb.h" | 1 | #include "pdb.h" |
2 | #include <sys/types.h> | ||
3 | #include <sys/stat.h> | ||
4 | #include <unistd.h> | ||
2 | 5 | ||
@@ -48,6 +51,9 @@ bool Cpdb::openfile(const char *src) | |||
48 | //char buf[0x100]; | 51 | //char buf[0x100]; |
49 | fseek(fin,0,SEEK_END); | 52 | struct stat buf; |
50 | file_length = ftell(fin); | 53 | stat(src, &buf); |
54 | file_length = buf.st_size; | ||
55 | // fseek(fin,0,SEEK_END); | ||
56 | // file_length = ftell(fin); | ||
51 | 57 | ||
52 | fseek(fin,0,SEEK_SET); | 58 | // fseek(fin,0,SEEK_SET); |
53 | 59 | ||
diff --git a/noncore/apps/opie-reader/plucker.cpp b/noncore/apps/opie-reader/plucker.cpp index ddda4bc..eb039de 100644 --- a/noncore/apps/opie-reader/plucker.cpp +++ b/noncore/apps/opie-reader/plucker.cpp | |||
@@ -3,14 +3,54 @@ | |||
3 | #include <qmessagebox.h> | 3 | #include <qmessagebox.h> |
4 | #include "plucker.h" | 4 | #include <qpixmap.h> |
5 | #include <qpe/qcopenvelope_qws.h> | ||
6 | #ifdef LOCALPICTURES | ||
7 | #include <qscrollview.h> | ||
8 | #endif | ||
9 | #include <qpe/global.h> | ||
10 | #include <qclipboard.h> | ||
11 | #include <qpe/qpeapplication.h> | ||
5 | 12 | ||
13 | #include "plucker.h" | ||
6 | #include "Aportis.h" | 14 | #include "Aportis.h" |
15 | #include "Palm2QImage.h" | ||
16 | #include "name.h" | ||
17 | |||
18 | CPlucker::CPlucker() : | ||
19 | #ifdef LOCALPICTURES | ||
20 | m_viewer(NULL), | ||
21 | m_picture(NULL), | ||
22 | #endif | ||
23 | expandedtextbuffer(NULL), | ||
24 | compressedtextbuffer(NULL), | ||
25 | urls(NULL) | ||
26 | { /*printf("constructing:%x\n",fin);*/ } | ||
7 | 27 | ||
8 | CPlucker::CPlucker() : expandedtextbuffer(NULL), compressedtextbuffer(NULL) { /*printf("constructing:%x\n",fin);*/ } | ||
9 | 28 | ||
29 | void CPlucker::Expand(UInt16 reclen, UInt8 type, UInt8* buffer, UInt16 buffersize) | ||
30 | { | ||
31 | if (type%2 == 0) | ||
32 | { | ||
33 | fread(buffer, reclen, sizeof(char), fin); | ||
34 | } | ||
35 | else | ||
36 | { | ||
37 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | ||
38 | switch (ntohs(hdr0.version)) | ||
39 | { | ||
40 | case 2: | ||
41 | UnZip(reclen, buffer, buffersize); | ||
42 | break; | ||
43 | case 1: | ||
44 | UnDoc(reclen, buffer, buffersize); | ||
45 | break; | ||
46 | } | ||
47 | } | ||
48 | } | ||
10 | 49 | ||
11 | int CPlucker::openfile(const char *src) | 50 | int CPlucker::OpenFile(const char *src) |
12 | { | 51 | { |
52 | m_lastBreak = 0; | ||
13 | if (!Cpdb::openfile(src)) | 53 | if (!Cpdb::openfile(src)) |
14 | { | 54 | { |
15 | return -1; | 55 | return -1; |
16 | } | 56 | } |
@@ -23,11 +63,3 @@ int CPlucker::openfile(const char *src) | |||
23 | 63 | ||
24 | textlength = 0; | 64 | EOPPhase = 0; |
25 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | ||
26 | { | ||
27 | CPlucker_dataRecord thisHdr; | ||
28 | gotorecordnumber(recptr); | ||
29 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | ||
30 | if (thisHdr.type < 2) textlength += htons(thisHdr.size); | ||
31 | } | ||
32 | |||
33 | gotorecordnumber(0); | 65 | gotorecordnumber(0); |
@@ -39,14 +71,140 @@ int CPlucker::openfile(const char *src) | |||
39 | 71 | ||
40 | // qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); | 72 | qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); |
41 | 73 | ||
42 | unsigned int nrecs = ntohs(hdr0.nRecords); | 74 | unsigned int nrecs = ntohs(hdr0.nRecords); |
43 | // qDebug("Version %u, no. res %u", ntohs(hdr0.version), nrecs); | 75 | qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); |
44 | for (unsigned int i = 0; i < 4*nrecs; i++) | 76 | UInt16 homerecid = 1; |
77 | UInt16 urlid = 0; | ||
78 | bool urlsfound = false; | ||
79 | for (unsigned int i = 0; i < nrecs; i++) | ||
45 | { | 80 | { |
46 | UInt8 id; | 81 | UInt16 id, name; |
47 | fread(&id, 1, sizeof(id), fin); | 82 | fread(&name, 1, sizeof(name), fin); |
48 | // qDebug("%x", id); | 83 | fread(&id, 1, sizeof(id), fin); |
84 | qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); | ||
85 | if (ntohs(name) == 0) homerecid = ntohs(id); | ||
86 | if (ntohs(name) == 2) | ||
87 | { | ||
88 | urlsfound = true; | ||
89 | urlid = id; | ||
90 | qDebug("Found url index:%d", ntohs(urlid)); | ||
91 | } | ||
92 | //qDebug("%x", id); | ||
49 | } | 93 | } |
94 | |||
95 | textlength = 0; | ||
96 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | ||
97 | { | ||
98 | CPlucker_dataRecord thisHdr; | ||
99 | gotorecordnumber(recptr); | ||
100 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | ||
101 | if (ntohs(thisHdr.uid) == homerecid) | ||
102 | { | ||
103 | m_homepos = textlength; | ||
104 | qDebug("Home pos found after %u records", recptr); | ||
105 | break; | ||
106 | } | ||
107 | if (thisHdr.type < 2) textlength += ntohs(thisHdr.size); | ||
108 | } | ||
109 | textlength = 0; | ||
110 | |||
111 | if (urlsfound) | ||
112 | { | ||
113 | unsigned short recptr = finduid(ntohs(urlid)); | ||
114 | if (recptr != 0) | ||
115 | { | ||
116 | CPlucker_dataRecord thisHdr; | ||
117 | gotorecordnumber(recptr); | ||
118 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | ||
119 | fread(&urlid, 1, sizeof(urlid), fin); | ||
120 | fread(&urlid, 1, sizeof(urlid), fin); | ||
121 | qDebug("urls are in %d", ntohs(urlid)); | ||
122 | recptr = finduid(ntohs(urlid)); | ||
123 | if (recptr != 0) | ||
124 | { | ||
125 | gotorecordnumber(recptr); | ||
126 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | ||
127 | qDebug("Found urls:%x",thisHdr.type); | ||
128 | UInt16 reclen = recordlength(recptr) - sizeof(thisHdr); | ||
129 | gotorecordnumber(recptr); | ||
130 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | ||
131 | urlsize = ntohs(thisHdr.size); | ||
132 | urls = new char[urlsize]; | ||
133 | Expand(reclen, thisHdr.type, (UInt8*)urls, urlsize); | ||
134 | } | ||
135 | } | ||
136 | } | ||
137 | /* | ||
138 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | ||
139 | { | ||
140 | CPlucker_dataRecord thisHdr; | ||
141 | gotorecordnumber(recptr); | ||
142 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | ||
143 | if (thisHdr.uid == urlid) | ||
144 | { | ||
145 | qDebug("Found urls:%x",thisHdr.type); | ||
146 | UInt16 reclen = recordlength(recptr) - sizeof(thisHdr); | ||
147 | gotorecordnumber(recptr); | ||
148 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | ||
149 | urlsize = ntohs(thisHdr.size); | ||
150 | urls = new char[urlsize]; | ||
151 | Expand(reclen, thisHdr.type, (UInt8*)urls, urlsize); | ||
152 | break; | ||
153 | } | ||
154 | } | ||
155 | */ | ||
50 | home(); | 156 | home(); |
157 | #ifdef LOCALPICTURES | ||
158 | if (m_viewer == NULL) | ||
159 | { | ||
160 | m_viewer = new QScrollView(NULL); | ||
161 | m_picture = new QWidget(m_viewer->viewport()); | ||
162 | m_viewer->addChild(m_picture); | ||
163 | } | ||
164 | #endif | ||
51 | return 0; | 165 | return 0; |
166 | |||
167 | } | ||
168 | |||
169 | void CPlucker::sizes(unsigned long& _file, unsigned long& _text) | ||
170 | { | ||
171 | qDebug("Sizes called:%u",textlength); | ||
172 | _file = file_length; | ||
173 | if (textlength == 0) | ||
174 | { | ||
175 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | ||
176 | { | ||
177 | CPlucker_dataRecord thisHdr; | ||
178 | gotorecordnumber(recptr); | ||
179 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | ||
180 | if (thisHdr.type < 2) textlength += ntohs(thisHdr.size); | ||
181 | } | ||
182 | } | ||
183 | _text = textlength; | ||
184 | //ntohl(hdr0.size); | ||
185 | } | ||
186 | |||
187 | |||
188 | char* CPlucker::geturl(UInt16 i) | ||
189 | { | ||
190 | if (urls == NULL) return NULL; | ||
191 | char* ptr = urls; | ||
192 | int rn = 1; | ||
193 | while (ptr - urls < urlsize) | ||
194 | { | ||
195 | if (rn == i) return ptr; | ||
196 | ptr += strlen(ptr)+1; | ||
197 | rn++; | ||
198 | } | ||
199 | return NULL; | ||
200 | } | ||
201 | |||
202 | CPlucker::~CPlucker() | ||
203 | { | ||
204 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; | ||
205 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; | ||
206 | if (urls != NULL) delete [] urls; | ||
207 | #ifdef LOCALPICTURES | ||
208 | if (m_viewer != NULL) delete m_viewer; | ||
209 | #endif | ||
52 | } | 210 | } |
@@ -58,22 +216,35 @@ int CPlucker::bgetch() | |||
58 | { | 216 | { |
59 | if (bufferrec >= ntohs(head.recordList.numRecords) - 1) return EOF; | 217 | if (!m_continuous) return EOF; |
60 | // qDebug("Passing through %u", currentpos); | 218 | if (bufferrec >= ntohs(head.recordList.numRecords) - 1) return EOF; |
61 | if (!expand(bufferrec+1)) return EOF; | 219 | //qDebug("Passing through %u", currentpos); |
62 | mystyle.unset(); | 220 | if (!expand(bufferrec+1)) return EOF; |
221 | mystyle.unset(); | ||
222 | ch = 10; | ||
223 | EOPPhase = 4; | ||
63 | } | 224 | } |
64 | 225 | else if (bufferpos == m_nextPara) | |
65 | if (bufferpos == m_nextPara) | ||
66 | { | 226 | { |
67 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; | 227 | while (bufferpos == m_nextPara) |
68 | m_nextParaIndex++; | 228 | { |
69 | if (m_nextParaIndex == m_nParas) | 229 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; |
70 | { | 230 | m_nextParaIndex++; |
71 | m_nextPara = -1; | 231 | if (m_nextParaIndex == m_nParas) |
72 | } | 232 | { |
73 | else | 233 | m_nextPara = -1; |
74 | { | 234 | } |
75 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | 235 | else |
76 | } | 236 | { |
77 | // qDebug("New paragraph"); | 237 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; |
78 | ch = 10; | 238 | } |
239 | } | ||
240 | mystyle.unset(); | ||
241 | if (m_lastBreak == locate()) | ||
242 | { | ||
243 | currentpos++; | ||
244 | ch = expandedtextbuffer[bufferpos++]; | ||
245 | } | ||
246 | else | ||
247 | { | ||
248 | ch = 10; | ||
249 | } | ||
79 | } | 250 | } |
@@ -81,4 +252,4 @@ int CPlucker::bgetch() | |||
81 | { | 252 | { |
82 | currentpos++; | 253 | currentpos++; |
83 | ch = expandedtextbuffer[bufferpos++]; | 254 | ch = expandedtextbuffer[bufferpos++]; |
84 | } | 255 | } |
@@ -89,172 +260,307 @@ int CPlucker::getch() | |||
89 | { | 260 | { |
90 | int ch = bgetch(); | 261 | mystyle.clearPicture(); |
91 | while (ch == 0) | 262 | |
92 | { | 263 | |
93 | ch = bgetch(); | 264 | if (EOPPhase > 0) |
94 | // qDebug("Function:%x", ch); | ||
95 | switch (ch) | ||
96 | { | ||
97 | case 0x38: | ||
98 | ch = 10; | ||
99 | break; | ||
100 | case 0x0a: | ||
101 | case 0x0c: | ||
102 | { | ||
103 | unsigned long ln = 0; | ||
104 | int skip = ch & 7; | ||
105 | for (int i = 0; i < 2; i++) | ||
106 | { | 265 | { |
107 | int ch = bgetch(); | 266 | int ch = 10; |
108 | ln = (ln << 8) + ch; | 267 | switch (EOPPhase) |
109 | // qDebug("ch:%d, ln:%u", ch, ln); | 268 | { |
269 | case 4: | ||
270 | mystyle.setPicture(hRule(100,5)); | ||
271 | mystyle.setCentreJustify(); | ||
272 | ch = '#'; | ||
273 | break; | ||
274 | case 3: | ||
275 | mystyle.setFontSize(3); | ||
276 | ch = 10; | ||
277 | break; | ||
278 | case 2: | ||
279 | ch = 10; | ||
280 | break; | ||
281 | case 1: | ||
282 | mystyle.unset(); | ||
283 | default: | ||
284 | ch = 10; | ||
285 | } | ||
286 | EOPPhase--; | ||
287 | return ch; | ||
110 | } | 288 | } |
111 | if (skip == 2) | 289 | |
290 | |||
291 | int ch = bgetch(); | ||
292 | while (ch == 0) | ||
112 | { | 293 | { |
113 | ln <<= 16; | 294 | ch = bgetch(); |
295 | //qDebug("Function:%x", ch); | ||
296 | switch (ch) | ||
297 | { | ||
298 | case 0x38: | ||
299 | // qDebug("Break:%u", locate()); | ||
300 | if (m_lastBreak == locate()) | ||
301 | { | ||
302 | ch = bgetch(); | ||
303 | } | ||
304 | else | ||
305 | { | ||
306 | ch = 10; | ||
307 | } | ||
308 | m_lastBreak = locate(); | ||
309 | break; | ||
310 | case 0x0a: | ||
311 | case 0x0c: | ||
312 | { | ||
313 | unsigned long ln = 0; | ||
314 | int skip = ch & 7; | ||
315 | for (int i = 0; i < 2; i++) | ||
316 | { | ||
317 | int ch = bgetch(); | ||
318 | ln = (ln << 8) + ch; | ||
319 | // qDebug("ch:%d, ln:%u", ch, ln); | ||
320 | } | ||
321 | if (skip == 2) | ||
322 | { | ||
323 | ln <<= 16; | ||
324 | } | ||
325 | else | ||
326 | { | ||
327 | for (int i = 0; i < 2; i++) | ||
328 | { | ||
329 | int ch = bgetch(); | ||
330 | ln = (ln << 8) + ch; | ||
331 | // qDebug("ch:%d, ln:%u", ch, ln); | ||
332 | } | ||
333 | } | ||
334 | // qDebug("ln:%u", ln); | ||
335 | mystyle.setLink(true); | ||
336 | mystyle.setData(ln); | ||
337 | // mystyle.setColour(255, 0, 0); | ||
338 | bool hasseen = false; | ||
339 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | ||
340 | { | ||
341 | if (*it == ln) | ||
342 | { | ||
343 | hasseen = true; | ||
344 | break; | ||
345 | } | ||
346 | } | ||
347 | if (hasseen) | ||
348 | { | ||
349 | mystyle.setStrikethru(); | ||
350 | } | ||
351 | else | ||
352 | { | ||
353 | mystyle.setUnderline(); | ||
354 | } | ||
355 | ch = bgetch(); | ||
356 | } | ||
357 | break; | ||
358 | case 0x08: | ||
359 | ch = bgetch(); | ||
360 | // mystyle.setColour(0, 0, 0); | ||
361 | mystyle.unsetUnderline(); | ||
362 | mystyle.unsetStrikethru(); | ||
363 | mystyle.setLink(false); | ||
364 | mystyle.setData(0); | ||
365 | break; | ||
366 | case 0x40: | ||
367 | mystyle.setItalic(); | ||
368 | ch = bgetch(); | ||
369 | break; | ||
370 | case 0x48: | ||
371 | mystyle.unsetItalic(); | ||
372 | ch = bgetch(); | ||
373 | break; | ||
374 | case 0x11: | ||
375 | { | ||
376 | ch = bgetch(); | ||
377 | // qDebug("Font:%d",ch); | ||
378 | switch (ch) | ||
379 | { | ||
380 | case 0: | ||
381 | mystyle.unsetMono(); | ||
382 | mystyle.unsetBold(); | ||
383 | mystyle.setFontSize(0); | ||
384 | break; | ||
385 | case 1: | ||
386 | mystyle.unsetMono(); | ||
387 | mystyle.setBold(); | ||
388 | mystyle.setFontSize(3); | ||
389 | break; | ||
390 | case 2: | ||
391 | mystyle.unsetMono(); | ||
392 | mystyle.setBold(); | ||
393 | mystyle.setFontSize(2); | ||
394 | break; | ||
395 | case 3: | ||
396 | mystyle.unsetMono(); | ||
397 | mystyle.setBold(); | ||
398 | // mystyle.unsetBold(); | ||
399 | mystyle.setFontSize(1); | ||
400 | break; | ||
401 | case 4: | ||
402 | mystyle.unsetMono(); | ||
403 | mystyle.setBold(); | ||
404 | // mystyle.unsetBold(); | ||
405 | mystyle.setFontSize(0); | ||
406 | break; | ||
407 | case 5: | ||
408 | mystyle.unsetMono(); | ||
409 | mystyle.setBold(); | ||
410 | mystyle.setFontSize(0); | ||
411 | break; | ||
412 | case 6: | ||
413 | mystyle.unsetMono(); | ||
414 | mystyle.setBold(); | ||
415 | mystyle.setFontSize(0); | ||
416 | break; | ||
417 | case 7: | ||
418 | mystyle.unsetMono(); | ||
419 | mystyle.setBold(); | ||
420 | mystyle.setFontSize(0); | ||
421 | break; | ||
422 | case 8: // should be fixed width | ||
423 | qDebug("Trying fixed width"); | ||
424 | mystyle.unsetBold(); | ||
425 | mystyle.setFontSize(0); | ||
426 | mystyle.setMono(); | ||
427 | break; | ||
428 | default: | ||
429 | mystyle.unsetBold(); | ||
430 | mystyle.unsetMono(); | ||
431 | mystyle.setFontSize(0); | ||
432 | break; | ||
433 | } | ||
434 | ch = bgetch(); | ||
435 | } | ||
436 | break; | ||
437 | case 0x29: | ||
438 | ch = bgetch(); | ||
439 | switch (ch) | ||
440 | { | ||
441 | case 0: | ||
442 | mystyle.setLeftJustify(); | ||
443 | // qDebug("left"); | ||
444 | break; | ||
445 | case 1: | ||
446 | mystyle.setRightJustify(); | ||
447 | // qDebug("right"); | ||
448 | break; | ||
449 | case 2: | ||
450 | mystyle.setCentreJustify(); | ||
451 | // qDebug("centre"); | ||
452 | break; | ||
453 | case 3: | ||
454 | mystyle.setFullJustify(); | ||
455 | // qDebug("full"); | ||
456 | break; | ||
457 | |||
458 | } | ||
459 | ch = bgetch(); | ||
460 | break; | ||
461 | case 0x53: | ||
462 | { | ||
463 | int r = bgetch(); | ||
464 | int g = bgetch(); | ||
465 | int b = bgetch(); | ||
466 | mystyle.setColour(r,g,b); | ||
467 | ch = bgetch(); | ||
468 | } | ||
469 | break; | ||
470 | case 0x1a: | ||
471 | case 0x5c: | ||
472 | { | ||
473 | bool hasalternate = (ch == 0x5c); | ||
474 | UInt16 ir = bgetch(); | ||
475 | ir = (ir << 8) + bgetch(); | ||
476 | if (hasalternate) | ||
477 | { | ||
478 | qDebug("Alternate image:%x", ir); | ||
479 | UInt16 ir2 = bgetch(); | ||
480 | ir2 = (ir2 << 8) + bgetch(); | ||
481 | mystyle.setPicture(expandimg(ir2, true), true, ir); | ||
482 | #ifdef LOCALPICTURES | ||
483 | UInt32 ln = ir; | ||
484 | ln <<= 16; | ||
485 | mystyle.setLink(true); | ||
486 | mystyle.setData(ln); | ||
487 | #endif | ||
488 | } | ||
489 | else | ||
490 | { | ||
491 | mystyle.setPicture(expandimg(ir)); | ||
492 | } | ||
493 | if (mystyle.getLink()) qDebug("Picture link!"); | ||
494 | ch = '#'; | ||
495 | } | ||
496 | // ch = bgetch(); | ||
497 | break; | ||
498 | case 0x33: | ||
499 | { | ||
500 | UInt8 h = bgetch(); | ||
501 | UInt8 wc = bgetch(); | ||
502 | UInt8 pc = bgetch(); | ||
503 | UInt16 w = wc; | ||
504 | // qDebug("h,w,pc [%u, %u, %u]", h, w, pc); | ||
505 | if (w == 0) | ||
506 | { | ||
507 | w = (240*(unsigned long)pc)/100; | ||
508 | } | ||
509 | if (w == 0) w = 320; | ||
510 | mystyle.setPicture(hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); | ||
511 | // if (mystyle.getLink()) qDebug("hRule link!"); | ||
512 | ch = '#'; | ||
513 | } | ||
514 | break; | ||
515 | case 0x60: | ||
516 | mystyle.setUnderline(); | ||
517 | ch = bgetch(); | ||
518 | break; | ||
519 | case 0x68: | ||
520 | mystyle.unsetUnderline(); | ||
521 | ch = bgetch(); | ||
522 | break; | ||
523 | case 0x22: | ||
524 | ch = bgetch(); | ||
525 | mystyle.setLeftMargin(ch); | ||
526 | // qDebug("Left margin:%d", ch); | ||
527 | ch = bgetch(); | ||
528 | mystyle.setRightMargin(ch); | ||
529 | // qDebug("Right margin:%d", ch); | ||
530 | ch = bgetch(); | ||
531 | break; | ||
532 | case 0x70: | ||
533 | mystyle.setStrikethru(); | ||
534 | ch = bgetch(); | ||
535 | break; | ||
536 | case 0x78: | ||
537 | mystyle.unsetStrikethru(); | ||
538 | ch = bgetch(); | ||
539 | break; | ||
540 | case 0x83: | ||
541 | case 0x85: | ||
542 | default: | ||
543 | qDebug("Function:%x NOT IMPLEMENTED", ch); | ||
544 | { | ||
545 | int skip = ch & 7; | ||
546 | for (int i = 0; i < skip; i++) | ||
547 | { | ||
548 | ch = bgetch(); | ||
549 | // qDebug("Arg %d, %d", i, ch); | ||
550 | } | ||
551 | ch = bgetch(); | ||
552 | } | ||
553 | } | ||
114 | } | 554 | } |
115 | else | 555 | |
556 | if (m_lastIsBreak && !mystyle.isMono()) | ||
116 | { | 557 | { |
117 | for (int i = 0; i < 2; i++) | 558 | while (ch == ' ') |
118 | { | 559 | { |
119 | int ch = bgetch(); | 560 | ch = getch(); |
120 | ln = (ln << 8) + ch; | 561 | } |
121 | // qDebug("ch:%d, ln:%u", ch, ln); | ||
122 | } | ||
123 | } | ||
124 | // qDebug("ln:%u", ln); | ||
125 | mystyle.setLink(true); | ||
126 | mystyle.setData(ln); | ||
127 | mystyle.setColour(255, 0, 0); | ||
128 | ch = bgetch(); | ||
129 | } | ||
130 | break; | ||
131 | case 0x08: | ||
132 | ch = bgetch(); | ||
133 | mystyle.setColour(0, 0, 0); | ||
134 | mystyle.setLink(false); | ||
135 | mystyle.setData(0); | ||
136 | break; | ||
137 | case 0x40: | ||
138 | mystyle.setItalic(); | ||
139 | ch = bgetch(); | ||
140 | break; | ||
141 | case 0x48: | ||
142 | mystyle.unsetItalic(); | ||
143 | ch = bgetch(); | ||
144 | break; | ||
145 | case 0x11: | ||
146 | { | ||
147 | ch = bgetch(); | ||
148 | qDebug("Font:%d",ch); | ||
149 | switch (ch) | ||
150 | { | ||
151 | case 0: | ||
152 | mystyle.unsetBold(); | ||
153 | mystyle.setFontSize(0); | ||
154 | break; | ||
155 | case 1: | ||
156 | mystyle.setBold(); | ||
157 | mystyle.setFontSize(1); | ||
158 | break; | ||
159 | case 2: | ||
160 | mystyle.setBold(); | ||
161 | mystyle.setFontSize(1); | ||
162 | break; | ||
163 | case 3: | ||
164 | // mystyle.setBold(); | ||
165 | mystyle.setFontSize(1); | ||
166 | break; | ||
167 | case 4: | ||
168 | // mystyle.setBold(); | ||
169 | mystyle.setFontSize(1); | ||
170 | break; | ||
171 | case 5: | ||
172 | mystyle.setBold(); | ||
173 | mystyle.setFontSize(0); | ||
174 | break; | ||
175 | case 6: | ||
176 | mystyle.setBold(); | ||
177 | mystyle.setFontSize(0); | ||
178 | break; | ||
179 | case 7: | ||
180 | mystyle.setBold(); | ||
181 | mystyle.setFontSize(0); | ||
182 | break; | ||
183 | case 8: // should be fixed width | ||
184 | mystyle.unsetBold(); | ||
185 | mystyle.setFontSize(0); | ||
186 | break; | ||
187 | default: | ||
188 | mystyle.unsetBold(); | ||
189 | mystyle.setFontSize(0); | ||
190 | break; | ||
191 | } | ||
192 | ch = bgetch(); | ||
193 | } | ||
194 | break; | ||
195 | case 0x29: | ||
196 | ch = bgetch(); | ||
197 | switch (ch) | ||
198 | { | ||
199 | case 0: | ||
200 | mystyle.setLeftJustify(); | ||
201 | // qDebug("left"); | ||
202 | break; | ||
203 | case 1: | ||
204 | mystyle.setRightJustify(); | ||
205 | // qDebug("right"); | ||
206 | break; | ||
207 | case 2: | ||
208 | mystyle.setCentreJustify(); | ||
209 | // qDebug("centre"); | ||
210 | break; | ||
211 | case 3: | ||
212 | mystyle.setFullJustify(); | ||
213 | // qDebug("full"); | ||
214 | break; | ||
215 | |||
216 | } | ||
217 | ch = bgetch(); | ||
218 | break; | ||
219 | case 0x53: | ||
220 | { | ||
221 | int r = bgetch(); | ||
222 | int g = bgetch(); | ||
223 | int b = bgetch(); | ||
224 | mystyle.setColour(r,g,b); | ||
225 | ch = bgetch(); | ||
226 | } | ||
227 | break; | ||
228 | case 0x1a: | ||
229 | /* | ||
230 | { | ||
231 | UInt16 ir = bgetch(); | ||
232 | ir = (ir << 8) + bgetch(); | ||
233 | expandimg(ir); | ||
234 | } | ||
235 | ch = bgetch(); | ||
236 | break; | ||
237 | */ | ||
238 | case 0x33: | ||
239 | case 0x22: | ||
240 | case 0x5c: | ||
241 | case 0x60: | ||
242 | case 0x68: | ||
243 | case 0x70: | ||
244 | case 0x78: | ||
245 | case 0x83: | ||
246 | case 0x85: | ||
247 | default: | ||
248 | qDebug("Function:%x NOT IMPLEMENTED", ch); | ||
249 | { | ||
250 | int skip = ch & 7; | ||
251 | for (int i = 0; i < skip; i++) | ||
252 | { | ||
253 | ch = bgetch(); | ||
254 | qDebug("Arg %d, %d", i, ch); | ||
255 | } | ||
256 | ch = bgetch(); | ||
257 | } | ||
258 | } | ||
259 | } | 562 | } |
563 | |||
564 | m_lastIsBreak = (ch == 10); | ||
565 | |||
260 | return ch; | 566 | return ch; |
@@ -278,6 +584,6 @@ unsigned int CPlucker::locate() | |||
278 | { | 584 | { |
279 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | 585 | fread(&thisHdr, 1, sizeof(thisHdr), fin); |
280 | if (thisHdr.type < 2) locpos += htons(thisHdr.size); | 586 | if (thisHdr.type < 2) locpos += ntohs(thisHdr.size); |
281 | thisrec++; | 587 | thisrec++; |
282 | gotorecordnumber(thisrec); | 588 | gotorecordnumber(thisrec); |
283 | } | 589 | } |
@@ -295,18 +601,22 @@ void CPlucker::locate(unsigned int n) | |||
295 | { | 601 | { |
296 | thisrec++; | 602 | thisrec++; |
297 | locpos += bs; | 603 | locpos += bs; |
298 | gotorecordnumber(thisrec); | 604 | gotorecordnumber(thisrec); |
299 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | 605 | fread(&thisHdr, 1, sizeof(thisHdr), fin); |
300 | if (thisHdr.type < 2) | 606 | if (thisHdr.type < 2) |
301 | { | 607 | { |
302 | bs = htons(thisHdr.size); | 608 | bs = ntohs(thisHdr.size); |
303 | } | 609 | } |
304 | else | 610 | else |
305 | { | 611 | { |
306 | bs = 0; | 612 | bs = 0; |
307 | } | 613 | } |
308 | } while (locpos + bs < n); | 614 | } while (locpos + bs <= n); |
309 | currentpos = locpos; | 615 | currentpos = locpos; |
310 | expand(thisrec); | 616 | expand(thisrec); |
617 | #ifdef _FAST | ||
311 | while (currentpos < n && bufferpos < buffercontent) bgetch(); | 618 | while (currentpos < n && bufferpos < buffercontent) bgetch(); |
619 | #else | ||
620 | while (currentpos < n && bufferpos < buffercontent) getch(); | ||
621 | #endif | ||
312 | } | 622 | } |
@@ -315,4 +625,6 @@ bool CPlucker::hyperlink(unsigned int n) | |||
315 | { | 625 | { |
626 | visited.push_front(n); | ||
316 | UInt16 tuid = (n >> 16); | 627 | UInt16 tuid = (n >> 16); |
317 | n &= 0xffff; | 628 | n &= 0xffff; |
629 | // qDebug("Hyper:<%u,%u>", tuid, n); | ||
318 | UInt16 thisrec = 1; | 630 | UInt16 thisrec = 1; |
@@ -323,8 +635,40 @@ bool CPlucker::hyperlink(unsigned int n) | |||
323 | { | 635 | { |
324 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | 636 | fread(&thisHdr, 1, sizeof(thisHdr), fin); |
325 | if (tuid <= htons(thisHdr.uid)) break; | 637 | if (tuid == ntohs(thisHdr.uid)) break; |
326 | if (thisHdr.type < 2) currentpos += htons(thisHdr.size); | 638 | if (thisHdr.type < 2) currentpos += ntohs(thisHdr.size); |
327 | // qDebug("hyper-cp:%u", currentpos); | 639 | //qDebug("hyper-cp:%u", currentpos); |
328 | thisrec++; | 640 | thisrec++; |
329 | gotorecordnumber(thisrec); | 641 | if (thisrec >= ntohs(head.recordList.numRecords)) |
642 | { | ||
643 | if (urls == NULL) | ||
644 | { | ||
645 | QMessageBox::information(NULL, | ||
646 | PROGNAME, | ||
647 | QString("No external links\nin this pluck") | ||
648 | ); | ||
649 | } | ||
650 | else | ||
651 | { | ||
652 | char *turl = geturl(tuid); | ||
653 | if (turl == NULL) | ||
654 | { | ||
655 | QMessageBox::information(NULL, | ||
656 | PROGNAME, | ||
657 | QString("Couldn't find link") | ||
658 | ); | ||
659 | } | ||
660 | else | ||
661 | { | ||
662 | QString wrd(turl); | ||
663 | QClipboard* cb = QApplication::clipboard(); | ||
664 | cb->setText(wrd); | ||
665 | if (wrd.length() > 10) | ||
666 | { | ||
667 | Global::statusMessage(wrd.left(8) + ".."); | ||
668 | } | ||
669 | } | ||
670 | } | ||
671 | return false; | ||
672 | } | ||
673 | gotorecordnumber(thisrec); | ||
330 | } | 674 | } |
@@ -332,12 +676,62 @@ bool CPlucker::hyperlink(unsigned int n) | |||
332 | { | 676 | { |
333 | QMessageBox::information(NULL, | 677 | if (thisHdr.type == 4) |
334 | QString("OpieReader"), | 678 | { |
335 | QString("External links\nnot yet supported") | 679 | QMessageBox::information(NULL, |
336 | ); | 680 | PROGNAME, |
337 | return false; | 681 | QString("Mailto links\nnot yet supported (2)")); |
682 | } | ||
683 | else | ||
684 | { | ||
685 | #ifdef LOCALPICTURES | ||
686 | if (thisHdr.type > 3) | ||
687 | { | ||
688 | #endif | ||
689 | QMessageBox::information(NULL, | ||
690 | PROGNAME, | ||
691 | QString("External links\nnot yet supported (2)") | ||
692 | ); | ||
693 | #ifdef LOCALPICTURES | ||
694 | } | ||
695 | else | ||
696 | { | ||
697 | showimg(tuid); | ||
698 | } | ||
699 | #endif | ||
700 | } | ||
701 | return false; | ||
702 | } | ||
703 | /* | ||
704 | if (thisHdr.type == 2 || thisHdr.type == 3) | ||
705 | { | ||
706 | expandimg(thisrec); | ||
707 | |||
338 | } | 708 | } |
709 | */ | ||
339 | else | 710 | else |
340 | { | 711 | { |
341 | expand(thisrec); | 712 | expand(thisrec); |
342 | while (bufferpos < n && bufferpos < buffercontent) getch(); | 713 | if (n != 0) |
714 | { | ||
715 | if (n >= m_nParas) | ||
716 | { | ||
717 | QMessageBox::information(NULL, | ||
718 | PROGNAME, | ||
719 | QString("Error in link\nPara # too big") | ||
720 | ); | ||
721 | return false; | ||
722 | } | ||
723 | unsigned int noff = 0; | ||
724 | for (int i = 0; i < n; i++) noff += m_ParaOffsets[i]; | ||
725 | n = noff; | ||
726 | } | ||
727 | if (n > ntohs(thisHdr.size)) | ||
728 | { | ||
729 | QMessageBox::information(NULL, | ||
730 | PROGNAME, | ||
731 | QString("Error in link\nOffset too big") | ||
732 | ); | ||
733 | return false; | ||
734 | } | ||
735 | qDebug("Hyper:<%u,%u>", tuid, n); | ||
736 | while (bufferpos < n && bufferpos < buffercontent) getch(); | ||
343 | } | 737 | } |
@@ -345,3 +739,113 @@ bool CPlucker::hyperlink(unsigned int n) | |||
345 | } | 739 | } |
740 | /* | ||
741 | bool CPlucker::hyperlink(unsigned int n) | ||
742 | { | ||
743 | visited.push_front(n); | ||
744 | UInt16 tuid = (n >> 16); | ||
745 | n &= 0xffff; | ||
746 | // qDebug("Hyper:<%u,%u>", tuid, n); | ||
747 | UInt16 thisrec = finduid(tuid); | ||
748 | if (thisrec == 0) | ||
749 | { | ||
750 | if (urls == NULL) | ||
751 | { | ||
752 | QMessageBox::information(NULL, | ||
753 | PROGNAME, | ||
754 | QString("No external links\nin this pluck") | ||
755 | ); | ||
756 | } | ||
757 | else | ||
758 | { | ||
759 | char *turl = geturl(tuid); | ||
760 | if (turl == NULL) | ||
761 | { | ||
762 | QMessageBox::information(NULL, | ||
763 | PROGNAME, | ||
764 | QString("Couldn't find link") | ||
765 | ); | ||
766 | } | ||
767 | else | ||
768 | { | ||
769 | QString wrd(turl); | ||
770 | QClipboard* cb = QApplication::clipboard(); | ||
771 | cb->setText(wrd); | ||
772 | if (wrd.length() > 10) | ||
773 | { | ||
774 | Global::statusMessage(wrd.left(8) + ".."); | ||
775 | } | ||
776 | } | ||
777 | } | ||
778 | return false; | ||
779 | } | ||
780 | else | ||
781 | { | ||
782 | currentpos = 0; | ||
783 | gotorecordnumber(thisrec); | ||
784 | CPlucker_dataRecord thisHdr; | ||
785 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | ||
346 | 786 | ||
787 | if (thisHdr.type > 1) | ||
788 | { | ||
789 | if (thisHdr.type == 4) | ||
790 | { | ||
791 | QMessageBox::information(NULL, | ||
792 | PROGNAME, | ||
793 | QString("Mailto links\nnot yet supported (2)")); | ||
794 | } | ||
795 | else | ||
796 | { | ||
797 | #ifdef LOCALPICTURES | ||
798 | if (thisHdr.type > 3) | ||
799 | { | ||
800 | #endif | ||
801 | QMessageBox::information(NULL, | ||
802 | PROGNAME, | ||
803 | QString("External links\nnot yet supported (2)") | ||
804 | ); | ||
805 | #ifdef LOCALPICTURES | ||
806 | } | ||
807 | else | ||
808 | { | ||
809 | showimg(tuid); | ||
810 | } | ||
811 | #endif | ||
812 | } | ||
813 | return false; | ||
814 | } | ||
815 | // if (thisHdr.type == 2 || thisHdr.type == 3) | ||
816 | // { | ||
817 | // expandimg(thisrec); | ||
818 | // } | ||
819 | else | ||
820 | { | ||
821 | expand(thisrec); | ||
822 | if (n != 0) | ||
823 | { | ||
824 | if (n >= m_nParas) | ||
825 | { | ||
826 | QMessageBox::information(NULL, | ||
827 | PROGNAME, | ||
828 | QString("Error in link\nPara # too big") | ||
829 | ); | ||
830 | return false; | ||
831 | } | ||
832 | unsigned int noff = 0; | ||
833 | for (int i = 0; i < n; i++) noff += m_ParaOffsets[i]; | ||
834 | n = noff; | ||
835 | } | ||
836 | if (n > ntohs(thisHdr.size)) | ||
837 | { | ||
838 | QMessageBox::information(NULL, | ||
839 | PROGNAME, | ||
840 | QString("Error in link\nOffset too big") | ||
841 | ); | ||
842 | return false; | ||
843 | } | ||
844 | qDebug("Hyper:<%u,%u>", tuid, n); | ||
845 | while (bufferpos < n && bufferpos < buffercontent) getch(); | ||
846 | } | ||
847 | return true; | ||
848 | } | ||
849 | } | ||
850 | */ | ||
347 | bool CPlucker::expand(int thisrec) | 851 | bool CPlucker::expand(int thisrec) |
@@ -354,12 +858,12 @@ bool CPlucker::expand(int thisrec) | |||
354 | { | 858 | { |
355 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | 859 | fread(&thisHdr, 1, sizeof(thisHdr), fin); |
356 | // qDebug("This (%d) type is %d, uid is %u", thisrec, thisHdr.type, ntohs(thisHdr.uid)); | 860 | //qDebug("This (%d) type is %d, uid is %u", thisrec, thisHdr.type, ntohs(thisHdr.uid)); |
357 | if (thisHdr.type < 2) break; | 861 | if (thisHdr.type < 2) break; |
358 | qDebug("Skipping paragraph of type %d", thisHdr.type); | 862 | qDebug("Skipping paragraph of type %d", thisHdr.type); |
359 | if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; | 863 | if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; |
360 | reclen = recordlength(thisrec); | 864 | reclen = recordlength(thisrec); |
361 | gotorecordnumber(thisrec); | 865 | gotorecordnumber(thisrec); |
362 | } | 866 | } |
363 | m_nParas = ntohs(thisHdr.nParagraphs); | 867 | m_nParas = ntohs(thisHdr.nParagraphs); |
364 | // qDebug("It has %u paragraphs and is %u bytes", htons(thisHdr.nParagraphs), htons(thisHdr.size)); | 868 | //qDebug("It has %u paragraphs and is %u bytes", ntohs(thisHdr.nParagraphs), ntohs(thisHdr.size)); |
365 | uid = ntohs(thisHdr.uid); | 869 | uid = ntohs(thisHdr.uid); |
@@ -367,8 +871,8 @@ bool CPlucker::expand(int thisrec) | |||
367 | { | 871 | { |
368 | UInt16 ubytes, attrs; | 872 | UInt16 ubytes, attrs; |
369 | fread(&ubytes, 1, sizeof(ubytes), fin); | 873 | fread(&ubytes, 1, sizeof(ubytes), fin); |
370 | fread(&attrs, 1, sizeof(attrs), fin); | 874 | fread(&attrs, 1, sizeof(attrs), fin); |
371 | m_ParaOffsets[i] = ntohs(ubytes); | 875 | m_ParaOffsets[i] = ntohs(ubytes); |
372 | m_ParaAttrs[i] = ntohs(attrs); | 876 | m_ParaAttrs[i] = ntohs(attrs); |
373 | // qDebug("Bytes %u, Attr %x", ntohs(ubytes), attrs); | 877 | //qDebug("Bytes %u, Attr %x", ntohs(ubytes), attrs); |
374 | } | 878 | } |
@@ -376,5 +880,5 @@ bool CPlucker::expand(int thisrec) | |||
376 | { | 880 | { |
377 | m_nextPara = m_ParaOffsets[0]; | 881 | m_nextPara = m_ParaOffsets[0]; |
378 | // qDebug("First offset = %u", m_nextPara); | 882 | //qDebug("First offset = %u", m_nextPara); |
379 | m_nextParaIndex = 0; | 883 | m_nextParaIndex = 0; |
380 | } | 884 | } |
@@ -382,3 +886,3 @@ bool CPlucker::expand(int thisrec) | |||
382 | { | 886 | { |
383 | m_nextPara = -1; | 887 | m_nextPara = -1; |
384 | } | 888 | } |
@@ -387,21 +891,5 @@ bool CPlucker::expand(int thisrec) | |||
387 | 891 | ||
388 | buffercontent = htons(thisHdr.size); | 892 | buffercontent = ntohs(thisHdr.size); |
389 | 893 | ||
390 | if (thisHdr.type == 0) | 894 | Expand(reclen, thisHdr.type, expandedtextbuffer, buffercontent); |
391 | { | ||
392 | fread(expandedtextbuffer, reclen, sizeof(char), fin); | ||
393 | } | ||
394 | else | ||
395 | { | ||
396 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | ||
397 | switch (ntohs(hdr0.version)) | ||
398 | { | ||
399 | case 2: | ||
400 | UnZip(reclen, expandedtextbuffer, buffercontent); | ||
401 | break; | ||
402 | case 1: | ||
403 | UnDoc(reclen, expandedtextbuffer, buffercontent); | ||
404 | break; | ||
405 | } | ||
406 | } | ||
407 | bufferpos = 0; | 895 | bufferpos = 0; |
@@ -442,2 +930,4 @@ void CPlucker::UnZip(size_t reclen, UInt8* tgtbuffer, UInt16 bsize) | |||
442 | 930 | ||
931 | //qDebug("err:%d - %u", err, zstream.avail_in); | ||
932 | |||
443 | } while ( err == Z_OK ); | 933 | } while ( err == Z_OK ); |
@@ -513,12 +1003,12 @@ CList<Bkmk>* CPlucker::getbkmklist() | |||
513 | { | 1003 | { |
514 | gotorecordnumber(i); | 1004 | gotorecordnumber(i); |
515 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | 1005 | fread(&thisHdr, 1, sizeof(thisHdr), fin); |
516 | if (thisHdr.type == 8) | 1006 | if (thisHdr.type == 8) |
517 | { | 1007 | { |
518 | UInt16 n; | 1008 | UInt16 n; |
519 | fread(&n, 1, sizeof(n), fin); | 1009 | fread(&n, 1, sizeof(n), fin); |
520 | n = ntohs(n); | 1010 | n = ntohs(n); |
521 | qDebug("Found %u bookmarks", n); | 1011 | qDebug("Found %u bookmarks", n); |
522 | } | 1012 | } |
523 | qDebug("Found:%d, %u", i , thisHdr.type); | 1013 | qDebug("Found:%d, %u", i , thisHdr.type); |
524 | } | 1014 | } |
@@ -528,7 +1018,15 @@ CList<Bkmk>* CPlucker::getbkmklist() | |||
528 | 1018 | ||
529 | void CPlucker::expandimg(UInt16 tgt) | 1019 | QImage* CPlucker::getimg(UInt16 tgt) |
530 | { | 1020 | { |
531 | qDebug("Image:%u", tgt); | 1021 | // static int imageno; |
1022 | // char* file = "tmp1"; | ||
1023 | // sprintf(file, "image%04u.tbmp", imageno++); | ||
1024 | // qDebug("Image:%u", tgt); | ||
532 | CPlucker_dataRecord thisHdr; | 1025 | CPlucker_dataRecord thisHdr; |
533 | size_t reclen; | 1026 | size_t reclen; |
1027 | UInt16 thisrec = finduid(tgt); | ||
1028 | reclen = recordlength(thisrec); | ||
1029 | gotorecordnumber(thisrec); | ||
1030 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | ||
1031 | /* | ||
534 | UInt16 thisrec = 0; | 1032 | UInt16 thisrec = 0; |
@@ -536,22 +1034,42 @@ void CPlucker::expandimg(UInt16 tgt) | |||
536 | { | 1034 | { |
537 | thisrec++; | 1035 | hthisrec++; |
538 | reclen = recordlength(thisrec); | 1036 | reclen = recordlength(thisrec); |
539 | gotorecordnumber(thisrec); | 1037 | gotorecordnumber(thisrec); |
540 | qDebug("thisrec:%u.%u", ftell(fin),thisrec); | 1038 | //qDebug("thisrec:%u.%u", ftell(fin),thisrec); |
541 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | 1039 | fread(&thisHdr, 1, sizeof(thisHdr), fin); |
542 | } | 1040 | } |
543 | while (ntohs(thisHdr.uid) != tgt); | 1041 | while (ntohs(thisHdr.uid) != tgt); |
544 | 1042 | */ | |
545 | reclen -= sizeof(thisHdr); | 1043 | reclen -= sizeof(thisHdr); |
546 | 1044 | ||
547 | UInt16 imgsize = htons(thisHdr.size); | 1045 | UInt16 imgsize = ntohs(thisHdr.size); |
548 | UInt8* imgbuffer = new UInt8[imgsize]; | 1046 | UInt8* imgbuffer = new UInt8[imgsize]; |
549 | 1047 | ||
550 | qDebug("type:%u", thisHdr.type); | 1048 | // qDebug("type:%u", thisHdr.type); |
1049 | Expand(reclen, thisHdr.type, imgbuffer, imgsize); | ||
551 | 1050 | ||
552 | if (thisHdr.type == 2) | 1051 | QImage* qimage = Palm2QImage(imgbuffer, imgsize); |
1052 | |||
1053 | delete [] imgbuffer; | ||
1054 | |||
1055 | return qimage; | ||
1056 | } | ||
1057 | |||
1058 | #include <qnamespace.h> | ||
1059 | |||
1060 | QPixmap* CPlucker::expandimg(UInt16 tgt, bool border) | ||
1061 | { | ||
1062 | QImage* qimage = getimg(tgt); | ||
1063 | if (qimage == NULL) return NULL; | ||
1064 | QPixmap* image = new QPixmap(0,0); | ||
1065 | QPixmap* ret; | ||
1066 | // qDebug("New image"); | ||
1067 | image->convertFromImage(*qimage); | ||
1068 | delete qimage; | ||
1069 | if (border) | ||
553 | { | 1070 | { |
554 | qDebug("Not compressed:%u.%u", ftell(fin),reclen); | 1071 | ret = new QPixmap(image->width()+4, image->height()+4); |
555 | fread(imgbuffer, reclen, sizeof(char), fin); | 1072 | ret->fill(Qt::red); |
556 | qDebug("Not compressed:%u.%u", ftell(fin),reclen); | 1073 | bitBlt(ret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP); |
1074 | delete image; | ||
557 | } | 1075 | } |
@@ -559,21 +1077,165 @@ void CPlucker::expandimg(UInt16 tgt) | |||
559 | { | 1077 | { |
560 | qDebug("Compressed"); | 1078 | ret = image; |
561 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | ||
562 | switch (ntohs(hdr0.version)) | ||
563 | { | ||
564 | case 2: | ||
565 | UnZip(reclen, imgbuffer, imgsize); | ||
566 | break; | ||
567 | case 1: | ||
568 | UnDoc(reclen, imgbuffer, imgsize); | ||
569 | break; | ||
570 | } | ||
571 | } | 1079 | } |
572 | FILE* imgfile = fopen("/home/tim/newreader/imagefile.tbmp", "w"); | 1080 | return ret; |
573 | if (imgfile != NULL) | 1081 | } |
1082 | |||
1083 | #ifdef _BUFFERPICS | ||
1084 | #include <qmap.h> | ||
1085 | #endif | ||
1086 | |||
1087 | QPixmap* CPlucker::getPicture(unsigned long tgt) | ||
1088 | { | ||
1089 | #ifdef _BUFFERPICS | ||
1090 | static QMap<unsigned long, QPixmap> pix; | ||
1091 | QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt); | ||
1092 | if (t == pix.end()) | ||
574 | { | 1093 | { |
575 | fwrite(imgbuffer, 1, imgsize, imgfile); | 1094 | pix[tgt] = *expandimg(tgt); |
576 | fclose(imgfile); | 1095 | return &pix[tgt]; |
577 | } | 1096 | } |
578 | delete [] imgbuffer; | 1097 | else |
1098 | return &(t.data()); | ||
1099 | #else | ||
1100 | return expandimg(tgt); | ||
1101 | #endif | ||
1102 | } | ||
1103 | |||
1104 | #ifdef LOCALPICTURES | ||
1105 | #include <unistd.h> | ||
1106 | #include <qpe/global.h> | ||
1107 | void CPlucker::showimg(UInt16 tgt) | ||
1108 | { | ||
1109 | qDebug("Crassssssh!"); | ||
1110 | QPixmap* qimage = expandimg(tgt); | ||
1111 | m_picture->setFixedSize(qimage->size()); | ||
1112 | m_picture->setBackgroundPixmap(*qimage); | ||
1113 | delete qimage; | ||
1114 | m_viewer->show(); | ||
1115 | |||
1116 | /* | ||
1117 | char tmp[] = "uqtreader.XXXXXX"; | ||
1118 | QImage* qimage = getimg(tgt); | ||
1119 | QPixmap* image = new QPixmap(0,0); | ||
1120 | // qDebug("New image"); | ||
1121 | image->convertFromImage(*qimage); | ||
1122 | delete qimage; | ||
1123 | char tmpfile[sizeof(tmp)+1]; | ||
1124 | strcpy(tmpfile,tmp); | ||
1125 | int f = mkstemp(tmpfile); | ||
1126 | close(f); | ||
1127 | qDebug("TMPFILE:%s", tmpfile); | ||
1128 | if (image->save(tmpfile,"PNG")) | ||
1129 | { | ||
1130 | QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)"); | ||
1131 | e << QString(tmpfile); | ||
1132 | } | ||
1133 | Global::statusMessage("Opening image"); | ||
1134 | sleep(5); | ||
1135 | delete image; | ||
1136 | unlink(tmpfile); | ||
1137 | */ | ||
1138 | } | ||
1139 | |||
1140 | #endif | ||
1141 | |||
1142 | void CPlucker::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | ||
1143 | { | ||
1144 | unsigned short sz = 0; | ||
1145 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | ||
1146 | { | ||
1147 | sz++; | ||
1148 | } | ||
1149 | size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long); | ||
1150 | unsigned char* newdata = new unsigned char[newlen]; | ||
1151 | unsigned char* pdata = newdata; | ||
1152 | memcpy(newdata, src, srclen); | ||
1153 | newdata += srclen; | ||
1154 | memcpy(newdata, &sz, sizeof(sz)); | ||
1155 | newdata += sizeof(sz); | ||
1156 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | ||
1157 | { | ||
1158 | unsigned long t = *it; | ||
1159 | qDebug("[%u]", t); | ||
1160 | memcpy(newdata, &t, sizeof(t)); | ||
1161 | newdata += sizeof(t); | ||
1162 | } | ||
1163 | m_nav.setSaveData(data, len, pdata, newlen); | ||
1164 | delete [] pdata; | ||
1165 | } | ||
1166 | |||
1167 | void CPlucker::putSaveData(unsigned char*& src, unsigned short& srclen) | ||
1168 | { | ||
1169 | unsigned short sz; | ||
1170 | if (srclen >= sizeof(sz)) | ||
1171 | { | ||
1172 | memcpy(&sz, src, sizeof(sz)); | ||
1173 | src += sizeof(sz); | ||
1174 | srclen -= sizeof(sz); | ||
1175 | } | ||
1176 | for (int i = 0; i < sz; i++) | ||
1177 | { | ||
1178 | unsigned long t; | ||
1179 | if (srclen >= sizeof(t)) | ||
1180 | { | ||
1181 | memcpy(&t, src, sizeof(t)); | ||
1182 | qDebug("[%u]", t); | ||
1183 | visited.push_front(t); | ||
1184 | src += sizeof(t); | ||
1185 | srclen -= sizeof(t); | ||
1186 | } | ||
1187 | else | ||
1188 | { | ||
1189 | QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself"); | ||
1190 | break; | ||
1191 | } | ||
1192 | } | ||
1193 | m_nav.putSaveData(src, srclen); | ||
1194 | } | ||
1195 | |||
1196 | unsigned short CPlucker::finduid(unsigned short urlid) | ||
1197 | { | ||
1198 | // qDebug("Finding %u", urlid); | ||
1199 | unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); | ||
1200 | unsigned short jmid = (jmin+jmax) >> 1; | ||
1201 | while (jmax - jmin > 1) | ||
1202 | { | ||
1203 | CPlucker_dataRecord thisHdr; | ||
1204 | gotorecordnumber(jmid); | ||
1205 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | ||
1206 | unsigned short luid = ntohs(thisHdr.uid); | ||
1207 | //qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); | ||
1208 | if (luid == urlid) | ||
1209 | { | ||
1210 | return jmid; | ||
1211 | } | ||
1212 | if (luid < urlid) | ||
1213 | { | ||
1214 | jmin = jmid; | ||
1215 | } | ||
1216 | else | ||
1217 | { | ||
1218 | jmax = jmid; | ||
1219 | } | ||
1220 | jmid = (jmin+jmax) >> 1; | ||
1221 | } | ||
1222 | CPlucker_dataRecord thisHdr; | ||
1223 | gotorecordnumber(jmin); | ||
1224 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | ||
1225 | unsigned short luid = ntohs(thisHdr.uid); | ||
1226 | qDebug("jmin at end:%u,%u", jmin, luid); | ||
1227 | if (luid == urlid) | ||
1228 | { | ||
1229 | return jmin; | ||
1230 | } | ||
1231 | gotorecordnumber(jmax); | ||
1232 | fread(&thisHdr, 1, sizeof(thisHdr), fin); | ||
1233 | luid = ntohs(thisHdr.uid); | ||
1234 | qDebug("jmax at end:%u,%u", jmax, luid); | ||
1235 | if (luid == urlid) | ||
1236 | { | ||
1237 | return jmax; | ||
1238 | } | ||
1239 | qDebug("Couldn't find %u", urlid); | ||
1240 | return 0; // Not found! | ||
579 | } | 1241 | } |
diff --git a/noncore/apps/opie-reader/plucker.h b/noncore/apps/opie-reader/plucker.h index d3ca732..083eac6 100644 --- a/noncore/apps/opie-reader/plucker.h +++ b/noncore/apps/opie-reader/plucker.h | |||
@@ -8,2 +8,9 @@ | |||
8 | #include "CBuffer.h" | 8 | #include "CBuffer.h" |
9 | #include "Navigation.h" | ||
10 | #include "my_list.h" | ||
11 | |||
12 | #ifdef LOCALPICTURES | ||
13 | class QScrollView; | ||
14 | class QWidget; | ||
15 | #endif | ||
9 | 16 | ||
@@ -31,3 +38,2 @@ struct CPluckerbkmk | |||
31 | 38 | ||
32 | |||
33 | const UInt32 CPLUCKER_ID = 0x5458547a; | 39 | const UInt32 CPLUCKER_ID = 0x5458547a; |
@@ -36,4 +42,14 @@ class CPlucker : public CExpander, Cpdb | |||
36 | { | 42 | { |
37 | size_t textlength; | 43 | unsigned short finduid(unsigned short); |
44 | char* geturl(UInt16); | ||
45 | void Expand(UInt16, UInt8, UInt8*, UInt16); | ||
46 | CList<unsigned long> visited; | ||
47 | bool m_lastIsBreak; | ||
48 | #ifdef LOCALPICTURES | ||
49 | QScrollView* m_viewer; | ||
50 | QWidget* m_picture; | ||
51 | #endif | ||
52 | size_t textlength, m_lastBreak; | ||
38 | UInt16 uid; | 53 | UInt16 uid; |
54 | UInt8 EOPPhase; | ||
39 | int m_nextPara, m_nextParaIndex; | 55 | int m_nextPara, m_nextParaIndex; |
@@ -48,2 +64,4 @@ class CPlucker : public CExpander, Cpdb | |||
48 | UInt8* compressedtextbuffer; | 64 | UInt8* compressedtextbuffer; |
65 | char* urls; | ||
66 | size_t urlsize; | ||
49 | size_t bufferpos; | 67 | size_t bufferpos; |
@@ -55,20 +73,25 @@ class CPlucker : public CExpander, Cpdb | |||
55 | void UnDoc(size_t, UInt8*, UInt16); | 73 | void UnDoc(size_t, UInt8*, UInt16); |
56 | void expandimg(UInt16 tgt); | 74 | #ifdef LOCALPICTURES |
75 | void showimg(UInt16 tgt); | ||
76 | #endif | ||
77 | QImage* getimg(UInt16 tgt); | ||
78 | QPixmap* expandimg(UInt16 tgt, bool border=false); | ||
57 | void home(); | 79 | void home(); |
58 | int bgetch(); | 80 | int bgetch(); |
81 | CNavigation m_nav; | ||
59 | public: | 82 | public: |
60 | virtual void sizes(unsigned long& _file, unsigned long& _text) | 83 | virtual void suspend() |
61 | { | 84 | { |
62 | _file = file_length; | 85 | CExpander::suspend(fin); |
63 | _text = textlength; | 86 | } |
64 | //ntohl(hdr0.size); | 87 | virtual void unsuspend() |
65 | } | 88 | { |
89 | CExpander::unsuspend(fin); | ||
90 | } | ||
91 | virtual QPixmap* getPicture(unsigned long tgt); | ||
92 | virtual void sizes(unsigned long& _file, unsigned long& _text); | ||
66 | virtual bool hasrandomaccess() { return true; } | 93 | virtual bool hasrandomaccess() { return true; } |
67 | virtual ~CPlucker() | 94 | virtual ~CPlucker(); |
68 | { | ||
69 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; | ||
70 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; | ||
71 | } | ||
72 | CPlucker(); | 95 | CPlucker(); |
73 | virtual int openfile(const char *src); | 96 | virtual int OpenFile(const char *src); |
74 | virtual int getch(); | 97 | virtual int getch(); |
@@ -80,5 +103,19 @@ class CPlucker : public CExpander, Cpdb | |||
80 | virtual MarkupType PreferredMarkup() | 103 | virtual MarkupType PreferredMarkup() |
81 | { | 104 | { |
82 | return cNONE; | 105 | return cNONE; |
83 | } | 106 | } |
107 | void saveposn(size_t posn) { m_nav.saveposn(posn); } | ||
108 | bool forward(size_t& loc) { return m_nav.forward(loc); } | ||
109 | bool back(size_t& loc) { return m_nav.back(loc); } | ||
110 | bool hasnavigation() { return true; } | ||
111 | unsigned long startSection() | ||
112 | { | ||
113 | return currentpos-bufferpos; | ||
114 | } | ||
115 | unsigned long endSection() | ||
116 | { | ||
117 | return startSection()+buffercontent; | ||
118 | } | ||
119 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen); | ||
120 | void putSaveData(unsigned char*& src, unsigned short& srclen); | ||
84 | }; | 121 | }; |
diff --git a/noncore/apps/opie-reader/ppm_expander.cpp b/noncore/apps/opie-reader/ppm_expander.cpp index 4f0a277..fe2745c 100644 --- a/noncore/apps/opie-reader/ppm_expander.cpp +++ b/noncore/apps/opie-reader/ppm_expander.cpp | |||
@@ -37,3 +37,3 @@ ppm_expander::~ppm_expander() { | |||
37 | 37 | ||
38 | int ppm_expander::openfile(const char* infile) | 38 | int ppm_expander::OpenFile(const char* infile) |
39 | { | 39 | { |
diff --git a/noncore/apps/opie-reader/ppm_expander.h b/noncore/apps/opie-reader/ppm_expander.h index 115988d..4278c82 100644 --- a/noncore/apps/opie-reader/ppm_expander.h +++ b/noncore/apps/opie-reader/ppm_expander.h | |||
@@ -27,3 +27,11 @@ class ppm_expander : public CExpander { | |||
27 | ppm_worker ppm; | 27 | ppm_worker ppm; |
28 | public: | 28 | public: |
29 | virtual void suspend() | ||
30 | { | ||
31 | CExpander::suspend(my_file_in); | ||
32 | } | ||
33 | virtual void unsuspend() | ||
34 | { | ||
35 | CExpander::unsuspend(my_file_in); | ||
36 | } | ||
29 | ppm_expander() : needppmend(false), my_file_in(NULL), my_read_buf(NULL) | 37 | ppm_expander() : needppmend(false), my_file_in(NULL), my_read_buf(NULL) |
@@ -35,3 +43,3 @@ class ppm_expander : public CExpander { | |||
35 | } | 43 | } |
36 | virtual int openfile(const char* infile); | 44 | virtual int OpenFile(const char* infile); |
37 | virtual int getch(); | 45 | virtual int getch(); |
diff --git a/noncore/apps/opie-reader/ustring.h b/noncore/apps/opie-reader/ustring.h index a4dc048..a3ef8df 100644 --- a/noncore/apps/opie-reader/ustring.h +++ b/noncore/apps/opie-reader/ustring.h | |||
@@ -65,2 +65,14 @@ inline QString toQString(tchar *_p, unsigned int len) | |||
65 | } | 65 | } |
66 | |||
67 | inline tchar* fromQString(const QString& qs) | ||
68 | { | ||
69 | int len = qs.length(); | ||
70 | tchar* ret = new tchar[len+1]; | ||
71 | for (int i = 0; i < len; i++) | ||
72 | { | ||
73 | ret[i] = qs[i].unicode(); | ||
74 | } | ||
75 | ret[len] = 0; | ||
76 | return ret; | ||
77 | } | ||
66 | #else | 78 | #else |
diff --git a/noncore/apps/opie-reader/version.h b/noncore/apps/opie-reader/version.h index 8b6c756..003e9db 100644 --- a/noncore/apps/opie-reader/version.h +++ b/noncore/apps/opie-reader/version.h | |||
@@ -2,3 +2,3 @@ | |||
2 | #define MAJOR 0 | 2 | #define MAJOR 0 |
3 | #define BKMKTYPE 5 | 3 | #define BKMKTYPE 6 |
4 | #define MINOR 'a' | 4 | #define MINOR 'a' |
diff --git a/noncore/apps/opie-reader/ztxt.cpp b/noncore/apps/opie-reader/ztxt.cpp index 289b13a..8091d32 100644 --- a/noncore/apps/opie-reader/ztxt.cpp +++ b/noncore/apps/opie-reader/ztxt.cpp | |||
@@ -9,3 +9,3 @@ ztxt::ztxt() : bInit(false), expandedtextbuffer(NULL), compressedtextbuffer(NULL | |||
9 | 9 | ||
10 | int ztxt::openfile(const char *src) | 10 | int ztxt::OpenFile(const char *src) |
11 | { | 11 | { |
diff --git a/noncore/apps/opie-reader/ztxt.h b/noncore/apps/opie-reader/ztxt.h index 20558a6..d7cb96a 100644 --- a/noncore/apps/opie-reader/ztxt.h +++ b/noncore/apps/opie-reader/ztxt.h | |||
@@ -76,20 +76,28 @@ class ztxt : public CExpander, Cpdb | |||
76 | void home(); | 76 | void home(); |
77 | public: | 77 | public: |
78 | virtual void suspend() | ||
79 | { | ||
80 | CExpander::suspend(fin); | ||
81 | } | ||
82 | virtual void unsuspend() | ||
83 | { | ||
84 | CExpander::unsuspend(fin); | ||
85 | } | ||
78 | virtual void sizes(unsigned long& _file, unsigned long& _text) | 86 | virtual void sizes(unsigned long& _file, unsigned long& _text) |
79 | { | 87 | { |
80 | _file = file_length; | 88 | _file = file_length; |
81 | _text = ntohl(hdr0.size); | 89 | _text = ntohl(hdr0.size); |
82 | } | 90 | } |
83 | virtual bool hasrandomaccess() { return (hdr0.randomAccess != 0); } | 91 | virtual bool hasrandomaccess() { return (hdr0.randomAccess != 0); } |
84 | virtual ~ztxt() | 92 | virtual ~ztxt() |
85 | { | 93 | { |
86 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; | 94 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; |
87 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; | 95 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; |
88 | if (bInit) | 96 | if (bInit) |
89 | { | 97 | { |
90 | inflateEnd(&zstream); | 98 | inflateEnd(&zstream); |
91 | } | 99 | } |
92 | } | 100 | } |
93 | ztxt(); | 101 | ztxt(); |
94 | virtual int openfile(const char *src); | 102 | virtual int OpenFile(const char *src); |
95 | virtual int getch(); | 103 | virtual int getch(); |
@@ -99,5 +107,5 @@ class ztxt : public CExpander, Cpdb | |||
99 | virtual MarkupType PreferredMarkup() | 107 | virtual MarkupType PreferredMarkup() |
100 | { | 108 | { |
101 | return cTEXT; | 109 | return cTEXT; |
102 | } | 110 | } |
103 | }; | 111 | }; |