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 /noncore | |
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, 3701 insertions, 643 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 | |||
@@ -91,5 +91,5 @@ CList<Bkmk>* Aportis::getbkmklist() | |||
91 | } | 91 | } |
92 | 92 | ||
93 | int Aportis::openfile(const char *src) | 93 | int Aportis::OpenFile(const char *src) |
94 | { | 94 | { |
95 | // printf("In openfile\n"); | 95 | // printf("In openfile\n"); |
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 | |||
@@ -76,4 +76,12 @@ class Aportis : public CExpander, Cpdb { | |||
76 | char bCompressed; | 76 | char bCompressed; |
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 | { |
@@ -84,5 +92,5 @@ public: | |||
84 | virtual ~Aportis() {} | 92 | virtual ~Aportis() {} |
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(); |
88 | virtual unsigned int locate(); | 96 | virtual unsigned int locate(); |
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,2 +1,3 @@ | |||
1 | #include "name.h" | ||
1 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
2 | 3 | ||
@@ -10,24 +11,54 @@ | |||
10 | const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); | 11 | const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); |
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 | ||
13 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) | 23 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) |
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 | ||
19 | if (_anno == NULL) | 26 | if (_anno == NULL) |
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 | } |
24 | else | 31 | else |
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 | } |
30 | } | 35 | } |
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() |
33 | { | 64 | { |
@@ -52,7 +83,7 @@ Bkmk& Bkmk::operator=(const Bkmk& rhs) | |||
52 | if (rhs.m_name != NULL) | 83 | if (rhs.m_name != NULL) |
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 |
@@ -60,7 +91,7 @@ Bkmk& Bkmk::operator=(const Bkmk& rhs) | |||
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 |
@@ -72,8 +103,8 @@ Bkmk& Bkmk::operator=(const Bkmk& rhs) | |||
72 | bool Bkmk::operator==(const Bkmk& rhs) | 103 | 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); |
75 | } | 106 | } |
76 | 107 | ||
77 | void Bkmk::setAnno(tchar* t) | 108 | void Bkmk::setAnno(unsigned char* t, unsigned short len) |
78 | { | 109 | { |
79 | if (m_anno != NULL) | 110 | if (m_anno != NULL) |
@@ -84,13 +115,39 @@ void Bkmk::setAnno(tchar* t) | |||
84 | if (t != NULL) | 115 | if (t != NULL) |
85 | { | 116 | { |
86 | int len = ustrlen(t)+1; | 117 | m_annolen = len; |
87 | m_anno = new tchar[len]; | 118 | m_anno = new unsigned char[m_annolen]; |
88 | for (int i = 0; i < len; i++) m_anno[i] = t[i]; | 119 | memcpy(m_anno, t, m_annolen); |
89 | } | 120 | } |
90 | else | 121 | else |
122 | { | ||
123 | m_annolen = sizeof(tchar); | ||
124 | m_anno = new unsigned char[m_annolen]; | ||
125 | *((tchar*)m_anno) = 0; | ||
126 | } | ||
127 | } | ||
128 | |||
129 | void Bkmk::setAnno(tchar* t) | ||
130 | { | ||
131 | if (m_anno != NULL) | ||
132 | { | ||
133 | delete [] m_anno; | ||
91 | m_anno = NULL; | 134 | m_anno = NULL; |
92 | } | 135 | } |
136 | if (t != NULL) | ||
137 | { | ||
138 | unsigned short len = ustrlen(t)+1; | ||
139 | m_annolen = sizeof(tchar)*len; | ||
140 | m_anno = new unsigned char[m_annolen]; | ||
141 | memcpy(m_anno, t, m_annolen); | ||
142 | } | ||
143 | else | ||
144 | { | ||
145 | m_annolen = sizeof(tchar); | ||
146 | m_anno = new unsigned char[m_annolen]; | ||
147 | *((tchar*)m_anno) = 0; | ||
148 | } | ||
149 | } | ||
93 | 150 | ||
94 | BkmkFile::BkmkFile(const char *fnm, bool w ) | 151 | BkmkFile::BkmkFile(const char *fnm, bool w = false) |
95 | : | 152 | : |
96 | wt(w), isUpgraded(false) | 153 | wt(w), isUpgraded(false) |
@@ -111,20 +168,16 @@ BkmkFile::~BkmkFile() | |||
111 | } | 168 | } |
112 | 169 | ||
113 | void BkmkFile::write(tchar* nm, tchar* an, const unsigned int& pos) | 170 | void BkmkFile::write(const Bkmk& b) |
114 | { | 171 | { |
115 | if (f != NULL) | 172 | if (f != NULL) |
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 | } |
125 | } | 180 | } |
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) |
130 | { | 183 | { |
@@ -139,27 +192,4 @@ void BkmkFile::write(CList<Bkmk>& bl) | |||
139 | } | 192 | } |
140 | 193 | ||
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 | } | ||
161 | return b; | ||
162 | } | ||
163 | |||
164 | CList<Bkmk>* BkmkFile::readall() | 194 | CList<Bkmk>* BkmkFile::readall() |
165 | { | 195 | { |
@@ -169,15 +199,15 @@ CList<Bkmk>* BkmkFile::readall() | |||
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; |
@@ -185,5 +215,21 @@ CList<Bkmk>* BkmkFile::readall() | |||
185 | else | 215 | else |
186 | { | 216 | { |
187 | bl = readall04(); | 217 | switch(newmagic & 0xff) |
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 | } | ||
188 | } | 234 | } |
189 | } | 235 | } |
@@ -191,10 +237,10 @@ CList<Bkmk>* BkmkFile::readall() | |||
191 | } | 237 | } |
192 | 238 | ||
193 | CList<Bkmk>* BkmkFile::readall04() | 239 | CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(FILE*)) |
194 | { | 240 | { |
195 | CList<Bkmk>* bl = new CList<Bkmk>; | 241 | CList<Bkmk>* bl = new CList<Bkmk>; |
196 | while (1) | 242 | while (1) |
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); |
@@ -204,18 +250,29 @@ CList<Bkmk>* BkmkFile::readall04() | |||
204 | } | 250 | } |
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); | ||
215 | } | 271 | } |
216 | return bl; | 272 | } |
273 | return b; | ||
217 | } | 274 | } |
218 | 275 | ||
219 | Bkmk* BkmkFile::read03() | 276 | Bkmk* BkmkFile::read05(FILE* f) |
220 | { | 277 | { |
221 | Bkmk* b = NULL; | 278 | Bkmk* b = NULL; |
@@ -225,14 +282,39 @@ Bkmk* BkmkFile::read03() | |||
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); |
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); | ||
237 | } | 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 | |||
@@ -3,4 +3,5 @@ | |||
3 | 3 | ||
4 | #include "config.h" | 4 | #include "config.h" |
5 | #include "Filedata.h" | ||
5 | #include <stdio.h> | 6 | #include <stdio.h> |
6 | 7 | ||
@@ -11,9 +12,14 @@ class Bkmk | |||
11 | { | 12 | { |
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); |
19 | Bkmk(const Bkmk& rhs) : m_name(NULL), m_anno(NULL) | 25 | Bkmk(const Bkmk& rhs) : m_name(NULL), m_anno(NULL) |
@@ -23,10 +29,22 @@ class Bkmk | |||
23 | ~Bkmk(); | 29 | ~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); } |
28 | Bkmk& operator=(const Bkmk& rhs); | 35 | Bkmk& operator=(const Bkmk& rhs); |
29 | bool operator==(const Bkmk& rhs); | 36 | bool operator==(const Bkmk& rhs); |
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 | }; |
32 | 50 | ||
@@ -38,9 +56,8 @@ class BkmkFile | |||
38 | static const unsigned long magic; | 56 | static const unsigned long magic; |
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); |
46 | public: | 63 | public: |
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,2 +1,4 @@ | |||
1 | #include "name.h" | ||
2 | |||
1 | #include "BuffDoc.h" | 3 | #include "BuffDoc.h" |
2 | //#include <FL/fl_draw.h> | 4 | //#include <FL/fl_draw.h> |
@@ -31,6 +33,110 @@ void BuffDoc::locate(unsigned int n) | |||
31 | } | 33 | } |
32 | 34 | ||
33 | bool BuffDoc::getline(CDrawBuffer* buff, int w) | 35 | #define NEWLINEBREAK |
36 | #ifdef NEWLINEBREAK | ||
37 | bool BuffDoc::getline(CDrawBuffer* buff, int wth) | ||
38 | { | ||
39 | bool moreleft = true; | ||
40 | bool margindone = false; | ||
41 | int w = wth-2*BORDER; | ||
42 | tchar ch = 32; | ||
43 | CStyle cs; | ||
44 | buff->empty(); | ||
45 | if (exp == NULL) | ||
46 | { | ||
47 | buff->empty(); | ||
48 | buff->setEof(); | ||
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++) | ||
34 | { | 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; | ||
35 | tchar ch = 32; | 141 | tchar ch = 32; |
36 | CStyle cs; | 142 | CStyle cs; |
@@ -47,4 +153,6 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
47 | *buff = lastword; | 153 | *buff = lastword; |
48 | cs = lastword.laststyle(); | 154 | cs = lastword.laststyle(); |
155 | w -= buff->leftMargin() + buff->rightMargin(); | ||
156 | margindone = true; | ||
49 | } | 157 | } |
50 | else buff->empty(); | 158 | else buff->empty(); |
@@ -54,5 +162,5 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
54 | if (slen > w) | 162 | if (slen > 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; |
@@ -60,10 +168,20 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
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] = '-'; |
172 | if (len > 2) | ||
173 | { | ||
174 | lastword.setright(*buff, len - 1); | ||
65 | buff->truncate(len-1); | 175 | buff->truncate(len-1); |
66 | buff->addch('-', cs); | 176 | buff->addch('-', cs); |
67 | (*buff)[len] = '\0'; | 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; |
69 | } | 187 | } |
@@ -78,4 +196,5 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
78 | buff->truncate(len); | 196 | buff->truncate(len); |
79 | laststartline = exp->locate(); | 197 | laststartline = exp->locate(); |
198 | buff->resize(); | ||
80 | return true; | 199 | return true; |
81 | } | 200 | } |
@@ -98,4 +217,9 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
98 | len++; | 217 | len++; |
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(); |
101 | if (slen < w && ch != ' ') | 225 | if (slen < w && ch != ' ') |
@@ -108,6 +232,14 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
108 | (*buff)[len] = '\0'; | 232 | (*buff)[len] = '\0'; |
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) |
113 | { | 245 | { |
@@ -123,9 +255,17 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
123 | } | 255 | } |
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(); |
131 | if (exp == NULL) | 271 | if (exp == NULL) |
@@ -145,4 +285,5 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w, int cw) | |||
145 | buff->truncate(i); | 285 | buff->truncate(i); |
146 | laststartline = exp->locate(); | 286 | laststartline = exp->locate(); |
287 | buff->resize(); | ||
147 | return (ch != UEOF); | 288 | return (ch != UEOF); |
148 | } | 289 | } |
@@ -183,5 +324,4 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) | |||
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 | { |
@@ -191,5 +331,4 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) | |||
191 | ret = exp->openfile(src); | 331 | ret = exp->openfile(src); |
192 | } | 332 | } |
193 | |||
194 | if (ret != 0) | 333 | if (ret != 0) |
195 | { | 334 | { |
@@ -199,16 +338,9 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) | |||
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 | |||
@@ -20,4 +20,25 @@ class BuffDoc | |||
20 | CFilterChain* filt; | 20 | CFilterChain* filt; |
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() |
23 | { | 44 | { |
@@ -62,8 +83,13 @@ class BuffDoc | |||
62 | ch = UEOF; | 83 | ch = UEOF; |
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); |
69 | bool getline(CDrawBuffer* buff, int w); | 95 | bool getline(CDrawBuffer* buff, int w); |
@@ -80,4 +106,8 @@ class BuffDoc | |||
80 | return i; | 106 | return i; |
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 | }; |
83 | 113 | ||
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 | |||
@@ -12,5 +12,5 @@ CBufferBase& CBufferBase::assign(const void* sztmp, size_t ms) | |||
12 | } | 12 | } |
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 | { |
16 | buffer = new unsigned char[len*membersize]; | 16 | buffer = new unsigned char[len*membersize]; |
@@ -32,5 +32,5 @@ void* CBufferBase::operator[](int i) | |||
32 | } | 32 | } |
33 | 33 | ||
34 | size_t CBufferBase::bstrlen(unsigned char* _buffer) | 34 | size_t CBufferBase::bstrlen(unsigned char* _buffer = NULL) |
35 | { | 35 | { |
36 | if (_buffer == NULL) _buffer = buffer; | 36 | if (_buffer == NULL) _buffer = buffer; |
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,18 +1,24 @@ | |||
1 | |||
2 | #include "CDrawBuffer.h" | 1 | #include "CDrawBuffer.h" |
3 | #include "FontControl.h" | 2 | #include "FontControl.h" |
4 | #include <qfontmetrics.h> | 3 | #include <qfontmetrics.h> |
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 | ||
7 | void CDrawBuffer::setright(CDrawBuffer& rhs, int f) | 13 | void CDrawBuffer::setright(CDrawBuffer& rhs, int f) |
8 | { | 14 | { |
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(); ) |
18 | { | 24 | { |
@@ -23,4 +29,7 @@ void CDrawBuffer::setright(CDrawBuffer& rhs, int f) | |||
23 | int st = next->start-f; | 29 | int st = next->start-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)); |
26 | } | 35 | } |
@@ -29,5 +38,4 @@ void CDrawBuffer::setright(CDrawBuffer& rhs, int f) | |||
29 | (*this)[i-f] = '\0'; | 38 | (*this)[i-f] = '\0'; |
30 | len = i; | 39 | len = i; |
31 | // qDebug("Tried 1"); | ||
32 | } | 40 | } |
33 | 41 | ||
@@ -41,5 +49,9 @@ CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) | |||
41 | m_descent = rhs.m_descent; | 49 | m_descent = rhs.m_descent; |
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++) |
45 | { | 57 | { |
@@ -56,5 +68,8 @@ CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) | |||
56 | { | 68 | { |
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())); |
60 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; | 75 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; |
@@ -68,7 +83,11 @@ void CDrawBuffer::empty() | |||
68 | len = 0; | 83 | len = 0; |
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 | } |
74 | 93 | ||
@@ -77,9 +96,4 @@ void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) | |||
77 | if (len == 0) | 96 | if (len == 0) |
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; |
85 | segs.first().style = _style; | 99 | segs.first().style = _style; |
@@ -87,12 +101,4 @@ void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) | |||
87 | else if (_style != segs.last().style) | 101 | else if (_style != segs.last().style) |
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)); |
98 | } | 104 | } |
@@ -121,8 +127,24 @@ int CDrawBuffer::width(int numchars) | |||
121 | } | 127 | } |
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()) |
130 | { | ||
131 | currentx += currentstyle.getPicture()->width(); | ||
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()); | ||
124 | QString str = text.mid(textstart->start, end-textstart->start); | 144 | QString str = text.mid(textstart->start, end-textstart->start); |
125 | QFontMetrics fm(f); | 145 | QFontMetrics fm(f); |
126 | currentx += fm.width(str); | 146 | currentx += fm.width(str); |
147 | } | ||
148 | } | ||
127 | textstart = textend; | 149 | textstart = textend; |
128 | } | 150 | } |
@@ -131,9 +153,46 @@ int CDrawBuffer::width(int numchars) | |||
131 | } | 153 | } |
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(); |
139 | switch (align) | 198 | switch (align) |
@@ -141,12 +200,10 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int | |||
141 | case CStyle::m_AlignRight: | 200 | case CStyle::m_AlignRight: |
142 | { | 201 | { |
143 | // int linelength = width(); | 202 | currentx = scwidth - width() - 2*BORDER; |
144 | currentx = scwidth - width(); | ||
145 | } | 203 | } |
146 | break; | 204 | break; |
147 | case CStyle::m_AlignCentre: | 205 | case CStyle::m_AlignCentre: |
148 | { | 206 | { |
149 | // int linelength = width(); | 207 | currentx = (scwidth - width())/2 - BORDER; |
150 | currentx = (scwidth - width())/2; | ||
151 | } | 208 | } |
152 | break; | 209 | break; |
@@ -155,4 +212,5 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int | |||
155 | break; | 212 | break; |
156 | } | 213 | } |
214 | */ | ||
157 | CList<textsegment>::iterator textend = textstart; | 215 | CList<textsegment>::iterator textend = textstart; |
158 | do | 216 | do |
@@ -161,10 +219,25 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int | |||
161 | int end = (textend != segs.end()) ? textend->start : length(); | 219 | int end = (textend != segs.end()) ? textend->start : length(); |
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++) |
170 | { | 243 | { |
@@ -175,11 +248,55 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int | |||
175 | else | 248 | else |
176 | { | 249 | { |
177 | _p->drawText( currentx, _y, str); | 250 | if (currentstyle.isPicture()) |
251 | { | ||
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 | { | ||
178 | QFontMetrics fm(f); | 282 | QFontMetrics fm(f); |
179 | currentx += fm.width(str); | 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 | } |
181 | textstart = textend; | 298 | textstart = textend; |
182 | } | 299 | } |
183 | while (textend != segs.end()); | 300 | while (textend != segs.end() && textstart->start < length()-1); |
184 | } | 301 | } |
185 | 302 | ||
@@ -189,5 +306,5 @@ CStyle CDrawBuffer::laststyle() | |||
189 | } | 306 | } |
190 | 307 | ||
191 | bool CDrawBuffer::isLink(int numchars, size_t& tgt) | 308 | linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt) |
192 | { | 309 | { |
193 | int end = 0; | 310 | int end = 0; |
@@ -199,13 +316,64 @@ bool CDrawBuffer::isLink(int numchars, size_t& tgt) | |||
199 | textend++; | 316 | textend++; |
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); |
327 | // if (currentstyle.isPicture()) qDebug("Clicked on picture"); | ||
328 | if (currentstyle.getPictureLink()) | ||
329 | { | ||
330 | tgt = currentstyle.getPictureLinkData(); | ||
331 | return ePicture; | ||
332 | } | ||
333 | if (currentstyle.getLink()) | ||
334 | { | ||
209 | tgt = currentstyle.getData(); | 335 | tgt = currentstyle.getData(); |
210 | return currentstyle.getLink(); | 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 | |||
@@ -8,9 +8,16 @@ | |||
8 | class QPainter; | 8 | class QPainter; |
9 | 9 | ||
10 | enum linkType | ||
11 | { | ||
12 | eNone, | ||
13 | eLink, | ||
14 | ePicture | ||
15 | }; | ||
16 | |||
10 | struct textsegment | 17 | struct textsegment |
11 | { | 18 | { |
12 | int start; | 19 | int start; |
13 | CStyle style; | 20 | CStyle style; |
14 | textsegment(int _start, CStyle _style) | 21 | textsegment(int _start, const CStyle& _style) |
15 | : | 22 | : |
16 | start(_start), style(_style) | 23 | start(_start), style(_style) |
@@ -25,6 +32,14 @@ class CDrawBuffer : public CBuffer | |||
25 | int len; | 32 | int len; |
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) |
30 | : | 45 | : |
@@ -33,4 +48,5 @@ class CDrawBuffer : public CBuffer | |||
33 | empty(); | 48 | empty(); |
34 | } | 49 | } |
50 | ~CDrawBuffer(); | ||
35 | /* | 51 | /* |
36 | CDrawBuffer() | 52 | CDrawBuffer() |
@@ -42,7 +58,6 @@ class CDrawBuffer : public CBuffer | |||
42 | */ | 58 | */ |
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(); |
48 | void addch(tchar ch, CStyle _style); | 63 | void addch(tchar ch, CStyle _style); |
@@ -53,7 +68,9 @@ class CDrawBuffer : public CBuffer | |||
53 | int descent() { return m_descent; } | 68 | int descent() { return m_descent; } |
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 | }; |
59 | #endif | 76 | #endif |
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 | |||
@@ -2,8 +2,14 @@ | |||
2 | #define __CExpander_h | 2 | #define __CExpander_h |
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" |
5 | #include "StyleConsts.h" | 9 | #include "StyleConsts.h" |
6 | #include "Markups.h" | 10 | #include "Markups.h" |
11 | #include "name.h" | ||
7 | 12 | ||
13 | class QPixmap; | ||
8 | class Bkmk; | 14 | class Bkmk; |
9 | 15 | ||
@@ -19,8 +25,24 @@ class CCharacterSource | |||
19 | class CExpander | 25 | 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; |
26 | virtual void locate(unsigned int n) = 0; | 48 | virtual void locate(unsigned int n) = 0; |
@@ -40,4 +62,63 @@ class CExpander | |||
40 | } | 62 | } |
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 | }; |
43 | #endif | 124 | #endif |
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 | |||
@@ -533,5 +533,5 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
533 | break; | 533 | break; |
534 | case 'c': | 534 | case 'c': |
535 | if (currentstyle.getJustify() == CStyle::m_AlignCentre) | 535 | if (currentstyle.getJustify() == m_AlignCentre) |
536 | { | 536 | { |
537 | currentstyle.setLeftJustify(); | 537 | currentstyle.setLeftJustify(); |
@@ -544,5 +544,5 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
544 | break; | 544 | break; |
545 | case 'r': | 545 | case 'r': |
546 | if (currentstyle.getJustify() == CStyle::m_AlignRight) | 546 | if (currentstyle.getJustify() == m_AlignRight) |
547 | { | 547 | { |
548 | currentstyle.setLeftJustify(); | 548 | currentstyle.setLeftJustify(); |
@@ -560,2 +560,125 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
560 | sty = currentstyle; | 560 | sty = currentstyle; |
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 | |||
@@ -267,3 +267,21 @@ class PeanutFormatter : public CFilter | |||
267 | virtual void getch(tchar& ch, CStyle& sty); | 267 | virtual void getch(tchar& ch, CStyle& sty); |
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 | |||
@@ -12,8 +12,9 @@ class FontControl | |||
12 | QString m_fontname; | 12 | QString m_fontname; |
13 | int m_maxsize; | 13 | int m_maxsize; |
14 | bool m_hasCourier; | ||
14 | public: | 15 | public: |
15 | FontControl(QString n = "helvetica", int size = 10) | 16 | FontControl(QString n = "helvetica", int size = 10) |
16 | : | 17 | : |
17 | m_fontsizes(NULL) | 18 | m_fontsizes(NULL), m_hasCourier(false) |
18 | { | 19 | { |
19 | ChangeFont(n, size); | 20 | ChangeFont(n, size); |
@@ -23,9 +24,20 @@ class FontControl | |||
23 | if (m_fontsizes != NULL) delete [] m_fontsizes; | 24 | if (m_fontsizes != NULL) delete [] m_fontsizes; |
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; } |
26 | int currentsize() { return m_fontsizes[m_size]; } | 29 | int currentsize() { return m_fontsizes[m_size]; } |
27 | int getsize(CStyle size) | 30 | int getsize(CStyle size) |
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 | } |
31 | int ascent() | 43 | int ascent() |
@@ -87,34 +99,5 @@ class FontControl | |||
87 | return ChangeFont(n, currentsize()); | 99 | return ChangeFont(n, currentsize()); |
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 | }; |
120 | 103 | ||
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 | |||
@@ -23,4 +23,5 @@ | |||
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include "StateData.h" | ||
25 | 26 | ||
26 | #ifdef _UNICODE | 27 | #ifdef _UNICODE |
@@ -36,5 +37,5 @@ const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; | |||
36 | //const int QTReader::fontsizes[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0}; | 37 | //const int QTReader::fontsizes[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,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), |
40 | m_delay(100), | 41 | m_delay(100), |
@@ -49,5 +50,7 @@ QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : | |||
49 | mouseUpOn(true), | 50 | mouseUpOn(true), |
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 | { |
53 | m_overlap = 1; | 56 | m_overlap = 1; |
@@ -82,7 +85,45 @@ long QTReader::real_delay() | |||
82 | void QTReader::mousePressEvent( QMouseEvent* _e ) | 85 | void QTReader::mousePressEvent( QMouseEvent* _e ) |
83 | { | 86 | { |
87 | buffdoc.unsuspend(); | ||
84 | if (_e->button() == RightButton) | 88 | if (_e->button() == RightButton) |
85 | { | 89 | { |
86 | mouseUpOn = false; | 90 | mouseUpOn = false; |
91 | if (buffdoc.hasnavigation()) | ||
92 | { | ||
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 | } | ||
125 | } | ||
126 | else | ||
127 | { | ||
87 | if (_e->y() > height()/2) | 128 | if (_e->y() > height()/2) |
88 | { | 129 | { |
@@ -95,6 +136,7 @@ void QTReader::mousePressEvent( QMouseEvent* _e ) | |||
95 | } | 136 | } |
96 | } | 137 | } |
138 | } | ||
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 | { |
100 | int lineno = 0; | 142 | int lineno = 0; |
@@ -113,8 +155,9 @@ bool QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t | |||
113 | int i; | 155 | int i; |
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 | } |
120 | 163 | ||
@@ -125,6 +168,13 @@ void QTReader::setTwoTouch(bool _b) | |||
125 | } | 168 | } |
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) |
130 | { | 180 | { |
@@ -142,8 +192,12 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | |||
142 | } | 192 | } |
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)) |
195 | { | ||
196 | case eLink: | ||
145 | { | 197 | { |
198 | size_t saveposn = pagelocate(); | ||
146 | if (buffdoc.hyperlink(tgt)) | 199 | if (buffdoc.hyperlink(tgt)) |
147 | { | 200 | { |
201 | buffdoc.saveposn(saveposn); | ||
148 | fillbuffer(); | 202 | fillbuffer(); |
149 | update(); | 203 | update(); |
@@ -155,4 +209,25 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | |||
155 | return; | 209 | return; |
156 | } | 210 | } |
211 | case ePicture: | ||
212 | { | ||
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; | ||
225 | } | ||
226 | case eNone: | ||
227 | break; | ||
228 | default: | ||
229 | qDebug("Unknown linktype"); | ||
230 | return; | ||
231 | } | ||
157 | if (m_twotouch) | 232 | if (m_twotouch) |
158 | { | 233 | { |
@@ -213,9 +288,10 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | |||
213 | CDrawBuffer* t = textarray[lineno]; | 288 | CDrawBuffer* t = textarray[lineno]; |
214 | int first = 0; | 289 | int first = 0; |
290 | int tgt = _e->x() - t->offset(width()); | ||
215 | while (1) | 291 | while (1) |
216 | { | 292 | { |
217 | int i = first+1; | 293 | int i = first+1; |
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 | { |
221 | wrd = toQString(t->data()+first, i - first); | 297 | wrd = toQString(t->data()+first, i - first); |
@@ -283,6 +359,75 @@ void QTReader::goUp() | |||
283 | } | 359 | } |
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()) |
288 | { | 433 | { |
@@ -361,29 +506,27 @@ void QTReader::keyPressEvent(QKeyEvent* e) | |||
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(); | ||
370 | m_autoScroll = sc; | ||
371 | if (m_autoScroll) autoscroll(); | ||
372 | } | 514 | } |
373 | } | 515 | } |
516 | else zoomin(); | ||
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; | ||
386 | if (m_autoScroll) autoscroll(); | ||
387 | } | 529 | } |
530 | else zoomout(); | ||
388 | } | 531 | } |
389 | break; | 532 | break; |
@@ -410,4 +553,6 @@ void QTReader::setautoscroll(bool _sc) | |||
410 | else | 553 | else |
411 | { | 554 | { |
555 | CDrawBuffer* reusebuffer = textarray[numlines]; | ||
556 | if (reusebuffer == NULL || reusebuffer->eof()) return; | ||
412 | m_autoScroll = true; | 557 | m_autoScroll = true; |
413 | autoscroll(); | 558 | autoscroll(); |
@@ -418,4 +563,5 @@ void QTReader::setautoscroll(bool _sc) | |||
418 | bool QTReader::getline(CDrawBuffer *buff) | 563 | bool QTReader::getline(CDrawBuffer *buff) |
419 | { | 564 | { |
565 | buffdoc.unsuspend(); | ||
420 | if (m_bMonoSpaced) | 566 | if (m_bMonoSpaced) |
421 | { | 567 | { |
@@ -460,9 +606,9 @@ void QTReader::doscroll() | |||
460 | if (textarray[numlines] == NULL) | 606 | if (textarray[numlines] == NULL) |
461 | { | 607 | { |
462 | textarray[numlines] = new CDrawBuffer; | 608 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
463 | } | 609 | } |
464 | locnarray[numlines] = locate(); | 610 | locnarray[numlines] = locate(); |
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(); |
468 | if (!ch) | 614 | if (!ch) |
@@ -470,5 +616,4 @@ void QTReader::doscroll() | |||
470 | m_autoScroll = false; | 616 | m_autoScroll = false; |
471 | ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); | 617 | ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); |
472 | emit OnRedraw(); | ||
473 | } | 618 | } |
474 | emit OnRedraw(); | 619 | emit OnRedraw(); |
@@ -493,61 +638,47 @@ void QTReader::setfont() | |||
493 | void QTReader::drawFonts( QPainter *p ) | 638 | void QTReader::drawFonts( QPainter *p ) |
494 | { | 639 | { |
640 | if (bDoUpdates) | ||
641 | { | ||
642 | qDebug("How refreshing..."); | ||
643 | if (buffdoc.empty()) return; | ||
495 | setfont(); | 644 | setfont(); |
496 | if (m_lastwidth != width() || m_lastheight != height()) | 645 | if (m_lastwidth != width()) |
497 | { | 646 | { |
647 | qDebug("Not Optimised %d", m_lastwidth); | ||
498 | m_lastwidth = width(); | 648 | m_lastwidth = width(); |
499 | m_lastheight = height(); | 649 | m_lastheight = height(); |
500 | locate(pagelocate()); | 650 | locate(pagelocate()); |
651 | qDebug("Not Optimised %d", m_lastwidth); | ||
501 | } | 652 | } |
502 | else | 653 | else |
503 | { | 654 | { |
504 | 655 | if (m_lastheight > height()) | |
505 | /* | ||
506 | int sl = screenlines(); | ||
507 | if (sl < numlines) | ||
508 | { | 656 | { |
509 | //qDebug("df:<%u,%u>",sl,numlines); | 657 | qDebug("Optimised < %d", numlines); |
510 | 658 | int ypos = 0; | |
511 | size_t newpos = locnarray[sl]; | 659 | for (int i = 0; i < numlines; i++) |
512 | CDrawBuffer** nta = new CDrawBuffer*[sl]; | 660 | { |
513 | size_t* nla = new size_t[sl]; | 661 | if ((ypos += textarray[i]->lineSpacing()) > height()) |
514 | for (int i = 0; i < sl; i++) | ||
515 | { | 662 | { |
516 | nta[i] = textarray[i]; | 663 | numlines = i; |
517 | nla[i] = locnarray[i]; | 664 | jumpto(locnarray[i+1]); |
665 | break; | ||
518 | } | 666 | } |
519 | for (int i = sl; i < numlines; i++) delete textarray[i]; | ||
520 | delete [] locnarray; | ||
521 | delete [] textarray; | ||
522 | textarray = nta; | ||
523 | locnarray = nla; | ||
524 | numlines = sl; | ||
525 | jumpto(mylastpos = newpos); | ||
526 | } | 667 | } |
527 | if (sl > numlines) | 668 | qDebug("Optimised < %d", numlines); |
528 | { | 669 | m_lastheight = height(); |
529 | //qDebug("df:<%u,%u>",sl,numlines); | ||
530 | CDrawBuffer** nta = new CDrawBuffer*[sl]; | ||
531 | size_t* nla = new size_t[sl]; | ||
532 | for (int i = 0; i < numlines; i++) | ||
533 | { | ||
534 | nta[i] = textarray[i]; | ||
535 | nla[i] = locnarray[i]; | ||
536 | } | 670 | } |
537 | if (locate() != mylastpos) jumpto(mylastpos); | 671 | else if (m_lastheight < height()) |
538 | for (int i = numlines; i < sl; i++) | ||
539 | { | 672 | { |
540 | nta[i] = new CDrawBuffer(&m_fontControl); | 673 | qDebug("Optimised > %d", numlines); |
541 | nla[i] = locate(); | 674 | int ypos = 0; |
542 | getline(nta[i]); | 675 | for (int i = 0; i <= numlines; i++) |
676 | { | ||
677 | ypos += textarray[i]->lineSpacing(); | ||
543 | } | 678 | } |
544 | mylastpos = locate(); | 679 | fillbuffer(numlines+1, ypos); |
545 | delete [] locnarray; | 680 | qDebug("Optimised > %d", numlines); |
546 | delete [] textarray; | 681 | m_lastheight = height(); |
547 | textarray = nta; | ||
548 | locnarray = nla; | ||
549 | numlines = sl; | ||
550 | } | 682 | } |
551 | */ | ||
552 | if (numlines > 0) | 683 | if (numlines > 0) |
553 | { | 684 | { |
@@ -556,7 +687,8 @@ void QTReader::drawFonts( QPainter *p ) | |||
556 | for (int i = 1; i < numlines; i++) | 687 | for (int i = 1; i < numlines; i++) |
557 | { | 688 | { |
558 | ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; | 689 | // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; |
690 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ | ||
691 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; | ||
559 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); | 692 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); |
560 | |||
561 | } | 693 | } |
562 | // mylastpos = locate(); | 694 | // mylastpos = locate(); |
@@ -566,4 +698,9 @@ void QTReader::drawFonts( QPainter *p ) | |||
566 | emit OnRedraw(); | 698 | emit OnRedraw(); |
567 | } | 699 | } |
700 | else | ||
701 | { | ||
702 | qDebug("Not so refreshing..."); | ||
703 | } | ||
704 | } | ||
568 | 705 | ||
569 | QString QTReader::firstword() | 706 | QString QTReader::firstword() |
@@ -608,4 +745,5 @@ void QTReader::init() | |||
608 | // setCaption( "Qt Draw Demo Application" ); | 745 | // setCaption( "Qt Draw Demo Application" ); |
609 | 746 | ||
747 | buffdoc.unsuspend(); | ||
610 | setBackgroundColor( white ); | 748 | setBackgroundColor( white ); |
611 | // QPainter p(this); | 749 | // QPainter p(this); |
@@ -619,7 +757,6 @@ void QTReader::init() | |||
619 | connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); | 757 | connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); |
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()) |
625 | { | 762 | { |
@@ -627,4 +764,5 @@ void QTReader::init() | |||
627 | load_file(m_lastfile); | 764 | load_file(m_lastfile); |
628 | } | 765 | } |
766 | */ | ||
629 | } | 767 | } |
630 | 768 | ||
@@ -702,4 +840,5 @@ int main( int argc, tchar **argv ) | |||
702 | bool QTReader::locate(unsigned long n) { | 840 | 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); |
705 | // qDebug("&buffdoc.located"); | 844 | // qDebug("&buffdoc.located"); |
@@ -720,4 +859,5 @@ unsigned int QTReader::screenlines() | |||
720 | bool QTReader::fillbuffer(int reuse, int ht) | 859 | bool QTReader::fillbuffer(int reuse, int ht) |
721 | { | 860 | { |
861 | buffdoc.unsuspend(); | ||
722 | if (buffdoc.empty()) return false; | 862 | if (buffdoc.empty()) return false; |
723 | m_scrolldy1 = m_scrolldy2 = 0; | 863 | m_scrolldy1 = m_scrolldy2 = 0; |
@@ -727,5 +867,5 @@ bool QTReader::fillbuffer(int reuse, int ht) | |||
727 | int ypos = ht; | 867 | int ypos = ht; |
728 | numlines = reuse; | 868 | numlines = reuse; |
729 | while (ypos < height()) | 869 | while (ypos < height() || numlines < 2) |
730 | { | 870 | { |
731 | if (textarray[numlines] == NULL) | 871 | if (textarray[numlines] == NULL) |
@@ -739,5 +879,5 @@ bool QTReader::fillbuffer(int reuse, int ht) | |||
739 | if (!ch) | 879 | if (!ch) |
740 | { | 880 | { |
741 | if (numlines - reuse == 1/* && locnarray[0] == buffdoc.locate()*/) | 881 | if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/) |
742 | { | 882 | { |
743 | locate(oldpagepos); | 883 | locate(oldpagepos); |
@@ -762,4 +902,5 @@ bool QTReader::fillbuffer(int reuse, int ht) | |||
762 | void QTReader::dopagedn() | 902 | void QTReader::dopagedn() |
763 | { | 903 | { |
904 | buffdoc.unsuspend(); | ||
764 | int skip = 0, ypos = 0; | 905 | int skip = 0, ypos = 0; |
765 | if (locate() != mylastpos) | 906 | if (locate() != mylastpos) |
@@ -769,4 +910,5 @@ void QTReader::dopagedn() | |||
769 | } | 910 | } |
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) |
772 | { | 914 | { |
@@ -778,4 +920,5 @@ void QTReader::dopagedn() | |||
778 | textarray[offset] = textarray[i]; | 920 | textarray[offset] = textarray[i]; |
779 | textarray[i] = reusebuffer; | 921 | textarray[i] = reusebuffer; |
922 | // reusebuffer->empty(); | ||
780 | locnarray[offset] = locnarray[i]; | 923 | locnarray[offset] = locnarray[i]; |
781 | locnarray[i] = reuselocn; | 924 | locnarray[i] = reuselocn; |
@@ -792,17 +935,35 @@ void QTReader::dopagedn() | |||
792 | void QTReader::dopageup() | 935 | 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; |
949 | int nbfl, ypos = 0; | ||
950 | |||
951 | while (1) | ||
800 | { | 952 | { |
801 | delta = target; | 953 | ch = true; |
802 | jumpto(0); | 954 | nbfl = 0; |
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()); | ||
803 | } | 964 | } |
804 | else | 965 | else |
805 | { | 966 | { |
806 | delta = 2048; | 967 | delta = guess; |
807 | 968 | ||
808 | jumpto(target - delta); | 969 | jumpto(target - delta); |
@@ -815,12 +976,10 @@ void QTReader::dopageup() | |||
815 | if (!getline(buff[0])) break; | 976 | if (!getline(buff[0])) break; |
816 | 977 | ||
817 | if (locate() > target) continue; | 978 | if (locate() > target) break; |
818 | } | 979 | } |
819 | while (!buffdoc.iseol()); | 980 | while (!buffdoc.iseol()); |
820 | } | 981 | } |
821 | int nbfl = 0; | ||
822 | 982 | ||
823 | bool ch = true; | 983 | ypos = 0; |
824 | int ypos = 0; | ||
825 | while (locate() < target) | 984 | while (locate() < target) |
826 | { | 985 | { |
@@ -832,8 +991,15 @@ void QTReader::dopageup() | |||
832 | if (!ch) break; | 991 | if (!ch) break; |
833 | } | 992 | } |
834 | if (ypos < height()) | 993 | if (ypos < height() && (delta != 0)) |
835 | { | 994 | { |
836 | locate(0); | 995 | for (int i = 0; i < nbfl; i++) |
837 | return; | 996 | { |
997 | delete buff[i]; | ||
998 | buff[i] = NULL; | ||
999 | } | ||
1000 | guess <<= 1; | ||
1001 | continue; | ||
1002 | } | ||
1003 | break; | ||
838 | } | 1004 | } |
839 | if (ch) | 1005 | if (ch) |
@@ -846,12 +1012,13 @@ void QTReader::dopageup() | |||
846 | ypos = 0; | 1012 | ypos = 0; |
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++; |
852 | } | 1018 | } |
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++) |
857 | { | 1024 | { |
@@ -859,4 +1026,5 @@ void QTReader::dopageup() | |||
859 | textarray[i] = buff[offset+i]; | 1026 | textarray[i] = buff[offset+i]; |
860 | locnarray[i] = loc[offset + i]; | 1027 | locnarray[i] = loc[offset + i]; |
1028 | ypos += textarray[i]->lineSpacing(); | ||
861 | } | 1029 | } |
862 | for (int i = 0; i < nbfl - numlines - 1; i++) | 1030 | for (int i = 0; i < nbfl - numlines - 1; i++) |
@@ -865,5 +1033,13 @@ void QTReader::dopageup() | |||
865 | } | 1033 | } |
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(); |
869 | 1045 | ||
@@ -884,7 +1060,10 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn) | |||
884 | m_lastfile = newfile; | 1060 | m_lastfile = newfile; |
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) |
887 | { | 1065 | { |
888 | bRC = true; | 1066 | bRC = true; |
1067 | buffdoc.setContinuous(m_continuousDocument); | ||
889 | // qDebug("buffdoc.openfile done"); | 1068 | // qDebug("buffdoc.openfile done"); |
890 | locate(lcn); | 1069 | locate(lcn); |
@@ -1013,4 +1192,5 @@ void QTReader::lineUp() | |||
1013 | void QTReader::lineUp() | 1192 | void QTReader::lineUp() |
1014 | { | 1193 | { |
1194 | buffdoc.unsuspend(); | ||
1015 | CDrawBuffer* buff = textarray[numlines]; | 1195 | CDrawBuffer* buff = textarray[numlines]; |
1016 | unsigned int loc; | 1196 | unsigned int loc; |
@@ -1020,4 +1200,5 @@ void QTReader::lineUp() | |||
1020 | unsigned int target = locnarray[0]; | 1200 | unsigned int target = locnarray[0]; |
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()) |
1023 | { | 1204 | { |
@@ -1035,4 +1216,12 @@ void QTReader::lineUp() | |||
1035 | break; | 1216 | break; |
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); |
1038 | do | 1227 | do |
@@ -1108,2 +1297,31 @@ MarkupType QTReader::PreferredMarkup() | |||
1108 | return m; | 1297 | return m; |
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 | |||
@@ -14,4 +14,6 @@ class CDrawBuffer; | |||
14 | class QPainter; | 14 | class QPainter; |
15 | class QTimer; | 15 | class QTimer; |
16 | class QPixmap; | ||
17 | class statedata; | ||
16 | 18 | ||
17 | class QTReader : public QWidget | 19 | class QTReader : public QWidget |
@@ -20,4 +22,5 @@ class QTReader : public QWidget | |||
20 | 22 | ||
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); |
23 | int m_delay; | 26 | int m_delay; |
@@ -38,5 +41,16 @@ public: | |||
38 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); | 41 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); |
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(); |
42 | void setautoscroll(bool); | 56 | void setautoscroll(bool); |
@@ -109,4 +123,16 @@ public: | |||
109 | setfilter(getfilter()); | 123 | setfilter(getfilter()); |
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) |
112 | { | 138 | { |
@@ -191,6 +217,10 @@ public: | |||
191 | if (bunindent) filt->addfilter(new unindent); | 217 | if (bunindent) filt->addfilter(new unindent); |
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); |
196 | if (bmakebold) filt->addfilter(new embolden); | 226 | if (bmakebold) filt->addfilter(new embolden); |
@@ -217,7 +247,8 @@ private slots: | |||
217 | private: | 247 | private: |
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(); |
223 | void lineDown(); | 254 | void lineDown(); |
@@ -230,10 +261,17 @@ private slots: | |||
230 | CBufferFace<size_t> locnarray; | 261 | CBufferFace<size_t> locnarray; |
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; |
235 | QString m_lastfile; | 269 | QString m_lastfile; |
236 | size_t m_lastposn; | 270 | size_t m_lastposn; |
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(); } |
239 | bool tight; | 277 | bool tight; |
@@ -242,10 +280,10 @@ private slots: | |||
242 | CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } | 280 | CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } |
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); } |
251 | void goUp(); | 289 | void goUp(); |
@@ -257,5 +295,5 @@ private slots: | |||
257 | bool fillbuffer(int ru = 0, int ht = 0); | 295 | bool fillbuffer(int ru = 0, int ht = 0); |
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[]; |
261 | // unsigned int *fontsizes; | 299 | // unsigned int *fontsizes; |
@@ -263,4 +301,5 @@ private slots: | |||
263 | QFontMetrics* m_fm; | 301 | QFontMetrics* m_fm; |
264 | QString firstword(); | 302 | QString firstword(); |
303 | void setstate(const statedata& sd); | ||
265 | 304 | ||
266 | signals: | 305 | signals: |
@@ -268,4 +307,5 @@ private slots: | |||
268 | void OnWordSelected(const QString&, size_t, const QString&); | 307 | void OnWordSelected(const QString&, size_t, const QString&); |
269 | void OnActionPressed(); | 308 | void OnActionPressed(); |
309 | void OnShowPicture(QPixmap&); | ||
270 | }; | 310 | }; |
271 | 311 | ||
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 | |||
@@ -22,5 +22,8 @@ | |||
22 | #include <qwidgetstack.h> | 22 | #include <qwidgetstack.h> |
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> |
26 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
@@ -43,4 +46,5 @@ | |||
43 | 46 | ||
44 | #include "QTReader.h" | 47 | #include "QTReader.h" |
48 | #include "GraphicWin.h" | ||
45 | #include "Bkmks.h" | 49 | #include "Bkmks.h" |
46 | #include "cbkmkselector.h" | 50 | #include "cbkmkselector.h" |
@@ -56,4 +60,14 @@ | |||
56 | #include "fileBrowser.h" | 60 | #include "fileBrowser.h" |
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 | ||
59 | 73 | ||
@@ -69,7 +83,8 @@ void QTReaderApp::listBkmkFiles() | |||
69 | { | 83 | { |
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 | ||
75 | while(1) | 90 | while(1) |
@@ -80,5 +95,5 @@ void QTReaderApp::listBkmkFiles() | |||
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); |
@@ -94,11 +109,19 @@ void QTReaderApp::listBkmkFiles() | |||
94 | editBar->hide(); | 109 | editBar->hide(); |
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 | { |
113 | Global::hideInputMethod(); | ||
114 | regBar->hide(); | ||
115 | } | ||
116 | if (searchVisible) | ||
117 | { | ||
118 | Global::hideInputMethod(); | ||
119 | searchBar->hide(); | ||
120 | } | ||
98 | m_nRegAction = cRmBkmkFile; | 121 | m_nRegAction = cRmBkmkFile; |
99 | editorStack->raiseWidget( bkmkselector ); | 122 | editorStack->raiseWidget( bkmkselector ); |
100 | } | 123 | } |
101 | else | 124 | else |
102 | QMessageBox::information(this, "OpieReader", "No bookmark files"); | 125 | QMessageBox::information(this, PROGNAME, "No bookmark files"); |
103 | } | 126 | } |
104 | 127 | ||
@@ -110,5 +133,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
110 | 133 | ||
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; |
@@ -119,7 +143,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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 ); |
125 | addToolBar(bar, "tool",QMainWindow::Top, true); | 150 | addToolBar(bar, "tool",QMainWindow::Top, true); |
@@ -127,4 +152,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
127 | 152 | ||
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 ); |
130 | QPopupMenu *format = new QPopupMenu( this ); | 156 | QPopupMenu *format = new QPopupMenu( this ); |
@@ -160,4 +186,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
160 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); | 186 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); |
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"); |
163 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); | 193 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); |
@@ -176,10 +206,15 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
176 | importSelector->setCloseVisible( FALSE ); | 206 | importSelector->setCloseVisible( FALSE ); |
177 | */ | 207 | */ |
208 | qDebug("Reading file list"); | ||
209 | readfilelist(); | ||
178 | 210 | ||
179 | reader = new QTReader( editorStack ); | 211 | reader = new QTReader( editorStack ); |
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" ); |
185 | 220 | ||
@@ -190,4 +225,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
190 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 225 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); |
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 ); |
193 | reader->brepara = config.readBoolEntry( "Repara", false ); | 229 | reader->brepara = config.readBoolEntry( "Repara", false ); |
@@ -199,4 +235,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
199 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 235 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
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); |
202 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 239 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
@@ -204,6 +241,10 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
204 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 241 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
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 ); |
209 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 250 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
@@ -216,4 +257,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
216 | 257 | ||
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() ) ); |
219 | connect( reader, SIGNAL( OnActionPressed() ), this, SLOT( OnActionPressed() ) ); | 262 | connect( reader, SIGNAL( OnActionPressed() ), this, SLOT( OnActionPressed() ) ); |
@@ -226,4 +269,9 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
226 | a->addTo( file ); | 269 | a->addTo( file ); |
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 | /* |
229 | a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 277 | a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
@@ -251,16 +299,38 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
251 | m_buttonAction[2] = new QAction( tr( "Mark" ), QString::null, 0, ag, NULL, true ); | 299 | m_buttonAction[2] = new QAction( tr( "Mark" ), QString::null, 0, ag, NULL, true ); |
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); |
254 | 304 | ||
255 | connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) ); | 305 | connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) ); |
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 | ||
266 | /* | 336 | /* |
@@ -273,16 +343,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
273 | a->addTo( file ); | 343 | a->addTo( file ); |
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 | ||
288 | file->insertSeparator(); | 346 | file->insertSeparator(); |
@@ -299,5 +357,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
299 | ag = new QActionGroup(this); | 357 | ag = new QActionGroup(this); |
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 ); |
303 | 361 | ||
@@ -346,4 +404,15 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
346 | 404 | ||
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 ); |
349 | connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); | 418 | connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); |
@@ -396,4 +465,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
396 | // a->addTo( format ); | 465 | // a->addTo( format ); |
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 ); |
399 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) ); | 472 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) ); |
@@ -417,5 +490,9 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
417 | a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL ); | 490 | a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL ); |
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 ); |
421 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) ); | 498 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) ); |
@@ -430,9 +507,13 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
430 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); | 507 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); |
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 | ||
438 | 519 | ||
@@ -440,5 +521,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
440 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 521 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
441 | a->setOn(reader->m_bMonoSpaced); | 522 | a->setOn(reader->m_bMonoSpaced); |
442 | format->insertSeparator(); | ||
443 | a->addTo( format ); | 523 | a->addTo( format ); |
444 | 524 | ||
@@ -580,4 +660,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
580 | m_fontBar->setHorizontalStretchable( TRUE ); | 660 | m_fontBar->setHorizontalStretchable( TRUE ); |
581 | 661 | ||
662 | qDebug("Font selector"); | ||
582 | m_fontSelector = new QComboBox(false, m_fontBar); | 663 | m_fontSelector = new QComboBox(false, m_fontBar); |
583 | m_fontBar->setStretchableWidget( m_fontSelector ); | 664 | m_fontBar->setStretchableWidget( m_fontSelector ); |
@@ -593,6 +674,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
593 | { | 674 | { |
594 | realfont = true; | 675 | realfont = true; |
595 | break; | ||
596 | } | 676 | } |
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]; |
@@ -608,15 +689,63 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
608 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); | 689 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); |
609 | 690 | ||
610 | 691 | qDebug("Initing"); | |
611 | reader->init(); | 692 | reader->init(); |
693 | qDebug("Inited"); | ||
694 | m_EncodingAction[reader->m_encd]->setOn(true); | ||
695 | m_buttonAction[m_spaceTarget]->setOn(true); | ||
696 | qDebug("fonting"); | ||
697 | do_setfont(reader->m_fontname); | ||
612 | if (!reader->m_lastfile.isEmpty()) | 698 | if (!reader->m_lastfile.isEmpty()) |
613 | { | 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"); | ||
614 | openFile( reader->m_lastfile ); | 733 | openFile( reader->m_lastfile ); |
615 | doc = new DocLnk(reader->m_lastfile); | ||
616 | } | 734 | } |
617 | m_EncodingAction[reader->m_encd]->setOn(true); | ||
618 | m_buttonAction[m_spaceTarget]->setOn(true); | ||
619 | do_setfont(reader->m_fontname); | ||
620 | } | 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 | ||
622 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | 751 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) |
@@ -631,5 +760,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
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 | } |
635 | else if ( msg == "warn(QString)" ) | 764 | else if ( msg == "warn(QString)" ) |
@@ -637,5 +766,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
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 | } |
641 | 770 | ||
@@ -752,5 +881,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
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; |
@@ -765,4 +894,18 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
765 | stripcr(info); | 894 | stripcr(info); |
766 | } | 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); | ||
908 | } | ||
909 | #endif | ||
767 | else if ( msg == "Markup/Auto(int)" ) | 910 | else if ( msg == "Markup/Auto(int)" ) |
768 | { | 911 | { |
@@ -877,4 +1020,20 @@ ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) | |||
877 | } | 1020 | } |
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) |
880 | { | 1039 | { |
@@ -911,14 +1070,15 @@ void QTReaderApp::autoScroll(bool _b) | |||
911 | { | 1070 | { |
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 | } |
924 | 1084 | ||
@@ -930,4 +1090,76 @@ void QTReaderApp::clearBkmkList() | |||
930 | } | 1090 | } |
931 | 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; | ||
1162 | } | ||
1163 | |||
932 | void QTReaderApp::fileOpen() | 1164 | void QTReaderApp::fileOpen() |
933 | { | 1165 | { |
@@ -938,9 +1170,17 @@ void QTReaderApp::fileOpen() | |||
938 | if (searchVisible) searchBar->hide(); | 1170 | if (searchVisible) searchBar->hide(); |
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 | } |
@@ -954,17 +1194,43 @@ void QTReaderApp::fileOpen() | |||
954 | fileSelector->reread(); | 1194 | fileSelector->reread(); |
955 | */ | 1195 | */ |
956 | fileBrowser* fb = new fileBrowser(this,"OpieReader",TRUE, | 1196 | if (pOpenlist != NULL) |
1197 | { | ||
1198 | m_nRegAction = cOpenFile; | ||
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, | ||
957 | 0, | 1215 | 0, |
958 | // WStyle_Customize | WStyle_NoBorderEx, | 1216 | // WStyle_Customize | WStyle_NoBorderEx, |
959 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); | 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 | } |
970 | 1236 | ||
@@ -974,5 +1240,5 @@ void QTReaderApp::showinfo() | |||
974 | if (reader->empty()) | 1240 | if (reader->empty()) |
975 | { | 1241 | { |
976 | QMessageBox::information(this, "OpieReader", "No file loaded", 1); | 1242 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
977 | } | 1243 | } |
978 | else | 1244 | else |
@@ -1021,5 +1287,5 @@ void QTReaderApp::addAnno(const QString& name, const QString& text) | |||
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 |
@@ -1078,5 +1344,5 @@ void QTReaderApp::addanno() | |||
1078 | if (reader->empty()) | 1344 | if (reader->empty()) |
1079 | { | 1345 | { |
1080 | QMessageBox::information(this, "OpieReader", "No file loaded", 1); | 1346 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
1081 | } | 1347 | } |
1082 | else | 1348 | else |
@@ -1087,4 +1353,5 @@ void QTReaderApp::addanno() | |||
1087 | m_annoIsEditing = true; | 1353 | m_annoIsEditing = true; |
1088 | editorStack->raiseWidget( m_annoWin ); | 1354 | editorStack->raiseWidget( m_annoWin ); |
1355 | Global::showInputMethod(); | ||
1089 | m_annoWin->setFocus(); | 1356 | m_annoWin->setFocus(); |
1090 | } | 1357 | } |
@@ -1133,10 +1400,10 @@ void QTReaderApp::editCopy() | |||
1133 | void QTReaderApp::pageup() | 1400 | void QTReaderApp::pageup() |
1134 | { | 1401 | { |
1135 | reader->goUp(); | 1402 | reader->NavUp(); |
1136 | } | 1403 | } |
1137 | 1404 | ||
1138 | void QTReaderApp::pagedn() | 1405 | void QTReaderApp::pagedn() |
1139 | { | 1406 | { |
1140 | reader->goDown(); | 1407 | reader->NavDown(); |
1141 | } | 1408 | } |
1142 | 1409 | ||
@@ -1145,4 +1412,14 @@ void QTReaderApp::stripcr(bool _b) | |||
1145 | reader->setstripcr(_b); | 1412 | reader->setstripcr(_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) |
1148 | { | 1425 | { |
@@ -1189,5 +1466,8 @@ void QTReaderApp::pagemode(bool _b) | |||
1189 | reader->setpagemode(_b); | 1466 | reader->setpagemode(_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) |
1193 | { | 1473 | { |
@@ -1232,5 +1512,5 @@ void QTReaderApp::do_overlap(const QString& lcn) | |||
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 | } |
1236 | 1516 | ||
@@ -1247,5 +1527,5 @@ void QTReaderApp::do_mono(const QString& lcn) | |||
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 | } |
1251 | 1531 | ||
@@ -1265,4 +1545,5 @@ void QTReaderApp::editFind() | |||
1265 | searchStack = new QStack<searchrecord>; | 1545 | searchStack = new QStack<searchrecord>; |
1266 | #endif | 1546 | #endif |
1547 | Global::showInputMethod(); | ||
1267 | searchBar->show(); | 1548 | searchBar->show(); |
1268 | searchVisible = TRUE; | 1549 | searchVisible = TRUE; |
@@ -1292,4 +1573,5 @@ void QTReaderApp::findClose() | |||
1292 | searchVisible = FALSE; | 1573 | searchVisible = FALSE; |
1293 | searchEdit->setText(""); | 1574 | searchEdit->setText(""); |
1575 | Global::hideInputMethod(); | ||
1294 | searchBar->hide(); | 1576 | searchBar->hide(); |
1295 | #ifdef __ISEARCH | 1577 | #ifdef __ISEARCH |
@@ -1309,4 +1591,5 @@ void QTReaderApp::regClose() | |||
1309 | regEdit->setText(""); | 1591 | regEdit->setText(""); |
1310 | regBar->hide(); | 1592 | regBar->hide(); |
1593 | Global::hideInputMethod(); | ||
1311 | reader->setFocus(); | 1594 | reader->setFocus(); |
1312 | } | 1595 | } |
@@ -1319,6 +1602,15 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | |||
1319 | { | 1602 | { |
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 |
1324 | while (strstr(test.data(),(const tchar*)arg) == NULL) | 1616 | while (strstr(test.data(),(const tchar*)arg) == NULL) |
@@ -1332,4 +1624,14 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | |||
1332 | { | 1624 | { |
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 | { |
@@ -1343,4 +1645,5 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | |||
1343 | } | 1645 | } |
1344 | } | 1646 | } |
1647 | pbar->hide(); | ||
1345 | reader->locate(pos); | 1648 | reader->locate(pos); |
1346 | return ret; | 1649 | return ret; |
@@ -1389,54 +1692,122 @@ void QTReaderApp::search() | |||
1389 | void QTReaderApp::openFile( const QString &f ) | 1692 | 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 | { |
1400 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); | 1704 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); |
1401 | 1705 | ||
1402 | clear(); | 1706 | if (fm.extension( FALSE ) == "desktop") |
1403 | 1707 | { | |
1404 | // editorStack->raiseWidget( reader ); | 1708 | DocLnk d(f); |
1405 | 1709 | QFileInfo fnew(d.file()); | |
1406 | // reader->setFocus(); | 1710 | fm = fnew; |
1711 | if (!fm.exists()) return; | ||
1712 | } | ||
1407 | 1713 | ||
1408 | // QMessageBox::information(0, "DocLnk", "Begin"); | 1714 | clear(); |
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(); |
1418 | } | 1719 | } |
1419 | else | 1720 | else |
1420 | { | 1721 | { |
1421 | QMessageBox::information(this, "OpieReader", "File does not exist"); | 1722 | QMessageBox::information(this, PROGNAME, "File does not exist"); |
1422 | } | 1723 | } |
1423 | 1724 | ||
1424 | } | 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(); | ||
1766 | } | ||
1767 | } | ||
1425 | 1768 | ||
1426 | void QTReaderApp::showEditTools() | 1769 | 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 | { |
1775 | editBar->hide(); | ||
1776 | searchBar->hide(); | ||
1777 | regBar->hide(); | ||
1778 | Global::hideInputMethod(); | ||
1779 | m_fontBar->hide(); | ||
1780 | //showNormal(); | ||
1781 | showFullScreen(); | ||
1782 | } | ||
1783 | else | ||
1784 | { | ||
1785 | qDebug("him"); | ||
1786 | Global::hideInputMethod(); | ||
1787 | qDebug("eb"); | ||
1432 | editBar->show(); | 1788 | editBar->show(); |
1433 | if ( searchVisible ) | 1789 | if ( searchVisible ) |
1790 | { | ||
1791 | Global::showInputMethod(); | ||
1434 | searchBar->show(); | 1792 | searchBar->show(); |
1793 | } | ||
1435 | if ( regVisible ) | 1794 | if ( regVisible ) |
1795 | { | ||
1796 | Global::showInputMethod(); | ||
1436 | regBar->show(); | 1797 | regBar->show(); |
1798 | } | ||
1437 | if (m_fontVisible) m_fontBar->show(); | 1799 | if (m_fontVisible) m_fontBar->show(); |
1800 | qDebug("sn"); | ||
1801 | showNormal(); | ||
1802 | qDebug("sm"); | ||
1803 | showMaximized(); | ||
1804 | //setCentralWidget(reader); | ||
1805 | } | ||
1438 | 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(); |
1442 | } | 1813 | } |
@@ -1474,11 +1845,11 @@ void QTReaderApp::save() | |||
1474 | void QTReaderApp::clear() | 1845 | 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(); |
1484 | } | 1855 | } |
@@ -1486,12 +1857,12 @@ void QTReaderApp::clear() | |||
1486 | void QTReaderApp::updateCaption() | 1857 | 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 | } |
1497 | 1868 | ||
@@ -1500,5 +1871,5 @@ void QTReaderApp::setDocument(const QString& fileref) | |||
1500 | bFromDocView = TRUE; | 1871 | bFromDocView = TRUE; |
1501 | //QMessageBox::information(0, "setDocument", fileref); | 1872 | //QMessageBox::information(0, "setDocument", fileref); |
1502 | openFile(DocLnk(fileref)); | 1873 | openFile(fileref); |
1503 | // showEditTools(); | 1874 | // showEditTools(); |
1504 | } | 1875 | } |
@@ -1506,5 +1877,11 @@ void QTReaderApp::setDocument(const QString& fileref) | |||
1506 | void QTReaderApp::closeEvent( QCloseEvent *e ) | 1877 | void QTReaderApp::closeEvent( QCloseEvent *e ) |
1507 | { | 1878 | { |
1508 | if (m_dontSave) | 1879 | if (m_fullscreen) |
1880 | { | ||
1881 | m_fullscreen = false; | ||
1882 | showEditTools(); | ||
1883 | e->accept(); | ||
1884 | } | ||
1885 | else if (m_dontSave) | ||
1509 | { | 1886 | { |
1510 | e->accept(); | 1887 | e->accept(); |
@@ -1522,4 +1899,5 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1522 | { | 1899 | { |
1523 | regBar->hide(); | 1900 | regBar->hide(); |
1901 | Global::hideInputMethod(); | ||
1524 | regVisible = false; | 1902 | regVisible = false; |
1525 | return; | 1903 | return; |
@@ -1528,4 +1906,5 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1528 | { | 1906 | { |
1529 | searchBar->hide(); | 1907 | searchBar->hide(); |
1908 | Global::hideInputMethod(); | ||
1530 | searchVisible = false; | 1909 | searchVisible = false; |
1531 | return; | 1910 | return; |
@@ -1533,5 +1912,5 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1533 | if (m_fBkmksChanged && pBkmklist != NULL) | 1912 | if (m_fBkmksChanged && pBkmklist != NULL) |
1534 | { | 1913 | { |
1535 | if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0) | 1914 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
1536 | savebkmks(); | 1915 | savebkmks(); |
1537 | delete pBkmklist; | 1916 | delete pBkmklist; |
@@ -1540,4 +1919,5 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1540 | } | 1919 | } |
1541 | bFromDocView = FALSE; | 1920 | bFromDocView = FALSE; |
1921 | updatefileinfo(); | ||
1542 | saveprefs(); | 1922 | saveprefs(); |
1543 | e->accept(); | 1923 | e->accept(); |
@@ -1553,5 +1933,5 @@ void QTReaderApp::do_gotomark() | |||
1553 | { | 1933 | { |
1554 | m_nRegAction = cGotoBkmk; | 1934 | m_nRegAction = cGotoBkmk; |
1555 | listbkmk(); | 1935 | listbkmk(pBkmklist); |
1556 | } | 1936 | } |
1557 | 1937 | ||
@@ -1559,16 +1939,21 @@ void QTReaderApp::do_delmark() | |||
1559 | { | 1939 | { |
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 |
1957 | qDebug("Item:%s", (const char*)toQString(i->name())); | ||
1573 | bkmkselector->insertItem(toQString(i->name())); | 1958 | bkmkselector->insertItem(toQString(i->name())); |
1574 | #else | 1959 | #else |
@@ -1583,10 +1968,18 @@ void QTReaderApp::listbkmk() | |||
1583 | editBar->hide(); | 1968 | editBar->hide(); |
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 ); |
1588 | } | 1981 | } |
1589 | else | 1982 | else |
1590 | QMessageBox::information(this, "OpieReader", "No bookmarks in memory"); | 1983 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
1591 | } | 1984 | } |
1592 | 1985 | ||
@@ -1601,7 +1994,55 @@ void QTReaderApp::do_regedit() | |||
1601 | { | 1994 | { |
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 | } |
1607 | 2048 | ||
@@ -1610,4 +2051,13 @@ void QTReaderApp::gotobkmk(int ind) | |||
1610 | switch (m_nRegAction) | 2051 | switch (m_nRegAction) |
1611 | { | 2052 | { |
2053 | case cOpenFile: | ||
2054 | { | ||
2055 | if (!openfrombkmk((*pOpenlist)[ind])) | ||
2056 | { | ||
2057 | pOpenlist->erase(ind); | ||
2058 | QMessageBox::information(this, PROGNAME, "Can't find file"); | ||
2059 | } | ||
2060 | } | ||
2061 | break; | ||
1612 | case cGotoBkmk: | 2062 | case cGotoBkmk: |
1613 | reader->locate((*pBkmklist)[ind]->value()); | 2063 | reader->locate((*pBkmklist)[ind]->value()); |
@@ -1620,5 +2070,5 @@ void QTReaderApp::gotobkmk(int ind) | |||
1620 | break; | 2070 | break; |
1621 | case cRmBkmkFile: | 2071 | case cRmBkmkFile: |
1622 | unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind))); | 2072 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); |
1623 | break; | 2073 | break; |
1624 | } | 2074 | } |
@@ -1628,4 +2078,9 @@ void QTReaderApp::gotobkmk(int ind) | |||
1628 | void QTReaderApp::cancelbkmk() | 2078 | 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(); |
1631 | } | 2086 | } |
@@ -1647,10 +2102,12 @@ void QTReaderApp::do_jump(const QString& lcn) | |||
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 | } |
1651 | 2106 | ||
1652 | void QTReaderApp::do_regaction() | 2107 | 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; |
1656 | switch(m_nRegAction) | 2113 | switch(m_nRegAction) |
@@ -1678,4 +2135,7 @@ void QTReaderApp::do_regaction() | |||
1678 | // editBar->show(); | 2135 | // editBar->show(); |
1679 | reader->setFocus(); | 2136 | reader->setFocus(); |
2137 | qApp->processEvents(); | ||
2138 | reader->bDoUpdates = true; | ||
2139 | reader->update(); | ||
1680 | } | 2140 | } |
1681 | 2141 | ||
@@ -1687,5 +2147,5 @@ void QTReaderApp::do_settarget(const QString& _txt) | |||
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 | } |
1691 | else | 2151 | else |
@@ -1710,21 +2170,30 @@ void QTReaderApp::setfont() | |||
1710 | } | 2170 | } |
1711 | 2171 | ||
1712 | void QTReaderApp::setfontHelper(const QString& lcn, int size) | 2172 | void QTReaderApp::setfontHelper(const QString& lcn, int size = 0) |
1713 | { | 2173 | { |
1714 | if (size == 0) size = reader->m_fontControl.currentsize(); | 2174 | if (size == 0) size = reader->m_fontControl.currentsize(); |
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 | { |
2188 | qDebug("cf2"); | ||
1723 | reader->ChangeFont(size); | 2189 | reader->ChangeFont(size); |
1724 | } | 2190 | } |
2191 | qDebug("ref"); | ||
1725 | reader->refresh(); | 2192 | reader->refresh(); |
1726 | m_fontBar->hide(); | 2193 | m_fontBar->hide(); |
1727 | m_fontVisible = false; | 2194 | m_fontVisible = false; |
1728 | showEditTools(); | 2195 | qDebug("showedit"); |
2196 | if (reader->isVisible()) showEditTools(); | ||
2197 | qDebug("showeditdone"); | ||
1729 | } | 2198 | } |
1730 | 2199 | ||
@@ -1782,5 +2251,5 @@ void QTReaderApp::saveprefs() | |||
1782 | { | 2251 | { |
1783 | // reader->saveprefs("uqtreader"); | 2252 | // reader->saveprefs("uqtreader"); |
1784 | Config config( "uqtreader" ); | 2253 | Config config( APPDIR ); |
1785 | config.setGroup( "View" ); | 2254 | config.setGroup( "View" ); |
1786 | 2255 | ||
@@ -1792,4 +2261,5 @@ void QTReaderApp::saveprefs() | |||
1792 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 2261 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
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 ); |
1795 | config.writeEntry( "Repara", reader->brepara ); | 2265 | config.writeEntry( "Repara", reader->brepara ); |
@@ -1801,4 +2271,5 @@ void QTReaderApp::saveprefs() | |||
1801 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 2271 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
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 ); |
1804 | config.writeEntry( "Fontname", reader->m_fontname ); | 2275 | config.writeEntry( "Fontname", reader->m_fontname ); |
@@ -1813,7 +2284,13 @@ void QTReaderApp::saveprefs() | |||
1813 | config.writeEntry( "Clipboard", m_doClipboard); | 2284 | config.writeEntry( "Clipboard", m_doClipboard); |
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 ); |
1816 | config.writeEntry( "Peanut", reader->bpeanut ); | 2290 | config.writeEntry( "Peanut", reader->bpeanut ); |
1817 | config.writeEntry( "MakeBold", reader->bmakebold ); | 2291 | config.writeEntry( "MakeBold", reader->bmakebold ); |
2292 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | ||
2293 | |||
2294 | savefilelist(); | ||
1818 | } | 2295 | } |
1819 | 2296 | ||
@@ -1888,5 +2365,5 @@ void QTReaderApp::savebkmks() | |||
1888 | if (pBkmklist != NULL) | 2365 | if (pBkmklist != NULL) |
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); |
1892 | } | 2369 | } |
@@ -1894,4 +2371,23 @@ void QTReaderApp::savebkmks() | |||
1894 | } | 2371 | } |
1895 | 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); | ||
2389 | } | ||
2390 | } | ||
2391 | |||
1896 | void QTReaderApp::readbkmks() | 2392 | void QTReaderApp::readbkmks() |
1897 | { | 2393 | { |
@@ -1900,5 +2396,20 @@ void QTReaderApp::readbkmks() | |||
1900 | delete pBkmklist; | 2396 | delete pBkmklist; |
1901 | } | 2397 | } |
1902 | BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string)); | 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 | } | ||
2410 | } | ||
2411 | |||
2412 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string)); | ||
2413 | |||
1903 | pBkmklist = bf.readall(); | 2414 | pBkmklist = bf.readall(); |
1904 | m_fBkmksChanged = bf.upgraded(); | 2415 | m_fBkmksChanged = bf.upgraded(); |
@@ -1922,5 +2433,5 @@ void QTReaderApp::do_addbkmk(const QString& text) | |||
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 |
@@ -1958,4 +2469,5 @@ void QTReaderApp::showAnnotation() | |||
1958 | m_annoWin->setAnno(toQString(m_anno->anno())); | 2469 | m_annoWin->setAnno(toQString(m_anno->anno())); |
1959 | m_annoIsEditing = false; | 2470 | m_annoIsEditing = false; |
2471 | Global::showInputMethod(); | ||
1960 | editorStack->raiseWidget( m_annoWin ); | 2472 | editorStack->raiseWidget( m_annoWin ); |
1961 | m_annoWin->setFocus(); | 2473 | m_annoWin->setFocus(); |
@@ -1986,4 +2498,5 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& | |||
1986 | m_annoWin->setPosn(posn); | 2498 | m_annoWin->setPosn(posn); |
1987 | m_annoIsEditing = true; | 2499 | m_annoIsEditing = true; |
2500 | Global::showInputMethod(); | ||
1988 | editorStack->raiseWidget( m_annoWin ); | 2501 | editorStack->raiseWidget( m_annoWin ); |
1989 | } | 2502 | } |
@@ -2018,4 +2531,9 @@ void QTReaderApp::OnActionPressed() | |||
2018 | } | 2531 | } |
2019 | break; | 2532 | break; |
2533 | case cesFullScreen: | ||
2534 | { | ||
2535 | m_actFullscreen->setOn(true); | ||
2536 | } | ||
2537 | break; | ||
2020 | default: | 2538 | default: |
2021 | { | 2539 | { |
@@ -2028,2 +2546,61 @@ void QTReaderApp::OnActionPressed() | |||
2028 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } | 2546 | 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 | |||
@@ -24,5 +24,5 @@ | |||
24 | 24 | ||
25 | #define MAX_ENCODING 6 | 25 | #define MAX_ENCODING 6 |
26 | #define MAX_ACTIONS 3 | 26 | #define MAX_ACTIONS 4 |
27 | 27 | ||
28 | #include <qmainwindow.h> | 28 | #include <qmainwindow.h> |
@@ -40,5 +40,5 @@ class QToolButton; | |||
40 | class QPopupMenu; | 40 | class QPopupMenu; |
41 | class QToolBar; | 41 | class QToolBar; |
42 | class QPEToolBar; | 42 | //class QPEToolBar; |
43 | class CBkmkSelector; | 43 | class CBkmkSelector; |
44 | class QProgressBar; | 44 | class QProgressBar; |
@@ -48,4 +48,5 @@ class QFloatBar; | |||
48 | class CDrawBuffer; | 48 | class CDrawBuffer; |
49 | class QTReader; | 49 | class QTReader; |
50 | class QPixmap; | ||
50 | 51 | ||
51 | enum ActionTypes | 52 | enum ActionTypes |
@@ -53,5 +54,6 @@ enum ActionTypes | |||
53 | cesOpenFile = 0, | 54 | cesOpenFile = 0, |
54 | cesAutoScroll, | 55 | cesAutoScroll, |
55 | cesActionMark | 56 | cesActionMark, |
57 | cesFullScreen | ||
56 | }; | 58 | }; |
57 | 59 | ||
@@ -66,4 +68,5 @@ struct searchrecord | |||
66 | 68 | ||
67 | class infowin; | 69 | class infowin; |
70 | class GraphicWin; | ||
68 | 71 | ||
69 | class QTReaderApp : public QMainWindow | 72 | class QTReaderApp : public QMainWindow |
@@ -77,5 +80,5 @@ class QTReaderApp : public QMainWindow | |||
77 | QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 80 | QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
78 | ~QTReaderApp(); | 81 | ~QTReaderApp(); |
79 | 82 | void suspend(); | |
80 | void openFile( const QString & ); | 83 | void openFile( const QString & ); |
81 | 84 | ||
@@ -84,7 +87,9 @@ class QTReaderApp : public QMainWindow | |||
84 | protected: | 87 | protected: |
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 ); |
90 | void readbkmks(); | 95 | void readbkmks(); |
@@ -98,8 +103,13 @@ class QTReaderApp : public QMainWindow | |||
98 | bool m_doDictionary; | 103 | bool m_doDictionary; |
99 | bool m_doClipboard; | 104 | bool m_doClipboard; |
105 | bool m_fullscreen; | ||
100 | 106 | ||
101 | public: | 107 | public: |
102 | void saveprefs(); | 108 | void saveprefs(); |
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); |
105 | void restoreFocus(); | 115 | void restoreFocus(); |
@@ -117,4 +127,5 @@ private slots: | |||
117 | } | 127 | } |
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); |
120 | void addAnno(const QString&, const QString&); | 131 | void addAnno(const QString&, const QString&); |
@@ -142,6 +153,4 @@ private slots: | |||
142 | void showinfo(); | 153 | void showinfo(); |
143 | void setDocument(const QString&); | 154 | void setDocument(const QString&); |
144 | void TBD(); | ||
145 | void TBDzoom(); | ||
146 | 155 | ||
147 | void indentplus(); | 156 | void indentplus(); |
@@ -149,4 +158,5 @@ private slots: | |||
149 | 158 | ||
150 | void fileOpen(); | 159 | void fileOpen(); |
160 | void fileClose(); | ||
151 | 161 | ||
152 | void editCopy(); | 162 | void editCopy(); |
@@ -167,8 +177,11 @@ private slots: | |||
167 | #endif | 177 | #endif |
168 | 178 | ||
169 | void openFile( const DocLnk & ); | ||
170 | void showEditTools(); | 179 | void showEditTools(); |
171 | 180 | ||
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); |
174 | void remap(bool); | 187 | void remap(bool); |
@@ -182,4 +195,5 @@ private slots: | |||
182 | void dblspce(bool); | 195 | void dblspce(bool); |
183 | void pagemode(bool); | 196 | void pagemode(bool); |
197 | void navkeys(bool); | ||
184 | // void gotobkmk(const QString& bm); | 198 | // void gotobkmk(const QString& bm); |
185 | void gotobkmk(int); | 199 | void gotobkmk(int); |
@@ -193,6 +207,16 @@ private slots: | |||
193 | 207 | ||
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(); |
198 | void colorChanged( const QColor &c ); | 222 | void colorChanged( const QColor &c ); |
@@ -224,9 +248,9 @@ private slots: | |||
224 | QTReader* reader; | 248 | QTReader* reader; |
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*/; |
228 | QToolBar /* *searchBar, *regBar,*/ *m_fontBar; | 253 | QToolBar /* *searchBar, *regBar,*/ *m_fontBar; |
229 | QLineEdit *searchEdit, *regEdit; | 254 | QLineEdit *searchEdit, *regEdit; |
230 | DocLnk *doc; | ||
231 | bool searchVisible; | 255 | bool searchVisible; |
232 | bool regVisible; | 256 | bool regVisible; |
@@ -244,5 +268,7 @@ private slots: | |||
244 | */ | 268 | */ |
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; |
248 | bool m_fBkmksChanged; | 274 | bool m_fBkmksChanged; |
@@ -261,3 +287,5 @@ const int cMonoSpace = 6; | |||
261 | const int cOverlap = 7; | 287 | 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 | |||
@@ -4,94 +4,160 @@ | |||
4 | typedef unsigned short StyleType; | 4 | typedef unsigned short StyleType; |
5 | 5 | ||
6 | class CStyle | 6 | #include <stdlib.h> |
7 | { | 7 | #include <qglobal.h> |
8 | // 15 14 13-5 4 3 2 1 0 | 8 | class QPixmap; |
9 | //bold italic spare align align fs fs fs | ||
10 | static const StyleType m_Bold = 1 << 15; | ||
11 | static const StyleType m_Italic = 1 << 14; | ||
12 | static const StyleType m_FontMask = 7; | ||
13 | static const StyleType m_FontBase = 3; | ||
14 | 9 | ||
15 | static const StyleType m_AlignShift = 3; | 10 | struct GraphicLink |
16 | static const StyleType m_AlignMask = 3 << m_AlignShift; | 11 | { |
17 | static const StyleType m_EveryBit = 0xffff; | 12 | QPixmap* graphic; |
13 | bool isLink; | ||
14 | unsigned long link; | ||
15 | GraphicLink(QPixmap* p, bool isLnk, unsigned long tgt) : | ||
16 | graphic(p), isLink(isLnk), link(tgt) {} | ||
17 | ~GraphicLink(); | ||
18 | }; | ||
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; |
24 | unsigned long data; | 47 | unsigned long data; |
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; |
52 | data = 0; | 68 | data = 0; |
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 | ||
63 | void setLeftJustify() | 134 | void setLeftJustify() |
64 | { | 135 | { |
65 | unjustify(); | 136 | sty.m_align = m_AlignLeft; |
66 | sty |= m_AlignLeft; | ||
67 | } | 137 | } |
68 | void setRightJustify() | 138 | void setRightJustify() |
69 | { | 139 | { |
70 | unjustify(); | 140 | sty.m_align = m_AlignRight; |
71 | sty |= m_AlignRight; | ||
72 | } | 141 | } |
73 | void setCentreJustify() | 142 | void setCentreJustify() |
74 | { | 143 | { |
75 | unjustify(); | 144 | sty.m_align = m_AlignCentre; |
76 | sty |= m_AlignCentre; | ||
77 | } | 145 | } |
78 | void setFullJustify() | 146 | void setFullJustify() |
79 | { | 147 | { |
80 | unjustify(); | 148 | sty.m_align = m_AlignJustify; |
81 | sty |= m_AlignJustify; | ||
82 | } | 149 | } |
83 | StyleType getJustify() | 150 | StyleType getJustify() |
84 | { | 151 | { |
85 | return sty & m_AlignMask; | 152 | return sty.m_align; |
86 | } | 153 | } |
87 | 154 | ||
88 | void setFontSize(int _fs) | 155 | void setFontSize(int _fs) |
89 | { | 156 | { |
90 | sty &= m_EveryBit ^ m_FontMask; | 157 | sty.m_fontsize = _fs; |
91 | sty |= m_FontBase + _fs; | ||
92 | } | 158 | } |
93 | int getFontSize() | 159 | int getFontSize() |
94 | { | 160 | { |
95 | return (sty & m_FontMask) - m_FontBase; | 161 | return sty.m_fontsize; |
96 | } | 162 | } |
97 | bool operator!=(const CStyle& rhs) | 163 | bool operator!=(const CStyle& rhs) |
@@ -99,14 +165,12 @@ 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) || | ||
104 | (isLink != rhs.isLink) | ||
105 | ); | 169 | ); |
106 | } | 170 | } |
107 | void setLink(bool _l) { isLink = _l; } | 171 | void setLink(bool _l) { sty.isLink = _l; } |
108 | bool getLink() { return isLink; } | 172 | bool getLink() { return sty.isLink; } |
109 | void setData(unsigned long _d) { data = _d; } | 173 | void setData(unsigned long _d) { sty.data = _d; } |
110 | unsigned long getData() { return data; } | 174 | unsigned long getData() { return sty.data; } |
111 | }; | 175 | }; |
112 | 176 | ||
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 | |||
@@ -11,4 +11,33 @@ class Text: public CExpander { | |||
11 | unsigned long fsize; | 11 | unsigned long fsize; |
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) {}; |
14 | virtual ~Text() | 43 | virtual ~Text() |
@@ -16,5 +45,5 @@ public: | |||
16 | if (file != NULL) gzclose(file); | 45 | if (file != NULL) gzclose(file); |
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); |
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 | |||
@@ -10,4 +10,5 @@ class CBkmkSelector : public QWidget | |||
10 | 10 | ||
11 | QListBox* bkmkselector; | 11 | QListBox* bkmkselector; |
12 | QPushButton* exitButton; | ||
12 | 13 | ||
13 | signals: | 14 | signals: |
@@ -28,5 +29,5 @@ public: | |||
28 | QVBoxLayout* grid = new QVBoxLayout(this); | 29 | QVBoxLayout* grid = new QVBoxLayout(this); |
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) ) ); |
32 | connect(bkmkselector, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) ); | 33 | connect(bkmkselector, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) ); |
@@ -38,4 +39,5 @@ public: | |||
38 | void insertItem(const QString& item) { bkmkselector->insertItem(item); } | 39 | void insertItem(const QString& item) { bkmkselector->insertItem(item); } |
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 | }; |
41 | 43 | ||
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 | |||
@@ -19,3 +19,7 @@ const int UEOF = -1; | |||
19 | #include "ustring.h" | 19 | #include "ustring.h" |
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 | |||
@@ -40,4 +40,5 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
40 | 40 | ||
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()); |
43 | 44 | ||
@@ -48,4 +49,6 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
48 | ListView->setSelectionMode(QListView::Single); | 49 | ListView->setSelectionMode(QListView::Single); |
49 | ListView->setAllColumnsShowFocus( TRUE ); | 50 | ListView->setAllColumnsShowFocus( TRUE ); |
51 | ListView->setColumnWidthMode(0, QListView::Manual); | ||
52 | ListView->setColumnWidthMode(1, QListView::Manual); | ||
50 | 53 | ||
51 | // signals and slots connections | 54 | // signals and slots connections |
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,7 +1,8 @@ | |||
1 | #include "name.h" | ||
1 | #include "infowin.h" | 2 | #include "infowin.h" |
2 | #include "version.h" | 3 | #include "version.h" |
3 | #include <stdio.h> | 4 | #include <stdio.h> |
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) |
7 | { | 8 | { |
@@ -34,5 +35,5 @@ infowin::infowin( QWidget *parent, const char *name, WFlags f) : | |||
34 | grid->addWidget(read, 4, 1); | 35 | grid->addWidget(read, 4, 1); |
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); |
38 | grid->addWidget(l, 5, 0); | 39 | grid->addWidget(l, 5, 0); |
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 | |||
@@ -10,5 +10,9 @@ QTReaderApp* app = NULL; | |||
10 | void handler(int signum) | 10 | 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); |
14 | } | 18 | } |
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 | |||
@@ -2,53 +2,68 @@ TEMPLATE = app | |||
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | HEADERS = Aportis.h \ | 3 | HEADERS = Aportis.h \ |
4 | Bkmks.h \ | ||
4 | BuffDoc.h \ | 5 | BuffDoc.h \ |
6 | CAnnoEdit.h \ | ||
5 | CBuffer.h \ | 7 | CBuffer.h \ |
6 | CDrawBuffer.h \ | 8 | CDrawBuffer.h \ |
9 | CEncoding.h \ | ||
7 | CExpander.h \ | 10 | CExpander.h \ |
8 | CFilter.h \ | 11 | CFilter.h \ |
12 | Filedata.h \ | ||
13 | FontControl.h \ | ||
14 | GraphicWin.h \ | ||
15 | Markups.h \ | ||
16 | Navigation.h \ | ||
17 | Palm2QImage.h \ | ||
18 | QFloatBar.h \ | ||
9 | QTReader.h \ | 19 | QTReader.h \ |
10 | QTReaderApp.h \ | 20 | QTReaderApp.h \ |
21 | QtrListView.h \ | ||
22 | Queue.h \ | ||
23 | StateData.h \ | ||
24 | StyleConsts.h \ | ||
11 | ZText.h \ | 25 | ZText.h \ |
12 | arith.h \ | 26 | arith.h \ |
13 | my_list.h \ | ||
14 | ppm.h \ | ||
15 | ppm_expander.h \ | ||
16 | cbkmkselector.h \ | 27 | cbkmkselector.h \ |
28 | config.h \ | ||
17 | fileBrowser.h \ | 29 | fileBrowser.h \ |
18 | ztxt.h \ | ||
19 | QtrListView.h \ | ||
20 | infowin.h \ | 30 | infowin.h \ |
21 | version.h \ | 31 | my_list.h \ |
32 | name.h \ | ||
33 | opie.h \ | ||
22 | pdb.h \ | 34 | pdb.h \ |
23 | utypes.h \ | ||
24 | ustring.h \ | ||
25 | CEncoding.h \ | ||
26 | CAnnoEdit.h \ | ||
27 | QFloatBar.h \ | ||
28 | StyleConsts.h \ | ||
29 | FontControl.h \ | ||
30 | plucker.h \ | 35 | plucker.h \ |
31 | Markups.h \ | 36 | ppm.h \ |
32 | Bkmks.h \ | 37 | ppm_expander.h \ |
33 | config.h | 38 | ustring.h \ |
39 | utypes.h \ | ||
40 | version.h \ | ||
41 | ztxt.h | ||
42 | |||
34 | SOURCES = Aportis.cpp \ | 43 | SOURCES = Aportis.cpp \ |
44 | Bkmks.cpp \ | ||
35 | BuffDoc.cpp \ | 45 | BuffDoc.cpp \ |
36 | CBuffer.cpp \ | 46 | CBuffer.cpp \ |
37 | CDrawBuffer.cpp \ | 47 | CDrawBuffer.cpp \ |
48 | CEncoding.cpp \ | ||
49 | CFilter.cpp \ | ||
50 | FontControl.cpp \ | ||
51 | Navigation.cpp \ | ||
52 | Palm2QImage.cpp \ | ||
38 | QTReader.cpp \ | 53 | QTReader.cpp \ |
39 | QTReaderApp.cpp \ | 54 | QTReaderApp.cpp \ |
40 | arith_d.cpp \ | ||
41 | main.cpp \ | ||
42 | ppm.cpp \ | ||
43 | ppm_expander.cpp \ | ||
44 | ztxt.cpp \ | ||
45 | QtrListView.cpp \ | 55 | QtrListView.cpp \ |
56 | StyleConsts.cpp \ | ||
57 | arith_d.cpp \ | ||
58 | fileBrowser.cpp \ | ||
46 | infowin.cpp \ | 59 | infowin.cpp \ |
60 | main.cpp \ | ||
47 | pdb.cpp \ | 61 | pdb.cpp \ |
48 | CEncoding.cpp \ | ||
49 | CFilter.cpp \ | ||
50 | plucker.cpp \ | 62 | plucker.cpp \ |
51 | Bkmks.cpp \ | 63 | ppm.cpp \ |
52 | fileBrowser.cpp | 64 | ppm_expander.cpp \ |
65 | ztxt.cpp | ||
66 | |||
67 | INTERFACES= | ||
53 | DESTDIR = $(OPIEDIR)/bin | 68 | DESTDIR = $(OPIEDIR)/bin |
54 | INCLUDEPATH += $(OPIEDIR)/include | 69 | INCLUDEPATH += $(OPIEDIR)/include |
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,3 +1,6 @@ | |||
1 | #include "pdb.h" | 1 | #include "pdb.h" |
2 | #include <sys/types.h> | ||
3 | #include <sys/stat.h> | ||
4 | #include <unistd.h> | ||
2 | 5 | ||
3 | size_t Cpdb::recordpos(int n) | 6 | size_t Cpdb::recordpos(int n) |
@@ -47,8 +50,11 @@ bool Cpdb::openfile(const char *src) | |||
47 | // just holds the first few chars of the file | 50 | // just holds the first few chars of the file |
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 | ||
54 | fread(&head, 1, sizeof(head), fin); | 60 | fread(&head, 1, sizeof(head), fin); |
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 | |||
@@ -2,13 +2,53 @@ | |||
2 | #include <string.h> | 2 | #include <string.h> |
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" | ||
7 | 17 | ||
8 | CPlucker::CPlucker() : expandedtextbuffer(NULL), compressedtextbuffer(NULL) { /*printf("constructing:%x\n",fin);*/ } | 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);*/ } | ||
9 | 27 | ||
10 | 28 | ||
11 | int CPlucker::openfile(const char *src) | 29 | void CPlucker::Expand(UInt16 reclen, UInt8 type, UInt8* buffer, UInt16 buffersize) |
12 | { | 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 | } | ||
49 | |||
50 | int CPlucker::OpenFile(const char *src) | ||
51 | { | ||
52 | m_lastBreak = 0; | ||
13 | if (!Cpdb::openfile(src)) | 53 | if (!Cpdb::openfile(src)) |
14 | { | 54 | { |
@@ -22,13 +62,5 @@ int CPlucker::openfile(const char *src) | |||
22 | // qDebug("Cool - this IS plucker"); | 62 | // qDebug("Cool - this IS plucker"); |
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); |
34 | fread(&hdr0, 1, sizeof(hdr0), fin); | 66 | fread(&hdr0, 1, sizeof(hdr0), fin); |
@@ -38,16 +70,142 @@ int CPlucker::openfile(const char *src) | |||
38 | expandedtextbuffer = new UInt8[buffersize]; | 70 | expandedtextbuffer = new UInt8[buffersize]; |
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; |
82 | fread(&name, 1, sizeof(name), fin); | ||
47 | fread(&id, 1, sizeof(id), fin); | 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 | } | ||
48 | // qDebug("%x", id); | 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 | } |
53 | 211 | ||
@@ -57,11 +215,15 @@ int CPlucker::bgetch() | |||
57 | if (bufferpos >= buffercontent) | 215 | if (bufferpos >= buffercontent) |
58 | { | 216 | { |
217 | if (!m_continuous) return EOF; | ||
59 | if (bufferrec >= ntohs(head.recordList.numRecords) - 1) return EOF; | 218 | if (bufferrec >= ntohs(head.recordList.numRecords) - 1) return EOF; |
60 | // qDebug("Passing through %u", currentpos); | 219 | // qDebug("Passing through %u", currentpos); |
61 | if (!expand(bufferrec+1)) return EOF; | 220 | if (!expand(bufferrec+1)) return EOF; |
62 | mystyle.unset(); | 221 | mystyle.unset(); |
222 | ch = 10; | ||
223 | EOPPhase = 4; | ||
63 | } | 224 | } |
64 | 225 | else if (bufferpos == m_nextPara) | |
65 | if (bufferpos == m_nextPara) | 226 | { |
227 | while (bufferpos == m_nextPara) | ||
66 | { | 228 | { |
67 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; | 229 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; |
@@ -75,7 +237,16 @@ int CPlucker::bgetch() | |||
75 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | 237 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; |
76 | } | 238 | } |
77 | // qDebug("New paragraph"); | 239 | } |
240 | mystyle.unset(); | ||
241 | if (m_lastBreak == locate()) | ||
242 | { | ||
243 | currentpos++; | ||
244 | ch = expandedtextbuffer[bufferpos++]; | ||
245 | } | ||
246 | else | ||
247 | { | ||
78 | ch = 10; | 248 | ch = 10; |
79 | } | 249 | } |
250 | } | ||
80 | else | 251 | else |
81 | { | 252 | { |
@@ -88,4 +259,34 @@ int CPlucker::bgetch() | |||
88 | int CPlucker::getch() | 259 | int CPlucker::getch() |
89 | { | 260 | { |
261 | mystyle.clearPicture(); | ||
262 | |||
263 | |||
264 | if (EOPPhase > 0) | ||
265 | { | ||
266 | int ch = 10; | ||
267 | switch (EOPPhase) | ||
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; | ||
288 | } | ||
289 | |||
290 | |||
90 | int ch = bgetch(); | 291 | int ch = bgetch(); |
91 | while (ch == 0) | 292 | while (ch == 0) |
@@ -96,5 +297,14 @@ int CPlucker::getch() | |||
96 | { | 297 | { |
97 | case 0x38: | 298 | case 0x38: |
299 | // qDebug("Break:%u", locate()); | ||
300 | if (m_lastBreak == locate()) | ||
301 | { | ||
302 | ch = bgetch(); | ||
303 | } | ||
304 | else | ||
305 | { | ||
98 | ch = 10; | 306 | ch = 10; |
307 | } | ||
308 | m_lastBreak = locate(); | ||
99 | break; | 309 | break; |
100 | case 0x0a: | 310 | case 0x0a: |
@@ -125,5 +335,22 @@ int CPlucker::getch() | |||
125 | mystyle.setLink(true); | 335 | mystyle.setLink(true); |
126 | mystyle.setData(ln); | 336 | mystyle.setData(ln); |
127 | mystyle.setColour(255, 0, 0); | 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 | } | ||
128 | ch = bgetch(); | 355 | ch = bgetch(); |
129 | } | 356 | } |
@@ -131,5 +358,7 @@ int CPlucker::getch() | |||
131 | case 0x08: | 358 | case 0x08: |
132 | ch = bgetch(); | 359 | ch = bgetch(); |
133 | mystyle.setColour(0, 0, 0); | 360 | // mystyle.setColour(0, 0, 0); |
361 | mystyle.unsetUnderline(); | ||
362 | mystyle.unsetStrikethru(); | ||
134 | mystyle.setLink(false); | 363 | mystyle.setLink(false); |
135 | mystyle.setData(0); | 364 | mystyle.setData(0); |
@@ -146,45 +375,58 @@ int CPlucker::getch() | |||
146 | { | 375 | { |
147 | ch = bgetch(); | 376 | ch = bgetch(); |
148 | qDebug("Font:%d",ch); | 377 | // qDebug("Font:%d",ch); |
149 | switch (ch) | 378 | switch (ch) |
150 | { | 379 | { |
151 | case 0: | 380 | case 0: |
381 | mystyle.unsetMono(); | ||
152 | mystyle.unsetBold(); | 382 | mystyle.unsetBold(); |
153 | mystyle.setFontSize(0); | 383 | mystyle.setFontSize(0); |
154 | break; | 384 | break; |
155 | case 1: | 385 | case 1: |
386 | mystyle.unsetMono(); | ||
156 | mystyle.setBold(); | 387 | mystyle.setBold(); |
157 | mystyle.setFontSize(1); | 388 | mystyle.setFontSize(3); |
158 | break; | 389 | break; |
159 | case 2: | 390 | case 2: |
391 | mystyle.unsetMono(); | ||
160 | mystyle.setBold(); | 392 | mystyle.setBold(); |
161 | mystyle.setFontSize(1); | 393 | mystyle.setFontSize(2); |
162 | break; | 394 | break; |
163 | case 3: | 395 | case 3: |
164 | // mystyle.setBold(); | 396 | mystyle.unsetMono(); |
397 | mystyle.setBold(); | ||
398 | // mystyle.unsetBold(); | ||
165 | mystyle.setFontSize(1); | 399 | mystyle.setFontSize(1); |
166 | break; | 400 | break; |
167 | case 4: | 401 | case 4: |
168 | // mystyle.setBold(); | 402 | mystyle.unsetMono(); |
169 | mystyle.setFontSize(1); | 403 | mystyle.setBold(); |
404 | // mystyle.unsetBold(); | ||
405 | mystyle.setFontSize(0); | ||
170 | break; | 406 | break; |
171 | case 5: | 407 | case 5: |
408 | mystyle.unsetMono(); | ||
172 | mystyle.setBold(); | 409 | mystyle.setBold(); |
173 | mystyle.setFontSize(0); | 410 | mystyle.setFontSize(0); |
174 | break; | 411 | break; |
175 | case 6: | 412 | case 6: |
413 | mystyle.unsetMono(); | ||
176 | mystyle.setBold(); | 414 | mystyle.setBold(); |
177 | mystyle.setFontSize(0); | 415 | mystyle.setFontSize(0); |
178 | break; | 416 | break; |
179 | case 7: | 417 | case 7: |
418 | mystyle.unsetMono(); | ||
180 | mystyle.setBold(); | 419 | mystyle.setBold(); |
181 | mystyle.setFontSize(0); | 420 | mystyle.setFontSize(0); |
182 | break; | 421 | break; |
183 | case 8: // should be fixed width | 422 | case 8: // should be fixed width |
423 | qDebug("Trying fixed width"); | ||
184 | mystyle.unsetBold(); | 424 | mystyle.unsetBold(); |
185 | mystyle.setFontSize(0); | 425 | mystyle.setFontSize(0); |
426 | mystyle.setMono(); | ||
186 | break; | 427 | break; |
187 | default: | 428 | default: |
188 | mystyle.unsetBold(); | 429 | mystyle.unsetBold(); |
430 | mystyle.unsetMono(); | ||
189 | mystyle.setFontSize(0); | 431 | mystyle.setFontSize(0); |
190 | break; | 432 | break; |
@@ -227,20 +469,73 @@ int CPlucker::getch() | |||
227 | break; | 469 | break; |
228 | case 0x1a: | 470 | case 0x1a: |
229 | /* | 471 | case 0x5c: |
230 | { | 472 | { |
473 | bool hasalternate = (ch == 0x5c); | ||
231 | UInt16 ir = bgetch(); | 474 | UInt16 ir = bgetch(); |
232 | ir = (ir << 8) + bgetch(); | 475 | ir = (ir << 8) + bgetch(); |
233 | expandimg(ir); | 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 | ||
234 | } | 488 | } |
235 | ch = bgetch(); | 489 | else |
490 | { | ||
491 | mystyle.setPicture(expandimg(ir)); | ||
492 | } | ||
493 | if (mystyle.getLink()) qDebug("Picture link!"); | ||
494 | ch = '#'; | ||
495 | } | ||
496 | // ch = bgetch(); | ||
236 | break; | 497 | break; |
237 | */ | ||
238 | case 0x33: | 498 | case 0x33: |
239 | case 0x22: | 499 | { |
240 | case 0x5c: | 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; | ||
241 | case 0x60: | 515 | case 0x60: |
516 | mystyle.setUnderline(); | ||
517 | ch = bgetch(); | ||
518 | break; | ||
242 | case 0x68: | 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; | ||
243 | case 0x70: | 532 | case 0x70: |
533 | mystyle.setStrikethru(); | ||
534 | ch = bgetch(); | ||
535 | break; | ||
244 | case 0x78: | 536 | case 0x78: |
537 | mystyle.unsetStrikethru(); | ||
538 | ch = bgetch(); | ||
539 | break; | ||
245 | case 0x83: | 540 | case 0x83: |
246 | case 0x85: | 541 | case 0x85: |
@@ -252,5 +547,5 @@ int CPlucker::getch() | |||
252 | { | 547 | { |
253 | ch = bgetch(); | 548 | ch = bgetch(); |
254 | qDebug("Arg %d, %d", i, ch); | 549 | // qDebug("Arg %d, %d", i, ch); |
255 | } | 550 | } |
256 | ch = bgetch(); | 551 | ch = bgetch(); |
@@ -258,4 +553,15 @@ int CPlucker::getch() | |||
258 | } | 553 | } |
259 | } | 554 | } |
555 | |||
556 | if (m_lastIsBreak && !mystyle.isMono()) | ||
557 | { | ||
558 | while (ch == ' ') | ||
559 | { | ||
560 | ch = getch(); | ||
561 | } | ||
562 | } | ||
563 | |||
564 | m_lastIsBreak = (ch == 10); | ||
565 | |||
260 | return ch; | 566 | return ch; |
261 | } | 567 | } |
@@ -278,5 +584,5 @@ 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); |
@@ -300,5 +606,5 @@ void CPlucker::locate(unsigned int n) | |||
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 |
@@ -306,14 +612,20 @@ void CPlucker::locate(unsigned int n) | |||
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 | } |
313 | 623 | ||
314 | bool CPlucker::hyperlink(unsigned int n) | 624 | 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; |
319 | currentpos = 0; | 631 | currentpos = 0; |
@@ -323,26 +635,218 @@ 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++; |
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 | } | ||
329 | gotorecordnumber(thisrec); | 673 | gotorecordnumber(thisrec); |
330 | } | 674 | } |
331 | if (thisHdr.type > 1) | 675 | if (thisHdr.type > 1) |
332 | { | 676 | { |
677 | if (thisHdr.type == 4) | ||
678 | { | ||
333 | QMessageBox::information(NULL, | 679 | QMessageBox::information(NULL, |
334 | QString("OpieReader"), | 680 | PROGNAME, |
335 | QString("External links\nnot yet supported") | 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)") | ||
336 | ); | 692 | ); |
693 | #ifdef LOCALPICTURES | ||
694 | } | ||
695 | else | ||
696 | { | ||
697 | showimg(tuid); | ||
698 | } | ||
699 | #endif | ||
700 | } | ||
337 | return false; | 701 | return false; |
338 | } | 702 | } |
703 | /* | ||
704 | if (thisHdr.type == 2 || thisHdr.type == 3) | ||
705 | { | ||
706 | expandimg(thisrec); | ||
707 | |||
708 | } | ||
709 | */ | ||
339 | else | 710 | else |
340 | { | 711 | { |
341 | expand(thisrec); | 712 | expand(thisrec); |
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); | ||
342 | while (bufferpos < n && bufferpos < buffercontent) getch(); | 736 | while (bufferpos < n && bufferpos < buffercontent) getch(); |
343 | } | 737 | } |
344 | return true; | 738 | return true; |
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) |
348 | { | 852 | { |
@@ -362,5 +866,5 @@ bool CPlucker::expand(int 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); |
366 | for (int i = 0; i < m_nParas; i++) | 870 | for (int i = 0; i < m_nParas; i++) |
@@ -386,23 +890,7 @@ bool CPlucker::expand(int thisrec) | |||
386 | reclen -= sizeof(thisHdr)+4*m_nParas; | 890 | reclen -= sizeof(thisHdr)+4*m_nParas; |
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; |
408 | bufferrec = thisrec; | 896 | bufferrec = thisrec; |
@@ -441,4 +929,6 @@ void CPlucker::UnZip(size_t reclen, UInt8* tgtbuffer, UInt16 bsize) | |||
441 | err = inflate( &zstream, Z_SYNC_FLUSH ); | 929 | err = inflate( &zstream, Z_SYNC_FLUSH ); |
442 | 930 | ||
931 | //qDebug("err:%d - %u", err, zstream.avail_in); | ||
932 | |||
443 | } while ( err == Z_OK ); | 933 | } while ( err == Z_OK ); |
444 | 934 | ||
@@ -527,53 +1017,225 @@ CList<Bkmk>* CPlucker::getbkmklist() | |||
527 | } | 1017 | } |
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; |
535 | do | 1033 | do |
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); | ||
1050 | |||
1051 | QImage* qimage = Palm2QImage(imgbuffer, imgsize); | ||
1052 | |||
1053 | delete [] imgbuffer; | ||
1054 | |||
1055 | return qimage; | ||
1056 | } | ||
1057 | |||
1058 | #include <qnamespace.h> | ||
551 | 1059 | ||
552 | if (thisHdr.type == 2) | 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 | } |
558 | else | 1076 | else |
559 | { | 1077 | { |
560 | qDebug("Compressed"); | 1078 | ret = image; |
561 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | 1079 | } |
562 | switch (ntohs(hdr0.version)) | 1080 | return ret; |
1081 | } | ||
1082 | |||
1083 | #ifdef _BUFFERPICS | ||
1084 | #include <qmap.h> | ||
1085 | #endif | ||
1086 | |||
1087 | QPixmap* CPlucker::getPicture(unsigned long tgt) | ||
563 | { | 1088 | { |
564 | case 2: | 1089 | #ifdef _BUFFERPICS |
565 | UnZip(reclen, imgbuffer, imgsize); | 1090 | static QMap<unsigned long, QPixmap> pix; |
566 | break; | 1091 | QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt); |
567 | case 1: | 1092 | if (t == pix.end()) |
568 | UnDoc(reclen, imgbuffer, imgsize); | 1093 | { |
1094 | pix[tgt] = *expandimg(tgt); | ||
1095 | return &pix[tgt]; | ||
1096 | } | ||
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"); | ||
569 | break; | 1190 | break; |
570 | } | 1191 | } |
571 | } | 1192 | } |
572 | FILE* imgfile = fopen("/home/tim/newreader/imagefile.tbmp", "w"); | 1193 | m_nav.putSaveData(src, srclen); |
573 | if (imgfile != NULL) | 1194 | } |
1195 | |||
1196 | unsigned short CPlucker::finduid(unsigned short urlid) | ||
574 | { | 1197 | { |
575 | fwrite(imgbuffer, 1, imgsize, imgfile); | 1198 | // qDebug("Finding %u", urlid); |
576 | fclose(imgfile); | 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; | ||
577 | } | 1211 | } |
578 | delete [] imgbuffer; | 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 | |||
@@ -7,4 +7,11 @@ | |||
7 | #include "pdb.h" | 7 | #include "pdb.h" |
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 | ||
10 | struct CPlucker_dataRecord | 17 | struct CPlucker_dataRecord |
@@ -30,11 +37,20 @@ struct CPluckerbkmk | |||
30 | }; | 37 | }; |
31 | 38 | ||
32 | |||
33 | const UInt32 CPLUCKER_ID = 0x5458547a; | 39 | const UInt32 CPLUCKER_ID = 0x5458547a; |
34 | 40 | ||
35 | class CPlucker : public CExpander, Cpdb | 41 | 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; |
40 | CBufferFace<UInt16> m_ParaOffsets; | 56 | CBufferFace<UInt16> m_ParaOffsets; |
@@ -47,4 +63,6 @@ class CPlucker : public CExpander, Cpdb | |||
47 | UInt8* expandedtextbuffer; | 63 | UInt8* expandedtextbuffer; |
48 | UInt8* compressedtextbuffer; | 64 | UInt8* compressedtextbuffer; |
65 | char* urls; | ||
66 | size_t urlsize; | ||
49 | size_t bufferpos; | 67 | size_t bufferpos; |
50 | UInt16 bufferrec; | 68 | UInt16 bufferrec; |
@@ -54,22 +72,27 @@ class CPlucker : public CExpander, Cpdb | |||
54 | void UnZip(size_t, UInt8*, UInt16); | 72 | void UnZip(size_t, UInt8*, UInt16); |
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; | ||
64 | //ntohl(hdr0.size); | ||
65 | } | 86 | } |
66 | virtual bool hasrandomaccess() { return true; } | 87 | virtual void unsuspend() |
67 | virtual ~CPlucker() | ||
68 | { | 88 | { |
69 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; | 89 | CExpander::unsuspend(fin); |
70 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; | ||
71 | } | 90 | } |
91 | virtual QPixmap* getPicture(unsigned long tgt); | ||
92 | virtual void sizes(unsigned long& _file, unsigned long& _text); | ||
93 | virtual bool hasrandomaccess() { return true; } | ||
94 | virtual ~CPlucker(); | ||
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(); |
75 | virtual void getch(int&, CStyle&); | 98 | virtual void getch(int&, CStyle&); |
@@ -82,4 +105,18 @@ class CPlucker : public CExpander, Cpdb | |||
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 | }; |
85 | 122 | ||
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 | |||
@@ -36,5 +36,5 @@ ppm_expander::~ppm_expander() { | |||
36 | } | 36 | } |
37 | 37 | ||
38 | int ppm_expander::openfile(const char* infile) | 38 | int ppm_expander::OpenFile(const char* infile) |
39 | { | 39 | { |
40 | my_file_in=fopen(infile,"rb"); | 40 | my_file_in=fopen(infile,"rb"); |
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,4 +27,12 @@ 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) |
30 | { | 38 | { |
@@ -34,5 +42,5 @@ class ppm_expander : public CExpander { | |||
34 | outbytes = 0; | 42 | outbytes = 0; |
35 | } | 43 | } |
36 | virtual int openfile(const char* infile); | 44 | virtual int OpenFile(const char* infile); |
37 | virtual int getch(); | 45 | virtual int getch(); |
38 | int locate(unsigned short block, unsigned int n); | 46 | int locate(unsigned short block, unsigned int n); |
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 | |||
@@ -64,4 +64,16 @@ inline QString toQString(tchar *_p, unsigned int len) | |||
64 | return ret; | 64 | return ret; |
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 |
67 | 79 | ||
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 | |||
@@ -1,5 +1,5 @@ | |||
1 | 1 | ||
2 | #define MAJOR 0 | 2 | #define MAJOR 0 |
3 | #define BKMKTYPE 5 | 3 | #define BKMKTYPE 6 |
4 | #define MINOR 'a' | 4 | #define MINOR 'a' |
5 | #define RELEASE_TYPE "beta" | 5 | #define RELEASE_TYPE "beta" |
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 | |||
@@ -8,5 +8,5 @@ ztxt::ztxt() : bInit(false), expandedtextbuffer(NULL), compressedtextbuffer(NULL | |||
8 | 8 | ||
9 | 9 | ||
10 | int ztxt::openfile(const char *src) | 10 | int ztxt::OpenFile(const char *src) |
11 | { | 11 | { |
12 | if (!Cpdb::openfile(src)) | 12 | if (!Cpdb::openfile(src)) |
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,4 +76,12 @@ 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 | { |
@@ -92,5 +100,5 @@ class ztxt : public CExpander, Cpdb | |||
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(); |
96 | virtual unsigned int locate(); | 104 | virtual unsigned int locate(); |