94 files changed, 4999 insertions, 1437 deletions
diff --git a/noncore/apps/opie-reader/Aportis.cpp b/noncore/apps/opie-reader/Aportis.cpp index 353996c..37dcc99 100644 --- a/noncore/apps/opie-reader/Aportis.cpp +++ b/noncore/apps/opie-reader/Aportis.cpp | |||
@@ -1,454 +1,460 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <string.h> | 2 | #include <string.h> |
3 | #include "Aportis.h" | 3 | #include "Aportis.h" |
4 | #include "my_list.h" | 4 | #include "my_list.h" |
5 | #include "Bkmks.h" | 5 | #include "Bkmks.h" |
6 | 6 | ||
7 | Aportis::Aportis() : peanutfile(false) { /*printf("constructing:%x\n",fin);*/ } | 7 | Aportis::Aportis() : peanutfile(false) { /*printf("constructing:%x\n",fin);*/ } |
8 | 8 | ||
9 | void Aportis::dePeanut(int& ch) | 9 | void Aportis::dePeanut(int& ch) |
10 | { | 10 | { |
11 | if (peanutfile && ch != EOF) | 11 | if (peanutfile && ch != EOF) |
12 | { | 12 | { |
13 | unsigned char c = ch; | 13 | unsigned char c = ch; |
14 | if (peanutfile) c ^= 0xa5; | 14 | if (peanutfile) c ^= 0xa5; |
15 | ch = c; | 15 | ch = c; |
16 | } | 16 | } |
17 | } | 17 | } |
18 | 18 | ||
19 | CList<Bkmk>* Aportis::getbkmklist() | 19 | CList<Bkmk>* Aportis::getbkmklist() |
20 | { | 20 | { |
21 | /* | 21 | /* |
22 | if (peanutfile) | 22 | if (peanutfile) |
23 | { | 23 | { |
24 | if (nRecs2 > nRecs) | 24 | if (nRecs2 > nRecs) |
25 | { | 25 | { |
26 | CList<Bkmk>* t = new CList<Bkmk>; | 26 | CList<Bkmk>* t = new CList<Bkmk>; |
27 | for (int i = nRecs; i < nRecs2; i++) | 27 | for (int i = nRecs; i < nRecs2; i++) |
28 | { | 28 | { |
29 | char name[17]; | 29 | char name[17]; |
30 | name[16] = '\0'; | 30 | name[16] = '\0'; |
31 | // qDebug("Record:%d, Length:%u",i,recordlength(i)); | 31 | // qDebug("Record:%d, Length:%u",i,recordlength(i)); |
32 | gotorecordnumber(i); | 32 | gotorecordnumber(i); |
33 | fread(name,1,16,fin); | 33 | fread(name,1,16,fin); |
34 | unsigned long lcn; | 34 | unsigned long lcn; |
35 | fread(&lcn,sizeof(lcn),1,fin); | 35 | fread(&lcn,sizeof(lcn),1,fin); |
36 | lcn ^= 0xa5a5a5a5; | 36 | lcn ^= 0xa5a5a5a5; |
37 | lcn = SwapLong(lcn); | 37 | lcn = SwapLong(lcn); |
38 | // qDebug("Bookmark:%s:%u", name,lcn); | 38 | // qDebug("Bookmark:%s:%u", name,lcn); |
39 | tchar tname[17]; | 39 | tchar tname[17]; |
40 | memset(tname, 0, sizeof(tname)); | 40 | memset(tname, 0, sizeof(tname)); |
41 | for (int i = 0; name[i] != 0; i++) | 41 | for (int i = 0; name[i] != 0; i++) |
42 | { | 42 | { |
43 | tname[i] = name[i] ^ 0xa5; | 43 | tname[i] = name[i] ^ 0xa5; |
44 | } | 44 | } |
45 | t->push_back(Bkmk(tname, NULL, lcn)); | 45 | t->push_back(Bkmk(tname, NULL, lcn)); |
46 | } | 46 | } |
47 | return t; | 47 | return t; |
48 | } | 48 | } |
49 | else | 49 | else |
50 | { | 50 | { |
51 | return NULL; | 51 | return NULL; |
52 | } | 52 | } |
53 | } | 53 | } |
54 | */ | 54 | */ |
55 | if (bCompressed != 4) return NULL; | 55 | if (bCompressed != 4) return NULL; |
56 | CList<Bkmk>* t = new CList<Bkmk>; | 56 | CList<Bkmk>* t = new CList<Bkmk>; |
57 | unsuspend(); | ||
57 | size_t cur = ftell(fin); | 58 | size_t cur = ftell(fin); |
58 | for (int i = 0; i < nRecs2; i++) | 59 | for (int i = 0; i < nRecs2; i++) |
59 | { | 60 | { |
60 | DWORD dwPos; | 61 | DWORD dwPos; |
61 | fseek(fin, 0x56 + 8*i, SEEK_SET); | 62 | fseek(fin, 0x56 + 8*i, SEEK_SET); |
62 | fread(&dwPos, 4, 1, fin); | 63 | fread(&dwPos, 4, 1, fin); |
63 | dwPos = SwapLong(dwPos); | 64 | dwPos = SwapLong(dwPos); |
64 | fseek(fin,dwPos,SEEK_SET); | 65 | fseek(fin,dwPos,SEEK_SET); |
65 | unsigned char ch; | 66 | unsigned char ch; |
66 | fread(&ch,1,1,fin); | 67 | fread(&ch,1,1,fin); |
67 | if (ch != 241) | 68 | if (ch != 241) |
68 | { | 69 | { |
69 | char name[17]; | 70 | char name[17]; |
70 | name[16] = '\0'; | 71 | name[16] = '\0'; |
71 | fseek(fin,dwPos,SEEK_SET); | 72 | fseek(fin,dwPos,SEEK_SET); |
72 | fread(name,1,16,fin); | 73 | fread(name,1,16,fin); |
73 | unsigned long lcn; | 74 | unsigned long lcn; |
74 | fread(&lcn,sizeof(lcn),1,fin); | 75 | fread(&lcn,sizeof(lcn),1,fin); |
75 | lcn = SwapLong(lcn); | 76 | lcn = SwapLong(lcn); |
76 | #ifdef _UNICODE | 77 | #ifdef _UNICODE |
77 | tchar tname[17]; | 78 | tchar tname[17]; |
78 | memset(tname, 0, sizeof(tname)); | 79 | memset(tname, 0, sizeof(tname)); |
79 | for (int i = 0; name[i] != 0; i++) | 80 | for (int i = 0; name[i] != 0; i++) |
80 | { | 81 | { |
81 | tname[i] = name[i]; | 82 | tname[i] = name[i]; |
82 | } | 83 | } |
83 | t->push_back(Bkmk(tname, NULL, lcn)); | 84 | t->push_back(Bkmk(tname, NULL, lcn)); |
84 | #else | 85 | #else |
85 | t->push_back(Bkmk(name,lcn)); | 86 | t->push_back(Bkmk(name,lcn)); |
86 | #endif | 87 | #endif |
87 | } | 88 | } |
88 | } | 89 | } |
89 | fseek(fin, cur, SEEK_SET); | 90 | fseek(fin, cur, SEEK_SET); |
90 | return t; | 91 | return t; |
91 | } | 92 | } |
92 | 93 | ||
93 | int Aportis::OpenFile(const char *src) | 94 | int Aportis::OpenFile(const char *src) |
94 | { | 95 | { |
95 | // printf("In openfile\n"); | 96 | // printf("In openfile\n"); |
96 | int ret = 0; | 97 | int ret = 0; |
97 | html = false; | 98 | html = false; |
98 | mobiimagerec = 0; | 99 | mobiimagerec = 0; |
99 | if (!Cpdb::openpdbfile(src)) return -1; | 100 | if (!Cpdb::openpdbfile(src)) return -1; |
100 | 101 | ||
101 | if (head.creator == 0x64414552 // 'dAER' | 102 | if (head.creator == 0x64414552 // 'dAER' |
102 | || head.type == 0x74584554) // 'tXET') | 103 | || head.type == 0x74584554) // 'tXET') |
103 | { | 104 | { |
104 | } | 105 | } |
105 | else if (memcmp(&head.creator, "PPrs", 4) == 0 && memcmp(&head.type, "PNRd", 4) == 0) | 106 | else if (memcmp(&head.creator, "PPrs", 4) == 0 && memcmp(&head.type, "PNRd", 4) == 0) |
106 | { | 107 | { |
107 | peanutfile = true; | 108 | peanutfile = true; |
108 | } | 109 | } |
109 | else if (memcmp(&head.creator, "MOBI", 4) == 0 && memcmp(&head.type, "BOOK", 4) == 0) | 110 | else if (memcmp(&head.creator, "MOBI", 4) == 0 && memcmp(&head.type, "BOOK", 4) == 0) |
110 | { | 111 | { |
111 | html = true; | 112 | html = true; |
112 | unsigned char vsn; | 113 | unsigned char vsn; |
113 | fseek(fin, recordpos(0)+39, SEEK_SET); | 114 | fseek(fin, recordpos(0)+39, SEEK_SET); |
114 | fread(&vsn, 1, sizeof(vsn), fin); | 115 | fread(&vsn, 1, sizeof(vsn), fin); |
115 | qDebug("Mobi version:%x", vsn); | 116 | qDebug("Mobi version:%x", vsn); |
116 | if (vsn > 2) | 117 | if (vsn > 2) |
117 | { | 118 | { |
118 | fseek(fin, recordpos(0)+110, SEEK_SET); | 119 | fseek(fin, recordpos(0)+110, SEEK_SET); |
119 | fread(&mobiimagerec, 1, sizeof(mobiimagerec), fin); | 120 | fread(&mobiimagerec, 1, sizeof(mobiimagerec), fin); |
120 | mobiimagerec = ntohs(mobiimagerec)-1; | 121 | mobiimagerec = ntohs(mobiimagerec)-1; |
121 | } | 122 | } |
122 | } | 123 | } |
123 | else | 124 | else |
124 | { | 125 | { |
125 | return -2; | 126 | return -2; |
126 | } | 127 | } |
127 | 128 | ||
128 | nRecs2 = nRecs = SwapWord(head.recordList.numRecords) - 1; | 129 | nRecs2 = nRecs = SwapWord(head.recordList.numRecords) - 1; |
129 | 130 | ||
130 | struct stat _stat; | 131 | struct stat _stat; |
131 | stat(src,&_stat); | 132 | stat(src,&_stat); |
132 | dwLen = _stat.st_size; | 133 | dwLen = _stat.st_size; |
133 | 134 | ||
134 | //fseek(fin,0,SEEK_END); | 135 | //fseek(fin,0,SEEK_END); |
135 | //dwLen = ftell(fin); | 136 | //dwLen = ftell(fin); |
136 | 137 | ||
137 | if (peanutfile) | 138 | if (peanutfile) |
138 | { | 139 | { |
139 | 140 | ||
140 | PeanutHeader hdr0; | 141 | PeanutHeader hdr0; |
141 | gotorecordnumber(0); | 142 | gotorecordnumber(0); |
142 | fread(&hdr0, sizeof(hdr0), 1, fin); | 143 | fread(&hdr0, sizeof(hdr0), 1, fin); |
143 | // qDebug("Version:%x", ntohs(hdr0.Version)); | 144 | // qDebug("Version:%x", ntohs(hdr0.Version)); |
144 | if (hdr0.Version && 0x0200) | 145 | if (hdr0.Version && 0x0200) |
145 | { | 146 | { |
146 | bCompressed = 2; | 147 | bCompressed = 2; |
147 | } | 148 | } |
148 | else | 149 | else |
149 | { | 150 | { |
150 | bCompressed = 1; | 151 | bCompressed = 1; |
151 | } | 152 | } |
152 | BlockSize = 4096; | 153 | BlockSize = 4096; |
153 | nRecs = SwapWord(hdr0.Records)-1; | 154 | nRecs = SwapWord(hdr0.Records)-1; |
154 | dwTLen = nRecs*BlockSize; | 155 | dwTLen = nRecs*BlockSize; |
155 | } | 156 | } |
156 | else | 157 | else |
157 | { | 158 | { |
158 | gotorecordnumber(0); | 159 | gotorecordnumber(0); |
159 | tDocRecord0 hdr0; | 160 | tDocRecord0 hdr0; |
160 | fread(&hdr0, sizeof(hdr0), 1, fin); | 161 | fread(&hdr0, sizeof(hdr0), 1, fin); |
161 | bCompressed = SwapWord(hdr0.wVersion); | 162 | bCompressed = SwapWord(hdr0.wVersion); |
162 | if (bCompressed!=1 && bCompressed!=2 && bCompressed != 4) { | 163 | if (bCompressed!=1 && bCompressed!=2 && bCompressed != 4) { |
163 | qDebug("ERROR:Unrecognised compression type in Aportis:%u", bCompressed); | 164 | qDebug("ERROR:Unrecognised compression type in Aportis:%u", bCompressed); |
164 | ret = bCompressed; | 165 | ret = bCompressed; |
165 | bCompressed = 2; | 166 | bCompressed = 2; |
166 | } | 167 | } |
167 | switch (bCompressed) | 168 | switch (bCompressed) |
168 | { | 169 | { |
169 | case 4: | 170 | case 4: |
170 | { | 171 | { |
171 | dwTLen = 0; | 172 | dwTLen = 0; |
172 | int i; | 173 | int i; |
173 | for (i = 0; i < nRecs; i++) | 174 | for (i = 0; i < nRecs; i++) |
174 | { | 175 | { |
175 | unsigned int bs = GetBS(i); | 176 | unsigned int bs = GetBS(i); |
176 | if (bs == 0) break; | 177 | if (bs == 0) break; |
177 | else dwTLen += bs; | 178 | else dwTLen += bs; |
178 | } | 179 | } |
179 | nRecs = i; | 180 | nRecs = i; |
180 | BlockSize = 0; | 181 | BlockSize = 0; |
181 | } | 182 | } |
182 | break; | 183 | break; |
183 | case 1: | 184 | case 1: |
184 | case 2: | 185 | case 2: |
185 | default: | 186 | default: |
186 | nRecs = SwapWord(hdr0.wNumRecs); | 187 | nRecs = SwapWord(hdr0.wNumRecs); |
187 | if (mobiimagerec == 0 || mobiimagerec > nRecs2) mobiimagerec = nRecs; | 188 | if (mobiimagerec == 0 || mobiimagerec > nRecs2) mobiimagerec = nRecs; |
188 | dwTLen = SwapLong(hdr0.dwStoryLen); | 189 | dwTLen = SwapLong(hdr0.dwStoryLen); |
189 | BlockSize = SwapWord(hdr0.wRecSize); | 190 | BlockSize = SwapWord(hdr0.wRecSize); |
190 | if (BlockSize == 0) | 191 | if (BlockSize == 0) |
191 | { | 192 | { |
192 | BlockSize = 4096; | 193 | BlockSize = 4096; |
193 | printf("WARNING: Blocksize not set in source file\n"); | 194 | printf("WARNING: Blocksize not set in source file\n"); |
194 | } | 195 | } |
195 | } | 196 | } |
196 | } | 197 | } |
197 | 198 | ||
198 | qDebug("Mobi image rec:%u", mobiimagerec); | 199 | qDebug("Mobi image rec:%u", mobiimagerec); |
199 | 200 | ||
200 | // this is the main record buffer | 201 | // this is the main record buffer |
201 | // it knows how to stretch to accomodate the decompress | 202 | // it knows how to stretch to accomodate the decompress |
202 | currentrec = 0; | 203 | currentrec = 0; |
203 | cbptr = 0; | 204 | cbptr = 0; |
204 | outptr = 0; | 205 | outptr = 0; |
205 | refreshbuffer(); | 206 | refreshbuffer(); |
206 | if (!html) | 207 | if (!html) |
207 | { | 208 | { |
208 | int c; | 209 | int c; |
209 | char htmltag[] = "<HTML>"; | 210 | char htmltag[] = "<HTML>"; |
210 | char *p = htmltag; | 211 | char *p = htmltag; |
211 | while (1) | 212 | while (1) |
212 | { | 213 | { |
213 | c = getch(); | 214 | c = getch(); |
214 | char ch = *p++; | 215 | char ch = *p++; |
215 | if (ch == 0) | 216 | if (ch == 0) |
216 | { | 217 | { |
217 | html = true; | 218 | html = true; |
218 | break; | 219 | break; |
219 | } | 220 | } |
220 | if (c != ch) | 221 | if (c != ch) |
221 | { | 222 | { |
222 | html = false; | 223 | html = false; |
223 | break; | 224 | break; |
224 | } | 225 | } |
225 | } | 226 | } |
226 | currentrec = 0; | 227 | currentrec = 0; |
227 | cbptr = 0; | 228 | cbptr = 0; |
228 | outptr = 0; | 229 | outptr = 0; |
229 | refreshbuffer(); | 230 | refreshbuffer(); |
230 | } | 231 | } |
231 | /* | 232 | /* |
232 | for (int i = 0; i < nRecs2; i++) | 233 | for (int i = 0; i < nRecs2; i++) |
233 | { | 234 | { |
234 | qDebug("Record:%u - %u bytes at position %x", i, recordlength(i), recordpos(i)); | 235 | qDebug("Record:%u - %u bytes at position %x", i, recordlength(i), recordpos(i)); |
235 | } | 236 | } |
236 | */ | 237 | */ |
237 | 238 | ||
238 | qDebug("Number of records:[%u,%u]", nRecs, nRecs2); | 239 | qDebug("Number of records:[%u,%u]", nRecs, nRecs2); |
239 | return ret; | 240 | return ret; |
240 | } | 241 | } |
241 | 242 | ||
242 | int Aportis::getch() | 243 | int Aportis::getch() |
243 | { | 244 | { |
244 | if (bCompressed == 1) | 245 | if (bCompressed == 1) |
245 | { | 246 | { |
246 | if ((dwRecLen == 0) && !refreshbuffer()) return EOF; | 247 | if ((dwRecLen == 0) && !refreshbuffer()) return EOF; |
247 | else | 248 | else |
248 | { | 249 | { |
250 | unsuspend(); | ||
249 | int c = getc(fin); | 251 | int c = getc(fin); |
250 | dePeanut(c); | 252 | dePeanut(c); |
251 | dwRecLen--; | 253 | dwRecLen--; |
252 | currentpos++; | 254 | currentpos++; |
253 | return c; | 255 | return c; |
254 | } | 256 | } |
255 | } | 257 | } |
256 | if (outptr != cbptr) | 258 | if (outptr != cbptr) |
257 | { | 259 | { |
258 | currentpos++; | 260 | currentpos++; |
259 | return (circbuf[outptr = (outptr + 1) % 2048]); | 261 | return (circbuf[outptr = (outptr + 1) % 2048]); |
260 | } | 262 | } |
261 | if ((dwRecLen == 0) && !refreshbuffer()) return EOF; | 263 | if ((dwRecLen == 0) && !refreshbuffer()) return EOF; |
262 | currentpos++; | 264 | currentpos++; |
263 | int c; | 265 | int c; |
264 | 266 | ||
265 | // take a char from the input buffer | 267 | // take a char from the input buffer |
268 | unsuspend(); | ||
266 | c = getc(fin); | 269 | c = getc(fin); |
267 | dePeanut(c); | 270 | dePeanut(c); |
268 | dwRecLen--; | 271 | dwRecLen--; |
269 | // separate the char into zones: 0, 1...8, 9...0x7F, 0x80...0xBF, 0xC0...0xFF | 272 | // separate the char into zones: 0, 1...8, 9...0x7F, 0x80...0xBF, 0xC0...0xFF |
270 | 273 | ||
271 | // codes 1...8 mean copy that many chars; for accented chars & binary | 274 | // codes 1...8 mean copy that many chars; for accented chars & binary |
272 | if (c == 0) | 275 | if (c == 0) |
273 | { | 276 | { |
274 | circbuf[outptr = cbptr = (cbptr+1)%2048] = c; | 277 | circbuf[outptr = cbptr = (cbptr+1)%2048] = c; |
275 | return c; | 278 | return c; |
276 | } | 279 | } |
277 | else if (c >= 0x09 && c <= 0x7F) | 280 | else if (c >= 0x09 && c <= 0x7F) |
278 | { | 281 | { |
279 | circbuf[outptr = cbptr = (cbptr+1)%2048] = c; | 282 | circbuf[outptr = cbptr = (cbptr+1)%2048] = c; |
280 | return c; | 283 | return c; |
281 | } | 284 | } |
282 | else if (c >= 0x01 && c <= 0x08) | 285 | else if (c >= 0x01 && c <= 0x08) |
283 | { | 286 | { |
284 | dwRecLen -= c; | 287 | dwRecLen -= c; |
285 | while(c--) | 288 | while(c--) |
286 | { | 289 | { |
287 | int c = getc(fin); | 290 | int c = getc(fin); |
288 | dePeanut(c); | 291 | dePeanut(c); |
289 | circbuf[cbptr = (cbptr+1)%2048] = c; | 292 | circbuf[cbptr = (cbptr+1)%2048] = c; |
290 | } | 293 | } |
291 | return circbuf[outptr = (outptr+1)%2048]; | 294 | return circbuf[outptr = (outptr+1)%2048]; |
292 | } | 295 | } |
293 | else if (c >= 0x80 && c <= 0xBF) | 296 | else if (c >= 0x80 && c <= 0xBF) |
294 | { | 297 | { |
295 | int m,n; | 298 | int m,n; |
296 | c <<= 8; | 299 | c <<= 8; |
297 | int c1 = getc(fin); | 300 | int c1 = getc(fin); |
298 | dePeanut(c1); | 301 | dePeanut(c1); |
299 | c += c1; | 302 | c += c1; |
300 | dwRecLen--; | 303 | dwRecLen--; |
301 | m = (c & 0x3FFF) >> COUNT_BITS; | 304 | m = (c & 0x3FFF) >> COUNT_BITS; |
302 | n = c & ((1<<COUNT_BITS) - 1); | 305 | n = c & ((1<<COUNT_BITS) - 1); |
303 | n += 3; | 306 | n += 3; |
304 | while (n--) | 307 | while (n--) |
305 | { | 308 | { |
306 | cbptr = (cbptr+1)%2048; | 309 | cbptr = (cbptr+1)%2048; |
307 | circbuf[cbptr] = circbuf[(cbptr+2048-m)%2048]; | 310 | circbuf[cbptr] = circbuf[(cbptr+2048-m)%2048]; |
308 | } | 311 | } |
309 | return circbuf[outptr = (outptr+1)%2048]; | 312 | return circbuf[outptr = (outptr+1)%2048]; |
310 | } | 313 | } |
311 | else if (c >= 0xC0 && c <= 0xFF) | 314 | else if (c >= 0xC0 && c <= 0xFF) |
312 | { | 315 | { |
313 | circbuf[cbptr = (cbptr+1)%2048] = ' '; | 316 | circbuf[cbptr = (cbptr+1)%2048] = ' '; |
314 | circbuf[cbptr = (cbptr+1)%2048] = c^0x80; | 317 | circbuf[cbptr = (cbptr+1)%2048] = c^0x80; |
315 | return circbuf[outptr = (outptr+1)%2048]; | 318 | return circbuf[outptr = (outptr+1)%2048]; |
316 | } | 319 | } |
317 | } | 320 | } |
318 | 321 | ||
319 | unsigned int Aportis::GetBS(unsigned int bn) | 322 | unsigned int Aportis::GetBS(unsigned int bn) |
320 | { | 323 | { |
321 | DWORD dwPos; | 324 | DWORD dwPos; |
322 | WORD fs; | 325 | WORD fs; |
323 | 326 | unsuspend(); | |
324 | fseek(fin, 0x56 + 8*bn, SEEK_SET); | 327 | fseek(fin, 0x56 + 8*bn, SEEK_SET); |
325 | fread(&dwPos, 4, 1, fin); | 328 | fread(&dwPos, 4, 1, fin); |
326 | dwPos = SwapLong(dwPos); | 329 | dwPos = SwapLong(dwPos); |
327 | fseek(fin,dwPos,SEEK_SET); | 330 | fseek(fin,dwPos,SEEK_SET); |
328 | 331 | ||
329 | // gotorecordnumber(bn+1); | 332 | // gotorecordnumber(bn+1); |
330 | unsigned char ch; | 333 | unsigned char ch; |
331 | fread(&ch,1,1,fin); | 334 | fread(&ch,1,1,fin); |
332 | if (ch == 241) | 335 | if (ch == 241) |
333 | { | 336 | { |
334 | fread(&fs,sizeof(fs),1,fin); | 337 | fread(&fs,sizeof(fs),1,fin); |
335 | fs = SwapWord(fs); | 338 | fs = SwapWord(fs); |
336 | } | 339 | } |
337 | else | 340 | else |
338 | fs = 0; | 341 | fs = 0; |
339 | return fs; | 342 | return fs; |
340 | } | 343 | } |
341 | 344 | ||
342 | unsigned int Aportis::locate() | 345 | unsigned int Aportis::locate() |
343 | { | 346 | { |
344 | if (bCompressed == 4) | 347 | if (bCompressed == 4) |
345 | { | 348 | { |
349 | unsuspend(); | ||
346 | size_t cur = ftell(fin); | 350 | size_t cur = ftell(fin); |
347 | unsigned int clen = 0; | 351 | unsigned int clen = 0; |
348 | for (unsigned int i = 0; i < currentrec-1; i++) | 352 | for (unsigned int i = 0; i < currentrec-1; i++) |
349 | { | 353 | { |
350 | unsigned int bs = GetBS(i); | 354 | unsigned int bs = GetBS(i); |
351 | if (bs == 0) break; | 355 | if (bs == 0) break; |
352 | clen += bs; | 356 | clen += bs; |
353 | } | 357 | } |
354 | fseek(fin,cur,SEEK_SET); | 358 | fseek(fin,cur,SEEK_SET); |
355 | return clen+currentpos; | 359 | return clen+currentpos; |
356 | } | 360 | } |
357 | else | 361 | else |
358 | return (currentrec-1)*BlockSize+currentpos; | 362 | return (currentrec-1)*BlockSize+currentpos; |
359 | } | 363 | } |
360 | 364 | ||
361 | void Aportis::locate(unsigned int n) | 365 | void Aportis::locate(unsigned int n) |
362 | { | 366 | { |
363 | unsigned int offset; | 367 | unsigned int offset; |
364 | // currentrec = (n >> OFFBITS); | 368 | // currentrec = (n >> OFFBITS); |
365 | switch (bCompressed) | 369 | switch (bCompressed) |
366 | { | 370 | { |
367 | case 4: | 371 | case 4: |
368 | { | 372 | { |
369 | DWORD clen = 0; | 373 | DWORD clen = 0; |
370 | offset = n; | 374 | offset = n; |
371 | unsigned int i; | 375 | unsigned int i; |
372 | for (i = 0; i < nRecs; i++) | 376 | for (i = 0; i < nRecs; i++) |
373 | { | 377 | { |
374 | unsigned int bs = GetBS(i); | 378 | unsigned int bs = GetBS(i); |
375 | if (bs == 0) break; | 379 | if (bs == 0) break; |
376 | clen += bs; | 380 | clen += bs; |
377 | if (clen > n) break; | 381 | if (clen > n) break; |
378 | offset = n - clen; | 382 | offset = n - clen; |
379 | } | 383 | } |
380 | currentrec = i; | 384 | currentrec = i; |
381 | } | 385 | } |
382 | break; | 386 | break; |
383 | case 1: | 387 | case 1: |
384 | case 2: | 388 | case 2: |
385 | default: | 389 | default: |
386 | currentrec = n / BlockSize; | 390 | currentrec = n / BlockSize; |
387 | offset = n % BlockSize; | 391 | offset = n % BlockSize; |
388 | } | 392 | } |
389 | 393 | ||
390 | outptr = cbptr; | 394 | outptr = cbptr; |
391 | refreshbuffer(); | 395 | refreshbuffer(); |
392 | while (currentpos < offset && getch() != EOF); | 396 | while (currentpos < offset && getch() != EOF); |
393 | } | 397 | } |
394 | 398 | ||
395 | bool Aportis::refreshbuffer() | 399 | bool Aportis::refreshbuffer() |
396 | { | 400 | { |
397 | if (currentrec < nRecs) | 401 | if (currentrec < nRecs) |
398 | { | 402 | { |
399 | dwRecLen = recordlength(currentrec+1); | 403 | dwRecLen = recordlength(currentrec+1); |
400 | gotorecordnumber(currentrec+1); | 404 | gotorecordnumber(currentrec+1); |
401 | if (bCompressed == 4) | 405 | if (bCompressed == 4) |
402 | { | 406 | { |
403 | unsigned char t[3]; | 407 | unsigned char t[3]; |
408 | unsuspend(); | ||
404 | fread(t,1,3,fin); | 409 | fread(t,1,3,fin); |
405 | if (t[0] != 241) | 410 | if (t[0] != 241) |
406 | { | 411 | { |
407 | printf("You shouldn't be here!\n"); | 412 | printf("You shouldn't be here!\n"); |
408 | return false; | 413 | return false; |
409 | } | 414 | } |
410 | dwRecLen -= 3; | 415 | dwRecLen -= 3; |
411 | } | 416 | } |
412 | /* | 417 | /* |
413 | int n = fread(t.buf, 1, dwRecLen, fin); | 418 | int n = fread(t.buf, 1, dwRecLen, fin); |
414 | t.len = n; | 419 | t.len = n; |
415 | // if(bCompressed) | 420 | // if(bCompressed) |
416 | t.Decompress(); | 421 | t.Decompress(); |
417 | 422 | ||
418 | t.buf[t.Len()] = '\0'; | 423 | t.buf[t.Len()] = '\0'; |
419 | */ | 424 | */ |
420 | currentpos = 0; | 425 | currentpos = 0; |
421 | currentrec++; | 426 | currentrec++; |
422 | return true; | 427 | return true; |
423 | } | 428 | } |
424 | else { | 429 | else { |
425 | return false; | 430 | return false; |
426 | } | 431 | } |
427 | } | 432 | } |
428 | 433 | ||
429 | #include <qimage.h> | 434 | #include <qimage.h> |
430 | 435 | ||
431 | QImage* Aportis::getPicture(unsigned long tgt) | 436 | QImage* Aportis::getPicture(unsigned long tgt) |
432 | { | 437 | { |
438 | unsuspend(); | ||
433 | unsigned short tgtrec = tgt+mobiimagerec; | 439 | unsigned short tgtrec = tgt+mobiimagerec; |
434 | if (tgtrec > nRecs2) return NULL; | 440 | if (tgtrec > nRecs2) return NULL; |
435 | size_t cur = ftell(fin); | 441 | size_t cur = ftell(fin); |
436 | unsigned short reclen = recordlength(tgtrec); | 442 | unsigned short reclen = recordlength(tgtrec); |
437 | gotorecordnumber(tgtrec); | 443 | gotorecordnumber(tgtrec); |
438 | UInt8* imgbuffer = new UInt8[reclen]; | 444 | UInt8* imgbuffer = new UInt8[reclen]; |
439 | fread(imgbuffer, 1, reclen, fin); | 445 | fread(imgbuffer, 1, reclen, fin); |
440 | QByteArray arr; | 446 | QByteArray arr; |
441 | arr.assign((const char*)imgbuffer, reclen); | 447 | arr.assign((const char*)imgbuffer, reclen); |
442 | 448 | ||
443 | QImage* qimage = new QImage(arr); | 449 | QImage* qimage = new QImage(arr); |
444 | fseek(fin, cur, SEEK_SET); | 450 | fseek(fin, cur, SEEK_SET); |
445 | 451 | ||
446 | return qimage; | 452 | return qimage; |
447 | } | 453 | } |
448 | 454 | ||
449 | #ifndef __STATIC | 455 | #ifndef __STATIC |
450 | extern "C" | 456 | extern "C" |
451 | { | 457 | { |
452 | CExpander* newcodec() { return new Aportis; } | 458 | CExpander* newcodec() { return new Aportis; } |
453 | } | 459 | } |
454 | #endif | 460 | #endif |
diff --git a/noncore/apps/opie-reader/ArriereCodec/.cvsignore b/noncore/apps/opie-reader/ArriereCodec/.cvsignore new file mode 100644 index 0000000..1810ee0 --- a/dev/null +++ b/noncore/apps/opie-reader/ArriereCodec/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile | ||
2 | config.in | ||
3 | moc_* | ||
4 | .moc | ||
5 | .obj | ||
diff --git a/noncore/apps/opie-reader/ArriereCodec/ArriereCodec.pro b/noncore/apps/opie-reader/ArriereCodec/ArriereCodec.pro new file mode 100644 index 0000000..8d820d6 --- a/dev/null +++ b/noncore/apps/opie-reader/ArriereCodec/ArriereCodec.pro | |||
@@ -0,0 +1,16 @@ | |||
1 | DEFINES += OPIE USEQPE | ||
2 | VPATH = .. | ||
3 | TEMPLATE= lib | ||
4 | CONFIG = qt warn_on release dll | ||
5 | HEADERS = arrierego.h | ||
6 | |||
7 | SOURCES = arrierego.cpp | ||
8 | |||
9 | INTERFACES= | ||
10 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | ||
11 | TARGET = ArriereGo | ||
12 | LIBS += -L$(OPIEDIR)/lib -lreader_pdb -lreader_pluckerbase -lreader_codec | ||
13 | |||
14 | INCLUDEPATH+= $(OPIEDIR)/include | ||
15 | DEPENDPATH += $(OPIEDIR)/include | ||
16 | DEFINES += USENEF | ||
diff --git a/noncore/apps/opie-reader/BuffDoc.cpp b/noncore/apps/opie-reader/BuffDoc.cpp index 1f0a524..355d14d 100644 --- a/noncore/apps/opie-reader/BuffDoc.cpp +++ b/noncore/apps/opie-reader/BuffDoc.cpp | |||
@@ -1,708 +1,759 @@ | |||
1 | #include "names.h" | 1 | #include "names.h" |
2 | 2 | ||
3 | #define NEWLINEBREAK | 3 | #define NEWLINEBREAK |
4 | #define INCREMENTALWIDTH | 4 | #define INCREMENTALWIDTH |
5 | 5 | ||
6 | #include "usenef.h" | ||
7 | #include "BuffDoc.h" | 6 | #include "BuffDoc.h" |
8 | #include "config.h" | 7 | #include "config.h" |
9 | #include "CDrawBuffer.h" | 8 | #include "CDrawBuffer.h" |
10 | #include "ZText.h" | 9 | #include "ZText.h" |
11 | #include "ebookcodec.h" | 10 | #include "ebookcodec.h" |
12 | 11 | ||
13 | #ifdef __STATIC | 12 | #ifdef __STATIC |
14 | #include "Aportis.h" | 13 | #include "Aportis.h" |
15 | #include "CHM.h" | 14 | #include "CHM.h" |
16 | #include "ppm_expander.h" | 15 | #include "ppm_expander.h" |
17 | #include "ztxt.h" | 16 | #include "ztxt.h" |
18 | #include "plucker.h" | 17 | #include "plucker.h" |
19 | #ifdef USENEF | 18 | #ifdef USENEF |
20 | #include "nef.h" | 19 | #include "nef.h" |
21 | #include "arrierego.h" | 20 | #include "arrierego.h" |
22 | #endif | 21 | #endif |
23 | #include "iSilo.h" | 22 | #include "iSilo.h" |
23 | #include "Reb.h" | ||
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | 26 | ||
27 | linkType BuffDoc::hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) | 27 | linkType BuffDoc::hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) |
28 | { | 28 | { |
29 | linkType bRet = eNone; | 29 | linkType bRet = eNone; |
30 | if (exp != NULL) | 30 | if (exp != NULL) |
31 | { | 31 | { |
32 | bRet = filt->hyperlink(n, noff, wrd, nm); | 32 | bRet = filt->hyperlink(n, noff, wrd, nm); |
33 | if ((bRet & eLink) != 0) | 33 | if ((bRet & eLink) != 0) |
34 | { | 34 | { |
35 | lastword.empty(); | 35 | lastword.empty(); |
36 | lastsizes[0] = laststartline = n; | 36 | lastsizes[0] = laststartline = n; |
37 | #ifdef NEWLINEBREAK | 37 | #ifdef NEWLINEBREAK |
38 | lastispara = false; | 38 | lastispara = false; |
39 | #else | 39 | #else |
40 | lastispara = false; | 40 | lastispara = false; |
41 | #endif | 41 | #endif |
42 | lastsizes[0] = laststartline = exp->locate(); | 42 | lastsizes[0] = laststartline = exp->locate(); |
43 | } | 43 | } |
44 | } | 44 | } |
45 | return bRet; | 45 | return bRet; |
46 | } | 46 | } |
47 | 47 | ||
48 | void BuffDoc::locate(unsigned int n) | 48 | void BuffDoc::locate(unsigned int n) |
49 | { | 49 | { |
50 | // //qDebug("BuffDoc:locating:%u",n); | 50 | // //qDebug("BuffDoc:locating:%u",n); |
51 | lastword.empty(); | 51 | lastword.empty(); |
52 | lastsizes[0] = laststartline = n; | 52 | lastsizes[0] = laststartline = n; |
53 | #ifdef NEWLINEBREAK | 53 | #ifdef NEWLINEBREAK |
54 | lastispara = false; | 54 | lastispara = false; |
55 | #else | 55 | #else |
56 | lastispara = false; | 56 | lastispara = false; |
57 | #endif | 57 | #endif |
58 | // tchar linebuf[1024]; | 58 | // tchar linebuf[1024]; |
59 | if (exp != NULL) filt->locate(n); | 59 | if (exp != NULL) filt->locate(n); |
60 | // //qDebug("BuffDoc:Located"); | 60 | // //qDebug("BuffDoc:Located"); |
61 | } | 61 | } |
62 | 62 | ||
63 | void BuffDoc::resetPos() | ||
64 | { | ||
65 | // //qDebug("BuffDoc:locating:%u",n); | ||
66 | lastword.empty(); | ||
67 | lastsizes[0] = laststartline = exp->locate(); | ||
68 | #ifdef NEWLINEBREAK | ||
69 | lastispara = false; | ||
70 | #else | ||
71 | lastispara = false; | ||
72 | #endif | ||
73 | } | ||
74 | |||
63 | static bool isletter(unsigned short c) | 75 | static bool isletter(unsigned short c) |
64 | { | 76 | { |
65 | if ('a' <= c && c <= 'z') return true; | 77 | if ('a' <= c && c <= 'z') return true; |
66 | if ('A' <= c && c <= 'Z') return true; | 78 | if ('A' <= c && c <= 'Z') return true; |
67 | // Cyrillic letters | 79 | // Cyrillic letters |
68 | if (0x400 <= c && c <= 0x52F) return true; | 80 | if (0x400 <= c && c <= 0x52F) return true; |
69 | return false; | 81 | return false; |
70 | } | 82 | } |
71 | 83 | ||
72 | static bool isvowel(unsigned short c) // Only want lower case vowels | 84 | static bool isvowel(unsigned short c) // Only want lower case vowels |
73 | { | 85 | { |
74 | switch (c) | 86 | switch (c) |
75 | { | 87 | { |
76 | case 'a': | 88 | case 'a': |
77 | case 'e': | 89 | case 'e': |
78 | case 'i': | 90 | case 'i': |
79 | case 'o': | 91 | case 'o': |
80 | case 'u': | 92 | case 'u': |
81 | // Cyrillic vowels | 93 | // Cyrillic vowels |
82 | case 0x430: | 94 | case 0x430: |
83 | case 0x435: | 95 | case 0x435: |
84 | case 0x438: | 96 | case 0x438: |
85 | case 0x43E: | 97 | case 0x43E: |
86 | case 0x443: | 98 | case 0x443: |
87 | case 0x44B: | 99 | case 0x44B: |
88 | case 0x44D: | 100 | case 0x44D: |
89 | case 0x44E: | 101 | case 0x44E: |
90 | case 0x44F: | 102 | case 0x44F: |
91 | case 0x451: | 103 | case 0x451: |
92 | 104 | ||
93 | case 0x450: | 105 | case 0x450: |
94 | case 0x454: | 106 | case 0x454: |
95 | case 0x456: | 107 | case 0x456: |
96 | case 0x457: | 108 | case 0x457: |
97 | case 0x45D: | 109 | case 0x45D: |
98 | 110 | ||
99 | case 0x463: | 111 | case 0x463: |
100 | 112 | ||
101 | case 0x4AF: | 113 | case 0x4AF: |
102 | case 0x4B1: | 114 | case 0x4B1: |
103 | case 0x4D1: | 115 | case 0x4D1: |
104 | case 0x4D3: | 116 | case 0x4D3: |
105 | 117 | ||
106 | case 0x4D5: | 118 | case 0x4D5: |
107 | case 0x4D7: | 119 | case 0x4D7: |
108 | case 0x4E3: | 120 | case 0x4E3: |
109 | case 0x4E5: | 121 | case 0x4E5: |
110 | case 0x4E7: | 122 | case 0x4E7: |
111 | case 0x4E9: | 123 | case 0x4E9: |
112 | case 0x4EB: | 124 | case 0x4EB: |
113 | case 0x4ED: | 125 | case 0x4ED: |
114 | case 0x4EF: | 126 | case 0x4EF: |
115 | case 0x4F1: | 127 | case 0x4F1: |
116 | case 0x4F3: | 128 | case 0x4F3: |
117 | case 0x4F9: | 129 | case 0x4F9: |
118 | return true; | 130 | return true; |
119 | default: | 131 | default: |
120 | return ((0xe0 <= c) && (c <= 0xfc) && (c != 0xf1) && (c != 0xf7) && (c != 0xe7)); | 132 | return ((0xe0 <= c) && (c <= 0xfc) && (c != 0xf1) && (c != 0xf7) && (c != 0xe7)); |
121 | } | 133 | } |
122 | } | 134 | } |
123 | 135 | ||
124 | inline bool isconsonant(unsigned short c) | 136 | inline bool isconsonant(unsigned short c) |
125 | { | 137 | { |
126 | switch( c ) | 138 | switch( c ) |
127 | { | 139 | { |
128 | // Some cyrillic letters are neither vowels, nor consonants, or otherwise | 140 | // Some cyrillic letters are neither vowels, nor consonants, or otherwise |
129 | // the letters no word can start from. | 141 | // the letters no word can start from. |
130 | case 0x439: | 142 | case 0x439: |
131 | case 0x44A: | 143 | case 0x44A: |
132 | case 0x44C: | 144 | case 0x44C: |
133 | 145 | ||
134 | case 0x45E: | 146 | case 0x45E: |
135 | 147 | ||
136 | return false; | 148 | return false; |
137 | 149 | ||
138 | default: | 150 | default: |
139 | return (isletter(c) && !isvowel(c)); | 151 | return (isletter(c) && !isvowel(c)); |
140 | } | 152 | } |
141 | return (isletter(c) && !isvowel(c)); | 153 | return (isletter(c) && !isvowel(c)); |
142 | } | 154 | } |
143 | 155 | ||
144 | #ifdef NEWLINEBREAK | 156 | #ifdef NEWLINEBREAK |
145 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht) | 157 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht) |
146 | { | 158 | { |
147 | bool moreleft = true; | 159 | bool moreleft = true; |
148 | bool margindone = false; | 160 | bool margindone = false; |
149 | int isCentred = -1; | 161 | int isCentred = -1; |
150 | int w = wth-(_lborder+_rborder); | 162 | int w = wth-(_lborder+_rborder); |
151 | tchar ch = 32; | 163 | tchar ch = 32; |
152 | CStyle cs; | 164 | CStyle cs; |
153 | buff->empty(); | 165 | buff->empty(); |
154 | if (exp == NULL) | 166 | if (exp == NULL) |
155 | { | 167 | { |
156 | buff->empty(); | 168 | buff->empty(); |
157 | buff->setEof(); | 169 | buff->setEof(); |
158 | return false; | 170 | return false; |
159 | } | 171 | } |
160 | int len = 0; | 172 | int len = 0; |
161 | if (lastword.length() > 0) | 173 | if (lastword.length() > 0) |
162 | { | 174 | { |
163 | if (isCentred < 0) | 175 | if (isCentred < 0) |
164 | { | 176 | { |
165 | isCentred = (lastword.firststyle().getJustify() == m_AlignCentre) ? 1 : 0; | 177 | isCentred = (lastword.firststyle().getJustify() == m_AlignCentre) ? 1 : 0; |
166 | } | 178 | } |
167 | *buff = lastword; | 179 | *buff = lastword; |
168 | cs = lastword.laststyle(); | 180 | cs = lastword.laststyle(); |
169 | w -= buff->leftMargin() + buff->rightMargin(); | 181 | w -= buff->leftMargin() + buff->rightMargin(); |
170 | margindone = true; | 182 | margindone = true; |
171 | len = lastword.length(); | 183 | len = lastword.length(); |
172 | } | 184 | } |
173 | else buff->empty(); | 185 | else buff->empty(); |
174 | lastword.empty(); | 186 | lastword.empty(); |
175 | unsigned int slen = buff->width(availht, len); | 187 | unsigned int slen = buff->width(availht, len); |
176 | if (lastispara) buff->setstartpara(); | 188 | if (lastispara) buff->setstartpara(); |
177 | int nospaces = 0; | 189 | int nospaces = 0; |
178 | while (1) | 190 | while (1) |
179 | { | 191 | { |
180 | getch(ch, cs, lastsizes[len]); | 192 | getch(ch, cs, lastsizes[len]); |
181 | if (isCentred < 0) | 193 | if (isCentred < 0) |
182 | { | 194 | { |
183 | isCentred = (cs.getJustify() == m_AlignCentre) ? 1 : 0; | 195 | isCentred = (cs.getJustify() == m_AlignCentre) ? 1 : 0; |
184 | } | 196 | } |
185 | if (ch == 10 && len == 0 && !lastispara) | 197 | if (ch == 10 && len == 0 && !lastispara) |
186 | { | 198 | { |
187 | getch(ch, cs, lastsizes[len]); | 199 | getch(ch, cs, lastsizes[len]); |
188 | buff->setstartpara(); | 200 | buff->setstartpara(); |
189 | } | 201 | } |
190 | if (ch == UEOF) | 202 | if (ch == UEOF) |
191 | { | 203 | { |
192 | buff->setendpara(cs); | 204 | buff->setendpara(cs); |
193 | if (len == 0) | 205 | if (len == 0) |
194 | { | 206 | { |
195 | buff->setEof(); | 207 | buff->setEof(); |
196 | moreleft = false; | 208 | moreleft = false; |
197 | } | 209 | } |
198 | laststartline = exp->locate(); | 210 | laststartline = exp->locate(); |
199 | break; | 211 | break; |
200 | } | 212 | } |
201 | if (ch == 10) | 213 | if (ch == 10) |
202 | { | 214 | { |
203 | buff->setendpara(cs); | 215 | buff->setendpara(cs); |
204 | lastispara = true; | 216 | lastispara = true; |
205 | laststartline = exp->locate(); | 217 | laststartline = exp->locate(); |
206 | break; | 218 | break; |
207 | } | 219 | } |
208 | if (ch == 6) | 220 | if (ch == 6) |
209 | { | 221 | { |
210 | buff->setendpara(cs); | 222 | buff->setendpara(cs); |
211 | buff->setBop(); | 223 | buff->setBop(); |
212 | lastispara = true; | 224 | lastispara = true; |
213 | laststartline = exp->locate(); | 225 | laststartline = exp->locate(); |
214 | break; | 226 | break; |
215 | } | 227 | } |
216 | lastispara = false; | 228 | lastispara = false; |
217 | buff->addch(ch, cs); | 229 | buff->addch(ch, cs); |
218 | if (ch == ' ') | 230 | if (ch == ' ') |
219 | { | 231 | { |
220 | nospaces++; | 232 | nospaces++; |
221 | } | 233 | } |
222 | len++; | 234 | len++; |
223 | if (!margindone) | 235 | if (!margindone) |
224 | { | 236 | { |
225 | w -= buff->leftMargin() + buff->rightMargin(); | 237 | w -= buff->leftMargin() + buff->rightMargin(); |
226 | margindone = true; | 238 | margindone = true; |
227 | } | 239 | } |
228 | #ifdef INCREMENTALWIDTH | 240 | #ifdef INCREMENTALWIDTH |
229 | if ((slen += buff->charwidth(len-1, cs)) > w) | 241 | if ((slen += buff->charwidth(len-1, cs)) > w) |
230 | #else | 242 | #else |
231 | if ((slen = buff->width(availht, len)) > w) | 243 | if ((slen = buff->width(availht, len)) > w) |
232 | #endif | 244 | #endif |
233 | { | 245 | { |
234 | if (ch == ' ' || len == 1) | 246 | if (ch == ' ' || len == 1) |
235 | { | 247 | { |
236 | if (ch == ' ') buff->truncate(len-1); | 248 | if (ch == ' ') buff->truncate(len-1); |
237 | laststartline = exp->locate(); | 249 | laststartline = exp->locate(); |
238 | break; | 250 | break; |
239 | } | 251 | } |
240 | else // should do a backward search for spaces, first. | 252 | else // should do a backward search for spaces, first. |
241 | { | 253 | { |
242 | int lastk = len-4; | 254 | int lastk = len-4; |
243 | for (int i = len-2; i > 0; i--) | 255 | for (int i = len-2; i > 0; i--) |
244 | { | 256 | { |
245 | if ( | 257 | if ( |
246 | (((*buff)[i] == 0x2014) && isletter((*buff)[i+1])) | 258 | (((*buff)[i] == 0x2014) && isletter((*buff)[i+1])) |
247 | || | 259 | || |
248 | ((*buff)[i] == '-') | 260 | ((*buff)[i] == '-') |
249 | // ((*buff)[i] == '-' && !(((*buff)[i-1] == '-') || ((*buff)[i+1] == '-'))) | 261 | // ((*buff)[i] == '-' && !(((*buff)[i-1] == '-') || ((*buff)[i+1] == '-'))) |
250 | ) | 262 | ) |
251 | { | 263 | { |
252 | (*buff)[len] = 0; | 264 | (*buff)[len] = 0; |
253 | lastword.setright(*buff, i+1); | 265 | lastword.setright(*buff, i+1); |
254 | buff->truncate(i+1); | 266 | buff->truncate(i+1); |
255 | (*buff)[i+1] = '\0'; | 267 | (*buff)[i+1] = '\0'; |
256 | laststartline = lastsizes[i+1]; | 268 | laststartline = lastsizes[i+1]; |
257 | // buff->resize(); | 269 | // buff->resize(); |
258 | for (int j = 0; j < lastword.length(); j++) | 270 | for (int j = 0; j < lastword.length(); j++) |
259 | { | 271 | { |
260 | lastsizes[j] = lastsizes[j+i+1]; | 272 | lastsizes[j] = lastsizes[j+i+1]; |
261 | } | 273 | } |
262 | return true; | 274 | return true; |
263 | } | 275 | } |
264 | 276 | ||
265 | //if (hyphenate && (m_hyphenthreshold+1)*i < m_hyphenthreshold*len) | 277 | //if (hyphenate && (m_hyphenthreshold+1)*i < m_hyphenthreshold*len) |
266 | // We end up with i+1 characters instead of len-1 | 278 | // We end up with i+1 characters instead of len-1 |
267 | // Thus we are removing len - 1 - (i + 1) = len-i-2 | 279 | // Thus we are removing len - 1 - (i + 1) = len-i-2 |
268 | // The space characters will be stretched to cover | 280 | // The space characters will be stretched to cover |
269 | // nospaces to nospaces + len - i - 2 | 281 | // nospaces to nospaces + len - i - 2 |
270 | // The stretch factor is hence | 282 | // The stretch factor is hence |
271 | // (nospaces+len-i-2)/nospaces | 283 | // (nospaces+len-i-2)/nospaces |
272 | if (hyphenate && !isCentred && ( 100*(nospaces+len-i-2) > (100+m_hyphenthreshold)*nospaces )) | 284 | if (hyphenate && !isCentred && ( 100*(nospaces+len-i-2) > (100+m_hyphenthreshold)*nospaces )) |
273 | { | 285 | { |
274 | /* | 286 | /* |
275 | if (m_customhyphen) | 287 | if (m_customhyphen) |
276 | { | 288 | { |
277 | for (int k = lastk; k >= i && k >= 2; k--) | 289 | for (int k = lastk; k >= i && k >= 2; k--) |
278 | { | 290 | { |
279 | if ( | 291 | if ( |
280 | isletter((*buff)[k+3]) | 292 | isletter((*buff)[k+3]) |
281 | && | 293 | && |
282 | isletter((*buff)[k+2]) | 294 | isletter((*buff)[k+2]) |
283 | && | 295 | && |
284 | isvowel((*buff)[k+1]) | 296 | isvowel((*buff)[k+1]) |
285 | && | 297 | && |
286 | isconsonant((*buff)[k]) | 298 | isconsonant((*buff)[k]) |
287 | && | 299 | && |
288 | isletter((*buff)[k-1]) | 300 | isletter((*buff)[k-1]) |
289 | && | 301 | && |
290 | isletter((*buff)[k-2]) | 302 | isletter((*buff)[k-2]) |
291 | ) | 303 | ) |
292 | { | 304 | { |
293 | (*buff)[len] = 0; | 305 | (*buff)[len] = 0; |
294 | lastword.setright(*buff, k+1); | 306 | lastword.setright(*buff, k+1); |
295 | buff->truncate(k+2); | 307 | buff->truncate(k+2); |
296 | (*buff)[k+1] = '-'; | 308 | (*buff)[k+1] = '-'; |
297 | (*buff)[k+2] = '\0'; | 309 | (*buff)[k+2] = '\0'; |
298 | laststartline = lastsizes[k+1]; | 310 | laststartline = lastsizes[k+1]; |
299 | buff->resize(); | 311 | buff->resize(); |
300 | for (int j = 0; j < lastword.length(); j++) | 312 | for (int j = 0; j < lastword.length(); j++) |
301 | { | 313 | { |
302 | lastsizes[j] = lastsizes[j+k+1]; | 314 | lastsizes[j] = lastsizes[j+k+1]; |
303 | } | 315 | } |
304 | return true; | 316 | return true; |
305 | } | 317 | } |
306 | } | 318 | } |
307 | } | 319 | } |
308 | else | 320 | else |
309 | */ | 321 | */ |
310 | { | 322 | { |
311 | for (int k = lastk; k >= i && k >= 1; k--) | 323 | for (int k = lastk; k >= i && k >= 1; k--) |
312 | { | 324 | { |
313 | if ( | 325 | if ( |
314 | /* | 326 | /* |
315 | ( | 327 | ( |
316 | k < len-3 | 328 | k < len-3 |
317 | && | 329 | && |
318 | k >= 1 | 330 | k >= 1 |
319 | && | 331 | && |
320 | isletter((*buff)[k+3]) | 332 | isletter((*buff)[k+3]) |
321 | && | 333 | && |
322 | isletter((*buff)[k+2]) | 334 | isletter((*buff)[k+2]) |
323 | && | 335 | && |
324 | isconsonant((*buff)[k+1]) | 336 | isconsonant((*buff)[k+1]) |
325 | && | 337 | && |
326 | ((*buff)[k+1] != 'y') | 338 | ((*buff)[k+1] != 'y') |
327 | && | 339 | && |
328 | ((*buff)[k+1] != 'h') | 340 | ((*buff)[k+1] != 'h') |
329 | && | 341 | && |
330 | isconsonant((*buff)[k]) | 342 | isconsonant((*buff)[k]) |
331 | && | 343 | && |
332 | ((*buff)[k] != 'h') | 344 | ((*buff)[k] != 'h') |
333 | && | 345 | && |
334 | isletter((*buff)[k-1]) | 346 | isletter((*buff)[k-1]) |
335 | ) | 347 | ) |
336 | || | 348 | || |
337 | */ | 349 | */ |
338 | ( | 350 | ( |
339 | isletter((*buff)[k+3]) | 351 | isletter((*buff)[k+3]) |
340 | && | 352 | && |
341 | isletter((*buff)[k+2]) | 353 | isletter((*buff)[k+2]) |
342 | && | 354 | && |
343 | isconsonant((*buff)[k+1]) | 355 | isconsonant((*buff)[k+1]) |
344 | && | 356 | && |
345 | ((*buff)[k+1] != 'y') | 357 | ((*buff)[k+1] != 'y') |
346 | && | 358 | && |
347 | isletter((*buff)[k]) | 359 | isletter((*buff)[k]) |
348 | && | 360 | && |
349 | ((*buff)[k] != 'h') | 361 | ((*buff)[k] != 'h') |
350 | && | 362 | && |
351 | isletter((*buff)[k-1]) | 363 | isletter((*buff)[k-1]) |
352 | && // Do not hyphenate when the first part ends with a vowel, | 364 | && // Do not hyphenate when the first part ends with a vowel, |
353 | // and the second starts with the two consonants. | 365 | // and the second starts with the two consonants. |
354 | // Examples: "co-nsona-nts" -> "con-sonants", | 366 | // Examples: "co-nsona-nts" -> "con-sonants", |
355 | // "hy-phenation" -> "hyp-henation" etc. | 367 | // "hy-phenation" -> "hyp-henation" etc. |
356 | !( isvowel( (*buff)[k] ) && isconsonant( (*buff)[k+2] ) ) | 368 | !( isvowel( (*buff)[k] ) && isconsonant( (*buff)[k+2] ) ) |
357 | ) | 369 | ) |
358 | ) | 370 | ) |
359 | { | 371 | { |
360 | (*buff)[len] = 0; | 372 | (*buff)[len] = 0; |
361 | lastword.setright(*buff, k+1); | 373 | lastword.setright(*buff, k+1); |
362 | buff->truncate(k+2); | 374 | buff->truncate(k+2); |
363 | (*buff)[k+1] = '-'; | 375 | (*buff)[k+1] = '-'; |
364 | (*buff)[k+2] = '\0'; | 376 | (*buff)[k+2] = '\0'; |
365 | laststartline = lastsizes[k+1]; | 377 | laststartline = lastsizes[k+1]; |
366 | // buff->resize(); | 378 | // buff->resize(); |
367 | for (int j = 0; j < lastword.length(); j++) | 379 | for (int j = 0; j < lastword.length(); j++) |
368 | { | 380 | { |
369 | lastsizes[j] = lastsizes[j+k+1]; | 381 | lastsizes[j] = lastsizes[j+k+1]; |
370 | } | 382 | } |
371 | return true; | 383 | return true; |
372 | } | 384 | } |
373 | } | 385 | } |
374 | } | 386 | } |
375 | lastk = i; | 387 | lastk = i; |
376 | } | 388 | } |
377 | if ((*buff)[i] == ' ') | 389 | if ((*buff)[i] == ' ') |
378 | { | 390 | { |
379 | (*buff)[len] = 0; | 391 | (*buff)[len] = 0; |
380 | lastword.setright(*buff, i+1); | 392 | lastword.setright(*buff, i+1); |
381 | buff->truncate(i); | 393 | buff->truncate(i); |
382 | (*buff)[i] = '\0'; | 394 | (*buff)[i] = '\0'; |
383 | laststartline = lastsizes[i+1]; | 395 | laststartline = lastsizes[i+1]; |
384 | // buff->resize(); | 396 | // buff->resize(); |
385 | for (int j = 0; j < lastword.length(); j++) | 397 | for (int j = 0; j < lastword.length(); j++) |
386 | { | 398 | { |
387 | lastsizes[j] = lastsizes[j+i+1]; | 399 | lastsizes[j] = lastsizes[j+i+1]; |
388 | } | 400 | } |
389 | return true; | 401 | return true; |
390 | } | 402 | } |
391 | } | 403 | } |
392 | laststartline = lastsizes[len-1]; | 404 | laststartline = lastsizes[len-1]; |
393 | (*buff)[len] = 0; | 405 | (*buff)[len] = 0; |
394 | lastword.setright(*buff, len - 1); | 406 | lastword.setright(*buff, len - 1); |
395 | buff->truncate(len-1); | 407 | buff->truncate(len-1); |
396 | buff->addch('-', cs); | 408 | buff->addch('-', cs); |
397 | for (int j = 0; j < lastword.length(); j++) | 409 | for (int j = 0; j < lastword.length(); j++) |
398 | { | 410 | { |
399 | lastsizes[j] = lastsizes[j+len]; | 411 | lastsizes[j] = lastsizes[j+len]; |
400 | } | 412 | } |
401 | break; | 413 | break; |
402 | } | 414 | } |
403 | } | 415 | } |
404 | } | 416 | } |
405 | (*buff)[len] = '\0'; | 417 | (*buff)[len] = '\0'; |
406 | // buff->resize(); | 418 | // buff->resize(); |
407 | return moreleft; | 419 | return moreleft; |
408 | } | 420 | } |
409 | #else | 421 | #else |
410 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned short _lborder, unsigned short _rborder) | 422 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned short _lborder, unsigned short _rborder) |
411 | { | 423 | { |
412 | bool margindone = false; | 424 | bool margindone = false; |
413 | int w = wth-(_lborder+_rborder); | 425 | int w = wth-(_lborder+_rborder); |
414 | tchar ch = 32; | 426 | tchar ch = 32; |
415 | CStyle cs; | 427 | CStyle cs; |
416 | buff->empty(); | 428 | buff->empty(); |
417 | if (exp == NULL) | 429 | if (exp == NULL) |
418 | { | 430 | { |
419 | //(*buff)[0] = '\0'; | 431 | //(*buff)[0] = '\0'; |
420 | buff->empty(); | 432 | buff->empty(); |
421 | return false; | 433 | return false; |
422 | } | 434 | } |
423 | int len = 0, lastcheck = 0; | 435 | int len = 0, lastcheck = 0; |
424 | if (lastword.length() > 0) | 436 | if (lastword.length() > 0) |
425 | { | 437 | { |
426 | *buff = lastword; | 438 | *buff = lastword; |
427 | cs = lastword.laststyle(); | 439 | cs = lastword.laststyle(); |
428 | w -= buff->leftMargin() + buff->rightMargin(); | 440 | w -= buff->leftMargin() + buff->rightMargin(); |
429 | margindone = true; | 441 | margindone = true; |
430 | } | 442 | } |
431 | else buff->empty(); | 443 | else buff->empty(); |
432 | // //qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); | 444 | // //qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); |
433 | lastcheck = len = buff->length(); | 445 | lastcheck = len = buff->length(); |
434 | unsigned int slen = buff->width(availht, len); | 446 | unsigned int slen = buff->width(availht, len); |
435 | if (slen > w) | 447 | if (slen > w) |
436 | { | 448 | { |
437 | for ( ; len > 1; len--) | 449 | for ( ; len > 1; len--) |
438 | { | 450 | { |
439 | if (buff->width(availht, len) < w) break; | 451 | if (buff->width(availht, len) < w) break; |
440 | } | 452 | } |
441 | // lastword = buff->data() + len - 1; | 453 | // lastword = buff->data() + len - 1; |
442 | laststartline = lastsizes[len-1]; | 454 | laststartline = lastsizes[len-1]; |
443 | for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1]; | 455 | for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1]; |
444 | // (*buff)[len-1] = '-'; | 456 | // (*buff)[len-1] = '-'; |
445 | if (len > 2) | 457 | if (len > 2) |
446 | { | 458 | { |
447 | lastword.setright(*buff, len - 1); | 459 | lastword.setright(*buff, len - 1); |
448 | buff->truncate(len-1); | 460 | buff->truncate(len-1); |
449 | buff->addch('-', cs); | 461 | buff->addch('-', cs); |
450 | (*buff)[len] = '\0'; | 462 | (*buff)[len] = '\0'; |
451 | } | 463 | } |
452 | 464 | ||
453 | else | 465 | else |
454 | { | 466 | { |
455 | lastword.empty(); | 467 | lastword.empty(); |
456 | (*buff)[len] = '\0'; | 468 | (*buff)[len] = '\0'; |
457 | } | 469 | } |
458 | // buff->resize(); | 470 | // buff->resize(); |
459 | return true; | 471 | return true; |
460 | } | 472 | } |
461 | if (lastispara) | 473 | if (lastispara) |
462 | { | 474 | { |
463 | lastispara = false; | 475 | lastispara = false; |
464 | // lastword[0] = '\0'; | 476 | // lastword[0] = '\0'; |
465 | lastword.empty(); | 477 | lastword.empty(); |
466 | len = buff->length(); | 478 | len = buff->length(); |
467 | while (buff->width(availht, len) > w) len--; | 479 | while (buff->width(availht, len) > w) len--; |
468 | // (*buff)[len] = '\0'; | 480 | // (*buff)[len] = '\0'; |
469 | buff->truncate(len); | 481 | buff->truncate(len); |
470 | laststartline = exp->locate(); | 482 | laststartline = exp->locate(); |
471 | // buff->resize(); | 483 | // buff->resize(); |
472 | return true; | 484 | return true; |
473 | } | 485 | } |
474 | lastispara = false; | 486 | lastispara = false; |
475 | for (int i = 0; i < len; i++) allsizes[i] = lastsizes[i]; | 487 | for (int i = 0; i < len; i++) allsizes[i] = lastsizes[i]; |
476 | while (slen < w) | 488 | while (slen < w) |
477 | { | 489 | { |
478 | lastcheck = len; | 490 | lastcheck = len; |
479 | getch(ch, cs, allsizes[len]); | 491 | getch(ch, cs, allsizes[len]); |
480 | while (ch != ' ' && ch != '\012' && ch != UEOF && len < 128) | 492 | while (ch != ' ' && ch != '\012' && ch != UEOF && len < 128) |
481 | { | 493 | { |
482 | len++; | 494 | len++; |
483 | buff->addch(ch,cs); | 495 | buff->addch(ch,cs); |
484 | getch(ch, cs, allsizes[len]); | 496 | getch(ch, cs, allsizes[len]); |
485 | } | 497 | } |
486 | (*buff)[len] = 0; | 498 | (*buff)[len] = 0; |
487 | slen = buff->width(availht, len); | 499 | slen = buff->width(availht, len); |
488 | len++; | 500 | len++; |
489 | buff->addch(' ', cs); | 501 | buff->addch(' ', cs); |
490 | if (!margindone) | 502 | if (!margindone) |
491 | { | 503 | { |
492 | w -= buff->leftMargin() + buff->rightMargin(); | 504 | w -= buff->leftMargin() + buff->rightMargin(); |
493 | margindone = true; | 505 | margindone = true; |
494 | } | 506 | } |
495 | allsizes[len] = exp->locate(); | 507 | allsizes[len] = exp->locate(); |
496 | if (slen < w && ch != ' ') | 508 | if (slen < w && ch != ' ') |
497 | { | 509 | { |
498 | lastcheck = len; | 510 | lastcheck = len; |
499 | break; | 511 | break; |
500 | } | 512 | } |
501 | lastispara = (ch == '\012'); | 513 | lastispara = (ch == '\012'); |
502 | } | 514 | } |
503 | (*buff)[len] = '\0'; | 515 | (*buff)[len] = '\0'; |
504 | // lastword = buff->data()+lastcheck; | 516 | // lastword = buff->data()+lastcheck; |
505 | #ifdef _WINDOWS | 517 | #ifdef _WINDOWS |
506 | lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); | 518 | lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); |
507 | { | 519 | { |
508 | int i; | 520 | int i; |
509 | for (i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; | 521 | for (i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; |
510 | } | 522 | } |
511 | #else | 523 | #else |
512 | lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); | 524 | lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); |
513 | for (int i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; | 525 | for (int i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; |
514 | #endif | 526 | #endif |
515 | if (lastcheck > 0) | 527 | if (lastcheck > 0) |
516 | { | 528 | { |
517 | laststartline = allsizes[lastcheck]; | 529 | laststartline = allsizes[lastcheck]; |
518 | // (*buff)[lastcheck-1] = '\0'; | 530 | // (*buff)[lastcheck-1] = '\0'; |
519 | buff->truncate(lastcheck-1); | 531 | buff->truncate(lastcheck-1); |
520 | } | 532 | } |
521 | else | 533 | else |
522 | { | 534 | { |
523 | laststartline = (lastcheck == len) ? exp->locate() : allsizes[lastcheck+1]; | 535 | laststartline = (lastcheck == len) ? exp->locate() : allsizes[lastcheck+1]; |
524 | // (*buff)[lastcheck] = '\0'; | 536 | // (*buff)[lastcheck] = '\0'; |
525 | buff->truncate(lastcheck); | 537 | buff->truncate(lastcheck); |
526 | } | 538 | } |
527 | // buff->frig(); | 539 | // buff->frig(); |
528 | // buff->resize(); | 540 | // buff->resize(); |
529 | if (ch == UEOF && buff->length() == 0) | 541 | if (ch == UEOF && buff->length() == 0) |
530 | { | 542 | { |
531 | buff->setEof(); | 543 | buff->setEof(); |
532 | return false; | 544 | return false; |
533 | } | 545 | } |
534 | return true; | 546 | return true; |
535 | } | 547 | } |
536 | #endif | 548 | #endif |
537 | 549 | ||
538 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw, unsigned short _lborder, unsigned short _rborder, int availht) | 550 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw, unsigned short _lborder, unsigned short _rborder, int availht) |
539 | { | 551 | { |
540 | int w = wth-(_lborder+_rborder); | 552 | int w = wth-(_lborder+_rborder); |
541 | buff->empty(); | 553 | buff->empty(); |
542 | if (exp == NULL) | 554 | if (exp == NULL) |
543 | { | 555 | { |
544 | return false; | 556 | return false; |
545 | } | 557 | } |
546 | tchar ch; | 558 | tchar ch; |
547 | CStyle cs; | 559 | CStyle cs; |
548 | int i = 1; | 560 | int i = 1; |
549 | int offset = buff->offset(w,0,0,availht); | 561 | int offset = buff->offset(w,0,0,availht); |
550 | while (i*cw < w-offset) | 562 | while (i*cw < w-offset) |
551 | { | 563 | { |
552 | unsigned long dummy; | 564 | unsigned long dummy; |
553 | getch(ch, cs, dummy); | 565 | getch(ch, cs, dummy); |
554 | if (ch == '\12' || ch == UEOF) break; | 566 | if (ch == '\12' || ch == UEOF) break; |
555 | buff->addch(ch,cs); | 567 | buff->addch(ch,cs); |
556 | i++; | 568 | i++; |
557 | } | 569 | } |
558 | buff->truncate(i); | 570 | buff->truncate(i); |
559 | laststartline = exp->locate(); | 571 | laststartline = exp->locate(); |
560 | // buff->resize(); | 572 | // buff->resize(); |
561 | return (ch != UEOF); | 573 | return (ch != UEOF); |
562 | } | 574 | } |
563 | 575 | ||
564 | int BuffDoc::openfile(QWidget* _parent, const char *src) | 576 | int BuffDoc::openfile(QWidget* _parent, const char *src) |
565 | { | 577 | { |
566 | if (exp != NULL) delete exp; | 578 | if (exp != NULL) delete exp; |
567 | exp = NULL; | 579 | exp = NULL; |
568 | 580 | ||
569 | #ifdef __STATIC | 581 | #ifdef __STATIC |
570 | exp = new Aportis; | 582 | exp = new Aportis; |
571 | int ret = exp->openfile(src); | 583 | int ret = exp->openfile(src); |
572 | if (ret == -1) | 584 | if (ret == -1) |
573 | { | 585 | { |
574 | delete exp; | 586 | delete exp; |
575 | exp = NULL; | 587 | exp = NULL; |
576 | return ret; | 588 | return ret; |
577 | } | 589 | } |
578 | if (ret == -2) | 590 | if (ret == -2) |
579 | { | 591 | { |
580 | 592 | ||
581 | delete exp; | 593 | delete exp; |
582 | exp = new ztxt; | 594 | exp = new ztxt; |
583 | ret = exp->openfile(src); | 595 | ret = exp->openfile(src); |
584 | } | 596 | } |
585 | /* | 597 | /* |
586 | } | 598 | } |
587 | if (ret != 0) | 599 | if (ret != 0) |
588 | { | 600 | { |
589 | delete exp; | 601 | delete exp; |
590 | exp = new ebookcodec("Aportis"); | 602 | exp = new ebookcodec("Aportis"); |
591 | ret = exp->openfile(src); | 603 | ret = exp->openfile(src); |
592 | if (ret == 0) qDebug("Aportis format"); | 604 | if (ret == 0) qDebug("Aportis format"); |
593 | } | 605 | } |
594 | */ | 606 | */ |
595 | #ifdef USENEF | 607 | #ifdef USENEF |
596 | if (ret != 0) | 608 | if (ret != 0) |
597 | { | 609 | { |
598 | 610 | ||
599 | delete exp; | 611 | delete exp; |
600 | exp = new CArriere; | 612 | exp = new CArriere; |
601 | ret = exp->openfile(src); | 613 | ret = exp->openfile(src); |
602 | if (ret == 0) qDebug("Arriere format"); | 614 | if (ret == 0) qDebug("Arriere format"); |
603 | } | 615 | } |
604 | if (ret != 0) | 616 | if (ret != 0) |
605 | { | 617 | { |
606 | 618 | ||
607 | delete exp; | 619 | delete exp; |
608 | exp = new CNEF; | 620 | exp = new CNEF; |
609 | ret = exp->openfile(src); | 621 | ret = exp->openfile(src); |
610 | if (ret == 0) qDebug("NEF format"); | 622 | if (ret == 0) qDebug("NEF format"); |
611 | } | 623 | } |
612 | #endif | 624 | #endif |
613 | if (ret != 0) | 625 | if (ret != 0) |
614 | { | 626 | { |
615 | 627 | ||
616 | delete exp; | 628 | delete exp; |
617 | exp = new CPlucker; | 629 | exp = new CPlucker; |
618 | ret = exp->openfile(src); | 630 | ret = exp->openfile(src); |
619 | } | 631 | } |
620 | if (ret != 0) | 632 | if (ret != 0) |
621 | { | 633 | { |
622 | 634 | ||
623 | delete exp; | 635 | delete exp; |
624 | exp = new CHM; | 636 | exp = new CHM; |
625 | ret = exp->openfile(src); | 637 | ret = exp->openfile(src); |
626 | } | 638 | } |
627 | if (ret != 0) | 639 | if (ret != 0) |
628 | { | 640 | { |
629 | 641 | ||
630 | delete exp; | 642 | delete exp; |
631 | exp = new iSilo; | 643 | exp = new iSilo; |
632 | ret = exp->openfile(src); | 644 | ret = exp->openfile(src); |
633 | } | 645 | } |
634 | if (ret != 0) | 646 | if (ret != 0) |
635 | { | 647 | { |
636 | delete exp; | 648 | delete exp; |
637 | //qDebug("Trying ppms"); | 649 | //qDebug("Trying ppms"); |
650 | exp = new CReb; | ||
651 | ret = exp->openfile(src); | ||
652 | } | ||
653 | if (ret != 0) | ||
654 | { | ||
655 | delete exp; | ||
656 | //qDebug("Trying ppms"); | ||
638 | exp = new ppm_expander; | 657 | exp = new ppm_expander; |
639 | ret = exp->openfile(src); | 658 | ret = exp->openfile(src); |
640 | } | 659 | } |
641 | if (ret != 0) | 660 | if (ret != 0) |
642 | { | 661 | { |
643 | delete exp; | 662 | delete exp; |
644 | exp = new Text; | 663 | exp = new Text; |
645 | // //qDebug("Trying text"); | 664 | // //qDebug("Trying text"); |
646 | ret = exp->openfile(src); | 665 | ret = exp->openfile(src); |
647 | if (ret == 0) qDebug("Text format"); | 666 | if (ret == 0) qDebug("Text format"); |
648 | } | 667 | } |
649 | 668 | ||
650 | if (ret != 0) | 669 | if (ret != 0) |
651 | { | 670 | { |
652 | delete exp; | 671 | delete exp; |
653 | QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file"); | 672 | QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file"); |
654 | return ret; | 673 | return ret; |
655 | } | 674 | } |
656 | // //qDebug("Doing final open:%x:%x",exp,filt); | 675 | // //qDebug("Doing final open:%x:%x",exp,filt); |
657 | #else | 676 | #else |
658 | QString codecpath(QTReaderUtil::getPluginPath()); | 677 | #ifdef USEQPE |
678 | #ifdef OPIE | ||
679 | QString codecpath(getenv("OPIEDIR")); | ||
680 | #else | ||
681 | QString codecpath(getenv("QTDIR")); | ||
682 | #endif | ||
683 | codecpath += "/plugins/reader/codecs"; | ||
684 | #else | ||
685 | QString codecpath(getenv("READERDIR")); | ||
686 | codecpath += "/codecs"; | ||
687 | #endif | ||
659 | QDir d(codecpath, "*.so"); | 688 | QDir d(codecpath, "*.so"); |
660 | 689 | ||
661 | if (d.exists()) | 690 | if (d.exists()) |
662 | { | 691 | { |
663 | 692 | ||
664 | const QFileInfoList *list = d.entryInfoList(); | 693 | const QFileInfoList *list = d.entryInfoList(); |
665 | QFileInfoListIterator it( *list ); // create list iterator | 694 | QFileInfoListIterator it( *list ); // create list iterator |
666 | QFileInfo *fi; // pointer for traversing | 695 | QFileInfo *fi; // pointer for traversing |
667 | 696 | ||
668 | int ret = -1; | 697 | int ret = -1; |
669 | while ( ret != 0 && (fi=it.current()) ) | 698 | while ( ret != 0 && (fi=it.current()) ) |
670 | { // for each file... | 699 | { // for each file... |
671 | if (exp != NULL) delete exp; | 700 | if (exp != NULL) delete exp; |
672 | qDebug("Trying %s", (const char*)fi->fileName()); | 701 | qDebug("Trying %s", (const char*)fi->fileName()); |
673 | exp = new ebookcodec(fi->fileName()); | 702 | exp = new ebookcodec(fi->fileName()); |
674 | ret = exp->openfile(src); | 703 | ret = exp->openfile(src); |
675 | ++it; | 704 | ++it; |
676 | } | 705 | } |
677 | qDebug("Buffdoc:Finished opening"); | 706 | qDebug("Buffdoc:Finished opening"); |
678 | if (ret != 0) | 707 | if (ret != 0) |
679 | { | 708 | { |
680 | if (exp != NULL) delete exp; | 709 | if (exp != NULL) delete exp; |
681 | exp = new Text; | 710 | exp = new Text; |
682 | ret = exp->openfile(src); | 711 | ret = exp->openfile(src); |
683 | } | 712 | } |
684 | } | 713 | } |
685 | else | 714 | else |
686 | { | 715 | { |
687 | if (exp != NULL) delete exp; | 716 | if (exp != NULL) delete exp; |
688 | exp = new Text; | 717 | exp = new Text; |
689 | exp->openfile(src); | 718 | exp->openfile(src); |
690 | } | 719 | } |
691 | #endif | 720 | #endif |
692 | lastword.empty(); | 721 | lastword.empty(); |
693 | lastsizes[0] = laststartline = 0; | 722 | lastsizes[0] = laststartline = 0; |
694 | #ifdef NEWLINEBREAK | 723 | #ifdef NEWLINEBREAK |
695 | lastispara = false; | 724 | lastispara = false; |
696 | #else | 725 | #else |
697 | lastispara = false; | 726 | lastispara = false; |
698 | #endif | 727 | #endif |
699 | exp->locate(exp->getHome()); | 728 | exp->locate(exp->getHome()); |
700 | filt->setsource(exp); | 729 | filt->setsource(exp); |
701 | qDebug("BuffDoc:file opened"); | 730 | qDebug("BuffDoc:file opened"); |
702 | return 0; | 731 | return 0; |
703 | } | 732 | } |
704 | 733 | ||
705 | QString BuffDoc::about() | 734 | QString BuffDoc::about() |
706 | { | 735 | { |
707 | return QString("Buffered Decompressor (c) Tim Wentford\nHyphenation algorithm (c) Tim Wentford\n (Cyrillic support by Konstantin Isakov\n")+filt->about(); | 736 | return QString("Buffered Decompressor (c) Tim Wentford\nHyphenation algorithm (c) Tim Wentford\n (Cyrillic support by Konstantin Isakov\n")+filt->about(); |
708 | } | 737 | } |
738 | |||
739 | int BuffDoc::getsentence(CBuffer& buff) | ||
740 | { | ||
741 | tchar ch; | ||
742 | int i = 0; | ||
743 | bool intext = false; | ||
744 | while ((ch = getch()) != 10 && ch != UEOF) | ||
745 | { | ||
746 | buff[i++] = ch; | ||
747 | if (ch == '"' || ch == '\'' || ch == 0x2018 || ch == 0x2019 || | ||
748 | ch == 0x201a || ch == 0x201b || ch == 0x201c || ch == 0x201d) | ||
749 | { | ||
750 | intext = !intext; | ||
751 | } | ||
752 | if (!intext && (ch == '.' || ch == '!' || ch == '?')) break; | ||
753 | } | ||
754 | |||
755 | buff[i] = '\0'; | ||
756 | if (i == 0 && ch == UEOF) i = -1; | ||
757 | laststartline = exp->locate(); | ||
758 | return i; | ||
759 | } | ||
diff --git a/noncore/apps/opie-reader/BuffDoc.h b/noncore/apps/opie-reader/BuffDoc.h index 2b4fb57..d6bfd99 100644 --- a/noncore/apps/opie-reader/BuffDoc.h +++ b/noncore/apps/opie-reader/BuffDoc.h | |||
@@ -1,143 +1,158 @@ | |||
1 | #ifndef __BuffDoc_h | 1 | #ifndef __BuffDoc_h |
2 | #define __BuffDoc_h | 2 | #define __BuffDoc_h |
3 | 3 | ||
4 | #include "CDrawBuffer.h" | 4 | #include "CDrawBuffer.h" |
5 | #include "CFilter.h" | 5 | #include "CFilter.h" |
6 | #include "CExpander.h" | 6 | #include "CExpander.h" |
7 | #include <qfontmetrics.h> | 7 | #include <qfontmetrics.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | 9 | ||
10 | class BuffDoc | 10 | class BuffDoc |
11 | { | 11 | { |
12 | CDrawBuffer lastword; | 12 | CDrawBuffer lastword; |
13 | CSizeBuffer lastsizes, allsizes; | 13 | CSizeBuffer lastsizes, allsizes; |
14 | size_t laststartline; | 14 | size_t laststartline; |
15 | bool lastispara; | 15 | bool lastispara; |
16 | CExpander_Interface* exp; | 16 | CExpander_Interface* exp; |
17 | CFilterChain* filt; | 17 | CFilterChain* filt; |
18 | int m_hyphenthreshold; | 18 | int m_hyphenthreshold; |
19 | // bool m_customhyphen; | 19 | // bool m_customhyphen; |
20 | public: | 20 | public: |
21 | QString about(); | 21 | QString about(); |
22 | bool findanchor(const QString& nm) | 22 | bool findanchor(const QString& nm) |
23 | { | 23 | { |
24 | return filt->findanchor(nm); | 24 | return filt->findanchor(nm); |
25 | } | 25 | } |
26 | // void setCustomHyphen(bool _v) { m_customhyphen = _v; } | 26 | // void setCustomHyphen(bool _v) { m_customhyphen = _v; } |
27 | // bool getCustomHyphen() { return m_customhyphen; } | 27 | // bool getCustomHyphen() { return m_customhyphen; } |
28 | void setHyphenThreshold(int _v) { m_hyphenthreshold = _v; } | 28 | void setHyphenThreshold(int _v) { m_hyphenthreshold = _v; } |
29 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | 29 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) |
30 | { | 30 | { |
31 | if (exp == NULL) | 31 | if (exp == NULL) |
32 | { | 32 | { |
33 | data = NULL; | 33 | data = NULL; |
34 | len = 0; | 34 | len = 0; |
35 | } | 35 | } |
36 | else | 36 | else |
37 | { | 37 | { |
38 | exp->setSaveData(data, len, src, srclen); | 38 | exp->setSaveData(data, len, src, srclen); |
39 | } | 39 | } |
40 | } | 40 | } |
41 | void putSaveData(unsigned char*& src, unsigned short& srclen) | 41 | void putSaveData(unsigned char*& src, unsigned short& srclen) |
42 | { | 42 | { |
43 | if (exp != NULL) | 43 | if (exp != NULL) |
44 | { | 44 | { |
45 | exp->putSaveData(src, srclen); | 45 | exp->putSaveData(src, srclen); |
46 | } | 46 | } |
47 | } | 47 | } |
48 | #ifdef USEQPE | 48 | #ifdef USEQPE |
49 | void suspend() { if (exp != NULL) exp->suspend(); } | 49 | void suspend() { if (exp != NULL) exp->suspend(); } |
50 | void unsuspend() { if (exp != NULL) exp->unsuspend(); } | ||
51 | #else | 50 | #else |
52 | void suspend() {} | 51 | void suspend() {} |
53 | void unsuspend() {} | ||
54 | #endif | 52 | #endif |
55 | ~BuffDoc() | 53 | ~BuffDoc() |
56 | { | 54 | { |
57 | delete filt; | 55 | delete filt; |
58 | delete exp; | 56 | delete exp; |
59 | } | 57 | } |
60 | BuffDoc() | 58 | BuffDoc() |
61 | { | 59 | { |
62 | exp = NULL; | 60 | exp = NULL; |
63 | filt = NULL; | 61 | filt = NULL; |
64 | lastword.empty(); | 62 | lastword.empty(); |
65 | // // qDebug("Buffdoc created"); | 63 | // // qDebug("Buffdoc created"); |
66 | } | 64 | } |
67 | bool empty() { return (exp == NULL); } | 65 | bool empty() { return (exp == NULL); } |
68 | void setfilter(CFilterChain* _f) | 66 | void setfilter(CFilterChain* _f) |
69 | { | 67 | { |
70 | if (filt != NULL) delete filt; | 68 | if (filt != NULL) delete filt; |
71 | filt = _f; | 69 | filt = _f; |
72 | filt->setsource(exp); | 70 | filt->setsource(exp); |
73 | } | 71 | } |
74 | CList<Bkmk>* getbkmklist() { return exp->getbkmklist(); } | 72 | CList<Bkmk>* getbkmklist() { return exp->getbkmklist(); } |
75 | bool hasrandomaccess() { return (exp == NULL) ? false : exp->hasrandomaccess(); } | 73 | bool hasrandomaccess() { return (exp == NULL) ? false : exp->hasrandomaccess(); } |
76 | bool iseol() { return (lastword[0] == '\0'); } | 74 | bool iseol() { return (lastword[0] == '\0'); } |
77 | int openfile(QWidget* _parent, const char *src); | 75 | int openfile(QWidget* _parent, const char *src); |
78 | tchar getch() | 76 | tchar getch() |
79 | { | 77 | { |
80 | tchar ch = UEOF; | 78 | tchar ch = UEOF; |
81 | CStyle sty; | 79 | CStyle sty; |
82 | if (exp != NULL) | 80 | if (exp != NULL) |
83 | { | 81 | { |
84 | unsigned long dummy; | 82 | unsigned long dummy; |
85 | filt->getch(ch, sty, dummy); | 83 | filt->getch(ch, sty, dummy); |
86 | } | 84 | } |
87 | return ch; | 85 | return ch; |
88 | } | 86 | } |
89 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 87 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
90 | { | 88 | { |
91 | if (exp != NULL) | 89 | if (exp != NULL) |
92 | { | 90 | { |
93 | filt->getch(ch, sty, pos); | 91 | filt->getch(ch, sty, pos); |
94 | } | 92 | } |
95 | else | 93 | else |
96 | ch = UEOF; | 94 | ch = UEOF; |
97 | } | 95 | } |
96 | /* | ||
97 | void rawgetch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
98 | { | ||
99 | if (exp != NULL) | ||
100 | { | ||
101 | filt->rawgetch(ch, sty, pos); | ||
102 | } | ||
103 | else | ||
104 | ch = UEOF; | ||
105 | } | ||
106 | */ | ||
98 | void setwidth(int w) { if (exp != NULL) exp->setwidth(w); } | 107 | void setwidth(int w) { if (exp != NULL) exp->setwidth(w); } |
99 | QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); } | 108 | QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); } |
100 | unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); } | 109 | unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); } |
101 | unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); } | 110 | unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); } |
111 | void resetPos(); | ||
102 | unsigned int locate() { return (exp == NULL) ? 0 : laststartline; } | 112 | unsigned int locate() { return (exp == NULL) ? 0 : laststartline; } |
103 | unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); } | 113 | unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); } |
104 | void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); } | 114 | void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); } |
105 | MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); } | 115 | MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); } |
106 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); | 116 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); |
107 | size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); } | 117 | size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); } |
108 | void locate(unsigned int n); | 118 | void locate(unsigned int n); |
109 | bool getline(CDrawBuffer* buff, int w, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht); | 119 | bool getline(CDrawBuffer* buff, int w, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht); |
110 | bool getline(CDrawBuffer* buff, int w, int cw, unsigned short _lborder, unsigned short _rborder, int availht); | 120 | bool getline(CDrawBuffer* buff, int w, int cw, unsigned short _lborder, unsigned short _rborder, int availht); |
111 | void sizes(unsigned long& fs, unsigned long& ts) | 121 | void sizes(unsigned long& fs, unsigned long& ts) |
112 | { | 122 | { |
113 | if (exp != NULL) | 123 | if (exp != NULL) |
114 | { | 124 | { |
115 | exp->sizes(fs,ts); | 125 | exp->sizes(fs,ts); |
116 | } | 126 | } |
117 | else | 127 | else |
118 | { | 128 | { |
119 | fs = ts = 0; | 129 | fs = ts = 0; |
120 | } | 130 | } |
121 | } | 131 | } |
122 | int getpara(CBuffer& buff) | 132 | int getpara(CBuffer& buff) |
123 | { | 133 | { |
124 | tchar ch; | 134 | tchar ch; |
125 | int i = 0; | 135 | int i = 0; |
126 | while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch; | 136 | while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch; |
127 | buff[i] = '\0'; | 137 | buff[i] = '\0'; |
128 | if (i == 0 && ch == UEOF) i = -1; | 138 | if (i == 0 && ch == UEOF) i = -1; |
129 | laststartline = exp->locate(); | 139 | laststartline = exp->locate(); |
130 | return i; | 140 | return i; |
131 | } | 141 | } |
142 | int getsentence(CBuffer& buff); | ||
132 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } | 143 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } |
133 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } | 144 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } |
134 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } | 145 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } |
135 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } | 146 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } |
136 | bool hasnavigation() { return filt->hasnavigation(); } | 147 | bool hasnavigation() { return (exp == NULL) ? false : filt->hasnavigation(); } |
137 | bool getFile(QString href) | 148 | bool getFile(const QString& href, QString& nm) |
149 | { | ||
150 | return (exp == NULL) ? false : exp->getFile(href, nm); | ||
151 | } | ||
152 | QString getTableAsHtml(unsigned long loc) | ||
138 | { | 153 | { |
139 | return (exp == NULL) ? false : exp->getFile(href); | 154 | return (exp != NULL) ? filt->getTableAsHtml(loc) : QString(""); |
140 | } | 155 | } |
141 | }; | 156 | }; |
142 | 157 | ||
143 | #endif | 158 | #endif |
diff --git a/noncore/apps/opie-reader/ButtonPrefs.cpp b/noncore/apps/opie-reader/ButtonPrefs.cpp index 50365a8..762de55 100644 --- a/noncore/apps/opie-reader/ButtonPrefs.cpp +++ b/noncore/apps/opie-reader/ButtonPrefs.cpp | |||
@@ -1,181 +1,185 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form implementation generated from reading ui file 'Prefs.ui' | 2 | ** Form implementation generated from reading ui file 'Prefs.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Feb 11 23:53:35 2003 | 4 | ** Created: Tue Feb 11 23:53:35 2003 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #include "ButtonPrefs.h" | 9 | #include "ButtonPrefs.h" |
10 | 10 | ||
11 | #include <qcheckbox.h> | 11 | #include <qcheckbox.h> |
12 | #include <qlabel.h> | 12 | #include <qlabel.h> |
13 | #include <qpushbutton.h> | 13 | #include <qpushbutton.h> |
14 | #include <qspinbox.h> | 14 | #include <qspinbox.h> |
15 | #include <qlayout.h> | 15 | #include <qlayout.h> |
16 | #include <qvariant.h> | 16 | #include <qvariant.h> |
17 | #include <qtooltip.h> | 17 | #include <qtooltip.h> |
18 | #include <qwhatsthis.h> | 18 | #include <qwhatsthis.h> |
19 | #include <qbuttongroup.h> | 19 | #include <qbuttongroup.h> |
20 | #include <qmultilineedit.h> | 20 | #include <qmultilineedit.h> |
21 | #ifdef USECOMBO | 21 | #ifdef USECOMBO |
22 | #include <qcombobox.h> | 22 | #include <qcombobox.h> |
23 | #else | 23 | #else |
24 | #include <qpe/menubutton.h> | 24 | #include <qpe/menubutton.h> |
25 | #endif | 25 | #endif |
26 | #include <qfontdatabase.h> | 26 | #include <qfontdatabase.h> |
27 | 27 | ||
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | 29 | ||
30 | class MyQListViewItem : public QListViewItem | 30 | class MyQListViewItem : public QListViewItem |
31 | { | 31 | { |
32 | orKey o; | 32 | orKey o; |
33 | public: | 33 | public: |
34 | MyQListViewItem(const orKey& _o, QListView* p, const QString& c1, const QString& c2, const QString& c3) : QListViewItem(p, c1, c2, c3), o(_o) { } | 34 | MyQListViewItem(const orKey& _o, QListView* p, const QString& c1, const QString& c2, const QString& c3) : QListViewItem(p, c1, c2, c3), o(_o) { } |
35 | orKey getKey() { return o; } | 35 | orKey getKey() { return o; } |
36 | }; | 36 | }; |
37 | 37 | ||
38 | void CButtonPrefs::mapkey(Qt::ButtonState st, int _key) | 38 | void CButtonPrefs::mapkey(Qt::ButtonState st, int _key) |
39 | { | 39 | { |
40 | mapkey(st, _key, action->currentItem()); | 40 | mapkey(st, _key, action->currentItem()); |
41 | } | 41 | } |
42 | 42 | ||
43 | void CButtonPrefs::mapkey(Qt::ButtonState st, int _key, int act) | 43 | void CButtonPrefs::mapkey(Qt::ButtonState st, int _key, int act) |
44 | { | 44 | { |
45 | orKey key(st, _key, ((act == cesScrollMore) || (act == cesScrollLess))); | 45 | orKey key(st, _key, ((act == cesScrollMore) || (act == cesScrollLess))); |
46 | QMap<orKey,QListViewItem*>::Iterator iter = listmap.find(key); | 46 | QMap<orKey,QListViewItem*>::Iterator iter = listmap.find(key); |
47 | if (iter != listmap.end()) | 47 | if (iter != listmap.end()) |
48 | { | 48 | { |
49 | lb->takeItem(iter.data()); | 49 | lb->takeItem(iter.data()); |
50 | } | 50 | } |
51 | (*kmap)[key] = act; | 51 | (*kmap)[key] = act; |
52 | listmap[key] = new MyQListViewItem(key, lb, key.text(), action->text(act), (key.isScroll()) ? "*":""); | 52 | listmap[key] = new MyQListViewItem(key, lb, key.text(), action->text(act), (key.isScroll()) ? "*":""); |
53 | } | 53 | } |
54 | 54 | ||
55 | void CButtonPrefs::keyPressEvent(QKeyEvent* e) | 55 | void CButtonPrefs::keyPressEvent(QKeyEvent* e) |
56 | { | 56 | { |
57 | switch (e->key()) | 57 | switch (e->key()) |
58 | { | 58 | { |
59 | case Key_Shift: | 59 | case Key_Shift: |
60 | case Key_Control: | 60 | case Key_Control: |
61 | case Key_Meta: | 61 | case Key_Meta: |
62 | case Key_Alt: | 62 | case Key_Alt: |
63 | case Key_CapsLock: | 63 | case Key_CapsLock: |
64 | case Key_NumLock: | 64 | case Key_NumLock: |
65 | case Key_ScrollLock: | 65 | case Key_ScrollLock: |
66 | e->ignore(); | 66 | e->ignore(); |
67 | break; | 67 | break; |
68 | default: | 68 | default: |
69 | mapkey(e->state(), e->key()); | 69 | mapkey(e->state(), e->key()); |
70 | e->accept(); | 70 | e->accept(); |
71 | break; | 71 | break; |
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | #ifdef USECOMBO | 75 | #ifdef USECOMBO |
76 | void CButtonPrefs::populate(QComboBox *mb) | 76 | void CButtonPrefs::populate(QComboBox *mb) |
77 | #else | 77 | #else |
78 | void CButtonPrefs::populate(MenuButton *mb) | 78 | void CButtonPrefs::populate(MenuButton *mb) |
79 | #endif | 79 | #endif |
80 | { | 80 | { |
81 | mb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 81 | mb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
82 | mb->insertItem( tr("Open file") ); | 82 | mb->insertItem( tr("Open file") ); |
83 | mb->insertItem( tr("Autoscroll") ); | 83 | mb->insertItem( tr("Autoscroll") ); |
84 | mb->insertItem( tr("Bookmark") ); | 84 | mb->insertItem( tr("Bookmark") ); |
85 | mb->insertItem( tr("Annotate") ); | 85 | mb->insertItem( tr("Annotate") ); |
86 | mb->insertItem( tr("Fullscreen") ); | 86 | mb->insertItem( tr("Fullscreen") ); |
87 | 87 | ||
88 | mb->insertItem( tr("Zoom in") ); | 88 | mb->insertItem( tr("Zoom in") ); |
89 | mb->insertItem( tr("Zoom out") ); | 89 | mb->insertItem( tr("Zoom out") ); |
90 | mb->insertItem( tr("Back") ); | 90 | mb->insertItem( tr("Back") ); |
91 | mb->insertItem( tr("Forward") ); | 91 | mb->insertItem( tr("Forward") ); |
92 | mb->insertItem( tr("Home") ); | 92 | mb->insertItem( tr("Home") ); |
93 | mb->insertItem( tr("Page up") ); | 93 | mb->insertItem( tr("Page up") ); |
94 | mb->insertItem( tr("Page down") ); | 94 | mb->insertItem( tr("Page down") ); |
95 | mb->insertItem( tr("Line up") ); | 95 | mb->insertItem( tr("Line up") ); |
96 | mb->insertItem( tr("Line down") ); | 96 | mb->insertItem( tr("Line down") ); |
97 | mb->insertItem( tr("Beginning") ); | 97 | mb->insertItem( tr("Beginning") ); |
98 | mb->insertItem( tr("End") ); | 98 | mb->insertItem( tr("End") ); |
99 | mb->insertItem( tr("Rotate") ); | 99 | mb->insertItem( tr("Rotate") ); |
100 | mb->insertItem( tr("Scroll faster") ); | 100 | mb->insertItem( tr("Scroll faster") ); |
101 | mb->insertItem( tr("Scroll slower") ); | 101 | mb->insertItem( tr("Scroll slower") ); |
102 | mb->insertItem( tr("Invert colours") ); | 102 | mb->insertItem( tr("Invert colours") ); |
103 | mb->insertItem( tr("Toggle tools") ); | 103 | mb->insertItem( tr("Toggle tools") ); |
104 | mb->insertItem( tr("Toggle scrollbar") ); | 104 | mb->insertItem( tr("Toggle scrollbar") ); |
105 | mb->insertItem( tr("Toggle statusbar") ); | 105 | mb->insertItem( tr("Toggle statusbar") ); |
106 | mb->insertItem( tr("Next link") ); | 106 | mb->insertItem( tr("Next link") ); |
107 | mb->insertItem( tr("Goto link") ); | 107 | mb->insertItem( tr("Goto link") ); |
108 | } | 108 | } |
109 | 109 | ||
110 | CButtonPrefs::CButtonPrefs( QMap<orKey, int>* _kmap, QWidget* parent, const char* name, WFlags fl ) | 110 | CButtonPrefs::CButtonPrefs( QMap<orKey, int>* _kmap, QWidget* parent, const char* name, WFlags fl ) |
111 | : QWidget( parent, name, fl ), kmap(_kmap) | 111 | : QWidget( parent, name, fl ), kmap(_kmap) |
112 | { | 112 | { |
113 | QVBoxLayout* vo = new QVBoxLayout(this); | 113 | QVBoxLayout* vo = new QVBoxLayout(this); |
114 | QHBoxLayout* lo = new QHBoxLayout(); | 114 | QHBoxLayout* lo = new QHBoxLayout(); |
115 | setFocusPolicy(QWidget::StrongFocus); | 115 | setFocusPolicy(QWidget::StrongFocus); |
116 | #ifdef USECOMBO | 116 | #ifdef USECOMBO |
117 | action = new QComboBox( this ); | 117 | action = new QComboBox( this ); |
118 | #else | 118 | #else |
119 | action = new MenuButton( this ); | 119 | action = new MenuButton( this ); |
120 | #endif | 120 | #endif |
121 | populate(action); | 121 | populate(action); |
122 | action->setFocusProxy(this); | 122 | action->setFocusProxy(this); |
123 | 123 | ||
124 | 124 | ||
125 | 125 | ||
126 | QMultiLineEdit* TextLabel1 = new QMultiLineEdit( this ); | 126 | QMultiLineEdit* TextLabel1 = new QMultiLineEdit( this ); |
127 | TextLabel1->setText( tr( "Press the key(s) you want assigned to the highlighted function.\n\nPress the delete button to unmap the key.\n\nUse the \"Close\" button (not the [x]) to finish." ) ); | 127 | TextLabel1->setText( tr( "Press the key(s) you want assigned to the highlighted function.\n\nPress the delete button to unmap the key.\n\nUse the \"Close\" button (not the [x]) to finish." ) ); |
128 | TextLabel1->setReadOnly(true); | 128 | TextLabel1->setReadOnly(true); |
129 | TextLabel1->setWordWrap(QMultiLineEdit::WidgetWidth); | 129 | TextLabel1->setWordWrap(QMultiLineEdit::WidgetWidth); |
130 | 130 | ||
131 | // lo->addWidget(TextLabel, 0, Qt::AlignTop); | 131 | // lo->addWidget(TextLabel, 0, Qt::AlignTop); |
132 | // lo->addWidget(action, 0, Qt::AlignTop); | 132 | // lo->addWidget(action, 0, Qt::AlignTop); |
133 | lo->addWidget(TextLabel1); | 133 | lo->addWidget(TextLabel1); |
134 | lo->addWidget(action); | 134 | lo->addWidget(action); |
135 | vo->addLayout(lo); | 135 | vo->addLayout(lo); |
136 | lb = new QListView(this); | 136 | lb = new QListView(this); |
137 | lb->addColumn( tr( "Key" ) ); | 137 | lb->addColumn( tr( "Key" ) ); |
138 | lb->addColumn( tr( "Function" ) ); | 138 | lb->addColumn( tr( "Function" ) ); |
139 | lb->addColumn( tr( "Scroll" ) ); | 139 | lb->addColumn( tr( "Scroll" ) ); |
140 | lb->setFocusProxy(this); | 140 | lb->setFocusProxy(this); |
141 | vo->addWidget(lb,1); | 141 | vo->addWidget(lb,1); |
142 | for (QMap<orKey,int>::Iterator i = kmap->begin(); i != kmap->end(); i++) | 142 | for (QMap<orKey,int>::Iterator i = kmap->begin(); i != kmap->end(); i++) |
143 | { | 143 | { |
144 | listmap[i.key()] = new MyQListViewItem(i.key(), lb, i.key().text(), action->text(i.data()), (i.key().isScroll()) ? "*":""); | 144 | listmap[i.key()] = new MyQListViewItem(i.key(), lb, i.key().text(), action->text(i.data()), (i.key().isScroll()) ? "*":""); |
145 | } | 145 | } |
146 | 146 | ||
147 | lo = new QHBoxLayout(); | 147 | lo = new QHBoxLayout(); |
148 | QLabel* TextLabel = new QLabel( this, "TextLabel1" ); | 148 | QLabel* TextLabel = new QLabel( this, "TextLabel1" ); |
149 | TextLabel->setText( tr( "Debounce" ) ); | 149 | TextLabel->setText( tr( "Debounce" ) ); |
150 | lo->addWidget(TextLabel); | 150 | lo->addWidget(TextLabel); |
151 | 151 | ||
152 | debounce = new QSpinBox( this, "Debounce" ); | 152 | debounce = new QSpinBox( this, "Debounce" ); |
153 | debounce->setRange(0,1000); | 153 | debounce->setRange(0,1000); |
154 | lo->addWidget(debounce); | 154 | lo->addWidget(debounce); |
155 | /* | ||
156 | QPushButton* assignClose = new QPushButton("Assign\nCancel", this); | ||
157 | lo->addWidget(assignClose); | ||
158 | */ | ||
155 | lo->addStretch(1); | 159 | lo->addStretch(1); |
156 | QPushButton* delButton = new QPushButton("Delete", this); | 160 | QPushButton* delButton = new QPushButton("Delete", this); |
157 | connect(delButton, SIGNAL( clicked() ), this, SLOT( erasemapping() )); | 161 | connect(delButton, SIGNAL( clicked() ), this, SLOT( erasemapping() )); |
158 | lo->addWidget(delButton); | 162 | lo->addWidget(delButton); |
159 | QPushButton* exitButton = new QPushButton("Close", this); | 163 | QPushButton* exitButton = new QPushButton("Close", this); |
160 | connect(exitButton, SIGNAL( clicked() ), this, SLOT( slotClosed() ) ); | 164 | connect(exitButton, SIGNAL( clicked() ), this, SLOT( slotClosed() ) ); |
161 | lo->addWidget(exitButton); | 165 | lo->addWidget(exitButton); |
162 | vo->addLayout(lo); | 166 | vo->addLayout(lo); |
163 | } | 167 | } |
164 | 168 | ||
165 | void CButtonPrefs::erasemapping() | 169 | void CButtonPrefs::erasemapping() |
166 | { | 170 | { |
167 | MyQListViewItem* li = (MyQListViewItem*)lb->selectedItem(); | 171 | MyQListViewItem* li = (MyQListViewItem*)lb->selectedItem(); |
168 | if (li != NULL) | 172 | if (li != NULL) |
169 | { | 173 | { |
170 | orKey key(li->getKey()); | 174 | orKey key(li->getKey()); |
171 | qDebug("Tapped %s", (const char*)key.text()); | 175 | qDebug("Tapped %s", (const char*)key.text()); |
172 | kmap->remove(key); | 176 | kmap->remove(key); |
173 | lb->takeItem(listmap[key]); | 177 | lb->takeItem(listmap[key]); |
174 | listmap.remove(key); | 178 | listmap.remove(key); |
175 | } | 179 | } |
176 | } | 180 | } |
177 | 181 | ||
178 | CButtonPrefs::~CButtonPrefs() | 182 | CButtonPrefs::~CButtonPrefs() |
179 | { | 183 | { |
180 | // no need to delete child widgets, Qt does it all for us | 184 | // no need to delete child widgets, Qt does it all for us |
181 | } | 185 | } |
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp index bfb3027..227f0f6 100644 --- a/noncore/apps/opie-reader/CDrawBuffer.cpp +++ b/noncore/apps/opie-reader/CDrawBuffer.cpp | |||
@@ -1,862 +1,879 @@ | |||
1 | #include "CDrawBuffer.h" | 1 | #include "CDrawBuffer.h" |
2 | #include "FontControl.h" | 2 | #include "FontControl.h" |
3 | #include <qfontmetrics.h> | 3 | #include <qfontmetrics.h> |
4 | #include <qpainter.h> | 4 | #include <qpainter.h> |
5 | #include <qpixmap.h> | 5 | #include <qpixmap.h> |
6 | #include <qimage.h> | 6 | #include <qimage.h> |
7 | 7 | ||
8 | CDrawBuffer::~CDrawBuffer() | 8 | CDrawBuffer::~CDrawBuffer() |
9 | { | 9 | { |
10 | while (!segs.isEmpty()) segs.erase(0); | 10 | while (!segs.isEmpty()) segs.erase(0); |
11 | } | 11 | } |
12 | 12 | ||
13 | void CDrawBuffer::setright(CDrawBuffer& rhs, int f) | 13 | void CDrawBuffer::setright(CDrawBuffer& rhs, int f) |
14 | { | 14 | { |
15 | int i; | 15 | int i; |
16 | len = rhs.len; | 16 | len = rhs.len; |
17 | fc = rhs.fc; | 17 | fc = rhs.fc; |
18 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; | 18 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
19 | while (!segs.isEmpty()) | 19 | while (!segs.isEmpty()) |
20 | { | 20 | { |
21 | segs.erase(0); | 21 | segs.erase(0); |
22 | } | 22 | } |
23 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); ) | 23 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); ) |
24 | { | 24 | { |
25 | CList<textsegment>::iterator next = iter; | 25 | CList<textsegment>::iterator next = iter; |
26 | iter++; | 26 | iter++; |
27 | if (iter == rhs.segs.end() || iter->start > f) | 27 | if (iter == rhs.segs.end() || iter->start > f) |
28 | { | 28 | { |
29 | int st = next->start-f; | 29 | int st = next->start-f; |
30 | if (st < 0) st = 0; | 30 | if (st < 0) st = 0; |
31 | 31 | ||
32 | CStyle _style = next->style; | 32 | CStyle _style = next->style; |
33 | segs.push_back(textsegment(st,next->style)); | 33 | segs.push_back(textsegment(st,next->style)); |
34 | } | 34 | } |
35 | } | 35 | } |
36 | for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i]; | 36 | for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i]; |
37 | (*this)[i-f] = '\0'; | 37 | (*this)[i-f] = '\0'; |
38 | len = i; | 38 | len = i; |
39 | } | 39 | } |
40 | 40 | ||
41 | CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) | 41 | CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) |
42 | { | 42 | { |
43 | int i; | 43 | int i; |
44 | // //qDebug("Trying 2"); | 44 | // //qDebug("Trying 2"); |
45 | len = rhs.len; | 45 | len = rhs.len; |
46 | m_ascent = rhs.m_ascent; | 46 | m_ascent = rhs.m_ascent; |
47 | m_descent = rhs.m_descent; | 47 | m_descent = rhs.m_descent; |
48 | m_lineSpacing = rhs.m_lineSpacing; | 48 | m_lineSpacing = rhs.m_lineSpacing; |
49 | m_lineExtraSpacing = rhs.m_lineExtraSpacing; | 49 | m_lineExtraSpacing = rhs.m_lineExtraSpacing; |
50 | m_showPartial = rhs.m_showPartial; | 50 | m_showPartial = rhs.m_showPartial; |
51 | while (!segs.isEmpty()) | 51 | while (!segs.isEmpty()) |
52 | { | 52 | { |
53 | segs.erase(0); | 53 | segs.erase(0); |
54 | } | 54 | } |
55 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) | 55 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) |
56 | { | 56 | { |
57 | segs.push_back(*iter); | 57 | segs.push_back(*iter); |
58 | } | 58 | } |
59 | for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; | 59 | for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; |
60 | (*this)[i] = '\0'; | 60 | (*this)[i] = '\0'; |
61 | len = i; | 61 | len = i; |
62 | // //qDebug("Tried 2"); | 62 | // //qDebug("Tried 2"); |
63 | return *this; | 63 | return *this; |
64 | } | 64 | } |
65 | 65 | ||
66 | CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) | 66 | CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) |
67 | { | 67 | { |
68 | int i; | 68 | int i; |
69 | while (!segs.isEmpty()) | 69 | while (!segs.isEmpty()) |
70 | { | 70 | { |
71 | segs.erase(0); | 71 | segs.erase(0); |
72 | } | 72 | } |
73 | segs.push_back(textsegment(0, CStyle())); | 73 | segs.push_back(textsegment(0, CStyle())); |
74 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; | 74 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; |
75 | (*this)[i] = '\0'; | 75 | (*this)[i] = '\0'; |
76 | len = i; | 76 | len = i; |
77 | return *this; | 77 | return *this; |
78 | } | 78 | } |
79 | 79 | ||
80 | void CDrawBuffer::empty() | 80 | void CDrawBuffer::empty() |
81 | { | 81 | { |
82 | m_bSop = false; | 82 | m_bSop = false; |
83 | m_bEop = false; | 83 | m_bEop = false; |
84 | m_bBop = false; | 84 | m_bBop = false; |
85 | len = 0; | 85 | len = 0; |
86 | (*this)[0] = 0; | 86 | (*this)[0] = 0; |
87 | while (!segs.isEmpty()) | 87 | while (!segs.isEmpty()) |
88 | { | 88 | { |
89 | segs.erase(0); | 89 | segs.erase(0); |
90 | } | 90 | } |
91 | segs.push_back(textsegment(0,CStyle())); | 91 | segs.push_back(textsegment(0,CStyle())); |
92 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; | 92 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
93 | m_bEof = false; | 93 | m_bEof = false; |
94 | } | 94 | } |
95 | 95 | ||
96 | void CDrawBuffer::setendpara(const CStyle& _style/* = ucFontBase*/) | 96 | void CDrawBuffer::setendpara(const CStyle& _style/* = ucFontBase*/) |
97 | { | 97 | { |
98 | m_bEop = true; | 98 | m_bEop = true; |
99 | if (len == 0) | 99 | if (len == 0) |
100 | { | 100 | { |
101 | segs.first().start = 0; | 101 | segs.first().start = 0; |
102 | segs.first().style = _style; | 102 | segs.first().style = _style; |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) | 106 | void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) |
107 | { | 107 | { |
108 | if (len == 0) | 108 | if (len == 0) |
109 | { | 109 | { |
110 | segs.first().start = 0; | 110 | segs.first().start = 0; |
111 | segs.first().style = _style; | 111 | segs.first().style = _style; |
112 | } | 112 | } |
113 | else if (_style != segs.last().style) | 113 | else if (_style != segs.last().style) |
114 | { | 114 | { |
115 | segs.push_back(textsegment(len, _style)); | 115 | segs.push_back(textsegment(len, _style)); |
116 | } | 116 | } |
117 | (*this)[len++] = ch; | 117 | (*this)[len++] = ch; |
118 | } | 118 | } |
119 | 119 | ||
120 | void CDrawBuffer::truncate(int n) | 120 | void CDrawBuffer::truncate(int n) |
121 | { | 121 | { |
122 | len = n; | 122 | len = n; |
123 | (*this)[n] = 0; | 123 | (*this)[n] = 0; |
124 | } | 124 | } |
125 | 125 | ||
126 | int CDrawBuffer::width(int availht, int numchars, bool onscreen, int scwidth, unsigned short _lborder, unsigned short _rborder) | 126 | int CDrawBuffer::width(int availht, int numchars, bool onscreen, int scwidth, unsigned short _lborder, unsigned short _rborder) |
127 | { | 127 | { |
128 | int gzoom = fc->gzoom(); | 128 | int gzoom = fc->gzoom(); |
129 | int currentx = 0, end = 0; | 129 | int currentx = 0, end = 0; |
130 | QString text = (numchars < 0) ? toQString(data()) : toQString(data(), numchars); | 130 | QString text = (numchars < 0) ? toQString(data()) : toQString(data(), numchars); |
131 | CList<textsegment>::iterator textstart = segs.begin(); | 131 | CList<textsegment>::iterator textstart = segs.begin(); |
132 | int extraspace = 0; | 132 | int extraspace = 0; |
133 | bool just = (onscreen && !m_bEop && textstart->style.getJustify() == m_AlignJustify); | 133 | bool just = (onscreen && !m_bEop && textstart->style.getJustify() == m_AlignJustify); |
134 | int spaces = 0; | 134 | int spaces = 0; |
135 | int spacesofar = 0; | 135 | int spacesofar = 0; |
136 | int spacenumber = 0; | 136 | int spacenumber = 0; |
137 | int nonspace = 0; | 137 | int nonspace = 0; |
138 | if (just) | 138 | if (just) |
139 | { | 139 | { |
140 | for (int i = 0; i < len; i++) | 140 | for (int i = 0; i < len; i++) |
141 | { | 141 | { |
142 | if ((*this)[i] != ' ') | 142 | if ((*this)[i] != ' ') |
143 | { | 143 | { |
144 | nonspace = i; | 144 | nonspace = i; |
145 | break; | 145 | break; |
146 | } | 146 | } |
147 | } | 147 | } |
148 | #ifdef _WINDOWS | 148 | #ifdef _WINDOWS |
149 | for (i = nonspace; i < len; i++) | 149 | for (i = nonspace; i < len; i++) |
150 | #else | 150 | #else |
151 | for (int i = nonspace; i < len; i++) | 151 | for (int i = nonspace; i < len; i++) |
152 | #endif | 152 | #endif |
153 | { | 153 | { |
154 | if ((*this)[i] == ' ') | 154 | if ((*this)[i] == ' ') |
155 | { | 155 | { |
156 | spaces++; | 156 | spaces++; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | if (spaces == 0) | 159 | if (spaces == 0) |
160 | { | 160 | { |
161 | just = false; | 161 | just = false; |
162 | } | 162 | } |
163 | else | 163 | else |
164 | { | 164 | { |
165 | extraspace = (scwidth - (_lborder+_rborder) - rightMargin() - leftMargin() - width(availht)); | 165 | extraspace = (scwidth - (_lborder+_rborder) - rightMargin() - leftMargin() - width(availht)); |
166 | if (extraspace == 0) just = false; | 166 | if (extraspace == 0) just = false; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | CList<textsegment>::iterator textend = textstart; | 169 | CList<textsegment>::iterator textend = textstart; |
170 | do | 170 | do |
171 | { | 171 | { |
172 | textend++; | 172 | textend++; |
173 | end = (textend != segs.end()) ? textend->start : len; | 173 | end = (textend != segs.end()) ? textend->start : len; |
174 | if (numchars >= 0 && end > numchars) | 174 | if (numchars >= 0 && end > numchars) |
175 | { | 175 | { |
176 | end = numchars; | 176 | end = numchars; |
177 | } | 177 | } |
178 | CStyle currentstyle = textstart->style; | 178 | CStyle currentstyle = textstart->style; |
179 | if (currentstyle.isPicture()) | 179 | if (currentstyle.isPicture()) |
180 | { | 180 | { |
181 | if (currentstyle.canScale()) | 181 | if (currentstyle.canScale()) |
182 | { | 182 | { |
183 | int ht = (gzoom*currentstyle.getPicture()->height())/100; | 183 | int ht = (gzoom*currentstyle.getPicture()->height())/100; |
184 | int wt = (gzoom*currentstyle.getPicture()->width())/100; | 184 | int wt = (gzoom*currentstyle.getPicture()->width())/100; |
185 | if (ht > availht) | 185 | if (ht > availht) |
186 | { | 186 | { |
187 | wt = (wt*availht)/ht; | 187 | wt = (wt*availht)/ht; |
188 | } | 188 | } |
189 | currentx += wt; | 189 | currentx += wt; |
190 | } | 190 | } |
191 | else | 191 | else |
192 | { | 192 | { |
193 | currentx += currentstyle.getPicture()->width(); | 193 | currentx += currentstyle.getPicture()->width(); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | else | 196 | else |
197 | { | 197 | { |
198 | if (currentstyle.isMono() && !fc->hasCourier()) | 198 | if (currentstyle.isMono() && !fc->hasCourier()) |
199 | { | 199 | { |
200 | int cw = (7*fc->getsize(currentstyle))/10; | 200 | int cw = (7*fc->getsize(currentstyle))/10; |
201 | currentx += cw*(end-textstart->start); | 201 | currentx += cw*(end-textstart->start); |
202 | } | 202 | } |
203 | else | 203 | else |
204 | { | 204 | { |
205 | QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 205 | QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
206 | // f.setUnderline(currentstyle.isUnderline()); | 206 | // f.setUnderline(currentstyle.isUnderline()); |
207 | QString str = text.mid(textstart->start, end-textstart->start); | 207 | QString str = text.mid(textstart->start, end-textstart->start); |
208 | QFontMetrics fm(f); | 208 | QFontMetrics fm(f); |
209 | if (just) | 209 | if (just) |
210 | { | 210 | { |
211 | int lastspace = -1; | 211 | int lastspace = -1; |
212 | int nsp = 0; | 212 | int nsp = 0; |
213 | int cx = currentx; | 213 | int cx = currentx; |
214 | while ((nsp = str.find(" ", lastspace+1)) >= 0) | 214 | while ((nsp = str.find(" ", lastspace+1)) >= 0) |
215 | { | 215 | { |
216 | if (nsp > nonspace) | 216 | if (nsp > nonspace) |
217 | { | 217 | { |
218 | spacenumber++; | 218 | spacenumber++; |
219 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; | 219 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; |
220 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 220 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
221 | int lw = fm.width(nstr); | 221 | int lw = fm.width(nstr); |
222 | cx += lw+nexttoadd; | 222 | cx += lw+nexttoadd; |
223 | spacesofar += nexttoadd; | 223 | spacesofar += nexttoadd; |
224 | lastspace = nsp; | 224 | lastspace = nsp; |
225 | } | 225 | } |
226 | else | 226 | else |
227 | { | 227 | { |
228 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 228 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
229 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); | 229 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); |
230 | int lw = fm.width(nstr); | 230 | int lw = fm.width(nstr); |
231 | cx += lw; | 231 | cx += lw; |
232 | lastspace = nsp; | 232 | lastspace = nsp; |
233 | } | 233 | } |
234 | } | 234 | } |
235 | QString nstr = str.right(str.length()-1-lastspace); | 235 | QString nstr = str.right(str.length()-1-lastspace); |
236 | cx += fm.width(nstr); | 236 | cx += fm.width(nstr); |
237 | currentx = cx; | 237 | currentx = cx; |
238 | } | 238 | } |
239 | else | 239 | else |
240 | { | 240 | { |
241 | currentx += fm.width(str); | 241 | currentx += fm.width(str); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | } | 244 | } |
245 | textstart = textend; | 245 | textstart = textend; |
246 | } | 246 | } |
247 | while (textend != segs.end() && end != numchars && textstart->start < len); | 247 | while (textend != segs.end() && end != numchars && textstart->start < len); |
248 | return currentx; | 248 | return currentx; |
249 | } | 249 | } |
250 | 250 | ||
251 | int CDrawBuffer::charwidth(int numchars, CStyle& currentstyle) | 251 | int CDrawBuffer::charwidth(int numchars, CStyle& currentstyle) |
252 | { | 252 | { |
253 | if (currentstyle.isPicture()) | 253 | if (currentstyle.isPicture()) |
254 | { | 254 | { |
255 | int gzoom = fc->gzoom(); | 255 | int gzoom = fc->gzoom(); |
256 | if (currentstyle.canScale()) | 256 | if (currentstyle.canScale()) |
257 | { | 257 | { |
258 | return (gzoom*currentstyle.getPicture()->width())/100; | 258 | return (gzoom*currentstyle.getPicture()->width())/100; |
259 | } | 259 | } |
260 | else | 260 | else |
261 | { | 261 | { |
262 | return currentstyle.getPicture()->width(); | 262 | return currentstyle.getPicture()->width(); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | else | 265 | else |
266 | { | 266 | { |
267 | if (currentstyle.isMono() && !fc->hasCourier()) | 267 | if (currentstyle.isMono() && !fc->hasCourier()) |
268 | { | 268 | { |
269 | return (7*fc->getsize(currentstyle))/10; | 269 | return (7*fc->getsize(currentstyle))/10; |
270 | } | 270 | } |
271 | else | 271 | else |
272 | { | 272 | { |
273 | QString text = QChar((data())[numchars]); | 273 | QString text = QChar((data())[numchars]); |
274 | QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 274 | QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
275 | // f.setUnderline(currentstyle.isUnderline()); | 275 | // f.setUnderline(currentstyle.isUnderline()); |
276 | QFontMetrics fm(f); | 276 | QFontMetrics fm(f); |
277 | return fm.width(text); | 277 | return fm.width(text); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | return 0; | 280 | return 0; |
281 | } | 281 | } |
282 | 282 | ||
283 | int CDrawBuffer::charwidth(int numchars) | 283 | int CDrawBuffer::charwidth(int numchars) |
284 | { | 284 | { |
285 | int gzoom = fc->gzoom(); | 285 | int gzoom = fc->gzoom(); |
286 | int end = 0; | 286 | int end = 0; |
287 | QString text = QChar((data())[numchars]); | 287 | QString text = QChar((data())[numchars]); |
288 | CList<textsegment>::iterator textstart = segs.begin(); | 288 | CList<textsegment>::iterator textstart = segs.begin(); |
289 | CList<textsegment>::iterator textend = textstart; | 289 | CList<textsegment>::iterator textend = textstart; |
290 | do | 290 | do |
291 | { | 291 | { |
292 | textend++; | 292 | textend++; |
293 | end = (textend != segs.end()) ? textend->start : len; | 293 | end = (textend != segs.end()) ? textend->start : len; |
294 | if (end <= numchars) | 294 | if (end <= numchars) |
295 | { | 295 | { |
296 | textstart = textend; | 296 | textstart = textend; |
297 | continue; | 297 | continue; |
298 | } | 298 | } |
299 | if (numchars >= 0 && end > numchars) | 299 | if (numchars >= 0 && end > numchars) |
300 | { | 300 | { |
301 | end = numchars; | 301 | end = numchars; |
302 | } | 302 | } |
303 | CStyle currentstyle = textstart->style; | 303 | CStyle currentstyle = textstart->style; |
304 | if (currentstyle.isPicture()) | 304 | if (currentstyle.isPicture()) |
305 | { | 305 | { |
306 | if (currentstyle.canScale()) | 306 | if (currentstyle.canScale()) |
307 | { | 307 | { |
308 | return (gzoom*currentstyle.getPicture()->width())/100; | 308 | return (gzoom*currentstyle.getPicture()->width())/100; |
309 | } | 309 | } |
310 | else | 310 | else |
311 | { | 311 | { |
312 | return currentstyle.getPicture()->width(); | 312 | return currentstyle.getPicture()->width(); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | else | 315 | else |
316 | { | 316 | { |
317 | if (currentstyle.isMono() && !fc->hasCourier()) | 317 | if (currentstyle.isMono() && !fc->hasCourier()) |
318 | { | 318 | { |
319 | return (7*fc->getsize(currentstyle))/10; | 319 | return (7*fc->getsize(currentstyle))/10; |
320 | } | 320 | } |
321 | else | 321 | else |
322 | { | 322 | { |
323 | QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 323 | QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
324 | // f.setUnderline(currentstyle.isUnderline()); | 324 | // f.setUnderline(currentstyle.isUnderline()); |
325 | QFontMetrics fm(f); | 325 | QFontMetrics fm(f); |
326 | return fm.width(text); | 326 | return fm.width(text); |
327 | } | 327 | } |
328 | } | 328 | } |
329 | textstart = textend; | 329 | textstart = textend; |
330 | } | 330 | } |
331 | while (textend != segs.end() /* && end != numchars*/ && textstart->start < len); | 331 | while (textend != segs.end() /* && end != numchars*/ && textstart->start < len); |
332 | return 0; | 332 | return 0; |
333 | } | 333 | } |
334 | 334 | ||
335 | 335 | ||
336 | 336 | ||
337 | int CDrawBuffer::leftMargin() | 337 | int CDrawBuffer::leftMargin() |
338 | { | 338 | { |
339 | return (segs.begin()->style.getLeftMargin()*fc->getsize(segs.begin()->style)+3)/6; | 339 | return (segs.begin()->style.getLeftMargin()*fc->getsize(segs.begin()->style)+3)/6; |
340 | } | 340 | } |
341 | 341 | ||
342 | int CDrawBuffer::rightMargin() | 342 | int CDrawBuffer::rightMargin() |
343 | { | 343 | { |
344 | return (segs.begin()->style.getRightMargin()*fc->getsize(segs.begin()->style)+3)/6; | 344 | return (segs.begin()->style.getRightMargin()*fc->getsize(segs.begin()->style)+3)/6; |
345 | } | 345 | } |
346 | 346 | ||
347 | int CDrawBuffer::offset(int scwidth, unsigned short _lborder, unsigned short _rborder, int availht) | 347 | int CDrawBuffer::offset(int scwidth, unsigned short _lborder, unsigned short _rborder, int availht) |
348 | { | 348 | { |
349 | int currentx = _lborder; | 349 | int currentx = _lborder; |
350 | switch(segs.begin()->style.getJustify()) | 350 | switch(segs.begin()->style.getJustify()) |
351 | { | 351 | { |
352 | case m_AlignRight: | 352 | case m_AlignRight: |
353 | { | 353 | { |
354 | currentx = scwidth - _rborder - rightMargin() - width(availht); | 354 | currentx = scwidth - _rborder - rightMargin() - width(availht); |
355 | } | 355 | } |
356 | break; | 356 | break; |
357 | case m_AlignCentre: | 357 | case m_AlignCentre: |
358 | { | 358 | { |
359 | currentx = ( | 359 | currentx = ( |
360 | scwidth - _lborder -_rborder + | 360 | scwidth - _lborder -_rborder + |
361 | leftMargin() - rightMargin() | 361 | leftMargin() - rightMargin() |
362 | - width(availht))/2 + _lborder; | 362 | - width(availht))/2 + _lborder; |
363 | } | 363 | } |
364 | break; | 364 | break; |
365 | case m_AlignJustify: | 365 | case m_AlignJustify: |
366 | case m_AlignLeft: | 366 | case m_AlignLeft: |
367 | case m_AlignNone: | ||
367 | currentx = _lborder + leftMargin(); | 368 | currentx = _lborder + leftMargin(); |
368 | break; | 369 | break; |
369 | } | 370 | } |
370 | return currentx; | 371 | return currentx; |
371 | } | 372 | } |
372 | 373 | ||
373 | void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth, unsigned short _lborder, unsigned short _rborder, const QColor& _bg, int availht) | 374 | void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth, unsigned short _lborder, unsigned short _rborder, const QColor& _bg, int availht) |
374 | { | 375 | { |
375 | CList<textsegment>::iterator textstart = segs.begin(); | 376 | CList<textsegment>::iterator textstart = segs.begin(); |
376 | QColor paperColour = QColor(qRgb(textstart->style.pRed(), | 377 | QColor paperColour = QColor(qRgb(textstart->style.pRed(), |
377 | textstart->style.pGreen(), | 378 | textstart->style.pGreen(), |
378 | textstart->style.pBlue())); | 379 | textstart->style.pBlue())); |
379 | 380 | ||
380 | Highlight(_p, !(paperColour == _bg), _lborder, _y, scwidth-(_lborder+_rborder), paperColour); | 381 | Highlight(_p, !(paperColour == _bg), _lborder, _y, scwidth-(_lborder+_rborder), paperColour); |
381 | // Highlight(_p, true, _lborder, _y, scwidth-(_lborder+_rborder), paperColour); | 382 | // Highlight(_p, true, _lborder, _y, scwidth-(_lborder+_rborder), paperColour); |
382 | int gzoom = fc->gzoom(); | 383 | int gzoom = fc->gzoom(); |
383 | int currentx = offset(scwidth, _lborder, _rborder, availht); | 384 | int currentx = offset(scwidth, _lborder, _rborder, availht); |
384 | if (!m_hastext) | 385 | if (!m_hastext) |
385 | { | 386 | { |
386 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); iter++) | 387 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); iter++) |
387 | { | 388 | { |
388 | CStyle currentstyle = iter->style; | 389 | CStyle currentstyle = iter->style; |
389 | if (currentstyle.isPicture()) | 390 | if (currentstyle.isPicture()) |
390 | { | 391 | { |
391 | CStyle currentstyle = segs.begin()->style; | 392 | CStyle currentstyle = segs.begin()->style; |
392 | int ht = (gzoom*currentstyle.getPicture()->height())/100; | 393 | int ht = (gzoom*currentstyle.getPicture()->height())/100; |
393 | int wt = (gzoom*currentstyle.getPicture()->width())/100; | 394 | int wt = (gzoom*currentstyle.getPicture()->width())/100; |
394 | bool willscale = false; | 395 | bool willscale = false; |
395 | if (ht > availht) | 396 | if (ht > availht) |
396 | { | 397 | { |
397 | wt = (wt*availht)/ht; | 398 | wt = (wt*availht)/ht; |
398 | ht = availht; | 399 | ht = availht; |
399 | willscale = true; | 400 | willscale = true; |
400 | } | 401 | } |
401 | 402 | ||
402 | QPixmap pc; | 403 | QPixmap pc; |
403 | if ((willscale || gzoom != 100) && currentstyle.canScale()) | 404 | if ((willscale || gzoom != 100) && currentstyle.canScale()) |
404 | { | 405 | { |
405 | QImage im = currentstyle.getPicture()->smoothScale(wt,ht); | 406 | QImage im = currentstyle.getPicture()->smoothScale(wt,ht); |
406 | pc.convertFromImage(im); | 407 | pc.convertFromImage(im); |
407 | } | 408 | } |
408 | else | 409 | else |
409 | { | 410 | { |
410 | pc.convertFromImage(*currentstyle.getPicture()); | 411 | pc.convertFromImage(*currentstyle.getPicture()); |
411 | } | 412 | } |
412 | int yoffset = pc.height()/2; | 413 | int yoffset = pc.height()/2; |
413 | _p->drawPixmap( currentx, _y-yoffset, pc ); | 414 | _p->drawPixmap( currentx, _y-yoffset, pc ); |
414 | currentx += pc.width(); | 415 | currentx += pc.width(); |
415 | } | 416 | } |
416 | } | 417 | } |
417 | return; | 418 | return; |
418 | } | 419 | } |
419 | QString text = toQString(data()); | 420 | QString text = toQString(data()); |
420 | int extraspace = 0; | 421 | int extraspace = 0; |
421 | bool just = (!m_bEop && textstart->style.getJustify() == m_AlignJustify); | 422 | bool just = (!m_bEop && textstart->style.getJustify() == m_AlignJustify); |
422 | int spaces = 0; | 423 | int spaces = 0; |
423 | int spacesofar = 0; | 424 | int spacesofar = 0; |
424 | int spacenumber = 0; | 425 | int spacenumber = 0; |
425 | int nonspace = 0; | 426 | int nonspace = 0; |
426 | if (just) | 427 | if (just) |
427 | { | 428 | { |
428 | for (int i = 0; i < len; i++) | 429 | for (int i = 0; i < len; i++) |
429 | { | 430 | { |
430 | if ((*this)[i] != ' ') | 431 | if ((*this)[i] != ' ') |
431 | { | 432 | { |
432 | nonspace = i; | 433 | nonspace = i; |
433 | break; | 434 | break; |
434 | } | 435 | } |
435 | } | 436 | } |
436 | #ifdef _WINDOWS | 437 | #ifdef _WINDOWS |
437 | for (i = nonspace; i < len; i++) | 438 | for (i = nonspace; i < len; i++) |
438 | #else | 439 | #else |
439 | for (int i = nonspace; i < len; i++) | 440 | for (int i = nonspace; i < len; i++) |
440 | #endif | 441 | #endif |
441 | { | 442 | { |
442 | if ((*this)[i] == ' ') | 443 | if ((*this)[i] == ' ') |
443 | { | 444 | { |
444 | spaces++; | 445 | spaces++; |
445 | } | 446 | } |
446 | } | 447 | } |
447 | if (spaces == 0) | 448 | if (spaces == 0) |
448 | { | 449 | { |
449 | just = false; | 450 | just = false; |
450 | } | 451 | } |
451 | else | 452 | else |
452 | { | 453 | { |
453 | extraspace = (scwidth - (_lborder+_rborder) - rightMargin() - leftMargin() - width(availht)); | 454 | extraspace = (scwidth - (_lborder+_rborder) - rightMargin() - leftMargin() - width(availht)); |
454 | if (extraspace == 0) just = false; | 455 | if (extraspace == 0) just = false; |
455 | } | 456 | } |
456 | } | 457 | } |
457 | CList<textsegment>::iterator textend = textstart; | 458 | CList<textsegment>::iterator textend = textstart; |
458 | 459 | ||
459 | bool drawBackground = false; | 460 | bool drawBackground = false; |
460 | do | 461 | do |
461 | { | 462 | { |
462 | textend++; | 463 | textend++; |
463 | int end = (textend != segs.end()) ? textend->start : len; | 464 | int end = (textend != segs.end()) ? textend->start : len; |
464 | CStyle currentstyle = textstart->style; | 465 | CStyle currentstyle = textstart->style; |
465 | /* | 466 | /* |
466 | bool drawBackground = ( | 467 | bool drawBackground = ( |
467 | currentstyle.bRed() != 255 | 468 | currentstyle.bRed() != 255 |
468 | || | 469 | || |
469 | currentstyle.bGreen() != 255 | 470 | currentstyle.bGreen() != 255 |
470 | || | 471 | || |
471 | currentstyle.bBlue() != 255 | 472 | currentstyle.bBlue() != 255 |
472 | ); | 473 | ); |
473 | */ | 474 | */ |
474 | QColor bgColour = QColor(qRgb(currentstyle.bRed(), | 475 | QColor bgColour = QColor(qRgb(currentstyle.bRed(), |
475 | currentstyle.bGreen(), | 476 | currentstyle.bGreen(), |
476 | currentstyle.bBlue())); | 477 | currentstyle.bBlue())); |
477 | drawBackground = !(bgColour == _bg); | 478 | drawBackground = !(bgColour == _bg); |
478 | 479 | ||
479 | // if (drawBackground) qDebug("Drawing background"); | 480 | // if (drawBackground) qDebug("Drawing background"); |
480 | 481 | ||
481 | QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 482 | QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
482 | //f.setUnderline(currentstyle.isUnderline()); | 483 | //f.setUnderline(currentstyle.isUnderline()); |
483 | //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); | 484 | //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); |
484 | _p->setFont(f); | 485 | _p->setFont(f); |
485 | QString str = text.mid(textstart->start, end-textstart->start); | 486 | QString str = text.mid(textstart->start, end-textstart->start); |
486 | #if defined(OPIE) || !defined(USEQPE) | 487 | #if defined(OPIE) || !defined(USEQPE) |
487 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100)); | 488 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10/*0*/)); |
488 | #else | 489 | #else |
489 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); | 490 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); |
490 | #endif | 491 | #endif |
491 | int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2; | 492 | int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2; |
492 | 493 | ||
493 | if (_bMono) | 494 | if (_bMono) |
494 | { | 495 | { |
495 | 496 | ||
496 | Highlight(_p, drawBackground, currentx, _y, str.length()*_charWidth, bgColour); | 497 | Highlight(_p, drawBackground, currentx, _y, str.length()*_charWidth, bgColour); |
497 | if (currentstyle.isUnderline()) | 498 | if (currentstyle.isUnderline()) |
498 | { | 499 | { |
499 | _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset); | 500 | _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset); |
500 | } | 501 | } |
501 | if (currentstyle.isStrikethru()) | 502 | if (currentstyle.isStrikethru()) |
502 | { | 503 | { |
503 | int ascent = fc->ascent(currentstyle)/3; | 504 | int ascent = fc->ascent(currentstyle)/3; |
504 | _p->drawLine( currentx, _y-ascent+voffset, currentx + str.length()*_charWidth, _y-ascent+voffset); | 505 | _p->drawLine( currentx, _y-ascent+voffset, currentx + str.length()*_charWidth, _y-ascent+voffset); |
505 | } | 506 | } |
506 | for (int i = 0; i < str.length(); i++) | 507 | for (int i = 0; i < str.length(); i++) |
507 | { | 508 | { |
508 | _p->drawText( currentx + i*_charWidth, _y+voffset, QString(str[i])); | 509 | _p->drawText( currentx + i*_charWidth, _y+voffset, QString(str[i])); |
509 | } | 510 | } |
510 | currentx += str.length()*_charWidth; | 511 | currentx += str.length()*_charWidth; |
511 | } | 512 | } |
512 | else | 513 | else |
513 | { | 514 | { |
514 | if (currentstyle.isPicture()) | 515 | if (currentstyle.isPicture()) |
515 | { | 516 | { |
516 | int ht = (gzoom*currentstyle.getPicture()->height())/100; | 517 | int ht = (gzoom*currentstyle.getPicture()->height())/100; |
517 | int wt = (gzoom*currentstyle.getPicture()->width())/100; | 518 | int wt = (gzoom*currentstyle.getPicture()->width())/100; |
518 | bool willscale = false; | 519 | bool willscale = false; |
519 | if (ht > availht) | 520 | if (ht > availht) |
520 | { | 521 | { |
521 | wt = (wt*availht)/ht; | 522 | wt = (wt*availht)/ht; |
522 | ht = availht; | 523 | ht = availht; |
523 | willscale = true; | 524 | willscale = true; |
524 | } | 525 | } |
525 | int ascent = fc->ascent(currentstyle)/2; | 526 | int ascent = fc->ascent(currentstyle)/2; |
526 | int yoffset = ht/2 + ascent; | 527 | int yoffset = ht/2 + ascent; |
527 | 528 | ||
528 | QPixmap pc; | 529 | QPixmap pc; |
529 | if ((willscale || gzoom != 100) && currentstyle.canScale()) | 530 | if ((willscale || gzoom != 100) && currentstyle.canScale()) |
530 | { | 531 | { |
531 | QImage im = currentstyle.getPicture()->smoothScale(wt,ht); | 532 | QImage im = currentstyle.getPicture()->smoothScale(wt,ht); |
532 | pc.convertFromImage(im); | 533 | pc.convertFromImage(im); |
533 | } | 534 | } |
534 | else | 535 | else |
535 | { | 536 | { |
536 | pc.convertFromImage(*currentstyle.getPicture()); | 537 | pc.convertFromImage(*currentstyle.getPicture()); |
537 | } | 538 | } |
538 | _p->drawPixmap( currentx, _y-yoffset, pc ); | 539 | _p->drawPixmap( currentx, _y-yoffset, pc ); |
539 | currentx += wt; | 540 | currentx += wt; |
540 | } | 541 | } |
541 | else | 542 | else |
542 | { | 543 | { |
543 | if (currentstyle.isMono() && !fc->hasCourier()) | 544 | if (currentstyle.isMono() && !fc->hasCourier()) |
544 | { | 545 | { |
545 | int cw = (7*fc->getsize(currentstyle))/10; | 546 | int cw = (7*fc->getsize(currentstyle))/10; |
546 | int w = cw*(end-textstart->start); | 547 | int w = cw*(end-textstart->start); |
547 | Highlight(_p, drawBackground, currentx, _y, w, bgColour); | 548 | Highlight(_p, drawBackground, currentx, _y, w, bgColour); |
548 | if (currentstyle.isUnderline()) | 549 | if (currentstyle.isUnderline()) |
549 | { | 550 | { |
550 | _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset); | 551 | _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset); |
551 | } | 552 | } |
552 | if (currentstyle.isStrikethru()) | 553 | if (currentstyle.isStrikethru()) |
553 | { | 554 | { |
554 | int ascent = fc->ascent(currentstyle)/3; | 555 | int ascent = fc->ascent(currentstyle)/3; |
555 | _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset); | 556 | _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset); |
556 | } | 557 | } |
557 | QString str = text.mid(textstart->start, end-textstart->start); | 558 | QString str = text.mid(textstart->start, end-textstart->start); |
558 | 559 | ||
559 | for (unsigned int i = 0; i < str.length(); i++) | 560 | for (unsigned int i = 0; i < str.length(); i++) |
560 | { | 561 | { |
561 | #ifdef _WINDOWS | 562 | #ifdef _WINDOWS |
562 | _p->drawText( currentx, _y+voffset, QString(str.at(i))); | 563 | _p->drawText( currentx, _y+voffset, QString(str.at(i))); |
563 | #else | 564 | #else |
564 | _p->drawText( currentx, _y+voffset, QString(str[i])); | 565 | _p->drawText( currentx, _y+voffset, QString(str[i])); |
565 | #endif | 566 | #endif |
566 | currentx += cw; | 567 | currentx += cw; |
567 | } | 568 | } |
568 | } | 569 | } |
569 | else | 570 | else |
570 | { | 571 | { |
571 | QFontMetrics fm(f); | 572 | QFontMetrics fm(f); |
572 | int w; | 573 | int w; |
573 | if (just) | 574 | if (just) |
574 | { | 575 | { |
575 | int lastspace = -1; | 576 | int lastspace = -1; |
576 | int nsp = 0; | 577 | int nsp = 0; |
577 | int cx = currentx; | 578 | int cx = currentx; |
578 | while ((nsp = str.find(" ", lastspace+1)) >= 0) | 579 | while ((nsp = str.find(" ", lastspace+1)) >= 0) |
579 | { | 580 | { |
580 | if (nsp+textstart->start >= nonspace) | 581 | if (nsp+textstart->start >= nonspace) |
581 | { | 582 | { |
582 | spacenumber++; | 583 | spacenumber++; |
583 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; | 584 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; |
584 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 585 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
585 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); | 586 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); |
586 | int lw = fm.width(nstr); | 587 | int lw = fm.width(nstr); |
587 | Highlight(_p, drawBackground, cx, _y, lw, bgColour); | 588 | Highlight(_p, drawBackground, cx, _y, lw, bgColour); |
588 | _p->drawText( cx, _y+voffset, nstr); | 589 | _p->drawText( cx, _y+voffset, nstr); |
589 | Highlight(_p, drawBackground, cx+lw, _y, nexttoadd, bgColour); | 590 | Highlight(_p, drawBackground, cx+lw, _y, nexttoadd, bgColour); |
590 | cx += lw+nexttoadd; | 591 | cx += lw+nexttoadd; |
591 | spacesofar += nexttoadd; | 592 | spacesofar += nexttoadd; |
592 | lastspace = nsp; | 593 | lastspace = nsp; |
593 | } | 594 | } |
594 | else | 595 | else |
595 | { | 596 | { |
596 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 597 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
597 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); | 598 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); |
598 | int lw = fm.width(nstr); | 599 | int lw = fm.width(nstr); |
599 | Highlight(_p, drawBackground, cx, _y, lw, bgColour); | 600 | Highlight(_p, drawBackground, cx, _y, lw, bgColour); |
600 | _p->drawText( cx, _y+voffset, nstr); | 601 | _p->drawText( cx, _y+voffset, nstr); |
601 | cx += lw; | 602 | cx += lw; |
602 | lastspace = nsp; | 603 | lastspace = nsp; |
603 | } | 604 | } |
604 | } | 605 | } |
605 | QString nstr = str.right(str.length()-1-lastspace); | 606 | QString nstr = str.right(str.length()-1-lastspace); |
606 | int lw = fm.width(nstr); | 607 | int lw = fm.width(nstr); |
607 | Highlight(_p, drawBackground, cx, _y, lw, bgColour); | 608 | Highlight(_p, drawBackground, cx, _y, lw, bgColour); |
608 | _p->drawText( cx, _y+voffset, nstr); | 609 | _p->drawText( cx, _y+voffset, nstr); |
609 | cx += lw; | 610 | cx += lw; |
610 | w = cx - currentx; | 611 | w = cx - currentx; |
611 | } | 612 | } |
612 | else | 613 | else |
613 | { | 614 | { |
614 | int lw = fm.width(str); | 615 | int lw = fm.width(str); |
615 | Highlight(_p, drawBackground, currentx, _y, lw, bgColour); | 616 | Highlight(_p, drawBackground, currentx, _y, lw, bgColour); |
616 | _p->drawText( currentx, _y+voffset, str); | 617 | _p->drawText( currentx, _y+voffset, str); |
617 | w = lw; | 618 | w = lw; |
618 | } | 619 | } |
619 | if (currentstyle.isUnderline()) | 620 | if (currentstyle.isUnderline()) |
620 | { | 621 | { |
621 | _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset); | 622 | _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset); |
622 | } | 623 | } |
623 | if (currentstyle.isStrikethru()) | 624 | if (currentstyle.isStrikethru()) |
624 | { | 625 | { |
625 | int ascent = fc->ascent(currentstyle)/3; | 626 | int ascent = fc->ascent(currentstyle)/3; |
626 | _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset); | 627 | _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset); |
627 | } | 628 | } |
628 | currentx += w; | 629 | currentx += w; |
629 | } | 630 | } |
630 | } | 631 | } |
631 | } | 632 | } |
632 | textstart = textend; | 633 | textstart = textend; |
633 | } | 634 | } |
634 | while (textend != segs.end() && textstart->start < len); | 635 | while (textend != segs.end() && textstart->start < len); |
635 | /* | 636 | /* |
636 | if (firstColour == bgColour) | 637 | if (firstColour == bgColour) |
637 | { | 638 | { |
638 | Highlight(_p, drawBackground, currentx, _y, scwidth - (currentx + _lborder + _rborder), bgColour); | 639 | Highlight(_p, drawBackground, currentx, _y, scwidth - (currentx + _lborder + _rborder), bgColour); |
639 | } | 640 | } |
640 | */ | 641 | */ |
641 | } | 642 | } |
642 | 643 | ||
643 | void CDrawBuffer::Highlight(QPainter* _p, bool drawBackground, int _x, int _y, int w, QColor bgColour) | 644 | void CDrawBuffer::Highlight(QPainter* _p, bool drawBackground, int _x, int _y, int w, QColor bgColour) |
644 | { | 645 | { |
645 | if (drawBackground) | 646 | if (drawBackground) |
646 | { | 647 | { |
647 | _p->fillRect(_x, _y-m_ascent, w, m_lineSpacing, bgColour); | 648 | _p->fillRect(_x, _y-m_ascent, w, m_lineSpacing, bgColour); |
648 | } | 649 | } |
649 | } | 650 | } |
650 | 651 | ||
651 | CStyle CDrawBuffer::laststyle() | 652 | CStyle CDrawBuffer::laststyle() |
652 | { | 653 | { |
653 | return segs.last().style; | 654 | return segs.last().style; |
654 | } | 655 | } |
655 | 656 | ||
656 | CStyle CDrawBuffer::firststyle() | 657 | CStyle CDrawBuffer::firststyle() |
657 | { | 658 | { |
658 | return segs.first().style; | 659 | return segs.first().style; |
659 | } | 660 | } |
660 | 661 | ||
661 | linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*& img) | 662 | linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*& img, size_t& tabletgt) |
662 | { | 663 | { |
663 | linkType ret = eNone; | 664 | linkType ret = eNone; |
664 | int end = 0; | 665 | int end = 0; |
665 | CStyle currentstyle; | 666 | CStyle currentstyle; |
666 | CList<textsegment>::iterator textstart = segs.begin(); | 667 | CList<textsegment>::iterator textstart = segs.begin(); |
667 | CList<textsegment>::iterator textend = textstart; | 668 | CList<textsegment>::iterator textend = textstart; |
668 | do | 669 | do |
669 | { | 670 | { |
670 | textend++; | 671 | textend++; |
671 | end = (textend != segs.end()) ? textend->start : len; | 672 | end = (textend != segs.end()) ? textend->start : len; |
672 | currentstyle = textstart->style; | 673 | currentstyle = textstart->style; |
673 | /* | 674 | /* |
674 | if (currentstyle.isPicture()) qDebug("Passed thru picture"); | 675 | if (currentstyle.isPicture()) qDebug("Passed thru picture"); |
675 | if (currentstyle.getLink()) qDebug("Passed thru link"); | 676 | if (currentstyle.getLink()) qDebug("Passed thru link"); |
676 | //qDebug("islink:%d - %d", numchars, end); | 677 | //qDebug("islink:%d - %d", numchars, end); |
677 | */ | 678 | */ |
678 | textstart = textend; | 679 | textstart = textend; |
679 | } | 680 | } |
680 | while (textend != segs.end() && end <= numchars); | 681 | while (textend != segs.end() && end <= numchars); |
681 | img = currentstyle.getPicture(); | 682 | img = currentstyle.getPicture(); |
682 | if (currentstyle.getPictureLink()) | 683 | if (currentstyle.getPictureLink()) |
683 | { | 684 | { |
684 | pictgt = currentstyle.getPictureLinkData(); | 685 | pictgt = currentstyle.getPictureLinkData(); |
685 | ret |= ePicture; | 686 | ret |= ePicture; |
686 | } | 687 | } |
687 | if (currentstyle.getLink()) | 688 | if (currentstyle.getLink()) |
688 | { | 689 | { |
689 | tgt = currentstyle.getData(); | 690 | tgt = currentstyle.getData(); |
690 | offset = currentstyle.getOffset(); | 691 | offset = currentstyle.getOffset(); |
691 | ret |= eLink; | 692 | ret |= eLink; |
692 | } | 693 | } |
694 | if (currentstyle.isTable()) | ||
695 | { | ||
696 | tabletgt = currentstyle.getTable(); | ||
697 | ret |= eTable; | ||
698 | } | ||
693 | return ret; | 699 | return ret; |
694 | } | 700 | } |
695 | 701 | ||
696 | void CDrawBuffer::resize(int availht) | 702 | void CDrawBuffer::resize(int availht) |
697 | { | 703 | { |
698 | int gzoom = fc->gzoom(); | 704 | int gzoom = fc->gzoom(); |
699 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; | 705 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
700 | /* | 706 | /* |
701 | int t_ascent = 0; | 707 | int t_ascent = 0; |
702 | int t_descent = 0; | 708 | int t_descent = 0; |
703 | int t_lineExtraSpacing = 0; | 709 | int t_lineExtraSpacing = 0; |
704 | */ | 710 | */ |
705 | int t_lineSpacing = 0; | 711 | int t_lineSpacing = 0; |
706 | m_hastext = false; | 712 | m_hastext = false; |
707 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) | 713 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) |
708 | { | 714 | { |
709 | CStyle _style = iter->style; | 715 | CStyle _style = iter->style; |
710 | if (!_style.isPicture()) | 716 | if (!_style.isPicture()) |
711 | { | 717 | { |
712 | m_hastext = true; | 718 | m_hastext = true; |
713 | break; | 719 | break; |
714 | } | 720 | } |
715 | iter++; | 721 | iter++; |
716 | } | 722 | } |
717 | if (m_hastext) | 723 | if (m_hastext) |
718 | { | 724 | { |
719 | 725 | int p_linespacing = 0; | |
720 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) | 726 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) |
721 | { | 727 | { |
722 | CList<textsegment>::iterator next = iter; | 728 | CList<textsegment>::iterator next = iter; |
723 | iter++; | 729 | iter++; |
724 | int st = next->start; | 730 | int st = next->start; |
725 | if (st < 0) st = 0; | 731 | if (st < 0) st = 0; |
726 | 732 | ||
727 | CStyle _style = next->style; | 733 | CStyle _style = next->style; |
728 | 734 | ||
729 | int linespacing, ascent, descent, extra; | 735 | int linespacing, ascent, descent, extra; |
730 | 736 | ||
731 | ascent = fc->ascent(_style); | 737 | ascent = fc->ascent(_style); |
732 | descent = fc->descent(_style); | 738 | descent = fc->descent(_style); |
733 | linespacing = fc->lineSpacing(_style); | 739 | linespacing = fc->lineSpacing(_style); |
734 | extra = linespacing - ascent - descent; | 740 | extra = linespacing - ascent - descent; |
735 | /* | 741 | /* |
736 | if (ascent > t_ascent) t_ascent = ascent; | 742 | if (ascent > t_ascent) t_ascent = ascent; |
737 | if (descent > t_descent) t_descent = descent; | 743 | if (descent > t_descent) t_descent = descent; |
738 | if (extra > t_lineExtraSpacing) t_lineExtraSpacing = extra; | 744 | if (extra > t_lineExtraSpacing) t_lineExtraSpacing = extra; |
739 | t_lineSpacing = t_ascent+t_descent+t_lineExtraSpacing; | 745 | t_lineSpacing = t_ascent+t_descent+t_lineExtraSpacing; |
740 | */ | 746 | */ |
741 | if (linespacing > t_lineSpacing) t_lineSpacing = linespacing; | 747 | if (linespacing > t_lineSpacing) t_lineSpacing = linespacing; |
742 | if (_style.isPicture()) | 748 | if (_style.isPicture()) |
743 | { | 749 | { |
744 | int ht = (gzoom*_style.getPicture()->height())/100; | 750 | int ht = (gzoom*_style.getPicture()->height())/100; |
745 | int wt = (gzoom*_style.getPicture()->width())/100; | 751 | int wt = (gzoom*_style.getPicture()->width())/100; |
746 | 752 | ||
747 | bool willscale = false; | 753 | bool willscale = false; |
748 | if (ht > availht) | 754 | if (ht > availht) |
749 | { | 755 | { |
750 | wt = (wt*availht)/ht; | 756 | wt = (wt*availht)/ht; |
751 | ht = availht; | 757 | ht = availht; |
752 | willscale = true; | 758 | willscale = true; |
753 | } | 759 | } |
754 | if (willscale || _style.canScale()) | 760 | if (willscale || _style.canScale()) |
755 | { | 761 | { |
756 | descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2; | 762 | descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2; |
757 | ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2; | 763 | ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2; |
758 | } | 764 | } |
765 | else | ||
766 | { | ||
767 | descent = (_style.getPicture()->height()-ascent)/2; | ||
768 | ascent = (_style.getPicture()->height()+ascent)/2; | ||
769 | } | ||
770 | int lineSpacing = ascent+descent; | ||
771 | if (lineSpacing > p_linespacing) | ||
772 | { | ||
773 | p_linespacing = lineSpacing; | ||
774 | } | ||
775 | extra = 0; | ||
759 | } | 776 | } |
760 | 777 | ||
761 | /* | 778 | /* |
762 | else if (fc != NULL) | 779 | else if (fc != NULL) |
763 | { | 780 | { |
764 | ascent = fc->ascent(_style); | 781 | ascent = fc->ascent(_style); |
765 | descent = fc->descent(_style); | 782 | descent = fc->descent(_style); |
766 | linespacing = fc->lineSpacing(_style); | 783 | linespacing = fc->lineSpacing(_style); |
767 | extra = linespacing - ascent - descent; | 784 | extra = linespacing - ascent - descent; |
768 | } | 785 | } |
769 | */ | 786 | */ |
770 | if (ascent > m_ascent) m_ascent = ascent; | 787 | if (ascent > m_ascent) m_ascent = ascent; |
771 | if (descent > m_descent) m_descent = descent; | 788 | if (descent > m_descent) m_descent = descent; |
772 | if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; | 789 | if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; |
773 | m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; | 790 | m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; |
774 | } | 791 | } |
775 | m_showPartial = (m_lineSpacing > t_lineSpacing); | 792 | m_showPartial = (p_linespacing > t_lineSpacing); |
776 | int lead = fc->getlead(); | 793 | int lead = fc->getlead(); |
777 | if (lead != 0) | 794 | if (lead != 0) |
778 | { | 795 | { |
779 | int xt = (lead*t_lineSpacing+5)/10; | 796 | int xt = (lead*t_lineSpacing+5)/10; |
780 | m_lineExtraSpacing += xt; | 797 | m_lineExtraSpacing += xt; |
781 | m_lineSpacing += xt; | 798 | m_lineSpacing += xt; |
782 | } | 799 | } |
783 | if (m_bSop) | 800 | if (m_bSop) |
784 | { | 801 | { |
785 | int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10; | 802 | int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10; |
786 | //qDebug("ExtraSpace:%d", xt); | 803 | //qDebug("ExtraSpace:%d", xt); |
787 | m_ascent += xt; | 804 | m_ascent += xt; |
788 | m_lineSpacing += xt; | 805 | m_lineSpacing += xt; |
789 | } | 806 | } |
790 | } | 807 | } |
791 | else | 808 | else |
792 | { | 809 | { |
793 | m_showPartial = true; | 810 | m_showPartial = true; |
794 | int maxheight = 0; | 811 | int maxheight = 0; |
795 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); iter++) | 812 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); iter++) |
796 | { | 813 | { |
797 | CStyle _style = iter->style; | 814 | CStyle _style = iter->style; |
798 | if (_style.isPicture()) | 815 | if (_style.isPicture()) |
799 | { | 816 | { |
800 | int ht = 0; | 817 | int ht = 0; |
801 | if (_style.canScale()) | 818 | if (_style.canScale()) |
802 | { | 819 | { |
803 | ht = ((gzoom*_style.getPicture()->height())/100); | 820 | ht = ((gzoom*_style.getPicture()->height())/100); |
804 | } | 821 | } |
805 | else | 822 | else |
806 | { | 823 | { |
807 | ht = _style.getPicture()->height(); | 824 | ht = _style.getPicture()->height(); |
808 | } | 825 | } |
809 | if (ht > availht) | 826 | if (ht > availht) |
810 | { | 827 | { |
811 | ht = availht; | 828 | ht = availht; |
812 | } | 829 | } |
813 | if (ht > maxheight) maxheight = ht; | 830 | if (ht > maxheight) maxheight = ht; |
814 | } | 831 | } |
815 | } | 832 | } |
816 | m_ascent = maxheight/2; | 833 | m_ascent = maxheight/2; |
817 | m_descent = maxheight-m_ascent; | 834 | m_descent = maxheight-m_ascent; |
818 | m_lineExtraSpacing = 0; | 835 | m_lineExtraSpacing = 0; |
819 | m_lineSpacing = m_ascent+m_descent; | 836 | m_lineSpacing = m_ascent+m_descent; |
820 | } | 837 | } |
821 | } | 838 | } |
822 | 839 | ||
823 | CStyle* CDrawBuffer::getNextLink(int& offset) | 840 | CStyle* CDrawBuffer::getNextLink(int& offset) |
824 | { | 841 | { |
825 | CStyle* ret = NULL; | 842 | CStyle* ret = NULL; |
826 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); ++iter) | 843 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); ++iter) |
827 | { | 844 | { |
828 | if (offset < iter->start && iter->style.getLink()) | 845 | if (offset < iter->start && iter->style.getLink()) |
829 | { | 846 | { |
830 | ret = &(iter->style); | 847 | ret = &(iter->style); |
831 | offset = iter->start; | 848 | offset = iter->start; |
832 | qDebug("Found a link at offset %d!", offset); | 849 | qDebug("Found a link at offset %d!", offset); |
833 | break; | 850 | break; |
834 | } | 851 | } |
835 | } | 852 | } |
836 | return ret; | 853 | return ret; |
837 | } | 854 | } |
838 | 855 | ||
839 | int CDrawBuffer::invertLink(int offset) | 856 | int CDrawBuffer::invertLink(int offset) |
840 | { | 857 | { |
841 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); ++iter) | 858 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); ++iter) |
842 | { | 859 | { |
843 | if (offset <= iter->start && iter->style.getLink()) | 860 | if (offset <= iter->start && iter->style.getLink()) |
844 | { | 861 | { |
845 | iter->style.invert(); | 862 | iter->style.invert(); |
846 | unsigned long currentvalue = iter->style.getData(); | 863 | unsigned long currentvalue = iter->style.getData(); |
847 | qDebug("Link data %u", currentvalue); | 864 | qDebug("Link data %u", currentvalue); |
848 | CList<textsegment>::iterator next = iter; | 865 | CList<textsegment>::iterator next = iter; |
849 | ++next; | 866 | ++next; |
850 | while (next != segs.end() && (currentvalue == next->style.getData()) && next->style.getLink()) | 867 | while (next != segs.end() && (currentvalue == next->style.getData()) && next->style.getLink()) |
851 | { | 868 | { |
852 | next->style.invert(); | 869 | next->style.invert(); |
853 | offset = next->start; | 870 | offset = next->start; |
854 | iter++; | 871 | iter++; |
855 | next++; | 872 | next++; |
856 | } | 873 | } |
857 | return offset; | 874 | return offset; |
858 | } | 875 | } |
859 | } | 876 | } |
860 | qDebug("Failed to invert"); | 877 | qDebug("Failed to invert"); |
861 | return offset; | 878 | return offset; |
862 | } | 879 | } |
diff --git a/noncore/apps/opie-reader/CDrawBuffer.h b/noncore/apps/opie-reader/CDrawBuffer.h index 2625a72..1782cf8 100644 --- a/noncore/apps/opie-reader/CDrawBuffer.h +++ b/noncore/apps/opie-reader/CDrawBuffer.h | |||
@@ -1,87 +1,87 @@ | |||
1 | #ifndef __CDRAWBUFFER_H | 1 | #ifndef __CDRAWBUFFER_H |
2 | #define __CDRAWBUFFER_H | 2 | #define __CDRAWBUFFER_H |
3 | 3 | ||
4 | #include <qcolor.h> | 4 | #include <qcolor.h> |
5 | #include "StyleConsts.h" | 5 | #include "StyleConsts.h" |
6 | #include "CBuffer.h" | 6 | #include "CBuffer.h" |
7 | #include "my_list.h" | 7 | #include "my_list.h" |
8 | #include "linktype.h" | 8 | #include "linktype.h" |
9 | 9 | ||
10 | class QPainter; | 10 | class QPainter; |
11 | class QImage; | 11 | class QImage; |
12 | 12 | ||
13 | struct textsegment | 13 | struct textsegment |
14 | { | 14 | { |
15 | int start; | 15 | int start; |
16 | CStyle style; | 16 | CStyle style; |
17 | textsegment(int _start, const CStyle& _style) | 17 | textsegment(int _start, const CStyle& _style) |
18 | : | 18 | : |
19 | start(_start), style(_style) | 19 | start(_start), style(_style) |
20 | {} | 20 | {} |
21 | }; | 21 | }; |
22 | 22 | ||
23 | class FontControl; | 23 | class FontControl; |
24 | 24 | ||
25 | class CDrawBuffer : public CBuffer | 25 | class CDrawBuffer : public CBuffer |
26 | { | 26 | { |
27 | bool m_hastext; | 27 | bool m_hastext; |
28 | CList<textsegment> segs; | 28 | CList<textsegment> segs; |
29 | int len; | 29 | int len; |
30 | FontControl* fc; | 30 | FontControl* fc; |
31 | int m_ascent, m_descent, m_lineSpacing, m_lineExtraSpacing; | 31 | int m_ascent, m_descent, m_lineSpacing, m_lineExtraSpacing; |
32 | bool m_bEof, m_bBop; | 32 | bool m_bEof, m_bBop; |
33 | bool m_bSop, m_bEop; | 33 | bool m_bSop, m_bEop; |
34 | bool m_showPartial; | 34 | bool m_showPartial; |
35 | CDrawBuffer(const CDrawBuffer&); | 35 | CDrawBuffer(const CDrawBuffer&); |
36 | CDrawBuffer& operator=(const tchar*sztmp); | 36 | CDrawBuffer& operator=(const tchar*sztmp); |
37 | void Highlight(QPainter*_p, bool drawBackground, int _x, int _y, int w, QColor bgColour); | 37 | void Highlight(QPainter*_p, bool drawBackground, int _x, int _y, int w, QColor bgColour); |
38 | public: | 38 | public: |
39 | void setstartpara() { m_bSop = true; } | 39 | void setstartpara() { m_bSop = true; } |
40 | void setBop() { m_bBop = true; } | 40 | void setBop() { m_bBop = true; } |
41 | bool isBop() { return m_bBop; } | 41 | bool isBop() { return m_bBop; } |
42 | void setendpara() { m_bEop = true; } | 42 | void setendpara() { m_bEop = true; } |
43 | void setendpara(const CStyle& cs); | 43 | void setendpara(const CStyle& cs); |
44 | int leftMargin(); | 44 | int leftMargin(); |
45 | int rightMargin(); | 45 | int rightMargin(); |
46 | void setEof() { m_bEof = true; } | 46 | void setEof() { m_bEof = true; } |
47 | bool eof() { return m_bEof; } | 47 | bool eof() { return m_bEof; } |
48 | CDrawBuffer& operator=(CDrawBuffer&); | 48 | CDrawBuffer& operator=(CDrawBuffer&); |
49 | CDrawBuffer(FontControl* _fs = NULL) | 49 | CDrawBuffer(FontControl* _fs = NULL) |
50 | : | 50 | : |
51 | fc(_fs) | 51 | fc(_fs) |
52 | { | 52 | { |
53 | empty(); | 53 | empty(); |
54 | } | 54 | } |
55 | ~CDrawBuffer(); | 55 | ~CDrawBuffer(); |
56 | /* | 56 | /* |
57 | CDrawBuffer() | 57 | CDrawBuffer() |
58 | : | 58 | : |
59 | size(0) | 59 | size(0) |
60 | { | 60 | { |
61 | empty(); | 61 | empty(); |
62 | } | 62 | } |
63 | */ | 63 | */ |
64 | int charwidth(int numchars, CStyle& currentstyle); | 64 | int charwidth(int numchars, CStyle& currentstyle); |
65 | int charwidth(int numchars); | 65 | int charwidth(int numchars); |
66 | int width(int availht, int numchars = -1, bool onscreen = false, int scwidth = 0, unsigned short _lborder = 0, unsigned short _rborder = 0); | 66 | int width(int availht, int numchars = -1, bool onscreen = false, int scwidth = 0, unsigned short _lborder = 0, unsigned short _rborder = 0); |
67 | int offset(int, unsigned short, unsigned short, int); | 67 | int offset(int, unsigned short, unsigned short, int); |
68 | void render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scw, unsigned short, unsigned short, const QColor&, int availht); | 68 | void render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scw, unsigned short, unsigned short, const QColor&, int availht); |
69 | void empty(); | 69 | void empty(); |
70 | void addch(tchar ch, CStyle _style); | 70 | void addch(tchar ch, CStyle _style); |
71 | void truncate(int); | 71 | void truncate(int); |
72 | void setright(CDrawBuffer&, int); | 72 | void setright(CDrawBuffer&, int); |
73 | CStyle firststyle(); | 73 | CStyle firststyle(); |
74 | CStyle laststyle(); | 74 | CStyle laststyle(); |
75 | int ascent() { return m_ascent; } | 75 | int ascent() { return m_ascent; } |
76 | int descent() { return m_descent; } | 76 | int descent() { return m_descent; } |
77 | int lineSpacing() { return m_lineSpacing; } | 77 | int lineSpacing() { return m_lineSpacing; } |
78 | int lineExtraSpacing() { return m_lineExtraSpacing; } | 78 | int lineExtraSpacing() { return m_lineExtraSpacing; } |
79 | 79 | ||
80 | // void frig(); | 80 | // void frig(); |
81 | linkType getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*&); | 81 | linkType getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*&, size_t&); |
82 | void resize(int); | 82 | void resize(int); |
83 | bool showPartial() { return m_showPartial; } | 83 | bool showPartial() { return m_showPartial; } |
84 | CStyle* getNextLink(int&); | 84 | CStyle* getNextLink(int&); |
85 | int invertLink(int); | 85 | int invertLink(int); |
86 | }; | 86 | }; |
87 | #endif | 87 | #endif |
diff --git a/noncore/apps/opie-reader/CEncoding.h b/noncore/apps/opie-reader/CEncoding.h index 1dfd74d..76cbfae 100644 --- a/noncore/apps/opie-reader/CEncoding.h +++ b/noncore/apps/opie-reader/CEncoding.h | |||
@@ -1,94 +1,101 @@ | |||
1 | #ifndef __CENCODING_H | 1 | #ifndef __CENCODING_H |
2 | #define __CENCODING_H | 2 | #define __CENCODING_H |
3 | 3 | ||
4 | #include "CExpander.h" | 4 | #include "CExpander.h" |
5 | 5 | ||
6 | #define MAX_ENCODING 6 | 6 | #define MAX_ENCODING 6 |
7 | 7 | ||
8 | class CEncoding : public CCharacterSource | 8 | class CEncoding : public CCharacterSource |
9 | { | 9 | { |
10 | friend class CFilterChain; | 10 | friend class CFilterChain; |
11 | protected: | 11 | protected: |
12 | CExpander_Interface* parent; | 12 | CExpander_Interface* parent; |
13 | linkType hyperlink(unsigned int n, unsigned int noff, QString& t, QString& nm) { return parent->hyperlink(n, noff, t, nm); } | 13 | linkType hyperlink(unsigned int n, unsigned int noff, QString& t, QString& nm) { return parent->hyperlink(n, noff, t, nm); } |
14 | public: | 14 | public: |
15 | virtual QString getTableAsHtml(unsigned long loc) | ||
16 | { | ||
17 | qDebug("CEncoding::getTableAsHtml()"); | ||
18 | return parent->getTableAsHtml(loc); | ||
19 | } | ||
15 | CEncoding() : parent(NULL) {} | 20 | CEncoding() : parent(NULL) {} |
16 | void setparent(CExpander_Interface* p) { parent = p; } | 21 | void setparent(CExpander_Interface* p) { parent = p; } |
17 | virtual ~CEncoding() {}; | 22 | virtual ~CEncoding() {}; |
18 | void locate(unsigned int n) { parent->locate(n); } | 23 | void locate(unsigned int n) { parent->locate(n); } |
19 | bool findanchor(const QString& nm) { return false; } | 24 | bool findanchor(const QString& nm) |
25 | { | ||
26 | return parent->findanchor(nm); | ||
27 | } | ||
20 | void saveposn(const QString& f, size_t posn) { parent->saveposn(posn); } | 28 | void saveposn(const QString& f, size_t posn) { parent->saveposn(posn); } |
21 | void writeposn(const QString& f, size_t posn) { parent->writeposn(posn); } | 29 | void writeposn(const QString& f, size_t posn) { parent->writeposn(posn); } |
22 | linkType forward(QString& f, size_t& loc) { return parent->forward(loc); } | 30 | linkType forward(QString& f, size_t& loc) { return parent->forward(loc); } |
23 | linkType back(QString& f, size_t& loc) { return parent->back(loc); } | 31 | linkType back(QString& f, size_t& loc) { return parent->back(loc); } |
24 | bool hasnavigation() { return parent->hasnavigation(); } | 32 | bool hasnavigation() { return parent->hasnavigation(); } |
25 | virtual int getwidth() { return parent->getwidth(); } | 33 | virtual int getwidth() { return parent->getwidth(); } |
26 | QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); } | 34 | QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); } |
27 | QImage* getPicture(const QString& href) { return parent->getPicture(href); } | 35 | QImage* getPicture(const QString& href) { return parent->getPicture(href); } |
28 | bool getFile(const QString& href) { qDebug("Encoding Get File"); return parent->getFile(href);} | 36 | bool getFile(const QString& href, const QString& nm) { qDebug("Encoding Get File"); return parent->getFile(href, nm);} |
29 | 37 | unsigned long startSection() { return parent->startSection(); } | |
30 | |||
31 | }; | 38 | }; |
32 | 39 | ||
33 | class CUtf8 : public CEncoding | 40 | class CUtf8 : public CEncoding |
34 | { | 41 | { |
35 | public: | 42 | public: |
36 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 43 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
37 | QString about() { return QString("UTF8 decoder (c) Tim Wentford\n")+parent->about(); } | 44 | QString about() { return QString("UTF8 decoder (c) Tim Wentford\n")+parent->about(); } |
38 | }; | 45 | }; |
39 | 46 | ||
40 | class CUcs16be : public CEncoding | 47 | class CUcs16be : public CEncoding |
41 | { | 48 | { |
42 | public: | 49 | public: |
43 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 50 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
44 | QString about() { return QString("UCS16 decoder (c) Tim Wentford\n")+parent->about(); } | 51 | QString about() { return QString("UCS16 decoder (c) Tim Wentford\n")+parent->about(); } |
45 | }; | 52 | }; |
46 | 53 | ||
47 | class CUcs16le : public CEncoding | 54 | class CUcs16le : public CEncoding |
48 | { | 55 | { |
49 | public: | 56 | public: |
50 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 57 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
51 | QString about() { return QString("UCS16 decoder (c) Tim Wentford\n")+parent->about(); } | 58 | QString about() { return QString("UCS16 decoder (c) Tim Wentford\n")+parent->about(); } |
52 | }; | 59 | }; |
53 | 60 | ||
54 | class Ccp1252 : public CEncoding | 61 | class Ccp1252 : public CEncoding |
55 | { | 62 | { |
56 | public: | 63 | public: |
57 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 64 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
58 | QString about() { return QString("Codepage 1252 decoder (c) Tim Wentford\n")+parent->about(); } | 65 | QString about() { return QString("Codepage 1252 decoder (c) Tim Wentford\n")+parent->about(); } |
59 | }; | 66 | }; |
60 | 67 | ||
61 | class CPalm : public Ccp1252 | 68 | class CPalm : public Ccp1252 |
62 | { | 69 | { |
63 | public: | 70 | public: |
64 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 71 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
65 | QString about() { return QString("Palm decoder (c) Tim Wentford\n")+parent->about(); } | 72 | QString about() { return QString("Palm decoder (c) Tim Wentford\n")+parent->about(); } |
66 | }; | 73 | }; |
67 | 74 | ||
68 | class CAscii : public CEncoding | 75 | class CAscii : public CEncoding |
69 | { | 76 | { |
70 | public: | 77 | public: |
71 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 78 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
72 | QString about() { return QString("Vanilla Ascii decoder (c) Tim Wentford\n")+parent->about(); } | 79 | QString about() { return QString("Vanilla Ascii decoder (c) Tim Wentford\n")+parent->about(); } |
73 | }; | 80 | }; |
74 | 81 | ||
75 | #include "CEncoding_tables.h" | 82 | #include "CEncoding_tables.h" |
76 | 83 | ||
77 | class CGeneral8Bit : public CEncoding | 84 | class CGeneral8Bit : public CEncoding |
78 | { | 85 | { |
79 | int m_index; | 86 | int m_index; |
80 | public: | 87 | public: |
81 | CGeneral8Bit(int _i) : m_index(_i) | 88 | CGeneral8Bit(int _i) : m_index(_i) |
82 | { | 89 | { |
83 | // qDebug("8Bit:%d", _i); | 90 | // qDebug("8Bit:%d", _i); |
84 | // qDebug("%s", unicodetable::iterator(_i)->mime); | 91 | // qDebug("%s", unicodetable::iterator(_i)->mime); |
85 | } | 92 | } |
86 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 93 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
87 | { | 94 | { |
88 | parent->getch(ch, sty, pos); | 95 | parent->getch(ch, sty, pos); |
89 | ch = unicodetable::unicodevalue(m_index, ch); | 96 | ch = unicodetable::unicodevalue(m_index, ch); |
90 | } | 97 | } |
91 | QString about() { return QString("8-bit decoder (c) Tim Wentford - based on QT code\n")+parent->about(); } | 98 | QString about() { return QString("8-bit decoder (c) Tim Wentford - based on QT code\n")+parent->about(); } |
92 | }; | 99 | }; |
93 | 100 | ||
94 | #endif | 101 | #endif |
diff --git a/noncore/apps/opie-reader/CExpander.cpp b/noncore/apps/opie-reader/CExpander.cpp index e398d86..1158a7a 100644 --- a/noncore/apps/opie-reader/CExpander.cpp +++ b/noncore/apps/opie-reader/CExpander.cpp | |||
@@ -1,103 +1,111 @@ | |||
1 | #include "CExpander.h" | 1 | #include "CExpander.h" |
2 | #ifdef USEQPE | ||
3 | #include <qpe/global.h> | ||
4 | #endif | ||
2 | 5 | ||
3 | size_t CExpander::getHome() { return m_homepos; } | 6 | size_t CExpander::getHome() { return m_homepos; } |
4 | 7 | ||
5 | CExpander::CExpander() : m_homepos(0), fname(NULL), m_scrWidth(240), m_currentstart(1), m_currentend(0) {}; | 8 | CExpander::CExpander() : m_homepos(0), fname(NULL), m_scrWidth(240), m_currentstart(1), m_currentend(0) {}; |
6 | 9 | ||
7 | CExpander::~CExpander() { if (fname != NULL) delete [] fname; }; | 10 | CExpander::~CExpander() { if (fname != NULL) delete [] fname; }; |
8 | 11 | ||
9 | int CExpander::openfile(const char *src) | 12 | int CExpander::openfile(const char *src) |
10 | { | 13 | { |
11 | bSuspended = false; | 14 | bSuspended = false; |
12 | fname = strdup(src); | 15 | fname = strdup(src); |
13 | return OpenFile(src); | 16 | return OpenFile(src); |
14 | } | 17 | } |
15 | 18 | ||
16 | void CExpander::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 19 | void CExpander::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
17 | { | 20 | { |
18 | pos = locate(); | 21 | pos = locate(); |
19 | int ich = getch(); | 22 | int ich = getch(); |
20 | ch = (ich == EOF) ? UEOF : ich; | 23 | ch = (ich == EOF) ? UEOF : ich; |
21 | // sty.unset(); | 24 | // sty.unset(); |
22 | } | 25 | } |
23 | 26 | ||
24 | linkType CExpander::hyperlink(unsigned int n, unsigned int, QString& wrd, QString& nm) | 27 | linkType CExpander::hyperlink(unsigned int n, unsigned int, QString& wrd, QString& nm) |
25 | { | 28 | { |
26 | locate(n); | 29 | locate(n); |
27 | return eLink; | 30 | return eLink; |
28 | } | 31 | } |
29 | 32 | ||
30 | unsigned long CExpander::startSection() | 33 | unsigned long CExpander::startSection() |
31 | { | 34 | { |
32 | unsigned long current = locate(); | 35 | unsigned long current = locate(); |
33 | if (m_currentstart > current || current > m_currentend) | 36 | if (m_currentstart > current || current > m_currentend) |
34 | { | 37 | { |
35 | start2endSection(); | 38 | start2endSection(); |
36 | } | 39 | } |
37 | return m_currentstart; | 40 | return m_currentstart; |
38 | } | 41 | } |
39 | 42 | ||
40 | unsigned long CExpander::endSection() | 43 | unsigned long CExpander::endSection() |
41 | { | 44 | { |
42 | unsigned long current = locate(); | 45 | unsigned long current = locate(); |
43 | if (m_currentstart > current || current > m_currentend) | 46 | if (m_currentstart > current || current > m_currentend) |
44 | { | 47 | { |
45 | start2endSection(); | 48 | start2endSection(); |
46 | } | 49 | } |
47 | return m_currentend; | 50 | return m_currentend; |
48 | } | 51 | } |
49 | 52 | ||
50 | void CExpander::start2endSection() | 53 | void CExpander::start2endSection() |
51 | { | 54 | { |
52 | m_currentstart = 0; | 55 | m_currentstart = 0; |
53 | unsigned long file; | 56 | unsigned long file; |
54 | sizes(file, m_currentend); | 57 | sizes(file, m_currentend); |
55 | } | 58 | } |
56 | 59 | ||
57 | #ifdef USEQPE | 60 | #ifdef USEQPE |
58 | void CExpander::suspend(FILE*& fin) | 61 | void CExpander::suspend(FILE*& fin) |
59 | { | 62 | { |
60 | bSuspended = true; | 63 | bSuspended = true; |
61 | suspos = ftell(fin); | 64 | suspos = ftell(fin); |
62 | fclose(fin); | 65 | fclose(fin); |
63 | fin = NULL; | 66 | fin = NULL; |
64 | sustime = time(NULL); | 67 | sustime = time(NULL); |
65 | } | 68 | } |
66 | 69 | ||
67 | void CExpander::unsuspend(FILE*& fin) | 70 | void CExpander::unsuspend(FILE*& fin) |
68 | { | 71 | { |
69 | if (bSuspended) | 72 | if (bSuspended) |
70 | { | 73 | { |
71 | bSuspended = false; | 74 | bSuspended = false; |
72 | int delay = time(NULL) - sustime; | 75 | int delay = time(NULL) - sustime; |
73 | if (delay < 10) sleep(10-delay); | 76 | if (delay < 10) |
77 | { | ||
78 | Global::statusMessage("Stalling"); | ||
79 | sleep(10-delay); | ||
80 | } | ||
74 | fin = fopen(fname, "rb"); | 81 | fin = fopen(fname, "rb"); |
75 | for (int i = 0; fin == NULL && i < 5; i++) | 82 | for (int i = 0; fin == NULL && i < 5; i++) |
76 | { | 83 | { |
84 | Global::statusMessage("Stalling"); | ||
77 | sleep(5); | 85 | sleep(5); |
78 | fin = fopen(fname, "rb"); | 86 | fin = fopen(fname, "rb"); |
79 | } | 87 | } |
80 | if (fin == NULL) | 88 | if (fin == NULL) |
81 | { | 89 | { |
82 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); | 90 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); |
83 | exit(0); | 91 | exit(0); |
84 | } | 92 | } |
85 | suspos = fseek(fin, suspos, SEEK_SET); | 93 | suspos = fseek(fin, suspos, SEEK_SET); |
86 | } | 94 | } |
87 | } | 95 | } |
88 | #endif | 96 | #endif |
89 | 97 | ||
90 | void CExpander::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | 98 | void CExpander::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) |
91 | { | 99 | { |
92 | len = srclen; | 100 | len = srclen; |
93 | data = new unsigned char[len]; | 101 | data = new unsigned char[len]; |
94 | memcpy(data, src, len); | 102 | memcpy(data, src, len); |
95 | } | 103 | } |
96 | 104 | ||
97 | void CExpander::putSaveData(unsigned char*& src, unsigned short& srclen) | 105 | void CExpander::putSaveData(unsigned char*& src, unsigned short& srclen) |
98 | { | 106 | { |
99 | if (srclen != 0) | 107 | if (srclen != 0) |
100 | { | 108 | { |
101 | qDebug("Don't know what to do with non-zero save data"); | 109 | qDebug("Don't know what to do with non-zero save data"); |
102 | } | 110 | } |
103 | } | 111 | } |
diff --git a/noncore/apps/opie-reader/CExpander.h b/noncore/apps/opie-reader/CExpander.h index 7fa84f9..24c317d 100644 --- a/noncore/apps/opie-reader/CExpander.h +++ b/noncore/apps/opie-reader/CExpander.h | |||
@@ -1,148 +1,156 @@ | |||
1 | #ifndef __CExpander_h | 1 | #ifndef __CExpander_h |
2 | #define __CExpander_h | 2 | #define __CExpander_h |
3 | 3 | ||
4 | #ifndef _WINDOWS | 4 | #ifndef _WINDOWS |
5 | #include <unistd.h> | 5 | #include <unistd.h> |
6 | #endif | 6 | #endif |
7 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | #include <time.h> | 8 | #include <time.h> |
9 | #include <sys/stat.h> | 9 | #include <sys/stat.h> |
10 | #include <qmessagebox.h> | 10 | #include <qmessagebox.h> |
11 | #include "config.h" | 11 | #include "config.h" |
12 | #include "StyleConsts.h" | 12 | #include "StyleConsts.h" |
13 | #include "Markups.h" | 13 | #include "Markups.h" |
14 | #include "names.h" | 14 | #include "names.h" |
15 | #include "linktype.h" | 15 | #include "linktype.h" |
16 | 16 | ||
17 | class QImage; | 17 | class QImage; |
18 | class Bkmk; | 18 | class Bkmk; |
19 | class QString; | 19 | class QString; |
20 | 20 | ||
21 | template<class T> | 21 | template<class T> |
22 | class CList; | 22 | class CList; |
23 | 23 | ||
24 | class CCharacterSource | 24 | class CCharacterSource |
25 | { | 25 | { |
26 | public: | 26 | public: |
27 | virtual QString getTableAsHtml(unsigned long loc) = 0; | ||
27 | virtual void getch(tchar&, CStyle&, unsigned long&) = 0; | 28 | virtual void getch(tchar&, CStyle&, unsigned long&) = 0; |
28 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString&, QString& nm) = 0; | 29 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString&, QString& nm) = 0; |
29 | virtual void locate(unsigned int n) = 0; | 30 | virtual void locate(unsigned int n) = 0; |
30 | virtual bool findanchor(const QString& nm) = 0; | 31 | virtual bool findanchor(const QString& nm) = 0; |
31 | virtual void saveposn(const QString& f, size_t posn) = 0; | 32 | virtual void saveposn(const QString& f, size_t posn) = 0; |
32 | virtual void writeposn(const QString& f, size_t posn) = 0; | 33 | virtual void writeposn(const QString& f, size_t posn) = 0; |
33 | virtual linkType forward(QString& f, size_t& loc) = 0; | 34 | virtual linkType forward(QString& f, size_t& loc) = 0; |
34 | virtual linkType back(QString& f, size_t& loc) = 0; | 35 | virtual linkType back(QString& f, size_t& loc) = 0; |
35 | virtual bool hasnavigation() = 0; | 36 | virtual bool hasnavigation() = 0; |
36 | virtual int getwidth() = 0; | 37 | virtual int getwidth() = 0; |
37 | virtual QImage* getPicture(unsigned long) = 0; | 38 | virtual QImage* getPicture(unsigned long) = 0; |
38 | virtual QImage* getPicture(const QString& href) = 0; | 39 | virtual QImage* getPicture(const QString& href) = 0; |
39 | virtual bool getFile(const QString& href) = 0; | 40 | virtual bool getFile(const QString& href, const QString& nm) = 0; |
40 | virtual QString about() = 0; | 41 | virtual QString about() = 0; |
42 | virtual unsigned long startSection() = 0; | ||
41 | }; | 43 | }; |
42 | 44 | ||
43 | class CExpander_Interface | 45 | class CExpander_Interface |
44 | { | 46 | { |
45 | public: | 47 | public: |
46 | #ifdef USEQPE | 48 | #ifdef USEQPE |
47 | virtual void suspend() = 0; | 49 | virtual void suspend() = 0; |
48 | virtual void unsuspend() = 0; | 50 | virtual void unsuspend() = 0; |
49 | #endif | 51 | #endif |
50 | virtual QString about() = 0; | 52 | virtual QString about() = 0; |
51 | virtual size_t getHome() = 0; | 53 | virtual size_t getHome() = 0; |
52 | //CExpander_Interface(); | 54 | //CExpander_Interface(); |
53 | //virtual ~CExpander_Interface(); | 55 | //virtual ~CExpander_Interface(); |
54 | virtual int openfile(const char *src) = 0; | 56 | virtual int openfile(const char *src) = 0; |
55 | //virtual int OpenFile(const char *src) = 0; | 57 | //virtual int OpenFile(const char *src) = 0; |
56 | virtual unsigned int locate() = 0; | 58 | virtual unsigned int locate() = 0; |
57 | virtual void locate(unsigned int n) = 0; | 59 | virtual void locate(unsigned int n) = 0; |
58 | virtual bool hasrandomaccess() = 0; | 60 | virtual bool hasrandomaccess() = 0; |
59 | virtual void sizes(unsigned long& file, unsigned long& text) = 0; | 61 | virtual void sizes(unsigned long& file, unsigned long& text) = 0; |
60 | virtual CList<Bkmk>* getbkmklist() { return NULL; } | 62 | virtual CList<Bkmk>* getbkmklist() { return NULL; } |
61 | virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos) = 0; | 63 | virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos) = 0; |
62 | virtual int getch() = 0; | 64 | virtual int getch() = 0; |
63 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) = 0; | 65 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) = 0; |
64 | virtual MarkupType PreferredMarkup() = 0; | 66 | virtual MarkupType PreferredMarkup() = 0; |
65 | virtual void saveposn(size_t posn) {} | 67 | virtual void saveposn(size_t posn) {} |
66 | virtual void writeposn(size_t posn) {} | 68 | virtual void writeposn(size_t posn) {} |
67 | virtual linkType forward(size_t& loc) { return eNone; } | 69 | virtual linkType forward(size_t& loc) { return eNone; } |
68 | virtual linkType back(size_t& loc) { return eNone; } | 70 | virtual linkType back(size_t& loc) { return eNone; } |
69 | virtual bool hasnavigation() { return false; } | 71 | virtual bool hasnavigation() { return false; } |
70 | virtual unsigned long startSection() = 0; | 72 | virtual unsigned long startSection() = 0; |
71 | virtual unsigned long endSection() = 0; | 73 | virtual unsigned long endSection() = 0; |
72 | virtual void start2endSection() = 0; | 74 | virtual void start2endSection() = 0; |
73 | virtual QImage* getPicture(unsigned long tgt) { return NULL; } | 75 | virtual QImage* getPicture(unsigned long tgt) { return NULL; } |
74 | virtual void setContinuous(bool _b) = 0; | 76 | virtual void setContinuous(bool _b) = 0; |
75 | #ifdef USEQPE | 77 | #ifdef USEQPE |
76 | virtual void suspend(FILE*& fin) = 0; | 78 | virtual void suspend(FILE*& fin) = 0; |
77 | virtual void unsuspend(FILE*& fin) = 0; | 79 | virtual void unsuspend(FILE*& fin) = 0; |
78 | #endif | 80 | #endif |
79 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) = 0; | 81 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) = 0; |
80 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen) = 0; | 82 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen) = 0; |
81 | virtual void setwidth(int w) = 0; | 83 | virtual void setwidth(int w) = 0; |
82 | // bool findstring(const QString& info); | 84 | // bool findstring(const QString& info); |
83 | // int getpara(CBuffer& buff); | 85 | // int getpara(CBuffer& buff); |
84 | virtual int getwidth() = 0; | 86 | virtual int getwidth() = 0; |
85 | virtual QImage* getPicture(const QString& href) = 0; | 87 | virtual QImage* getPicture(const QString& href) = 0; |
86 | virtual bool getFile(const QString& href) = 0; | 88 | virtual bool getFile(const QString& href, const QString& nm) = 0; |
89 | virtual bool findanchor(const QString& nm) = 0; | ||
90 | virtual QString getTableAsHtml(unsigned long loc) { return QString(""); } | ||
87 | }; | 91 | }; |
88 | 92 | ||
89 | class CExpander : public CExpander_Interface | 93 | class CExpander : public CExpander_Interface |
90 | { | 94 | { |
91 | protected: | 95 | protected: |
92 | size_t m_homepos; | 96 | size_t m_homepos; |
93 | bool m_continuous; | 97 | bool m_continuous; |
94 | char* fname; | 98 | char* fname; |
95 | bool bSuspended; | 99 | bool bSuspended; |
96 | size_t suspos; | 100 | size_t suspos; |
97 | time_t sustime; | 101 | time_t sustime; |
98 | int m_scrWidth; | 102 | int m_scrWidth; |
99 | unsigned long m_currentstart, m_currentend; | 103 | unsigned long m_currentstart, m_currentend; |
100 | public: | 104 | public: |
101 | #ifdef USEQPE | 105 | #ifdef USEQPE |
102 | virtual void suspend() = 0; | 106 | virtual void suspend() = 0; |
103 | virtual void unsuspend() = 0; | 107 | virtual void unsuspend() = 0; |
104 | #endif | 108 | #endif |
105 | size_t getHome(); | 109 | size_t getHome(); |
106 | CExpander(); | 110 | CExpander(); |
107 | virtual ~CExpander(); | 111 | virtual ~CExpander(); |
108 | int openfile(const char *src); | 112 | int openfile(const char *src); |
109 | virtual int OpenFile(const char *src) = 0; | 113 | virtual int OpenFile(const char *src) = 0; |
110 | virtual unsigned int locate() = 0; | 114 | virtual unsigned int locate() = 0; |
111 | virtual void locate(unsigned int n) = 0; | 115 | virtual void locate(unsigned int n) = 0; |
112 | virtual bool hasrandomaccess() = 0; | 116 | virtual bool hasrandomaccess() = 0; |
113 | virtual void sizes(unsigned long& file, unsigned long& text) = 0; | 117 | virtual void sizes(unsigned long& file, unsigned long& text) = 0; |
114 | virtual CList<Bkmk>* getbkmklist() { return NULL; } | 118 | virtual CList<Bkmk>* getbkmklist() { return NULL; } |
115 | virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 119 | virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
116 | virtual int getch() = 0; | 120 | virtual int getch() = 0; |
117 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); | 121 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); |
118 | virtual MarkupType PreferredMarkup() = 0; | 122 | virtual MarkupType PreferredMarkup() = 0; |
119 | virtual void saveposn(size_t posn) {} | 123 | virtual void saveposn(size_t posn) {} |
120 | virtual void writeposn(size_t posn) {} | 124 | virtual void writeposn(size_t posn) {} |
121 | virtual linkType forward(size_t& loc) { return eNone; } | 125 | virtual linkType forward(size_t& loc) { return eNone; } |
122 | virtual linkType back(size_t& loc) { return eNone; } | 126 | virtual linkType back(size_t& loc) { return eNone; } |
123 | virtual bool hasnavigation() { return false; } | 127 | virtual bool hasnavigation() { return false; } |
124 | unsigned long startSection(); | 128 | unsigned long startSection(); |
125 | unsigned long endSection(); | 129 | unsigned long endSection(); |
126 | virtual void start2endSection(); | 130 | virtual void start2endSection(); |
127 | virtual QImage* getPicture(unsigned long tgt) { return NULL; } | 131 | virtual QImage* getPicture(unsigned long tgt) { return NULL; } |
128 | void setContinuous(bool _b) { m_continuous = _b; } | 132 | void setContinuous(bool _b) { m_continuous = _b; } |
129 | #ifdef USEQPE | 133 | #ifdef USEQPE |
130 | virtual void suspend(FILE*& fin); | 134 | virtual void suspend(FILE*& fin); |
131 | virtual void unsuspend(FILE*& fin); | 135 | virtual void unsuspend(FILE*& fin); |
132 | #endif | 136 | #endif |
133 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen); | 137 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen); |
134 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen); | 138 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen); |
135 | void setwidth(int w) | 139 | void setwidth(int w) |
136 | { | 140 | { |
137 | m_scrWidth = w; | 141 | m_scrWidth = w; |
138 | } | 142 | } |
139 | int getwidth() | 143 | int getwidth() |
140 | { | 144 | { |
141 | return m_scrWidth; | 145 | return m_scrWidth; |
142 | } | 146 | } |
143 | // bool findstring(const QString& info); | 147 | // bool findstring(const QString& info); |
144 | // int getpara(CBuffer& buff); | 148 | // int getpara(CBuffer& buff); |
145 | virtual QImage* getPicture(const QString& href) { return NULL; } | 149 | virtual QImage* getPicture(const QString& href) { return NULL; } |
146 | virtual bool getFile(const QString& href) { return false; } | 150 | virtual bool getFile(const QString& href, const QString& nm) { return false; } |
151 | virtual bool findanchor(const QString& nm) | ||
152 | { | ||
153 | return false; | ||
154 | } | ||
147 | }; | 155 | }; |
148 | #endif | 156 | #endif |
diff --git a/noncore/apps/opie-reader/CFilter.cpp b/noncore/apps/opie-reader/CFilter.cpp index ab98829..25cdfae 100644 --- a/noncore/apps/opie-reader/CFilter.cpp +++ b/noncore/apps/opie-reader/CFilter.cpp | |||
@@ -1,815 +1,861 @@ | |||
1 | #include <qmap.h> | 1 | #include <qmap.h> |
2 | #include <qfileinfo.h> | 2 | #include <qfileinfo.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qdir.h> | 4 | #include <qdir.h> |
5 | |||
5 | #ifdef USEQPE | 6 | #ifdef USEQPE |
6 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
7 | #endif | 8 | #endif |
8 | #include "CDrawBuffer.h" | 9 | #include "CDrawBuffer.h" |
9 | #include "CFilter.h" | 10 | #include "CFilter.h" |
10 | #include "hrule.h" | 11 | #include "hrule.h" |
11 | #include "util.h" | ||
12 | 12 | ||
13 | #include <qregexp.h> | 13 | #include <qregexp.h> |
14 | #include <qimage.h> | 14 | #include <qimage.h> |
15 | #include <qpixmap.h> | 15 | #include <qpixmap.h> |
16 | //#include <qprogressdialog.h> | 16 | //#include <qprogressdialog.h> |
17 | //#include <qapplication.h> | 17 | //#include <qapplication.h> |
18 | 18 | ||
19 | void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) | 19 | void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) |
20 | { | 20 | { |
21 | if (uselast) | 21 | if (uselast) |
22 | { | 22 | { |
23 | ch = lastchar; | 23 | ch = lastchar; |
24 | uselast = false; | 24 | uselast = false; |
25 | } | 25 | } |
26 | else | 26 | else |
27 | { | 27 | { |
28 | parent->getch(ch, sty, pos); | 28 | parent->getch(ch, sty, pos); |
29 | } | 29 | } |
30 | } | 30 | } |
31 | 31 | ||
32 | void textfmt::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 32 | void textfmt::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
33 | { | 33 | { |
34 | mygetch(ch, sty, pos); | 34 | mygetch(ch, sty, pos); |
35 | do | 35 | do |
36 | { | 36 | { |
37 | sty = currentstyle; | 37 | sty = currentstyle; |
38 | switch (ch) | 38 | switch (ch) |
39 | { | 39 | { |
40 | case 10: | 40 | case 10: |
41 | currentstyle.unset(); | 41 | currentstyle.unset(); |
42 | sty = currentstyle; | 42 | sty = currentstyle; |
43 | break; | 43 | break; |
44 | // Use this if you want to replace -- by em-dash | 44 | // Use this if you want to replace -- by em-dash |
45 | case '-': | 45 | case '-': |
46 | // parent->getch(ch, sty); | 46 | // parent->getch(ch, sty); |
47 | mygetch(ch, sty, pos); | 47 | mygetch(ch, sty, pos); |
48 | if (ch == '-') | 48 | if (ch == '-') |
49 | { | 49 | { |
50 | ch = 0x2014; | 50 | ch = 0x2014; |
51 | } | 51 | } |
52 | else | 52 | else |
53 | { | 53 | { |
54 | lastchar = ch; | 54 | lastchar = ch; |
55 | uselast = true; | 55 | uselast = true; |
56 | ch = '-'; | 56 | ch = '-'; |
57 | } | 57 | } |
58 | break; | 58 | break; |
59 | case '*': | 59 | case '*': |
60 | if (currentstyle.isBold()) | 60 | if (currentstyle.isBold()) |
61 | { | 61 | { |
62 | // Already bold - time to turn it off? | 62 | // Already bold - time to turn it off? |
63 | // The next two lines ensure that * follows a character but it works better without | 63 | // The next two lines ensure that * follows a character but it works better without |
64 | // QChar c(lastchar); | 64 | // QChar c(lastchar); |
65 | // if ((lastchar != '*') && (c.isPunct() || c.isLetterOrNumber())) | 65 | // if ((lastchar != '*') && (c.isPunct() || c.isLetterOrNumber())) |
66 | if (lastchar != '*') | 66 | if (lastchar != '*') |
67 | { | 67 | { |
68 | currentstyle.unsetBold(); | 68 | currentstyle.unsetBold(); |
69 | CStyle dummy; | 69 | CStyle dummy; |
70 | // parent->getch(ch, dummy); | 70 | // parent->getch(ch, dummy); |
71 | mygetch(ch, dummy, pos); | 71 | mygetch(ch, dummy, pos); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | else | 74 | else |
75 | { | 75 | { |
76 | // not bold - time to turn it on? | 76 | // not bold - time to turn it on? |
77 | CStyle dummy; | 77 | CStyle dummy; |
78 | // parent->getch(ch, dummy); | 78 | // parent->getch(ch, dummy); |
79 | mygetch(ch, dummy, pos); | 79 | mygetch(ch, dummy, pos); |
80 | QChar c(ch); | 80 | QChar c(ch); |
81 | if ((ch != '*') && (c.isPunct() || c.isLetterOrNumber())) | 81 | if ((ch != '*') && (c.isPunct() || c.isLetterOrNumber())) |
82 | { | 82 | { |
83 | currentstyle.setBold(); | 83 | currentstyle.setBold(); |
84 | } | 84 | } |
85 | else | 85 | else |
86 | { | 86 | { |
87 | lastchar = ch; | 87 | lastchar = ch; |
88 | uselast = true; | 88 | uselast = true; |
89 | ch = '*'; | 89 | ch = '*'; |
90 | } | 90 | } |
91 | 91 | ||
92 | } | 92 | } |
93 | break; | 93 | break; |
94 | case '_': | 94 | case '_': |
95 | if (currentstyle.isItalic()) | 95 | if (currentstyle.isItalic()) |
96 | { | 96 | { |
97 | // Already bold - time to turn it off? | 97 | // Already bold - time to turn it off? |
98 | // The next two lines ensure that * follows a character but it works better without | 98 | // The next two lines ensure that * follows a character but it works better without |
99 | // QChar c(lastchar); | 99 | // QChar c(lastchar); |
100 | // if ((lastchar != '_') && (c.isPunct() || c.isLetterOrNumber())) | 100 | // if ((lastchar != '_') && (c.isPunct() || c.isLetterOrNumber())) |
101 | if (lastchar != '_') | 101 | if (lastchar != '_') |
102 | { | 102 | { |
103 | currentstyle.unsetItalic(); | 103 | currentstyle.unsetItalic(); |
104 | CStyle dummy; | 104 | CStyle dummy; |
105 | // parent->getch(ch, dummy); | 105 | // parent->getch(ch, dummy); |
106 | mygetch(ch, dummy, pos); | 106 | mygetch(ch, dummy, pos); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | else | 109 | else |
110 | { | 110 | { |
111 | // not bold - time to turn it on? | 111 | // not bold - time to turn it on? |
112 | CStyle dummy; | 112 | CStyle dummy; |
113 | // parent->getch(ch, dummy); | 113 | // parent->getch(ch, dummy); |
114 | mygetch(ch, dummy, pos); | 114 | mygetch(ch, dummy, pos); |
115 | QChar c(ch); | 115 | QChar c(ch); |
116 | if ((ch != '_') && (c.isPunct() || c.isLetterOrNumber())) | 116 | if ((ch != '_') && (c.isPunct() || c.isLetterOrNumber())) |
117 | { | 117 | { |
118 | currentstyle.setItalic(); | 118 | currentstyle.setItalic(); |
119 | } | 119 | } |
120 | else | 120 | else |
121 | { | 121 | { |
122 | lastchar = ch; | 122 | lastchar = ch; |
123 | uselast = true; | 123 | uselast = true; |
124 | ch = '_'; | 124 | ch = '_'; |
125 | } | 125 | } |
126 | 126 | ||
127 | } | 127 | } |
128 | break; | 128 | break; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | while (sty != currentstyle); | 131 | while (sty != currentstyle); |
132 | if (!uselast) lastchar = ch; | 132 | if (!uselast) lastchar = ch; |
133 | return; | 133 | return; |
134 | } | 134 | } |
135 | 135 | ||
136 | void remap::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 136 | void remap::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
137 | { | 137 | { |
138 | if (q[offset] != 0) | 138 | if (q[offset] != 0) |
139 | { | 139 | { |
140 | q[offset++]; | 140 | q[offset++]; |
141 | sty = currentstyle; | 141 | sty = currentstyle; |
142 | return; | 142 | return; |
143 | } | 143 | } |
144 | parent->getch(ch, sty, pos); | 144 | parent->getch(ch, sty, pos); |
145 | switch (ch) | 145 | switch (ch) |
146 | { | 146 | { |
147 | case 0x201a: | 147 | case 0x201a: |
148 | ch = '\''; | 148 | ch = '\''; |
149 | break; | 149 | break; |
150 | case 0x0192: | 150 | case 0x0192: |
151 | ch = 'f'; | 151 | ch = 'f'; |
152 | break; | 152 | break; |
153 | case 0x201e: | 153 | case 0x201e: |
154 | ch = '"'; | 154 | ch = '"'; |
155 | break; | 155 | break; |
156 | case 0x2026: | 156 | case 0x2026: |
157 | offset = 0; | 157 | offset = 0; |
158 | q[0] = '.'; | 158 | q[0] = '.'; |
159 | q[1] = '.'; | 159 | q[1] = '.'; |
160 | q[2] = 0; | 160 | q[2] = 0; |
161 | ch = '.'; // should be ... | 161 | ch = '.'; // should be ... |
162 | break; | 162 | break; |
163 | case 0x0160: | 163 | case 0x0160: |
164 | ch = 'S'; | 164 | ch = 'S'; |
165 | break; | 165 | break; |
166 | case 0x2039: | 166 | case 0x2039: |
167 | ch = '<'; | 167 | ch = '<'; |
168 | break; | 168 | break; |
169 | case 0x0152: | 169 | case 0x0152: |
170 | offset = 0; | 170 | offset = 0; |
171 | q[0] = 'E'; | 171 | q[0] = 'E'; |
172 | q[1] = 0; | 172 | q[1] = 0; |
173 | ch = 'O'; | 173 | ch = 'O'; |
174 | break; | 174 | break; |
175 | case 0x017d: | 175 | case 0x017d: |
176 | ch = 'Z'; | 176 | ch = 'Z'; |
177 | break; | 177 | break; |
178 | case 0x2018: | 178 | case 0x2018: |
179 | ch = '\''; | 179 | ch = '\''; |
180 | break; | 180 | break; |
181 | case 0x2019: | 181 | case 0x2019: |
182 | ch = '\''; | 182 | ch = '\''; |
183 | break; | 183 | break; |
184 | case 0x201c: | 184 | case 0x201c: |
185 | ch = '"'; | 185 | ch = '"'; |
186 | break; | 186 | break; |
187 | case 0x201d: | 187 | case 0x201d: |
188 | ch = '"'; | 188 | ch = '"'; |
189 | break; | 189 | break; |
190 | case 0x2022: | 190 | case 0x2022: |
191 | ch = '>'; | 191 | ch = '>'; |
192 | break; | 192 | break; |
193 | case 0x2013: | 193 | case 0x2013: |
194 | ch = '-'; | 194 | ch = '-'; |
195 | break; | 195 | break; |
196 | case 0x2014: | 196 | case 0x2014: |
197 | offset = 0; | 197 | offset = 0; |
198 | q[0] = '-'; | 198 | q[0] = '-'; |
199 | q[1] = 0; | 199 | q[1] = 0; |
200 | ch = '-'; // should be -- | 200 | ch = '-'; // should be -- |
201 | break; | 201 | break; |
202 | case 0x02dc: | 202 | case 0x02dc: |
203 | ch = '~'; | 203 | ch = '~'; |
204 | break; | 204 | break; |
205 | case 0x0161: | 205 | case 0x0161: |
206 | ch = 's'; | 206 | ch = 's'; |
207 | break; | 207 | break; |
208 | case 0x203a: | 208 | case 0x203a: |
209 | ch = '>'; | 209 | ch = '>'; |
210 | break; | 210 | break; |
211 | case 0x0153: | 211 | case 0x0153: |
212 | offset = 0; | 212 | offset = 0; |
213 | q[0] = 'e'; | 213 | q[0] = 'e'; |
214 | q[1] = 0; | 214 | q[1] = 0; |
215 | ch = 'o';// should be oe | 215 | ch = 'o';// should be oe |
216 | break; | 216 | break; |
217 | /* | 217 | /* |
218 | case 0x0009: // tab | 218 | case 0x0009: // tab |
219 | offset = 0; | 219 | offset = 0; |
220 | q[0] = ' '; | 220 | q[0] = ' '; |
221 | q[1] = 0; | 221 | q[1] = 0; |
222 | ch = ' '; | 222 | ch = ' '; |
223 | break; | 223 | break; |
224 | */ | 224 | */ |
225 | case 0x017e: | 225 | case 0x017e: |
226 | ch = 'z'; | 226 | ch = 'z'; |
227 | break; | 227 | break; |
228 | case 0x0178: | 228 | case 0x0178: |
229 | ch = 'Y'; | 229 | ch = 'Y'; |
230 | break; | 230 | break; |
231 | } | 231 | } |
232 | currentstyle = sty; | 232 | currentstyle = sty; |
233 | } | 233 | } |
234 | 234 | ||
235 | void PeanutFormatter::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 235 | void PeanutFormatter::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
236 | { | 236 | { |
237 | CStyle dummy; | 237 | CStyle dummy; |
238 | currentstyle.setColour(0,0,0); | 238 | currentstyle.setColour(0,0,0); |
239 | parent->getch(ch, dummy, pos); | 239 | parent->getch(ch, dummy, pos); |
240 | while (ch == '\\') | 240 | while (ch == '\\') |
241 | { | 241 | { |
242 | parent->getch(ch, dummy, pos); | 242 | parent->getch(ch, dummy, pos); |
243 | if (ch == '\\') break; | 243 | if (ch == '\\') break; |
244 | switch(ch) | 244 | switch(ch) |
245 | { | 245 | { |
246 | case 'a': | 246 | case 'a': |
247 | { | 247 | { |
248 | int code = 0; | 248 | int code = 0; |
249 | for (int i = 0; i < 3; i++) | 249 | for (int i = 0; i < 3; i++) |
250 | { | 250 | { |
251 | parent->getch(ch, dummy, pos); | 251 | parent->getch(ch, dummy, pos); |
252 | code = 10*code + ch - '0'; | 252 | code = 10*code + ch - '0'; |
253 | } | 253 | } |
254 | ch = code; | 254 | ch = code; |
255 | } | 255 | } |
256 | break; | 256 | break; |
257 | case 'v': | 257 | case 'v': |
258 | { | 258 | { |
259 | while (1) | 259 | while (1) |
260 | { | 260 | { |
261 | parent->getch(ch, dummy, pos); | 261 | parent->getch(ch, dummy, pos); |
262 | if (ch == '\\') | 262 | if (ch == '\\') |
263 | { | 263 | { |
264 | parent->getch(ch, dummy, pos); | 264 | parent->getch(ch, dummy, pos); |
265 | if (ch == 'v') | 265 | if (ch == 'v') |
266 | { | 266 | { |
267 | parent->getch(ch, dummy, pos); | 267 | parent->getch(ch, dummy, pos); |
268 | break; | 268 | break; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | } | 271 | } |
272 | } | 272 | } |
273 | break; | 273 | break; |
274 | case 's': | 274 | case 's': |
275 | case 'n': | 275 | case 'n': |
276 | currentstyle.setFontSize(0); | 276 | currentstyle.setFontSize(0); |
277 | parent->getch(ch,dummy, pos); | 277 | parent->getch(ch,dummy, pos); |
278 | break; | 278 | break; |
279 | case 'p': | 279 | case 'p': |
280 | currentstyle.unset(); | 280 | currentstyle.unset(); |
281 | // parent->getch(ch,dummy); | 281 | // parent->getch(ch,dummy); |
282 | ch = 10; | 282 | ch = 10; |
283 | break; | 283 | break; |
284 | case 'l': | 284 | case 'l': |
285 | if (currentstyle.getFontSize() == 1) | 285 | if (currentstyle.getFontSize() == 1) |
286 | { | 286 | { |
287 | currentstyle.setFontSize(0); | 287 | currentstyle.setFontSize(0); |
288 | } | 288 | } |
289 | else | 289 | else |
290 | { | 290 | { |
291 | currentstyle.setFontSize(1); | 291 | currentstyle.setFontSize(1); |
292 | } | 292 | } |
293 | parent->getch(ch, dummy, pos); | 293 | parent->getch(ch, dummy, pos); |
294 | break; | 294 | break; |
295 | case 'x': | 295 | case 'x': |
296 | if (currentstyle.getFontSize() == 0) | 296 | if (currentstyle.getFontSize() == 0) |
297 | { | 297 | { |
298 | // currentstyle.unset(); | 298 | // currentstyle.unset(); |
299 | // currentstyle.setBold(); | 299 | // currentstyle.setBold(); |
300 | currentstyle.setFontSize(1); | 300 | currentstyle.setFontSize(1); |
301 | } | 301 | } |
302 | else | 302 | else |
303 | { | 303 | { |
304 | currentstyle.unset(); | 304 | currentstyle.unset(); |
305 | } | 305 | } |
306 | // parent->getch(ch, dummy); | 306 | // parent->getch(ch, dummy); |
307 | ch = 10; | 307 | ch = 10; |
308 | break; | 308 | break; |
309 | case 'i': | 309 | case 'i': |
310 | if (currentstyle.isItalic()) | 310 | if (currentstyle.isItalic()) |
311 | { | 311 | { |
312 | currentstyle.unsetItalic(); | 312 | currentstyle.unsetItalic(); |
313 | } | 313 | } |
314 | else | 314 | else |
315 | { | 315 | { |
316 | currentstyle.setItalic(); | 316 | currentstyle.setItalic(); |
317 | } | 317 | } |
318 | parent->getch(ch, dummy, pos); | 318 | parent->getch(ch, dummy, pos); |
319 | break; | 319 | break; |
320 | case 'b': | 320 | case 'b': |
321 | case 'B': | 321 | case 'B': |
322 | if (currentstyle.isBold()) | 322 | if (currentstyle.isBold()) |
323 | { | 323 | { |
324 | currentstyle.unsetBold(); | 324 | currentstyle.unsetBold(); |
325 | } | 325 | } |
326 | else | 326 | else |
327 | { | 327 | { |
328 | currentstyle.setBold(); | 328 | currentstyle.setBold(); |
329 | } | 329 | } |
330 | parent->getch(ch, dummy, pos); | 330 | parent->getch(ch, dummy, pos); |
331 | break; | 331 | break; |
332 | case 'c': | 332 | case 'c': |
333 | if (currentstyle.getJustify() == m_AlignCentre) | 333 | if (currentstyle.getJustify() == m_AlignCentre) |
334 | { | 334 | { |
335 | currentstyle.setLeftJustify(); | 335 | currentstyle.setLeftJustify(); |
336 | } | 336 | } |
337 | else | 337 | else |
338 | { | 338 | { |
339 | currentstyle.setCentreJustify(); | 339 | currentstyle.setCentreJustify(); |
340 | } | 340 | } |
341 | parent->getch(ch, dummy, pos); | 341 | parent->getch(ch, dummy, pos); |
342 | break; | 342 | break; |
343 | case 'r': | 343 | case 'r': |
344 | if (currentstyle.getJustify() == m_AlignRight) | 344 | if (currentstyle.getJustify() == m_AlignRight) |
345 | { | 345 | { |
346 | currentstyle.setLeftJustify(); | 346 | currentstyle.setLeftJustify(); |
347 | } | 347 | } |
348 | else | 348 | else |
349 | { | 349 | { |
350 | currentstyle.setRightJustify(); | 350 | currentstyle.setRightJustify(); |
351 | } | 351 | } |
352 | parent->getch(ch, dummy, pos); | 352 | parent->getch(ch, dummy, pos); |
353 | break; | 353 | break; |
354 | default: | 354 | default: |
355 | currentstyle.setColour(255,0,0); | 355 | currentstyle.setColour(255,0,0); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | sty = currentstyle; | 358 | sty = currentstyle; |
359 | } | 359 | } |
360 | 360 | ||
361 | void OnePara::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 361 | void OnePara::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
362 | { | 362 | { |
363 | parent->getch(ch, sty, pos); | 363 | parent->getch(ch, sty, pos); |
364 | if (m_lastchar == 10) | 364 | if (m_lastchar == 10) |
365 | { | 365 | { |
366 | while (ch == 10) parent->getch(ch, sty, pos); | 366 | while (ch == 10) parent->getch(ch, sty, pos); |
367 | } | 367 | } |
368 | m_lastchar = ch; | 368 | m_lastchar = ch; |
369 | } | 369 | } |
370 | 370 | ||
371 | void repalm::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 371 | void repalm::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
372 | { | 372 | { |
373 | parent->getch(ch, sty, pos); | 373 | parent->getch(ch, sty, pos); |
374 | switch (ch) | 374 | switch (ch) |
375 | { | 375 | { |
376 | case 0x80: | 376 | case 0x80: |
377 | ch = 0x20ac; | 377 | ch = 0x20ac; |
378 | break; | 378 | break; |
379 | case 0x82: | 379 | case 0x82: |
380 | ch = 0x201a; | 380 | ch = 0x201a; |
381 | break; | 381 | break; |
382 | case 0x83: | 382 | case 0x83: |
383 | ch = 0x0192; | 383 | ch = 0x0192; |
384 | break; | 384 | break; |
385 | case 0x84: | 385 | case 0x84: |
386 | ch = 0x201e; | 386 | ch = 0x201e; |
387 | break; | 387 | break; |
388 | case 0x85: | 388 | case 0x85: |
389 | ch = 0x2026; | 389 | ch = 0x2026; |
390 | break; | 390 | break; |
391 | case 0x86: | 391 | case 0x86: |
392 | ch = 0x2020; | 392 | ch = 0x2020; |
393 | break; | 393 | break; |
394 | case 0x87: | 394 | case 0x87: |
395 | ch = 0x2021; | 395 | ch = 0x2021; |
396 | break; | 396 | break; |
397 | case 0x88: | 397 | case 0x88: |
398 | ch = 0x02c6; | 398 | ch = 0x02c6; |
399 | break; | 399 | break; |
400 | case 0x89: | 400 | case 0x89: |
401 | ch = 0x2030; | 401 | ch = 0x2030; |
402 | break; | 402 | break; |
403 | case 0x8a: | 403 | case 0x8a: |
404 | ch = 0x0160; | 404 | ch = 0x0160; |
405 | break; | 405 | break; |
406 | case 0x8b: | 406 | case 0x8b: |
407 | ch = 0x2039; | 407 | ch = 0x2039; |
408 | break; | 408 | break; |
409 | case 0x8c: | 409 | case 0x8c: |
410 | ch = 0x0152; | 410 | ch = 0x0152; |
411 | break; | 411 | break; |
412 | /* | 412 | /* |
413 | case 0x8e: | 413 | case 0x8e: |
414 | ch = 0x017d; | 414 | ch = 0x017d; |
415 | break; | 415 | break; |
416 | */ | 416 | */ |
417 | case 0x91: | 417 | case 0x91: |
418 | ch = 0x2018; | 418 | ch = 0x2018; |
419 | break; | 419 | break; |
420 | case 0x92: | 420 | case 0x92: |
421 | ch = 0x2019; | 421 | ch = 0x2019; |
422 | break; | 422 | break; |
423 | case 0x93: | 423 | case 0x93: |
424 | ch = 0x201c; | 424 | ch = 0x201c; |
425 | break; | 425 | break; |
426 | case 0x94: | 426 | case 0x94: |
427 | ch = 0x201d; | 427 | ch = 0x201d; |
428 | break; | 428 | break; |
429 | case 0x95: | 429 | case 0x95: |
430 | ch = 0x2022; | 430 | ch = 0x2022; |
431 | break; | 431 | break; |
432 | case 0x96: | 432 | case 0x96: |
433 | ch = 0x2013; | 433 | ch = 0x2013; |
434 | break; | 434 | break; |
435 | case 0x97: | 435 | case 0x97: |
436 | ch = 0x2014; | 436 | ch = 0x2014; |
437 | break; | 437 | break; |
438 | case 0x98: | 438 | case 0x98: |
439 | ch = 0x02dc; | 439 | ch = 0x02dc; |
440 | break; | 440 | break; |
441 | case 0x99: | 441 | case 0x99: |
442 | ch = 0x2122; | 442 | ch = 0x2122; |
443 | break; | 443 | break; |
444 | case 0x9a: | 444 | case 0x9a: |
445 | ch = 0x0161; | 445 | ch = 0x0161; |
446 | break; | 446 | break; |
447 | case 0x9b: | 447 | case 0x9b: |
448 | ch = 0x203a; | 448 | ch = 0x203a; |
449 | break; | 449 | break; |
450 | case 0x9c: | 450 | case 0x9c: |
451 | ch = 0x0153; | 451 | ch = 0x0153; |
452 | break; | 452 | break; |
453 | case 0x9e: | 453 | case 0x9e: |
454 | ch = 0x017e; | 454 | ch = 0x017e; |
455 | break; | 455 | break; |
456 | case 0x9f: | 456 | case 0x9f: |
457 | ch = 0x0178; | 457 | ch = 0x0178; |
458 | break; | 458 | break; |
459 | case 0x18: | 459 | case 0x18: |
460 | ch = 0x2026; | 460 | ch = 0x2026; |
461 | break; | 461 | break; |
462 | case 0x19: | 462 | case 0x19: |
463 | ch = 0x2007; | 463 | ch = 0x2007; |
464 | break; | 464 | break; |
465 | case 0x8d: | 465 | case 0x8d: |
466 | ch = 0x2662; | 466 | ch = 0x2662; |
467 | break; | 467 | break; |
468 | case 0x8e: | 468 | case 0x8e: |
469 | ch = 0x2663; | 469 | ch = 0x2663; |
470 | break; | 470 | break; |
471 | case 0x8f: | 471 | case 0x8f: |
472 | ch = 0x2661; | 472 | ch = 0x2661; |
473 | break; | 473 | break; |
474 | case 0x90: | 474 | case 0x90: |
475 | ch = 0x2660; | 475 | ch = 0x2660; |
476 | break; | 476 | break; |
477 | default: | 477 | default: |
478 | break; | 478 | break; |
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
482 | //static tchar nextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 }; | 482 | //static tchar nextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 }; |
483 | //static tchar prevpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','p','r','e','v','i','o','u','s',' ','p','a','r','t',0 }; | 483 | //static tchar prevpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','p','r','e','v','i','o','u','s',' ','p','a','r','t',0 }; |
484 | 484 | ||
485 | void DePluck::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 485 | void DePluck::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
486 | { | 486 | { |
487 | if (m_buffed > 0) | 487 | if (m_buffed > 0) |
488 | { | 488 | { |
489 | sty = m_laststyle; | 489 | sty = m_laststyle; |
490 | ch = nextpart[m_current++]; | 490 | ch = nextpart[m_current++]; |
491 | if (m_current == m_buffed) | 491 | if (m_current == m_buffed) |
492 | { | 492 | { |
493 | m_current = m_buffed = 0; | 493 | m_current = m_buffed = 0; |
494 | } | 494 | } |
495 | } | 495 | } |
496 | else | 496 | else |
497 | { | 497 | { |
498 | if (m_buffer != 0) | 498 | if (m_buffer != 0) |
499 | { | 499 | { |
500 | ch = m_buffer; | 500 | ch = m_buffer; |
501 | m_buffer = 0; | 501 | m_buffer = 0; |
502 | return; | 502 | return; |
503 | } | 503 | } |
504 | unsigned long lnk, lnkoff; | 504 | unsigned long lnk, lnkoff; |
505 | do | 505 | do |
506 | { | 506 | { |
507 | if (nextpart[m_buffed] == 0) break; | 507 | if (nextpart[m_buffed] == 0) break; |
508 | parent->getch(ch, sty, pos); | 508 | parent->getch(ch, sty, pos); |
509 | m_laststyle = sty; | 509 | m_laststyle = sty; |
510 | if (sty.getLink()) | 510 | if (sty.getLink()) |
511 | { | 511 | { |
512 | lnk = sty.getData(); | 512 | lnk = sty.getData(); |
513 | lnkoff = sty.getOffset(); | 513 | lnkoff = sty.getOffset(); |
514 | } | 514 | } |
515 | } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed); | 515 | } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed); |
516 | m_current = 0; | 516 | m_current = 0; |
517 | if (nextpart[m_buffed] == 0) | 517 | if (nextpart[m_buffed] == 0) |
518 | { | 518 | { |
519 | m_buffed = 0; | 519 | m_buffed = 0; |
520 | QString dmy, dmy2; | 520 | QString dmy, dmy2; |
521 | parent->hyperlink(lnk, lnkoff, dmy, dmy2); | 521 | parent->hyperlink(lnk, lnkoff, dmy, dmy2); |
522 | do | 522 | do |
523 | { | 523 | { |
524 | parent->getch(ch, sty, pos); | 524 | parent->getch(ch, sty, pos); |
525 | } | 525 | } |
526 | while (ch != 10); | 526 | while (ch != 10); |
527 | parent->getch(ch, sty, pos); | 527 | parent->getch(ch, sty, pos); |
528 | } | 528 | } |
529 | else if (m_buffed > 0) | 529 | else if (m_buffed > 0) |
530 | { | 530 | { |
531 | m_buffer = ch; | 531 | m_buffer = ch; |
532 | ch = nextpart[0]; | 532 | ch = nextpart[0]; |
533 | if (m_buffed == 1) | 533 | if (m_buffed == 1) |
534 | { | 534 | { |
535 | m_buffed = 0; | 535 | m_buffed = 0; |
536 | } | 536 | } |
537 | else m_current = 1; | 537 | else m_current = 1; |
538 | } | 538 | } |
539 | } | 539 | } |
540 | 540 | ||
541 | return; | 541 | return; |
542 | } | 542 | } |
543 | 543 | ||
544 | HighlightFilter::HighlightFilter(QTReader* _p) : pReader(_p), lastpos(0), nextpos(0), red(255), green(255), blue(255) | 544 | HighlightFilter::HighlightFilter(QTReader* _p) : pReader(_p), lastpos(0), nextpos(0), red(255), green(255), blue(255) |
545 | { | 545 | { |
546 | } | 546 | } |
547 | 547 | ||
548 | #include "Bkmks.h" | 548 | #include "Bkmks.h" |
549 | #include "QTReader.h" | 549 | #include "QTReader.h" |
550 | 550 | ||
551 | void HighlightFilter::refresh(unsigned long pos) | 551 | void HighlightFilter::refresh(unsigned long pos) |
552 | { | 552 | { |
553 | bkmks = pReader->Bkmklist(); | 553 | bkmks = pReader->Bkmklist(); |
554 | 554 | ||
555 | red = green = blue = 255; | 555 | red = green = blue = 255; |
556 | 556 | ||
557 | if (bkmks == NULL) | 557 | if (bkmks == NULL) |
558 | { | 558 | { |
559 | lastpos = 0; | 559 | lastpos = 0; |
560 | nextpos = 0xffffffff; | 560 | nextpos = 0xffffffff; |
561 | } | 561 | } |
562 | else | 562 | else |
563 | { | 563 | { |
564 | lastpos = 0; | 564 | lastpos = 0; |
565 | nextpos = 0xffffffff; | 565 | nextpos = 0xffffffff; |
566 | for (CList<Bkmk>::iterator i = bkmks->begin(); i != bkmks->end(); i++) | 566 | for (CList<Bkmk>::iterator i = bkmks->begin(); i != bkmks->end(); i++) |
567 | { | 567 | { |
568 | if ((*i).value() <= pos && pos < (*i).value2()) | 568 | if ((*i).value() <= pos && pos < (*i).value2()) |
569 | { | 569 | { |
570 | red = i->red(); | 570 | red = i->red(); |
571 | green = i->green(); | 571 | green = i->green(); |
572 | blue = i->blue(); | 572 | blue = i->blue(); |
573 | lastpos = (*i).value(); | 573 | lastpos = (*i).value(); |
574 | nextpos = (*i).value2(); | 574 | nextpos = (*i).value2(); |
575 | break; | 575 | break; |
576 | } | 576 | } |
577 | if ((*i).value() > pos) | 577 | if ((*i).value() > pos) |
578 | { | 578 | { |
579 | nextpos = (*i).value(); | 579 | nextpos = (*i).value(); |
580 | break; | 580 | break; |
581 | } | 581 | } |
582 | lastpos = (*i).value(); | 582 | lastpos = (*i).value(); |
583 | } | 583 | } |
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
587 | void HighlightFilter::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 587 | void HighlightFilter::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
588 | { | 588 | { |
589 | parent->getch(ch, sty, pos); | 589 | parent->getch(ch, sty, pos); |
590 | if (bkmks != pReader->Bkmklist() || pos <= lastpos || pos >= nextpos) | 590 | if (bkmks != pReader->Bkmklist() || pos <= lastpos || pos >= nextpos) |
591 | { | 591 | { |
592 | // qDebug("Recalc <%lu, %lu, %lu>", lastpos, pos, nextpos); | 592 | // qDebug("Recalc <%lu, %lu, %lu>", lastpos, pos, nextpos); |
593 | refresh(pos); | 593 | refresh(pos); |
594 | // qDebug("Recalc(2) <%lu, %lu, %lu>", lastpos, pos, nextpos); | 594 | // qDebug("Recalc(2) <%lu, %lu, %lu>", lastpos, pos, nextpos); |
595 | } | 595 | } |
596 | int r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); | 596 | int r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); |
597 | if (r == 255 && g == 255 && b == 255) | 597 | if (r == 255 && g == 255 && b == 255) |
598 | { | 598 | { |
599 | sty.setBackground(red, green, blue); | 599 | sty.setBackground(red, green, blue); |
600 | } | 600 | } |
601 | } | 601 | } |
602 | 602 | ||
603 | void kern::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 603 | void kern::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
604 | { | 604 | { |
605 | if (uselast) | 605 | if (uselast) |
606 | { | 606 | { |
607 | ch = lastchar; | 607 | ch = lastchar; |
608 | sty = laststy; | 608 | sty = laststy; |
609 | uselast = false; | 609 | uselast = false; |
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | else | 612 | else |
613 | { | 613 | { |
614 | parent->getch(ch, sty, pos); | 614 | parent->getch(ch, sty, pos); |
615 | } | 615 | } |
616 | switch (ch) | 616 | switch (ch) |
617 | { | 617 | { |
618 | case 'f': | 618 | case 'f': |
619 | { | 619 | { |
620 | tchar savedchar = 'f'; | 620 | tchar savedchar = 'f'; |
621 | parent->getch(ch, sty, pos); | 621 | parent->getch(ch, sty, pos); |
622 | switch (ch) | 622 | switch (ch) |
623 | { | 623 | { |
624 | case 'i': | 624 | case 'i': |
625 | ch = (251 << 8) + 1; | 625 | ch = (251 << 8) + 1; |
626 | break; | 626 | break; |
627 | case 'l': | 627 | case 'l': |
628 | ch = (251 << 8) + 2; | 628 | ch = (251 << 8) + 2; |
629 | break; | 629 | break; |
630 | default: | 630 | default: |
631 | lastchar = ch; | 631 | lastchar = ch; |
632 | uselast = true; | 632 | uselast = true; |
633 | laststy = sty; | 633 | laststy = sty; |
634 | ch = savedchar; | 634 | ch = savedchar; |
635 | } | 635 | } |
636 | } | 636 | } |
637 | break; | 637 | break; |
638 | default: | 638 | default: |
639 | break; | 639 | break; |
640 | } | 640 | } |
641 | } | 641 | } |
642 | 642 | ||
643 | class ErrorFilter : public CFilter | 643 | class ErrorFilter : public CFilter |
644 | { | 644 | { |
645 | QString error; | 645 | QString error; |
646 | int currentpos; | 646 | int currentpos; |
647 | public: | 647 | public: |
648 | ErrorFilter(const QString& _s) : error(_s), currentpos(0) {} | 648 | ErrorFilter(const QString& _s) : error(_s), currentpos(0) {} |
649 | ~ErrorFilter() {} | 649 | ~ErrorFilter() {} |
650 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 650 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
651 | { | 651 | { |
652 | if (currentpos == error.length()) | 652 | if (currentpos == error.length()) |
653 | { | 653 | { |
654 | ch = UEOF; | 654 | ch = UEOF; |
655 | currentpos = 0; | 655 | currentpos = 0; |
656 | } | 656 | } |
657 | else | 657 | else |
658 | { | 658 | { |
659 | ch = error[currentpos++].unicode(); | 659 | ch = error[currentpos++].unicode(); |
660 | } | 660 | } |
661 | } | 661 | } |
662 | QString about() { return parent->about(); } | 662 | QString about() { return parent->about(); } |
663 | }; | 663 | }; |
664 | 664 | ||
665 | #ifndef __STATIC | 665 | #ifndef __STATIC |
666 | ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL) | 666 | ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL) |
667 | { | 667 | { |
668 | QString filterpath(QTReaderUtil::getPluginPath("filters")); | 668 | #ifdef USEQPE |
669 | filterpath += "/lib"; | 669 | #ifdef OPIE |
670 | QString filterpath(getenv("OPIEDIR")); | ||
671 | #else | ||
672 | QString filterpath(getenv("QTDIR")); | ||
673 | #endif | ||
674 | filterpath += "/plugins/reader/filters/lib"; | ||
675 | #else | ||
676 | QString filterpath(getenv("READERDIR")); | ||
677 | filterpath += "/filters/lib"; | ||
678 | #endif | ||
670 | filterpath += nm; | 679 | filterpath += nm; |
671 | filterpath += ".so"; | 680 | filterpath += ".so"; |
672 | if (QFile::exists(filterpath)) | 681 | if (QFile::exists(filterpath)) |
673 | { | 682 | { |
674 | qDebug("Filter:%s", (const char*)filterpath); | 683 | qDebug("Filter:%s", (const char*)filterpath); |
675 | handle = dlopen(filterpath, RTLD_LAZY); | 684 | handle = dlopen(filterpath, RTLD_LAZY); |
676 | if (handle == 0) | 685 | if (handle == 0) |
677 | { | 686 | { |
678 | qDebug("Can't find filter:%s", dlerror()); | 687 | qDebug("Can't find filter:%s", dlerror()); |
679 | // status = -10; | 688 | // status = -10; |
680 | filt = new ErrorFilter(QString("Can't find plugin:")+nm); | 689 | filt = new ErrorFilter(QString("Can't find plugin:")+nm); |
681 | return; | 690 | return; |
682 | } | 691 | } |
683 | CFilter* (*newfilter)(const QString&); | 692 | CFilter* (*newfilter)(const QString&); |
684 | newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); | 693 | newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); |
685 | if (newfilter == NULL) | 694 | if (newfilter == NULL) |
686 | { | 695 | { |
687 | qDebug("Can't find newfilter"); | 696 | qDebug("Can't find newfilter"); |
688 | filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm); | 697 | filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm); |
689 | return; | 698 | return; |
690 | } | 699 | } |
691 | filt = (*newfilter)(optional); | 700 | filt = (*newfilter)(optional); |
692 | } | 701 | } |
693 | else | 702 | else |
694 | { | 703 | { |
695 | qDebug("No filter path"); | 704 | qDebug("No filter path:%s", (const char*)filterpath); |
696 | filt = new ErrorFilter(QString("No filter plugins installed:")+nm); | 705 | filt = new ErrorFilter(QString("No filter plugins installed:")+nm); |
697 | } | 706 | } |
698 | if (filt == NULL) | 707 | if (filt == NULL) |
699 | { | 708 | { |
700 | qDebug("Can't do newfilter"); | 709 | qDebug("Can't do newfilter"); |
701 | filt = new ErrorFilter(QString("Filter creation failed:")+nm); | 710 | filt = new ErrorFilter(QString("Filter creation failed:")+nm); |
702 | return; | 711 | return; |
703 | } | 712 | } |
704 | } | 713 | } |
705 | #endif | 714 | #endif |
706 | 715 | ||
707 | void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 716 | void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
708 | { | 717 | { |
709 | parent->getch(ch, sty, pos); | 718 | parent->getch(ch, sty, pos); |
710 | int r,g,b; | 719 | int r,g,b; |
711 | r = 255 - sty.Red(), g = 255 - sty.Green(), b = 255 - sty.Blue(); | 720 | r = 255 - sty.Red(), g = 255 - sty.Green(), b = 255 - sty.Blue(); |
712 | sty.setColour(r,g,b); | 721 | sty.setColour(r,g,b); |
713 | r = 255 - sty.bRed(), g = 255 - sty.bGreen(), b = 255 - sty.bBlue(); | 722 | r = 255 - sty.bRed(), g = 255 - sty.bGreen(), b = 255 - sty.bBlue(); |
714 | sty.setBackground(r,g,b); | 723 | sty.setBackground(r,g,b); |
715 | r = 255 - sty.pRed(), g = 255 - sty.pGreen(), b = 255 - sty.pBlue(); | 724 | r = 255 - sty.pRed(), g = 255 - sty.pGreen(), b = 255 - sty.pBlue(); |
716 | sty.setPaper(r,g,b); | 725 | sty.setPaper(r,g,b); |
717 | } | 726 | } |
718 | /* | 727 | /* |
719 | void makeNegative::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 728 | void makeNegative::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
720 | { | 729 | { |
721 | parent->getch(ch, sty, pos); | 730 | parent->getch(ch, sty, pos); |
722 | QColor fg(sty.Red(), sty.Green(), sty.Blue()); | 731 | QColor fg(sty.Red(), sty.Green(), sty.Blue()); |
723 | int h,s,v; | 732 | int h,s,v; |
724 | fg.hsv(&h,&s,&v); | 733 | fg.hsv(&h,&s,&v); |
725 | fg.setHsv(h,s,255-v); | 734 | fg.setHsv(h,s,255-v); |
726 | int r,g,b; | 735 | int r,g,b; |
727 | fg.rgb(&r,&g,&b); | 736 | fg.rgb(&r,&g,&b); |
728 | sty.setColour(r,g,b); | 737 | sty.setColour(r,g,b); |
729 | 738 | ||
730 | fg = QColor(sty.bRed(), sty.bGreen(), sty.bBlue()); | 739 | fg = QColor(sty.bRed(), sty.bGreen(), sty.bBlue()); |
731 | fg.hsv(&h,&s,&v); | 740 | fg.hsv(&h,&s,&v); |
732 | fg.setHsv(h,s,255-v); | 741 | fg.setHsv(h,s,255-v); |
733 | fg.rgb(&r,&g,&b); | 742 | fg.rgb(&r,&g,&b); |
734 | sty.setBackground(r,g,b); | 743 | sty.setBackground(r,g,b); |
735 | } | 744 | } |
736 | */ | 745 | */ |
737 | void setbg::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 746 | void setbg::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
738 | { | 747 | { |
739 | parent->getch(ch, sty, pos); | 748 | parent->getch(ch, sty, pos); |
740 | int r = sty.pRed(), g = sty.pGreen(), b = sty.pBlue(); | 749 | int r = sty.pRed(), g = sty.pGreen(), b = sty.pBlue(); |
741 | if (r == 255 && g == 255 && b == 255) | 750 | if (r == 255 && g == 255 && b == 255) |
742 | { | 751 | { |
743 | sty.setPaper(m_r,m_g,m_b); | 752 | sty.setPaper(m_r,m_g,m_b); |
744 | } | 753 | } |
745 | else | 754 | else |
746 | { | 755 | { |
747 | qDebug("We have background [%x%x%x]", r, g, b); | 756 | qDebug("We have background [%x%x%x]", r, g, b); |
748 | } | 757 | } |
749 | r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); | 758 | r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); |
750 | if (r == 255 && g == 255 && b == 255) | 759 | if (r == 255 && g == 255 && b == 255) |
751 | { | 760 | { |
752 | sty.setBackground(m_r,m_g,m_b); | 761 | sty.setBackground(m_r,m_g,m_b); |
753 | } | 762 | } |
754 | else | 763 | else |
755 | { | 764 | { |
756 | qDebug("We have background [%x%x%x]", r, g, b); | 765 | qDebug("We have background [%x%x%x]", r, g, b); |
757 | } | 766 | } |
758 | } | 767 | } |
759 | 768 | ||
760 | void setfg::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 769 | void setfg::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
761 | { | 770 | { |
762 | parent->getch(ch, sty, pos); | 771 | parent->getch(ch, sty, pos); |
763 | int r = sty.Red(), g = sty.Green(), b = sty.Blue(); | 772 | int r = sty.Red(), g = sty.Green(), b = sty.Blue(); |
764 | if (r == 0 && g == 0 && b == 0) | 773 | if (r == 0 && g == 0 && b == 0) |
765 | { | 774 | { |
766 | sty.setColour(m_r,m_g,m_b); | 775 | sty.setColour(m_r,m_g,m_b); |
767 | } | 776 | } |
768 | } | 777 | } |
769 | 778 | ||
770 | #include "CRegExp.h" | 779 | #include "CRegExp.h" |
771 | 780 | ||
772 | repara::repara(const QString& pat) : tch(0) | 781 | repara::repara(const QString& pat) : tch(0) |
773 | { | 782 | { |
774 | // QString pat("{\\n[A-Z\"]}"); | 783 | // QString pat("{\\n[A-Z\"]}"); |
775 | flt = new CRegExpFilt(pat, false); | 784 | flt = new CRegExpFilt(pat, false); |
776 | qDebug("Construction done"); | 785 | qDebug("Construction done"); |
777 | } | 786 | } |
778 | 787 | ||
779 | repara::~repara() | 788 | repara::~repara() |
780 | { | 789 | { |
781 | delete flt; | 790 | delete flt; |
782 | } | 791 | } |
783 | 792 | ||
784 | void repara::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 793 | void repara::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
785 | { | 794 | { |
786 | if (flt->empty()) | 795 | if (flt->empty()) |
787 | { | 796 | { |
788 | while (flt->empty()) | 797 | while (flt->empty()) |
789 | { | 798 | { |
790 | parent->getch(ch, sty, pos); | 799 | parent->getch(ch, sty, pos); |
791 | flt->addch(ch); | 800 | flt->addch(ch); |
792 | } | 801 | } |
793 | } | 802 | } |
794 | ch = flt->pop(); | 803 | ch = flt->pop(); |
795 | /* | 804 | /* |
796 | parent->getch(ch, sty, pos); | 805 | parent->getch(ch, sty, pos); |
797 | if (ch == 10 || ch == ' ') | 806 | if (ch == 10 || ch == ' ') |
798 | { | 807 | { |
799 | if (tch == 10) | 808 | if (tch == 10) |
800 | { | 809 | { |
801 | tch = ch; | 810 | tch = ch; |
802 | ch = 10; | 811 | ch = 10; |
803 | return; | 812 | return; |
804 | } | 813 | } |
805 | else | 814 | else |
806 | { | 815 | { |
807 | tch = ch; | 816 | tch = ch; |
808 | ch = ' '; | 817 | ch = ' '; |
809 | return; | 818 | return; |
810 | } | 819 | } |
811 | } | 820 | } |
812 | tch = ch; | 821 | tch = ch; |
813 | */ | 822 | */ |
814 | return; | 823 | return; |
815 | } | 824 | } |
825 | |||
826 | void tableLink::getch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
827 | { | ||
828 | if (offset >= (int)text.length()) | ||
829 | { | ||
830 | offset = -1; | ||
831 | sty.setColour(m_r, m_g, m_b); | ||
832 | do | ||
833 | { | ||
834 | parent->getch(ch, sty, pos); | ||
835 | } | ||
836 | while (sty.isTable()); | ||
837 | return; | ||
838 | } | ||
839 | if (offset >= 0) | ||
840 | { | ||
841 | ch = text[offset++].unicode(); | ||
842 | return; | ||
843 | } | ||
844 | parent->getch(ch, sty, pos); | ||
845 | if (sty.isTable()) | ||
846 | { | ||
847 | offset = 1; | ||
848 | ch = text[0].unicode(); | ||
849 | m_r = sty.Red(), m_g = sty.Green(), m_b = sty.Blue(); | ||
850 | sty.setColour(255, 0, 0); | ||
851 | } | ||
852 | return; | ||
853 | } | ||
854 | |||
855 | void underlineLink::getch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
856 | { | ||
857 | parent->getch(ch, sty, pos); | ||
858 | if (sty.getLink()) sty.setUnderline(); | ||
859 | //if (isLink && !sty.getLink()) sty.unsetUnderline(); | ||
860 | //isLink = sty.getLink(); | ||
861 | } | ||
diff --git a/noncore/apps/opie-reader/CFilter.h b/noncore/apps/opie-reader/CFilter.h index 174e6b4..594b606 100644 --- a/noncore/apps/opie-reader/CFilter.h +++ b/noncore/apps/opie-reader/CFilter.h | |||
@@ -1,474 +1,523 @@ | |||
1 | #ifndef __CFILTER_H | 1 | #ifndef __CFILTER_H |
2 | #define __CFILTER_H | 2 | #define __CFILTER_H |
3 | 3 | ||
4 | #include "CExpander.h" | 4 | #include "CExpander.h" |
5 | #include "CEncoding.h" | 5 | #include "CEncoding.h" |
6 | 6 | ||
7 | class CFilter_IFace : public CCharacterSource | 7 | class CFilter_IFace : public CCharacterSource |
8 | { | 8 | { |
9 | public: | 9 | public: |
10 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) = 0; | 10 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) = 0; |
11 | virtual void setparent(CCharacterSource* p) = 0; | 11 | virtual void setparent(CCharacterSource* p) = 0; |
12 | virtual ~CFilter_IFace() {}; | 12 | virtual ~CFilter_IFace() {}; |
13 | virtual void locate(unsigned int n) = 0; | 13 | virtual void locate(unsigned int n) = 0; |
14 | virtual bool findanchor(const QString& nm) = 0; | 14 | virtual bool findanchor(const QString& nm) = 0; |
15 | virtual void saveposn(const QString& f, size_t posn) = 0; | 15 | virtual void saveposn(const QString& f, size_t posn) = 0; |
16 | virtual void writeposn(const QString& f, size_t posn) = 0; | 16 | virtual void writeposn(const QString& f, size_t posn) = 0; |
17 | virtual linkType forward(QString& f, size_t& loc) = 0; | 17 | virtual linkType forward(QString& f, size_t& loc) = 0; |
18 | virtual linkType back(QString& f, size_t& loc) = 0; | 18 | virtual linkType back(QString& f, size_t& loc) = 0; |
19 | virtual bool hasnavigation() = 0; | 19 | virtual bool hasnavigation() = 0; |
20 | virtual int getwidth() = 0; | 20 | virtual int getwidth() = 0; |
21 | virtual CCharacterSource* getparent() = 0; | 21 | virtual CCharacterSource* getparent() = 0; |
22 | virtual unsigned long startSection() = 0; | ||
22 | }; | 23 | }; |
23 | 24 | ||
24 | class CFilter : public CFilter_IFace | 25 | class CFilter : public CFilter_IFace |
25 | { | 26 | { |
26 | protected: | 27 | protected: |
27 | CCharacterSource* parent; | 28 | CCharacterSource* parent; |
28 | public: | 29 | public: |
30 | virtual QString getTableAsHtml(unsigned long loc) | ||
31 | { | ||
32 | qDebug("CFilter::getTableAsHtml()"); | ||
33 | return parent->getTableAsHtml(loc); | ||
34 | } | ||
29 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) | 35 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) |
30 | { | 36 | { |
31 | return parent->hyperlink(n,noff,w,nm); | 37 | return parent->hyperlink(n,noff,w,nm); |
32 | } | 38 | } |
33 | CFilter() : parent(NULL) {} | 39 | CFilter() : parent(NULL) {} |
34 | void setparent(CCharacterSource* p) { parent = p; } | 40 | void setparent(CCharacterSource* p) { parent = p; } |
35 | CCharacterSource* getparent() { return parent; } | 41 | CCharacterSource* getparent() { return parent; } |
36 | virtual ~CFilter() {}; | 42 | virtual ~CFilter() {}; |
37 | virtual void locate(unsigned int n) | 43 | virtual void locate(unsigned int n) |
38 | { | 44 | { |
39 | parent->locate(n); | 45 | parent->locate(n); |
40 | } | 46 | } |
41 | virtual bool findanchor(const QString& nm) | 47 | virtual bool findanchor(const QString& nm) |
42 | { | 48 | { |
43 | return parent->findanchor(nm); | 49 | return parent->findanchor(nm); |
44 | } | 50 | } |
45 | virtual void saveposn(const QString& f, size_t posn) { parent->saveposn(f, posn); } | 51 | virtual void saveposn(const QString& f, size_t posn) { parent->saveposn(f, posn); } |
46 | virtual void writeposn(const QString& f, size_t posn) { parent->writeposn(f, posn); } | 52 | virtual void writeposn(const QString& f, size_t posn) { parent->writeposn(f, posn); } |
47 | virtual linkType forward(QString& f, size_t& loc) { return parent->forward(f, loc); } | 53 | virtual linkType forward(QString& f, size_t& loc) { return parent->forward(f, loc); } |
48 | virtual linkType back(QString& f, size_t& loc) { return parent->back(f, loc); } | 54 | virtual linkType back(QString& f, size_t& loc) { return parent->back(f, loc); } |
49 | virtual bool hasnavigation() { return parent->hasnavigation(); } | 55 | virtual bool hasnavigation() { return parent->hasnavigation(); } |
50 | virtual int getwidth() { return parent->getwidth(); } | 56 | virtual int getwidth() { return parent->getwidth(); } |
51 | QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); } | 57 | QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); } |
52 | QImage* getPicture(const QString& href) { return parent->getPicture(href); } | 58 | QImage* getPicture(const QString& href) { return parent->getPicture(href); } |
53 | bool getFile(const QString& href) { return parent->getFile(href); } | 59 | bool getFile(const QString& href, const QString& nm) { return parent->getFile(href, nm); } |
60 | virtual unsigned long startSection() { return parent->startSection(); } | ||
54 | }; | 61 | }; |
55 | 62 | ||
56 | class CFilterChain | 63 | class CFilterChain |
57 | { | 64 | { |
58 | CExpander_Interface* expander; | 65 | CExpander_Interface* expander; |
59 | CEncoding* encoder; | 66 | CEncoding* encoder; |
60 | CFilter_IFace* first; | 67 | CFilter_IFace* first; |
61 | CCharacterSource* front; | 68 | CCharacterSource* front; |
62 | public: | 69 | public: |
63 | CFilterChain(CEncoding* _e) : encoder(_e), first(NULL), front(_e) {}; | 70 | CFilterChain(CEncoding* _e) : encoder(_e), first(NULL), front(_e) {}; |
64 | ~CFilterChain() | 71 | ~CFilterChain() |
65 | { | 72 | { |
66 | CCharacterSource* p = front; | 73 | CCharacterSource* p = front; |
67 | while (p != encoder) | 74 | while (p != encoder) |
68 | { | 75 | { |
69 | CFilter_IFace* pnext = (CFilter_IFace*)p; | 76 | CFilter_IFace* pnext = (CFilter_IFace*)p; |
70 | p = ((CFilter_IFace*)p)->getparent(); | 77 | p = ((CFilter_IFace*)p)->getparent(); |
71 | delete pnext; | 78 | delete pnext; |
72 | } | 79 | } |
73 | delete encoder; | 80 | delete encoder; |
74 | } | 81 | } |
75 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) | 82 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) |
76 | { | 83 | { |
77 | return front->hyperlink(n, noff, wrd, nm); | 84 | return front->hyperlink(n, noff, wrd, nm); |
78 | } | 85 | } |
86 | QString getTableAsHtml(unsigned long loc) | ||
87 | { | ||
88 | return front->getTableAsHtml(loc); | ||
89 | } | ||
79 | void locate(unsigned int n) | 90 | void locate(unsigned int n) |
80 | { | 91 | { |
81 | front->locate(n); | 92 | front->locate(n); |
82 | } | 93 | } |
83 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 94 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
84 | { | 95 | { |
85 | front->getch(ch, sty, pos); | 96 | front->getch(ch, sty, pos); |
86 | } | 97 | } |
98 | /* | ||
99 | void rawgetch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
100 | { | ||
101 | encoder->getch(ch, sty, pos); | ||
102 | } | ||
103 | */ | ||
87 | void addfilter(CFilter_IFace* p) | 104 | void addfilter(CFilter_IFace* p) |
88 | { | 105 | { |
89 | if (first == NULL) | 106 | if (first == NULL) |
90 | { | 107 | { |
91 | front = first = p; | 108 | front = first = p; |
92 | p->setparent(encoder); | 109 | p->setparent(encoder); |
93 | } | 110 | } |
94 | else | 111 | else |
95 | { | 112 | { |
96 | p->setparent(front); | 113 | p->setparent(front); |
97 | front = p; | 114 | front = p; |
98 | } | 115 | } |
99 | } | 116 | } |
100 | void setsource(CExpander_Interface* p) | 117 | void setsource(CExpander_Interface* p) |
101 | { | 118 | { |
102 | expander = p; | 119 | expander = p; |
103 | encoder->setparent(p); | 120 | encoder->setparent(p); |
104 | } | 121 | } |
105 | void setencoder(CEncoding* p) | 122 | void setencoder(CEncoding* p) |
106 | { | 123 | { |
107 | delete encoder; | 124 | delete encoder; |
108 | encoder = p; | 125 | encoder = p; |
109 | first->setparent(p); | 126 | first->setparent(p); |
110 | encoder->setparent(expander); | 127 | encoder->setparent(expander); |
111 | } | 128 | } |
112 | bool findanchor(const QString& nm) | 129 | bool findanchor(const QString& nm) |
113 | { | 130 | { |
114 | return front->findanchor(nm); | 131 | return front->findanchor(nm); |
115 | } | 132 | } |
116 | void saveposn(const QString& f, size_t posn) { front->saveposn(f, posn); } | 133 | void saveposn(const QString& f, size_t posn) { front->saveposn(f, posn); } |
117 | void writeposn(const QString& f, size_t posn) { front->writeposn(f, posn); } | 134 | void writeposn(const QString& f, size_t posn) { front->writeposn(f, posn); } |
118 | linkType forward(QString& f, size_t& loc) { return front->forward(f, loc); } | 135 | linkType forward(QString& f, size_t& loc) { return front->forward(f, loc); } |
119 | linkType back(QString& f, size_t& loc) { return front->back(f, loc); } | 136 | linkType back(QString& f, size_t& loc) { return front->back(f, loc); } |
120 | bool hasnavigation() { return front->hasnavigation(); } | 137 | bool hasnavigation() { return front->hasnavigation(); } |
121 | QString about() { return QString("Filter chain (c) Tim Wentford\n")+front->about(); } | 138 | QString about() { return QString("Filter chain (c) Tim Wentford\n")+front->about(); } |
122 | }; | 139 | }; |
123 | 140 | ||
124 | class stripcr : public CFilter | 141 | class stripcr : public CFilter |
125 | { | 142 | { |
126 | public: | 143 | public: |
127 | stripcr() {} | 144 | stripcr() {} |
128 | ~stripcr() {} | 145 | ~stripcr() {} |
129 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 146 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
130 | { | 147 | { |
131 | do | 148 | do |
132 | { | 149 | { |
133 | parent->getch(ch, sty, pos); | 150 | parent->getch(ch, sty, pos); |
134 | } | 151 | } |
135 | while (ch == 13); | 152 | while (ch == 13); |
136 | } | 153 | } |
137 | QString about() { return QString("StripCR filter (c) Tim Wentford\n")+parent->about(); } | 154 | QString about() { return QString("StripCR filter (c) Tim Wentford\n")+parent->about(); } |
138 | }; | 155 | }; |
139 | 156 | ||
140 | class dehyphen : public CFilter | 157 | class dehyphen : public CFilter |
141 | { | 158 | { |
142 | bool m_bCharWaiting; | 159 | bool m_bCharWaiting; |
143 | tchar m_nextChar; | 160 | tchar m_nextChar; |
144 | CStyle m_nextSty; | 161 | CStyle m_nextSty; |
145 | public: | 162 | public: |
146 | dehyphen() : m_bCharWaiting(false) {} | 163 | dehyphen() : m_bCharWaiting(false) {} |
147 | ~dehyphen() {} | 164 | ~dehyphen() {} |
148 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 165 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
149 | { | 166 | { |
150 | if (m_bCharWaiting) | 167 | if (m_bCharWaiting) |
151 | { | 168 | { |
152 | m_bCharWaiting = false; | 169 | m_bCharWaiting = false; |
153 | ch = m_nextChar; | 170 | ch = m_nextChar; |
154 | sty = m_nextSty; | 171 | sty = m_nextSty; |
155 | return; | 172 | return; |
156 | } | 173 | } |
157 | parent->getch(ch, sty, pos); | 174 | parent->getch(ch, sty, pos); |
158 | if (ch != '-') return; | 175 | if (ch != '-') return; |
159 | parent->getch(m_nextChar, m_nextSty, pos); | 176 | parent->getch(m_nextChar, m_nextSty, pos); |
160 | if (m_nextChar != 10) | 177 | if (m_nextChar != 10) |
161 | { | 178 | { |
162 | m_bCharWaiting = true; | 179 | m_bCharWaiting = true; |
163 | ch = '-'; | 180 | ch = '-'; |
164 | return; | 181 | return; |
165 | } | 182 | } |
166 | parent->getch(ch, sty, pos); | 183 | parent->getch(ch, sty, pos); |
167 | } | 184 | } |
168 | QString about() { return QString("Hyphenation filter (c) Tim Wentford\n")+parent->about(); } | 185 | QString about() { return QString("Hyphenation filter (c) Tim Wentford\n")+parent->about(); } |
169 | }; | 186 | }; |
170 | 187 | ||
171 | template<class A, class B>class QMap; | 188 | template<class A, class B>class QMap; |
172 | 189 | ||
173 | const int m_cmaxdepth = 8; | 190 | const int m_cmaxdepth = 8; |
174 | 191 | ||
175 | class htmlmark | 192 | class htmlmark |
176 | { | 193 | { |
177 | QString file; | 194 | QString file; |
178 | size_t pos; | 195 | size_t pos; |
179 | public: | 196 | public: |
180 | htmlmark() : file(), pos(0) {} | 197 | htmlmark() : file(), pos(0) {} |
181 | htmlmark(const QString& _f, size_t _p) : file(_f), pos(_p) {} | 198 | htmlmark(const QString& _f, size_t _p) : file(_f), pos(_p) {} |
182 | QString filename() { return file; } | 199 | QString filename() { return file; } |
183 | size_t posn() { return pos; } | 200 | size_t posn() { return pos; } |
184 | }; | 201 | }; |
185 | 202 | ||
186 | class unindent : public CFilter | 203 | class unindent : public CFilter |
187 | { | 204 | { |
188 | tchar lc; | 205 | tchar lc; |
189 | public: | 206 | public: |
190 | unindent() : lc(0) {} | 207 | unindent() : lc(0) {} |
191 | ~unindent() {} | 208 | ~unindent() {} |
192 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 209 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
193 | { | 210 | { |
194 | if (lc == 10) | 211 | if (lc == 10) |
195 | { | 212 | { |
196 | do | 213 | do |
197 | { | 214 | { |
198 | parent->getch(ch, sty, pos); | 215 | parent->getch(ch, sty, pos); |
199 | } | 216 | } |
200 | while (ch == ' '); | 217 | while (ch == ' '); |
201 | } | 218 | } |
202 | else parent->getch(ch, sty, pos); | 219 | else parent->getch(ch, sty, pos); |
203 | lc = ch; | 220 | lc = ch; |
204 | return; | 221 | return; |
205 | } | 222 | } |
206 | QString about() { return QString("Unindent filter (c) Tim Wentford\n")+parent->about(); } | 223 | QString about() { return QString("Unindent filter (c) Tim Wentford\n")+parent->about(); } |
207 | }; | 224 | }; |
208 | 225 | ||
209 | class CRegExpFilt; | 226 | class CRegExpFilt; |
210 | class repara : public CFilter | 227 | class repara : public CFilter |
211 | { | 228 | { |
212 | tchar tch; | 229 | tchar tch; |
213 | CRegExpFilt* flt; | 230 | CRegExpFilt* flt; |
214 | public: | 231 | public: |
215 | repara(const QString&); | 232 | repara(const QString&); |
216 | ~repara(); | 233 | ~repara(); |
217 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 234 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
218 | QString about() { return QString("Reparagraph filter (c) Tim Wentford\n")+parent->about(); } | 235 | QString about() { return QString("Reparagraph filter (c) Tim Wentford\n")+parent->about(); } |
219 | }; | 236 | }; |
220 | 237 | ||
221 | class indenter : public CFilter | 238 | class indenter : public CFilter |
222 | { | 239 | { |
223 | int amnt; | 240 | int amnt; |
224 | int indent; | 241 | int indent; |
225 | CStyle lsty; | 242 | CStyle lsty; |
226 | public: | 243 | public: |
227 | indenter(int _a=5) : amnt(_a), indent(0) {} | 244 | indenter(int _a=5) : amnt(_a), indent(0) {} |
228 | ~indenter() {} | 245 | ~indenter() {} |
229 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 246 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
230 | { | 247 | { |
231 | if (indent > 0) | 248 | if (indent > 0) |
232 | { | 249 | { |
233 | indent--; | 250 | indent--; |
234 | ch = ' '; | 251 | ch = ' '; |
235 | sty = lsty; | 252 | sty = lsty; |
236 | return; | 253 | return; |
237 | } | 254 | } |
238 | parent->getch(ch, sty, pos); | 255 | parent->getch(ch, sty, pos); |
239 | if (ch == 10) | 256 | if (ch == 10) |
240 | { | 257 | { |
241 | indent = amnt; | 258 | indent = amnt; |
242 | lsty = sty; | 259 | lsty = sty; |
243 | } | 260 | } |
244 | return; | 261 | return; |
245 | } | 262 | } |
246 | QString about() { return QString("Indentation filter (c) Tim Wentford\n")+parent->about(); } | 263 | QString about() { return QString("Indentation filter (c) Tim Wentford\n")+parent->about(); } |
247 | }; | 264 | }; |
248 | 265 | ||
249 | class dblspce : public CFilter | 266 | class dblspce : public CFilter |
250 | { | 267 | { |
251 | bool lastlf; | 268 | bool lastlf; |
252 | CStyle lsty; | 269 | CStyle lsty; |
253 | public: | 270 | public: |
254 | dblspce() : lastlf(false) {} | 271 | dblspce() : lastlf(false) {} |
255 | ~dblspce() {} | 272 | ~dblspce() {} |
256 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 273 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
257 | { | 274 | { |
258 | if (lastlf) | 275 | if (lastlf) |
259 | { | 276 | { |
260 | lastlf = false; | 277 | lastlf = false; |
261 | ch = 10; | 278 | ch = 10; |
262 | sty = lsty; | 279 | sty = lsty; |
263 | return; | 280 | return; |
264 | } | 281 | } |
265 | parent->getch(ch, sty, pos); | 282 | parent->getch(ch, sty, pos); |
266 | if (lastlf = (ch == 10)) | 283 | if (lastlf = (ch == 10)) |
267 | { | 284 | { |
268 | lsty = sty; | 285 | lsty = sty; |
269 | } | 286 | } |
270 | return; | 287 | return; |
271 | } | 288 | } |
272 | QString about() { return QString("Double space (c) Tim Wentford\n")+parent->about(); } | 289 | QString about() { return QString("Double space (c) Tim Wentford\n")+parent->about(); } |
273 | }; | 290 | }; |
274 | 291 | ||
275 | class textfmt : public CFilter | 292 | class textfmt : public CFilter |
276 | { | 293 | { |
277 | CStyle currentstyle; | 294 | CStyle currentstyle; |
278 | tchar lastchar; | 295 | tchar lastchar; |
279 | bool uselast; | 296 | bool uselast; |
280 | void mygetch(tchar&, CStyle&, unsigned long& pos); | 297 | void mygetch(tchar&, CStyle&, unsigned long& pos); |
281 | public: | 298 | public: |
282 | textfmt() : lastchar(0), uselast(false) {} | 299 | textfmt() : lastchar(0), uselast(false) {} |
283 | ~textfmt() {} | 300 | ~textfmt() {} |
284 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 301 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
285 | QString about() { return QString("Text formatting filter (c) Tim Wentford\n")+parent->about(); } | 302 | QString about() { return QString("Text formatting filter (c) Tim Wentford\n")+parent->about(); } |
286 | }; | 303 | }; |
287 | 304 | ||
288 | class embolden : public CFilter | 305 | class embolden : public CFilter |
289 | { | 306 | { |
290 | public: | 307 | public: |
291 | embolden() {} | 308 | embolden() {} |
292 | ~embolden() {} | 309 | ~embolden() {} |
293 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 310 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
294 | { | 311 | { |
295 | parent->getch(ch, sty, pos); | 312 | parent->getch(ch, sty, pos); |
296 | sty.setBold(); | 313 | sty.setBold(); |
297 | } | 314 | } |
298 | QString about() { return QString("Emboldening filter (c) Tim Wentford\n")+parent->about(); } | 315 | QString about() { return QString("Emboldening filter (c) Tim Wentford\n")+parent->about(); } |
299 | }; | 316 | }; |
300 | 317 | ||
301 | class remap : public CFilter | 318 | class remap : public CFilter |
302 | { | 319 | { |
303 | tchar q[3]; | 320 | tchar q[3]; |
304 | int offset; | 321 | int offset; |
305 | CStyle currentstyle; | 322 | CStyle currentstyle; |
306 | public: | 323 | public: |
307 | remap() : offset(0) { q[0] = 0; } | 324 | remap() : offset(0) { q[0] = 0; } |
308 | ~remap() {} | 325 | ~remap() {} |
309 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 326 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
310 | QString about() { return QString("Character remapping filter (c) Tim Wentford\n")+parent->about(); } | 327 | QString about() { return QString("Character remapping filter (c) Tim Wentford\n")+parent->about(); } |
311 | }; | 328 | }; |
312 | 329 | ||
313 | class PeanutFormatter : public CFilter | 330 | class PeanutFormatter : public CFilter |
314 | { | 331 | { |
315 | CStyle currentstyle; | 332 | CStyle currentstyle; |
316 | public: | 333 | public: |
317 | ~PeanutFormatter() {} | 334 | ~PeanutFormatter() {} |
318 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 335 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
319 | QString about() { return QString("PML filter (c) Tim Wentford\n")+parent->about(); } | 336 | QString about() { return QString("PML filter (c) Tim Wentford\n")+parent->about(); } |
320 | }; | 337 | }; |
321 | 338 | ||
322 | class OnePara : public CFilter | 339 | class OnePara : public CFilter |
323 | { | 340 | { |
324 | tchar m_lastchar; | 341 | tchar m_lastchar; |
325 | public: | 342 | public: |
326 | OnePara() : m_lastchar(0) {} | 343 | OnePara() : m_lastchar(0) {} |
327 | ~OnePara() {} | 344 | ~OnePara() {} |
328 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 345 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
329 | QString about() { return QString("Single space filter (c) Tim Wentford\n")+parent->about(); } | 346 | QString about() { return QString("Single space filter (c) Tim Wentford\n")+parent->about(); } |
330 | }; | 347 | }; |
331 | 348 | ||
332 | class DePluck : public CFilter | 349 | class DePluck : public CFilter |
333 | { | 350 | { |
334 | tchar* nextpart; | 351 | tchar* nextpart; |
335 | tchar m_buffer; | 352 | tchar m_buffer; |
336 | int m_buffed; | 353 | int m_buffed; |
337 | int m_current; | 354 | int m_current; |
338 | bool m_debuff; | 355 | bool m_debuff; |
339 | CStyle m_laststyle; | 356 | CStyle m_laststyle; |
340 | public: | 357 | public: |
341 | DePluck(tchar* t) : nextpart(t), m_buffer(0), m_buffed(0), m_current(0), m_debuff(false) {} | 358 | DePluck(tchar* t) : nextpart(t), m_buffer(0), m_buffed(0), m_current(0), m_debuff(false) {} |
342 | ~DePluck() {} | 359 | ~DePluck() {} |
343 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 360 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
344 | QString about() { return QString("Depluck filter (c) Tim Wentford\n")+parent->about(); } | 361 | QString about() { return QString("Depluck filter (c) Tim Wentford\n")+parent->about(); } |
345 | }; | 362 | }; |
346 | 363 | ||
347 | class repalm : public CFilter | 364 | class repalm : public CFilter |
348 | { | 365 | { |
349 | public: | 366 | public: |
350 | ~repalm() {} | 367 | ~repalm() {} |
351 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 368 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
352 | QString about() { return QString("Repalm filter (c) Tim Wentford\n")+parent->about(); } | 369 | QString about() { return QString("Repalm filter (c) Tim Wentford\n")+parent->about(); } |
353 | }; | 370 | }; |
354 | 371 | ||
355 | class FullJust : public CFilter | 372 | class FullJust : public CFilter |
356 | { | 373 | { |
357 | public: | 374 | public: |
358 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 375 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
359 | { | 376 | { |
360 | parent->getch(ch, sty, pos); | 377 | parent->getch(ch, sty, pos); |
361 | if (sty.getJustify() == m_AlignLeft) sty.setFullJustify(); | 378 | if (sty.getJustify() == m_AlignLeft) sty.setFullJustify(); |
362 | } | 379 | } |
363 | QString about() { return QString("Full justification filter (c) Tim Wentford\n")+parent->about(); } | 380 | QString about() { return QString("Full justification filter (c) Tim Wentford\n")+parent->about(); } |
364 | }; | 381 | }; |
365 | /* | 382 | /* |
366 | class AddSpace : public CFilter | 383 | class AddSpace : public CFilter |
367 | { | 384 | { |
368 | unsigned char m_espc; | 385 | unsigned char m_espc; |
369 | public: | 386 | public: |
370 | AddSpace(unsigned char s) : m_espc(s) {} | 387 | AddSpace(unsigned char s) : m_espc(s) {} |
371 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 388 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
372 | { | 389 | { |
373 | parent->getch(ch, sty, pos); | 390 | parent->getch(ch, sty, pos); |
374 | sty.setExtraSpace(m_espc); | 391 | sty.setExtraSpace(m_espc); |
375 | } | 392 | } |
376 | }; | 393 | }; |
377 | */ | 394 | */ |
378 | 395 | ||
379 | class QTReader; | 396 | class QTReader; |
380 | 397 | ||
381 | class HighlightFilter : public CFilter | 398 | class HighlightFilter : public CFilter |
382 | { | 399 | { |
383 | QTReader* pReader; | 400 | QTReader* pReader; |
384 | unsigned long lastpos, nextpos; | 401 | unsigned long lastpos, nextpos; |
385 | unsigned char red, green, blue; | 402 | unsigned char red, green, blue; |
386 | CList<Bkmk>* bkmks; | 403 | CList<Bkmk>* bkmks; |
387 | public: | 404 | public: |
388 | HighlightFilter(QTReader*); | 405 | HighlightFilter(QTReader*); |
389 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 406 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
390 | void refresh(unsigned long); | 407 | void refresh(unsigned long); |
391 | QString about() { return QString("High-lighting filter (c) Tim Wentford\n")+parent->about(); } | 408 | QString about() { return QString("High-lighting filter (c) Tim Wentford\n")+parent->about(); } |
392 | }; | 409 | }; |
393 | 410 | ||
394 | #ifndef __STATIC | 411 | #ifndef __STATIC |
395 | #include <dlfcn.h> | 412 | #include <dlfcn.h> |
396 | 413 | ||
397 | class ExternFilter : public CFilter_IFace | 414 | class ExternFilter : public CFilter_IFace |
398 | { | 415 | { |
399 | CFilter* filt; | 416 | CFilter* filt; |
400 | void *handle; | 417 | void *handle; |
401 | public: | 418 | public: |
402 | linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) | 419 | linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) |
403 | { | 420 | { |
404 | return filt->hyperlink(n, noff, w, nm); | 421 | return filt->hyperlink(n, noff, w, nm); |
405 | } | 422 | } |
423 | QString getTableAsHtml(unsigned long loc) | ||
424 | { | ||
425 | qDebug("ExternFilter::getTableAsHtml()"); | ||
426 | return filt->getTableAsHtml(loc); | ||
427 | } | ||
406 | void setparent(CCharacterSource* p) { filt->setparent(p); } | 428 | void setparent(CCharacterSource* p) { filt->setparent(p); } |
407 | ExternFilter(const QString& nm, const QString& optional); | 429 | ExternFilter(const QString& nm, const QString& optional); |
408 | ~ExternFilter() | 430 | ~ExternFilter() |
409 | { | 431 | { |
410 | if (filt != NULL) delete filt; | 432 | if (filt != NULL) delete filt; |
411 | if (handle != NULL) dlclose(handle); | 433 | if (handle != NULL) dlclose(handle); |
412 | } | 434 | } |
413 | void locate(unsigned int n) { filt->locate(n); } | 435 | void locate(unsigned int n) { filt->locate(n); } |
414 | bool findanchor(const QString& nm) { return filt->findanchor(nm); } | 436 | bool findanchor(const QString& nm) |
437 | { | ||
438 | return filt->findanchor(nm); | ||
439 | } | ||
415 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } | 440 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } |
416 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } | 441 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } |
417 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } | 442 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } |
418 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } | 443 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } |
419 | bool hasnavigation() { return filt->hasnavigation(); } | 444 | bool hasnavigation() { return filt->hasnavigation(); } |
420 | int getwidth() { return filt->getwidth(); } | 445 | int getwidth() { return filt->getwidth(); } |
421 | CCharacterSource* getparent() { return filt->getparent(); } | 446 | CCharacterSource* getparent() { return filt->getparent(); } |
422 | void getch(tchar& c, CStyle& s, unsigned long& l) { filt->getch(c, s, l); } | 447 | void getch(tchar& c, CStyle& s, unsigned long& l) { filt->getch(c, s, l); } |
423 | QImage* getPicture(unsigned long tgt) { return filt->getPicture(tgt); } | 448 | QImage* getPicture(unsigned long tgt) { return filt->getPicture(tgt); } |
424 | CFilter* filter() { return filt; } | 449 | CFilter* filter() { return filt; } |
425 | QImage* getPicture(const QString& href) { return filt->getPicture(href); } | 450 | QImage* getPicture(const QString& href) { return filt->getPicture(href); } |
426 | bool getFile(const QString& href) { return filt->getFile(href); } | 451 | bool getFile(const QString& href, const QString& nm) { return filt->getFile(href, nm); } |
427 | QString about() { return QString("Filter plug-in (c) Tim Wentford\n")+filt->about(); } | 452 | QString about() { return QString("Filter plug-in (c) Tim Wentford\n")+filt->about(); } |
453 | unsigned long startSection() { return filt->startSection(); } | ||
428 | }; | 454 | }; |
429 | #endif | 455 | #endif |
430 | 456 | ||
431 | class kern : public CFilter | 457 | class kern : public CFilter |
432 | { | 458 | { |
433 | tchar lastchar; | 459 | tchar lastchar; |
434 | bool uselast; | 460 | bool uselast; |
435 | CStyle laststy; | 461 | CStyle laststy; |
436 | public: | 462 | public: |
437 | kern() : lastchar(0), uselast(false) {} | 463 | kern() : lastchar(0), uselast(false) {} |
438 | ~kern() {} | 464 | ~kern() {} |
439 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 465 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
440 | QString about() { return QString("Kerning filter (c) Tim Wentford\n")+parent->about(); } | 466 | QString about() { return QString("Kerning filter (c) Tim Wentford\n")+parent->about(); } |
441 | }; | 467 | }; |
442 | 468 | ||
443 | class makeInverse : public CFilter | 469 | class makeInverse : public CFilter |
444 | { | 470 | { |
445 | public: | 471 | public: |
446 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 472 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
447 | QString about() { return QString("Colourmap inversion filter (c) Tim Wentford\n")+parent->about(); } | 473 | QString about() { return QString("Colourmap inversion filter (c) Tim Wentford\n")+parent->about(); } |
448 | }; | 474 | }; |
449 | /* | 475 | /* |
450 | class makeNegative : public CFilter | 476 | class makeNegative : public CFilter |
451 | { | 477 | { |
452 | public: | 478 | public: |
453 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 479 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
454 | }; | 480 | }; |
455 | */ | 481 | */ |
456 | class setbg : public CFilter | 482 | class setbg : public CFilter |
457 | { | 483 | { |
458 | int m_r, m_g, m_b; | 484 | int m_r, m_g, m_b; |
459 | public: | 485 | public: |
460 | setbg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} | 486 | setbg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} |
461 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 487 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
462 | QString about() { return QString("Background colour filter (c) Tim Wentford\n")+parent->about(); } | 488 | QString about() { return QString("Background colour filter (c) Tim Wentford\n")+parent->about(); } |
463 | }; | 489 | }; |
464 | 490 | ||
465 | class setfg : public CFilter | 491 | class setfg : public CFilter |
466 | { | 492 | { |
467 | int m_r, m_g, m_b; | 493 | int m_r, m_g, m_b; |
468 | public: | 494 | public: |
469 | setfg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} | 495 | setfg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} |
470 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 496 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
471 | QString about() { return QString("Foreground colour filter (c) Tim Wentford\n")+parent->about(); } | 497 | QString about() { return QString("Foreground colour filter (c) Tim Wentford\n")+parent->about(); } |
472 | }; | 498 | }; |
473 | 499 | ||
500 | class tableLink : public CFilter | ||
501 | { | ||
502 | QString text; | ||
503 | int offset; | ||
504 | int m_r, m_g, m_b; | ||
505 | public: | ||
506 | tableLink() : text( "See Table" ), offset(-1) | ||
507 | { | ||
508 | } | ||
509 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | ||
510 | QString about() { return QString("Table link filter (c) Tim Wentford\n")+parent->about(); } | ||
511 | }; | ||
512 | |||
513 | class underlineLink : public CFilter | ||
514 | { | ||
515 | bool isLink; | ||
516 | public: | ||
517 | underlineLink() : isLink(false) {} | ||
518 | ~underlineLink() {} | ||
519 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | ||
520 | QString about() { return QString("Link underlining filter (c) Tim Wentford\n")+parent->about(); } | ||
521 | }; | ||
522 | |||
474 | #endif | 523 | #endif |
diff --git a/noncore/apps/opie-reader/CHM.cpp b/noncore/apps/opie-reader/CHM.cpp index 88d53bf..ace5abc 100644 --- a/noncore/apps/opie-reader/CHM.cpp +++ b/noncore/apps/opie-reader/CHM.cpp | |||
@@ -1,379 +1,390 @@ | |||
1 | #include "CHM.h" | 1 | #include "CHM.h" |
2 | #include "chm_lib.h" | 2 | #include "chm_lib.h" |
3 | #include <qstring.h> | 3 | #include <qstring.h> |
4 | #include <qstringlist.h> | 4 | #include <qstringlist.h> |
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | #include <qimage.h> | 6 | #include <qimage.h> |
7 | #include <qpixmap.h> | 7 | #include <qpixmap.h> |
8 | #ifdef USEQPE | ||
9 | #include <qpe/global.h> | ||
10 | #endif | ||
8 | 11 | ||
9 | #ifndef __STATIC | 12 | #ifndef __STATIC |
10 | extern "C" | 13 | extern "C" |
11 | { | 14 | { |
12 | CExpander* newcodec() { return new CHM; } | 15 | CExpander* newcodec() { return new CHM; } |
13 | } | 16 | } |
14 | #endif | 17 | #endif |
15 | 18 | ||
16 | static int _print_ui_index(struct chmFile *h, struct chmUnitInfo *ui, | 19 | static int _print_ui_index(struct chmFile *h, struct chmUnitInfo *ui, |
17 | void *context) | 20 | void *context) |
18 | { | 21 | { |
19 | CHM *chm = (CHM *)context; | 22 | CHM *chm = (CHM *)context; |
20 | QString temp = "<tr>"; | 23 | QString temp = "<tr>"; |
21 | char buff[1024]; | 24 | char buff[1024]; |
22 | sprintf( buff,"<td align=right>%8d\n</td><td><a href=\"%s\">%s</a></td></tr>",(int)ui->length, ui->path, ui->path); | 25 | sprintf( buff,"<td align=right>%8d\n</td><td><a href=\"%s\">%s</a></td></tr>",(int)ui->length, ui->path, ui->path); |
23 | temp += buff; | 26 | temp += buff; |
24 | chm->addContent(temp); | 27 | chm->addContent(temp); |
25 | return CHM_ENUMERATOR_CONTINUE; | 28 | return CHM_ENUMERATOR_CONTINUE; |
26 | } | 29 | } |
27 | 30 | ||
28 | static int _get_hhc (struct chmFile *h, struct chmUnitInfo *ui, | 31 | static int _get_hhc (struct chmFile *h, struct chmUnitInfo *ui, |
29 | void *context) | 32 | void *context) |
30 | { | 33 | { |
31 | CHM *chm = (CHM *)context; | 34 | CHM *chm = (CHM *)context; |
32 | QString PathName = ui->path; | 35 | QString PathName = ui->path; |
33 | if (PathName.find(".hhc") > -1) { | 36 | if (PathName.find(".hhc") > -1) { |
34 | chm->setPath(PathName); | 37 | chm->setPath(PathName); |
35 | } | 38 | } |
36 | return CHM_ENUMERATOR_CONTINUE; | 39 | return CHM_ENUMERATOR_CONTINUE; |
37 | } | 40 | } |
38 | 41 | ||
39 | CHM::CHM() { | 42 | CHM::CHM() { |
40 | chmFile = NULL; | 43 | chmFile = NULL; |
41 | chmPath = ""; | 44 | chmPath = ""; |
42 | chmHHCPath = ""; | 45 | chmHHCPath = ""; |
43 | chmBuffer = ""; | 46 | chmBuffer = ""; |
44 | bufpos = 0; | 47 | bufpos = 0; |
45 | } | 48 | } |
46 | 49 | ||
47 | CHM::~CHM() { | 50 | CHM::~CHM() { |
48 | if (chmFile != NULL) | 51 | if (chmFile != NULL) |
49 | chm_close(chmFile); | 52 | chm_close(chmFile); |
50 | } | 53 | } |
51 | 54 | ||
52 | void CHM::suspend() { | 55 | void CHM::suspend() { |
53 | #ifdef USEQPE | 56 | #ifdef USEQPE |
54 | bSuspended = true; | 57 | bSuspended = true; |
55 | //suspos = gztell(file); | 58 | //suspos = gztell(file); |
56 | chm_close(chmFile); | 59 | chm_close(chmFile); |
57 | chmFile = NULL; | 60 | chmFile = NULL; |
58 | sustime = time(NULL); | 61 | sustime = time(NULL); |
59 | #endif | 62 | #endif |
60 | } | 63 | } |
61 | 64 | ||
62 | void CHM::unsuspend() { | 65 | void CHM::unsuspend() { |
63 | #ifdef USEQPE | 66 | #ifdef USEQPE |
64 | if (bSuspended) | 67 | if (bSuspended) |
65 | { | 68 | { |
66 | bSuspended = false; | 69 | bSuspended = false; |
67 | int delay = time(NULL) - sustime; | 70 | int delay = time(NULL) - sustime; |
68 | if (delay < 10) | 71 | if (delay < 10) |
69 | sleep(10-delay); | 72 | { |
73 | Global::statusMessage("Stalling"); | ||
74 | sleep(10-delay); | ||
75 | } | ||
70 | chmFile = chm_open(fname); | 76 | chmFile = chm_open(fname); |
71 | for (int i = 0; chmFile == NULL && i < 5; i++) { | 77 | for (int i = 0; chmFile == NULL && i < 5; i++) { |
78 | Global::statusMessage("Stalling"); | ||
72 | sleep(5); | 79 | sleep(5); |
73 | chmFile = chm_open(fname); | 80 | chmFile = chm_open(fname); |
74 | } | 81 | } |
75 | if (chmFile == NULL) { | 82 | if (chmFile == NULL) { |
76 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); | 83 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); |
77 | exit(0); | 84 | exit(0); |
78 | } | 85 | } |
79 | //suspos = gzseek(file, suspos, SEEK_SET); | 86 | //suspos = gzseek(file, suspos, SEEK_SET); |
80 | } | 87 | } |
81 | #endif | 88 | #endif |
82 | } | 89 | } |
83 | 90 | ||
84 | void CHM::addContent(QString content) { | 91 | void CHM::addContent(QString content) { |
85 | chmBuffer += content; | 92 | chmBuffer += content; |
86 | } | 93 | } |
87 | 94 | ||
88 | void CHM::FillHomeContent() { | 95 | void CHM::FillHomeContent() { |
96 | unsuspend(); | ||
89 | if (chmHHCPath != "") { | 97 | if (chmHHCPath != "") { |
90 | const char *ext; | 98 | const char *ext; |
91 | char buffer[65536]; | 99 | char buffer[65536]; |
92 | unsigned int swath, offset; | 100 | unsigned int swath, offset; |
93 | QString tmp=""; | 101 | QString tmp=""; |
94 | QString HTML=""; | 102 | QString HTML=""; |
95 | /* try to find the file */ | 103 | /* try to find the file */ |
96 | const char *filename = (const char *)chmHHCPath; | 104 | const char *filename = (const char *)chmHHCPath; |
97 | if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) | 105 | if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) |
98 | { | 106 | { |
99 | chmBuffer = "HELP"; | 107 | chmBuffer = "HELP"; |
100 | fsize = chmBuffer.length(); | 108 | fsize = chmBuffer.length(); |
101 | return; | 109 | return; |
102 | } | 110 | } |
103 | m_homestart = m_ui.start; | 111 | m_homestart = m_ui.start; |
104 | m_homeend = m_homestart + m_ui.length; | 112 | m_homeend = m_homestart + m_ui.length; |
105 | swath = 65536; | 113 | swath = 65536; |
106 | offset = 0; | 114 | offset = 0; |
107 | fsize = m_ui.length; | 115 | fsize = m_ui.length; |
108 | while (offset < m_ui.length) | 116 | while (offset < m_ui.length) |
109 | { | 117 | { |
110 | if ((m_ui.length - offset) < 65536) | 118 | if ((m_ui.length - offset) < 65536) |
111 | swath = m_ui.length - offset; | 119 | swath = m_ui.length - offset; |
112 | else | 120 | else |
113 | swath = 65536; | 121 | swath = 65536; |
114 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); | 122 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); |
115 | tmp += buffer; | 123 | tmp += buffer; |
116 | offset += swath; | 124 | offset += swath; |
117 | } | 125 | } |
118 | HTML +="<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN>\r\n"; | 126 | HTML +="<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN>\r\n"; |
119 | HTML +="<HTML>\r\n"; | 127 | HTML +="<HTML>\r\n"; |
120 | HTML +="<BODY>\r\n"; | 128 | HTML +="<BODY>\r\n"; |
121 | HTML +="<h2>Home Page</h2>\r\n"; | 129 | HTML +="<h2>Home Page</h2>\r\n"; |
122 | HTML +="<h3>\r\n"; | 130 | HTML +="<h3>\r\n"; |
123 | QStringList qsl = QStringList::split("\r\n",tmp); | 131 | QStringList qsl = QStringList::split("\r\n",tmp); |
124 | QString NameFind ="<param name=\"Name\" value=\""; | 132 | QString NameFind ="<param name=\"Name\" value=\""; |
125 | QString LocalFind = "<param name=\"Local\" value=\""; | 133 | QString LocalFind = "<param name=\"Local\" value=\""; |
126 | QString ULOpenFind = "<UL>"; | 134 | QString ULOpenFind = "<UL>"; |
127 | QString LIOpenFind = "<LI>"; | 135 | QString LIOpenFind = "<LI>"; |
128 | QString ULCloseFind = "</UL>"; | 136 | QString ULCloseFind = "</UL>"; |
129 | QString Name = ""; | 137 | QString Name = ""; |
130 | QString Local = ""; | 138 | QString Local = ""; |
131 | for ( QStringList::Iterator it = qsl.begin(); it != qsl.end(); ++it ) { | 139 | for ( QStringList::Iterator it = qsl.begin(); it != qsl.end(); ++it ) { |
132 | QString Line = (*it); | 140 | QString Line = (*it); |
133 | int NamePos = Line.find( NameFind); | 141 | int NamePos = Line.find( NameFind); |
134 | int LocalPos = Line.find( LocalFind); | 142 | int LocalPos = Line.find( LocalFind); |
135 | if (NamePos > -1) { | 143 | if (NamePos > -1) { |
136 | Name = Line.mid(NamePos+NameFind.length(),Line.length()); | 144 | Name = Line.mid(NamePos+NameFind.length(),Line.length()); |
137 | Name = Name.left(Name.length() - 2); | 145 | Name = Name.left(Name.length() - 2); |
138 | } | 146 | } |
139 | if (LocalPos > -1) { | 147 | if (LocalPos > -1) { |
140 | Local = Line.mid(LocalPos+LocalFind.length(),Line.length()); | 148 | Local = Line.mid(LocalPos+LocalFind.length(),Line.length()); |
141 | Local = Local.left(Local.length() - 2); | 149 | Local = Local.left(Local.length() - 2); |
142 | if (Name != "") { | 150 | if (Name != "") { |
143 | HTML += "<br>\r\n<a href="; | 151 | HTML += "<br>\r\n<a href="; |
144 | HTML += Local; | 152 | HTML += Local; |
145 | HTML += ">"; | 153 | HTML += ">"; |
146 | HTML += Name; | 154 | HTML += Name; |
147 | HTML += "</a>\r\n"; | 155 | HTML += "</a>\r\n"; |
148 | Name = ""; | 156 | Name = ""; |
149 | } | 157 | } |
150 | } | 158 | } |
151 | } | 159 | } |
152 | HTML +="</h3>"; | 160 | HTML +="</h3>"; |
153 | HTML +="</BODY>\r\n"; | 161 | HTML +="</BODY>\r\n"; |
154 | HTML +="</HTML>\r\n"; | 162 | HTML +="</HTML>\r\n"; |
155 | chmHomeBuffer = HTML; | 163 | chmHomeBuffer = HTML; |
156 | chmBuffer = HTML; | 164 | chmBuffer = HTML; |
157 | fsize = chmBuffer.length(); | 165 | fsize = chmBuffer.length(); |
158 | m_currentstart = m_ui.start; | 166 | m_currentstart = m_ui.start; |
159 | m_currentend = m_currentstart+chmBuffer.length(); | 167 | m_currentend = m_currentstart+chmBuffer.length(); |
160 | } | 168 | } |
161 | } | 169 | } |
162 | 170 | ||
163 | bool CHM::FillBuffer() | 171 | bool CHM::FillBuffer() |
164 | { | 172 | { |
173 | unsuspend(); | ||
165 | bool bRetVal = false; | 174 | bool bRetVal = false; |
166 | char buffer[65536]; | 175 | char buffer[65536]; |
167 | int swath, offset; | 176 | int swath, offset; |
168 | chmBuffer = ""; | 177 | chmBuffer = ""; |
169 | swath = 65536; | 178 | swath = 65536; |
170 | offset = 0; | 179 | offset = 0; |
171 | fsize = m_ui.length; | 180 | fsize = m_ui.length; |
172 | while (offset < m_ui.length) | 181 | while (offset < m_ui.length) |
173 | { | 182 | { |
174 | if ((m_ui.length - offset) < 65536) | 183 | if ((m_ui.length - offset) < 65536) |
175 | swath = m_ui.length - offset; | 184 | swath = m_ui.length - offset; |
176 | else | 185 | else |
177 | swath = 65536; | 186 | swath = 65536; |
178 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); | 187 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); |
179 | chmBuffer += buffer; | 188 | chmBuffer += buffer; |
180 | offset += swath; | 189 | offset += swath; |
181 | } | 190 | } |
182 | //There seems to be a ton of gobbledygook at the end that is reminiscent of the hhc file - remove it | 191 | //There seems to be a ton of gobbledygook at the end that is reminiscent of the hhc file - remove it |
183 | QString temp = chmBuffer.lower(); | 192 | QString temp = chmBuffer.lower(); |
184 | int lpos = temp.find("</html"); | 193 | int lpos = temp.find("</html"); |
185 | if (lpos > -1) { | 194 | if (lpos > -1) { |
186 | chmBuffer.truncate(lpos); | 195 | chmBuffer.truncate(lpos); |
187 | chmBuffer = chmBuffer+"</HTML>"; | 196 | chmBuffer = chmBuffer+"</HTML>"; |
188 | } | 197 | } |
189 | fsize = chmBuffer.length(); | 198 | fsize = chmBuffer.length(); |
190 | 199 | ||
191 | bufpos = 0; | 200 | bufpos = 0; |
192 | bRetVal = true; | 201 | bRetVal = true; |
193 | m_currentstart = m_ui.start; | 202 | m_currentstart = m_ui.start; |
194 | m_currentend = m_currentstart+chmBuffer.length(); | 203 | m_currentend = m_currentstart+chmBuffer.length(); |
195 | return bRetVal; | 204 | return bRetVal; |
196 | } | 205 | } |
197 | 206 | ||
198 | bool CHM::FillContent() { | 207 | bool CHM::FillContent() { |
208 | unsuspend(); | ||
199 | bool bRetVal = false; | 209 | bool bRetVal = false; |
200 | if (chmPath != "") { | 210 | if (chmPath != "") { |
201 | /* try to find the file */ | 211 | /* try to find the file */ |
202 | const char *filename = (const char *)chmPath; | 212 | const char *filename = (const char *)chmPath; |
203 | if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) | 213 | if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) |
204 | { | 214 | { |
205 | fsize = chmBuffer.length(); | 215 | fsize = chmBuffer.length(); |
206 | return bRetVal; | 216 | return bRetVal; |
207 | } | 217 | } |
208 | 218 | ||
209 | char buffer[65536]; | 219 | char buffer[65536]; |
210 | int swath, offset; | 220 | int swath, offset; |
211 | chmBuffer = ""; | 221 | chmBuffer = ""; |
212 | swath = 65536; | 222 | swath = 65536; |
213 | offset = 0; | 223 | offset = 0; |
214 | fsize = m_ui.length; | 224 | fsize = m_ui.length; |
215 | while (offset < m_ui.length) | 225 | while (offset < m_ui.length) |
216 | { | 226 | { |
217 | if ((m_ui.length - offset) < 65536) | 227 | if ((m_ui.length - offset) < 65536) |
218 | swath = m_ui.length - offset; | 228 | swath = m_ui.length - offset; |
219 | else | 229 | else |
220 | swath = 65536; | 230 | swath = 65536; |
221 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); | 231 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); |
222 | chmBuffer += buffer; | 232 | chmBuffer += buffer; |
223 | offset += swath; | 233 | offset += swath; |
224 | } | 234 | } |
225 | //There seems to be a ton of gobbledygook at the end that is reminiscent of the hhc file - remove it | 235 | //There seems to be a ton of gobbledygook at the end that is reminiscent of the hhc file - remove it |
226 | QString temp = chmBuffer.lower(); | 236 | QString temp = chmBuffer.lower(); |
227 | int lpos = temp.find("</html"); | 237 | int lpos = temp.find("</html"); |
228 | if (lpos > -1) { | 238 | if (lpos > -1) { |
229 | chmBuffer.truncate(lpos); | 239 | chmBuffer.truncate(lpos); |
230 | chmBuffer = chmBuffer+"</HTML>"; | 240 | chmBuffer = chmBuffer+"</HTML>"; |
231 | } | 241 | } |
232 | fsize = chmBuffer.length(); | 242 | fsize = chmBuffer.length(); |
233 | 243 | ||
234 | bufpos = 0; | 244 | bufpos = 0; |
235 | m_currentstart = m_ui.start; | 245 | m_currentstart = m_ui.start; |
236 | m_currentend = m_currentstart+chmBuffer.length(); | 246 | m_currentend = m_currentstart+chmBuffer.length(); |
237 | bRetVal = true; | 247 | bRetVal = true; |
238 | } | 248 | } |
239 | return bRetVal; | 249 | return bRetVal; |
240 | } | 250 | } |
241 | 251 | ||
242 | bool CHM::getFile(const QString& href) { | 252 | bool CHM::getFile(const QString& _href, const QString& ) { |
253 | QString href = "/" + _href; | ||
243 | qDebug("Got:%s", (const char*)href); | 254 | qDebug("Got:%s", (const char*)href); |
244 | bool bRetVal = false; | 255 | bool bRetVal = false; |
245 | QString temp = chmPath; | 256 | QString temp = chmPath; |
246 | chmPath = href; | 257 | chmPath = href; |
247 | if (FillContent()) { | 258 | if (FillContent()) { |
248 | qDebug("Got it"); | 259 | qDebug("Got it"); |
249 | bRetVal = true; | 260 | bRetVal = true; |
250 | } else { | 261 | } else { |
251 | qDebug("Missed"); | 262 | qDebug("Missed"); |
252 | chmPath = temp; | 263 | chmPath = temp; |
253 | FillContent(); | 264 | FillContent(); |
254 | } | 265 | } |
255 | return bRetVal; | 266 | return bRetVal; |
256 | } | 267 | } |
257 | 268 | ||
258 | QImage *CHM::getPicture(const QString& href) { | 269 | QImage *CHM::getPicture(const QString& href) { |
259 | QImage *img = NULL; | 270 | QImage *img = NULL; |
260 | QString PicRef = "/"+href; | 271 | QString PicRef = "/"+href; |
261 | struct chmUnitInfo ui; | 272 | struct chmUnitInfo ui; |
262 | const char *ext; | 273 | const char *ext; |
263 | /* try to find the file */ | 274 | /* try to find the file */ |
264 | const char *filename = (const char *)PicRef; | 275 | const char *filename = (const char *)PicRef; |
265 | if (chm_resolve_object(chmFile, filename, &ui) != CHM_RESOLVE_SUCCESS) | 276 | if (chm_resolve_object(chmFile, filename, &ui) != CHM_RESOLVE_SUCCESS) |
266 | { | 277 | { |
267 | qDebug ("Could not resolve image"); | 278 | qDebug ("Could not resolve image"); |
268 | return img; | 279 | return img; |
269 | } | 280 | } |
270 | if (ui.length > 0) { | 281 | if (ui.length > 0) { |
271 | char *temp = new char[ui.length]; | 282 | char *temp = new char[ui.length]; |
272 | char buffer[65536]; | 283 | char buffer[65536]; |
273 | int swath, offset; | 284 | int swath, offset; |
274 | swath = 65536; | 285 | swath = 65536; |
275 | offset = 0; | 286 | offset = 0; |
276 | 287 | ||
277 | while (offset < ui.length) | 288 | while (offset < ui.length) |
278 | { | 289 | { |
279 | if ((ui.length - offset) < 65536) | 290 | if ((ui.length - offset) < 65536) |
280 | swath = ui.length - offset; | 291 | swath = ui.length - offset; |
281 | else | 292 | else |
282 | swath = 65536; | 293 | swath = 65536; |
283 | swath = (int)chm_retrieve_object(chmFile, &ui, (unsigned char *) buffer, offset, swath); | 294 | swath = (int)chm_retrieve_object(chmFile, &ui, (unsigned char *) buffer, offset, swath); |
284 | memcpy( (void *) (temp + offset), (void *)&buffer, swath ); | 295 | memcpy( (void *) (temp + offset), (void *)&buffer, swath ); |
285 | offset += swath; | 296 | offset += swath; |
286 | } | 297 | } |
287 | QByteArray qba; | 298 | QByteArray qba; |
288 | qba.setRawData( (const char *)temp, ui.length); | 299 | qba.setRawData( (const char *)temp, ui.length); |
289 | QPixmap qpm(qba); | 300 | QPixmap qpm(qba); |
290 | img = new QImage(qpm.convertToImage()); | 301 | img = new QImage(qpm.convertToImage()); |
291 | qba.resetRawData((const char *)temp, ui.length); | 302 | qba.resetRawData((const char *)temp, ui.length); |
292 | delete[] temp; | 303 | delete[] temp; |
293 | } | 304 | } |
294 | 305 | ||
295 | return img; | 306 | return img; |
296 | } | 307 | } |
297 | 308 | ||
298 | int CHM::OpenFile(const char *src) { | 309 | int CHM::OpenFile(const char *src) { |
299 | if (chmFile != NULL) chm_close(chmFile); | 310 | if (chmFile != NULL) chm_close(chmFile); |
300 | struct stat _stat; | 311 | struct stat _stat; |
301 | stat(src,&_stat); | 312 | stat(src,&_stat); |
302 | fsize = _stat.st_size; | 313 | fsize = _stat.st_size; |
303 | chmFile = chm_open(src); | 314 | chmFile = chm_open(src); |
304 | if (chmFile != NULL) { | 315 | if (chmFile != NULL) { |
305 | chm_enumerate(chmFile, | 316 | chm_enumerate(chmFile, |
306 | CHM_ENUMERATE_ALL, | 317 | CHM_ENUMERATE_ALL, |
307 | _get_hhc, | 318 | _get_hhc, |
308 | (void *)this); | 319 | (void *)this); |
309 | if ( chmPath != "") { | 320 | if ( chmPath != "") { |
310 | setHomePath(chmPath); | 321 | setHomePath(chmPath); |
311 | FillHomeContent(); | 322 | FillHomeContent(); |
312 | } | 323 | } |
313 | } | 324 | } |
314 | m_homepos = locate(); | 325 | m_homepos = locate(); |
315 | qDebug("Home:%u", m_homepos); | 326 | qDebug("Home:%u", m_homepos); |
316 | return (chmFile==NULL); | 327 | return (chmFile==NULL); |
317 | } | 328 | } |
318 | 329 | ||
319 | int CHM::getch() { | 330 | int CHM::getch() { |
320 | if ( (bufpos+1) >= chmBuffer.length() ) | 331 | if ( (bufpos+1) >= chmBuffer.length() ) |
321 | return EOF; | 332 | return EOF; |
322 | #ifdef _WINDOWS | 333 | #ifdef _WINDOWS |
323 | QChar letter = chmBuffer.at(bufpos++); | 334 | QChar letter = chmBuffer.at(bufpos++); |
324 | #else | 335 | #else |
325 | QChar letter = chmBuffer[bufpos++]; | 336 | QChar letter = chmBuffer[bufpos++]; |
326 | #endif | 337 | #endif |
327 | return (int)(char)letter; | 338 | return (int)(char)letter; |
328 | } | 339 | } |
329 | 340 | ||
330 | void CHM::getch(tchar& ch, CStyle& sty) | 341 | void CHM::getch(tchar& ch, CStyle& sty) |
331 | { | 342 | { |
332 | int ich = getch(); | 343 | int ich = getch(); |
333 | ch = (ich == EOF) ? UEOF : ich; | 344 | ch = (ich == EOF) ? UEOF : ich; |
334 | } | 345 | } |
335 | 346 | ||
336 | void CHM::start2endSection() | 347 | void CHM::start2endSection() |
337 | { | 348 | { |
338 | m_currentstart = m_ui.start; | 349 | m_currentstart = m_ui.start; |
339 | m_currentend = m_currentstart+chmBuffer.length(); | 350 | m_currentend = m_currentstart+chmBuffer.length(); |
340 | } | 351 | } |
341 | 352 | ||
342 | unsigned int CHM::locate() { | 353 | unsigned int CHM::locate() { |
343 | return m_currentstart+bufpos; | 354 | return m_currentstart+bufpos; |
344 | } | 355 | } |
345 | 356 | ||
346 | void CHM::locate(unsigned int n) { | 357 | void CHM::locate(unsigned int n) { |
347 | if (n == 0) n = m_homepos; | 358 | if (n == 0) n = m_homepos; |
348 | if (n >= m_homestart && n < m_homeend) | 359 | if (n >= m_homestart && n < m_homeend) |
349 | { | 360 | { |
350 | FillHomeContent(); | 361 | FillHomeContent(); |
351 | bufpos = n - m_homestart; | 362 | bufpos = n - m_homestart; |
352 | start2endSection(); | 363 | start2endSection(); |
353 | qDebug("Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); | 364 | qDebug("Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); |
354 | } | 365 | } |
355 | else if (n >= m_currentstart && n < m_currentend) | 366 | else if (n >= m_currentstart && n < m_currentend) |
356 | { | 367 | { |
357 | bufpos = n - m_currentstart; | 368 | bufpos = n - m_currentstart; |
358 | } | 369 | } |
359 | else if (CHM_RESOLVE_FAILURE == chm_resolve_location(chmFile, n/4, &m_ui)) | 370 | else if (CHM_RESOLVE_FAILURE == chm_resolve_location(chmFile, n/4, &m_ui)) |
360 | { | 371 | { |
361 | qDebug("Resolve failure"); | 372 | qDebug("Resolve failure"); |
362 | FillHomeContent(); | 373 | FillHomeContent(); |
363 | bufpos = 0; | 374 | bufpos = 0; |
364 | start2endSection(); | 375 | start2endSection(); |
365 | qDebug("Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); | 376 | qDebug("Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); |
366 | } | 377 | } |
367 | else | 378 | else |
368 | { | 379 | { |
369 | qDebug("Resolve success"); | 380 | qDebug("Resolve success"); |
370 | FillBuffer(); | 381 | FillBuffer(); |
371 | start2endSection(); | 382 | start2endSection(); |
372 | bufpos=n-m_currentstart; | 383 | bufpos=n-m_currentstart; |
373 | qDebug("Not Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); | 384 | qDebug("Not Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); |
374 | } | 385 | } |
375 | } | 386 | } |
376 | 387 | ||
377 | void CHM::sizes(unsigned long& _file, unsigned long& _text) { | 388 | void CHM::sizes(unsigned long& _file, unsigned long& _text) { |
378 | _text = _file = fsize; | 389 | _text = _file = fsize; |
379 | } | 390 | } |
diff --git a/noncore/apps/opie-reader/CHM.h b/noncore/apps/opie-reader/CHM.h index 001f7fc..291818d 100644 --- a/noncore/apps/opie-reader/CHM.h +++ b/noncore/apps/opie-reader/CHM.h | |||
@@ -1,67 +1,67 @@ | |||
1 | #ifndef __CHM_h | 1 | #ifndef __CHM_h |
2 | #define __CHM_h | 2 | #define __CHM_h |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <sys/stat.h> | 4 | #include <sys/stat.h> |
5 | #include "CExpander.h" | 5 | #include "CExpander.h" |
6 | #include "chm_lib.h" | 6 | #include "chm_lib.h" |
7 | #include "my_list.h" | 7 | #include "my_list.h" |
8 | #include "CExpander.h" | 8 | #include "CExpander.h" |
9 | 9 | ||
10 | struct Ref { | 10 | struct Ref { |
11 | QString RefName; | 11 | QString RefName; |
12 | QString RefLoc; | 12 | QString RefLoc; |
13 | int beginpos; | 13 | int beginpos; |
14 | int endpos; | 14 | int endpos; |
15 | }; | 15 | }; |
16 | 16 | ||
17 | struct Pic { | 17 | struct Pic { |
18 | QString RefName; | 18 | QString RefName; |
19 | QString RefLoc; | 19 | QString RefLoc; |
20 | int beginpos; | 20 | int beginpos; |
21 | int endpos; | 21 | int endpos; |
22 | }; | 22 | }; |
23 | 23 | ||
24 | class CHM : public CExpander | 24 | class CHM : public CExpander |
25 | { | 25 | { |
26 | void start2endSection(); | 26 | void start2endSection(); |
27 | struct chmUnitInfo m_ui; | 27 | struct chmUnitInfo m_ui; |
28 | struct chmFile *chmFile; | 28 | struct chmFile *chmFile; |
29 | chmUnitInfo chmui; | 29 | chmUnitInfo chmui; |
30 | //alloc a meg to buffer | 30 | //alloc a meg to buffer |
31 | QString chmHomeBuffer; | 31 | QString chmHomeBuffer; |
32 | QString chmBuffer; | 32 | QString chmBuffer; |
33 | QString chmPath; | 33 | QString chmPath; |
34 | QString chmHHCPath; | 34 | QString chmHHCPath; |
35 | unsigned int bufpos; | 35 | unsigned int bufpos; |
36 | unsigned long fsize; | 36 | unsigned long fsize; |
37 | unsigned long m_homestart, m_homeend; | 37 | unsigned long m_homestart, m_homeend; |
38 | public: | 38 | public: |
39 | void suspend(); | 39 | void suspend(); |
40 | void unsuspend(); | 40 | void unsuspend(); |
41 | bool hasnavigation() { return true; } | 41 | bool hasnavigation() { return true; } |
42 | 42 | ||
43 | CHM(); | 43 | CHM(); |
44 | virtual ~CHM(); | 44 | virtual ~CHM(); |
45 | int OpenFile(const char *src); | 45 | int OpenFile(const char *src); |
46 | int getch(); | 46 | int getch(); |
47 | unsigned int locate(); | 47 | unsigned int locate(); |
48 | void locate(unsigned int n); | 48 | void locate(unsigned int n); |
49 | bool hasrandomaccess() { return true; } | 49 | bool hasrandomaccess() { return true; } |
50 | void sizes(unsigned long& _file, unsigned long& _text); | 50 | void sizes(unsigned long& _file, unsigned long& _text); |
51 | void addContent(QString content); | 51 | void addContent(QString content); |
52 | void getch(tchar& ch, CStyle& sty); | 52 | void getch(tchar& ch, CStyle& sty); |
53 | void setPath(QString PathName) {chmPath = PathName;}; | 53 | void setPath(QString PathName) {chmPath = PathName;}; |
54 | void setHomePath(QString PathName) {chmHHCPath = PathName;}; | 54 | void setHomePath(QString PathName) {chmHHCPath = PathName;}; |
55 | 55 | ||
56 | MarkupType PreferredMarkup() { | 56 | MarkupType PreferredMarkup() { |
57 | return cCHM; | 57 | return cCHM; |
58 | } | 58 | } |
59 | bool getFile(const QString& href); | 59 | bool getFile(const QString& href, const QString& nm); |
60 | QImage *getPicture(const QString& href); | 60 | QImage *getPicture(const QString& href); |
61 | QString about() { return QString("CHM codec (c) Bob Griffin\nchm_lib (c) Jed Wing\nLZX code (c) Stuart Cale"); } | 61 | QString about() { return QString("CHM codec (c) Bob Griffin\nchm_lib (c) Jed Wing\nLZX code (c) Stuart Cale"); } |
62 | private : | 62 | private : |
63 | bool FillBuffer(); | 63 | bool FillBuffer(); |
64 | bool FillContent(); | 64 | bool FillContent(); |
65 | void FillHomeContent(); | 65 | void FillHomeContent(); |
66 | }; | 66 | }; |
67 | #endif | 67 | #endif |
diff --git a/noncore/apps/opie-reader/CRegExp.cpp b/noncore/apps/opie-reader/CRegExp.cpp index 77dc2dc..6318d28 100644 --- a/noncore/apps/opie-reader/CRegExp.cpp +++ b/noncore/apps/opie-reader/CRegExp.cpp | |||
@@ -1,599 +1,599 @@ | |||
1 | #include "CRegExp.h" | 1 | #include "CRegExp.h" |
2 | 2 | ||
3 | //#include <stdio.h> | 3 | //#include <stdio.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | //#include <string.h> | 5 | //#include <string.h> |
6 | 6 | ||
7 | 7 | ||
8 | tchar CRegExpFilt::escapedchar(tchar c) | 8 | tchar CRegExpFilt::escapedchar(tchar c) |
9 | { | 9 | { |
10 | switch (c) | 10 | switch (c) |
11 | { | 11 | { |
12 | case '\\': | 12 | case '\\': |
13 | return '\\'; | 13 | return '\\'; |
14 | break; | 14 | break; |
15 | case '"': | 15 | case '"': |
16 | return '\"'; | 16 | return '\"'; |
17 | break; | 17 | break; |
18 | case 'a': | 18 | case 'a': |
19 | return '\a'; | 19 | return '\a'; |
20 | break; | 20 | break; |
21 | case 'b': | 21 | case 'b': |
22 | return '\b'; | 22 | return '\b'; |
23 | break; | 23 | break; |
24 | case 'f': | 24 | case 'f': |
25 | return '\f'; | 25 | return '\f'; |
26 | break; | 26 | break; |
27 | case 'n': | 27 | case 'n': |
28 | return '\n'; | 28 | return '\n'; |
29 | break; | 29 | break; |
30 | case 'r': | 30 | case 'r': |
31 | return '\r'; | 31 | return '\r'; |
32 | break; | 32 | break; |
33 | case 't': | 33 | case 't': |
34 | return '\t'; | 34 | return '\t'; |
35 | break; | 35 | break; |
36 | case 'v': | 36 | case 'v': |
37 | return '\v'; | 37 | return '\v'; |
38 | break; | 38 | break; |
39 | default: | 39 | default: |
40 | return c; | 40 | return c; |
41 | break; | 41 | break; |
42 | } | 42 | } |
43 | } | 43 | } |
44 | 44 | ||
45 | void CRegExpFilt::regchar(tchar c, bool insens) | 45 | void CRegExpFilt::regchar(tchar c, bool insens) |
46 | { | 46 | { |
47 | if (insens) | 47 | if (insens) |
48 | { | 48 | { |
49 | tchar t = upper(c); | 49 | tchar t = upper(c); |
50 | CV[t] = 0; | 50 | CV[t] = 0; |
51 | t = lower(c); | 51 | t = lower(c); |
52 | CV[t] = 0; | 52 | CV[t] = 0; |
53 | } | 53 | } |
54 | else | 54 | else |
55 | { | 55 | { |
56 | CV[c] = 0; | 56 | CV[c] = 0; |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | void CRegExpFilt::prepreprocessing(const QString& pat, bool insens) | 60 | void CRegExpFilt::prepreprocessing(const QString& pat, bool insens) |
61 | { | 61 | { |
62 | for (unsigned int p = 0; p < pat.length(); p++) | 62 | for (unsigned int p = 0; p < pat.length(); p++) |
63 | { | 63 | { |
64 | #ifdef _WINDOWS | 64 | #ifdef _WINDOWS |
65 | switch (pat.at(p).unicode()) | 65 | switch (pat.at(p).unicode()) |
66 | #else | 66 | #else |
67 | switch (pat[p].unicode()) | 67 | switch (pat[p].unicode()) |
68 | #endif | 68 | #endif |
69 | { | 69 | { |
70 | case '{': | 70 | case '{': |
71 | { | 71 | { |
72 | break; | 72 | break; |
73 | } | 73 | } |
74 | case '}': | 74 | case '}': |
75 | { | 75 | { |
76 | break; | 76 | break; |
77 | } | 77 | } |
78 | case '^': | 78 | case '^': |
79 | { | 79 | { |
80 | break; | 80 | break; |
81 | } | 81 | } |
82 | case '.' : | 82 | case '.' : |
83 | { | 83 | { |
84 | break; | 84 | break; |
85 | } | 85 | } |
86 | case '#': | 86 | case '#': |
87 | { | 87 | { |
88 | p++; | 88 | p++; |
89 | #ifdef _WINDOWS | 89 | #ifdef _WINDOWS |
90 | while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9') | 90 | while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9') |
91 | #else | 91 | #else |
92 | while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9') | 92 | while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9') |
93 | #endif | 93 | #endif |
94 | { | 94 | { |
95 | } | 95 | } |
96 | p--; | 96 | p--; |
97 | break; | 97 | break; |
98 | } | 98 | } |
99 | case '\\' : | 99 | case '\\' : |
100 | { | 100 | { |
101 | #ifdef _WINDOWS | 101 | #ifdef _WINDOWS |
102 | tchar c = escapedchar(pat.at(++p).unicode()); | 102 | tchar c = escapedchar(pat.at(++p).unicode()); |
103 | #else | 103 | #else |
104 | tchar c = escapedchar(pat[++p].unicode()); | 104 | tchar c = escapedchar(pat[++p].unicode()); |
105 | #endif | 105 | #endif |
106 | regchar(c, insens); | 106 | regchar(c, insens); |
107 | break; | 107 | break; |
108 | } | 108 | } |
109 | 109 | ||
110 | case '[' : | 110 | case '[' : |
111 | { | 111 | { |
112 | tchar clast; | 112 | tchar clast; |
113 | bool invert = false; | 113 | bool invert = false; |
114 | tchar c; | 114 | tchar c; |
115 | #ifdef _WINDOWS | 115 | #ifdef _WINDOWS |
116 | if (pat.at(p+1).unicode() == '^') | 116 | if (pat.at(p+1).unicode() == '^') |
117 | #else | 117 | #else |
118 | if (pat[p+1].unicode() == '^') | 118 | if (pat[p+1].unicode() == '^') |
119 | #endif | 119 | #endif |
120 | { | 120 | { |
121 | p++; | 121 | p++; |
122 | invert = true; | 122 | invert = true; |
123 | } | 123 | } |
124 | #ifdef _WINDOWS | 124 | #ifdef _WINDOWS |
125 | while ((c = pat.at(++p).unicode()) != ']') | 125 | while ((c = pat.at(++p).unicode()) != ']') |
126 | #else | 126 | #else |
127 | while ((c = pat[++p].unicode()) != ']') | 127 | while ((c = pat[++p].unicode()) != ']') |
128 | #endif | 128 | #endif |
129 | { | 129 | { |
130 | if (c == '\\') | 130 | if (c == '\\') |
131 | { | 131 | { |
132 | #ifdef _WINDOWS | 132 | #ifdef _WINDOWS |
133 | c = escapedchar(pat.at(++p).unicode()); | 133 | c = escapedchar(pat.at(++p).unicode()); |
134 | #else | 134 | #else |
135 | c = escapedchar(pat[++p].unicode()); | 135 | c = escapedchar(pat[++p].unicode()); |
136 | #endif | 136 | #endif |
137 | if (c == ']') break; | 137 | if (c == ']') break; |
138 | } | 138 | } |
139 | if (c == '-') | 139 | if (c == '-') |
140 | { | 140 | { |
141 | #ifdef _WINDOWS | 141 | #ifdef _WINDOWS |
142 | c = pat.at(++p).unicode(); | 142 | c = pat.at(++p).unicode(); |
143 | #else | 143 | #else |
144 | c = pat[++p].unicode(); | 144 | c = pat[++p].unicode(); |
145 | #endif | 145 | #endif |
146 | for (tchar j = clast; j <= c; j++) | 146 | for (tchar j = clast; j <= c; j++) |
147 | { | 147 | { |
148 | regchar(j, insens); | 148 | regchar(j, insens); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | else | 151 | else |
152 | { | 152 | { |
153 | regchar(c, insens); | 153 | regchar(c, insens); |
154 | } | 154 | } |
155 | clast = c; | 155 | clast = c; |
156 | } | 156 | } |
157 | break; | 157 | break; |
158 | } | 158 | } |
159 | default : | 159 | default : |
160 | { | 160 | { |
161 | #ifdef _WINDOWS | 161 | #ifdef _WINDOWS |
162 | regchar(pat.at(p).unicode(), insens); | 162 | regchar(pat.at(p).unicode(), insens); |
163 | #else | 163 | #else |
164 | regchar(pat[p].unicode(), insens); | 164 | regchar(pat[p].unicode(), insens); |
165 | #endif | 165 | #endif |
166 | break; | 166 | break; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | } | 169 | } |
170 | /* | 170 | /* |
171 | for (iter i = CV.begin(); i != CV.end(); ++i) | 171 | for (iter i = CV.begin(); i != CV.end(); ++i) |
172 | { | 172 | { |
173 | printf("Pre: [%u]\n", i.first()); | 173 | printf("Pre: [%u]\n", i.first()); |
174 | } | 174 | } |
175 | */ | 175 | */ |
176 | CV[0] = 0; | 176 | CV[0] = 0; |
177 | } | 177 | } |
178 | 178 | ||
179 | unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens) | 179 | unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens) |
180 | { | 180 | { |
181 | prepreprocessing(pat, insens); | 181 | prepreprocessing(pat, insens); |
182 | qDebug("PrePreProcessing done"); | 182 | qDebug("PrePreProcessing done"); |
183 | unsigned int p, m; | 183 | unsigned int p, m; |
184 | bool inkeep = false; | 184 | bool inkeep = false; |
185 | keep = 0; | 185 | keep = 0; |
186 | replace = 0; | 186 | replace = 0; |
187 | for (unsigned int j = 0; j < WORD_SIZE; j++) | 187 | for (unsigned int j = 0; j < WORD_SIZE; j++) |
188 | { | 188 | { |
189 | bit[j] = (1 << (WORD_SIZE -j -1)); | 189 | bit[j] = (1 << (WORD_SIZE -j -1)); |
190 | lfcnt[j] = 0; | 190 | lfcnt[j] = 0; |
191 | } | 191 | } |
192 | 192 | ||
193 | for (p = 0, m = 0; p < pat.length(); p++) | 193 | for (p = 0, m = 0; p < pat.length(); p++) |
194 | { | 194 | { |
195 | qDebug("m is %u", m); | 195 | qDebug("m is %u", m); |
196 | if (inkeep) keep |= bit[m]; | 196 | if (inkeep) keep |= bit[m]; |
197 | #ifdef _WINDOWS | 197 | #ifdef _WINDOWS |
198 | switch (pat.at(p).unicode()) | 198 | switch (pat.at(p).unicode()) |
199 | #else | 199 | #else |
200 | switch (pat[p].unicode()) | 200 | switch (pat[p].unicode()) |
201 | #endif | 201 | #endif |
202 | { | 202 | { |
203 | case '{': | 203 | case '{': |
204 | { | 204 | { |
205 | inkeep = true; | 205 | inkeep = true; |
206 | break; | 206 | break; |
207 | } | 207 | } |
208 | case '}': | 208 | case '}': |
209 | { | 209 | { |
210 | keep ^= bit[m]; | 210 | keep ^= bit[m]; |
211 | inkeep = false; | 211 | inkeep = false; |
212 | break; | 212 | break; |
213 | } | 213 | } |
214 | case '^': | 214 | case '^': |
215 | { | 215 | { |
216 | replace |= bit[m]; | 216 | replace |= bit[m]; |
217 | lfcnt[m]++; | 217 | lfcnt[m]++; |
218 | break; | 218 | break; |
219 | } | 219 | } |
220 | case '.' : | 220 | case '.' : |
221 | { | 221 | { |
222 | for (iter j = CV.begin(); j != CV.end(); ++j) CV[j.first()] |= bit[m]; | 222 | for (iter j = CV.begin(); j != CV.end(); ++j) CV[j.first()] |= bit[m]; |
223 | m++; | 223 | m++; |
224 | break; | 224 | break; |
225 | } | 225 | } |
226 | case '#': | 226 | case '#': |
227 | { | 227 | { |
228 | if (m > 0) | 228 | if (m > 0) |
229 | { | 229 | { |
230 | p++; | 230 | p++; |
231 | int count = 0; | 231 | int count = 0; |
232 | #ifdef _WINDOWS | 232 | #ifdef _WINDOWS |
233 | while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9') | 233 | while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9') |
234 | #else | 234 | #else |
235 | while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9') | 235 | while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9') |
236 | #endif | 236 | #endif |
237 | { | 237 | { |
238 | #ifdef _WINDOWS | 238 | #ifdef _WINDOWS |
239 | count = 10*count + pat.at(p++).unicode() - '0'; | 239 | count = 10*count + pat.at(p++).unicode() - '0'; |
240 | #else | 240 | #else |
241 | count = 10*count + pat[p++].unicode() - '0'; | 241 | count = 10*count + pat[p++].unicode() - '0'; |
242 | #endif | 242 | #endif |
243 | } | 243 | } |
244 | p--; | 244 | p--; |
245 | count = count-1; | 245 | count = count-1; |
246 | unsigned int mask = 0; | 246 | unsigned int mask = 0; |
247 | for (unsigned int i = m; i < m+count; i++) | 247 | for (unsigned int i = m; i < m+count; i++) |
248 | { | 248 | { |
249 | mask |= bit[i]; | 249 | mask |= bit[i]; |
250 | } | 250 | } |
251 | 251 | ||
252 | for (iter it = CV.begin(); it != CV.end(); ++it) | 252 | for (iter it = CV.begin(); it != CV.end(); ++it) |
253 | { | 253 | { |
254 | if (CV[it.first()] & bit[m-1]) | 254 | if (CV[it.first()] & bit[m-1]) |
255 | { | 255 | { |
256 | CV[it.first()] |= mask; | 256 | CV[it.first()] |= mask; |
257 | } | 257 | } |
258 | } | 258 | } |
259 | if (keep & bit[m-1]) keep |= mask; | 259 | if (keep & bit[m-1]) keep |= mask; |
260 | m += count; | 260 | m += count; |
261 | } | 261 | } |
262 | else | 262 | else |
263 | { | 263 | { |
264 | p++; | 264 | p++; |
265 | } | 265 | } |
266 | break; | 266 | break; |
267 | } | 267 | } |
268 | case '\\' : | 268 | case '\\' : |
269 | { | 269 | { |
270 | #ifdef _WINDOWS | 270 | #ifdef _WINDOWS |
271 | tchar c = escapedchar(pat.at(++p).unicode()); | 271 | tchar c = escapedchar(pat.at(++p).unicode()); |
272 | #else | 272 | #else |
273 | tchar c = escapedchar(pat[++p].unicode()); | 273 | tchar c = escapedchar(pat[++p].unicode()); |
274 | #endif | 274 | #endif |
275 | if (insens) | 275 | if (insens) |
276 | { | 276 | { |
277 | CV[upper(c)] |= bit[m]; | 277 | CV[upper(c)] |= bit[m]; |
278 | CV[lower(c)] |= bit[m]; | 278 | CV[lower(c)] |= bit[m]; |
279 | } | 279 | } |
280 | else | 280 | else |
281 | { | 281 | { |
282 | CV[c] |= bit[m]; | 282 | CV[c] |= bit[m]; |
283 | } | 283 | } |
284 | m++; | 284 | m++; |
285 | break; | 285 | break; |
286 | } | 286 | } |
287 | 287 | ||
288 | case '[' : | 288 | case '[' : |
289 | { | 289 | { |
290 | tchar c, clast; | 290 | tchar c, clast; |
291 | bool invert = false; | 291 | bool invert = false; |
292 | #ifdef _WINDOWS | 292 | #ifdef _WINDOWS |
293 | if (pat.at(p+1).unicode() == '^') | 293 | if (pat.at(p+1).unicode() == '^') |
294 | #else | 294 | #else |
295 | if (pat[p+1].unicode() == '^') | 295 | if (pat[p+1].unicode() == '^') |
296 | #endif | 296 | #endif |
297 | { | 297 | { |
298 | p++; | 298 | p++; |
299 | invert = true; | 299 | invert = true; |
300 | } | 300 | } |
301 | #ifdef _WINDOWS | 301 | #ifdef _WINDOWS |
302 | while ((c = pat.at(++p).unicode()) != ']') | 302 | while ((c = pat.at(++p).unicode()) != ']') |
303 | #else | 303 | #else |
304 | while ((c = pat[++p].unicode()) != ']') | 304 | while ((c = pat[++p].unicode()) != ']') |
305 | #endif | 305 | #endif |
306 | { | 306 | { |
307 | if (c == '\\') | 307 | if (c == '\\') |
308 | { | 308 | { |
309 | #ifdef _WINDOWS | 309 | #ifdef _WINDOWS |
310 | c = escapedchar(pat.at(++p).unicode()); | 310 | c = escapedchar(pat.at(++p).unicode()); |
311 | #else | 311 | #else |
312 | c = escapedchar(pat[++p].unicode()); | 312 | c = escapedchar(pat[++p].unicode()); |
313 | #endif | 313 | #endif |
314 | if (c == ']') break; | 314 | if (c == ']') break; |
315 | } | 315 | } |
316 | if (c == '-') | 316 | if (c == '-') |
317 | { | 317 | { |
318 | #ifdef _WINDOWS | 318 | #ifdef _WINDOWS |
319 | c = pat.at(++p).unicode(); | 319 | c = pat.at(++p).unicode(); |
320 | #else | 320 | #else |
321 | c = pat[++p].unicode(); | 321 | c = pat[++p].unicode(); |
322 | #endif | 322 | #endif |
323 | for (tchar j = clast; j <= c; j++) | 323 | for (tchar j = clast; j <= c; j++) |
324 | { | 324 | { |
325 | if (insens) | 325 | if (insens) |
326 | { | 326 | { |
327 | iter it; | 327 | iter it; |
328 | if ((it = CV.find(upper(j))) != CV.end()) | 328 | if ((it = CV.find(upper(j))) != CV.end()) |
329 | CV[it] |= bit[m]; | 329 | CV[it] |= bit[m]; |
330 | else | 330 | else |
331 | CV[0] |= bit[m]; | 331 | CV[0] |= bit[m]; |
332 | if ((it = CV.find(lower(j))) != CV.end()) | 332 | if ((it = CV.find(lower(j))) != CV.end()) |
333 | CV[it] |= bit[m]; | 333 | CV[it] |= bit[m]; |
334 | else | 334 | else |
335 | CV[0] |= bit[m]; | 335 | CV[0] |= bit[m]; |
336 | } | 336 | } |
337 | else | 337 | else |
338 | { | 338 | { |
339 | iter it; | 339 | iter it; |
340 | if ((it = CV.find(j)) != CV.end()) | 340 | if ((it = CV.find(j)) != CV.end()) |
341 | CV[it] |= bit[m]; | 341 | CV[it] |= bit[m]; |
342 | else | 342 | else |
343 | { | 343 | { |
344 | CV[0] |= bit[m]; | 344 | CV[0] |= bit[m]; |
345 | } | 345 | } |
346 | } | 346 | } |
347 | } | 347 | } |
348 | } | 348 | } |
349 | else | 349 | else |
350 | { | 350 | { |
351 | if (insens) | 351 | if (insens) |
352 | { | 352 | { |
353 | iter it; | 353 | iter it; |
354 | if ((it = CV.find(upper(c))) != CV.end()) | 354 | if ((it = CV.find(upper(c))) != CV.end()) |
355 | CV[it] |= bit[m]; | 355 | CV[it] |= bit[m]; |
356 | else | 356 | else |
357 | CV[0] |= bit[m]; | 357 | CV[0] |= bit[m]; |
358 | if ((it = CV.find(lower(c))) != CV.end()) | 358 | if ((it = CV.find(lower(c))) != CV.end()) |
359 | CV[it] |= bit[m]; | 359 | CV[it] |= bit[m]; |
360 | else | 360 | else |
361 | CV[0] |= bit[m]; | 361 | CV[0] |= bit[m]; |
362 | } | 362 | } |
363 | else | 363 | else |
364 | { | 364 | { |
365 | iter it; | 365 | iter it; |
366 | if ((it = CV.find(c)) != CV.end()) | 366 | if ((it = CV.find(c)) != CV.end()) |
367 | CV[it] |= bit[m]; | 367 | CV[it] |= bit[m]; |
368 | else | 368 | else |
369 | CV[0] |= bit[m]; | 369 | CV[0] |= bit[m]; |
370 | } | 370 | } |
371 | } | 371 | } |
372 | clast = c; | 372 | clast = c; |
373 | } | 373 | } |
374 | if (invert) | 374 | if (invert) |
375 | { | 375 | { |
376 | for (iter i = CV.begin(); i != CV.end(); ++i) | 376 | for (iter i = CV.begin(); i != CV.end(); ++i) |
377 | { | 377 | { |
378 | CV[i.first()] ^= bit[m]; | 378 | CV[i.first()] ^= bit[m]; |
379 | } | 379 | } |
380 | } | 380 | } |
381 | m++; | 381 | m++; |
382 | break; | 382 | break; |
383 | } | 383 | } |
384 | default : | 384 | default : |
385 | { | 385 | { |
386 | #ifdef _WINDOWS | 386 | #ifdef _WINDOWS |
387 | tchar c = pat.at(p).unicode(); | 387 | tchar c = pat.at(p).unicode(); |
388 | #else | 388 | #else |
389 | tchar c = pat[p].unicode(); | 389 | tchar c = pat[p].unicode(); |
390 | #endif | 390 | #endif |
391 | if (insens) | 391 | if (insens) |
392 | { | 392 | { |
393 | CV[upper(c)] |= bit[m]; | 393 | CV[upper(c)] |= bit[m]; |
394 | CV[lower(c)] |= bit[m]; | 394 | CV[lower(c)] |= bit[m]; |
395 | } | 395 | } |
396 | else CV[c] |= bit[m]; | 396 | else CV[c] |= bit[m]; |
397 | m++; | 397 | m++; |
398 | break; | 398 | break; |
399 | } | 399 | } |
400 | } | 400 | } |
401 | } | 401 | } |
402 | qDebug("Returning:%u",m); | 402 | qDebug("Returning:%u",m); |
403 | return m; | 403 | return m; |
404 | } | 404 | } |
405 | 405 | ||
406 | bool CRegExpFilt::empty() | 406 | bool CRegExpFilt::empty() |
407 | { | 407 | { |
408 | return m_outQueue.empty(); | 408 | return m_outQueue.empty(); |
409 | } | 409 | } |
410 | 410 | ||
411 | tchar CRegExpFilt::pop() | 411 | tchar CRegExpFilt::pop() |
412 | { | 412 | { |
413 | return m_outQueue.pop(); | 413 | return m_outQueue.pop(); |
414 | } | 414 | } |
415 | 415 | ||
416 | bool CRegExpFilt::addch(tchar ch) | 416 | bool CRegExpFilt::addch(tchar ch) |
417 | { | 417 | { |
418 | word[cur] = ch; | 418 | word[cur] = ch; |
419 | cur = (cur+1)%patlength; | 419 | cur = (cur+1)%patlength; |
420 | if (len < patlength) len++; | 420 | if (len < patlength) len++; |
421 | 421 | ||
422 | unsigned int cv = 0; | 422 | unsigned int cv = 0; |
423 | iter it; | 423 | iter it; |
424 | if ((it = CV.find(ch)) == CV.end()) | 424 | if ((it = CV.find(ch)) == CV.end()) |
425 | { | 425 | { |
426 | cv = CV[0]; | 426 | cv = CV[0]; |
427 | } | 427 | } |
428 | else | 428 | else |
429 | { | 429 | { |
430 | cv = CV[it]; | 430 | cv = CV[it]; |
431 | } | 431 | } |
432 | 432 | ||
433 | R = ((R >> 1) | bit_0) & cv; /* Exact matches */ | 433 | R = ((R >> 1) | bit_0) & cv; /* Exact matches */ |
434 | if (R & endpos) | 434 | if (R & endpos) |
435 | { | 435 | { |
436 | for (unsigned int i = 0; i < patlength; i++) | 436 | for (unsigned int i = 0; i < patlength; i++) |
437 | { | 437 | { |
438 | if (replace & bit[i]) | 438 | if (replace & bit[i]) |
439 | { | 439 | { |
440 | for (unsigned int j = 0; j < lfcnt[i]; j++) | 440 | for (unsigned int j = 0; j < lfcnt[i]; j++) |
441 | { | 441 | { |
442 | m_outQueue.push(10); | 442 | m_outQueue.push(10); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | if (keep & bit[i]) | 445 | if (keep & bit[i]) |
446 | { | 446 | { |
447 | m_outQueue.push(word[(cur+i)%patlength]); | 447 | m_outQueue.push(word[(cur+i)%patlength]); |
448 | // putchar('*'); | 448 | // putchar('*'); |
449 | // putchar(i + '0'); | 449 | // putchar(i + '0'); |
450 | } | 450 | } |
451 | len = 0; | 451 | len = 0; |
452 | } | 452 | } |
453 | return true; | 453 | return true; |
454 | } | 454 | } |
455 | else | 455 | else |
456 | { | 456 | { |
457 | if (len == patlength) | 457 | if (len == patlength) |
458 | { | 458 | { |
459 | tchar ch = word[cur]; | 459 | tchar ch = word[cur]; |
460 | if (ch == 10) ch = ' '; | 460 | if (ch == 10) ch = ' '; |
461 | m_outQueue.push(ch); | 461 | m_outQueue.push(ch); |
462 | } | 462 | } |
463 | return false; | 463 | return false; |
464 | } | 464 | } |
465 | } | 465 | } |
466 | 466 | ||
467 | void CRegExpFilt::restart() | 467 | void CRegExpFilt::restart() |
468 | { | 468 | { |
469 | R = 0; | 469 | R = 0; |
470 | len = 0; | 470 | len = 0; |
471 | } | 471 | } |
472 | 472 | ||
473 | CRegExpFilt::CRegExpFilt(const QString& pat, bool insensflag) : CV(300) | 473 | CRegExpFilt::CRegExpFilt(const QString& pat, bool insensflag) : CV(300) |
474 | { | 474 | { |
475 | cur = 0; | 475 | cur = 0; |
476 | patlength = preprocessing(pat, insensflag); | 476 | patlength = preprocessing(pat, insensflag); |
477 | qDebug("Preprocesing done:%u", patlength); | 477 | qDebug("Preprocesing done:%u", patlength); |
478 | endpos = bit[patlength-1]; | 478 | endpos = bit[patlength-1]; |
479 | bit_0 = bit[0]; | 479 | bit_0 = bit[0]; |
480 | 480 | ||
481 | restart(); | 481 | restart(); |
482 | 482 | ||
483 | qDebug("Pattern: %s:%u", (const char*)pat, patlength); | 483 | qDebug("Pattern: %s:%u", (const char*)pat, patlength); |
484 | 484 | ||
485 | } | 485 | } |
486 | 486 | ||
487 | 487 | ||
488 | CRegExpFilt::~CRegExpFilt() | 488 | CRegExpFilt::~CRegExpFilt() |
489 | { | 489 | { |
490 | } | 490 | } |
491 | 491 | ||
492 | #ifdef NOWAYISTHISDEFINED | 492 | #ifdef NOWAYISTHISDEFINED |
493 | void reportmatch(tchar *line, /*tchar *text,*/ unsigned int mtype, unsigned int lino) | 493 | void reportmatch(tchar *line, /*tchar *text,*/ unsigned int mtype, unsigned int lino) |
494 | { | 494 | { |
495 | /* | 495 | /* |
496 | tchar *text = line + strlen(line); | 496 | tchar *text = line + strlen(line); |
497 | 497 | ||
498 | tchar *ptr = line; | 498 | tchar *ptr = line; |
499 | if (mtype == 0) | 499 | if (mtype == 0) |
500 | printf("Exact match at line number %u.\n", lino); | 500 | printf("Exact match at line number %u.\n", lino); |
501 | else | 501 | else |
502 | printf("%u error match at line number %u.\n", mtype, lino); | 502 | printf("%u error match at line number %u.\n", mtype, lino); |
503 | while (ptr < text) putchar(*ptr++); | 503 | while (ptr < text) putchar(*ptr++); |
504 | printf("%c[4m^%c[24m%s\n", 27, 27, ptr); | 504 | printf("%c[4m^%c[24m%s\n", 27, 27, ptr); |
505 | */ | 505 | */ |
506 | } | 506 | } |
507 | 507 | ||
508 | 508 | ||
509 | void usage(void) | 509 | void usage(void) |
510 | { | 510 | { |
511 | printf("Usage: CRegExpFilt [-i] pattern/a file\n"); | 511 | printf("Usage: CRegExpFilt [-i] pattern/a file\n"); |
512 | } | 512 | } |
513 | 513 | ||
514 | int getline(tchar *s,int lim,FILE *f) | 514 | int getline(tchar *s,int lim,FILE *f) |
515 | { | 515 | { |
516 | int c, i; | 516 | int c, i; |
517 | 517 | ||
518 | for (i = 0; i < lim-1 && (c = getc(f)) != EOF && c != '\n'; ) | 518 | for (i = 0; i < lim-1 && (c = getc(f)) != EOF && c != '\n'; ) |
519 | { | 519 | { |
520 | s[i++] = (tchar)c; | 520 | s[i++] = (tchar)c; |
521 | } | 521 | } |
522 | s[i] = '\0'; | 522 | s[i] = '\0'; |
523 | return ((c == EOF && i == 0) ? -1 : i); | 523 | return ((c == EOF && i == 0) ? -1 : i); |
524 | } | 524 | } |
525 | 525 | ||
526 | #define BUF_SIZE256 | 526 | #define BUF_SIZE256 |
527 | 527 | ||
528 | int main(int argc, char **argv) | 528 | int main(int argc, char **argv) |
529 | { | 529 | { |
530 | unsigned int lino = 0; | 530 | unsigned int lino = 0; |
531 | unsigned int blino = 0; | 531 | unsigned int blino = 0; |
532 | bool insens = false; | 532 | bool insens = false; |
533 | int len; | 533 | int len; |
534 | tchar line[BUF_SIZE]; | 534 | tchar line[BUF_SIZE]; |
535 | FILE *inf; | 535 | FILE *inf; |
536 | 536 | ||
537 | /* Error checking of cmd ln args! */ | 537 | /* Error checking of cmd ln args! */ |
538 | if (argc < 3) | 538 | if (argc < 3) |
539 | {usage(); return 10; } | 539 | {usage(); return 10; } |
540 | /* Corresponds to requiring a minimum of 3 matches */ | 540 | /* Corresponds to requiring a minimum of 3 matches */ |
541 | for (len = 1; len < argc-2; len++) | 541 | for (len = 1; len < argc-2; len++) |
542 | { | 542 | { |
543 | if (argv[len][0] != '-') | 543 | if (argv[len][0] != '-') |
544 | {usage(); return 10; } | 544 | {usage(); return 10; } |
545 | else switch (argv[len][1]) | 545 | else switch (argv[len][1]) |
546 | { | 546 | { |
547 | case 'i' : | 547 | case 'i' : |
548 | { | 548 | { |
549 | insens = true; | 549 | insens = true; |
550 | break; | 550 | break; |
551 | } | 551 | } |
552 | default : | 552 | default : |
553 | {usage(); return 10;} | 553 | {usage(); return 10;} |
554 | } | 554 | } |
555 | } | 555 | } |
556 | 556 | ||
557 | tchar* pattern = new tchar[strlen(argv[argc-2])+1]; | 557 | tchar* pattern = new tchar[strlen(argv[argc-2])+1]; |
558 | 558 | ||
559 | for (int i = 0; (pattern[i] = argv[argc-2][i]) != 0; i++); | 559 | for (int i = 0; (pattern[i] = argv[argc-2][i]) != 0; i++); |
560 | 560 | ||
561 | 561 | ||
562 | 562 | ||
563 | CRegExpFilt test(pattern, insens); | 563 | CRegExpFilt test(pattern, insens); |
564 | 564 | ||
565 | delete [] pattern; | 565 | delete [] pattern; |
566 | 566 | ||
567 | inf = fopen(argv[argc-1], "r"); | 567 | inf = fopen(argv[argc-1], "r"); |
568 | if (!inf) | 568 | if (!inf) |
569 | { | 569 | { |
570 | printf("file not found\n"); | 570 | printf("file not found\n"); |
571 | return 10; | 571 | return 10; |
572 | } | 572 | } |
573 | 573 | ||
574 | while ((len = getline(line, BUF_SIZE, inf)) >= 0) | 574 | while ((len = getline(line, BUF_SIZE, inf)) >= 0) |
575 | { | 575 | { |
576 | lino++; | 576 | lino++; |
577 | bool ret = false; | 577 | bool ret = false; |
578 | 578 | ||
579 | { | 579 | { |
580 | tchar *textend = line+len; | 580 | tchar *textend = line+len; |
581 | tchar *text = line; | 581 | tchar *text = line; |
582 | while (text < textend) | 582 | while (text < textend) |
583 | { | 583 | { |
584 | ret |= test.addch(*text++); | 584 | ret |= test.addch(*text++); |
585 | } | 585 | } |
586 | ret |= test.addch('\n'); | 586 | ret |= test.addch('\n'); |
587 | while (!test.empty()) | 587 | while (!test.empty()) |
588 | { | 588 | { |
589 | putchar(test.pop()); | 589 | putchar(test.pop()); |
590 | } | 590 | } |
591 | } | 591 | } |
592 | // inswt = test.addch(line, len); | 592 | // inswt = test.addch(line, len); |
593 | if (ret) reportmatch(line, 0, lino); | 593 | if (ret) reportmatch(line, 0, lino); |
594 | } | 594 | } |
595 | fclose(inf); | 595 | fclose(inf); |
596 | //CloseSTDLIB(); | 596 | //CloseSTDLIB(); |
597 | return 0; | 597 | return 0; |
598 | } | 598 | } |
599 | #endif | 599 | #endif |
diff --git a/noncore/apps/opie-reader/CSource.h b/noncore/apps/opie-reader/CSource.h new file mode 100644 index 0000000..2885f72 --- a/dev/null +++ b/noncore/apps/opie-reader/CSource.h | |||
@@ -0,0 +1,62 @@ | |||
1 | #ifndef __CSOURCE_H | ||
2 | #define __CSOURCE_H | ||
3 | |||
4 | class CInfo | ||
5 | { | ||
6 | public: | ||
7 | virtual unsigned long size() = 0; | ||
8 | }; | ||
9 | |||
10 | class CSource : public CInfo | ||
11 | { | ||
12 | public: | ||
13 | virtual int get() = 0; | ||
14 | }; | ||
15 | |||
16 | class CSink : public CInfo | ||
17 | { | ||
18 | public: | ||
19 | virtual void put(unsigned char c) = 0; | ||
20 | }; | ||
21 | |||
22 | class CMemSource : public CSource | ||
23 | { | ||
24 | unsigned long m_total_size; | ||
25 | unsigned long m_current; | ||
26 | unsigned char* m_buffer; | ||
27 | public: | ||
28 | CMemSource(unsigned char* _buffer, unsigned long _size) | ||
29 | : | ||
30 | m_total_size(_size), | ||
31 | m_current(0), | ||
32 | m_buffer(_buffer) | ||
33 | {} | ||
34 | unsigned long size() { return m_current; } | ||
35 | int get() | ||
36 | { | ||
37 | return ((m_current < m_total_size) ? m_buffer[m_current++] : -1); | ||
38 | } | ||
39 | }; | ||
40 | |||
41 | class CMemSink : public CSink | ||
42 | { | ||
43 | unsigned long m_total_size; | ||
44 | unsigned long m_current; | ||
45 | unsigned char* m_buffer; | ||
46 | public: | ||
47 | CMemSink(unsigned char* _buffer, unsigned long _size) | ||
48 | : | ||
49 | m_total_size(_size), | ||
50 | m_current(0), | ||
51 | m_buffer(_buffer) | ||
52 | {} | ||
53 | unsigned long size() { return m_current; } | ||
54 | void put(unsigned char c) | ||
55 | { | ||
56 | if (m_current < m_total_size) | ||
57 | { | ||
58 | m_buffer[m_current++] = c; | ||
59 | } | ||
60 | } | ||
61 | }; | ||
62 | #endif | ||
diff --git a/noncore/apps/opie-reader/Coder.h b/noncore/apps/opie-reader/Coder.h new file mode 100644 index 0000000..64587cf --- a/dev/null +++ b/noncore/apps/opie-reader/Coder.h | |||
@@ -0,0 +1,113 @@ | |||
1 | #include "CSource.h" | ||
2 | /**************************************************************************** | ||
3 | * This file is part of PPMd project * | ||
4 | * Contents: 'Carryless rangecoder' by Dmitry Subbotin * | ||
5 | * Comments: this implementation is claimed to be a public domain * | ||
6 | ****************************************************************************/ | ||
7 | /********************** Original text ************************************* | ||
8 | //////// Carryless rangecoder (c) 1999 by Dmitry Subbotin //////// | ||
9 | |||
10 | typedef unsigned int uint; | ||
11 | typedef unsigned char uc; | ||
12 | |||
13 | #define DO(n) for (int _=0; _<n; _++) | ||
14 | #define TOP (1<<24) | ||
15 | #define BOT (1<<16) | ||
16 | |||
17 | |||
18 | class RangeCoder | ||
19 | { | ||
20 | uint low, code, range, passed; | ||
21 | FILE *f; | ||
22 | |||
23 | void OutByte (uc c) { passed++; fputc(c,f); } | ||
24 | uc InByte () { passed++; return fgetc(f); } | ||
25 | |||
26 | public: | ||
27 | |||
28 | uint GetPassed () { return passed; } | ||
29 | void StartEncode (FILE *F) { f=F; passed=low=0; range= (uint) -1; } | ||
30 | void FinishEncode () { DO(4) OutByte(low>>24), low<<=8; } | ||
31 | void StartDecode (FILE *F) { passed=low=code=0; range= (uint) -1; | ||
32 | f=F; DO(4) code= code<<8 | InByte(); | ||
33 | } | ||
34 | |||
35 | void Encode (uint cumFreq, uint freq, uint totFreq) { | ||
36 | assert(cumFreq+freq<totFreq && freq && totFreq<=BOT); | ||
37 | low += cumFreq * (range/= totFreq); | ||
38 | range*= freq; | ||
39 | while ((low ^ low+range)<TOP || range<BOT && ((range= -low & BOT-1),1)) | ||
40 | OutByte(low>>24), range<<=8, low<<=8; | ||
41 | } | ||
42 | |||
43 | uint GetFreq (uint totFreq) { | ||
44 | uint tmp= (code-low) / (range/= totFreq); | ||
45 | if (tmp >= totFreq) throw ("Input data corrupt"); // or force it to return | ||
46 | return tmp; // a valid value :) | ||
47 | } | ||
48 | |||
49 | void Decode (uint cumFreq, uint freq, uint totFreq) { | ||
50 | assert(cumFreq+freq<totFreq && freq && totFreq<=BOT); | ||
51 | low += cumFreq*range; | ||
52 | range*= freq; | ||
53 | while ((low ^ low+range)<TOP || range<BOT && ((range= -low & BOT-1),1)) | ||
54 | code= code<<8 | InByte(), range<<=8, low<<=8; | ||
55 | } | ||
56 | }; | ||
57 | *****************************************************************************/ | ||
58 | |||
59 | static struct SUBRANGE { | ||
60 | DWORD LowCount, HighCount, scale; | ||
61 | } SubRange; | ||
62 | enum { TOP=1 << 24, BOT=1 << 15 }; | ||
63 | static DWORD low, code, range; | ||
64 | |||
65 | inline void ariInitEncoder() | ||
66 | { | ||
67 | low=0; range=DWORD(-1); | ||
68 | } | ||
69 | #define ARI_ENC_NORMALIZE(stream) { \ | ||
70 | while ((low ^ (low+range)) < TOP || range < BOT && \ | ||
71 | ((range= -low & (BOT-1)),1)) { \ | ||
72 | _PPMD_E_PUTC(low >> 24,stream); \ | ||
73 | range <<= 8; low <<= 8; \ | ||
74 | } \ | ||
75 | } | ||
76 | inline void ariEncodeSymbol() | ||
77 | { | ||
78 | low += SubRange.LowCount*(range /= SubRange.scale); | ||
79 | range *= SubRange.HighCount-SubRange.LowCount; | ||
80 | } | ||
81 | inline void ariShiftEncodeSymbol(UINT SHIFT) | ||
82 | { | ||
83 | low += SubRange.LowCount*(range >>= SHIFT); | ||
84 | range *= SubRange.HighCount-SubRange.LowCount; | ||
85 | } | ||
86 | #define ARI_FLUSH_ENCODER(stream) { \ | ||
87 | for (UINT i=0;i < 4;i++) { \ | ||
88 | _PPMD_E_PUTC(low >> 24,stream); low <<= 8; \ | ||
89 | } \ | ||
90 | } | ||
91 | #define ARI_INIT_DECODER(stream) { \ | ||
92 | low=code=0; range=DWORD(-1); \ | ||
93 | for (UINT i=0;i < 4;i++) \ | ||
94 | code=(code << 8) | _PPMD_D_GETC(stream); \ | ||
95 | } | ||
96 | #define ARI_DEC_NORMALIZE(stream) { \ | ||
97 | while ((low ^ (low+range)) < TOP || range < BOT && \ | ||
98 | ((range= -low & (BOT-1)),1)) { \ | ||
99 | code=(code << 8) | _PPMD_D_GETC(stream); \ | ||
100 | range <<= 8; low <<= 8; \ | ||
101 | } \ | ||
102 | } | ||
103 | inline UINT ariGetCurrentCount() { | ||
104 | return (code-low)/(range /= SubRange.scale); | ||
105 | } | ||
106 | inline UINT ariGetCurrentShiftCount(UINT SHIFT) { | ||
107 | return (code-low)/(range >>= SHIFT); | ||
108 | } | ||
109 | inline void ariRemoveSubrange() | ||
110 | { | ||
111 | low += range*SubRange.LowCount; | ||
112 | range *= SubRange.HighCount-SubRange.LowCount; | ||
113 | } | ||
diff --git a/noncore/apps/opie-reader/FliteCmd/.cvsignore b/noncore/apps/opie-reader/FliteCmd/.cvsignore new file mode 100644 index 0000000..1810ee0 --- a/dev/null +++ b/noncore/apps/opie-reader/FliteCmd/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile | ||
2 | config.in | ||
3 | moc_* | ||
4 | .moc | ||
5 | .obj | ||
diff --git a/noncore/apps/opie-reader/FliteCmd/FliteCmd.pro b/noncore/apps/opie-reader/FliteCmd/FliteCmd.pro new file mode 100644 index 0000000..0e1a782 --- a/dev/null +++ b/noncore/apps/opie-reader/FliteCmd/FliteCmd.pro | |||
@@ -0,0 +1,18 @@ | |||
1 | DEFINES += OPIE USEQPE | ||
2 | VPATH = .. | ||
3 | TEMPLATE= lib | ||
4 | CONFIG = qt warn_on release dll | ||
5 | HEADERS = flitecmd.h | ||
6 | |||
7 | SOURCES = flitecmd.cpp | ||
8 | |||
9 | |||
10 | INTERFACES= | ||
11 | DESTDIR = $(OPIEDIR)/plugins/reader/outcodecs | ||
12 | TARGET = flitecmd | ||
13 | |||
14 | |||
15 | INCLUDEPATH+= $(OPIEDIR)/include | ||
16 | DEPENDPATH += $(OPIEDIR)/include | ||
17 | |||
18 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/noncore/apps/opie-reader/FliteDyn/.cvsignore b/noncore/apps/opie-reader/FliteDyn/.cvsignore new file mode 100644 index 0000000..1810ee0 --- a/dev/null +++ b/noncore/apps/opie-reader/FliteDyn/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile | ||
2 | config.in | ||
3 | moc_* | ||
4 | .moc | ||
5 | .obj | ||
diff --git a/noncore/apps/opie-reader/FliteDyn/FliteDyn.pro b/noncore/apps/opie-reader/FliteDyn/FliteDyn.pro new file mode 100644 index 0000000..a949209 --- a/dev/null +++ b/noncore/apps/opie-reader/FliteDyn/FliteDyn.pro | |||
@@ -0,0 +1,18 @@ | |||
1 | DEFINES += OPIE USEQPE | ||
2 | VPATH = .. | ||
3 | TEMPLATE= lib | ||
4 | CONFIG = qt warn_on release dll | ||
5 | HEADERS = flitedyn.h | ||
6 | |||
7 | SOURCES = flitedyn.cpp | ||
8 | |||
9 | |||
10 | INTERFACES= | ||
11 | DESTDIR = $(OPIEDIR)/plugins/reader/outcodecs | ||
12 | TARGET = flitedyn | ||
13 | LIBS += -L/home/tim/flite/flite-1.2-release/lib -lflite_cmu_us_kal -lflite_usenglish -lflite_cmulex -lflite | ||
14 | |||
15 | INCLUDEPATH+= /home/tim/flite/flite-1.2-release/include $(OPIEDIR)/include | ||
16 | DEPENDPATH += /home/tim/flite/flite-1.2-release/include $(OPIEDIR)/include | ||
17 | |||
18 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/noncore/apps/opie-reader/FliteDyn16/.cvsignore b/noncore/apps/opie-reader/FliteDyn16/.cvsignore new file mode 100644 index 0000000..1810ee0 --- a/dev/null +++ b/noncore/apps/opie-reader/FliteDyn16/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile | ||
2 | config.in | ||
3 | moc_* | ||
4 | .moc | ||
5 | .obj | ||
diff --git a/noncore/apps/opie-reader/FliteDyn16/FliteDyn16.pro b/noncore/apps/opie-reader/FliteDyn16/FliteDyn16.pro new file mode 100644 index 0000000..49c2c42 --- a/dev/null +++ b/noncore/apps/opie-reader/FliteDyn16/FliteDyn16.pro | |||
@@ -0,0 +1,18 @@ | |||
1 | DEFINES += OPIE USEQPE | ||
2 | VPATH = .. | ||
3 | TEMPLATE= lib | ||
4 | CONFIG = qt warn_on release dll | ||
5 | HEADERS = flitedyn.h | ||
6 | |||
7 | SOURCES = flitedyn.cpp | ||
8 | |||
9 | |||
10 | INTERFACES= | ||
11 | DESTDIR = $(OPIEDIR)/plugins/reader/outcodecs | ||
12 | TARGET = flitedyn | ||
13 | LIBS += -L/home/tim/flite/flite-1.2-release/lib -lflite_cmu_us_kal16 -lflite_usenglish -lflite_cmulex -lflite | ||
14 | |||
15 | INCLUDEPATH+= /home/tim/flite/flite-1.2-release/include $(OPIEDIR)/include | ||
16 | DEPENDPATH += /home/tim/flite/flite-1.2-release/include $(OPIEDIR)/include | ||
17 | |||
18 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/noncore/apps/opie-reader/FontControl.cpp b/noncore/apps/opie-reader/FontControl.cpp index 9bb3bc0..08b8c52 100644 --- a/noncore/apps/opie-reader/FontControl.cpp +++ b/noncore/apps/opie-reader/FontControl.cpp | |||
@@ -1,66 +1,67 @@ | |||
1 | #include <qfontdatabase.h> | 1 | #include <qfontdatabase.h> |
2 | |||
2 | #include "FontControl.h" | 3 | #include "FontControl.h" |
3 | 4 | ||
4 | int FontControl::gzoom() | 5 | int FontControl::gzoom() |
5 | { | 6 | { |
6 | if (m_fixgraphics) | 7 | if (m_fixgraphics) |
7 | { | 8 | { |
8 | return 100; | 9 | return 100; |
9 | } | 10 | } |
10 | else | 11 | else |
11 | { | 12 | { |
12 | int ret; | 13 | int ret; |
13 | if (m_size == g_size) | 14 | if (m_size == g_size) |
14 | { | 15 | { |
15 | ret = m_fontsizes[m_size]*m_basesize; | 16 | ret = m_fontsizes[m_size]*m_basesize; |
16 | } | 17 | } |
17 | else if (g_size < 0) | 18 | else if (g_size < 0) |
18 | { | 19 | { |
19 | int f = -g_size; | 20 | int f = -g_size; |
20 | ret = (m_fontsizes[0]*m_basesize) >> (f/2); | 21 | ret = (m_fontsizes[0]*m_basesize) >> (f/2); |
21 | if (f%2) ret = (2*ret/3); | 22 | if (f%2) ret = (2*ret/3); |
22 | } | 23 | } |
23 | else | 24 | else |
24 | { | 25 | { |
25 | int f = g_size - m_maxsize + 1; | 26 | int f = g_size - m_maxsize + 1; |
26 | ret = (m_fontsizes[m_maxsize-1]*m_basesize) << (f/2); | 27 | ret = (m_fontsizes[m_maxsize-1]*m_basesize) << (f/2); |
27 | if (f%2) ret = (3*ret/2); | 28 | if (f%2) ret = (3*ret/2); |
28 | } | 29 | } |
29 | return ret; | 30 | return ret; |
30 | } | 31 | } |
31 | } | 32 | } |
32 | 33 | ||
33 | bool FontControl::ChangeFont(QString& n, int tgt) | 34 | bool FontControl::ChangeFont(QString& n, int tgt) |
34 | { | 35 | { |
35 | QValueList<int>::Iterator it; | 36 | QValueList<int>::Iterator it; |
36 | QFontDatabase fdb; | 37 | QFontDatabase fdb; |
37 | QValueList<int> sizes = fdb.pointSizes(n); | 38 | QValueList<int> sizes = fdb.pointSizes(n); |
38 | if (sizes.count() == 0) | 39 | if (sizes.count() == 0) |
39 | { | 40 | { |
40 | return false; | 41 | return false; |
41 | } | 42 | } |
42 | else | 43 | else |
43 | { | 44 | { |
44 | m_fontname = n; | 45 | m_fontname = n; |
45 | m_maxsize = sizes.count(); | 46 | m_maxsize = sizes.count(); |
46 | if (m_fontsizes != NULL) delete [] m_fontsizes; | 47 | if (m_fontsizes != NULL) delete [] m_fontsizes; |
47 | m_fontsizes = new int[m_maxsize]; | 48 | m_fontsizes = new int[m_maxsize]; |
48 | uint i = 0; | 49 | uint i = 0; |
49 | uint best = 0; | 50 | uint best = 0; |
50 | for (it = sizes.begin(); it != sizes.end(); it++) | 51 | for (it = sizes.begin(); it != sizes.end(); it++) |
51 | { | 52 | { |
52 | #if defined(OPIE) || !defined(USEQPE) | 53 | #if defined(OPIE) || !defined(USEQPE) |
53 | m_fontsizes[i] = (*it); | 54 | m_fontsizes[i] = (*it); |
54 | #else | 55 | #else |
55 | m_fontsizes[i] = (*it)/10; | 56 | m_fontsizes[i] = (*it)/10; |
56 | #endif | 57 | #endif |
57 | if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) | 58 | if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) |
58 | { | 59 | { |
59 | best = i; | 60 | best = i; |
60 | } | 61 | } |
61 | i++; | 62 | i++; |
62 | } | 63 | } |
63 | g_size = m_size = best; | 64 | g_size = m_size = best; |
64 | } | 65 | } |
65 | return true; | 66 | return true; |
66 | } | 67 | } |
diff --git a/noncore/apps/opie-reader/FontControl.h b/noncore/apps/opie-reader/FontControl.h index 90d39b2..563e1a8 100644 --- a/noncore/apps/opie-reader/FontControl.h +++ b/noncore/apps/opie-reader/FontControl.h | |||
@@ -1,172 +1,172 @@ | |||
1 | #ifndef __FONTCONTROL_H | 1 | #ifndef __FONTCONTROL_H |
2 | #define __FONTCONTROL_H | 2 | #define __FONTCONTROL_H |
3 | 3 | ||
4 | #include <qfontmetrics.h> | 4 | #include <qfontmetrics.h> |
5 | #include "StyleConsts.h" | 5 | #include "StyleConsts.h" |
6 | 6 | ||
7 | class FontControl | 7 | class FontControl |
8 | { | 8 | { |
9 | int * m_fontsizes; | 9 | int * m_fontsizes; |
10 | int m_size, g_size; | 10 | int m_size, g_size; |
11 | QString m_fontname; | 11 | QString m_fontname; |
12 | QString m_fixedfontname; | 12 | QString m_fixedfontname; |
13 | int m_maxsize; | 13 | int m_maxsize; |
14 | bool m_hasCourier; | 14 | bool m_hasCourier; |
15 | int m_leading, m_extraspace; | 15 | int m_leading, m_extraspace; |
16 | unsigned char m_basesize; | 16 | unsigned char m_basesize; |
17 | bool m_fixgraphics; | 17 | bool m_fixgraphics; |
18 | public: | 18 | public: |
19 | void FixGraphics(bool _b) | 19 | void FixGraphics(bool _b) |
20 | { | 20 | { |
21 | m_fixgraphics = _b; | 21 | m_fixgraphics = _b; |
22 | } | 22 | } |
23 | bool FixGraphics() | 23 | bool FixGraphics() |
24 | { | 24 | { |
25 | return m_fixgraphics; | 25 | return m_fixgraphics; |
26 | } | 26 | } |
27 | void setBaseSize(unsigned char _s) { m_basesize = _s; } | 27 | void setBaseSize(unsigned char _s) { m_basesize = _s; } |
28 | unsigned char getBaseSize() { return m_basesize; } | 28 | unsigned char getBaseSize() { return m_basesize; } |
29 | int gzoom(); | 29 | int gzoom(); |
30 | FontControl(QString n = "helvetica", int size = 10) | 30 | FontControl(QString n = "helvetica", int size = 10) |
31 | : | 31 | : |
32 | m_fontsizes(NULL), m_hasCourier(false), m_leading(0), m_extraspace(0), m_fixgraphics(true) | 32 | m_fontsizes(NULL), m_hasCourier(false), m_leading(0), m_extraspace(0), m_fixgraphics(true) |
33 | { | 33 | { |
34 | ChangeFont(n, size); | 34 | ChangeFont(n, size); |
35 | } | 35 | } |
36 | ~FontControl() | 36 | ~FontControl() |
37 | { | 37 | { |
38 | if (m_fontsizes != NULL) delete [] m_fontsizes; | 38 | if (m_fontsizes != NULL) delete [] m_fontsizes; |
39 | } | 39 | } |
40 | void hasCourier(bool _b, const QString& _nm) | 40 | void hasCourier(bool _b, const QString& _nm) |
41 | { | 41 | { |
42 | m_hasCourier = _b; | 42 | m_hasCourier = _b; |
43 | m_fixedfontname = _nm; | 43 | m_fixedfontname = _nm; |
44 | } | 44 | } |
45 | QString& fixedfontname() { return m_fixedfontname; } | 45 | QString& fixedfontname() { return m_fixedfontname; } |
46 | bool hasCourier() { return m_hasCourier; } | 46 | bool hasCourier() { return m_hasCourier; } |
47 | QString name() { return m_fontname; } | 47 | QString name() { return m_fontname; } |
48 | int currentsize() { return (m_fontsizes == NULL) ? 0 : m_fontsizes[m_size]; } | 48 | int currentsize() { return (m_fontsizes == NULL) ? 0 : m_fontsizes[m_size]; } |
49 | int getsize(const CStyle& size) | 49 | int getsize(const CStyle& size) |
50 | { | 50 | { |
51 | return getsize(size.getFontSize()); | 51 | return getsize(size.getFontSize()); |
52 | } | 52 | } |
53 | int getsize(int _offset) | 53 | int getsize(int _offset) |
54 | { | 54 | { |
55 | int tgt = m_size+_offset; | 55 | int tgt = m_size+_offset; |
56 | if (tgt < 0) | 56 | if (tgt < 0) |
57 | { | 57 | { |
58 | tgt = 0; | 58 | tgt = 0; |
59 | } | 59 | } |
60 | if (tgt >= m_maxsize) | 60 | if (tgt >= m_maxsize) |
61 | { | 61 | { |
62 | tgt = m_maxsize - 1; | 62 | tgt = m_maxsize - 1; |
63 | } | 63 | } |
64 | return m_fontsizes[tgt]; | 64 | return tgt >= 0 ? m_fontsizes[tgt] : 12; |
65 | } | 65 | } |
66 | int ascent() | 66 | int ascent() |
67 | { | 67 | { |
68 | QFont f(name(), currentsize()); | 68 | QFont f(name(), currentsize()); |
69 | QFontMetrics fm(f); | 69 | QFontMetrics fm(f); |
70 | return fm.ascent(); | 70 | return fm.ascent(); |
71 | } | 71 | } |
72 | int ascent(const CStyle& ch) | 72 | int ascent(const CStyle& ch) |
73 | { | 73 | { |
74 | QFont f(name(), getsize(ch)); | 74 | QFont f(name(), getsize(ch)); |
75 | QFontMetrics fm(f); | 75 | QFontMetrics fm(f); |
76 | return fm.ascent(); | 76 | return fm.ascent(); |
77 | } | 77 | } |
78 | int descent() | 78 | int descent() |
79 | { | 79 | { |
80 | QFont f(name(), currentsize()); | 80 | QFont f(name(), currentsize()); |
81 | QFontMetrics fm(f); | 81 | QFontMetrics fm(f); |
82 | return fm.descent(); | 82 | return fm.descent(); |
83 | } | 83 | } |
84 | int descent(const CStyle& ch) | 84 | int descent(const CStyle& ch) |
85 | { | 85 | { |
86 | QFont f(name(), getsize(ch)); | 86 | QFont f(name(), getsize(ch)); |
87 | QFontMetrics fm(f); | 87 | QFontMetrics fm(f); |
88 | return fm.descent(); | 88 | return fm.descent(); |
89 | } | 89 | } |
90 | int lineSpacing() | 90 | int lineSpacing() |
91 | { | 91 | { |
92 | QFont f(name(), currentsize()); | 92 | QFont f(name(), currentsize()); |
93 | QFontMetrics fm(f); | 93 | QFontMetrics fm(f); |
94 | return fm.lineSpacing(); | 94 | return fm.lineSpacing(); |
95 | } | 95 | } |
96 | int lineSpacing(const CStyle& ch) | 96 | int lineSpacing(const CStyle& ch) |
97 | { | 97 | { |
98 | QFont f(name(), getsize(ch)); | 98 | QFont f(name(), getsize(ch)); |
99 | QFontMetrics fm(f); | 99 | QFontMetrics fm(f); |
100 | return fm.lineSpacing(); | 100 | return fm.lineSpacing(); |
101 | } | 101 | } |
102 | bool decreasesize() | 102 | bool decreasesize() |
103 | { | 103 | { |
104 | if (m_fixgraphics) | 104 | if (m_fixgraphics) |
105 | { | 105 | { |
106 | if (--m_size < 0) | 106 | if (--m_size < 0) |
107 | { | 107 | { |
108 | m_size = 0; | 108 | m_size = 0; |
109 | return false; | 109 | return false; |
110 | } | 110 | } |
111 | g_size = m_size; | 111 | g_size = m_size; |
112 | } | 112 | } |
113 | else | 113 | else |
114 | { | 114 | { |
115 | if (g_size-- == m_size) | 115 | if (g_size-- == m_size) |
116 | { | 116 | { |
117 | if (--m_size < 0) | 117 | if (--m_size < 0) |
118 | { | 118 | { |
119 | m_size = 0; | 119 | m_size = 0; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | } | 122 | } |
123 | // qDebug("Font:%d Graphics:%d", m_size, g_size); | 123 | // qDebug("Font:%d Graphics:%d", m_size, g_size); |
124 | return true; | 124 | return true; |
125 | } | 125 | } |
126 | bool increasesize() | 126 | bool increasesize() |
127 | { | 127 | { |
128 | if (m_fixgraphics) | 128 | if (m_fixgraphics) |
129 | { | 129 | { |
130 | if (++m_size >= m_maxsize) | 130 | if (++m_size >= m_maxsize) |
131 | { | 131 | { |
132 | m_size = m_maxsize - 1; | 132 | m_size = m_maxsize - 1; |
133 | return false; | 133 | return false; |
134 | } | 134 | } |
135 | g_size = m_size; | 135 | g_size = m_size; |
136 | } | 136 | } |
137 | else | 137 | else |
138 | { | 138 | { |
139 | if (g_size++ == m_size) | 139 | if (g_size++ == m_size) |
140 | { | 140 | { |
141 | if (++m_size >= m_maxsize) | 141 | if (++m_size >= m_maxsize) |
142 | { | 142 | { |
143 | m_size = m_maxsize - 1; | 143 | m_size = m_maxsize - 1; |
144 | } | 144 | } |
145 | } | 145 | } |
146 | } | 146 | } |
147 | return true; | 147 | return true; |
148 | } | 148 | } |
149 | bool ChangeFont(QString& n) | 149 | bool ChangeFont(QString& n) |
150 | { | 150 | { |
151 | return ChangeFont(n, currentsize()); | 151 | return ChangeFont(n, currentsize()); |
152 | } | 152 | } |
153 | bool ChangeFont(QString& n, int tgt); | 153 | bool ChangeFont(QString& n, int tgt); |
154 | void setlead(int _lead) | 154 | void setlead(int _lead) |
155 | { | 155 | { |
156 | m_leading = _lead; | 156 | m_leading = _lead; |
157 | } | 157 | } |
158 | int getlead() | 158 | int getlead() |
159 | { | 159 | { |
160 | return m_leading; | 160 | return m_leading; |
161 | } | 161 | } |
162 | void setextraspace(int _lead) | 162 | void setextraspace(int _lead) |
163 | { | 163 | { |
164 | m_extraspace = _lead; | 164 | m_extraspace = _lead; |
165 | } | 165 | } |
166 | int getextraspace() | 166 | int getextraspace() |
167 | { | 167 | { |
168 | return m_extraspace; | 168 | return m_extraspace; |
169 | } | 169 | } |
170 | }; | 170 | }; |
171 | 171 | ||
172 | #endif | 172 | #endif |
diff --git a/noncore/apps/opie-reader/Model.cpp b/noncore/apps/opie-reader/Model.cpp new file mode 100644 index 0000000..6b61fa0 --- a/dev/null +++ b/noncore/apps/opie-reader/Model.cpp | |||
@@ -0,0 +1,721 @@ | |||
1 | /**************************************************************************** | ||
2 | * This file is part of PPMd project * | ||
3 | * Written and distributed to public domain by Dmitry Shkarin 1997, * | ||
4 | * 1999-2001 * | ||
5 | * Contents: PPMII model description and encoding/decoding routines * | ||
6 | ****************************************************************************/ | ||
7 | #include <string.h> | ||
8 | #include "PPMd.h" | ||
9 | #pragma hdrstop | ||
10 | #include "Coder.h" | ||
11 | #include "SubAlloc.h" | ||
12 | |||
13 | enum { UP_FREQ=5, INT_BITS=7, PERIOD_BITS=7, TOT_BITS=INT_BITS+PERIOD_BITS, | ||
14 | INTERVAL=1 << INT_BITS, BIN_SCALE=1 << TOT_BITS, MAX_FREQ=124, O_BOUND=9 }; | ||
15 | |||
16 | #pragma pack(1) | ||
17 | static struct SEE2_CONTEXT { // SEE-contexts for PPM-contexts with masked symbols | ||
18 | WORD Summ; | ||
19 | BYTE Shift, Count; | ||
20 | void init(UINT InitVal) { Summ=InitVal << (Shift=PERIOD_BITS-4); Count=7; } | ||
21 | UINT getMean() { | ||
22 | UINT RetVal=(Summ >> Shift); Summ -= RetVal; | ||
23 | return RetVal+(RetVal == 0); | ||
24 | } | ||
25 | void update() { | ||
26 | if (Shift < PERIOD_BITS && --Count == 0) { | ||
27 | Summ += Summ; Count=3 << Shift++; | ||
28 | } | ||
29 | } | ||
30 | } _PACK_ATTR SEE2Cont[24][32], DummySEE2Cont; | ||
31 | static struct PPM_CONTEXT { // Notes: | ||
32 | BYTE NumStats, Flags; // 1. NumStats & NumMasked contain | ||
33 | WORD SummFreq; // number of symbols minus 1 | ||
34 | struct STATE { // 2. sizeof(WORD) > sizeof(BYTE) | ||
35 | BYTE Symbol, Freq; // 3. contexts example: | ||
36 | PPM_CONTEXT* Successor; // MaxOrder: | ||
37 | } _PACK_ATTR * Stats; // ABCD context | ||
38 | PPM_CONTEXT* Suffix; // BCD suffix | ||
39 | inline void encodeBinSymbol(int symbol);// BCDE successor | ||
40 | inline void encodeSymbol1(int symbol);// other orders: | ||
41 | inline void encodeSymbol2(int symbol);// BCD context | ||
42 | inline void decodeBinSymbol();// CD suffix | ||
43 | inline void decodeSymbol1();// BCDE successor | ||
44 | inline void decodeSymbol2(); | ||
45 | inline void update1(STATE* p); | ||
46 | inline void update2(STATE* p); | ||
47 | inline SEE2_CONTEXT* makeEscFreq2(); | ||
48 | void rescale(); | ||
49 | void refresh(int OldNU,BOOL Scale); | ||
50 | PPM_CONTEXT* cutOff(int Order); | ||
51 | PPM_CONTEXT* removeBinConts(int Order); | ||
52 | STATE& oneState() const { return (STATE&) SummFreq; } | ||
53 | } _PACK_ATTR* MaxContext; | ||
54 | #pragma pack() | ||
55 | |||
56 | static BYTE NS2BSIndx[256], QTable[260]; // constants | ||
57 | static PPM_CONTEXT::STATE* FoundState; // found next state transition | ||
58 | static int InitEsc, OrderFall, RunLength, InitRL, MaxOrder; | ||
59 | static BYTE CharMask[256], NumMasked, PrevSuccess, EscCount, PrintCount; | ||
60 | static WORD BinSumm[25][64]; // binary SEE-contexts | ||
61 | static MR_METHOD MRMethod; | ||
62 | |||
63 | inline void SWAP(PPM_CONTEXT::STATE& s1,PPM_CONTEXT::STATE& s2) | ||
64 | { | ||
65 | /* | ||
66 | WORD t1=(WORD&) s1; PPM_CONTEXT* t2=s1.Successor; | ||
67 | (WORD&) s1 = (WORD&) s2; s1.Successor=s2.Successor; | ||
68 | (WORD&) s2 = t1; s2.Successor=t2; | ||
69 | */ | ||
70 | PPM_CONTEXT::STATE t = s1; | ||
71 | s1 = s2; | ||
72 | s2 = t; | ||
73 | } | ||
74 | inline void StateCpy(PPM_CONTEXT::STATE& s1,const PPM_CONTEXT::STATE& s2) | ||
75 | { | ||
76 | // (WORD&) s1=(WORD&) s2; s1.Successor=s2.Successor; | ||
77 | s1 = s2; | ||
78 | } | ||
79 | struct PPMD_STARTUP { inline PPMD_STARTUP(); } PPMd_StartUp; | ||
80 | inline PPMD_STARTUP::PPMD_STARTUP() // constants initialization | ||
81 | { | ||
82 | UINT i, k, m, Step; | ||
83 | for (i=0,k=1;i < N1 ;i++,k += 1) Indx2Units[i]=k; | ||
84 | for (k++;i < N1+N2 ;i++,k += 2) Indx2Units[i]=k; | ||
85 | for (k++;i < N1+N2+N3 ;i++,k += 3) Indx2Units[i]=k; | ||
86 | for (k++;i < N1+N2+N3+N4;i++,k += 4) Indx2Units[i]=k; | ||
87 | for (k=i=0;k < 128;k++) { | ||
88 | i += (Indx2Units[i] < k+1); Units2Indx[k]=i; | ||
89 | } | ||
90 | NS2BSIndx[0]=2*0; NS2BSIndx[1]=2*1; | ||
91 | memset(NS2BSIndx+2,2*2,9); memset(NS2BSIndx+11,2*3,256-11); | ||
92 | for (i=0;i < UP_FREQ;i++) QTable[i]=i; | ||
93 | for (m=i=UP_FREQ, k=Step=1;i < 260;i++) { | ||
94 | QTable[i]=m; | ||
95 | if ( !--k ) { k = ++Step; m++; } | ||
96 | } | ||
97 | (DWORD&) DummySEE2Cont=PPMdSignature; | ||
98 | } | ||
99 | static void _STDCALL StartModelRare(int MaxOrder,MR_METHOD MRMethod) | ||
100 | { | ||
101 | UINT i, k, m; | ||
102 | memset(CharMask,0,sizeof(CharMask)); EscCount=PrintCount=1; | ||
103 | if (MaxOrder < 2) { // we are in solid mode | ||
104 | OrderFall=::MaxOrder; | ||
105 | for (PPM_CONTEXT* pc=MaxContext;pc->Suffix != NULL;pc=pc->Suffix) | ||
106 | OrderFall--; | ||
107 | return; | ||
108 | } | ||
109 | OrderFall=::MaxOrder=MaxOrder; ::MRMethod=MRMethod; | ||
110 | InitSubAllocator(); | ||
111 | RunLength=InitRL=-((MaxOrder < 12)?MaxOrder:12)-1; | ||
112 | MaxContext = (PPM_CONTEXT*) AllocContext(); | ||
113 | MaxContext->Suffix=NULL; | ||
114 | MaxContext->SummFreq=(MaxContext->NumStats=255)+2; | ||
115 | MaxContext->Stats = (PPM_CONTEXT::STATE*) AllocUnits(256/2); | ||
116 | for (PrevSuccess=i=0;i < 256;i++) { | ||
117 | MaxContext->Stats[i].Symbol=i; MaxContext->Stats[i].Freq=1; | ||
118 | MaxContext->Stats[i].Successor=NULL; | ||
119 | } | ||
120 | static const WORD InitBinEsc[]={0x3CDD,0x1F3F,0x59BF,0x48F3,0x64A1,0x5ABC,0x6632,0x6051}; | ||
121 | for (i=m=0;m < 25;m++) { | ||
122 | while (QTable[i] == m) i++; | ||
123 | for (k=0;k < 8;k++) | ||
124 | BinSumm[m][k]=BIN_SCALE-InitBinEsc[k]/(i+1); | ||
125 | for (k=8;k < 64;k += 8) | ||
126 | memcpy(BinSumm[m]+k,BinSumm[m],8*sizeof(WORD)); | ||
127 | } | ||
128 | for (i=m=0;m < 24;m++) { | ||
129 | while (QTable[i+3] == m+3) i++; | ||
130 | SEE2Cont[m][0].init(2*i+5); | ||
131 | for (k=1;k < 32;k++) SEE2Cont[m][k]=SEE2Cont[m][0]; | ||
132 | } | ||
133 | } | ||
134 | void PPM_CONTEXT::refresh(int OldNU,BOOL Scale) | ||
135 | { | ||
136 | int i=NumStats, EscFreq; | ||
137 | STATE* p = Stats = (STATE*) ShrinkUnits(Stats,OldNU,(i+2) >> 1); | ||
138 | Flags=(Flags & (0x10+0x04*Scale))+0x08*(p->Symbol >= 0x40); | ||
139 | EscFreq=SummFreq-p->Freq; | ||
140 | SummFreq = (p->Freq=(p->Freq+Scale) >> Scale); | ||
141 | do { | ||
142 | EscFreq -= (++p)->Freq; | ||
143 | SummFreq += (p->Freq=(p->Freq+Scale) >> Scale); | ||
144 | Flags |= 0x08*(p->Symbol >= 0x40); | ||
145 | } while ( --i ); | ||
146 | SummFreq += (EscFreq=(EscFreq+Scale) >> Scale); | ||
147 | } | ||
148 | #define P_CALL(F) ( PrefetchData(p->Successor), \ | ||
149 | p->Successor=p->Successor->F(Order+1)) | ||
150 | PPM_CONTEXT* PPM_CONTEXT::cutOff(int Order) | ||
151 | { | ||
152 | int i, tmp; | ||
153 | STATE* p; | ||
154 | if ( !NumStats ) { | ||
155 | if ((BYTE*) (p=&oneState())->Successor >= UnitsStart) { | ||
156 | if (Order < MaxOrder) P_CALL(cutOff); | ||
157 | else p->Successor=NULL; | ||
158 | if (!p->Successor && Order > O_BOUND) | ||
159 | goto REMOVE; | ||
160 | return this; | ||
161 | } else { | ||
162 | REMOVE: SpecialFreeUnit(this); return NULL; | ||
163 | } | ||
164 | } | ||
165 | PrefetchData(Stats); | ||
166 | Stats = (STATE*) MoveUnitsUp(Stats,tmp=(NumStats+2) >> 1); | ||
167 | for (p=Stats+(i=NumStats);p >= Stats;p--) | ||
168 | if ((BYTE*) p->Successor < UnitsStart) { | ||
169 | p->Successor=NULL; SWAP(*p,Stats[i--]); | ||
170 | } else if (Order < MaxOrder) P_CALL(cutOff); | ||
171 | else p->Successor=NULL; | ||
172 | if (i != NumStats && Order) { | ||
173 | NumStats=i; p=Stats; | ||
174 | if (i < 0) { FreeUnits(p,tmp); goto REMOVE; } | ||
175 | else if (i == 0) { | ||
176 | Flags=(Flags & 0x10)+0x08*(p->Symbol >= 0x40); | ||
177 | StateCpy(oneState(),*p); FreeUnits(p,tmp); | ||
178 | oneState().Freq=(oneState().Freq+11) >> 3; | ||
179 | } else refresh(tmp,SummFreq > 16*i); | ||
180 | } | ||
181 | return this; | ||
182 | } | ||
183 | PPM_CONTEXT* PPM_CONTEXT::removeBinConts(int Order) | ||
184 | { | ||
185 | STATE* p; | ||
186 | if ( !NumStats ) { | ||
187 | p=&oneState(); | ||
188 | if ((BYTE*) p->Successor >= UnitsStart && Order < MaxOrder) | ||
189 | P_CALL(removeBinConts); | ||
190 | else p->Successor=NULL; | ||
191 | if (!p->Successor && (!Suffix->NumStats || Suffix->Flags == 0xFF)) { | ||
192 | FreeUnits(this,1); return NULL; | ||
193 | } else return this; | ||
194 | } | ||
195 | PrefetchData(Stats); | ||
196 | for (p=Stats+NumStats;p >= Stats;p--) | ||
197 | if ((BYTE*) p->Successor >= UnitsStart && Order < MaxOrder) | ||
198 | P_CALL(removeBinConts); | ||
199 | else p->Successor=NULL; | ||
200 | return this; | ||
201 | } | ||
202 | static void RestoreModelRare(PPM_CONTEXT* pc1,PPM_CONTEXT* MinContext, | ||
203 | PPM_CONTEXT* FSuccessor) | ||
204 | { | ||
205 | PPM_CONTEXT* pc; | ||
206 | PPM_CONTEXT::STATE* p; | ||
207 | for (pc=MaxContext, pText=HeapStart;pc != pc1;pc=pc->Suffix) | ||
208 | if (--(pc->NumStats) == 0) { | ||
209 | pc->Flags=(pc->Flags & 0x10)+0x08*(pc->Stats->Symbol >= 0x40); | ||
210 | p=pc->Stats; StateCpy(pc->oneState(),*p); | ||
211 | SpecialFreeUnit(p); | ||
212 | pc->oneState().Freq=(pc->oneState().Freq+11) >> 3; | ||
213 | } else | ||
214 | pc->refresh((pc->NumStats+3) >> 1,FALSE); | ||
215 | for ( ;pc != MinContext;pc=pc->Suffix) | ||
216 | if ( !pc->NumStats ) | ||
217 | pc->oneState().Freq -= pc->oneState().Freq >> 1; | ||
218 | else if ((pc->SummFreq += 4) > 128+4*pc->NumStats) | ||
219 | pc->refresh((pc->NumStats+2) >> 1,TRUE); | ||
220 | if (MRMethod > MRM_FREEZE) { | ||
221 | MaxContext=FSuccessor; GlueCount += !(BList[1].Stamp & 1); | ||
222 | } else if (MRMethod == MRM_FREEZE) { | ||
223 | while ( MaxContext->Suffix ) MaxContext=MaxContext->Suffix; | ||
224 | MaxContext->removeBinConts(0); MRMethod=MR_METHOD(MRMethod+1); | ||
225 | GlueCount=0; OrderFall=MaxOrder; | ||
226 | } else if (MRMethod == MRM_RESTART || GetUsedMemory() < (SubAllocatorSize >> 1)) { | ||
227 | StartModelRare(MaxOrder,MRMethod); | ||
228 | EscCount=0; PrintCount=0xFF; | ||
229 | } else { | ||
230 | while ( MaxContext->Suffix ) MaxContext=MaxContext->Suffix; | ||
231 | do { | ||
232 | MaxContext->cutOff(0); ExpandTextArea(); | ||
233 | } while (GetUsedMemory() > 3*(SubAllocatorSize >> 2)); | ||
234 | GlueCount=0; OrderFall=MaxOrder; | ||
235 | } | ||
236 | } | ||
237 | static PPM_CONTEXT* _FASTCALL CreateSuccessors(BOOL Skip,PPM_CONTEXT::STATE* p, | ||
238 | PPM_CONTEXT* pc); | ||
239 | static PPM_CONTEXT* _FASTCALL ReduceOrder(PPM_CONTEXT::STATE* p,PPM_CONTEXT* pc) | ||
240 | { | ||
241 | PPM_CONTEXT::STATE* p1, * ps[MAX_O], ** pps=ps; | ||
242 | PPM_CONTEXT* pc1=pc, * UpBranch = (PPM_CONTEXT*) pText; | ||
243 | BYTE tmp, sym=FoundState->Symbol; | ||
244 | *pps++ = FoundState; FoundState->Successor=UpBranch; | ||
245 | OrderFall++; | ||
246 | if ( p ) { pc=pc->Suffix; goto LOOP_ENTRY; } | ||
247 | for ( ; ; ) { | ||
248 | if ( !pc->Suffix ) { | ||
249 | if (MRMethod > MRM_FREEZE) { | ||
250 | FROZEN: do { (*--pps)->Successor = pc; } while (pps != ps); | ||
251 | pText=HeapStart+1; OrderFall=1; | ||
252 | } | ||
253 | return pc; | ||
254 | } | ||
255 | pc=pc->Suffix; | ||
256 | if ( pc->NumStats ) { | ||
257 | if ((p=pc->Stats)->Symbol != sym) | ||
258 | do { tmp=p[1].Symbol; p++; } while (tmp != sym); | ||
259 | tmp=2*(p->Freq < MAX_FREQ-9); | ||
260 | p->Freq += tmp; pc->SummFreq += tmp; | ||
261 | } else { p=&(pc->oneState()); p->Freq += (p->Freq < 32); } | ||
262 | LOOP_ENTRY: | ||
263 | if ( p->Successor ) break; | ||
264 | *pps++ = p; p->Successor=UpBranch; | ||
265 | OrderFall++; | ||
266 | } | ||
267 | if (MRMethod > MRM_FREEZE) { | ||
268 | pc = p->Successor; goto FROZEN; | ||
269 | } else if (p->Successor <= UpBranch) { | ||
270 | p1=FoundState; FoundState=p; | ||
271 | p->Successor=CreateSuccessors(FALSE,NULL,pc); | ||
272 | FoundState=p1; | ||
273 | } | ||
274 | if (OrderFall == 1 && pc1 == MaxContext) { | ||
275 | FoundState->Successor=p->Successor; pText--; | ||
276 | } | ||
277 | return p->Successor; | ||
278 | } | ||
279 | void PPM_CONTEXT::rescale() | ||
280 | { | ||
281 | UINT OldNU, Adder, EscFreq, i=NumStats; | ||
282 | STATE tmp, * p1, * p; | ||
283 | for (p=FoundState;p != Stats;p--) SWAP(p[0],p[-1]); | ||
284 | p->Freq += 4; SummFreq += 4; | ||
285 | EscFreq=SummFreq-p->Freq; | ||
286 | Adder=(OrderFall != 0 || MRMethod > MRM_FREEZE); | ||
287 | SummFreq = (p->Freq=(p->Freq+Adder) >> 1); | ||
288 | do { | ||
289 | EscFreq -= (++p)->Freq; | ||
290 | SummFreq += (p->Freq=(p->Freq+Adder) >> 1); | ||
291 | if (p[0].Freq > p[-1].Freq) { | ||
292 | StateCpy(tmp,*(p1=p)); | ||
293 | do StateCpy(p1[0],p1[-1]); while (tmp.Freq > (--p1)[-1].Freq); | ||
294 | StateCpy(*p1,tmp); | ||
295 | } | ||
296 | } while ( --i ); | ||
297 | if (p->Freq == 0) { | ||
298 | do { i++; } while ((--p)->Freq == 0); | ||
299 | EscFreq += i; OldNU=(NumStats+2) >> 1; | ||
300 | if ((NumStats -= i) == 0) { | ||
301 | StateCpy(tmp,*Stats); | ||
302 | tmp.Freq=(2*tmp.Freq+EscFreq-1)/EscFreq; | ||
303 | if (tmp.Freq > MAX_FREQ/3) tmp.Freq=MAX_FREQ/3; | ||
304 | FreeUnits(Stats,OldNU); StateCpy(oneState(),tmp); | ||
305 | Flags=(Flags & 0x10)+0x08*(tmp.Symbol >= 0x40); | ||
306 | FoundState=&oneState(); return; | ||
307 | } | ||
308 | Stats = (STATE*) ShrinkUnits(Stats,OldNU,(NumStats+2) >> 1); | ||
309 | Flags &= ~0x08; i=NumStats; | ||
310 | Flags |= 0x08*((p=Stats)->Symbol >= 0x40); | ||
311 | do { Flags |= 0x08*((++p)->Symbol >= 0x40); } while ( --i ); | ||
312 | } | ||
313 | SummFreq += (EscFreq -= (EscFreq >> 1)); | ||
314 | Flags |= 0x04; FoundState=Stats; | ||
315 | } | ||
316 | static PPM_CONTEXT* _FASTCALL CreateSuccessors(BOOL Skip,PPM_CONTEXT::STATE* p, | ||
317 | PPM_CONTEXT* pc) | ||
318 | { | ||
319 | PPM_CONTEXT ct, * UpBranch=FoundState->Successor; | ||
320 | PPM_CONTEXT::STATE* ps[MAX_O], ** pps=ps; | ||
321 | UINT cf, s0; | ||
322 | BYTE tmp, sym=FoundState->Symbol; | ||
323 | if ( !Skip ) { | ||
324 | *pps++ = FoundState; | ||
325 | if ( !pc->Suffix ) goto NO_LOOP; | ||
326 | } | ||
327 | if ( p ) { pc=pc->Suffix; goto LOOP_ENTRY; } | ||
328 | do { | ||
329 | pc=pc->Suffix; | ||
330 | if ( pc->NumStats ) { | ||
331 | if ((p=pc->Stats)->Symbol != sym) | ||
332 | do { tmp=p[1].Symbol; p++; } while (tmp != sym); | ||
333 | tmp=(p->Freq < MAX_FREQ-9); | ||
334 | p->Freq += tmp; pc->SummFreq += tmp; | ||
335 | } else { | ||
336 | p=&(pc->oneState()); | ||
337 | p->Freq += (!pc->Suffix->NumStats & (p->Freq < 24)); | ||
338 | } | ||
339 | LOOP_ENTRY: | ||
340 | if (p->Successor != UpBranch) { | ||
341 | pc=p->Successor; break; | ||
342 | } | ||
343 | *pps++ = p; | ||
344 | } while ( pc->Suffix ); | ||
345 | NO_LOOP: | ||
346 | if (pps == ps) return pc; | ||
347 | ct.NumStats=0; ct.Flags=0x10*(sym >= 0x40); | ||
348 | ct.oneState().Symbol=sym=*(BYTE*) UpBranch; | ||
349 | ct.oneState().Successor=(PPM_CONTEXT*) (((BYTE*) UpBranch)+1); | ||
350 | ct.Flags |= 0x08*(sym >= 0x40); | ||
351 | if ( pc->NumStats ) { | ||
352 | if ((p=pc->Stats)->Symbol != sym) | ||
353 | do { tmp=p[1].Symbol; p++; } while (tmp != sym); | ||
354 | s0=pc->SummFreq-pc->NumStats-(cf=p->Freq-1); | ||
355 | ct.oneState().Freq=1+((2*cf <= s0)?(5*cf > s0):((cf+2*s0-3)/s0)); | ||
356 | } else | ||
357 | ct.oneState().Freq=pc->oneState().Freq; | ||
358 | do { | ||
359 | PPM_CONTEXT* pc1 = (PPM_CONTEXT*) AllocContext(); | ||
360 | if ( !pc1 ) return NULL; | ||
361 | ((DWORD*) pc1)[0] = ((DWORD*) &ct)[0]; | ||
362 | ((DWORD*) pc1)[1] = ((DWORD*) &ct)[1]; | ||
363 | pc1->Suffix=pc; (*--pps)->Successor=pc=pc1; | ||
364 | } while (pps != ps); | ||
365 | return pc; | ||
366 | } | ||
367 | static inline void UpdateModel(PPM_CONTEXT* MinContext) | ||
368 | { | ||
369 | PPM_CONTEXT::STATE* p=NULL; | ||
370 | PPM_CONTEXT* Successor, * FSuccessor, * pc, * pc1=MaxContext; | ||
371 | UINT ns1, ns, cf, sf, s0, FFreq=FoundState->Freq; | ||
372 | BYTE Flag, sym, FSymbol=FoundState->Symbol; | ||
373 | FSuccessor=FoundState->Successor; pc=MinContext->Suffix; | ||
374 | if (FFreq < MAX_FREQ/4 && pc) { | ||
375 | if ( pc->NumStats ) { | ||
376 | if ((p=pc->Stats)->Symbol != FSymbol) { | ||
377 | do { sym=p[1].Symbol; p++; } while (sym != FSymbol); | ||
378 | if (p[0].Freq >= p[-1].Freq) { | ||
379 | SWAP(p[0],p[-1]); p--; | ||
380 | } | ||
381 | } | ||
382 | cf=2*(p->Freq < MAX_FREQ-9); | ||
383 | p->Freq += cf; pc->SummFreq += cf; | ||
384 | } else { p=&(pc->oneState()); p->Freq += (p->Freq < 32); } | ||
385 | } | ||
386 | if (!OrderFall && FSuccessor) { | ||
387 | FoundState->Successor=CreateSuccessors(TRUE,p,MinContext); | ||
388 | if ( !FoundState->Successor ) goto RESTART_MODEL; | ||
389 | MaxContext=FoundState->Successor; return; | ||
390 | } | ||
391 | *pText++ = FSymbol; Successor = (PPM_CONTEXT*) pText; | ||
392 | if (pText >= UnitsStart) goto RESTART_MODEL; | ||
393 | if ( FSuccessor ) { | ||
394 | if ((BYTE*) FSuccessor < UnitsStart) | ||
395 | FSuccessor=CreateSuccessors(FALSE,p,MinContext); | ||
396 | } else | ||
397 | FSuccessor=ReduceOrder(p,MinContext); | ||
398 | if ( !FSuccessor ) goto RESTART_MODEL; | ||
399 | if ( !--OrderFall ) { | ||
400 | Successor=FSuccessor; pText -= (MaxContext != MinContext); | ||
401 | } else if (MRMethod > MRM_FREEZE) { | ||
402 | Successor=FSuccessor; pText=HeapStart; | ||
403 | OrderFall=0; | ||
404 | } | ||
405 | s0=MinContext->SummFreq-(ns=MinContext->NumStats)-FFreq; | ||
406 | for (Flag=0x08*(FSymbol >= 0x40);pc1 != MinContext;pc1=pc1->Suffix) { | ||
407 | if ((ns1=pc1->NumStats) != 0) { | ||
408 | if ((ns1 & 1) != 0) { | ||
409 | p=(PPM_CONTEXT::STATE*) ExpandUnits(pc1->Stats,(ns1+1) >> 1); | ||
410 | if ( !p ) goto RESTART_MODEL; | ||
411 | pc1->Stats=p; | ||
412 | } | ||
413 | pc1->SummFreq += (3*ns1+1 < ns); | ||
414 | } else { | ||
415 | p=(PPM_CONTEXT::STATE*) AllocUnits(1); | ||
416 | if ( !p ) goto RESTART_MODEL; | ||
417 | StateCpy(*p,pc1->oneState()); pc1->Stats=p; | ||
418 | if (p->Freq < MAX_FREQ/4-1) p->Freq += p->Freq; | ||
419 | else p->Freq = MAX_FREQ-4; | ||
420 | pc1->SummFreq=p->Freq+InitEsc+(ns > 2); | ||
421 | } | ||
422 | cf=2*FFreq*(pc1->SummFreq+6); sf=s0+pc1->SummFreq; | ||
423 | if (cf < 6*sf) { | ||
424 | cf=1+(cf > sf)+(cf >= 4*sf); | ||
425 | pc1->SummFreq += 4; | ||
426 | } else { | ||
427 | cf=4+(cf > 9*sf)+(cf > 12*sf)+(cf > 15*sf); | ||
428 | pc1->SummFreq += cf; | ||
429 | } | ||
430 | p=pc1->Stats+(++pc1->NumStats); p->Successor=Successor; | ||
431 | p->Symbol = FSymbol; p->Freq = cf; | ||
432 | pc1->Flags |= Flag; | ||
433 | } | ||
434 | MaxContext=FSuccessor; return; | ||
435 | RESTART_MODEL: | ||
436 | RestoreModelRare(pc1,MinContext,FSuccessor); | ||
437 | } | ||
438 | // Tabulated escapes for exponential symbol distribution | ||
439 | static const BYTE ExpEscape[16]={ 25,14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 }; | ||
440 | #define GET_MEAN(SUMM,SHIFT,ROUND) ((SUMM+(1 << (SHIFT-ROUND))) >> (SHIFT)) | ||
441 | inline void PPM_CONTEXT::encodeBinSymbol(int symbol) | ||
442 | { | ||
443 | BYTE indx=NS2BSIndx[Suffix->NumStats]+PrevSuccess+Flags; | ||
444 | STATE& rs=oneState(); | ||
445 | WORD& bs=BinSumm[QTable[rs.Freq-1]][indx+((RunLength >> 26) & 0x20)]; | ||
446 | if (rs.Symbol == symbol) { | ||
447 | FoundState=&rs; rs.Freq += (rs.Freq < 196); | ||
448 | SubRange.LowCount=0; SubRange.HighCount=bs; | ||
449 | bs += INTERVAL-GET_MEAN(bs,PERIOD_BITS,2); | ||
450 | PrevSuccess=1; RunLength++; | ||
451 | } else { | ||
452 | SubRange.LowCount=bs; bs -= GET_MEAN(bs,PERIOD_BITS,2); | ||
453 | SubRange.HighCount=BIN_SCALE; InitEsc=ExpEscape[bs >> 10]; | ||
454 | CharMask[rs.Symbol]=EscCount; | ||
455 | NumMasked=PrevSuccess=0; FoundState=NULL; | ||
456 | } | ||
457 | } | ||
458 | inline void PPM_CONTEXT::decodeBinSymbol() | ||
459 | { | ||
460 | BYTE indx=NS2BSIndx[Suffix->NumStats]+PrevSuccess+Flags; | ||
461 | STATE& rs=oneState(); | ||
462 | WORD& bs=BinSumm[QTable[rs.Freq-1]][indx+((RunLength >> 26) & 0x20)]; | ||
463 | if (ariGetCurrentShiftCount(TOT_BITS) < bs) { | ||
464 | FoundState=&rs; rs.Freq += (rs.Freq < 196); | ||
465 | SubRange.LowCount=0; SubRange.HighCount=bs; | ||
466 | bs += INTERVAL-GET_MEAN(bs,PERIOD_BITS,2); | ||
467 | PrevSuccess=1; RunLength++; | ||
468 | } else { | ||
469 | SubRange.LowCount=bs; bs -= GET_MEAN(bs,PERIOD_BITS,2); | ||
470 | SubRange.HighCount=BIN_SCALE; InitEsc=ExpEscape[bs >> 10]; | ||
471 | CharMask[rs.Symbol]=EscCount; | ||
472 | NumMasked=PrevSuccess=0; FoundState=NULL; | ||
473 | } | ||
474 | } | ||
475 | inline void PPM_CONTEXT::update1(STATE* p) | ||
476 | { | ||
477 | (FoundState=p)->Freq += 4; SummFreq += 4; | ||
478 | if (p[0].Freq > p[-1].Freq) { | ||
479 | SWAP(p[0],p[-1]); FoundState=--p; | ||
480 | if (p->Freq > MAX_FREQ) rescale(); | ||
481 | } | ||
482 | } | ||
483 | inline void PPM_CONTEXT::encodeSymbol1(int symbol) | ||
484 | { | ||
485 | UINT LoCnt, i=Stats->Symbol; | ||
486 | STATE* p=Stats; SubRange.scale=SummFreq; | ||
487 | if (i == symbol) { | ||
488 | PrevSuccess=(2*(SubRange.HighCount=p->Freq) >= SubRange.scale); | ||
489 | (FoundState=p)->Freq += 4; SummFreq += 4; | ||
490 | RunLength += PrevSuccess; | ||
491 | if (p->Freq > MAX_FREQ) rescale(); | ||
492 | SubRange.LowCount=0; return; | ||
493 | } | ||
494 | LoCnt=p->Freq; | ||
495 | i=NumStats; PrevSuccess=0; | ||
496 | while ((++p)->Symbol != symbol) { | ||
497 | LoCnt += p->Freq; | ||
498 | if (--i == 0) { | ||
499 | if ( Suffix ) PrefetchData(Suffix); | ||
500 | SubRange.LowCount=LoCnt; CharMask[p->Symbol]=EscCount; | ||
501 | i=NumMasked=NumStats; FoundState=NULL; | ||
502 | do { CharMask[(--p)->Symbol]=EscCount; } while ( --i ); | ||
503 | SubRange.HighCount=SubRange.scale; | ||
504 | return; | ||
505 | } | ||
506 | } | ||
507 | SubRange.HighCount=(SubRange.LowCount=LoCnt)+p->Freq; | ||
508 | update1(p); | ||
509 | } | ||
510 | inline void PPM_CONTEXT::decodeSymbol1() | ||
511 | { | ||
512 | UINT i, count, HiCnt=Stats->Freq; | ||
513 | STATE* p=Stats; SubRange.scale=SummFreq; | ||
514 | if ((count=ariGetCurrentCount()) < HiCnt) { | ||
515 | PrevSuccess=(2*(SubRange.HighCount=HiCnt) >= SubRange.scale); | ||
516 | (FoundState=p)->Freq=(HiCnt += 4); SummFreq += 4; | ||
517 | RunLength += PrevSuccess; | ||
518 | if (HiCnt > MAX_FREQ) rescale(); | ||
519 | SubRange.LowCount=0; return; | ||
520 | } | ||
521 | i=NumStats; PrevSuccess=0; | ||
522 | while ((HiCnt += (++p)->Freq) <= count) | ||
523 | if (--i == 0) { | ||
524 | if ( Suffix ) PrefetchData(Suffix); | ||
525 | SubRange.LowCount=HiCnt; CharMask[p->Symbol]=EscCount; | ||
526 | i=NumMasked=NumStats; FoundState=NULL; | ||
527 | do { CharMask[(--p)->Symbol]=EscCount; } while ( --i ); | ||
528 | SubRange.HighCount=SubRange.scale; | ||
529 | return; | ||
530 | } | ||
531 | SubRange.LowCount=(SubRange.HighCount=HiCnt)-p->Freq; | ||
532 | update1(p); | ||
533 | } | ||
534 | inline void PPM_CONTEXT::update2(STATE* p) | ||
535 | { | ||
536 | (FoundState=p)->Freq += 4; SummFreq += 4; | ||
537 | if (p->Freq > MAX_FREQ) rescale(); | ||
538 | EscCount++; RunLength=InitRL; | ||
539 | } | ||
540 | inline SEE2_CONTEXT* PPM_CONTEXT::makeEscFreq2() | ||
541 | { | ||
542 | BYTE* pb=(BYTE*) Stats; UINT t=2*NumStats; | ||
543 | PrefetchData(pb); PrefetchData(pb+t); | ||
544 | PrefetchData(pb += 2*t); PrefetchData(pb+t); | ||
545 | SEE2_CONTEXT* psee2c; | ||
546 | if (NumStats != 0xFF) { | ||
547 | t=Suffix->NumStats; | ||
548 | psee2c=SEE2Cont[QTable[NumStats+2]-3]+(SummFreq > 11*(NumStats+1)); | ||
549 | psee2c += 2*(2*NumStats < t+NumMasked)+Flags; | ||
550 | SubRange.scale=psee2c->getMean(); | ||
551 | } else { | ||
552 | psee2c=&DummySEE2Cont; SubRange.scale=1; | ||
553 | } | ||
554 | return psee2c; | ||
555 | } | ||
556 | inline void PPM_CONTEXT::encodeSymbol2(int symbol) | ||
557 | { | ||
558 | SEE2_CONTEXT* psee2c=makeEscFreq2(); | ||
559 | UINT Sym, LoCnt=0, i=NumStats-NumMasked; | ||
560 | STATE* p1, * p=Stats-1; | ||
561 | do { | ||
562 | do { Sym=p[1].Symbol; p++; } while (CharMask[Sym] == EscCount); | ||
563 | CharMask[Sym]=EscCount; | ||
564 | if (Sym == symbol) goto SYMBOL_FOUND; | ||
565 | LoCnt += p->Freq; | ||
566 | } while ( --i ); | ||
567 | SubRange.HighCount=(SubRange.scale += (SubRange.LowCount=LoCnt)); | ||
568 | psee2c->Summ += SubRange.scale; NumMasked = NumStats; | ||
569 | return; | ||
570 | SYMBOL_FOUND: | ||
571 | SubRange.LowCount=LoCnt; SubRange.HighCount=(LoCnt+=p->Freq); | ||
572 | for (p1=p; --i ; ) { | ||
573 | do { Sym=p1[1].Symbol; p1++; } while (CharMask[Sym] == EscCount); | ||
574 | LoCnt += p1->Freq; | ||
575 | } | ||
576 | SubRange.scale += LoCnt; | ||
577 | psee2c->update(); update2(p); | ||
578 | } | ||
579 | inline void PPM_CONTEXT::decodeSymbol2() | ||
580 | { | ||
581 | SEE2_CONTEXT* psee2c=makeEscFreq2(); | ||
582 | UINT Sym, count, HiCnt=0, i=NumStats-NumMasked; | ||
583 | STATE* ps[256], ** pps=ps, * p=Stats-1; | ||
584 | do { | ||
585 | do { Sym=p[1].Symbol; p++; } while (CharMask[Sym] == EscCount); | ||
586 | HiCnt += p->Freq; *pps++ = p; | ||
587 | } while ( --i ); | ||
588 | SubRange.scale += HiCnt; count=ariGetCurrentCount(); | ||
589 | p=*(pps=ps); | ||
590 | if (count < HiCnt) { | ||
591 | HiCnt=0; | ||
592 | while ((HiCnt += p->Freq) <= count) p=*++pps; | ||
593 | SubRange.LowCount = (SubRange.HighCount=HiCnt)-p->Freq; | ||
594 | psee2c->update(); update2(p); | ||
595 | } else { | ||
596 | SubRange.LowCount=HiCnt; SubRange.HighCount=SubRange.scale; | ||
597 | i=NumStats-NumMasked; NumMasked = NumStats; | ||
598 | do { CharMask[(*pps)->Symbol]=EscCount; pps++; } while ( --i ); | ||
599 | psee2c->Summ += SubRange.scale; | ||
600 | } | ||
601 | } | ||
602 | inline void ClearMask(CInfo* EncodedFile, CInfo* DecodedFile) | ||
603 | { | ||
604 | EscCount=1; memset(CharMask,0,sizeof(CharMask)); | ||
605 | // if (++PrintCount == 0) PrintInfo(DecodedFile,EncodedFile); | ||
606 | } | ||
607 | void _STDCALL EncodeFile(CSink* EncodedFile, CSource* DecodedFile, | ||
608 | int MaxOrder,MR_METHOD MRMethod) | ||
609 | { | ||
610 | ariInitEncoder(); StartModelRare(MaxOrder,MRMethod); | ||
611 | for (PPM_CONTEXT* MinContext; ; ) { | ||
612 | BYTE ns=(MinContext=MaxContext)->NumStats; | ||
613 | int c = _PPMD_E_GETC(DecodedFile); | ||
614 | if ( ns ) { | ||
615 | MinContext->encodeSymbol1(c); ariEncodeSymbol(); | ||
616 | } else { | ||
617 | MinContext->encodeBinSymbol(c); ariShiftEncodeSymbol(TOT_BITS); | ||
618 | } | ||
619 | while ( !FoundState ) { | ||
620 | ARI_ENC_NORMALIZE(EncodedFile); | ||
621 | do { | ||
622 | OrderFall++; MinContext=MinContext->Suffix; | ||
623 | if ( !MinContext ) goto STOP_ENCODING; | ||
624 | } while (MinContext->NumStats == NumMasked); | ||
625 | MinContext->encodeSymbol2(c); ariEncodeSymbol(); | ||
626 | } | ||
627 | if (!OrderFall && (BYTE*) FoundState->Successor >= UnitsStart) | ||
628 | PrefetchData(MaxContext=FoundState->Successor); | ||
629 | else { | ||
630 | UpdateModel(MinContext); PrefetchData(MaxContext); | ||
631 | if (EscCount == 0) ClearMask(EncodedFile,DecodedFile); | ||
632 | } | ||
633 | ARI_ENC_NORMALIZE(EncodedFile); | ||
634 | } | ||
635 | STOP_ENCODING: | ||
636 | ARI_FLUSH_ENCODER(EncodedFile); //PrintInfo(DecodedFile,EncodedFile); | ||
637 | } | ||
638 | void _STDCALL DecodeFile(CSink* DecodedFile, CSource* EncodedFile, | ||
639 | int MaxOrder,MR_METHOD MRMethod) | ||
640 | { | ||
641 | ARI_INIT_DECODER(EncodedFile); StartModelRare(MaxOrder,MRMethod); | ||
642 | PPM_CONTEXT* MinContext=MaxContext; | ||
643 | for (BYTE ns=MinContext->NumStats; ; ) { | ||
644 | ( ns )?(MinContext->decodeSymbol1()):(MinContext->decodeBinSymbol()); | ||
645 | ariRemoveSubrange(); | ||
646 | while ( !FoundState ) { | ||
647 | ARI_DEC_NORMALIZE(EncodedFile); | ||
648 | do { | ||
649 | OrderFall++; MinContext=MinContext->Suffix; | ||
650 | if ( !MinContext ) goto STOP_DECODING; | ||
651 | } while (MinContext->NumStats == NumMasked); | ||
652 | MinContext->decodeSymbol2(); ariRemoveSubrange(); | ||
653 | } | ||
654 | _PPMD_D_PUTC(FoundState->Symbol,DecodedFile); | ||
655 | if (!OrderFall && (BYTE*) FoundState->Successor >= UnitsStart) | ||
656 | PrefetchData(MaxContext=FoundState->Successor); | ||
657 | else { | ||
658 | UpdateModel(MinContext); PrefetchData(MaxContext); | ||
659 | if (EscCount == 0) ClearMask(EncodedFile,DecodedFile); | ||
660 | } | ||
661 | ns=(MinContext=MaxContext)->NumStats; | ||
662 | ARI_DEC_NORMALIZE(EncodedFile); | ||
663 | } | ||
664 | STOP_DECODING: | ||
665 | // PrintInfo(DecodedFile,EncodedFile); | ||
666 | return; | ||
667 | } | ||
668 | |||
669 | |||
670 | |||
671 | #include "PPMd.h" | ||
672 | #include "CSource.h" | ||
673 | |||
674 | size_t UnPPM(bool extra, unsigned char* readbuffer, size_t reclen, unsigned char* buffer, size_t buffersize) | ||
675 | { | ||
676 | unsigned short order, mem, offset = 1; | ||
677 | int type = 0; | ||
678 | if (extra) | ||
679 | { | ||
680 | order = readbuffer[1]; | ||
681 | mem = readbuffer[0]; | ||
682 | type = order >> 6; | ||
683 | order = (order & 63) + 2; | ||
684 | offset = 2; | ||
685 | } | ||
686 | else | ||
687 | { | ||
688 | order = readbuffer[0]; | ||
689 | mem = order >> 4; | ||
690 | order = (order & 15) + 2; | ||
691 | } | ||
692 | mem++; | ||
693 | // qDebug("Mem:%u Order:%u Type:%u\n", mem, order, type); | ||
694 | StartSubAllocator(mem); | ||
695 | CMemSink sink(buffer, buffersize); | ||
696 | CMemSource source(readbuffer+offset, reclen-offset); | ||
697 | DecodeFile(&sink,&source,order,(MR_METHOD)type); | ||
698 | StopSubAllocator(); | ||
699 | return sink.size(); | ||
700 | } | ||
701 | |||
702 | |||
703 | extern "C" | ||
704 | { | ||
705 | |||
706 | size_t PluckerDecompress3(unsigned char* a, size_t b, unsigned char* c, size_t d) | ||
707 | { | ||
708 | return UnPPM(false, a, b, c, d); | ||
709 | } | ||
710 | |||
711 | size_t PluckerDecompress4(unsigned char* a, size_t b, unsigned char* c, size_t d) | ||
712 | { | ||
713 | return UnPPM(true, a, b, c, d); | ||
714 | } | ||
715 | |||
716 | size_t RebDecompress(unsigned char* a, size_t b, unsigned char* c, size_t d) | ||
717 | { | ||
718 | return UnPPM(true, a, b, c, d); | ||
719 | } | ||
720 | |||
721 | } | ||
diff --git a/noncore/apps/opie-reader/Model.h b/noncore/apps/opie-reader/Model.h new file mode 100644 index 0000000..f3f5274 --- a/dev/null +++ b/noncore/apps/opie-reader/Model.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef __MODEL_H | ||
2 | #define __MODEL_H | ||
3 | |||
4 | extern "C" | ||
5 | { | ||
6 | size_t PluckerDecompress3(unsigned char* a, size_t b, unsigned char* c, size_t d); | ||
7 | size_t PluckerDecompress4(unsigned char* a, size_t b, unsigned char* c, size_t d); | ||
8 | size_t RebDecompress(unsigned char* a, size_t b, unsigned char* c, size_t d); | ||
9 | } | ||
10 | |||
11 | #endif | ||
diff --git a/noncore/apps/opie-reader/Palm2QImage.cpp b/noncore/apps/opie-reader/Palm2QImage.cpp index c6907eb..361755f 100644 --- a/noncore/apps/opie-reader/Palm2QImage.cpp +++ b/noncore/apps/opie-reader/Palm2QImage.cpp | |||
@@ -1,298 +1,299 @@ | |||
1 | /* -*- mode: c; indent-tabs-mode: nil; -*- */ | 1 | /* -*- mode: c; indent-tabs-mode: nil; -*- */ |
2 | |||
2 | #include <stdio.h> | 3 | #include <stdio.h> |
3 | #include <stdlib.h> | 4 | #include <stdlib.h> |
4 | #include <string.h> | 5 | #include <string.h> |
5 | #ifndef _WINDOWS | 6 | #ifndef _WINDOWS |
6 | #include <unistd.h> /* for link */ | 7 | #include <unistd.h> /* for link */ |
7 | #endif | 8 | #endif |
8 | #include <sys/types.h> | 9 | #include <sys/types.h> |
9 | #include <sys/stat.h> | 10 | #include <sys/stat.h> |
10 | #include <stdarg.h> | 11 | #include <stdarg.h> |
11 | 12 | ||
12 | #include <qimage.h> | 13 | #include <qimage.h> |
13 | 14 | ||
14 | /***********************************************************************/ | 15 | /***********************************************************************/ |
15 | /***********************************************************************/ | 16 | /***********************************************************************/ |
16 | /***** *****/ | 17 | /***** *****/ |
17 | /***** Code to decode the Palm image format to JPEG *****/ | 18 | /***** Code to decode the Palm image format to JPEG *****/ |
18 | /***** *****/ | 19 | /***** *****/ |
19 | /***********************************************************************/ | 20 | /***********************************************************************/ |
20 | /***********************************************************************/ | 21 | /***********************************************************************/ |
21 | 22 | ||
22 | #define READ_BIGENDIAN_SHORT(p) (((p)[0] << 8)|((p)[1])) | 23 | #define READ_BIGENDIAN_SHORT(p) (((p)[0] << 8)|((p)[1])) |
23 | #define READ_BIGENDIAN_LONG(p) (((p)[0] << 24)|((p)[1] << 16)|((p)[2] << 8)|((p)[3])) | 24 | #define READ_BIGENDIAN_LONG(p) (((p)[0] << 24)|((p)[1] << 16)|((p)[2] << 8)|((p)[3])) |
24 | 25 | ||
25 | #define PALM_IS_COMPRESSED_FLAG 0x8000 | 26 | #define PALM_IS_COMPRESSED_FLAG 0x8000 |
26 | #define PALM_HAS_COLORMAP_FLAG 0x4000 | 27 | #define PALM_HAS_COLORMAP_FLAG 0x4000 |
27 | #define PALM_HAS_TRANSPARENCY_FLAG 0x2000 | 28 | #define PALM_HAS_TRANSPARENCY_FLAG 0x2000 |
28 | #define PALM_DIRECT_COLOR_FLAG 0x0400 | 29 | #define PALM_DIRECT_COLOR_FLAG 0x0400 |
29 | #define PALM_4_BYTE_FIELD_FLAG 0x0200 | 30 | #define PALM_4_BYTE_FIELD_FLAG 0x0200 |
30 | 31 | ||
31 | #define PALM_COMPRESSION_SCANLINE 0x00 | 32 | #define PALM_COMPRESSION_SCANLINE 0x00 |
32 | #define PALM_COMPRESSION_RLE 0x01 | 33 | #define PALM_COMPRESSION_RLE 0x01 |
33 | #define PALM_COMPRESSION_PACKBITS 0x02 | 34 | #define PALM_COMPRESSION_PACKBITS 0x02 |
34 | #define PALM_COMPRESSION_NONE 0xFF | 35 | #define PALM_COMPRESSION_NONE 0xFF |
35 | 36 | ||
36 | #define PALM_COLORMAP_SIZE 232 | 37 | #define PALM_COLORMAP_SIZE 232 |
37 | 38 | ||
38 | typedef struct { | 39 | typedef struct { |
39 | unsigned char red; | 40 | unsigned char red; |
40 | unsigned char green; | 41 | unsigned char green; |
41 | unsigned char blue; | 42 | unsigned char blue; |
42 | } ColorMapEntry; | 43 | } ColorMapEntry; |
43 | 44 | ||
44 | static ColorMapEntry Palm8BitColormap[] = { | 45 | static ColorMapEntry Palm8BitColormap[] = { |
45 | { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 }, | 46 | { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 }, |
46 | { 255, 51, 255 }, { 255, 0, 255 }, { 255, 255, 204 }, { 255, 204, 204 }, | 47 | { 255, 51, 255 }, { 255, 0, 255 }, { 255, 255, 204 }, { 255, 204, 204 }, |
47 | { 255, 153, 204 }, { 255, 102, 204 }, { 255, 51, 204 }, { 255, 0, 204 }, | 48 | { 255, 153, 204 }, { 255, 102, 204 }, { 255, 51, 204 }, { 255, 0, 204 }, |
48 | { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 }, | 49 | { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 }, |
49 | { 255, 51, 153 }, { 255, 0, 153 }, { 204, 255, 255 }, { 204, 204, 255 }, | 50 | { 255, 51, 153 }, { 255, 0, 153 }, { 204, 255, 255 }, { 204, 204, 255 }, |
50 | { 204, 153, 255 }, { 204, 102, 255 }, { 204, 51, 255 }, { 204, 0, 255 }, | 51 | { 204, 153, 255 }, { 204, 102, 255 }, { 204, 51, 255 }, { 204, 0, 255 }, |
51 | { 204, 255, 204 }, { 204, 204, 204 }, { 204, 153, 204 }, { 204, 102, 204 }, | 52 | { 204, 255, 204 }, { 204, 204, 204 }, { 204, 153, 204 }, { 204, 102, 204 }, |
52 | { 204, 51, 204 }, { 204, 0, 204 }, { 204, 255, 153 }, { 204, 204, 153 }, | 53 | { 204, 51, 204 }, { 204, 0, 204 }, { 204, 255, 153 }, { 204, 204, 153 }, |
53 | { 204, 153, 153 }, { 204, 102, 153 }, { 204, 51, 153 }, { 204, 0, 153 }, | 54 | { 204, 153, 153 }, { 204, 102, 153 }, { 204, 51, 153 }, { 204, 0, 153 }, |
54 | { 153, 255, 255 }, { 153, 204, 255 }, { 153, 153, 255 }, { 153, 102, 255 }, | 55 | { 153, 255, 255 }, { 153, 204, 255 }, { 153, 153, 255 }, { 153, 102, 255 }, |
55 | { 153, 51, 255 }, { 153, 0, 255 }, { 153, 255, 204 }, { 153, 204, 204 }, | 56 | { 153, 51, 255 }, { 153, 0, 255 }, { 153, 255, 204 }, { 153, 204, 204 }, |
56 | { 153, 153, 204 }, { 153, 102, 204 }, { 153, 51, 204 }, { 153, 0, 204 }, | 57 | { 153, 153, 204 }, { 153, 102, 204 }, { 153, 51, 204 }, { 153, 0, 204 }, |
57 | { 153, 255, 153 }, { 153, 204, 153 }, { 153, 153, 153 }, { 153, 102, 153 }, | 58 | { 153, 255, 153 }, { 153, 204, 153 }, { 153, 153, 153 }, { 153, 102, 153 }, |
58 | { 153, 51, 153 }, { 153, 0, 153 }, { 102, 255, 255 }, { 102, 204, 255 }, | 59 | { 153, 51, 153 }, { 153, 0, 153 }, { 102, 255, 255 }, { 102, 204, 255 }, |
59 | { 102, 153, 255 }, { 102, 102, 255 }, { 102, 51, 255 }, { 102, 0, 255 }, | 60 | { 102, 153, 255 }, { 102, 102, 255 }, { 102, 51, 255 }, { 102, 0, 255 }, |
60 | { 102, 255, 204 }, { 102, 204, 204 }, { 102, 153, 204 }, { 102, 102, 204 }, | 61 | { 102, 255, 204 }, { 102, 204, 204 }, { 102, 153, 204 }, { 102, 102, 204 }, |
61 | { 102, 51, 204 }, { 102, 0, 204 }, { 102, 255, 153 }, { 102, 204, 153 }, | 62 | { 102, 51, 204 }, { 102, 0, 204 }, { 102, 255, 153 }, { 102, 204, 153 }, |
62 | { 102, 153, 153 }, { 102, 102, 153 }, { 102, 51, 153 }, { 102, 0, 153 }, | 63 | { 102, 153, 153 }, { 102, 102, 153 }, { 102, 51, 153 }, { 102, 0, 153 }, |
63 | { 51, 255, 255 }, { 51, 204, 255 }, { 51, 153, 255 }, { 51, 102, 255 }, | 64 | { 51, 255, 255 }, { 51, 204, 255 }, { 51, 153, 255 }, { 51, 102, 255 }, |
64 | { 51, 51, 255 }, { 51, 0, 255 }, { 51, 255, 204 }, { 51, 204, 204 }, | 65 | { 51, 51, 255 }, { 51, 0, 255 }, { 51, 255, 204 }, { 51, 204, 204 }, |
65 | { 51, 153, 204 }, { 51, 102, 204 }, { 51, 51, 204 }, { 51, 0, 204 }, | 66 | { 51, 153, 204 }, { 51, 102, 204 }, { 51, 51, 204 }, { 51, 0, 204 }, |
66 | { 51, 255, 153 }, { 51, 204, 153 }, { 51, 153, 153 }, { 51, 102, 153 }, | 67 | { 51, 255, 153 }, { 51, 204, 153 }, { 51, 153, 153 }, { 51, 102, 153 }, |
67 | { 51, 51, 153 }, { 51, 0, 153 }, { 0, 255, 255 }, { 0, 204, 255 }, | 68 | { 51, 51, 153 }, { 51, 0, 153 }, { 0, 255, 255 }, { 0, 204, 255 }, |
68 | { 0, 153, 255 }, { 0, 102, 255 }, { 0, 51, 255 }, { 0, 0, 255 }, | 69 | { 0, 153, 255 }, { 0, 102, 255 }, { 0, 51, 255 }, { 0, 0, 255 }, |
69 | { 0, 255, 204 }, { 0, 204, 204 }, { 0, 153, 204 }, { 0, 102, 204 }, | 70 | { 0, 255, 204 }, { 0, 204, 204 }, { 0, 153, 204 }, { 0, 102, 204 }, |
70 | { 0, 51, 204 }, { 0, 0, 204 }, { 0, 255, 153 }, { 0, 204, 153 }, | 71 | { 0, 51, 204 }, { 0, 0, 204 }, { 0, 255, 153 }, { 0, 204, 153 }, |
71 | { 0, 153, 153 }, { 0, 102, 153 }, { 0, 51, 153 }, { 0, 0, 153 }, | 72 | { 0, 153, 153 }, { 0, 102, 153 }, { 0, 51, 153 }, { 0, 0, 153 }, |
72 | { 255, 255, 102 }, { 255, 204, 102 }, { 255, 153, 102 }, { 255, 102, 102 }, | 73 | { 255, 255, 102 }, { 255, 204, 102 }, { 255, 153, 102 }, { 255, 102, 102 }, |
73 | { 255, 51, 102 }, { 255, 0, 102 }, { 255, 255, 51 }, { 255, 204, 51 }, | 74 | { 255, 51, 102 }, { 255, 0, 102 }, { 255, 255, 51 }, { 255, 204, 51 }, |
74 | { 255, 153, 51 }, { 255, 102, 51 }, { 255, 51, 51 }, { 255, 0, 51 }, | 75 | { 255, 153, 51 }, { 255, 102, 51 }, { 255, 51, 51 }, { 255, 0, 51 }, |
75 | { 255, 255, 0 }, { 255, 204, 0 }, { 255, 153, 0 }, { 255, 102, 0 }, | 76 | { 255, 255, 0 }, { 255, 204, 0 }, { 255, 153, 0 }, { 255, 102, 0 }, |
76 | { 255, 51, 0 }, { 255, 0, 0 }, { 204, 255, 102 }, { 204, 204, 102 }, | 77 | { 255, 51, 0 }, { 255, 0, 0 }, { 204, 255, 102 }, { 204, 204, 102 }, |
77 | { 204, 153, 102 }, { 204, 102, 102 }, { 204, 51, 102 }, { 204, 0, 102 }, | 78 | { 204, 153, 102 }, { 204, 102, 102 }, { 204, 51, 102 }, { 204, 0, 102 }, |
78 | { 204, 255, 51 }, { 204, 204, 51 }, { 204, 153, 51 }, { 204, 102, 51 }, | 79 | { 204, 255, 51 }, { 204, 204, 51 }, { 204, 153, 51 }, { 204, 102, 51 }, |
79 | { 204, 51, 51 }, { 204, 0, 51 }, { 204, 255, 0 }, { 204, 204, 0 }, | 80 | { 204, 51, 51 }, { 204, 0, 51 }, { 204, 255, 0 }, { 204, 204, 0 }, |
80 | { 204, 153, 0 }, { 204, 102, 0 }, { 204, 51, 0 }, { 204, 0, 0 }, | 81 | { 204, 153, 0 }, { 204, 102, 0 }, { 204, 51, 0 }, { 204, 0, 0 }, |
81 | { 153, 255, 102 }, { 153, 204, 102 }, { 153, 153, 102 }, { 153, 102, 102 }, | 82 | { 153, 255, 102 }, { 153, 204, 102 }, { 153, 153, 102 }, { 153, 102, 102 }, |
82 | { 153, 51, 102 }, { 153, 0, 102 }, { 153, 255, 51 }, { 153, 204, 51 }, | 83 | { 153, 51, 102 }, { 153, 0, 102 }, { 153, 255, 51 }, { 153, 204, 51 }, |
83 | { 153, 153, 51 }, { 153, 102, 51 }, { 153, 51, 51 }, { 153, 0, 51 }, | 84 | { 153, 153, 51 }, { 153, 102, 51 }, { 153, 51, 51 }, { 153, 0, 51 }, |
84 | { 153, 255, 0 }, { 153, 204, 0 }, { 153, 153, 0 }, { 153, 102, 0 }, | 85 | { 153, 255, 0 }, { 153, 204, 0 }, { 153, 153, 0 }, { 153, 102, 0 }, |
85 | { 153, 51, 0 }, { 153, 0, 0 }, { 102, 255, 102 }, { 102, 204, 102 }, | 86 | { 153, 51, 0 }, { 153, 0, 0 }, { 102, 255, 102 }, { 102, 204, 102 }, |
86 | { 102, 153, 102 }, { 102, 102, 102 }, { 102, 51, 102 }, { 102, 0, 102 }, | 87 | { 102, 153, 102 }, { 102, 102, 102 }, { 102, 51, 102 }, { 102, 0, 102 }, |
87 | { 102, 255, 51 }, { 102, 204, 51 }, { 102, 153, 51 }, { 102, 102, 51 }, | 88 | { 102, 255, 51 }, { 102, 204, 51 }, { 102, 153, 51 }, { 102, 102, 51 }, |
88 | { 102, 51, 51 }, { 102, 0, 51 }, { 102, 255, 0 }, { 102, 204, 0 }, | 89 | { 102, 51, 51 }, { 102, 0, 51 }, { 102, 255, 0 }, { 102, 204, 0 }, |
89 | { 102, 153, 0 }, { 102, 102, 0 }, { 102, 51, 0 }, { 102, 0, 0 }, | 90 | { 102, 153, 0 }, { 102, 102, 0 }, { 102, 51, 0 }, { 102, 0, 0 }, |
90 | { 51, 255, 102 }, { 51, 204, 102 }, { 51, 153, 102 }, { 51, 102, 102 }, | 91 | { 51, 255, 102 }, { 51, 204, 102 }, { 51, 153, 102 }, { 51, 102, 102 }, |
91 | { 51, 51, 102 }, { 51, 0, 102 }, { 51, 255, 51 }, { 51, 204, 51 }, | 92 | { 51, 51, 102 }, { 51, 0, 102 }, { 51, 255, 51 }, { 51, 204, 51 }, |
92 | { 51, 153, 51 }, { 51, 102, 51 }, { 51, 51, 51 }, { 51, 0, 51 }, | 93 | { 51, 153, 51 }, { 51, 102, 51 }, { 51, 51, 51 }, { 51, 0, 51 }, |
93 | { 51, 255, 0 }, { 51, 204, 0 }, { 51, 153, 0 }, { 51, 102, 0 }, | 94 | { 51, 255, 0 }, { 51, 204, 0 }, { 51, 153, 0 }, { 51, 102, 0 }, |
94 | { 51, 51, 0 }, { 51, 0, 0 }, { 0, 255, 102 }, { 0, 204, 102 }, | 95 | { 51, 51, 0 }, { 51, 0, 0 }, { 0, 255, 102 }, { 0, 204, 102 }, |
95 | { 0, 153, 102 }, { 0, 102, 102 }, { 0, 51, 102 }, { 0, 0, 102 }, | 96 | { 0, 153, 102 }, { 0, 102, 102 }, { 0, 51, 102 }, { 0, 0, 102 }, |
96 | { 0, 255, 51 }, { 0, 204, 51 }, { 0, 153, 51 }, { 0, 102, 51 }, | 97 | { 0, 255, 51 }, { 0, 204, 51 }, { 0, 153, 51 }, { 0, 102, 51 }, |
97 | { 0, 51, 51 }, { 0, 0, 51 }, { 0, 255, 0 }, { 0, 204, 0 }, | 98 | { 0, 51, 51 }, { 0, 0, 51 }, { 0, 255, 0 }, { 0, 204, 0 }, |
98 | { 0, 153, 0 }, { 0, 102, 0 }, { 0, 51, 0 }, { 17, 17, 17 }, | 99 | { 0, 153, 0 }, { 0, 102, 0 }, { 0, 51, 0 }, { 17, 17, 17 }, |
99 | { 34, 34, 34 }, { 68, 68, 68 }, { 85, 85, 85 }, { 119, 119, 119 }, | 100 | { 34, 34, 34 }, { 68, 68, 68 }, { 85, 85, 85 }, { 119, 119, 119 }, |
100 | { 136, 136, 136 }, { 170, 170, 170 }, { 187, 187, 187 }, { 221, 221, 221 }, | 101 | { 136, 136, 136 }, { 170, 170, 170 }, { 187, 187, 187 }, { 221, 221, 221 }, |
101 | { 238, 238, 238 }, { 192, 192, 192 }, { 128, 0, 0 }, { 128, 0, 128 }, | 102 | { 238, 238, 238 }, { 192, 192, 192 }, { 128, 0, 0 }, { 128, 0, 128 }, |
102 | { 0, 128, 0 }, { 0, 128, 128 }, { 0, 0, 0 }, { 0, 0, 0 }, | 103 | { 0, 128, 0 }, { 0, 128, 128 }, { 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 }, |
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 }, |
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 }, |
106 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 107 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
107 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 108 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
108 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }}; | 109 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }}; |
109 | 110 | ||
110 | static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }}; | 111 | static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }}; |
111 | 112 | ||
112 | static ColorMapEntry Palm2BitColormap[] = { | 113 | static ColorMapEntry Palm2BitColormap[] = { |
113 | { 255, 255, 255 }, { 192, 192, 192 }, { 128, 128, 128 }, { 0, 0, 0 }}; | 114 | { 255, 255, 255 }, { 192, 192, 192 }, { 128, 128, 128 }, { 0, 0, 0 }}; |
114 | 115 | ||
115 | static ColorMapEntry Palm4BitColormap[] = { | 116 | static ColorMapEntry Palm4BitColormap[] = { |
116 | { 255, 255, 255 }, { 238, 238, 238 }, { 221, 221, 221 }, { 204, 204, 204 }, | 117 | { 255, 255, 255 }, { 238, 238, 238 }, { 221, 221, 221 }, { 204, 204, 204 }, |
117 | { 187, 187, 187 }, { 170, 170, 170 }, { 153, 153, 153 }, { 136, 136, 136 }, | 118 | { 187, 187, 187 }, { 170, 170, 170 }, { 153, 153, 153 }, { 136, 136, 136 }, |
118 | { 119, 119, 119 }, { 102, 102, 102 }, { 85, 85, 85 }, { 68, 68, 68 }, | 119 | { 119, 119, 119 }, { 102, 102, 102 }, { 85, 85, 85 }, { 68, 68, 68 }, |
119 | { 51, 51, 51 }, { 34, 34, 34 }, { 17, 17, 17 }, { 0, 0, 0 }}; | 120 | { 51, 51, 51 }, { 34, 34, 34 }, { 17, 17, 17 }, { 0, 0, 0 }}; |
120 | 121 | ||
121 | QImage* Palm2QImage | 122 | QImage* Palm2QImage |
122 | (unsigned char *image_bytes_in, int byte_count_in) | 123 | (unsigned char *image_bytes_in, int byte_count_in) |
123 | { | 124 | { |
124 | unsigned int width, height, bytes_per_row, flags, next_depth_offset; | 125 | unsigned int width, height, bytes_per_row, flags, next_depth_offset; |
125 | unsigned int bits_per_pixel, version, transparent_index, compression_type, i, j, inval, inbit, mask, incount; | 126 | unsigned int bits_per_pixel, version, transparent_index, compression_type, i, j, inval, inbit, mask, incount; |
126 | unsigned int palm_red_bits, palm_green_bits, palm_blue_bits; | 127 | unsigned int palm_red_bits, palm_green_bits, palm_blue_bits; |
127 | unsigned char *palm_ptr, *x_ptr, *imagedata, *inbyte, *rowbuf, *lastrow, | 128 | unsigned char *palm_ptr, *x_ptr, *imagedata, *inbyte, *rowbuf, *lastrow, |
128 | *imagedatastart, *palmimage; | 129 | *imagedatastart, *palmimage; |
129 | ColorMapEntry *colormap; | 130 | ColorMapEntry *colormap; |
130 | 131 | ||
131 | palmimage = image_bytes_in; | 132 | palmimage = image_bytes_in; |
132 | width = READ_BIGENDIAN_SHORT(palmimage + 0); | 133 | width = READ_BIGENDIAN_SHORT(palmimage + 0); |
133 | height = READ_BIGENDIAN_SHORT(palmimage + 2); | 134 | height = READ_BIGENDIAN_SHORT(palmimage + 2); |
134 | bytes_per_row = READ_BIGENDIAN_SHORT(palmimage + 4); | 135 | bytes_per_row = READ_BIGENDIAN_SHORT(palmimage + 4); |
135 | flags = READ_BIGENDIAN_SHORT(palmimage + 6); | 136 | flags = READ_BIGENDIAN_SHORT(palmimage + 6); |
136 | bits_per_pixel = palmimage[8]; | 137 | bits_per_pixel = palmimage[8]; |
137 | version = palmimage[9]; | 138 | version = palmimage[9]; |
138 | next_depth_offset = READ_BIGENDIAN_SHORT(palmimage + 10); | 139 | next_depth_offset = READ_BIGENDIAN_SHORT(palmimage + 10); |
139 | transparent_index = palmimage[12]; | 140 | transparent_index = palmimage[12]; |
140 | compression_type = palmimage[13]; | 141 | compression_type = palmimage[13]; |
141 | /* bytes 14 and 15 are reserved by Palm and always 0 */ | 142 | /* bytes 14 and 15 are reserved by Palm and always 0 */ |
142 | 143 | ||
143 | #if 0 | 144 | #if 0 |
144 | // qDebug ("Palm image is %dx%d, %d bpp, version %d, flags 0x%x, compression %d", width, height, bits_per_pixel, version, flags, compression_type); | 145 | // qDebug ("Palm image is %dx%d, %d bpp, version %d, flags 0x%x, compression %d", width, height, bits_per_pixel, version, flags, compression_type); |
145 | #endif | 146 | #endif |
146 | 147 | ||
147 | if (compression_type == PALM_COMPRESSION_PACKBITS) { | 148 | if (compression_type == PALM_COMPRESSION_PACKBITS) { |
148 | // qDebug ("Image uses packbits compression; not yet supported"); | 149 | // qDebug ("Image uses packbits compression; not yet supported"); |
149 | return NULL; | 150 | return NULL; |
150 | } else if ((compression_type != PALM_COMPRESSION_NONE) && | 151 | } else if ((compression_type != PALM_COMPRESSION_NONE) && |
151 | (compression_type != PALM_COMPRESSION_RLE) && | 152 | (compression_type != PALM_COMPRESSION_RLE) && |
152 | (compression_type != PALM_COMPRESSION_SCANLINE)) { | 153 | (compression_type != PALM_COMPRESSION_SCANLINE)) { |
153 | // qDebug ("Image uses unknown compression, code 0x%x", compression_type); | 154 | // qDebug ("Image uses unknown compression, code 0x%x", compression_type); |
154 | return NULL; | 155 | return NULL; |
155 | } | 156 | } |
156 | 157 | ||
157 | /* as of PalmOS 4.0, there are 6 different kinds of Palm pixmaps: | 158 | /* as of PalmOS 4.0, there are 6 different kinds of Palm pixmaps: |
158 | 159 | ||
159 | 1, 2, or 4 bit grayscale | 160 | 1, 2, or 4 bit grayscale |
160 | 8-bit StaticColor using the Palm standard colormap | 161 | 8-bit StaticColor using the Palm standard colormap |
161 | 8-bit PseudoColor using a user-specified colormap | 162 | 8-bit PseudoColor using a user-specified colormap |
162 | 16-bit DirectColor using 5 bits for red, 6 for green, and 5 for blue | 163 | 16-bit DirectColor using 5 bits for red, 6 for green, and 5 for blue |
163 | 164 | ||
164 | Each of these can be compressed with one of four compression schemes, | 165 | Each of these can be compressed with one of four compression schemes, |
165 | "RLE", "Scanline", "PackBits", or none. | 166 | "RLE", "Scanline", "PackBits", or none. |
166 | 167 | ||
167 | We begin by constructing the colormap. | 168 | We begin by constructing the colormap. |
168 | */ | 169 | */ |
169 | 170 | ||
170 | if (flags & PALM_HAS_COLORMAP_FLAG) { | 171 | if (flags & PALM_HAS_COLORMAP_FLAG) { |
171 | // qDebug("Palm images with custom colormaps are not currently supported.\n"); | 172 | // qDebug("Palm images with custom colormaps are not currently supported.\n"); |
172 | return NULL; | 173 | return NULL; |
173 | } else if (bits_per_pixel == 1) { | 174 | } else if (bits_per_pixel == 1) { |
174 | colormap = Palm1BitColormap; | 175 | colormap = Palm1BitColormap; |
175 | imagedatastart = palmimage + 16; | 176 | imagedatastart = palmimage + 16; |
176 | } else if (bits_per_pixel == 2) { | 177 | } else if (bits_per_pixel == 2) { |
177 | colormap = Palm2BitColormap; | 178 | colormap = Palm2BitColormap; |
178 | imagedatastart = palmimage + 16; | 179 | imagedatastart = palmimage + 16; |
179 | } else if (bits_per_pixel == 4) { | 180 | } else if (bits_per_pixel == 4) { |
180 | colormap = Palm4BitColormap; | 181 | colormap = Palm4BitColormap; |
181 | imagedatastart = palmimage + 16; | 182 | imagedatastart = palmimage + 16; |
182 | } else if (bits_per_pixel == 8) { | 183 | } else if (bits_per_pixel == 8) { |
183 | colormap = Palm8BitColormap; | 184 | colormap = Palm8BitColormap; |
184 | imagedatastart = palmimage + 16; | 185 | imagedatastart = palmimage + 16; |
185 | } else if (bits_per_pixel == 16 && (flags & PALM_DIRECT_COLOR_FLAG)) { | 186 | } else if (bits_per_pixel == 16 && (flags & PALM_DIRECT_COLOR_FLAG)) { |
186 | colormap = NULL; | 187 | colormap = NULL; |
187 | palm_red_bits = palmimage[16]; | 188 | palm_red_bits = palmimage[16]; |
188 | palm_green_bits = palmimage[17]; | 189 | palm_green_bits = palmimage[17]; |
189 | palm_blue_bits = palmimage[18]; | 190 | palm_blue_bits = palmimage[18]; |
190 | // qDebug("Bits:%d, %d, %d", palm_red_bits, palm_green_bits, palm_blue_bits); | 191 | // qDebug("Bits:%d, %d, %d", palm_red_bits, palm_green_bits, palm_blue_bits); |
191 | if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) { | 192 | if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) { |
192 | // qDebug("Can't handle this format DirectColor image -- too wide in some color (%d:%d:%d)\n", palm_red_bits, palm_green_bits, palm_blue_bits); | 193 | // qDebug("Can't handle this format DirectColor image -- too wide in some color (%d:%d:%d)\n", palm_red_bits, palm_green_bits, palm_blue_bits); |
193 | return NULL; | 194 | return NULL; |
194 | } | 195 | } |
195 | if (bits_per_pixel > (8 * sizeof(unsigned long))) { | 196 | if (bits_per_pixel > (8 * sizeof(unsigned long))) { |
196 | // qDebug ("Can't handle this format DirectColor image -- too many bits per pixel (%d)\n", bits_per_pixel); | 197 | // qDebug ("Can't handle this format DirectColor image -- too many bits per pixel (%d)\n", bits_per_pixel); |
197 | return NULL; | 198 | return NULL; |
198 | } | 199 | } |
199 | imagedatastart = palmimage + 24; | 200 | imagedatastart = palmimage + 24; |
200 | } else { | 201 | } else { |
201 | // qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel); | 202 | // qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel); |
202 | return NULL; | 203 | return NULL; |
203 | } | 204 | } |
204 | 205 | ||
205 | #ifndef USEQPE | 206 | #ifndef USEQPE |
206 | QImage* qimage = new QImage(width, height, 32); | 207 | QImage* qimage = new QImage(width, height, 32); |
207 | #else | 208 | #else |
208 | QImage* qimage = new QImage(width, height, 16); | 209 | QImage* qimage = new QImage(width, height, 16); |
209 | #endif | 210 | #endif |
210 | 211 | ||
211 | /* row by row, uncompress the Palm image and copy it to the JPEG buffer */ | 212 | /* row by row, uncompress the Palm image and copy it to the JPEG buffer */ |
212 | rowbuf = new unsigned char[bytes_per_row * width]; | 213 | rowbuf = new unsigned char[bytes_per_row * width]; |
213 | lastrow = new unsigned char[bytes_per_row * width]; | 214 | lastrow = new unsigned char[bytes_per_row * width]; |
214 | 215 | ||
215 | for (i=0, palm_ptr = imagedatastart , x_ptr = imagedata; i < height; ++i) { | 216 | for (i=0, palm_ptr = imagedatastart , x_ptr = imagedata; i < height; ++i) { |
216 | // qDebug("inval:%x palm_ptr:%x x_ptr:%x bpr:%x", inval, palm_ptr, x_ptr, bytes_per_row); | 217 | // qDebug("inval:%x palm_ptr:%x x_ptr:%x bpr:%x", inval, palm_ptr, x_ptr, bytes_per_row); |
217 | 218 | ||
218 | /* first, uncompress the Palm image */ | 219 | /* first, uncompress the Palm image */ |
219 | if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_RLE)) { | 220 | if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_RLE)) { |
220 | for (j = 0; j < bytes_per_row; ) { | 221 | for (j = 0; j < bytes_per_row; ) { |
221 | incount = *palm_ptr++; | 222 | incount = *palm_ptr++; |
222 | inval = *palm_ptr++; | 223 | inval = *palm_ptr++; |
223 | memset(rowbuf + j, inval, incount); | 224 | memset(rowbuf + j, inval, incount); |
224 | j += incount; | 225 | j += incount; |
225 | } | 226 | } |
226 | } else if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_SCANLINE)) { | 227 | } else if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_SCANLINE)) { |
227 | for (j = 0; j < bytes_per_row; j += 8) { | 228 | for (j = 0; j < bytes_per_row; j += 8) { |
228 | incount = *palm_ptr++; | 229 | incount = *palm_ptr++; |
229 | inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8; | 230 | inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8; |
230 | for (inbit = 0; inbit < inval; inbit += 1) { | 231 | for (inbit = 0; inbit < inval; inbit += 1) { |
231 | if (incount & (1 << (7 - inbit))) | 232 | if (incount & (1 << (7 - inbit))) |
232 | rowbuf[j + inbit] = *palm_ptr++; | 233 | rowbuf[j + inbit] = *palm_ptr++; |
233 | else | 234 | else |
234 | rowbuf[j + inbit] = lastrow[j + inbit]; | 235 | rowbuf[j + inbit] = lastrow[j + inbit]; |
235 | } | 236 | } |
236 | } | 237 | } |
237 | memcpy (lastrow, rowbuf, bytes_per_row); | 238 | memcpy (lastrow, rowbuf, bytes_per_row); |
238 | } else if (((flags & PALM_IS_COMPRESSED_FLAG) && | 239 | } else if (((flags & PALM_IS_COMPRESSED_FLAG) && |
239 | (compression_type == PALM_COMPRESSION_NONE)) || | 240 | (compression_type == PALM_COMPRESSION_NONE)) || |
240 | ((flags & PALM_IS_COMPRESSED_FLAG) == 0)) | 241 | ((flags & PALM_IS_COMPRESSED_FLAG) == 0)) |
241 | { | 242 | { |
242 | memcpy (rowbuf, palm_ptr, bytes_per_row); | 243 | memcpy (rowbuf, palm_ptr, bytes_per_row); |
243 | palm_ptr += bytes_per_row; | 244 | palm_ptr += bytes_per_row; |
244 | } | 245 | } |
245 | else { | 246 | else { |
246 | qDebug("Case 4"); | 247 | qDebug("Case 4"); |
247 | qDebug("Is compressed:%s", ((flags & PALM_IS_COMPRESSED_FLAG) == 0) ? "false" : "true"); | 248 | qDebug("Is compressed:%s", ((flags & PALM_IS_COMPRESSED_FLAG) == 0) ? "false" : "true"); |
248 | qDebug("Has colourmap:%s", ((flags & PALM_HAS_COLORMAP_FLAG) == 0) ? "false" : "true"); | 249 | qDebug("Has colourmap:%s", ((flags & PALM_HAS_COLORMAP_FLAG) == 0) ? "false" : "true"); |
249 | qDebug("Has transparency:%s", ((flags & PALM_HAS_TRANSPARENCY_FLAG) == 0) ? "false" : "true"); | 250 | qDebug("Has transparency:%s", ((flags & PALM_HAS_TRANSPARENCY_FLAG) == 0) ? "false" : "true"); |
250 | qDebug("Direct colour:%s", ((flags & PALM_DIRECT_COLOR_FLAG) == 0) ? "false" : "true"); | 251 | qDebug("Direct colour:%s", ((flags & PALM_DIRECT_COLOR_FLAG) == 0) ? "false" : "true"); |
251 | qDebug("four byte field:%s", ((flags & PALM_4_BYTE_FIELD_FLAG) == 0) ? "false" : "true"); | 252 | qDebug("four byte field:%s", ((flags & PALM_4_BYTE_FIELD_FLAG) == 0) ? "false" : "true"); |
252 | memcpy (rowbuf, palm_ptr, bytes_per_row); | 253 | memcpy (rowbuf, palm_ptr, bytes_per_row); |
253 | palm_ptr += bytes_per_row; | 254 | palm_ptr += bytes_per_row; |
254 | } | 255 | } |
255 | /* next, write it to the GDK bitmap */ | 256 | /* next, write it to the GDK bitmap */ |
256 | if (colormap) { | 257 | if (colormap) { |
257 | mask = (1 << bits_per_pixel) - 1; | 258 | mask = (1 << bits_per_pixel) - 1; |
258 | for (inbit = 8 - bits_per_pixel, inbyte = rowbuf, j = 0; j < width; ++j) { | 259 | for (inbit = 8 - bits_per_pixel, inbyte = rowbuf, j = 0; j < width; ++j) { |
259 | inval = ((*inbyte) & (mask << inbit)) >> inbit; | 260 | inval = ((*inbyte) & (mask << inbit)) >> inbit; |
260 | /* correct for oddity of the 8-bit color Palm pixmap... */ | 261 | /* correct for oddity of the 8-bit color Palm pixmap... */ |
261 | if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231; | 262 | if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231; |
262 | /* now lookup the correct color and set the pixel in the GTK bitmap */ | 263 | /* now lookup the correct color and set the pixel in the GTK bitmap */ |
263 | QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue); | 264 | QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue); |
264 | qimage->setPixel(j, i, colour); | 265 | qimage->setPixel(j, i, colour); |
265 | if (!inbit) { | 266 | if (!inbit) { |
266 | ++inbyte; | 267 | ++inbyte; |
267 | inbit = 8 - bits_per_pixel; | 268 | inbit = 8 - bits_per_pixel; |
268 | } else { | 269 | } else { |
269 | inbit -= bits_per_pixel; | 270 | inbit -= bits_per_pixel; |
270 | } | 271 | } |
271 | } | 272 | } |
272 | } else if (!colormap && | 273 | } else if (!colormap && |
273 | bits_per_pixel == 16) { | 274 | bits_per_pixel == 16) { |
274 | for (inbyte = rowbuf, j = 0; j < width; ++j) { | 275 | for (inbyte = rowbuf, j = 0; j < width; ++j) { |
275 | inval = ((unsigned short)inbyte[0] << (unsigned short)8) | inbyte[1]; | 276 | inval = ((unsigned short)inbyte[0] << (unsigned short)8) | inbyte[1]; |
276 | 277 | ||
277 | /* | 278 | /* |
278 | qDebug ("pixel is %d,%d (%d:%d:%d)", | 279 | qDebug ("pixel is %d,%d (%d:%d:%d)", |
279 | j, i, | 280 | j, i, |
280 | ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), | 281 | ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), |
281 | ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), | 282 | ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), |
282 | ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); | 283 | ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); |
283 | */ | 284 | */ |
284 | QRgb colour = qRgb( | 285 | QRgb colour = qRgb( |
285 | ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), | 286 | ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), |
286 | ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), | 287 | ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), |
287 | ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); | 288 | ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); |
288 | qimage->setPixel(j, i, colour); | 289 | qimage->setPixel(j, i, colour); |
289 | inbyte += 2; | 290 | inbyte += 2; |
290 | } | 291 | } |
291 | } | 292 | } |
292 | } | 293 | } |
293 | 294 | ||
294 | delete [] rowbuf; | 295 | delete [] rowbuf; |
295 | delete [] lastrow; | 296 | delete [] lastrow; |
296 | 297 | ||
297 | return qimage; | 298 | return qimage; |
298 | } | 299 | } |
diff --git a/noncore/apps/opie-reader/Prefs.cpp b/noncore/apps/opie-reader/Prefs.cpp index 2733faa..6c4d45b 100644 --- a/noncore/apps/opie-reader/Prefs.cpp +++ b/noncore/apps/opie-reader/Prefs.cpp | |||
@@ -1,777 +1,840 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form implementation generated from reading ui file 'Prefs.ui' | 2 | ** Form implementation generated from reading ui file 'Prefs.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Feb 11 23:53:35 2003 | 4 | ** Created: Tue Feb 11 23:53:35 2003 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #include "Prefs.h" | 9 | #include "Prefs.h" |
10 | 10 | ||
11 | #include <stdlib.h> | ||
12 | |||
11 | #include <qcheckbox.h> | 13 | #include <qcheckbox.h> |
12 | #include <qlabel.h> | 14 | #include <qlabel.h> |
13 | #include <qpushbutton.h> | 15 | #include <qpushbutton.h> |
14 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
15 | #include <qlayout.h> | 17 | #include <qlayout.h> |
16 | #include <qvariant.h> | 18 | #include <qvariant.h> |
17 | #include <qtooltip.h> | 19 | #include <qtooltip.h> |
18 | #include <qwhatsthis.h> | 20 | #include <qwhatsthis.h> |
19 | #include <qbuttongroup.h> | 21 | #include <qbuttongroup.h> |
20 | #include <qlineedit.h> | 22 | #include <qlineedit.h> |
23 | #include <qdir.h> | ||
21 | #ifdef USECOMBO | 24 | #ifdef USECOMBO |
22 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
23 | #else | 26 | #else |
24 | #include <qpe/menubutton.h> | 27 | #include <qpe/menubutton.h> |
25 | #endif | 28 | #endif |
26 | #include <qfontdatabase.h> | 29 | #include <qfontdatabase.h> |
27 | 30 | ||
28 | #ifdef USECOMBO | 31 | #ifdef USECOMBO |
29 | void populate_colours(QComboBox *mb) | 32 | void populate_colours(QComboBox *mb) |
30 | #else | 33 | #else |
31 | void populate_colours(MenuButton *mb) | 34 | void populate_colours(MenuButton *mb) |
32 | #endif | 35 | #endif |
33 | { | 36 | { |
34 | mb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 37 | mb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
35 | mb->insertItem("White"); | 38 | mb->insertItem("White"); |
36 | mb->insertItem("Black"); | 39 | mb->insertItem("Black"); |
37 | mb->insertItem("Dark Gray"); | 40 | mb->insertItem("Dark Gray"); |
38 | mb->insertItem("Gray"); | 41 | mb->insertItem("Gray"); |
39 | mb->insertItem("Light Gray"); | 42 | mb->insertItem("Light Gray"); |
40 | mb->insertItem("Red"); | 43 | mb->insertItem("Red"); |
41 | mb->insertItem("Green"); | 44 | mb->insertItem("Green"); |
42 | mb->insertItem("Blue"); | 45 | mb->insertItem("Blue"); |
43 | mb->insertItem("Cyan"); | 46 | mb->insertItem("Cyan"); |
44 | mb->insertItem("Magenta"); | 47 | mb->insertItem("Magenta"); |
45 | mb->insertItem("Yellow"); | 48 | mb->insertItem("Yellow"); |
46 | mb->insertItem("Dark Red"); | 49 | mb->insertItem("Dark Red"); |
47 | mb->insertItem("Dark Green"); | 50 | mb->insertItem("Dark Green"); |
48 | mb->insertItem("Dark Blue"); | 51 | mb->insertItem("Dark Blue"); |
49 | mb->insertItem("Dark Cyan"); | 52 | mb->insertItem("Dark Cyan"); |
50 | mb->insertItem("Dark Magenta"); | 53 | mb->insertItem("Dark Magenta"); |
51 | mb->insertItem("Dark Yellow"); | 54 | mb->insertItem("Dark Yellow"); |
52 | } | 55 | } |
53 | 56 | ||
54 | CLayoutPrefs::CLayoutPrefs( QWidget* parent, const char* name, WFlags fl ) | 57 | CLayoutPrefs::CLayoutPrefs( QWidget* parent, const char* name, WFlags fl ) |
55 | : QWidget( parent, name, fl ) | 58 | : QWidget( parent, name, fl ) |
56 | { | 59 | { |
57 | QHBoxLayout* hb = new QHBoxLayout(this); | 60 | QHBoxLayout* hb = new QHBoxLayout(this); |
58 | QButtonGroup* bg = new QButtonGroup(2, Qt::Horizontal, "Text", this); | 61 | QButtonGroup* bg = new QButtonGroup(2, Qt::Horizontal, "Text", this); |
59 | hb->addWidget(bg); | 62 | hb->addWidget(bg); |
60 | 63 | ||
61 | StripCR = new QCheckBox( bg ); | 64 | StripCR = new QCheckBox( bg ); |
62 | StripCR->setText( tr( "Strip CR" ) ); | 65 | StripCR->setText( tr( "Strip CR" ) ); |
63 | 66 | ||
64 | Dehyphen = new QCheckBox( bg ); | 67 | Dehyphen = new QCheckBox( bg ); |
65 | Dehyphen->setText( tr( "Dehyphen" ) ); | 68 | Dehyphen->setText( tr( "Dehyphen" ) ); |
66 | 69 | ||
67 | SingleSpace = new QCheckBox( bg ); | 70 | SingleSpace = new QCheckBox( bg ); |
68 | SingleSpace->setText( tr( "Single Space" ) ); | 71 | SingleSpace->setText( tr( "Single Space" ) ); |
69 | 72 | ||
70 | Unindent = new QCheckBox( bg ); | 73 | Unindent = new QCheckBox( bg ); |
71 | Unindent->setText( tr( "Unindent" ) ); | 74 | Unindent->setText( tr( "Unindent" ) ); |
72 | 75 | ||
73 | Reparagraph = new QCheckBox( bg ); | 76 | Reparagraph = new QCheckBox( bg ); |
74 | Reparagraph->setText( tr( "Reparagraph" ) ); | 77 | Reparagraph->setText( tr( "Reparagraph" ) ); |
75 | 78 | ||
76 | DoubleSpace = new QCheckBox( bg ); | 79 | DoubleSpace = new QCheckBox( bg ); |
77 | DoubleSpace->setText( tr( "Double Space" ) ); | 80 | DoubleSpace->setText( tr( "Double Space" ) ); |
78 | 81 | ||
79 | Remap = new QCheckBox( bg ); | 82 | Remap = new QCheckBox( bg ); |
80 | Remap->setText( tr( "Remap" ) ); | 83 | Remap->setText( tr( "Remap" ) ); |
81 | 84 | ||
82 | Embolden = new QCheckBox( bg ); | 85 | Embolden = new QCheckBox( bg ); |
83 | Embolden->setText( tr( "Embolden" ) ); | 86 | Embolden->setText( tr( "Embolden" ) ); |
84 | 87 | ||
85 | FullJustify = new QCheckBox( bg ); | 88 | FullJustify = new QCheckBox( bg ); |
86 | FullJustify->setText( tr( "Full Justify" ) ); | 89 | FullJustify->setText( tr( "Full Justify" ) ); |
87 | 90 | ||
88 | FixGraphics = new QCheckBox( bg ); | 91 | FixGraphics = new QCheckBox( bg ); |
89 | FixGraphics->setText( tr( "Fix Graphic Size" ) ); | 92 | FixGraphics->setText( tr( "Fix Graphic Size" ) ); |
90 | 93 | ||
91 | hyphenate = new QCheckBox( bg ); | 94 | hyphenate = new QCheckBox( bg ); |
92 | hyphenate->setText( tr( "Hyphenate" ) ); | 95 | hyphenate->setText( tr( "Hyphenate" ) ); |
93 | 96 | ||
94 | /* | 97 | /* |
95 | customhyphen = new QCheckBox( bg ); | 98 | customhyphen = new QCheckBox( bg ); |
96 | customhyphen->setText( tr( "Custom Hyphen'n" ) ); | 99 | customhyphen->setText( tr( "Custom Hyphen'n" ) ); |
97 | */ | 100 | */ |
98 | 101 | ||
99 | prepalm = new QCheckBox( bg ); | 102 | prepalm = new QCheckBox( bg ); |
100 | prepalm->setText( tr( "Repalm(Baen)" ) ); | 103 | prepalm->setText( tr( "Repalm(Baen)" ) ); |
101 | 104 | ||
102 | pkern = new QCheckBox( bg ); | 105 | pkern = new QCheckBox( bg ); |
103 | pkern->setText( tr( "Kern" ) ); | 106 | pkern->setText( tr( "Kern" ) ); |
104 | 107 | ||
108 | InlineTables = new QCheckBox( bg ); | ||
109 | InlineTables->setText( tr( "Inline Tables" ) ); | ||
110 | |||
111 | Underlinelinks = new QCheckBox( bg ); | ||
112 | Underlinelinks->setText( tr( "Underline Links" ) ); | ||
105 | /* | 113 | /* |
106 | Negative = new QCheckBox( bg ); | 114 | Negative = new QCheckBox( bg ); |
107 | Negative->setText( tr( "Negative" ) ); | 115 | Negative->setText( tr( "Negative" ) ); |
108 | */ | 116 | */ |
109 | 117 | ||
110 | // Inverse = new QCheckBox( bg ); | 118 | // Inverse = new QCheckBox( bg ); |
111 | // Inverse->setText( tr( "Inverse" ) ); | 119 | // Inverse->setText( tr( "Inverse" ) ); |
112 | } | 120 | } |
113 | 121 | ||
114 | /* | 122 | /* |
115 | * Destroys the object and frees any allocated resources | 123 | * Destroys the object and frees any allocated resources |
116 | */ | 124 | */ |
117 | CLayoutPrefs::~CLayoutPrefs() | 125 | CLayoutPrefs::~CLayoutPrefs() |
118 | { | 126 | { |
119 | // no need to delete child widgets, Qt does it all for us | 127 | // no need to delete child widgets, Qt does it all for us |
120 | } | 128 | } |
121 | 129 | ||
122 | 130 | ||
123 | 131 | ||
124 | CLayoutPrefs2::CLayoutPrefs2( int w, QWidget* parent, const char* name, WFlags fl ) | 132 | CLayoutPrefs2::CLayoutPrefs2( int w, QWidget* parent, const char* name, WFlags fl ) |
125 | : QWidget( parent, name, fl ) | 133 | : QWidget( parent, name, fl ) |
126 | { | 134 | { |
127 | 135 | ||
128 | QVBoxLayout* vb = new QVBoxLayout(this); | 136 | QVBoxLayout* vb = new QVBoxLayout(this); |
129 | QGridLayout* gl = new QGridLayout(vb, 4, 5); | 137 | QGridLayout* gl = new QGridLayout(vb, 4, 5); |
130 | 138 | ||
131 | QLabel *TextLabel; | 139 | QLabel *TextLabel; |
132 | 140 | ||
133 | TextLabel = new QLabel( this ); | 141 | TextLabel = new QLabel( this ); |
134 | TextLabel->setText( tr( "Page\nOverlap" ) ); | 142 | TextLabel->setText( tr( "Page\nOverlap" ) ); |
135 | gl->addWidget(TextLabel, 0, 0); | 143 | gl->addWidget(TextLabel, 0, 0); |
136 | pageoverlap = new QSpinBox( this ); | 144 | pageoverlap = new QSpinBox( this ); |
137 | pageoverlap->setRange(0,20); | 145 | pageoverlap->setRange(0,20); |
138 | gl->addWidget(pageoverlap, 0, 1); | 146 | gl->addWidget(pageoverlap, 0, 1); |
139 | 147 | ||
140 | TextLabel = new QLabel( this, "TextLabel1" ); | 148 | TextLabel = new QLabel( this, "TextLabel1" ); |
141 | TextLabel->setText( tr( "Indent" ) ); | 149 | TextLabel->setText( tr( "Indent" ) ); |
142 | gl->addWidget(TextLabel, 1, 0); | 150 | gl->addWidget(TextLabel, 1, 0); |
143 | Indent = new QSpinBox( this, "Indent" ); | 151 | Indent = new QSpinBox( this, "Indent" ); |
144 | Indent->setRange(0,20); | 152 | Indent->setRange(0,20); |
145 | gl->addWidget(Indent, 1, 1); | 153 | gl->addWidget(Indent, 1, 1); |
146 | 154 | ||
147 | 155 | ||
148 | 156 | ||
149 | TextLabel = new QLabel( this ); | 157 | TextLabel = new QLabel( this ); |
150 | TextLabel->setText( tr( "Graphics\nZoom" ) ); | 158 | TextLabel->setText( tr( "Graphics\nZoom" ) ); |
151 | gl->addWidget(TextLabel, 1, 2); | 159 | gl->addWidget(TextLabel, 1, 2); |
152 | gfxzoom = new QSpinBox( this ); | 160 | gfxzoom = new QSpinBox( this ); |
153 | gfxzoom->setRange(0,2000); | 161 | gfxzoom->setRange(0,2000); |
154 | gfxzoom->setLineStep(10); | 162 | gfxzoom->setLineStep(10); |
155 | gfxzoom->setSuffix("%"); | 163 | gfxzoom->setSuffix("%"); |
156 | gl->addWidget(gfxzoom, 1, 3); | 164 | gl->addWidget(gfxzoom, 1, 3); |
157 | 165 | ||
158 | TextLabel = new QLabel( this, "TextLabel4" ); | 166 | TextLabel = new QLabel( this, "TextLabel4" ); |
159 | TextLabel->setText( tr( "Top\nMargin" ) ); | 167 | TextLabel->setText( tr( "Top\nMargin" ) ); |
160 | gl->addWidget(TextLabel, 2, 0); | 168 | gl->addWidget(TextLabel, 2, 0); |
161 | TopMargin = new QSpinBox( this, "TMargin" ); | 169 | TopMargin = new QSpinBox( this, "TMargin" ); |
162 | TopMargin->setRange(0, 1000); | 170 | TopMargin->setRange(0, 1000); |
163 | gl->addWidget(TopMargin, 2, 1); | 171 | gl->addWidget(TopMargin, 2, 1); |
164 | 172 | ||
165 | TextLabel = new QLabel( this ); | 173 | TextLabel = new QLabel( this ); |
166 | TextLabel->setText( tr( "Bottom\nMargin" ) ); | 174 | TextLabel->setText( tr( "Bottom\nMargin" ) ); |
167 | gl->addWidget(TextLabel, 2, 2); | 175 | gl->addWidget(TextLabel, 2, 2); |
168 | BottomMargin = new QSpinBox( this, "BMargin" ); | 176 | BottomMargin = new QSpinBox( this, "BMargin" ); |
169 | BottomMargin->setRange(0, 1000); | 177 | BottomMargin->setRange(0, 1000); |
170 | gl->addWidget(BottomMargin, 2, 3); | 178 | gl->addWidget(BottomMargin, 2, 3); |
171 | 179 | ||
172 | TextLabel = new QLabel( this, "TextLabel4" ); | 180 | TextLabel = new QLabel( this, "TextLabel4" ); |
173 | TextLabel->setText( tr( "Left\nMargin" ) ); | 181 | TextLabel->setText( tr( "Left\nMargin" ) ); |
174 | gl->addWidget(TextLabel, 3, 0); | 182 | gl->addWidget(TextLabel, 3, 0); |
175 | LeftMargin = new QSpinBox( this, "LMargin" ); | 183 | LeftMargin = new QSpinBox( this, "LMargin" ); |
176 | LeftMargin->setRange(0, 1000); | 184 | LeftMargin->setRange(0, 1000); |
177 | gl->addWidget(LeftMargin, 3, 1); | 185 | gl->addWidget(LeftMargin, 3, 1); |
178 | 186 | ||
179 | TextLabel = new QLabel( this ); | 187 | TextLabel = new QLabel( this ); |
180 | TextLabel->setText( tr( "Right\nMargin" ) ); | 188 | TextLabel->setText( tr( "Right\nMargin" ) ); |
181 | gl->addWidget(TextLabel, 3, 2); | 189 | gl->addWidget(TextLabel, 3, 2); |
182 | RightMargin = new QSpinBox( this, "RMargin" ); | 190 | RightMargin = new QSpinBox( this, "RMargin" ); |
183 | RightMargin->setRange(0, 1000); | 191 | RightMargin->setRange(0, 1000); |
184 | gl->addWidget(RightMargin, 3, 3); | 192 | gl->addWidget(RightMargin, 3, 3); |
185 | 193 | ||
186 | TextLabel = new QLabel( this ); | 194 | TextLabel = new QLabel( this ); |
187 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); | 195 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); |
188 | gl->addWidget(TextLabel, 4, 0); | 196 | gl->addWidget(TextLabel, 4, 0); |
189 | ParaLead = new QSpinBox( this ); | 197 | ParaLead = new QSpinBox( this ); |
190 | ParaLead->setRange(-5, 50); | 198 | ParaLead->setRange(-5, 50); |
191 | gl->addWidget(ParaLead, 4, 1); | 199 | gl->addWidget(ParaLead, 4, 1); |
192 | 200 | ||
193 | TextLabel = new QLabel( this ); | 201 | TextLabel = new QLabel( this ); |
194 | TextLabel->setText( tr( "Line\nLeading" ) ); | 202 | TextLabel->setText( tr( "Line\nLeading" ) ); |
195 | gl->addWidget(TextLabel, 4, 2); | 203 | gl->addWidget(TextLabel, 4, 2); |
196 | LineLead = new QSpinBox( this ); | 204 | LineLead = new QSpinBox( this ); |
197 | LineLead->setRange(-5, 50); | 205 | LineLead->setRange(-5, 50); |
198 | gl->addWidget(LineLead, 4, 3); | 206 | gl->addWidget(LineLead, 4, 3); |
199 | 207 | ||
200 | gl = new QGridLayout(vb, 2, 2); | 208 | gl = new QGridLayout(vb, 2, 2); |
201 | 209 | ||
202 | TextLabel = new QLabel( this); | 210 | TextLabel = new QLabel( this); |
203 | TextLabel->setText( tr( "Markup" ) ); | 211 | TextLabel->setText( tr( "Markup" ) ); |
204 | gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); | 212 | gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); |
205 | TextLabel = new QLabel( this); | 213 | TextLabel = new QLabel( this); |
206 | TextLabel->setText( tr( "Font" ) ); | 214 | TextLabel->setText( tr( "Font" ) ); |
207 | gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); | 215 | gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); |
208 | 216 | ||
209 | 217 | ||
210 | #ifdef USECOMBO | 218 | #ifdef USECOMBO |
211 | Markup = new QComboBox( this); | 219 | Markup = new QComboBox( this); |
212 | #else | 220 | #else |
213 | Markup = new MenuButton( this); | 221 | Markup = new MenuButton( this); |
214 | #endif | 222 | #endif |
215 | Markup->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 223 | Markup->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
216 | Markup->insertItem("Auto"); | 224 | Markup->insertItem("Auto"); |
217 | Markup->insertItem("None"); | 225 | Markup->insertItem("None"); |
218 | Markup->insertItem("Text"); | 226 | Markup->insertItem("Text"); |
219 | Markup->insertItem("HTML"); | 227 | Markup->insertItem("HTML"); |
220 | Markup->insertItem("PML"); | 228 | Markup->insertItem("PML"); |
221 | gl->addWidget(Markup, 1, 0, Qt::AlignTop); | 229 | gl->addWidget(Markup, 1, 0, Qt::AlignTop); |
222 | 230 | ||
223 | #ifdef USECOMBO | 231 | #ifdef USECOMBO |
224 | fontselector = new QComboBox( this); | 232 | fontselector = new QComboBox( this); |
225 | #else | 233 | #else |
226 | fontselector = new MenuButton( this); | 234 | fontselector = new MenuButton( this); |
227 | #endif | 235 | #endif |
228 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 236 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
229 | { | 237 | { |
230 | QFontDatabase f; | 238 | QFontDatabase f; |
231 | QStringList flist = f.families(); | 239 | QStringList flist = f.families(); |
232 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 240 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
233 | { | 241 | { |
234 | fontselector->insertItem(*nm); | 242 | fontselector->insertItem(*nm); |
235 | } | 243 | } |
236 | } // delete the FontDatabase!!! | 244 | } // delete the FontDatabase!!! |
237 | gl->addWidget(fontselector, 1, 1, Qt::AlignTop); | 245 | gl->addWidget(fontselector, 1, 1, Qt::AlignTop); |
238 | 246 | ||
239 | #ifdef USECOMBO | 247 | #ifdef USECOMBO |
240 | bgsel = new QComboBox( this ); | 248 | bgsel = new QComboBox( this ); |
241 | #else | 249 | #else |
242 | bgsel = new MenuButton( this ); | 250 | bgsel = new MenuButton( this ); |
243 | #endif | 251 | #endif |
244 | populate_colours(bgsel); | 252 | populate_colours(bgsel); |
245 | 253 | ||
246 | #ifdef USECOMBO | 254 | #ifdef USECOMBO |
247 | fgsel = new QComboBox( this ); | 255 | fgsel = new QComboBox( this ); |
248 | #else | 256 | #else |
249 | fgsel = new MenuButton( this ); | 257 | fgsel = new MenuButton( this ); |
250 | #endif | 258 | #endif |
251 | populate_colours(fgsel); | 259 | populate_colours(fgsel); |
252 | gl = new QGridLayout(vb, 2, 2); | 260 | gl = new QGridLayout(vb, 2, 2); |
253 | 261 | ||
254 | TextLabel = new QLabel( this); | 262 | TextLabel = new QLabel( this); |
255 | TextLabel->setText( tr( "Background" ) ); | 263 | TextLabel->setText( tr( "Background" ) ); |
256 | gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); | 264 | gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); |
257 | TextLabel = new QLabel( this); | 265 | TextLabel = new QLabel( this); |
258 | TextLabel->setText( tr( "Foreground" ) ); | 266 | TextLabel->setText( tr( "Foreground" ) ); |
259 | gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); | 267 | gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); |
260 | 268 | ||
261 | gl->addWidget(bgsel, 1, 0, Qt::AlignTop); | 269 | gl->addWidget(bgsel, 1, 0, Qt::AlignTop); |
262 | gl->addWidget(fgsel, 1, 1, Qt::AlignTop); | 270 | gl->addWidget(fgsel, 1, 1, Qt::AlignTop); |
263 | 271 | ||
264 | } | 272 | } |
265 | /* | 273 | /* |
266 | CLayoutPrefs2::CLayoutPrefs2( int w, QWidget* parent, const char* name, WFlags fl ) | 274 | CLayoutPrefs2::CLayoutPrefs2( int w, QWidget* parent, const char* name, WFlags fl ) |
267 | : QWidget( parent, name, fl ) | 275 | : QWidget( parent, name, fl ) |
268 | { | 276 | { |
269 | 277 | ||
270 | QVBoxLayout* vb = new QVBoxLayout(this); | 278 | QVBoxLayout* vb = new QVBoxLayout(this); |
271 | QGridLayout* gl = new QGridLayout(vb, 4, 3); | 279 | QGridLayout* gl = new QGridLayout(vb, 4, 3); |
272 | 280 | ||
273 | QLabel *TextLabel; | 281 | QLabel *TextLabel; |
274 | 282 | ||
275 | TextLabel = new QLabel( this, "TextLabel1" ); | 283 | TextLabel = new QLabel( this, "TextLabel1" ); |
276 | TextLabel->setText( tr( "Indent" ) ); | 284 | TextLabel->setText( tr( "Indent" ) ); |
277 | gl->addWidget(TextLabel, 0, 0); | 285 | gl->addWidget(TextLabel, 0, 0); |
278 | 286 | ||
279 | 287 | ||
280 | TextLabel = new QLabel( this ); | 288 | TextLabel = new QLabel( this ); |
281 | TextLabel->setText( tr( "Page\nOverlap" ) ); | 289 | TextLabel->setText( tr( "Page\nOverlap" ) ); |
282 | gl->addWidget(TextLabel, 0, 1); | 290 | gl->addWidget(TextLabel, 0, 1); |
283 | 291 | ||
284 | TextLabel = new QLabel( this ); | 292 | TextLabel = new QLabel( this ); |
285 | TextLabel->setText( tr( "Graphics\nZoom" ) ); | 293 | TextLabel->setText( tr( "Graphics\nZoom" ) ); |
286 | gl->addWidget(TextLabel, 0, 2); | 294 | gl->addWidget(TextLabel, 0, 2); |
287 | 295 | ||
288 | Indent = new QSpinBox( this, "Indent" ); | 296 | Indent = new QSpinBox( this, "Indent" ); |
289 | Indent->setRange(0,20); | 297 | Indent->setRange(0,20); |
290 | gl->addWidget(Indent, 1, 0); | 298 | gl->addWidget(Indent, 1, 0); |
291 | 299 | ||
292 | pageoverlap = new QSpinBox( this ); | 300 | pageoverlap = new QSpinBox( this ); |
293 | pageoverlap->setRange(0,20); | 301 | pageoverlap->setRange(0,20); |
294 | gl->addWidget(pageoverlap, 1, 1); | 302 | gl->addWidget(pageoverlap, 1, 1); |
295 | 303 | ||
296 | gfxzoom = new QSpinBox( this ); | 304 | gfxzoom = new QSpinBox( this ); |
297 | gfxzoom->setRange(0,100); | 305 | gfxzoom->setRange(0,100); |
298 | gl->addWidget(gfxzoom, 1, 2); | 306 | gl->addWidget(gfxzoom, 1, 2); |
299 | 307 | ||
300 | TextLabel = new QLabel( this, "TextLabel4" ); | 308 | TextLabel = new QLabel( this, "TextLabel4" ); |
301 | TextLabel->setText( tr( "Margin" ) ); | 309 | TextLabel->setText( tr( "Margin" ) ); |
302 | gl->addWidget(TextLabel, 2, 0); | 310 | gl->addWidget(TextLabel, 2, 0); |
303 | 311 | ||
304 | TextLabel = new QLabel( this ); | 312 | TextLabel = new QLabel( this ); |
305 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); | 313 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); |
306 | gl->addWidget(TextLabel, 2, 1); | 314 | gl->addWidget(TextLabel, 2, 1); |
307 | 315 | ||
308 | TextLabel = new QLabel( this ); | 316 | TextLabel = new QLabel( this ); |
309 | TextLabel->setText( tr( "Line\nLeading" ) ); | 317 | TextLabel->setText( tr( "Line\nLeading" ) ); |
310 | gl->addWidget(TextLabel, 2, 2); | 318 | gl->addWidget(TextLabel, 2, 2); |
311 | 319 | ||
312 | Margin = new QSpinBox( this, "Margin" ); | 320 | Margin = new QSpinBox( this, "Margin" ); |
313 | Margin->setRange(0, w/2); | 321 | Margin->setRange(0, w/2); |
314 | gl->addWidget(Margin, 3, 0); | 322 | gl->addWidget(Margin, 3, 0); |
315 | 323 | ||
316 | ParaLead = new QSpinBox( this ); | 324 | ParaLead = new QSpinBox( this ); |
317 | ParaLead->setRange(-5, 50); | 325 | ParaLead->setRange(-5, 50); |
318 | gl->addWidget(ParaLead, 3, 1); | 326 | gl->addWidget(ParaLead, 3, 1); |
319 | 327 | ||
320 | LineLead = new QSpinBox( this ); | 328 | LineLead = new QSpinBox( this ); |
321 | LineLead->setRange(-5, 50); | 329 | LineLead->setRange(-5, 50); |
322 | gl->addWidget(LineLead, 3, 2); | 330 | gl->addWidget(LineLead, 3, 2); |
323 | 331 | ||
324 | gl = new QGridLayout(vb, 2, 2); | 332 | gl = new QGridLayout(vb, 2, 2); |
325 | 333 | ||
326 | TextLabel = new QLabel( this); | 334 | TextLabel = new QLabel( this); |
327 | TextLabel->setText( tr( "Markup" ) ); | 335 | TextLabel->setText( tr( "Markup" ) ); |
328 | gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); | 336 | gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); |
329 | TextLabel = new QLabel( this); | 337 | TextLabel = new QLabel( this); |
330 | TextLabel->setText( tr( "Font" ) ); | 338 | TextLabel->setText( tr( "Font" ) ); |
331 | gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); | 339 | gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); |
332 | 340 | ||
333 | 341 | ||
334 | #ifdef USECOMBO | 342 | #ifdef USECOMBO |
335 | Markup = new QComboBox( this); | 343 | Markup = new QComboBox( this); |
336 | #else | 344 | #else |
337 | Markup = new MenuButton( this); | 345 | Markup = new MenuButton( this); |
338 | #endif | 346 | #endif |
339 | Markup->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 347 | Markup->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
340 | Markup->insertItem("Auto"); | 348 | Markup->insertItem("Auto"); |
341 | Markup->insertItem("None"); | 349 | Markup->insertItem("None"); |
342 | Markup->insertItem("Text"); | 350 | Markup->insertItem("Text"); |
343 | Markup->insertItem("HTML"); | 351 | Markup->insertItem("HTML"); |
344 | Markup->insertItem("PML"); | 352 | Markup->insertItem("PML"); |
345 | gl->addWidget(Markup, 1, 0, Qt::AlignTop); | 353 | gl->addWidget(Markup, 1, 0, Qt::AlignTop); |
346 | 354 | ||
347 | #ifdef USECOMBO | 355 | #ifdef USECOMBO |
348 | fontselector = new QComboBox( this); | 356 | fontselector = new QComboBox( this); |
349 | #else | 357 | #else |
350 | fontselector = new MenuButton( this); | 358 | fontselector = new MenuButton( this); |
351 | #endif | 359 | #endif |
352 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 360 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
353 | { | 361 | { |
354 | QFontDatabase f; | 362 | QFontDatabase f; |
355 | QStringList flist = f.families(); | 363 | QStringList flist = f.families(); |
356 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 364 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
357 | { | 365 | { |
358 | fontselector->insertItem(*nm); | 366 | fontselector->insertItem(*nm); |
359 | } | 367 | } |
360 | } // delete the FontDatabase!!! | 368 | } // delete the FontDatabase!!! |
361 | gl->addWidget(fontselector, 1, 1, Qt::AlignTop); | 369 | gl->addWidget(fontselector, 1, 1, Qt::AlignTop); |
362 | 370 | ||
363 | #ifdef USECOMBO | 371 | #ifdef USECOMBO |
364 | bgsel = new QComboBox( this ); | 372 | bgsel = new QComboBox( this ); |
365 | #else | 373 | #else |
366 | bgsel = new MenuButton( this ); | 374 | bgsel = new MenuButton( this ); |
367 | #endif | 375 | #endif |
368 | populate_colours(bgsel); | 376 | populate_colours(bgsel); |
369 | 377 | ||
370 | #ifdef USECOMBO | 378 | #ifdef USECOMBO |
371 | fgsel = new QComboBox( this ); | 379 | fgsel = new QComboBox( this ); |
372 | #else | 380 | #else |
373 | fgsel = new MenuButton( this ); | 381 | fgsel = new MenuButton( this ); |
374 | #endif | 382 | #endif |
375 | populate_colours(fgsel); | 383 | populate_colours(fgsel); |
376 | gl = new QGridLayout(vb, 2, 2); | 384 | gl = new QGridLayout(vb, 2, 2); |
377 | 385 | ||
378 | TextLabel = new QLabel( this); | 386 | TextLabel = new QLabel( this); |
379 | TextLabel->setText( tr( "Background" ) ); | 387 | TextLabel->setText( tr( "Background" ) ); |
380 | gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); | 388 | gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); |
381 | TextLabel = new QLabel( this); | 389 | TextLabel = new QLabel( this); |
382 | TextLabel->setText( tr( "Foreground" ) ); | 390 | TextLabel->setText( tr( "Foreground" ) ); |
383 | gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); | 391 | gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); |
384 | 392 | ||
385 | gl->addWidget(bgsel, 1, 0, Qt::AlignTop); | 393 | gl->addWidget(bgsel, 1, 0, Qt::AlignTop); |
386 | gl->addWidget(fgsel, 1, 1, Qt::AlignTop); | 394 | gl->addWidget(fgsel, 1, 1, Qt::AlignTop); |
387 | 395 | ||
388 | } | 396 | } |
389 | */ | 397 | */ |
390 | /* | 398 | /* |
391 | CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) | 399 | CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) |
392 | : QWidget( parent, name, fl ) | 400 | : QWidget( parent, name, fl ) |
393 | { | 401 | { |
394 | QHBoxLayout* hb = new QHBoxLayout(this); | 402 | QHBoxLayout* hb = new QHBoxLayout(this); |
395 | 403 | ||
396 | QVBoxLayout* vb = new QVBoxLayout; | 404 | QVBoxLayout* vb = new QVBoxLayout; |
397 | hb->addLayout(vb); | 405 | hb->addLayout(vb); |
398 | 406 | ||
399 | QLabel *TextLabel; | 407 | QLabel *TextLabel; |
400 | 408 | ||
401 | TextLabel = new QLabel( this, "TextLabel1" ); | 409 | TextLabel = new QLabel( this, "TextLabel1" ); |
402 | TextLabel->setText( tr( "Indent" ) ); | 410 | TextLabel->setText( tr( "Indent" ) ); |
403 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 411 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
404 | Indent = new QSpinBox( this, "Indent" ); | 412 | Indent = new QSpinBox( this, "Indent" ); |
405 | Indent->setRange(0,20); | 413 | Indent->setRange(0,20); |
406 | vb->addWidget( Indent, 0, Qt::AlignLeft ); | 414 | vb->addWidget( Indent, 0, Qt::AlignLeft ); |
407 | 415 | ||
408 | TextLabel = new QLabel( this ); | 416 | TextLabel = new QLabel( this ); |
409 | TextLabel->setText( tr( "Page\nOverlap" ) ); | 417 | TextLabel->setText( tr( "Page\nOverlap" ) ); |
410 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 418 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
411 | pageoverlap = new QSpinBox( this ); | 419 | pageoverlap = new QSpinBox( this ); |
412 | pageoverlap->setRange(0,20); | 420 | pageoverlap->setRange(0,20); |
413 | vb->addWidget( pageoverlap, 0, Qt::AlignLeft ); | 421 | vb->addWidget( pageoverlap, 0, Qt::AlignLeft ); |
414 | 422 | ||
415 | TextLabel = new QLabel( this ); | 423 | TextLabel = new QLabel( this ); |
416 | TextLabel->setText( tr( "Graphics\nZoom" ) ); | 424 | TextLabel->setText( tr( "Graphics\nZoom" ) ); |
417 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 425 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
418 | gfxzoom = new QSpinBox( this ); | 426 | gfxzoom = new QSpinBox( this ); |
419 | gfxzoom->setRange(0,100); | 427 | gfxzoom->setRange(0,100); |
420 | vb->addWidget( gfxzoom, 0, Qt::AlignLeft ); | 428 | vb->addWidget( gfxzoom, 0, Qt::AlignLeft ); |
421 | 429 | ||
422 | vb->addStretch(); | 430 | vb->addStretch(); |
423 | 431 | ||
424 | vb = new QVBoxLayout; | 432 | vb = new QVBoxLayout; |
425 | hb->addLayout(vb); | 433 | hb->addLayout(vb); |
426 | 434 | ||
427 | TextLabel = new QLabel( this, "TextLabel4" ); | 435 | TextLabel = new QLabel( this, "TextLabel4" ); |
428 | TextLabel->setText( tr( "Margin" ) ); | 436 | TextLabel->setText( tr( "Margin" ) ); |
429 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 437 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
430 | Margin = new QSpinBox( this, "Margin" ); | 438 | Margin = new QSpinBox( this, "Margin" ); |
431 | Margin->setRange(0, 100); | 439 | Margin->setRange(0, 100); |
432 | vb->addWidget( Margin, 0, Qt::AlignLeft ); | 440 | vb->addWidget( Margin, 0, Qt::AlignLeft ); |
433 | 441 | ||
434 | TextLabel = new QLabel( this ); | 442 | TextLabel = new QLabel( this ); |
435 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); | 443 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); |
436 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 444 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
437 | ParaLead = new QSpinBox( this ); | 445 | ParaLead = new QSpinBox( this ); |
438 | ParaLead->setRange(-5, 50); | 446 | ParaLead->setRange(-5, 50); |
439 | vb->addWidget( ParaLead, 0, Qt::AlignLeft ); | 447 | vb->addWidget( ParaLead, 0, Qt::AlignLeft ); |
440 | 448 | ||
441 | TextLabel = new QLabel( this ); | 449 | TextLabel = new QLabel( this ); |
442 | TextLabel->setText( tr( "Line\nLeading" ) ); | 450 | TextLabel->setText( tr( "Line\nLeading" ) ); |
443 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 451 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
444 | LineLead = new QSpinBox( this ); | 452 | LineLead = new QSpinBox( this ); |
445 | LineLead->setRange(-5, 50); | 453 | LineLead->setRange(-5, 50); |
446 | vb->addWidget( LineLead, 0, Qt::AlignLeft ); | 454 | vb->addWidget( LineLead, 0, Qt::AlignLeft ); |
447 | 455 | ||
448 | vb->addStretch(); | 456 | vb->addStretch(); |
449 | 457 | ||
450 | vb = new QVBoxLayout; | 458 | vb = new QVBoxLayout; |
451 | hb->addLayout(vb); | 459 | hb->addLayout(vb); |
452 | 460 | ||
453 | 461 | ||
454 | TextLabel = new QLabel( this); | 462 | TextLabel = new QLabel( this); |
455 | TextLabel->setText( tr( "Markup" ) ); | 463 | TextLabel->setText( tr( "Markup" ) ); |
456 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 464 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
457 | Markup = new MenuButton( this); | 465 | Markup = new MenuButton( this); |
458 | Markup->insertItem("Auto"); | 466 | Markup->insertItem("Auto"); |
459 | Markup->insertItem("None"); | 467 | Markup->insertItem("None"); |
460 | Markup->insertItem("Text"); | 468 | Markup->insertItem("Text"); |
461 | Markup->insertItem("HTML"); | 469 | Markup->insertItem("HTML"); |
462 | Markup->insertItem("PML"); | 470 | Markup->insertItem("PML"); |
463 | vb->addWidget( Markup, 0, Qt::AlignLeft ); | 471 | vb->addWidget( Markup, 0, Qt::AlignLeft ); |
464 | 472 | ||
465 | TextLabel = new QLabel( this); | 473 | TextLabel = new QLabel( this); |
466 | TextLabel->setText( tr( "Font" ) ); | 474 | TextLabel->setText( tr( "Font" ) ); |
467 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 475 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
468 | fontselector = new MenuButton( this); | 476 | fontselector = new MenuButton( this); |
469 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 477 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
470 | { | 478 | { |
471 | FontDatabase f; | 479 | FontDatabase f; |
472 | QStringList flist = f.families(); | 480 | QStringList flist = f.families(); |
473 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 481 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
474 | { | 482 | { |
475 | fontselector->insertItem(*nm); | 483 | fontselector->insertItem(*nm); |
476 | } | 484 | } |
477 | } // delete the FontDatabase!!! | 485 | } // delete the FontDatabase!!! |
478 | vb->addWidget( fontselector, 0, Qt::AlignLeft ); | 486 | vb->addWidget( fontselector, 0, Qt::AlignLeft ); |
479 | 487 | ||
480 | vb->addStretch(); | 488 | vb->addStretch(); |
481 | } | 489 | } |
482 | */ | 490 | */ |
483 | /* | 491 | /* |
484 | * Destroys the object and frees any allocated resources | 492 | * Destroys the object and frees any allocated resources |
485 | */ | 493 | */ |
486 | CLayoutPrefs2::~CLayoutPrefs2() | 494 | CLayoutPrefs2::~CLayoutPrefs2() |
487 | { | 495 | { |
488 | // no need to delete child widgets, Qt does it all for us | 496 | // no need to delete child widgets, Qt does it all for us |
489 | } | 497 | } |
490 | 498 | ||
491 | /* | 499 | /* |
492 | CPluckerPrefs::CPluckerPrefs( QWidget* parent, const char* name, WFlags fl ) | 500 | CPluckerPrefs::CPluckerPrefs( QWidget* parent, const char* name, WFlags fl ) |
493 | : QWidget( parent, name, fl ) | 501 | : QWidget( parent, name, fl ) |
494 | { | 502 | { |
495 | Layout11 = new QVBoxLayout(this); | 503 | Layout11 = new QVBoxLayout(this); |
496 | Layout11->setMargin( 0 ); | 504 | Layout11->setMargin( 0 ); |
497 | 505 | ||
498 | Depluck = new QCheckBox( this, "Depluck" ); | 506 | Depluck = new QCheckBox( this, "Depluck" ); |
499 | Depluck->setText( tr( "Depluck" ) ); | 507 | Depluck->setText( tr( "Depluck" ) ); |
500 | Layout11->addWidget( Depluck ); | 508 | Layout11->addWidget( Depluck ); |
501 | 509 | ||
502 | Dejpluck = new QCheckBox( this, "Dejpluck" ); | 510 | Dejpluck = new QCheckBox( this, "Dejpluck" ); |
503 | Dejpluck->setText( tr( "Dejpluck" ) ); | 511 | Dejpluck->setText( tr( "Dejpluck" ) ); |
504 | Layout11->addWidget( Dejpluck ); | 512 | Layout11->addWidget( Dejpluck ); |
505 | 513 | ||
506 | Continuous = new QCheckBox( this, "Continuous" ); | 514 | Continuous = new QCheckBox( this, "Continuous" ); |
507 | Continuous->setText( tr( "Continuous" ) ); | 515 | Continuous->setText( tr( "Continuous" ) ); |
508 | Layout11->addWidget( Continuous ); | 516 | Layout11->addWidget( Continuous ); |
509 | 517 | ||
510 | } | 518 | } |
511 | 519 | ||
512 | CPluckerPrefs::~CPluckerPrefs() | 520 | CPluckerPrefs::~CPluckerPrefs() |
513 | { | 521 | { |
514 | // no need to delete child widgets, Qt does it all for us | 522 | // no need to delete child widgets, Qt does it all for us |
515 | } | 523 | } |
516 | */ | 524 | */ |
517 | /* | 525 | /* |
518 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) | 526 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) |
519 | : QWidget( parent, name, fl ) | 527 | : QWidget( parent, name, fl ) |
520 | { | 528 | { |
521 | 529 | ||
522 | QVBoxLayout* Layout11 = new QVBoxLayout(this); | 530 | QVBoxLayout* Layout11 = new QVBoxLayout(this); |
523 | Layout11->setMargin( 0 ); | 531 | Layout11->setMargin( 0 ); |
524 | 532 | ||
525 | 533 | ||
526 | QHBoxLayout* hl = new QHBoxLayout; | 534 | QHBoxLayout* hl = new QHBoxLayout; |
527 | 535 | ||
528 | QLabel* TextLabel = new QLabel( this ); | 536 | QLabel* TextLabel = new QLabel( this ); |
529 | TextLabel->setText( tr( "Action for\nSelect Button" ) ); | 537 | TextLabel->setText( tr( "Action for\nSelect Button" ) ); |
530 | hl->addWidget(TextLabel); | 538 | hl->addWidget(TextLabel); |
531 | 539 | ||
532 | action = new QComboBox( this ); | 540 | action = new QComboBox( this ); |
533 | action->insertItem("Open file"); | 541 | action->insertItem("Open file"); |
534 | action->insertItem("Autoscroll"); | 542 | action->insertItem("Autoscroll"); |
535 | action->insertItem("Mark"); | 543 | action->insertItem("Mark"); |
536 | action->insertItem("Annotate"); | 544 | action->insertItem("Annotate"); |
537 | action->insertItem("Fullscreen"); | 545 | action->insertItem("Fullscreen"); |
538 | hl->addWidget( action ); | 546 | hl->addWidget( action ); |
539 | 547 | ||
540 | Layout11->addLayout(hl); | 548 | Layout11->addLayout(hl); |
541 | 549 | ||
542 | hl = new QHBoxLayout; | 550 | hl = new QHBoxLayout; |
543 | 551 | ||
544 | TextLabel = new QLabel( this ); | 552 | TextLabel = new QLabel( this ); |
545 | TextLabel->setText( tr( "Dictionary\nApplication" ) ); | 553 | TextLabel->setText( tr( "Dictionary\nApplication" ) ); |
546 | hl->addWidget(TextLabel); | 554 | hl->addWidget(TextLabel); |
547 | target = new QLineEdit(this); | 555 | target = new QLineEdit(this); |
548 | hl->addWidget( target ); | 556 | hl->addWidget( target ); |
549 | 557 | ||
550 | Layout11->addLayout(hl); | 558 | Layout11->addLayout(hl); |
551 | 559 | ||
552 | 560 | ||
553 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Selection Target", this); | 561 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Selection Target", this); |
554 | Layout11->addWidget( bg ); | 562 | Layout11->addWidget( bg ); |
555 | 563 | ||
556 | annotation = new QCheckBox( bg ); | 564 | annotation = new QCheckBox( bg ); |
557 | annotation->setText( tr( "Annotation" ) ); | 565 | annotation->setText( tr( "Annotation" ) ); |
558 | 566 | ||
559 | dictionary = new QCheckBox( bg ); | 567 | dictionary = new QCheckBox( bg ); |
560 | dictionary->setText( tr( "Dictionary" ) ); | 568 | dictionary->setText( tr( "Dictionary" ) ); |
561 | 569 | ||
562 | clipboard = new QCheckBox( bg ); | 570 | clipboard = new QCheckBox( bg ); |
563 | clipboard->setText( tr( "Clipboard" ) ); | 571 | clipboard->setText( tr( "Clipboard" ) ); |
564 | 572 | ||
573 | QCheckBox* outcodec = new QCheckBox( bg ); | ||
574 | outcodec->setText( tr( "Output" ) ); | ||
575 | |||
565 | } | 576 | } |
566 | 577 | ||
567 | CMiscPrefs::~CMiscPrefs() | 578 | CMiscPrefs::~CMiscPrefs() |
568 | { | 579 | { |
569 | // no need to delete child widgets, Qt does it all for us | 580 | // no need to delete child widgets, Qt does it all for us |
570 | } | 581 | } |
571 | */ | 582 | */ |
572 | 583 | ||
573 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) | 584 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) |
574 | : QWidget( parent, name, fl ) | 585 | : QWidget( parent, name, fl ) |
575 | { | 586 | { |
576 | 587 | ||
577 | QVBoxLayout* vl = new QVBoxLayout(this); | 588 | QVBoxLayout* vl = new QVBoxLayout(this); |
578 | QHBoxLayout* hl = new QHBoxLayout; | 589 | QHBoxLayout* hl = new QHBoxLayout; |
579 | vl->addLayout(hl); | 590 | vl->addLayout(hl); |
580 | 591 | ||
581 | vl->setMargin( 0 ); | 592 | vl->setMargin( 0 ); |
582 | hl->setMargin( 0 ); | 593 | hl->setMargin( 0 ); |
583 | 594 | ||
584 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Select Action", this); | 595 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Select Action", this); |
585 | hl->addWidget( gb ); | 596 | hl->addWidget( gb ); |
586 | 597 | ||
587 | annotation = new QCheckBox( gb ); | 598 | annotation = new QCheckBox( gb ); |
588 | annotation->setText( tr( "Annotation" ) ); | 599 | annotation->setText( tr( "Annotation" ) ); |
589 | 600 | ||
590 | dictionary = new QCheckBox( gb ); | 601 | dictionary = new QCheckBox( gb ); |
591 | dictionary->setText( tr( "Dictionary" ) ); | 602 | dictionary->setText( tr( "Dictionary" ) ); |
592 | 603 | ||
593 | clipboard = new QCheckBox( gb ); | 604 | clipboard = new QCheckBox( gb ); |
594 | clipboard->setText( tr( "Clipboard" ) ); | 605 | clipboard->setText( tr( "Clipboard" ) ); |
595 | 606 | ||
607 | boutput = new QCheckBox( gb ); | ||
608 | boutput->setText( tr( "Output" ) ); | ||
609 | |||
596 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Plucker", this); | 610 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Plucker", this); |
597 | hl->addWidget( bg ); | 611 | hl->addWidget( bg ); |
598 | 612 | ||
599 | Depluck = new QCheckBox( bg ); | 613 | Depluck = new QCheckBox( bg ); |
600 | Depluck->setText( tr( "Depluck" ) ); | 614 | Depluck->setText( tr( "Depluck" ) ); |
601 | 615 | ||
602 | Dejpluck = new QCheckBox( bg ); | 616 | Dejpluck = new QCheckBox( bg ); |
603 | Dejpluck->setText( tr( "Dejpluck" ) ); | 617 | Dejpluck->setText( tr( "Dejpluck" ) ); |
604 | 618 | ||
605 | Continuous = new QCheckBox( bg ); | 619 | Continuous = new QCheckBox( bg ); |
606 | Continuous->setText( tr( "Continuous" ) ); | 620 | Continuous->setText( tr( "Continuous" ) ); |
607 | 621 | bg = new QButtonGroup(2, Qt::Horizontal, "Background", this); | |
608 | bg = new QButtonGroup(2, Qt::Horizontal, "Scroll", this); | ||
609 | vl->addWidget( bg ); | 622 | vl->addWidget( bg ); |
610 | 623 | ||
611 | // scrollinplace = new QCheckBox( bg ); | 624 | // QLabel* TextLabel = new QLabel( bg ); |
612 | // scrollinplace->setText( tr( "In Place" ) ); | 625 | // TextLabel->setText( tr( "Copy an image to \"background\" in\n~/Applications/uqtreader/Theme/" ) ); |
626 | |||
613 | #ifdef USECOMBO | 627 | #ifdef USECOMBO |
614 | scrolltype = new QComboBox( bg ); | 628 | bgtype = new QComboBox( bg ); |
615 | #else | 629 | #else |
616 | scrolltype = new MenuButton( this); | 630 | bgtype = new MenuButton( this); |
617 | #endif | 631 | #endif |
618 | scrolltype->insertItem("In Place"); | 632 | bgtype->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
619 | scrolltype->insertItem("Rolling (moving bg)"); | 633 | |
620 | scrolltype->insertItem("Rolling (window)"); | 634 | bgtype->insertItem( tr("Centred") ); |
621 | scrolltype->insertItem("Rolling (static bg)"); | 635 | bgtype->insertItem( tr("Tiled") ); |
622 | scrolltype->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 636 | bgtype->insertItem( tr("Fitted") ); |
623 | 637 | ||
638 | DoubleBuffer = new QCheckBox( bg ); | ||
639 | DoubleBuffer->setText( tr( "Double Buffer" ) ); | ||
624 | 640 | ||
641 | QLabel* TextLabel = new QLabel( bg ); | ||
642 | TextLabel->setText( tr( "Minibar Colour" ) ); | ||
625 | #ifdef USECOMBO | 643 | #ifdef USECOMBO |
626 | scrollcolor = new QComboBox( bg ); | 644 | minibarcol = new QComboBox( bg ); |
627 | #else | 645 | #else |
628 | scrollcolor = new MenuButton( this); | 646 | minibarcol = new MenuButton( this); |
629 | #endif | 647 | #endif |
630 | populate_colours(scrollcolor); | 648 | populate_colours(minibarcol); |
631 | scrollcolor->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 649 | minibarcol->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
650 | } | ||
651 | |||
652 | CMiscPrefs::~CMiscPrefs() | ||
653 | { | ||
654 | // no need to delete child widgets, Qt does it all for us | ||
655 | } | ||
656 | |||
657 | CScrollPrefs::CScrollPrefs( QWidget* parent, const char* name, WFlags fl ) | ||
658 | : QWidget( parent, name, fl ) | ||
659 | { | ||
660 | |||
661 | QHBoxLayout* hl = new QHBoxLayout(this); | ||
632 | 662 | ||
663 | hl->setMargin( 0 ); | ||
664 | |||
665 | QButtonGroup* bg = new QButtonGroup(2, Qt::Horizontal, "Scroll", this); | ||
666 | hl->addWidget( bg ); | ||
633 | 667 | ||
668 | // scrollinplace = new QCheckBox( bg ); | ||
669 | // scrollinplace->setText( tr( "In Place" ) ); | ||
634 | QLabel* TextLabel = new QLabel( bg ); | 670 | QLabel* TextLabel = new QLabel( bg ); |
635 | TextLabel->setText( tr( "Scroll step" ) ); | 671 | TextLabel->setText( tr( "Scroll step" ) ); |
636 | // gl->addWidget(TextLabel, 2, 0); | 672 | // gl->addWidget(TextLabel, 2, 0); |
637 | scrollstep = new QSpinBox( bg ); | 673 | scrollstep = new QSpinBox( bg ); |
638 | scrollstep->setRange(1, 10); | 674 | scrollstep->setRange(1, 10); |
639 | scrollstep->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 675 | scrollstep->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
640 | 676 | ||
641 | TextLabel = new QLabel( bg ); | 677 | TextLabel = new QLabel( bg ); |
642 | TextLabel->setText( tr( "Minibar Colour" ) ); | 678 | TextLabel->setText( tr( "Scroll type" ) ); |
643 | #ifdef USECOMBO | 679 | #ifdef USECOMBO |
644 | minibarcol = new QComboBox( bg ); | 680 | scrolltype = new QComboBox( bg ); |
645 | #else | 681 | #else |
646 | minibarcol = new MenuButton( this); | 682 | scrolltype = new MenuButton( this); |
647 | #endif | 683 | #endif |
648 | populate_colours(minibarcol); | 684 | scrolltype->insertItem("In Place"); |
649 | minibarcol->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 685 | scrolltype->insertItem("Rolling (moving bg)"); |
686 | scrolltype->insertItem("Rolling (window)"); | ||
687 | scrolltype->insertItem("Rolling (static bg)"); | ||
688 | scrolltype->insertItem("Send to output"); | ||
689 | scrolltype->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||
650 | 690 | ||
691 | TextLabel = new QLabel( bg ); | ||
692 | TextLabel->setText( tr( "Colour of scroll\nprogress indicator" ) ); | ||
651 | 693 | ||
652 | bg = new QButtonGroup(2, Qt::Vertical, "Background", this); | 694 | #ifdef USECOMBO |
653 | vl->addWidget( bg ); | 695 | scrollcolor = new QComboBox( bg ); |
696 | #else | ||
697 | scrollcolor = new MenuButton( this); | ||
698 | #endif | ||
699 | populate_colours(scrollcolor); | ||
700 | scrollcolor->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||
654 | 701 | ||
655 | // QLabel* TextLabel = new QLabel( bg ); | 702 | TextLabel = new QLabel( bg ); |
656 | // TextLabel->setText( tr( "Copy an image to \"background\" in\n~/Applications/uqtreader/Theme/" ) ); | 703 | TextLabel->setText( tr( "Output" ) ); |
657 | 704 | ||
658 | #ifdef USECOMBO | 705 | #ifdef USECOMBO |
659 | bgtype = new QComboBox( bg ); | 706 | outcodec = new QComboBox( bg ); |
660 | #else | 707 | #else |
661 | bgtype = new MenuButton( this); | 708 | outcodec = new MenuButton( this); |
662 | #endif | 709 | #endif |
663 | bgtype->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 710 | #ifdef USEQPE |
664 | 711 | #ifdef OPIE | |
665 | bgtype->insertItem( tr("Centred") ); | 712 | QString codecpath(getenv("OPIEDIR")); |
666 | bgtype->insertItem( tr("Tiled") ); | 713 | #else |
667 | bgtype->insertItem( tr("Fitted") ); | 714 | QString codecpath(getenv("QTDIR")); |
715 | #endif | ||
716 | codecpath += "/plugins/reader/outcodecs"; | ||
717 | #else | ||
718 | QString codecpath(getenv("READERDIR")); | ||
719 | codecpath += "/outcodecs"; | ||
720 | #endif | ||
721 | QDir ocd(codecpath, "lib*.so"); | ||
722 | for (int i = 0; i < ocd.count(); ++i) | ||
723 | { | ||
724 | QString tmp(ocd[i]); | ||
725 | outcodec->insertItem(tmp.mid(3,tmp.length()-6)); | ||
726 | } | ||
727 | outcodec->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||
668 | } | 728 | } |
669 | 729 | ||
670 | CMiscPrefs::~CMiscPrefs() | 730 | CScrollPrefs::~CScrollPrefs() |
671 | { | 731 | { |
672 | // no need to delete child widgets, Qt does it all for us | 732 | // no need to delete child widgets, Qt does it all for us |
673 | } | 733 | } |
674 | 734 | ||
735 | |||
675 | CPrefs::CPrefs( int w, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) | 736 | CPrefs::CPrefs( int w, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) |
676 | { | 737 | { |
677 | setCaption(tr( "OpieReader Settings" ) ); | 738 | setCaption(tr( "OpieReader Settings" ) ); |
678 | QTabWidget* td = new QTabWidget(this); | 739 | QTabWidget* td = new QTabWidget(this); |
679 | layout = new CLayoutPrefs(this); | 740 | layout = new CLayoutPrefs(this); |
680 | layout2 = new CLayoutPrefs2(w, this); | 741 | layout2 = new CLayoutPrefs2(w, this); |
742 | scroll = new CScrollPrefs(this); | ||
681 | misc = new CMiscPrefs(this); | 743 | misc = new CMiscPrefs(this); |
682 | // button = new CButtonPrefs(kmap, this); | 744 | // button = new CButtonPrefs(kmap, this); |
683 | inter = new CInterPrefs(this); | 745 | inter = new CInterPrefs(this); |
684 | td->addTab(layout, tr("Layout")); | 746 | td->addTab(layout, tr("Layout")); |
685 | td->addTab(layout2, tr("Layout(2)")); | 747 | td->addTab(layout2, tr("Layout(2)")); |
686 | td->addTab(inter, tr("Locale")); | 748 | td->addTab(inter, tr("Locale")); |
749 | td->addTab(scroll, tr("Scroll")); | ||
687 | td->addTab(misc, tr("Misc")); | 750 | td->addTab(misc, tr("Misc")); |
688 | // td->addTab(button, tr("Buttons")); | 751 | // td->addTab(button, tr("Buttons")); |
689 | QVBoxLayout* v = new QVBoxLayout(this); | 752 | QVBoxLayout* v = new QVBoxLayout(this); |
690 | v->addWidget(td); | 753 | v->addWidget(td); |
691 | 754 | ||
692 | if (fs) showMaximized(); | 755 | if (fs) showMaximized(); |
693 | } | 756 | } |
694 | 757 | ||
695 | 758 | ||
696 | /* | 759 | /* |
697 | 760 | ||
698 | Unicode | 761 | Unicode |
699 | Ideo/Word | 762 | Ideo/Word |
700 | Width | 763 | Width |
701 | Encoding | 764 | Encoding |
702 | 765 | ||
703 | */ | 766 | */ |
704 | 767 | ||
705 | #include "CEncoding_tables.h" | 768 | #include "CEncoding_tables.h" |
706 | 769 | ||
707 | CInterPrefs::CInterPrefs( QWidget* parent, const char* name, WFlags fl ) | 770 | CInterPrefs::CInterPrefs( QWidget* parent, const char* name, WFlags fl ) |
708 | : QWidget( parent, name, fl ) | 771 | : QWidget( parent, name, fl ) |
709 | { | 772 | { |
710 | QHBoxLayout* hb = new QHBoxLayout(this); | 773 | QHBoxLayout* hb = new QHBoxLayout(this); |
711 | 774 | ||
712 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("International"), this); | 775 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("International"), this); |
713 | 776 | ||
714 | hb->addWidget(gb); | 777 | hb->addWidget(gb); |
715 | 778 | ||
716 | QLabel *TextLabel; | 779 | QLabel *TextLabel; |
717 | 780 | ||
718 | ideogram = new QCheckBox( gb ); | 781 | ideogram = new QCheckBox( gb ); |
719 | ideogram->setText( tr( "Ideograms" ) ); | 782 | ideogram->setText( tr( "Ideograms" ) ); |
720 | 783 | ||
721 | TextLabel = new QLabel( gb ); | 784 | TextLabel = new QLabel( gb ); |
722 | TextLabel->setText( tr( "Ideogram Width" ) ); | 785 | TextLabel->setText( tr( "Ideogram Width" ) ); |
723 | ideogramwidth = new QSpinBox( gb ); | 786 | ideogramwidth = new QSpinBox( gb ); |
724 | ideogramwidth->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 787 | ideogramwidth->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
725 | ideogramwidth->setRange(1,200); | 788 | ideogramwidth->setRange(1,200); |
726 | 789 | ||
727 | propfontchange = new QCheckBox( gb ); | 790 | propfontchange = new QCheckBox( gb ); |
728 | propfontchange->setText( tr( "Apply font\nto dialogs" ) ); | 791 | propfontchange->setText( tr( "Apply font\nto dialogs" ) ); |
729 | 792 | ||
730 | TextLabel = new QLabel( gb ); | 793 | TextLabel = new QLabel( gb ); |
731 | TextLabel->setText( tr( "Encoding" ) ); | 794 | TextLabel->setText( tr( "Encoding" ) ); |
732 | #ifdef USECOMBO | 795 | #ifdef USECOMBO |
733 | encoding = new QComboBox(gb); | 796 | encoding = new QComboBox(gb); |
734 | #else | 797 | #else |
735 | encoding = new MenuButton(gb); | 798 | encoding = new MenuButton(gb); |
736 | #endif | 799 | #endif |
737 | encoding->insertItem("Ascii"); | 800 | encoding->insertItem("Ascii"); |
738 | encoding->insertItem("UTF-8"); | 801 | encoding->insertItem("UTF-8"); |
739 | encoding->insertItem("UCS-2(BE)"); | 802 | encoding->insertItem("UCS-2(BE)"); |
740 | encoding->insertItem("USC-2(LE)"); | 803 | encoding->insertItem("USC-2(LE)"); |
741 | encoding->insertItem("Palm"); | 804 | encoding->insertItem("Palm"); |
742 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) | 805 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) |
743 | { | 806 | { |
744 | encoding->insertItem(iter->mime); | 807 | encoding->insertItem(iter->mime); |
745 | } | 808 | } |
746 | 809 | ||
747 | QVBoxLayout* vb = new QVBoxLayout; | 810 | QVBoxLayout* vb = new QVBoxLayout; |
748 | 811 | ||
749 | gb = new QGroupBox(1, Qt::Horizontal, "Dictionary", this); | 812 | gb = new QGroupBox(1, Qt::Horizontal, "Dictionary", this); |
750 | 813 | ||
751 | TextLabel = new QLabel( gb ); | 814 | TextLabel = new QLabel( gb ); |
752 | TextLabel->setText( tr( "Application" ) ); | 815 | TextLabel->setText( tr( "Application" ) ); |
753 | application = new QLineEdit(gb); | 816 | application = new QLineEdit(gb); |
754 | application->setFixedWidth(80); | 817 | application->setFixedWidth(80); |
755 | 818 | ||
756 | TextLabel = new QLabel( gb ); | 819 | TextLabel = new QLabel( gb ); |
757 | TextLabel->setText( tr( "Message" ) ); | 820 | TextLabel->setText( tr( "Message" ) ); |
758 | message = new QLineEdit(gb); | 821 | message = new QLineEdit(gb); |
759 | message->setFixedWidth(80); | 822 | message->setFixedWidth(80); |
760 | // message->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 823 | // message->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
761 | twotouch = new QCheckBox( gb ); | 824 | twotouch = new QCheckBox( gb ); |
762 | twotouch->setText( tr( "Two/One\nTouch" ) ); | 825 | twotouch->setText( tr( "Two/One\nTouch" ) ); |
763 | 826 | ||
764 | SwapMouse = new QCheckBox( gb ); | 827 | SwapMouse = new QCheckBox( gb ); |
765 | SwapMouse->setText("Swap Tap\nActions"); | 828 | SwapMouse->setText("Swap Tap\nActions"); |
766 | 829 | ||
767 | 830 | ||
768 | vb->addWidget(gb); | 831 | vb->addWidget(gb); |
769 | 832 | ||
770 | // vb->addStretch(); | 833 | // vb->addStretch(); |
771 | hb->addLayout(vb); | 834 | hb->addLayout(vb); |
772 | } | 835 | } |
773 | 836 | ||
774 | CInterPrefs::~CInterPrefs() | 837 | CInterPrefs::~CInterPrefs() |
775 | { | 838 | { |
776 | // no need to delete child widgets, Qt does it all for us | 839 | // no need to delete child widgets, Qt does it all for us |
777 | } | 840 | } |
diff --git a/noncore/apps/opie-reader/Prefs.h b/noncore/apps/opie-reader/Prefs.h index cf12b70..103484e 100644 --- a/noncore/apps/opie-reader/Prefs.h +++ b/noncore/apps/opie-reader/Prefs.h | |||
@@ -1,385 +1,430 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form interface generated from reading ui file 'Prefs.ui' | 2 | ** Form interface generated from reading ui file 'Prefs.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Feb 11 23:53:32 2003 | 4 | ** Created: Tue Feb 11 23:53:32 2003 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #ifndef CPREFS_H | 9 | #ifndef CPREFS_H |
10 | #define CPREFS_H | 10 | #define CPREFS_H |
11 | 11 | ||
12 | #include <qvariant.h> | 12 | #include <qvariant.h> |
13 | #include <qwidget.h> | 13 | #include <qwidget.h> |
14 | #include <qtabdialog.h> | 14 | #include <qtabdialog.h> |
15 | #include <qtabwidget.h> | 15 | #include <qtabwidget.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qlineedit.h> | 18 | #include <qlineedit.h> |
19 | 19 | ||
20 | #define USECOMBO | 20 | #define USECOMBO |
21 | 21 | ||
22 | #ifdef USECOMBO | 22 | #ifdef USECOMBO |
23 | #include <qcombobox.h> | 23 | #include <qcombobox.h> |
24 | #else | 24 | #else |
25 | #include <qpe/menubutton.h> | 25 | #include <qpe/menubutton.h> |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | #include "orkey.h" | 28 | #include "orkey.h" |
29 | 29 | ||
30 | class QVBoxLayout; | 30 | class QVBoxLayout; |
31 | class QHBoxLayout; | 31 | class QHBoxLayout; |
32 | class QGridLayout; | 32 | class QGridLayout; |
33 | //class QCheckBox; | 33 | //class QCheckBox; |
34 | class QLabel; | 34 | class QLabel; |
35 | //class QSpinBox; | 35 | //class QSpinBox; |
36 | class QListViewItem; | 36 | class QListViewItem; |
37 | 37 | ||
38 | class CLayoutPrefs : public QWidget | 38 | class CLayoutPrefs : public QWidget |
39 | { | 39 | { |
40 | 40 | ||
41 | public: | 41 | public: |
42 | 42 | ||
43 | friend class CPrefs; | 43 | friend class CPrefs; |
44 | 44 | ||
45 | CLayoutPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 45 | CLayoutPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
46 | ~CLayoutPrefs(); | 46 | ~CLayoutPrefs(); |
47 | 47 | ||
48 | QCheckBox* StripCR; | 48 | QCheckBox* StripCR; |
49 | QCheckBox* Dehyphen; | 49 | QCheckBox* Dehyphen; |
50 | QCheckBox* SingleSpace; | 50 | QCheckBox* SingleSpace; |
51 | QCheckBox* Unindent; | 51 | QCheckBox* Unindent; |
52 | QCheckBox* Reparagraph; | 52 | QCheckBox* Reparagraph; |
53 | QCheckBox* DoubleSpace; | 53 | QCheckBox* DoubleSpace; |
54 | QCheckBox* Remap; | 54 | QCheckBox* Remap; |
55 | QCheckBox* Embolden; | 55 | QCheckBox* Embolden; |
56 | QCheckBox* FullJustify; | 56 | QCheckBox* FullJustify; |
57 | QCheckBox* FixGraphics; | 57 | QCheckBox* FixGraphics; |
58 | QCheckBox* hyphenate; | 58 | QCheckBox* hyphenate; |
59 | // QCheckBox* customhyphen; | 59 | // QCheckBox* customhyphen; |
60 | QCheckBox* prepalm; | 60 | QCheckBox* prepalm; |
61 | QCheckBox* pkern; | 61 | QCheckBox* pkern; |
62 | // QCheckBox* Inverse; | 62 | // QCheckBox* Inverse; |
63 | // QCheckBox* Negative; | 63 | // QCheckBox* Negative; |
64 | QCheckBox* InlineTables; | ||
65 | QCheckBox* Underlinelinks; | ||
64 | }; | 66 | }; |
65 | 67 | ||
66 | class CLayoutPrefs2 : public QWidget | 68 | class CLayoutPrefs2 : public QWidget |
67 | { | 69 | { |
68 | 70 | ||
69 | public: | 71 | public: |
70 | 72 | ||
71 | friend class CPrefs; | 73 | friend class CPrefs; |
72 | 74 | ||
73 | CLayoutPrefs2( int w, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 75 | CLayoutPrefs2( int w, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
74 | ~CLayoutPrefs2(); | 76 | ~CLayoutPrefs2(); |
75 | 77 | ||
76 | QSpinBox* ParaLead; | 78 | QSpinBox* ParaLead; |
77 | QSpinBox* LineLead; | 79 | QSpinBox* LineLead; |
78 | QSpinBox* Indent; | 80 | QSpinBox* Indent; |
79 | QSpinBox *TopMargin, *BottomMargin, *LeftMargin, *RightMargin, *gfxzoom, *pageoverlap; | 81 | QSpinBox *TopMargin, *BottomMargin, *LeftMargin, *RightMargin, *gfxzoom, *pageoverlap; |
80 | #ifdef USECOMBO | 82 | #ifdef USECOMBO |
81 | QComboBox *Markup, *fontselector, *fgsel, *bgsel; | 83 | QComboBox *Markup, *fontselector, *fgsel, *bgsel; |
82 | #else | 84 | #else |
83 | MenuButton *Markup, *fontselector, *fgsel, *bgsel; | 85 | MenuButton *Markup, *fontselector, *fgsel, *bgsel; |
84 | #endif | 86 | #endif |
85 | }; | 87 | }; |
86 | 88 | ||
87 | /* | 89 | /* |
88 | class CPluckerPrefs : public QWidget | 90 | class CPluckerPrefs : public QWidget |
89 | { | 91 | { |
90 | 92 | ||
91 | public: | 93 | public: |
92 | 94 | ||
93 | friend class CPrefs; | 95 | friend class CPrefs; |
94 | 96 | ||
95 | CPluckerPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 97 | CPluckerPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
96 | ~CPluckerPrefs(); | 98 | ~CPluckerPrefs(); |
97 | 99 | ||
98 | QCheckBox* Depluck; | 100 | QCheckBox* Depluck; |
99 | QCheckBox* Dejpluck; | 101 | QCheckBox* Dejpluck; |
100 | QCheckBox* Continuous; | 102 | QCheckBox* Continuous; |
103 | QCheckBox* DoubleBuffer; | ||
101 | protected: | 104 | protected: |
102 | 105 | ||
103 | QHBoxLayout* Layout5; | 106 | QHBoxLayout* Layout5; |
104 | QVBoxLayout* Layout11; | 107 | QVBoxLayout* Layout11; |
105 | QGridLayout* Layout4; | 108 | QGridLayout* Layout4; |
106 | 109 | ||
107 | }; | 110 | }; |
108 | */ | 111 | */ |
109 | class CMiscPrefs : public QWidget | 112 | class CMiscPrefs : public QWidget |
110 | { | 113 | { |
111 | 114 | ||
112 | public: | 115 | public: |
113 | 116 | ||
114 | friend class CPrefs; | 117 | friend class CPrefs; |
115 | 118 | ||
116 | CMiscPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 119 | CMiscPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
117 | ~CMiscPrefs(); | 120 | ~CMiscPrefs(); |
118 | 121 | ||
119 | QCheckBox *annotation, *dictionary, *clipboard; | 122 | QCheckBox *annotation, *dictionary, *clipboard, *boutput; |
120 | QCheckBox *Depluck, *Dejpluck, *Continuous; | 123 | QCheckBox *Depluck, *Dejpluck, *Continuous, *DoubleBuffer; |
124 | |||
125 | #ifdef USECOMBO | ||
126 | QComboBox *bgtype, *minibarcol; | ||
127 | #else | ||
128 | MenuButton *bgtype, *minibarcol; | ||
129 | #endif | ||
130 | }; | ||
131 | |||
132 | class CScrollPrefs : public QWidget | ||
133 | { | ||
134 | |||
135 | public: | ||
136 | |||
137 | friend class CPrefs; | ||
138 | |||
139 | CScrollPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | ||
140 | ~CScrollPrefs(); | ||
121 | 141 | ||
122 | QSpinBox *scrollstep; | 142 | QSpinBox *scrollstep; |
123 | 143 | ||
124 | #ifdef USECOMBO | 144 | #ifdef USECOMBO |
125 | QComboBox *scrollcolor, *bgtype, *scrolltype, *minibarcol; | 145 | QComboBox *scrollcolor, *scrolltype, *outcodec; |
126 | #else | 146 | #else |
127 | MenuButton *scrollcolor, *bgtype, *scrolltype, *minibarcol; | 147 | MenuButton *scrollcolor, *scrolltype, *outcodec; |
128 | #endif | 148 | #endif |
129 | }; | 149 | }; |
130 | /* | 150 | /* |
131 | class QListView; | 151 | class QListView; |
132 | class QListViewItem; | 152 | class QListViewItem; |
133 | 153 | ||
134 | class CButtonPrefs : public QWidget | 154 | sclass CButtonPrefs : public QWidget |
135 | { | 155 | { |
136 | Q_OBJECT | 156 | Q_OBJECT |
137 | QMap<orKey, int> *kmap; | 157 | QMap<orKey, int> *kmap; |
138 | QMap<orKey, QListViewItem*> listmap; | 158 | QMap<orKey, QListViewItem*> listmap; |
139 | QListView* lb; | 159 | QListView* lb; |
140 | void keyPressEvent(QKeyEvent* e); | 160 | void keyPressEvent(QKeyEvent* e); |
141 | #ifdef USECOMBO | 161 | #ifdef USECOMBO |
142 | void populate(QComboBox*); | 162 | void populate(QComboBox*); |
143 | #else | 163 | #else |
144 | void populate(MenuButton*); | 164 | void populate(MenuButton*); |
145 | #endif | 165 | #endif |
146 | public: | 166 | public: |
147 | 167 | ||
148 | friend class CPrefs; | 168 | friend class CPrefs; |
149 | 169 | ||
150 | CButtonPrefs( QMap<orKey, int>*, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 170 | CButtonPrefs( QMap<orKey, int>*, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
151 | ~CButtonPrefs(); | 171 | ~CButtonPrefs(); |
152 | 172 | ||
153 | #ifdef USECOMBO | 173 | #ifdef USECOMBO |
154 | QComboBox *action; | 174 | QComboBox *action; |
155 | #else | 175 | #else |
156 | MenuButton *action; | 176 | MenuButton *action; |
157 | #endif | 177 | #endif |
158 | QSpinBox* debounce; | 178 | QSpinBox* debounce; |
159 | 179 | ||
160 | // QCheckBox *leftScroll, *rightScroll, *upScroll, *downScroll; | 180 | // QCheckBox *leftScroll, *rightScroll, *upScroll, *downScroll; |
161 | private slots: | 181 | private slots: |
162 | void erasemapping(QListViewItem*); | 182 | void erasemapping(QListViewItem*); |
163 | }; | 183 | }; |
164 | */ | 184 | */ |
165 | class CInterPrefs : public QWidget | 185 | class CInterPrefs : public QWidget |
166 | { | 186 | { |
167 | 187 | ||
168 | public: | 188 | public: |
169 | 189 | ||
170 | friend class CPrefs; | 190 | friend class CPrefs; |
171 | 191 | ||
172 | CInterPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 192 | CInterPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
173 | ~CInterPrefs(); | 193 | ~CInterPrefs(); |
174 | 194 | ||
175 | QCheckBox *ideogram, *propfontchange, *SwapMouse, *twotouch; | 195 | QCheckBox *ideogram, *propfontchange, *SwapMouse, *twotouch; |
176 | #ifdef USECOMBO | 196 | #ifdef USECOMBO |
177 | QComboBox* encoding; | 197 | QComboBox* encoding; |
178 | #else | 198 | #else |
179 | MenuButton* encoding; | 199 | MenuButton* encoding; |
180 | #endif | 200 | #endif |
181 | QSpinBox* ideogramwidth; | 201 | QSpinBox* ideogramwidth; |
182 | QLineEdit *application, *message; | 202 | QLineEdit *application, *message; |
183 | }; | 203 | }; |
184 | 204 | ||
185 | 205 | ||
186 | class CPrefs : public QDialog | 206 | class CPrefs : public QDialog |
187 | { | 207 | { |
188 | Q_OBJECT | 208 | Q_OBJECT |
189 | CLayoutPrefs* layout; | 209 | CLayoutPrefs* layout; |
190 | CLayoutPrefs2* layout2; | 210 | CLayoutPrefs2* layout2; |
191 | CMiscPrefs* misc; | 211 | CMiscPrefs* misc; |
192 | // CButtonPrefs* button; | 212 | CScrollPrefs* scroll; |
193 | CInterPrefs* inter; | 213 | CInterPrefs* inter; |
194 | 214 | ||
195 | void keyPressEvent(QKeyEvent* e) | 215 | void keyPressEvent(QKeyEvent* e) |
196 | { | 216 | { |
197 | switch (e->key()) | 217 | switch (e->key()) |
198 | { | 218 | { |
199 | case Key_Escape: | 219 | case Key_Escape: |
200 | e->accept(); | 220 | e->accept(); |
201 | reject(); | 221 | reject(); |
202 | break; | 222 | break; |
203 | case Key_Space: | 223 | case Key_Space: |
204 | case Key_Return: | 224 | case Key_Return: |
205 | e->accept(); | 225 | e->accept(); |
206 | accept(); | 226 | accept(); |
207 | break; | 227 | break; |
208 | default: | 228 | default: |
209 | QWidget::keyPressEvent(e); | 229 | QWidget::keyPressEvent(e); |
210 | } | 230 | } |
211 | } | 231 | } |
212 | public: | 232 | public: |
213 | CPrefs(int w, bool fs = true, QWidget* parent = 0, const char* name = 0); | 233 | CPrefs(int w, bool fs = true, QWidget* parent = 0, const char* name = 0); |
214 | ~CPrefs() | 234 | ~CPrefs() |
215 | { | 235 | { |
216 | } | 236 | } |
217 | bool hyphenate() { return layout->hyphenate->isChecked(); } | 237 | bool hyphenate() { return layout->hyphenate->isChecked(); } |
218 | void hyphenate(bool _v) { layout->hyphenate->setChecked(_v); } | 238 | void hyphenate(bool _v) { layout->hyphenate->setChecked(_v); } |
219 | /* | 239 | /* |
220 | bool customhyphen() { return layout->customhyphen->isChecked(); } | 240 | bool customhyphen() { return layout->customhyphen->isChecked(); } |
221 | void customhyphen(bool _v) { layout->customhyphen->setChecked(_v); } | 241 | void customhyphen(bool _v) { layout->customhyphen->setChecked(_v); } |
222 | */ | 242 | */ |
223 | bool StripCR() { return layout->StripCR->isChecked(); } | 243 | bool StripCR() { return layout->StripCR->isChecked(); } |
244 | bool InlineTables() { return layout->InlineTables->isChecked(); } | ||
224 | bool repalm() { return layout->prepalm->isChecked(); } | 245 | bool repalm() { return layout->prepalm->isChecked(); } |
246 | bool UnderlineLink() { return layout->Underlinelinks->isChecked(); } | ||
225 | bool kern() { return layout->pkern->isChecked(); } | 247 | bool kern() { return layout->pkern->isChecked(); } |
226 | bool Dehyphen() { return layout->Dehyphen->isChecked(); } | 248 | bool Dehyphen() { return layout->Dehyphen->isChecked(); } |
227 | bool SingleSpace() { return layout->SingleSpace->isChecked(); } | 249 | bool SingleSpace() { return layout->SingleSpace->isChecked(); } |
228 | bool Unindent() { return layout->Unindent->isChecked(); } | 250 | bool Unindent() { return layout->Unindent->isChecked(); } |
229 | bool Reparagraph() { return layout->Reparagraph->isChecked(); } | 251 | bool Reparagraph() { return layout->Reparagraph->isChecked(); } |
230 | bool DoubleSpace() { return layout->DoubleSpace->isChecked(); } | 252 | bool DoubleSpace() { return layout->DoubleSpace->isChecked(); } |
231 | bool Remap() { return layout->Remap->isChecked(); } | 253 | bool Remap() { return layout->Remap->isChecked(); } |
232 | bool Embolden() { return layout->Embolden->isChecked(); } | 254 | bool Embolden() { return layout->Embolden->isChecked(); } |
233 | bool FullJustify() { return layout->FullJustify->isChecked(); } | 255 | bool FullJustify() { return layout->FullJustify->isChecked(); } |
234 | // bool Inverse() { return layout->Inverse->isChecked(); } | 256 | // bool Inverse() { return layout->Inverse->isChecked(); } |
235 | // bool Negative() { return layout->Negative->isChecked(); } | 257 | // bool Negative() { return layout->Negative->isChecked(); } |
236 | bool FixGraphics() { return layout->FixGraphics->isChecked(); } | 258 | bool FixGraphics() { return layout->FixGraphics->isChecked(); } |
237 | int ParaLead() { return layout2->ParaLead->value(); } | 259 | int ParaLead() { return layout2->ParaLead->value(); } |
238 | int LineLead() { return layout2->LineLead->value(); } | 260 | int LineLead() { return layout2->LineLead->value(); } |
239 | int TopMargin() { return layout2->TopMargin->value(); } | 261 | int TopMargin() { return layout2->TopMargin->value(); } |
240 | int BottomMargin() { return layout2->BottomMargin->value(); } | 262 | int BottomMargin() { return layout2->BottomMargin->value(); } |
241 | int LeftMargin() { return layout2->LeftMargin->value(); } | 263 | int LeftMargin() { return layout2->LeftMargin->value(); } |
242 | int RightMargin() { return layout2->RightMargin->value(); } | 264 | int RightMargin() { return layout2->RightMargin->value(); } |
243 | int Indent() { return layout2->Indent->value(); } | 265 | int Indent() { return layout2->Indent->value(); } |
244 | int Markup() { return layout2->Markup->currentItem(); } | 266 | int Markup() { return layout2->Markup->currentItem(); } |
245 | QString Font() { return layout2->fontselector->currentText(); } | 267 | QString Font() { return layout2->fontselector->currentText(); } |
246 | 268 | ||
247 | 269 | ||
248 | void StripCR(bool v) { layout->StripCR->setChecked(v); } | 270 | void StripCR(bool v) { layout->StripCR->setChecked(v); } |
271 | void InlineTables(bool v) { layout->InlineTables->setChecked(v); } | ||
249 | void repalm(bool v) { layout->prepalm->setChecked(v); } | 272 | void repalm(bool v) { layout->prepalm->setChecked(v); } |
273 | void UnderlineLink(bool v) { layout->Underlinelinks->setChecked(v); } | ||
250 | void kern(bool v) { layout->pkern->setChecked(v); } | 274 | void kern(bool v) { layout->pkern->setChecked(v); } |
251 | void Dehyphen(bool v) { layout->Dehyphen->setChecked(v); } | 275 | void Dehyphen(bool v) { layout->Dehyphen->setChecked(v); } |
252 | void SingleSpace(bool v) { layout->SingleSpace->setChecked(v); } | 276 | void SingleSpace(bool v) { layout->SingleSpace->setChecked(v); } |
253 | void Unindent(bool v) { layout->Unindent->setChecked(v); } | 277 | void Unindent(bool v) { layout->Unindent->setChecked(v); } |
254 | void Reparagraph(bool v) { layout->Reparagraph->setChecked(v); } | 278 | void Reparagraph(bool v) { layout->Reparagraph->setChecked(v); } |
255 | void DoubleSpace(bool v) { layout->DoubleSpace->setChecked(v); } | 279 | void DoubleSpace(bool v) { layout->DoubleSpace->setChecked(v); } |
256 | void Remap(bool v) { layout->Remap->setChecked(v); } | 280 | void Remap(bool v) { layout->Remap->setChecked(v); } |
257 | void Embolden(bool v) { layout->Embolden->setChecked(v); } | 281 | void Embolden(bool v) { layout->Embolden->setChecked(v); } |
258 | void FullJustify(bool v) { layout->FullJustify->setChecked(v); } | 282 | void FullJustify(bool v) { layout->FullJustify->setChecked(v); } |
259 | // void Negative(bool v) { layout->Negative->setChecked(v); } | 283 | // void Negative(bool v) { layout->Negative->setChecked(v); } |
260 | // void Inverse(bool v) { layout->Inverse->setChecked(v); } | 284 | // void Inverse(bool v) { layout->Inverse->setChecked(v); } |
261 | void FixGraphics(bool v) { layout->FixGraphics->setChecked(v); } | 285 | void FixGraphics(bool v) { layout->FixGraphics->setChecked(v); } |
262 | void ParaLead(int v) { layout2->ParaLead->setValue(v); } | 286 | void ParaLead(int v) { layout2->ParaLead->setValue(v); } |
263 | void LineLead(int v) { layout2->LineLead->setValue(v); } | 287 | void LineLead(int v) { layout2->LineLead->setValue(v); } |
264 | void TopMargin(int v) { layout2->TopMargin->setValue(v); } | 288 | void TopMargin(int v) { layout2->TopMargin->setValue(v); } |
265 | void BottomMargin(int v) { layout2->BottomMargin->setValue(v); } | 289 | void BottomMargin(int v) { layout2->BottomMargin->setValue(v); } |
266 | void LeftMargin(int v) { layout2->LeftMargin->setValue(v); } | 290 | void LeftMargin(int v) { layout2->LeftMargin->setValue(v); } |
267 | void RightMargin(int v) { layout2->RightMargin->setValue(v); } | 291 | void RightMargin(int v) { layout2->RightMargin->setValue(v); } |
268 | void Indent(int v) { layout2->Indent->setValue(v); } | 292 | void Indent(int v) { layout2->Indent->setValue(v); } |
269 | #ifdef USECOMBO | 293 | #ifdef USECOMBO |
270 | void Markup(int v) { layout2->Markup->setCurrentItem(v); } | 294 | void Markup(int v) { layout2->Markup->setCurrentItem(v); } |
271 | #else | 295 | #else |
272 | void Markup(int v) { layout2->Markup->select(v); } | 296 | void Markup(int v) { layout2->Markup->select(v); } |
273 | #endif | 297 | #endif |
274 | #ifdef USECOMBO | 298 | #ifdef USECOMBO |
275 | void bgtype(int v) { misc->bgtype->setCurrentItem(v); } | 299 | void bgtype(int v) { misc->bgtype->setCurrentItem(v); } |
276 | void scrollcolor(int v) { misc->scrollcolor->setCurrentItem(v); } | 300 | void scrollcolor(int v) { scroll->scrollcolor->setCurrentItem(v); } |
277 | void minibarcol(int v) { misc->minibarcol->setCurrentItem(v); } | 301 | void minibarcol(int v) { misc->minibarcol->setCurrentItem(v); } |
278 | #else | 302 | #else |
279 | void bgtype(int v) { misc->bgtype->select(v); } | 303 | void bgtype(int v) { misc->bgtype->select(v); } |
280 | void scrollcolor(int v) { misc->scrollcolor->select(v); } | 304 | void scrollcolor(int v) { scroll->scrollcolor->select(v); } |
281 | void minibarcol(int v) { misc->minibarcol->select(v); } | 305 | void minibarcol(int v) { misc->minibarcol->select(v); } |
282 | #endif | 306 | #endif |
283 | int bgtype() { return misc->bgtype->currentItem(); } | 307 | int bgtype() { return misc->bgtype->currentItem(); } |
284 | int scrollcolor() { return misc->scrollcolor->currentItem(); } | 308 | int scrollcolor() { return scroll->scrollcolor->currentItem(); } |
285 | int minibarcol() { return misc->minibarcol->currentItem(); } | 309 | int minibarcol() { return misc->minibarcol->currentItem(); } |
286 | 310 | ||
287 | 311 | ||
288 | #ifdef USECOMBO | 312 | #ifdef USECOMBO |
289 | void foreground(int v) { layout2->fgsel->setCurrentItem(v); } | 313 | void foreground(int v) { layout2->fgsel->setCurrentItem(v); } |
290 | #else | 314 | #else |
291 | void foreground(int v) { layout2->fgsel->select(v); } | 315 | void foreground(int v) { layout2->fgsel->select(v); } |
292 | #endif | 316 | #endif |
293 | int foreground() { return layout2->fgsel->currentItem(); } | 317 | int foreground() { return layout2->fgsel->currentItem(); } |
294 | 318 | ||
295 | #ifdef USECOMBO | 319 | #ifdef USECOMBO |
296 | void background(int v) { layout2->bgsel->setCurrentItem(v); } | 320 | void background(int v) { layout2->bgsel->setCurrentItem(v); } |
297 | #else | 321 | #else |
298 | void background(int v) { layout2->bgsel->select(v); } | 322 | void background(int v) { layout2->bgsel->select(v); } |
299 | #endif | 323 | #endif |
300 | int background() { return layout2->bgsel->currentItem(); } | 324 | int background() { return layout2->bgsel->currentItem(); } |
301 | 325 | ||
302 | 326 | ||
303 | |||
304 | #ifdef USECOMBO | 327 | #ifdef USECOMBO |
305 | void Font(QString& s) | 328 | void Font(QString& s) |
306 | { | 329 | { |
307 | for (int i = 1; i <= layout2->fontselector->count(); i++) | 330 | for (int i = 1; i <= layout2->fontselector->count(); i++) |
308 | { | 331 | { |
309 | if (layout2->fontselector->text(i) == s) | 332 | if (layout2->fontselector->text(i) == s) |
310 | { | 333 | { |
311 | layout2->fontselector->setCurrentItem(i); | 334 | layout2->fontselector->setCurrentItem(i); |
312 | break; | 335 | break; |
313 | } | 336 | } |
314 | } | 337 | } |
315 | } | 338 | } |
316 | #else | 339 | #else |
317 | void Font(QString& s) { layout2->fontselector->select(s); } | 340 | void Font(QString& s) { layout2->fontselector->select(s); } |
318 | #endif | 341 | #endif |
319 | 342 | ||
343 | #ifdef USECOMBO | ||
344 | void outcodec(QString& s) | ||
345 | { | ||
346 | for (int i = 1; i <= scroll->outcodec->count(); i++) | ||
347 | { | ||
348 | if (scroll->outcodec->text(i) == s) | ||
349 | { | ||
350 | scroll->outcodec->setCurrentItem(i); | ||
351 | break; | ||
352 | } | ||
353 | } | ||
354 | } | ||
355 | #else | ||
356 | void outcodec(QString& s) { scroll->outcodec->select(s); } | ||
357 | #endif | ||
358 | QString outcodec() { return scroll->outcodec->currentText(); } | ||
359 | |||
360 | void miscoutput(bool v) { return misc->boutput->setChecked(v); } | ||
361 | bool miscoutput() { return misc->boutput->isChecked(); } | ||
362 | |||
320 | bool Depluck() { return misc->Depluck->isChecked(); } | 363 | bool Depluck() { return misc->Depluck->isChecked(); } |
321 | void Depluck(bool v) { misc->Depluck->setChecked(v); } | 364 | void Depluck(bool v) { misc->Depluck->setChecked(v); } |
322 | bool Dejpluck() { return misc->Dejpluck->isChecked(); } | 365 | bool Dejpluck() { return misc->Dejpluck->isChecked(); } |
323 | void Dejpluck(bool v) { misc->Dejpluck->setChecked(v); } | 366 | void Dejpluck(bool v) { misc->Dejpluck->setChecked(v); } |
324 | bool Continuous() { return misc->Continuous->isChecked(); } | 367 | bool Continuous() { return misc->Continuous->isChecked(); } |
325 | void Continuous(bool v) { misc->Continuous->setChecked(v); } | 368 | void Continuous(bool v) { misc->Continuous->setChecked(v); } |
369 | bool DoubleBuffer() { return misc->DoubleBuffer->isChecked(); } | ||
370 | void DoubleBuffer(bool v) { misc->DoubleBuffer->setChecked(v); } | ||
326 | bool SwapMouse() { return inter->SwapMouse->isChecked(); } | 371 | bool SwapMouse() { return inter->SwapMouse->isChecked(); } |
327 | void SwapMouse(bool v) { inter->SwapMouse->setChecked(v); } | 372 | void SwapMouse(bool v) { inter->SwapMouse->setChecked(v); } |
328 | 373 | ||
329 | 374 | ||
330 | void dictApplication(const QString& v) { inter->application->setText(v); } | 375 | void dictApplication(const QString& v) { inter->application->setText(v); } |
331 | QString dictApplication() { return inter->application->text(); } | 376 | QString dictApplication() { return inter->application->text(); } |
332 | void dictMessage(const QString& v) { inter->message->setText(v); } | 377 | void dictMessage(const QString& v) { inter->message->setText(v); } |
333 | QString dictMessage() { return inter->message->text(); } | 378 | QString dictMessage() { return inter->message->text(); } |
334 | 379 | ||
335 | void miscannotation(bool v) { misc->annotation->setChecked(v); } | 380 | void miscannotation(bool v) { misc->annotation->setChecked(v); } |
336 | void miscdictionary(bool v) { misc->dictionary->setChecked(v); } | 381 | void miscdictionary(bool v) { misc->dictionary->setChecked(v); } |
337 | void miscclipboard(bool v) { misc->clipboard->setChecked(v); } | 382 | void miscclipboard(bool v) { misc->clipboard->setChecked(v); } |
338 | bool miscannotation() { return misc->annotation->isChecked(); } | 383 | bool miscannotation() { return misc->annotation->isChecked(); } |
339 | bool miscdictionary() { return misc->dictionary->isChecked(); } | 384 | bool miscdictionary() { return misc->dictionary->isChecked(); } |
340 | bool miscclipboard() { return misc->clipboard->isChecked(); } | 385 | bool miscclipboard() { return misc->clipboard->isChecked(); } |
341 | /* | 386 | /* |
342 | int Debounce() { return button->debounce->value(); } | 387 | int Debounce() { return button->debounce->value(); } |
343 | void Debounce(int v) { button->debounce->setValue(v); } | 388 | void Debounce(int v) { button->debounce->setValue(v); } |
344 | */ | 389 | */ |
345 | /* | 390 | /* |
346 | bool leftScroll() { return button->leftScroll->isChecked(); } | 391 | bool leftScroll() { return button->leftScroll->isChecked(); } |
347 | void leftScroll(bool v) { button->leftScroll->setChecked(v); } | 392 | void leftScroll(bool v) { button->leftScroll->setChecked(v); } |
348 | bool rightScroll() { return button->rightScroll->isChecked(); } | 393 | bool rightScroll() { return button->rightScroll->isChecked(); } |
349 | void rightScroll(bool v) { button->rightScroll->setChecked(v); } | 394 | void rightScroll(bool v) { button->rightScroll->setChecked(v); } |
350 | bool upScroll() { return button->upScroll->isChecked(); } | 395 | bool upScroll() { return button->upScroll->isChecked(); } |
351 | void upScroll(bool v) { button->upScroll->setChecked(v); } | 396 | void upScroll(bool v) { button->upScroll->setChecked(v); } |
352 | bool downScroll() { return button->downScroll->isChecked(); } | 397 | bool downScroll() { return button->downScroll->isChecked(); } |
353 | void downScroll(bool v) { button->downScroll->setChecked(v); } | 398 | void downScroll(bool v) { button->downScroll->setChecked(v); } |
354 | */ | 399 | */ |
355 | 400 | ||
356 | int gfxsize() { return layout2->gfxzoom->value()/10; } | 401 | int gfxsize() { return layout2->gfxzoom->value()/10; } |
357 | void gfxsize(int v) { layout2->gfxzoom->setValue(10*v); } | 402 | void gfxsize(int v) { layout2->gfxzoom->setValue(10*v); } |
358 | int pageoverlap() { return layout2->pageoverlap->value(); } | 403 | int pageoverlap() { return layout2->pageoverlap->value(); } |
359 | void pageoverlap(int v) { layout2->pageoverlap->setValue(v); } | 404 | void pageoverlap(int v) { layout2->pageoverlap->setValue(v); } |
360 | 405 | ||
361 | bool twotouch() { return inter->twotouch->isChecked(); } | 406 | bool twotouch() { return inter->twotouch->isChecked(); } |
362 | void twotouch(bool v) { inter->twotouch->setChecked(v); } | 407 | void twotouch(bool v) { inter->twotouch->setChecked(v); } |
363 | 408 | ||
364 | bool ideogram() { return inter->ideogram->isChecked(); } | 409 | bool ideogram() { return inter->ideogram->isChecked(); } |
365 | void ideogram(bool v) { inter->ideogram->setChecked(v); } | 410 | void ideogram(bool v) { inter->ideogram->setChecked(v); } |
366 | 411 | ||
367 | int ideogramwidth() { return inter->ideogramwidth->value(); } | 412 | int ideogramwidth() { return inter->ideogramwidth->value(); } |
368 | void ideogramwidth(int v) { inter->ideogramwidth->setValue(v); } | 413 | void ideogramwidth(int v) { inter->ideogramwidth->setValue(v); } |
369 | 414 | ||
370 | bool propfontchange() { return inter->propfontchange->isChecked(); } | 415 | bool propfontchange() { return inter->propfontchange->isChecked(); } |
371 | void propfontchange(bool v) { inter->propfontchange->setChecked(v); } | 416 | void propfontchange(bool v) { inter->propfontchange->setChecked(v); } |
372 | 417 | ||
373 | int encoding() { return inter->encoding->currentItem(); } | 418 | int encoding() { return inter->encoding->currentItem(); } |
374 | int scrolltype() { return misc->scrolltype->currentItem(); } | 419 | int scrolltype() { return scroll->scrolltype->currentItem(); } |
375 | #ifdef USECOMBO | 420 | #ifdef USECOMBO |
376 | void encoding(int v) { inter->encoding->setCurrentItem(v); } | 421 | void encoding(int v) { inter->encoding->setCurrentItem(v); } |
377 | void scrolltype(int v) { misc->scrolltype->setCurrentItem(v); } | 422 | void scrolltype(int v) { scroll->scrolltype->setCurrentItem(v); } |
378 | #else | 423 | #else |
379 | void encoding(int v) { inter->encoding->select(v); } | 424 | void encoding(int v) { inter->encoding->select(v); } |
380 | void scrolltype(int v) { misc->scrolltype->select(v); } | 425 | void scrolltype(int v) { scroll->scrolltype->select(v); } |
381 | #endif | 426 | #endif |
382 | void scrollstep(int v) { misc->scrollstep->setValue(v); } | 427 | void scrollstep(int v) { scroll->scrollstep->setValue(v); } |
383 | int scrollstep() { return misc->scrollstep->value(); } | 428 | int scrollstep() { return scroll->scrollstep->value(); } |
384 | }; | 429 | }; |
385 | #endif // CPREFS_H | 430 | #endif // CPREFS_H |
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp index 33884a0..0c56dd4 100644 --- a/noncore/apps/opie-reader/QTReader.cpp +++ b/noncore/apps/opie-reader/QTReader.cpp | |||
@@ -1,2985 +1,3492 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This file is part of an example program for Qt. This example | 6 | ** This file is part of an example program for Qt. This example |
7 | ** program may be used, distributed and modified without limitation. | 7 | ** program may be used, distributed and modified without limitation. |
8 | ** | 8 | ** |
9 | *****************************************************************************/ | 9 | *****************************************************************************/ |
10 | 10 | ||
11 | const int _SBARHEIGHT = 3; | 11 | const int _SBARHEIGHT = 3; |
12 | 12 | ||
13 | #include <qpainter.h> | 13 | #include <qpainter.h> |
14 | //#include <qdirectpainter_qws.h> | 14 | //#include <qdirectpainter_qws.h> |
15 | #include <qimage.h> | 15 | #include <qimage.h> |
16 | #include <qtimer.h> | 16 | #include <qtimer.h> |
17 | #include "config.h" | 17 | #include "config.h" |
18 | #include "QTReader.h" | 18 | #include "QTReader.h" |
19 | //#include "QTReaderApp.h" | 19 | //#include "QTReaderApp.h" |
20 | #include "CDrawBuffer.h" | 20 | #include "CDrawBuffer.h" |
21 | #ifdef USEQPE | 21 | #ifdef USEQPE |
22 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | #endif | 23 | #endif |
24 | #include <math.h> | 24 | #include <math.h> |
25 | #include <ctype.h> | 25 | #include <ctype.h> |
26 | #include <stdio.h> //for sprintf | 26 | #include <stdio.h> //for sprintf |
27 | #ifdef USEQPE | 27 | #ifdef USEQPE |
28 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
29 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
30 | #include <qpe/global.h> | 30 | #include <qpe/global.h> |
31 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | #endif | 32 | #endif |
33 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include "TableDialog.h" | ||
36 | #include "outputcodec.h" | ||
35 | 37 | ||
38 | /* | ||
36 | #ifdef _UNICODE | 39 | #ifdef _UNICODE |
37 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; | 40 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; |
38 | #else | 41 | #else |
39 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; | 42 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; |
40 | #endif | 43 | #endif |
44 | */ | ||
41 | //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; | 45 | //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; |
42 | 46 | ||
43 | //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; | 47 | //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; |
44 | //const int QTReader::fontsizes[] = {10,16,17,22,0}; | 48 | //const int QTReader::fontsizes[] = {10,16,17,22,0}; |
45 | //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; | 49 | //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; |
46 | //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}; | 50 | //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}; |
47 | 51 | ||
48 | tchar QTReader::pluckernextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 }; | 52 | tchar QTReader::pluckernextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 }; |
49 | tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; | 53 | tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; |
50 | //tchar QTReader::jplucknextpart[] = { 10,'#',10,'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; | 54 | //tchar QTReader::jplucknextpart[] = { 10,'#',10,'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; |
51 | 55 | ||
52 | |||
53 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : | 56 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : |
54 | QWidget(parent, name, f), | 57 | QWidget(parent, name, f | WRepaintNoErase | WResizeNoErase), |
58 | m_outofdate(true), | ||
55 | m_default_fg(0,0,0), | 59 | m_default_fg(0,0,0), |
56 | m_default_bg(255,255,255), | 60 | m_default_bg(255,255,255), |
57 | m_bg(255,255,255), | 61 | m_bg(255,255,255), |
58 | m_delay(100), | 62 | m_delay(100), |
59 | m_scrolldy1(0), | 63 | m_scrolldy1(0), |
60 | m_scrolldy2(0), | 64 | m_scrolldy2(0), |
61 | m_totalscroll(0), | 65 | m_totalscroll(0), |
62 | m_autoScroll(false), | 66 | m_autoScroll(false), |
63 | //textarray(NULL), | 67 | //textarray(NULL), |
64 | //locnarray(NULL), | 68 | //locnarray(NULL), |
65 | numlines(0), | 69 | numlines(0), |
66 | m_fontname("unifont"), | 70 | m_fontname("unifont"), |
67 | m_fm(NULL), | 71 | m_fm(NULL), |
68 | mouseUpOn(true), | 72 | mouseUpOn(true), |
69 | m_twotouch(true), | 73 | m_twotouch(true), |
70 | m_touchone(true), | 74 | m_touchone(true), |
71 | bDoUpdates(false), | 75 | bDoUpdates(false), |
72 | #ifdef _SCROLLPIPE | 76 | #ifdef _SCROLLPIPE |
73 | m_pipeout(NULL), | 77 | m_pipeout(NULL), |
74 | #endif | 78 | #endif |
75 | m_left_border(2), | 79 | m_left_border(2), |
76 | m_right_border(2), | 80 | m_right_border(2), |
77 | m_rotated(true), | 81 | m_rotated(true), |
78 | pBkmklist(NULL), | 82 | pBkmklist(NULL), |
79 | m_scrollpos(0), | 83 | m_scrollpos(0), |
80 | // bNegative(false), | 84 | // bNegative(false), |
81 | bInverse(false), | 85 | bInverse(false), |
82 | m_highlightfilter(NULL), | 86 | m_highlightfilter(NULL), |
83 | m_bgIsScaled(false), | 87 | m_bgIsScaled(false), |
84 | m_scrollstep(2), | 88 | m_scrollstep(2), |
85 | m_topmargin(5), | 89 | m_topmargin(5), |
86 | m_bottommargin(5), | 90 | m_bottommargin(5), |
87 | m_reparastring("{\\n[\\n ]}"), | 91 | m_reparastring("{\\n[\\n ]}"), |
88 | m_currentlinkstyle(NULL), | 92 | m_currentlinkstyle(NULL), |
89 | m_currentlinkoffset(-1), | 93 | m_currentlinkoffset(-1), |
90 | m_currentlink(-1) | 94 | m_currentlink(-1) |
91 | { | 95 | { |
96 | m_output = NULL; | ||
92 | m_overlap = 1; | 97 | m_overlap = 1; |
93 | setKeyCompression ( true ); | 98 | setKeyCompression ( true ); |
94 | #ifdef DOUBLEBUFFER | ||
95 | dbuff = new QPixmap(); | ||
96 | dbp = new QPainter(); | ||
97 | // if (painter->isActive()) painter->end(); | ||
98 | // painter->begin(frame); | ||
99 | #endif | ||
100 | // init(); | ||
101 | 99 | ||
100 | dbuff = NULL; | ||
101 | dbp = NULL; | ||
102 | } | 102 | } |
103 | 103 | ||
104 | /* | 104 | /* |
105 | QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : | 105 | QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : |
106 | QWidget(parent, name, f), | 106 | QWidget(parent, name, f), |
107 | m_textfont(0), | 107 | m_textfont(0), |
108 | m_textsize(1), | 108 | m_textsize(1), |
109 | textarray(NULL), | 109 | textarray(NULL), |
110 | numlines(0), | 110 | numlines(0), |
111 | bstripcr(true), | 111 | bstripcr(true), |
112 | bunindent(false), | 112 | bunindent(false), |
113 | brepara(false), | 113 | brepara(false), |
114 | bdblspce(false), | 114 | bdblspce(false), |
115 | btight(false), | 115 | btight(false), |
116 | bindenter(0), | 116 | bindenter(0), |
117 | m_fm(NULL) | 117 | m_fm(NULL) |
118 | { | 118 | { |
119 | init(); | 119 | init(); |
120 | // // qDebug("Load_file(1)"); | 120 | // // qDeb2ug("Load_file(1)"); |
121 | load_file((const tchar*)filename); | 121 | load_file((const tchar*)filename); |
122 | } | 122 | } |
123 | */ | 123 | */ |
124 | 124 | ||
125 | /* | 125 | /* |
126 | void QTReader::mouseMoveEvent(QMouseEvent* _e) | 126 | void QTReader::mouseMoveEvent(QMouseEvent* _e) |
127 | { | 127 | { |
128 | 128 | ||
129 | mouseUpOn = !(_e->pos().x() == -1); | 129 | mouseUpOn = !(_e->pos().x() == -1); |
130 | 130 | ||
131 | qDebug("MouseMove:[%d, %d]", _e->pos().x(), _e->pos().y()); | 131 | qDebug("MouseMove:[%d, %d]", _e->pos().x(), _e->pos().y()); |
132 | } | 132 | } |
133 | */ | 133 | */ |
134 | long QTReader::real_delay() | 134 | long QTReader::real_delay() |
135 | { | 135 | { |
136 | return m_scrollstep*( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); | 136 | return m_scrollstep*( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); |
137 | } | 137 | } |
138 | 138 | ||
139 | void QTReader::mousePressEvent( QMouseEvent* _e ) | 139 | void QTReader::mousePressEvent( QMouseEvent* _e ) |
140 | { | 140 | { |
141 | buffdoc.unsuspend(); | 141 | m_drageligible = false; |
142 | qDebug("Mouse pressed at (%u, %u)", _e->x(), _e->y()); | ||
142 | int x, y, ht, wh; | 143 | int x, y, ht, wh; |
143 | if (m_rotated) | 144 | if (m_rotated) |
144 | { | 145 | { |
145 | x = _e->y(); | 146 | x = _e->y(); |
146 | y = width()-_e->x(); | 147 | y = width()-_e->x(); |
147 | ht = width(); | 148 | ht = width(); |
148 | wh = height(); | 149 | wh = height(); |
149 | } | 150 | } |
150 | else | 151 | else |
151 | { | 152 | { |
152 | x = _e->x(); | 153 | x = _e->x(); |
153 | y = _e->y(); | 154 | y = _e->y(); |
154 | ht = height(); | 155 | ht = height(); |
155 | wh = width(); | 156 | wh = width(); |
156 | } | 157 | } |
157 | if (_e->button() == RightButton) | 158 | if (x >= m_left_border && x <= wh - m_right_border && y >= m_topmargin && y <= ht-m_bottommargin) |
158 | { | 159 | { |
159 | //qDebug("MousePress"); | 160 | if (_e->button() == RightButton) |
160 | mouseUpOn = false; | ||
161 | if (m_swapmouse) | ||
162 | { | 161 | { |
163 | int lineno = 0; | 162 | //qDebug("MousePress"); |
164 | /* | 163 | mouseUpOn = false; |
164 | if (m_swapmouse) | ||
165 | { | ||
166 | int lineno = 0; | ||
167 | /* | ||
165 | int hgt = textarray[0]->lineSpacing(); | 168 | int hgt = textarray[0]->lineSpacing(); |
166 | while ((hgt < y) && (lineno < numlines)) | 169 | while ((hgt < y) && (lineno < numlines)) |
167 | { | 170 | { |
168 | hgt += textarray[++lineno]->lineSpacing(); | 171 | hgt += textarray[++lineno]->lineSpacing(); |
169 | } | 172 | } |
170 | */ | 173 | */ |
171 | size_t startpos, startoffset, tgt, tgtoffset, pictgt; | 174 | size_t startpos, startoffset, tgt, tgtoffset, pictgt, tabtgt; |
172 | QImage* img; | 175 | QImage* img; |
173 | getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img); | 176 | getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img, tabtgt); |
174 | processmousewordevent(startpos, startoffset, _e, lineno); | 177 | processmousewordevent(startpos, startoffset, _e, lineno); |
178 | } | ||
179 | else | ||
180 | { | ||
181 | processmousepositionevent(_e); | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | else | ||
186 | { | ||
187 | int ln = -1; | ||
188 | int mp; | ||
189 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); | ||
190 | switch (m_scrollpos) | ||
191 | { | ||
192 | case 1: | ||
193 | { | ||
194 | if (m_rotated) | ||
195 | { | ||
196 | if (_e->x() < m_bottommargin) | ||
197 | { | ||
198 | ln = height(); | ||
199 | mp = _e->y(); | ||
200 | } | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | if (_e->y() > height()-m_bottommargin) | ||
205 | { | ||
206 | ln = width(); | ||
207 | mp = _e->x(); | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | break; | ||
212 | case 2: | ||
213 | { | ||
214 | if (m_rotated) | ||
215 | { | ||
216 | if (_e->y() > height() - m_right_border) | ||
217 | { | ||
218 | ln = width(); | ||
219 | mp = width()-_e->x(); | ||
220 | } | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | if (_e->x() > width() - m_right_border) | ||
225 | { | ||
226 | ln = height(); | ||
227 | mp = _e->y(); | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | break; | ||
232 | case 3: | ||
233 | { | ||
234 | if (m_rotated) | ||
235 | { | ||
236 | if (_e->y() < m_left_border) | ||
237 | { | ||
238 | ln = width(); | ||
239 | mp = width()-_e->x(); | ||
240 | } | ||
241 | } | ||
242 | else | ||
243 | { | ||
244 | if (_e->x() < m_left_border) | ||
245 | { | ||
246 | ln = height(); | ||
247 | mp = _e->y(); | ||
248 | } | ||
249 | } | ||
250 | } | ||
251 | break; | ||
252 | case 0: | ||
253 | default: | ||
254 | ln = -1; | ||
255 | break; | ||
256 | } | ||
257 | if (ln >= 0) | ||
258 | { | ||
259 | int dp = (sectionsize*mp+ln/2)/ln + buffdoc.startSection(); | ||
260 | int winsize = locnarray[numlines]-locnarray[0]; | ||
261 | int slidersize = 10*(sectionsize+ln/2)/ln; | ||
262 | if (slidersize > winsize) | ||
263 | { | ||
264 | int mid = (locnarray[0] + locnarray[numlines])/2; | ||
265 | slidersize /= 2; | ||
266 | if (dp < mid-slidersize) | ||
267 | { | ||
268 | dopageup(); | ||
269 | } | ||
270 | else if (dp > mid+slidersize) | ||
271 | { | ||
272 | dopagedn(); | ||
273 | } | ||
274 | //if (mid-slidersize < dp && dp < mid+slidersize) | ||
275 | else | ||
276 | { | ||
277 | m_drageligible = true; | ||
278 | } | ||
279 | } | ||
280 | else | ||
281 | { | ||
282 | if (dp < locnarray[0]) | ||
283 | { | ||
284 | dopageup(); | ||
285 | } | ||
286 | else if (dp > locnarray[numlines]) | ||
287 | { | ||
288 | dopagedn(); | ||
289 | } | ||
290 | //if (locnarray[0] < dp && dp < locnarray[numlines]) | ||
291 | else | ||
292 | { | ||
293 | m_drageligible = true; | ||
294 | } | ||
295 | } | ||
296 | qDebug("Drag eligible:%s", (m_drageligible) ? "true" : "false"); | ||
297 | } | ||
298 | else | ||
299 | { | ||
300 | if (m_scrollpos == 1) | ||
301 | { | ||
302 | if (x < m_left_border) | ||
303 | { | ||
304 | lineUp(); | ||
305 | } | ||
306 | if (y > ht - m_bottommargin) | ||
307 | { | ||
308 | lineDown(); | ||
309 | } | ||
310 | } | ||
311 | else if (m_scrollpos != 0) | ||
312 | { | ||
313 | if (y < m_topmargin) | ||
314 | { | ||
315 | lineUp(); | ||
316 | } | ||
317 | if (y > ht - m_bottommargin) | ||
318 | { | ||
319 | lineDown(); | ||
320 | } | ||
321 | } | ||
175 | } | 322 | } |
176 | else | ||
177 | processmousepositionevent(_e); | ||
178 | } | 323 | } |
179 | } | 324 | } |
180 | 325 | ||
181 | void QTReader::processmousepositionevent( QMouseEvent* _e ) | 326 | void QTReader::processmousepositionevent( QMouseEvent* _e ) |
182 | { | 327 | { |
183 | int x, y, ht, wh; | 328 | int x, y, ht, wh; |
184 | if (m_rotated) | 329 | if (m_rotated) |
185 | { | 330 | { |
186 | x = _e->y(); | 331 | x = _e->y(); |
187 | y = width()-_e->x(); | 332 | y = width()-_e->x(); |
188 | ht = width(); | 333 | ht = width(); |
189 | wh = height(); | 334 | wh = height(); |
190 | } | 335 | } |
191 | else | 336 | else |
192 | { | 337 | { |
193 | x = _e->x(); | 338 | x = _e->x(); |
194 | y = _e->y(); | 339 | y = _e->y(); |
195 | ht = height(); | 340 | ht = height(); |
196 | wh = width(); | 341 | wh = width(); |
197 | } | 342 | } |
198 | if (buffdoc.hasnavigation()) | 343 | if (buffdoc.hasnavigation()) |
199 | { | 344 | { |
200 | if (y > (2*ht)/3) | 345 | if (y > (2*ht)/3) |
201 | { | 346 | { |
202 | goDown(); | 347 | goDown(); |
203 | } | 348 | } |
204 | else if (y < ht/3) | 349 | else if (y < ht/3) |
205 | { | 350 | { |
206 | goUp(); | 351 | goUp(); |
207 | } | 352 | } |
208 | else | 353 | else |
209 | { | 354 | { |
210 | if (x < wh/3) | 355 | if (x < wh/3) |
211 | { | 356 | { |
212 | goBack(); | 357 | goBack(); |
213 | } | 358 | } |
214 | else if (x > (2*wh)/3) | 359 | else if (x > (2*wh)/3) |
215 | { | 360 | { |
216 | goForward(); | 361 | goForward(); |
217 | } | 362 | } |
218 | else | 363 | else |
219 | { | 364 | { |
220 | goHome(); | 365 | goHome(); |
221 | } | 366 | } |
222 | } | 367 | } |
223 | } | 368 | } |
224 | else | 369 | else |
225 | { | 370 | { |
226 | if (y > ht/2) | 371 | if (y > ht/2) |
227 | { | 372 | { |
228 | goDown(); | 373 | goDown(); |
229 | } | 374 | } |
230 | else | 375 | else |
231 | { | 376 | { |
232 | goUp(); | 377 | goUp(); |
233 | } | 378 | } |
234 | } | 379 | } |
235 | } | 380 | } |
236 | 381 | ||
237 | void QTReader::goHome() | 382 | void QTReader::goHome() |
238 | { | 383 | { |
239 | if (buffdoc.hasnavigation()) | 384 | if (buffdoc.hasnavigation()) |
240 | { | 385 | { |
241 | size_t current=pagelocate(); | 386 | size_t current=pagelocate(); |
242 | size_t home=buffdoc.getHome(); | 387 | size_t home=buffdoc.getHome(); |
243 | if (current!=home) | 388 | if (current!=home) |
244 | { | 389 | { |
245 | buffdoc.saveposn(m_lastfile, current); | 390 | buffdoc.saveposn(m_lastfile, current); |
246 | locate(home); | 391 | locate(home); |
247 | } | 392 | } |
248 | } | 393 | } |
249 | else | 394 | else |
250 | locate(0); | 395 | locate(0); |
251 | } | 396 | } |
252 | 397 | ||
253 | void QTReader::goBack() | 398 | void QTReader::goBack() |
254 | { | 399 | { |
255 | if (buffdoc.hasnavigation()) | 400 | if (buffdoc.hasnavigation()) |
256 | { | 401 | { |
257 | size_t target = pagelocate(); | 402 | size_t target = pagelocate(); |
258 | QString nxt = m_lastfile; | 403 | QString nxt = m_lastfile; |
259 | buffdoc.writeposn(m_lastfile, target); | 404 | buffdoc.writeposn(m_lastfile, target); |
260 | linkType lt = buffdoc.back(nxt, target); | 405 | linkType lt = buffdoc.back(nxt, target); |
261 | if ((lt & eFile) != 0) | 406 | if ((lt & eFile) != 0) |
262 | { | 407 | { |
263 | if (nxt != m_lastfile) | 408 | if (nxt != m_lastfile) |
264 | { | 409 | { |
265 | emit NewFileRequest(nxt); | 410 | emit NewFileRequest(nxt); |
266 | } | 411 | } |
267 | locate(target); | 412 | locate(target); |
268 | } | 413 | } |
269 | else if ((lt & eLink) != 0) | 414 | else if ((lt & eLink) != 0) |
270 | { | 415 | { |
271 | locate(target); | 416 | locate(target); |
272 | } | 417 | } |
273 | } | 418 | } |
274 | } | 419 | } |
275 | 420 | ||
276 | void QTReader::goForward() | 421 | void QTReader::goForward() |
277 | { | 422 | { |
278 | if (buffdoc.hasnavigation()) | 423 | if (buffdoc.hasnavigation()) |
279 | { | 424 | { |
280 | size_t target = pagelocate(); | 425 | size_t target = pagelocate(); |
281 | QString nxt = m_lastfile; | 426 | QString nxt = m_lastfile; |
282 | linkType lt = buffdoc.forward(nxt, target); | 427 | linkType lt = buffdoc.forward(nxt, target); |
283 | if ((lt & eFile) != 0) | 428 | if ((lt & eFile) != 0) |
284 | { | 429 | { |
285 | if (nxt != m_lastfile) | 430 | if (nxt != m_lastfile) |
286 | { | 431 | { |
287 | emit NewFileRequest(nxt); | 432 | emit NewFileRequest(nxt); |
288 | } | 433 | } |
289 | locate(target); | 434 | locate(target); |
290 | } | 435 | } |
291 | else if ((lt & eLink) != 0) | 436 | else if ((lt & eLink) != 0) |
292 | { | 437 | { |
293 | locate(target); | 438 | locate(target); |
294 | } | 439 | } |
295 | } | 440 | } |
296 | } | 441 | } |
297 | 442 | ||
298 | linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*& img) | 443 | linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*& img, size_t& tabtgt) |
299 | { | 444 | { |
300 | int ht; | 445 | int ht; |
301 | if (m_scrolldy == m_topmargin) | 446 | if (m_scrolldy == m_topmargin) |
302 | { | 447 | { |
303 | lineno = 0; | 448 | lineno = 0; |
304 | ht = textarray[0]->lineSpacing()-m_scrolldy1 + m_topmargin; | 449 | ht = textarray[0]->lineSpacing()-m_scrolldy1 + m_topmargin; |
305 | } | 450 | } |
306 | else | 451 | else |
307 | { | 452 | { |
308 | if (y >= m_scrolldy) | 453 | if (y >= m_scrolldy) |
309 | { | 454 | { |
310 | lineno = 0; | 455 | lineno = 0; |
311 | ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy + m_topmargin; | 456 | ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy + m_topmargin; |
312 | } | 457 | } |
313 | else | 458 | else |
314 | { | 459 | { |
315 | lineno = 0; | 460 | lineno = 0; |
316 | ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy+m_topmargin; | 461 | ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy+m_topmargin; |
317 | while ((ht < h) && (lineno < numlines-1)) | 462 | while ((ht < h) && (lineno < numlines-1)) |
318 | { | 463 | { |
319 | ht += textarray[++lineno]->lineSpacing(); | 464 | ht += textarray[++lineno]->lineSpacing(); |
320 | } | 465 | } |
321 | ht = textarray[lineno]->lineSpacing(); | 466 | ht = textarray[lineno]->lineSpacing(); |
322 | } | 467 | } |
323 | } | 468 | } |
324 | while ((ht < y) && (lineno < numlines-1)) | 469 | while ((ht < y) && (lineno < numlines-1)) |
325 | { | 470 | { |
326 | ht += textarray[++lineno]->lineSpacing(); | 471 | ht += textarray[++lineno]->lineSpacing(); |
327 | } | 472 | } |
328 | if (ht < y && textarray[numlines]->showPartial()) lineno = numlines; | 473 | if (ht < y && textarray[numlines]->showPartial()) lineno = numlines; |
329 | start = locnarray[lineno]; | 474 | start = locnarray[lineno]; |
330 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; | 475 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; |
331 | if (m_bMonoSpaced) | 476 | if (m_bMonoSpaced) |
332 | { | 477 | { |
333 | offset = (x - textarray[lineno]->offset(w, m_left_border, m_right_border, availht))/m_charWidth; | 478 | offset = (x - textarray[lineno]->offset(w, m_left_border, m_right_border, availht))/m_charWidth; |
334 | } | 479 | } |
335 | else | 480 | else |
336 | { | 481 | { |
337 | int i; | 482 | int i; |
338 | CDrawBuffer* t = textarray[lineno]; | 483 | CDrawBuffer* t = textarray[lineno]; |
339 | x = x - t->offset(width(), m_left_border, m_right_border, availht); | 484 | x = x - t->offset(width(), m_left_border, m_right_border, availht); |
340 | for (i = t->length(); i > 0 && t->width(availht, i, true, w, m_left_border, m_right_border) > x; i--); | 485 | for (i = t->length(); i > 0 && t->width(availht, i, true, w, m_left_border, m_right_border) > x; i--); |
341 | offset = i; | 486 | offset = i; |
342 | } | 487 | } |
343 | return textarray[lineno]->getLinkType(offset, tgt, tgtoffset, pictgt, img); | 488 | return textarray[lineno]->getLinkType(offset, tgt, tgtoffset, pictgt, img, tabtgt); |
344 | } | 489 | } |
345 | 490 | ||
346 | void QTReader::suspend() | 491 | void QTReader::suspend() |
347 | { | 492 | { |
348 | buffdoc.suspend(); | 493 | buffdoc.suspend(); |
349 | /*#ifdef OPIE | 494 | /*#ifdef OPIE |
350 | if (memcmp("/mnt/", m_lastfile.latin1(), 5) == 0) buffdoc.suspend(); | 495 | if (memcmp("/mnt/", m_lastfile.latin1(), 5) == 0) buffdoc.suspend(); |
351 | #else | 496 | #else |
352 | if (memcmp("/usr/mnt.rom/", m_lastfile.latin1(), 13) == 0) buffdoc.suspend(); | 497 | if (memcmp("/usr/mnt.rom/", m_lastfile.latin1(), 13) == 0) buffdoc.suspend(); |
353 | #endif | 498 | #endif |
354 | */ | 499 | */ |
355 | } | 500 | } |
356 | 501 | ||
502 | void QTReader::setDoubleBuffer(bool _b) | ||
503 | { | ||
504 | m_doubleBuffered = _b; | ||
505 | if (_b || m_rotated) | ||
506 | { | ||
507 | if (dbuff == NULL) | ||
508 | { | ||
509 | dbuff = new QPixmap(); | ||
510 | dbp = new QPainter(); | ||
511 | } | ||
512 | if (m_rotated) | ||
513 | { | ||
514 | dbuff->resize(height(), width()); | ||
515 | } | ||
516 | else | ||
517 | { | ||
518 | dbuff->resize(width(), height()); | ||
519 | } | ||
520 | m_outofdate = true; | ||
521 | } | ||
522 | else | ||
523 | { | ||
524 | if (dbuff != NULL) | ||
525 | { | ||
526 | delete dbuff; | ||
527 | delete dbp; | ||
528 | } | ||
529 | dbuff = NULL; | ||
530 | dbp = NULL; | ||
531 | } | ||
532 | } | ||
533 | |||
357 | void QTReader::setTwoTouch(bool _b) | 534 | void QTReader::setTwoTouch(bool _b) |
358 | { | 535 | { |
359 | setBackgroundColor( m_bg ); | 536 | setBackgroundColor( m_bg ); |
360 | m_twotouch = m_touchone = _b; | 537 | m_twotouch = m_touchone = _b; |
361 | } | 538 | } |
362 | 539 | ||
363 | void QTReader::setContinuous(bool _b) | 540 | void QTReader::setContinuous(bool _b) |
364 | { | 541 | { |
365 | buffdoc.unsuspend(); | ||
366 | buffdoc.setContinuous(m_continuousDocument = _b); | 542 | buffdoc.setContinuous(m_continuousDocument = _b); |
367 | } | 543 | } |
368 | 544 | ||
369 | void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno) | 545 | void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno) |
370 | { | 546 | { |
371 | unsigned long wrdstart, wrdend; | 547 | unsigned long wrdstart, wrdend; |
372 | QString wrd; | 548 | QString wrd; |
373 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; | 549 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; |
374 | if (m_twotouch) | 550 | if (m_twotouch) |
375 | { | 551 | { |
376 | if (m_touchone) | 552 | if (m_touchone) |
377 | { | 553 | { |
378 | m_touchone = false; | 554 | m_touchone = false; |
379 | m_startpos = startpos; | 555 | m_startpos = startpos; |
380 | m_startoffset = startoffset; | 556 | m_startoffset = startoffset; |
381 | setBackgroundColor( lightGray ); | 557 | setBackgroundColor( lightGray ); |
382 | } | 558 | } |
383 | else | 559 | else |
384 | { | 560 | { |
385 | m_touchone = true; | 561 | m_touchone = true; |
386 | setBackgroundColor( m_bg ); | 562 | setBackgroundColor( m_bg ); |
387 | size_t endpos, endoffset; | 563 | size_t endpos, endoffset; |
388 | endpos = startpos; | 564 | endpos = startpos; |
389 | endoffset = startoffset; | 565 | endoffset = startoffset; |
390 | size_t currentpos = locate(); | 566 | size_t currentpos = locate(); |
391 | if (endpos >= m_startpos) | 567 | if (endpos >= m_startpos) |
392 | { | 568 | { |
393 | jumpto(m_startpos); | 569 | jumpto(m_startpos); |
394 | for (int i = 0; i < m_startoffset; i++) | 570 | for (int i = 0; i < m_startoffset; i++) |
395 | { | 571 | { |
396 | getch(); | 572 | getch(); |
397 | } | 573 | } |
398 | wrdstart = buffdoc.explocate(); | 574 | wrdstart = buffdoc.explocate(); |
399 | if (m_startpos == endpos) | 575 | if (m_startpos == endpos) |
400 | { | 576 | { |
401 | for (int i = m_startoffset; i <= endoffset; i++) | 577 | for (int i = m_startoffset; i <= endoffset; i++) |
402 | { | 578 | { |
403 | wrd += QChar(getch()); | 579 | wrd += QChar(getch()); |
404 | } | 580 | } |
405 | } | 581 | } |
406 | else | 582 | else |
407 | { | 583 | { |
408 | while (buffdoc.explocate() <= endpos) | 584 | while (buffdoc.explocate() <= endpos) |
409 | { | 585 | { |
410 | wrd += QChar(getch()); | 586 | wrd += QChar(getch()); |
411 | } | 587 | } |
412 | for (int i = 0; i < endoffset; i++) | 588 | for (int i = 0; i < endoffset; i++) |
413 | { | 589 | { |
414 | wrd += QChar(getch()); | 590 | wrd += QChar(getch()); |
415 | } | 591 | } |
416 | } | 592 | } |
417 | wrdend = buffdoc.explocate(); | 593 | wrdend = buffdoc.explocate(); |
418 | jumpto(currentpos); | 594 | jumpto(currentpos); |
419 | } | 595 | } |
420 | } | 596 | } |
421 | } | 597 | } |
422 | else if (m_bMonoSpaced) | 598 | else if (m_bMonoSpaced) |
423 | { | 599 | { |
424 | int chno = (m_rotated) ? | 600 | int chno = (m_rotated) ? |
425 | (_e->y()-textarray[lineno]->offset(height(), m_left_border, m_right_border, availht))/m_charWidth | 601 | (_e->y()-textarray[lineno]->offset(height(), m_left_border, m_right_border, availht))/m_charWidth |
426 | : | 602 | : |
427 | (_e->x()-textarray[lineno]->offset(width(), m_left_border, m_right_border, availht))/m_charWidth; | 603 | (_e->x()-textarray[lineno]->offset(width(), m_left_border, m_right_border, availht))/m_charWidth; |
428 | if (chno < ustrlen(textarray[lineno]->data())) | 604 | if (chno < ustrlen(textarray[lineno]->data())) |
429 | { | 605 | { |
430 | wrd[0] = textarray[lineno]->data()[chno]; | 606 | wrd[0] = textarray[lineno]->data()[chno]; |
431 | } | 607 | } |
432 | } | 608 | } |
433 | else | 609 | else |
434 | { | 610 | { |
435 | CDrawBuffer* t = textarray[lineno]; | 611 | CDrawBuffer* t = textarray[lineno]; |
436 | int first = 0; | 612 | int first = 0; |
437 | int tgt = (m_rotated) ? | 613 | int tgt = (m_rotated) ? |
438 | _e->y() - t->offset(height(), m_left_border, m_right_border, availht) : | 614 | _e->y() - t->offset(height(), m_left_border, m_right_border, availht) : |
439 | _e->x() - t->offset(width(), m_left_border, m_right_border, availht); | 615 | _e->x() - t->offset(width(), m_left_border, m_right_border, availht); |
440 | while (1) | 616 | while (1) |
441 | { | 617 | { |
442 | int i = first+1; | 618 | int i = first+1; |
443 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; | 619 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; |
444 | while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; | 620 | while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; |
445 | if (t->width(availht, i, true, (m_rotated) ? height() : width(), m_left_border, m_right_border) > tgt) | 621 | if (t->width(availht, i, true, (m_rotated) ? height() : width(), m_left_border, m_right_border) > tgt) |
446 | { | 622 | { |
447 | wrd = toQString(t->data()+first, i - first); | 623 | wrd = toQString(t->data()+first, i - first); |
448 | // qDebug("Got %s", (const char *)wrd); | 624 | // qDebug("Got %s", (const char *)wrd); |
449 | break; | 625 | break; |
450 | } | 626 | } |
451 | while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; | 627 | while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; |
452 | if ((*t)[i] == 0) break; | 628 | if ((*t)[i] == 0) break; |
453 | first = i; | 629 | first = i; |
454 | } | 630 | } |
455 | } | 631 | } |
456 | if (!wrd.isEmpty()) | 632 | if (!wrd.isEmpty()) |
457 | { | 633 | { |
458 | qDebug("Selecteed:%s", (const char*)wrd); | 634 | qDebug("Selected:%s", (const char*)wrd); |
459 | if (m_twotouch) | 635 | if (m_twotouch) |
460 | { | 636 | { |
461 | emit OnWordSelected(wrd, wrdstart, wrdend, wrd); | 637 | emit OnWordSelected(wrd, wrdstart, wrdend, wrd); |
462 | } | 638 | } |
463 | else | 639 | else |
464 | { | 640 | { |
465 | QString line = toQString(textarray[lineno]->data()); | 641 | QString line = toQString(textarray[lineno]->data()); |
466 | emit OnWordSelected(wrd, locnarray[lineno], locnarray[lineno]+line.length(), line); | 642 | emit OnWordSelected(wrd, locnarray[lineno], locnarray[lineno]+line.length(), line); |
467 | } | 643 | } |
468 | } | 644 | } |
469 | } | 645 | } |
470 | 646 | ||
471 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | 647 | #ifdef USETIMER |
648 | void QTReader::actionDrag() | ||
472 | { | 649 | { |
473 | buffdoc.unsuspend(); | 650 | if (m_drageligible) |
474 | int x, y, ht, wh; | ||
475 | if (m_rotated) | ||
476 | { | 651 | { |
477 | x = _e->y(); | 652 | int fivepages = 5*((2*width()+m_textsize/2)/m_textsize)*((height()+m_textsize/2)/m_textsize); |
478 | y = width()-_e->x(); | 653 | if (m_dragtarget > fivepages && locnarray[numlines] < m_dragtarget - fivepages) |
479 | ht = width(); | 654 | { |
480 | wh = height(); | 655 | int tgt = m_dragtarget - fivepages/2; |
656 | //qDebug("Jumping to %u (%u)", tgt, fivepages); | ||
657 | if (tgt < buffdoc.startSection()) | ||
658 | { | ||
659 | tgt = buffdoc.startSection(); | ||
660 | } | ||
661 | locate(tgt); | ||
662 | drawFonts(); | ||
663 | } | ||
664 | else if (locnarray[0] > m_dragtarget+fivepages) | ||
665 | { | ||
666 | int tgt = m_dragtarget + fivepages/2; | ||
667 | //qDebug("Jumping to %u (%u)", tgt, fivepages); | ||
668 | if (tgt > buffdoc.endSection()) | ||
669 | { | ||
670 | dopageup(); | ||
671 | } | ||
672 | else | ||
673 | { | ||
674 | locate(tgt); | ||
675 | drawFonts(); | ||
676 | } | ||
677 | } | ||
678 | else if (locnarray[numlines] <= m_dragtarget) | ||
679 | { | ||
680 | dopagedn(); | ||
681 | } | ||
682 | else if (locnarray[0] > m_dragtarget) | ||
683 | { | ||
684 | dopageup(); | ||
685 | } | ||
481 | } | 686 | } |
482 | else | 687 | else |
483 | { | 688 | { |
484 | x = _e->x(); | 689 | m_dragtimer->stop(); |
485 | y = _e->y(); | ||
486 | ht = height(); | ||
487 | wh = width(); | ||
488 | } | 690 | } |
489 | if (_e->button() == LeftButton) | 691 | } |
692 | #endif | ||
693 | |||
694 | void QTReader::mouseMoveEvent( QMouseEvent* _e ) | ||
695 | { | ||
696 | if (m_drageligible) | ||
490 | { | 697 | { |
491 | if (mouseUpOn) | 698 | int ht; |
699 | int mp; | ||
700 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); | ||
701 | //qDebug("Mouse moved to (%u, %u)", _e->x(), _e->y()); | ||
702 | switch (m_scrollpos) | ||
492 | { | 703 | { |
493 | // qDebug("MouseRelease"); | 704 | case 1: |
494 | switch(m_scrollpos) | 705 | { |
706 | if (m_rotated) | ||
707 | { | ||
708 | ht = height(); | ||
709 | mp = _e->y(); | ||
710 | } | ||
711 | else | ||
712 | { | ||
713 | ht = width(); | ||
714 | mp = _e->x(); | ||
715 | } | ||
716 | } | ||
717 | break; | ||
718 | case 2: | ||
719 | case 3: | ||
720 | { | ||
721 | if (m_rotated) | ||
722 | { | ||
723 | ht = width(); | ||
724 | mp = width()-_e->x(); | ||
725 | } | ||
726 | else | ||
727 | { | ||
728 | ht = height(); | ||
729 | mp = _e->y(); | ||
730 | } | ||
731 | } | ||
732 | break; | ||
733 | case 0: | ||
734 | default: | ||
735 | ht = -1; | ||
736 | break; | ||
737 | } | ||
738 | if (ht >= 0) | ||
739 | { | ||
740 | #ifdef USETIMER | ||
741 | m_dragtarget = (sectionsize*mp+ht/2)/ht + buffdoc.startSection(); | ||
742 | if (!m_dragtimer->isActive()) | ||
495 | { | 743 | { |
496 | case 1: // Bottom | 744 | m_dragtimer->start(0, false); |
497 | if (y > ht - 5) | ||
498 | { | ||
499 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*x+wh/2)/wh); | ||
500 | return; | ||
501 | } | ||
502 | break; | ||
503 | case 2: // right | ||
504 | if (x > wh - m_right_border) | ||
505 | { | ||
506 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); | ||
507 | return; | ||
508 | } | ||
509 | break; | ||
510 | case 3: // left | ||
511 | if (x < m_left_border) | ||
512 | { | ||
513 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); | ||
514 | return; | ||
515 | } | ||
516 | break; | ||
517 | case 0: | ||
518 | default: | ||
519 | break; | ||
520 | } | 745 | } |
521 | if (textarray[0] != NULL) | 746 | #else |
747 | int dp = (sectionsize*mp+ht/2)/ht + buffdoc.startSection(); | ||
748 | locate(dp); | ||
749 | #endif | ||
750 | } | ||
751 | } | ||
752 | } | ||
753 | |||
754 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | ||
755 | { | ||
756 | qDebug("Mouse released at (%u, %u)", _e->x(), _e->y()); | ||
757 | if (m_drageligible) | ||
758 | { | ||
759 | m_drageligible = false; | ||
760 | } | ||
761 | else | ||
762 | { | ||
763 | int x, y, ht, wh; | ||
764 | if (m_rotated) | ||
765 | { | ||
766 | x = _e->y(); | ||
767 | y = width()-_e->x(); | ||
768 | ht = width(); | ||
769 | wh = height(); | ||
770 | } | ||
771 | else | ||
772 | { | ||
773 | x = _e->x(); | ||
774 | y = _e->y(); | ||
775 | ht = height(); | ||
776 | wh = width(); | ||
777 | } | ||
778 | if (_e->button() == LeftButton) | ||
779 | { | ||
780 | if (mouseUpOn) | ||
522 | { | 781 | { |
523 | QString line; | 782 | // qDebug("MouseRelease"); |
524 | // int lineno = _e->y()/m_linespacing; | 783 | /* |
525 | int lineno = 0; | 784 | switch(m_scrollpos) |
526 | /* | ||
527 | int ht = textarray[0]->lineSpacing(); | ||
528 | while ((ht < y) && (lineno < numlines)) | ||
529 | { | 785 | { |
530 | ht += textarray[++lineno]->lineSpacing(); | 786 | case 1: // Bottom |
787 | if (y > ht - 5) | ||
788 | { | ||
789 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*x+wh/2)/wh); | ||
790 | return; | ||
531 | } | 791 | } |
532 | */ | 792 | break; |
533 | size_t startpos, startoffset, tgt, tgtoffset, pictgt; | 793 | case 2: // right |
534 | QImage* img; | 794 | if (x > wh - m_right_border) |
535 | if (m_currentlinkstyle != NULL) | 795 | { |
536 | { | 796 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); |
537 | textarray[m_currentlink]->invertLink(m_currentlinkoffset); | 797 | return; |
538 | m_currentlinkstyle = NULL; | 798 | } |
539 | m_currentlink = -1; | 799 | break; |
540 | m_currentlinkoffset = -1; | 800 | case 3: // left |
541 | } | 801 | if (x < m_left_border) |
542 | linkType glt = getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img); | 802 | { |
543 | if ((glt & eLink) != 0) | 803 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); |
544 | { | 804 | return; |
545 | if ((glt & ePicture) != 0) | 805 | } |
546 | { | 806 | break; |
547 | qDebug("Big Picture:%x", pictgt); | 807 | case 0: |
548 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) | 808 | default: |
549 | { | 809 | break; |
550 | QImage* pm = buffdoc.getPicture(pictgt); | 810 | } |
551 | if (pm != NULL) | 811 | */ |
552 | { | 812 | if (textarray[0] != NULL) |
553 | emit OnShowPicture(*pm); | 813 | { |
554 | delete pm; | 814 | QString line; |
555 | return; | 815 | // int lineno = _e->y()/m_linespacing; |
556 | } | 816 | int lineno = 0; |
557 | } | 817 | /* |
558 | } | 818 | int ht = textarray[0]->lineSpacing(); |
559 | else if (img != NULL) | 819 | while ((ht < y) && (lineno < numlines)) |
560 | { | 820 | { |
561 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) | 821 | ht += textarray[++lineno]->lineSpacing(); |
562 | { | 822 | } |
563 | emit OnShowPicture(*img); | 823 | */ |
564 | return; | 824 | size_t startpos, startoffset, tgt, tgtoffset, pictgt, tabtgt; |
565 | } | 825 | QImage* img; |
566 | } | 826 | if (m_currentlinkstyle != NULL) |
567 | size_t saveposn = pagelocate(); | 827 | { |
568 | QString href, nm; | 828 | textarray[m_currentlink]->invertLink(m_currentlinkoffset); |
569 | linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm); | 829 | m_currentlinkstyle = NULL; |
570 | qDebug("URL(1):%s", (const char*)href); | 830 | m_currentlink = -1; |
571 | if ((lt & eFile) != 0) | 831 | m_currentlinkoffset = -1; |
572 | { | 832 | } |
573 | buffdoc.saveposn(m_lastfile, saveposn); | 833 | linkType glt = getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img, tabtgt); |
834 | if (bNoInlineTables && ((glt & eTable) != 0)) | ||
835 | { | ||
836 | size_t currentpos = locate(); | ||
837 | QString tabtext = buffdoc.getTableAsHtml(tabtgt); | ||
838 | qDebug("TABLE:%u:%u:%s", currentpos, tabtgt, (const char*)tabtext); | ||
839 | QFont f(m_fontname, m_fontControl.currentsize()); | ||
574 | #ifdef USEQPE | 840 | #ifdef USEQPE |
841 | CTableDialog td(f, tabtext, true, this); | ||
842 | #else | ||
843 | CTableDialog td(f, tabtext, false, this); | ||
844 | #endif | ||
845 | td.exec(); | ||
846 | jumpto(currentpos); | ||
847 | } | ||
848 | if ((glt & eLink) != 0) | ||
849 | { | ||
850 | if ((glt & ePicture) != 0) | ||
575 | { | 851 | { |
576 | QCopEnvelope e("QPE/System", "busy()"); | 852 | qDebug("Big Picture:%x", pictgt); |
853 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) | ||
854 | { | ||
855 | QImage* pm = buffdoc.getPicture(pictgt); | ||
856 | if (pm != NULL) | ||
857 | { | ||
858 | emit OnShowPicture(*pm); | ||
859 | delete pm; | ||
860 | return; | ||
861 | } | ||
862 | } | ||
577 | } | 863 | } |
578 | #endif | 864 | else if (img != NULL) |
579 | ResetScroll(); | ||
580 | if (!href.isEmpty()) | ||
581 | { | ||
582 | if (!buffdoc.getFile(href)) | ||
583 | { | ||
584 | emit NewFileRequest(href); | ||
585 | } | ||
586 | else | ||
587 | { | ||
588 | ResetScroll(); | ||
589 | fillbuffer(); | ||
590 | update(); | ||
591 | } | ||
592 | } | ||
593 | if (!nm.isEmpty()) | ||
594 | { | ||
595 | qDebug("QTReader:Finding %s", (const char*)nm); | ||
596 | if (buffdoc.findanchor(nm)) | ||
597 | { | ||
598 | fillbuffer(); | ||
599 | update(); | ||
600 | } | ||
601 | } | ||
602 | //fillbuffer(); | ||
603 | //update(); | ||
604 | #ifdef USEQPE | ||
605 | { | 865 | { |
606 | QCopEnvelope e("QPE/System", "notBusy()"); | 866 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) |
867 | { | ||
868 | emit OnShowPicture(*img); | ||
869 | return; | ||
870 | } | ||
607 | } | 871 | } |
608 | #endif | 872 | size_t saveposn = pagelocate(); |
609 | } | 873 | QString href, nm; |
610 | else if ((lt & eLink) != 0) | 874 | linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm); |
611 | { | 875 | qDebug("URL(1):%s", (const char*)href); |
612 | buffdoc.saveposn(m_lastfile, saveposn); | 876 | if ((lt & eFile) != 0) |
613 | ResetScroll(); | 877 | { |
614 | fillbuffer(); | 878 | buffdoc.saveposn(m_lastfile, saveposn); |
615 | update(); | 879 | #ifdef USEQPE |
616 | } | ||
617 | else | ||
618 | { | ||
619 | if ((lt & ePicture) != 0) | ||
620 | { | 880 | { |
621 | QImage* pm = buffdoc.getPicture(tgt); | 881 | QCopEnvelope e("QPE/System", "busy()"); |
622 | if (pm != NULL) | ||
623 | { | ||
624 | emit OnShowPicture(*pm); | ||
625 | delete pm; | ||
626 | } | ||
627 | } | 882 | } |
628 | else | 883 | #endif |
884 | ResetScroll(); | ||
885 | if (!href.isEmpty()) | ||
886 | { | ||
887 | if (!buffdoc.getFile(href, nm)) | ||
888 | { | ||
889 | emit NewFileRequest(href); | ||
890 | } | ||
891 | else | ||
892 | { | ||
893 | qDebug("BEFORE:%u", pagelocate()); | ||
894 | buffdoc.resetPos(); | ||
895 | ResetScroll(); | ||
896 | fillbuffer(); | ||
897 | qDebug("AFTER:%u", pagelocate()); | ||
898 | m_outofdate = true; | ||
899 | update(); | ||
900 | } | ||
901 | } | ||
902 | if (!nm.isEmpty()) | ||
903 | { | ||
904 | qDebug("QTReader:Finding %s", (const char*)nm); | ||
905 | if (buffdoc.findanchor(nm)) | ||
906 | { | ||
907 | buffdoc.resetPos(); | ||
908 | fillbuffer(); | ||
909 | m_outofdate = true; | ||
910 | update(); | ||
911 | } | ||
912 | } | ||
913 | //fillbuffer(); | ||
914 | //update(); | ||
915 | #ifdef USEQPE | ||
629 | { | 916 | { |
630 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); | 917 | QCopEnvelope e("QPE/System", "notBusy()"); |
631 | if (!href.isEmpty()) | ||
632 | { | ||
633 | emit OnURLSelected(href, tgt); | ||
634 | } | ||
635 | } | 918 | } |
636 | locate(pagelocate()); | 919 | #endif |
637 | } | 920 | } |
638 | return; | 921 | else if ((lt & eLink) != 0) |
639 | } | 922 | { |
640 | else if ((glt & ePicture) != 0) | 923 | buffdoc.saveposn(m_lastfile, saveposn); |
641 | { | 924 | ResetScroll(); |
642 | qDebug("Big Picture:%x", pictgt); | 925 | fillbuffer(); |
643 | QImage* pm = buffdoc.getPicture(pictgt); | 926 | m_outofdate = true; |
644 | if (pm != NULL) | 927 | update(); |
645 | { | 928 | } |
646 | emit OnShowPicture(*pm); | 929 | else |
647 | delete pm; | 930 | { |
648 | } | 931 | if ((lt & ePicture) != 0) |
649 | else | 932 | { |
650 | { | 933 | QImage* pm = buffdoc.getPicture(tgt); |
651 | locate(pagelocate()); | 934 | if (pm != NULL) |
652 | } | 935 | { |
653 | return; | 936 | emit OnShowPicture(*pm); |
654 | } | 937 | delete pm; |
655 | else if (img != NULL) | 938 | } |
656 | { | 939 | } |
657 | emit OnShowPicture(*img); | 940 | else |
658 | return; | 941 | { |
659 | } | 942 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); |
660 | if (m_swapmouse) | 943 | if (!href.isEmpty()) |
944 | { | ||
945 | emit OnURLSelected(href, tgt); | ||
946 | } | ||
947 | } | ||
948 | } | ||
949 | return; | ||
950 | } | ||
951 | else if ((glt & ePicture) != 0) | ||
952 | { | ||
953 | qDebug("Big Picture:%x", pictgt); | ||
954 | QImage* pm = buffdoc.getPicture(pictgt); | ||
955 | if (pm != NULL) | ||
956 | { | ||
957 | emit OnShowPicture(*pm); | ||
958 | delete pm; | ||
959 | } | ||
960 | else | ||
961 | { | ||
962 | update(); | ||
963 | } | ||
964 | return; | ||
965 | } | ||
966 | else if (img != NULL) | ||
967 | { | ||
968 | emit OnShowPicture(*img); | ||
969 | return; | ||
970 | } | ||
971 | if (m_swapmouse) | ||
661 | processmousepositionevent(_e); | 972 | processmousepositionevent(_e); |
662 | else | 973 | else |
663 | processmousewordevent(startpos, startoffset, _e, lineno); | 974 | processmousewordevent(startpos, startoffset, _e, lineno); |
975 | } | ||
976 | } | ||
977 | else | ||
978 | { | ||
979 | mouseUpOn = true; | ||
664 | } | 980 | } |
665 | } | ||
666 | else | ||
667 | { | ||
668 | mouseUpOn = true; | ||
669 | } | 981 | } |
670 | } | 982 | } |
671 | } | 983 | } |
672 | 984 | ||
673 | void QTReader::focusInEvent(QFocusEvent* e) | 985 | void QTReader::focusInEvent(QFocusEvent* e) |
674 | { | 986 | { |
675 | if (m_autoScroll) timer->start(real_delay(), false); | 987 | if (m_autoScroll && (m_scrolltype != 4)) timer->start(real_delay(), false); |
676 | update(); | 988 | update(); |
677 | } | 989 | } |
678 | 990 | ||
679 | void QTReader::focusOutEvent(QFocusEvent* e) | 991 | void QTReader::focusOutEvent(QFocusEvent* e) |
680 | { | 992 | { |
681 | if (m_autoScroll) | 993 | if (m_autoScroll) |
682 | { | 994 | { |
683 | timer->stop(); | 995 | if (m_scrolltype != 4) |
996 | { | ||
997 | timer->stop(); | ||
998 | } | ||
999 | else | ||
1000 | { | ||
1001 | m_autoScroll = false; | ||
1002 | } | ||
684 | //m_scrolldy1 = m_scrolldy2 = 0; | 1003 | //m_scrolldy1 = m_scrolldy2 = 0; |
685 | } | 1004 | } |
686 | } | 1005 | } |
687 | 1006 | ||
688 | #include <qapplication.h> | 1007 | #include <qapplication.h> |
689 | #include <qdrawutil.h> | 1008 | #include <qdrawutil.h> |
690 | #ifndef _WINDOWS | 1009 | #ifndef _WINDOWS |
691 | #include <unistd.h> | 1010 | #include <unistd.h> |
692 | #endif | 1011 | #endif |
693 | 1012 | ||
694 | void QTReader::goDown() | 1013 | void QTReader::goDown() |
695 | { | 1014 | { |
696 | if (m_bpagemode) | 1015 | if (m_bpagemode) |
697 | { | 1016 | { |
698 | dopagedn(); | 1017 | dopagedn(); |
699 | } | 1018 | } |
700 | else | 1019 | else |
701 | { | 1020 | { |
702 | lineDown(); | 1021 | lineDown(); |
703 | } | 1022 | } |
704 | } | 1023 | } |
705 | 1024 | ||
706 | void QTReader::goUp() | 1025 | void QTReader::goUp() |
707 | { | 1026 | { |
708 | if (m_bpagemode) | 1027 | if (m_bpagemode) |
709 | { | 1028 | { |
710 | dopageup(); | 1029 | dopageup(); |
711 | } | 1030 | } |
712 | else | 1031 | else |
713 | { | 1032 | { |
714 | lineUp(); | 1033 | lineUp(); |
715 | } | 1034 | } |
716 | } | 1035 | } |
717 | 1036 | ||
718 | void QTReader::NavUp() | 1037 | void QTReader::NavUp() |
719 | { | 1038 | { |
720 | buffdoc.unsuspend(); | ||
721 | if (buffdoc.hasnavigation()) | 1039 | if (buffdoc.hasnavigation()) |
722 | { | 1040 | { |
723 | /* | 1041 | /* |
724 | size_t target = pagelocate(); | 1042 | size_t target = pagelocate(); |
725 | if (buffdoc.back(target)) | 1043 | if (buffdoc.back(target)) |
726 | { | 1044 | { |
727 | locate(target); | 1045 | locate(target); |
728 | } | 1046 | } |
729 | */ | 1047 | */ |
730 | locate(buffdoc.startSection()); | 1048 | locate(buffdoc.startSection()); |
731 | } | 1049 | } |
732 | else | 1050 | else |
733 | { | 1051 | { |
734 | goUp(); | 1052 | goUp(); |
735 | } | 1053 | } |
736 | } | 1054 | } |
737 | 1055 | ||
738 | void QTReader::NavDown() | 1056 | void QTReader::NavDown() |
739 | { | 1057 | { |
740 | buffdoc.unsuspend(); | ||
741 | if (buffdoc.hasnavigation()) | 1058 | if (buffdoc.hasnavigation()) |
742 | { | 1059 | { |
743 | /* | 1060 | /* |
744 | size_t target = pagelocate(); | 1061 | size_t target = pagelocate(); |
745 | if (buffdoc.forward(target)) | 1062 | if (buffdoc.forward(target)) |
746 | { | 1063 | { |
747 | locate(target); | 1064 | locate(target); |
748 | } | 1065 | } |
749 | */ | 1066 | */ |
750 | dopageup(buffdoc.endSection()); | 1067 | dopageup(buffdoc.endSection()); |
751 | } | 1068 | } |
752 | else | 1069 | else |
753 | { | 1070 | { |
754 | goDown(); | 1071 | goDown(); |
755 | } | 1072 | } |
756 | } | 1073 | } |
757 | 1074 | ||
758 | void QTReader::zoomin() | 1075 | void QTReader::zoomin() |
759 | { | 1076 | { |
760 | if (m_fontControl.increasesize()) | 1077 | if (m_fontControl.increasesize()) |
761 | { | 1078 | { |
762 | bool sc = m_autoScroll; | 1079 | bool sc = m_autoScroll; |
763 | setautoscroll(false); | 1080 | setautoscroll(false); |
764 | setfont(); | 1081 | setfont(); |
765 | locate(pagelocate()); | 1082 | refresh(); |
766 | repaint(); | ||
767 | setautoscroll(sc); | 1083 | setautoscroll(sc); |
768 | } | 1084 | } |
769 | } | 1085 | } |
770 | 1086 | ||
771 | void QTReader::zoomout() | 1087 | void QTReader::zoomout() |
772 | { | 1088 | { |
773 | if (m_fontControl.decreasesize()) | 1089 | if (m_fontControl.decreasesize()) |
774 | { | 1090 | { |
775 | bool sc = m_autoScroll; | 1091 | bool sc = m_autoScroll; |
776 | setautoscroll(false); | 1092 | setautoscroll(false); |
777 | setfont(); | 1093 | setfont(); |
778 | locate(pagelocate()); | 1094 | refresh(); |
779 | repaint(); | ||
780 | setautoscroll(sc); | 1095 | setautoscroll(sc); |
781 | } | 1096 | } |
782 | } | 1097 | } |
783 | 1098 | ||
784 | void QTReader::reduceScroll() | 1099 | void QTReader::reduceScroll() |
785 | { | 1100 | { |
786 | if (m_delay < 59049) | 1101 | if (m_delay < 59049) |
787 | { | 1102 | { |
788 | m_delay = (3*m_delay)/2; | 1103 | m_delay = (3*m_delay)/2; |
789 | timer->changeInterval(real_delay()); | 1104 | timer->changeInterval(real_delay()); |
790 | } | 1105 | } |
791 | else | 1106 | else |
792 | { | 1107 | { |
793 | m_delay = 59049; | 1108 | m_delay = 59049; |
794 | } | 1109 | } |
795 | } | 1110 | } |
796 | 1111 | ||
797 | void QTReader::increaseScroll() | 1112 | void QTReader::increaseScroll() |
798 | { | 1113 | { |
799 | if (m_delay > 454) | 1114 | if (m_delay > 454) |
800 | { | 1115 | { |
801 | m_delay = (2*m_delay)/3; | 1116 | m_delay = (2*m_delay)/3; |
802 | timer->changeInterval(real_delay()); | 1117 | timer->changeInterval(real_delay()); |
803 | } | 1118 | } |
804 | else | 1119 | else |
805 | { | 1120 | { |
806 | m_delay = 454; | 1121 | m_delay = 454; |
807 | } | 1122 | } |
808 | } | 1123 | } |
809 | 1124 | ||
810 | void QTReader::keyPressEvent(QKeyEvent* e) | 1125 | void QTReader::keyPressEvent(QKeyEvent* e) |
811 | { | 1126 | { |
812 | buffdoc.unsuspend(); | 1127 | |
813 | |||
814 | //((QTReaderApp*)parent()->parent())->handlekey(e); | 1128 | //((QTReaderApp*)parent()->parent())->handlekey(e); |
815 | emit HandleKeyRequest(e); | 1129 | emit HandleKeyRequest(e); |
816 | // e->ignore(); | 1130 | // e->ignore(); |
817 | return; | 1131 | return; |
818 | #ifdef _SCROLLPIPE | 1132 | #ifdef _SCROLLPIPE |
819 | if (m_isPaused) | 1133 | if (m_isPaused) |
820 | { | 1134 | { |
821 | m_isPaused = false; | 1135 | m_isPaused = false; |
822 | if (e->key() != Key_Space) | 1136 | if (e->key() != Key_Space) |
823 | { | 1137 | { |
824 | m_autoScroll = false; | 1138 | m_autoScroll = false; |
825 | if (m_pipeout != NULL) | 1139 | if (m_pipeout != NULL) |
826 | { | 1140 | { |
827 | pclose(m_pipeout); | 1141 | pclose(m_pipeout); |
828 | m_pipeout = NULL; | 1142 | m_pipeout = NULL; |
829 | } | 1143 | } |
830 | //((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); | 1144 | //((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); |
831 | emit SetScrollState(m_autoScroll); | 1145 | emit SetScrollState(m_autoScroll); |
832 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 1146 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
833 | } | 1147 | } |
834 | else | 1148 | else |
835 | { | 1149 | { |
836 | timer->start(real_delay(), false); | 1150 | timer->start(real_delay(), false); |
837 | } | 1151 | } |
838 | e->accept(); | 1152 | e->accept(); |
839 | return; | 1153 | return; |
840 | } | 1154 | } |
841 | #endif | 1155 | #endif |
842 | } | 1156 | } |
843 | 1157 | ||
844 | void QTReader::CalculateScrollParameters() | 1158 | void QTReader::CalculateScrollParameters() |
845 | { | 1159 | { |
846 | int bmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 1160 | int bmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
847 | if (bmargin < m_bottommargin) bmargin = m_bottommargin; | 1161 | if (bmargin < m_bottommargin) bmargin = m_bottommargin; |
848 | switch (m_scrolltype) | 1162 | switch (m_scrolltype) |
849 | { | 1163 | { |
850 | case 0: | 1164 | case 0: |
851 | { | 1165 | { |
852 | if (m_scrolldy == m_topmargin) | 1166 | if (m_scrolldy == m_topmargin) |
853 | { | 1167 | { |
854 | m_scrolldy1 = 0; | 1168 | m_scrolldy1 = 0; |
855 | m_scrolldy2 = 0; | 1169 | m_scrolldy2 = 0; |
856 | m_totalscroll = 0; | 1170 | m_totalscroll = 0; |
857 | return; | 1171 | return; |
858 | } | 1172 | } |
859 | if (m_scrolldy < textarray[0]->lineSpacing()) | 1173 | if (m_scrolldy < textarray[0]->lineSpacing()) |
860 | { | 1174 | { |
861 | m_scrolldy2 = m_scrolldy; | 1175 | m_scrolldy2 = m_scrolldy; |
862 | return; | 1176 | return; |
863 | } | 1177 | } |
864 | int ht = m_scrolldy - m_scrolldy1; | 1178 | int ht = m_scrolldy - m_scrolldy1; |
865 | int i; | 1179 | int i; |
866 | for (i = 0; (ht < ((m_rotated) ? width() : height())-bmargin) && (i < numlines); i++) | 1180 | for (i = 0; (ht < ((m_rotated) ? width() : height())-bmargin) && (i < numlines); i++) |
867 | { | 1181 | { |
868 | ht += textarray[i]->lineSpacing(); | 1182 | ht += textarray[i]->lineSpacing(); |
869 | } | 1183 | } |
870 | ht = 0; | 1184 | ht = 0; |
871 | int j; | 1185 | int j; |
872 | i--; | 1186 | i--; |
873 | for (j = i; j < numlines; j++) | 1187 | for (j = i; j < numlines; j++) |
874 | { | 1188 | { |
875 | ht += textarray[j]->lineSpacing(); | 1189 | ht += textarray[j]->lineSpacing(); |
876 | } | 1190 | } |
877 | ht -= ( | 1191 | ht -= ( |
878 | textarray[i]->lineExtraSpacing() | 1192 | textarray[i]->lineExtraSpacing() |
879 | + | 1193 | + |
880 | (i != 0) ? textarray[numlines-1]->lineExtraSpacing() : 0 | 1194 | (i != 0) ? textarray[numlines-1]->lineExtraSpacing() : 0 |
881 | )/2-2; | 1195 | )/2-2; |
882 | 1196 | ||
883 | m_scrolldy2 = m_scrolldy-ht; | 1197 | m_scrolldy2 = m_scrolldy-ht; |
884 | } | 1198 | } |
885 | break; | 1199 | break; |
886 | case 1: | 1200 | case 1: |
887 | case 2: | 1201 | case 2: |
888 | case 3: | 1202 | case 3: |
889 | { | 1203 | { |
890 | int ypos = m_topmargin; | 1204 | int ypos = m_topmargin; |
891 | for (int i = 0; i < numlines; i++) | 1205 | for (int i = 0; i < numlines; i++) |
892 | { | 1206 | { |
893 | ypos += textarray[i]->lineSpacing(); | 1207 | ypos += textarray[i]->lineSpacing(); |
894 | } | 1208 | } |
895 | ypos -= ( | 1209 | ypos -= ( |
896 | textarray[0]->lineExtraSpacing() | 1210 | textarray[0]->lineExtraSpacing() |
897 | + | 1211 | + |
898 | ((numlines > 1) ? textarray[numlines-1]->lineExtraSpacing() : 0) | 1212 | ((numlines > 1) ? textarray[numlines-1]->lineExtraSpacing() : 0) |
899 | )/2 + | 1213 | )/2 + |
900 | m_scrolldy1 - 2; | 1214 | m_scrolldy1 - 2; |
901 | m_scrolldy2 = ((m_rotated) ? width() : height()) - ypos - bmargin; | 1215 | m_scrolldy2 = ((m_rotated) ? width() : height()) - ypos - bmargin; |
902 | } | 1216 | } |
903 | break; | 1217 | break; |
904 | } | 1218 | } |
905 | } | 1219 | } |
906 | 1220 | ||
907 | void QTReader::setautoscroll(bool _sc) | 1221 | void QTReader::setautoscroll(bool _sc) |
908 | { | 1222 | { |
1223 | m_outofdate = true; | ||
909 | if (_sc == m_autoScroll) return; | 1224 | if (_sc == m_autoScroll) return; |
910 | if (m_autoScroll) | 1225 | if (m_autoScroll) |
911 | { | 1226 | { |
912 | m_autoScroll = false; | 1227 | m_autoScroll = false; |
913 | #ifdef USEQPE | 1228 | #ifdef USEQPE |
914 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 1229 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
915 | #endif | 1230 | #endif |
916 | #ifdef _SCROLLPIPE | 1231 | #ifdef _SCROLLPIPE |
917 | if (m_pipeout != NULL) | 1232 | if (m_pipeout != NULL) |
918 | { | 1233 | { |
919 | pclose(m_pipeout); | 1234 | pclose(m_pipeout); |
920 | m_pipeout = NULL; | 1235 | m_pipeout = NULL; |
921 | } | 1236 | } |
922 | #endif | 1237 | #endif |
923 | //m_scrolldy1 = 0; | 1238 | //m_scrolldy1 = 0; |
924 | //refresh(); | 1239 | //refresh(); |
925 | } | 1240 | } |
926 | else | 1241 | else |
927 | { | 1242 | { |
928 | CDrawBuffer* reusebuffer = textarray[numlines]; | 1243 | CDrawBuffer* reusebuffer = textarray[numlines]; |
929 | if (reusebuffer == NULL || reusebuffer->eof()) return; | 1244 | if (reusebuffer == NULL || reusebuffer->eof()) return; |
1245 | #ifndef __STATIC | ||
1246 | if ((m_scrolltype == 4) && !checkoutput()) return; | ||
1247 | #endif | ||
930 | m_autoScroll = true; | 1248 | m_autoScroll = true; |
931 | CalculateScrollParameters(); | 1249 | CalculateScrollParameters(); |
932 | 1250 | ||
933 | #ifdef _SCROLLPIPE | 1251 | #ifdef _SCROLLPIPE |
934 | if (!m_pipetarget.isEmpty()) | 1252 | if (!m_pipetarget.isEmpty()) |
935 | { | 1253 | { |
936 | // qDebug("Opening pipe to %s", (const char*)m_pipetarget); | 1254 | // qDebug("Opening pipe to %s", (const char*)m_pipetarget); |
937 | m_pipeout = popen((const char*)m_pipetarget, "w"); | 1255 | m_pipeout = popen((const char*)m_pipetarget, "w"); |
938 | m_isPaused = false; | 1256 | m_isPaused = false; |
939 | } | 1257 | } |
940 | #endif | 1258 | #endif |
941 | autoscroll(); | 1259 | autoscroll(); |
942 | #ifdef USEQPE | 1260 | #ifdef USEQPE |
943 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed | 1261 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed |
944 | #endif | 1262 | #endif |
945 | } | 1263 | } |
946 | } | 1264 | } |
947 | 1265 | ||
948 | bool QTReader::getline(CDrawBuffer *buff) | 1266 | bool QTReader::getline(CDrawBuffer *buff) |
949 | { | 1267 | { |
950 | buffdoc.unsuspend(); | ||
951 | bool bRet; | 1268 | bool bRet; |
952 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; | 1269 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; |
953 | if (m_bMonoSpaced) | 1270 | if (m_bMonoSpaced) |
954 | { | 1271 | { |
955 | bRet = buffdoc.getline(buff ,(m_rotated) ? height() : width(), m_charWidth, m_left_border, m_right_border, availht); | 1272 | bRet = buffdoc.getline(buff ,(m_rotated) ? height() : width(), m_charWidth, m_left_border, m_right_border, availht); |
956 | } | 1273 | } |
957 | else | 1274 | else |
958 | { | 1275 | { |
959 | bRet = buffdoc.getline(buff, (m_rotated) ? height() : width(), m_left_border, m_right_border, hyphenate, availht); | 1276 | bRet = buffdoc.getline(buff, (m_rotated) ? height() : width(), m_left_border, m_right_border, hyphenate, availht); |
960 | } | 1277 | } |
961 | buff->resize(availht); | 1278 | buff->resize(availht); |
962 | return bRet; | 1279 | return bRet; |
963 | } | 1280 | } |
964 | 1281 | ||
965 | void QTReader::doscroll() | 1282 | void QTReader::doscroll() |
966 | { | 1283 | { |
967 | if (!m_autoScroll) | 1284 | if (!m_autoScroll) |
968 | { | 1285 | { |
969 | timer->stop(); | 1286 | timer->stop(); |
970 | return; | 1287 | return; |
971 | } | 1288 | } |
972 | switch (m_scrolltype) | 1289 | switch (m_scrolltype) |
973 | { | 1290 | { |
974 | case 0: | 1291 | case 0: |
975 | doinplacescroll(); | 1292 | doinplacescroll(); |
976 | break; | 1293 | break; |
977 | case 1: | 1294 | case 1: |
978 | dorollingscroll(false); | 1295 | dorollingscroll(false); |
979 | break; | 1296 | break; |
980 | case 2: | 1297 | case 2: |
981 | dorollingscroll(true); | 1298 | dorollingscroll(true); |
982 | break; | 1299 | break; |
983 | case 3: | 1300 | case 3: |
984 | dostaticscroll(); | 1301 | dostaticscroll(); |
985 | break; | 1302 | break; |
986 | } | 1303 | } |
987 | } | 1304 | } |
988 | 1305 | ||
989 | void QTReader::doinplacescroll() | 1306 | void QTReader::doinplacescroll() |
990 | { | 1307 | { |
991 | QPainter p( this ); | 1308 | QPainter p( this ); |
992 | // p.setBackgroundMode(OpaqueMode); | 1309 | // p.setBackgroundMode(OpaqueMode); |
993 | int wh, ht; | 1310 | int wh, ht; |
994 | int bmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 1311 | int bmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
995 | if (bmargin < m_bottommargin) bmargin = m_bottommargin; | 1312 | if (bmargin < m_bottommargin) bmargin = m_bottommargin; |
996 | if (m_rotated) | 1313 | if (m_rotated) |
997 | { | 1314 | { |
998 | ht = width()-bmargin; | 1315 | ht = width()-bmargin; |
999 | wh = height(); | 1316 | wh = height(); |
1000 | } | 1317 | } |
1001 | else | 1318 | else |
1002 | { | 1319 | { |
1003 | ht = height()-bmargin; | 1320 | ht = height()-bmargin; |
1004 | wh = width(); | 1321 | wh = width(); |
1005 | } | 1322 | } |
1006 | int lastdy = m_scrolldy; | 1323 | int lastdy = m_scrolldy; |
1007 | m_scrolldy += m_scrollstep; | 1324 | m_scrolldy += m_scrollstep; |
1008 | if ((m_scrolldy1 = m_scrolldy1+m_scrollstep) >= textarray[0]->lineSpacing()) | 1325 | if ((m_scrolldy1 = m_scrolldy1+m_scrollstep) >= textarray[0]->lineSpacing()) |
1009 | { | 1326 | { |
1010 | int ht = textarray[0]->lineSpacing(); | 1327 | int ht = textarray[0]->lineSpacing(); |
1011 | #ifdef _SCROLLPIPE | 1328 | #ifdef _SCROLLPIPE |
1012 | if (m_pipeout != NULL) | 1329 | if (m_pipeout != NULL) |
1013 | { | 1330 | { |
1014 | QString outstr = toQString(textarray[0]->data()); | 1331 | QString outstr = toQString(textarray[0]->data()); |
1015 | if (!outstr.isEmpty()) | 1332 | if (!outstr.isEmpty()) |
1016 | { | 1333 | { |
1017 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 1334 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
1018 | fflush(m_pipeout); | 1335 | fflush(m_pipeout); |
1019 | } | 1336 | } |
1020 | else if (m_pauseAfterEachPara) | 1337 | else if (m_pauseAfterEachPara) |
1021 | { | 1338 | { |
1022 | m_isPaused = true; | 1339 | m_isPaused = true; |
1023 | timer->stop(); | 1340 | timer->stop(); |
1024 | } | 1341 | } |
1025 | } | 1342 | } |
1026 | #endif | 1343 | #endif |
1027 | CDrawBuffer* buff = textarray[0]; | 1344 | CDrawBuffer* buff = textarray[0]; |
1028 | for (int i = 1; i <= numlines; i++) | 1345 | for (int i = 1; i <= numlines; i++) |
1029 | { | 1346 | { |
1030 | textarray[i-1] = textarray[i]; | 1347 | textarray[i-1] = textarray[i]; |
1031 | locnarray[i-1] = locnarray[i]; | 1348 | locnarray[i-1] = locnarray[i]; |
1032 | } | 1349 | } |
1033 | textarray[numlines] = buff; | 1350 | textarray[numlines] = buff; |
1034 | --numlines; | 1351 | --numlines; |
1035 | m_scrolldy1 -= ht; | 1352 | m_scrolldy1 -= ht; |
1036 | } | 1353 | } |
1037 | if ((m_scrolldy2 = m_scrolldy2+m_scrollstep) >= textarray[numlines]->lineSpacing()) | 1354 | if ((m_scrolldy2 = m_scrolldy2+m_scrollstep) >= textarray[numlines]->lineSpacing()) |
1038 | { | 1355 | { |
1039 | m_scrolldy2 -= textarray[numlines]->lineSpacing(); | 1356 | m_scrolldy2 -= textarray[numlines]->lineSpacing(); |
1040 | numlines++; | 1357 | numlines++; |
1041 | 1358 | ||
1042 | if (textarray[numlines] == NULL) | 1359 | if (textarray[numlines] == NULL) |
1043 | { | 1360 | { |
1044 | textarray[numlines] = new CDrawBuffer(&m_fontControl); | 1361 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
1045 | } | 1362 | } |
1046 | locnarray[numlines] = locate(); | 1363 | locnarray[numlines] = locate(); |
1047 | int ch = getline(textarray[numlines]); | 1364 | int ch = getline(textarray[numlines]); |
1048 | if (m_rotated) | 1365 | if (m_rotated) |
1049 | { | 1366 | { |
1050 | blitRot(width()-m_scrolldy, 0, height(), -1, textarray[numlines-1]); | 1367 | blitRot(width()-m_scrolldy, 0, height(), -1, textarray[numlines-1]); |
1051 | } | 1368 | } |
1052 | else | 1369 | else |
1053 | { | 1370 | { |
1054 | if (m_bgpm.isNull()) | 1371 | if (m_bgpm.isNull()) |
1055 | { | 1372 | { |
1056 | p.fillRect(m_left_border,m_scrolldy-textarray[numlines-1]->lineSpacing(),width()-(m_left_border+m_right_border),textarray[numlines-1]->lineSpacing(),m_bg); | 1373 | p.fillRect(m_left_border,m_scrolldy-textarray[numlines-1]->lineSpacing(),width()-(m_left_border+m_right_border),textarray[numlines-1]->lineSpacing(),m_bg); |
1057 | } | 1374 | } |
1058 | else | 1375 | else |
1059 | { | 1376 | { |
1060 | int h_tmp = textarray[numlines-1]->lineSpacing(); | 1377 | int h_tmp = textarray[numlines-1]->lineSpacing(); |
1061 | bitBlt(this, m_left_border, m_scrolldy-h_tmp, dbuff, m_left_border, m_scrolldy-h_tmp, width()-(m_left_border+m_right_border), h_tmp); | 1378 | bitBlt(this, m_left_border, m_scrolldy-h_tmp, dbuff, m_left_border, m_scrolldy-h_tmp, width()-(m_left_border+m_right_border), h_tmp); |
1062 | } | 1379 | } |
1063 | textarray[numlines-1]->render(&p, m_scrolldy -textarray[numlines-1]->lineSpacing()+ textarray[numlines-1]->ascent(), m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | 1380 | textarray[numlines-1]->render(&p, m_scrolldy -textarray[numlines-1]->lineSpacing()+ textarray[numlines-1]->ascent(), m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); |
1064 | } | 1381 | } |
1065 | mylastpos = locate(); | 1382 | mylastpos = locate(); |
1066 | if (!ch) | 1383 | if (!ch) |
1067 | { | 1384 | { |
1068 | /* | ||
1069 | if (m_rotated) | ||
1070 | { | ||
1071 | blitRot2(0,0,height(),width()-m_scrolldy,NULL); | ||
1072 | // blitRot2(0,0,0,height(),width()-m_scrolldy,NULL); | ||
1073 | } | ||
1074 | else | ||
1075 | { | ||
1076 | if (m_bgpm.isNull()) | ||
1077 | { | ||
1078 | p.fillRect(0,m_scrolldy,width(),height()-m_scrolldy,m_bg); | ||
1079 | } | ||
1080 | else | ||
1081 | { | ||
1082 | bitBlt(this, 0, m_scrolldy, dbuff, 0, m_scrolldy, width(), height()-m_scrolldy); | ||
1083 | } | ||
1084 | } | ||
1085 | */ | ||
1086 | m_scrolldy = m_topmargin; | 1385 | m_scrolldy = m_topmargin; |
1087 | m_autoScroll = false; | 1386 | m_autoScroll = false; |
1088 | #ifdef _SCROLLPIPE | 1387 | #ifdef _SCROLLPIPE |
1089 | for (int i = 0; i < numlines; i++) | 1388 | for (int i = 0; i < numlines; i++) |
1090 | { | 1389 | { |
1091 | if (m_pipeout != NULL) | 1390 | if (m_pipeout != NULL) |
1092 | { | 1391 | { |
1093 | QString outstr = toQString(textarray[i]->data()); | 1392 | QString outstr = toQString(textarray[i]->data()); |
1094 | if (!outstr.isEmpty()) | 1393 | if (!outstr.isEmpty()) |
1095 | { | 1394 | { |
1096 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 1395 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
1097 | fflush(m_pipeout); | 1396 | fflush(m_pipeout); |
1098 | } | 1397 | } |
1099 | } | 1398 | } |
1100 | } | 1399 | } |
1101 | #endif | 1400 | #endif |
1102 | //((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); | ||
1103 | emit SetScrollState(m_autoScroll); | 1401 | emit SetScrollState(m_autoScroll); |
1104 | #ifdef USEQPE | 1402 | #ifdef USEQPE |
1105 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 1403 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
1106 | #endif | 1404 | #endif |
1107 | } | 1405 | } |
1108 | if (m_scrolldy > ht-textarray[numlines]->lineSpacing()) | 1406 | if (m_scrolldy > ht-textarray[numlines]->lineSpacing()) |
1109 | { | 1407 | { |
1110 | if (m_rotated) | 1408 | if (m_rotated) |
1111 | { | 1409 | { |
1112 | if (m_bgpm.isNull()) | 1410 | if (m_bgpm.isNull()) |
1113 | { | 1411 | { |
1114 | p.fillRect(bmargin, m_left_border, ht-m_scrolldy, wh-(m_left_border+m_right_border), m_bg); | 1412 | p.fillRect(bmargin, m_left_border, ht-m_scrolldy, wh-(m_left_border+m_right_border), m_bg); |
1115 | } | 1413 | } |
1116 | else | 1414 | else |
1117 | { | 1415 | { |
1118 | blitRot(bmargin, 0,height(), ht-m_scrolldy, NULL); | 1416 | blitRot(bmargin, 0,height(), ht-m_scrolldy, NULL); |
1119 | } | 1417 | } |
1120 | } | 1418 | } |
1121 | else | 1419 | else |
1122 | if (m_bgpm.isNull()) | 1420 | if (m_bgpm.isNull()) |
1123 | { | 1421 | { |
1124 | p.fillRect(m_left_border,m_scrolldy,width()-(m_left_border+m_right_border),height()-m_scrolldy,m_bg); | 1422 | p.fillRect(m_left_border,m_scrolldy,width()-(m_left_border+m_right_border),height()-m_scrolldy,m_bg); |
1125 | } | 1423 | } |
1126 | else | 1424 | else |
1127 | { | 1425 | { |
1128 | bitBlt(this,m_left_border,m_scrolldy,dbuff,m_left_border,m_scrolldy,width()-(m_left_border+m_right_border), height()-m_scrolldy); | 1426 | bitBlt(this,m_left_border,m_scrolldy,dbuff,m_left_border,m_scrolldy,width()-(m_left_border+m_right_border), height()-m_scrolldy); |
1129 | } | 1427 | } |
1130 | m_scrolldy = m_topmargin; | 1428 | m_scrolldy = m_topmargin; |
1131 | m_scrolldy2 = 0; | 1429 | m_scrolldy2 = 0; |
1132 | } | 1430 | } |
1133 | redrawScroll(&p); | 1431 | redrawScroll(&p); |
1134 | emitRedraw(); | 1432 | emitRedraw(); |
1135 | lastdy = -1; | 1433 | lastdy = -1; |
1136 | } | 1434 | } |
1137 | // else | 1435 | // else |
1138 | { | 1436 | { |
1139 | if (m_rotated) | 1437 | if (m_rotated) |
1140 | { | 1438 | { |
1141 | if (lastdy >= 0) | 1439 | if (lastdy >= 0) |
1142 | { | 1440 | { |
1143 | if (m_bgpm.isNull()) | 1441 | if (m_bgpm.isNull()) |
1144 | { | 1442 | { |
1145 | p.fillRect(width()-lastdy, m_left_border, m_scrollstep, wh-(m_left_border+m_right_border),m_bg); | 1443 | p.fillRect(width()-lastdy, m_left_border, m_scrollstep, wh-(m_left_border+m_right_border),m_bg); |
1146 | } | 1444 | } |
1147 | else | 1445 | else |
1148 | { | 1446 | { |
1149 | blitRot(width()-lastdy,m_left_border,wh-(m_left_border+m_right_border), m_scrollstep, NULL); | 1447 | blitRot(width()-lastdy,m_left_border,wh-(m_left_border+m_right_border), m_scrollstep, NULL); |
1150 | } | 1448 | } |
1151 | } | 1449 | } |
1152 | p.fillRect(width()-m_scrolldy, m_left_border, 1,wh-(m_left_border+m_right_border),m_scrollcolor); | 1450 | p.fillRect(width()-m_scrolldy, m_left_border, 1,wh-(m_left_border+m_right_border),m_scrollcolor); |
1153 | } | 1451 | } |
1154 | else | 1452 | else |
1155 | { | 1453 | { |
1156 | if (lastdy >= 0) | 1454 | if (lastdy >= 0) |
1157 | { | 1455 | { |
1158 | if (m_bgpm.isNull()) | 1456 | if (m_bgpm.isNull()) |
1159 | { | 1457 | { |
1160 | p.fillRect(m_left_border,lastdy,width()-(m_left_border+m_right_border),m_scrollstep,m_bg); | 1458 | p.fillRect(m_left_border,lastdy,width()-(m_left_border+m_right_border),m_scrollstep,m_bg); |
1161 | } | 1459 | } |
1162 | else | 1460 | else |
1163 | { | 1461 | { |
1164 | bitBlt(this, m_left_border, lastdy, dbuff, m_left_border, lastdy, width()-(m_left_border+m_right_border), m_scrollstep); | 1462 | bitBlt(this, m_left_border, lastdy, dbuff, m_left_border, lastdy, width()-(m_left_border+m_right_border), m_scrollstep); |
1165 | } | 1463 | } |
1166 | } | 1464 | } |
1167 | p.fillRect(m_left_border,m_scrolldy,width()-(m_left_border+m_right_border),1,m_scrollcolor); | 1465 | p.fillRect(m_left_border,m_scrolldy,width()-(m_left_border+m_right_border),1,m_scrollcolor); |
1168 | } | 1466 | } |
1169 | } | 1467 | } |
1170 | } | 1468 | } |
1171 | 1469 | ||
1172 | void QTReader::dorollingscroll(bool _statbord) | 1470 | void QTReader::dorollingscroll(bool _statbord) |
1173 | { | 1471 | { |
1174 | bool bredrawscroll = false; | 1472 | bool bredrawscroll = false; |
1175 | QPainter p( this ); | 1473 | QPainter p( this ); |
1176 | // 2 = right, 3 = left | 1474 | // 2 = right, 3 = left |
1177 | int tmargin = (_statbord) ? m_topmargin : 0; | 1475 | int tmargin = (_statbord) ? m_topmargin : 0; |
1178 | int lmargin = (m_scrollpos == 3 || _statbord) ? m_left_border : 0; | 1476 | int lmargin = (m_scrollpos == 3 || _statbord) ? m_left_border : 0; |
1179 | int rmargin = (m_scrollpos == 2 || _statbord) ? m_right_border : 0; | 1477 | int rmargin = (m_scrollpos == 2 || _statbord) ? m_right_border : 0; |
1180 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 1478 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
1181 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; | 1479 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; |
1182 | if (m_rotated) | 1480 | if (m_rotated) |
1183 | { | 1481 | { |
1184 | m_totalscroll = (m_totalscroll+m_scrollstep) % width(); | 1482 | m_totalscroll = (m_totalscroll+m_scrollstep) % width(); |
1185 | bitBlt(this, m_scrollstep+hmargin, lmargin, this, hmargin, lmargin, width()-tmargin-hmargin, height()-(lmargin+rmargin)); | 1483 | bitBlt(this, m_scrollstep+hmargin, lmargin, this, hmargin, lmargin, width()-tmargin-hmargin, height()-(lmargin+rmargin)); |
1186 | if (!m_bgpm.isNull()) | 1484 | if (!m_bgpm.isNull()) |
1187 | { | 1485 | { |
1188 | blitRot(hmargin, tmargin, height(), m_scrollstep, NULL); | 1486 | blitRot(hmargin, tmargin, height(), m_scrollstep, NULL); |
1189 | } | 1487 | } |
1190 | else | 1488 | else |
1191 | { | 1489 | { |
1192 | p.fillRect(hmargin, rmargin, m_scrollstep, height()-lmargin-rmargin, m_bg); | 1490 | p.fillRect(hmargin, rmargin, m_scrollstep, height()-lmargin-rmargin, m_bg); |
1193 | } | 1491 | } |
1194 | } | 1492 | } |
1195 | else | 1493 | else |
1196 | { | 1494 | { |
1197 | m_totalscroll = (m_totalscroll+m_scrollstep) % height(); | 1495 | m_totalscroll = (m_totalscroll+m_scrollstep) % height(); |
1198 | bitBlt(this,lmargin,tmargin,this,lmargin,tmargin+m_scrollstep,width()-(lmargin+rmargin),height() - tmargin - hmargin - m_scrollstep); | 1496 | bitBlt(this,lmargin,tmargin,this,lmargin,tmargin+m_scrollstep,width()-(lmargin+rmargin),height() - tmargin - hmargin - m_scrollstep); |
1199 | if (m_bgpm.isNull()) | 1497 | if (m_bgpm.isNull()) |
1200 | { | 1498 | { |
1201 | p.fillRect(0, height() - (m_scrollstep+1) - hmargin, width(), (m_scrollstep+1), m_bg); | 1499 | p.fillRect(0, height() - (m_scrollstep+1) - hmargin, width(), (m_scrollstep+1), m_bg); |
1202 | } | 1500 | } |
1203 | else | 1501 | else |
1204 | { | 1502 | { |
1205 | int loff = (_statbord) ? 0 : m_totalscroll; | 1503 | int loff = (_statbord) ? 0 : m_totalscroll; |
1206 | bitBlt(this,0,height() - (m_scrollstep+1) - hmargin, dbuff, 0, (loff+height() - (m_scrollstep+1) - hmargin) % height(), width(), (m_scrollstep+1)); | 1504 | bitBlt(this,0,height() - (m_scrollstep+1) - hmargin, dbuff, 0, (loff+height() - (m_scrollstep+1) - hmargin) % height(), width(), (m_scrollstep+1)); |
1207 | } | 1505 | } |
1208 | } | 1506 | } |
1209 | 1507 | ||
1210 | if ((m_scrolldy1 = m_scrolldy1+m_scrollstep) >= textarray[0]->lineSpacing()) | 1508 | if ((m_scrolldy1 = m_scrolldy1+m_scrollstep) >= textarray[0]->lineSpacing()) |
1211 | { | 1509 | { |
1212 | int ht = textarray[0]->lineSpacing(); | 1510 | int ht = textarray[0]->lineSpacing(); |
1213 | bredrawscroll = true; | 1511 | bredrawscroll = true; |
1214 | #ifdef _SCROLLPIPE | 1512 | #ifdef _SCROLLPIPE |
1215 | if (m_pipeout != NULL) | 1513 | if (m_pipeout != NULL) |
1216 | { | 1514 | { |
1217 | QString outstr = toQString(textarray[0]->data()); | 1515 | QString outstr = toQString(textarray[0]->data()); |
1218 | if (!outstr.isEmpty()) | 1516 | if (!outstr.isEmpty()) |
1219 | { | 1517 | { |
1220 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 1518 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
1221 | fflush(m_pipeout); | 1519 | fflush(m_pipeout); |
1222 | } | 1520 | } |
1223 | else if (m_pauseAfterEachPara) | 1521 | else if (m_pauseAfterEachPara) |
1224 | { | 1522 | { |
1225 | m_isPaused = true; | 1523 | m_isPaused = true; |
1226 | timer->stop(); | 1524 | timer->stop(); |
1227 | } | 1525 | } |
1228 | } | 1526 | } |
1229 | #endif | 1527 | #endif |
1230 | CDrawBuffer* buff = textarray[0]; | 1528 | CDrawBuffer* buff = textarray[0]; |
1231 | for (int i = 1; i <= numlines; i++) | 1529 | for (int i = 1; i <= numlines; i++) |
1232 | { | 1530 | { |
1233 | textarray[i-1] = textarray[i]; | 1531 | textarray[i-1] = textarray[i]; |
1234 | locnarray[i-1] = locnarray[i]; | 1532 | locnarray[i-1] = locnarray[i]; |
1235 | } | 1533 | } |
1236 | textarray[numlines] = buff; | 1534 | textarray[numlines] = buff; |
1237 | --numlines; | 1535 | --numlines; |
1238 | m_scrolldy1 -= ht; | 1536 | m_scrolldy1 -= ht; |
1239 | } | 1537 | } |
1240 | if ((m_scrolldy2 = m_scrolldy2+m_scrollstep) >= textarray[numlines]->lineSpacing()) | 1538 | if ((m_scrolldy2 = m_scrolldy2+m_scrollstep) >= textarray[numlines]->lineSpacing()) |
1241 | { | 1539 | { |
1242 | bredrawscroll = true; | 1540 | bredrawscroll = true; |
1243 | m_scrolldy2 -= textarray[numlines]->lineSpacing(); | 1541 | m_scrolldy2 -= textarray[numlines]->lineSpacing(); |
1244 | numlines++; | 1542 | numlines++; |
1245 | 1543 | ||
1246 | if (textarray[numlines] == NULL) | 1544 | if (textarray[numlines] == NULL) |
1247 | { | 1545 | { |
1248 | textarray[numlines] = new CDrawBuffer(&m_fontControl); | 1546 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
1249 | } | 1547 | } |
1250 | locnarray[numlines] = locate(); | 1548 | locnarray[numlines] = locate(); |
1251 | int ch = getline(textarray[numlines]); | 1549 | int ch = getline(textarray[numlines]); |
1252 | if (m_rotated) | 1550 | if (m_rotated) |
1253 | { | 1551 | { |
1254 | blitRot(hmargin, 0, height(), -1, textarray[numlines-1]); | 1552 | blitRot(hmargin, 0, height(), -1, textarray[numlines-1]); |
1255 | } | 1553 | } |
1256 | else | 1554 | else |
1257 | { | 1555 | { |
1258 | // textarray[numlines-1]->render(&p, height() - textarray[numlines-1]->descent() - 2 - hmargin, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg); | 1556 | // textarray[numlines-1]->render(&p, height() - textarray[numlines-1]->descent() - 2 - hmargin, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg); |
1259 | textarray[numlines-1]->render(&p, height() - textarray[numlines-1]->descent() - textarray[numlines-1]->lineExtraSpacing() - 1 - hmargin, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | 1557 | textarray[numlines-1]->render(&p, height() - textarray[numlines-1]->descent() - textarray[numlines-1]->lineExtraSpacing() - 1 - hmargin, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); |
1260 | 1558 | ||
1261 | } | 1559 | } |
1262 | mylastpos = locate(); | 1560 | mylastpos = locate(); |
1263 | if (!ch) | 1561 | if (!ch) |
1264 | { | 1562 | { |
1265 | redrawScroll(&p); | 1563 | redrawScroll(&p); |
1266 | emitRedraw(); | 1564 | emitRedraw(); |
1267 | m_autoScroll = false; | 1565 | m_autoScroll = false; |
1268 | #ifdef _SCROLLPIPE | 1566 | #ifdef _SCROLLPIPE |
1269 | for (int i = 0; i < numlines; i++) | 1567 | for (int i = 0; i < numlines; i++) |
1270 | { | 1568 | { |
1271 | if (m_pipeout != NULL) | 1569 | if (m_pipeout != NULL) |
1272 | { | 1570 | { |
1273 | QString outstr = toQString(textarray[i]->data()); | 1571 | QString outstr = toQString(textarray[i]->data()); |
1274 | if (!outstr.isEmpty()) | 1572 | if (!outstr.isEmpty()) |
1275 | { | 1573 | { |
1276 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 1574 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
1277 | fflush(m_pipeout); | 1575 | fflush(m_pipeout); |
1278 | } | 1576 | } |
1279 | } | 1577 | } |
1280 | } | 1578 | } |
1281 | #endif | 1579 | #endif |
1282 | emit SetScrollState(m_autoScroll); | 1580 | emit SetScrollState(m_autoScroll); |
1283 | #ifdef USEQPE | 1581 | #ifdef USEQPE |
1284 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 1582 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
1285 | #endif | 1583 | #endif |
1286 | return; | 1584 | return; |
1287 | } | 1585 | } |
1288 | } | 1586 | } |
1289 | if (!bredrawscroll && ((m_scrolldy2/m_scrollstep) % 10 == 5) && textarray[numlines]->showPartial()) | 1587 | if (!bredrawscroll && ((m_scrolldy2/m_scrollstep) % 10 == 5) && textarray[numlines]->showPartial()) |
1290 | { | 1588 | { |
1291 | if (m_rotated) | 1589 | if (m_rotated) |
1292 | { | 1590 | { |
1293 | blitRot(hmargin + m_scrolldy2 - textarray[numlines]->lineSpacing(), 0, height(), -1, textarray[numlines]); | 1591 | blitRot(hmargin + m_scrolldy2 - textarray[numlines]->lineSpacing(), 0, height(), -1, textarray[numlines]); |
1294 | } | 1592 | } |
1295 | else | 1593 | else |
1296 | { | 1594 | { |
1297 | textarray[numlines]->render( &p, height() + textarray[numlines]->lineSpacing() - textarray[numlines]->descent() - 2 - hmargin-m_scrolldy2, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | 1595 | textarray[numlines]->render( &p, height() + textarray[numlines]->lineSpacing() - textarray[numlines]->descent() - 2 - hmargin-m_scrolldy2, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); |
1298 | } | 1596 | } |
1299 | } | 1597 | } |
1300 | if (m_scrollpos != 0) | 1598 | if (m_scrollpos != 0) |
1301 | { | 1599 | { |
1302 | redrawScroll(&p); | 1600 | redrawScroll(&p); |
1303 | } | 1601 | } |
1304 | if (bredrawscroll) emitRedraw(); | 1602 | if (bredrawscroll) emitRedraw(); |
1305 | } | 1603 | } |
1306 | 1604 | ||
1307 | void QTReader::dostaticscroll() | 1605 | void QTReader::dostaticscroll() |
1308 | { | 1606 | { |
1309 | redrawall(); | 1607 | redrawall(); |
1310 | bool bredraw = false; | 1608 | bool bredraw = false; |
1311 | if ((m_scrolldy1 = m_scrolldy1+m_scrollstep) >= textarray[0]->lineSpacing()) | 1609 | if ((m_scrolldy1 = m_scrolldy1+m_scrollstep) >= textarray[0]->lineSpacing()) |
1312 | { | 1610 | { |
1313 | int ht = textarray[0]->lineSpacing(); | 1611 | int ht = textarray[0]->lineSpacing(); |
1314 | bredraw = true; | 1612 | bredraw = true; |
1315 | #ifdef _SCROLLPIPE | 1613 | #ifdef _SCROLLPIPE |
1316 | if (m_pipeout != NULL) | 1614 | if (m_pipeout != NULL) |
1317 | { | 1615 | { |
1318 | QString outstr = toQString(textarray[0]->data()); | 1616 | QString outstr = toQString(textarray[0]->data()); |
1319 | if (!outstr.isEmpty()) | 1617 | if (!outstr.isEmpty()) |
1320 | { | 1618 | { |
1321 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 1619 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
1322 | fflush(m_pipeout); | 1620 | fflush(m_pipeout); |
1323 | } | 1621 | } |
1324 | else if (m_pauseAfterEachPara) | 1622 | else if (m_pauseAfterEachPara) |
1325 | { | 1623 | { |
1326 | m_isPaused = true; | 1624 | m_isPaused = true; |
1327 | timer->stop(); | 1625 | timer->stop(); |
1328 | } | 1626 | } |
1329 | } | 1627 | } |
1330 | #endif | 1628 | #endif |
1331 | CDrawBuffer* buff = textarray[0]; | 1629 | CDrawBuffer* buff = textarray[0]; |
1332 | for (int i = 1; i <= numlines; i++) | 1630 | for (int i = 1; i <= numlines; i++) |
1333 | { | 1631 | { |
1334 | textarray[i-1] = textarray[i]; | 1632 | textarray[i-1] = textarray[i]; |
1335 | locnarray[i-1] = locnarray[i]; | 1633 | locnarray[i-1] = locnarray[i]; |
1336 | } | 1634 | } |
1337 | textarray[numlines] = buff; | 1635 | textarray[numlines] = buff; |
1338 | --numlines; | 1636 | --numlines; |
1339 | m_scrolldy1 -= ht; | 1637 | m_scrolldy1 -= ht; |
1340 | } | 1638 | } |
1341 | if ((m_scrolldy2 = m_scrolldy2 + m_scrollstep) >= textarray[numlines]->lineSpacing()) | 1639 | if ((m_scrolldy2 = m_scrolldy2 + m_scrollstep) >= textarray[numlines]->lineSpacing()) |
1342 | { | 1640 | { |
1343 | bredraw = true; | 1641 | bredraw = true; |
1344 | m_scrolldy2 -= textarray[numlines]->lineSpacing(); | 1642 | m_scrolldy2 -= textarray[numlines]->lineSpacing(); |
1345 | numlines++; | 1643 | numlines++; |
1346 | 1644 | ||
1347 | if (textarray[numlines] == NULL) | 1645 | if (textarray[numlines] == NULL) |
1348 | { | 1646 | { |
1349 | textarray[numlines] = new CDrawBuffer(&m_fontControl); | 1647 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
1350 | } | 1648 | } |
1351 | locnarray[numlines] = locate(); | 1649 | locnarray[numlines] = locate(); |
1352 | int ch = getline(textarray[numlines]); | 1650 | int ch = getline(textarray[numlines]); |
1353 | mylastpos = locate(); | 1651 | mylastpos = locate(); |
1354 | if (!ch) | 1652 | if (!ch) |
1355 | { | 1653 | { |
1356 | redrawall(); | 1654 | redrawall(); |
1357 | emitRedraw(); | 1655 | emitRedraw(); |
1358 | m_autoScroll = false; | 1656 | m_autoScroll = false; |
1359 | #ifdef _SCROLLPIPE | 1657 | #ifdef _SCROLLPIPE |
1360 | for (int i = 0; i < numlines; i++) | 1658 | for (int i = 0; i < numlines; i++) |
1361 | { | 1659 | { |
1362 | if (m_pipeout != NULL) | 1660 | if (m_pipeout != NULL) |
1363 | { | 1661 | { |
1364 | QString outstr = toQString(textarray[i]->data()); | 1662 | QString outstr = toQString(textarray[i]->data()); |
1365 | if (!outstr.isEmpty()) | 1663 | if (!outstr.isEmpty()) |
1366 | { | 1664 | { |
1367 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 1665 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
1368 | fflush(m_pipeout); | 1666 | fflush(m_pipeout); |
1369 | } | 1667 | } |
1370 | } | 1668 | } |
1371 | } | 1669 | } |
1372 | #endif | 1670 | #endif |
1373 | emit SetScrollState(m_autoScroll); | 1671 | emit SetScrollState(m_autoScroll); |
1374 | #ifdef USEQPE | 1672 | #ifdef USEQPE |
1375 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 1673 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
1376 | #endif | 1674 | #endif |
1377 | return; | 1675 | return; |
1378 | } | 1676 | } |
1379 | } | 1677 | } |
1380 | if (bredraw) emitRedraw(); | 1678 | if (bredraw) emitRedraw(); |
1381 | } | 1679 | } |
1382 | 1680 | ||
1383 | void QTReader::redrawScroll(QPainter* p) | 1681 | void QTReader::redrawScroll(QPainter* p) |
1384 | { | 1682 | { |
1385 | int offset = (m_scrolltype == 1) ? m_totalscroll : 0; | 1683 | int offset = (m_scrolltype == 1) ? m_totalscroll : 0; |
1386 | switch (m_scrollpos) | 1684 | switch (m_scrollpos) |
1387 | { | 1685 | { |
1388 | case 1: | 1686 | case 1: |
1389 | { | 1687 | { |
1390 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 1688 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
1391 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; | 1689 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; |
1392 | if (m_rotated) | 1690 | if (m_rotated) |
1393 | { | 1691 | { |
1394 | if (m_bgpm.isNull()) | 1692 | if (m_bgpm.isNull()) |
1395 | { | 1693 | { |
1396 | p->fillRect(0,0,hmargin,height(),m_bg); | 1694 | p->fillRect(0,0,hmargin,height(),m_bg); |
1397 | } | 1695 | } |
1398 | else | 1696 | else |
1399 | { | 1697 | { |
1400 | blitRot(0,0, height(), hmargin, NULL); | 1698 | blitRot(0,0, height(), hmargin, NULL); |
1401 | } | 1699 | } |
1402 | } | 1700 | } |
1403 | else | 1701 | else |
1404 | { | 1702 | { |
1405 | if (m_bgpm.isNull()) | 1703 | if (m_bgpm.isNull()) |
1406 | { | 1704 | { |
1407 | p->fillRect(0,height() - hmargin,width(),hmargin,m_bg); | 1705 | p->fillRect(0,height() - hmargin,width(),hmargin,m_bg); |
1408 | } | 1706 | } |
1409 | else | 1707 | else |
1410 | { | 1708 | { |
1411 | int toffset = (offset+height()-hmargin) % height(); | 1709 | int toffset = (offset+height()-hmargin) % height(); |
1412 | if (toffset+hmargin > height()) | 1710 | if (toffset+hmargin > height()) |
1413 | { | 1711 | { |
1414 | int fp = height()-toffset; | 1712 | int fp = height()-toffset; |
1415 | bitBlt(this, | 1713 | bitBlt(this, |
1416 | 0,height() - hmargin, | 1714 | 0,height() - hmargin, |
1417 | dbuff, | 1715 | dbuff, |
1418 | 0, toffset, width(), fp); | 1716 | 0, toffset, width(), fp); |
1419 | bitBlt(this, | 1717 | bitBlt(this, |
1420 | 0,height()-hmargin+fp, | 1718 | 0,height()-hmargin+fp, |
1421 | dbuff, | 1719 | dbuff, |
1422 | 0, 0, width(), hmargin-fp); | 1720 | 0, 0, width(), hmargin-fp); |
1423 | } | 1721 | } |
1424 | else | 1722 | else |
1425 | { | 1723 | { |
1426 | bitBlt(this, | 1724 | bitBlt(this, |
1427 | 0,height() - hmargin, | 1725 | 0,height() - hmargin, |
1428 | dbuff, | 1726 | dbuff, |
1429 | 0, toffset, width(), hmargin); | 1727 | 0, toffset, width(), hmargin); |
1430 | } | 1728 | } |
1431 | } | 1729 | } |
1432 | } | 1730 | } |
1433 | } | 1731 | } |
1434 | break; | 1732 | break; |
1435 | case 2: //right | 1733 | case 2: //right |
1436 | if (m_rotated) | 1734 | if (m_rotated) |
1437 | { | 1735 | { |
1438 | if (m_bgpm.isNull()) | 1736 | if (m_bgpm.isNull()) |
1439 | { | 1737 | { |
1440 | p->fillRect(0,height()-m_right_border,width(),m_right_border,m_bg); | 1738 | p->fillRect(0,height()-m_right_border,width(),m_right_border,m_bg); |
1441 | } | 1739 | } |
1442 | else | 1740 | else |
1443 | { | 1741 | { |
1444 | blitRot(0,height()-m_right_border, m_right_border, width(), NULL); | 1742 | blitRot(0,height()-m_right_border, m_right_border, width(), NULL); |
1445 | } | 1743 | } |
1446 | } | 1744 | } |
1447 | else | 1745 | else |
1448 | { | 1746 | { |
1449 | if (m_bgpm.isNull()) | 1747 | if (m_bgpm.isNull()) |
1450 | { | 1748 | { |
1451 | p->fillRect(width()-m_right_border,0,m_right_border,height(),m_bg); | 1749 | p->fillRect(width()-m_right_border,0,m_right_border,height(),m_bg); |
1452 | } | 1750 | } |
1453 | else | 1751 | else |
1454 | { | 1752 | { |
1455 | int x = width() - m_right_border; | 1753 | int x = width() - m_right_border; |
1456 | int fp = height()-offset; | 1754 | int fp = height()-offset; |
1457 | bitBlt(this, x, 0, dbuff, x, offset, m_right_border, fp); | 1755 | bitBlt(this, x, 0, dbuff, x, offset, m_right_border, fp); |
1458 | bitBlt(this, x, fp, dbuff, x, 0, m_right_border, height()-fp); | 1756 | bitBlt(this, x, fp, dbuff, x, 0, m_right_border, height()-fp); |
1459 | } | 1757 | } |
1460 | } | 1758 | } |
1461 | break; | 1759 | break; |
1462 | case 3: //left | 1760 | case 3: //left |
1463 | if (m_rotated) | 1761 | if (m_rotated) |
1464 | { | 1762 | { |
1465 | if (m_bgpm.isNull()) | 1763 | if (m_bgpm.isNull()) |
1466 | { | 1764 | { |
1467 | p->fillRect(0,0,width(),m_left_border,m_bg); | 1765 | p->fillRect(0,0,width(),m_left_border,m_bg); |
1468 | } | 1766 | } |
1469 | else | 1767 | else |
1470 | { | 1768 | { |
1471 | blitRot(0,0, m_left_border, width(), NULL); | 1769 | blitRot(0,0, m_left_border, width(), NULL); |
1472 | } | 1770 | } |
1473 | } | 1771 | } |
1474 | else | 1772 | else |
1475 | { | 1773 | { |
1476 | if (m_bgpm.isNull()) | 1774 | if (m_bgpm.isNull()) |
1477 | { | 1775 | { |
1478 | p->fillRect(0,0,m_left_border,height(),m_bg); | 1776 | p->fillRect(0,0,m_left_border,height(),m_bg); |
1479 | } | 1777 | } |
1480 | else | 1778 | else |
1481 | { | 1779 | { |
1482 | int fp = height()-offset; | 1780 | int fp = height()-offset; |
1483 | bitBlt(this, 0, 0, dbuff, 0, offset, m_left_border, fp); | 1781 | bitBlt(this, 0, 0, dbuff, 0, offset, m_left_border, fp); |
1484 | bitBlt(this, 0, fp, dbuff, 0, 0, m_left_border, height()-fp); | 1782 | bitBlt(this, 0, fp, dbuff, 0, 0, m_left_border, height()-fp); |
1485 | } | 1783 | } |
1486 | } | 1784 | } |
1487 | break; | 1785 | break; |
1488 | case 0: | 1786 | case 0: |
1489 | default: | 1787 | default: |
1490 | break; | 1788 | break; |
1491 | } | 1789 | } |
1492 | if (m_scrollpos != 0) DrawScroll(p, width(), height()); | 1790 | if (m_scrollpos != 0) DrawScroll(p, width(), height()); |
1493 | } | 1791 | } |
1494 | 1792 | ||
1495 | void QTReader::autoscroll() | 1793 | void QTReader::autoscroll() |
1496 | { | 1794 | { |
1497 | drawBackground(); | 1795 | if (m_scrolltype == 4) |
1498 | dbp->end(); | 1796 | { |
1499 | timer->start(real_delay(), false); | 1797 | readAloud(); |
1798 | } | ||
1799 | else | ||
1800 | { | ||
1801 | if (dbuff != NULL) | ||
1802 | { | ||
1803 | dbp->begin(dbuff); | ||
1804 | drawBackground(dbp); | ||
1805 | dbp->end(); | ||
1806 | } | ||
1807 | timer->start(real_delay(), false); | ||
1808 | } | ||
1500 | } | 1809 | } |
1501 | 1810 | ||
1502 | void QTReader::setfont() | 1811 | void QTReader::setfont() |
1503 | { | 1812 | { |
1504 | // m_fontControl.Change | 1813 | // m_fontControl.Change |
1505 | m_charWidth = (m_charpc*m_fontControl.currentsize())/100; | 1814 | m_charWidth = (m_charpc*m_fontControl.currentsize())/100; |
1506 | if (m_charWidth <= 0) m_charWidth = 1; | 1815 | if (m_charWidth <= 0) m_charWidth = 1; |
1507 | m_ascent = m_fontControl.ascent(); | 1816 | m_ascent = m_fontControl.ascent(); |
1508 | m_descent = m_fontControl.descent(); | 1817 | m_descent = m_fontControl.descent(); |
1509 | m_linespacing = m_fontControl.lineSpacing(); | 1818 | m_linespacing = m_fontControl.lineSpacing(); |
1510 | } | 1819 | } |
1511 | 1820 | ||
1512 | void QTReader::DrawStraight(QPainter* p, int w, int h) | 1821 | void QTReader::DrawStraight(QPainter* p, int w, int h) |
1513 | { | 1822 | { |
1514 | if (m_scrolldy == m_topmargin) | 1823 | if (m_scrolldy == m_topmargin) |
1515 | { | 1824 | { |
1516 | int ypos = textarray[0]->ascent()-m_scrolldy1+m_topmargin; | 1825 | int ypos = textarray[0]->ascent()-m_scrolldy1+m_topmargin; |
1517 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); | 1826 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); |
1518 | int i; | 1827 | int i; |
1519 | for (i = 1; i < numlines; i++) | 1828 | for (i = 1; i < numlines; i++) |
1520 | { | 1829 | { |
1521 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ | 1830 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ |
1522 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; | 1831 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; |
1523 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); | 1832 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); |
1524 | } | 1833 | } |
1525 | if (textarray[i]->showPartial()) | 1834 | if (textarray[i]->showPartial()) |
1526 | { | 1835 | { |
1527 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ | 1836 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ |
1528 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; | 1837 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; |
1529 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); | 1838 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); |
1530 | } | 1839 | } |
1531 | } | 1840 | } |
1532 | else | 1841 | else |
1533 | { | 1842 | { |
1534 | int ypos = textarray[0]->ascent()-m_scrolldy1+m_scrolldy+m_topmargin; | 1843 | int ypos = textarray[0]->ascent()-m_scrolldy1+m_scrolldy+m_topmargin; |
1535 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); | 1844 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); |
1536 | // p->fillRect(m_border, 0, w-2*m_border, m_scrolldy, m_bg); | 1845 | // p->fillRect(m_border, 0, w-2*m_border, m_scrolldy, m_bg); |
1537 | for (int i = 1; i < numlines; i++) | 1846 | for (int i = 1; i < numlines; i++) |
1538 | { | 1847 | { |
1539 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ | 1848 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ |
1540 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; | 1849 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; |
1541 | if (ypos+textarray[i]->descent() > h) | 1850 | if (ypos+textarray[i]->descent() > h) |
1542 | { | 1851 | { |
1543 | ypos = textarray[i]->ascent(); | 1852 | ypos = textarray[i]->ascent(); |
1544 | } | 1853 | } |
1545 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); | 1854 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); |
1546 | } | 1855 | } |
1547 | p->fillRect(m_left_border,m_scrolldy,w-(m_left_border+m_right_border),1,m_scrollcolor); | 1856 | p->fillRect(m_left_border,m_scrolldy,w-(m_left_border+m_right_border),1,m_scrollcolor); |
1548 | } | 1857 | } |
1549 | bool wasrotated = m_rotated; | 1858 | bool wasrotated = m_rotated; |
1550 | m_rotated = false; | 1859 | m_rotated = false; |
1551 | DrawScroll(p, w, h); | 1860 | DrawScroll(p, w, h); |
1552 | m_rotated = wasrotated; | 1861 | m_rotated = wasrotated; |
1553 | 1862 | ||
1554 | } | 1863 | } |
1555 | 1864 | ||
1556 | void QTReader::redrawall() | 1865 | void QTReader::redrawall() |
1557 | { | 1866 | { |
1558 | if (m_rotated) | 1867 | if (m_rotated) |
1559 | { | 1868 | { |
1560 | #ifdef DOUBLEBUFFER | 1869 | if (dbuff != NULL) |
1561 | drawBackground(); | 1870 | { |
1562 | DrawStraight(dbp, height(), width()); | 1871 | dbp->begin(dbuff); |
1563 | dbp->end(); | 1872 | drawBackground(dbp); |
1564 | 1873 | DrawStraight(dbp, height(), width()); | |
1565 | QWMatrix m; | 1874 | dbp->end(); |
1566 | m.rotate(90); | 1875 | |
1567 | QPixmap rp = dbuff->xForm(m); | 1876 | QWMatrix m; |
1568 | bitBlt(this, 0,0,&rp,0,0,-1,-1); | 1877 | m.rotate(90); |
1569 | #else | 1878 | QPixmap rp = dbuff->xForm(m); |
1570 | QPixmap dbuff(height(), width()); | 1879 | bitBlt(this, 0,0,&rp,0,0,-1,-1); |
1571 | QPainter dbp(&dbuff); | 1880 | } |
1572 | // dbp.setBackgroundMode(OpaqueMode); | 1881 | else |
1573 | dbp.fillRect(dbuff.rect(), m_bg); | 1882 | { |
1574 | 1883 | qDebug("This shouldn't happen but it doesn't matter if it does (rotated == double buffered)"); | |
1575 | DrawStraight(&dbp, height(), width()); | 1884 | QPixmap dbuff(height(), width()); |
1576 | 1885 | QPainter dbp(&dbuff); | |
1577 | QWMatrix m; | 1886 | |
1578 | m.rotate(90); | 1887 | drawBackground(&dbp); |
1579 | QPixmap rp = dbuff.xForm(m); | 1888 | DrawStraight(&dbp, height(), width()); |
1580 | bitBlt(this, 0,0,&rp,0,0,-1,-1); | 1889 | |
1581 | #endif | 1890 | QWMatrix m; |
1891 | m.rotate(90); | ||
1892 | QPixmap rp = dbuff.xForm(m); | ||
1893 | bitBlt(this, 0,0,&rp,0,0,-1,-1); | ||
1894 | } | ||
1582 | } | 1895 | } |
1583 | else | 1896 | else |
1584 | { | 1897 | { |
1585 | #ifdef DOUBLEBUFFER | 1898 | if (dbuff != NULL) |
1586 | drawBackground(); | 1899 | { |
1587 | DrawStraight(dbp, width(), height()); | 1900 | dbp->begin(dbuff); |
1588 | dbp->end(); | 1901 | drawBackground(dbp); |
1589 | bitBlt(this, 0,0,dbuff,0,0,-1,-1); | 1902 | DrawStraight(dbp, width(), height()); |
1590 | #else | 1903 | dbp->end(); |
1591 | DrawStraight(p, width(), height()); | 1904 | bitBlt(this, 0,0,dbuff,0,0,-1,-1); |
1592 | #endif | 1905 | } |
1906 | else | ||
1907 | { | ||
1908 | QPainter p(this); | ||
1909 | drawBackground(&p); | ||
1910 | DrawStraight(&p, width(), height()); | ||
1911 | } | ||
1593 | } | 1912 | } |
1594 | } | 1913 | } |
1595 | 1914 | ||
1596 | void QTReader::drawFonts() | 1915 | void QTReader::drawFonts() |
1597 | { | 1916 | { |
1598 | if (bDoUpdates) | 1917 | if (bDoUpdates) |
1599 | { | 1918 | { |
1600 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 1919 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
1601 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; | 1920 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; |
1602 | //qDebug("How refreshing..."); | 1921 | //qDebug("How refreshing..."); |
1603 | if (buffdoc.empty()) return; | 1922 | if (buffdoc.empty()) |
1923 | { | ||
1924 | if (dbuff != NULL) | ||
1925 | { | ||
1926 | dbp->begin(dbuff); | ||
1927 | drawBackground(dbp); | ||
1928 | dbp->end(); | ||
1929 | } | ||
1930 | else | ||
1931 | { | ||
1932 | QPainter p(this); | ||
1933 | drawBackground(&p); | ||
1934 | } | ||
1935 | return; | ||
1936 | } | ||
1604 | setfont(); | 1937 | setfont(); |
1605 | //if (!m_autoScroll) m_scrolldy1 = 0; | 1938 | //if (!m_autoScroll) m_scrolldy1 = 0; |
1606 | #ifdef ROTATION_ENABLED | 1939 | if (dbuff != NULL && (dbuff->width() != width() || dbuff->height() != height())) |
1940 | { | ||
1941 | qDebug("Oh no! A resize event was missed..."); | ||
1942 | if (m_rotated) | ||
1943 | { | ||
1944 | dbuff->resize(height(), width()); | ||
1945 | } | ||
1946 | else | ||
1947 | { | ||
1948 | dbuff->resize(width(), height()); | ||
1949 | } | ||
1950 | m_lastwidth = 0; | ||
1951 | } | ||
1607 | if (m_lastwidth != ((m_rotated) ? height() : width())) | 1952 | if (m_lastwidth != ((m_rotated) ? height() : width())) |
1608 | { | 1953 | { |
1609 | m_scrolldy = m_topmargin; | 1954 | m_scrolldy = m_topmargin; |
1610 | // qDebug("Not Optimised %d", m_lastwidth); | 1955 | // qDebug("Not Optimised %d", m_lastwidth); |
1611 | m_lastwidth = ((m_rotated) ? height() : width()); | 1956 | m_lastwidth = ((m_rotated) ? height() : width()); |
1612 | m_lastheight = ((m_rotated) ? width() : height()); | 1957 | m_lastheight = ((m_rotated) ? width() : height()); |
1613 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); | 1958 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); |
1614 | locate(pagelocate()); | 1959 | buffdoc.locate(pagelocate()); |
1960 | fillbuffer(); | ||
1961 | redrawall(); | ||
1615 | // qDebug("Not Optimised %d", m_lastwidth); | 1962 | // qDebug("Not Optimised %d", m_lastwidth); |
1616 | } | 1963 | } |
1617 | else | 1964 | else |
1618 | { | 1965 | { |
1619 | int newht = ((m_rotated) ? width() : height()); | 1966 | int newht = ((m_rotated) ? width() : height()); |
1620 | if (m_lastheight > newht) | 1967 | if (m_lastheight > newht) |
1621 | { | 1968 | { |
1622 | // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht); | 1969 | // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht); |
1623 | m_scrolldy = m_topmargin; | 1970 | m_scrolldy = m_topmargin; |
1624 | int ypos = m_scrolldy1+m_topmargin; | 1971 | int ypos = m_scrolldy1+m_topmargin; |
1625 | for (int i = 0; i < numlines; i++) | 1972 | for (int i = 0; i < numlines; i++) |
1626 | { | 1973 | { |
1627 | if ((ypos += textarray[i]->lineSpacing()) > newht - hmargin) | 1974 | if ((ypos += textarray[i]->lineSpacing()) > newht - hmargin) |
1628 | { | 1975 | { |
1629 | numlines = i; | 1976 | numlines = i; |
1630 | jumpto(mylastpos = locnarray[i+1]); | 1977 | jumpto(mylastpos = locnarray[i+1]); |
1631 | break; | 1978 | break; |
1632 | } | 1979 | } |
1633 | } | 1980 | } |
1634 | // qDebug("Optimised < %d", numlines); | 1981 | // qDebug("Optimised < %d", numlines); |
1635 | m_lastheight = newht; | 1982 | m_lastheight = newht; |
1636 | } | 1983 | } |
1637 | else if (m_lastheight < newht) | 1984 | else if (m_lastheight < newht) |
1638 | { | 1985 | { |
1639 | m_scrolldy = m_topmargin; | 1986 | m_scrolldy = m_topmargin; |
1640 | // qDebug("Optimised > %d", numlines); | 1987 | // qDebug("Optimised > %d", numlines); |
1641 | int ypos = m_scrolldy1+m_topmargin; | 1988 | int ypos = m_scrolldy1+m_topmargin; |
1642 | for (int i = 0; i <= numlines; i++) | 1989 | for (int i = 0; i <= numlines; i++) |
1643 | { | 1990 | { |
1644 | ypos += textarray[i]->lineSpacing(); | 1991 | ypos += textarray[i]->lineSpacing(); |
1645 | } | 1992 | } |
1646 | fillbuffer(numlines+1, ypos, newht); | 1993 | fillbuffer(numlines+1, ypos, newht); |
1647 | // qDebug("Optimised > %d", numlines); | 1994 | // qDebug("Optimised > %d", numlines); |
1648 | } | 1995 | } |
1649 | if (numlines > 0) | 1996 | if (numlines > 0) |
1650 | { | 1997 | { |
1651 | redrawall(); | 1998 | redrawall(); |
1652 | } | 1999 | } |
1653 | } | 2000 | } |
1654 | #else | ||
1655 | if (m_lastwidth != width()) | ||
1656 | { | ||
1657 | // qDebug("Not Optimised %d", m_lastwidth); | ||
1658 | m_lastwidth = width(); | ||
1659 | m_lastheight = height(); | ||
1660 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); | ||
1661 | locate(pagelocate()); | ||
1662 | // qDebug("Not Optimised %d", m_lastwidth); | ||
1663 | } | ||
1664 | else | ||
1665 | { | ||
1666 | int newht = height(); | ||
1667 | if (m_lastheight > newht) | ||
1668 | { | ||
1669 | // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht); | ||
1670 | int ypos = m_topmargin; | ||
1671 | for (int i = 0; i < numlines; i++) | ||
1672 | { | ||
1673 | if ((ypos += textarray[i]->lineSpacing()) > newht - hmargin) | ||
1674 | { | ||
1675 | numlines = i; | ||
1676 | jumpto(mylastpos = locnarray[i+1]); | ||
1677 | break; | ||
1678 | } | ||
1679 | } | ||
1680 | // qDebug("Optimised < %d", numlines); | ||
1681 | m_lastheight = newht; | ||
1682 | } | ||
1683 | else if (m_lastheight < newht) | ||
1684 | { | ||
1685 | // qDebug("Optimised > %d", numlines); | ||
1686 | int ypos = m_topmargin; | ||
1687 | for (int i = 0; i <= numlines; i++) | ||
1688 | { | ||
1689 | ypos += textarray[i]->lineSpacing(); | ||
1690 | } | ||
1691 | fillbuffer(numlines+1, ypos, newht); | ||
1692 | // qDebug("Optimised > %d", numlines); | ||
1693 | } | ||
1694 | if (numlines > 0) | ||
1695 | { | ||
1696 | int ypos = textarray[0]->ascent()+m_topmargin; | ||
1697 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | ||
1698 | // int last = (m_showlast) ? numlines : numlines-1; | ||
1699 | // for (int i = 1; i <= last; i++) | ||
1700 | for (int i = 1; i < numlines; i++) | ||
1701 | { | ||
1702 | // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; | ||
1703 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ | ||
1704 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; | ||
1705 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | ||
1706 | } | ||
1707 | // mylastpos = locate(); | ||
1708 | } | ||
1709 | } | ||
1710 | #endif | ||
1711 | emitRedraw(); | 2001 | emitRedraw(); |
1712 | } | 2002 | } |
1713 | /* | 2003 | /* |
1714 | else | 2004 | else |
1715 | { | 2005 | { |
1716 | qDebug("Not so refreshing..."); | 2006 | qDebug("Not so refreshing..."); |
1717 | } | 2007 | } |
1718 | */ | 2008 | */ |
1719 | } | 2009 | } |
1720 | 2010 | ||
1721 | void QTReader::DrawScroll( QPainter *p, int _w, int _h ) | 2011 | void QTReader::DrawScroll( QPainter *p, int _w, int _h ) |
1722 | { | 2012 | { |
1723 | if (!buffdoc.empty()) | 2013 | if (!buffdoc.empty()) |
1724 | { | 2014 | { |
1725 | QBrush checkered = QBrush( Dense4Pattern ); | 2015 | QBrush checkered = QBrush( Dense4Pattern ); |
1726 | checkered.setColor(m_scrollbarcolor); | 2016 | checkered.setColor(m_scrollbarcolor); |
1727 | switch (m_scrollpos) | 2017 | switch (m_scrollpos) |
1728 | { | 2018 | { |
1729 | case 1: | 2019 | case 1: |
1730 | if (m_rotated) | 2020 | if (m_rotated) |
1731 | { | 2021 | { |
1732 | p->fillRect(0, 0, 2, _h, checkered); | 2022 | p->fillRect(0, 0, 2, _h, checkered); |
1733 | } | 2023 | } |
1734 | else | 2024 | else |
1735 | { | 2025 | { |
1736 | p->fillRect(0, _h-2, _w, 2, checkered); | 2026 | p->fillRect(0, _h-2, _w, 2, checkered); |
1737 | } | 2027 | } |
1738 | break; | 2028 | break; |
1739 | case 2: | 2029 | case 2: |
1740 | if (m_rotated) | 2030 | if (m_rotated) |
1741 | { | 2031 | { |
1742 | p->fillRect(0, _h-2, _w, 2, checkered); | 2032 | p->fillRect(0, _h-2, _w, 2, checkered); |
1743 | } | 2033 | } |
1744 | else | 2034 | else |
1745 | { | 2035 | { |
1746 | p->fillRect(_w-2, 0, 2, _h, checkered); | 2036 | p->fillRect(_w-2, 0, 2, _h, checkered); |
1747 | } | 2037 | } |
1748 | break; | 2038 | break; |
1749 | case 3: | 2039 | case 3: |
1750 | if (m_rotated) | 2040 | if (m_rotated) |
1751 | { | 2041 | { |
1752 | p->fillRect(0, 0, _w, 2, checkered); | 2042 | p->fillRect(0, 0, _w, 2, checkered); |
1753 | } | 2043 | } |
1754 | else | 2044 | else |
1755 | { | 2045 | { |
1756 | p->fillRect(0, 0, 2, _h, checkered); | 2046 | p->fillRect(0, 0, 2, _h, checkered); |
1757 | } | 2047 | } |
1758 | break; | 2048 | break; |
1759 | case 0: | 2049 | case 0: |
1760 | default: | 2050 | default: |
1761 | break; | 2051 | break; |
1762 | } | 2052 | } |
1763 | switch (m_scrollpos) | 2053 | switch (m_scrollpos) |
1764 | { | 2054 | { |
1765 | case 1: | 2055 | case 1: |
1766 | { | 2056 | { |
1767 | int ht; | 2057 | int ht; |
1768 | if (m_rotated) | 2058 | if (m_rotated) |
1769 | { | 2059 | { |
1770 | ht = _h; | 2060 | ht = _h; |
1771 | } | 2061 | } |
1772 | else | 2062 | else |
1773 | { | 2063 | { |
1774 | ht = _w; | 2064 | ht = _w; |
1775 | } | 2065 | } |
1776 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); | 2066 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); |
1777 | int mid = (ht*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); | 2067 | int mid = (ht*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); |
1778 | int sliderheight = ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize; | 2068 | int sliderheight = ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize; |
1779 | int sliderpos; | 2069 | int sliderpos; |
1780 | if (sliderheight < 10) | 2070 | if (sliderheight < 10) |
1781 | { | 2071 | { |
1782 | sliderheight = 10; | 2072 | sliderheight = 10; |
1783 | sliderpos = mid-5; | 2073 | sliderpos = mid-5; |
1784 | } | 2074 | } |
1785 | else | 2075 | else |
1786 | { | 2076 | { |
1787 | sliderpos = (ht*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize; | 2077 | sliderpos = (ht*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize; |
1788 | } | 2078 | } |
1789 | if (m_rotated) | 2079 | if (m_rotated) |
1790 | { | 2080 | { |
1791 | p->fillRect(0, sliderpos, 3, sliderheight, m_scrollbarcolor); | 2081 | p->fillRect(0, sliderpos, 3, sliderheight, m_scrollbarcolor); |
1792 | } | 2082 | } |
1793 | else | 2083 | else |
1794 | { | 2084 | { |
1795 | p->fillRect(sliderpos, _h-3, sliderheight, 3, m_scrollbarcolor); | 2085 | p->fillRect(sliderpos, _h-3, sliderheight, 3, m_scrollbarcolor); |
1796 | } | 2086 | } |
1797 | } | 2087 | } |
1798 | break; | 2088 | break; |
1799 | case 2: | 2089 | case 2: |
1800 | case 3: | 2090 | case 3: |
1801 | { | 2091 | { |
1802 | int ht; | 2092 | int ht; |
1803 | if (m_rotated) | 2093 | if (m_rotated) |
1804 | { | 2094 | { |
1805 | ht = _w; | 2095 | ht = _w; |
1806 | } | 2096 | } |
1807 | else | 2097 | else |
1808 | { | 2098 | { |
1809 | ht = _h; | 2099 | ht = _h; |
1810 | } | 2100 | } |
1811 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); | 2101 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); |
1812 | int mid = (ht*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); | 2102 | int mid = (ht*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); |
1813 | int sliderheight = ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize; | 2103 | int sliderheight = ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize; |
1814 | int sliderpos; | 2104 | int sliderpos; |
1815 | if (sliderheight < 10) | 2105 | if (sliderheight < 10) |
1816 | { | 2106 | { |
1817 | sliderheight = 10; | 2107 | sliderheight = 10; |
1818 | sliderpos = mid-5; | 2108 | sliderpos = mid-5; |
1819 | } | 2109 | } |
1820 | else | 2110 | else |
1821 | { | 2111 | { |
1822 | sliderpos = (ht*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize; | 2112 | sliderpos = (ht*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize; |
1823 | } | 2113 | } |
1824 | if (m_rotated) | 2114 | if (m_rotated) |
1825 | { | 2115 | { |
1826 | int hoff; | 2116 | int hoff; |
1827 | if (m_scrollpos == 2) //right | 2117 | if (m_scrollpos == 2) //right |
1828 | { | 2118 | { |
1829 | hoff = _h-3; | 2119 | hoff = _h-3; |
1830 | } | 2120 | } |
1831 | else | 2121 | else |
1832 | { | 2122 | { |
1833 | hoff = 0; | 2123 | hoff = 0; |
1834 | } | 2124 | } |
1835 | p->fillRect(ht-sliderpos-sliderheight, hoff, sliderheight, 3, m_scrollbarcolor); | 2125 | p->fillRect(ht-sliderpos-sliderheight, hoff, sliderheight, 3, m_scrollbarcolor); |
1836 | } | 2126 | } |
1837 | else | 2127 | else |
1838 | { | 2128 | { |
1839 | int hoff; | 2129 | int hoff; |
1840 | if (m_scrollpos == 2) //right | 2130 | if (m_scrollpos == 2) //right |
1841 | { | 2131 | { |
1842 | hoff = _w-3; | 2132 | hoff = _w-3; |
1843 | } | 2133 | } |
1844 | else | 2134 | else |
1845 | { | 2135 | { |
1846 | hoff = 0; | 2136 | hoff = 0; |
1847 | } | 2137 | } |
1848 | p->fillRect(hoff, sliderpos, 3, sliderheight, m_scrollbarcolor); | 2138 | p->fillRect(hoff, sliderpos, 3, sliderheight, m_scrollbarcolor); |
1849 | } | 2139 | } |
1850 | } | 2140 | } |
1851 | break; | 2141 | break; |
1852 | case 0: | 2142 | case 0: |
1853 | default: | 2143 | default: |
1854 | break; | 2144 | break; |
1855 | } | 2145 | } |
1856 | } | 2146 | } |
1857 | } | 2147 | } |
1858 | 2148 | ||
1859 | /* | 2149 | /* |
1860 | void QTReader::DrawScroll( QPainter *p ) | 2150 | void QTReader::DrawScroll( QPainter *p ) |
1861 | { | 2151 | { |
1862 | if (m_border > 5 && !buffdoc.empty()) | 2152 | if (m_border > 5 && !buffdoc.empty()) |
1863 | { | 2153 | { |
1864 | int ht, wh; | 2154 | int ht, wh; |
1865 | if (m_rotated) | 2155 | if (m_rotated) |
1866 | { | 2156 | { |
1867 | ht = width(); | 2157 | ht = width(); |
1868 | wh = height()g; | 2158 | wh = height()g; |
1869 | p->fillRect(0, wh-2, ht, 2, cyan); | 2159 | p->fillRect(0, wh-2, ht, 2, cyan); |
1870 | } | 2160 | } |
1871 | else | 2161 | else |
1872 | { | 2162 | { |
1873 | ht = height(); | 2163 | ht = height(); |
1874 | wh = width(); | 2164 | wh = width(); |
1875 | p->fillRect(wh-2, 0, 2, ht, cyan); | 2165 | p->fillRect(wh-2, 0, 2, ht, cyan); |
1876 | } | 2166 | } |
1877 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); | 2167 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); |
1878 | int mid = (ht*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); | 2168 | int mid = (ht*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); |
1879 | if (m_rotated) | 2169 | if (m_rotated) |
1880 | { | 2170 | { |
1881 | p->fillRect(ht-mid-5, wh-2, 10, 2, yellow); | 2171 | p->fillRect(ht-mid-5, wh-2, 10, 2, yellow); |
1882 | p->fillRect(ht-(ht*(locnarray[numlines]-buffdoc.startSection())+sectionsize/2)/sectionsize, wh-2, ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize, 2, magenta); | 2172 | p->fillRect(ht-(ht*(locnarray[numlines]-buffdoc.startSection())+sectionsize/2)/sectionsize, wh-2, ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize, 2, magenta); |
1883 | } | 2173 | } |
1884 | else | 2174 | else |
1885 | { | 2175 | { |
1886 | p->fillRect(wh-2, mid-5, 2, 10, yellow); | 2176 | p->fillRect(wh-2, mid-5, 2, 10, yellow); |
1887 | p->fillRect(wh-2, (ht*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize, 2, ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize, magenta); | 2177 | p->fillRect(wh-2, (ht*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize, 2, ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize, magenta); |
1888 | } | 2178 | } |
1889 | } | 2179 | } |
1890 | } | 2180 | } |
1891 | */ | 2181 | */ |
1892 | QString QTReader::firstword() | 2182 | QString QTReader::firstword() |
1893 | { | 2183 | { |
1894 | if (m_bMonoSpaced) | 2184 | if (m_bMonoSpaced) |
1895 | { | 2185 | { |
1896 | return toQString(textarray[0]->data()); | 2186 | return toQString(textarray[0]->data()); |
1897 | } | 2187 | } |
1898 | else | 2188 | else |
1899 | { | 2189 | { |
1900 | int start, end, len, j; | 2190 | int start, end, len, j; |
1901 | for (j = 0; j < numlines; j++) | 2191 | for (j = 0; j < numlines; j++) |
1902 | { | 2192 | { |
1903 | len = textarray[j]->length(); | 2193 | len = textarray[j]->length(); |
1904 | for (start = 0; start < len && !isalpha((*textarray[j])[start]); start++); | 2194 | for (start = 0; start < len && !isalpha((*textarray[j])[start]); start++); |
1905 | if (start < len) break; | 2195 | if (start < len) break; |
1906 | } | 2196 | } |
1907 | if (j < numlines) | 2197 | if (j < numlines) |
1908 | { | 2198 | { |
1909 | QString ret = ""; | 2199 | QString ret = ""; |
1910 | for (end = start; end < len && isalpha((*textarray[j])[end]); end++) | 2200 | for (end = start; end < len && isalpha((*textarray[j])[end]); end++) |
1911 | ret += (*textarray[j])[end]; | 2201 | ret += (*textarray[j])[end]; |
1912 | if (ret.isEmpty()) ret = "Current position"; | 2202 | if (ret.isEmpty()) ret = "Current position"; |
1913 | return ret; | 2203 | return ret; |
1914 | } | 2204 | } |
1915 | else | 2205 | else |
1916 | return "Current position"; | 2206 | return "Current position"; |
1917 | } | 2207 | } |
1918 | } | 2208 | } |
1919 | 2209 | ||
1920 | // | 2210 | // |
1921 | // Construct the QTReader with buttons. | 2211 | // Construct the QTReader with buttons. |
1922 | // | 2212 | // |
1923 | 2213 | ||
1924 | bool QTReader::ChangeFont(int tgt) | 2214 | bool QTReader::ChangeFont(int tgt) |
1925 | { | 2215 | { |
1926 | return m_fontControl.ChangeFont(m_fontname, tgt); | 2216 | return m_fontControl.ChangeFont(m_fontname, tgt); |
1927 | } | 2217 | } |
1928 | 2218 | ||
1929 | void QTReader::init() | 2219 | void QTReader::init() |
1930 | { | 2220 | { |
1931 | buffdoc.unsuspend(); | ||
1932 | setBackgroundColor( m_bg ); | 2221 | setBackgroundColor( m_bg ); |
1933 | buffdoc.setfilter(getfilter()); | 2222 | buffdoc.setfilter(getfilter()); |
1934 | ChangeFont(m_textsize); | 2223 | ChangeFont(m_textsize); |
1935 | setFocusPolicy(QWidget::StrongFocus); | 2224 | setFocusPolicy(QWidget::StrongFocus); |
1936 | timer = new QTimer(this); | 2225 | timer = new QTimer(this); |
1937 | connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); | 2226 | connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); |
2227 | #ifdef USETIMER | ||
2228 | m_dragtimer = new QTimer(this); | ||
2229 | connect(m_dragtimer, SIGNAL(timeout()), this, SLOT(actionDrag())); | ||
2230 | #endif | ||
1938 | // QMessageBox::information(this, "init", m_lastfile, 1); | 2231 | // QMessageBox::information(this, "init", m_lastfile, 1); |
1939 | setfont(); | 2232 | setfont(); |
1940 | } | 2233 | } |
1941 | 2234 | ||
1942 | // | 2235 | // |
1943 | // Clean up | 2236 | // Clean up |
1944 | // | 2237 | // |
1945 | QTReader::~QTReader() | 2238 | QTReader::~QTReader() |
1946 | { | 2239 | { |
1947 | #ifdef DOUBLEBUFFER | 2240 | if (m_output != NULL) |
1948 | delete dbuff; | 2241 | { |
1949 | delete dbp; | 2242 | delete m_output; |
1950 | #endif | 2243 | } |
2244 | if (dbuff != NULL) | ||
2245 | { | ||
2246 | delete dbuff; | ||
2247 | delete dbp; | ||
2248 | } | ||
1951 | #ifdef USEQPE | 2249 | #ifdef USEQPE |
1952 | if (m_autoScroll) | 2250 | if (m_autoScroll) |
1953 | { | 2251 | { |
1954 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 2252 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
1955 | } | 2253 | } |
1956 | #endif | 2254 | #endif |
1957 | #ifdef _SCROLLPIPE | 2255 | #ifdef _SCROLLPIPE |
1958 | if (m_pipeout != NULL) | 2256 | if (m_pipeout != NULL) |
1959 | { | 2257 | { |
1960 | fclose(m_pipeout); | 2258 | fclose(m_pipeout); |
1961 | } | 2259 | } |
1962 | #endif | 2260 | #endif |
1963 | } | 2261 | } |
1964 | 2262 | ||
1965 | // | 2263 | // |
1966 | // Called when the print button is clicked. | 2264 | // Called when the print button is clicked. |
1967 | // | 2265 | // |
1968 | /* | 2266 | /* |
1969 | void QTReader::printIt() | 2267 | void QTReader::printIt() |
1970 | { | 2268 | { |
1971 | #ifndef QT_NO_PRINTER | 2269 | #ifndef QT_NO_PRINTER |
1972 | if ( printer->setup( this ) ) { | 2270 | if ( printer->setup( this ) ) { |
1973 | QPainter paint; | 2271 | QPainter paint; |
1974 | if ( !paint.begin( printer ) ) | 2272 | if ( !paint.begin( printer ) ) |
1975 | return; | 2273 | return; |
1976 | drawIt( &paint ); | 2274 | drawIt( &paint ); |
1977 | } | 2275 | } |
1978 | #endif | 2276 | #endif |
1979 | } | 2277 | } |
1980 | */ | 2278 | */ |
1981 | // | 2279 | // |
1982 | // Called when the widget needs to be updated. | 2280 | // Called when the widget needs to be updated. |
1983 | // | 2281 | // |
1984 | 2282 | ||
1985 | void QTReader::paintEvent( QPaintEvent * ) | 2283 | void QTReader::paintEvent( QPaintEvent * p ) |
1986 | { | 2284 | { |
1987 | drawFonts(); | 2285 | if ((dbuff != NULL) && !m_outofdate) |
2286 | { | ||
2287 | if (m_rotated) | ||
2288 | { | ||
2289 | if ((p->rect().width() != width()) || (p->rect().height() != height())) | ||
2290 | { | ||
2291 | qDebug("Partial paint"); | ||
2292 | QRect r; | ||
2293 | r.setTop(width()-p->rect().right()-1); | ||
2294 | r.setLeft(p->rect().top()); | ||
2295 | r.setHeight(p->rect().width()); | ||
2296 | r.setWidth(p->rect().height()); | ||
2297 | QPixmap p1(r.width(), r.height()); | ||
2298 | bitBlt(&p1, QPoint(0, 0), dbuff, r); | ||
2299 | QWMatrix m; | ||
2300 | m.rotate(90); | ||
2301 | QPixmap p2 = p1.xForm(m); | ||
2302 | bitBlt(this, p->rect().left(), p->rect().top(), &p2, 0, 0, -1, -1); | ||
2303 | } | ||
2304 | else | ||
2305 | { | ||
2306 | qDebug("Full paint"); | ||
2307 | QWMatrix m; | ||
2308 | m.rotate(90); | ||
2309 | QPixmap rp = dbuff->xForm(m); | ||
2310 | bitBlt(this, 0,0,&rp,0,0,-1,-1); | ||
2311 | } | ||
2312 | } | ||
2313 | else | ||
2314 | { | ||
2315 | //bitBlt(this, 0,0,dbuff,0,0,-1,-1); | ||
2316 | bitBlt(this,p->rect().topLeft(),dbuff,p->rect()); | ||
2317 | } | ||
2318 | } | ||
2319 | else | ||
2320 | { | ||
2321 | drawFonts(); | ||
2322 | } | ||
2323 | m_outofdate = false; | ||
1988 | } | 2324 | } |
1989 | 2325 | ||
1990 | // | 2326 | // |
1991 | // Called when the widget has been resized. | 2327 | // Called when the widget has been resized. |
1992 | // Moves the button group to the upper right corner | 2328 | // Moves the button group to the upper right corner |
1993 | // of the widget. | 2329 | // of the widget. |
1994 | 2330 | ||
1995 | /* | 2331 | /* |
1996 | void QTReader::resizeEvent( QResizeEvent * ) | 2332 | void QTReader::resizeEvent( QResizeEvent * ) |
1997 | { | 2333 | { |
1998 | // // qDebug("resize:(%u,%u)", width(), height()); | 2334 | // // qDebug("resize:(%u,%u)", width(), height()); |
1999 | // bgroup->move( width()-bgroup->width(), 0 ); | 2335 | // bgroup->move( width()-bgroup->width(), 0 ); |
2000 | } | 2336 | } |
2001 | */ | 2337 | */ |
2002 | 2338 | ||
2003 | // | 2339 | // |
2004 | // Create and display our widget. | 2340 | // Create and display our widget. |
2005 | // | 2341 | // |
2006 | /* | 2342 | /* |
2007 | int main( int argc, tchar **argv ) | 2343 | int main( int argc, tchar **argv ) |
2008 | { | 2344 | { |
2009 | QApplication app( argc, argv ); | 2345 | QApplication app( argc, argv ); |
2010 | QTReader draw; | 2346 | QTReader draw; |
2011 | app.setMainWidget( &draw ); | 2347 | app.setMainWidget( &draw ); |
2012 | draw.setCaption("Qt Example - Drawdemo"); | 2348 | draw.setCaption("Qt Example - Drawdemo"); |
2013 | draw.show(); | 2349 | draw.show(); |
2014 | return app.exec(); | 2350 | return app.exec(); |
2015 | } | 2351 | } |
2016 | */ | 2352 | */ |
2017 | 2353 | ||
2018 | 2354 | ||
2355 | bool QTReader::locate(unsigned long n) | ||
2356 | { | ||
2357 | m_outofdate = true; | ||
2358 | m_lastwidth = 0; | ||
2359 | locnarray[0] = n; | ||
2360 | ResetScroll(); | ||
2361 | update(); | ||
2362 | return true; | ||
2363 | } | ||
2364 | /* | ||
2019 | bool QTReader::locate(unsigned long n) { | 2365 | bool QTReader::locate(unsigned long n) { |
2020 | //printf("Locate\n"); | 2366 | //printf("Locate\n"); |
2021 | buffdoc.unsuspend(); | ||
2022 | buffdoc.locate(n); | 2367 | buffdoc.locate(n); |
2023 | // // qDebug("&buffdoc.located"); | 2368 | // // qDebug("&buffdoc.located"); |
2024 | ResetScroll(); | 2369 | ResetScroll(); |
2025 | fillbuffer(); | 2370 | fillbuffer(); |
2371 | m_outofdate = true; | ||
2026 | // // qDebug("&Buffer filled"); | 2372 | // // qDebug("&Buffer filled"); |
2027 | update(); | 2373 | update(); |
2028 | // // qDebug("&Located"); | 2374 | // // qDebug("&Located"); |
2029 | emitRedraw(); | 2375 | emitRedraw(); |
2030 | return true; | 2376 | return true; |
2031 | } | 2377 | } |
2032 | 2378 | */ | |
2033 | unsigned int QTReader::screenlines() | 2379 | unsigned int QTReader::screenlines() |
2034 | { | 2380 | { |
2035 | // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; | 2381 | // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; |
2036 | // return (height()-m_descent)/(m_linespacing); | 2382 | // return (height()-m_descent)/(m_linespacing); |
2037 | return (height()-2)/(m_linespacing); | 2383 | return (height()-2)/(m_linespacing); |
2038 | }; | 2384 | }; |
2039 | 2385 | ||
2040 | bool QTReader::fillbuffer(int reuse, int ht, int newht) | 2386 | bool QTReader::fillbuffer(int reuse, int ht, int newht) |
2041 | { | 2387 | { |
2042 | buffdoc.unsuspend(); | ||
2043 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 2388 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
2044 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; | 2389 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; |
2045 | if (ht < 0) ht = m_topmargin; | 2390 | if (ht < 0) ht = m_topmargin; |
2046 | if (buffdoc.empty()) return false; | 2391 | if (buffdoc.empty()) return false; |
2047 | if (newht < 0) | 2392 | if (newht < 0) |
2048 | m_lastheight = (m_rotated) ? width() : height(); | 2393 | m_lastheight = (m_rotated) ? width() : height(); |
2049 | else | 2394 | else |
2050 | m_lastheight = newht; | 2395 | m_lastheight = newht; |
2051 | int ch; | 2396 | int ch; |
2052 | bool ret = false; | 2397 | bool ret = false; |
2053 | unsigned int oldpagepos = locnarray[reuse]; | 2398 | unsigned int oldpagepos = locnarray[reuse]; |
2054 | int lastypos = ht, ypos = ht; | 2399 | int lastypos = ht, ypos = ht; |
2055 | numlines = reuse; | 2400 | numlines = reuse; |
2056 | while (ypos < m_lastheight - hmargin || numlines < 2) | 2401 | while (ypos < m_lastheight - hmargin || numlines < 2) |
2057 | { | 2402 | { |
2058 | lastypos = ypos; | 2403 | lastypos = ypos; |
2059 | if (textarray[numlines] == NULL) | 2404 | if (textarray[numlines] == NULL) |
2060 | { | 2405 | { |
2061 | textarray[numlines] = new CDrawBuffer(&m_fontControl); | 2406 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
2062 | } | 2407 | } |
2063 | locnarray[numlines] = locate(); | 2408 | locnarray[numlines] = locate(); |
2064 | int ch = getline(textarray[numlines]); | 2409 | int ch = getline(textarray[numlines]); |
2065 | ypos += textarray[numlines]->lineSpacing(); | 2410 | ypos += textarray[numlines]->lineSpacing(); |
2411 | /* | ||
2412 | QString tmp = toQString(textarray[numlines]->data()); | ||
2413 | printf("[%u, %u, %u](%s):%s\n", lastypos, m_lastheight-hmargin, ypos, | ||
2414 | ((textarray[numlines]->showPartial()) ? "TRUE" : "FALSE"), | ||
2415 | (const char*)tmp); | ||
2416 | */ | ||
2066 | numlines++; | 2417 | numlines++; |
2067 | if (!ch) | 2418 | if (!ch) |
2068 | { | 2419 | { |
2069 | if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/) | 2420 | if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/) |
2070 | { | 2421 | { |
2071 | qDebug("FALSE"); | 2422 | qDebug("FALSE"); |
2423 | if (oldpagepos < buffdoc.endSection()) | ||
2072 | locate(oldpagepos); | 2424 | locate(oldpagepos); |
2073 | return false; | 2425 | else |
2426 | dopageup(buffdoc.endSection()); | ||
2427 | return false; | ||
2074 | } | 2428 | } |
2075 | else | 2429 | else |
2076 | { | 2430 | { |
2077 | qDebug("TRUE"); | 2431 | qDebug("TRUE"); |
2078 | --numlines; | 2432 | --numlines; |
2079 | mylastpos = locate(); | 2433 | mylastpos = locate(); |
2080 | return true; | 2434 | return true; |
2081 | } | 2435 | } |
2082 | } | 2436 | } |
2083 | if (numlines > 1 && textarray[numlines-2]->isBop()) | 2437 | if (numlines > 1 && textarray[numlines-2]->isBop()) |
2084 | { | 2438 | { |
2085 | --numlines; | 2439 | --numlines; |
2086 | mylastpos = locate(); | 2440 | mylastpos = locate(); |
2087 | return true; | 2441 | return true; |
2088 | } | 2442 | } |
2089 | } | 2443 | } |
2090 | 2444 | ||
2091 | --numlines; | 2445 | --numlines; |
2092 | mylastpos = locate(); | 2446 | mylastpos = locate(); |
2093 | m_scrollpart = m_lastheight - lastypos - hmargin; | 2447 | m_scrollpart = m_lastheight - lastypos - hmargin; |
2094 | if (m_autoScroll) | 2448 | if (m_autoScroll) |
2095 | { | 2449 | { |
2096 | CalculateScrollParameters(); | 2450 | CalculateScrollParameters(); |
2097 | } | 2451 | } |
2098 | return true; | 2452 | return true; |
2099 | } | 2453 | } |
2100 | 2454 | ||
2101 | void QTReader::dopagedn() | 2455 | void QTReader::dopagedn() |
2102 | { | 2456 | { |
2103 | // qDebug("HEIGHT(2):%d", m_lastheight); | 2457 | // qDebug("HEIGHT(2):%d", m_lastheight); |
2104 | buffdoc.unsuspend(); | ||
2105 | ResetScroll(); | 2458 | ResetScroll(); |
2106 | int skip = 0, ypos = m_topmargin; | 2459 | int skip = 0, ypos = m_topmargin; |
2107 | if (locate() != mylastpos) | 2460 | if (locate() != mylastpos) |
2108 | { | 2461 | { |
2109 | jumpto(mylastpos); | 2462 | jumpto(mylastpos); |
2110 | } | 2463 | } |
2111 | CDrawBuffer* reusebuffer = textarray[numlines]; | 2464 | CDrawBuffer* reusebuffer = textarray[numlines]; |
2112 | if (reusebuffer != NULL) | 2465 | if (reusebuffer != NULL) |
2113 | { | 2466 | { |
2114 | if (reusebuffer->eof()) return; | 2467 | if (reusebuffer->eof()) return; |
2115 | for (int i = 0; i <= m_overlap; i++) | 2468 | for (int i = 0; i <= m_overlap; i++) |
2116 | { | 2469 | { |
2117 | int offset = numlines - m_overlap + i; | 2470 | int offset = numlines - m_overlap + i; |
2118 | reusebuffer = textarray[offset]; | 2471 | reusebuffer = textarray[offset]; |
2119 | size_t reuselocn = locnarray[offset]; | 2472 | size_t reuselocn = locnarray[offset]; |
2120 | textarray[offset] = textarray[i]; | 2473 | textarray[offset] = textarray[i]; |
2121 | textarray[i] = reusebuffer; | 2474 | textarray[i] = reusebuffer; |
2122 | // reusebuffer->empty(); | 2475 | // reusebuffer->empty(); |
2123 | locnarray[offset] = locnarray[i]; | 2476 | locnarray[offset] = locnarray[i]; |
2124 | locnarray[i] = reuselocn; | 2477 | locnarray[i] = reuselocn; |
2125 | ypos += textarray[i]->lineSpacing(); | 2478 | ypos += textarray[i]->lineSpacing(); |
2126 | skip++; | 2479 | skip++; |
2127 | } | 2480 | } |
2128 | } | 2481 | } |
2129 | if (numlines <= 1) | 2482 | if (numlines <= 1) |
2130 | { | 2483 | { |
2131 | skip = 0; | 2484 | skip = 0; |
2132 | ypos = 0; | 2485 | ypos = 0; |
2133 | qDebug("Doing extra skip"); | 2486 | qDebug("Doing extra skip"); |
2134 | } | 2487 | } |
2135 | if (fillbuffer(skip, ypos)) | 2488 | if (fillbuffer(skip, ypos)) |
2136 | { | 2489 | { |
2137 | drawFonts(); | 2490 | drawFonts(); |
2138 | } | 2491 | } |
2139 | } | 2492 | } |
2140 | 2493 | ||
2141 | void QTReader::dopageup() | 2494 | void QTReader::dopageup() |
2142 | { | 2495 | { |
2143 | dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]); | 2496 | dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]); |
2144 | } | 2497 | } |
2145 | 2498 | ||
2146 | bool QTReader::synch(size_t start, size_t end) | 2499 | bool QTReader::synch(size_t start, size_t end) |
2147 | { | 2500 | { |
2148 | jumpto(start); | 2501 | jumpto(start); |
2149 | while (start++ < end) | 2502 | while (start++ < end) |
2150 | { | 2503 | { |
2151 | tchar ch = getch(); | 2504 | tchar ch = getch(); |
2152 | if (ch == 10) return true; | 2505 | if (ch == 10) return true; |
2153 | if (ch == UEOF) return false; | 2506 | if ((ch == UEOF) || (ch == 6)) |
2154 | if (ch == 6) return false; | 2507 | { |
2508 | return false; | ||
2509 | } | ||
2155 | } | 2510 | } |
2156 | return false; | 2511 | return false; |
2157 | } | 2512 | } |
2158 | 2513 | ||
2159 | void QTReader::dopageup(unsigned int target) | 2514 | void QTReader::dopageup(unsigned int target) |
2160 | { | 2515 | { |
2161 | buffdoc.unsuspend(); | ||
2162 | ResetScroll(); | 2516 | ResetScroll(); |
2163 | CBufferFace<CDrawBuffer*> buff; | 2517 | CBufferFace<CDrawBuffer*> buff; |
2164 | CBufferFace<size_t> loc; | 2518 | CBufferFace<size_t> loc; |
2165 | |||
2166 | size_t delta, guess = 2*(locate()-pagelocate()), lastdelta = 0; | 2519 | size_t delta, guess = 2*(locate()-pagelocate()), lastdelta = 0; |
2520 | qDebug("dopageup:: locate():%u pagelocate():%u guess:%u", locate(), pagelocate(), guess); | ||
2167 | bool ch = true; | 2521 | bool ch = true; |
2168 | int nbfl, ypos = m_topmargin; | 2522 | int nbfl, ypos = m_topmargin; |
2169 | if (guess < 128) guess = 128; | 2523 | if (guess < 128) guess = 128; |
2170 | while (1) | 2524 | while (1) |
2171 | { | 2525 | { |
2172 | // qDebug("Guess:%u", guess); | 2526 | // qDebug("Guess:%u", guess); |
2173 | 2527 | ||
2174 | ch = true; | 2528 | ch = true; |
2175 | if (target < guess) | 2529 | if (target < guess) |
2176 | { | 2530 | { |
2177 | delta = 0; // 0 is a flag to say don't guess any more | 2531 | delta = 0; // 0 is a flag to say don't guess any more |
2178 | jumpto( (m_continuousDocument) ? 0 : buffdoc.startSection() ); | 2532 | jumpto( (m_continuousDocument) ? 0 : buffdoc.startSection() ); |
2179 | } | 2533 | } |
2180 | else if (!m_continuousDocument && (target - guess < buffdoc.startSection())) | 2534 | else if (!m_continuousDocument && (target - guess < buffdoc.startSection())) |
2181 | { | 2535 | { |
2182 | delta = 0; // 0 is a flag to say don't guess any more | 2536 | delta = 0; // 0 is a flag to say don't guess any more |
2537 | qDebug("Jumping to startsection:%d", buffdoc.startSection()); | ||
2183 | jumpto(buffdoc.startSection()); | 2538 | jumpto(buffdoc.startSection()); |
2184 | } | 2539 | } |
2185 | else | 2540 | else |
2186 | { | 2541 | { |
2187 | delta = guess; | 2542 | delta = guess; |
2188 | if (!synch(target-delta, target-lastdelta)) | 2543 | if (!synch(target-delta, target-lastdelta)) |
2189 | { | 2544 | { |
2190 | lastdelta = delta; | 2545 | lastdelta = delta; |
2191 | if (guess < 4000) | 2546 | if (guess < 4000) |
2192 | { | 2547 | { |
2193 | guess <<= 1; | 2548 | guess <<= 1; |
2194 | continue; | 2549 | continue; |
2195 | } | 2550 | } |
2196 | else | 2551 | else |
2197 | { | 2552 | { |
2198 | jumpto(target-delta); | 2553 | jumpto(target-delta); |
2199 | } | 2554 | } |
2200 | } | 2555 | } |
2201 | } | 2556 | } |
2202 | 2557 | ||
2203 | nbfl = 0; | 2558 | nbfl = 0; |
2204 | ypos = m_topmargin; | 2559 | ypos = m_topmargin; |
2205 | 2560 | ||
2206 | while (locate() < target) | 2561 | while (locate() < target) |
2207 | { | 2562 | { |
2208 | if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); | 2563 | if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); |
2209 | loc[nbfl] = locate(); | 2564 | loc[nbfl] = locate(); |
2210 | ch = getline(buff[nbfl]); | 2565 | ch = getline(buff[nbfl]); |
2211 | ypos += buff[nbfl]->lineSpacing(); | 2566 | ypos += buff[nbfl]->lineSpacing(); |
2212 | nbfl++; | 2567 | nbfl++; |
2213 | if (!ch) break; | 2568 | if (!ch) break; |
2214 | } | 2569 | } |
2215 | if (guess < 4000 && ypos < ((m_rotated) ? width() : height())-(m_bottommargin) && (delta != 0)) | 2570 | if (guess < 4000 && ypos < ((m_rotated) ? width() : height())-(m_bottommargin) && (delta != 0)) |
2216 | { | 2571 | { |
2217 | for (int i = 0; i < nbfl; i++) | 2572 | for (int i = 0; i < nbfl; i++) |
2218 | { | 2573 | { |
2219 | delete buff[i]; | 2574 | delete buff[i]; |
2220 | buff[i] = NULL; | 2575 | buff[i] = NULL; |
2221 | } | 2576 | } |
2222 | guess <<= 1; | 2577 | guess <<= 1; |
2223 | continue; | 2578 | continue; |
2224 | } | 2579 | } |
2225 | break; | 2580 | break; |
2226 | } | 2581 | } |
2227 | if (ch) | 2582 | if (ch) |
2228 | { | 2583 | { |
2229 | if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); | 2584 | if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); |
2230 | loc[nbfl] = locate(); | 2585 | loc[nbfl] = locate(); |
2231 | int ch = getline(buff[nbfl]); | 2586 | int ch = getline(buff[nbfl]); |
2232 | nbfl++; | 2587 | nbfl++; |
2233 | } | 2588 | } |
2234 | /* | 2589 | /* |
2235 | ypos = 0; | 2590 | ypos = 0; |
2236 | numlines = 0; | 2591 | numlines = 0; |
2237 | while (ypos < height() && numlines <= nbfl-1) | 2592 | while (ypos < height() && numlines <= nbfl-1) |
2238 | { | 2593 | { |
2239 | ypos += buff[nbfl - numlines - 1]->lineSpacing(); | 2594 | ypos += buff[nbfl - numlines - 1]->lineSpacing(); |
2240 | numlines++; | 2595 | numlines++; |
2241 | } | 2596 | } |
2242 | --numlines; | 2597 | --numlines; |
2243 | */ | 2598 | */ |
2244 | 2599 | ||
2245 | ypos = m_topmargin; | 2600 | ypos = m_topmargin; |
2246 | numlines = 0; | 2601 | numlines = 0; |
2247 | while (ypos < ((m_rotated) ? width() : height())-m_bottommargin && numlines+2 <= nbfl) | 2602 | while (ypos < ((m_rotated) ? width() : height())-m_bottommargin && numlines+2 <= nbfl) |
2248 | { | 2603 | { |
2249 | ypos += buff[nbfl - numlines - 2]->lineSpacing(); | 2604 | ypos += buff[nbfl - numlines - 2]->lineSpacing(); |
2250 | numlines++; | 2605 | numlines++; |
2251 | } | 2606 | } |
2252 | if (numlines > 0) --numlines; | 2607 | if (numlines > 0) --numlines; |
2253 | if (numlines == 0 && nbfl > 1) numlines = 1; | 2608 | if (numlines == 0 && nbfl > 1) numlines = 1; |
2254 | 2609 | ||
2255 | int offset = nbfl-1; | 2610 | int offset = nbfl-1; |
2256 | offset -= numlines; | 2611 | offset -= numlines; |
2257 | ypos = m_topmargin; | 2612 | ypos = m_topmargin; |
2258 | for (int i = 0; i <= numlines; i++) | 2613 | for (int i = 0; i <= numlines; i++) |
2259 | { | 2614 | { |
2260 | delete textarray[i]; | 2615 | delete textarray[i]; |
2261 | textarray[i] = buff[offset+i]; | 2616 | textarray[i] = buff[offset+i]; |
2262 | locnarray[i] = loc[offset + i]; | 2617 | locnarray[i] = loc[offset + i]; |
2263 | ypos += textarray[i]->lineSpacing(); | 2618 | ypos += textarray[i]->lineSpacing(); |
2264 | } | 2619 | } |
2265 | #ifdef _WINDOWS | 2620 | #ifdef _WINDOWS |
2266 | for (i = 0; i < nbfl - numlines - 1; i++) | 2621 | for (i = 0; i < nbfl - numlines - 1; i++) |
2267 | #else | 2622 | #else |
2268 | for (int i = 0; i < nbfl - numlines - 1; i++) | 2623 | for (int i = 0; i < nbfl - numlines - 1; i++) |
2269 | #endif | 2624 | #endif |
2270 | { | 2625 | { |
2271 | delete buff[i]; | 2626 | delete buff[i]; |
2272 | } | 2627 | } |
2273 | 2628 | ||
2274 | while (ypos < ((m_rotated) ? width() : height())-m_bottommargin) | 2629 | while (ypos < ((m_rotated) ? width() : height())-m_bottommargin) |
2275 | { | 2630 | { |
2276 | numlines++; | 2631 | numlines++; |
2277 | locnarray[numlines] = locate(); | 2632 | locnarray[numlines] = locate(); |
2278 | if (textarray[numlines] == NULL) textarray[numlines] = new CDrawBuffer(&m_fontControl); | 2633 | if (textarray[numlines] == NULL) textarray[numlines] = new CDrawBuffer(&m_fontControl); |
2279 | if (!getline(textarray[numlines])) break; | 2634 | if (!getline(textarray[numlines])) break; |
2280 | ypos += textarray[numlines]->lineSpacing(); | 2635 | ypos += textarray[numlines]->lineSpacing(); |
2281 | } | 2636 | } |
2282 | 2637 | ||
2283 | mylastpos = locate(); | 2638 | mylastpos = locate(); |
2284 | CalculateScrollParameters(); | 2639 | CalculateScrollParameters(); |
2285 | drawFonts(); | 2640 | drawFonts(); |
2286 | // repaint(); | 2641 | // repaint(); |
2287 | } | 2642 | } |
2288 | 2643 | ||
2289 | bool QTReader::load_file(const char *newfile, unsigned int _lcn) | 2644 | bool QTReader::load_file(const char *newfile, unsigned int _lcn) |
2290 | { | 2645 | { |
2291 | // QMessageBox::information(this, "Name", name, 1); | 2646 | // QMessageBox::information(this, "Name", name, 1); |
2292 | // QMessageBox::information(this, "load_file", newfile, 1); | 2647 | // QMessageBox::information(this, "load_file", newfile, 1); |
2293 | int prog = 0; | 2648 | int prog = 0; |
2294 | bool bRC = false; | 2649 | bool bRC = false; |
2295 | unsigned int lcn = _lcn; | 2650 | unsigned int lcn = _lcn; |
2651 | bDoUpdates = false; | ||
2296 | ResetScroll(); | 2652 | ResetScroll(); |
2297 | if (m_lastfile == newfile) | 2653 | if (m_lastfile == newfile && lcn == 0) |
2298 | { | 2654 | { |
2299 | lcn = m_lastposn; | 2655 | lcn = m_lastposn; |
2300 | } | 2656 | } |
2301 | // QMessageBox::information(0, "Opening...", newfile); | 2657 | // QMessageBox::information(0, "Opening...", newfile); |
2302 | if (m_rotated) | 2658 | if (m_rotated) |
2303 | { | 2659 | { |
2304 | m_lastwidth = height(); | 2660 | m_lastwidth = height(); |
2305 | m_lastheight = width(); | 2661 | m_lastheight = width(); |
2306 | } | 2662 | } |
2307 | else | 2663 | else |
2308 | { | 2664 | { |
2309 | m_lastwidth = width(); | 2665 | m_lastwidth = width(); |
2310 | m_lastheight = height(); | 2666 | m_lastheight = height(); |
2311 | } | 2667 | } |
2312 | if (buffdoc.openfile(this,newfile) == 0) | 2668 | if (buffdoc.openfile(this,newfile) == 0) |
2313 | { | 2669 | { |
2314 | m_lastfile = newfile; | 2670 | m_lastfile = newfile; |
2315 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); | 2671 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); |
2316 | bRC = true; | 2672 | bRC = true; |
2317 | buffdoc.setContinuous(m_continuousDocument); | 2673 | buffdoc.setContinuous(m_continuousDocument); |
2318 | qDebug("buffdoc.openfile done"); | 2674 | qDebug("buffdoc.openfile done"); |
2319 | locate(lcn); | ||
2320 | qDebug("buffdoc.locate done"); | ||
2321 | } | 2675 | } |
2322 | setfilter(getfilter()); | 2676 | setfilter(getfilter()); |
2323 | qDebug("Updated"); | 2677 | qDebug("Updated"); |
2678 | bDoUpdates = true; | ||
2679 | locate(lcn); | ||
2324 | return bRC; | 2680 | return bRC; |
2325 | } | 2681 | } |
2326 | 2682 | ||
2327 | void QTReader::lineDown() | 2683 | void QTReader::lineDown() |
2328 | { | 2684 | { |
2329 | int ypos = m_topmargin; | 2685 | int ypos = m_topmargin; |
2330 | ResetScroll(); | 2686 | ResetScroll(); |
2331 | int offset = numlines; | 2687 | int offset = numlines; |
2332 | 2688 | ||
2333 | for (int i = 0; i <= numlines; i++) | 2689 | for (int i = 0; i <= numlines; i++) |
2334 | { | 2690 | { |
2335 | if ((ypos += textarray[numlines-i]->lineSpacing()) > ((m_rotated) ? width() : height())) | 2691 | if ((ypos += textarray[numlines-i]->lineSpacing()) > ((m_rotated) ? width() : height())) |
2336 | { | 2692 | { |
2337 | offset = i-1; | 2693 | offset = i-1; |
2338 | break; | 2694 | break; |
2339 | } | 2695 | } |
2340 | } | 2696 | } |
2341 | offset = numlines - offset; | 2697 | offset = numlines - offset; |
2342 | #ifdef _WINDOWS | 2698 | #ifdef _WINDOWS |
2343 | for (i = offset; i <= numlines; i++) | 2699 | for (i = offset; i <= numlines; i++) |
2344 | #else | 2700 | #else |
2345 | for (int i = offset; i <= numlines; i++) | 2701 | for (int i = offset; i <= numlines; i++) |
2346 | #endif | 2702 | #endif |
2347 | { | 2703 | { |
2348 | CDrawBuffer* buff = textarray[i-offset]; | 2704 | CDrawBuffer* buff = textarray[i-offset]; |
2349 | textarray[i-offset] = textarray[i]; | 2705 | textarray[i-offset] = textarray[i]; |
2350 | locnarray[i-offset] = locnarray[i]; | 2706 | locnarray[i-offset] = locnarray[i]; |
2351 | textarray[i] = buff; | 2707 | textarray[i] = buff; |
2352 | } | 2708 | } |
2353 | numlines = numlines - offset + 1; | 2709 | numlines = numlines - offset + 1; |
2354 | locnarray[numlines] = locate(); | 2710 | locnarray[numlines] = locate(); |
2355 | if (textarray[numlines] == NULL) | 2711 | if (textarray[numlines] == NULL) |
2356 | { | 2712 | { |
2357 | textarray[numlines] = new CDrawBuffer(&m_fontControl); | 2713 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
2358 | } | 2714 | } |
2359 | getline(textarray[numlines]); | 2715 | getline(textarray[numlines]); |
2360 | mylastpos = locate(); | 2716 | mylastpos = locate(); |
2717 | m_outofdate = true; | ||
2361 | update(); | 2718 | update(); |
2362 | } | 2719 | } |
2363 | /* | 2720 | /* |
2364 | void QTReader::lineUp() | 2721 | void QTReader::lineUp() |
2365 | { | 2722 | { |
2366 | CBuffer** buff = textarray; | 2723 | CBuffer** buff = textarray; |
2367 | unsigned int *loc = new unsigned int[numlines]; | 2724 | unsigned int *loc = new unsigned int[numlines]; |
2368 | int cbptr = 0; | 2725 | int cbptr = 0; |
2369 | if (locate() != mylastpos) jumpto(mylastpos); | 2726 | if (locate() != mylastpos) jumpto(mylastpos); |
2370 | unsigned int target = locnarray[numlines-1]; | 2727 | unsigned int target = locnarray[numlines-1]; |
2371 | if (buffdoc.hasrandomaccess()) | 2728 | if (buffdoc.hasrandomaccess()) |
2372 | { | 2729 | { |
2373 | unsigned int delta = locate()-pagelocate(); | 2730 | unsigned int delta = locate()-pagelocate(); |
2374 | if (delta < 64) delta = 64; | 2731 | if (delta < 64) delta = 64; |
2375 | do | 2732 | do |
2376 | { | 2733 | { |
2377 | delta <<= 1; | 2734 | delta <<= 1; |
2378 | if (delta >= target) | 2735 | if (delta >= target) |
2379 | { | 2736 | { |
2380 | delta = target; | 2737 | delta = target; |
2381 | jumpto(0); | 2738 | jumpto(0); |
2382 | for (int i = 0; i < numlines; i++) | 2739 | for (int i = 0; i < numlines; i++) |
2383 | { | 2740 | { |
2384 | loc[i] = locate(); | 2741 | loc[i] = locate(); |
2385 | getline(buff[i]); | 2742 | getline(buff[i]); |
2386 | } | 2743 | } |
2387 | break; | 2744 | break; |
2388 | } | 2745 | } |
2389 | jumpto(target-delta); | 2746 | jumpto(target-delta); |
2390 | do | 2747 | do |
2391 | { | 2748 | { |
2392 | buffdoc.getline(buff[0],width()); | 2749 | buffdoc.getline(buff[0],width()); |
2393 | #ifdef WS | 2750 | #ifdef WS |
2394 | //printf("Trying:%s\n",buff[0]); | 2751 | //printf("Trying:%s\n",buff[0]); |
2395 | #endif | 2752 | #endif |
2396 | if (locate() > target) continue; | 2753 | if (locate() > target) continue; |
2397 | } | 2754 | } |
2398 | while (!buffdoc.iseol()); | 2755 | while (!buffdoc.iseol()); |
2399 | for (int i = 0; i < numlines; i++) | 2756 | for (int i = 0; i < numlines; i++) |
2400 | { | 2757 | { |
2401 | loc[i] = locate(); | 2758 | loc[i] = locate(); |
2402 | buffdoc.getline(buff[i],width()); | 2759 | buffdoc.getline(buff[i],width()); |
2403 | #ifdef WS | 2760 | #ifdef WS |
2404 | //printf("Filling:%s\n",buff[i]); | 2761 | //printf("Filling:%s\n",buff[i]); |
2405 | #endif | 2762 | #endif |
2406 | } | 2763 | } |
2407 | } | 2764 | } |
2408 | while (locate() >= target && delta < 4096); | 2765 | while (locate() >= target && delta < 4096); |
2409 | #ifdef WS | 2766 | #ifdef WS |
2410 | //printf("Delta:%u\n",delta); | 2767 | //printf("Delta:%u\n",delta); |
2411 | #endif | 2768 | #endif |
2412 | } | 2769 | } |
2413 | else | 2770 | else |
2414 | { | 2771 | { |
2415 | jumpto(0); | 2772 | jumpto(0); |
2416 | for (int i = 0; i < numlines; i++) | 2773 | for (int i = 0; i < numlines; i++) |
2417 | { | 2774 | { |
2418 | loc[i] = locate(); | 2775 | loc[i] = locate(); |
2419 | buffdoc.getline(buff[i],width()); | 2776 | buffdoc.getline(buff[i],width()); |
2420 | } | 2777 | } |
2421 | } | 2778 | } |
2422 | cbptr = 0; | 2779 | cbptr = 0; |
2423 | while (locate() < target) | 2780 | while (locate() < target) |
2424 | { | 2781 | { |
2425 | loc[cbptr] = locate(); | 2782 | loc[cbptr] = locate(); |
2426 | buffdoc.getline(buff[cbptr], width()); | 2783 | buffdoc.getline(buff[cbptr], width()); |
2427 | #ifdef WS | 2784 | #ifdef WS |
2428 | //printf("Adding:%s\n",buff[cbptr]->data()); | 2785 | //printf("Adding:%s\n",buff[cbptr]->data()); |
2429 | #endif | 2786 | #endif |
2430 | cbptr = (cbptr+1) % numlines; | 2787 | cbptr = (cbptr+1) % numlines; |
2431 | } | 2788 | } |
2432 | pagepos = loc[cbptr]; | 2789 | pagepos = loc[cbptr]; |
2433 | textarray = new CBuffer*[numlines]; | 2790 | textarray = new CBuffer*[numlines]; |
2434 | for (int i = 0; i < numlines; i++) | 2791 | for (int i = 0; i < numlines; i++) |
2435 | { | 2792 | { |
2436 | int j = (cbptr+i)%numlines; | 2793 | int j = (cbptr+i)%numlines; |
2437 | textarray[i] = buff[j]; | 2794 | textarray[i] = buff[j]; |
2438 | locnarray[i] = loc[j]; | 2795 | locnarray[i] = loc[j]; |
2439 | } | 2796 | } |
2440 | delete [] buff; | 2797 | delete [] buff; |
2441 | delete [] loc; | 2798 | delete [] loc; |
2442 | mylastpos = locate(); | 2799 | mylastpos = locate(); |
2443 | update(); | 2800 | update(); |
2444 | } | 2801 | } |
2445 | */ | 2802 | */ |
2446 | 2803 | ||
2447 | void QTReader::ResetScroll() | 2804 | void QTReader::ResetScroll() |
2448 | { | 2805 | { |
2449 | m_totalscroll = 0; | 2806 | m_totalscroll = 0; |
2450 | m_scrolldy1 = 0; | 2807 | m_scrolldy1 = 0; |
2451 | m_scrolldy = m_topmargin; | 2808 | m_scrolldy = m_topmargin; |
2452 | if (m_autoScroll && ((m_scrolltype == 0) || !m_bgpm.isNull())) | 2809 | if (m_autoScroll && ((m_scrolltype == 0) || !m_bgpm.isNull())) |
2453 | { | 2810 | { |
2454 | setautoscroll(false); | 2811 | setautoscroll(false); |
2455 | } | 2812 | } |
2456 | } | 2813 | } |
2457 | 2814 | ||
2458 | void QTReader::lineUp() | 2815 | void QTReader::lineUp() |
2459 | { | 2816 | { |
2460 | dopageup(locnarray[numlines-1]); | 2817 | dopageup(locnarray[numlines-1]); |
2461 | 2818 | ||
2462 | /* | 2819 | /* |
2463 | buffdoc.unsuspend(); | 2820 | buffdoc.unsuspend(); |
2464 | ResetScroll(); | 2821 | ResetScroll(); |
2465 | 2822 | ||
2466 | CDrawBuffer* buff = textarray[numlines]; | 2823 | CDrawBuffer* buff = textarray[numlines]; |
2467 | unsigned int loc; | 2824 | unsigned int loc; |
2468 | unsigned int end = locnarray[numlines]; | 2825 | unsigned int end = locnarray[numlines]; |
2469 | int cbptr = 0; | 2826 | int cbptr = 0; |
2470 | if (locate() != mylastpos) jumpto(mylastpos); | 2827 | if (locate() != mylastpos) jumpto(mylastpos); |
2471 | unsigned int target = locnarray[0]; | 2828 | unsigned int target = locnarray[0]; |
2472 | if (target == 0) return; | 2829 | if (target == 0) return; |
2473 | if (!m_continuousDocument && (target == buffdoc.startSection())) return; | 2830 | if (!m_continuousDocument && (target == buffdoc.startSection())) return; |
2474 | if (buffdoc.hasrandomaccess()) | 2831 | if (buffdoc.hasrandomaccess()) |
2475 | { | 2832 | { |
2476 | unsigned int delta = locate()-pagelocate(); | 2833 | unsigned int delta = locate()-pagelocate(); |
2477 | if (delta < 64) delta = 64; | 2834 | if (delta < 64) delta = 64; |
2478 | do | 2835 | do |
2479 | { | 2836 | { |
2480 | delta <<= 1; | 2837 | delta <<= 1; |
2481 | if (delta >= target) | 2838 | if (delta >= target) |
2482 | { | 2839 | { |
2483 | delta = target; | 2840 | delta = target; |
2484 | jumpto(0); | 2841 | jumpto(0); |
2485 | loc = locate(); | 2842 | loc = locate(); |
2486 | getline(buff); | 2843 | getline(buff); |
2487 | break; | 2844 | break; |
2488 | } | 2845 | } |
2489 | else if (!m_continuousDocument && (target - delta < buffdoc.startSection())) | 2846 | else if (!m_continuousDocument && (target - delta < buffdoc.startSection())) |
2490 | { | 2847 | { |
2491 | delta = target-buffdoc.startSection(); | 2848 | delta = target-buffdoc.startSection(); |
2492 | jumpto(buffdoc.startSection()); | 2849 | jumpto(buffdoc.startSection()); |
2493 | loc = locate(); | 2850 | loc = locate(); |
2494 | getline(buff); | 2851 | getline(buff); |
2495 | break; | 2852 | break; |
2496 | } | 2853 | } |
2497 | jumpto(target-delta); | 2854 | jumpto(target-delta); |
2498 | do | 2855 | do |
2499 | { | 2856 | { |
2500 | getline(buff); | 2857 | getline(buff); |
2501 | #ifdef WS | 2858 | #ifdef WS |
2502 | //printf("Trying:%s\n",buff[0]); | 2859 | //printf("Trying:%s\n",buff[0]); |
2503 | #endif | 2860 | #endif |
2504 | if (locate() > target) continue; | 2861 | if (locate() > target) continue; |
2505 | } | 2862 | } |
2506 | while (!buffdoc.iseol()); | 2863 | while (!buffdoc.iseol()); |
2507 | loc = locate(); | 2864 | loc = locate(); |
2508 | getline(buff); | 2865 | getline(buff); |
2509 | } | 2866 | } |
2510 | while (locate() >= target && delta < 4096); | 2867 | while (locate() >= target && delta < 4096); |
2511 | } | 2868 | } |
2512 | else | 2869 | else |
2513 | { | 2870 | { |
2514 | jumpto(0); | 2871 | jumpto(0); |
2515 | loc = locate(); | 2872 | loc = locate(); |
2516 | getline(buff); | 2873 | getline(buff); |
2517 | } | 2874 | } |
2518 | cbptr = 0; | 2875 | cbptr = 0; |
2519 | while (locate() < target) | 2876 | while (locate() < target) |
2520 | { | 2877 | { |
2521 | loc = locate(); | 2878 | loc = locate(); |
2522 | getline(buff); | 2879 | getline(buff); |
2523 | } | 2880 | } |
2524 | for (int i = numlines; i > 0; i--) | 2881 | for (int i = numlines; i > 0; i--) |
2525 | { | 2882 | { |
2526 | textarray[i] = textarray[i-1]; | 2883 | textarray[i] = textarray[i-1]; |
2527 | locnarray[i] = locnarray[i-1]; | 2884 | locnarray[i] = locnarray[i-1]; |
2528 | } | 2885 | } |
2529 | textarray[0] = buff; | 2886 | textarray[0] = buff; |
2530 | locnarray[0] = loc; | 2887 | locnarray[0] = loc; |
2531 | int start = numlines; | 2888 | int start = numlines; |
2532 | int ypos = m_topmargin; | 2889 | int ypos = m_topmargin; |
2533 | #ifdef _WINDOWS | 2890 | #ifdef _WINDOWS |
2534 | for (i = 0; i <= numlines; i++) | 2891 | for (i = 0; i <= numlines; i++) |
2535 | #else | 2892 | #else |
2536 | for (int i = 0; i <= numlines; i++) | 2893 | for (int i = 0; i <= numlines; i++) |
2537 | #endif | 2894 | #endif |
2538 | { | 2895 | { |
2539 | ypos += textarray[i]->lineSpacing(); | 2896 | ypos += textarray[i]->lineSpacing(); |
2540 | if (ypos > ((m_rotated) ? width() : height())) | 2897 | if (ypos > ((m_rotated) ? width() : height())) |
2541 | { | 2898 | { |
2542 | start = i; | 2899 | start = i; |
2543 | ypos -= textarray[i]->lineSpacing(); | 2900 | ypos -= textarray[i]->lineSpacing(); |
2544 | break; | 2901 | break; |
2545 | } | 2902 | } |
2546 | } | 2903 | } |
2547 | jumpto(locnarray[start]); | 2904 | jumpto(locnarray[start]); |
2548 | fillbuffer(start, ypos); | 2905 | fillbuffer(start, ypos); |
2549 | repaint(); | 2906 | repaint(); |
2550 | */ | 2907 | */ |
2551 | } | 2908 | } |
2552 | 2909 | ||
2553 | bool QTReader::empty() | 2910 | bool QTReader::empty() |
2554 | { | 2911 | { |
2555 | return buffdoc.empty(); | 2912 | return buffdoc.empty(); |
2556 | } | 2913 | } |
2557 | 2914 | ||
2558 | MarkupType QTReader::PreferredMarkup() | 2915 | MarkupType QTReader::PreferredMarkup() |
2559 | { | 2916 | { |
2560 | MarkupType m = buffdoc.PreferredMarkup(); | 2917 | MarkupType m = buffdoc.PreferredMarkup(); |
2561 | if (m == cTEXT) | 2918 | if (m == cTEXT) |
2562 | { | 2919 | { |
2563 | int ext = m_lastfile.findRev('.'); | 2920 | int ext = m_lastfile.findRev('.'); |
2564 | if (ext >= 0) | 2921 | if (ext >= 0) |
2565 | { | 2922 | { |
2566 | QString ft = m_lastfile.right(m_lastfile.length()-ext-1).upper(); | 2923 | QString ft = m_lastfile.right(m_lastfile.length()-ext-1).upper(); |
2567 | if (ft.left(3) == "HTM") | 2924 | if (ft.left(3) == "HTM") |
2568 | { | 2925 | { |
2569 | m = cHTML; | 2926 | m = cHTML; |
2570 | } | 2927 | } |
2571 | } | 2928 | } |
2572 | } | 2929 | } |
2573 | return m; | 2930 | return m; |
2574 | } | 2931 | } |
2575 | #ifdef DOUBLEBUFFER | 2932 | |
2576 | void QTReader::resizeEvent( QResizeEvent * p ) | 2933 | void QTReader::resizeEvent( QResizeEvent * p ) |
2577 | { | 2934 | { |
2578 | if (m_rotated) | 2935 | qDebug("Resizing"); |
2579 | { | 2936 | m_outofdate = true; |
2580 | dbuff->resize(p->size().height(),p->size().width()); | 2937 | if (dbuff != NULL) |
2581 | } | ||
2582 | else | ||
2583 | { | 2938 | { |
2584 | dbuff->resize(p->size()); | 2939 | if (m_rotated) |
2940 | { | ||
2941 | dbuff->resize(p->size().height(),p->size().width()); | ||
2942 | } | ||
2943 | else | ||
2944 | { | ||
2945 | dbuff->resize(p->size()); | ||
2946 | } | ||
2585 | } | 2947 | } |
2586 | m_bgIsScaled = false; | 2948 | m_bgIsScaled = false; |
2587 | if (m_bgtype == bgStretched) | 2949 | if (m_bgtype == bgStretched) |
2588 | { | 2950 | { |
2589 | emit RefreshBitmap(); | 2951 | emit RefreshBitmap(); |
2590 | } | 2952 | } |
2591 | 2953 | ||
2592 | { | 2954 | { |
2593 | int h, w; | 2955 | int h, w; |
2594 | if (m_rotated) | 2956 | if (m_rotated) |
2595 | { | 2957 | { |
2596 | h = p->size().width(); | 2958 | h = p->size().width(); |
2597 | w = p->size().height(); | 2959 | w = p->size().height(); |
2598 | } | 2960 | } |
2599 | else | 2961 | else |
2600 | { | 2962 | { |
2601 | w = p->size().width(); | 2963 | w = p->size().width(); |
2602 | h = p->size().height(); | 2964 | h = p->size().height(); |
2603 | } | 2965 | } |
2604 | m_topmargin = (h*m_abstopmargin+500)/1000; | 2966 | m_topmargin = (h*m_abstopmargin+500)/1000; |
2605 | m_bottommargin = (h*m_absbottommargin+500)/1000; | 2967 | m_bottommargin = (h*m_absbottommargin+500)/1000; |
2606 | m_left_border = (w*m_absleft_border+500)/1000; | 2968 | m_left_border = (w*m_absleft_border+500)/1000; |
2607 | m_right_border = (w*m_absright_border+500)/1000; | 2969 | m_right_border = (w*m_absright_border+500)/1000; |
2608 | |||
2609 | qDebug("Top margin:%u", m_topmargin ); | ||
2610 | qDebug("Bottom margin:%u", m_bottommargin ); | ||
2611 | qDebug("Left margin:%u", m_left_border ); | ||
2612 | qDebug("Right margin:%u", m_right_border ); | ||
2613 | } | 2970 | } |
2971 | if (dbuff != NULL && buffdoc.empty()) | ||
2972 | { | ||
2973 | dbp->begin(dbuff); | ||
2974 | drawBackground(dbp); | ||
2975 | dbp->end(); | ||
2976 | } | ||
2614 | } | 2977 | } |
2615 | #endif | ||
2616 | 2978 | ||
2617 | void QTReader::setrotated(bool sfs) | 2979 | void QTReader::setrotated(bool sfs) |
2618 | { | 2980 | { |
2981 | qDebug("Rotating"); | ||
2619 | m_rotated = sfs; | 2982 | m_rotated = sfs; |
2620 | #ifdef DOUBLEBUFFER | 2983 | setDoubleBuffer(m_doubleBuffered); |
2621 | if (m_rotated) | ||
2622 | { | ||
2623 | dbuff->resize(height(), width()); | ||
2624 | } | ||
2625 | else | ||
2626 | { | ||
2627 | dbuff->resize(width(), height()); | ||
2628 | } | ||
2629 | m_bgIsScaled = false; | 2984 | m_bgIsScaled = false; |
2630 | #endif | 2985 | m_outofdate = true; |
2986 | /* | ||
2631 | int h, w; | 2987 | int h, w; |
2632 | if (m_rotated) | 2988 | if (m_rotated) |
2633 | { | 2989 | { |
2634 | h = width(); | 2990 | h = width(); |
2635 | w = height(); | 2991 | w = height(); |
2636 | } | 2992 | } |
2637 | else | 2993 | else |
2638 | { | 2994 | { |
2639 | w = width(); | 2995 | w = width(); |
2640 | h = height(); | 2996 | h = height(); |
2641 | } | 2997 | } |
2642 | m_topmargin = (h*m_abstopmargin+500)/1000; | 2998 | m_topmargin = (h*m_abstopmargin+500)/1000; |
2643 | m_bottommargin = (h*m_absbottommargin+500)/1000; | 2999 | m_bottommargin = (h*m_absbottommargin+500)/1000; |
2644 | m_left_border = (w*m_absleft_border+500)/1000; | 3000 | m_left_border = (w*m_absleft_border+500)/1000; |
2645 | m_right_border = (w*m_absright_border+500)/1000; | 3001 | m_right_border = (w*m_absright_border+500)/1000; |
2646 | 3002 | ||
2647 | qDebug("Top margin:%u", m_topmargin ); | 3003 | qDebug("Top margin:%u", m_topmargin ); |
2648 | qDebug("Bottom margin:%u", m_bottommargin ); | 3004 | qDebug("Bottom margin:%u", m_bottommargin ); |
2649 | qDebug("Left margin:%u", m_left_border ); | 3005 | qDebug("Left margin:%u", m_left_border ); |
2650 | qDebug("Right margin:%u", m_right_border ); | 3006 | qDebug("Right margin:%u", m_right_border ); |
3007 | */ | ||
2651 | } | 3008 | } |
2652 | 3009 | ||
2653 | void QTReader::drawBackground() | 3010 | void QTReader::drawBackground(QPainter *p) |
2654 | { | 3011 | { |
2655 | dbp->begin(dbuff); | 3012 | // p->setBackgroundMode(OpaqueMode); |
2656 | // dbp->setBackgroundMode(OpaqueMode); | 3013 | p->setBackgroundColor(m_bg); |
2657 | dbp->setBackgroundColor(m_bg); | 3014 | if (dbuff != NULL) |
2658 | dbp->eraseRect(dbuff->rect()); | 3015 | { |
3016 | p->eraseRect(dbuff->rect()); | ||
3017 | } | ||
3018 | else | ||
3019 | { | ||
3020 | if (m_rotated) | ||
3021 | { | ||
3022 | p->eraseRect(0,0,height(),width()); | ||
3023 | } | ||
3024 | else | ||
3025 | { | ||
3026 | p->eraseRect(rect()); | ||
3027 | } | ||
3028 | } | ||
2659 | if (!m_bgpm.isNull()) | 3029 | if (!m_bgpm.isNull()) |
2660 | { | 3030 | { |
2661 | // dbp->setBackgroundMode(TransparentMode); | 3031 | // p->setBackgroundMode(TransparentMode); |
2662 | switch (m_bgtype) | 3032 | switch (m_bgtype) |
2663 | { | 3033 | { |
2664 | case bgCentred: | 3034 | case bgCentred: |
2665 | { | 3035 | { |
2666 | int w = (dbuff->rect().width()-m_bgpm.width())/2; | 3036 | if (dbuff == NULL) |
2667 | int h = (dbuff->rect().height()-m_bgpm.height())/2; | 3037 | { |
2668 | dbp->drawPixmap(w,h,m_bgpm); | 3038 | p->drawPixmap(width(),height(),m_bgpm); |
3039 | } | ||
3040 | else | ||
3041 | { | ||
3042 | int w = (dbuff->rect().width()-m_bgpm.width())/2; | ||
3043 | int h = (dbuff->rect().height()-m_bgpm.height())/2; | ||
3044 | p->drawPixmap(w,h,m_bgpm); | ||
3045 | } | ||
2669 | } | 3046 | } |
2670 | break; | 3047 | break; |
2671 | case bgTiled: | 3048 | case bgTiled: |
2672 | { | 3049 | { |
2673 | dbp->drawTiledPixmap(0,0,dbuff->rect().width(),dbuff->rect().height(),m_bgpm); | 3050 | if (dbuff == NULL) |
2674 | /* | ||
2675 | for (int h = 0; h < dbuff->rect().height(); h += m_bgpm.height()) | ||
2676 | { | 3051 | { |
2677 | for (int w = 0; w < dbuff->rect().width(); w += m_bgpm.width()) | 3052 | p->drawTiledPixmap(0,0,width(),height(),m_bgpm); |
2678 | { | 3053 | } |
2679 | dbp->drawPixmap(w,h,m_bgpm); | 3054 | else |
2680 | } | 3055 | { |
3056 | p->drawTiledPixmap(0,0,dbuff->rect().width(),dbuff->rect().height(),m_bgpm); | ||
2681 | } | 3057 | } |
2682 | */ | ||
2683 | } | 3058 | } |
2684 | break; | 3059 | break; |
2685 | case bgStretched: | 3060 | case bgStretched: |
2686 | { | 3061 | { |
2687 | if (!m_bgIsScaled) | 3062 | if (!m_bgIsScaled) |
2688 | { | 3063 | { |
2689 | m_bgIsScaled = true; | 3064 | m_bgIsScaled = true; |
2690 | QImage im = m_bgpm.convertToImage(); | 3065 | QImage im = m_bgpm.convertToImage(); |
2691 | m_bgpm.convertFromImage(im.smoothScale(dbuff->rect().width(), dbuff->rect().height())); | 3066 | if (dbuff == NULL) |
3067 | { | ||
3068 | m_bgpm.convertFromImage(im.smoothScale(width(),height())); | ||
3069 | } | ||
3070 | else | ||
3071 | { | ||
3072 | m_bgpm.convertFromImage(im.smoothScale(dbuff->rect().width(), dbuff->rect().height())); | ||
3073 | } | ||
2692 | } | 3074 | } |
2693 | dbp->drawPixmap(0,0,m_bgpm); | 3075 | p->drawPixmap(0,0,m_bgpm); |
2694 | } | 3076 | } |
2695 | break; | 3077 | break; |
2696 | default: | 3078 | default: |
2697 | qDebug("Unknown background type"); | 3079 | qDebug("Unknown background type"); |
2698 | } | 3080 | } |
2699 | // dbp->setBackgroundMode(OpaqueMode); | 3081 | // p->setBackgroundMode(OpaqueMode); |
2700 | } | 3082 | } |
2701 | } | 3083 | } |
2702 | 3084 | ||
2703 | void QTReader::blitRot(int dx, int dy, int sw, int sh, CDrawBuffer* txt) | 3085 | void QTReader::blitRot(int dx, int dy, int sw, int sh, CDrawBuffer* txt) |
2704 | { | 3086 | { |
2705 | if (txt != NULL) | 3087 | if (txt != NULL) |
2706 | { | 3088 | { |
2707 | sh = txt->lineSpacing(); | 3089 | sh = txt->lineSpacing(); |
2708 | } | 3090 | } |
2709 | int sy = width()-dx-sh; | 3091 | int sy = width()-dx-sh; |
2710 | if (m_autoScroll && !(m_scrolltype == 0)) | 3092 | if (m_autoScroll && !(m_scrolltype == 0)) |
2711 | { | 3093 | { |
2712 | sy = (sy+m_totalscroll+1)%width(); | 3094 | sy = (sy+m_totalscroll+1)%width(); |
2713 | } | 3095 | } |
2714 | 3096 | ||
2715 | QPixmap pm(sw, sh); | 3097 | QPixmap pm(sw, sh); |
2716 | 3098 | ||
2717 | QPainter pd(&pm, this); | 3099 | QPainter pd(&pm, this); |
2718 | if (m_bgpm.isNull()) | 3100 | if (m_bgpm.isNull()) |
2719 | { | 3101 | { |
2720 | pd.eraseRect(pm.rect()); | 3102 | pd.eraseRect(pm.rect()); |
2721 | } | 3103 | } |
2722 | else | 3104 | else |
2723 | { | 3105 | { |
2724 | if (sy+pm.height() > dbuff->height()) | 3106 | if (sy+pm.height() > dbuff->height()) |
2725 | { | 3107 | { |
2726 | // pd.eraseRect(pm.rect()); | 3108 | // pd.eraseRect(pm.rect()); |
2727 | int fh = dbuff->height() - sy; | 3109 | int fh = dbuff->height() - sy; |
2728 | if (sy+fh > dbuff->height()) | 3110 | if (sy+fh > dbuff->height()) |
2729 | { | 3111 | { |
2730 | qDebug("Oh no!"); | 3112 | qDebug("Oh no!"); |
2731 | } | 3113 | } |
2732 | 3114 | ||
2733 | if (fh > pm.height()) | 3115 | if (fh > pm.height()) |
2734 | { | 3116 | { |
2735 | qDebug("Oh no! - 2"); | 3117 | qDebug("Oh no! - 2"); |
2736 | } | 3118 | } |
2737 | 3119 | ||
2738 | bitBlt(&pm,0,0,dbuff,dy,sy,pm.width(),fh); | 3120 | bitBlt(&pm,0,0,dbuff,dy,sy,pm.width(),fh); |
2739 | bitBlt(&pm,0,fh,dbuff,dy,0,pm.width(),pm.height()-fh); | 3121 | bitBlt(&pm,0,fh,dbuff,dy,0,pm.width(),pm.height()-fh); |
2740 | } | 3122 | } |
2741 | else | 3123 | else |
2742 | { | 3124 | { |
2743 | bitBlt(&pm,0,0,dbuff,dy,sy,pm.width(),pm.height()); | 3125 | bitBlt(&pm,0,0,dbuff,dy,sy,pm.width(),pm.height()); |
2744 | } | 3126 | } |
2745 | } | 3127 | } |
2746 | if (txt != NULL) | 3128 | if (txt != NULL) |
2747 | { | 3129 | { |
2748 | // txt->render(&pd, txt->lineSpacing() - txt->descent() - txt->lineExtraSpacing(), m_bMonoSpaced, m_charWidth, sw, m_left_border, m_right_border, m_bg); | 3130 | // txt->render(&pd, txt->lineSpacing() - txt->descent() - txt->lineExtraSpacing(), m_bMonoSpaced, m_charWidth, sw, m_left_border, m_right_border, m_bg); |
2749 | txt->render(&pd, txt->lineSpacing() - txt->descent() - txt->lineExtraSpacing(), m_bMonoSpaced, m_charWidth, sw, m_left_border, m_right_border, m_bg, width()-m_topmargin-m_bottommargin); | 3131 | txt->render(&pd, txt->lineSpacing() - txt->descent() - txt->lineExtraSpacing(), m_bMonoSpaced, m_charWidth, sw, m_left_border, m_right_border, m_bg, width()-m_topmargin-m_bottommargin); |
2750 | } | 3132 | } |
2751 | QWMatrix m; | 3133 | QWMatrix m; |
2752 | m.rotate(90); | 3134 | m.rotate(90); |
2753 | QPixmap rp = pm.xForm(m); | 3135 | QPixmap rp = pm.xForm(m); |
2754 | /* | 3136 | /* |
2755 | p.drawPixmap(QPoint(dx, dy), rp); | 3137 | p.drawPixmap(QPoint(dx, dy), rp); |
2756 | */ | 3138 | */ |
2757 | bitBlt(this, dx, dy, &rp, 0, 0, -1, -1, CopyROP); | 3139 | bitBlt(this, dx, dy, &rp, 0, 0, -1, -1, CopyROP); |
2758 | } | 3140 | } |
2759 | 3141 | ||
2760 | QString QTReader::about() | 3142 | QString QTReader::about() |
2761 | { | 3143 | { |
2762 | return QString("QTReader widget (c) Tim Wentford\n")+buffdoc.about() + "\nMini-scrollbar by Markus Gritsch\nNavigation History fixes by Frantisek Dufka"; | 3144 | QString ab = QString("QTReader widget (c) Tim Wentford\n")+buffdoc.about() + "\nMini-scrollbar by Markus Gritsch\nNavigation History fixes by Frantisek Dufka"; |
3145 | if (m_output != NULL) | ||
3146 | { | ||
3147 | ab += QString("\n") + m_output->about(); | ||
3148 | } | ||
3149 | return ab; | ||
2763 | } | 3150 | } |
2764 | 3151 | ||
2765 | void QTReader::getNextLink() | 3152 | void QTReader::getNextLink() |
2766 | { | 3153 | { |
2767 | if (m_scrolldy != 0) | 3154 | if (m_scrolldy != 0) |
2768 | { | 3155 | { |
2769 | setautoscroll(false); | 3156 | setautoscroll(false); |
2770 | ResetScroll(); | 3157 | ResetScroll(); |
2771 | redrawall(); | 3158 | redrawall(); |
2772 | } | 3159 | } |
2773 | bool redraw = false; | 3160 | bool redraw = false; |
2774 | bool found = false; | 3161 | bool found = false; |
2775 | if (m_currentlink >= 0) | 3162 | if (m_currentlink >= 0) |
2776 | { | 3163 | { |
2777 | m_currentlinkoffset = textarray[m_currentlink]->invertLink(m_currentlinkoffset); | 3164 | m_currentlinkoffset = textarray[m_currentlink]->invertLink(m_currentlinkoffset); |
2778 | if ((m_currentlinkstyle = textarray[m_currentlink]->getNextLink(m_currentlinkoffset)) != NULL) | 3165 | if ((m_currentlinkstyle = textarray[m_currentlink]->getNextLink(m_currentlinkoffset)) != NULL) |
2779 | { | 3166 | { |
2780 | qDebug("Found a link at %u", m_currentlinkoffset); | 3167 | qDebug("Found a link at %u", m_currentlinkoffset); |
2781 | int offset = textarray[m_currentlink]->invertLink(m_currentlinkoffset); | 3168 | int offset = textarray[m_currentlink]->invertLink(m_currentlinkoffset); |
2782 | qDebug("Finishes at %u", offset); | 3169 | qDebug("Finishes at %u", offset); |
2783 | found = true; | 3170 | found = true; |
2784 | } | 3171 | } |
2785 | redraw = true; | 3172 | redraw = true; |
2786 | drawSingleLine(m_currentlink); | 3173 | drawSingleLine(m_currentlink); |
2787 | // if (found) return; | 3174 | // if (found) return; |
2788 | } | 3175 | } |
2789 | if (!found) | 3176 | if (!found) |
2790 | { | 3177 | { |
2791 | m_currentlinkoffset = -1; | 3178 | m_currentlinkoffset = -1; |
2792 | for (int i = m_currentlink+1; i < numlines; ++i) | 3179 | for (int i = m_currentlink+1; i < numlines; ++i) |
2793 | { | 3180 | { |
2794 | if ((m_currentlinkstyle = textarray[i]->getNextLink(m_currentlinkoffset)) != NULL) | 3181 | if ((m_currentlinkstyle = textarray[i]->getNextLink(m_currentlinkoffset)) != NULL) |
2795 | { | 3182 | { |
2796 | m_currentlink = i; | 3183 | m_currentlink = i; |
2797 | qDebug("Found a link at %u", m_currentlinkoffset); | 3184 | qDebug("Found a link at %u", m_currentlinkoffset); |
2798 | int offset = textarray[m_currentlink]->invertLink(m_currentlinkoffset); | 3185 | int offset = textarray[m_currentlink]->invertLink(m_currentlinkoffset); |
2799 | qDebug("Finishes at %u", offset); | 3186 | qDebug("Finishes at %u", offset); |
2800 | //drawSingleLine(i); | 3187 | //drawSingleLine(i); |
2801 | redraw = true; | 3188 | redraw = true; |
2802 | found = true; | 3189 | found = true; |
2803 | drawSingleLine(m_currentlink); | 3190 | drawSingleLine(m_currentlink); |
2804 | break; | 3191 | break; |
2805 | } | 3192 | } |
2806 | } | 3193 | } |
2807 | } | 3194 | } |
2808 | if (redraw) | 3195 | if (redraw) |
2809 | { | 3196 | { |
2810 | // redrawall(); | 3197 | // redrawall(); |
2811 | } | 3198 | } |
2812 | if (!found) | 3199 | if (!found) |
2813 | { | 3200 | { |
2814 | m_currentlink = -1; | 3201 | m_currentlink = -1; |
2815 | m_currentlinkstyle = NULL; | 3202 | m_currentlinkstyle = NULL; |
2816 | m_currentlinkoffset = -1; | 3203 | m_currentlinkoffset = -1; |
2817 | dopagedn(); | 3204 | dopagedn(); |
2818 | } | 3205 | } |
2819 | } | 3206 | } |
2820 | 3207 | ||
2821 | void QTReader::emitRedraw() | 3208 | void QTReader::emitRedraw() |
2822 | { | 3209 | { |
2823 | m_currentlinkstyle = NULL; | 3210 | m_currentlinkstyle = NULL; |
2824 | m_currentlink = -1; | 3211 | m_currentlink = -1; |
2825 | m_currentlinkoffset = -1; | 3212 | m_currentlinkoffset = -1; |
2826 | emit OnRedraw(); | 3213 | emit OnRedraw(); |
2827 | }; | 3214 | }; |
2828 | 3215 | ||
2829 | void QTReader::drawSingleLine(int lineno) | 3216 | void QTReader::drawSingleLine(int lineno) |
2830 | { | 3217 | { |
2831 | QPainter p( this ); | 3218 | QPainter p( this ); |
2832 | int ypos = textarray[0]->ascent()+m_topmargin; | 3219 | int ypos = textarray[0]->ascent()+m_topmargin; |
2833 | if (lineno == 0) | 3220 | if (lineno == 0) |
2834 | { | 3221 | { |
2835 | if (m_rotated) | 3222 | if (m_rotated) |
2836 | { | 3223 | { |
2837 | blitRot(width()-(ypos+textarray[lineno]->descent()+textarray[lineno]->lineExtraSpacing()), 0, height(), -1, textarray[lineno]); | 3224 | blitRot(width()-(ypos+textarray[lineno]->descent()+textarray[lineno]->lineExtraSpacing()), 0, height(), -1, textarray[lineno]); |
2838 | } | 3225 | } |
2839 | else | 3226 | else |
2840 | { | 3227 | { |
2841 | if (m_bgpm.isNull()) | 3228 | if (m_bgpm.isNull()) |
2842 | { | 3229 | { |
2843 | p.fillRect(m_left_border,ypos-textarray[lineno]->ascent(),width()-(m_left_border+m_right_border),textarray[lineno]->lineSpacing(),m_bg); | 3230 | p.fillRect(m_left_border,ypos-textarray[lineno]->ascent(),width()-(m_left_border+m_right_border),textarray[lineno]->lineSpacing(),m_bg); |
2844 | } | 3231 | } |
2845 | else | 3232 | else |
2846 | { | 3233 | { |
2847 | bitBlt(this, m_left_border, ypos-textarray[lineno]->ascent(), dbuff, m_left_border, ypos-textarray[lineno]->ascent(), width()-(m_left_border+m_right_border), textarray[lineno]->lineSpacing()); | 3234 | bitBlt(this, m_left_border, ypos-textarray[lineno]->ascent(), dbuff, m_left_border, ypos-textarray[lineno]->ascent(), width()-(m_left_border+m_right_border), textarray[lineno]->lineSpacing()); |
2848 | } | 3235 | } |
2849 | textarray[lineno]->render( &p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | 3236 | textarray[lineno]->render( &p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); |
2850 | } | 3237 | } |
2851 | } | 3238 | } |
2852 | for (int i = 1; i < numlines; i++) | 3239 | for (int i = 1; i < numlines; i++) |
2853 | { | 3240 | { |
2854 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ | 3241 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ |
2855 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; | 3242 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; |
2856 | if (i == lineno) | 3243 | if (i == lineno) |
2857 | { | 3244 | { |
2858 | if (m_rotated) | 3245 | if (m_rotated) |
2859 | { | 3246 | { |
2860 | blitRot(width()-(ypos+textarray[i]->descent()+textarray[i]->lineExtraSpacing()), 0, height(), -1, textarray[i]); | 3247 | blitRot(width()-(ypos+textarray[i]->descent()+textarray[i]->lineExtraSpacing()), 0, height(), -1, textarray[i]); |
2861 | } | 3248 | } |
2862 | else | 3249 | else |
2863 | { | 3250 | { |
2864 | if (m_bgpm.isNull()) | 3251 | if (m_bgpm.isNull()) |
2865 | { | 3252 | { |
2866 | p.fillRect(m_left_border,ypos-textarray[lineno]->ascent(),width()-(m_left_border+m_right_border),textarray[lineno]->lineSpacing(),m_bg); | 3253 | p.fillRect(m_left_border,ypos-textarray[lineno]->ascent(),width()-(m_left_border+m_right_border),textarray[lineno]->lineSpacing(),m_bg); |
2867 | } | 3254 | } |
2868 | else | 3255 | else |
2869 | { | 3256 | { |
2870 | bitBlt(this, m_left_border, ypos-textarray[lineno]->ascent(), dbuff, m_left_border, ypos-textarray[lineno]->ascent(), width()-(m_left_border+m_right_border), textarray[lineno]->lineSpacing()); | 3257 | bitBlt(this, m_left_border, ypos-textarray[lineno]->ascent(), dbuff, m_left_border, ypos-textarray[lineno]->ascent(), width()-(m_left_border+m_right_border), textarray[lineno]->lineSpacing()); |
2871 | } | 3258 | } |
2872 | textarray[i]->render( &p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | 3259 | textarray[i]->render( &p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); |
2873 | } | 3260 | } |
2874 | } | 3261 | } |
2875 | } | 3262 | } |
2876 | } | 3263 | } |
2877 | 3264 | ||
2878 | 3265 | ||
2879 | void QTReader::gotoLink() | 3266 | void QTReader::gotoLink() |
2880 | { | 3267 | { |
2881 | if (m_currentlinkstyle == NULL) return; | 3268 | if (m_currentlinkstyle == NULL) return; |
2882 | textarray[m_currentlink]->invertLink(m_currentlinkoffset); | 3269 | textarray[m_currentlink]->invertLink(m_currentlinkoffset); |
2883 | size_t saveposn = pagelocate(); | 3270 | size_t saveposn = pagelocate(); |
2884 | QString href, nm; | 3271 | QString href, nm; |
2885 | unsigned long tgt = m_currentlinkstyle->getData(); | 3272 | unsigned long tgt = m_currentlinkstyle->getData(); |
2886 | unsigned long tgtoffset = m_currentlinkstyle->getOffset(); | 3273 | unsigned long tgtoffset = m_currentlinkstyle->getOffset(); |
2887 | linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm); | 3274 | linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm); |
2888 | qDebug("URL(1):%s", (const char*)href); | 3275 | qDebug("URL(1):%s", (const char*)href); |
2889 | if ((lt & eFile) != 0) | 3276 | if ((lt & eFile) != 0) |
2890 | { | 3277 | { |
2891 | buffdoc.saveposn(m_lastfile, saveposn); | 3278 | buffdoc.saveposn(m_lastfile, saveposn); |
2892 | #ifdef USEQPE | 3279 | #ifdef USEQPE |
2893 | { | 3280 | { |
2894 | QCopEnvelope e("QPE/System", "busy()"); | 3281 | QCopEnvelope e("QPE/System", "busy()"); |
2895 | } | 3282 | } |
2896 | #endif | 3283 | #endif |
2897 | ResetScroll(); | 3284 | ResetScroll(); |
2898 | if (!href.isEmpty()) | 3285 | if (!href.isEmpty()) |
2899 | { | 3286 | { |
2900 | if (!buffdoc.getFile(href)) | 3287 | if (!buffdoc.getFile(href, nm)) |
2901 | { | 3288 | { |
2902 | emit NewFileRequest(href); | 3289 | emit NewFileRequest(href); |
2903 | } | 3290 | } |
2904 | else | 3291 | else |
2905 | { | 3292 | { |
2906 | ResetScroll(); | 3293 | ResetScroll(); |
2907 | fillbuffer(); | 3294 | fillbuffer(); |
3295 | m_outofdate = true; | ||
2908 | update(); | 3296 | update(); |
2909 | } | 3297 | } |
2910 | } | 3298 | } |
2911 | if (!nm.isEmpty()) | 3299 | if (!nm.isEmpty()) |
2912 | { | 3300 | { |
2913 | qDebug("QTReader:Finding %s", (const char*)nm); | 3301 | qDebug("QTReader:Finding %s", (const char*)nm); |
2914 | if (buffdoc.findanchor(nm)) | 3302 | if (buffdoc.findanchor(nm)) |
2915 | { | 3303 | { |
3304 | buffdoc.resetPos(); | ||
2916 | fillbuffer(); | 3305 | fillbuffer(); |
3306 | m_outofdate = true; | ||
2917 | update(); | 3307 | update(); |
2918 | } | 3308 | } |
2919 | } | 3309 | } |
2920 | //fillbuffer(); | 3310 | //fillbuffer(); |
2921 | //update(); | 3311 | //update(); |
2922 | #ifdef USEQPE | 3312 | #ifdef USEQPE |
2923 | { | 3313 | { |
2924 | QCopEnvelope e("QPE/System", "notBusy()"); | 3314 | QCopEnvelope e("QPE/System", "notBusy()"); |
2925 | } | 3315 | } |
2926 | #endif | 3316 | #endif |
2927 | } | 3317 | } |
2928 | else if ((lt & eLink) != 0) | 3318 | else if ((lt & eLink) != 0) |
2929 | { | 3319 | { |
2930 | buffdoc.saveposn(m_lastfile, saveposn); | 3320 | buffdoc.saveposn(m_lastfile, saveposn); |
2931 | ResetScroll(); | 3321 | ResetScroll(); |
2932 | fillbuffer(); | 3322 | fillbuffer(); |
3323 | m_outofdate = true; | ||
2933 | update(); | 3324 | update(); |
2934 | } | 3325 | } |
2935 | else | 3326 | else |
2936 | { | 3327 | { |
2937 | if ((lt & ePicture) != 0) | 3328 | if ((lt & ePicture) != 0) |
2938 | { | 3329 | { |
2939 | QImage* pm = buffdoc.getPicture(tgt); | 3330 | QImage* pm = buffdoc.getPicture(tgt); |
2940 | if (pm != NULL) | 3331 | if (pm != NULL) |
2941 | { | 3332 | { |
2942 | emit OnShowPicture(*pm); | 3333 | emit OnShowPicture(*pm); |
2943 | delete pm; | 3334 | delete pm; |
2944 | } | 3335 | } |
2945 | } | 3336 | } |
2946 | else | 3337 | else |
2947 | { | 3338 | { |
2948 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); | 3339 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); |
2949 | if (!href.isEmpty()) | 3340 | if (!href.isEmpty()) |
2950 | { | 3341 | { |
2951 | emit OnURLSelected(href, tgt); | 3342 | emit OnURLSelected(href, tgt); |
3343 | refresh(); | ||
2952 | } | 3344 | } |
2953 | } | 3345 | } |
2954 | locate(pagelocate()); | ||
2955 | } | 3346 | } |
2956 | m_currentlinkstyle = NULL; | 3347 | m_currentlinkstyle = NULL; |
2957 | m_currentlink = -1; | 3348 | m_currentlink = -1; |
2958 | m_currentlinkoffset = -1; | 3349 | m_currentlinkoffset = -1; |
2959 | } | 3350 | } |
2960 | 3351 | ||
2961 | void QTReader::refresh(bool full) | 3352 | void QTReader::refresh(bool full) |
2962 | { | 3353 | { |
3354 | qDebug("Refreshing"); | ||
2963 | int h, w; | 3355 | int h, w; |
2964 | if (m_rotated) | 3356 | if (m_rotated) |
2965 | { | 3357 | { |
2966 | h = width(); | 3358 | h = width(); |
2967 | w = height(); | 3359 | w = height(); |
2968 | } | 3360 | } |
2969 | else | 3361 | else |
2970 | { | 3362 | { |
2971 | w = width(); | 3363 | w = width(); |
2972 | h = height(); | 3364 | h = height(); |
2973 | } | 3365 | } |
2974 | m_topmargin = (h*m_abstopmargin+500)/1000; | 3366 | m_topmargin = (h*m_abstopmargin+500)/1000; |
2975 | m_bottommargin = (h*m_absbottommargin+500)/1000; | 3367 | m_bottommargin = (h*m_absbottommargin+500)/1000; |
2976 | m_left_border = (w*m_absleft_border+500)/1000; | 3368 | m_left_border = (w*m_absleft_border+500)/1000; |
2977 | m_right_border = (w*m_absright_border+500)/1000; | 3369 | m_right_border = (w*m_absright_border+500)/1000; |
2978 | 3370 | ||
2979 | qDebug("Top margin:%u", m_topmargin ); | 3371 | qDebug("Top margin:%u", m_topmargin ); |
2980 | qDebug("Bottom margin:%u", m_bottommargin ); | 3372 | qDebug("Bottom margin:%u", m_bottommargin ); |
2981 | qDebug("Left margin:%u", m_left_border ); | 3373 | qDebug("Left margin:%u", m_left_border ); |
2982 | qDebug("Right margin:%u", m_right_border ); | 3374 | qDebug("Right margin:%u", m_right_border ); |
2983 | if (full && m_highlightfilter) m_highlightfilter->refresh(pagelocate()); | 3375 | if (full && m_highlightfilter) m_highlightfilter->refresh(pagelocate()); |
3376 | m_outofdate = true; | ||
2984 | locate(pagelocate()); | 3377 | locate(pagelocate()); |
2985 | } | 3378 | } |
3379 | |||
3380 | #include "striphtml.h" | ||
3381 | |||
3382 | CFilterChain* QTReader::getfilter() | ||
3383 | { | ||
3384 | CFilterChain * filt = new CFilterChain(getencoding()); | ||
3385 | if (bstripcr) filt->addfilter(new stripcr); | ||
3386 | |||
3387 | if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); | ||
3388 | if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); | ||
3389 | // if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); | ||
3390 | |||
3391 | #ifdef __STATIC | ||
3392 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); | ||
3393 | if (bautofmt && (PreferredMarkup() == cCHM)) | ||
3394 | { | ||
3395 | striphtml* f = new striphtml(m_lastfile); | ||
3396 | f->setchm(true); | ||
3397 | filt->addfilter(f); | ||
3398 | } | ||
3399 | #else | ||
3400 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new ExternFilter("HTMLfilter", m_lastfile)); | ||
3401 | if (bautofmt && (PreferredMarkup() == cCHM)) | ||
3402 | { | ||
3403 | ExternFilter* f = new ExternFilter("HTMLfilter",m_lastfile); | ||
3404 | ((striphtml*)f->filter())->setchm(true); | ||
3405 | filt->addfilter(f); | ||
3406 | } | ||
3407 | #endif | ||
3408 | m_highlightfilter = new HighlightFilter(this); | ||
3409 | filt->addfilter(m_highlightfilter); | ||
3410 | |||
3411 | if (bdehyphen) filt->addfilter(new dehyphen); | ||
3412 | if (bunindent) filt->addfilter(new unindent); | ||
3413 | if (brepara) filt->addfilter(new repara(m_reparastring)); | ||
3414 | if (bonespace) filt->addfilter(new OnePara); | ||
3415 | if (bindenter) filt->addfilter(new indenter(bindenter)); | ||
3416 | if (bdblspce) filt->addfilter(new dblspce); | ||
3417 | if (bdepluck) filt->addfilter(new DePluck(pluckernextpart)); | ||
3418 | if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart)); | ||
3419 | if (brepalm) filt->addfilter(new repalm); | ||
3420 | if (bunderlineLink) filt->addfilter(new underlineLink); | ||
3421 | if (bkern) filt->addfilter(new kern); | ||
3422 | if (bremap) filt->addfilter(new remap); | ||
3423 | if (bmakebold) filt->addfilter(new embolden); | ||
3424 | if (bfulljust) filt->addfilter(new FullJust); | ||
3425 | int r,g,b; | ||
3426 | m_default_bg.rgb(&r, &g, &b); | ||
3427 | if (r != 255 || g != 255 || b != 255) | ||
3428 | filt->addfilter(new setbg(r,g,b)); | ||
3429 | m_default_fg.rgb(&r, &g, &b); | ||
3430 | if (r != 0 || g != 0 || b != 0) | ||
3431 | filt->addfilter(new setfg(r,g,b)); | ||
3432 | // if (bNegative) filt->addfilter(new makeNegative); | ||
3433 | if (bInverse) filt->addfilter(new makeInverse); | ||
3434 | if (bNoInlineTables) filt->addfilter(new tableLink); | ||
3435 | return filt; | ||
3436 | } | ||
3437 | |||
3438 | void QTReader::readAloud() | ||
3439 | { | ||
3440 | #ifdef __STATIC | ||
3441 | return; | ||
3442 | #else | ||
3443 | CBuffer para; | ||
3444 | jumpto(pagelocate()); | ||
3445 | while (m_autoScroll && (buffdoc.getpara(para) != -1)) | ||
3446 | { | ||
3447 | if (para.length() > 0) | ||
3448 | { | ||
3449 | unsigned long lastpos = buffdoc.explocate(); | ||
3450 | while (lastpos > mylastpos) | ||
3451 | { | ||
3452 | dopagedn(); | ||
3453 | qApp->processEvents(); | ||
3454 | } | ||
3455 | jumpto(lastpos); | ||
3456 | QString txt = toQString(para.data()); | ||
3457 | |||
3458 | doOutput(txt); | ||
3459 | } | ||
3460 | qApp->processEvents(); | ||
3461 | } | ||
3462 | #endif | ||
3463 | } | ||
3464 | |||
3465 | bool QTReader::doOutput(const QString& wrd) | ||
3466 | { | ||
3467 | if (m_output != NULL) | ||
3468 | { | ||
3469 | m_output->output(wrd); | ||
3470 | return true; | ||
3471 | } | ||
3472 | else | ||
3473 | { | ||
3474 | return false; | ||
3475 | } | ||
3476 | } | ||
3477 | |||
3478 | bool QTReader::checkoutput() | ||
3479 | { | ||
3480 | if (m_output == NULL) | ||
3481 | { | ||
3482 | m_output = new outputcodec(m_outputName); | ||
3483 | if (reinterpret_cast<outputcodec*>(m_output)->getStatus() != 0) | ||
3484 | { | ||
3485 | delete m_output; | ||
3486 | m_output = NULL; | ||
3487 | QMessageBox::warning(this, PROGNAME, QString("Couldn't find output codec\n")+m_outputName); | ||
3488 | return false; | ||
3489 | } | ||
3490 | } | ||
3491 | return true; | ||
3492 | } | ||
diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h index 3bcdde4..9daa07a 100644 --- a/noncore/apps/opie-reader/QTReader.h +++ b/noncore/apps/opie-reader/QTReader.h | |||
@@ -1,415 +1,375 @@ | |||
1 | #ifndef __QTREADER_H | 1 | #ifndef __QTREADER_H |
2 | #define __QTREADER_H | 2 | #define __QTREADER_H |
3 | 3 | ||
4 | //#define _SCROLLPIPE | 4 | //#define _SCROLLPIPE |
5 | #include <qwidget.h> | 5 | #include <qwidget.h> |
6 | //#include <qpainter.h> | 6 | //#include <qpainter.h> |
7 | #include "my_list.h" | 7 | #include "my_list.h" |
8 | #include "BuffDoc.h" | 8 | #include "BuffDoc.h" |
9 | #include "FontControl.h" | 9 | #include "FontControl.h" |
10 | 10 | ||
11 | //#include <qtimer.h> | 11 | //#include <qtimer.h> |
12 | 12 | ||
13 | class CDrawBuffer; | 13 | class CDrawBuffer; |
14 | //class CBuffer; | 14 | //class CBuffer; |
15 | #include <qpixmap.h> | 15 | #include <qpixmap.h> |
16 | class QPainter; | 16 | class QPainter; |
17 | class QTimer; | 17 | class QTimer; |
18 | class QImage; | 18 | class QImage; |
19 | 19 | ||
20 | #include "BGType.h" | 20 | #include "BGType.h" |
21 | #include "striphtml.h" | ||
22 | 21 | ||
23 | #define ROTATION_ENABLED | ||
24 | #define SPECIALSCROLL | 22 | #define SPECIALSCROLL |
25 | #define DOUBLEBUFFER | 23 | |
26 | #ifdef DOUBLEBUFFER | ||
27 | class QPainter; | 24 | class QPainter; |
28 | #endif | 25 | class COutput; |
29 | 26 | ||
30 | class CStyle; | 27 | class CStyle; |
28 | #define USETIMER | ||
31 | 29 | ||
32 | class QTReader : public QWidget | 30 | class QTReader : public QWidget |
33 | { | 31 | { |
34 | Q_OBJECT | 32 | Q_OBJECT |
35 | friend class QTReaderApp; | 33 | friend class QTReaderApp; |
36 | #ifdef DOUBLEBUFFER | 34 | #ifdef USETIMER |
35 | QTimer* m_dragtimer; | ||
36 | unsigned long m_dragtarget; | ||
37 | #endif | ||
38 | COutput* m_output; | ||
39 | bool checkoutput(); | ||
40 | bool m_outofdate, m_drageligible; | ||
37 | QPixmap *dbuff; | 41 | QPixmap *dbuff; |
38 | QPainter* dbp; | 42 | QPainter* dbp; |
39 | #endif | ||
40 | void drawSingleLine(int lineno); | 43 | void drawSingleLine(int lineno); |
41 | void gotoLink(); | 44 | void gotoLink(); |
42 | void emitRedraw(); | 45 | void emitRedraw(); |
43 | CStyle* m_currentlinkstyle; | 46 | CStyle* m_currentlinkstyle; |
44 | int m_currentlink; | 47 | int m_currentlink; |
45 | int m_currentlinkoffset; | 48 | int m_currentlinkoffset; |
46 | QPixmap m_bgpm; | 49 | QPixmap m_bgpm; |
47 | bool m_bgIsScaled; | 50 | bool m_bgIsScaled; |
48 | bground m_bgtype; | 51 | bground m_bgtype; |
49 | int m_scrollpos; | 52 | int m_scrollpos; |
50 | unsigned short m_scrollstep; | 53 | unsigned short m_scrollstep; |
51 | void blitRot(int dx, int sx, int sw, int sh, CDrawBuffer* txt); | 54 | void blitRot(int dx, int sx, int sw, int sh, CDrawBuffer* txt); |
52 | void setBackgroundBitmap(const QPixmap& _pm, bground bg) | 55 | void setBackgroundBitmap(const QPixmap& _pm, bground bg) |
53 | { | 56 | { |
54 | m_bgpm = _pm; | 57 | m_bgpm = _pm; |
55 | m_bgtype = bg; | 58 | m_bgtype = bg; |
56 | m_bgIsScaled = false; | 59 | m_bgIsScaled = false; |
57 | } | 60 | } |
58 | 61 | ||
59 | QColor m_bg, m_default_bg, m_default_fg, m_negative_fg; | 62 | QColor m_bg, m_default_bg, m_default_fg, m_negative_fg; |
60 | static tchar pluckernextpart[]; | 63 | static tchar pluckernextpart[]; |
61 | static tchar jplucknextpart[]; | 64 | static tchar jplucknextpart[]; |
62 | CList<Bkmk>* pBkmklist; | 65 | CList<Bkmk>* pBkmklist; |
63 | void setHyphenThreshold(int _v) { buffdoc.setHyphenThreshold(_v); } | 66 | void setHyphenThreshold(int _v) { buffdoc.setHyphenThreshold(_v); } |
64 | void ResetScroll(); | 67 | void ResetScroll(); |
65 | void increaseScroll(); | 68 | void increaseScroll(); |
66 | void reduceScroll(); | 69 | void reduceScroll(); |
67 | void drawText(QPainter& p, int x, int y, tchar* text); | 70 | void drawText(QPainter& p, int x, int y, tchar* text); |
68 | void DrawScroll( QPainter *p, int w, int h ); | 71 | void DrawScroll( QPainter *p, int w, int h ); |
69 | void dorollingscroll(bool); | 72 | void dorollingscroll(bool); |
70 | void doinplacescroll(); | 73 | void doinplacescroll(); |
71 | void dostaticscroll(); | 74 | void dostaticscroll(); |
72 | void suspend(); | 75 | void suspend(); |
73 | void redrawScroll(QPainter* p); | 76 | void redrawScroll(QPainter* p); |
74 | int m_delay, m_scrolltype; | 77 | int m_delay, m_scrolltype; |
75 | unsigned int m_overlap; | 78 | unsigned int m_overlap; |
76 | bool m_autoScroll, m_swapmouse; | 79 | bool m_autoScroll, m_swapmouse; |
77 | void drawBackground(); | 80 | void drawBackground(QPainter*); |
78 | #ifdef ROTATION_ENABLED | ||
79 | bool m_rotated; | 81 | bool m_rotated; |
80 | void setrotated(bool); | 82 | void setrotated(bool); |
81 | #endif | ||
82 | void autoscroll(); | 83 | void autoscroll(); |
83 | QTimer* timer; | 84 | QTimer* timer; |
84 | int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart, m_totalscroll; | 85 | int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart, m_totalscroll; |
85 | void focusInEvent(QFocusEvent*); | 86 | void focusInEvent(QFocusEvent*); |
86 | void focusOutEvent(QFocusEvent*); | 87 | void focusOutEvent(QFocusEvent*); |
87 | void processmousepositionevent( QMouseEvent* _e ); | 88 | void processmousepositionevent( QMouseEvent* _e ); |
88 | void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno); | 89 | void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno); |
89 | bool ChangeFont(int); | 90 | bool ChangeFont(int); |
90 | bool getline(CDrawBuffer*); | 91 | bool getline(CDrawBuffer*); |
91 | int m_charWidth; | 92 | int m_charWidth; |
92 | int m_charpc; | 93 | int m_charpc; |
93 | unsigned short m_absleft_border, m_absright_border; | 94 | unsigned short m_absleft_border, m_absright_border; |
94 | unsigned short m_left_border, m_right_border; | 95 | unsigned short m_left_border, m_right_border; |
95 | FontControl m_fontControl; | 96 | FontControl m_fontControl; |
96 | void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); } | 97 | void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); } |
97 | unsigned char getBaseSize() { return m_fontControl.getBaseSize(); } | 98 | unsigned char getBaseSize() { return m_fontControl.getBaseSize(); } |
99 | QString m_outputName; | ||
98 | #ifdef _SCROLLPIPE | 100 | #ifdef _SCROLLPIPE |
99 | FILE* m_pipeout; | 101 | FILE* m_pipeout; |
100 | QString m_pipetarget; | 102 | QString m_pipetarget; |
101 | bool m_isPaused; | 103 | bool m_isPaused; |
102 | bool m_pauseAfterEachPara; | 104 | bool m_pauseAfterEachPara; |
103 | #endif | 105 | #endif |
104 | public: | 106 | public: |
105 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); | 107 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); |
106 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); | 108 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); |
107 | ~QTReader(); | 109 | ~QTReader(); |
108 | QString about(); | 110 | QString about(); |
111 | void readAloud(); | ||
109 | CList<Bkmk>* Bkmklist() { return pBkmklist; } | 112 | CList<Bkmk>* Bkmklist() { return pBkmklist; } |
110 | void setBackground(const QColor& _c) | 113 | void setBackground(const QColor& _c) |
111 | { | 114 | { |
112 | m_default_bg = _c; | 115 | m_default_bg = _c; |
113 | reset_bg(); | 116 | reset_bg(); |
114 | } | 117 | } |
115 | void setForeground(const QColor& _c) | 118 | void setForeground(const QColor& _c) |
116 | { | 119 | { |
117 | m_default_fg = _c; | 120 | m_default_fg = _c; |
118 | int r,g,b; | 121 | int r,g,b; |
119 | m_default_fg.rgb(&r, &g, &b); | 122 | m_default_fg.rgb(&r, &g, &b); |
120 | r = 255-r; | 123 | r = 255-r; |
121 | g = 255-g; | 124 | g = 255-g; |
122 | b = 255-b; | 125 | b = 255-b; |
123 | m_negative_fg.setRgb(r,g,b); | 126 | m_negative_fg.setRgb(r,g,b); |
124 | } | 127 | } |
125 | void zoomin(); | 128 | void zoomin(); |
126 | void zoomout(); | 129 | void zoomout(); |
127 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | 130 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) |
128 | { | 131 | { |
129 | buffdoc.setSaveData(data, len, src, srclen); | 132 | buffdoc.setSaveData(data, len, src, srclen); |
130 | } | 133 | } |
131 | void putSaveData(unsigned char*& src, unsigned short& srclen) | 134 | void putSaveData(unsigned char*& src, unsigned short& srclen) |
132 | { | 135 | { |
133 | buffdoc.putSaveData(src, srclen); | 136 | buffdoc.putSaveData(src, srclen); |
134 | } | 137 | } |
135 | bool empty(); | 138 | bool empty(); |
136 | void setContinuous(bool _b); | 139 | void setContinuous(bool _b); |
137 | void toggle_autoscroll(); | 140 | void toggle_autoscroll(); |
138 | void setautoscroll(bool); | 141 | void setautoscroll(bool); |
139 | void disableAutoscroll() { m_autoScroll = false; } | 142 | void disableAutoscroll() { m_autoScroll = false; } |
140 | void copy() | 143 | void copy() |
141 | { | 144 | { |
142 | /* | 145 | /* |
143 | size_t nd = locate(); | 146 | size_t nd = locate(); |
144 | jumpto(m_mark); | 147 | jumpto(m_mark); |
145 | QString text; | 148 | QString text; |
146 | while (m_mark < nd) | 149 | while (m_mark < nd) |
147 | { | 150 | { |
148 | text += buffdoc.getch(); | 151 | text += buffdoc.getch(); |
149 | m_mark++; | 152 | m_mark++; |
150 | } | 153 | } |
151 | QApplication::clipboard()->setText(text); | 154 | QApplication::clipboard()->setText(text); |
152 | jumpto(nd); | 155 | jumpto(nd); |
153 | */ | 156 | */ |
154 | }; | 157 | }; |
155 | void clear() {}; | 158 | void clear() {}; |
156 | void setText(const QString& n, const QString& s) { m_string = n; load_file((const char*)s); }; | 159 | void setText(const QString& n, const QString& s, unsigned int lcn = 0) { m_string = n; load_file((const char*)s, lcn); }; |
157 | /* | 160 | /* |
158 | void setText(bool oldfile) | 161 | void setText(bool oldfile) |
159 | { | 162 | { |
160 | if (oldfile) | 163 | if (oldfile) |
161 | { | 164 | { |
162 | m_string = m_lastfile; | 165 | m_string = m_lastfile; |
163 | load_file((const tchar*)m_string); | 166 | load_file((const tchar*)m_string); |
164 | } | 167 | } |
165 | else | 168 | else |
166 | { | 169 | { |
167 | m_string = QString::null; | 170 | m_string = QString::null; |
168 | } | 171 | } |
169 | }; | 172 | }; |
170 | */ | 173 | */ |
171 | void setlead(int _lead) | 174 | void setlead(int _lead) |
172 | { | 175 | { |
173 | m_fontControl.setlead(_lead); | 176 | m_fontControl.setlead(_lead); |
174 | } | 177 | } |
175 | int getlead() | 178 | int getlead() |
176 | { | 179 | { |
177 | return m_fontControl.getlead(); | 180 | return m_fontControl.getlead(); |
178 | } | 181 | } |
179 | void setextraspace(int _lead) | 182 | void setextraspace(int _lead) |
180 | { | 183 | { |
181 | m_fontControl.setextraspace(_lead); | 184 | m_fontControl.setextraspace(_lead); |
182 | } | 185 | } |
183 | int getextraspace() | 186 | int getextraspace() |
184 | { | 187 | { |
185 | return m_fontControl.getextraspace(); | 188 | return m_fontControl.getextraspace(); |
186 | } | 189 | } |
187 | void setpagemode(bool _b) | 190 | void setpagemode(bool _b) |
188 | { | 191 | { |
189 | m_bpagemode = _b; | 192 | m_bpagemode = _b; |
190 | } | 193 | } |
191 | void setmono(bool _b) | 194 | void setmono(bool _b) |
192 | { | 195 | { |
193 | m_bMonoSpaced = _b; | 196 | m_bMonoSpaced = _b; |
194 | ChangeFont(m_fontControl.currentsize()); | 197 | ChangeFont(m_fontControl.currentsize()); |
195 | locate(pagelocate()); | 198 | locate(pagelocate()); |
196 | } | 199 | } |
197 | void setencoding(int _f) | 200 | void setencoding(int _f) |
198 | { | 201 | { |
199 | m_encd = _f; | 202 | m_encd = _f; |
200 | setfilter(getfilter()); | 203 | setfilter(getfilter()); |
201 | } | 204 | } |
202 | MarkupType PreferredMarkup(); | 205 | MarkupType PreferredMarkup(); |
203 | CEncoding* getencoding() | 206 | CEncoding* getencoding() |
204 | { | 207 | { |
205 | // qDebug("m_encd:%d", m_encd); | 208 | // qDebug("m_encd:%d", m_encd); |
206 | switch (m_encd) | 209 | switch (m_encd) |
207 | { | 210 | { |
208 | case 4: | 211 | case 4: |
209 | // qDebug("palm"); | 212 | // qDebug("palm"); |
210 | return new CPalm; | 213 | return new CPalm; |
211 | case 1: | 214 | case 1: |
212 | // qDebug("utf8"); | 215 | // qDebug("utf8"); |
213 | return new CUtf8; | 216 | return new CUtf8; |
214 | case 2: | 217 | case 2: |
215 | // qDebug("ucs16be"); | 218 | // qDebug("ucs16be"); |
216 | return new CUcs16be; | 219 | return new CUcs16be; |
217 | case 3: | 220 | case 3: |
218 | // qDebug("ucs16le"); | 221 | // qDebug("ucs16le"); |
219 | return new CUcs16le; | 222 | return new CUcs16le; |
220 | case 0: | 223 | case 0: |
221 | // qDebug("ascii"); | 224 | // qDebug("ascii"); |
222 | return new CAscii; | 225 | return new CAscii; |
223 | default: | 226 | default: |
224 | return new CGeneral8Bit(m_encd-MAX_ENCODING+1); | 227 | return new CGeneral8Bit(m_encd-MAX_ENCODING+1); |
225 | } | 228 | } |
226 | } | 229 | } |
227 | HighlightFilter* m_highlightfilter; | 230 | HighlightFilter* m_highlightfilter; |
228 | CFilterChain* getfilter() | 231 | CFilterChain* getfilter(); |
229 | { | ||
230 | CFilterChain * filt = new CFilterChain(getencoding()); | ||
231 | if (bstripcr) filt->addfilter(new stripcr); | ||
232 | |||
233 | if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); | ||
234 | if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); | ||
235 | // if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); | ||
236 | |||
237 | #ifdef __STATIC | ||
238 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); | ||
239 | if (bautofmt && (PreferredMarkup() == cCHM)) | ||
240 | { | ||
241 | filt->addfilter(new striphtml(m_lastfile)); | ||
242 | } | ||
243 | #else | ||
244 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new ExternFilter("HTMLfilter", m_lastfile)); | ||
245 | if (bautofmt && (PreferredMarkup() == cCHM)) | ||
246 | { | ||
247 | ExternFilter* f = new ExternFilter("HTMLfilter",m_lastfile); | ||
248 | ((striphtml*)f->filter())->setchm(true); | ||
249 | filt->addfilter(f); | ||
250 | } | ||
251 | #endif | ||
252 | m_highlightfilter = new HighlightFilter(this); | ||
253 | filt->addfilter(m_highlightfilter); | ||
254 | |||
255 | if (bdehyphen) filt->addfilter(new dehyphen); | ||
256 | if (bunindent) filt->addfilter(new unindent); | ||
257 | if (brepara) filt->addfilter(new repara(m_reparastring)); | ||
258 | if (bonespace) filt->addfilter(new OnePara); | ||
259 | if (bindenter) filt->addfilter(new indenter(bindenter)); | ||
260 | if (bdblspce) filt->addfilter(new dblspce); | ||
261 | if (bdepluck) filt->addfilter(new DePluck(pluckernextpart)); | ||
262 | if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart)); | ||
263 | if (brepalm) filt->addfilter(new repalm); | ||
264 | if (bkern) filt->addfilter(new kern); | ||
265 | if (bremap) filt->addfilter(new remap); | ||
266 | if (bmakebold) filt->addfilter(new embolden); | ||
267 | if (bfulljust) filt->addfilter(new FullJust); | ||
268 | int r,g,b; | ||
269 | m_default_bg.rgb(&r, &g, &b); | ||
270 | if (r != 255 || g != 255 || b != 255) | ||
271 | filt->addfilter(new setbg(r,g,b)); | ||
272 | m_default_fg.rgb(&r, &g, &b); | ||
273 | if (r != 0 || g != 0 || b != 0) | ||
274 | filt->addfilter(new setfg(r,g,b)); | ||
275 | // if (bNegative) filt->addfilter(new makeNegative); | ||
276 | if (bInverse) filt->addfilter(new makeInverse); | ||
277 | return filt; | ||
278 | } | ||
279 | |||
280 | 232 | ||
281 | private slots: | 233 | private slots: |
234 | #ifdef USETIMER | ||
235 | void actionDrag(); | ||
236 | #endif | ||
282 | void dopageup(); | 237 | void dopageup(); |
283 | void lineDown(); | 238 | void lineDown(); |
284 | void lineUp(); | 239 | void lineUp(); |
285 | void dopagedn(); | 240 | void dopagedn(); |
286 | void goHome(); | 241 | void goHome(); |
287 | void goBack(); | 242 | void goBack(); |
288 | void goForward(); | 243 | void goForward(); |
289 | void doscroll(); | 244 | void doscroll(); |
290 | void paintEvent( QPaintEvent * ); | 245 | void paintEvent( QPaintEvent * ); |
291 | #ifdef DOUBLEBUFFER | 246 | |
292 | void resizeEvent( QResizeEvent * p ); | 247 | void resizeEvent( QResizeEvent * p ); |
293 | #endif | 248 | |
294 | void keyPressEvent(QKeyEvent*); | 249 | void keyPressEvent(QKeyEvent*); |
295 | private: | 250 | private: |
296 | // void drawIt( QPainter * ); | 251 | // void drawIt( QPainter * ); |
297 | void redrawall(); | 252 | void redrawall(); |
298 | void drawFonts(); | 253 | void drawFonts(); |
299 | void DrawStraight(QPainter* p, int w, int h); | 254 | void DrawStraight(QPainter* p, int w, int h); |
300 | QColor m_scrollcolor, m_scrollbarcolor; | 255 | QColor m_scrollcolor, m_scrollbarcolor; |
301 | void setTwoTouch(bool _b); | 256 | void setTwoTouch(bool _b); |
302 | void init(); | 257 | void init(); |
258 | void mouseMoveEvent( QMouseEvent* ); | ||
303 | void mousePressEvent( QMouseEvent* ); | 259 | void mousePressEvent( QMouseEvent* ); |
304 | void mouseReleaseEvent( QMouseEvent* ); | 260 | void mouseReleaseEvent( QMouseEvent* ); |
305 | // void mouseDoubleClickEvent( QMouseEvent* ); | 261 | // void mouseDoubleClickEvent( QMouseEvent* ); |
306 | QString m_string, m_fontname, m_reparastring; | 262 | QString m_string, m_fontname, m_reparastring; |
307 | void setfont(); | 263 | void setfont(); |
264 | bool m_doubleBuffered; | ||
265 | |||
266 | void setDoubleBuffer(bool _b); | ||
308 | //myoutput stuff | 267 | //myoutput stuff |
309 | private: | 268 | private: |
310 | #ifdef SPECIALSCROLL | 269 | #ifdef SPECIALSCROLL |
311 | int m_scrolldy; | 270 | int m_scrolldy; |
312 | #endif | 271 | #endif |
313 | bool mouseUpOn; | 272 | bool mouseUpOn; |
314 | linkType getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*&); | 273 | linkType getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*&, size_t&); |
315 | bool m_twotouch, m_touchone; | 274 | bool m_twotouch, m_touchone; |
316 | size_t m_startpos, m_startoffset; | 275 | size_t m_startpos, m_startoffset; |
317 | void dopageup(unsigned int); | 276 | void dopageup(unsigned int); |
318 | long real_delay(); | 277 | long real_delay(); |
319 | int m_textsize; | 278 | int m_textsize; |
320 | int m_lastwidth, m_lastheight; | 279 | int m_lastwidth, m_lastheight; |
321 | CBufferFace<CDrawBuffer*> textarray; | 280 | CBufferFace<CDrawBuffer*> textarray; |
322 | CBufferFace<size_t> locnarray; | 281 | CBufferFace<size_t> locnarray; |
323 | unsigned int numlines; | 282 | unsigned int numlines; |
324 | // bool m_showlast; | 283 | // bool m_showlast; |
325 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust, /*bNegative,*/ bInverse; | 284 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust, /*bNegative,*/ bInverse, bNoInlineTables; |
326 | bool bkern, brepalm; | 285 | bool bkern, brepalm, bunderlineLink; |
327 | bool m_bpagemode, m_bMonoSpaced, m_continuousDocument; | 286 | bool m_bpagemode, m_bMonoSpaced, m_continuousDocument; |
328 | unsigned char bindenter; | 287 | unsigned char bindenter; |
329 | QString m_lastfile; | 288 | QString m_lastfile; |
330 | size_t m_lastposn; | 289 | size_t m_lastposn; |
331 | bool bDoUpdates; | 290 | bool bDoUpdates; |
332 | public: | 291 | public: |
292 | bool doOutput(const QString& wrd); | ||
333 | void setDoUpdates(bool b) { bDoUpdates = b; } | 293 | void setDoUpdates(bool b) { bDoUpdates = b; } |
334 | void setStripCR(bool b) { bstripcr = b; } | 294 | void setStripCR(bool b) { bstripcr = b; } |
335 | void NavUp(); | 295 | void NavUp(); |
336 | void NavDown(); | 296 | void NavDown(); |
337 | tchar getch() { return buffdoc.getch(); } | 297 | tchar getch() { return buffdoc.getch(); } |
338 | bool synch(size_t, size_t); | 298 | bool synch(size_t, size_t); |
339 | bool tight; | 299 | bool tight; |
340 | bool load_file(const char *newfile, unsigned int lcn=0); | 300 | bool load_file(const char *newfile, unsigned int lcn=0); |
341 | BuffDoc buffdoc; | 301 | BuffDoc buffdoc; |
342 | CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } | 302 | CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } |
343 | bool locate(unsigned long n); | 303 | bool locate(unsigned long n); |
344 | void jumpto(unsigned long n) { buffdoc.locate(n); } | 304 | void jumpto(unsigned long n) { buffdoc.locate(n); } |
345 | unsigned long locate() { return buffdoc.locate(); } | 305 | unsigned long locate() { return buffdoc.locate(); } |
346 | unsigned long explocate() { return buffdoc.explocate(); } | 306 | unsigned long explocate() { return buffdoc.explocate(); } |
347 | unsigned long pagelocate() { return locnarray[0]; } | 307 | unsigned long pagelocate() { return locnarray[0]; } |
348 | unsigned long mylastpos; | 308 | unsigned long mylastpos; |
349 | void getNextLink(); | 309 | void getNextLink(); |
350 | void setfilter(CFilterChain *f) { buffdoc.setfilter(f); if (bDoUpdates) locate(pagelocate()); } | 310 | void setfilter(CFilterChain *f) { buffdoc.setfilter(f); if (bDoUpdates) locate(pagelocate()); } |
351 | void restore() { jumpto(mylastpos); } | 311 | void restore() { jumpto(mylastpos); } |
352 | void goUp(); | 312 | void goUp(); |
353 | void refresh(bool full = false); | 313 | void refresh(bool full = false); |
354 | void goDown(); | 314 | void goDown(); |
355 | // bool bold; | 315 | // bool bold; |
356 | int textsize() { return m_textsize; } | 316 | int textsize() { return m_textsize; } |
357 | void textsize(int ts) { m_textsize = ts; } | 317 | void textsize(int ts) { m_textsize = ts; } |
358 | bool fillbuffer(int ru = 0, int ht = -1, int newht = -1); | 318 | bool fillbuffer(int ru = 0, int ht = -1, int newht = -1); |
359 | void CalculateScrollParameters(); | 319 | void CalculateScrollParameters(); |
360 | unsigned int screenlines(); | 320 | unsigned int screenlines(); |
361 | void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.sizes(fs,ts); } | 321 | void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.sizes(fs,ts); } |
362 | static const char *fonts[]; | 322 | static const char *fonts[]; |
363 | // unsigned int *fontsizes; | 323 | // unsigned int *fontsizes; |
364 | int m_ascent, m_descent, m_linespacing; | 324 | int m_ascent, m_descent, m_linespacing; |
365 | int m_topmargin, m_bottommargin; | 325 | int m_topmargin, m_bottommargin; |
366 | int m_abstopmargin, m_absbottommargin; | 326 | int m_abstopmargin, m_absbottommargin; |
367 | QFontMetrics* m_fm; | 327 | QFontMetrics* m_fm; |
368 | QString firstword(); | 328 | QString firstword(); |
369 | bool hyphenate; | 329 | bool hyphenate; |
370 | void reset_bg() | 330 | void reset_bg() |
371 | { | 331 | { |
372 | int r,g,b; | 332 | int r,g,b; |
373 | m_default_bg.rgb(&r, &g, &b); | 333 | m_default_bg.rgb(&r, &g, &b); |
374 | if (bInverse) | 334 | if (bInverse) |
375 | { | 335 | { |
376 | r = 255-r; | 336 | r = 255-r; |
377 | g = 255-g; | 337 | g = 255-g; |
378 | b = 255-b; | 338 | b = 255-b; |
379 | } | 339 | } |
380 | m_bg.setRgb(r,g,b); | 340 | m_bg.setRgb(r,g,b); |
381 | /* | 341 | /* |
382 | int h,s,v; | 342 | int h,s,v; |
383 | m_bg.hsv(&h, &s, &v); | 343 | m_bg.hsv(&h, &s, &v); |
384 | if (bNegative) | 344 | if (bNegative) |
385 | { | 345 | { |
386 | v = 255-v; | 346 | v = 255-v; |
387 | m_bg.setHsv(h,s,v); | 347 | m_bg.setHsv(h,s,v); |
388 | } | 348 | } |
389 | */ | 349 | */ |
390 | setBackgroundColor( m_bg ); | 350 | setBackgroundColor( m_bg ); |
391 | } | 351 | } |
392 | void setInverse(bool b) | 352 | void setInverse(bool b) |
393 | { | 353 | { |
394 | bInverse = b; | 354 | bInverse = b; |
395 | reset_bg(); | 355 | reset_bg(); |
396 | } | 356 | } |
397 | /* | 357 | /* |
398 | void setNegative() | 358 | void setNegative() |
399 | { | 359 | { |
400 | bNegative = !bNegative; | 360 | bNegative = !bNegative; |
401 | reset_bg(); | 361 | reset_bg(); |
402 | } | 362 | } |
403 | */ | 363 | */ |
404 | signals: | 364 | signals: |
405 | void OnRedraw(); | 365 | void OnRedraw(); |
406 | void OnWordSelected(const QString&, size_t, size_t, const QString&); | 366 | void OnWordSelected(const QString&, size_t, size_t, const QString&); |
407 | void OnShowPicture(QImage&); | 367 | void OnShowPicture(QImage&); |
408 | void OnURLSelected(const QString&, const size_t); | 368 | void OnURLSelected(const QString&, const size_t); |
409 | void NewFileRequest(const QString&); | 369 | void NewFileRequest(const QString&); |
410 | void HandleKeyRequest(QKeyEvent*); | 370 | void HandleKeyRequest(QKeyEvent*); |
411 | void SetScrollState(bool); | 371 | void SetScrollState(bool); |
412 | void RefreshBitmap(); | 372 | void RefreshBitmap(); |
413 | }; | 373 | }; |
414 | 374 | ||
415 | #endif | 375 | #endif |
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index 876b65a..6753698 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -1,4963 +1,5069 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. Allrights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. Allrights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | |||
20 | #include <qregexp.h> | 21 | #include <qregexp.h> |
21 | #include <qclipboard.h> | 22 | #include <qclipboard.h> |
22 | #include <qwidgetstack.h> | 23 | #include <qwidgetstack.h> |
23 | #ifdef USEQPE | 24 | #ifdef USEQPE |
24 | #include <qpe/qpemenubar.h> | 25 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 26 | #include <qpe/qpetoolbar.h> |
26 | #endif | 27 | #endif |
27 | #include <qmenubar.h> | 28 | #include <qmenubar.h> |
28 | #include <qtoolbar.h> | 29 | #include <qtoolbar.h> |
29 | #ifdef USEQPE | 30 | #ifdef USEQPE |
30 | #include <qpe/menubutton.h> | 31 | #include <qpe/menubutton.h> |
31 | #endif | 32 | #endif |
32 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
33 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
34 | #include <qaction.h> | 35 | #include <qaction.h> |
35 | #include <qapplication.h> | 36 | #include <qapplication.h> |
36 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
37 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
38 | #include <qspinbox.h> | 39 | #include <qspinbox.h> |
39 | #include <qobjectlist.h> | 40 | #include <qobjectlist.h> |
40 | #include <qstatusbar.h> | 41 | #include <qstatusbar.h> |
41 | #ifdef USEQPE | 42 | #ifdef USEQPE |
42 | #include <qpe/global.h> | 43 | #include <qpe/global.h> |
43 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
44 | #endif | 45 | #endif |
45 | #include <qfileinfo.h> | 46 | #include <qfileinfo.h> |
46 | #include <stdlib.h> //getenv | 47 | #include <stdlib.h> //getenv |
47 | #include <qprogressbar.h> | 48 | #include <qprogressbar.h> |
48 | #ifdef USEQPE | 49 | #ifdef USEQPE |
49 | #include <qpe/config.h> | 50 | #include <qpe/config.h> |
50 | #endif | 51 | #endif |
51 | #include <qbuttongroup.h> | 52 | #include <qbuttongroup.h> |
52 | #include <qradiobutton.h> | 53 | #include <qradiobutton.h> |
53 | #ifdef USEQPE | 54 | #ifdef USEQPE |
54 | #include <qpe/qcopenvelope_qws.h> | 55 | #include <qpe/qcopenvelope_qws.h> |
55 | #endif | 56 | #endif |
56 | #include "QTReader.h" | 57 | #include "QTReader.h" |
57 | #include "GraphicWin.h" | 58 | #include "GraphicWin.h" |
58 | #include "Bkmks.h" | 59 | #include "Bkmks.h" |
59 | #include "cbkmkselector.h" | 60 | #include "cbkmkselector.h" |
60 | #include "infowin.h" | 61 | #include "infowin.h" |
61 | #include "ToolbarPrefs.h" | 62 | #include "ToolbarPrefs.h" |
62 | #include "Prefs.h" | 63 | #include "Prefs.h" |
63 | #include "CAnnoEdit.h" | 64 | #include "CAnnoEdit.h" |
64 | #include "QFloatBar.h" | 65 | #include "QFloatBar.h" |
65 | #include "FixedFont.h" | 66 | #include "FixedFont.h" |
66 | #include "URLDialog.h" | 67 | #include "URLDialog.h" |
67 | #include "util.h" | 68 | #include "util.h" |
68 | #include <qfontdatabase.h> | 69 | #include <qfontdatabase.h> |
70 | |||
69 | #ifdef USEQPE | 71 | #ifdef USEQPE |
70 | #include <qpe/resource.h> | 72 | #include <qpe/resource.h> |
71 | #ifdef OPIE | 73 | #ifdef OPIE |
72 | //#include <qpe/applnk.h> | 74 | #if defined(OPIEFILEDIALOG) |
75 | #include <qpe/applnk.h> | ||
73 | #include <opie2/ofiledialog.h> | 76 | #include <opie2/ofiledialog.h> |
74 | using namespace Opie::Ui; | 77 | using namespace Opie::Ui; |
75 | #else | 78 | #else |
76 | #include "fileBrowser.h" | 79 | #include "fileBrowser.h" |
77 | #endif | 80 | #endif |
78 | #else | 81 | #else |
82 | #include "fileBrowser.h" | ||
83 | #endif | ||
84 | #else | ||
79 | #include "qfiledialog.h" | 85 | #include "qfiledialog.h" |
80 | #endif | 86 | #endif |
81 | 87 | ||
82 | #include "QTReaderApp.h" | 88 | #include "QTReaderApp.h" |
83 | #include "CDrawBuffer.h" | 89 | #include "CDrawBuffer.h" |
84 | #include "Filedata.h" | 90 | #include "Filedata.h" |
85 | #include "names.h" | 91 | #include "names.h" |
86 | #include "CEncoding_tables.h" | 92 | #include "CEncoding_tables.h" |
87 | #include "CloseDialog.h" | 93 | #include "CloseDialog.h" |
88 | 94 | ||
89 | #include "ButtonPrefs.h" | 95 | #include "ButtonPrefs.h" |
90 | 96 | ||
91 | bool CheckVersion(int&, int&, char&); | 97 | bool CheckVersion(int&, int&, char&, QWidget*); |
92 | 98 | ||
93 | #ifdef _WINDOWS | 99 | #ifdef _WINDOWS |
94 | #define PICDIR "c:\\uqtreader\\pics\\" | 100 | #define PICDIR "c:\\uqtreader\\pics\\" |
95 | #else | 101 | #else |
96 | #ifdef USEQPE | 102 | #ifdef USEQPE |
97 | #define USEMSGS | 103 | #define USEMSGS |
98 | #define PICDIR "opie-reader/" | 104 | #define PICDIR "opie-reader/" |
99 | #else | 105 | #else |
100 | //#define PICDIR "/home/tim/uqtreader/pics/" | 106 | //#define PICDIR "/home/tim/uqtreader/pics/" |
101 | QString picdir() | 107 | QString picdir() |
102 | { | 108 | { |
103 | QString hd(getenv("READERDIR")); | 109 | QString hd(getenv("READERDIR")); |
104 | return hd + "/pics"; | 110 | return hd + "/pics"; |
105 | } | 111 | } |
106 | #define PICDIR picdir() | 112 | #define PICDIR picdir() |
107 | #endif | 113 | #endif |
108 | #endif | 114 | #endif |
109 | 115 | ||
110 | unsigned long QTReaderApp::m_uid = 0; | 116 | unsigned long QTReaderApp::m_uid = 0; |
111 | 117 | ||
112 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } | 118 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } |
113 | 119 | ||
114 | #ifdef USEQPE | 120 | #ifdef USEQPE |
115 | #define geticon(iconname) Resource::loadPixmap( iconname ) | 121 | #define geticon(iconname) Resource::loadPixmap( iconname ) |
116 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) | 122 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) |
117 | #else | 123 | #else |
118 | //#define geticon(iconname) QPixmap(PICDIR iconname ".png") | 124 | //#define geticon(iconname) QPixmap(PICDIR iconname ".png") |
119 | #define geticon(iconname) QPixmap(PICDIR +"/"+iconname+".png") | 125 | #define geticon(iconname) QPixmap(PICDIR +"/"+iconname+".png") |
120 | #define getmyicon(iconname) geticon(iconname) | 126 | #define getmyicon(iconname) geticon(iconname) |
121 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) | 127 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) |
122 | #endif | 128 | #endif |
123 | 129 | ||
124 | #ifndef _WINDOWS | 130 | #ifndef _WINDOWS |
125 | #include <unistd.h> | 131 | #include <unistd.h> |
126 | #endif | 132 | #endif |
127 | #include <stddef.h> | 133 | #include <stddef.h> |
128 | #ifndef _WINDOWS | 134 | #ifndef _WINDOWS |
129 | #include <dirent.h> | 135 | #include <dirent.h> |
130 | #endif | 136 | #endif |
131 | 137 | ||
132 | void QTReaderApp::listBkmkFiles() | 138 | void QTReaderApp::listBkmkFiles() |
133 | { | 139 | { |
134 | bkmkselector->clear(); | 140 | bkmkselector->clear(); |
135 | bkmkselector->setText("Cancel"); | 141 | bkmkselector->setText("Cancel"); |
136 | #ifndef USEQPE | 142 | #ifndef USEQPE |
137 | int cnt = 0; | 143 | int cnt = 0; |
138 | 144 | ||
139 | QDir d = QDir::home(); // "/" | 145 | QDir d = QDir::home(); // "/" |
140 | if ( !d.cd(APPDIR) ) { // "/tmp" | 146 | if ( !d.cd(APPDIR) ) { // "/tmp" |
141 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 147 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
142 | d = QDir::home(); | 148 | d = QDir::home(); |
143 | d.mkdir(APPDIR); | 149 | d.mkdir(APPDIR); |
144 | d.cd(APPDIR); | 150 | d.cd(APPDIR); |
145 | } | 151 | } |
146 | 152 | ||
147 | 153 | ||
148 | 154 | ||
149 | 155 | ||
150 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 156 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
151 | // d.setSorting( QDir::Size | QDir::Reversed ); | 157 | // d.setSorting( QDir::Size | QDir::Reversed ); |
152 | 158 | ||
153 | const QFileInfoList *list = d.entryInfoList(); | 159 | const QFileInfoList *list = d.entryInfoList(); |
154 | QFileInfoListIterator it( *list ); // create list iterator | 160 | QFileInfoListIterator it( *list ); // create list iterator |
155 | QFileInfo *fi; // pointer for traversing | 161 | QFileInfo *fi; // pointer for traversing |
156 | |||
157 | while ( (fi=it.current()) ) { // for each file... | 162 | while ( (fi=it.current()) ) { // for each file... |
158 | 163 | ||
159 | bkmkselector->insertItem(fi->fileName()); | 164 | bkmkselector->insertItem(fi->fileName(), cnt++); |
160 | cnt++; | ||
161 | 165 | ||
162 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | 166 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); |
163 | ++it; // goto next list element | 167 | ++it; // goto next list element |
164 | } | 168 | } |
165 | 169 | ||
166 | #else /* USEQPE */ | 170 | #else /* USEQPE */ |
167 | int cnt = 0; | 171 | int cnt = 0; |
168 | DIR *d; | 172 | DIR *d; |
169 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); | 173 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); |
170 | 174 | ||
171 | while(1) | 175 | while(1) |
172 | { | 176 | { |
173 | struct dirent* de; | 177 | struct dirent* de; |
174 | struct stat buf; | 178 | struct stat buf; |
175 | de = readdir(d); | 179 | de = readdir(d); |
176 | if (de == NULL) break; | 180 | if (de == NULL) break; |
177 | 181 | ||
178 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 182 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) |
179 | { | 183 | { |
180 | bkmkselector->insertItem(de->d_name); | 184 | bkmkselector->insertItem(de->d_name, cnt++); |
181 | cnt++; | ||
182 | } | 185 | } |
183 | } | 186 | } |
184 | 187 | ||
185 | closedir(d); | 188 | closedir(d); |
186 | #endif | 189 | #endif |
187 | if (cnt > 0) | 190 | if (cnt > 0) |
188 | { | 191 | { |
189 | //tjw menu->hide(); | 192 | //tjw menu->hide(); |
190 | 193 | ||
191 | 194 | ||
192 | editorStack->raiseWidget( bkmkselector ); | 195 | editorStack->raiseWidget( bkmkselector ); |
193 | hidetoolbars(); | 196 | hidetoolbars(); |
194 | m_nBkmkAction = cRmBkmkFile; | 197 | m_nBkmkAction = cRmBkmkFile; |
195 | } | 198 | } |
196 | else | 199 | else |
197 | QMessageBox::information(this, PROGNAME, "No bookmark files"); | 200 | QMessageBox::information(this, PROGNAME, "No bookmark files"); |
198 | } | 201 | } |
199 | 202 | ||
200 | void QTReaderApp::hidetoolbars() | 203 | void QTReaderApp::hidetoolbars() |
201 | { | 204 | { |
202 | if (m_scrollbar != NULL) m_scrollbar->hide(); | 205 | if (m_scrollbar != NULL) m_scrollbar->hide(); |
203 | if (m_prog != NULL) m_prog->hide(); | 206 | if (m_prog != NULL) m_prog->hide(); |
204 | 207 | ||
205 | #ifdef USEQPE | 208 | #if defined(USEQPE) |
206 | menubar->hide(); | 209 | menubar->hide(); |
207 | #endif | 210 | #endif |
208 | 211 | ||
209 | if (m_scrollbar != NULL) m_scrollbar->hide(); | 212 | if (m_scrollbar != NULL) m_scrollbar->hide(); |
210 | 213 | ||
211 | if (fileBar != NULL) fileBar->hide(); | 214 | if (fileBar != NULL) fileBar->hide(); |
212 | if (viewBar != NULL) viewBar->hide(); | 215 | if (viewBar != NULL) viewBar->hide(); |
213 | if (navBar != NULL) navBar->hide(); | 216 | if (navBar != NULL) navBar->hide(); |
214 | if (markBar != NULL) markBar->hide(); | 217 | if (markBar != NULL) markBar->hide(); |
215 | if (m_fontVisible) m_fontBar->hide(); | 218 | if (m_fontVisible) m_fontBar->hide(); |
216 | if (regVisible) | 219 | if (regVisible) |
217 | { | 220 | { |
218 | #ifdef USEQPE | 221 | #ifdef USEQPE |
219 | Global::hideInputMethod(); | 222 | Global::hideInputMethod(); |
220 | #endif | 223 | #endif |
221 | regBar->hide(); | 224 | regBar->hide(); |
222 | } | 225 | } |
223 | if (searchVisible) | 226 | if (searchVisible) |
224 | { | 227 | { |
225 | #ifdef USEQPE | 228 | #ifdef USEQPE |
226 | Global::hideInputMethod(); | 229 | Global::hideInputMethod(); |
227 | #endif | 230 | #endif |
228 | searchBar->hide(); | 231 | searchBar->hide(); |
229 | } | 232 | } |
230 | } | 233 | } |
231 | 234 | ||
232 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | 235 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) |
233 | : QMainWindow( parent, name, f ), m_dontSave(false), | 236 | : QMainWindow( parent, name, f ), m_dontSave(false), |
234 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL), m_scrollbar(NULL), m_localscroll(2), m_hidebars(false), m_kmapchanged(false) | 237 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL), m_scrollbar(NULL), m_localscroll(2), m_hidebars(false), m_kmapchanged(false) |
235 | { | 238 | { |
236 | { | 239 | { |
237 | setKeyCompression ( true ); | 240 | setKeyCompression ( true ); |
238 | #ifndef USEQPE | 241 | #ifndef USEQPE |
239 | QDir d = QDir::home(); // "/" | 242 | QDir d = QDir::home(); // "/" |
240 | d.cd(APPDIR); | 243 | d.cd(APPDIR); |
241 | QFileInfo fi(d, ".keymap"); | 244 | QFileInfo fi(d, ".keymap"); |
242 | FILE* f = fopen((const char *)fi.absFilePath(), "r"); | 245 | FILE* f = fopen((const char *)fi.absFilePath(), "r"); |
243 | #else /* USEQPE */ | 246 | #else /* USEQPE */ |
244 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "r"); | 247 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "r"); |
245 | #endif /* USEQPE */ | 248 | #endif /* USEQPE */ |
246 | if (f != NULL) | 249 | if (f != NULL) |
247 | { | 250 | { |
248 | uint cnt; | 251 | uint cnt; |
249 | if ((fread(&cnt, sizeof(cnt), 1, f) != 0) && (cnt == KEYMAPVERSION)) | 252 | if ((fread(&cnt, sizeof(cnt), 1, f) != 0) && (cnt == KEYMAPVERSION)) |
250 | { | 253 | { |
251 | if (fread(&cnt, sizeof(cnt), 1, f) == 0) cnt = 0; | 254 | if (fread(&cnt, sizeof(cnt), 1, f) == 0) cnt = 0; |
252 | for (uint i = 0; i != cnt; i++) | 255 | for (uint i = 0; i != cnt; i++) |
253 | { | 256 | { |
254 | orKey key; | 257 | orKey key; |
255 | int data; | 258 | int data; |
256 | fread(&key, sizeof(key), 1, f); | 259 | fread(&key, sizeof(key), 1, f); |
257 | fread(&data, sizeof(data), 1, f); | 260 | fread(&data, sizeof(data), 1, f); |
258 | kmap[key] = data; | 261 | kmap[key] = data; |
259 | } | 262 | } |
260 | } | 263 | } |
261 | fclose(f); | 264 | fclose(f); |
262 | } | 265 | } |
263 | } | 266 | } |
264 | 267 | ||
265 | m_url_clipboard = false; | 268 | m_url_clipboard = false; |
266 | m_url_localfile = false; | 269 | m_url_localfile = false; |
267 | m_url_globalfile = false; | 270 | m_url_globalfile = false; |
268 | ftime(&m_lastkeytime); | 271 | ftime(&m_lastkeytime); |
269 | //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); | 272 | //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); |
270 | //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); | 273 | //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); |
271 | 274 | ||
272 | m_bcloseDisabled = true; | 275 | m_bcloseDisabled = true; |
273 | m_disableesckey = false; | 276 | m_disableesckey = false; |
274 | pBkmklist = NULL; | 277 | pBkmklist = NULL; |
275 | pOpenlist = NULL; | 278 | pOpenlist = NULL; |
276 | // doc = 0; | 279 | // doc = 0; |
277 | 280 | ||
278 | m_fBkmksChanged = false; | 281 | m_fBkmksChanged = false; |
279 | 282 | ||
280 | QString lang = getenv( "LANG" ); | 283 | QString lang = getenv( "LANG" ); |
281 | QString rot = getenv( "QWS_DISPLAY" ); | 284 | QString rot = getenv( "QWS_DISPLAY" ); |
282 | 285 | ||
283 | /* | 286 | /* |
284 | int m_rot = 0; | 287 | int m_rot = 0; |
285 | if (rot.contains("Rot90")) | 288 | if (rot.contains("Rot90")) |
286 | { | 289 | { |
287 | m_rot = 90; | 290 | m_rot = 90; |
288 | } | 291 | } |
289 | else if (rot.contains("Rot180")) | 292 | else if (rot.contains("Rot180")) |
290 | { | 293 | { |
291 | m_rot = 180; | 294 | m_rot = 180; |
292 | } | 295 | } |
293 | else if (rot.contains("Rot270")) | 296 | else if (rot.contains("Rot270")) |
294 | { | 297 | { |
295 | m_rot = 270; | 298 | m_rot = 270; |
296 | } | 299 | } |
297 | 300 | ||
298 | // qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); | 301 | // qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); |
299 | */ | 302 | */ |
300 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; | 303 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; |
301 | 304 | ||
302 | #ifdef USEQPE | 305 | #ifdef USEQPE |
303 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); | 306 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); |
304 | #else | 307 | #else |
305 | setIcon( QPixmap (PICDIR + "/uqtreader.png") ); | 308 | setIcon( QPixmap (PICDIR + "/uqtreader.png") ); |
306 | #endif /* USEQPE */ | 309 | #endif /* USEQPE */ |
307 | 310 | ||
308 | // QPEToolBar *bar = new QPEToolBar( this ); | 311 | // QPEToolBar *bar = new QPEToolBar( this ); |
309 | // menubar = new QPEToolBar( this ); | 312 | // menubar = new QPEToolBar( this ); |
310 | #ifdef USEQPE | 313 | #ifdef USEQPE |
311 | Config config( APPDIR ); | 314 | Config config( APPDIR ); |
312 | #else | 315 | #else |
313 | QDir d = QDir::home(); // "/" | 316 | QDir d = QDir::home(); // "/" |
314 | if ( !d.cd(APPDIR) ) { // "/tmp" | 317 | if ( !d.cd(APPDIR) ) { // "/tmp" |
315 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 318 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
316 | d = QDir::home(); | 319 | d = QDir::home(); |
317 | d.mkdir(APPDIR); | 320 | d.mkdir(APPDIR); |
318 | d.cd(APPDIR); | 321 | d.cd(APPDIR); |
319 | } | 322 | } |
320 | QFileInfo fi(d, INIFILE); | 323 | QFileInfo fi(d, INIFILE); |
321 | // qDebug("Path:%s", (const char*)fi.absFilePath()); | 324 | // qDebug("Path:%s", (const char*)fi.absFilePath()); |
322 | Config config(fi.absFilePath()); | 325 | Config config(fi.absFilePath()); |
323 | #endif | 326 | #endif |
324 | config.setGroup("Toolbar"); | 327 | config.setGroup("Toolbar"); |
325 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); | 328 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); |
326 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); | 329 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); |
327 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | 330 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); |
328 | m_qtscroll = config.readNumEntry("QTScrollBar", false); | 331 | m_qtscroll = config.readNumEntry("QTScrollBar", false); |
329 | m_localscroll = config.readNumEntry("LocalScrollBar", false); | 332 | m_localscroll = config.readNumEntry("LocalScrollBar", false); |
330 | 333 | ||
331 | // fileBar = new QToolBar("File", this); | 334 | // fileBar = new QToolBar("File", this); |
332 | // QToolBar* viewBar = new QToolBar("File", this); | 335 | // QToolBar* viewBar = new QToolBar("File", this); |
333 | // QToolBar* navBar = new QToolBar("File", this); | 336 | // QToolBar* navBar = new QToolBar("File", this); |
334 | // QToolBar* markBar = new QToolBar("File", this); | 337 | // QToolBar* markBar = new QToolBar("File", this); |
335 | 338 | ||
336 | #ifdef USEQPE | 339 | #if defined(USEQPE) |
337 | menubar = new QToolBar("Menus", this, m_tbposition); | 340 | menubar = new QToolBar("Menus", this, m_tbposition); |
338 | mb = new QPEMenuBar( menubar ); | 341 | mb = new QPEMenuBar( menubar ); |
339 | #else | 342 | #else |
340 | mb = new QMenuBar( this ); | 343 | mb = new QMenuBar( this ); |
341 | #endif | 344 | #endif |
342 | 345 | ||
343 | #ifdef USEQPE | 346 | #if defined(USEQPE) |
344 | QPopupMenu* tmp = new QPopupMenu(mb); | 347 | QPopupMenu* tmp = new QPopupMenu(mb); |
345 | mb->insertItem( geticon( "AppsIcon" ), tmp ); | 348 | mb->insertItem( geticon( "AppsIcon" ), tmp ); |
346 | #else | 349 | #else |
347 | QMenuBar* tmp = mb; | 350 | QMenuBar* tmp = mb; |
348 | #endif | 351 | #endif |
349 | 352 | ||
350 | QPopupMenu *file = new QPopupMenu( mb ); | 353 | QPopupMenu *file = new QPopupMenu( mb ); |
351 | tmp->insertItem( tr( "File" ), file ); | 354 | tmp->insertItem( tr( "File" ), file ); |
352 | 355 | ||
353 | QPopupMenu *navigation = new QPopupMenu(mb); | 356 | QPopupMenu *navigation = new QPopupMenu(mb); |
354 | tmp->insertItem( tr( "Navigation" ), navigation ); | 357 | tmp->insertItem( tr( "Navigation" ), navigation ); |
355 | 358 | ||
356 | QPopupMenu *view = new QPopupMenu( mb ); | 359 | QPopupMenu *view = new QPopupMenu( mb ); |
357 | tmp->insertItem( tr( "View" ), view ); | 360 | tmp->insertItem( tr( "View" ), view ); |
358 | 361 | ||
359 | QPopupMenu *marks = new QPopupMenu( this ); | 362 | QPopupMenu *marks = new QPopupMenu( this ); |
360 | tmp->insertItem( tr( "Marks" ), marks ); | 363 | tmp->insertItem( tr( "Marks" ), marks ); |
361 | 364 | ||
362 | QPopupMenu *settings = new QPopupMenu( this ); | 365 | QPopupMenu *settings = new QPopupMenu( this ); |
363 | tmp->insertItem( tr( "Settings" ), settings ); | 366 | tmp->insertItem( tr( "Settings" ), settings ); |
364 | 367 | ||
365 | // addToolBar(menubar, "Menus",QMainWindow::Top); | 368 | // addToolBar(menubar, "Menus",QMainWindow::Top); |
366 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); | 369 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); |
367 | 370 | ||
368 | // QPopupMenu *edit = new QPopupMenu( this ); | 371 | // QPopupMenu *edit = new QPopupMenu( this ); |
369 | 372 | ||
370 | /* | 373 | /* |
371 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 374 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
372 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 375 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
373 | a->addTo( bar ); | 376 | a->addTo( bar ); |
374 | a->addTo( file ); | 377 | a->addTo( file ); |
375 | */ | 378 | */ |
376 | QWidget* widge = new QWidget(this); | 379 | QWidget* widge = new QWidget(this); |
377 | setCentralWidget( widge ); | 380 | setCentralWidget( widge ); |
378 | QVBoxLayout* vlayout = new QVBoxLayout(widge); | 381 | QVBoxLayout* vlayout = new QVBoxLayout(widge); |
379 | m_layout = new QBoxLayout(QBoxLayout::LeftToRight); | 382 | m_layout = new QBoxLayout(QBoxLayout::LeftToRight); |
380 | m_prog = new QLabel(widge); | 383 | m_prog = new QLabel(widge); |
381 | vlayout->addLayout(m_layout, 1); | 384 | vlayout->addLayout(m_layout, 1); |
382 | vlayout->addWidget(m_prog); | 385 | vlayout->addWidget(m_prog); |
383 | 386 | ||
384 | editorStack = new QWidgetStack( widge ); | 387 | editorStack = new QWidgetStack( widge ); |
385 | // setCentralWidget( editorStack ); | 388 | // setCentralWidget( editorStack ); |
386 | 389 | ||
387 | searchVisible = FALSE; | 390 | searchVisible = FALSE; |
388 | regVisible = FALSE; | 391 | regVisible = FALSE; |
389 | m_fontVisible = false; | 392 | m_fontVisible = false; |
390 | 393 | ||
391 | m_buttonprefs = new CButtonPrefs(&kmap, this); | 394 | m_buttonprefs = new CButtonPrefs(&kmap, this); |
392 | editorStack->addWidget(m_buttonprefs, get_unique_id()); | 395 | editorStack->addWidget(m_buttonprefs, get_unique_id()); |
393 | connect( m_buttonprefs, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); | 396 | connect( m_buttonprefs, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); |
394 | 397 | ||
395 | 398 | ||
396 | m_annoWin = new CAnnoEdit(editorStack); | 399 | m_annoWin = new CAnnoEdit(editorStack); |
397 | editorStack->addWidget(m_annoWin, get_unique_id()); | 400 | editorStack->addWidget(m_annoWin, get_unique_id()); |
398 | connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); | 401 | connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); |
399 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); | 402 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); |
400 | 403 | ||
401 | m_infoWin = new infowin(editorStack); | 404 | m_infoWin = new infowin(editorStack); |
402 | editorStack->addWidget(m_infoWin, get_unique_id()); | 405 | editorStack->addWidget(m_infoWin, get_unique_id()); |
403 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); | 406 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); |
404 | 407 | ||
405 | m_graphicwin = new GraphicWin(editorStack); | 408 | m_graphicwin = new GraphicWin(editorStack); |
406 | editorStack->addWidget(m_graphicwin, get_unique_id()); | 409 | editorStack->addWidget(m_graphicwin, get_unique_id()); |
407 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); | 410 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); |
408 | 411 | ||
409 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); | 412 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); |
410 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); | 413 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); |
411 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); | 414 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); |
412 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); | 415 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); |
413 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); | 416 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); |
414 | editorStack->addWidget( bkmkselector, get_unique_id() ); | 417 | editorStack->addWidget( bkmkselector, get_unique_id() ); |
415 | 418 | ||
416 | /* | 419 | /* |
417 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); | 420 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); |
418 | connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); | 421 | connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); |
419 | 422 | ||
420 | editorStack->addWidget( importSelector, get_unique_id() ); | 423 | editorStack->addWidget( importSelector, get_unique_id() ); |
421 | 424 | ||
422 | // don't need the close visible, it is redundant... | 425 | // don't need the close visible, it is redundant... |
423 | importSelector->setCloseVisible( FALSE ); | 426 | importSelector->setCloseVisible( FALSE ); |
424 | */ | 427 | */ |
425 | // qDebug("Reading file list"); | 428 | // qDebug("Reading file list"); |
426 | readfilelist(); | 429 | readfilelist(); |
427 | 430 | ||
428 | reader = new QTReader( editorStack ); | 431 | reader = new QTReader( editorStack ); |
429 | 432 | ||
430 | reader->setDoUpdates(false); | 433 | reader->setDoUpdates(false); |
431 | 434 | ||
432 | #ifdef USEQPE | 435 | #ifdef USEQPE |
433 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); | 436 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); |
434 | #endif | 437 | #endif |
435 | 438 | ||
436 | // qDebug("Reading config"); | 439 | // qDebug("Reading config"); |
437 | // Config config( APPDIR ); | 440 | // Config config( APPDIR ); |
438 | config.setGroup( "View" ); | 441 | config.setGroup( "View" ); |
442 | #if defined(USEQPE) && defined(USENEWFULLSCREEN) | ||
443 | m_usenewfullscreen = config.readBoolEntry("NewFullScreen", false); | ||
444 | #endif | ||
439 | m_debounce = config.readNumEntry("Debounce", 0); | 445 | m_debounce = config.readNumEntry("Debounce", 0); |
440 | m_buttonprefs->Debounce(m_debounce); | 446 | m_buttonprefs->Debounce(m_debounce); |
441 | #ifdef USEQPE | 447 | #ifdef USEQPE |
442 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); | 448 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); |
443 | #else | 449 | #else |
444 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); | 450 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); |
445 | #endif | 451 | #endif |
446 | reader->setStripCR(config.readBoolEntry( "StripCr", true )); | 452 | reader->setStripCR(config.readBoolEntry( "StripCr", true )); |
447 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | 453 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); |
448 | /* | 454 | /* |
449 | bool btmp = config.readBoolEntry("Negative", false); | 455 | bool btmp = config.readBoolEntry("Negative", false); |
450 | if (btmp) reader->setNegative(); | 456 | if (btmp) reader->setNegative(); |
451 | */ | 457 | */ |
452 | reader->bInverse = config.readBoolEntry("Inverse", false); | 458 | reader->bInverse = config.readBoolEntry("Inverse", false); |
453 | reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", false )); | 459 | reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", false )); |
454 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); | 460 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); |
455 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); | 461 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); |
456 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | 462 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); |
457 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | 463 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); |
458 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | 464 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); |
465 | reader->bNoInlineTables = config.readBoolEntry( "NoInlineTables", false ); | ||
459 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 466 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); |
460 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 467 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
461 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | 468 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); |
462 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); | 469 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); |
463 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | 470 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); |
464 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 471 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
465 | reader->brepara = config.readBoolEntry( "Repara", false ); | 472 | reader->brepara = config.readBoolEntry( "Repara", false ); |
466 | reader->m_reparastring = config.readEntry( "ReparaString", "\\n{[\\n \\t]}"); | 473 | reader->m_reparastring = config.readEntry( "ReparaString", "\\n{[\\n \\t]}"); |
467 | m_bgtype = (bground)config.readNumEntry( "BackgroundType" , 0 ); | 474 | m_bgtype = (bground)config.readNumEntry( "BackgroundType" , 0 ); |
468 | m_themename = config.readEntry("Theme", QString::null ); | 475 | m_themename = config.readEntry("Theme", QString::null ); |
469 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | 476 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); |
470 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | 477 | reader->bindenter = config.readNumEntry( "Indent", 0 ); |
471 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | 478 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); |
472 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | 479 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); |
473 | reader->m_scrollstep = config.readNumEntry( "ScrollStep", 1); | 480 | reader->m_scrollstep = config.readNumEntry( "ScrollStep", 1); |
481 | reader->m_outputName = config.readEntry( "OutputCodec", ""); | ||
482 | |||
474 | 483 | ||
475 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | 484 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); |
476 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 485 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
477 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 486 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
478 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 487 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); |
479 | reader->m_rotated = config.readBoolEntry( "IsRotated", false ); | 488 | reader->m_rotated = config.readBoolEntry( "IsRotated", false ); |
480 | reader->m_scrolltype = config.readNumEntry( "ScrollType", 0 ); | 489 | reader->m_scrolltype = config.readNumEntry( "ScrollType", 0 ); |
481 | m_statusstring = config.readEntry("StatusContent", "%P%% Doc:%d/%D %p%% %z%%"); | 490 | m_statusstring = config.readEntry("StatusContent", "%P%% Doc:%d/%D %p%% %z%%"); |
482 | m_statusishidden = config.readBoolEntry("StatusHidden", false); | 491 | m_statusishidden = config.readBoolEntry("StatusHidden", false); |
483 | m_background = config.readNumEntry( "Background", 0 ); | 492 | m_background = config.readNumEntry( "Background", 0 ); |
484 | reader->setBackground(getcolour(m_background)); | 493 | reader->setBackground(getcolour(m_background)); |
485 | m_foreground = config.readNumEntry( "Foreground", 1 ); | 494 | m_foreground = config.readNumEntry( "Foreground", 1 ); |
486 | reader->setForeground(getcolour(m_foreground)); | 495 | reader->setForeground(getcolour(m_foreground)); |
487 | m_scrollcolor = config.readNumEntry( "ScrollColour", 5 ); | 496 | m_scrollcolor = config.readNumEntry( "ScrollColour", 5 ); |
488 | setscrollcolour(); | 497 | setscrollcolour(); |
489 | m_scrollbarcolor = config.readNumEntry( "ScrollBarColour", 5 ); | 498 | m_scrollbarcolor = config.readNumEntry( "ScrollBarColour", 5 ); |
490 | setscrollbarcolour(); | 499 | setscrollbarcolour(); |
491 | reader->hyphenate = config.readBoolEntry( "Hyphenate", false ); | 500 | reader->hyphenate = config.readBoolEntry( "Hyphenate", false ); |
492 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); | 501 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); |
493 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 502 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
494 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 503 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); |
495 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 504 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
496 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 505 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
497 | reader->m_abstopmargin = config.readNumEntry( "Top Margin", 100 ); | 506 | reader->m_abstopmargin = config.readNumEntry( "Top Margin", 100 ); |
498 | reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", 100 ); | 507 | reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", 100 ); |
499 | reader->m_absleft_border = config.readNumEntry( "Left Margin", 100 ); | 508 | reader->m_absleft_border = config.readNumEntry( "Left Margin", 100 ); |
500 | reader->m_absright_border = config.readNumEntry( "Right Margin", 100 ); | 509 | reader->m_absright_border = config.readNumEntry( "Right Margin", 100 ); |
501 | 510 | ||
502 | m_scrollishidden = config.readBoolEntry( "HideScrollBar", false ); | 511 | m_scrollishidden = config.readBoolEntry( "HideScrollBar", false ); |
512 | m_hidebars = config.readBoolEntry( "HideToolBar", false ); | ||
503 | 513 | ||
504 | reader->brepalm = config.readBoolEntry( "Repalm", false ); | 514 | reader->brepalm = config.readBoolEntry( "Repalm", false ); |
515 | reader->bunderlineLink = config.readBoolEntry( "UnderlineLink", true ); | ||
505 | reader->bkern = config.readBoolEntry( "Kern", false ); | 516 | reader->bkern = config.readBoolEntry( "Kern", false ); |
506 | reader->bremap = config.readBoolEntry( "Remap", true ); | 517 | reader->bremap = config.readBoolEntry( "Remap", true ); |
507 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | 518 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); |
508 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | 519 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); |
520 | reader->setDoubleBuffer(config.readBoolEntry("DoubleBuffer", true)); | ||
509 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 521 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
510 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 522 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
511 | #ifdef _SCROLLPIPE | 523 | #ifdef _SCROLLPIPE |
512 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); | 524 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); |
513 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); | 525 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); |
514 | #endif | 526 | #endif |
515 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | 527 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); |
516 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | 528 | m_doAnnotation = config.readBoolEntry( "Annotation", false); |
517 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | 529 | m_doDictionary = config.readBoolEntry( "Dictionary", false); |
518 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | 530 | m_doClipboard = config.readBoolEntry( "Clipboard", false); |
531 | m_doOutput = config.readBoolEntry( "OutputTgt", false); | ||
519 | /* | 532 | /* |
520 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | 533 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); |
521 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); | 534 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); |
522 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); | 535 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); |
523 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); | 536 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); |
524 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); | 537 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); |
525 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); | 538 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); |
526 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | 539 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); |
527 | 540 | ||
528 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | 541 | m_leftScroll = config.readBoolEntry("LeftScroll", false); |
529 | m_rightScroll = config.readBoolEntry("RightScroll", false); | 542 | m_rightScroll = config.readBoolEntry("RightScroll", false); |
530 | m_upScroll = config.readBoolEntry("UpScroll", true); | 543 | m_upScroll = config.readBoolEntry("UpScroll", true); |
531 | m_downScroll = config.readBoolEntry("DownScroll", true); | 544 | m_downScroll = config.readBoolEntry("DownScroll", true); |
532 | */ | 545 | */ |
533 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); | 546 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); |
534 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); | 547 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); |
535 | reader->setHyphenThreshold(config.readNumEntry( "HyphenThreshold", 50 )); | 548 | reader->setHyphenThreshold(config.readNumEntry( "HyphenThreshold", 50 )); |
536 | // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false )); | 549 | // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false )); |
537 | #ifndef USEQPE | 550 | #ifndef USEQPE |
538 | config.setGroup( "Geometry" ); | 551 | config.setGroup( "Geometry" ); |
539 | setGeometry(0,0, | 552 | setGeometry(0,0, |
540 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), | 553 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), |
541 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); | 554 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); |
542 | move( | 555 | move( |
543 | config.readNumEntry( "x", 20 ), | 556 | config.readNumEntry( "x", 20 ), |
544 | config.readNumEntry( "y", 20 )); | 557 | config.readNumEntry( "y", 20 )); |
545 | #else | 558 | #else |
546 | m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", false); | 559 | m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", false); |
547 | #endif | 560 | #endif |
548 | 561 | ||
549 | 562 | ||
550 | 563 | ||
551 | setTwoTouch(m_twoTouch); | 564 | setTwoTouch(m_twoTouch); |
552 | 565 | ||
553 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); | 566 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); |
554 | 567 | ||
555 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); | 568 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); |
556 | connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, size_t, const QString&) ) ); | 569 | connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, size_t, const QString&) ) ); |
557 | connect( reader, SIGNAL( OnURLSelected(const QString&, const size_t) ), this, SLOT( OnURLSelected(const QString&, const size_t) ) ); | 570 | connect( reader, SIGNAL( OnURLSelected(const QString&, const size_t) ), this, SLOT( OnURLSelected(const QString&, const size_t) ) ); |
558 | connect( reader, SIGNAL( NewFileRequest(const QString&) ), this, SLOT( forceopen(const QString&) ) ); | 571 | connect( reader, SIGNAL( NewFileRequest(const QString&) ), this, SLOT( forceopen(const QString&) ) ); |
559 | connect( reader, SIGNAL( HandleKeyRequest(QKeyEvent*) ), this, SLOT( handlekey(QKeyEvent*) ) ); | 572 | connect( reader, SIGNAL( HandleKeyRequest(QKeyEvent*) ), this, SLOT( handlekey(QKeyEvent*) ) ); |
560 | connect( reader, SIGNAL( SetScrollState(bool) ), this, SLOT( setScrollState(bool) ) ); | 573 | connect( reader, SIGNAL( SetScrollState(bool) ), this, SLOT( setScrollState(bool) ) ); |
561 | connect( reader, SIGNAL(RefreshBitmap()), this, SLOT(setBackgroundBitmap())); | 574 | connect( reader, SIGNAL(RefreshBitmap()), this, SLOT(setBackgroundBitmap())); |
562 | editorStack->addWidget( reader, get_unique_id() ); | 575 | editorStack->addWidget( reader, get_unique_id() ); |
563 | 576 | ||
564 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); | 577 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); |
565 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); | 578 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); |
566 | m_preferences_action->addTo( settings ); | 579 | m_preferences_action->addTo( settings ); |
567 | 580 | ||
568 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); | 581 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); |
569 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); | 582 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); |
570 | m_saveconfig_action->addTo( settings ); | 583 | m_saveconfig_action->addTo( settings ); |
571 | 584 | ||
572 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); | 585 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); |
573 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); | 586 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); |
574 | m_loadconfig_action->addTo( settings ); | 587 | m_loadconfig_action->addTo( settings ); |
575 | 588 | ||
576 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); | 589 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); |
577 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); | 590 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); |
578 | m_tidyconfig_action->addTo( settings ); | 591 | m_tidyconfig_action->addTo( settings ); |
579 | 592 | ||
580 | settings->insertSeparator(); | 593 | settings->insertSeparator(); |
581 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); | 594 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); |
582 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); | 595 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); |
583 | m_toolbarprefs_action->addTo( settings ); | 596 | m_toolbarprefs_action->addTo( settings ); |
584 | 597 | ||
585 | m_buttonprefs_action = new QAction( tr( "Buttons" ), QString::null, 0, this, NULL); | 598 | m_buttonprefs_action = new QAction( tr( "Buttons" ), QString::null, 0, this, NULL); |
586 | connect( m_buttonprefs_action, SIGNAL( activated() ), this, SLOT( showbuttonprefs() ) ); | 599 | connect( m_buttonprefs_action, SIGNAL( activated() ), this, SLOT( showbuttonprefs() ) ); |
587 | m_buttonprefs_action->addTo( settings ); | 600 | m_buttonprefs_action->addTo( settings ); |
588 | 601 | ||
589 | m_loadtheme_action = new QAction( tr( "Load Theme" ), QString::null, 0, this, NULL); | 602 | m_loadtheme_action = new QAction( tr( "Load Theme" ), QString::null, 0, this, NULL); |
590 | connect( m_loadtheme_action, SIGNAL( activated() ), this, SLOT( LoadTheme() ) ); | 603 | connect( m_loadtheme_action, SIGNAL( activated() ), this, SLOT( LoadTheme() ) ); |
591 | m_loadtheme_action->addTo( settings ); | 604 | m_loadtheme_action->addTo( settings ); |
592 | 605 | ||
593 | m_repara_action = new QAction( tr( "EOP Marker" ), QString::null, 0, this, NULL); | 606 | m_repara_action = new QAction( tr( "EOP Marker" ), QString::null, 0, this, NULL); |
594 | connect( m_repara_action, SIGNAL( activated() ), this, SLOT( reparastring() ) ); | 607 | connect( m_repara_action, SIGNAL( activated() ), this, SLOT( reparastring() ) ); |
595 | m_repara_action->addTo(settings); | 608 | m_repara_action->addTo(settings); |
596 | 609 | ||
597 | #ifdef USEQPE | 610 | #ifdef USEQPE |
598 | m_grab_action = new QAction( tr( "Grab Buttons" ), QString::null, 0, this, NULL, true ); | 611 | m_grab_action = new QAction( tr( "Grab Buttons" ), QString::null, 0, this, NULL, true ); |
599 | connect( m_grab_action, SIGNAL( toggled(bool) ), this, SLOT( setgrab(bool) ) ); | 612 | connect( m_grab_action, SIGNAL( toggled(bool) ), this, SLOT( setgrab(bool) ) ); |
600 | m_grab_action->setOn(m_grabkeyboard); | 613 | m_grab_action->setOn(m_grabkeyboard); |
601 | m_grab_action->addTo( settings ); | 614 | m_grab_action->addTo( settings ); |
602 | #endif | 615 | #endif |
603 | 616 | ||
604 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); | 617 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); |
605 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 618 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
606 | m_open_action->addTo( file ); | 619 | m_open_action->addTo( file ); |
607 | 620 | ||
608 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); | 621 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); |
609 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); | 622 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); |
610 | m_close_action->addTo( file ); | 623 | m_close_action->addTo( file ); |
611 | 624 | ||
612 | #ifdef _SCRIPT | 625 | #ifdef _SCRIPT |
613 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); | 626 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); |
614 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); | 627 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); |
615 | a->addTo( file ); | 628 | a->addTo( file ); |
616 | #endif | 629 | #endif |
617 | /* | 630 | /* |
618 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); | 631 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); |
619 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); | 632 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); |
620 | a->addTo( file ); | 633 | a->addTo( file ); |
621 | 634 | ||
622 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); | 635 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); |
623 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 636 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
624 | a->addTo( filebar() ); | 637 | a->addTo( filebar() ); |
625 | a->addTo( edit ); | 638 | a->addTo( edit ); |
626 | */ | 639 | */ |
627 | 640 | ||
628 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); | 641 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); |
629 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); | 642 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); |
630 | m_info_action->addTo( file ); | 643 | m_info_action->addTo( file ); |
631 | 644 | ||
632 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); | 645 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); |
633 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); | 646 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); |
634 | m_touch_action->setOn(m_twoTouch); | 647 | m_touch_action->setOn(m_twoTouch); |
635 | m_touch_action->addTo( file ); | 648 | m_touch_action->addTo( file ); |
636 | 649 | ||
637 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); | 650 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); |
638 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 651 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
639 | file->insertSeparator(); | 652 | file->insertSeparator(); |
640 | // a->addTo( bar ); | 653 | // a->addTo( bar ); |
641 | m_find_action->addTo( file ); | 654 | m_find_action->addTo( file ); |
642 | 655 | ||
643 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); | 656 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); |
644 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); | 657 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); |
645 | m_exportlinks_action->addTo( file ); | 658 | m_exportlinks_action->addTo( file ); |
646 | 659 | ||
647 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); | 660 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); |
648 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); | 661 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); |
649 | m_scrollButton->addTo(navigation); | 662 | m_scrollButton->addTo(navigation); |
650 | m_scrollButton->setOn(false); | 663 | m_scrollButton->setOn(false); |
651 | 664 | ||
652 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); | 665 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); |
653 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); | 666 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); |
654 | m_start_action->addTo(navigation); | 667 | m_start_action->addTo(navigation); |
655 | 668 | ||
656 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); | 669 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); |
657 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); | 670 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); |
658 | m_end_action->addTo(navigation); | 671 | m_end_action->addTo(navigation); |
659 | 672 | ||
660 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); | 673 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); |
661 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); | 674 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); |
662 | m_jump_action->addTo(navigation); | 675 | m_jump_action->addTo(navigation); |
663 | 676 | ||
664 | m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); | 677 | m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); |
665 | connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); | 678 | connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); |
666 | m_pageline_action->addTo(navigation); | 679 | m_pageline_action->addTo(navigation); |
667 | m_pageline_action->setOn(reader->m_bpagemode); | 680 | m_pageline_action->setOn(reader->m_bpagemode); |
668 | 681 | ||
669 | m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); | 682 | m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); |
670 | connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); | 683 | connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); |
671 | m_pageup_action->addTo( navigation ); | 684 | m_pageup_action->addTo( navigation ); |
672 | 685 | ||
673 | m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); | 686 | m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); |
674 | connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 687 | connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
675 | m_pagedn_action->addTo( navigation ); | 688 | m_pagedn_action->addTo( navigation ); |
676 | 689 | ||
677 | m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 ); | 690 | m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 ); |
678 | connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) ); | 691 | connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) ); |
679 | m_back_action->addTo( navigation ); | 692 | m_back_action->addTo( navigation ); |
680 | 693 | ||
681 | m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 ); | 694 | m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 ); |
682 | connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) ); | 695 | connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) ); |
683 | m_home_action->addTo( navigation ); | 696 | m_home_action->addTo( navigation ); |
684 | 697 | ||
685 | m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 ); | 698 | m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 ); |
686 | connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) ); | 699 | connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) ); |
687 | m_forward_action->addTo( navigation ); | 700 | m_forward_action->addTo( navigation ); |
688 | 701 | ||
689 | /* | 702 | /* |
690 | a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); | 703 | a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); |
691 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 704 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
692 | a->addTo( file ); | 705 | a->addTo( file ); |
693 | 706 | ||
694 | a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); | 707 | a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); |
695 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 708 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
696 | a->addTo( file ); | 709 | a->addTo( file ); |
697 | */ | 710 | */ |
698 | 711 | ||
699 | // file->insertSeparator(); | 712 | // file->insertSeparator(); |
700 | 713 | ||
701 | #ifdef _SCROLLPIPE | 714 | #ifdef _SCROLLPIPE |
702 | 715 | ||
703 | QActionGroup* ag = new QActionGroup(this); | 716 | QActionGroup* ag = new QActionGroup(this); |
704 | ag->setExclusive(false); | 717 | ag->setExclusive(false); |
705 | spacemenu = new QPopupMenu(this); | 718 | spacemenu = new QPopupMenu(this); |
706 | file->insertItem( tr( "Scrolling" ), spacemenu ); | 719 | file->insertItem( tr( "Scrolling" ), spacemenu ); |
707 | 720 | ||
708 | a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL); | 721 | a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL); |
709 | connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) ); | 722 | connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) ); |
710 | 723 | ||
711 | a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true ); | 724 | a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true ); |
712 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) ); | 725 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) ); |
713 | a->setOn(reader->m_pauseAfterEachPara); | 726 | a->setOn(reader->m_pauseAfterEachPara); |
714 | 727 | ||
715 | ag->addTo(spacemenu); | 728 | ag->addTo(spacemenu); |
716 | // file->insertSeparator(); | 729 | // file->insertSeparator(); |
717 | 730 | ||
718 | #endif | 731 | #endif |
719 | 732 | ||
720 | /* | 733 | /* |
721 | a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); | 734 | a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); |
722 | connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); | 735 | connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); |
723 | a->addTo( file ); | 736 | a->addTo( file ); |
724 | */ | 737 | */ |
725 | 738 | ||
726 | /* | 739 | /* |
727 | a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 ); | 740 | a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 ); |
728 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 741 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
729 | a->addTo( fileBar ); | 742 | a->addTo( fileBar ); |
730 | a->addTo( edit ); | 743 | a->addTo( edit ); |
731 | */ | 744 | */ |
732 | 745 | ||
733 | // a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 ); | 746 | // a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 ); |
734 | 747 | ||
735 | m_fullscreen = false; | 748 | m_fullscreen = false; |
736 | m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true ); | 749 | m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true ); |
737 | connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); | 750 | connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); |
738 | m_actFullscreen->setOn(m_fullscreen); | 751 | m_actFullscreen->setOn(m_fullscreen); |
739 | m_actFullscreen->addTo( view ); | 752 | m_actFullscreen->addTo( view ); |
740 | 753 | ||
741 | m_rotate_action = new QAction( tr( "Rotate" ), geticon( "repeat" ), QString::null, 0, this, NULL, true ); | 754 | m_rotate_action = new QAction( tr( "Rotate" ), geticon( "repeat" ), QString::null, 0, this, NULL, true ); |
742 | connect( m_rotate_action, SIGNAL( toggled(bool) ), this, SLOT( setrotated(bool) ) ); | 755 | connect( m_rotate_action, SIGNAL( toggled(bool) ), this, SLOT( setrotated(bool) ) ); |
743 | m_rotate_action->setOn(reader->m_rotated); | 756 | m_rotate_action->setOn(reader->m_rotated); |
744 | m_rotate_action->addTo( view ); | 757 | m_rotate_action->addTo( view ); |
745 | 758 | ||
746 | m_inverse_action = new QAction( tr( "Invert" ), getmyicon( "invert" ), QString::null, 0, this, NULL, true ); | 759 | m_inverse_action = new QAction( tr( "Invert" ), getmyicon( "invert" ), QString::null, 0, this, NULL, true ); |
747 | connect( m_inverse_action, SIGNAL( toggled(bool) ), this, SLOT( setinverted(bool) ) ); | 760 | connect( m_inverse_action, SIGNAL( toggled(bool) ), this, SLOT( setinverted(bool) ) ); |
748 | m_inverse_action->setOn(reader->bInverse); | 761 | m_inverse_action->setOn(reader->bInverse); |
749 | m_inverse_action->addTo( view ); | 762 | m_inverse_action->addTo( view ); |
750 | 763 | ||
751 | view->insertSeparator(); | 764 | view->insertSeparator(); |
752 | 765 | ||
753 | m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this); | 766 | m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this); |
754 | connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) ); | 767 | connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) ); |
755 | m_zoomin_action->addTo( view ); | 768 | m_zoomin_action->addTo( view ); |
756 | 769 | ||
757 | m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this); | 770 | m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this); |
758 | connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) ); | 771 | connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) ); |
759 | m_zoomout_action->addTo( view ); | 772 | m_zoomout_action->addTo( view ); |
760 | 773 | ||
761 | view->insertSeparator(); | 774 | view->insertSeparator(); |
762 | m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this); | 775 | m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this); |
763 | connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) ); | 776 | connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) ); |
764 | m_setfont_action->addTo( view ); | 777 | m_setfont_action->addTo( view ); |
765 | 778 | ||
766 | view->insertSeparator(); | 779 | view->insertSeparator(); |
767 | m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); | 780 | m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); |
768 | connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); | 781 | connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); |
769 | m_setenc_action->addTo( view ); | 782 | m_setenc_action->addTo( view ); |
770 | 783 | ||
771 | m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); | 784 | m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); |
772 | connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 785 | connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
773 | m_setmono_action->addTo( view ); | 786 | m_setmono_action->addTo( view ); |
774 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 787 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
775 | 788 | ||
776 | 789 | ||
777 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); | 790 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); |
778 | // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); | 791 | // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); |
779 | 792 | ||
780 | 793 | ||
781 | 794 | ||
782 | // a->addTo( filebar() ); | 795 | // a->addTo( filebar() ); |
783 | // view->insertSeparator(); | 796 | // view->insertSeparator(); |
784 | 797 | ||
785 | /* | 798 | /* |
786 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); | 799 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); |
787 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 800 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
788 | a->setOn(reader->m_bMonoSpaced); | 801 | a->setOn(reader->m_bMonoSpaced); |
789 | a->addTo( view ); | 802 | a->addTo( view ); |
790 | */ | 803 | */ |
791 | /* | 804 | /* |
792 | a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); | 805 | a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); |
793 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); | 806 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); |
794 | a->addTo( view ); | 807 | a->addTo( view ); |
795 | */ | 808 | */ |
796 | 809 | ||
797 | m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); | 810 | m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); |
798 | connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); | 811 | connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); |
799 | m_mark_action->addTo( marks ); | 812 | m_mark_action->addTo( marks ); |
800 | 813 | ||
801 | m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); | 814 | m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); |
802 | connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); | 815 | connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); |
803 | m_annotate_action->addTo( marks ); | 816 | m_annotate_action->addTo( marks ); |
804 | 817 | ||
805 | m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); | 818 | m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); |
806 | connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); | 819 | connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); |
807 | m_goto_action->addTo( marks ); | 820 | m_goto_action->addTo( marks ); |
808 | 821 | ||
809 | m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); | 822 | m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); |
810 | connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); | 823 | connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); |
811 | m_delete_action->addTo( marks ); | 824 | m_delete_action->addTo( marks ); |
812 | 825 | ||
813 | m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); | 826 | m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); |
814 | connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); | 827 | connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); |
815 | marks->insertSeparator(); | 828 | marks->insertSeparator(); |
816 | m_autogen_action->addTo( marks ); | 829 | m_autogen_action->addTo( marks ); |
817 | 830 | ||
818 | m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); | 831 | m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); |
819 | connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); | 832 | connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); |
820 | m_clear_action->addTo( marks ); | 833 | m_clear_action->addTo( marks ); |
821 | 834 | ||
822 | m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); | 835 | m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); |
823 | connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); | 836 | connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); |
824 | m_save_action->addTo( marks ); | 837 | m_save_action->addTo( marks ); |
825 | 838 | ||
826 | m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); | 839 | m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); |
827 | connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); | 840 | connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); |
828 | marks->insertSeparator(); | 841 | marks->insertSeparator(); |
829 | m_tidy_action->addTo( marks ); | 842 | m_tidy_action->addTo( marks ); |
830 | 843 | ||
831 | m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); | 844 | m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); |
832 | connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); | 845 | connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); |
833 | marks->insertSeparator(); | 846 | marks->insertSeparator(); |
834 | m_startBlock_action->addTo( marks ); | 847 | m_startBlock_action->addTo( marks ); |
835 | 848 | ||
836 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); | 849 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); |
837 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 850 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
838 | m_endBlock_action->addTo( marks ); | 851 | m_endBlock_action->addTo( marks ); |
839 | 852 | ||
840 | m_bkmkAvail = NULL; | 853 | m_bkmkAvail = NULL; |
841 | 854 | ||
842 | 855 | ||
843 | setToolBarsMovable(m_tbmove); | 856 | setToolBarsMovable(m_tbmove); |
844 | addtoolbars(&config); | 857 | addtoolbars(&config); |
858 | if (m_hidebars) | ||
859 | { | ||
860 | #if defined(USEQPE) | ||
861 | menubar->hide(); | ||
862 | #endif | ||
863 | if (fileBar != NULL) fileBar->hide(); | ||
864 | if (viewBar != NULL) viewBar->hide(); | ||
865 | if (navBar != NULL) navBar->hide(); | ||
866 | if (markBar != NULL) markBar->hide(); | ||
867 | mb->hide(); | ||
868 | } | ||
869 | |||
845 | 870 | ||
846 | pbar = new QProgressBar(this); | 871 | pbar = new QProgressBar(this); |
847 | pbar->hide(); | 872 | pbar->hide(); |
848 | 873 | ||
849 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 874 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
850 | 875 | ||
851 | searchBar->setHorizontalStretchable( TRUE ); | 876 | searchBar->setHorizontalStretchable( TRUE ); |
852 | 877 | ||
853 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | 878 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); |
854 | 879 | ||
855 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 880 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
856 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 881 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
857 | // searchEdit->setFont( f ); | 882 | // searchEdit->setFont( f ); |
858 | searchBar->setStretchableWidget( searchEdit ); | 883 | searchBar->setStretchableWidget( searchEdit ); |
859 | 884 | ||
860 | 885 | ||
861 | #ifdef __ISEARCH | 886 | #ifdef __ISEARCH |
862 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 887 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
863 | this, SLOT( search( const QString& ) ) ); | 888 | this, SLOT( search( const QString& ) ) ); |
864 | #else | 889 | #else |
865 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 890 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
866 | this, SLOT( search( ) ) ); | 891 | this, SLOT( search( ) ) ); |
867 | #endif | 892 | #endif |
868 | QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); | 893 | QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); |
869 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 894 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
870 | a->addTo( searchBar ); | 895 | a->addTo( searchBar ); |
871 | 896 | ||
872 | a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); | 897 | a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); |
873 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 898 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
874 | a->addTo( searchBar ); | 899 | a->addTo( searchBar ); |
875 | 900 | ||
876 | searchBar->hide(); | 901 | searchBar->hide(); |
877 | 902 | ||
878 | regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); | 903 | regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); |
879 | connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | 904 | connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); |
880 | 905 | ||
881 | regBar->setHorizontalStretchable( TRUE ); | 906 | regBar->setHorizontalStretchable( TRUE ); |
882 | 907 | ||
883 | regEdit = new QLineEdit( regBar, "regEdit" ); | 908 | regEdit = new QLineEdit( regBar, "regEdit" ); |
884 | // regEdit->setFont( f ); | 909 | // regEdit->setFont( f ); |
885 | 910 | ||
886 | regBar->setStretchableWidget( regEdit ); | 911 | regBar->setStretchableWidget( regEdit ); |
887 | 912 | ||
888 | connect( regEdit, SIGNAL( returnPressed( ) ), | 913 | connect( regEdit, SIGNAL( returnPressed( ) ), |
889 | this, SLOT( do_regaction() ) ); | 914 | this, SLOT( do_regaction() ) ); |
890 | 915 | ||
891 | a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); | 916 | a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); |
892 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); | 917 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); |
893 | a->addTo( regBar ); | 918 | a->addTo( regBar ); |
894 | 919 | ||
895 | a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); | 920 | a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); |
896 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); | 921 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); |
897 | a->addTo( regBar ); | 922 | a->addTo( regBar ); |
898 | 923 | ||
899 | regBar->hide(); | 924 | regBar->hide(); |
900 | 925 | ||
901 | m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); | 926 | m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); |
902 | 927 | ||
903 | m_fontBar->setHorizontalStretchable( TRUE ); | 928 | m_fontBar->setHorizontalStretchable( TRUE ); |
904 | 929 | ||
905 | // qDebug("Font selector"); | 930 | // qDebug("Font selector"); |
906 | m_fontSelector = new QComboBox(false, m_fontBar); | 931 | m_fontSelector = new QComboBox(false, m_fontBar); |
907 | m_fontBar->setStretchableWidget( m_fontSelector ); | 932 | m_fontBar->setStretchableWidget( m_fontSelector ); |
908 | { | 933 | { |
909 | QFontDatabase f; | 934 | QFontDatabase f; |
910 | QStringList flist = f.families(); | 935 | QStringList flist = f.families(); |
911 | bool realfont = false; | 936 | bool realfont = false; |
912 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 937 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
913 | { | 938 | { |
914 | if (reader->m_fontname == *nm) | 939 | if (reader->m_fontname == *nm) |
915 | { | 940 | { |
916 | realfont = true; | 941 | realfont = true; |
917 | } | 942 | } |
918 | if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); | 943 | if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); |
919 | } | 944 | } |
920 | if (!realfont) reader->m_fontname = flist[0]; | 945 | if (!realfont) reader->m_fontname = flist[0]; |
921 | } // delete the FontDatabase!!! | 946 | } // delete the FontDatabase!!! |
922 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), | 947 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), |
923 | this, SLOT( do_setfont(const QString&) ) ); | 948 | this, SLOT( do_setfont(const QString&) ) ); |
924 | connect( m_fontSelector, SIGNAL( activated(int ) ), | 949 | connect( m_fontSelector, SIGNAL( activated(int ) ), |
925 | this, SLOT( do_setencoding(int) ) ); | 950 | this, SLOT( do_setencoding(int) ) ); |
926 | 951 | ||
927 | m_fontBar->hide(); | 952 | m_fontBar->hide(); |
928 | m_fontVisible = false; | 953 | m_fontVisible = false; |
929 | #ifdef USEMSGS | 954 | #ifdef USEMSGS |
930 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), | 955 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), |
931 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); | 956 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); |
932 | #endif | 957 | #endif |
933 | // qDebug("Initing"); | 958 | // qDebug("Initing"); |
934 | 959 | ||
935 | m_layout->addWidget(editorStack); | 960 | m_layout->addWidget(editorStack); |
936 | if (m_qtscroll != 0) | 961 | if (m_qtscroll != 0) |
937 | { | 962 | { |
938 | /* | 963 | /* |
939 | m_scrollbar = new QToolBar( "Autogen", this, (m_localscrollbar) ? QMainWindow::Left : QMainWindow::Right, TRUE ); | 964 | m_scrollbar = new QToolBar( "Autogen", this, (m_localscrollbar) ? QMainWindow::Left : QMainWindow::Right, TRUE ); |
940 | 965 | ||
941 | m_scrollbar->setVerticalStretchable( TRUE ); | 966 | m_scrollbar->setVerticalStretchable( TRUE ); |
942 | */ | 967 | */ |
943 | scrollbar = m_scrollbar = new QScrollBar(QScrollBar::Vertical, widge); | 968 | scrollbar = m_scrollbar = new QScrollBar(QScrollBar::Vertical, widge); |
944 | m_layout->addWidget(scrollbar); | 969 | m_layout->addWidget(scrollbar); |
945 | scrollbar->setTracking(false); | 970 | scrollbar->setTracking(false); |
946 | //connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); | 971 | //connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); |
947 | //m_scrollbar->setStretchableWidget( scrollbar ); | 972 | //m_scrollbar->setStretchableWidget( scrollbar ); |
948 | if (m_scrollishidden) | 973 | if (m_scrollishidden) |
949 | { | 974 | { |
950 | m_scrollbar->hide(); | 975 | m_scrollbar->hide(); |
951 | } | 976 | } |
952 | else | 977 | else |
953 | { | 978 | { |
954 | m_scrollbar->show(); | 979 | m_scrollbar->show(); |
955 | } | 980 | } |
956 | 981 | ||
957 | setrotated(reader->m_rotated); | 982 | setrotated(reader->m_rotated); |
958 | } | 983 | } |
959 | else | 984 | else |
960 | { | 985 | { |
961 | m_scrollbar = NULL; | 986 | m_scrollbar = NULL; |
962 | } | 987 | } |
963 | setBackgroundBitmap(); | 988 | setBackgroundBitmap(); |
964 | m_inverse_action->setOn(reader->bInverse); | 989 | m_inverse_action->setOn(reader->bInverse); |
965 | reader->init(); | 990 | reader->init(); |
966 | 991 | ||
967 | // qDebug("Inited"); | 992 | // qDebug("Inited"); |
968 | // m_buttonAction[m_spaceTarget]->setOn(true); | 993 | // m_buttonAction[m_spaceTarget]->setOn(true); |
969 | // qDebug("fonting"); | 994 | // qDebug("fonting"); |
970 | do_setfont(reader->m_fontname); | 995 | do_setfont(reader->m_fontname); |
971 | // qDebug("fonted"); | 996 | // qDebug("fonted"); |
972 | QFont progfont(reader->m_fontname, reader->m_fontControl.getsize(0)); | 997 | QFont progfont(reader->m_fontname, reader->m_fontControl.getsize(0)); |
973 | m_prog->setFont( progfont ); | 998 | m_prog->setFont( progfont ); |
974 | if (m_statusishidden) m_prog->hide(); | 999 | if (m_statusishidden) m_prog->hide(); |
1000 | showEditTools(); | ||
975 | if (!reader->m_lastfile.isEmpty()) | 1001 | if (!reader->m_lastfile.isEmpty()) |
976 | { | 1002 | { |
977 | //qDebug("doclnk"); | 1003 | //qDebug("doclnk"); |
978 | //doc = new DocLnk(reader->m_lastfile); | 1004 | //doc = new DocLnk(reader->m_lastfile); |
979 | //qDebug("doclnk done"); | 1005 | //qDebug("doclnk done"); |
980 | if (pOpenlist != NULL) | 1006 | if (pOpenlist != NULL) |
981 | { | 1007 | { |
982 | 1008 | ||
983 | /* | 1009 | /* |
984 | int ind = 0; | 1010 | int ind = 0; |
985 | Bkmk* p = (*pOpenlist)[ind]; | 1011 | Bkmk* p = (*pOpenlist)[ind]; |
986 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | 1012 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) |
987 | { | 1013 | { |
988 | p = (*pOpenlist)[++ind]; | 1014 | p = (*pOpenlist)[++ind]; |
989 | } | 1015 | } |
990 | */ | 1016 | */ |
991 | Bkmk* p = NULL; | 1017 | Bkmk* p = NULL; |
992 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | 1018 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) |
993 | { | 1019 | { |
994 | p = iter.pContent(); | 1020 | p = iter.pContent(); |
995 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) | 1021 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) |
996 | { | 1022 | { |
997 | break; | 1023 | break; |
998 | } | 1024 | } |
999 | // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); | 1025 | // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); |
1000 | p = NULL; | 1026 | p = NULL; |
1001 | } | 1027 | } |
1002 | if (p != NULL) | 1028 | if (p != NULL) |
1003 | { | 1029 | { |
1004 | if (!openfrombkmk(p)) | 1030 | if (!openfrombkmk(p)) |
1005 | { | 1031 | { |
1006 | showEditTools(); | 1032 | showEditTools(); |
1007 | } | 1033 | } |
1008 | } | 1034 | } |
1009 | else | 1035 | else |
1010 | { | 1036 | { |
1011 | openFile( reader->m_lastfile ); | 1037 | openFile( reader->m_lastfile ); |
1012 | } | 1038 | } |
1013 | } | 1039 | } |
1014 | else | 1040 | else |
1015 | { | 1041 | { |
1016 | if (!reader->m_lastfile.isEmpty()) | 1042 | if (!reader->m_lastfile.isEmpty()) |
1017 | { | 1043 | { |
1018 | openFile( reader->m_lastfile ); | 1044 | openFile( reader->m_lastfile ); |
1019 | } | 1045 | } |
1020 | } | 1046 | } |
1021 | } | 1047 | } |
1022 | else | 1048 | else |
1023 | { | 1049 | { |
1024 | showEditTools(); | 1050 | showEditTools(); |
1025 | } | 1051 | } |
1026 | // qApp->processEvents(); | 1052 | // qApp->processEvents(); |
1027 | if (m_scrollbar == NULL || m_scrollbar->isHidden()) | 1053 | if (m_scrollbar == NULL || m_scrollbar->isHidden()) |
1028 | { | 1054 | { |
1029 | reader->m_scrollpos = m_localscroll; | 1055 | reader->m_scrollpos = m_localscroll; |
1030 | } | 1056 | } |
1031 | else | 1057 | else |
1032 | { | 1058 | { |
1033 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; | 1059 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; |
1034 | } | 1060 | } |
1035 | reader->bDoUpdates = true; | 1061 | // reader->bDoUpdates = true; |
1036 | reader->update(); | 1062 | // reader->update(); |
1037 | config.setGroup("Version"); | 1063 | config.setGroup("Version"); |
1038 | int major = config.readNumEntry("Major", 0); | 1064 | int major = config.readNumEntry("Major", 0); |
1039 | int bkmktype = config.readNumEntry("BkmkType", 0); | 1065 | int bkmktype = config.readNumEntry("BkmkType", 0); |
1040 | char minor = config.readNumEntry("Minor", 0); | 1066 | char minor = config.readNumEntry("Minor", 0); |
1041 | if (CheckVersion(major, bkmktype, minor)) | 1067 | if (CheckVersion(major, bkmktype, minor, this)) |
1042 | { | 1068 | { |
1043 | config.writeEntry("Major", major); | 1069 | config.writeEntry("Major", major); |
1044 | config.writeEntry("BkmkType", bkmktype); | 1070 | config.writeEntry("BkmkType", bkmktype); |
1045 | config.writeEntry("Minor", (int)minor); | 1071 | config.writeEntry("Minor", (int)minor); |
1046 | } | 1072 | } |
1047 | // qDebug("finished update"); | 1073 | // qDebug("finished update"); |
1048 | if (kmap.isEmpty()) | 1074 | if (kmap.isEmpty()) |
1049 | { | 1075 | { |
1050 | QMessageBox::warning(this, PROGNAME, "You haven't mapped any keys yet!\n\nYou will be taken to the key\nmapping dialog.\nA few defaults are provided\nbut you can change then to\nsuit yourself.\n\nYou can change the key\nmapping at any time by\nselecting the Settings/Button\noption on the menu."); | 1076 | QMessageBox::warning(this, PROGNAME, "You haven't mapped any keys yet!\n\nYou will be taken to the key\nmapping dialog.\nA few defaults are provided\nbut you can change then to\nsuit yourself.\n\nYou can change the key\nmapping at any time by\nselecting the Settings/Button\noption on the menu."); |
1051 | 1077 | ||
1052 | m_buttonprefs->mapkey(Qt::NoButton, Key_Up, cesPageUp); | 1078 | m_buttonprefs->mapkey(Qt::NoButton, Key_Up, cesPageUp); |
1053 | m_buttonprefs->mapkey(Qt::NoButton, Key_Down, cesPageDown); | 1079 | m_buttonprefs->mapkey(Qt::NoButton, Key_Down, cesPageDown); |
1054 | 1080 | ||
1055 | m_buttonprefs->mapkey(Qt::NoButton, Key_Right, cesZoomIn); | 1081 | m_buttonprefs->mapkey(Qt::NoButton, Key_Right, cesZoomIn); |
1056 | m_buttonprefs->mapkey(Qt::NoButton, Key_Left, cesZoomOut); | 1082 | m_buttonprefs->mapkey(Qt::NoButton, Key_Left, cesZoomOut); |
1057 | 1083 | ||
1058 | showbuttonprefs(); | 1084 | showbuttonprefs(); |
1059 | } | 1085 | } |
1060 | } | 1086 | } |
1061 | 1087 | ||
1062 | void QTReaderApp::addtoolbars(Config* config) | 1088 | void QTReaderApp::addtoolbars(Config* config) |
1063 | { | 1089 | { |
1064 | config->setGroup("Toolbar"); | 1090 | config->setGroup("Toolbar"); |
1065 | 1091 | ||
1066 | if (fileBar != NULL) | 1092 | if (fileBar != NULL) |
1067 | { | 1093 | { |
1068 | #ifdef USEQPE | 1094 | #if defined(USEQPE) |
1069 | if (fileBar != menubar) | 1095 | if (fileBar != menubar) |
1070 | { | 1096 | { |
1071 | fileBar->clear(); | 1097 | fileBar->clear(); |
1072 | } | 1098 | } |
1073 | else | 1099 | else |
1074 | { | 1100 | { |
1075 | m_preferences_action->removeFrom( filebar() ); | 1101 | m_preferences_action->removeFrom( filebar() ); |
1076 | m_open_action->removeFrom( filebar() ); | 1102 | m_open_action->removeFrom( filebar() ); |
1077 | m_close_action->removeFrom( filebar() ); | 1103 | m_close_action->removeFrom( filebar() ); |
1078 | m_info_action->removeFrom( filebar() ); | 1104 | m_info_action->removeFrom( filebar() ); |
1079 | m_touch_action->removeFrom( filebar() ); | 1105 | m_touch_action->removeFrom( filebar() ); |
1080 | m_find_action->removeFrom( filebar() ); | 1106 | m_find_action->removeFrom( filebar() ); |
1081 | } | 1107 | } |
1082 | #else | 1108 | #else |
1083 | fileBar->clear(); | 1109 | fileBar->clear(); |
1084 | #endif | 1110 | #endif |
1085 | } | 1111 | } |
1086 | 1112 | ||
1087 | m_preferences_action->addTo( filebar() ); | 1113 | m_preferences_action->addTo( filebar() ); |
1088 | addfilebar(config, "Open", m_open_action); | 1114 | addfilebar(config, "Open", m_open_action); |
1089 | addfilebar(config, "Close", m_close_action); | 1115 | addfilebar(config, "Close", m_close_action); |
1090 | addfilebar(config, "Info", m_info_action); | 1116 | addfilebar(config, "Info", m_info_action); |
1091 | addfilebar(config, "Two/One Touch", m_touch_action); | 1117 | addfilebar(config, "Two/One Touch", m_touch_action); |
1092 | addfilebar(config, "Find", m_find_action); | 1118 | addfilebar(config, "Find", m_find_action); |
1093 | 1119 | ||
1094 | if (navBar != NULL) | 1120 | if (navBar != NULL) |
1095 | { | 1121 | { |
1096 | #ifdef USEQPE | 1122 | #if defined(USEQPE) |
1097 | if ((navBar == fileBar) && (fileBar == menubar)) | 1123 | if ((navBar == fileBar) && (fileBar == menubar)) |
1098 | #else | 1124 | #else |
1099 | if (navBar == fileBar) | 1125 | if (navBar == fileBar) |
1100 | #endif | 1126 | #endif |
1101 | { | 1127 | { |
1102 | m_scrollButton->removeFrom( navbar() ); | 1128 | m_scrollButton->removeFrom( navbar() ); |
1103 | m_start_action->removeFrom( navbar() ); | 1129 | m_start_action->removeFrom( navbar() ); |
1104 | m_end_action->removeFrom( navbar() ); | 1130 | m_end_action->removeFrom( navbar() ); |
1105 | m_jump_action->removeFrom( navbar() ); | 1131 | m_jump_action->removeFrom( navbar() ); |
1106 | m_pageline_action->removeFrom( navbar() ); | 1132 | m_pageline_action->removeFrom( navbar() ); |
1107 | m_pageup_action->removeFrom( navbar() ); | 1133 | m_pageup_action->removeFrom( navbar() ); |
1108 | m_pagedn_action->removeFrom( navbar() ); | 1134 | m_pagedn_action->removeFrom( navbar() ); |
1109 | m_back_action->removeFrom( navbar() ); | 1135 | m_back_action->removeFrom( navbar() ); |
1110 | m_home_action->removeFrom( navbar() ); | 1136 | m_home_action->removeFrom( navbar() ); |
1111 | m_forward_action->removeFrom( navbar() ); | 1137 | m_forward_action->removeFrom( navbar() ); |
1112 | } | 1138 | } |
1113 | else if (navBar != fileBar) | 1139 | else if (navBar != fileBar) |
1114 | { | 1140 | { |
1115 | navBar->clear(); | 1141 | navBar->clear(); |
1116 | } | 1142 | } |
1117 | } | 1143 | } |
1118 | 1144 | ||
1119 | addnavbar(config, "Scroll", m_scrollButton); | 1145 | addnavbar(config, "Scroll", m_scrollButton); |
1120 | addnavbar(config, "Goto Start", m_start_action); | 1146 | addnavbar(config, "Goto Start", m_start_action); |
1121 | addnavbar(config, "Goto End", m_end_action); | 1147 | addnavbar(config, "Goto End", m_end_action); |
1122 | 1148 | ||
1123 | addnavbar(config, "Jump", m_jump_action); | 1149 | addnavbar(config, "Jump", m_jump_action); |
1124 | addnavbar(config, "Page/Line Scroll", m_pageline_action); | 1150 | addnavbar(config, "Page/Line Scroll", m_pageline_action); |
1125 | 1151 | ||
1126 | addnavbar(config, "Page Up", m_pageup_action); | 1152 | addnavbar(config, "Page Up", m_pageup_action); |
1127 | addnavbar(config, "Page Down", m_pagedn_action); | 1153 | addnavbar(config, "Page Down", m_pagedn_action); |
1128 | 1154 | ||
1129 | addnavbar(config, "Back", m_back_action); | 1155 | addnavbar(config, "Back", m_back_action); |
1130 | addnavbar(config, "Home", m_home_action); | 1156 | addnavbar(config, "Home", m_home_action); |
1131 | addnavbar(config, "Forward", m_forward_action); | 1157 | addnavbar(config, "Forward", m_forward_action); |
1132 | 1158 | ||
1133 | if (viewBar != NULL) | 1159 | if (viewBar != NULL) |
1134 | { | 1160 | { |
1135 | #ifdef USEQPE | 1161 | #if defined(USEQPE) |
1136 | if ((viewBar == fileBar) && (fileBar == menubar)) | 1162 | if ((viewBar == fileBar) && (fileBar == menubar)) |
1137 | #else | 1163 | #else |
1138 | if (viewBar == fileBar) | 1164 | if (viewBar == fileBar) |
1139 | #endif | 1165 | #endif |
1140 | { | 1166 | { |
1141 | m_actFullscreen->removeFrom( filebar() ); | 1167 | m_actFullscreen->removeFrom( filebar() ); |
1142 | m_rotate_action->removeFrom( viewbar() ); | 1168 | m_rotate_action->removeFrom( viewbar() ); |
1143 | m_inverse_action->removeFrom( viewbar() ); | 1169 | m_inverse_action->removeFrom( viewbar() ); |
1144 | m_zoomin_action->removeFrom( viewbar() ); | 1170 | m_zoomin_action->removeFrom( viewbar() ); |
1145 | m_zoomout_action->removeFrom( viewbar() ); | 1171 | m_zoomout_action->removeFrom( viewbar() ); |
1146 | m_setfont_action->removeFrom( viewbar() ); | 1172 | m_setfont_action->removeFrom( viewbar() ); |
1147 | m_setenc_action->removeFrom( viewbar() ); | 1173 | m_setenc_action->removeFrom( viewbar() ); |
1148 | m_setmono_action->removeFrom( viewbar() ); | 1174 | m_setmono_action->removeFrom( viewbar() ); |
1149 | } | 1175 | } |
1150 | else if (viewBar != fileBar) | 1176 | else if (viewBar != fileBar) |
1151 | { | 1177 | { |
1152 | viewBar->clear(); | 1178 | viewBar->clear(); |
1153 | } | 1179 | } |
1154 | } | 1180 | } |
1155 | 1181 | ||
1156 | addviewbar(config, "Fullscreen", m_actFullscreen); | 1182 | addviewbar(config, "Fullscreen", m_actFullscreen); |
1157 | addviewbar(config, "Rotate", m_rotate_action); | 1183 | addviewbar(config, "Rotate", m_rotate_action); |
1158 | addviewbar(config, "Invert Action", m_inverse_action); | 1184 | addviewbar(config, "Invert Action", m_inverse_action); |
1159 | addviewbar(config, "Zoom In", m_zoomin_action); | 1185 | addviewbar(config, "Zoom In", m_zoomin_action); |
1160 | addviewbar(config, "Zoom Out", m_zoomout_action); | 1186 | addviewbar(config, "Zoom Out", m_zoomout_action); |
1161 | addviewbar(config, "Set Font", m_setfont_action); | 1187 | addviewbar(config, "Set Font", m_setfont_action); |
1162 | addviewbar(config, "Encoding Select", m_setenc_action); | 1188 | addviewbar(config, "Encoding Select", m_setenc_action); |
1163 | addviewbar(config, "Ideogram Mode", m_setmono_action); | 1189 | addviewbar(config, "Ideogram Mode", m_setmono_action); |
1164 | 1190 | ||
1165 | if (markBar != NULL) | 1191 | if (markBar != NULL) |
1166 | { | 1192 | { |
1167 | #ifdef USEQPE | 1193 | #if defined(USEQPE) |
1168 | if ((markBar == fileBar) && (fileBar == menubar)) | 1194 | if ((markBar == fileBar) && (fileBar == menubar)) |
1169 | #else | 1195 | #else |
1170 | if (markBar == fileBar) | 1196 | if (markBar == fileBar) |
1171 | #endif | 1197 | #endif |
1172 | { | 1198 | { |
1173 | m_mark_action->removeFrom( markbar() ); | 1199 | m_mark_action->removeFrom( markbar() ); |
1174 | m_annotate_action->removeFrom( markbar()); | 1200 | m_annotate_action->removeFrom( markbar()); |
1175 | m_goto_action->removeFrom( markbar() ); | 1201 | m_goto_action->removeFrom( markbar() ); |
1176 | m_delete_action->removeFrom( markbar() ); | 1202 | m_delete_action->removeFrom( markbar() ); |
1177 | m_autogen_action->removeFrom( markbar() ); | 1203 | m_autogen_action->removeFrom( markbar() ); |
1178 | m_clear_action->removeFrom( markbar() ); | 1204 | m_clear_action->removeFrom( markbar() ); |
1179 | m_save_action->removeFrom( markbar() ); | 1205 | m_save_action->removeFrom( markbar() ); |
1180 | m_tidy_action->removeFrom( markbar() ); | 1206 | m_tidy_action->removeFrom( markbar() ); |
1181 | m_startBlock_action->removeFrom( markbar() ); | 1207 | m_startBlock_action->removeFrom( markbar() ); |
1182 | m_endBlock_action->removeFrom( markbar() ); | 1208 | m_endBlock_action->removeFrom( markbar() ); |
1183 | } | 1209 | } |
1184 | else if (markBar != fileBar) | 1210 | else if (markBar != fileBar) |
1185 | { | 1211 | { |
1186 | markBar->clear(); | 1212 | markBar->clear(); |
1187 | } | 1213 | } |
1188 | } | 1214 | } |
1189 | addmarkbar(config, "Mark", m_mark_action); | 1215 | addmarkbar(config, "Mark", m_mark_action); |
1190 | addmarkbar(config, "Annotate", m_annotate_action); | 1216 | addmarkbar(config, "Annotate", m_annotate_action); |
1191 | addmarkbar(config, "Goto", m_goto_action); | 1217 | addmarkbar(config, "Goto", m_goto_action); |
1192 | addmarkbar(config, "Delete", m_delete_action); | 1218 | addmarkbar(config, "Delete", m_delete_action); |
1193 | addmarkbar(config, "Autogen", m_autogen_action); | 1219 | addmarkbar(config, "Autogen", m_autogen_action); |
1194 | addmarkbar(config, "Clear", m_clear_action); | 1220 | addmarkbar(config, "Clear", m_clear_action); |
1195 | addmarkbar(config, "Save", m_save_action); | 1221 | addmarkbar(config, "Save", m_save_action); |
1196 | addmarkbar(config, "Tidy", m_tidy_action); | 1222 | addmarkbar(config, "Tidy", m_tidy_action); |
1197 | addmarkbar(config, "Start Block", m_startBlock_action); | 1223 | addmarkbar(config, "Start Block", m_startBlock_action); |
1198 | addmarkbar(config, "Copy Block", m_endBlock_action); | 1224 | addmarkbar(config, "Copy Block", m_endBlock_action); |
1199 | if (checkbar(config, "Annotation indicator")) | 1225 | if (checkbar(config, "Annotation indicator")) |
1200 | { | 1226 | { |
1201 | if (m_bkmkAvail == NULL) | 1227 | if (m_bkmkAvail == NULL) |
1202 | { | 1228 | { |
1203 | m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 ); | 1229 | m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 ); |
1204 | connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); | 1230 | connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); |
1205 | 1231 | ||
1206 | m_bkmkAvail->setEnabled(false); | 1232 | m_bkmkAvail->setEnabled(false); |
1207 | } | 1233 | } |
1208 | QLabel *spacer = new QLabel(markBar, ""); | 1234 | QLabel *spacer = new QLabel(markBar, ""); |
1209 | markbar()->setStretchableWidget(spacer); | 1235 | markbar()->setStretchableWidget(spacer); |
1210 | m_bkmkAvail->removeFrom( markbar() ); | 1236 | m_bkmkAvail->removeFrom( markbar() ); |
1211 | m_bkmkAvail->addTo( markbar() ); | 1237 | m_bkmkAvail->addTo( markbar() ); |
1212 | } | 1238 | } |
1213 | else | 1239 | else |
1214 | { | 1240 | { |
1215 | if (m_bkmkAvail != NULL) | 1241 | if (m_bkmkAvail != NULL) |
1216 | { | 1242 | { |
1217 | m_bkmkAvail->removeFrom( markbar() ); | 1243 | m_bkmkAvail->removeFrom( markbar() ); |
1218 | delete m_bkmkAvail; | 1244 | delete m_bkmkAvail; |
1219 | m_bkmkAvail = NULL; | 1245 | m_bkmkAvail = NULL; |
1220 | } | 1246 | } |
1221 | } | 1247 | } |
1222 | } | 1248 | } |
1223 | 1249 | ||
1224 | bool QTReaderApp::checkbar(Config* _config, const QString& key) | 1250 | bool QTReaderApp::checkbar(Config* _config, const QString& key) |
1225 | { | 1251 | { |
1226 | return _config->readBoolEntry(key, false); | 1252 | return _config->readBoolEntry(key, false); |
1227 | } | 1253 | } |
1228 | 1254 | ||
1229 | 1255 | ||
1230 | QToolBar* QTReaderApp::filebar() | 1256 | QToolBar* QTReaderApp::filebar() |
1231 | { | 1257 | { |
1232 | if (fileBar == NULL) | 1258 | if (fileBar == NULL) |
1233 | { | 1259 | { |
1234 | switch (m_tbpol) | 1260 | switch (m_tbpol) |
1235 | { | 1261 | { |
1236 | #ifdef USEQPE | 1262 | #if defined(USEQPE) |
1237 | case cesSingle: | 1263 | case cesSingle: |
1238 | // qDebug("Setting filebar to menubar"); | 1264 | // qDebug("Setting filebar to menubar"); |
1239 | fileBar = menubar; | 1265 | fileBar = menubar; |
1240 | break; | 1266 | break; |
1241 | #endif | 1267 | #endif |
1242 | default: | 1268 | default: |
1243 | qDebug("Incorrect toolbar policy set"); | 1269 | qDebug("Incorrect toolbar policy set"); |
1244 | case cesMenuTool: | 1270 | case cesMenuTool: |
1245 | case cesMultiple: | 1271 | case cesMultiple: |
1246 | // qDebug("Creating new file bar"); | 1272 | // qDebug("Creating new file bar"); |
1247 | fileBar = new QToolBar("File", this, m_tbposition); | 1273 | fileBar = new QToolBar("File", this, m_tbposition); |
1248 | break; | 1274 | break; |
1249 | } | 1275 | } |
1250 | //fileBar->setHorizontalStretchable( true ); | 1276 | //fileBar->setHorizontalStretchable( true ); |
1251 | } | 1277 | } |
1252 | return fileBar; | 1278 | return fileBar; |
1253 | } | 1279 | } |
1254 | QToolBar* QTReaderApp::viewbar() | 1280 | QToolBar* QTReaderApp::viewbar() |
1255 | { | 1281 | { |
1256 | if (viewBar == NULL) | 1282 | if (viewBar == NULL) |
1257 | { | 1283 | { |
1258 | switch (m_tbpol) | 1284 | switch (m_tbpol) |
1259 | { | 1285 | { |
1260 | case cesMultiple: | 1286 | case cesMultiple: |
1261 | viewBar = new QToolBar("View", this, m_tbposition); | 1287 | viewBar = new QToolBar("View", this, m_tbposition); |
1262 | break; | 1288 | break; |
1263 | default: | 1289 | default: |
1264 | qDebug("Incorrect toolbar policy set"); | 1290 | qDebug("Incorrect toolbar policy set"); |
1265 | #ifdef USEQPE | 1291 | #ifdef USEQPE |
1266 | case cesSingle: | 1292 | case cesSingle: |
1267 | #endif | 1293 | #endif |
1268 | case cesMenuTool: | 1294 | case cesMenuTool: |
1269 | viewBar = fileBar; | 1295 | viewBar = fileBar; |
1270 | break; | 1296 | break; |
1271 | } | 1297 | } |
1272 | } | 1298 | } |
1273 | return viewBar; | 1299 | return viewBar; |
1274 | } | 1300 | } |
1275 | QToolBar* QTReaderApp::navbar() | 1301 | QToolBar* QTReaderApp::navbar() |
1276 | { | 1302 | { |
1277 | if (navBar == NULL) | 1303 | if (navBar == NULL) |
1278 | { | 1304 | { |
1279 | switch (m_tbpol) | 1305 | switch (m_tbpol) |
1280 | { | 1306 | { |
1281 | case cesMultiple: | 1307 | case cesMultiple: |
1282 | // qDebug("Creating new nav bar"); | 1308 | // qDebug("Creating new nav bar"); |
1283 | navBar = new QToolBar("Navigation", this, m_tbposition); | 1309 | navBar = new QToolBar("Navigation", this, m_tbposition); |
1284 | break; | 1310 | break; |
1285 | default: | 1311 | default: |
1286 | qDebug("Incorrect toolbar policy set"); | 1312 | qDebug("Incorrect toolbar policy set"); |
1287 | #ifdef USEQPE | 1313 | #ifdef USEQPE |
1288 | case cesSingle: | 1314 | case cesSingle: |
1289 | #endif | 1315 | #endif |
1290 | case cesMenuTool: | 1316 | case cesMenuTool: |
1291 | navBar = fileBar; | 1317 | navBar = fileBar; |
1292 | // qDebug("Setting navbar to filebar"); | 1318 | // qDebug("Setting navbar to filebar"); |
1293 | break; | 1319 | break; |
1294 | } | 1320 | } |
1295 | } | 1321 | } |
1296 | return navBar; | 1322 | return navBar; |
1297 | } | 1323 | } |
1298 | QToolBar* QTReaderApp::markbar() | 1324 | QToolBar* QTReaderApp::markbar() |
1299 | { | 1325 | { |
1300 | if (markBar == NULL) | 1326 | if (markBar == NULL) |
1301 | { | 1327 | { |
1302 | switch (m_tbpol) | 1328 | switch (m_tbpol) |
1303 | { | 1329 | { |
1304 | case cesMultiple: | 1330 | case cesMultiple: |
1305 | markBar = new QToolBar("Marks", this, m_tbposition); | 1331 | markBar = new QToolBar("Marks", this, m_tbposition); |
1306 | break; | 1332 | break; |
1307 | default: | 1333 | default: |
1308 | qDebug("Incorrect toolbar policy set"); | 1334 | qDebug("Incorrect toolbar policy set"); |
1309 | #ifdef USEQPE | 1335 | #ifdef USEQPE |
1310 | case cesSingle: | 1336 | case cesSingle: |
1311 | #endif | 1337 | #endif |
1312 | case cesMenuTool: | 1338 | case cesMenuTool: |
1313 | markBar = fileBar; | 1339 | markBar = fileBar; |
1314 | break; | 1340 | break; |
1315 | } | 1341 | } |
1316 | } | 1342 | } |
1317 | return markBar; | 1343 | return markBar; |
1318 | } | 1344 | } |
1319 | 1345 | ||
1320 | void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) | 1346 | void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) |
1321 | { | 1347 | { |
1322 | if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); | 1348 | if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); |
1323 | } | 1349 | } |
1324 | void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) | 1350 | void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) |
1325 | { | 1351 | { |
1326 | if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); | 1352 | if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); |
1327 | } | 1353 | } |
1328 | void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) | 1354 | void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) |
1329 | { | 1355 | { |
1330 | if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); | 1356 | if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); |
1331 | } | 1357 | } |
1332 | void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) | 1358 | void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) |
1333 | { | 1359 | { |
1334 | if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); | 1360 | if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); |
1335 | } | 1361 | } |
1336 | 1362 | ||
1337 | void QTReaderApp::suspend() { reader->suspend(); } | 1363 | void QTReaderApp::suspend() { reader->suspend(); } |
1338 | 1364 | ||
1339 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | 1365 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) |
1340 | { | 1366 | { |
1341 | #ifndef USEMSGS | 1367 | #ifndef USEMSGS |
1342 | return; | 1368 | return; |
1343 | #else | 1369 | #else |
1344 | QString msg = QString::fromUtf8(_msg); | 1370 | QString msg = QString::fromUtf8(_msg); |
1345 | 1371 | ||
1346 | qDebug("Received:%s", (const char*)msg); | 1372 | qDebug("Received:%s", (const char*)msg); |
1347 | QDataStream stream( _data, IO_ReadOnly ); | 1373 | QDataStream stream( _data, IO_ReadOnly ); |
1348 | if ( msg == "suspend()" ) | 1374 | if ( msg == "suspend()" ) |
1349 | { | 1375 | { |
1350 | qDebug("Suspending"); | 1376 | qDebug("Suspending"); |
1351 | suspend(); | 1377 | suspend(); |
1352 | qDebug("Suspendedb"); | 1378 | qDebug("Suspendedb"); |
1353 | } | 1379 | } |
1354 | return; | 1380 | return; |
1355 | /* | 1381 | /* |
1356 | QDataStream stream( _data, IO_ReadOnly ); | 1382 | QDataStream stream( _data, IO_ReadOnly ); |
1357 | if ( msg == "info(QString)" ) | 1383 | if ( msg == "info(QString)" ) |
1358 | { | 1384 | { |
1359 | QString info; | 1385 | QString info; |
1360 | stream >> info; | 1386 | stream >> info; |
1361 | QMessageBox::information(this, PROGNAME, info); | 1387 | QMessageBox::information(this, PROGNAME, info); |
1362 | } | 1388 | } |
1363 | else if ( msg == "Update(int)" ) | 1389 | else if ( msg == "Update(int)" ) |
1364 | { | 1390 | { |
1365 | int info; | 1391 | int info; |
1366 | stream >> info; | 1392 | stream >> info; |
1367 | if (info) | 1393 | if (info) |
1368 | { | 1394 | { |
1369 | reader->bDoUpdates = true; | 1395 | reader->bDoUpdates = true; |
1370 | reader->refresh(); | 1396 | reader->refresh(); |
1371 | } | 1397 | } |
1372 | else | 1398 | else |
1373 | { | 1399 | { |
1374 | reader->bDoUpdates = false; | 1400 | reader->bDoUpdates = false; |
1375 | } | 1401 | } |
1376 | } | 1402 | } |
1377 | else if ( msg == "warn(QString)" ) | 1403 | else if ( msg == "warn(QString)" ) |
1378 | { | 1404 | { |
1379 | QString info; | 1405 | QString info; |
1380 | stream >> info; | 1406 | stream >> info; |
1381 | QMessageBox::warning(this, PROGNAME, info); | 1407 | QMessageBox::warning(this, PROGNAME, info); |
1382 | } | 1408 | } |
1383 | else if ( msg == "exit()" ) | 1409 | else if ( msg == "exit()" ) |
1384 | { | 1410 | { |
1385 | m_dontSave = true; | 1411 | m_dontSave = true; |
1386 | close(); | 1412 | close(); |
1387 | } | 1413 | } |
1388 | else if ( msg == "pageDown()" ) | 1414 | else if ( msg == "pageDown()" ) |
1389 | { | 1415 | { |
1390 | reader->dopagedn(); | 1416 | reader->dopagedn(); |
1391 | } | 1417 | } |
1392 | else if ( msg == "pageUp()" ) | 1418 | else if ( msg == "pageUp()" ) |
1393 | { | 1419 | { |
1394 | reader->dopageup(); | 1420 | reader->dopageup(); |
1395 | } | 1421 | } |
1396 | else if ( msg == "lineDown()" ) | 1422 | else if ( msg == "lineDown()" ) |
1397 | { | 1423 | { |
1398 | reader->lineDown(); | 1424 | reader->lineDown(); |
1399 | } | 1425 | } |
1400 | else if ( msg == "lineUp()" ) | 1426 | else if ( msg == "lineUp()" ) |
1401 | { | 1427 | { |
1402 | reader->lineUp(); | 1428 | reader->lineUp(); |
1403 | } | 1429 | } |
1404 | else if ( msg == "showText()" ) | 1430 | else if ( msg == "showText()" ) |
1405 | { | 1431 | { |
1406 | showEditTools(); | 1432 | showEditTools(); |
1407 | } | 1433 | } |
1408 | else if ( msg == "home()" ) | 1434 | else if ( msg == "home()" ) |
1409 | { | 1435 | { |
1410 | reader->goHome(); | 1436 | reader->goHome(); |
1411 | } | 1437 | } |
1412 | else if ( msg == "back()" ) | 1438 | else if ( msg == "back()" ) |
1413 | { | 1439 | { |
1414 | reader->goBack(); | 1440 | reader->goBack(); |
1415 | } | 1441 | } |
1416 | else if ( msg == "forward()" ) | 1442 | else if ( msg == "forward()" ) |
1417 | { | 1443 | { |
1418 | reader->goForward(); | 1444 | reader->goForward(); |
1419 | } | 1445 | } |
1420 | else if ( msg == "File/Open(QString)" ) | 1446 | else if ( msg == "File/Open(QString)" ) |
1421 | { | 1447 | { |
1422 | QString info; | 1448 | QString info; |
1423 | stream >> info; | 1449 | stream >> info; |
1424 | openFile( info ); | 1450 | openFile( info ); |
1425 | } | 1451 | } |
1426 | else if ( msg == "File/Info()" ) | 1452 | else if ( msg == "File/Info()" ) |
1427 | { | 1453 | { |
1428 | showinfo(); | 1454 | showinfo(); |
1429 | } | 1455 | } |
1430 | else if ( msg == "File/Action(QString)" ) | 1456 | else if ( msg == "File/Action(QString)" ) |
1431 | { | 1457 | { |
1432 | QString info; | 1458 | QString info; |
1433 | stream >> info; | 1459 | stream >> info; |
1434 | m_spaceTarget = ActNameToInt(info); | 1460 | m_spaceTarget = ActNameToInt(info); |
1435 | } | 1461 | } |
1436 | else if ( msg == "Navigation/Scroll(int)" ) | 1462 | else if ( msg == "Navigation/Scroll(int)" ) |
1437 | { | 1463 | { |
1438 | int info; | 1464 | int info; |
1439 | stream >> info; | 1465 | stream >> info; |
1440 | autoScroll(info); | 1466 | autoScroll(info); |
1441 | } | 1467 | } |
1442 | 1468 | ||
1443 | else if ( msg == "Navigation/GotoStart()" ) | 1469 | else if ( msg == "Navigation/GotoStart()" ) |
1444 | { | 1470 | { |
1445 | gotoStart(); | 1471 | gotoStart(); |
1446 | } | 1472 | } |
1447 | else if ( msg == "Navigation/GotoEnd()" ) | 1473 | else if ( msg == "Navigation/GotoEnd()" ) |
1448 | { | 1474 | { |
1449 | gotoEnd(); | 1475 | gotoEnd(); |
1450 | } | 1476 | } |
1451 | else if ( msg == "Navigation/Jump(int)" ) | 1477 | else if ( msg == "Navigation/Jump(int)" ) |
1452 | { | 1478 | { |
1453 | int info; | 1479 | int info; |
1454 | stream >> info; | 1480 | stream >> info; |
1455 | reader->locate(info); | 1481 | reader->locate(info); |
1456 | } | 1482 | } |
1457 | else if ( msg == "Navigation/Page/LineScroll(int)" ) | 1483 | else if ( msg == "Navigation/Page/LineScroll(int)" ) |
1458 | { | 1484 | { |
1459 | int info; | 1485 | int info; |
1460 | stream >> info; | 1486 | stream >> info; |
1461 | pagemode(info); | 1487 | pagemode(info); |
1462 | } | 1488 | } |
1463 | else if ( msg == "Navigation/SetOverlap(int)" ) | 1489 | else if ( msg == "Navigation/SetOverlap(int)" ) |
1464 | { | 1490 | { |
1465 | int info; | 1491 | int info; |
1466 | stream >> info; | 1492 | stream >> info; |
1467 | reader->m_overlap = info; | 1493 | reader->m_overlap = info; |
1468 | } | 1494 | } |
1469 | else if ( msg == "Navigation/SetMargin(int)" ) | 1495 | else if ( msg == "Navigation/SetMargin(int)" ) |
1470 | { | 1496 | { |
1471 | int info; | 1497 | int info; |
1472 | stream >> info; | 1498 | stream >> info; |
1473 | do_margin(info); | 1499 | do_margin(info); |
1474 | } | 1500 | } |
1475 | else if ( msg == "File/SetDictionary(QString)" ) | 1501 | else if ( msg == "File/SetDictionary(QString)" ) |
1476 | { | 1502 | { |
1477 | QString info; | 1503 | QString info; |
1478 | stream >> info; | 1504 | stream >> info; |
1479 | do_settarget(info); | 1505 | do_settarget(info); |
1480 | } | 1506 | } |
1481 | #ifdef _SCROLLPIPE | 1507 | #ifdef _SCROLLPIPE |
1482 | else if ( msg == "File/SetScrollTarget(QString)" ) | 1508 | else if ( msg == "File/SetScrollTarget(QString)" ) |
1483 | { | 1509 | { |
1484 | QString info; | 1510 | QString info; |
1485 | stream >> info; | 1511 | stream >> info; |
1486 | reader->m_pipetarget = info; | 1512 | reader->m_pipetarget = info; |
1487 | } | 1513 | } |
1488 | #endif | 1514 | #endif |
1489 | else if ( msg == "File/Two/OneTouch(int)" ) | 1515 | else if ( msg == "File/Two/OneTouch(int)" ) |
1490 | { | 1516 | { |
1491 | int info; | 1517 | int info; |
1492 | stream >> info; | 1518 | stream >> info; |
1493 | setTwoTouch(info); | 1519 | setTwoTouch(info); |
1494 | } | 1520 | } |
1495 | else if ( msg == "Target/Annotation(int)" ) | 1521 | else if ( msg == "Target/Annotation(int)" ) |
1496 | { | 1522 | { |
1497 | int info; | 1523 | int info; |
1498 | stream >> info; | 1524 | stream >> info; |
1499 | OnAnnotation(info); | 1525 | OnAnnotation(info); |
1500 | } | 1526 | } |
1501 | else if ( msg == "Target/Dictionary(int)" ) | 1527 | else if ( msg == "Target/Dictionary(int)" ) |
1502 | { | 1528 | { |
1503 | int info; | 1529 | int info; |
1504 | stream >> info; | 1530 | stream >> info; |
1505 | OnDictionary(info); | 1531 | OnDictionary(info); |
1506 | } | 1532 | } |
1507 | else if ( msg == "Target/Clipboard(int)" ) | 1533 | else if ( msg == "Target/Clipboard(int)" ) |
1508 | { | 1534 | { |
1509 | int info; | 1535 | int info; |
1510 | stream >> info; | 1536 | stream >> info; |
1511 | OnClipboard(info); | 1537 | OnClipboard(info); |
1512 | } | 1538 | } |
1513 | else if ( msg == "File/Find(QString)" ) | 1539 | else if ( msg == "File/Find(QString)" ) |
1514 | { | 1540 | { |
1515 | QString info; | 1541 | QString info; |
1516 | stream >> info; | 1542 | stream >> info; |
1517 | QRegExp arg(info); | 1543 | QRegExp arg(info); |
1518 | size_t pos = reader->pagelocate(); | 1544 | size_t pos = reader->pagelocate(); |
1519 | size_t start = pos; | 1545 | size_t start = pos; |
1520 | CDrawBuffer test(&(reader->m_fontControl)); | 1546 | CDrawBuffer test(&(reader->m_fontControl)); |
1521 | reader->getline(&test); | 1547 | reader->getline(&test); |
1522 | while (arg.match(toQString(test.data())) == -1) | 1548 | while (arg.match(toQString(test.data())) == -1) |
1523 | { | 1549 | { |
1524 | pos = reader->locate(); | 1550 | pos = reader->locate(); |
1525 | if (!reader->getline(&test)) | 1551 | if (!reader->getline(&test)) |
1526 | { | 1552 | { |
1527 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); | 1553 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); |
1528 | pos = start; | 1554 | pos = start; |
1529 | break; | 1555 | break; |
1530 | } | 1556 | } |
1531 | } | 1557 | } |
1532 | reader->locate(pos); | 1558 | reader->locate(pos); |
1533 | } | 1559 | } |
1534 | else if ( msg == "File/Fullscreen(int)" ) | 1560 | else if ( msg == "File/Fullscreen(int)" ) |
1535 | { | 1561 | { |
1536 | int info; | 1562 | int info; |
1537 | stream >> info; | 1563 | stream >> info; |
1538 | setfullscreen(info); | 1564 | setfullscreen(info); |
1539 | } | 1565 | } |
1540 | else if ( msg == "File/Continuous(int)" ) | 1566 | else if ( msg == "File/Continuous(int)" ) |
1541 | { | 1567 | { |
1542 | int info; | 1568 | int info; |
1543 | stream >> info; | 1569 | stream >> info; |
1544 | setcontinuous(info); | 1570 | setcontinuous(info); |
1545 | } | 1571 | } |
1546 | else if ( msg == "Markup(QString)" ) | 1572 | else if ( msg == "Markup(QString)" ) |
1547 | { | 1573 | { |
1548 | QString info; | 1574 | QString info; |
1549 | stream >> info; | 1575 | stream >> info; |
1550 | if (info == "Auto") | 1576 | if (info == "Auto") |
1551 | { | 1577 | { |
1552 | autofmt(true); | 1578 | autofmt(true); |
1553 | } | 1579 | } |
1554 | if (info == "None") | 1580 | if (info == "None") |
1555 | { | 1581 | { |
1556 | autofmt(false); | 1582 | autofmt(false); |
1557 | textfmt(false); | 1583 | textfmt(false); |
1558 | striphtml(false); | 1584 | striphtml(false); |
1559 | peanut(false); | 1585 | peanut(false); |
1560 | } | 1586 | } |
1561 | if (info == "Text") | 1587 | if (info == "Text") |
1562 | { | 1588 | { |
1563 | textfmt(true); | 1589 | textfmt(true); |
1564 | } | 1590 | } |
1565 | if (info == "HTML") | 1591 | if (info == "HTML") |
1566 | { | 1592 | { |
1567 | striphtml(true); | 1593 | striphtml(true); |
1568 | } | 1594 | } |
1569 | if (info == "Peanut/PML") | 1595 | if (info == "Peanut/PML") |
1570 | { | 1596 | { |
1571 | peanut(true); | 1597 | peanut(true); |
1572 | } | 1598 | } |
1573 | } | 1599 | } |
1574 | else if ( msg == "Layout/StripCR(int)" ) | 1600 | else if ( msg == "Layout/StripCR(int)" ) |
1575 | { | 1601 | { |
1576 | int info; | 1602 | int info; |
1577 | stream >> info; | 1603 | stream >> info; |
1578 | stripcr(info); | 1604 | stripcr(info); |
1579 | } | 1605 | } |
1580 | else if ( msg == "Layout/Dehyphen(int)" ) | 1606 | else if ( msg == "Layout/Dehyphen(int)" ) |
1581 | { | 1607 | { |
1582 | int info; | 1608 | int info; |
1583 | stream >> info; | 1609 | stream >> info; |
1584 | dehyphen(info); | 1610 | dehyphen(info); |
1585 | } | 1611 | } |
1586 | else if ( msg == "Layout/Depluck(int)" ) | 1612 | else if ( msg == "Layout/Depluck(int)" ) |
1587 | { | 1613 | { |
1588 | int info; | 1614 | int info; |
1589 | stream >> info; | 1615 | stream >> info; |
1590 | depluck(info); | 1616 | depluck(info); |
1591 | } | 1617 | } |
1592 | else if ( msg == "Layout/Dejpluck(int)" ) | 1618 | else if ( msg == "Layout/Dejpluck(int)" ) |
1593 | { | 1619 | { |
1594 | int info; | 1620 | int info; |
1595 | stream >> info; | 1621 | stream >> info; |
1596 | dejpluck(info); | 1622 | dejpluck(info); |
1597 | } | 1623 | } |
1598 | else if ( msg == "Layout/SingleSpace(int)" ) | 1624 | else if ( msg == "Layout/SingleSpace(int)" ) |
1599 | { | 1625 | { |
1600 | int info; | 1626 | int info; |
1601 | stream >> info; | 1627 | stream >> info; |
1602 | onespace(info); | 1628 | onespace(info); |
1603 | } | 1629 | } |
1604 | else if ( msg == "Layout/Repalm(int)" ) | 1630 | else if ( msg == "Layout/Repalm(int)" ) |
1605 | { | 1631 | { |
1606 | int info; | 1632 | int info; |
1607 | stream >> info; | 1633 | stream >> info; |
1608 | repalm(info); | 1634 | repalm(info); |
1609 | } | 1635 | } |
1610 | else if ( msg == "Layout/Unindent(int)" ) | 1636 | else if ( msg == "Layout/Unindent(int)" ) |
1611 | { | 1637 | { |
1612 | int info; | 1638 | int info; |
1613 | stream >> info; | 1639 | stream >> info; |
1614 | unindent(info); | 1640 | unindent(info); |
1615 | } | 1641 | } |
1616 | else if ( msg == "Layout/Re-paragraph(int)" ) | 1642 | else if ( msg == "Layout/Re-paragraph(int)" ) |
1617 | { | 1643 | { |
1618 | int info; | 1644 | int info; |
1619 | stream >> info; | 1645 | stream >> info; |
1620 | repara(info); | 1646 | repara(info); |
1621 | } | 1647 | } |
1622 | else if ( msg == "Layout/DoubleSpace(int)" ) | 1648 | else if ( msg == "Layout/DoubleSpace(int)" ) |
1623 | { | 1649 | { |
1624 | int info; | 1650 | int info; |
1625 | stream >> info; | 1651 | stream >> info; |
1626 | dblspce(info); | 1652 | dblspce(info); |
1627 | } | 1653 | } |
1628 | else if ( msg == "Layout/Indent(int)" ) | 1654 | else if ( msg == "Layout/Indent(int)" ) |
1629 | { | 1655 | { |
1630 | int info; | 1656 | int info; |
1631 | stream >> info; | 1657 | stream >> info; |
1632 | reader->bindenter = info; | 1658 | reader->bindenter = info; |
1633 | reader->setfilter(reader->getfilter()); | 1659 | reader->setfilter(reader->getfilter()); |
1634 | } | 1660 | } |
1635 | else if ( msg == "Layout/Remap(int)" ) | 1661 | else if ( msg == "Layout/Remap(int)" ) |
1636 | { | 1662 | { |
1637 | int info; | 1663 | int info; |
1638 | stream >> info; | 1664 | stream >> info; |
1639 | remap(info); | 1665 | remap(info); |
1640 | } | 1666 | } |
1641 | else if ( msg == "Layout/Embolden(int)" ) | 1667 | else if ( msg == "Layout/Embolden(int)" ) |
1642 | { | 1668 | { |
1643 | int info; | 1669 | int info; |
1644 | stream >> info; | 1670 | stream >> info; |
1645 | embolden(info); | 1671 | embolden(info); |
1646 | } | 1672 | } |
1647 | else if ( msg == "Format/Ideogram/Word(int)" ) | 1673 | else if ( msg == "Format/Ideogram/Word(int)" ) |
1648 | { | 1674 | { |
1649 | int info; | 1675 | int info; |
1650 | stream >> info; | 1676 | stream >> info; |
1651 | monospace(info); | 1677 | monospace(info); |
1652 | } | 1678 | } |
1653 | else if ( msg == "Format/SetWidth(int)" ) | 1679 | else if ( msg == "Format/SetWidth(int)" ) |
1654 | { | 1680 | { |
1655 | int info; | 1681 | int info; |
1656 | stream >> info; | 1682 | stream >> info; |
1657 | reader->m_charpc = info; | 1683 | reader->m_charpc = info; |
1658 | reader->setfont(); | 1684 | reader->setfont(); |
1659 | reader->refresh(); | 1685 | reader->refresh(); |
1660 | } | 1686 | } |
1661 | else if ( msg == "Format/SetFont(QString,int)" ) | 1687 | else if ( msg == "Format/SetFont(QString,int)" ) |
1662 | { | 1688 | { |
1663 | QString fontname; | 1689 | QString fontname; |
1664 | int size; | 1690 | int size; |
1665 | stream >> fontname; | 1691 | stream >> fontname; |
1666 | stream >> size; | 1692 | stream >> size; |
1667 | setfontHelper(fontname, size); | 1693 | setfontHelper(fontname, size); |
1668 | } | 1694 | } |
1669 | else if ( msg == "Marks/Autogen(QString)" ) | 1695 | else if ( msg == "Marks/Autogen(QString)" ) |
1670 | { | 1696 | { |
1671 | QString info; | 1697 | QString info; |
1672 | stream >> info; | 1698 | stream >> info; |
1673 | do_autogen(info); | 1699 | do_autogen(info); |
1674 | } | 1700 | } |
1675 | else if ( msg == "File/StartBlock()" ) | 1701 | else if ( msg == "File/StartBlock()" ) |
1676 | { | 1702 | { |
1677 | editMark(); | 1703 | editMark(); |
1678 | } | 1704 | } |
1679 | else if ( msg == "File/CopyBlock()" ) | 1705 | else if ( msg == "File/CopyBlock()" ) |
1680 | { | 1706 | { |
1681 | editCopy(); | 1707 | editCopy(); |
1682 | } | 1708 | } |
1683 | */ | 1709 | */ |
1684 | #endif | 1710 | #endif |
1685 | } | 1711 | } |
1686 | 1712 | ||
1687 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) | 1713 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) |
1688 | { | 1714 | { |
1689 | for (int i = 0; i < MAX_ACTIONS; i++) | 1715 | for (int i = 0; i < MAX_ACTIONS; i++) |
1690 | { | 1716 | { |
1691 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; | 1717 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; |
1692 | } | 1718 | } |
1693 | return cesAutoScroll; | 1719 | return cesAutoScroll; |
1694 | } | 1720 | } |
1695 | 1721 | ||
1696 | void QTReaderApp::setinverted(bool sfs) | 1722 | void QTReaderApp::setinverted(bool sfs) |
1697 | { | 1723 | { |
1698 | reader->setInverse(sfs); | 1724 | reader->setInverse(sfs); |
1699 | reader->setfilter(reader->getfilter()); | 1725 | reader->setfilter(reader->getfilter()); |
1700 | reader->refresh(); | 1726 | reader->refresh(); |
1701 | } | 1727 | } |
1702 | 1728 | ||
1703 | void QTReaderApp::setrotated(bool sfs) | 1729 | void QTReaderApp::setrotated(bool sfs) |
1704 | { | 1730 | { |
1705 | reader->setrotated(sfs); | 1731 | reader->setrotated(sfs); |
1706 | if (sfs) | 1732 | if (sfs) |
1707 | { | 1733 | { |
1708 | m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::BottomToTop : QBoxLayout::TopToBottom ); | 1734 | m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::BottomToTop : QBoxLayout::TopToBottom ); |
1709 | if (m_scrollbar != NULL) | 1735 | if (m_scrollbar != NULL) |
1710 | { | 1736 | { |
1711 | scrollbar->disconnect(); | 1737 | scrollbar->disconnect(); |
1712 | m_scrollbar->setOrientation(Qt::Horizontal); | 1738 | m_scrollbar->setOrientation(Qt::Horizontal); |
1713 | connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineUp()) ); | 1739 | connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineUp()) ); |
1714 | connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineDown()) ); | 1740 | connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineDown()) ); |
1715 | connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopageup()) ); | 1741 | connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopageup()) ); |
1716 | connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopagedn()) ); | 1742 | connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopagedn()) ); |
1717 | connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); | 1743 | connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); |
1718 | } | 1744 | } |
1719 | //reader->repaint(0, reader->m_left_border, reader->width(), reader->height()-2*reader->m_border); | 1745 | //reader->repaint(0, reader->m_left_border, reader->width(), reader->height()-2*reader->m_border); |
1720 | reader->repaint(); | ||
1721 | } | 1746 | } |
1722 | else | 1747 | else |
1723 | { | 1748 | { |
1724 | m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight ); | 1749 | m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight ); |
1725 | if (m_scrollbar != NULL) | 1750 | if (m_scrollbar != NULL) |
1726 | { | 1751 | { |
1727 | scrollbar->disconnect(); | 1752 | scrollbar->disconnect(); |
1728 | m_scrollbar->setOrientation(Qt::Vertical); | 1753 | m_scrollbar->setOrientation(Qt::Vertical); |
1729 | connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineDown()) ); | 1754 | connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineDown()) ); |
1730 | connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineUp()) ); | 1755 | connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineUp()) ); |
1731 | connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopagedn()) ); | 1756 | connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopagedn()) ); |
1732 | connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopageup()) ); | 1757 | connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopageup()) ); |
1733 | connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); | 1758 | connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); |
1734 | } | 1759 | } |
1735 | //reader->repaint(reader->m_border, 0, reader->width()-2*reader->m_border, reader->height()); | 1760 | //reader->repaint(reader->m_border, 0, reader->width()-2*reader->m_border, reader->height()); |
1736 | reader->repaint(); | ||
1737 | } | 1761 | } |
1738 | // reader->update(); | 1762 | reader->refresh(); |
1739 | } | 1763 | } |
1740 | 1764 | ||
1741 | void QTReaderApp::setgrab(bool sfs) | 1765 | void QTReaderApp::setgrab(bool sfs) |
1742 | { | 1766 | { |
1743 | #ifdef USEQPE | 1767 | #ifdef USEQPE |
1744 | m_grabkeyboard = sfs; | 1768 | m_grabkeyboard = sfs; |
1745 | if (m_grabkeyboard) | 1769 | if (m_grabkeyboard) |
1746 | { | 1770 | { |
1747 | ((QPEApplication*)qApp)->grabKeyboard(); | 1771 | ((QPEApplication*)qApp)->grabKeyboard(); |
1748 | } | 1772 | } |
1749 | else | 1773 | else |
1750 | { | 1774 | { |
1751 | ((QPEApplication*)qApp)->ungrabKeyboard(); | 1775 | ((QPEApplication*)qApp)->ungrabKeyboard(); |
1752 | } | 1776 | } |
1753 | #endif | 1777 | #endif |
1754 | } | 1778 | } |
1755 | 1779 | ||
1756 | void QTReaderApp::setfullscreen(bool sfs) | 1780 | void QTReaderApp::setfullscreen(bool sfs) |
1757 | { | 1781 | { |
1758 | reader->bDoUpdates = false; | 1782 | reader->bDoUpdates = false; |
1759 | m_fullscreen = sfs; | 1783 | m_fullscreen = sfs; |
1760 | showEditTools(); | 1784 | showEditTools(); |
1761 | // qApp->processEvents(); | 1785 | // qApp->processEvents(); |
1762 | reader->bDoUpdates = true; | 1786 | reader->bDoUpdates = true; |
1763 | reader->update(); | 1787 | reader->update(); |
1764 | } | 1788 | } |
1765 | /* | 1789 | /* |
1766 | void QTReaderApp::buttonActionSelected(QAction* _a) | 1790 | void QTReaderApp::buttonActionSelected(QAction* _a) |
1767 | { | 1791 | { |
1768 | //// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); | 1792 | //// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); |
1769 | m_spaceTarget = ActNameToInt(_a->text()); | 1793 | m_spaceTarget = ActNameToInt(_a->text()); |
1770 | } | 1794 | } |
1771 | */ | 1795 | */ |
1772 | QTReaderApp::~QTReaderApp() | 1796 | QTReaderApp::~QTReaderApp() |
1773 | { | 1797 | { |
1774 | } | 1798 | } |
1775 | 1799 | ||
1776 | void QTReaderApp::autoScroll(bool _b) | 1800 | void QTReaderApp::autoScroll(bool _b) |
1777 | { | 1801 | { |
1778 | reader->setautoscroll(_b); | 1802 | reader->setautoscroll(_b); |
1779 | setScrollState(reader->m_autoScroll); | 1803 | setScrollState(reader->m_autoScroll); |
1780 | } | 1804 | } |
1781 | 1805 | ||
1782 | void QTReaderApp::zoomin() | 1806 | void QTReaderApp::zoomin() |
1783 | { | 1807 | { |
1784 | reader->zoomin(); | 1808 | reader->zoomin(); |
1785 | QFont f(reader->m_fontname, reader->m_fontControl.getsize(0)); | 1809 | QFont f(reader->m_fontname, reader->m_fontControl.getsize(0)); |
1786 | m_prog->setFont( f ); | 1810 | m_prog->setFont( f ); |
1787 | } | 1811 | } |
1788 | 1812 | ||
1789 | void QTReaderApp::zoomout() | 1813 | void QTReaderApp::zoomout() |
1790 | { | 1814 | { |
1791 | reader->zoomout(); | 1815 | reader->zoomout(); |
1792 | QFont f(reader->m_fontname, reader->m_fontControl.getsize(0)); | 1816 | QFont f(reader->m_fontname, reader->m_fontControl.getsize(0)); |
1793 | m_prog->setFont( f ); | 1817 | m_prog->setFont( f ); |
1794 | } | 1818 | } |
1795 | 1819 | ||
1796 | void QTReaderApp::clearBkmkList() | 1820 | void QTReaderApp::clearBkmkList() |
1797 | { | 1821 | { |
1798 | delete pBkmklist; | 1822 | delete pBkmklist; |
1799 | reader->pBkmklist = pBkmklist = NULL; | 1823 | reader->pBkmklist = pBkmklist = NULL; |
1800 | m_fBkmksChanged = false; | 1824 | m_fBkmksChanged = false; |
1801 | reader->refresh(true); | 1825 | reader->refresh(true); |
1802 | } | 1826 | } |
1803 | 1827 | ||
1804 | void QTReaderApp::fileClose() | 1828 | void QTReaderApp::fileClose() |
1805 | { | 1829 | { |
1806 | CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); | 1830 | CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); |
1807 | if (cd->exec()) | 1831 | if (cd->exec()) |
1808 | { | 1832 | { |
1809 | if (pOpenlist != NULL) | 1833 | if (pOpenlist != NULL) |
1810 | { | 1834 | { |
1811 | int ind = 0; | 1835 | int ind = 0; |
1812 | Bkmk* p = (*pOpenlist)[ind]; | 1836 | Bkmk* p = (*pOpenlist)[ind]; |
1813 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | 1837 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) |
1814 | { | 1838 | { |
1815 | p = (*pOpenlist)[++ind]; | 1839 | p = (*pOpenlist)[++ind]; |
1816 | } | 1840 | } |
1817 | if (p != NULL) pOpenlist->erase(ind); | 1841 | if (p != NULL) pOpenlist->erase(ind); |
1818 | if (cd->delFile()) | 1842 | if (cd->delFile()) |
1819 | { | 1843 | { |
1820 | unlink((const char*)reader->m_lastfile); | 1844 | unlink((const char*)reader->m_lastfile); |
1821 | } | 1845 | } |
1822 | if (cd->delMarks()) | 1846 | if (cd->delMarks()) |
1823 | { | 1847 | { |
1824 | #ifndef USEQPE | 1848 | #ifndef USEQPE |
1825 | QDir d = QDir::home(); // "/" | 1849 | QDir d = QDir::home(); // "/" |
1826 | d.cd(APPDIR); | 1850 | d.cd(APPDIR); |
1827 | d.remove(reader->m_string); | 1851 | d.remove(reader->m_string); |
1828 | #else /* USEQPE */ | 1852 | #else /* USEQPE */ |
1829 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 1853 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
1830 | #endif /* USEQPE */ | 1854 | #endif /* USEQPE */ |
1831 | } | 1855 | } |
1832 | if (cd->delConfig()) | 1856 | if (cd->delConfig()) |
1833 | { | 1857 | { |
1834 | #ifndef USEQPE | 1858 | #ifndef USEQPE |
1835 | QDir d = QDir::home(); // "/" | 1859 | QDir d = QDir::home(); // "/" |
1836 | d.cd(APPDIR "/configs"); | 1860 | d.cd(APPDIR "/configs"); |
1837 | d.remove(reader->m_string); | 1861 | d.remove(reader->m_string); |
1838 | #else /* USEQPE */ | 1862 | #else /* USEQPE */ |
1839 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); | 1863 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); |
1840 | #endif /* USEQPE */ | 1864 | #endif /* USEQPE */ |
1841 | } | 1865 | } |
1842 | } | 1866 | } |
1843 | 1867 | ||
1844 | fileOpen2(); | 1868 | fileOpen2(); |
1845 | } | 1869 | } |
1846 | delete cd; | 1870 | delete cd; |
1847 | } | 1871 | } |
1848 | 1872 | ||
1849 | void QTReaderApp::updatefileinfo() | 1873 | void QTReaderApp::updatefileinfo() |
1850 | { | 1874 | { |
1851 | if (reader->m_string.isEmpty()) return; | 1875 | if (reader->m_string.isEmpty()) return; |
1852 | if (reader->m_lastfile.isEmpty()) return; | 1876 | if (reader->m_lastfile.isEmpty()) return; |
1853 | tchar* nm = fromQString(reader->m_string); | 1877 | tchar* nm = fromQString(reader->m_string); |
1854 | tchar* fl = fromQString(reader->m_lastfile); | 1878 | tchar* fl = fromQString(reader->m_lastfile); |
1855 | // qDebug("Lastfile:%x", fl); | 1879 | // qDebug("Lastfile:%x", fl); |
1856 | bool notadded = true; | 1880 | bool notadded = true; |
1857 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; | 1881 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; |
1858 | else | 1882 | else |
1859 | { | 1883 | { |
1860 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | 1884 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) |
1861 | { | 1885 | { |
1862 | if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) | 1886 | if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) |
1863 | { | 1887 | { |
1864 | iter->value(reader->pagelocate()); | 1888 | iter->value(reader->pagelocate()); |
1865 | unsigned short dlen; | 1889 | unsigned short dlen; |
1866 | unsigned char* data; | 1890 | unsigned char* data; |
1867 | CFiledata fd(iter->anno()); | 1891 | CFiledata fd(iter->anno()); |
1868 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | 1892 | reader->setSaveData(data, dlen, fd.content(), fd.length()); |
1869 | // qDebug("Filedata(1):%u, %u", fd.length(), dlen); | 1893 | // qDebug("Filedata(1):%u, %u", fd.length(), dlen); |
1870 | // getstate(data, dlen); | 1894 | // getstate(data, dlen); |
1871 | iter->setAnno(data, dlen); | 1895 | iter->setAnno(data, dlen); |
1872 | notadded = false; | 1896 | notadded = false; |
1873 | delete [] data; | 1897 | delete [] data; |
1874 | break; | 1898 | break; |
1875 | } | 1899 | } |
1876 | } | 1900 | } |
1877 | } | 1901 | } |
1878 | // qDebug("Added?:%x", notadded); | 1902 | // qDebug("Added?:%x", notadded); |
1879 | if (notadded) | 1903 | if (notadded) |
1880 | { | 1904 | { |
1881 | struct stat fnstat; | 1905 | struct stat fnstat; |
1882 | stat((const char *)reader->m_lastfile, &fnstat); | 1906 | stat((const char *)reader->m_lastfile, &fnstat); |
1883 | CFiledata fd(fnstat.st_mtime, fl); | 1907 | CFiledata fd(fnstat.st_mtime, fl); |
1884 | unsigned short dlen; | 1908 | unsigned short dlen; |
1885 | unsigned char* data; | 1909 | unsigned char* data; |
1886 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | 1910 | reader->setSaveData(data, dlen, fd.content(), fd.length()); |
1887 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); | 1911 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); |
1888 | //qDebug("Filedata(2):%u, %u", fd.length(), dlen); | 1912 | //qDebug("Filedata(2):%u, %u", fd.length(), dlen); |
1889 | delete [] data; | 1913 | delete [] data; |
1890 | } | 1914 | } |
1891 | delete [] nm; | 1915 | delete [] nm; |
1892 | delete [] fl; | 1916 | delete [] fl; |
1893 | } | 1917 | } |
1894 | 1918 | ||
1895 | void QTReaderApp::fileOpen() | 1919 | void QTReaderApp::fileOpen() |
1896 | { | 1920 | { |
1897 | /* | 1921 | /* |
1898 | menu->hide(); | 1922 | menu->hide(); |
1899 | fileBar->hide(); | 1923 | fileBar->hide(); |
1900 | if (regVisible) regBar->hide(); | 1924 | if (regVisible) regBar->hide(); |
1901 | if (searchVisible) searchBar->hide(); | 1925 | if (searchVisible) searchBar->hide(); |
1902 | */ | 1926 | */ |
1903 | // qDebug("fileOpen"); | 1927 | // qDebug("fileOpen"); |
1904 | // if (!reader->m_lastfile.isEmpty()) | 1928 | // if (!reader->m_lastfile.isEmpty()) |
1905 | updatefileinfo(); | 1929 | updatefileinfo(); |
1906 | fileOpen2(); | 1930 | fileOpen2(); |
1907 | } | 1931 | } |
1908 | 1932 | ||
1909 | void QTReaderApp::fileOpen2() | 1933 | void QTReaderApp::fileOpen2() |
1910 | { | 1934 | { |
1911 | if (pBkmklist != NULL) | 1935 | if (pBkmklist != NULL) |
1912 | { | 1936 | { |
1913 | if (m_fBkmksChanged) | 1937 | if (m_fBkmksChanged) |
1914 | { | 1938 | { |
1915 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | 1939 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
1916 | savebkmks(); | 1940 | savebkmks(); |
1917 | } | 1941 | } |
1918 | delete pBkmklist; | 1942 | delete pBkmklist; |
1919 | reader->pBkmklist = pBkmklist = NULL; | 1943 | reader->pBkmklist = pBkmklist = NULL; |
1920 | m_fBkmksChanged = false; | 1944 | m_fBkmksChanged = false; |
1921 | } | 1945 | } |
1922 | reader->disableAutoscroll(); | 1946 | reader->disableAutoscroll(); |
1923 | /* | 1947 | /* |
1924 | editorStack->raiseWidget( fileSelector ); | 1948 | editorStack->raiseWidget( fileSelector ); |
1925 | fileSelector->reread(); | 1949 | fileSelector->reread(); |
1926 | */ | 1950 | */ |
1927 | bool usebrowser = true; | 1951 | bool usebrowser = true; |
1928 | if (pOpenlist != NULL) | 1952 | if (pOpenlist != NULL) |
1929 | { | 1953 | { |
1930 | m_nBkmkAction = cOpenFile; | 1954 | m_nBkmkAction = cOpenFile; |
1931 | if (listbkmk(pOpenlist, "Browse")) usebrowser = false; | 1955 | if (listbkmk(pOpenlist, "Browse", true)) usebrowser = false; |
1932 | } | 1956 | } |
1933 | if (usebrowser) | 1957 | if (usebrowser) |
1934 | { | 1958 | { |
1935 | QString fn = usefilebrowser(); | 1959 | QString fn = usefilebrowser(); |
1936 | //qApp->processEvents(); | 1960 | //qApp->processEvents(); |
1937 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 1961 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
1938 | { | 1962 | { |
1939 | openFile(fn); | 1963 | openFile(fn); |
1940 | } | 1964 | } |
1941 | reader->setFocus(); | 1965 | reader->setFocus(); |
1942 | } | 1966 | } |
1943 | // reader->refresh(); | 1967 | // reader->refresh(); |
1944 | // qDebug("HEIGHT:%d", reader->m_lastheight); | 1968 | // qDebug("HEIGHT:%d", reader->m_lastheight); |
1945 | } | 1969 | } |
1946 | 1970 | ||
1947 | QString QTReaderApp::usefilebrowser() | 1971 | QString QTReaderApp::usefilebrowser() |
1948 | { | 1972 | { |
1949 | #ifndef USEQPE | 1973 | #ifndef USEQPE |
1950 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); | 1974 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); |
1951 | return s; | 1975 | return s; |
1952 | #else | 1976 | #else |
1953 | QString fn; | 1977 | QString fn; |
1954 | #ifdef OPIE | 1978 | #if defined(OPIE) && defined(OPIEFILEDIALOG) |
1955 | QMap<QString, QStringList> mimeTypes; | 1979 | QMap<QString, QStringList> mimeTypes; |
1956 | QStringList etypes; | 1980 | QStringList etypes; |
1957 | etypes << "etext/*"; | 1981 | etypes << "etext/*"; |
1958 | mimeTypes.insert( tr("eText"), etypes ); | 1982 | mimeTypes.insert( tr("eText"), etypes ); |
1959 | QStringList types; | 1983 | QStringList types; |
1960 | types << "text/*"; | 1984 | types << "text/*"; |
1961 | mimeTypes.insert( tr("Text"), types ); | 1985 | mimeTypes.insert( tr("Text"), types ); |
1962 | mimeTypes.insert( tr("All"), "*/*" ); | 1986 | mimeTypes.insert( tr("All"), "*/*" ); |
1963 | fn = OFileDialog::getOpenFileName(OFileSelector::EXTENDED_ALL, QFileInfo(reader->m_lastfile).dirPath(true), QString::null, mimeTypes, 0, "OpieReader"); | 1987 | fn = OFileDialog::getOpenFileName(OFileSelector::EXTENDED_ALL, QFileInfo(reader->m_lastfile).dirPath(true), QString::null, mimeTypes, 0, "OpieReader"); |
1964 | #else | 1988 | #else |
1965 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, | 1989 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, |
1966 | 0, | 1990 | 0, |
1967 | // WStyle_Customize | WStyle_NoBorderEx, | 1991 | // WStyle_Customize | WStyle_NoBorderEx, |
1968 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); | 1992 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); |
1969 | 1993 | ||
1970 | 1994 | ||
1971 | if (fb->exec()) | 1995 | if (fb->exec()) |
1972 | { | 1996 | { |
1973 | fn = fb->getCurrentFile(); | 1997 | fn = fb->getCurrentFile(); |
1974 | } | 1998 | } |
1975 | // qDebug("Selected %s", (const char*)fn); | 1999 | // qDebug("Selected %s", (const char*)fn); |
1976 | delete fb; | 2000 | delete fb; |
1977 | #endif | 2001 | #endif |
1978 | showEditTools(); | 2002 | showEditTools(); |
1979 | return fn; | 2003 | return fn; |
1980 | #endif | 2004 | #endif |
1981 | } | 2005 | } |
1982 | 2006 | ||
1983 | void QTReaderApp::showgraphic(QImage& pm) | 2007 | void QTReaderApp::showgraphic(QImage& pm) |
1984 | { | 2008 | { |
1985 | m_graphicwin->setImage(pm); | 2009 | m_graphicwin->setImage(pm); |
1986 | editorStack->raiseWidget( m_graphicwin ); | 2010 | editorStack->raiseWidget( m_graphicwin ); |
1987 | hidetoolbars(); | 2011 | hidetoolbars(); |
1988 | m_graphicwin->setFocus(); | 2012 | m_graphicwin->setFocus(); |
1989 | } | 2013 | } |
1990 | 2014 | ||
1991 | void QTReaderApp::showbuttonprefs() | 2015 | void QTReaderApp::showbuttonprefs() |
1992 | { | 2016 | { |
1993 | editorStack->raiseWidget( m_buttonprefs ); | 2017 | editorStack->raiseWidget( m_buttonprefs ); |
1994 | hidetoolbars(); | 2018 | hidetoolbars(); |
1995 | m_buttonprefs->setFocus(); | 2019 | m_buttonprefs->setFocus(); |
1996 | m_kmapchanged = true; | 2020 | m_kmapchanged = true; |
1997 | } | 2021 | } |
1998 | 2022 | ||
1999 | void QTReaderApp::showprefs() | 2023 | void QTReaderApp::showprefs() |
2000 | { | 2024 | { |
2001 | CPrefs* prefwin = new CPrefs(reader->width(), !m_bFloatingDialog, this); | 2025 | CPrefs* prefwin = new CPrefs(reader->width(), !m_bFloatingDialog, this); |
2002 | 2026 | ||
2003 | // prefwin->Debounce(m_debounce); | 2027 | // prefwin->Debounce(m_debounce); |
2004 | prefwin->bgtype(m_bgtype); | 2028 | prefwin->bgtype(m_bgtype); |
2005 | prefwin->repalm(reader->brepalm); | 2029 | prefwin->repalm(reader->brepalm); |
2030 | prefwin->UnderlineLink(reader->bunderlineLink); | ||
2006 | prefwin->kern(reader->bkern); | 2031 | prefwin->kern(reader->bkern); |
2007 | prefwin->hyphenate(reader->hyphenate); | 2032 | prefwin->hyphenate(reader->hyphenate); |
2008 | // prefwin->customhyphen(reader->buffdoc.getCustomHyphen()); | 2033 | // prefwin->customhyphen(reader->buffdoc.getCustomHyphen()); |
2009 | prefwin->scrolltype(reader->m_scrolltype); | 2034 | prefwin->scrolltype(reader->m_scrolltype); |
2010 | prefwin->scrollstep(reader->m_scrollstep); | 2035 | prefwin->scrollstep(reader->m_scrollstep); |
2011 | prefwin->scrollcolor(m_scrollcolor); | 2036 | prefwin->scrollcolor(m_scrollcolor); |
2012 | prefwin->minibarcol(m_scrollbarcolor); | 2037 | prefwin->minibarcol(m_scrollbarcolor); |
2013 | prefwin->foreground(m_foreground); | 2038 | prefwin->foreground(m_foreground); |
2014 | prefwin->background(m_background); | 2039 | prefwin->background(m_background); |
2015 | prefwin->twotouch(m_twoTouch); | 2040 | prefwin->twotouch(m_twoTouch); |
2016 | prefwin->propfontchange(m_propogatefontchange); | 2041 | prefwin->propfontchange(m_propogatefontchange); |
2017 | prefwin->StripCR(reader->bstripcr); | 2042 | prefwin->StripCR(reader->bstripcr); |
2043 | prefwin->InlineTables(!reader->bNoInlineTables); | ||
2018 | prefwin->Dehyphen(reader->bdehyphen); | 2044 | prefwin->Dehyphen(reader->bdehyphen); |
2019 | prefwin->SingleSpace(reader->bonespace); | 2045 | prefwin->SingleSpace(reader->bonespace); |
2020 | prefwin->Unindent(reader->bunindent); | 2046 | prefwin->Unindent(reader->bunindent); |
2021 | prefwin->Reparagraph(reader->brepara); | 2047 | prefwin->Reparagraph(reader->brepara); |
2022 | prefwin->DoubleSpace(reader->bdblspce); | 2048 | prefwin->DoubleSpace(reader->bdblspce); |
2023 | prefwin->Remap(reader->bremap); | 2049 | prefwin->Remap(reader->bremap); |
2024 | prefwin->Embolden(reader->bmakebold); | 2050 | prefwin->Embolden(reader->bmakebold); |
2025 | prefwin->FullJustify(reader->bfulljust); | 2051 | prefwin->FullJustify(reader->bfulljust); |
2026 | // prefwin->Inverse(reader->bInverse); | 2052 | // prefwin->Inverse(reader->bInverse); |
2027 | // prefwin->Negative(reader->bNegative); | 2053 | // prefwin->Negative(reader->bNegative); |
2028 | prefwin->FixGraphics(reader->m_fontControl.FixGraphics()); | 2054 | prefwin->FixGraphics(reader->m_fontControl.FixGraphics()); |
2029 | prefwin->ParaLead(reader->getextraspace()); | 2055 | prefwin->ParaLead(reader->getextraspace()); |
2030 | prefwin->LineLead(reader->getlead()); | 2056 | prefwin->LineLead(reader->getlead()); |
2031 | prefwin->TopMargin(reader->m_abstopmargin); | 2057 | prefwin->TopMargin(reader->m_abstopmargin); |
2032 | prefwin->BottomMargin(reader->m_absbottommargin); | 2058 | prefwin->BottomMargin(reader->m_absbottommargin); |
2033 | prefwin->LeftMargin(reader->m_absleft_border); | 2059 | prefwin->LeftMargin(reader->m_absleft_border); |
2034 | prefwin->RightMargin(reader->m_absright_border); | 2060 | prefwin->RightMargin(reader->m_absright_border); |
2035 | prefwin->Indent(reader->bindenter); | 2061 | prefwin->Indent(reader->bindenter); |
2036 | if (reader->bautofmt) | 2062 | if (reader->bautofmt) |
2037 | { | 2063 | { |
2038 | prefwin->Markup(0); | 2064 | prefwin->Markup(0); |
2039 | } | 2065 | } |
2040 | else if (reader->btextfmt) | 2066 | else if (reader->btextfmt) |
2041 | { | 2067 | { |
2042 | prefwin->Markup(2); | 2068 | prefwin->Markup(2); |
2043 | } | 2069 | } |
2044 | else if (reader->bstriphtml) | 2070 | else if (reader->bstriphtml) |
2045 | { | 2071 | { |
2046 | prefwin->Markup(3); | 2072 | prefwin->Markup(3); |
2047 | } | 2073 | } |
2048 | else if (reader->bpeanut) | 2074 | else if (reader->bpeanut) |
2049 | { | 2075 | { |
2050 | prefwin->Markup(4); | 2076 | prefwin->Markup(4); |
2051 | } | 2077 | } |
2052 | else | 2078 | else |
2053 | { | 2079 | { |
2054 | prefwin->Markup(1); | 2080 | prefwin->Markup(1); |
2055 | } | 2081 | } |
2056 | prefwin->Depluck(reader->bdepluck); | 2082 | prefwin->Depluck(reader->bdepluck); |
2057 | prefwin->Dejpluck(reader->bdejpluck); | 2083 | prefwin->Dejpluck(reader->bdejpluck); |
2058 | prefwin->Continuous(reader->m_continuousDocument); | 2084 | prefwin->Continuous(reader->m_continuousDocument); |
2085 | prefwin->DoubleBuffer(reader->m_doubleBuffered); | ||
2059 | 2086 | ||
2060 | prefwin->dictApplication(m_targetapp); | 2087 | prefwin->dictApplication(m_targetapp); |
2061 | prefwin->dictMessage(m_targetmsg); | 2088 | prefwin->dictMessage(m_targetmsg); |
2062 | 2089 | ||
2063 | /* | 2090 | /* |
2064 | prefwin->leftScroll(m_leftScroll); | 2091 | prefwin->leftScroll(m_leftScroll); |
2065 | prefwin->rightScroll(m_rightScroll); | 2092 | prefwin->rightScroll(m_rightScroll); |
2066 | prefwin->upScroll(m_upScroll); | 2093 | prefwin->upScroll(m_upScroll); |
2067 | prefwin->downScroll(m_downScroll); | 2094 | prefwin->downScroll(m_downScroll); |
2068 | */ | 2095 | */ |
2069 | 2096 | ||
2070 | prefwin->miscannotation(m_doAnnotation); | 2097 | prefwin->miscannotation(m_doAnnotation); |
2071 | prefwin->miscdictionary(m_doDictionary); | 2098 | prefwin->miscdictionary(m_doDictionary); |
2072 | prefwin->miscclipboard(m_doClipboard); | 2099 | prefwin->miscclipboard(m_doClipboard); |
2100 | prefwin->miscoutput(m_doOutput); | ||
2073 | 2101 | ||
2074 | prefwin->SwapMouse(reader->m_swapmouse); | 2102 | prefwin->SwapMouse(reader->m_swapmouse); |
2075 | 2103 | ||
2076 | prefwin->Font(reader->m_fontname); | 2104 | prefwin->Font(reader->m_fontname); |
2077 | 2105 | ||
2078 | prefwin->gfxsize(reader->getBaseSize()); | 2106 | prefwin->gfxsize(reader->getBaseSize()); |
2079 | 2107 | ||
2080 | prefwin->pageoverlap(reader->m_overlap); | 2108 | prefwin->pageoverlap(reader->m_overlap); |
2081 | 2109 | ||
2082 | prefwin->ideogram(reader->m_bMonoSpaced); | 2110 | prefwin->ideogram(reader->m_bMonoSpaced); |
2083 | 2111 | ||
2084 | prefwin->encoding(reader->m_encd); | 2112 | prefwin->encoding(reader->m_encd); |
2085 | 2113 | ||
2086 | prefwin->ideogramwidth(reader->m_charpc); | 2114 | prefwin->ideogramwidth(reader->m_charpc); |
2087 | 2115 | ||
2116 | prefwin->outcodec(reader->m_outputName); | ||
2117 | |||
2088 | if (prefwin->exec()) | 2118 | if (prefwin->exec()) |
2089 | { | 2119 | { |
2090 | // m_debounce = prefwin->Debounce(); | 2120 | // m_debounce = prefwin->Debounce(); |
2091 | reader->brepalm = prefwin->repalm(); | 2121 | reader->brepalm = prefwin->repalm(); |
2122 | reader->bunderlineLink = prefwin->UnderlineLink(); | ||
2123 | |||
2092 | reader->bkern = prefwin->kern(); | 2124 | reader->bkern = prefwin->kern(); |
2093 | reader->hyphenate = prefwin->hyphenate(); | 2125 | reader->hyphenate = prefwin->hyphenate(); |
2094 | // reader->buffdoc.setCustomHyphen(prefwin->customhyphen()); | 2126 | // reader->buffdoc.setCustomHyphen(prefwin->customhyphen()); |
2095 | reader->m_scrolltype = prefwin->scrolltype(); | 2127 | reader->m_scrolltype = prefwin->scrolltype(); |
2096 | reader->m_scrollstep = prefwin->scrollstep(); | 2128 | reader->m_scrollstep = prefwin->scrollstep(); |
2097 | m_scrollcolor = prefwin->scrollcolor(); | 2129 | m_scrollcolor = prefwin->scrollcolor(); |
2098 | setscrollcolour(); | 2130 | setscrollcolour(); |
2099 | m_scrollbarcolor = prefwin->minibarcol(); | 2131 | m_scrollbarcolor = prefwin->minibarcol(); |
2100 | setscrollbarcolour(); | 2132 | setscrollbarcolour(); |
2101 | m_foreground = prefwin->foreground(); | 2133 | m_foreground = prefwin->foreground(); |
2102 | reader->setForeground(getcolour(m_foreground)); | 2134 | reader->setForeground(getcolour(m_foreground)); |
2103 | m_background = prefwin->background(); | 2135 | m_background = prefwin->background(); |
2104 | reader->setBackground(getcolour(m_background)); | 2136 | reader->setBackground(getcolour(m_background)); |
2105 | m_twoTouch = prefwin->twotouch(); | 2137 | m_twoTouch = prefwin->twotouch(); |
2106 | reader->setTwoTouch(m_twoTouch); | 2138 | reader->setTwoTouch(m_twoTouch); |
2107 | m_touch_action->setOn(m_twoTouch); | 2139 | m_touch_action->setOn(m_twoTouch); |
2108 | 2140 | ||
2109 | reader->bstripcr = prefwin->StripCR(); | 2141 | reader->bstripcr = prefwin->StripCR(); |
2142 | reader->bNoInlineTables = !prefwin->InlineTables(); | ||
2110 | reader->bdehyphen = prefwin->Dehyphen(); | 2143 | reader->bdehyphen = prefwin->Dehyphen(); |
2111 | reader->bonespace = prefwin->SingleSpace(); | 2144 | reader->bonespace = prefwin->SingleSpace(); |
2112 | reader->bunindent = prefwin->Unindent(); | 2145 | reader->bunindent = prefwin->Unindent(); |
2113 | reader->brepara = prefwin->Reparagraph(); | 2146 | reader->brepara = prefwin->Reparagraph(); |
2114 | reader->bdblspce = prefwin->DoubleSpace(); | 2147 | reader->bdblspce = prefwin->DoubleSpace(); |
2115 | reader->bremap = prefwin->Remap(); | 2148 | reader->bremap = prefwin->Remap(); |
2116 | reader->bmakebold = prefwin->Embolden(); | 2149 | reader->bmakebold = prefwin->Embolden(); |
2117 | reader->bfulljust = prefwin->FullJustify(); | 2150 | reader->bfulljust = prefwin->FullJustify(); |
2118 | //if (reader->bInverse != prefwin->Inverse()) reader->setInverse(prefwin->Inverse()); | 2151 | //if (reader->bInverse != prefwin->Inverse()) reader->setInverse(prefwin->Inverse()); |
2119 | //if (reader->bNegative != prefwin->Negative()) reader->setNegative(); | 2152 | //if (reader->bNegative != prefwin->Negative()) reader->setNegative(); |
2120 | reader->m_fontControl.FixGraphics(prefwin->FixGraphics()); | 2153 | reader->m_fontControl.FixGraphics(prefwin->FixGraphics()); |
2121 | 2154 | ||
2122 | reader->setextraspace(prefwin->ParaLead()); | 2155 | reader->setextraspace(prefwin->ParaLead()); |
2123 | reader->setlead(prefwin->LineLead()); | 2156 | reader->setlead(prefwin->LineLead()); |
2124 | reader->m_abstopmargin = prefwin->TopMargin(); | 2157 | reader->m_abstopmargin = prefwin->TopMargin(); |
2125 | reader->m_absbottommargin = prefwin->BottomMargin(); | 2158 | reader->m_absbottommargin = prefwin->BottomMargin(); |
2126 | reader->m_absleft_border = prefwin->LeftMargin(); | 2159 | reader->m_absleft_border = prefwin->LeftMargin(); |
2127 | reader->m_absright_border = prefwin->RightMargin(); | 2160 | reader->m_absright_border = prefwin->RightMargin(); |
2128 | reader->bindenter = prefwin->Indent(); | 2161 | reader->bindenter = prefwin->Indent(); |
2129 | reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; | 2162 | reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; |
2130 | switch (prefwin->Markup()) | 2163 | switch (prefwin->Markup()) |
2131 | { | 2164 | { |
2132 | case 0: | 2165 | case 0: |
2133 | reader->bautofmt = true; | 2166 | reader->bautofmt = true; |
2134 | break; | 2167 | break; |
2135 | case 1: | 2168 | case 1: |
2136 | break; | 2169 | break; |
2137 | case 2: | 2170 | case 2: |
2138 | reader->btextfmt = true; | 2171 | reader->btextfmt = true; |
2139 | break; | 2172 | break; |
2140 | case 3: | 2173 | case 3: |
2141 | reader->bstriphtml = true; | 2174 | reader->bstriphtml = true; |
2142 | break; | 2175 | break; |
2143 | case 4: | 2176 | case 4: |
2144 | reader->bpeanut = true; | 2177 | reader->bpeanut = true; |
2145 | break; | 2178 | break; |
2146 | default: | 2179 | default: |
2147 | qDebug("Format out of range"); | 2180 | qDebug("Format out of range"); |
2148 | } | 2181 | } |
2149 | reader->bdepluck = prefwin->Depluck(); | 2182 | reader->bdepluck = prefwin->Depluck(); |
2150 | reader->bdejpluck = prefwin->Dejpluck(); | 2183 | reader->bdejpluck = prefwin->Dejpluck(); |
2151 | reader->setContinuous(prefwin->Continuous()); | 2184 | reader->setContinuous(prefwin->Continuous()); |
2185 | reader->setDoubleBuffer(prefwin->DoubleBuffer()); | ||
2152 | 2186 | ||
2153 | /* | 2187 | /* |
2154 | m_leftScroll = prefwin->leftScroll(); | 2188 | m_leftScroll = prefwin->leftScroll(); |
2155 | m_rightScroll = prefwin->rightScroll(); | 2189 | m_rightScroll = prefwin->rightScroll(); |
2156 | m_upScroll = prefwin->upScroll(); | 2190 | m_upScroll = prefwin->upScroll(); |
2157 | m_downScroll = prefwin->downScroll(); | 2191 | m_downScroll = prefwin->downScroll(); |
2158 | */ | 2192 | */ |
2159 | m_targetapp = prefwin->dictApplication(); | 2193 | m_targetapp = prefwin->dictApplication(); |
2160 | m_targetmsg = prefwin->dictMessage(); | 2194 | m_targetmsg = prefwin->dictMessage(); |
2161 | 2195 | ||
2162 | m_doAnnotation = prefwin->miscannotation(); | 2196 | m_doAnnotation = prefwin->miscannotation(); |
2163 | m_doDictionary = prefwin->miscdictionary(); | 2197 | m_doDictionary = prefwin->miscdictionary(); |
2164 | m_doClipboard = prefwin->miscclipboard(); | 2198 | m_doClipboard = prefwin->miscclipboard(); |
2199 | m_doOutput = prefwin->miscoutput(); | ||
2165 | reader->m_swapmouse = prefwin->SwapMouse(); | 2200 | reader->m_swapmouse = prefwin->SwapMouse(); |
2166 | reader->setBaseSize(prefwin->gfxsize()); | 2201 | reader->setBaseSize(prefwin->gfxsize()); |
2167 | reader->m_overlap = prefwin->pageoverlap(); | 2202 | reader->m_overlap = prefwin->pageoverlap(); |
2168 | reader->m_bMonoSpaced = prefwin->ideogram(); | 2203 | reader->m_bMonoSpaced = prefwin->ideogram(); |
2169 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 2204 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
2170 | reader->m_encd = prefwin->encoding(); | 2205 | reader->m_encd = prefwin->encoding(); |
2171 | reader->m_charpc = prefwin->ideogramwidth(); | 2206 | reader->m_charpc = prefwin->ideogramwidth(); |
2172 | 2207 | ||
2173 | if ( | 2208 | if ( |
2174 | reader->m_fontname != prefwin->Font() | 2209 | reader->m_fontname != prefwin->Font() |
2175 | || | 2210 | || |
2176 | m_propogatefontchange != prefwin->propfontchange()) | 2211 | m_propogatefontchange != prefwin->propfontchange()) |
2177 | { | 2212 | { |
2178 | m_propogatefontchange = prefwin->propfontchange(); | 2213 | m_propogatefontchange = prefwin->propfontchange(); |
2179 | setfontHelper(prefwin->Font()); | 2214 | setfontHelper(prefwin->Font()); |
2180 | } | 2215 | } |
2181 | if (m_bgtype != (bground)prefwin->bgtype()) | 2216 | if (m_bgtype != (bground)prefwin->bgtype()) |
2182 | { | 2217 | { |
2183 | m_bgtype = (bground)prefwin->bgtype(); | 2218 | m_bgtype = (bground)prefwin->bgtype(); |
2184 | setBackgroundBitmap(); | 2219 | setBackgroundBitmap(); |
2185 | } | 2220 | } |
2221 | qDebug("OutCodec:%s", (const char*)prefwin->outcodec()); | ||
2222 | if (reader->m_outputName != prefwin->outcodec()) | ||
2223 | { | ||
2224 | if (reader->m_output != NULL) | ||
2225 | { | ||
2226 | QMessageBox::warning(this, PROGNAME, "Change of output codec\nrequires a restart"); | ||
2227 | } | ||
2228 | reader->m_outputName = prefwin->outcodec(); | ||
2229 | } | ||
2186 | delete prefwin; | 2230 | delete prefwin; |
2187 | reader->setfilter(reader->getfilter()); | 2231 | reader->setfilter(reader->getfilter()); |
2188 | reader->refresh(); | 2232 | reader->refresh(); |
2189 | } | 2233 | } |
2190 | else | 2234 | else |
2191 | { | 2235 | { |
2192 | delete prefwin; | 2236 | delete prefwin; |
2193 | } | 2237 | } |
2194 | } | 2238 | } |
2195 | 2239 | ||
2196 | void QTReaderApp::showtoolbarprefs() | 2240 | void QTReaderApp::showtoolbarprefs() |
2197 | { | 2241 | { |
2198 | #ifdef USEQPE | 2242 | #ifdef USEQPE |
2199 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); | 2243 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); |
2200 | #else | 2244 | #else |
2201 | QFileInfo fi; | 2245 | QFileInfo fi; |
2202 | QDir d = QDir::home(); // "/" | 2246 | QDir d = QDir::home(); // "/" |
2203 | if ( !d.cd(APPDIR) ) | 2247 | if ( !d.cd(APPDIR) ) |
2204 | { // "/tmp" | 2248 | { // "/tmp" |
2205 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | 2249 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
2206 | d = QDir::home(); | 2250 | d = QDir::home(); |
2207 | d.mkdir(APPDIR); | 2251 | d.mkdir(APPDIR); |
2208 | d.cd(APPDIR); | 2252 | d.cd(APPDIR); |
2209 | } | 2253 | } |
2210 | fi.setFile(d, INIFILE); | 2254 | fi.setFile(d, INIFILE); |
2211 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); | 2255 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); |
2212 | #endif | 2256 | #endif |
2213 | prefwin->tbpolicy(m_tbpolsave); | 2257 | prefwin->tbpolicy(m_tbpolsave); |
2214 | prefwin->tbposition(m_tbposition-2); | 2258 | prefwin->tbposition(m_tbposition-2); |
2215 | prefwin->tbmovable(m_tbmovesave); | 2259 | prefwin->tbmovable(m_tbmovesave); |
2216 | prefwin->floating(m_bFloatingDialog); | 2260 | prefwin->floating(m_bFloatingDialog); |
2217 | prefwin->qtscroll(m_qtscroll); | 2261 | prefwin->qtscroll(m_qtscroll); |
2218 | prefwin->localscroll(m_localscroll); | 2262 | prefwin->localscroll(m_localscroll); |
2219 | if (prefwin->exec()) | 2263 | if (prefwin->exec()) |
2220 | { | 2264 | { |
2221 | m_bFloatingDialog = prefwin->floating(); | 2265 | m_bFloatingDialog = prefwin->floating(); |
2222 | if ( | 2266 | if ( |
2223 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() | 2267 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() |
2224 | || | 2268 | || |
2225 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) | 2269 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) |
2226 | || | 2270 | || |
2227 | m_tbmovesave != prefwin->tbmovable() | 2271 | m_tbmovesave != prefwin->tbmovable() |
2228 | || | 2272 | || |
2229 | m_qtscroll != prefwin->qtscroll() | 2273 | m_qtscroll != prefwin->qtscroll() |
2230 | // || | 2274 | // || |
2231 | // m_localscrollbar != prefwin->scrollonleft() | 2275 | // m_localscrollbar != prefwin->scrollonleft() |
2232 | ) | 2276 | ) |
2233 | { | 2277 | { |
2234 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); | 2278 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); |
2235 | } | 2279 | } |
2236 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); | 2280 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); |
2237 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); | 2281 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); |
2238 | m_tbmovesave = prefwin->tbmovable(); | 2282 | m_tbmovesave = prefwin->tbmovable(); |
2239 | reader->m_scrollpos = m_localscroll = prefwin->localscroll(); | 2283 | reader->m_scrollpos = m_localscroll = prefwin->localscroll(); |
2240 | if (m_qtscroll != prefwin->qtscroll()) | 2284 | if (m_qtscroll != prefwin->qtscroll()) |
2241 | { | 2285 | { |
2242 | m_qtscroll = prefwin->qtscroll(); | 2286 | m_qtscroll = prefwin->qtscroll(); |
2243 | setrotated(reader->m_rotated); | 2287 | setrotated(reader->m_rotated); |
2244 | } | 2288 | } |
2245 | if (m_scrollbar == NULL || m_scrollbar->isHidden()) | 2289 | if (m_scrollbar == NULL || m_scrollbar->isHidden()) |
2246 | { | 2290 | { |
2247 | reader->m_scrollpos = m_localscroll; | 2291 | reader->m_scrollpos = m_localscroll; |
2248 | } | 2292 | } |
2249 | else | 2293 | else |
2250 | { | 2294 | { |
2251 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; | 2295 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; |
2252 | } | 2296 | } |
2253 | bool isChanged = prefwin->isChanged(); | 2297 | bool isChanged = prefwin->isChanged(); |
2254 | delete prefwin; | 2298 | delete prefwin; |
2255 | #ifdef USEQPE | 2299 | #ifdef USEQPE |
2256 | Config config( APPDIR ); | 2300 | Config config( APPDIR ); |
2257 | #else | 2301 | #else |
2258 | QFileInfo fi; | 2302 | QFileInfo fi; |
2259 | QDir d = QDir::home(); // "/" | 2303 | QDir d = QDir::home(); // "/" |
2260 | if ( !d.cd(APPDIR) ) | 2304 | if ( !d.cd(APPDIR) ) |
2261 | { // "/tmp" | 2305 | { // "/tmp" |
2262 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | 2306 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
2263 | d = QDir::home(); | 2307 | d = QDir::home(); |
2264 | d.mkdir(APPDIR); | 2308 | d.mkdir(APPDIR); |
2265 | d.cd(APPDIR); | 2309 | d.cd(APPDIR); |
2266 | } | 2310 | } |
2267 | fi.setFile(d, INIFILE); | 2311 | fi.setFile(d, INIFILE); |
2268 | Config config( fi.absFilePath() ); | 2312 | Config config( fi.absFilePath() ); |
2269 | #endif | 2313 | #endif |
2270 | if (isChanged) addtoolbars(&config); | 2314 | if (isChanged) addtoolbars(&config); |
2271 | } | 2315 | } |
2272 | else | 2316 | else |
2273 | { | 2317 | { |
2274 | delete prefwin; | 2318 | delete prefwin; |
2275 | } | 2319 | } |
2276 | } | 2320 | } |
2277 | 2321 | ||
2278 | void QTReaderApp::showinfo() | 2322 | void QTReaderApp::showinfo() |
2279 | { | 2323 | { |
2280 | unsigned long ds, fs, ts, pl, dl; | 2324 | unsigned long ds, fs, ts, pl, dl; |
2281 | if (reader->empty()) | 2325 | if (reader->empty()) |
2282 | { | 2326 | { |
2283 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 2327 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
2284 | } | 2328 | } |
2285 | else | 2329 | else |
2286 | { | 2330 | { |
2287 | reader->sizes(fs,ts); | 2331 | reader->sizes(fs,ts); |
2288 | ds = reader->buffdoc.endSection() - reader->buffdoc.startSection(); | 2332 | ds = reader->buffdoc.endSection() - reader->buffdoc.startSection(); |
2289 | pl = reader->pagelocate(); | 2333 | pl = reader->pagelocate(); |
2290 | dl = pl - reader->buffdoc.startSection(); | 2334 | dl = pl - reader->buffdoc.startSection(); |
2291 | m_infoWin->setFileSize(fs); | 2335 | m_infoWin->setFileSize(fs); |
2292 | m_infoWin->setTextSize(ts); | 2336 | m_infoWin->setTextSize(ts); |
2293 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); | 2337 | if (fs > UINT_MAX/100) |
2338 | { | ||
2339 | unsigned long t1 = (ts+50)/100; | ||
2340 | m_infoWin->setRatio(100-(fs + (t1 >> 1))/t1); | ||
2341 | } | ||
2342 | else | ||
2343 | { | ||
2344 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); | ||
2345 | } | ||
2294 | m_infoWin->setLocation(pl); | 2346 | m_infoWin->setLocation(pl); |
2295 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); | 2347 | if (pl > UINT_MAX/100) |
2348 | { | ||
2349 | unsigned long t1 = (ts+50)/100; | ||
2350 | m_infoWin->setRead((pl + (t1 >> 1))/t1); | ||
2351 | } | ||
2352 | else | ||
2353 | { | ||
2354 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); | ||
2355 | } | ||
2296 | m_infoWin->setDocSize(ds); | 2356 | m_infoWin->setDocSize(ds); |
2297 | m_infoWin->setDocLocation(dl); | 2357 | m_infoWin->setDocLocation(dl); |
2298 | m_infoWin->setDocRead((100*dl + (ds >> 1))/ds); | 2358 | if (dl > UINT_MAX/100) |
2359 | { | ||
2360 | unsigned long d1 = (ds+50)/100; | ||
2361 | m_infoWin->setDocRead((dl + (d1 >> 1))/d1); | ||
2362 | } | ||
2363 | else | ||
2364 | { | ||
2365 | m_infoWin->setDocRead((100*dl + (ds >> 1))/ds); | ||
2366 | } | ||
2299 | m_infoWin->setZoom(reader->m_fontControl.currentsize()*10); | 2367 | m_infoWin->setZoom(reader->m_fontControl.currentsize()*10); |
2300 | m_infoWin->setAbout(QString("\nApplication (c) Tim Wentford\n")+reader->about()); | 2368 | m_infoWin->setAbout(QString("\nApplication (c) Tim Wentford\n")+reader->about()); |
2301 | editorStack->raiseWidget( m_infoWin ); | 2369 | editorStack->raiseWidget( m_infoWin ); |
2302 | hidetoolbars(); | 2370 | hidetoolbars(); |
2303 | m_infoWin->setFocus(); | 2371 | m_infoWin->setFocus(); |
2304 | } | 2372 | } |
2305 | } | 2373 | } |
2306 | 2374 | ||
2307 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn, size_t posn2) | 2375 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn, size_t posn2) |
2308 | { | 2376 | { |
2309 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; | 2377 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; |
2310 | #ifdef _UNICODE | 2378 | #ifdef _UNICODE |
2311 | CBuffer buff(name.length()+1); | 2379 | CBuffer buff(name.length()+1); |
2312 | int i; | 2380 | int i; |
2313 | for (i = 0; i < name.length(); i++) | 2381 | for (i = 0; i < name.length(); i++) |
2314 | { | 2382 | { |
2315 | buff[i] = name[i].unicode(); | 2383 | buff[i] = name[i].unicode(); |
2316 | } | 2384 | } |
2317 | buff[i] = 0; | 2385 | buff[i] = 0; |
2318 | CBuffer buff2(text.length()+1); | 2386 | CBuffer buff2(text.length()+1); |
2319 | for (i = 0; i < text.length(); i++) | 2387 | for (i = 0; i < text.length(); i++) |
2320 | { | 2388 | { |
2321 | buff2[i] = text[i].unicode(); | 2389 | buff2[i] = text[i].unicode(); |
2322 | } | 2390 | } |
2323 | buff2[i] = 0; | 2391 | buff2[i] = 0; |
2324 | Bkmk b(buff.data(), buff2.data(), posn, posn2); | 2392 | Bkmk b(buff.data(), buff2.data(), posn, posn2); |
2325 | QColor c = m_annoWin->getColor(); | 2393 | QColor c = m_annoWin->getColor(); |
2326 | int red,green,blue; | 2394 | int red,green,blue; |
2327 | c.rgb(&red, &green, &blue); | 2395 | c.rgb(&red, &green, &blue); |
2328 | b.red(red); | 2396 | b.red(red); |
2329 | b.green(green); | 2397 | b.green(green); |
2330 | b.blue(blue); | 2398 | b.blue(blue); |
2331 | pBkmklist->push_front(b); | 2399 | pBkmklist->push_front(b); |
2332 | #else | 2400 | #else |
2333 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); | 2401 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); |
2334 | #endif | 2402 | #endif |
2335 | m_fBkmksChanged = true; | 2403 | m_fBkmksChanged = true; |
2336 | pBkmklist->sort(); | 2404 | pBkmklist->sort(); |
2337 | } | 2405 | } |
2338 | 2406 | ||
2339 | void QTReaderApp::addAnno(const QString& name, const QString& text) | 2407 | void QTReaderApp::addAnno(const QString& name, const QString& text) |
2340 | { | 2408 | { |
2341 | if (m_annoIsEditing) | 2409 | if (m_annoIsEditing) |
2342 | { | 2410 | { |
2343 | if (name.isEmpty()) | 2411 | if (name.isEmpty()) |
2344 | { | 2412 | { |
2345 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); | 2413 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); |
2346 | } | 2414 | } |
2347 | else | 2415 | else |
2348 | { | 2416 | { |
2349 | addAnno(name, text, m_annoWin->getPosn(), m_annoWin->getPosn2()); | 2417 | addAnno(name, text, m_annoWin->getPosn(), m_annoWin->getPosn2()); |
2350 | } | 2418 | } |
2351 | showEditTools(); | 2419 | showEditTools(); |
2352 | } | 2420 | } |
2353 | else | 2421 | else |
2354 | { | 2422 | { |
2355 | if (m_annoWin->edited()) | 2423 | if (m_annoWin->edited()) |
2356 | { | 2424 | { |
2357 | CBuffer buff(text.length()+1); | 2425 | CBuffer buff(text.length()+1); |
2358 | int i; | 2426 | int i; |
2359 | for (i = 0; i < text.length(); i++) | 2427 | for (i = 0; i < text.length(); i++) |
2360 | { | 2428 | { |
2361 | buff[i] = text[i].unicode(); | 2429 | buff[i] = text[i].unicode(); |
2362 | } | 2430 | } |
2363 | buff[i] = 0; | 2431 | buff[i] = 0; |
2364 | m_fBkmksChanged = true; | 2432 | m_fBkmksChanged = true; |
2365 | m_anno->setAnno(buff.data()); | 2433 | m_anno->setAnno(buff.data()); |
2366 | } | 2434 | } |
2367 | QColor c = m_annoWin->getColor(); | 2435 | QColor c = m_annoWin->getColor(); |
2368 | int red,green,blue; | 2436 | int red,green,blue; |
2369 | c.rgb(&red, &green, &blue); | 2437 | c.rgb(&red, &green, &blue); |
2370 | m_anno->red(red); | 2438 | m_anno->red(red); |
2371 | m_anno->green(green); | 2439 | m_anno->green(green); |
2372 | m_anno->blue(blue); | 2440 | m_anno->blue(blue); |
2373 | bool found = findNextBookmark(m_anno->value()+1); | 2441 | bool found = findNextBookmark(m_anno->value()+1); |
2374 | if (found) | 2442 | if (found) |
2375 | { | 2443 | { |
2376 | m_annoWin->setName(toQString(m_anno->name())); | 2444 | m_annoWin->setName(toQString(m_anno->name())); |
2377 | m_annoWin->setAnno(toQString(m_anno->anno())); | 2445 | m_annoWin->setAnno(toQString(m_anno->anno())); |
2378 | m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); | 2446 | m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); |
2379 | } | 2447 | } |
2380 | else | 2448 | else |
2381 | { | 2449 | { |
2382 | showEditTools(); | 2450 | showEditTools(); |
2383 | } | 2451 | } |
2384 | } | 2452 | } |
2385 | } | 2453 | } |
2386 | 2454 | ||
2387 | bool QTReaderApp::findNextBookmark(size_t start) | 2455 | bool QTReaderApp::findNextBookmark(size_t start) |
2388 | { | 2456 | { |
2389 | bool found = false; | 2457 | bool found = false; |
2390 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) | 2458 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) |
2391 | { | 2459 | { |
2392 | if (iter->value() >= start) | 2460 | if (iter->value() >= start) |
2393 | { | 2461 | { |
2394 | if (iter->value() < reader->locate()) | 2462 | if (iter->value() < reader->locate()) |
2395 | { | 2463 | { |
2396 | found = true; | 2464 | found = true; |
2397 | m_anno = iter.pContent(); | 2465 | m_anno = iter.pContent(); |
2398 | } | 2466 | } |
2399 | break; | 2467 | break; |
2400 | } | 2468 | } |
2401 | } | 2469 | } |
2402 | return found; | 2470 | return found; |
2403 | } | 2471 | } |
2404 | 2472 | ||
2405 | void QTReaderApp::addanno() | 2473 | void QTReaderApp::addanno() |
2406 | { | 2474 | { |
2407 | if (reader->empty()) | 2475 | if (reader->empty()) |
2408 | { | 2476 | { |
2409 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 2477 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
2410 | } | 2478 | } |
2411 | else | 2479 | else |
2412 | { | 2480 | { |
2413 | m_annoWin->setName(""); | 2481 | m_annoWin->setName(""); |
2414 | m_annoWin->setAnno(""); | 2482 | m_annoWin->setAnno(""); |
2415 | m_annoWin->setPosn(reader->pagelocate()); | 2483 | m_annoWin->setPosn(reader->pagelocate()); |
2416 | m_annoIsEditing = true; | 2484 | m_annoIsEditing = true; |
2417 | editorStack->raiseWidget( m_annoWin ); | 2485 | editorStack->raiseWidget( m_annoWin ); |
2418 | hidetoolbars(); | 2486 | hidetoolbars(); |
2419 | #ifdef USEQPE | 2487 | #ifdef USEQPE |
2420 | Global::showInputMethod(); | 2488 | Global::showInputMethod(); |
2421 | #endif | 2489 | #endif |
2422 | m_annoWin->setFocus(); | 2490 | m_annoWin->setFocus(); |
2423 | } | 2491 | } |
2424 | } | 2492 | } |
2425 | 2493 | ||
2426 | void QTReaderApp::infoClose() | 2494 | void QTReaderApp::infoClose() |
2427 | { | 2495 | { |
2428 | m_debounce = m_buttonprefs->Debounce(); | 2496 | m_debounce = m_buttonprefs->Debounce(); |
2429 | if (m_kmapchanged) | 2497 | if (m_kmapchanged) |
2430 | { | 2498 | { |
2431 | m_kmapchanged = false; | 2499 | m_kmapchanged = false; |
2432 | #ifndef USEQPE | 2500 | #ifndef USEQPE |
2433 | QDir d = QDir::home(); // "/" | 2501 | QDir d = QDir::home(); // "/" |
2434 | d.cd(APPDIR); | 2502 | d.cd(APPDIR); |
2435 | QFileInfo fi(d, ".keymap"); | 2503 | QFileInfo fi(d, ".keymap"); |
2436 | FILE* f = fopen((const char *)fi.absFilePath(), "w"); | 2504 | FILE* f = fopen((const char *)fi.absFilePath(), "w"); |
2437 | #else /* USEQPE */ | 2505 | #else /* USEQPE */ |
2438 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "w"); | 2506 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "w"); |
2439 | #endif /* USEQPE */ | 2507 | #endif /* USEQPE */ |
2440 | if (f != NULL) | 2508 | if (f != NULL) |
2441 | { | 2509 | { |
2442 | uint cnt = KEYMAPVERSION; | 2510 | uint cnt = KEYMAPVERSION; |
2443 | fwrite(&cnt, sizeof(cnt), 1, f); | 2511 | fwrite(&cnt, sizeof(cnt), 1, f); |
2444 | cnt = kmap.count(); | 2512 | cnt = kmap.count(); |
2445 | fwrite(&cnt, sizeof(cnt), 1, f); | 2513 | fwrite(&cnt, sizeof(cnt), 1, f); |
2446 | for (QMap<orKey,int>::Iterator i = kmap.begin(); i != kmap.end(); i++) | 2514 | for (QMap<orKey,int>::Iterator i = kmap.begin(); i != kmap.end(); i++) |
2447 | { | 2515 | { |
2448 | orKey key = i.key(); | 2516 | orKey key = i.key(); |
2449 | int data = i.data(); | 2517 | int data = i.data(); |
2450 | fwrite(&key, sizeof(key), 1, f); | 2518 | fwrite(&key, sizeof(key), 1, f); |
2451 | fwrite(&data, sizeof(data), 1, f); | 2519 | fwrite(&data, sizeof(data), 1, f); |
2452 | qDebug("Saved %s as %u", (const char*)key.text(), data); | 2520 | qDebug("Saved %s as %u", (const char*)key.text(), data); |
2453 | } | 2521 | } |
2454 | fclose(f); | 2522 | fclose(f); |
2455 | } | 2523 | } |
2456 | } | 2524 | } |
2457 | showEditTools(); | 2525 | showEditTools(); |
2458 | } | 2526 | } |
2459 | 2527 | ||
2460 | /* | 2528 | /* |
2461 | void QTReaderApp::fileRevert() | 2529 | void QTReaderApp::fileRevert() |
2462 | { | 2530 | { |
2463 | clear(); | 2531 | clear(); |
2464 | fileOpen(); | 2532 | fileOpen(); |
2465 | } | 2533 | } |
2466 | 2534 | ||
2467 | void QTReaderApp::editCut() | 2535 | void QTReaderApp::editCut() |
2468 | { | 2536 | { |
2469 | #ifndef QT_NO_CLIPBOARD | 2537 | #ifndef QT_NO_CLIPBOARD |
2470 | editor->cut(); | 2538 | editor->cut(); |
2471 | #endif | 2539 | #endif |
2472 | } | 2540 | } |
2473 | */ | 2541 | */ |
2474 | void QTReaderApp::editMark() | 2542 | void QTReaderApp::editMark() |
2475 | { | 2543 | { |
2476 | m_savedpos = reader->pagelocate(); | 2544 | m_savedpos = reader->pagelocate(); |
2477 | } | 2545 | } |
2478 | 2546 | ||
2479 | void QTReaderApp::editCopy() | 2547 | void QTReaderApp::editCopy() |
2480 | { | 2548 | { |
2481 | QClipboard* cb = QApplication::clipboard(); | 2549 | QClipboard* cb = QApplication::clipboard(); |
2482 | QString text; | 2550 | QString text; |
2483 | int ch; | 2551 | int ch; |
2484 | unsigned long currentpos = reader->pagelocate(); | 2552 | unsigned long currentpos = reader->pagelocate(); |
2485 | unsigned long endpos = reader->locate(); | 2553 | unsigned long endpos = reader->locate(); |
2486 | if (m_savedpos == 0xffffffff) | 2554 | if (m_savedpos == 0xffffffff) |
2487 | { | 2555 | { |
2488 | m_savedpos = currentpos; | 2556 | m_savedpos = currentpos; |
2489 | } | 2557 | } |
2490 | reader->jumpto(m_savedpos); | 2558 | reader->jumpto(m_savedpos); |
2491 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) | 2559 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) |
2492 | { | 2560 | { |
2493 | text += ch; | 2561 | text += ch; |
2494 | } | 2562 | } |
2495 | cb->setText(text); | 2563 | cb->setText(text); |
2496 | reader->locate(currentpos); | 2564 | reader->locate(currentpos); |
2497 | m_savedpos = 0xffffffff; | 2565 | m_savedpos = 0xffffffff; |
2498 | } | 2566 | } |
2499 | 2567 | ||
2500 | void QTReaderApp::gotoStart() | 2568 | void QTReaderApp::gotoStart() |
2501 | { | 2569 | { |
2502 | reader->locate(reader->buffdoc.startSection()); | 2570 | reader->locate(reader->buffdoc.startSection()); |
2503 | } | 2571 | } |
2504 | 2572 | ||
2505 | void QTReaderApp::gotoEnd() | 2573 | void QTReaderApp::gotoEnd() |
2506 | { | 2574 | { |
2507 | reader->dopageup(reader->buffdoc.endSection()); | 2575 | reader->dopageup(reader->buffdoc.endSection()); |
2508 | } | 2576 | } |
2509 | 2577 | ||
2510 | void QTReaderApp::pageup() | 2578 | void QTReaderApp::pageup() |
2511 | { | 2579 | { |
2512 | reader->NavUp(); | 2580 | reader->NavUp(); |
2513 | } | 2581 | } |
2514 | 2582 | ||
2515 | void QTReaderApp::pagedn() | 2583 | void QTReaderApp::pagedn() |
2516 | { | 2584 | { |
2517 | reader->NavDown(); | 2585 | reader->NavDown(); |
2518 | } | 2586 | } |
2519 | 2587 | ||
2520 | void QTReaderApp::pagemode(bool _b) | 2588 | void QTReaderApp::pagemode(bool _b) |
2521 | { | 2589 | { |
2522 | reader->setpagemode(_b); | 2590 | reader->setpagemode(_b); |
2523 | } | 2591 | } |
2524 | 2592 | ||
2525 | /* | 2593 | /* |
2526 | void QTReaderApp::setspacing() | 2594 | void QTReaderApp::setspacing() |
2527 | { | 2595 | { |
2528 | m_nRegAction = cMonoSpace; | 2596 | m_nRegAction = cMonoSpace; |
2529 | char lcn[20]; | 2597 | char lcn[20]; |
2530 | sprintf(lcn, "%lu", reader->m_charpc); | 2598 | sprintf(lcn, "%lu", reader->m_charpc); |
2531 | regEdit->setText(lcn); | 2599 | regEdit->setText(lcn); |
2532 | do_regedit(); | 2600 | do_regedit(); |
2533 | } | 2601 | } |
2534 | */ | 2602 | */ |
2535 | void QTReaderApp::settarget() | 2603 | void QTReaderApp::settarget() |
2536 | { | 2604 | { |
2537 | m_nRegAction = cSetTarget; | 2605 | m_nRegAction = cSetTarget; |
2538 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) | 2606 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) |
2539 | + "/" | 2607 | + "/" |
2540 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); | 2608 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); |
2541 | regEdit->setText(text); | 2609 | regEdit->setText(text); |
2542 | do_regedit(); | 2610 | do_regedit(); |
2543 | } | 2611 | } |
2544 | 2612 | ||
2545 | /* | 2613 | /* |
2546 | void QTReaderApp::do_mono(const QString& lcn) | 2614 | void QTReaderApp::do_mono(const QString& lcn) |
2547 | { | 2615 | { |
2548 | bool ok; | 2616 | bool ok; |
2549 | unsigned long ulcn = lcn.toULong(&ok); | 2617 | unsigned long ulcn = lcn.toULong(&ok); |
2550 | if (ok) | 2618 | if (ok) |
2551 | { | 2619 | { |
2552 | reader->m_charpc = ulcn; | 2620 | reader->m_charpc = ulcn; |
2553 | reader->setfont(); | 2621 | reader->setfont(); |
2554 | reader->refresh(); | 2622 | reader->refresh(); |
2555 | //reader->setmono(true); | 2623 | //reader->setmono(true); |
2556 | } | 2624 | } |
2557 | else | 2625 | else |
2558 | QMessageBox::information(this, PROGNAME, "Must be a number"); | 2626 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
2559 | } | 2627 | } |
2560 | */ | 2628 | */ |
2561 | /* | 2629 | /* |
2562 | void QTReaderApp::editPaste() | 2630 | void QTReaderApp::editPaste() |
2563 | { | 2631 | { |
2564 | #ifndef QT_NO_CLIPBOARD | 2632 | #ifndef QT_NO_CLIPBOARD |
2565 | editor->paste(); | 2633 | editor->paste(); |
2566 | #endif | 2634 | #endif |
2567 | } | 2635 | } |
2568 | */ | 2636 | */ |
2569 | 2637 | ||
2570 | void QTReaderApp::editFind() | 2638 | void QTReaderApp::editFind() |
2571 | { | 2639 | { |
2572 | searchStart = reader->pagelocate(); | 2640 | searchStart = reader->pagelocate(); |
2573 | #ifdef __ISEARCH | 2641 | #ifdef __ISEARCH |
2574 | searchStack = new QStack<searchrecord>; | 2642 | searchStack = new QStack<searchrecord>; |
2575 | #endif | 2643 | #endif |
2576 | #ifdef USEQPE | 2644 | #ifdef USEQPE |
2577 | Global::showInputMethod(); | 2645 | Global::showInputMethod(); |
2578 | #endif | 2646 | #endif |
2579 | searchBar->show(); | 2647 | searchBar->show(); |
2580 | searchVisible = TRUE; | 2648 | searchVisible = TRUE; |
2581 | searchEdit->setFocus(); | 2649 | searchEdit->setFocus(); |
2582 | #ifdef __ISEARCH | 2650 | #ifdef __ISEARCH |
2583 | searchStack->push(new searchrecord("",reader->pagelocate())); | 2651 | searchStack->push(new searchrecord("",reader->pagelocate())); |
2584 | #endif | 2652 | #endif |
2585 | } | 2653 | } |
2586 | 2654 | ||
2587 | void QTReaderApp::findNext() | 2655 | void QTReaderApp::findNext() |
2588 | { | 2656 | { |
2589 | // // qDebug("findNext called\n"); | 2657 | // // qDebug("findNext called\n"); |
2590 | #ifdef __ISEARCH | 2658 | #ifdef __ISEARCH |
2591 | QString arg = searchEdit->text(); | 2659 | QString arg = searchEdit->text(); |
2592 | #else | 2660 | #else |
2593 | QRegExp arg = searchEdit->text(); | 2661 | QRegExp arg = searchEdit->text(); |
2594 | #endif | 2662 | #endif |
2595 | CDrawBuffer test(&(reader->m_fontControl)); | 2663 | CDrawBuffer test(&(reader->m_fontControl)); |
2596 | size_t start = reader->pagelocate(); | 2664 | size_t start = reader->pagelocate(); |
2597 | reader->jumpto(start); | 2665 | reader->jumpto(start); |
2598 | reader->getline(&test); | 2666 | reader->getline(&test); |
2599 | dosearch(start, test, arg); | 2667 | dosearch(start, test, arg); |
2600 | } | 2668 | } |
2601 | 2669 | ||
2602 | void QTReaderApp::findClose() | 2670 | void QTReaderApp::findClose() |
2603 | { | 2671 | { |
2604 | searchVisible = FALSE; | 2672 | searchVisible = FALSE; |
2605 | searchEdit->setText(""); | 2673 | searchEdit->setText(""); |
2606 | #ifdef USEQPE | 2674 | #ifdef USEQPE |
2607 | Global::hideInputMethod(); | 2675 | Global::hideInputMethod(); |
2608 | #endif | 2676 | #endif |
2609 | searchBar->hide(); | 2677 | searchBar->hide(); |
2610 | #ifdef __ISEARCH | 2678 | #ifdef __ISEARCH |
2611 | // searchStack = new QStack<searchrecord>; | 2679 | // searchStack = new QStack<searchrecord>; |
2612 | while (!searchStack->isEmpty()) | 2680 | while (!searchStack->isEmpty()) |
2613 | { | 2681 | { |
2614 | delete searchStack->pop(); | 2682 | delete searchStack->pop(); |
2615 | } | 2683 | } |
2616 | delete searchStack; | 2684 | delete searchStack; |
2617 | #endif | 2685 | #endif |
2618 | reader->setFocus(); | 2686 | reader->setFocus(); |
2619 | } | 2687 | } |
2620 | 2688 | ||
2621 | void QTReaderApp::regClose() | 2689 | void QTReaderApp::regClose() |
2622 | { | 2690 | { |
2623 | regVisible = FALSE; | 2691 | regVisible = FALSE; |
2624 | regEdit->setText(""); | 2692 | regEdit->setText(""); |
2625 | regBar->hide(); | 2693 | regBar->hide(); |
2626 | #ifdef USEQPE | 2694 | #ifdef USEQPE |
2627 | Global::hideInputMethod(); | 2695 | Global::hideInputMethod(); |
2628 | #endif | 2696 | #endif |
2629 | reader->setFocus(); | 2697 | reader->setFocus(); |
2630 | } | 2698 | } |
2631 | 2699 | ||
2632 | #ifdef __ISEARCH | 2700 | #ifdef __ISEARCH |
2633 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) | 2701 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) |
2634 | #else | 2702 | #else |
2635 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | 2703 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) |
2636 | #endif | 2704 | #endif |
2637 | { | 2705 | { |
2638 | bool ret = true; | 2706 | bool ret = true; |
2639 | unsigned long fs, ts; | 2707 | unsigned long fs, ts; |
2640 | reader->sizes(fs,ts); | 2708 | reader->sizes(fs,ts); |
2641 | size_t pos = reader->locate(); | 2709 | size_t pos = reader->locate(); |
2642 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); | 2710 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); |
2643 | pbar->show(); | 2711 | pbar->show(); |
2644 | pbar->raise(); | 2712 | pbar->raise(); |
2645 | pbar->reset(); | 2713 | pbar->reset(); |
2646 | int offset; | 2714 | int offset; |
2647 | int lastpc = (100*pos)/ts; | 2715 | int lastpc = (100*pos)/ts; |
2648 | pbar->setProgress(lastpc); | 2716 | pbar->setProgress(lastpc); |
2649 | // qApp->processEvents(); | 2717 | // qApp->processEvents(); |
2650 | if (reader->buffdoc.getpara(test) >= 0) | 2718 | if (reader->buffdoc.getpara(test) >= 0) |
2651 | { | 2719 | { |
2652 | reader->setFocus(); | 2720 | reader->setFocus(); |
2653 | #ifdef __ISEARCH | 2721 | #ifdef __ISEARCH |
2654 | while (strstr(test.data(),(const tchar*)arg) == NULL) | 2722 | while (strstr(test.data(),(const tchar*)arg) == NULL) |
2655 | #else | 2723 | #else |
2656 | #ifdef _UNICODE | 2724 | #ifdef _UNICODE |
2657 | while ((offset = arg.match(toQString(test.data()))) == -1) | 2725 | while ((offset = arg.match(toQString(test.data()))) == -1) |
2658 | #else | 2726 | #else |
2659 | while (arg.match(test.data()) == -1) | 2727 | while (arg.match(test.data()) == -1) |
2660 | #endif | 2728 | #endif |
2661 | #endif | 2729 | #endif |
2662 | { | 2730 | { |
2663 | pos = reader->locate(); | 2731 | pos = reader->locate(); |
2664 | int pc = (100*pos)/ts; | 2732 | int pc = (100*pos)/ts; |
2665 | if (pc != lastpc) | 2733 | if (pc != lastpc) |
2666 | { | 2734 | { |
2667 | pbar->setProgress(pc); | 2735 | pbar->setProgress(pc); |
2668 | qApp->processEvents(); | 2736 | qApp->processEvents(); |
2669 | reader->setFocus(); | 2737 | reader->setFocus(); |
2670 | lastpc = pc; | 2738 | lastpc = pc; |
2671 | } | 2739 | } |
2672 | 2740 | ||
2673 | if (reader->buffdoc.getpara(test) < 0) | 2741 | if (reader->buffdoc.getpara(test) < 0) |
2674 | { | 2742 | { |
2675 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2743 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2676 | pos = searchStart; | 2744 | pos = searchStart; |
2677 | else | 2745 | else |
2678 | pos = start; | 2746 | pos = start; |
2679 | findClose(); | 2747 | findClose(); |
2680 | pbar->hide(); | 2748 | pbar->hide(); |
2681 | reader->locate(pos); | 2749 | reader->locate(pos); |
2682 | return false; | 2750 | return false; |
2683 | } | 2751 | } |
2684 | } | 2752 | } |
2685 | // qDebug("Found it at %u:%u", pos, offset); | 2753 | // qDebug("Found it at %u:%u", pos, offset); |
2686 | pbar->hide(); | 2754 | pbar->hide(); |
2687 | // qDebug("Hid"); | 2755 | // qDebug("Hid"); |
2688 | reader->locate(pos+offset); | 2756 | reader->locate(pos+offset); |
2689 | // qDebug("Loacted"); | 2757 | // qDebug("Loacted"); |
2690 | // qDebug("page up"); | 2758 | // qDebug("page up"); |
2691 | ret = true; | 2759 | ret = true; |
2692 | } | 2760 | } |
2693 | else | 2761 | else |
2694 | { | 2762 | { |
2695 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2763 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2696 | pos = searchStart; | 2764 | pos = searchStart; |
2697 | else | 2765 | else |
2698 | pos = start; | 2766 | pos = start; |
2699 | ret = false; | 2767 | ret = false; |
2700 | findClose(); | 2768 | findClose(); |
2701 | } | 2769 | } |
2702 | return ret; | 2770 | return ret; |
2703 | } | 2771 | } |
2704 | 2772 | ||
2705 | #ifdef __ISEARCH | 2773 | #ifdef __ISEARCH |
2706 | void QTReaderApp::search(const QString & arg) | 2774 | void QTReaderApp::search(const QString & arg) |
2707 | { | 2775 | { |
2708 | searchrecord* ss = searchStack->top(); | 2776 | searchrecord* ss = searchStack->top(); |
2709 | CBuffer test; | 2777 | CBuffer test; |
2710 | size_t start = reader->pagelocate(); | 2778 | size_t start = reader->pagelocate(); |
2711 | bool haspopped = false; | 2779 | bool haspopped = false; |
2712 | while (arg.left(ss->s.length()) != ss->s) | 2780 | while (arg.left(ss->s.length()) != ss->s) |
2713 | { | 2781 | { |
2714 | haspopped = true; | 2782 | haspopped = true; |
2715 | start = ss->pos; | 2783 | start = ss->pos; |
2716 | // reader->locate(start); | 2784 | // reader->locate(start); |
2717 | searchStack->pop(); | 2785 | searchStack->pop(); |
2718 | delete ss; | 2786 | delete ss; |
2719 | } | 2787 | } |
2720 | if (haspopped) reader->locate(start); | 2788 | if (haspopped) reader->locate(start); |
2721 | /* | 2789 | /* |
2722 | if (arg.length() < ss->len) | 2790 | if (arg.length() < ss->len) |
2723 | { | 2791 | { |
2724 | start = ss->pos; | 2792 | start = ss->pos; |
2725 | reader->locate(start); | 2793 | reader->locate(start); |
2726 | searchStack->pop(); | 2794 | searchStack->pop(); |
2727 | delete ss; | 2795 | delete ss; |
2728 | } | 2796 | } |
2729 | */ | 2797 | */ |
2730 | else | 2798 | else |
2731 | { | 2799 | { |
2732 | start = reader->pagelocate(); | 2800 | start = reader->pagelocate(); |
2733 | reader->jumpto(start); | 2801 | reader->jumpto(start); |
2734 | searchStack->push(new searchrecord(arg,start)); | 2802 | searchStack->push(new searchrecord(arg,start)); |
2735 | } | 2803 | } |
2736 | dosearch(start, test, arg); | 2804 | dosearch(start, test, arg); |
2737 | } | 2805 | } |
2738 | #else | 2806 | #else |
2739 | void QTReaderApp::search() | 2807 | void QTReaderApp::search() |
2740 | { | 2808 | { |
2741 | findNext(); | 2809 | findNext(); |
2742 | } | 2810 | } |
2743 | #endif | 2811 | #endif |
2744 | 2812 | ||
2745 | void QTReaderApp::openFile( const QString &f ) | 2813 | void QTReaderApp::openFile( const QString &f, unsigned int loc ) |
2746 | { | 2814 | { |
2747 | // qDebug("File:%s", (const char*)f); | 2815 | // qDebug("File:%s", (const char*)f); |
2748 | // openFile(DocLnk(f)); | 2816 | // openFile(DocLnk(f)); |
2749 | //} | 2817 | //} |
2750 | // | 2818 | // |
2751 | //void QTReaderApp::openFile( const DocLnk &f ) | 2819 | //void QTReaderApp::openFile( const DocLnk &f ) |
2752 | //{ | 2820 | //{ |
2753 | clear(); | 2821 | clear(); |
2754 | QFileInfo fm(f); | 2822 | QFileInfo fm(f); |
2755 | if ( fm.exists() ) | 2823 | if ( fm.exists() ) |
2756 | { | 2824 | { |
2757 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); | 2825 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); |
2758 | #ifdef USEQPE | 2826 | #ifdef USEQPE |
2759 | if (fm.extension( FALSE ) == "desktop") | 2827 | if (fm.extension( FALSE ) == "desktop") |
2760 | { | 2828 | { |
2761 | DocLnk d(f); | 2829 | DocLnk d(f); |
2762 | QFileInfo fnew(d.file()); | 2830 | QFileInfo fnew(d.file()); |
2763 | fm = fnew; | 2831 | fm = fnew; |
2764 | if (!fm.exists()) return; | 2832 | if (!fm.exists()) return; |
2765 | } | 2833 | } |
2766 | #endif | 2834 | #endif |
2767 | clear(); | 2835 | clear(); |
2768 | reader->setText(fm.baseName(), fm.absFilePath()); | 2836 | reader->setText(fm.baseName(), fm.absFilePath(), loc); |
2769 | m_loadedconfig = readconfig(APPDIR "/configs", reader->m_string, false); | 2837 | m_loadedconfig = readconfig(APPDIR "/configs", reader->m_string, false); |
2770 | qDebug("Showing tools"); | 2838 | qDebug("Showing tools"); |
2771 | showEditTools(); | 2839 | showEditTools(); |
2772 | qDebug("Shown tools"); | 2840 | qDebug("Shown tools"); |
2773 | readbkmks(); | 2841 | readbkmks(); |
2774 | qDebug("read markss"); | 2842 | qDebug("read markss"); |
2775 | m_savedpos = 0xffffffff; | 2843 | m_savedpos = 0xffffffff; |
2776 | } | 2844 | } |
2777 | else | 2845 | else |
2778 | { | 2846 | { |
2779 | QString msg = f; | 2847 | QString msg = f; |
2780 | msg += "\nFile does not exist"; | 2848 | msg += "\nFile does not exist"; |
2781 | QMessageBox::information(this, PROGNAME, msg); | 2849 | QMessageBox::information(this, PROGNAME, msg); |
2782 | reader->m_lastfile = QString::null; | 2850 | reader->m_lastfile = QString::null; |
2783 | } | 2851 | } |
2784 | 2852 | ||
2785 | } | 2853 | } |
2786 | /* | 2854 | /* |
2787 | void QTReaderApp::resizeEvent(QResizeEvent* e) | 2855 | void QTReaderApp::resizeEvent(QResizeEvent* e) |
2788 | { | 2856 | { |
2789 | if (m_fullscreen) | 2857 | if (m_fullscreen) |
2790 | { | 2858 | { |
2791 | showNormal(); | 2859 | showNormal(); |
2792 | showFullScreen(); | 2860 | showFullScreen(); |
2793 | } | 2861 | } |
2794 | } | 2862 | } |
2795 | */ | 2863 | */ |
2796 | void QTReaderApp::handlekey(QKeyEvent* e) | 2864 | void QTReaderApp::handlekey(QKeyEvent* e) |
2797 | { | 2865 | { |
2798 | // qDebug("Keypress event"); | 2866 | // qDebug("Keypress event"); |
2799 | timeb now; | 2867 | timeb now; |
2800 | ftime(&now); | 2868 | ftime(&now); |
2801 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; | 2869 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; |
2802 | if (etime < m_debounce) | 2870 | if (etime < m_debounce) |
2803 | { | 2871 | { |
2804 | return; | 2872 | return; |
2805 | } | 2873 | } |
2806 | switch(e->key()) | 2874 | switch(e->key()) |
2807 | { | 2875 | { |
2808 | case Key_Escape: | 2876 | case Key_Escape: |
2809 | // qDebug("escape event"); | 2877 | qDebug("escape event"); |
2810 | if (m_disableesckey) | 2878 | if (m_disableesckey) |
2811 | { | 2879 | { |
2812 | m_disableesckey = false; | 2880 | m_disableesckey = false; |
2813 | } | 2881 | } |
2814 | else | 2882 | else |
2815 | { | 2883 | { |
2816 | m_bcloseDisabled = true; | 2884 | m_bcloseDisabled = true; |
2817 | if (m_fullscreen) | 2885 | if (m_fullscreen) |
2818 | { | 2886 | { |
2819 | m_actFullscreen->setOn(false); | 2887 | m_actFullscreen->setOn(false); |
2820 | e->accept(); | 2888 | e->accept(); |
2821 | } | 2889 | } |
2822 | else | 2890 | else |
2823 | { | 2891 | { |
2824 | // qDebug("escape action"); | 2892 | // qDebug("escape action"); |
2825 | doAction(e); | 2893 | doAction(e); |
2826 | } | 2894 | } |
2827 | } | 2895 | } |
2828 | break; | 2896 | break; |
2829 | /* | 2897 | /* |
2830 | case Key_Left: | 2898 | case Key_Left: |
2831 | { | 2899 | { |
2832 | if (reader->m_autoScroll) | 2900 | if (reader->m_autoScroll) |
2833 | { | 2901 | { |
2834 | reader->reduceScroll(); | 2902 | reader->reduceScroll(); |
2835 | } | 2903 | } |
2836 | else | 2904 | else |
2837 | { | 2905 | { |
2838 | doAction(e); | 2906 | doAction(e); |
2839 | } | 2907 | } |
2840 | } | 2908 | } |
2841 | break; | 2909 | break; |
2842 | case Key_Right: | 2910 | case Key_Right: |
2843 | { | 2911 | { |
2844 | if (reader->m_autoScroll) | 2912 | if (reader->m_autoScroll) |
2845 | { | 2913 | { |
2846 | reader->increaseScroll(); | 2914 | reader->increaseScroll(); |
2847 | } | 2915 | } |
2848 | else | 2916 | else |
2849 | { | 2917 | { |
2850 | doAction(e); | 2918 | doAction(e); |
2851 | } | 2919 | } |
2852 | } | 2920 | } |
2853 | break; | 2921 | break; |
2854 | case Key_Up: | 2922 | case Key_Up: |
2855 | { | 2923 | { |
2856 | if (reader->m_autoScroll) | 2924 | if (reader->m_autoScroll) |
2857 | { | 2925 | { |
2858 | reader->increaseScroll(); | 2926 | reader->increaseScroll(); |
2859 | } | 2927 | } |
2860 | else | 2928 | else |
2861 | { | 2929 | { |
2862 | doAction(e); | 2930 | doAction(e); |
2863 | } | 2931 | } |
2864 | } | 2932 | } |
2865 | break; | 2933 | break; |
2866 | case Key_Down: | 2934 | case Key_Down: |
2867 | { | 2935 | { |
2868 | if (reader->m_autoScroll) | 2936 | if (reader->m_autoScroll) |
2869 | { | 2937 | { |
2870 | reader->reduceScroll(); | 2938 | reader->reduceScroll(); |
2871 | } | 2939 | } |
2872 | else | 2940 | else |
2873 | { | 2941 | { |
2874 | doAction(e); | 2942 | doAction(e); |
2875 | } | 2943 | } |
2876 | } | 2944 | } |
2877 | break; | 2945 | break; |
2878 | */ | 2946 | */ |
2879 | default: | 2947 | default: |
2880 | { | 2948 | { |
2881 | doAction(e); | 2949 | doAction(e); |
2882 | } | 2950 | } |
2883 | 2951 | ||
2884 | /* | 2952 | /* |
2885 | QString msg("Key press was:"); | 2953 | QString msg("Key press was:"); |
2886 | QString key; | 2954 | QString key; |
2887 | msg += key.setNum(e->key()); | 2955 | msg += key.setNum(e->key()); |
2888 | QMessageBox::information(this, PROGNAME, msg); | 2956 | QMessageBox::information(this, PROGNAME, msg); |
2889 | */ | 2957 | */ |
2890 | } | 2958 | } |
2891 | ftime(&m_lastkeytime); | 2959 | ftime(&m_lastkeytime); |
2892 | } | 2960 | } |
2893 | 2961 | ||
2894 | #ifdef NEWFULLSCREEN | 2962 | #if defined(USEQPE) && defined(USENEWFULLSCREEN) |
2895 | void QTReaderApp::enableFullscreen() | 2963 | void QTReaderApp::focusInEvent(QFocusEvent *) |
2896 | { | ||
2897 | setFixedSize(qApp->desktop()->size()); | ||
2898 | showNormal(); | ||
2899 | reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); | ||
2900 | showFullScreen(); | ||
2901 | } | ||
2902 | |||
2903 | void QTReaderApp::resizeEvent(QResizeEvent *) | ||
2904 | { | 2964 | { |
2905 | if (m_fullscreen && (size() != qApp->desktop()->size())) | 2965 | if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader)) |
2906 | { | 2966 | { |
2907 | enableFullscreen(); | 2967 | m_usenewfullscreen = false; |
2968 | reader->bDoUpdates = false; | ||
2969 | showEditTools(); | ||
2970 | reader->bDoUpdates = true; | ||
2971 | reader->update(); | ||
2972 | m_usenewfullscreen = true; | ||
2908 | } | 2973 | } |
2909 | } | 2974 | } |
2910 | 2975 | ||
2911 | void QTReaderApp::focusInEvent(QFocusEvent*) | 2976 | void QTReaderApp::resizeEvent(QResizeEvent *) |
2912 | { | 2977 | { |
2913 | if (m_fullscreen) | 2978 | if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader)) |
2914 | { | 2979 | { |
2915 | enableFullscreen(); | 2980 | m_usenewfullscreen = false; |
2916 | raise(); | 2981 | reader->bDoUpdates = false; |
2982 | showEditTools(); | ||
2983 | reader->bDoUpdates = true; | ||
2984 | reader->update(); | ||
2985 | m_usenewfullscreen = true; | ||
2917 | } | 2986 | } |
2918 | } | 2987 | } |
2919 | #endif | 2988 | #endif |
2920 | 2989 | ||
2921 | void QTReaderApp::showEditTools() | 2990 | void QTReaderApp::showEditTools() |
2922 | { | 2991 | { |
2923 | // if ( !doc ) | 2992 | // if ( !doc ) |
2924 | //close(); | 2993 | //close(); |
2925 | if (m_fullscreen) | 2994 | if (m_fullscreen) |
2926 | { | 2995 | { |
2927 | #ifdef USEQPE | 2996 | #if defined(USEQPE) |
2928 | if (menubar != NULL) menubar->hide(); | 2997 | if (menubar != NULL) menubar->hide(); |
2929 | #endif | 2998 | #endif |
2930 | if (fileBar != NULL) fileBar->hide(); | 2999 | if (fileBar != NULL) fileBar->hide(); |
2931 | if (viewBar != NULL) viewBar->hide(); | 3000 | if (viewBar != NULL) viewBar->hide(); |
2932 | if (navBar != NULL) navBar->hide(); | 3001 | if (navBar != NULL) navBar->hide(); |
2933 | if (markBar != NULL) markBar->hide(); | 3002 | if (markBar != NULL) markBar->hide(); |
2934 | if (m_prog != NULL) | 3003 | if (m_prog != NULL) |
2935 | { | 3004 | { |
2936 | // qDebug("Hiding status"); | 3005 | // qDebug("Hiding status"); |
2937 | m_prog->hide(); | 3006 | m_prog->hide(); |
2938 | } | 3007 | } |
2939 | searchBar->hide(); | 3008 | searchBar->hide(); |
2940 | regBar->hide(); | 3009 | regBar->hide(); |
2941 | #ifdef USEQPE | 3010 | #ifdef USEQPE |
2942 | Global::hideInputMethod(); | 3011 | Global::hideInputMethod(); |
2943 | #endif | 3012 | #endif |
2944 | if (m_scrollbar != NULL) m_scrollbar->hide(); | 3013 | if (m_scrollbar != NULL) m_scrollbar->hide(); |
2945 | m_fontBar->hide(); | 3014 | m_fontBar->hide(); |
2946 | //showNormal(); | 3015 | //showNormal(); |
2947 | #ifdef NEWFULLSCREEN | ||
2948 | enableFullscreen(); | ||
2949 | #else | ||
2950 | showFullScreen(); | 3016 | showFullScreen(); |
2951 | #endif | 3017 | } |
2952 | } | ||
2953 | else | 3018 | else |
2954 | { | 3019 | { |
2955 | //qDebug("him"); | 3020 | //qDebug("him"); |
2956 | #ifdef USEQPE | 3021 | #ifdef USEQPE |
2957 | Global::hideInputMethod(); | 3022 | Global::hideInputMethod(); |
2958 | #endif | 3023 | #endif |
2959 | //qDebug("eb"); | 3024 | //qDebug("eb"); |
2960 | if (m_scrollbar != NULL) | 3025 | if (m_scrollbar != NULL) |
2961 | { | 3026 | { |
2962 | if (m_scrollishidden) | 3027 | if (m_scrollishidden) |
2963 | { | 3028 | { |
2964 | m_scrollbar->hide(); | 3029 | m_scrollbar->hide(); |
2965 | } | 3030 | } |
2966 | else | 3031 | else |
2967 | { | 3032 | { |
2968 | m_scrollbar->show(); | 3033 | m_scrollbar->show(); |
2969 | } | 3034 | } |
2970 | } | 3035 | } |
2971 | if (!m_hidebars) | 3036 | if (!m_hidebars) |
2972 | { | 3037 | { |
2973 | #ifdef USEQPE | 3038 | #if defined(USEQPE) |
2974 | menubar->show(); | 3039 | menubar->show(); |
2975 | #endif | 3040 | #endif |
2976 | if (fileBar != NULL) fileBar->show(); | 3041 | if (fileBar != NULL) fileBar->show(); |
2977 | if (viewBar != NULL) viewBar->show(); | 3042 | if (viewBar != NULL) viewBar->show(); |
2978 | if (navBar != NULL) navBar->show(); | 3043 | if (navBar != NULL) navBar->show(); |
2979 | if (markBar != NULL) markBar->show(); | 3044 | if (markBar != NULL) markBar->show(); |
2980 | if (m_prog != NULL && !m_statusishidden) | 3045 | if (m_prog != NULL && !m_statusishidden) |
2981 | { | 3046 | { |
2982 | // qDebug("Showing status"); | 3047 | // qDebug("Showing status"); |
2983 | m_prog->show(); | 3048 | m_prog->show(); |
2984 | // qDebug("Shown status"); | 3049 | // qDebug("Shown status"); |
2985 | } | 3050 | } |
2986 | // qDebug("Showing mb"); | 3051 | // qDebug("Showing mb"); |
2987 | mb->show(); | 3052 | mb->show(); |
2988 | } | 3053 | } |
2989 | if ( searchVisible ) | 3054 | if ( searchVisible ) |
2990 | { | 3055 | { |
2991 | #ifdef USEQPE | 3056 | #ifdef USEQPE |
2992 | Global::showInputMethod(); | 3057 | Global::showInputMethod(); |
2993 | #endif | 3058 | #endif |
2994 | searchBar->show(); | 3059 | searchBar->show(); |
2995 | } | 3060 | } |
2996 | if ( regVisible ) | 3061 | if ( regVisible ) |
2997 | { | 3062 | { |
2998 | #ifdef USEQPE | 3063 | #ifdef USEQPE |
2999 | Global::showInputMethod(); | 3064 | Global::showInputMethod(); |
3000 | #endif | 3065 | #endif |
3001 | regBar->show(); | 3066 | regBar->show(); |
3002 | } | 3067 | } |
3003 | if (m_fontVisible) m_fontBar->show(); | 3068 | if (m_fontVisible) m_fontBar->show(); |
3004 | //qDebug("sn"); | 3069 | //qDebug("sn"); |
3005 | showNormal(); | 3070 | showNormal(); |
3006 | //qDebug("sm"); | 3071 | //qDebug("sm"); |
3007 | #ifdef USEQPE | 3072 | #if defined(USEQPE) && !defined(SIMPAD) |
3008 | showMaximized(); | 3073 | showMaximized(); |
3009 | #endif | 3074 | #endif |
3010 | //setCentralWidget(reader); | 3075 | //setCentralWidget(reader); |
3011 | } | 3076 | } |
3012 | 3077 | ||
3013 | // qDebug("uc"); | 3078 | // qDebug("uc"); |
3014 | updateCaption(); | 3079 | updateCaption(); |
3015 | // qDebug("rw"); | 3080 | // qDebug("rw"); |
3016 | editorStack->raiseWidget( reader ); | 3081 | editorStack->raiseWidget( reader ); |
3017 | // qDebug("sf"); | 3082 | // qDebug("sf"); |
3018 | reader->setFocus(); | 3083 | reader->setFocus(); |
3019 | // qDebug("ref"); | 3084 | // qDebug("ref"); |
3020 | reader->refresh(true); | 3085 | //reader->refresh(true); |
3021 | // qDebug("done"); | 3086 | // qDebug("done"); |
3022 | } | 3087 | } |
3023 | /* | 3088 | /* |
3024 | void QTReaderApp::save() | 3089 | void QTReaderApp::save() |
3025 | { | 3090 | { |
3026 | if ( !doc ) | 3091 | if ( !doc ) |
3027 | return; | 3092 | return; |
3028 | if ( !editor->edited() ) | 3093 | if ( !editor->edited() ) |
3029 | return; | 3094 | return; |
3030 | 3095 | ||
3031 | QString rt = editor->text(); | 3096 | QString rt = editor->text(); |
3032 | QString pt = rt; | 3097 | QString pt = rt; |
3033 | 3098 | ||
3034 | if ( doc->name().isEmpty() ) { | 3099 | if ( doc->name().isEmpty() ) { |
3035 | unsigned ispace = pt.find( ' ' ); | 3100 | unsigned ispace = pt.find( ' ' ); |
3036 | unsigned ienter = pt.find( '\n' ); | 3101 | unsigned ienter = pt.find( '\n' ); |
3037 | int i = (ispace < ienter) ? ispace : ienter; | 3102 | int i = (ispace < ienter) ? ispace : ienter; |
3038 | QString docname; | 3103 | QString docname; |
3039 | if ( i == -1 ) { | 3104 | if ( i == -1 ) { |
3040 | if ( pt.isEmpty() ) | 3105 | if ( pt.isEmpty() ) |
3041 | docname = "Empty Text"; | 3106 | docname = "Empty Text"; |
3042 | else | 3107 | else |
3043 | docname = pt; | 3108 | docname = pt; |
3044 | } else { | 3109 | } else { |
3045 | docname = pt.left( i ); | 3110 | docname = pt.left( i ); |
3046 | } | 3111 | } |
3047 | doc->setName(docname); | 3112 | doc->setName(docname); |
3048 | } | 3113 | } |
3049 | FileManager fm; | 3114 | FileManager fm; |
3050 | fm.saveFile( *doc, rt ); | 3115 | fm.saveFile( *doc, rt ); |
3051 | } | 3116 | } |
3052 | */ | 3117 | */ |
3053 | 3118 | ||
3054 | void QTReaderApp::clear() | 3119 | void QTReaderApp::clear() |
3055 | { | 3120 | { |
3056 | // if (doc != 0) | 3121 | // if (doc != 0) |
3057 | // { | 3122 | // { |
3058 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); | 3123 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); |
3059 | //delete doc; | 3124 | //delete doc; |
3060 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); | 3125 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); |
3061 | //doc = 0; | 3126 | //doc = 0; |
3062 | // } | 3127 | // } |
3063 | reader->clear(); | 3128 | reader->clear(); |
3064 | } | 3129 | } |
3065 | 3130 | ||
3066 | void QTReaderApp::updateCaption() | 3131 | void QTReaderApp::updateCaption() |
3067 | { | 3132 | { |
3068 | // if ( !doc ) | 3133 | // if ( !doc ) |
3069 | //setCaption( tr("QTReader") ); | 3134 | //setCaption( tr("QTReader") ); |
3070 | // else { | 3135 | // else { |
3071 | //QString s = doc->name(); | 3136 | //QString s = doc->name(); |
3072 | //if ( s.isEmpty() ) | 3137 | //if ( s.isEmpty() ) |
3073 | // s = tr( "Unnamed" ); | 3138 | // s = tr( "Unnamed" ); |
3074 | setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) ); | 3139 | setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) ); |
3075 | // } | 3140 | // } |
3076 | } | 3141 | } |
3077 | 3142 | ||
3078 | void QTReaderApp::setDocument(const QString& fileref) | 3143 | void QTReaderApp::setDocument(const QString& fileref) |
3079 | { | 3144 | { |
3080 | //QMessageBox::information(0, "setDocument", fileref); | 3145 | //QMessageBox::information(0, "setDocument", fileref); |
3081 | openFile(fileref); | 3146 | openFile(fileref); |
3082 | // showEditTools(); | 3147 | // showEditTools(); |
3083 | } | 3148 | } |
3084 | 3149 | ||
3085 | void QTReaderApp::closeEvent( QCloseEvent *e ) | 3150 | void QTReaderApp::closeEvent( QCloseEvent *e ) |
3086 | { | 3151 | { |
3087 | // qDebug("Close event"); | 3152 | // qDebug("Close event"); |
3088 | if (m_fullscreen) | 3153 | if (m_fullscreen) |
3089 | { | 3154 | { |
3090 | m_fullscreen = false; | 3155 | m_fullscreen = false; |
3091 | showEditTools(); | 3156 | showEditTools(); |
3092 | e->ignore(); | 3157 | e->ignore(); |
3093 | } | 3158 | } |
3094 | else if (editorStack->visibleWidget() == m_buttonprefs) | 3159 | else if (editorStack->visibleWidget() == m_buttonprefs) |
3095 | { | 3160 | { |
3096 | m_buttonprefs->mapkey(Qt::NoButton, Key_Escape); | 3161 | m_buttonprefs->mapkey(Qt::NoButton, Key_Escape); |
3097 | e->ignore(); | 3162 | e->ignore(); |
3098 | } | 3163 | } |
3099 | else if (m_dontSave) | 3164 | else if (m_dontSave) |
3100 | { | 3165 | { |
3101 | e->accept(); | 3166 | e->accept(); |
3102 | } | 3167 | } |
3103 | else | 3168 | else |
3104 | { | 3169 | { |
3105 | if (editorStack->visibleWidget() == reader) | 3170 | if (editorStack->visibleWidget() == reader) |
3106 | { | 3171 | { |
3107 | if ((kmap.find(orKey(Qt::NoButton,Key_Escape,false)) != kmap.end()) && m_bcloseDisabled) | 3172 | if ((kmap.find(orKey(Qt::NoButton,Key_Escape,false)) != kmap.end()) && m_bcloseDisabled) |
3108 | { | 3173 | { |
3109 | //qDebug("Close disabled"); | 3174 | //qDebug("Close disabled"); |
3110 | m_bcloseDisabled = false; | 3175 | m_bcloseDisabled = false; |
3111 | e->ignore(); | 3176 | e->ignore(); |
3112 | } | 3177 | } |
3113 | else | 3178 | else |
3114 | { | 3179 | { |
3115 | if (m_fontVisible) | 3180 | if (m_fontVisible) |
3116 | { | 3181 | { |
3117 | m_fontBar->hide(); | 3182 | m_fontBar->hide(); |
3118 | m_fontVisible = false; | 3183 | m_fontVisible = false; |
3119 | e->ignore(); | 3184 | e->ignore(); |
3120 | return; | 3185 | return; |
3121 | } | 3186 | } |
3122 | if (regVisible) | 3187 | if (regVisible) |
3123 | { | 3188 | { |
3124 | regBar->hide(); | 3189 | regBar->hide(); |
3125 | #ifdef USEQPE | 3190 | #ifdef USEQPE |
3126 | Global::hideInputMethod(); | 3191 | Global::hideInputMethod(); |
3127 | #endif | 3192 | #endif |
3128 | regVisible = false; | 3193 | regVisible = false; |
3129 | e->ignore(); | 3194 | e->ignore(); |
3130 | return; | 3195 | return; |
3131 | } | 3196 | } |
3132 | if (searchVisible) | 3197 | if (searchVisible) |
3133 | { | 3198 | { |
3134 | searchBar->hide(); | 3199 | searchBar->hide(); |
3135 | #ifdef USEQPE | 3200 | #ifdef USEQPE |
3136 | Global::hideInputMethod(); | 3201 | Global::hideInputMethod(); |
3137 | #endif | 3202 | #endif |
3138 | searchVisible = false; | 3203 | searchVisible = false; |
3139 | e->ignore(); | 3204 | e->ignore(); |
3140 | return; | 3205 | return; |
3141 | } | 3206 | } |
3142 | if (m_fBkmksChanged && pBkmklist != NULL) | 3207 | if (m_fBkmksChanged && pBkmklist != NULL) |
3143 | { | 3208 | { |
3144 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | 3209 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
3145 | savebkmks(); | 3210 | savebkmks(); |
3146 | delete pBkmklist; | 3211 | delete pBkmklist; |
3147 | reader->pBkmklist = pBkmklist = NULL; | 3212 | reader->pBkmklist = pBkmklist = NULL; |
3148 | m_fBkmksChanged = false; | 3213 | m_fBkmksChanged = false; |
3149 | } | 3214 | } |
3150 | updatefileinfo(); | 3215 | updatefileinfo(); |
3151 | saveprefs(); | 3216 | saveprefs(); |
3152 | e->accept(); | 3217 | e->accept(); |
3153 | } | 3218 | } |
3154 | } | 3219 | } |
3155 | else | 3220 | else |
3156 | { | 3221 | { |
3157 | showEditTools(); | 3222 | showEditTools(); |
3158 | m_disableesckey = true; | 3223 | m_disableesckey = true; |
3159 | } | 3224 | } |
3160 | } | 3225 | } |
3161 | } | 3226 | } |
3162 | 3227 | ||
3163 | void QTReaderApp::do_gotomark() | 3228 | void QTReaderApp::do_gotomark() |
3164 | { | 3229 | { |
3165 | m_nBkmkAction = cGotoBkmk; | 3230 | m_nBkmkAction = cGotoBkmk; |
3166 | if (!listbkmk(pBkmklist)) | 3231 | if (!listbkmk(pBkmklist)) |
3167 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 3232 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
3168 | } | 3233 | } |
3169 | 3234 | ||
3170 | void QTReaderApp::do_delmark() | 3235 | void QTReaderApp::do_delmark() |
3171 | { | 3236 | { |
3172 | m_nBkmkAction = cDelBkmk; | 3237 | m_nBkmkAction = cDelBkmk; |
3173 | if (!listbkmk(pBkmklist)) | 3238 | if (!listbkmk(pBkmklist)) |
3174 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 3239 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
3175 | } | 3240 | } |
3176 | 3241 | ||
3177 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) | 3242 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab, bool presel) |
3178 | { | 3243 | { |
3179 | bkmkselector->clear(); | 3244 | bkmkselector->clear(); |
3180 | if (_lab.isEmpty()) | 3245 | if (_lab.isEmpty()) |
3181 | bkmkselector->setText("Cancel"); | 3246 | bkmkselector->setText("Cancel"); |
3182 | else | 3247 | else |
3183 | bkmkselector->setText(_lab); | 3248 | bkmkselector->setText(_lab); |
3184 | int cnt = 0; | 3249 | int cnt = 0; |
3250 | int slt = -1; | ||
3185 | if (plist != NULL) | 3251 | if (plist != NULL) |
3186 | { | 3252 | { |
3187 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) | 3253 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) |
3188 | { | 3254 | { |
3255 | if (presel) | ||
3256 | { | ||
3257 | Bkmk* p = i.pContent(); | ||
3258 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) | ||
3259 | { | ||
3260 | slt = cnt; | ||
3261 | } | ||
3262 | } | ||
3189 | #ifdef _UNICODE | 3263 | #ifdef _UNICODE |
3190 | // qDebug("Item:%s", (const char*)toQString(i->name())); | 3264 | // qDebug("Item:%s", (const char*)toQString(i->name())); |
3191 | bkmkselector->insertItem(toQString(i->name())); | 3265 | bkmkselector->insertItem(toQString(i->name()), cnt++); |
3192 | #else | 3266 | #else |
3193 | bkmkselector->insertItem(i->name()); | 3267 | bkmkselector->insertItem(i->name(), cnt++); |
3194 | #endif | 3268 | #endif |
3195 | cnt++; | 3269 | |
3196 | } | 3270 | } |
3197 | } | 3271 | } |
3198 | if (cnt > 0) | 3272 | if (cnt > 0) |
3199 | { | 3273 | { |
3200 | hidetoolbars(); | 3274 | hidetoolbars(); |
3201 | editorStack->raiseWidget( bkmkselector ); | 3275 | editorStack->raiseWidget( bkmkselector ); |
3276 | if (slt != -1) bkmkselector->setCurrentItem(slt); | ||
3202 | return true; | 3277 | return true; |
3203 | } | 3278 | } |
3204 | else | 3279 | else |
3205 | return false; | 3280 | return false; |
3206 | } | 3281 | } |
3207 | 3282 | ||
3208 | void QTReaderApp::do_autogen() | 3283 | void QTReaderApp::do_autogen() |
3209 | { | 3284 | { |
3210 | m_nRegAction = cAutoGen; | 3285 | m_nRegAction = cAutoGen; |
3211 | regEdit->setText(m_autogenstr); | 3286 | regEdit->setText(m_autogenstr); |
3212 | do_regedit(); | 3287 | do_regedit(); |
3213 | } | 3288 | } |
3214 | 3289 | ||
3215 | void QTReaderApp::do_regedit() | 3290 | void QTReaderApp::do_regedit() |
3216 | { | 3291 | { |
3217 | // fileBar->hide(); | 3292 | // fileBar->hide(); |
3218 | reader->bDoUpdates = false; | 3293 | reader->bDoUpdates = false; |
3219 | // qDebug("Showing regbar"); | 3294 | // qDebug("Showing regbar"); |
3220 | regBar->show(); | 3295 | regBar->show(); |
3221 | // qDebug("Showing kbd"); | 3296 | // qDebug("Showing kbd"); |
3222 | #ifdef USEQPE | 3297 | #ifdef USEQPE |
3223 | Global::showInputMethod(); | 3298 | Global::showInputMethod(); |
3224 | #endif | 3299 | #endif |
3225 | regVisible = true; | 3300 | regVisible = true; |
3226 | regEdit->setFocus(); | 3301 | regEdit->setFocus(); |
3227 | // qApp->processEvents(); | 3302 | // qApp->processEvents(); |
3228 | reader->bDoUpdates = true; | 3303 | reader->bDoUpdates = true; |
3229 | reader->update(); | 3304 | reader->update(); |
3230 | } | 3305 | } |
3231 | 3306 | ||
3232 | bool QTReaderApp::openfrombkmk(Bkmk* bk) | 3307 | bool QTReaderApp::openfrombkmk(Bkmk* bk) |
3233 | { | 3308 | { |
3234 | QString fn = toQString( | 3309 | QString fn = toQString( |
3235 | CFiledata(bk->anno()).name() | 3310 | CFiledata(bk->anno()).name() |
3236 | ); | 3311 | ); |
3237 | //qDebug("fileinfo"); | 3312 | //qDebug("fileinfo"); |
3238 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 3313 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
3239 | { | 3314 | { |
3240 | //qDebug("Opening"); | 3315 | //qDebug("Opening"); |
3241 | openFile(fn); | ||
3242 | struct stat fnstat; | 3316 | struct stat fnstat; |
3243 | stat((const char *)reader->m_lastfile, &fnstat); | 3317 | stat((const char *)fn, &fnstat); |
3244 | 3318 | ||
3245 | if (CFiledata(bk->anno()).date() | 3319 | if (CFiledata(bk->anno()).date() |
3246 | != fnstat.st_mtime) | 3320 | != fnstat.st_mtime) |
3247 | { | 3321 | { |
3248 | CFiledata fd(bk->anno()); | 3322 | CFiledata fd(bk->anno()); |
3249 | fd.setdate(fnstat.st_mtime); | 3323 | fd.setdate(fnstat.st_mtime); |
3250 | bk->value(0); | 3324 | bk->value(0); |
3325 | reader->m_lastposn = 0; | ||
3326 | openFile(fn); | ||
3251 | } | 3327 | } |
3252 | else | 3328 | else |
3253 | { | 3329 | { |
3254 | unsigned short svlen = bk->filedatalen(); | 3330 | unsigned short svlen = bk->filedatalen(); |
3255 | unsigned char* svdata = bk->filedata(); | 3331 | unsigned char* svdata = bk->filedata(); |
3332 | openFile(fn, bk->value()); | ||
3256 | reader->putSaveData(svdata, svlen); | 3333 | reader->putSaveData(svdata, svlen); |
3257 | // setstate(svdata, svlen); | 3334 | // setstate(svdata, svlen); |
3258 | if (svlen != 0) | 3335 | if (svlen != 0) |
3259 | { | 3336 | { |
3260 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); | 3337 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); |
3261 | } | 3338 | } |
3262 | // qDebug("updating"); | 3339 | // qDebug("updating"); |
3263 | // showEditTools(); | 3340 | // showEditTools(); |
3264 | reader->locate(bk->value()); | ||
3265 | } | 3341 | } |
3266 | return true; | 3342 | return true; |
3267 | } | 3343 | } |
3268 | else | 3344 | else |
3269 | { | 3345 | { |
3270 | return false; | 3346 | return false; |
3271 | } | 3347 | } |
3272 | } | 3348 | } |
3273 | 3349 | ||
3274 | void QTReaderApp::gotobkmk(int ind) | 3350 | void QTReaderApp::gotobkmk(int ind) |
3275 | { | 3351 | { |
3276 | qDebug("gbkmk"); | 3352 | qDebug("gbkmk"); |
3277 | showEditTools(); | 3353 | showEditTools(); |
3278 | switch (m_nBkmkAction) | 3354 | switch (m_nBkmkAction) |
3279 | { | 3355 | { |
3280 | case cOpenFile: | 3356 | case cOpenFile: |
3281 | { | 3357 | { |
3282 | // qApp->processEvents(); | 3358 | // qApp->processEvents(); |
3283 | if (!openfrombkmk((*pOpenlist)[ind])) | 3359 | if (!openfrombkmk((*pOpenlist)[ind])) |
3284 | { | 3360 | { |
3285 | pOpenlist->erase(ind); | 3361 | pOpenlist->erase(ind); |
3286 | QMessageBox::information(this, PROGNAME, "Can't find file"); | 3362 | QMessageBox::information(this, PROGNAME, "Can't find file"); |
3287 | } | 3363 | } |
3288 | } | 3364 | } |
3289 | break; | 3365 | break; |
3290 | case cGotoBkmk: | 3366 | case cGotoBkmk: |
3291 | reader->buffdoc.saveposn(reader->m_lastfile, reader->pagelocate()); | 3367 | reader->buffdoc.saveposn(reader->m_lastfile, reader->pagelocate()); |
3292 | reader->locate((*pBkmklist)[ind]->value()); | 3368 | reader->locate((*pBkmklist)[ind]->value()); |
3293 | break; | 3369 | break; |
3294 | case cDelBkmk: | 3370 | case cDelBkmk: |
3295 | //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); | 3371 | //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); |
3296 | pBkmklist->erase(ind); | 3372 | pBkmklist->erase(ind); |
3297 | m_fBkmksChanged = true; | 3373 | m_fBkmksChanged = true; |
3298 | reader->refresh(true); | 3374 | reader->refresh(true); |
3299 | // pBkmklist->sort(); | 3375 | // pBkmklist->sort(); |
3300 | break; | 3376 | break; |
3301 | case cRmBkmkFile: | 3377 | case cRmBkmkFile: |
3302 | { | 3378 | { |
3303 | #ifndef USEQPE | 3379 | #ifndef USEQPE |
3304 | QDir d = QDir::home(); // "/" | 3380 | QDir d = QDir::home(); // "/" |
3305 | d.cd(APPDIR); | 3381 | d.cd(APPDIR); |
3306 | d.remove(bkmkselector->text(ind)); | 3382 | d.remove(bkmkselector->text(ind)); |
3307 | #else /* USEQPE */ | 3383 | #else /* USEQPE */ |
3308 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); | 3384 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); |
3309 | #endif /* USEQPE */ | 3385 | #endif /* USEQPE */ |
3310 | } | 3386 | } |
3311 | break; | 3387 | break; |
3312 | case cLdConfig: | 3388 | case cLdConfig: |
3313 | readconfig(APPDIR "/configs", bkmkselector->text(ind), false); | 3389 | readconfig(APPDIR "/configs", bkmkselector->text(ind), false); |
3314 | break; | 3390 | break; |
3315 | case cLdTheme: | 3391 | case cLdTheme: |
3316 | m_themename = bkmkselector->text(ind); | 3392 | m_themename = bkmkselector->text(ind); |
3317 | readconfig(QString(APPDIR "/Themes/")+m_themename , "config", false); | 3393 | readconfig(QString(APPDIR "/Themes/")+m_themename , "config", false); |
3318 | setBackgroundBitmap(); | 3394 | setBackgroundBitmap(); |
3319 | break; | 3395 | break; |
3320 | case cRmConfig: | 3396 | case cRmConfig: |
3321 | { | 3397 | { |
3322 | #ifndef USEQPE | 3398 | #ifndef USEQPE |
3323 | QDir d = QDir::home(); // "/" | 3399 | QDir d = QDir::home(); // "/" |
3324 | d.cd(APPDIR "/configs"); | 3400 | d.cd(APPDIR "/configs"); |
3325 | d.remove(bkmkselector->text(ind)); | 3401 | d.remove(bkmkselector->text(ind)); |
3326 | #else /* USEQPE */ | 3402 | #else /* USEQPE */ |
3327 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); | 3403 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); |
3328 | #endif /* USEQPE */ | 3404 | #endif /* USEQPE */ |
3329 | } | 3405 | } |
3330 | break; | 3406 | break; |
3331 | case cExportLinks: | 3407 | case cExportLinks: |
3332 | { | 3408 | { |
3333 | #ifndef USEQPE | 3409 | #ifndef USEQPE |
3334 | QDir d = QDir::home(); // "/" | 3410 | QDir d = QDir::home(); // "/" |
3335 | d.cd(APPDIR "/urls"); | 3411 | d.cd(APPDIR "/urls"); |
3336 | QFileInfo fi(d, bkmkselector->text(ind)); | 3412 | QFileInfo fi(d, bkmkselector->text(ind)); |
3337 | if (fi.exists()) | 3413 | if (fi.exists()) |
3338 | { | 3414 | { |
3339 | QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); | 3415 | QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); |
3340 | if (!outfile.isEmpty()) | 3416 | if (!outfile.isEmpty()) |
3341 | { | 3417 | { |
3342 | FILE* fout = fopen((const char *)outfile, "w"); | 3418 | FILE* fout = fopen((const char *)outfile, "w"); |
3343 | if (fout != NULL) | 3419 | if (fout != NULL) |
3344 | { | 3420 | { |
3345 | FILE* fin = fopen((const char *)fi.absFilePath(), "r"); | 3421 | FILE* fin = fopen((const char *)fi.absFilePath(), "r"); |
3346 | if (fin != NULL) | 3422 | if (fin != NULL) |
3347 | { | 3423 | { |
3348 | fprintf(fout, "<html><body>\n"); | 3424 | fprintf(fout, "<html><body>\n"); |
3349 | int ch = 0; | 3425 | int ch = 0; |
3350 | while ((ch = fgetc(fin)) != EOF) | 3426 | while ((ch = fgetc(fin)) != EOF) |
3351 | { | 3427 | { |
3352 | fputc(ch, fout); | 3428 | fputc(ch, fout); |
3353 | } | 3429 | } |
3354 | fclose(fin); | 3430 | fclose(fin); |
3355 | fprintf(fout, "</html></body>\n"); | 3431 | fprintf(fout, "</html></body>\n"); |
3356 | d.remove(bkmkselector->text(ind)); | 3432 | d.remove(bkmkselector->text(ind)); |
3357 | } | 3433 | } |
3358 | fclose(fout); | 3434 | fclose(fout); |
3359 | } | 3435 | } |
3360 | else | 3436 | else |
3361 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 3437 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
3362 | } | 3438 | } |
3363 | } | 3439 | } |
3364 | #else /* USEQPE */ | 3440 | #else /* USEQPE */ |
3365 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | 3441 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); |
3366 | if (fin != NULL) | 3442 | if (fin != NULL) |
3367 | { | 3443 | { |
3368 | bool allok = false; | 3444 | bool allok = false; |
3369 | #ifdef OPIE | 3445 | #if defined(OPIE) && defined(OPIEFILEDIALOG) |
3370 | QString outfile = OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, QString::null, QString::null, MimeTypes(), 0, "OpieReader"); | 3446 | QString outfile = OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, QString::null, QString::null, MimeTypes(), 0, "OpieReader"); |
3371 | if (!outfile.isEmpty()) | 3447 | if (!outfile.isEmpty()) |
3372 | { | 3448 | { |
3373 | FILE* fout = fopen((const char *)outfile, "w"); | 3449 | FILE* fout = fopen((const char *)outfile, "w"); |
3374 | if (fout != NULL) | 3450 | if (fout != NULL) |
3375 | { | 3451 | { |
3376 | fprintf(fout, "<html><body>\n"); | 3452 | fprintf(fout, "<html><body>\n"); |
3377 | int ch = 0; | 3453 | int ch = 0; |
3378 | while ((ch = fgetc(fin)) != EOF) | 3454 | while ((ch = fgetc(fin)) != EOF) |
3379 | { | 3455 | { |
3380 | fputc(ch, fout); | 3456 | fputc(ch, fout); |
3381 | } | 3457 | } |
3382 | fprintf(fout, "</html></body>\n"); | 3458 | fprintf(fout, "</html></body>\n"); |
3383 | fclose(fout); | 3459 | fclose(fout); |
3384 | allok = true; | 3460 | allok = true; |
3385 | } | 3461 | } |
3386 | else | 3462 | else |
3387 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 3463 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
3388 | } | 3464 | } |
3389 | fclose(fin); | 3465 | fclose(fin); |
3390 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); | 3466 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); |
3391 | #else | 3467 | #else |
3392 | fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); | 3468 | fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); |
3393 | if (fb->exec()) | 3469 | if (fb->exec()) |
3394 | { | 3470 | { |
3395 | QString outfile = fb->getCurrentFile(); | 3471 | QString outfile = fb->getCurrentFile(); |
3396 | FILE* fout = fopen((const char *)outfile, "w"); | 3472 | FILE* fout = fopen((const char *)outfile, "w"); |
3397 | if (fout != NULL) | 3473 | if (fout != NULL) |
3398 | { | 3474 | { |
3399 | fprintf(fout, "<html><body>\n"); | 3475 | fprintf(fout, "<html><body>\n"); |
3400 | int ch = 0; | 3476 | int ch = 0; |
3401 | while ((ch = fgetc(fin)) != EOF) | 3477 | while ((ch = fgetc(fin)) != EOF) |
3402 | { | 3478 | { |
3403 | fputc(ch, fout); | 3479 | fputc(ch, fout); |
3404 | } | 3480 | } |
3405 | fprintf(fout, "</html></body>\n"); | 3481 | fprintf(fout, "</html></body>\n"); |
3406 | fclose(fout); | 3482 | fclose(fout); |
3407 | allok = true; | 3483 | allok = true; |
3408 | } | 3484 | } |
3409 | else | 3485 | else |
3410 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 3486 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
3411 | } | 3487 | } |
3412 | delete fb; | 3488 | delete fb; |
3413 | fclose(fin); | 3489 | fclose(fin); |
3414 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); | 3490 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); |
3415 | #endif | 3491 | #endif |
3416 | } | 3492 | } |
3417 | else | 3493 | else |
3418 | { | 3494 | { |
3419 | QMessageBox::information(this, PROGNAME, "Couldn't open input"); | 3495 | QMessageBox::information(this, PROGNAME, "Couldn't open input"); |
3420 | } | 3496 | } |
3421 | 3497 | ||
3422 | /* | 3498 | /* |
3423 | CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); | 3499 | CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); |
3424 | int ret = f->exec(); | 3500 | int ret = f->exec(); |
3425 | qDebug("Return:%d", ret); | 3501 | qDebug("Return:%d", ret); |
3426 | DocLnk* doc = f->getDoc(); | 3502 | DocLnk* doc = f->getDoc(); |
3427 | if (doc != NULL) | 3503 | if (doc != NULL) |
3428 | { | 3504 | { |
3429 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | 3505 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); |
3430 | QString rt; | 3506 | QString rt; |
3431 | rt = "<html><body>\n"; | 3507 | rt = "<html><body>\n"; |
3432 | int ch = 0; | 3508 | int ch = 0; |
3433 | while ((ch = fgetc(fin)) != EOF) | 3509 | while ((ch = fgetc(fin)) != EOF) |
3434 | { | 3510 | { |
3435 | rt += (char)ch; | 3511 | rt += (char)ch; |
3436 | } | 3512 | } |
3437 | fclose(fin); | 3513 | fclose(fin); |
3438 | rt += "</html></body>\n"; | 3514 | rt += "</html></body>\n"; |
3439 | if ( doc->name().isEmpty() ) | 3515 | if ( doc->name().isEmpty() ) |
3440 | { | 3516 | { |
3441 | doc->setName(bkmkselector->text(ind)); | 3517 | doc->setName(bkmkselector->text(ind)); |
3442 | } | 3518 | } |
3443 | FileManager fm; | 3519 | FileManager fm; |
3444 | fm.saveFile( *doc, rt ); | 3520 | fm.saveFile( *doc, rt ); |
3445 | qDebug("YES"); | 3521 | qDebug("YES"); |
3446 | } | 3522 | } |
3447 | else | 3523 | else |
3448 | { | 3524 | { |
3449 | qDebug("NO"); | 3525 | qDebug("NO"); |
3450 | } | 3526 | } |
3451 | delete f; | 3527 | delete f; |
3452 | */ | 3528 | */ |
3453 | 3529 | ||
3454 | #endif /* USEQPE */ | 3530 | #endif /* USEQPE */ |
3455 | } | 3531 | } |
3456 | break; | 3532 | break; |
3457 | } | 3533 | } |
3458 | } | 3534 | } |
3459 | 3535 | ||
3460 | void QTReaderApp::cancelbkmk() | 3536 | void QTReaderApp::cancelbkmk() |
3461 | { | 3537 | { |
3462 | if (m_nBkmkAction == cOpenFile) | 3538 | if (m_nBkmkAction == cOpenFile) |
3463 | { | 3539 | { |
3464 | QString fn = usefilebrowser(); | 3540 | QString fn = usefilebrowser(); |
3465 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); | 3541 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); |
3466 | } | 3542 | } |
3467 | showEditTools(); | 3543 | showEditTools(); |
3468 | } | 3544 | } |
3469 | 3545 | ||
3470 | void QTReaderApp::reparastring() | 3546 | void QTReaderApp::reparastring() |
3471 | { | 3547 | { |
3472 | m_nRegAction = cRepara; | 3548 | m_nRegAction = cRepara; |
3473 | regEdit->setText(reader->m_reparastring); | 3549 | regEdit->setText(reader->m_reparastring); |
3474 | do_regedit(); | 3550 | do_regedit(); |
3475 | } | 3551 | } |
3476 | 3552 | ||
3477 | void QTReaderApp::do_reparastring(const QString& _lcn) | 3553 | void QTReaderApp::do_reparastring(const QString& _lcn) |
3478 | { | 3554 | { |
3479 | reader->m_reparastring = _lcn; | 3555 | reader->m_reparastring = _lcn; |
3480 | if (reader->brepara) | 3556 | if (reader->brepara) |
3481 | { | 3557 | { |
3482 | reader->bDoUpdates = true; | 3558 | reader->bDoUpdates = true; |
3483 | reader->setfilter(reader->getfilter()); | 3559 | reader->setfilter(reader->getfilter()); |
3484 | } | 3560 | } |
3485 | } | 3561 | } |
3486 | 3562 | ||
3487 | void QTReaderApp::jump() | 3563 | void QTReaderApp::jump() |
3488 | { | 3564 | { |
3489 | m_nRegAction = cJump; | 3565 | m_nRegAction = cJump; |
3490 | char lcn[20]; | 3566 | char lcn[20]; |
3491 | sprintf(lcn, "%lu", reader->pagelocate()); | 3567 | sprintf(lcn, "%lu", reader->pagelocate()); |
3492 | regEdit->setText(lcn); | 3568 | regEdit->setText(lcn); |
3493 | do_regedit(); | 3569 | do_regedit(); |
3494 | } | 3570 | } |
3495 | 3571 | ||
3496 | void QTReaderApp::do_jump(const QString& _lcn) | 3572 | void QTReaderApp::do_jump(const QString& _lcn) |
3497 | { | 3573 | { |
3498 | bool ok; | 3574 | bool ok; |
3499 | QString lcn = _lcn.stripWhiteSpace(); | 3575 | QString lcn = _lcn.stripWhiteSpace(); |
3500 | unsigned long ulcn = lcn.toULong(&ok); | 3576 | unsigned long ulcn = lcn.toULong(&ok); |
3501 | if (!ok) | 3577 | if (!ok) |
3502 | { | 3578 | { |
3503 | double pc = 0.0; | 3579 | double pc = 0.0; |
3504 | #ifdef _WINDOWS | 3580 | #ifdef _WINDOWS |
3505 | if (lcn.at(lcn.length()-1) == '%') | 3581 | if (lcn.at(lcn.length()-1) == '%') |
3506 | #else | 3582 | #else |
3507 | if (lcn[lcn.length()-1] == '%') | 3583 | if (lcn[lcn.length()-1] == '%') |
3508 | #endif | 3584 | #endif |
3509 | { | 3585 | { |
3510 | lcn = lcn.left(lcn.length()-1); | 3586 | lcn = lcn.left(lcn.length()-1); |
3511 | pc = lcn.toDouble(&ok); | 3587 | pc = lcn.toDouble(&ok); |
3512 | } | 3588 | } |
3513 | else | 3589 | else |
3514 | { | 3590 | { |
3515 | pc = lcn.toDouble(&ok); | 3591 | pc = lcn.toDouble(&ok); |
3516 | } | 3592 | } |
3517 | if (ok && 0 <= pc && pc <= 100) | 3593 | if (ok && 0 <= pc && pc <= 100) |
3518 | { | 3594 | { |
3519 | ulcn = (pc*(reader->buffdoc.endSection()-reader->buffdoc.startSection()))/100 + reader->buffdoc.startSection(); | 3595 | ulcn = (pc*(reader->buffdoc.endSection()-reader->buffdoc.startSection()))/100 + reader->buffdoc.startSection(); |
3520 | } | 3596 | } |
3521 | else | 3597 | else |
3522 | { | 3598 | { |
3523 | ok = false; | 3599 | ok = false; |
3524 | } | 3600 | } |
3525 | } | 3601 | } |
3526 | if (ok) | 3602 | if (ok) |
3527 | reader->locate(ulcn); | 3603 | reader->locate(ulcn); |
3528 | else | 3604 | else |
3529 | QMessageBox::information(this, PROGNAME, "Must be a number\nor a percentage"); | 3605 | QMessageBox::information(this, PROGNAME, "Must be a number\nor a percentage"); |
3530 | } | 3606 | } |
3531 | 3607 | ||
3532 | void QTReaderApp::do_regaction() | 3608 | void QTReaderApp::do_regaction() |
3533 | { | 3609 | { |
3534 | reader->bDoUpdates = false; | 3610 | reader->bDoUpdates = false; |
3535 | regBar->hide(); | 3611 | regBar->hide(); |
3536 | #ifdef USEQPE | 3612 | #ifdef USEQPE |
3537 | Global::hideInputMethod(); | 3613 | Global::hideInputMethod(); |
3538 | #endif | 3614 | #endif |
3539 | regVisible = false; | 3615 | regVisible = false; |
3540 | switch(m_nRegAction) | 3616 | switch(m_nRegAction) |
3541 | { | 3617 | { |
3542 | case cAutoGen: | 3618 | case cAutoGen: |
3543 | do_autogen(regEdit->text()); | 3619 | do_autogen(regEdit->text()); |
3544 | break; | 3620 | break; |
3545 | case cAddBkmk: | 3621 | case cAddBkmk: |
3546 | do_addbkmk(regEdit->text()); | 3622 | do_addbkmk(regEdit->text()); |
3547 | break; | 3623 | break; |
3548 | case cRepara: | 3624 | case cRepara: |
3549 | do_reparastring(regEdit->text()); | 3625 | do_reparastring(regEdit->text()); |
3550 | break; | 3626 | break; |
3551 | case cJump: | 3627 | case cJump: |
3552 | do_jump(regEdit->text()); | 3628 | do_jump(regEdit->text()); |
3553 | break; | 3629 | break; |
3554 | /* | 3630 | /* |
3555 | case cMonoSpace: | 3631 | case cMonoSpace: |
3556 | do_mono(regEdit->text()); | 3632 | do_mono(regEdit->text()); |
3557 | break; | 3633 | break; |
3558 | */ | 3634 | */ |
3559 | case cSetTarget: | 3635 | case cSetTarget: |
3560 | do_settarget(regEdit->text()); | 3636 | do_settarget(regEdit->text()); |
3561 | break; | 3637 | break; |
3562 | #ifdef _SCROLLPIPE | 3638 | #ifdef _SCROLLPIPE |
3563 | case cSetPipeTarget: | 3639 | case cSetPipeTarget: |
3564 | do_setpipetarget(regEdit->text()); | 3640 | do_setpipetarget(regEdit->text()); |
3565 | break; | 3641 | break; |
3566 | #endif | 3642 | #endif |
3567 | case cSetConfigName: | 3643 | case cSetConfigName: |
3568 | // qDebug("Saving config"); | 3644 | // qDebug("Saving config"); |
3569 | do_saveconfig(regEdit->text(), false); | 3645 | do_saveconfig(regEdit->text(), false); |
3570 | break; | 3646 | break; |
3571 | } | 3647 | } |
3572 | // reader->restore(); | 3648 | // reader->restore(); |
3573 | // fileBar->show(); | 3649 | // fileBar->show(); |
3574 | reader->setFocus(); | 3650 | reader->setFocus(); |
3575 | // qApp->processEvents(); | 3651 | // qApp->processEvents(); |
3576 | reader->bDoUpdates = true; | 3652 | reader->bDoUpdates = true; |
3577 | reader->update(); | 3653 | reader->update(); |
3578 | } | 3654 | } |
3579 | 3655 | ||
3580 | void QTReaderApp::do_settarget(const QString& _txt) | 3656 | void QTReaderApp::do_settarget(const QString& _txt) |
3581 | { | 3657 | { |
3582 | int ind = _txt.find('/'); | 3658 | int ind = _txt.find('/'); |
3583 | if (ind == -1) | 3659 | if (ind == -1) |
3584 | { | 3660 | { |
3585 | m_targetapp = ""; | 3661 | m_targetapp = ""; |
3586 | m_targetmsg = ""; | 3662 | m_targetmsg = ""; |
3587 | QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); | 3663 | QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); |
3588 | } | 3664 | } |
3589 | else | 3665 | else |
3590 | { | 3666 | { |
3591 | m_targetapp = _txt.left(ind); | 3667 | m_targetapp = _txt.left(ind); |
3592 | m_targetmsg = _txt.right(_txt.length()-ind-1); | 3668 | m_targetmsg = _txt.right(_txt.length()-ind-1); |
3593 | } | 3669 | } |
3594 | } | 3670 | } |
3595 | 3671 | ||
3596 | void QTReaderApp::chooseencoding() | 3672 | void QTReaderApp::chooseencoding() |
3597 | { | 3673 | { |
3598 | m_fontSelector->clear(); | 3674 | m_fontSelector->clear(); |
3599 | m_fontSelector->insertItem("Ascii"); | 3675 | m_fontSelector->insertItem("Ascii"); |
3600 | m_fontSelector->insertItem("UTF-8"); | 3676 | m_fontSelector->insertItem("UTF-8"); |
3601 | m_fontSelector->insertItem("UCS-2(BE)"); | 3677 | m_fontSelector->insertItem("UCS-2(BE)"); |
3602 | m_fontSelector->insertItem("USC-2(LE)"); | 3678 | m_fontSelector->insertItem("USC-2(LE)"); |
3603 | m_fontSelector->insertItem("Palm"); | 3679 | m_fontSelector->insertItem("Palm"); |
3604 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) | 3680 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) |
3605 | { | 3681 | { |
3606 | m_fontSelector->insertItem(iter->mime); | 3682 | m_fontSelector->insertItem(iter->mime); |
3607 | } // delete the FontDatabase!!! | 3683 | } // delete the FontDatabase!!! |
3608 | m_fontSelector->setCurrentItem (reader->m_encd); | 3684 | m_fontSelector->setCurrentItem (reader->m_encd); |
3609 | m_fontAction = cChooseEncoding; | 3685 | m_fontAction = cChooseEncoding; |
3610 | m_fontBar->show(); | 3686 | m_fontBar->show(); |
3611 | m_fontVisible = true; | 3687 | m_fontVisible = true; |
3612 | } | 3688 | } |
3613 | 3689 | ||
3614 | void QTReaderApp::setfont() | 3690 | void QTReaderApp::setfont() |
3615 | { | 3691 | { |
3616 | m_fontSelector->clear(); | 3692 | m_fontSelector->clear(); |
3617 | { | 3693 | { |
3618 | QFontDatabase f; | 3694 | QFontDatabase f; |
3619 | QStringList flist = f.families(); | 3695 | QStringList flist = f.families(); |
3620 | m_fontSelector->insertStringList(flist); | 3696 | m_fontSelector->insertStringList(flist); |
3621 | } // delete the FontDatabase!!! | 3697 | } // delete the FontDatabase!!! |
3622 | 3698 | ||
3623 | for (int i = 1; i <= m_fontSelector->count(); i++) | 3699 | for (int i = 1; i <= m_fontSelector->count(); i++) |
3624 | { | 3700 | { |
3625 | if (m_fontSelector->text(i) == reader->m_fontname) | 3701 | if (m_fontSelector->text(i) == reader->m_fontname) |
3626 | { | 3702 | { |
3627 | m_fontSelector->setCurrentItem(i); | 3703 | m_fontSelector->setCurrentItem(i); |
3628 | break; | 3704 | break; |
3629 | } | 3705 | } |
3630 | } | 3706 | } |
3631 | m_fontAction = cChooseFont; | 3707 | m_fontAction = cChooseFont; |
3632 | m_fontBar->show(); | 3708 | m_fontBar->show(); |
3633 | m_fontVisible = true; | 3709 | m_fontVisible = true; |
3634 | } | 3710 | } |
3635 | 3711 | ||
3636 | void QTReaderApp::setfontHelper(const QString& lcn, int size) | 3712 | void QTReaderApp::setfontHelper(const QString& lcn, int size) |
3637 | { | 3713 | { |
3638 | if (size == 0) size = reader->m_fontControl.currentsize(); | 3714 | if (size == 0) size = reader->m_fontControl.currentsize(); |
3639 | if (m_propogatefontchange) | 3715 | if (m_propogatefontchange) |
3640 | { | 3716 | { |
3641 | QFont f(lcn, 10); | 3717 | QFont f(lcn, 10); |
3642 | bkmkselector->setFont( f ); | 3718 | bkmkselector->setFont( f ); |
3643 | regEdit->setFont( f ); | 3719 | regEdit->setFont( f ); |
3644 | searchEdit->setFont( f ); | 3720 | searchEdit->setFont( f ); |
3645 | m_annoWin->setFont( f ); | 3721 | m_annoWin->setFont( f ); |
3646 | } | 3722 | } |
3647 | reader->m_fontname = lcn; | 3723 | reader->m_fontname = lcn; |
3648 | if (!reader->ChangeFont(size)) | 3724 | if (!reader->ChangeFont(size)) |
3649 | { | 3725 | { |
3650 | reader->ChangeFont(size); | 3726 | reader->ChangeFont(size); |
3651 | } | 3727 | } |
3652 | } | 3728 | } |
3653 | 3729 | ||
3654 | void QTReaderApp::do_setencoding(int i) | 3730 | void QTReaderApp::do_setencoding(int i) |
3655 | { | 3731 | { |
3656 | qDebug("setencoding:%d", i); | 3732 | qDebug("setencoding:%d", i); |
3657 | if (m_fontAction == cChooseEncoding) | 3733 | if (m_fontAction == cChooseEncoding) |
3658 | { | 3734 | { |
3659 | reader->setencoding(i); | 3735 | reader->setencoding(i); |
3660 | } | 3736 | } |
3661 | reader->refresh(); | 3737 | reader->refresh(); |
3662 | m_fontBar->hide(); | 3738 | m_fontBar->hide(); |
3663 | m_fontVisible = false; | 3739 | m_fontVisible = false; |
3664 | // qDebug("showedit"); | 3740 | // qDebug("showedit"); |
3665 | if (reader->isVisible()) showEditTools(); | 3741 | if (reader->isVisible()) showEditTools(); |
3666 | // qDebug("showeditdone"); | 3742 | // qDebug("showeditdone"); |
3667 | } | 3743 | } |
3668 | 3744 | ||
3669 | void QTReaderApp::do_setfont(const QString& lcn) | 3745 | void QTReaderApp::do_setfont(const QString& lcn) |
3670 | { | 3746 | { |
3671 | if (m_fontAction == cChooseFont) | 3747 | if (m_fontAction == cChooseFont) |
3672 | { | 3748 | { |
3673 | setfontHelper(lcn); | 3749 | setfontHelper(lcn); |
3674 | } | 3750 | } |
3675 | reader->refresh(); | 3751 | reader->refresh(); |
3676 | m_fontBar->hide(); | 3752 | m_fontBar->hide(); |
3677 | m_fontVisible = false; | 3753 | m_fontVisible = false; |
3678 | // qDebug("setfont"); | 3754 | // qDebug("setfont"); |
3679 | //if (reader->isVisible()) | 3755 | //if (reader->isVisible()) |
3680 | showEditTools(); | 3756 | showEditTools(); |
3681 | // qDebug("showeditdone"); | 3757 | // qDebug("showeditdone"); |
3682 | } | 3758 | } |
3683 | 3759 | ||
3684 | void QTReaderApp::do_autogen(const QString& regText) | 3760 | void QTReaderApp::do_autogen(const QString& regText) |
3685 | { | 3761 | { |
3686 | unsigned long fs, ts; | 3762 | unsigned long fs, ts; |
3687 | reader->sizes(fs,ts); | 3763 | reader->sizes(fs,ts); |
3688 | // // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); | 3764 | // // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); |
3689 | m_autogenstr = regText; | 3765 | m_autogenstr = regText; |
3690 | QRegExp re(regText); | 3766 | QRegExp re(regText); |
3691 | CBuffer buff; | 3767 | CBuffer buff; |
3692 | if (pBkmklist != NULL) delete pBkmklist; | 3768 | if (pBkmklist != NULL) delete pBkmklist; |
3693 | reader->pBkmklist = pBkmklist = new CList<Bkmk>; | 3769 | reader->pBkmklist = pBkmklist = new CList<Bkmk>; |
3694 | m_fBkmksChanged = true; | 3770 | m_fBkmksChanged = true; |
3695 | 3771 | ||
3696 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); | 3772 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); |
3697 | pbar->show(); | 3773 | pbar->show(); |
3698 | pbar->raise(); | 3774 | pbar->raise(); |
3699 | pbar->reset(); | 3775 | pbar->reset(); |
3700 | reader->update(); | 3776 | reader->update(); |
3701 | qApp->processEvents(); | 3777 | qApp->processEvents(); |
3702 | reader->setFocus(); | 3778 | reader->setFocus(); |
3703 | reader->jumpto(0); | 3779 | reader->jumpto(0); |
3704 | int lastpc = 0; | 3780 | int lastpc = 0; |
3705 | int i = 0; | 3781 | int i = 0; |
3782 | unsigned int llcn = reader->locate(); | ||
3706 | while (i >= 0) | 3783 | while (i >= 0) |
3707 | { | 3784 | { |
3708 | unsigned int lcn = reader->locate(); | 3785 | unsigned int lcn = llcn; |
3709 | int pc = (100*lcn)/ts; | 3786 | int pc = (100*lcn)/ts; |
3710 | if (pc != lastpc) | 3787 | if (pc != lastpc) |
3711 | { | 3788 | { |
3712 | pbar->setProgress(pc); | 3789 | pbar->setProgress(pc); |
3713 | qApp->processEvents(); | 3790 | qApp->processEvents(); |
3714 | if (reader->locate() != lcn) reader->jumpto(lcn); | 3791 | if (reader->locate() != lcn) reader->jumpto(lcn); |
3715 | reader->setFocus(); | 3792 | reader->setFocus(); |
3716 | lastpc = pc; | 3793 | lastpc = pc; |
3717 | } | 3794 | } |
3718 | i = reader->buffdoc.getpara(buff); | 3795 | i = reader->buffdoc.getpara(buff); |
3719 | #ifdef _UNICODE | 3796 | #ifdef _UNICODE |
3720 | if (re.match(toQString(buff.data())) != -1) | 3797 | if (re.match(toQString(buff.data())) != -1) |
3721 | #else | 3798 | #else |
3722 | if (re.match(buff.data()) != -1) | 3799 | if (re.match(buff.data()) != -1) |
3723 | #endif | 3800 | #endif |
3724 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); | 3801 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); |
3802 | /* | ||
3803 | llcn = reader->locate(); | ||
3804 | if ((i == 0) && (llcn+1 < ts)) | ||
3805 | { | ||
3806 | reader->jumpto(++llcn); | ||
3807 | i = 1; | ||
3808 | } | ||
3809 | */ | ||
3725 | } | 3810 | } |
3726 | pBkmklist->sort(); | 3811 | pBkmklist->sort(); |
3727 | pbar->setProgress(100); | 3812 | pbar->setProgress(100); |
3728 | qApp->processEvents(); | 3813 | qApp->processEvents(); |
3729 | pbar->hide(); | 3814 | pbar->hide(); |
3730 | reader->refresh(); | 3815 | reader->refresh(); |
3731 | } | 3816 | } |
3732 | 3817 | ||
3733 | void QTReaderApp::saveprefs() | 3818 | void QTReaderApp::saveprefs() |
3734 | { | 3819 | { |
3735 | do_saveconfig( APPDIR, true ); | 3820 | do_saveconfig( APPDIR, true ); |
3736 | savefilelist(); | 3821 | savefilelist(); |
3737 | } | 3822 | } |
3738 | 3823 | ||
3739 | /* | 3824 | /* |
3740 | void QTReaderApp::oldFile() | 3825 | void QTReaderApp::oldFile() |
3741 | { | 3826 | { |
3742 | // qDebug("oldFile called"); | 3827 | // qDebug("oldFile called"); |
3743 | reader->setText(true); | 3828 | reader->setText(true); |
3744 | // qDebug("settext called"); | 3829 | // qDebug("settext called"); |
3745 | showEditTools(); | 3830 | showEditTools(); |
3746 | // qDebug("showedit called"); | 3831 | // qDebug("showedit called"); |
3747 | } | 3832 | } |
3748 | */ | 3833 | */ |
3749 | 3834 | ||
3750 | /* | 3835 | /* |
3751 | void info_cb(Fl_Widget* o, void* _data) | 3836 | void info_cb(Fl_Widget* o, void* _data) |
3752 | { | 3837 | { |
3753 | 3838 | ||
3754 | if (infowin == NULL) | 3839 | if (infowin == NULL) |
3755 | { | 3840 | { |
3756 | 3841 | ||
3757 | infowin = new Fl_Window(160,240); | 3842 | infowin = new Fl_Window(160,240); |
3758 | filename = new Fl_Output(45,5,110,14,"Filename"); | 3843 | filename = new Fl_Output(45,5,110,14,"Filename"); |
3759 | filesize = new Fl_Output(45,25,110,14,"Filesize"); | 3844 | filesize = new Fl_Output(45,25,110,14,"Filesize"); |
3760 | textsize = new Fl_Output(45,45,110,14,"Textsize"); | 3845 | textsize = new Fl_Output(45,45,110,14,"Textsize"); |
3761 | comprat = new CBar(45,65,110,14,"Ratio %"); | 3846 | comprat = new CBar(45,65,110,14,"Ratio %"); |
3762 | posn = new Fl_Output(45,85,110,14,"Location"); | 3847 | posn = new Fl_Output(45,85,110,14,"Location"); |
3763 | frcn = new CBar(45,105,110,14,"% Read"); | 3848 | frcn = new CBar(45,105,110,14,"% Read"); |
3764 | about = new Fl_Multiline_Output(5,125,150,90); | 3849 | about = new Fl_Multiline_Output(5,125,150,90); |
3765 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); | 3850 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); |
3766 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); | 3851 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); |
3767 | infowin->set_modal(); | 3852 | infowin->set_modal(); |
3768 | } | 3853 | } |
3769 | if (((reader_ui *)_data)->g_filename[0] != '\0') | 3854 | if (((reader_ui *)_data)->g_filename[0] != '\0') |
3770 | { | 3855 | { |
3771 | unsigned long fs,ts; | 3856 | unsigned long fs,ts; |
3772 | tchar sz[20]; | 3857 | tchar sz[20]; |
3773 | ((reader_ui *)_data)->input->sizes(fs,ts); | 3858 | ((reader_ui *)_data)->input->sizes(fs,ts); |
3774 | unsigned long pl = ((reader_ui *)_data)->input->locate(); | 3859 | unsigned long pl = ((reader_ui *)_data)->input->locate(); |
3775 | 3860 | ||
3776 | filename->value(((reader_ui *)_data)->g_filename); | 3861 | filename->value(((reader_ui *)_data)->g_filename); |
3777 | 3862 | ||
3778 | sprintf(sz,"%u",fs); | 3863 | sprintf(sz,"%u",fs); |
3779 | filesize->value(sz); | 3864 | filesize->value(sz); |
3780 | 3865 | ||
3781 | sprintf(sz,"%u",ts); | 3866 | sprintf(sz,"%u",ts); |
3782 | textsize->value(sz); | 3867 | textsize->value(sz); |
3783 | 3868 | ||
3784 | comprat->value(100-(100*fs + (ts >> 1))/ts); | 3869 | comprat->value(100-(100*fs + (ts >> 1))/ts); |
3785 | 3870 | ||
3786 | sprintf(sz,"%u",pl); | 3871 | sprintf(sz,"%u",pl); |
3787 | posn->value(sz); | 3872 | posn->value(sz); |
3788 | 3873 | ||
3789 | frcn->value((100*pl + (ts >> 1))/ts); | 3874 | frcn->value((100*pl + (ts >> 1))/ts); |
3790 | } | 3875 | } |
3791 | infowin->show(); | 3876 | infowin->show(); |
3792 | } | 3877 | } |
3793 | */ | 3878 | */ |
3794 | 3879 | ||
3795 | void QTReaderApp::savebkmks() | 3880 | void QTReaderApp::savebkmks() |
3796 | { | 3881 | { |
3797 | if (pBkmklist != NULL) | 3882 | if (pBkmklist != NULL) |
3798 | { | 3883 | { |
3799 | #ifndef USEQPE | 3884 | #ifndef USEQPE |
3800 | QDir d = QDir::home(); // "/" | 3885 | QDir d = QDir::home(); // "/" |
3801 | d.cd(APPDIR); | 3886 | d.cd(APPDIR); |
3802 | QFileInfo fi(d, reader->m_string); | 3887 | QFileInfo fi(d, reader->m_string); |
3803 | BkmkFile bf((const char *)fi.absFilePath(), true, true); | 3888 | BkmkFile bf((const char *)fi.absFilePath(), true, true); |
3804 | #else /* USEQPE */ | 3889 | #else /* USEQPE */ |
3805 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true, true); | 3890 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true, true); |
3806 | #endif /* USEQPE */ | 3891 | #endif /* USEQPE */ |
3807 | bf.write(*pBkmklist); | 3892 | bf.write(*pBkmklist); |
3808 | } | 3893 | } |
3809 | m_fBkmksChanged = false; | 3894 | m_fBkmksChanged = false; |
3810 | } | 3895 | } |
3811 | 3896 | ||
3812 | void QTReaderApp::readfilelist() | 3897 | void QTReaderApp::readfilelist() |
3813 | { | 3898 | { |
3814 | #ifndef USEQPE | 3899 | #ifndef USEQPE |
3815 | QDir d = QDir::home(); // "/" | 3900 | QDir d = QDir::home(); // "/" |
3816 | d.cd(APPDIR); | 3901 | d.cd(APPDIR); |
3817 | QFileInfo fi(d, ".openfiles"); | 3902 | QFileInfo fi(d, ".openfiles"); |
3818 | BkmkFile bf((const char *)fi.absFilePath(), false, false); | 3903 | BkmkFile bf((const char *)fi.absFilePath(), false, false); |
3819 | #else /* USEQPE */ | 3904 | #else /* USEQPE */ |
3820 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), false, false); | 3905 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), false, false); |
3821 | #endif /* USEQPE */ | 3906 | #endif /* USEQPE */ |
3822 | // qDebug("Reading open files"); | 3907 | // qDebug("Reading open files"); |
3823 | pOpenlist = bf.readall(); | 3908 | pOpenlist = bf.readall(); |
3824 | // if (pOpenlist != NULL) qDebug("...with success"); | 3909 | // if (pOpenlist != NULL) qDebug("...with success"); |
3825 | // else qDebug("...without success!"); | 3910 | // else qDebug("...without success!"); |
3826 | } | 3911 | } |
3827 | 3912 | ||
3828 | void QTReaderApp::savefilelist() | 3913 | void QTReaderApp::savefilelist() |
3829 | { | 3914 | { |
3830 | if (pOpenlist != NULL) | 3915 | if (pOpenlist != NULL) |
3831 | { | 3916 | { |
3832 | #ifndef USEQPE | 3917 | #ifndef USEQPE |
3833 | QDir d = QDir::home(); // "/" | 3918 | QDir d = QDir::home(); // "/" |
3834 | d.cd(APPDIR); | 3919 | d.cd(APPDIR); |
3835 | QFileInfo fi(d, ".openfiles"); | 3920 | QFileInfo fi(d, ".openfiles"); |
3836 | BkmkFile bf((const char *)fi.absFilePath(), true, false); | 3921 | BkmkFile bf((const char *)fi.absFilePath(), true, false); |
3837 | #else /* USEQPE */ | 3922 | #else /* USEQPE */ |
3838 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true, false); | 3923 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true, false); |
3839 | #endif /* USEQPE */ | 3924 | #endif /* USEQPE */ |
3840 | //qDebug("Writing open files"); | 3925 | //qDebug("Writing open files"); |
3841 | bf.write(*pOpenlist); | 3926 | bf.write(*pOpenlist); |
3842 | } | 3927 | } |
3843 | } | 3928 | } |
3844 | 3929 | ||
3845 | void QTReaderApp::readbkmks() | 3930 | void QTReaderApp::readbkmks() |
3846 | { | 3931 | { |
3847 | if (pBkmklist != NULL) | 3932 | if (pBkmklist != NULL) |
3848 | { | 3933 | { |
3849 | delete pBkmklist; | 3934 | delete pBkmklist; |
3850 | } | 3935 | } |
3851 | struct stat fnstat; | 3936 | struct stat fnstat; |
3852 | struct stat bkstat; | 3937 | struct stat bkstat; |
3853 | #ifndef USEQPE | 3938 | #ifndef USEQPE |
3854 | QDir d = QDir::home(); // "/" | 3939 | QDir d = QDir::home(); // "/" |
3855 | d.cd(APPDIR); | 3940 | d.cd(APPDIR); |
3856 | QFileInfo fi(d, reader->m_string); | 3941 | QFileInfo fi(d, reader->m_string); |
3857 | #endif /* ! USEQPE */ | 3942 | #endif /* ! USEQPE */ |
3858 | if ( | 3943 | if ( |
3859 | stat((const char *)reader->m_lastfile, &fnstat) == 0 | 3944 | stat((const char *)reader->m_lastfile, &fnstat) == 0 |
3860 | && | 3945 | && |
3861 | #ifndef USEQPE | 3946 | #ifndef USEQPE |
3862 | stat((const char *)fi.absFilePath(), &bkstat) == 0 | 3947 | stat((const char *)fi.absFilePath(), &bkstat) == 0 |
3863 | #else /* USEQPE */ | 3948 | #else /* USEQPE */ |
3864 | stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 | 3949 | stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 |
3865 | #endif /* USEQPE */ | 3950 | #endif /* USEQPE */ |
3866 | ) | 3951 | ) |
3867 | { | 3952 | { |
3868 | if (bkstat.st_mtime < fnstat.st_mtime) | 3953 | if (bkstat.st_mtime < fnstat.st_mtime) |
3869 | { | 3954 | { |
3870 | #ifndef USEQPE | 3955 | #ifndef USEQPE |
3871 | unlink((const char *)fi.absFilePath()); | 3956 | unlink((const char *)fi.absFilePath()); |
3872 | #else /* USEQPE */ | 3957 | #else /* USEQPE */ |
3873 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 3958 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
3874 | #endif /* USEQPE */ | 3959 | #endif /* USEQPE */ |
3875 | } | 3960 | } |
3876 | } | 3961 | } |
3877 | 3962 | ||
3878 | #ifndef USEQPE | 3963 | #ifndef USEQPE |
3879 | BkmkFile bf((const char *)fi.absFilePath(), false, true); | 3964 | BkmkFile bf((const char *)fi.absFilePath(), false, true); |
3880 | #else /* USEQPE */ | 3965 | #else /* USEQPE */ |
3881 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), false, true); | 3966 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), false, true); |
3882 | #endif /* USEQPE */ | 3967 | #endif /* USEQPE */ |
3883 | 3968 | ||
3884 | reader->pBkmklist = pBkmklist = bf.readall(); | 3969 | reader->pBkmklist = pBkmklist = bf.readall(); |
3885 | m_fBkmksChanged = bf.upgraded(); | 3970 | m_fBkmksChanged = bf.upgraded(); |
3886 | if (pBkmklist == NULL) | 3971 | if (pBkmklist == NULL) |
3887 | { | 3972 | { |
3888 | reader->pBkmklist = pBkmklist = reader->getbkmklist(); | 3973 | reader->pBkmklist = pBkmklist = reader->getbkmklist(); |
3889 | } | 3974 | } |
3890 | if (pBkmklist != NULL) | 3975 | if (pBkmklist != NULL) |
3891 | pBkmklist->sort(); | 3976 | pBkmklist->sort(); |
3892 | } | 3977 | } |
3893 | 3978 | ||
3894 | void QTReaderApp::addbkmk() | 3979 | void QTReaderApp::addbkmk() |
3895 | { | 3980 | { |
3896 | m_nRegAction = cAddBkmk; | 3981 | m_nRegAction = cAddBkmk; |
3897 | regEdit->setText(reader->firstword()); | 3982 | regEdit->setText(reader->firstword()); |
3898 | do_regedit(); | 3983 | do_regedit(); |
3899 | } | 3984 | } |
3900 | 3985 | ||
3901 | void QTReaderApp::do_addbkmk(const QString& text) | 3986 | void QTReaderApp::do_addbkmk(const QString& text) |
3902 | { | 3987 | { |
3903 | if (text.isEmpty()) | 3988 | if (text.isEmpty()) |
3904 | { | 3989 | { |
3905 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); | 3990 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); |
3906 | } | 3991 | } |
3907 | else | 3992 | else |
3908 | { | 3993 | { |
3909 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; | 3994 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; |
3910 | #ifdef _UNICODE | 3995 | #ifdef _UNICODE |
3911 | CBuffer buff; | 3996 | CBuffer buff; |
3912 | int i = 0; | 3997 | int i = 0; |
3913 | for (i = 0; i < text.length(); i++) | 3998 | for (i = 0; i < text.length(); i++) |
3914 | { | 3999 | { |
3915 | buff[i] = text[i].unicode(); | 4000 | buff[i] = text[i].unicode(); |
3916 | } | 4001 | } |
3917 | buff[i] = 0; | 4002 | buff[i] = 0; |
3918 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); | 4003 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); |
3919 | #else | 4004 | #else |
3920 | pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); | 4005 | pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); |
3921 | #endif | 4006 | #endif |
3922 | m_fBkmksChanged = true; | 4007 | m_fBkmksChanged = true; |
3923 | pBkmklist->sort(); | 4008 | pBkmklist->sort(); |
3924 | reader->refresh(true); | 4009 | reader->refresh(true); |
3925 | } | 4010 | } |
3926 | } | 4011 | } |
3927 | 4012 | ||
3928 | void QTReaderApp::UpdateStatus() | 4013 | void QTReaderApp::UpdateStatus() |
3929 | { | 4014 | { |
3930 | QString status; | 4015 | QString status; |
3931 | for (int i = 0; i < m_statusstring.length(); i++) | 4016 | for (int i = 0; i < m_statusstring.length(); i++) |
3932 | { | 4017 | { |
3933 | if (m_statusstring[i].unicode() == '%') | 4018 | if (m_statusstring[i].unicode() == '%') |
3934 | { | 4019 | { |
3935 | i++; | 4020 | i++; |
3936 | if (i < m_statusstring.length()) | 4021 | if (i < m_statusstring.length()) |
3937 | { | 4022 | { |
3938 | switch (m_statusstring[i].unicode()) | 4023 | switch (m_statusstring[i].unicode()) |
3939 | { | 4024 | { |
3940 | case 'F': | 4025 | case 'F': |
3941 | { | 4026 | { |
3942 | unsigned long fs,ts; | 4027 | unsigned long fs,ts; |
3943 | reader->sizes(fs,ts); | 4028 | reader->sizes(fs,ts); |
3944 | status += filesize(ts); | 4029 | status += filesize(ts); |
3945 | } | 4030 | } |
3946 | break; | 4031 | break; |
3947 | case 'f': | 4032 | case 'f': |
3948 | { | 4033 | { |
3949 | status += filesize(reader->pagelocate()); | 4034 | status += filesize(reader->pagelocate()); |
3950 | } | 4035 | } |
3951 | break; | 4036 | break; |
3952 | case 'D': | 4037 | case 'D': |
3953 | { | 4038 | { |
3954 | status += filesize(reader->buffdoc.endSection()-reader->buffdoc.startSection()); | 4039 | status += filesize(reader->buffdoc.endSection()-reader->buffdoc.startSection()); |
3955 | } | 4040 | } |
3956 | break; | 4041 | break; |
3957 | case 'd': | 4042 | case 'd': |
3958 | { | 4043 | { |
3959 | status += filesize(reader->pagelocate()-reader->buffdoc.startSection()); | 4044 | status += filesize(reader->pagelocate()-reader->buffdoc.startSection()); |
3960 | } | 4045 | } |
3961 | break; | 4046 | break; |
3962 | case 'P': | 4047 | case 'P': |
3963 | { | 4048 | { |
3964 | unsigned long fs,ts; | 4049 | unsigned long fs,ts; |
3965 | reader->sizes(fs,ts); | 4050 | reader->sizes(fs,ts); |
3966 | status += percent(reader->pagelocate(),ts); | 4051 | status += percent(reader->pagelocate(),ts); |
3967 | } | 4052 | } |
3968 | break; | 4053 | break; |
3969 | case 'p': | 4054 | case 'p': |
3970 | { | 4055 | { |
3971 | status += percent(reader->pagelocate()-reader->buffdoc.startSection(),reader->buffdoc.endSection()-reader->buffdoc.startSection()); | 4056 | status += percent(reader->pagelocate()-reader->buffdoc.startSection(),reader->buffdoc.endSection()-reader->buffdoc.startSection()); |
3972 | } | 4057 | } |
3973 | break; | 4058 | break; |
3974 | case 'z': | 4059 | case 'z': |
3975 | { | 4060 | { |
3976 | // qDebug("case d"); | 4061 | // qDebug("case d"); |
3977 | status += QString().setNum(reader->m_fontControl.currentsize()*10); | 4062 | status += QString().setNum(reader->m_fontControl.currentsize()*10); |
3978 | } | 4063 | } |
3979 | break; | 4064 | break; |
3980 | default: | 4065 | default: |
3981 | status += m_statusstring[i]; | 4066 | status += m_statusstring[i]; |
3982 | } | 4067 | } |
3983 | } | 4068 | } |
3984 | } | 4069 | } |
3985 | else | 4070 | else |
3986 | { | 4071 | { |
3987 | status += m_statusstring[i]; | 4072 | status += m_statusstring[i]; |
3988 | } | 4073 | } |
3989 | } | 4074 | } |
3990 | m_prog->setText(status); | 4075 | m_prog->setText(status); |
3991 | } | 4076 | } |
3992 | 4077 | ||
3993 | void QTReaderApp::OnRedraw() | 4078 | void QTReaderApp::OnRedraw() |
3994 | { | 4079 | { |
3995 | if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) | 4080 | if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) |
3996 | { | 4081 | { |
3997 | bool found = findNextBookmark(reader->pagelocate()); | 4082 | bool found = findNextBookmark(reader->pagelocate()); |
3998 | m_bkmkAvail->setEnabled(found); | 4083 | m_bkmkAvail->setEnabled(found); |
3999 | } | 4084 | } |
4000 | if (m_scrollbar != NULL) | 4085 | if (m_scrollbar != NULL) |
4001 | { | 4086 | { |
4002 | //qDebug("OnRedraw:[%u, %u]", reader->buffdoc.startSection(), reader->buffdoc.endSection()); | 4087 | //qDebug("OnRedraw:[%u, %u]", reader->buffdoc.startSection(), reader->buffdoc.endSection()); |
4003 | scrollbar->setRange(reader->buffdoc.startSection(), reader->buffdoc.endSection()-1); | 4088 | scrollbar->setRange(reader->buffdoc.startSection(), reader->buffdoc.endSection()-1); |
4004 | scrollbar->setPageStep(reader->locate()-reader->pagelocate()); | 4089 | scrollbar->setPageStep(reader->locate()-reader->pagelocate()); |
4005 | scrollbar->setValue((reader->m_rotated) ? | 4090 | scrollbar->setValue((reader->m_rotated) ? |
4006 | (reader->buffdoc.endSection() - reader->locate()+reader->buffdoc.startSection()) : | 4091 | (reader->buffdoc.endSection() - reader->locate()+reader->buffdoc.startSection()) : |
4007 | reader->pagelocate()); | 4092 | reader->pagelocate()); |
4008 | } | 4093 | } |
4009 | if (m_prog->isVisible()) | 4094 | if (m_prog->isVisible()) |
4010 | { | 4095 | { |
4011 | // qDebug("updating status"); | 4096 | // qDebug("updating status"); |
4012 | UpdateStatus(); | 4097 | UpdateStatus(); |
4013 | // qDebug("updated status"); | 4098 | // qDebug("updated status"); |
4014 | } | 4099 | } |
4015 | } | 4100 | } |
4016 | 4101 | ||
4017 | void QTReaderApp::showAnnotation() | 4102 | void QTReaderApp::showAnnotation() |
4018 | { | 4103 | { |
4019 | m_annoWin->setName(toQString(m_anno->name())); | 4104 | m_annoWin->setName(toQString(m_anno->name())); |
4020 | m_annoWin->setAnno(toQString(m_anno->anno())); | 4105 | m_annoWin->setAnno(toQString(m_anno->anno())); |
4021 | m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); | 4106 | m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); |
4022 | m_annoIsEditing = false; | 4107 | m_annoIsEditing = false; |
4023 | #ifdef USEQPE | 4108 | #ifdef USEQPE |
4024 | Global::showInputMethod(); | 4109 | Global::showInputMethod(); |
4025 | #endif | 4110 | #endif |
4026 | editorStack->raiseWidget( m_annoWin ); | 4111 | editorStack->raiseWidget( m_annoWin ); |
4027 | hidetoolbars(); | 4112 | hidetoolbars(); |
4028 | m_annoWin->setFocus(); | 4113 | m_annoWin->setFocus(); |
4029 | } | 4114 | } |
4030 | 4115 | ||
4031 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, size_t posn2, const QString& line) | 4116 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, size_t posn2, const QString& line) |
4032 | { | 4117 | { |
4033 | //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); | 4118 | //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); |
4034 | 4119 | ||
4120 | if (m_doOutput && reader->checkoutput()) | ||
4121 | { | ||
4122 | reader->doOutput(wrd); | ||
4123 | } | ||
4035 | if (m_doClipboard) | 4124 | if (m_doClipboard) |
4036 | { | 4125 | { |
4037 | QClipboard* cb = QApplication::clipboard(); | 4126 | QClipboard* cb = QApplication::clipboard(); |
4038 | cb->setText(wrd); | 4127 | cb->setText(wrd); |
4039 | #ifdef USEQPE | 4128 | #ifdef USEQPE |
4040 | if (wrd.length() > 10) | 4129 | if (wrd.length() > 10) |
4041 | { | 4130 | { |
4042 | Global::statusMessage(wrd.left(8) + ".."); | 4131 | Global::statusMessage(wrd.left(8) + ".."); |
4043 | } | 4132 | } |
4044 | else | 4133 | else |
4045 | { | 4134 | { |
4046 | Global::statusMessage(wrd); | 4135 | Global::statusMessage(wrd); |
4047 | } | 4136 | } |
4048 | #endif | 4137 | #endif |
4049 | } | 4138 | } |
4050 | if (m_doAnnotation) | 4139 | if (m_doAnnotation) |
4051 | { | 4140 | { |
4052 | //addAnno(wrd, "Need to be able to edit this", posn); | 4141 | //addAnno(wrd, "Need to be able to edit this", posn); |
4053 | m_annoWin->setName(line); | 4142 | m_annoWin->setName(line); |
4054 | m_annoWin->setAnno(""); | 4143 | m_annoWin->setAnno(""); |
4055 | m_annoWin->setPosn(posn); | 4144 | m_annoWin->setPosn(posn); |
4056 | m_annoWin->setPosn2(posn2); | 4145 | m_annoWin->setPosn2(posn2); |
4057 | m_annoIsEditing = true; | 4146 | m_annoIsEditing = true; |
4058 | #ifdef USEQPE | 4147 | #ifdef USEQPE |
4059 | Global::showInputMethod(); | 4148 | Global::showInputMethod(); |
4060 | #endif | 4149 | #endif |
4061 | editorStack->raiseWidget( m_annoWin ); | 4150 | editorStack->raiseWidget( m_annoWin ); |
4062 | hidetoolbars(); | 4151 | hidetoolbars(); |
4063 | } | 4152 | } |
4064 | #ifdef USEQPE | 4153 | #ifdef USEQPE |
4065 | if (m_doDictionary) | 4154 | if (m_doDictionary) |
4066 | { | 4155 | { |
4067 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) | 4156 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) |
4068 | { | 4157 | { |
4069 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); | 4158 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); |
4070 | e << wrd; | 4159 | e << wrd; |
4071 | } | 4160 | } |
4072 | } | 4161 | } |
4073 | #endif | 4162 | #endif |
4074 | } | 4163 | } |
4075 | 4164 | ||
4076 | void QTReaderApp::doAction(QKeyEvent* e) | 4165 | void QTReaderApp::doAction(QKeyEvent* e) |
4077 | { | 4166 | { |
4078 | QMap<orKey,int>::Iterator f = kmap.end(); | 4167 | QMap<orKey,int>::Iterator f = kmap.end(); |
4079 | 4168 | ||
4080 | if (reader->m_autoScroll) | 4169 | if (reader->m_autoScroll) |
4081 | { | 4170 | { |
4082 | f = kmap.find(orKey(e->state(), e->key(), true)); | 4171 | f = kmap.find(orKey(e->state(), e->key(), true)); |
4083 | } | 4172 | } |
4084 | if (f == kmap.end()) | 4173 | if (f == kmap.end()) |
4085 | { | 4174 | { |
4086 | f = kmap.find(orKey(e->state(), e->key(), false)); | 4175 | f = kmap.find(orKey(e->state(), e->key(), false)); |
4087 | } | 4176 | } |
4088 | 4177 | ||
4089 | if (f == kmap.end()) | 4178 | if (f == kmap.end()) |
4090 | { | 4179 | { |
4091 | qDebug("doaction (no action) : %d %d %d", e->key(), e->state(), f.data()); | 4180 | qDebug("doaction (no action) : %d %d %d", e->key(), e->state(), f.data()); |
4092 | e->ignore(); | 4181 | e->ignore(); |
4093 | } | 4182 | } |
4094 | else | 4183 | else |
4095 | { | 4184 | { |
4096 | qDebug("doaction (some action) : %d %d %d", e->key(), e->state(), f.data()); | 4185 | qDebug("doaction (some action) : %d %d %d", e->key(), e->state(), f.data()); |
4097 | ActionTypes a = (ActionTypes)f.data(); | 4186 | ActionTypes a = (ActionTypes)f.data(); |
4098 | e->accept(); | 4187 | e->accept(); |
4099 | //qDebug("Accepted"); | 4188 | //qDebug("Accepted"); |
4100 | switch (a) | 4189 | switch (a) |
4101 | { | 4190 | { |
4102 | case cesGotoLink: | 4191 | case cesGotoLink: |
4103 | { | 4192 | { |
4104 | reader->gotoLink(); | 4193 | reader->gotoLink(); |
4105 | } | 4194 | } |
4106 | break; | 4195 | break; |
4107 | case cesNextLink: | 4196 | case cesNextLink: |
4108 | { | 4197 | { |
4109 | reader->getNextLink(); | 4198 | reader->getNextLink(); |
4110 | } | 4199 | } |
4111 | break; | 4200 | break; |
4112 | case cesInvertColours: | 4201 | case cesInvertColours: |
4113 | m_inverse_action->setOn(!reader->bInverse); | 4202 | m_inverse_action->setOn(!reader->bInverse); |
4114 | break; | 4203 | break; |
4115 | case cesToggleBars: | 4204 | case cesToggleBars: |
4116 | m_hidebars = !m_hidebars; | 4205 | m_hidebars = !m_hidebars; |
4117 | if (m_hidebars) | 4206 | if (m_hidebars) |
4118 | { | 4207 | { |
4119 | #ifdef USEQPE | 4208 | #if defined(USEQPE) |
4120 | menubar->hide(); | 4209 | menubar->hide(); |
4121 | #endif | 4210 | #endif |
4122 | if (fileBar != NULL) fileBar->hide(); | 4211 | if (fileBar != NULL) fileBar->hide(); |
4123 | if (viewBar != NULL) viewBar->hide(); | 4212 | if (viewBar != NULL) viewBar->hide(); |
4124 | if (navBar != NULL) navBar->hide(); | 4213 | if (navBar != NULL) navBar->hide(); |
4125 | if (markBar != NULL) markBar->hide(); | 4214 | if (markBar != NULL) markBar->hide(); |
4126 | mb->hide(); | 4215 | mb->hide(); |
4127 | } | 4216 | } |
4128 | else | 4217 | else |
4129 | { | 4218 | { |
4130 | #ifdef USEQPE | 4219 | #if defined(USEQPE) |
4131 | menubar->show(); | 4220 | menubar->show(); |
4132 | #endif | 4221 | #endif |
4133 | if (fileBar != NULL) fileBar->show(); | 4222 | if (fileBar != NULL) fileBar->show(); |
4134 | if (viewBar != NULL) viewBar->show(); | 4223 | if (viewBar != NULL) viewBar->show(); |
4135 | if (navBar != NULL) navBar->show(); | 4224 | if (navBar != NULL) navBar->show(); |
4136 | if (markBar != NULL) markBar->show(); | 4225 | if (markBar != NULL) markBar->show(); |
4137 | mb->show(); | 4226 | mb->show(); |
4138 | } | 4227 | } |
4139 | break; | 4228 | break; |
4140 | case cesToggleScrollBar: | 4229 | case cesToggleScrollBar: |
4141 | if (m_scrollbar != NULL) | 4230 | if (m_scrollbar != NULL) |
4142 | { | 4231 | { |
4143 | if (m_scrollbar->isHidden()) | 4232 | if (m_scrollbar->isHidden()) |
4144 | { | 4233 | { |
4145 | m_scrollishidden = false; | 4234 | m_scrollishidden = false; |
4146 | m_scrollbar->show(); | 4235 | m_scrollbar->show(); |
4147 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; | 4236 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; |
4148 | } | 4237 | } |
4149 | else | 4238 | else |
4150 | { | 4239 | { |
4151 | m_scrollishidden = true; | 4240 | m_scrollishidden = true; |
4152 | m_scrollbar->hide(); | 4241 | m_scrollbar->hide(); |
4153 | reader->m_scrollpos = m_localscroll; | 4242 | reader->m_scrollpos = m_localscroll; |
4154 | } | 4243 | } |
4155 | } | 4244 | } |
4156 | break; | 4245 | break; |
4157 | case cesToggleStatusBar: | 4246 | case cesToggleStatusBar: |
4158 | if (m_prog != NULL) | 4247 | if (m_prog != NULL) |
4159 | { | 4248 | { |
4160 | if (m_prog->isHidden()) | 4249 | if (m_prog->isHidden()) |
4161 | { | 4250 | { |
4162 | m_statusishidden = false; | 4251 | m_statusishidden = false; |
4163 | m_prog->show(); | 4252 | m_prog->show(); |
4164 | } | 4253 | } |
4165 | else | 4254 | else |
4166 | { | 4255 | { |
4167 | m_statusishidden = true; | 4256 | m_statusishidden = true; |
4168 | m_prog->hide(); | 4257 | m_prog->hide(); |
4169 | } | 4258 | } |
4170 | } | 4259 | } |
4171 | break; | 4260 | break; |
4172 | case cesOpenFile: | 4261 | case cesOpenFile: |
4173 | { | 4262 | { |
4174 | qDebug("Open file"); | 4263 | qDebug("Open file"); |
4175 | fileOpen(); | 4264 | fileOpen(); |
4176 | } | 4265 | } |
4177 | break; | 4266 | break; |
4178 | case cesAutoScroll: | 4267 | case cesAutoScroll: |
4179 | { | 4268 | { |
4180 | reader->setautoscroll(!reader->m_autoScroll); | 4269 | reader->setautoscroll(!reader->m_autoScroll); |
4181 | setScrollState(reader->m_autoScroll); | 4270 | setScrollState(reader->m_autoScroll); |
4182 | } | 4271 | } |
4183 | break; | 4272 | break; |
4184 | case cesActionMark: | 4273 | case cesActionMark: |
4185 | { | 4274 | { |
4186 | addbkmk(); | 4275 | addbkmk(); |
4187 | } | 4276 | } |
4188 | break; | 4277 | break; |
4189 | case cesFullScreen: | 4278 | case cesFullScreen: |
4190 | { | 4279 | { |
4191 | m_actFullscreen->setOn(!m_fullscreen); | 4280 | m_actFullscreen->setOn(!m_fullscreen); |
4192 | } | 4281 | } |
4193 | break; | 4282 | break; |
4194 | case cesRotate: | 4283 | case cesRotate: |
4195 | { | 4284 | { |
4196 | m_rotate_action->setOn(!reader->m_rotated); | 4285 | m_rotate_action->setOn(!reader->m_rotated); |
4197 | } | 4286 | } |
4198 | break; | 4287 | break; |
4199 | case cesActionAnno: | 4288 | case cesActionAnno: |
4200 | { | 4289 | { |
4201 | addanno(); | 4290 | addanno(); |
4202 | } | 4291 | } |
4203 | break; | 4292 | break; |
4204 | case cesZoomIn: | 4293 | case cesZoomIn: |
4205 | zoomin(); | 4294 | zoomin(); |
4206 | break; | 4295 | break; |
4207 | case cesZoomOut: | 4296 | case cesZoomOut: |
4208 | zoomout(); | 4297 | zoomout(); |
4209 | break; | 4298 | break; |
4210 | case cesBack: | 4299 | case cesBack: |
4211 | reader->goBack(); | 4300 | reader->goBack(); |
4212 | break; | 4301 | break; |
4213 | case cesForward: | 4302 | case cesForward: |
4214 | reader->goForward(); | 4303 | reader->goForward(); |
4215 | break; | 4304 | break; |
4216 | case cesHome: | 4305 | case cesHome: |
4217 | reader->goHome(); | 4306 | reader->goHome(); |
4218 | break; | 4307 | break; |
4219 | case cesPageUp: | 4308 | case cesPageUp: |
4220 | reader->dopageup(); | 4309 | reader->dopageup(); |
4221 | /* | 4310 | /* |
4222 | ftime(&m_lastkeytime); | 4311 | ftime(&m_lastkeytime); |
4223 | m_fndelay = m_debounce; | 4312 | m_fndelay = m_debounce; |
4224 | // | 4313 | // |
4225 | { | 4314 | { |
4226 | timeb now; | 4315 | timeb now; |
4227 | ftime(&now); | 4316 | ftime(&now); |
4228 | m_fndelay = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm+100; | 4317 | m_fndelay = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm+100; |
4229 | } | 4318 | } |
4230 | */ | 4319 | */ |
4231 | break; | 4320 | break; |
4232 | case cesPageDown: | 4321 | case cesPageDown: |
4233 | reader->dopagedn(); | 4322 | reader->dopagedn(); |
4234 | /* | 4323 | /* |
4235 | ftime(&m_lastkeytime); | 4324 | ftime(&m_lastkeytime); |
4236 | m_fndelay = m_debounce; | 4325 | m_fndelay = m_debounce; |
4237 | // | 4326 | // |
4238 | if (m_debounce != 0) | 4327 | if (m_debounce != 0) |
4239 | { | 4328 | { |
4240 | timeb now; | 4329 | timeb now; |
4241 | ftime(&now); | 4330 | ftime(&now); |
4242 | m_fndelay = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm+10; | 4331 | m_fndelay = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm+10; |
4243 | } | 4332 | } |
4244 | */ | 4333 | */ |
4245 | break; | 4334 | break; |
4246 | case cesLineUp: | 4335 | case cesLineUp: |
4247 | reader->lineUp(); | 4336 | reader->lineUp(); |
4248 | break; | 4337 | break; |
4249 | case cesLineDown: | 4338 | case cesLineDown: |
4250 | reader->lineDown(); | 4339 | reader->lineDown(); |
4251 | break; | 4340 | break; |
4252 | case cesStartDoc: | 4341 | case cesStartDoc: |
4253 | gotoStart(); | 4342 | gotoStart(); |
4254 | break; | 4343 | break; |
4255 | case cesEndDoc: | 4344 | case cesEndDoc: |
4256 | gotoEnd(); | 4345 | gotoEnd(); |
4257 | break; | 4346 | break; |
4258 | case cesScrollMore: | 4347 | case cesScrollMore: |
4259 | reader->increaseScroll(); | 4348 | reader->increaseScroll(); |
4260 | break; | 4349 | break; |
4261 | case cesScrollLess: | 4350 | case cesScrollLess: |
4262 | reader->reduceScroll(); | 4351 | reader->reduceScroll(); |
4263 | break; | 4352 | break; |
4264 | default: | 4353 | default: |
4265 | qDebug("Unknown ActionType:%u", a); | 4354 | qDebug("Unknown ActionType:%u", a); |
4266 | break; | 4355 | break; |
4267 | } | 4356 | } |
4268 | } | 4357 | } |
4269 | } | 4358 | } |
4270 | 4359 | ||
4271 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } | 4360 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } |
4272 | void QTReaderApp::restoreFocus() { reader->setFocus(); } | 4361 | void QTReaderApp::restoreFocus() { reader->setFocus(); } |
4273 | 4362 | ||
4274 | void QTReaderApp::SaveConfig() | 4363 | void QTReaderApp::SaveConfig() |
4275 | { | 4364 | { |
4276 | m_nRegAction = cSetConfigName; | 4365 | m_nRegAction = cSetConfigName; |
4277 | regEdit->setText(reader->m_string); | 4366 | regEdit->setText(reader->m_string); |
4278 | do_regedit(); | 4367 | do_regedit(); |
4279 | } | 4368 | } |
4280 | 4369 | ||
4281 | void QTReaderApp::do_saveconfig(const QString& _txt, bool full) | 4370 | void QTReaderApp::do_saveconfig(const QString& _txt, bool full) |
4282 | { | 4371 | { |
4283 | // qDebug("do_saveconfig:%s", (const char*)_txt); | 4372 | // qDebug("do_saveconfig:%s", (const char*)_txt); |
4284 | #ifdef USEQPE | 4373 | #ifdef USEQPE |
4285 | QString configname; | 4374 | QString configname; |
4286 | Config::Domain dom; | 4375 | Config::Domain dom; |
4287 | 4376 | ||
4288 | if (full) | 4377 | if (full) |
4289 | { | 4378 | { |
4290 | configname = _txt; | 4379 | configname = _txt; |
4291 | dom = Config::User; | 4380 | dom = Config::User; |
4292 | } | 4381 | } |
4293 | else | 4382 | else |
4294 | { | 4383 | { |
4295 | configname = Global::applicationFileName(APPDIR "/configs", _txt); | 4384 | configname = Global::applicationFileName(APPDIR "/configs", _txt); |
4296 | dom = Config::File; | 4385 | dom = Config::File; |
4297 | } | 4386 | } |
4298 | 4387 | ||
4299 | Config config(configname, dom); | 4388 | Config config(configname, dom); |
4300 | config.setGroup( "View" ); | 4389 | config.setGroup( "View" ); |
4301 | 4390 | ||
4302 | #else | 4391 | #else |
4303 | QFileInfo fi; | 4392 | QFileInfo fi; |
4304 | if (full) | 4393 | if (full) |
4305 | { | 4394 | { |
4306 | // qDebug("full:%s", (const char*)_txt); | 4395 | // qDebug("full:%s", (const char*)_txt); |
4307 | QDir d = QDir::home(); // "/" | 4396 | QDir d = QDir::home(); // "/" |
4308 | if ( !d.cd(_txt) ) | 4397 | if ( !d.cd(_txt) ) |
4309 | { // "/tmp" | 4398 | { // "/tmp" |
4310 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); | 4399 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); |
4311 | d = QDir::home(); | 4400 | d = QDir::home(); |
4312 | d.mkdir(_txt); | 4401 | d.mkdir(_txt); |
4313 | d.cd(_txt); | 4402 | d.cd(_txt); |
4314 | } | 4403 | } |
4315 | fi.setFile(d, INIFILE); | 4404 | fi.setFile(d, INIFILE); |
4316 | } | 4405 | } |
4317 | else | 4406 | else |
4318 | { | 4407 | { |
4319 | QDir d = QDir::home(); // "/" | 4408 | QDir d = QDir::home(); // "/" |
4320 | if ( !d.cd(APPDIR) ) | 4409 | if ( !d.cd(APPDIR) ) |
4321 | { // "/tmp" | 4410 | { // "/tmp" |
4322 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 4411 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
4323 | d = QDir::home(); | 4412 | d = QDir::home(); |
4324 | d.mkdir(APPDIR); | 4413 | d.mkdir(APPDIR); |
4325 | d.cd(APPDIR); | 4414 | d.cd(APPDIR); |
4326 | } | 4415 | } |
4327 | if ( !d.cd("configs") ) | 4416 | if ( !d.cd("configs") ) |
4328 | { // "/tmp" | 4417 | { // "/tmp" |
4329 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); | 4418 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); |
4330 | d = QDir::home(); | 4419 | d = QDir::home(); |
4331 | d.cd(APPDIR); | 4420 | d.cd(APPDIR); |
4332 | d.mkdir("configs"); | 4421 | d.mkdir("configs"); |
4333 | d.cd("configs"); | 4422 | d.cd("configs"); |
4334 | } | 4423 | } |
4335 | fi.setFile(d, _txt); | 4424 | fi.setFile(d, _txt); |
4336 | } | 4425 | } |
4337 | //qDebug("Path:%s", (const char*)fi.absFilePath()); | 4426 | //qDebug("Path:%s", (const char*)fi.absFilePath()); |
4338 | Config config(fi.absFilePath()); | 4427 | Config config(fi.absFilePath()); |
4339 | #endif | 4428 | #endif |
4340 | 4429 | ||
4341 | 4430 | ||
4342 | config.writeEntry( "StripCr", reader->bstripcr ); | 4431 | config.writeEntry( "StripCr", reader->bstripcr ); |
4432 | config.writeEntry( "NoInlineTables", reader->bNoInlineTables ); | ||
4343 | config.writeEntry( "AutoFmt", reader->bautofmt ); | 4433 | config.writeEntry( "AutoFmt", reader->bautofmt ); |
4344 | config.writeEntry( "TextFmt", reader->btextfmt ); | 4434 | config.writeEntry( "TextFmt", reader->btextfmt ); |
4345 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 4435 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
4346 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 4436 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
4347 | config.writeEntry( "Depluck", reader->bdepluck ); | 4437 | config.writeEntry( "Depluck", reader->bdepluck ); |
4348 | config.writeEntry( "Dejpluck", reader->bdejpluck ); | 4438 | config.writeEntry( "Dejpluck", reader->bdejpluck ); |
4349 | config.writeEntry( "OneSpace", reader->bonespace ); | 4439 | config.writeEntry( "OneSpace", reader->bonespace ); |
4350 | config.writeEntry( "Unindent", reader->bunindent ); | 4440 | config.writeEntry( "Unindent", reader->bunindent ); |
4351 | config.writeEntry( "Repara", reader->brepara ); | 4441 | config.writeEntry( "Repara", reader->brepara ); |
4352 | config.writeEntry( "ReparaString", reader->m_reparastring); | 4442 | config.writeEntry( "ReparaString", reader->m_reparastring); |
4353 | config.writeEntry( "BackgroundType" , (int)m_bgtype ); | 4443 | config.writeEntry( "BackgroundType" , (int)m_bgtype ); |
4354 | config.writeEntry( "Theme", m_themename ); | 4444 | config.writeEntry( "Theme", m_themename ); |
4355 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | 4445 | config.writeEntry( "DoubleSpace", reader->bdblspce ); |
4356 | config.writeEntry( "Indent", reader->bindenter ); | 4446 | config.writeEntry( "Indent", reader->bindenter ); |
4357 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | 4447 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); |
4358 | config.writeEntry( "ScrollDelay", reader->m_delay); | 4448 | config.writeEntry( "ScrollDelay", reader->m_delay); |
4359 | config.writeEntry( "ScrollStep", reader->m_scrollstep); | 4449 | config.writeEntry( "ScrollStep", reader->m_scrollstep); |
4360 | config.writeEntry( "ScrollType", reader->m_scrolltype ); | 4450 | config.writeEntry( "ScrollType", reader->m_scrolltype ); |
4361 | if (full) | 4451 | if (full) |
4362 | { | 4452 | { |
4363 | config.writeEntry("Debounce", m_debounce); | 4453 | config.writeEntry("Debounce", m_debounce); |
4364 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | 4454 | config.writeEntry("FloatDialogs", m_bFloatingDialog); |
4365 | reader->m_lastposn = reader->pagelocate(); | 4455 | reader->m_lastposn = reader->pagelocate(); |
4366 | config.writeEntry( "LastFile", reader->m_lastfile ); | 4456 | config.writeEntry( "LastFile", reader->m_lastfile ); |
4367 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 4457 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
4458 | config.writeEntry( "OutputCodec", reader->m_outputName); | ||
4368 | } | 4459 | } |
4369 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 4460 | config.writeEntry( "PageMode", reader->m_bpagemode ); |
4370 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 4461 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); |
4371 | config.writeEntry( "SwapMouse", reader->m_swapmouse); | 4462 | config.writeEntry( "SwapMouse", reader->m_swapmouse); |
4372 | config.writeEntry( "IsRotated", reader->m_rotated ); | 4463 | config.writeEntry( "IsRotated", reader->m_rotated ); |
4373 | config.writeEntry("StatusContent", m_statusstring); | 4464 | config.writeEntry("StatusContent", m_statusstring); |
4374 | config.writeEntry("StatusHidden", m_statusishidden); | 4465 | config.writeEntry("StatusHidden", m_statusishidden); |
4375 | config.writeEntry( "Background", m_background ); | 4466 | config.writeEntry( "Background", m_background ); |
4376 | config.writeEntry( "Foreground", m_foreground ); | 4467 | config.writeEntry( "Foreground", m_foreground ); |
4377 | config.writeEntry( "ScrollColour", m_scrollcolor ); | 4468 | config.writeEntry( "ScrollColour", m_scrollcolor ); |
4378 | config.writeEntry( "ScrollBarColour", m_scrollbarcolor ); | 4469 | config.writeEntry( "ScrollBarColour", m_scrollbarcolor ); |
4379 | config.writeEntry( "Hyphenate", reader->hyphenate ); | 4470 | config.writeEntry( "Hyphenate", reader->hyphenate ); |
4380 | // config.writeEntry( "CustomHyphen", reader->buffdoc.getCustomHyphen() ); | 4471 | // config.writeEntry( "CustomHyphen", reader->buffdoc.getCustomHyphen() ); |
4381 | config.writeEntry( "Fontname", reader->m_fontname ); | 4472 | config.writeEntry( "Fontname", reader->m_fontname ); |
4382 | config.writeEntry( "Encoding", reader->m_encd ); | 4473 | config.writeEntry( "Encoding", reader->m_encd ); |
4383 | config.writeEntry( "CharSpacing", reader->m_charpc ); | 4474 | config.writeEntry( "CharSpacing", reader->m_charpc ); |
4384 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | 4475 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); |
4385 | config.writeEntry( "Top Margin", (int)reader->m_abstopmargin ); | 4476 | config.writeEntry( "Top Margin", (int)reader->m_abstopmargin ); |
4386 | config.writeEntry( "Bottom Margin", (int)reader->m_absbottommargin ); | 4477 | config.writeEntry( "Bottom Margin", (int)reader->m_absbottommargin ); |
4387 | config.writeEntry( "Left Margin", (int)reader->m_absleft_border ); | 4478 | config.writeEntry( "Left Margin", (int)reader->m_absleft_border ); |
4388 | config.writeEntry( "Right Margin", (int)reader->m_absright_border ); | 4479 | config.writeEntry( "Right Margin", (int)reader->m_absright_border ); |
4389 | config.writeEntry( "TargetApp", m_targetapp ); | 4480 | config.writeEntry( "TargetApp", m_targetapp ); |
4390 | config.writeEntry( "TargetMsg", m_targetmsg ); | 4481 | config.writeEntry( "TargetMsg", m_targetmsg ); |
4391 | #ifdef _SCROLLPIPE | 4482 | #ifdef _SCROLLPIPE |
4392 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); | 4483 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); |
4393 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | 4484 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); |
4394 | #endif | 4485 | #endif |
4395 | config.writeEntry( "TwoTouch", m_twoTouch ); | 4486 | config.writeEntry( "TwoTouch", m_twoTouch ); |
4396 | config.writeEntry( "Annotation", m_doAnnotation); | 4487 | config.writeEntry( "Annotation", m_doAnnotation); |
4397 | config.writeEntry( "Dictionary", m_doDictionary); | 4488 | config.writeEntry( "Dictionary", m_doDictionary); |
4398 | config.writeEntry( "Clipboard", m_doClipboard); | 4489 | config.writeEntry( "Clipboard", m_doClipboard); |
4490 | config.writeEntry( "OutputTgt", m_doOutput); | ||
4399 | /* | 4491 | /* |
4400 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 4492 | config.writeEntry( "SpaceTarget", m_spaceTarget); |
4401 | config.writeEntry( "EscapeTarget", m_escapeTarget); | 4493 | config.writeEntry( "EscapeTarget", m_escapeTarget); |
4402 | config.writeEntry( "ReturnTarget", m_returnTarget); | 4494 | config.writeEntry( "ReturnTarget", m_returnTarget); |
4403 | config.writeEntry( "LeftTarget", m_leftTarget); | 4495 | config.writeEntry( "LeftTarget", m_leftTarget); |
4404 | config.writeEntry( "RightTarget", m_rightTarget); | 4496 | config.writeEntry( "RightTarget", m_rightTarget); |
4405 | config.writeEntry( "UpTarget", m_upTarget); | 4497 | config.writeEntry( "UpTarget", m_upTarget); |
4406 | config.writeEntry( "DownTarget", m_downTarget); | 4498 | config.writeEntry( "DownTarget", m_downTarget); |
4407 | config.writeEntry("LeftScroll", m_leftScroll); | 4499 | config.writeEntry("LeftScroll", m_leftScroll); |
4408 | config.writeEntry("RightScroll", m_rightScroll); | 4500 | config.writeEntry("RightScroll", m_rightScroll); |
4409 | config.writeEntry("UpScroll", m_upScroll); | 4501 | config.writeEntry("UpScroll", m_upScroll); |
4410 | config.writeEntry("DownScroll", m_downScroll); | 4502 | config.writeEntry("DownScroll", m_downScroll); |
4411 | */ | 4503 | */ |
4412 | config.writeEntry( "Repalm", reader->brepalm ); | 4504 | config.writeEntry( "Repalm", reader->brepalm ); |
4505 | config.writeEntry( "UnderlineLink", reader->bunderlineLink ); | ||
4413 | config.writeEntry( "HideScrollBar", m_scrollishidden ); | 4506 | config.writeEntry( "HideScrollBar", m_scrollishidden ); |
4507 | config.writeEntry( "HideToolBar", m_hidebars ); | ||
4414 | config.writeEntry( "Kern", reader->bkern ); | 4508 | config.writeEntry( "Kern", reader->bkern ); |
4415 | config.writeEntry( "Remap", reader->bremap ); | 4509 | config.writeEntry( "Remap", reader->bremap ); |
4416 | config.writeEntry( "Peanut", reader->bpeanut ); | 4510 | config.writeEntry( "Peanut", reader->bpeanut ); |
4417 | config.writeEntry( "MakeBold", reader->bmakebold ); | 4511 | config.writeEntry( "MakeBold", reader->bmakebold ); |
4418 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | 4512 | config.writeEntry( "Continuous", reader->m_continuousDocument ); |
4513 | config.writeEntry( "DoubleBuffer", reader->m_doubleBuffered); | ||
4419 | config.writeEntry( "FullJust", reader->bfulljust ); | 4514 | config.writeEntry( "FullJust", reader->bfulljust ); |
4420 | // config.writeEntry( "Negative", reader->bNegative ); | 4515 | // config.writeEntry( "Negative", reader->bNegative ); |
4421 | config.writeEntry( "Inverse", reader->bInverse ); | 4516 | config.writeEntry( "Inverse", reader->bInverse ); |
4422 | config.writeEntry( "FixGraphics", reader->m_fontControl.FixGraphics()); | 4517 | config.writeEntry( "FixGraphics", reader->m_fontControl.FixGraphics()); |
4423 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); | 4518 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); |
4424 | config.writeEntry( "ExtraLead", reader->getlead() ); | 4519 | config.writeEntry( "ExtraLead", reader->getlead() ); |
4425 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); | 4520 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); |
4426 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); | 4521 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); |
4427 | #ifdef USEQPE | 4522 | #ifdef USEQPE |
4428 | config.writeEntry( "GrabKeyboard", m_grabkeyboard ); | 4523 | config.writeEntry( "GrabKeyboard", m_grabkeyboard ); |
4429 | #endif | 4524 | #endif |
4430 | if (full) | 4525 | if (full) |
4431 | { | 4526 | { |
4432 | config.setGroup( "Toolbar" ); | 4527 | config.setGroup( "Toolbar" ); |
4433 | config.writeEntry("QTScrollBar", m_qtscroll); | 4528 | config.writeEntry("QTScrollBar", m_qtscroll); |
4434 | config.writeEntry("LocalScrollBar", m_localscroll); | 4529 | config.writeEntry("LocalScrollBar", m_localscroll); |
4435 | config.writeEntry("Movable", m_tbmovesave); | 4530 | config.writeEntry("Movable", m_tbmovesave); |
4436 | config.writeEntry("Policy", m_tbpolsave); | 4531 | config.writeEntry("Policy", m_tbpolsave); |
4437 | config.writeEntry("Position", m_tbposition); | 4532 | config.writeEntry("Position", m_tbposition); |
4438 | #ifndef USEQPE | 4533 | #ifndef USEQPE |
4439 | if (!isMaximized() && !isMinimized()) | 4534 | if (!isMaximized() && !isMinimized()) |
4440 | { | 4535 | { |
4441 | config.setGroup( "Geometry" ); | 4536 | config.setGroup( "Geometry" ); |
4442 | config.writeEntry( "x", x() ); | 4537 | config.writeEntry( "x", x() ); |
4443 | config.writeEntry( "y", y() ); | 4538 | config.writeEntry( "y", y() ); |
4444 | config.writeEntry( "width", width() ); | 4539 | config.writeEntry( "width", width() ); |
4445 | config.writeEntry( "height", height() ); | 4540 | config.writeEntry( "height", height() ); |
4446 | } | 4541 | } |
4447 | #endif | 4542 | #endif |
4448 | } | 4543 | } |
4449 | } | 4544 | } |
4450 | 4545 | ||
4451 | #ifdef _SCROLLPIPE | 4546 | #ifdef _SCROLLPIPE |
4452 | void QTReaderApp::setpipetarget() | 4547 | void QTReaderApp::setpipetarget() |
4453 | { | 4548 | { |
4454 | m_nRegAction = cSetPipeTarget; | 4549 | m_nRegAction = cSetPipeTarget; |
4455 | QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget; | 4550 | QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget; |
4456 | regEdit->setText(text); | 4551 | regEdit->setText(text); |
4457 | do_regedit(); | 4552 | do_regedit(); |
4458 | } | 4553 | } |
4459 | 4554 | ||
4460 | void QTReaderApp::do_setpipetarget(const QString& _txt) | 4555 | void QTReaderApp::do_setpipetarget(const QString& _txt) |
4461 | { | 4556 | { |
4462 | reader->m_pipetarget = _txt; | 4557 | reader->m_pipetarget = _txt; |
4463 | } | 4558 | } |
4464 | 4559 | ||
4465 | void QTReaderApp::setpause(bool sfs) | 4560 | void QTReaderApp::setpause(bool sfs) |
4466 | { | 4561 | { |
4467 | reader->m_pauseAfterEachPara = sfs; | 4562 | reader->m_pauseAfterEachPara = sfs; |
4468 | } | 4563 | } |
4469 | #endif | 4564 | #endif |
4470 | 4565 | ||
4471 | void QTReaderApp::monospace(bool _b) | 4566 | void QTReaderApp::monospace(bool _b) |
4472 | { | 4567 | { |
4473 | reader->setmono(_b); | 4568 | reader->setmono(_b); |
4474 | } | 4569 | } |
4475 | 4570 | ||
4476 | bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool full=false) | 4571 | bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool full=false) |
4477 | { | 4572 | { |
4478 | #ifdef USEQPE | 4573 | #ifdef USEQPE |
4479 | QString configname; | 4574 | QString configname; |
4480 | Config::Domain dom; | 4575 | Config::Domain dom; |
4481 | 4576 | ||
4482 | if (full) | 4577 | if (full) |
4483 | { | 4578 | { |
4484 | configname = _txt; | 4579 | configname = _txt; |
4485 | dom = Config::User; | 4580 | dom = Config::User; |
4486 | } | 4581 | } |
4487 | else | 4582 | else |
4488 | { | 4583 | { |
4489 | configname = Global::applicationFileName(dirname, _txt); | 4584 | configname = Global::applicationFileName(dirname, _txt); |
4490 | QFileInfo fm(configname); | 4585 | QFileInfo fm(configname); |
4491 | if ( !fm.exists() ) return false; | 4586 | if ( !fm.exists() ) return false; |
4492 | dom = Config::File; | 4587 | dom = Config::File; |
4493 | } | 4588 | } |
4494 | 4589 | ||
4495 | Config config(configname, dom); | 4590 | Config config(configname, dom); |
4496 | config.setGroup( "View" ); | 4591 | config.setGroup( "View" ); |
4497 | 4592 | ||
4498 | #else | 4593 | #else |
4499 | QString fullname; | 4594 | QString fullname; |
4500 | if (full) | 4595 | if (full) |
4501 | { | 4596 | { |
4502 | fullname = QDir::homeDirPath() + "/" + _txt + "/" + INIFILE; | 4597 | fullname = QDir::homeDirPath() + "/" + _txt + "/" + INIFILE; |
4503 | } | 4598 | } |
4504 | else | 4599 | else |
4505 | { | 4600 | { |
4506 | fullname = QDir::homeDirPath() + "/" + dirname + "/" + _txt; | 4601 | fullname = QDir::homeDirPath() + "/" + dirname + "/" + _txt; |
4507 | } | 4602 | } |
4508 | if (!QFile::exists(fullname)) return false; | 4603 | if (!QFile::exists(fullname)) return false; |
4509 | 4604 | ||
4510 | Config config(fullname); | 4605 | Config config(fullname); |
4511 | #endif | 4606 | #endif |
4512 | if (full) | 4607 | if (full) |
4513 | { | 4608 | { |
4514 | config.setGroup("Toolbar"); | 4609 | config.setGroup("Toolbar"); |
4515 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", m_tbmovesave); | 4610 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", m_tbmovesave); |
4516 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", m_tbpolsave); | 4611 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", m_tbpolsave); |
4517 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", m_tbposition); | 4612 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", m_tbposition); |
4518 | } | 4613 | } |
4519 | config.setGroup( "View" ); | 4614 | config.setGroup( "View" ); |
4520 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", m_bFloatingDialog); | 4615 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", m_bFloatingDialog); |
4521 | reader->bstripcr = config.readBoolEntry( "StripCr", reader->bstripcr ); | 4616 | reader->bstripcr = config.readBoolEntry( "StripCr", reader->bstripcr ); |
4617 | reader->bNoInlineTables = config.readBoolEntry( "NoInlineTables", reader->bNoInlineTables ); | ||
4522 | reader->bfulljust = config.readBoolEntry( "FullJust", reader->bfulljust ); | 4618 | reader->bfulljust = config.readBoolEntry( "FullJust", reader->bfulljust ); |
4523 | reader->bInverse = config.readBoolEntry( "Inverse", reader->bInverse ); | 4619 | reader->bInverse = config.readBoolEntry( "Inverse", reader->bInverse ); |
4524 | // reader->bNegative = config.readBoolEntry( "Negative", false ); | 4620 | // reader->bNegative = config.readBoolEntry( "Negative", false ); |
4525 | reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", reader->m_fontControl.FixGraphics() )); | 4621 | reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", reader->m_fontControl.FixGraphics() )); |
4526 | reader->setextraspace(config.readNumEntry( "ExtraSpace", reader->getextraspace() )); | 4622 | reader->setextraspace(config.readNumEntry( "ExtraSpace", reader->getextraspace() )); |
4527 | reader->setlead(config.readNumEntry( "ExtraLead", reader->getlead() )); | 4623 | reader->setlead(config.readNumEntry( "ExtraLead", reader->getlead() )); |
4528 | reader->btextfmt = config.readBoolEntry( "TextFmt", reader->btextfmt ); | 4624 | reader->btextfmt = config.readBoolEntry( "TextFmt", reader->btextfmt ); |
4529 | reader->bautofmt = config.readBoolEntry( "AutoFmt", reader->bautofmt ); | 4625 | reader->bautofmt = config.readBoolEntry( "AutoFmt", reader->bautofmt ); |
4530 | reader->bstriphtml = config.readBoolEntry( "StripHtml", reader->bstriphtml ); | 4626 | reader->bstriphtml = config.readBoolEntry( "StripHtml", reader->bstriphtml ); |
4531 | reader->bpeanut = config.readBoolEntry( "Peanut", reader->bpeanut ); | 4627 | reader->bpeanut = config.readBoolEntry( "Peanut", reader->bpeanut ); |
4532 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", reader->bdehyphen ); | 4628 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", reader->bdehyphen ); |
4533 | reader->bdepluck = config.readBoolEntry( "Depluck", reader->bdepluck ); | 4629 | reader->bdepluck = config.readBoolEntry( "Depluck", reader->bdepluck ); |
4534 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", reader->bdejpluck ); | 4630 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", reader->bdejpluck ); |
4535 | reader->bonespace = config.readBoolEntry( "OneSpace", reader->bonespace ); | 4631 | reader->bonespace = config.readBoolEntry( "OneSpace", reader->bonespace ); |
4536 | reader->bunindent = config.readBoolEntry( "Unindent", reader->bunindent ); | 4632 | reader->bunindent = config.readBoolEntry( "Unindent", reader->bunindent ); |
4537 | reader->brepara = config.readBoolEntry( "Repara", reader->brepara ); | 4633 | reader->brepara = config.readBoolEntry( "Repara", reader->brepara ); |
4538 | reader->m_reparastring = config.readEntry( "ReparaString", reader->m_reparastring); | 4634 | reader->m_reparastring = config.readEntry( "ReparaString", reader->m_reparastring); |
4539 | m_bgtype = (bground)config.readNumEntry( "BackgroundType" , m_bgtype ); | 4635 | m_bgtype = (bground)config.readNumEntry( "BackgroundType" , m_bgtype ); |
4540 | m_themename = config.readEntry("Theme", m_themename ); | 4636 | m_themename = config.readEntry("Theme", m_themename ); |
4541 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", reader->bdblspce ); | 4637 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", reader->bdblspce ); |
4542 | reader->bindenter = config.readNumEntry( "Indent", reader->bindenter ); | 4638 | reader->bindenter = config.readNumEntry( "Indent", reader->bindenter ); |
4543 | reader->m_textsize = config.readNumEntry( "FontSize", reader->m_textsize ); | 4639 | reader->m_textsize = config.readNumEntry( "FontSize", reader->m_textsize ); |
4544 | reader->m_delay = config.readNumEntry( "ScrollDelay", reader->m_delay); | 4640 | reader->m_delay = config.readNumEntry( "ScrollDelay", reader->m_delay); |
4545 | reader->m_scrollstep = config.readNumEntry( "ScrollStep", reader->m_scrollstep); | 4641 | reader->m_scrollstep = config.readNumEntry( "ScrollStep", reader->m_scrollstep); |
4546 | reader->m_scrolltype = config.readNumEntry( "ScrollType", reader->m_scrolltype); | 4642 | reader->m_scrolltype = config.readNumEntry( "ScrollType", reader->m_scrolltype); |
4547 | if (full) | 4643 | if (full) |
4548 | { | 4644 | { |
4549 | reader->m_lastfile = config.readEntry( "LastFile", reader->m_lastfile ); | 4645 | reader->m_lastfile = config.readEntry( "LastFile", reader->m_lastfile ); |
4550 | reader->m_lastposn = config.readNumEntry( "LastPosn", reader->m_lastposn ); | 4646 | reader->m_lastposn = config.readNumEntry( "LastPosn", reader->m_lastposn ); |
4551 | } | 4647 | } |
4552 | reader->m_bpagemode = config.readBoolEntry( "PageMode", reader->m_bpagemode ); | 4648 | reader->m_bpagemode = config.readBoolEntry( "PageMode", reader->m_bpagemode ); |
4553 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", reader->m_bMonoSpaced); | 4649 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", reader->m_bMonoSpaced); |
4554 | reader->m_rotated = config.readBoolEntry( "IsRotated", reader->m_rotated ); | 4650 | reader->m_rotated = config.readBoolEntry( "IsRotated", reader->m_rotated ); |
4555 | m_statusstring = config.readEntry("StatusContent", m_statusstring); | 4651 | m_statusstring = config.readEntry("StatusContent", m_statusstring); |
4556 | m_statusishidden = config.readBoolEntry("StatusHidden", m_statusishidden); | 4652 | m_statusishidden = config.readBoolEntry("StatusHidden", m_statusishidden); |
4557 | m_background = config.readNumEntry( "Background", m_background ); | 4653 | m_background = config.readNumEntry( "Background", m_background ); |
4558 | reader->setBackground(getcolour(m_background)); | 4654 | reader->setBackground(getcolour(m_background)); |
4559 | m_foreground = config.readNumEntry( "Foreground", m_foreground ); | 4655 | m_foreground = config.readNumEntry( "Foreground", m_foreground ); |
4560 | reader->setForeground(getcolour(m_foreground)); | 4656 | reader->setForeground(getcolour(m_foreground)); |
4561 | m_scrollcolor = config.readNumEntry( "ScrollColour", m_scrollcolor); | 4657 | m_scrollcolor = config.readNumEntry( "ScrollColour", m_scrollcolor); |
4562 | setscrollcolour(); | 4658 | setscrollcolour(); |
4563 | m_scrollbarcolor = config.readNumEntry( "ScrollBarColour", m_scrollbarcolor); | 4659 | m_scrollbarcolor = config.readNumEntry( "ScrollBarColour", m_scrollbarcolor); |
4564 | setscrollbarcolour(); | 4660 | setscrollbarcolour(); |
4565 | reader->hyphenate = config.readBoolEntry( "Hyphenate", reader->hyphenate ); | 4661 | reader->hyphenate = config.readBoolEntry( "Hyphenate", reader->hyphenate ); |
4566 | // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false )); | 4662 | // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false )); |
4567 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", reader->m_swapmouse); | 4663 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", reader->m_swapmouse); |
4568 | reader->m_fontname = config.readEntry( "Fontname", reader->m_fontname ); | 4664 | reader->m_fontname = config.readEntry( "Fontname", reader->m_fontname ); |
4569 | reader->m_encd = config.readNumEntry( "Encoding", reader->m_encd ); | 4665 | reader->m_encd = config.readNumEntry( "Encoding", reader->m_encd ); |
4570 | reader->m_charpc = config.readNumEntry( "CharSpacing", reader->m_charpc ); | 4666 | reader->m_charpc = config.readNumEntry( "CharSpacing", reader->m_charpc ); |
4571 | reader->m_overlap = config.readNumEntry( "Overlap", reader->m_overlap ); | 4667 | reader->m_overlap = config.readNumEntry( "Overlap", reader->m_overlap ); |
4572 | reader->m_abstopmargin = config.readNumEntry( "Top Margin", reader->m_abstopmargin ); | 4668 | reader->m_abstopmargin = config.readNumEntry( "Top Margin", reader->m_abstopmargin ); |
4573 | reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", reader->m_absbottommargin ); | 4669 | reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", reader->m_absbottommargin ); |
4574 | reader->m_absleft_border = config.readNumEntry( "Left Margin", reader->m_absleft_border ); | 4670 | reader->m_absleft_border = config.readNumEntry( "Left Margin", reader->m_absleft_border ); |
4575 | reader->m_absright_border = config.readNumEntry( "Right Margin", reader->m_absright_border ); | 4671 | reader->m_absright_border = config.readNumEntry( "Right Margin", reader->m_absright_border ); |
4576 | m_scrollishidden = config.readBoolEntry( "HideScrollBar", m_scrollishidden ); | 4672 | m_scrollishidden = config.readBoolEntry( "HideScrollBar", m_scrollishidden ); |
4673 | m_hidebars = config.readBoolEntry( "HideToolBar", m_hidebars ); | ||
4577 | reader->brepalm = config.readBoolEntry( "Repalm", reader->brepalm ); | 4674 | reader->brepalm = config.readBoolEntry( "Repalm", reader->brepalm ); |
4675 | reader->bunderlineLink = config.readBoolEntry( "UnderlineLink", reader->bunderlineLink ); | ||
4578 | reader->bkern = config.readBoolEntry( "Kern", reader->bkern ); | 4676 | reader->bkern = config.readBoolEntry( "Kern", reader->bkern ); |
4579 | reader->bremap = config.readBoolEntry( "Remap", reader->bremap ); | 4677 | reader->bremap = config.readBoolEntry( "Remap", reader->bremap ); |
4580 | reader->bmakebold = config.readBoolEntry( "MakeBold", reader->bmakebold ); | 4678 | reader->bmakebold = config.readBoolEntry( "MakeBold", reader->bmakebold ); |
4581 | reader->setContinuous(config.readBoolEntry( "Continuous", reader->m_continuousDocument )); | 4679 | reader->setContinuous(config.readBoolEntry( "Continuous", reader->m_continuousDocument )); |
4680 | reader->setDoubleBuffer(config.readBoolEntry("DoubleBuffer", reader->m_doubleBuffered)); | ||
4582 | m_targetapp = config.readEntry( "TargetApp", m_targetapp ); | 4681 | m_targetapp = config.readEntry( "TargetApp", m_targetapp ); |
4583 | m_targetmsg = config.readEntry( "TargetMsg", m_targetmsg ); | 4682 | m_targetmsg = config.readEntry( "TargetMsg", m_targetmsg ); |
4584 | #ifdef _SCROLLPIPE | 4683 | #ifdef _SCROLLPIPE |
4585 | reader->m_pipetarget = config.readEntry( "PipeTarget", reader->m_pipetarget ); | 4684 | reader->m_pipetarget = config.readEntry( "PipeTarget", reader->m_pipetarget ); |
4586 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | 4685 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); |
4587 | #endif | 4686 | #endif |
4588 | m_twoTouch = config.readBoolEntry( "TwoTouch", m_twoTouch); | 4687 | m_twoTouch = config.readBoolEntry( "TwoTouch", m_twoTouch); |
4589 | m_doAnnotation = config.readBoolEntry( "Annotation", m_doAnnotation); | 4688 | m_doAnnotation = config.readBoolEntry( "Annotation", m_doAnnotation); |
4590 | m_doDictionary = config.readBoolEntry( "Dictionary", m_doDictionary); | 4689 | m_doDictionary = config.readBoolEntry( "Dictionary", m_doDictionary); |
4591 | m_doClipboard = config.readBoolEntry( "Clipboard", m_doClipboard); | 4690 | m_doClipboard = config.readBoolEntry( "Clipboard", m_doClipboard); |
4691 | m_doOutput = config.readBoolEntry( "OutputTgt", m_doOutput); | ||
4592 | #ifdef USEQPE | 4692 | #ifdef USEQPE |
4593 | m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", m_grabkeyboard); | 4693 | m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", m_grabkeyboard); |
4594 | #endif | 4694 | #endif |
4595 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", m_propogatefontchange); | 4695 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", m_propogatefontchange); |
4596 | reader->setBaseSize(config.readNumEntry( "Basesize", reader->getBaseSize() )); | 4696 | reader->setBaseSize(config.readNumEntry( "Basesize", reader->getBaseSize() )); |
4597 | reader->setTwoTouch(m_twoTouch); | 4697 | reader->setTwoTouch(m_twoTouch); |
4698 | |||
4699 | reader->m_outputName = config.readEntry( "OutputCodec", reader->m_outputName); | ||
4598 | 4700 | ||
4599 | m_touch_action->setOn(m_twoTouch); | 4701 | m_touch_action->setOn(m_twoTouch); |
4600 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 4702 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
4601 | setfontHelper(reader->m_fontname); | 4703 | setfontHelper(reader->m_fontname); |
4602 | if (full) | 4704 | if (full) |
4603 | { | 4705 | { |
4604 | addtoolbars(&config); | 4706 | addtoolbars(&config); |
4605 | } | 4707 | } |
4606 | reader->setfilter(reader->getfilter()); | 4708 | reader->setfilter(reader->getfilter()); |
4607 | reader->refresh(); | 4709 | reader->refresh(); |
4608 | return true; | 4710 | return true; |
4609 | } | 4711 | } |
4610 | 4712 | ||
4611 | bool QTReaderApp::PopulateConfig(const char* tgtdir, bool usedirs) | 4713 | bool QTReaderApp::PopulateConfig(const char* tgtdir, bool usedirs) |
4612 | { | 4714 | { |
4613 | bkmkselector->clear(); | 4715 | bkmkselector->clear(); |
4614 | bkmkselector->setText("Cancel"); | 4716 | bkmkselector->setText("Cancel"); |
4615 | #ifndef USEQPE | 4717 | #ifndef USEQPE |
4616 | int cnt = 0; | 4718 | int cnt = 0; |
4617 | 4719 | ||
4618 | QDir d = QDir::home(); // "/" | 4720 | QDir d = QDir::home(); // "/" |
4619 | if ( !d.cd(APPDIR) ) { // "/tmp" | 4721 | if ( !d.cd(APPDIR) ) { // "/tmp" |
4620 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 4722 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
4621 | d = QDir::home(); | 4723 | d = QDir::home(); |
4622 | d.mkdir(APPDIR); | 4724 | d.mkdir(APPDIR); |
4623 | d.cd(APPDIR); | 4725 | d.cd(APPDIR); |
4624 | } | 4726 | } |
4625 | if ( !d.cd(tgtdir) ) { // "/tmp" | 4727 | if ( !d.cd(tgtdir) ) { // "/tmp" |
4626 | qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir ); | 4728 | qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir ); |
4627 | d = QDir::home(); | 4729 | d = QDir::home(); |
4628 | d.mkdir(tgtdir); | 4730 | d.mkdir(tgtdir); |
4629 | d.cd(tgtdir); | 4731 | d.cd(tgtdir); |
4630 | } | 4732 | } |
4631 | d.setFilter( ((usedirs) ? QDir::Dirs : QDir::Files) | QDir::NoSymLinks ); | 4733 | d.setFilter( ((usedirs) ? QDir::Dirs : QDir::Files) | QDir::NoSymLinks ); |
4632 | // d.setSorting( QDir::Size | QDir::Reversed ); | 4734 | // d.setSorting( QDir::Size | QDir::Reversed ); |
4633 | 4735 | ||
4634 | const QFileInfoList *list = d.entryInfoList(); | 4736 | const QFileInfoList *list = d.entryInfoList(); |
4635 | QFileInfoListIterator it( *list ); // create list iterator | 4737 | QFileInfoListIterator it( *list ); // create list iterator |
4636 | QFileInfo *fi; // pointer for traversing | 4738 | QFileInfo *fi; // pointer for traversing |
4637 | 4739 | ||
4638 | while ( (fi=it.current()) ) { // for each file... | 4740 | while ( (fi=it.current()) ) { // for each file... |
4639 | 4741 | ||
4640 | bkmkselector->insertItem(fi->fileName()); | 4742 | bkmkselector->insertItem(fi->fileName(), cnt++); |
4641 | cnt++; | ||
4642 | 4743 | ||
4643 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | 4744 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); |
4644 | ++it; // goto next list element | 4745 | ++it; // goto next list element |
4645 | } | 4746 | } |
4646 | 4747 | ||
4647 | #else /* USEQPE */ | 4748 | #else /* USEQPE */ |
4648 | int cnt = 0; | 4749 | int cnt = 0; |
4649 | DIR *d; | 4750 | DIR *d; |
4650 | char* finaldir; | 4751 | char* finaldir; |
4651 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; | 4752 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; |
4652 | strcpy(finaldir, APPDIR); | 4753 | strcpy(finaldir, APPDIR); |
4653 | strcat(finaldir, "/"); | 4754 | strcat(finaldir, "/"); |
4654 | strcat(finaldir, tgtdir); | 4755 | strcat(finaldir, tgtdir); |
4655 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); | 4756 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); |
4656 | 4757 | ||
4657 | while(1) | 4758 | while(1) |
4658 | { | 4759 | { |
4659 | struct dirent* de; | 4760 | struct dirent* de; |
4660 | struct stat buf; | 4761 | struct stat buf; |
4661 | de = readdir(d); | 4762 | de = readdir(d); |
4662 | if (de == NULL) break; | 4763 | if (de == NULL) break; |
4663 | 4764 | ||
4664 | if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && ((usedirs && S_ISDIR(buf.st_mode)) || (!usedirs && S_ISREG(buf.st_mode)))) | 4765 | if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && ((usedirs && S_ISDIR(buf.st_mode)) || (!usedirs && S_ISREG(buf.st_mode)))) |
4665 | { | 4766 | { |
4666 | bkmkselector->insertItem(de->d_name); | 4767 | bkmkselector->insertItem(de->d_name, cnt++); |
4667 | cnt++; | ||
4668 | } | 4768 | } |
4669 | } | 4769 | } |
4670 | delete [] finaldir; | 4770 | delete [] finaldir; |
4671 | closedir(d); | 4771 | closedir(d); |
4672 | #endif | 4772 | #endif |
4673 | return (cnt > 0); | 4773 | return (cnt > 0); |
4674 | } | 4774 | } |
4675 | 4775 | ||
4676 | void QTReaderApp::LoadTheme() | 4776 | void QTReaderApp::LoadTheme() |
4677 | { | 4777 | { |
4678 | if (PopulateConfig("Themes", true)) | 4778 | if (PopulateConfig("Themes", true)) |
4679 | { | 4779 | { |
4680 | editorStack->raiseWidget( bkmkselector ); | 4780 | editorStack->raiseWidget( bkmkselector ); |
4681 | hidetoolbars(); | 4781 | hidetoolbars(); |
4682 | m_nBkmkAction = cLdTheme; | 4782 | m_nBkmkAction = cLdTheme; |
4683 | } | 4783 | } |
4684 | else | 4784 | else |
4685 | QMessageBox::information(this, PROGNAME, "No config files"); | 4785 | QMessageBox::information(this, PROGNAME, "No config files"); |
4686 | } | 4786 | } |
4687 | 4787 | ||
4688 | void QTReaderApp::LoadConfig() | 4788 | void QTReaderApp::LoadConfig() |
4689 | { | 4789 | { |
4690 | if (PopulateConfig("configs")) | 4790 | if (PopulateConfig("configs")) |
4691 | { | 4791 | { |
4692 | editorStack->raiseWidget( bkmkselector ); | 4792 | editorStack->raiseWidget( bkmkselector ); |
4693 | hidetoolbars(); | 4793 | hidetoolbars(); |
4694 | m_nBkmkAction = cLdConfig; | 4794 | m_nBkmkAction = cLdConfig; |
4695 | } | 4795 | } |
4696 | else | 4796 | else |
4697 | QMessageBox::information(this, PROGNAME, "No config files"); | 4797 | QMessageBox::information(this, PROGNAME, "No config files"); |
4698 | } | 4798 | } |
4699 | 4799 | ||
4700 | void QTReaderApp::TidyConfig() | 4800 | void QTReaderApp::TidyConfig() |
4701 | { | 4801 | { |
4702 | if (PopulateConfig("configs")) | 4802 | if (PopulateConfig("configs")) |
4703 | { | 4803 | { |
4704 | editorStack->raiseWidget( bkmkselector ); | 4804 | editorStack->raiseWidget( bkmkselector ); |
4705 | hidetoolbars(); | 4805 | hidetoolbars(); |
4706 | m_nBkmkAction = cRmConfig; | 4806 | m_nBkmkAction = cRmConfig; |
4707 | } | 4807 | } |
4708 | else | 4808 | else |
4709 | QMessageBox::information(this, PROGNAME, "No config files"); | 4809 | QMessageBox::information(this, PROGNAME, "No config files"); |
4710 | } | 4810 | } |
4711 | 4811 | ||
4712 | void QTReaderApp::ExportLinks() | 4812 | void QTReaderApp::ExportLinks() |
4713 | { | 4813 | { |
4714 | if (PopulateConfig("urls")) | 4814 | if (PopulateConfig("urls")) |
4715 | { | 4815 | { |
4716 | editorStack->raiseWidget( bkmkselector ); | 4816 | editorStack->raiseWidget( bkmkselector ); |
4717 | hidetoolbars(); | 4817 | hidetoolbars(); |
4718 | m_nBkmkAction = cExportLinks; | 4818 | m_nBkmkAction = cExportLinks; |
4719 | } | 4819 | } |
4720 | else | 4820 | else |
4721 | QMessageBox::information(this, PROGNAME, "No url files"); | 4821 | QMessageBox::information(this, PROGNAME, "No url files"); |
4722 | } | 4822 | } |
4723 | 4823 | ||
4724 | void QTReaderApp::OnURLSelected(const QString& href, const size_t tgt) | 4824 | void QTReaderApp::OnURLSelected(const QString& href, const size_t tgt) |
4725 | { | 4825 | { |
4726 | #ifndef USEQPE | 4826 | #ifndef USEQPE |
4727 | qDebug("URL:%s", (const char*)href); | 4827 | qDebug("URL:%s", (const char*)href); |
4728 | int col = href.find(':'); | 4828 | int col = href.find(':'); |
4729 | if (col > 0) | 4829 | if (col > 0) |
4730 | { | 4830 | { |
4731 | QString type = href.left(col); | 4831 | QString type = href.left(col); |
4732 | qDebug("Type:%s", (const char*)type); | 4832 | qDebug("Type:%s", (const char*)type); |
4733 | } | 4833 | } |
4734 | else | 4834 | else |
4735 | { | 4835 | { |
4736 | qDebug("No type"); | 4836 | qDebug("No type"); |
4737 | } | 4837 | } |
4838 | QString msg = "External URL\n" + href; | ||
4839 | QMessageBox::information(this, PROGNAME, msg); | ||
4738 | #else | 4840 | #else |
4739 | if (href.isEmpty()) | 4841 | if (href.isEmpty()) |
4740 | { | 4842 | { |
4741 | QMessageBox::information(this, PROGNAME, "No URL information supplied"); | 4843 | QMessageBox::information(this, PROGNAME, "No URL information supplied"); |
4742 | } | 4844 | } |
4743 | else | 4845 | else |
4744 | { | 4846 | { |
4745 | CURLDialog* urld = new CURLDialog(href, false, this); | 4847 | CURLDialog* urld = new CURLDialog(href, false, this); |
4746 | urld->clipboard(m_url_clipboard); | 4848 | urld->clipboard(m_url_clipboard); |
4747 | urld->localfile(m_url_localfile); | 4849 | urld->localfile(m_url_localfile); |
4748 | urld->globalfile(m_url_globalfile); | 4850 | urld->globalfile(m_url_globalfile); |
4749 | if (urld->exec()) | 4851 | if (urld->exec()) |
4750 | { | 4852 | { |
4751 | m_url_clipboard = urld->clipboard(); | 4853 | m_url_clipboard = urld->clipboard(); |
4752 | m_url_localfile = urld->localfile(); | 4854 | m_url_localfile = urld->localfile(); |
4753 | m_url_globalfile = urld->globalfile(); | 4855 | m_url_globalfile = urld->globalfile(); |
4754 | if (m_url_clipboard) | 4856 | if (m_url_clipboard) |
4755 | { | 4857 | { |
4756 | QClipboard* cb = QApplication::clipboard(); | 4858 | QClipboard* cb = QApplication::clipboard(); |
4757 | cb->setText(href); | 4859 | cb->setText(href); |
4758 | qDebug("<a href=\"%s\">%s</a>", (const char*)href, (const char*)href); | 4860 | qDebug("<a href=\"%s\">%s</a>", (const char*)href, (const char*)href); |
4759 | } | 4861 | } |
4760 | if (m_url_localfile) | 4862 | if (m_url_localfile) |
4761 | { | 4863 | { |
4762 | writeUrl(reader->m_string, href); | 4864 | writeUrl(reader->m_string, href); |
4763 | } | 4865 | } |
4764 | if (m_url_globalfile) | 4866 | if (m_url_globalfile) |
4765 | { | 4867 | { |
4766 | writeUrl("GlobalURLFile", href); | 4868 | writeUrl("GlobalURLFile", href); |
4767 | } | 4869 | } |
4768 | } | 4870 | } |
4769 | delete urld; | 4871 | delete urld; |
4770 | } | 4872 | } |
4771 | #endif | 4873 | #endif |
4772 | } | 4874 | } |
4773 | 4875 | ||
4774 | void QTReaderApp::writeUrl(const QString& file, const QString& href) | 4876 | void QTReaderApp::writeUrl(const QString& file, const QString& href) |
4775 | { | 4877 | { |
4776 | QString filename; | 4878 | QString filename; |
4777 | #ifdef USEQPE | 4879 | #ifdef USEQPE |
4778 | filename = Global::applicationFileName(APPDIR "/urls", file); | 4880 | filename = Global::applicationFileName(APPDIR "/urls", file); |
4779 | #else | 4881 | #else |
4780 | QFileInfo fi; | 4882 | QFileInfo fi; |
4781 | QDir d = QDir::home(); // "/" | 4883 | QDir d = QDir::home(); // "/" |
4782 | if ( !d.cd(APPDIR) ) | 4884 | if ( !d.cd(APPDIR) ) |
4783 | { // "/tmp" | 4885 | { // "/tmp" |
4784 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 4886 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
4785 | d = QDir::home(); | 4887 | d = QDir::home(); |
4786 | d.mkdir(APPDIR); | 4888 | d.mkdir(APPDIR); |
4787 | d.cd(APPDIR); | 4889 | d.cd(APPDIR); |
4788 | } | 4890 | } |
4789 | if ( !d.cd("urls") ) | 4891 | if ( !d.cd("urls") ) |
4790 | { // "/tmp" | 4892 | { // "/tmp" |
4791 | qWarning( "Cannot find the \"~/" APPDIR "/urls\" directory" ); | 4893 | qWarning( "Cannot find the \"~/" APPDIR "/urls\" directory" ); |
4792 | d = QDir::home(); | 4894 | d = QDir::home(); |
4793 | d.cd(APPDIR); | 4895 | d.cd(APPDIR); |
4794 | d.mkdir("urls"); | 4896 | d.mkdir("urls"); |
4795 | d.cd("urls"); | 4897 | d.cd("urls"); |
4796 | } | 4898 | } |
4797 | fi.setFile(d, file); | 4899 | fi.setFile(d, file); |
4798 | filename = fi.absFilePath(); | 4900 | filename = fi.absFilePath(); |
4799 | #endif | 4901 | #endif |
4800 | FILE* fout = fopen(filename, "a"); | 4902 | FILE* fout = fopen(filename, "a"); |
4801 | if (fout != NULL) | 4903 | if (fout != NULL) |
4802 | { | 4904 | { |
4803 | fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href); | 4905 | fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href); |
4804 | fclose(fout); | 4906 | fclose(fout); |
4805 | } | 4907 | } |
4806 | else | 4908 | else |
4807 | { | 4909 | { |
4808 | QMessageBox::warning(this, PROGNAME, "Problem with writing URL"); | 4910 | QMessageBox::warning(this, PROGNAME, "Problem with writing URL"); |
4809 | } | 4911 | } |
4810 | } | 4912 | } |
4811 | 4913 | ||
4812 | QColor QTReaderApp::getcolour(int _c) | 4914 | QColor QTReaderApp::getcolour(int _c) |
4813 | { | 4915 | { |
4814 | QColor c = white; | 4916 | QColor c = white; |
4815 | switch (_c) | 4917 | switch (_c) |
4816 | { | 4918 | { |
4817 | case 0: | 4919 | case 0: |
4818 | c = white; | 4920 | c = white; |
4819 | break; | 4921 | break; |
4820 | case 1: | 4922 | case 1: |
4821 | c = black; | 4923 | c = black; |
4822 | break; | 4924 | break; |
4823 | case 2: | 4925 | case 2: |
4824 | c = darkGray; | 4926 | c = darkGray; |
4825 | break; | 4927 | break; |
4826 | case 3: | 4928 | case 3: |
4827 | c = gray; | 4929 | c = gray; |
4828 | break; | 4930 | break; |
4829 | case 4: | 4931 | case 4: |
4830 | c = lightGray; | 4932 | c = lightGray; |
4831 | break; | 4933 | break; |
4832 | case 5: | 4934 | case 5: |
4833 | c = red; | 4935 | c = red; |
4834 | break; | 4936 | break; |
4835 | case 6: | 4937 | case 6: |
4836 | c = green; | 4938 | c = green; |
4837 | break; | 4939 | break; |
4838 | case 7: | 4940 | case 7: |
4839 | c = blue; | 4941 | c = blue; |
4840 | break; | 4942 | break; |
4841 | case 8: | 4943 | case 8: |
4842 | c = cyan; | 4944 | c = cyan; |
4843 | break; | 4945 | break; |
4844 | case 9: | 4946 | case 9: |
4845 | c = magenta; | 4947 | c = magenta; |
4846 | break; | 4948 | break; |
4847 | case 10: | 4949 | case 10: |
4848 | c = yellow; | 4950 | c = yellow; |
4849 | break; | 4951 | break; |
4850 | case 11: | 4952 | case 11: |
4851 | c = darkRed; | 4953 | c = darkRed; |
4852 | break; | 4954 | break; |
4853 | case 12: | 4955 | case 12: |
4854 | c = darkGreen; | 4956 | c = darkGreen; |
4855 | break; | 4957 | break; |
4856 | case 13: | 4958 | case 13: |
4857 | c = darkBlue; | 4959 | c = darkBlue; |
4858 | break; | 4960 | break; |
4859 | case 14: | 4961 | case 14: |
4860 | c = darkCyan; | 4962 | c = darkCyan; |
4861 | break; | 4963 | break; |
4862 | case 15: | 4964 | case 15: |
4863 | c = darkMagenta; | 4965 | c = darkMagenta; |
4864 | break; | 4966 | break; |
4865 | case 16: | 4967 | case 16: |
4866 | c = darkYellow; | 4968 | c = darkYellow; |
4867 | break; | 4969 | break; |
4868 | default: | 4970 | default: |
4869 | c = lightGray; | 4971 | c = lightGray; |
4870 | break; | 4972 | break; |
4871 | } | 4973 | } |
4872 | return c; | 4974 | return c; |
4873 | } | 4975 | } |
4874 | 4976 | ||
4875 | void QTReaderApp::setscrollcolour() | 4977 | void QTReaderApp::setscrollcolour() |
4876 | { | 4978 | { |
4877 | /* | 4979 | /* |
4878 | QColor xc = getcolour(m_scrollcolor); | 4980 | QColor xc = getcolour(m_scrollcolor); |
4879 | int r,g,b; | 4981 | int r,g,b; |
4880 | xc.rgb(&r,&g,&b); | 4982 | xc.rgb(&r,&g,&b); |
4881 | reader->m_scrollcolor.setRgb(255^r, 255^g, 255^b); | 4983 | reader->m_scrollcolor.setRgb(255^r, 255^g, 255^b); |
4882 | */ | 4984 | */ |
4883 | reader->m_scrollcolor = getcolour(m_scrollcolor); | 4985 | reader->m_scrollcolor = getcolour(m_scrollcolor); |
4884 | } | 4986 | } |
4885 | 4987 | ||
4886 | void QTReaderApp::setscrollbarcolour() | 4988 | void QTReaderApp::setscrollbarcolour() |
4887 | { | 4989 | { |
4888 | /* | 4990 | /* |
4889 | QColor xc = getcolour(m_scrollcolor); | 4991 | QColor xc = getcolour(m_scrollcolor); |
4890 | int r,g,b; | 4992 | int r,g,b; |
4891 | xc.rgb(&r,&g,&b); | 4993 | xc.rgb(&r,&g,&b); |
4892 | reader->m_scrollcolor.setRgb(255^r, 255^g, 255^b); | 4994 | reader->m_scrollcolor.setRgb(255^r, 255^g, 255^b); |
4893 | */ | 4995 | */ |
4894 | reader->m_scrollbarcolor = getcolour(m_scrollbarcolor); | 4996 | reader->m_scrollbarcolor = getcolour(m_scrollbarcolor); |
4895 | } | 4997 | } |
4896 | 4998 | ||
4897 | void QTReaderApp::forceopen(const QString& filename) | 4999 | void QTReaderApp::forceopen(const QString& filename) |
4898 | { | 5000 | { |
4899 | /* | 5001 | /* |
4900 | QFileInfo fi(reader->m_lastfile); | 5002 | QFileInfo fi(reader->m_lastfile); |
4901 | fi = QFileInfo(filename); | 5003 | fi = QFileInfo(filename); |
4902 | QString flnm = fi.absFilePath(); | 5004 | QString flnm = fi.absFilePath(); |
4903 | */ | 5005 | */ |
4904 | if (!filename.isEmpty()) | 5006 | if (!filename.isEmpty() && QFileInfo(filename).exists()) |
4905 | { | 5007 | { |
4906 | updatefileinfo(); | 5008 | updatefileinfo(); |
4907 | if (pBkmklist != NULL) | 5009 | if (pBkmklist != NULL) |
4908 | { | 5010 | { |
4909 | if (m_fBkmksChanged) | 5011 | if (m_fBkmksChanged) |
4910 | { | 5012 | { |
4911 | savebkmks(); | 5013 | savebkmks(); |
4912 | } | 5014 | } |
4913 | delete pBkmklist; | 5015 | delete pBkmklist; |
4914 | pBkmklist = NULL; | 5016 | pBkmklist = NULL; |
4915 | m_fBkmksChanged = false; | 5017 | m_fBkmksChanged = false; |
4916 | } | 5018 | } |
4917 | reader->disableAutoscroll(); | 5019 | reader->disableAutoscroll(); |
4918 | openFile(filename); | 5020 | openFile(filename); |
4919 | reader->setFocus(); | 5021 | reader->setFocus(); |
4920 | } | 5022 | } |
5023 | else | ||
5024 | { | ||
5025 | OnURLSelected(filename, 0); | ||
5026 | } | ||
4921 | } | 5027 | } |
4922 | 5028 | ||
4923 | void QTReaderApp::actionscroll(int v) | 5029 | void QTReaderApp::actionscroll(int v) |
4924 | { | 5030 | { |
4925 | if (reader->m_rotated) | 5031 | if (reader->m_rotated) |
4926 | { | 5032 | { |
4927 | reader->dopageup(reader->buffdoc.startSection()+reader->buffdoc.endSection()-v); | 5033 | reader->dopageup(reader->buffdoc.startSection()+reader->buffdoc.endSection()-v); |
4928 | } | 5034 | } |
4929 | else | 5035 | else |
4930 | { | 5036 | { |
4931 | /* | 5037 | /* |
4932 | if (reader->pagelocate() < v) | 5038 | if (reader->pagelocate() < v) |
4933 | { | 5039 | { |
4934 | while (reader->pagelocate() < v) reader->lineDown(); | 5040 | while (reader->pagelocate() < v) reader->lineDown(); |
4935 | } | 5041 | } |
4936 | else | 5042 | else |
4937 | */ | 5043 | */ |
4938 | reader->locate(v); | 5044 | reader->locate(v); |
4939 | } | 5045 | } |
4940 | } | 5046 | } |
4941 | 5047 | ||
4942 | void QTReaderApp::setBackgroundBitmap() | 5048 | void QTReaderApp::setBackgroundBitmap() |
4943 | { | 5049 | { |
4944 | #ifdef USEQPE | 5050 | #ifdef USEQPE |
4945 | QString file = APPDIR "/Themes/"; | 5051 | QString file = APPDIR "/Themes/"; |
4946 | file += m_themename; | 5052 | file += m_themename; |
4947 | QString tgt = Global::applicationFileName(file,"background"); | 5053 | QString tgt = Global::applicationFileName(file,"background"); |
4948 | #else | 5054 | #else |
4949 | QString tgt(QDir::homeDirPath()); | 5055 | QString tgt(QDir::homeDirPath()); |
4950 | tgt += QString("/" APPDIR "/Themes/") + m_themename + "/background"; | 5056 | tgt += QString("/" APPDIR "/Themes/") + m_themename + "/background"; |
4951 | #endif | 5057 | #endif |
4952 | qDebug("Trying to load %s", (const char *)tgt); | 5058 | qDebug("Trying to load %s", (const char *)tgt); |
4953 | QPixmap pm(tgt); | 5059 | QPixmap pm(tgt); |
4954 | reader->setBackgroundBitmap(pm, m_bgtype); | 5060 | reader->setBackgroundBitmap(pm, m_bgtype); |
4955 | } | 5061 | } |
4956 | 5062 | ||
4957 | /* | 5063 | /* |
4958 | 5064 | ||
4959 | myChannel = new QCopChannel( "QPE/FooBar", this ); | 5065 | myChannel = new QCopChannel( "QPE/FooBar", this ); |
4960 | connect( myChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 5066 | connect( myChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
4961 | this, SLOT(fooBarMessage( const QCString &, const QByteArray &)) ); | 5067 | this, SLOT(fooBarMessage( const QCString &, const QByteArray &)) ); |
4962 | 5068 | ||
4963 | */ | 5069 | */ |
diff --git a/noncore/apps/opie-reader/QTReaderApp.h b/noncore/apps/opie-reader/QTReaderApp.h index ad47fc9..ab1b7ad 100644 --- a/noncore/apps/opie-reader/QTReaderApp.h +++ b/noncore/apps/opie-reader/QTReaderApp.h | |||
@@ -1,484 +1,485 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef __QTREADERAPP_H | 20 | #ifndef __QTREADERAPP_H |
21 | #define __QTREADERAPP_H | 21 | #define __QTREADERAPP_H |
22 | 22 | ||
23 | //#define _SCROLLPIPE | 23 | //#define _SCROLLPIPE |
24 | //#define __ISEARCH | 24 | //#define __ISEARCH |
25 | 25 | ||
26 | //#define MAX_ENCODING 6 | 26 | //#define MAX_ENCODING 6 |
27 | #define MAX_ACTIONS 5 | 27 | #define MAX_ACTIONS 5 |
28 | 28 | ||
29 | #include <sys/timeb.h> | 29 | #include <sys/timeb.h> |
30 | #include <qmainwindow.h> | 30 | #include <qmainwindow.h> |
31 | #include "CExpander.h" | 31 | #include "CExpander.h" |
32 | #include "CEncoding.h" | 32 | #include "CEncoding.h" |
33 | #include <qlist.h> | 33 | #include <qlist.h> |
34 | //#include <qpe/filemanager.h> | 34 | //#include <qpe/filemanager.h> |
35 | #include <qmap.h> | 35 | #include <qmap.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | #include <qstack.h> | 37 | #include <qstack.h> |
38 | #include <qlistbox.h> | 38 | #include <qlistbox.h> |
39 | #ifdef USEQPE | 39 | #ifdef USEQPE |
40 | #include <qpe/qpeapplication.h> | 40 | #include <qpe/qpeapplication.h> |
41 | #endif | 41 | #endif |
42 | #include "orkey.h" | 42 | #include "orkey.h" |
43 | //#include "Queue.h" | 43 | //#include "Queue.h" |
44 | #include "BGType.h" | 44 | #include "BGType.h" |
45 | 45 | ||
46 | class QBoxLayout; | 46 | class QBoxLayout; |
47 | class QWidgetStack; | 47 | class QWidgetStack; |
48 | class QToolButton; | 48 | class QToolButton; |
49 | class QPopupMenu; | 49 | class QPopupMenu; |
50 | class QToolBar; | 50 | class QToolBar; |
51 | #ifdef USEQPE | 51 | #ifdef USEQPE |
52 | class QPEToolBar; | 52 | class QPEToolBar; |
53 | class QPEMenuBar; | 53 | class QPEMenuBar; |
54 | #endif | 54 | #endif |
55 | class QScrollBar; | 55 | class QScrollBar; |
56 | class CBkmkSelector; | 56 | class CBkmkSelector; |
57 | class QProgressBar; | 57 | class QProgressBar; |
58 | class QAction; | 58 | class QAction; |
59 | class CAnnoEdit; | 59 | class CAnnoEdit; |
60 | class QFloatBar; | 60 | class QFloatBar; |
61 | class CDrawBuffer; | 61 | class CDrawBuffer; |
62 | class QTReader; | 62 | class QTReader; |
63 | class QImage; | 63 | class QImage; |
64 | class Config; | 64 | class Config; |
65 | class CButtonPrefs; | 65 | class CButtonPrefs; |
66 | 66 | ||
67 | #ifdef USEQPE | 67 | #ifdef USEQPE |
68 | enum ToolbarPolicy | 68 | enum ToolbarPolicy |
69 | { | 69 | { |
70 | cesSingle = 0, | 70 | cesSingle = 0, |
71 | cesMenuTool, | 71 | cesMenuTool, |
72 | cesMultiple | 72 | cesMultiple |
73 | }; | 73 | }; |
74 | #else | 74 | #else |
75 | enum ToolbarPolicy | 75 | enum ToolbarPolicy |
76 | { | 76 | { |
77 | cesMenuTool = 0, | 77 | cesMenuTool = 0, |
78 | cesMultiple | 78 | cesMultiple |
79 | }; | 79 | }; |
80 | #endif | 80 | #endif |
81 | 81 | ||
82 | enum regedit_type | 82 | enum regedit_type |
83 | { | 83 | { |
84 | cAutoGen, | 84 | cAutoGen, |
85 | cAddBkmk, | 85 | cAddBkmk, |
86 | cJump, | 86 | cJump, |
87 | cMonoSpace, | 87 | cMonoSpace, |
88 | cSetTarget, | 88 | cSetTarget, |
89 | #ifdef _SCROLLPIPE | 89 | #ifdef _SCROLLPIPE |
90 | cSetPipeTarget, | 90 | cSetPipeTarget, |
91 | #endif | 91 | #endif |
92 | cSetConfigName, | 92 | cSetConfigName, |
93 | cMargin, | 93 | cMargin, |
94 | cExtraSpace, | 94 | cExtraSpace, |
95 | cExtraLead, | 95 | cExtraLead, |
96 | cRepara | 96 | cRepara |
97 | }; | 97 | }; |
98 | 98 | ||
99 | enum bkmk_action | 99 | enum bkmk_action |
100 | { | 100 | { |
101 | cOpenFile, | 101 | cOpenFile, |
102 | cGotoBkmk, | 102 | cGotoBkmk, |
103 | cDelBkmk, | 103 | cDelBkmk, |
104 | cRmBkmkFile, | 104 | cRmBkmkFile, |
105 | cLdConfig, | 105 | cLdConfig, |
106 | cRmConfig, | 106 | cRmConfig, |
107 | cExportLinks, | 107 | cExportLinks, |
108 | cLdTheme | 108 | cLdTheme |
109 | }; | 109 | }; |
110 | 110 | ||
111 | enum fontselector_action | 111 | enum fontselector_action |
112 | { | 112 | { |
113 | cChooseFont, | 113 | cChooseFont, |
114 | cChooseEncoding | 114 | cChooseEncoding |
115 | }; | 115 | }; |
116 | 116 | ||
117 | #ifdef __ISEARCH | 117 | #ifdef __ISEARCH |
118 | struct searchrecord | 118 | struct searchrecord |
119 | { | 119 | { |
120 | QString s; | 120 | QString s; |
121 | size_t pos; | 121 | size_t pos; |
122 | searchrecord(const QString& _s, size_t _pos) : s(_s), pos(_pos) {} | 122 | searchrecord(const QString& _s, size_t _pos) : s(_s), pos(_pos) {} |
123 | }; | 123 | }; |
124 | #endif | 124 | #endif |
125 | 125 | ||
126 | class infowin; | 126 | class infowin; |
127 | class GraphicWin; | 127 | class GraphicWin; |
128 | 128 | ||
129 | class QTReaderApp : public QMainWindow | 129 | class QTReaderApp : public QMainWindow |
130 | { | 130 | { |
131 | Q_OBJECT | 131 | Q_OBJECT |
132 | 132 | ||
133 | QColor getcolour(int c); | 133 | QColor getcolour(int c); |
134 | 134 | ||
135 | QMap<orKey, int> kmap; | 135 | QMap<orKey, int> kmap; |
136 | unsigned long m_savedpos; | 136 | unsigned long m_savedpos; |
137 | int m_debounce; | 137 | int m_debounce; |
138 | bool m_kmapchanged; | 138 | bool m_kmapchanged; |
139 | bground m_bgtype; | 139 | bground m_bgtype; |
140 | timeb m_lastkeytime; | 140 | timeb m_lastkeytime; |
141 | QScrollBar* m_scrollbar; | 141 | QScrollBar* m_scrollbar; |
142 | QScrollBar* scrollbar; | 142 | QScrollBar* scrollbar; |
143 | int m_qtscroll, m_localscroll; | 143 | int m_qtscroll, m_localscroll; |
144 | bool m_hidebars, m_scrollishidden, m_statusishidden; | 144 | bool m_hidebars, m_scrollishidden, m_statusishidden; |
145 | QBoxLayout *m_layout; | 145 | QBoxLayout *m_layout; |
146 | QLabel* m_prog; | 146 | QLabel* m_prog; |
147 | bool m_annoIsEditing; | 147 | bool m_annoIsEditing; |
148 | bool m_propogatefontchange, m_bFloatingDialog; | 148 | bool m_propogatefontchange, m_bFloatingDialog; |
149 | bool m_url_clipboard, m_url_localfile, m_url_globalfile; | 149 | bool m_url_clipboard, m_url_localfile, m_url_globalfile; |
150 | CButtonPrefs* m_buttonprefs; | 150 | CButtonPrefs* m_buttonprefs; |
151 | fontselector_action m_fontAction; | 151 | fontselector_action m_fontAction; |
152 | void doAction(QKeyEvent* e); | 152 | void doAction(QKeyEvent* e); |
153 | 153 | ||
154 | public: | 154 | public: |
155 | QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 155 | QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
156 | ~QTReaderApp(); | 156 | ~QTReaderApp(); |
157 | 157 | ||
158 | void hideEvent(QHideEvent*) | 158 | void hideEvent(QHideEvent*) |
159 | { | 159 | { |
160 | #ifdef USEQPE | 160 | #ifdef USEQPE |
161 | if (m_grabkeyboard) | 161 | if (m_grabkeyboard) |
162 | { | 162 | { |
163 | ((QPEApplication*)qApp)->ungrabKeyboard(); | 163 | ((QPEApplication*)qApp)->ungrabKeyboard(); |
164 | } | 164 | } |
165 | #endif | 165 | #endif |
166 | suspend(); | 166 | suspend(); |
167 | } | 167 | } |
168 | #ifdef USEQPE | 168 | #ifdef USEQPE |
169 | void showEvent(QShowEvent*) | 169 | void showEvent(QShowEvent*) |
170 | { | 170 | { |
171 | if (m_grabkeyboard) | 171 | if (m_grabkeyboard) |
172 | { | 172 | { |
173 | ((QPEApplication*)qApp)->grabKeyboard(); | 173 | ((QPEApplication*)qApp)->grabKeyboard(); |
174 | } | 174 | } |
175 | } | 175 | } |
176 | #endif | 176 | #endif |
177 | void suspend(); | 177 | void suspend(); |
178 | void openFile( const QString & ); | 178 | void openFile( const QString &, unsigned int loc = 0 ); |
179 | 179 | ||
180 | 180 | ||
181 | protected: | 181 | protected: |
182 | void setfontHelper(const QString& lcn, int size = 0); | 182 | void setfontHelper(const QString& lcn, int size = 0); |
183 | QAction* m_bkmkAvail, *m_actFullscreen; | 183 | QAction* m_bkmkAvail, *m_actFullscreen; |
184 | CAnnoEdit* m_annoWin; | 184 | CAnnoEdit* m_annoWin; |
185 | Bkmk* m_anno; | 185 | Bkmk* m_anno; |
186 | int m_scrollcolor, m_scrollbarcolor, m_background, m_foreground; | 186 | int m_scrollcolor, m_scrollbarcolor, m_background, m_foreground; |
187 | // void resizeEvent(QResizeEvent* e); | 187 | // void resizeEvent(QResizeEvent* e); |
188 | void closeEvent( QCloseEvent *e ); | 188 | void closeEvent( QCloseEvent *e ); |
189 | #ifdef NEWFULLSCREEN | 189 | #if defined(USEQPE) && defined(USENEWFULLSCREEN) |
190 | bool m_usenewfullscreen; | ||
190 | void resizeEvent(QResizeEvent *); | 191 | void resizeEvent(QResizeEvent *); |
191 | void focusInEvent(QFocusEvent*); | 192 | void focusInEvent(QFocusEvent*); |
192 | void enableFullscreen(); | ||
193 | #endif | 193 | #endif |
194 | void readbkmks(); | 194 | void readbkmks(); |
195 | void do_mono(const QString&); | 195 | void do_mono(const QString&); |
196 | void do_jump(const QString&); | 196 | void do_jump(const QString&); |
197 | void do_reparastring(const QString&); | 197 | void do_reparastring(const QString&); |
198 | void do_settarget(const QString&); | 198 | void do_settarget(const QString&); |
199 | #ifdef _SCROLLPIPE | 199 | #ifdef _SCROLLPIPE |
200 | //void do_setpipetarget(const QString&); | 200 | //void do_setpipetarget(const QString&); |
201 | #endif | 201 | #endif |
202 | void do_saveconfig(const QString&, bool); | 202 | void do_saveconfig(const QString&, bool); |
203 | bool readconfig(const QString&, const QString&, bool); | 203 | bool readconfig(const QString&, const QString&, bool); |
204 | bool PopulateConfig(const char*, bool usedirs = false); | 204 | bool PopulateConfig(const char*, bool usedirs = false); |
205 | ActionTypes ActNameToInt(const QString&); | 205 | ActionTypes ActNameToInt(const QString&); |
206 | #ifdef USEQPE | 206 | #ifdef USEQPE |
207 | bool m_grabkeyboard; | 207 | bool m_grabkeyboard; |
208 | #endif | 208 | #endif |
209 | bool m_doAnnotation; | 209 | bool m_doAnnotation; |
210 | bool m_doDictionary; | 210 | bool m_doDictionary; |
211 | bool m_doOutput; | ||
211 | bool m_doClipboard; | 212 | bool m_doClipboard; |
212 | bool m_fullscreen; | 213 | bool m_fullscreen; |
213 | bool m_loadedconfig; | 214 | bool m_loadedconfig; |
214 | public: | 215 | public: |
215 | void saveprefs(); | 216 | void saveprefs(); |
216 | public slots: | 217 | public slots: |
217 | void setBackgroundBitmap(); | 218 | void setBackgroundBitmap(); |
218 | void UpdateStatus(); | 219 | void UpdateStatus(); |
219 | void setScrollState(bool _b); | 220 | void setScrollState(bool _b); |
220 | void handlekey(QKeyEvent* e); | 221 | void handlekey(QKeyEvent* e); |
221 | void forceopen(const QString& filename); | 222 | void forceopen(const QString& filename); |
222 | void setDocument(const QString&); | 223 | void setDocument(const QString&); |
223 | private slots: | 224 | private slots: |
224 | #ifdef _SCRIPT | 225 | #ifdef _SCRIPT |
225 | // void RunScript(); | 226 | // void RunScript(); |
226 | #endif | 227 | #endif |
227 | void actionscroll(int v); | 228 | void actionscroll(int v); |
228 | void SaveConfig(); | 229 | void SaveConfig(); |
229 | void LoadTheme(); | 230 | void LoadTheme(); |
230 | void LoadConfig(); | 231 | void LoadConfig(); |
231 | void TidyConfig(); | 232 | void TidyConfig(); |
232 | void ExportLinks(); | 233 | void ExportLinks(); |
233 | void zoomin(); | 234 | void zoomin(); |
234 | void zoomout(); | 235 | void zoomout(); |
235 | void chooseencoding(); | 236 | void chooseencoding(); |
236 | void setfullscreen(bool sfs); | 237 | void setfullscreen(bool sfs); |
237 | void setrotated(bool sfs); | 238 | void setrotated(bool sfs); |
238 | void setinverted(bool sfs); | 239 | void setinverted(bool sfs); |
239 | void setgrab(bool sfs); | 240 | void setgrab(bool sfs); |
240 | // void setcontinuous(bool sfs); | 241 | // void setcontinuous(bool sfs); |
241 | void setTwoTouch(bool _b); | 242 | void setTwoTouch(bool _b); |
242 | void restoreFocus(); | 243 | void restoreFocus(); |
243 | void OnAnnotation(bool _b) | 244 | void OnAnnotation(bool _b) |
244 | { | 245 | { |
245 | m_doAnnotation = _b; | 246 | m_doAnnotation = _b; |
246 | } | 247 | } |
247 | void OnDictionary(bool _b) | 248 | void OnDictionary(bool _b) |
248 | { | 249 | { |
249 | m_doDictionary = _b; | 250 | m_doDictionary = _b; |
250 | } | 251 | } |
251 | void OnClipboard(bool _b) | 252 | void OnClipboard(bool _b) |
252 | { | 253 | { |
253 | m_doClipboard = _b; | 254 | m_doClipboard = _b; |
254 | } | 255 | } |
255 | void OnWordSelected(const QString&, size_t, size_t, const QString&); | 256 | void OnWordSelected(const QString&, size_t, size_t, const QString&); |
256 | void OnURLSelected(const QString& href, const size_t tgt); | 257 | void OnURLSelected(const QString& href, const size_t tgt); |
257 | void showgraphic(QImage&); | 258 | void showgraphic(QImage&); |
258 | void addAnno(const QString&, const QString&, size_t, size_t); | 259 | void addAnno(const QString&, const QString&, size_t, size_t); |
259 | void addAnno(const QString&, const QString&); | 260 | void addAnno(const QString&, const QString&); |
260 | void addanno(); | 261 | void addanno(); |
261 | void showAnnotation(); | 262 | void showAnnotation(); |
262 | void do_setencoding(int i); | 263 | void do_setencoding(int i); |
263 | void do_setfont(const QString&); | 264 | void do_setfont(const QString&); |
264 | //void buttonActionSelected(QAction*); | 265 | //void buttonActionSelected(QAction*); |
265 | void msgHandler(const QCString&, const QByteArray&); | 266 | void msgHandler(const QCString&, const QByteArray&); |
266 | void monospace(bool); | 267 | void monospace(bool); |
267 | void jump(); | 268 | void jump(); |
268 | void reparastring(); | 269 | void reparastring(); |
269 | void settarget(); | 270 | void settarget(); |
270 | #ifdef _SCROLLPIPE | 271 | #ifdef _SCROLLPIPE |
271 | //void setpipetarget(); | 272 | //void setpipetarget(); |
272 | //void setpause(bool); | 273 | //void setpause(bool); |
273 | #endif | 274 | #endif |
274 | //void setspacing(); | 275 | //void setspacing(); |
275 | void setfont(); | 276 | void setfont(); |
276 | void clearBkmkList(); | 277 | void clearBkmkList(); |
277 | void listBkmkFiles(); | 278 | void listBkmkFiles(); |
278 | void editMark(); | 279 | void editMark(); |
279 | void autoScroll(bool); | 280 | void autoScroll(bool); |
280 | void addbkmk(); | 281 | void addbkmk(); |
281 | void savebkmks(); | 282 | void savebkmks(); |
282 | //void importFiles(); | 283 | //void importFiles(); |
283 | void showprefs(); | 284 | void showprefs(); |
284 | void showtoolbarprefs(); | 285 | void showtoolbarprefs(); |
285 | void showbuttonprefs(); | 286 | void showbuttonprefs(); |
286 | void infoClose(); | 287 | void infoClose(); |
287 | // void oldFile(); | 288 | // void oldFile(); |
288 | void showinfo(); | 289 | void showinfo(); |
289 | 290 | ||
290 | // void indentplus(); | 291 | // void indentplus(); |
291 | // void indentminus(); | 292 | // void indentminus(); |
292 | 293 | ||
293 | void fileOpen(); | 294 | void fileOpen(); |
294 | void fileClose(); | 295 | void fileClose(); |
295 | 296 | ||
296 | void editCopy(); | 297 | void editCopy(); |
297 | void editFind(); | 298 | void editFind(); |
298 | 299 | ||
299 | void gotoStart(); | 300 | void gotoStart(); |
300 | void gotoEnd(); | 301 | void gotoEnd(); |
301 | 302 | ||
302 | void pageup(); | 303 | void pageup(); |
303 | void pagedn(); | 304 | void pagedn(); |
304 | 305 | ||
305 | void findNext(); | 306 | void findNext(); |
306 | void findClose(); | 307 | void findClose(); |
307 | 308 | ||
308 | void regClose(); | 309 | void regClose(); |
309 | 310 | ||
310 | #ifdef __ISEARCH | 311 | #ifdef __ISEARCH |
311 | // void search( const QString& ); | 312 | // void search( const QString& ); |
312 | #else | 313 | #else |
313 | void search(); | 314 | void search(); |
314 | #endif | 315 | #endif |
315 | 316 | ||
316 | void showEditTools(); | 317 | void showEditTools(); |
317 | 318 | ||
318 | // void stripcr(bool); | 319 | // void stripcr(bool); |
319 | // void setfulljust(bool); | 320 | // void setfulljust(bool); |
320 | // void onespace(bool); | 321 | // void onespace(bool); |
321 | // void repalm(bool); | 322 | // void repalm(bool); |
322 | // void peanut(bool _b); | 323 | // void peanut(bool _b); |
323 | // void remap(bool); | 324 | // void remap(bool); |
324 | // void embolden(bool); | 325 | // void embolden(bool); |
325 | // void autofmt(bool); | 326 | // void autofmt(bool); |
326 | // void textfmt(bool); | 327 | // void textfmt(bool); |
327 | // void striphtml(bool); | 328 | // void striphtml(bool); |
328 | // void dehyphen(bool); | 329 | // void dehyphen(bool); |
329 | // void depluck(bool); | 330 | // void depluck(bool); |
330 | // void dejpluck(bool); | 331 | // void dejpluck(bool); |
331 | // void unindent(bool); | 332 | // void unindent(bool); |
332 | // void repara(bool); | 333 | // void repara(bool); |
333 | // void dblspce(bool); | 334 | // void dblspce(bool); |
334 | void pagemode(bool); | 335 | void pagemode(bool); |
335 | // void gotobkmk(const QString& bm); | 336 | // void gotobkmk(const QString& bm); |
336 | void gotobkmk(int); | 337 | void gotobkmk(int); |
337 | void cancelbkmk(); | 338 | void cancelbkmk(); |
338 | void do_gotomark(); | 339 | void do_gotomark(); |
339 | void do_delmark(); | 340 | void do_delmark(); |
340 | void do_autogen(); | 341 | void do_autogen(); |
341 | void do_regaction(); | 342 | void do_regaction(); |
342 | void OnRedraw(); | 343 | void OnRedraw(); |
343 | 344 | ||
344 | private: | 345 | private: |
345 | void setscrollcolour(); | 346 | void setscrollcolour(); |
346 | void setscrollbarcolour(); | 347 | void setscrollbarcolour(); |
347 | void writeUrl(const QString& file, const QString& href); | 348 | void writeUrl(const QString& file, const QString& href); |
348 | QAction *m_preferences_action, *m_open_action, *m_close_action; | 349 | QAction *m_preferences_action, *m_open_action, *m_close_action; |
349 | QAction *m_info_action, *m_touch_action, *m_find_action, *m_start_action; | 350 | QAction *m_info_action, *m_touch_action, *m_find_action, *m_start_action; |
350 | QAction *m_end_action, *m_jump_action, *m_pageline_action; | 351 | QAction *m_end_action, *m_jump_action, *m_pageline_action; |
351 | QAction *m_pageup_action, *m_pagedn_action, *m_back_action; | 352 | QAction *m_pageup_action, *m_pagedn_action, *m_back_action; |
352 | QAction *m_home_action, *m_forward_action, *m_zoomin_action; | 353 | QAction *m_home_action, *m_forward_action, *m_zoomin_action; |
353 | QAction *m_zoomout_action, *m_setfont_action, *m_mark_action; | 354 | QAction *m_zoomout_action, *m_setfont_action, *m_mark_action; |
354 | QAction *m_annotate_action, *m_goto_action, *m_delete_action; | 355 | QAction *m_annotate_action, *m_goto_action, *m_delete_action; |
355 | QAction *m_autogen_action, *m_clear_action, *m_save_action; | 356 | QAction *m_autogen_action, *m_clear_action, *m_save_action; |
356 | QAction *m_tidy_action, *m_startBlock_action, *m_endBlock_action; | 357 | QAction *m_tidy_action, *m_startBlock_action, *m_endBlock_action; |
357 | QAction *m_setenc_action, *m_setmono_action, *m_saveconfig_action; | 358 | QAction *m_setenc_action, *m_setmono_action, *m_saveconfig_action; |
358 | QAction *m_loadconfig_action, *m_loadtheme_action, *m_toolbarprefs_action, *m_tidyconfig_action; | 359 | QAction *m_loadconfig_action, *m_loadtheme_action, *m_toolbarprefs_action, *m_tidyconfig_action; |
359 | QAction *m_exportlinks_action, *m_rotate_action, *m_buttonprefs_action, *m_inverse_action; | 360 | QAction *m_exportlinks_action, *m_rotate_action, *m_buttonprefs_action, *m_inverse_action; |
360 | QAction *m_repara_action; | 361 | QAction *m_repara_action; |
361 | #ifdef USEQPE | 362 | #ifdef USEQPE |
362 | QAction *m_grab_action; | 363 | QAction *m_grab_action; |
363 | #endif | 364 | #endif |
364 | void addtoolbars(Config* config); | 365 | void addtoolbars(Config* config); |
365 | ToolbarPolicy m_tbpol, m_tbpolsave; | 366 | ToolbarPolicy m_tbpol, m_tbpolsave; |
366 | ToolBarDock m_tbposition; | 367 | ToolBarDock m_tbposition; |
367 | bool m_tbmove, m_tbmovesave; | 368 | bool m_tbmove, m_tbmovesave; |
368 | QToolBar* filebar(); | 369 | QToolBar* filebar(); |
369 | QToolBar* viewbar(); | 370 | QToolBar* viewbar(); |
370 | QToolBar* navbar(); | 371 | QToolBar* navbar(); |
371 | QToolBar* markbar(); | 372 | QToolBar* markbar(); |
372 | void hidetoolbars(); | 373 | void hidetoolbars(); |
373 | void addfilebar(Config* _config, const QString& key, QAction* a); | 374 | void addfilebar(Config* _config, const QString& key, QAction* a); |
374 | void addviewbar(Config* _config, const QString& key, QAction* a); | 375 | void addviewbar(Config* _config, const QString& key, QAction* a); |
375 | void addnavbar(Config* _config, const QString& key, QAction* a); | 376 | void addnavbar(Config* _config, const QString& key, QAction* a); |
376 | void addmarkbar(Config* _config, const QString& key, QAction* a); | 377 | void addmarkbar(Config* _config, const QString& key, QAction* a); |
377 | bool checkbar(Config* _config, const QString& key); | 378 | bool checkbar(Config* _config, const QString& key); |
378 | #ifdef _SCRIPT | 379 | #ifdef _SCRIPT |
379 | void SaveScript(const char* sname); | 380 | void SaveScript(const char* sname); |
380 | #endif | 381 | #endif |
381 | /* | 382 | /* |
382 | void setstate(unsigned char* _sd, unsigned short _sdlen); | 383 | void setstate(unsigned char* _sd, unsigned short _sdlen); |
383 | void getstate(unsigned char*& data, unsigned short& len); | 384 | void getstate(unsigned char*& data, unsigned short& len); |
384 | */ | 385 | */ |
385 | void fileOpen2(); | 386 | void fileOpen2(); |
386 | void readfilelist(); | 387 | void readfilelist(); |
387 | void savefilelist(); | 388 | void savefilelist(); |
388 | void updatefileinfo(); | 389 | void updatefileinfo(); |
389 | bool openfrombkmk(Bkmk*); | 390 | bool openfrombkmk(Bkmk*); |
390 | QString m_targetapp, m_targetmsg, m_statusstring, m_themename; | 391 | QString m_targetapp, m_targetmsg, m_statusstring, m_themename; |
391 | bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null); | 392 | bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null, bool presel=false); |
392 | QString usefilebrowser(); | 393 | QString usefilebrowser(); |
393 | void do_regedit(); | 394 | void do_regedit(); |
394 | void colorChanged( const QColor &c ); | 395 | void colorChanged( const QColor &c ); |
395 | void clear(); | 396 | void clear(); |
396 | void updateCaption(); | 397 | void updateCaption(); |
397 | void do_autogen(const QString&); | 398 | void do_autogen(const QString&); |
398 | void do_addbkmk(const QString&); | 399 | void do_addbkmk(const QString&); |
399 | bool findNextBookmark(size_t start); | 400 | bool findNextBookmark(size_t start); |
400 | 401 | ||
401 | private: | 402 | private: |
402 | 403 | ||
403 | QAction* m_scrollButton; | 404 | QAction* m_scrollButton; |
404 | 405 | ||
405 | QAction* m_buttonAction[MAX_ACTIONS]; | 406 | QAction* m_buttonAction[MAX_ACTIONS]; |
406 | 407 | ||
407 | CBkmkSelector* bkmkselector; | 408 | CBkmkSelector* bkmkselector; |
408 | 409 | ||
409 | // ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget, | 410 | // ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget, |
410 | //m_upTarget, m_downTarget; | 411 | //m_upTarget, m_downTarget; |
411 | //bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll; | 412 | //bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll; |
412 | bool m_bcloseDisabled, m_disableesckey; | 413 | bool m_bcloseDisabled, m_disableesckey; |
413 | size_t searchStart; | 414 | size_t searchStart; |
414 | #ifdef __ISEARCH | 415 | #ifdef __ISEARCH |
415 | QStack<searchrecord>* searchStack; | 416 | QStack<searchrecord>* searchStack; |
416 | bool dosearch(size_t start, CDrawBuffer& test, const QString& arg); | 417 | bool dosearch(size_t start, CDrawBuffer& test, const QString& arg); |
417 | #else | 418 | #else |
418 | bool dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg); | 419 | bool dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg); |
419 | #endif | 420 | #endif |
420 | QWidgetStack *editorStack; | 421 | QWidgetStack *editorStack; |
421 | QTReader* reader; | 422 | QTReader* reader; |
422 | QComboBox* m_fontSelector; | 423 | QComboBox* m_fontSelector; |
423 | // QPEToolBar /* *menu,*/ *fileBar; | 424 | // QPEToolBar /* *menu,*/ *fileBar; |
424 | #ifdef USEQPE | 425 | #if defined(USEQPE) |
425 | QToolBar *menubar; | 426 | QToolBar *menubar; |
426 | #endif | 427 | #endif |
427 | QToolBar *fileBar, *navBar, *viewBar, *markBar; | 428 | QToolBar *fileBar, *navBar, *viewBar, *markBar; |
428 | #ifdef USEQPE | 429 | #if defined(USEQPE) |
429 | QPEMenuBar *mb; | 430 | QPEMenuBar *mb; |
430 | #else | 431 | #else |
431 | QMenuBar *mb; | 432 | QMenuBar *mb; |
432 | #endif | 433 | #endif |
433 | QFloatBar *searchBar, *regBar/*, *m_fontBar*/; | 434 | QFloatBar *searchBar, *regBar/*, *m_fontBar*/; |
434 | QToolBar /* *searchBar, *regBar,*/ *m_fontBar; | 435 | QToolBar /* *searchBar, *regBar,*/ *m_fontBar; |
435 | QLineEdit *searchEdit, *regEdit; | 436 | QLineEdit *searchEdit, *regEdit; |
436 | bool searchVisible; | 437 | bool searchVisible; |
437 | bool regVisible; | 438 | bool regVisible; |
438 | bool m_fontVisible, m_twoTouch; | 439 | bool m_fontVisible, m_twoTouch; |
439 | static unsigned long m_uid; | 440 | static unsigned long m_uid; |
440 | long unsigned get_unique_id() { return m_uid++; } | 441 | long unsigned get_unique_id() { return m_uid++; } |
441 | /* | 442 | /* |
442 | void resizeEvent( QResizeEvent * r) | 443 | void resizeEvent( QResizeEvent * r) |
443 | { | 444 | { |
444 | // qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height()); | 445 | // qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height()); |
445 | // qDebug("resize:(%u,%u)", r->size().width(), r->size().height()); | 446 | // qDebug("resize:(%u,%u)", r->size().width(), r->size().height()); |
446 | // bgroup->move( width()-bgroup->width(), 0 ); | 447 | // bgroup->move( width()-bgroup->width(), 0 ); |
447 | } | 448 | } |
448 | */ | 449 | */ |
449 | CList<Bkmk>* pBkmklist; | 450 | CList<Bkmk>* pBkmklist; |
450 | CList<Bkmk>* pOpenlist; | 451 | CList<Bkmk>* pOpenlist; |
451 | infowin* m_infoWin; | 452 | infowin* m_infoWin; |
452 | GraphicWin* m_graphicwin; | 453 | GraphicWin* m_graphicwin; |
453 | QProgressBar* pbar; | 454 | QProgressBar* pbar; |
454 | bool m_fBkmksChanged; | 455 | bool m_fBkmksChanged; |
455 | // int m_nRegAction; | 456 | // int m_nRegAction; |
456 | regedit_type m_nRegAction; | 457 | regedit_type m_nRegAction; |
457 | bkmk_action m_nBkmkAction; | 458 | bkmk_action m_nBkmkAction; |
458 | QString m_autogenstr; | 459 | QString m_autogenstr; |
459 | bool m_dontSave; | 460 | bool m_dontSave; |
460 | }; | 461 | }; |
461 | 462 | ||
462 | //const int cAutoGen = 0; | 463 | //const int cAutoGen = 0; |
463 | //const int cAddBkmk = 1; | 464 | //const int cAddBkmk = 1; |
464 | //const int cDelBkmk = 2; | 465 | //const int cDelBkmk = 2; |
465 | //const int cGotoBkmk = 3; | 466 | //const int cGotoBkmk = 3; |
466 | //const int cRmBkmkFile = 4; | 467 | //const int cRmBkmkFile = 4; |
467 | //const int cJump = 5; | 468 | //const int cJump = 5; |
468 | //const int cMonoSpace = 6; | 469 | //const int cMonoSpace = 6; |
469 | //const int cOverlap = 7; | 470 | //const int cOverlap = 7; |
470 | //const int cSetTarget = 8; | 471 | //const int cSetTarget = 8; |
471 | //const int cOpenFile = 9; | 472 | //const int cOpenFile = 9; |
472 | //const int cSetPipeTarget = 10; | 473 | //const int cSetPipeTarget = 10; |
473 | //const int cSetConfigName = 11; | 474 | //const int cSetConfigName = 11; |
474 | //const int cMargin = 12; | 475 | //const int cMargin = 12; |
475 | //const int cExtraSpace = 14; | 476 | //const int cExtraSpace = 14; |
476 | //const int cExtraLead = 15; | 477 | //const int cExtraLead = 15; |
477 | //const int cGfxSize = 16; | 478 | //const int cGfxSize = 16; |
478 | //const int cChooseFont = 2; | 479 | //const int cChooseFont = 2; |
479 | //const int cChooseEncoding = 1; | 480 | //const int cChooseEncoding = 1; |
480 | 481 | ||
481 | #endif | 482 | #endif |
482 | 483 | ||
483 | 484 | ||
484 | 485 | ||
diff --git a/noncore/apps/opie-reader/Reb.cpp b/noncore/apps/opie-reader/Reb.cpp new file mode 100644 index 0000000..2e6c1fc --- a/dev/null +++ b/noncore/apps/opie-reader/Reb.cpp | |||
@@ -0,0 +1,789 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <string.h> | ||
3 | #include <qimage.h> | ||
4 | #include "decompress.h" | ||
5 | #include "Reb.h" | ||
6 | #include "my_list.h" | ||
7 | #include "Bkmks.h" | ||
8 | #include "Model.h" | ||
9 | /* | ||
10 | #ifdef offsetof | ||
11 | #define OffsetOf(type, field) ((int) offsetof(type, field)) | ||
12 | #else | ||
13 | #define OffsetOf(type, field) ((int) ((char *) &((type *) 0)->field)) | ||
14 | #endif | ||
15 | |||
16 | template<class T> | ||
17 | UInt32 binarychop(T* data, UInt32 n, T val) | ||
18 | { | ||
19 | UInt32 jl = 0,jh = n-1,jm = (jl+jh)/2; | ||
20 | while (jh > jl+1) | ||
21 | { | ||
22 | if (data[jm] > val) | ||
23 | { | ||
24 | jh = jm; | ||
25 | } | ||
26 | else | ||
27 | { | ||
28 | jl = jm; | ||
29 | } | ||
30 | jm = (jl+jh)/2; | ||
31 | } | ||
32 | return jl; | ||
33 | } | ||
34 | |||
35 | template<class T, class D> | ||
36 | UInt32 binarychop(D* data, UInt32 n, T val, UInt32 offset) | ||
37 | { | ||
38 | UInt32 jl = 0,jh = n-1,jm = (jl+jh)/2; | ||
39 | while (jh > jl+1) | ||
40 | { | ||
41 | T* d = reinterpret_cast<T*>(reinterpret_cast<char*>(data+jm)+offset); | ||
42 | if (*d > val) | ||
43 | { | ||
44 | jh = jm; | ||
45 | } | ||
46 | else | ||
47 | { | ||
48 | jl = jm; | ||
49 | } | ||
50 | jm = (jl+jh)/2; | ||
51 | } | ||
52 | return jl; | ||
53 | } | ||
54 | */ | ||
55 | |||
56 | CReb::CReb() | ||
57 | : | ||
58 | fin(NULL), m_indexpages(NULL), m_pagedetails(NULL),tagoffset(0), | ||
59 | tags(NULL), paras(NULL), noparas(0), joins(NULL), nojoins(0) | ||
60 | { | ||
61 | } | ||
62 | |||
63 | CReb::~CReb() | ||
64 | { | ||
65 | if (fin != NULL) fclose(fin); | ||
66 | if (m_indexpages != NULL) delete [] m_indexpages; | ||
67 | if (m_pagedetails != NULL) delete [] m_pagedetails; | ||
68 | if (tags != NULL) delete [] tags; | ||
69 | if (paras != NULL) delete [] paras; | ||
70 | if (joins != NULL) delete [] joins; | ||
71 | } | ||
72 | |||
73 | unsigned int CReb::locate() | ||
74 | { | ||
75 | return m_pagedetails[currentpage.pageno()].pagestart+currentpage.offset(); | ||
76 | } | ||
77 | |||
78 | void CReb::locate(unsigned int n) | ||
79 | { | ||
80 | /* | ||
81 | UInt32 cp = nopages-1; | ||
82 | for (int i = 0; i < nopages; ++i) | ||
83 | { | ||
84 | if (m_pagedetails[i].pagestart > n) | ||
85 | { | ||
86 | cp = i-1; | ||
87 | break; | ||
88 | } | ||
89 | } | ||
90 | qDebug("Requesting %u from page %u [%u]", n, cp, n - m_pagedetails[cp].pagestart); | ||
91 | */ | ||
92 | //UInt32 jl = binarychop<UInt32, Page_detail>(m_pagedetails, nopages, n, OffsetOf(Page_detail, pagestart)); | ||
93 | |||
94 | UInt32 jl = 0,jh = nopages-1,jm = (jl+jh)/2; | ||
95 | while (jh > jl+1) | ||
96 | { | ||
97 | if (m_pagedetails[jm].pagestart > n) | ||
98 | { | ||
99 | jh = jm; | ||
100 | } | ||
101 | else | ||
102 | { | ||
103 | jl = jm; | ||
104 | } | ||
105 | jm = (jl+jh)/2; | ||
106 | } | ||
107 | |||
108 | unsuspend(); | ||
109 | Page_detail rs = m_pagedetails[jl]; | ||
110 | UInt32 val = n - rs.pagestart; | ||
111 | if (jl != currentpage.pageno()) readindex(jl); | ||
112 | currentpage.setoffset(page2pos(jl), jl, ((rs.flags & 8) != 0), rs.len, val); | ||
113 | if (noparas > 0) | ||
114 | { | ||
115 | //jl = binarychop<int, ParaRef>(paras, noparas, val, OffsetOf(ParaRef, pos)); | ||
116 | |||
117 | UInt32 jl = 0,jh = noparas-1,jm = (jl+jh)/2; | ||
118 | while (jh > jl+1) | ||
119 | { | ||
120 | if (paras[jm].pos > val) | ||
121 | { | ||
122 | jh = jm; | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | jl = jm; | ||
127 | } | ||
128 | jm = (jl+jh)/2; | ||
129 | } | ||
130 | |||
131 | qDebug("TAGS:%s", (const char*)tags[paras[jl].tag]); | ||
132 | tagstring = tags[paras[jl].tag]+"<br>"; // Add br to set extra space to 0 | ||
133 | tagoffset = 0; | ||
134 | } | ||
135 | unsigned long current = locate(); | ||
136 | if (m_currentstart > current || current > m_currentend) | ||
137 | { | ||
138 | start2endSection(); | ||
139 | } | ||
140 | if (current != n) qDebug("ERROR:Ended up at %u", current); | ||
141 | } | ||
142 | |||
143 | bool CReb::getFile(const QString& href, const QString& nm) | ||
144 | { | ||
145 | qDebug("File:%s, Name:%s", (const char*)href, (const char*)nm); | ||
146 | QMap<QString, UInt32>::Iterator iter = m_index.find(href); | ||
147 | if (iter != m_index.end()) | ||
148 | { | ||
149 | qDebug("REB:BEFORE:%u", locate()); | ||
150 | startpage(iter.data()); | ||
151 | qDebug("REB:AFTER:%u", locate()); | ||
152 | return true; | ||
153 | } | ||
154 | else | ||
155 | { | ||
156 | return false; | ||
157 | } | ||
158 | } | ||
159 | |||
160 | QImage* CReb::getPicture(const QString& ref) | ||
161 | { | ||
162 | QMap<QString, UInt32>::Iterator iter = m_index.find(ref); | ||
163 | if (iter != m_index.end()) | ||
164 | { | ||
165 | unsuspend(); | ||
166 | Page_detail rs = m_pagedetails[iter.data()]; | ||
167 | char* imgbuffer = new char[rs.len]; | ||
168 | fseek(fin, page2pos(iter.data()), SEEK_SET); | ||
169 | fread(imgbuffer, rs.len, 1, fin); | ||
170 | QByteArray arr; | ||
171 | arr.assign((const char*)imgbuffer, rs.len); | ||
172 | QImage* qimage = new QImage(arr); | ||
173 | return qimage; | ||
174 | } | ||
175 | else | ||
176 | { | ||
177 | return NULL; | ||
178 | } | ||
179 | } | ||
180 | |||
181 | CList<Bkmk>* CReb::getbkmklist() { return NULL; } | ||
182 | |||
183 | void CReb::home() | ||
184 | { | ||
185 | startpage(m_homepage); | ||
186 | } | ||
187 | |||
188 | int CReb::OpenFile(const char *src) | ||
189 | { | ||
190 | m_binary = false; | ||
191 | if (fin != NULL) fclose(fin); | ||
192 | fin = fopen(src, "r"); | ||
193 | if (fin == NULL) | ||
194 | { | ||
195 | return -1; | ||
196 | } | ||
197 | UInt32 type; | ||
198 | fseek(fin, 6, SEEK_SET); | ||
199 | fread(&type, 1, sizeof(type), fin); | ||
200 | qDebug("CREB:Okay %x", type); | ||
201 | |||
202 | if (type == 0x4f56554e || type == 0x574d4954 || type == 0x576d6954) | ||
203 | { | ||
204 | struct stat _stat; | ||
205 | stat(src, &_stat); | ||
206 | file_length = _stat.st_size; | ||
207 | fread(&m_blocksize, 1, sizeof(m_blocksize), fin); | ||
208 | if (type == 0x574d4954 || type == 0x576d6954) | ||
209 | { | ||
210 | if (type == 0x576d6954) m_binary = true; | ||
211 | qDebug("Blocksize(1) %x", m_blocksize); | ||
212 | unsigned char ct = (m_blocksize >> 24) & 0xff; | ||
213 | qDebug("Compress type:%x", ct); | ||
214 | switch (ct) | ||
215 | { | ||
216 | case 0: | ||
217 | m_decompress = UnZip; | ||
218 | break; | ||
219 | case 3: | ||
220 | m_decompress = getdecompressor("PluckerDecompress3"); | ||
221 | break; | ||
222 | case 4: | ||
223 | m_decompress = getdecompressor("PluckerDecompress4"); | ||
224 | break; | ||
225 | } | ||
226 | if (m_decompress == NULL) return -1; | ||
227 | m_blocksize = 1024*(m_blocksize & 0xffffff); | ||
228 | } | ||
229 | else | ||
230 | { | ||
231 | m_blocksize = 4096; | ||
232 | m_decompress = UnZip; | ||
233 | } | ||
234 | qDebug("Blocksize %u", m_blocksize); | ||
235 | currentpage.init(fin, m_blocksize, m_decompress); | ||
236 | qDebug("Its a REB!!!!"); | ||
237 | fseek(fin, 0x18, SEEK_SET); | ||
238 | fread(&toc, 1, sizeof(toc), fin); | ||
239 | qDebug("Expect this to be 128 or 20:%x", toc); | ||
240 | fread(&type, 1, sizeof(type), fin); | ||
241 | qDebug("File length:%u", type); | ||
242 | fseek(fin, toc, SEEK_SET); | ||
243 | fread(&nopages, 1, sizeof(nopages), fin); | ||
244 | m_indexpages = new UInt32[nopages]; | ||
245 | m_pagedetails = new Page_detail[nopages]; | ||
246 | qDebug("There are %u pages", nopages); | ||
247 | UInt32 loc = 0; | ||
248 | UInt32 homeguess = nopages-1; | ||
249 | QString homeurl; | ||
250 | for (int i = 0; i < nopages; ++i) | ||
251 | { | ||
252 | char name[32]; | ||
253 | UInt32 len, pos, flags; | ||
254 | fread(name, 1, 32, fin); | ||
255 | fread(&len, 1, 4, fin); | ||
256 | fread(&pos, 1, 4, fin); | ||
257 | fread(&flags, 1, 4, fin); | ||
258 | //qDebug("Page %u (%s) is %u bytes at %u (%u) of type %u", i, name, len, pos, loc, flags); | ||
259 | m_index[name] = i; | ||
260 | m_pagedetails[i] = Page_detail(loc, len, flags); | ||
261 | |||
262 | if (QString(name).find(".htm", 0, false) >= 0) | ||
263 | { | ||
264 | if (homeguess > i) homeguess = i; | ||
265 | if ((flags & 8) != 0) | ||
266 | { | ||
267 | UInt32 lastpos = ftell(fin); | ||
268 | loc += pagelength(i); | ||
269 | fseek(fin, lastpos, SEEK_SET); | ||
270 | } | ||
271 | else | ||
272 | { | ||
273 | loc += len; | ||
274 | } | ||
275 | } | ||
276 | if ((flags & 2) != 0) | ||
277 | { | ||
278 | UInt32 lastpos = ftell(fin); | ||
279 | RBPage* idx = new RBPage(); | ||
280 | idx->init(fin, m_blocksize, m_decompress); | ||
281 | idx->startpage(page2pos(i), i, ((flags & 8) != 0), len); | ||
282 | int c = 0; | ||
283 | while (c != EOF) | ||
284 | { | ||
285 | QString s(""); | ||
286 | while (1) | ||
287 | { | ||
288 | c = idx->getch(this); | ||
289 | if (c == 10 || c == EOF) break; | ||
290 | s += c; | ||
291 | } | ||
292 | if (s.left(5) == "BODY=") | ||
293 | { | ||
294 | homeurl = s.right(s.length()-5); | ||
295 | qDebug("Home:%s", (const char*)homeurl); | ||
296 | } | ||
297 | else | ||
298 | { | ||
299 | qDebug("Info:%s", (const char*)s); | ||
300 | } | ||
301 | } | ||
302 | delete idx; | ||
303 | fseek(fin, lastpos, SEEK_SET); | ||
304 | } | ||
305 | } | ||
306 | text_length = loc; | ||
307 | qDebug("Looking for homepage"); | ||
308 | if (homeurl.isEmpty()) | ||
309 | { | ||
310 | m_homepage = homeguess; | ||
311 | } | ||
312 | else | ||
313 | { | ||
314 | QMap<QString, UInt32>::Iterator iter = m_index.find(homeurl); | ||
315 | if (iter != m_index.end()) | ||
316 | { | ||
317 | m_homepage = iter.data(); | ||
318 | } | ||
319 | else | ||
320 | { | ||
321 | m_homepage = homeguess; | ||
322 | } | ||
323 | } | ||
324 | m_homepos = m_pagedetails[m_homepage].pagestart; | ||
325 | qDebug("Finding indices"); | ||
326 | for (QMap<QString, UInt32>::Iterator iter = m_index.begin(); iter != m_index.end(); ++iter) | ||
327 | { | ||
328 | QString href = iter.key(); | ||
329 | if (href.find(".htm", 0, false) >= 0) | ||
330 | { | ||
331 | QString hind = href.left(href.find(".htm", 0, false))+".hidx"; | ||
332 | //qDebug("Index is %s", (const char*)hind); | ||
333 | QMap<QString, UInt32>::Iterator iter2 = m_index.find(hind); | ||
334 | if (iter2 != m_index.end()) | ||
335 | { | ||
336 | m_indexpages[iter.data()] = iter2.data(); | ||
337 | } | ||
338 | } | ||
339 | } | ||
340 | qDebug("Going home"); | ||
341 | home(); | ||
342 | return 0; | ||
343 | } | ||
344 | else | ||
345 | { | ||
346 | char * tmp = (char*)(&type); | ||
347 | for (int i = 0; i < 4; ++i) qDebug("%d:%c", i, tmp[i]); | ||
348 | return -1; | ||
349 | } | ||
350 | } | ||
351 | |||
352 | UInt32 CReb::page2pos(UInt32 page) | ||
353 | { | ||
354 | fseek(fin, toc+40+44*page, SEEK_SET); | ||
355 | UInt32 pos; | ||
356 | fread(&pos, 1, 4, fin); | ||
357 | return pos; | ||
358 | } | ||
359 | |||
360 | UInt32 CReb::pagelength(UInt32 pagenum) | ||
361 | { | ||
362 | fseek(fin, toc+40+44*pagenum, SEEK_SET); | ||
363 | UInt32 pos; | ||
364 | fread(&pos, 1, 4, fin); | ||
365 | fseek(fin, pos+4, SEEK_SET); | ||
366 | UInt32 len; | ||
367 | fread(&len, 1, sizeof(len), fin); | ||
368 | return len; | ||
369 | } | ||
370 | |||
371 | void CReb::readindex(UInt32 cp) | ||
372 | { | ||
373 | if (joins != NULL) | ||
374 | { | ||
375 | delete [] joins; | ||
376 | joins = NULL; | ||
377 | } | ||
378 | if (tags != NULL) | ||
379 | { | ||
380 | delete [] tags; | ||
381 | tags = NULL; | ||
382 | } | ||
383 | if (paras != NULL) | ||
384 | { | ||
385 | delete [] paras; | ||
386 | paras = NULL; | ||
387 | } | ||
388 | noparas = 0; | ||
389 | nojoins = 0; | ||
390 | names.clear(); | ||
391 | |||
392 | UInt32 rspage = m_indexpages[cp]; | ||
393 | if (rspage != 0) | ||
394 | { | ||
395 | Page_detail rs = m_pagedetails[rspage]; | ||
396 | int count = 0; | ||
397 | RBPage* idx = new RBPage(); | ||
398 | idx->init(fin, m_blocksize, m_decompress); | ||
399 | idx->startpage(page2pos(rspage), rspage, ((rs.flags & 8) != 0), rs.len); | ||
400 | int c = 0; | ||
401 | int phase = 0; | ||
402 | int i; | ||
403 | if (m_binary) | ||
404 | { | ||
405 | count = idx->getuint(this); | ||
406 | qDebug("tag count:%d", count); | ||
407 | tags = new QString[count]; | ||
408 | for (int i = 0; i < count; ++i) | ||
409 | { | ||
410 | QString s; | ||
411 | while (1) | ||
412 | { | ||
413 | c = idx->getch(this); | ||
414 | if (c == 0 || c == EOF) break; | ||
415 | s += c; | ||
416 | } | ||
417 | unsigned short val = idx->getuint(this); | ||
418 | if (val != 0xffff) | ||
419 | { | ||
420 | tags[i] = tags[val]+s; | ||
421 | } | ||
422 | else | ||
423 | { | ||
424 | tags[i] = s; | ||
425 | } | ||
426 | //qDebug("tags[%d](%d) = %s", i, val, (const char*)tags[i]); | ||
427 | } | ||
428 | noparas = idx->getint(this); | ||
429 | qDebug("Para count %d", noparas); | ||
430 | paras = new ParaRef[noparas]; | ||
431 | for (int i = 0; i < noparas; ++i) | ||
432 | { | ||
433 | paras[i] = ParaRef(idx->getint(this), idx->getuint(this)); | ||
434 | } | ||
435 | count = idx->getint(this); | ||
436 | qDebug("Name count %d", count); | ||
437 | for (int i = 0; i < count; ++i) | ||
438 | { | ||
439 | QString s; | ||
440 | while (1) | ||
441 | { | ||
442 | c = idx->getch(this); | ||
443 | if (c == 0 || c == EOF) break; | ||
444 | s += c; | ||
445 | } | ||
446 | int val = idx->getint(this); | ||
447 | names[s.mid(1,s.length()-2)] = val; | ||
448 | qDebug("names[%s] = %d", (const char*)s, val); | ||
449 | } | ||
450 | count = idx->getint(this); | ||
451 | qDebug("Join count %d", count); | ||
452 | if (count > 0) | ||
453 | { | ||
454 | nojoins = count+2; | ||
455 | joins = new UInt32[count+2]; | ||
456 | joins[0] = 0; | ||
457 | joins[count+1] = currentpage.length(); | ||
458 | for (int i = 1; i < count+1; ++i) | ||
459 | { | ||
460 | joins[i] = idx->getint(this); | ||
461 | } | ||
462 | } | ||
463 | } | ||
464 | else | ||
465 | { | ||
466 | while (c != EOF) | ||
467 | { | ||
468 | QString s(""); | ||
469 | while (1) | ||
470 | { | ||
471 | c = idx->getch(this); | ||
472 | if (c == 10 || c == EOF) break; | ||
473 | s += c; | ||
474 | } | ||
475 | //qDebug("%s", (const char*)s); | ||
476 | if (count > 0) | ||
477 | { | ||
478 | --count; | ||
479 | int sp = s.findRev(' '); | ||
480 | QString l = s.left(sp); | ||
481 | int val = s.right(s.length()-sp).toInt(); | ||
482 | switch (phase) | ||
483 | { | ||
484 | case 4: | ||
485 | //qDebug("Join %d is at offset %d", i, val); | ||
486 | joins[i++] = val; | ||
487 | break; | ||
488 | case 3: | ||
489 | //qDebug("Name %s is at offset %d", (const char*)l.mid(1,l.length()-2), val+m_pagedetails[cp].pagestart); | ||
490 | names[l.mid(1,l.length()-2)] = val; | ||
491 | break; | ||
492 | case 1: | ||
493 | //qDebug("%s:%d [%d]", (const char*)l, val, i); | ||
494 | if (val >= 0) | ||
495 | { | ||
496 | tags[i++] = tags[val]+l; | ||
497 | } | ||
498 | else | ||
499 | { | ||
500 | tags[i++] = l; | ||
501 | } | ||
502 | //qDebug("TAG:%s", (const char*)tags[i-1]); | ||
503 | break; | ||
504 | case 2: | ||
505 | paras[i++] = ParaRef(QString(l).toInt(), val); | ||
506 | //qDebug("Para:%u - %u (%s)", QString(l).toInt(), val, (const char*)s); | ||
507 | break; | ||
508 | default: | ||
509 | qDebug("%s:%d", (const char*)l, val); | ||
510 | break; | ||
511 | } | ||
512 | } | ||
513 | else | ||
514 | { | ||
515 | QString key = "[tags "; | ||
516 | if (s.left(key.length()) == key) | ||
517 | { | ||
518 | phase = 1; | ||
519 | i = 0; | ||
520 | count = s.mid(key.length(),s.length()-key.length()-1).toInt(); | ||
521 | qDebug("%s:%s:%d", (const char*)key, (const char*)s, count); | ||
522 | tags = new QString[count]; | ||
523 | } | ||
524 | key = "[paragraphs "; | ||
525 | if (s.left(key.length()) == key) | ||
526 | { | ||
527 | phase = 2; | ||
528 | i = 0; | ||
529 | count = s.mid(key.length(),s.length()-key.length()-1).toInt(); | ||
530 | qDebug("%s:%s:%d", (const char*)key, (const char*)s, count); | ||
531 | paras = new ParaRef[count]; | ||
532 | noparas = count; | ||
533 | } | ||
534 | key = "[names "; | ||
535 | if (s.left(key.length()) == key) | ||
536 | { | ||
537 | phase = 3; | ||
538 | count = s.mid(key.length(),s.length()-key.length()-1).toInt(); | ||
539 | qDebug("%s:%s:%d", (const char*)key, (const char*)s, count); | ||
540 | } | ||
541 | key = "[joins "; | ||
542 | if (s.left(key.length()) == key) | ||
543 | { | ||
544 | phase = 4; | ||
545 | count = s.mid(key.length(),s.length()-key.length()-1).toInt(); | ||
546 | qDebug("%s:%s:%d", (const char*)key, (const char*)s, count); | ||
547 | nojoins = count+2; | ||
548 | i = 1; | ||
549 | joins = new UInt32[count+2]; | ||
550 | joins[0] = 0; | ||
551 | joins[count+1] = currentpage.length(); | ||
552 | qDebug("%s:%s:%d", (const char*)key, (const char*)s, count); | ||
553 | } | ||
554 | qDebug("ZC:%s", (const char*)s); | ||
555 | } | ||
556 | } | ||
557 | } | ||
558 | // for (int i = 0; i < nojoins; ++i) qDebug("JOINS:%u %u", i, joins[i]); | ||
559 | delete idx; | ||
560 | } | ||
561 | } | ||
562 | |||
563 | bool CReb::findanchor(const QString& _info) | ||
564 | { | ||
565 | QMap<QString, int>::Iterator iter = names.find(_info); | ||
566 | if (iter != names.end()) | ||
567 | { | ||
568 | locate(iter.data()+m_pagedetails[currentpage.pageno()].pagestart); | ||
569 | return true; | ||
570 | } | ||
571 | return false; | ||
572 | } | ||
573 | |||
574 | #ifdef USEQPE | ||
575 | void CReb::suspend() | ||
576 | { | ||
577 | CExpander::suspend(fin); | ||
578 | } | ||
579 | void CReb::unsuspend() | ||
580 | { | ||
581 | CExpander::unsuspend(fin); | ||
582 | } | ||
583 | #endif | ||
584 | |||
585 | #ifndef __STATIC | ||
586 | extern "C" | ||
587 | { | ||
588 | CExpander* newcodec() { return new CReb; } | ||
589 | } | ||
590 | #endif | ||
591 | |||
592 | void CReb::startpage(UInt32 pgno) | ||
593 | { | ||
594 | Page_detail rs = m_pagedetails[pgno]; | ||
595 | unsuspend(); | ||
596 | readindex(pgno); | ||
597 | currentpage.startpage(page2pos(pgno), pgno, ((rs.flags & 8) != 0), rs.len); | ||
598 | } | ||
599 | |||
600 | void CReb::startpage(UInt32 _cp, bool _isCompressed, UInt32 _len) | ||
601 | { | ||
602 | unsuspend(); | ||
603 | readindex(_cp); | ||
604 | currentpage.startpage(page2pos(_cp), _cp, _isCompressed, _len); | ||
605 | } | ||
606 | |||
607 | void RBPage::initpage(UInt32 pos, size_t _cp, bool _isCompressed, UInt32 _len) | ||
608 | { | ||
609 | filepos = pos; | ||
610 | m_pageno = _cp; | ||
611 | m_Compressed = _isCompressed; | ||
612 | m_pagelen = _len; | ||
613 | currentchunk = 0; | ||
614 | pageoffset = 0; | ||
615 | |||
616 | if (chunklist != NULL) delete [] chunklist; | ||
617 | |||
618 | fseek(fin, filepos, SEEK_SET); | ||
619 | if (m_Compressed) | ||
620 | { | ||
621 | fread(&nochunks, 1, sizeof(nochunks), fin); | ||
622 | fread(&m_pagelen, 1, sizeof(m_pagelen), fin); | ||
623 | chunklist = new UInt32[nochunks]; | ||
624 | fread(chunklist, nochunks, 4, fin); | ||
625 | } | ||
626 | else | ||
627 | { | ||
628 | chunklist = NULL; | ||
629 | nochunks = (_len+m_blocksize-1)/m_blocksize; | ||
630 | } | ||
631 | m_startoff = 0; | ||
632 | m_endoff = m_pagelen; | ||
633 | chunkpos = ftell(fin); | ||
634 | qDebug("Compressed:%u Expanded:%u", _len, m_pagelen); | ||
635 | } | ||
636 | |||
637 | void RBPage::startpage(UInt32 pos, UInt32 _cp, bool _isCompressed, UInt32 _len) | ||
638 | { | ||
639 | initpage(pos, _cp, _isCompressed, _len); | ||
640 | readchunk(); | ||
641 | } | ||
642 | |||
643 | int CReb::getch() | ||
644 | { | ||
645 | if (tagoffset < tagstring.length()) | ||
646 | return tagstring[tagoffset++].unicode(); | ||
647 | else | ||
648 | return currentpage.getch(this); | ||
649 | } | ||
650 | |||
651 | int RBPage::getch(CReb* parent) | ||
652 | { | ||
653 | if (chunkoffset >= chunklen) | ||
654 | { | ||
655 | if (++currentchunk >= nochunks) | ||
656 | { | ||
657 | --currentchunk; | ||
658 | return EOF; | ||
659 | } | ||
660 | pageoffset += chunklen; | ||
661 | parent->unsuspend(); | ||
662 | readchunk(); | ||
663 | } | ||
664 | if (offset() == m_endoff) return EOF; | ||
665 | return chunk[chunkoffset++]; | ||
666 | } | ||
667 | |||
668 | unsigned short int RBPage::getuint(CReb* parent) | ||
669 | { | ||
670 | unsigned short int ret = 0; | ||
671 | char *buffer = (char*)(&ret); | ||
672 | for (int i = 0; i < 2; ++i) | ||
673 | { | ||
674 | int ch = getch(parent); | ||
675 | if (ch == EOF) return 0; | ||
676 | buffer[i] = ch; | ||
677 | } | ||
678 | return ret; | ||
679 | } | ||
680 | |||
681 | int RBPage::getint(CReb* parent) | ||
682 | { | ||
683 | int ret = 0; | ||
684 | char *buffer = (char*)(&ret); | ||
685 | for (int i = 0; i < 4; ++i) | ||
686 | { | ||
687 | int ch = getch(parent); | ||
688 | if (ch == EOF) return 0; | ||
689 | buffer[i] = ch; | ||
690 | } | ||
691 | return ret; | ||
692 | } | ||
693 | |||
694 | void RBPage::readchunk() | ||
695 | { | ||
696 | if (m_Compressed) | ||
697 | { | ||
698 | chunkoffset = 0; | ||
699 | fseek(fin, chunkpos, SEEK_SET); | ||
700 | UInt8* inbuf = new UInt8[chunklist[currentchunk]]; | ||
701 | fread(inbuf, 1, chunklist[currentchunk], fin); | ||
702 | chunklen = (*m_decompress)(inbuf, chunklist[currentchunk], chunk, m_blocksize); | ||
703 | delete [] inbuf; | ||
704 | chunkpos = ftell(fin); | ||
705 | } | ||
706 | else | ||
707 | { | ||
708 | chunkoffset = 0; | ||
709 | chunklen = m_blocksize; | ||
710 | if (m_blocksize*(currentchunk+1) > m_pagelen) | ||
711 | { | ||
712 | chunklen = m_pagelen - currentchunk*m_blocksize; | ||
713 | } | ||
714 | fseek(fin, chunkpos, SEEK_SET); | ||
715 | chunklen = fread(chunk, 1, chunklen, fin); | ||
716 | chunkpos = ftell(fin); | ||
717 | } | ||
718 | } | ||
719 | |||
720 | void RBPage::setoffset(UInt32 pos, size_t _cp, bool _isCompressed, UInt32 _len, UInt32 _offset) | ||
721 | { | ||
722 | if (m_pageno != _cp) | ||
723 | { | ||
724 | initpage(pos, _cp, _isCompressed, _len); | ||
725 | } | ||
726 | else | ||
727 | { | ||
728 | if (m_Compressed) | ||
729 | { | ||
730 | chunkpos = filepos + sizeof(nochunks) + sizeof(m_pagelen) + 4*nochunks; | ||
731 | } | ||
732 | else | ||
733 | { | ||
734 | chunkpos = filepos; | ||
735 | } | ||
736 | } | ||
737 | |||
738 | currentchunk = _offset/m_blocksize; | ||
739 | pageoffset = m_blocksize*currentchunk; | ||
740 | if (m_Compressed) | ||
741 | { | ||
742 | for (int i = 0; i < currentchunk; ++i) | ||
743 | { | ||
744 | chunkpos += chunklist[i]; | ||
745 | } | ||
746 | } | ||
747 | else | ||
748 | { | ||
749 | chunkpos += pageoffset; | ||
750 | } | ||
751 | readchunk(); | ||
752 | chunkoffset = _offset - pageoffset; | ||
753 | } | ||
754 | |||
755 | void CReb::start2endSection() | ||
756 | { | ||
757 | if (m_pagedetails != NULL) | ||
758 | { | ||
759 | if (nojoins > 0) | ||
760 | { | ||
761 | //UInt32 jl = binarychop<UInt32>(joins, nojoins, currentpage.offset()); | ||
762 | |||
763 | UInt32 jl = 0,jh = nojoins-1,jm = (jl+jh)/2; | ||
764 | while (jh > jl+1) | ||
765 | { | ||
766 | if (joins[jm] > currentpage.offset()) | ||
767 | { | ||
768 | jh = jm; | ||
769 | } | ||
770 | else | ||
771 | { | ||
772 | jl = jm; | ||
773 | } | ||
774 | jm = (jl+jh)/2; | ||
775 | } | ||
776 | |||
777 | currentpage.m_startoff = joins[jl]; | ||
778 | currentpage.m_endoff = joins[jl+1]-1; | ||
779 | //currentpage.m_endoff = joins[jh]-1; | ||
780 | } | ||
781 | m_currentstart = m_pagedetails[currentpage.pageno()].pagestart+currentpage.m_startoff; | ||
782 | m_currentend = m_pagedetails[currentpage.pageno()].pagestart+currentpage.m_endoff; | ||
783 | } | ||
784 | else | ||
785 | { | ||
786 | m_currentstart = m_currentend = 0; | ||
787 | } | ||
788 | qDebug("s2e:[%u, %u, %u]", m_currentstart, locate(), m_currentend); | ||
789 | } | ||
diff --git a/noncore/apps/opie-reader/Reb.h b/noncore/apps/opie-reader/Reb.h new file mode 100644 index 0000000..f268eb0 --- a/dev/null +++ b/noncore/apps/opie-reader/Reb.h | |||
@@ -0,0 +1,157 @@ | |||
1 | #ifndef __REB_H | ||
2 | #define __REB_H | ||
3 | #include <stdio.h> | ||
4 | #include <zlib.h> | ||
5 | #include <sys/stat.h> | ||
6 | #ifdef USEQPE | ||
7 | #include <qpe/global.h> | ||
8 | #endif | ||
9 | #include <qmap.h> | ||
10 | |||
11 | #include "CExpander.h" | ||
12 | #include <zlib.h> | ||
13 | |||
14 | #ifdef _WINDOWS | ||
15 | #include <winsock.h> | ||
16 | #endif | ||
17 | |||
18 | #include "mytypes.h" | ||
19 | |||
20 | /* | ||
21 | struct Reb_Segment | ||
22 | { | ||
23 | UInt32 len, page, flags; | ||
24 | Reb_Segment(UInt32 _len = 0, UInt32 _page = 0, UInt32 _flags = 0) | ||
25 | : | ||
26 | len(_len), page(_page), flags(_flags) | ||
27 | {} | ||
28 | }; | ||
29 | */ | ||
30 | |||
31 | class CReb; | ||
32 | |||
33 | class RBPage | ||
34 | { | ||
35 | UInt32 filepos; | ||
36 | UInt32 pageoffset; | ||
37 | UInt32 nochunks, currentchunk, chunkpos, chunklen, chunkoffset; | ||
38 | UInt32 m_pagelen, m_blocksize; | ||
39 | bool m_Compressed; | ||
40 | void readchunk(); | ||
41 | UInt32* chunklist; | ||
42 | UInt8* chunk; | ||
43 | FILE* fin; | ||
44 | UInt32 m_pageno; | ||
45 | void initpage(UInt32 pos, size_t _cp, bool _isCompressed, UInt32 _len); | ||
46 | size_t (*m_decompress)(UInt8*, size_t, UInt8*, size_t); | ||
47 | public: | ||
48 | RBPage() : pageoffset(0), nochunks(0), currentchunk(0), chunkpos(0), chunkoffset(0), m_pagelen(0), m_Compressed(false), chunklist(NULL), chunk(NULL) {} | ||
49 | ~RBPage() | ||
50 | { | ||
51 | if (chunk != NULL) delete [] chunk; | ||
52 | if (chunklist != NULL) delete [] chunklist; | ||
53 | } | ||
54 | int getch(CReb*); | ||
55 | unsigned short int getuint(CReb*); | ||
56 | int getint(CReb*); | ||
57 | void startpage(UInt32, UInt32, bool, UInt32); | ||
58 | UInt32 pageno() { return m_pageno; } | ||
59 | UInt32 offset() { return pageoffset+chunkoffset; } | ||
60 | void setoffset(UInt32, size_t, bool, UInt32, UInt32); | ||
61 | void init(FILE* _f, UInt32 _bs, size_t (*_decompress)(UInt8*, size_t, UInt8*, size_t)) | ||
62 | { | ||
63 | fin = _f; | ||
64 | m_blocksize = _bs; | ||
65 | chunk = new UInt8[m_blocksize]; | ||
66 | m_decompress = _decompress; | ||
67 | } | ||
68 | UInt32 length() { return m_pagelen; } | ||
69 | UInt32 m_startoff, m_endoff; | ||
70 | }; | ||
71 | |||
72 | struct Page_detail | ||
73 | { | ||
74 | UInt32 pagestart, len, flags; | ||
75 | Page_detail(UInt32 _ps = 0, UInt32 _l = 0, UInt32 _f = 0) | ||
76 | : | ||
77 | pagestart(_ps), len(_l), flags(_f) | ||
78 | { | ||
79 | } | ||
80 | }; | ||
81 | |||
82 | struct ParaRef | ||
83 | { | ||
84 | int pos, tag; | ||
85 | ParaRef(int _pos = 0, int _tag = 0) : pos(_pos), tag(_tag) | ||
86 | { | ||
87 | //qDebug("New PARAREF:%d, %d", pos, tag); | ||
88 | } | ||
89 | }; | ||
90 | |||
91 | class CReb : public CExpander | ||
92 | { | ||
93 | //friend class RBPage; | ||
94 | size_t (*m_decompress)(UInt8*, size_t, UInt8*, size_t); | ||
95 | RBPage currentpage; | ||
96 | UInt32 nopages, m_homepage, m_blocksize; | ||
97 | |||
98 | QMap<QString, UInt32> m_index; | ||
99 | |||
100 | size_t file_length, text_length; | ||
101 | UInt32 toc; | ||
102 | FILE* fin; | ||
103 | void home(); | ||
104 | void startpage(UInt32); | ||
105 | void startpage(UInt32, bool, UInt32); | ||
106 | void readchunk(); | ||
107 | QString tagstring; | ||
108 | UInt32 tagoffset; | ||
109 | UInt32 pagelength(UInt32); | ||
110 | QImage* getPicture(const QString& ref); | ||
111 | UInt32 page2pos(UInt32); | ||
112 | //UInt32 m_pagelen; | ||
113 | UInt32* m_indexpages; | ||
114 | Page_detail* m_pagedetails; | ||
115 | // void UnZip(size_t bsize); | ||
116 | QMap<QString, int> names; | ||
117 | QString* tags; | ||
118 | ParaRef* paras; | ||
119 | UInt32* joins; | ||
120 | UInt32 nojoins; | ||
121 | UInt32 noparas; | ||
122 | bool m_binary; | ||
123 | void readindex(UInt32); | ||
124 | public: | ||
125 | bool findanchor(const QString& _info); | ||
126 | QString about() { return QString("REB codec (c) Tim Wentford"); } | ||
127 | bool getFile(const QString& href, const QString& nm); | ||
128 | void start2endSection(); | ||
129 | void sizes(unsigned long& _file, unsigned long& _text) | ||
130 | { | ||
131 | _file = file_length; | ||
132 | _text = text_length; | ||
133 | } | ||
134 | bool hasrandomaccess() { return true; } | ||
135 | virtual ~CReb(); | ||
136 | CReb(); | ||
137 | int OpenFile(const char *src); | ||
138 | int getch(); | ||
139 | unsigned int locate(); | ||
140 | void locate(unsigned int n); | ||
141 | CList<Bkmk>* getbkmklist(); | ||
142 | MarkupType PreferredMarkup() | ||
143 | { | ||
144 | return cCHM; | ||
145 | } | ||
146 | #ifdef USEQPE | ||
147 | void suspend(); | ||
148 | void unsuspend(); | ||
149 | #else | ||
150 | void suspend() {} | ||
151 | void unsuspend() {} | ||
152 | #endif | ||
153 | }; | ||
154 | |||
155 | #endif | ||
156 | |||
157 | |||
diff --git a/noncore/apps/opie-reader/RebCodec/.cvsignore b/noncore/apps/opie-reader/RebCodec/.cvsignore new file mode 100644 index 0000000..1810ee0 --- a/dev/null +++ b/noncore/apps/opie-reader/RebCodec/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile | ||
2 | config.in | ||
3 | moc_* | ||
4 | .moc | ||
5 | .obj | ||
diff --git a/noncore/apps/opie-reader/RebCodec/RebCodec.pro b/noncore/apps/opie-reader/RebCodec/RebCodec.pro new file mode 100644 index 0000000..2d6410a --- a/dev/null +++ b/noncore/apps/opie-reader/RebCodec/RebCodec.pro | |||
@@ -0,0 +1,21 @@ | |||
1 | DEFINES += OPIE USEQPE | ||
2 | VPATH = .. | ||
3 | TEMPLATE= lib | ||
4 | CONFIG = qt warn_on release dll | ||
5 | HEADERS = Reb.h | ||
6 | |||
7 | SOURCES = Reb.cpp \ | ||
8 | decompress.cpp | ||
9 | |||
10 | |||
11 | INTERFACES= | ||
12 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | ||
13 | TARGET = Reb | ||
14 | LIBS += -L$(OPIEDIR)/lib -lreader_codec | ||
15 | |||
16 | |||
17 | INCLUDEPATH+= $(OPIEDIR)/include | ||
18 | DEPENDPATH += $(OPIEDIR)/include | ||
19 | |||
20 | include( $(OPIEDIR)/include.pro ) | ||
21 | |||
diff --git a/noncore/apps/opie-reader/StyleConsts.h b/noncore/apps/opie-reader/StyleConsts.h index 8e23c6f..4b7ff4b 100644 --- a/noncore/apps/opie-reader/StyleConsts.h +++ b/noncore/apps/opie-reader/StyleConsts.h | |||
@@ -1,222 +1,232 @@ | |||
1 | #ifndef __STYLECONSTS_H | 1 | #ifndef __STYLECONSTS_H |
2 | #define __STYLECONSTS_H | 2 | #define __STYLECONSTS_H |
3 | 3 | ||
4 | typedef unsigned short StyleType; | 4 | typedef unsigned short StyleType; |
5 | 5 | ||
6 | #ifdef _WINDOWS | 6 | #ifdef _WINDOWS |
7 | #include <string.h> | 7 | #include <string.h> |
8 | #endif | 8 | #endif |
9 | #include <string.h> | 9 | #include <string.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <qglobal.h> | 11 | #include <qglobal.h> |
12 | class QImage; | 12 | class QImage; |
13 | 13 | ||
14 | struct GraphicLink | 14 | struct GraphicLink |
15 | { | 15 | { |
16 | QImage* graphic; | 16 | QImage* graphic; |
17 | bool isLink; | 17 | bool isLink; |
18 | unsigned long link; | 18 | unsigned long link; |
19 | GraphicLink(QImage* p, bool isLnk, unsigned long tgt) : | 19 | GraphicLink(QImage* p, bool isLnk, unsigned long tgt) : |
20 | graphic(p), isLink(isLnk), link(tgt) {} | 20 | graphic(p), isLink(isLnk), link(tgt) {} |
21 | ~GraphicLink(); | 21 | ~GraphicLink(); |
22 | }; | 22 | }; |
23 | 23 | ||
24 | struct pmstore | 24 | struct pmstore |
25 | { | 25 | { |
26 | unsigned int count; | 26 | unsigned int count; |
27 | bool m_isScaleable; | 27 | bool m_isScaleable; |
28 | GraphicLink* graphic; | 28 | GraphicLink* graphic; |
29 | pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale) | 29 | pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale) |
30 | { | 30 | { |
31 | graphic = new GraphicLink(p, isLnk, tgt); | 31 | graphic = new GraphicLink(p, isLnk, tgt); |
32 | } | 32 | } |
33 | ~pmstore(); | 33 | ~pmstore(); |
34 | }; | 34 | }; |
35 | 35 | ||
36 | enum EalignmentType | 36 | enum EalignmentType |
37 | { | 37 | { |
38 | m_AlignLeft, | 38 | m_AlignLeft, |
39 | m_AlignRight, | 39 | m_AlignRight, |
40 | m_AlignCentre, | 40 | m_AlignCentre, |
41 | m_AlignJustify | 41 | m_AlignJustify, |
42 | m_AlignNone | ||
42 | }; | 43 | }; |
43 | 44 | ||
44 | class CBasicStyle | 45 | class CBasicStyle |
45 | { | 46 | { |
46 | friend class CStyle; | 47 | friend class CStyle; |
47 | bool m_bold, | 48 | bool m_bold, |
48 | m_italic; | 49 | m_italic; |
50 | unsigned long m_table; | ||
49 | int m_fontsize; | 51 | int m_fontsize; |
50 | EalignmentType m_align; | 52 | EalignmentType m_align; |
51 | unsigned char red, green, blue; | 53 | unsigned char red, green, blue; |
52 | unsigned char bred, bgreen, bblue; | 54 | unsigned char bred, bgreen, bblue; |
53 | unsigned char pred, pgreen, pblue; | 55 | unsigned char pred, pgreen, pblue; |
54 | unsigned long data; | 56 | unsigned long data; |
55 | unsigned long offset; | 57 | unsigned long offset; |
56 | bool isLink; | 58 | bool isLink; |
57 | // bool isVisited; | 59 | // bool isVisited; |
58 | bool m_underline; | 60 | bool m_underline; |
59 | bool m_strikethru; | 61 | bool m_strikethru; |
60 | bool m_monospaced; | 62 | bool m_monospaced; |
61 | unsigned char m_leftmargin, m_rightmargin; | 63 | unsigned char m_leftmargin, m_rightmargin; |
62 | signed char m_extraspace; | 64 | signed char m_extraspace; |
63 | signed char m_voffset; | 65 | signed char m_voffset; |
64 | CBasicStyle() | 66 | CBasicStyle() |
65 | { | 67 | { |
66 | unset(); | 68 | unset(); |
69 | m_table = 0xffffffff; | ||
67 | } | 70 | } |
68 | bool operator!=(const CBasicStyle& rhs) | 71 | bool operator!=(const CBasicStyle& rhs) |
69 | { | 72 | { |
70 | return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0); | 73 | return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0); |
71 | } | 74 | } |
72 | void unset() | 75 | void unset() |
73 | { | 76 | { |
74 | m_bold = false; | 77 | m_bold = false; |
75 | m_italic = false; | 78 | m_italic = false; |
76 | m_fontsize = 0; | 79 | m_fontsize = 0; |
77 | m_align = m_AlignLeft; | 80 | m_align = m_AlignLeft; |
78 | red = green = blue = 0; | 81 | red = green = blue = 0; |
79 | bred = bgreen = bblue = 255; | 82 | bred = bgreen = bblue = 255; |
80 | pred = pgreen = pblue = 255; | 83 | pred = pgreen = pblue = 255; |
81 | data = 0; | 84 | data = 0; |
82 | offset = 0; | 85 | offset = 0; |
83 | isLink = false; | 86 | isLink = false; |
84 | // isVisited = false; | 87 | // isVisited = false; |
85 | m_underline = false; | 88 | m_underline = false; |
86 | m_strikethru = false; | 89 | m_strikethru = false; |
87 | m_leftmargin = 0; | 90 | m_leftmargin = 0; |
88 | m_rightmargin = 0; | 91 | m_rightmargin = 0; |
89 | m_monospaced = false; | 92 | m_monospaced = false; |
90 | m_extraspace = 0; | 93 | m_extraspace = 0; |
91 | m_voffset = 0; | 94 | m_voffset = 0; |
92 | } | 95 | } |
93 | }; | 96 | }; |
94 | 97 | ||
95 | class CStyle | 98 | class CStyle |
96 | { | 99 | { |
97 | CBasicStyle sty; | 100 | CBasicStyle sty; |
98 | pmstore* graphic; | 101 | pmstore* graphic; |
99 | public: | 102 | public: |
100 | signed char getVOffset() { return sty.m_voffset; } | 103 | signed char getVOffset() { return sty.m_voffset; } |
101 | void setVOffset(signed char sp) { sty.m_voffset = sp; } | 104 | void setVOffset(signed char sp) { sty.m_voffset = sp; } |
102 | signed char getExtraSpace() { return sty.m_extraspace; } | 105 | signed char getExtraSpace() { return sty.m_extraspace; } |
103 | void setExtraSpace(signed char sp) { sty.m_extraspace = sp; } | 106 | void setExtraSpace(signed char sp) { sty.m_extraspace = sp; } |
104 | bool getPictureLink() | 107 | bool getPictureLink() |
105 | { | 108 | { |
106 | return (graphic != NULL && graphic->graphic->isLink); | 109 | return (graphic != NULL && graphic->graphic->isLink); |
107 | } | 110 | } |
108 | unsigned long getPictureLinkData() | 111 | unsigned long getPictureLinkData() |
109 | { | 112 | { |
110 | return graphic->graphic->link; | 113 | return graphic->graphic->link; |
111 | } | 114 | } |
112 | void setLeftMargin(unsigned char m) { sty.m_leftmargin = m; } | 115 | void setLeftMargin(unsigned char m) { sty.m_leftmargin = m; } |
113 | unsigned char getLeftMargin() { return sty.m_leftmargin; } | 116 | unsigned char getLeftMargin() { return sty.m_leftmargin; } |
114 | void setRightMargin(unsigned char m) { sty.m_rightmargin = m; } | 117 | void setRightMargin(unsigned char m) { sty.m_rightmargin = m; } |
115 | unsigned char getRightMargin() { return sty.m_rightmargin; } | 118 | unsigned char getRightMargin() { return sty.m_rightmargin; } |
116 | unsigned char Red() { return sty.red; } | 119 | unsigned char Red() { return sty.red; } |
117 | unsigned char Green() { return sty.green; } | 120 | unsigned char Green() { return sty.green; } |
118 | unsigned char Blue() { return sty.blue; } | 121 | unsigned char Blue() { return sty.blue; } |
119 | void setColour(unsigned char r, unsigned char g, unsigned char b) | 122 | void setColour(unsigned char r, unsigned char g, unsigned char b) |
120 | { | 123 | { |
121 | sty.red = r; | 124 | sty.red = r; |
122 | sty.green = g; | 125 | sty.green = g; |
123 | sty.blue = b; | 126 | sty.blue = b; |
124 | } | 127 | } |
125 | unsigned char bRed() { return sty.bred; } | 128 | unsigned char bRed() { return sty.bred; } |
126 | unsigned char bGreen() { return sty.bgreen; } | 129 | unsigned char bGreen() { return sty.bgreen; } |
127 | unsigned char bBlue() { return sty.bblue; } | 130 | unsigned char bBlue() { return sty.bblue; } |
128 | unsigned char pRed() { return sty.pred; } | 131 | unsigned char pRed() { return sty.pred; } |
129 | unsigned char pGreen() { return sty.pgreen; } | 132 | unsigned char pGreen() { return sty.pgreen; } |
130 | unsigned char pBlue() { return sty.pblue; } | 133 | unsigned char pBlue() { return sty.pblue; } |
131 | void setPaper(unsigned char r, unsigned char g, unsigned char b) | 134 | void setPaper(unsigned char r, unsigned char g, unsigned char b) |
132 | { | 135 | { |
133 | sty.pred = r; | 136 | sty.pred = r; |
134 | sty.pgreen = g; | 137 | sty.pgreen = g; |
135 | sty.pblue = b; | 138 | sty.pblue = b; |
136 | } | 139 | } |
137 | void setBackground(unsigned char r, unsigned char g, unsigned char b) | 140 | void setBackground(unsigned char r, unsigned char g, unsigned char b) |
138 | { | 141 | { |
139 | sty.bred = r; | 142 | sty.bred = r; |
140 | sty.bgreen = g; | 143 | sty.bgreen = g; |
141 | sty.bblue = b; | 144 | sty.bblue = b; |
142 | } | 145 | } |
143 | CStyle() : graphic(NULL) {} | 146 | CStyle() : graphic(NULL) {} |
144 | ~CStyle(); | 147 | ~CStyle(); |
145 | // CStyle(CStyle&); | 148 | // CStyle(CStyle&); |
146 | CStyle(const CStyle&); | 149 | CStyle(const CStyle&); |
147 | CStyle& operator=(const CStyle&); | 150 | CStyle& operator=(const CStyle&); |
148 | void unset(); | 151 | void unset(); |
152 | bool isTable() const { return (sty.m_table != 0xffffffff); } | ||
153 | void setTable(unsigned long _b) { sty.m_table = _b; } | ||
154 | unsigned long getTable() { return sty.m_table; } | ||
149 | bool isPicture() const { return (graphic != NULL); } | 155 | bool isPicture() const { return (graphic != NULL); } |
150 | bool canScale() const { return graphic->m_isScaleable; } | 156 | bool canScale() const { return graphic->m_isScaleable; } |
151 | void clearPicture(); | 157 | void clearPicture(); |
152 | void setPicture(bool canScale, QImage* _g, bool il=false, unsigned long tgt=0); | 158 | void setPicture(bool canScale, QImage* _g, bool il=false, unsigned long tgt=0); |
153 | QImage* getPicture() | 159 | QImage* getPicture() |
154 | { | 160 | { |
155 | QImage* pm = ((graphic != NULL) ? graphic->graphic->graphic : NULL); | 161 | QImage* pm = ((graphic != NULL) ? graphic->graphic->graphic : NULL); |
156 | return pm; | 162 | return pm; |
157 | } | 163 | } |
158 | void setUnderline() { sty.m_underline = true; } | 164 | void setUnderline() { sty.m_underline = true; } |
159 | void unsetUnderline() { sty.m_underline = false; } | 165 | void unsetUnderline() { sty.m_underline = false; } |
160 | bool isUnderline() { return sty.m_underline; } | 166 | bool isUnderline() { return sty.m_underline; } |
161 | void setStrikethru() { sty.m_strikethru = true; } | 167 | void setStrikethru() { sty.m_strikethru = true; } |
162 | void unsetStrikethru() { sty.m_strikethru = false; } | 168 | void unsetStrikethru() { sty.m_strikethru = false; } |
163 | bool isStrikethru() { return sty.m_strikethru; } | 169 | bool isStrikethru() { return sty.m_strikethru; } |
164 | void setBold() { sty.m_bold = true; } | 170 | void setBold() { sty.m_bold = true; } |
165 | void unsetBold() { sty.m_bold = false; } | 171 | void unsetBold() { sty.m_bold = false; } |
166 | bool isBold() { return sty.m_bold; } | 172 | bool isBold() { return sty.m_bold; } |
167 | void setItalic() { sty.m_italic = true; } | 173 | void setItalic() { sty.m_italic = true; } |
168 | void unsetItalic() { sty.m_italic = false; } | 174 | void unsetItalic() { sty.m_italic = false; } |
169 | bool isItalic() { return sty.m_italic; } | 175 | bool isItalic() { return sty.m_italic; } |
170 | void setMono() { sty.m_monospaced = true; } | 176 | void setMono() { sty.m_monospaced = true; } |
171 | void unsetMono() { sty.m_monospaced = false; } | 177 | void unsetMono() { sty.m_monospaced = false; } |
172 | bool isMono() { return sty.m_monospaced; } | 178 | bool isMono() { return sty.m_monospaced; } |
173 | 179 | ||
174 | void setLeftJustify() | 180 | void setLeftJustify() |
175 | { | 181 | { |
176 | sty.m_align = m_AlignLeft; | 182 | sty.m_align = m_AlignLeft; |
177 | } | 183 | } |
178 | void setRightJustify() | 184 | void setRightJustify() |
179 | { | 185 | { |
180 | sty.m_align = m_AlignRight; | 186 | sty.m_align = m_AlignRight; |
181 | } | 187 | } |
182 | void setCentreJustify() | 188 | void setCentreJustify() |
183 | { | 189 | { |
184 | sty.m_align = m_AlignCentre; | 190 | sty.m_align = m_AlignCentre; |
185 | } | 191 | } |
186 | void setFullJustify() | 192 | void setFullJustify() |
187 | { | 193 | { |
188 | sty.m_align = m_AlignJustify; | 194 | sty.m_align = m_AlignJustify; |
189 | } | 195 | } |
196 | void setNoJustify() | ||
197 | { | ||
198 | sty.m_align = m_AlignNone; | ||
199 | } | ||
190 | StyleType getJustify() | 200 | StyleType getJustify() |
191 | { | 201 | { |
192 | return sty.m_align; | 202 | return sty.m_align; |
193 | } | 203 | } |
194 | 204 | ||
195 | void setFontSize(int _fs) | 205 | void setFontSize(int _fs) |
196 | { | 206 | { |
197 | sty.m_fontsize = _fs; | 207 | sty.m_fontsize = _fs; |
198 | } | 208 | } |
199 | int getFontSize() const | 209 | int getFontSize() const |
200 | { | 210 | { |
201 | return sty.m_fontsize; | 211 | return sty.m_fontsize; |
202 | } | 212 | } |
203 | bool operator!=(const CStyle& rhs) | 213 | bool operator!=(const CStyle& rhs) |
204 | { | 214 | { |
205 | return | 215 | return |
206 | ( | 216 | ( |
207 | (sty != rhs.sty) || | 217 | (sty != rhs.sty) || |
208 | (graphic != rhs.graphic) | 218 | (graphic != rhs.graphic) |
209 | ); | 219 | ); |
210 | } | 220 | } |
211 | void setLink(bool _l) { sty.isLink = _l; } | 221 | void setLink(bool _l) { sty.isLink = _l; } |
212 | bool getLink() { return sty.isLink; } | 222 | bool getLink() { return sty.isLink; } |
213 | // void setVisited(bool _l) { sty.isVisited = _l; } | 223 | // void setVisited(bool _l) { sty.isVisited = _l; } |
214 | // bool getVisited() { return sty.isVisited; } | 224 | // bool getVisited() { return sty.isVisited; } |
215 | void setData(unsigned long _d) { sty.data = _d; } | 225 | void setData(unsigned long _d) { sty.data = _d; } |
216 | unsigned long getData() { return sty.data; } | 226 | unsigned long getData() { return sty.data; } |
217 | void setOffset(unsigned long _d) { sty.offset = _d; } | 227 | void setOffset(unsigned long _d) { sty.offset = _d; } |
218 | unsigned long getOffset() { return sty.offset; } | 228 | unsigned long getOffset() { return sty.offset; } |
219 | void invert(); | 229 | void invert(); |
220 | }; | 230 | }; |
221 | 231 | ||
222 | #endif | 232 | #endif |
diff --git a/noncore/apps/opie-reader/SubAlloc.h b/noncore/apps/opie-reader/SubAlloc.h new file mode 100644 index 0000000..ded2b73 --- a/dev/null +++ b/noncore/apps/opie-reader/SubAlloc.h | |||
@@ -0,0 +1,201 @@ | |||
1 | /**************************************************************************** | ||
2 | * This file is part of PPMd project * | ||
3 | * Written and distributed to public domain by Dmitry Shkarin 1997, * | ||
4 | * 1999-2001 * | ||
5 | * Contents: memory allocation routines * | ||
6 | ****************************************************************************/ | ||
7 | |||
8 | enum { UNIT_SIZE=12, N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4, | ||
9 | N_INDEXES=N1+N2+N3+N4 }; | ||
10 | |||
11 | #pragma pack(1) | ||
12 | struct BLK_NODE { | ||
13 | DWORD Stamp; | ||
14 | BLK_NODE* next; | ||
15 | BOOL avail() const { return (next != NULL); } | ||
16 | void link(BLK_NODE* p) { p->next=next; next=p; } | ||
17 | void unlink() { next=next->next; } | ||
18 | void* remove() { | ||
19 | BLK_NODE* p=next; unlink(); | ||
20 | Stamp--; return p; | ||
21 | } | ||
22 | inline void insert(void* pv,int NU); | ||
23 | } BList[N_INDEXES]; | ||
24 | struct MEM_BLK: public BLK_NODE { DWORD NU; } _PACK_ATTR; | ||
25 | #pragma pack() | ||
26 | |||
27 | static BYTE Indx2Units[N_INDEXES], Units2Indx[128]; // constants | ||
28 | static DWORD GlueCount, SubAllocatorSize=0; | ||
29 | static BYTE* HeapStart, * pText, * UnitsStart, * LoUnit, * HiUnit; | ||
30 | |||
31 | inline void PrefetchData(void* Addr) | ||
32 | { | ||
33 | #if defined(_USE_PREFETCHING) | ||
34 | BYTE PrefetchByte = *(volatile BYTE*) Addr; | ||
35 | #endif /* defined(_USE_PREFETCHING) */ | ||
36 | } | ||
37 | inline void BLK_NODE::insert(void* pv,int NU) { | ||
38 | MEM_BLK* p=(MEM_BLK*) pv; link(p); | ||
39 | p->Stamp=~0UL; p->NU=NU; | ||
40 | Stamp++; | ||
41 | } | ||
42 | inline UINT U2B(UINT NU) { return 8*NU+4*NU; } | ||
43 | inline void SplitBlock(void* pv,UINT OldIndx,UINT NewIndx) | ||
44 | { | ||
45 | UINT i, k, UDiff=Indx2Units[OldIndx]-Indx2Units[NewIndx]; | ||
46 | BYTE* p=((BYTE*) pv)+U2B(Indx2Units[NewIndx]); | ||
47 | if (Indx2Units[i=Units2Indx[UDiff-1]] != UDiff) { | ||
48 | k=Indx2Units[--i]; BList[i].insert(p,k); | ||
49 | p += U2B(k); UDiff -= k; | ||
50 | } | ||
51 | BList[Units2Indx[UDiff-1]].insert(p,UDiff); | ||
52 | } | ||
53 | DWORD _STDCALL GetUsedMemory() | ||
54 | { | ||
55 | DWORD i, RetVal=SubAllocatorSize-(HiUnit-LoUnit)-(UnitsStart-pText); | ||
56 | for (i=0;i < N_INDEXES;i++) | ||
57 | RetVal -= UNIT_SIZE*Indx2Units[i]*BList[i].Stamp; | ||
58 | return RetVal; | ||
59 | } | ||
60 | void _STDCALL StopSubAllocator() { | ||
61 | if ( SubAllocatorSize ) { | ||
62 | SubAllocatorSize=0; delete[] HeapStart; | ||
63 | } | ||
64 | } | ||
65 | BOOL _STDCALL StartSubAllocator(UINT SASize) | ||
66 | { | ||
67 | DWORD t=SASize << 19U; | ||
68 | if (SubAllocatorSize == t) return TRUE; | ||
69 | StopSubAllocator(); | ||
70 | if ((HeapStart=new BYTE[t]) == NULL) return FALSE; | ||
71 | SubAllocatorSize=t; return TRUE; | ||
72 | } | ||
73 | static inline void InitSubAllocator() | ||
74 | { | ||
75 | memset(BList,0,sizeof(BList)); | ||
76 | HiUnit=(pText=HeapStart)+SubAllocatorSize; | ||
77 | UINT Diff=UNIT_SIZE*(SubAllocatorSize/8/UNIT_SIZE*7); | ||
78 | LoUnit=UnitsStart=HiUnit-Diff; GlueCount=0; | ||
79 | } | ||
80 | static void GlueFreeBlocks() | ||
81 | { | ||
82 | UINT i, k, sz; | ||
83 | MEM_BLK s0, * p, * p0, * p1; | ||
84 | if (LoUnit != HiUnit) *LoUnit=0; | ||
85 | for (i=0, (p0=&s0)->next=NULL;i < N_INDEXES;i++) | ||
86 | while ( BList[i].avail() ) { | ||
87 | p=(MEM_BLK*) BList[i].remove(); | ||
88 | if ( !p->NU ) continue; | ||
89 | while ((p1=p+p->NU)->Stamp == ~0UL) { | ||
90 | p->NU += p1->NU; p1->NU=0; | ||
91 | } | ||
92 | p0->link(p); p0=p; | ||
93 | } | ||
94 | while ( s0.avail() ) { | ||
95 | p=(MEM_BLK*) s0.remove(); sz=p->NU; | ||
96 | if ( !sz ) continue; | ||
97 | for ( ;sz > 128;sz -= 128, p += 128) | ||
98 | BList[N_INDEXES-1].insert(p,128); | ||
99 | if (Indx2Units[i=Units2Indx[sz-1]] != sz) { | ||
100 | k=sz-Indx2Units[--i]; BList[k-1].insert(p+(sz-k),k); | ||
101 | } | ||
102 | BList[i].insert(p,Indx2Units[i]); | ||
103 | } | ||
104 | GlueCount=1 << 13; | ||
105 | } | ||
106 | static void* _STDCALL AllocUnitsRare(UINT indx) | ||
107 | { | ||
108 | UINT i=indx; | ||
109 | if ( !GlueCount ) { | ||
110 | GlueFreeBlocks(); | ||
111 | if ( BList[i].avail() ) return BList[i].remove(); | ||
112 | } | ||
113 | do { | ||
114 | if (++i == N_INDEXES) { | ||
115 | GlueCount--; i=U2B(Indx2Units[indx]); | ||
116 | return (UnitsStart-pText > i)?(UnitsStart -= i):(NULL); | ||
117 | } | ||
118 | } while ( !BList[i].avail() ); | ||
119 | void* RetVal=BList[i].remove(); SplitBlock(RetVal,i,indx); | ||
120 | return RetVal; | ||
121 | } | ||
122 | inline void* AllocUnits(UINT NU) | ||
123 | { | ||
124 | UINT indx=Units2Indx[NU-1]; | ||
125 | if ( BList[indx].avail() ) return BList[indx].remove(); | ||
126 | void* RetVal=LoUnit; LoUnit += U2B(Indx2Units[indx]); | ||
127 | if (LoUnit <= HiUnit) return RetVal; | ||
128 | LoUnit -= U2B(Indx2Units[indx]); return AllocUnitsRare(indx); | ||
129 | } | ||
130 | inline void* AllocContext() | ||
131 | { | ||
132 | if (HiUnit != LoUnit) return (HiUnit -= UNIT_SIZE); | ||
133 | else if ( BList->avail() ) return BList->remove(); | ||
134 | else return AllocUnitsRare(0); | ||
135 | } | ||
136 | inline void UnitsCpy(void* Dest,void* Src,UINT NU) | ||
137 | { | ||
138 | DWORD* p1=(DWORD*) Dest, * p2=(DWORD*) Src; | ||
139 | do { | ||
140 | p1[0]=p2[0]; p1[1]=p2[1]; | ||
141 | p1[2]=p2[2]; | ||
142 | p1 += 3; p2 += 3; | ||
143 | } while ( --NU ); | ||
144 | } | ||
145 | inline void* ExpandUnits(void* OldPtr,UINT OldNU) | ||
146 | { | ||
147 | UINT i0=Units2Indx[OldNU-1], i1=Units2Indx[OldNU-1+1]; | ||
148 | if (i0 == i1) return OldPtr; | ||
149 | void* ptr=AllocUnits(OldNU+1); | ||
150 | if ( ptr ) { | ||
151 | UnitsCpy(ptr,OldPtr,OldNU); BList[i0].insert(OldPtr,OldNU); | ||
152 | } | ||
153 | return ptr; | ||
154 | } | ||
155 | inline void* ShrinkUnits(void* OldPtr,UINT OldNU,UINT NewNU) | ||
156 | { | ||
157 | UINT i0=Units2Indx[OldNU-1], i1=Units2Indx[NewNU-1]; | ||
158 | if (i0 == i1) return OldPtr; | ||
159 | if ( BList[i1].avail() ) { | ||
160 | void* ptr=BList[i1].remove(); UnitsCpy(ptr,OldPtr,NewNU); | ||
161 | BList[i0].insert(OldPtr,Indx2Units[i0]); | ||
162 | return ptr; | ||
163 | } else { | ||
164 | SplitBlock(OldPtr,i0,i1); return OldPtr; | ||
165 | } | ||
166 | } | ||
167 | inline void FreeUnits(void* ptr,UINT NU) { | ||
168 | UINT indx=Units2Indx[NU-1]; | ||
169 | BList[indx].insert(ptr,Indx2Units[indx]); | ||
170 | } | ||
171 | inline void SpecialFreeUnit(void* ptr) | ||
172 | { | ||
173 | if ((BYTE*) ptr != UnitsStart) BList->insert(ptr,1); | ||
174 | else { *(DWORD*) ptr=~0UL; UnitsStart += UNIT_SIZE; } | ||
175 | } | ||
176 | inline void* MoveUnitsUp(void* OldPtr,UINT NU) | ||
177 | { | ||
178 | UINT indx=Units2Indx[NU-1]; | ||
179 | if ((BYTE*) OldPtr > UnitsStart+16*1024 || (BLK_NODE*) OldPtr > BList[indx].next) | ||
180 | return OldPtr; | ||
181 | void* ptr=BList[indx].remove(); | ||
182 | UnitsCpy(ptr,OldPtr,NU); NU=Indx2Units[indx]; | ||
183 | if ((BYTE*) OldPtr != UnitsStart) BList[indx].insert(OldPtr,NU); | ||
184 | else UnitsStart += U2B(NU); | ||
185 | return ptr; | ||
186 | } | ||
187 | static inline void ExpandTextArea() | ||
188 | { | ||
189 | BLK_NODE* p; | ||
190 | UINT Count[N_INDEXES]; memset(Count,0,sizeof(Count)); | ||
191 | while ((p=(BLK_NODE*) UnitsStart)->Stamp == ~0UL) { | ||
192 | MEM_BLK* pm=(MEM_BLK*) p; UnitsStart=(BYTE*) (pm+pm->NU); | ||
193 | Count[Units2Indx[pm->NU-1]]++; pm->Stamp=0; | ||
194 | } | ||
195 | for (UINT i=0;i < N_INDEXES;i++) | ||
196 | for (p=BList+i;Count[i] != 0;p=p->next) | ||
197 | while ( !p->next->Stamp ) { | ||
198 | p->unlink(); BList[i].Stamp--; | ||
199 | if ( !--Count[i] ) break; | ||
200 | } | ||
201 | } | ||
diff --git a/noncore/apps/opie-reader/TableDialog.cpp b/noncore/apps/opie-reader/TableDialog.cpp new file mode 100644 index 0000000..b67d534 --- a/dev/null +++ b/noncore/apps/opie-reader/TableDialog.cpp | |||
@@ -0,0 +1,17 @@ | |||
1 | #include "TableDialog.h" | ||
2 | |||
3 | CTableDialog::CTableDialog(const QFont& f, const QString& tabtext, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) | ||
4 | { | ||
5 | setCaption("Table View"); | ||
6 | QVBoxLayout *tmp = new QVBoxLayout(this); | ||
7 | QTextView* qtv = new QTextView(this); | ||
8 | qtv->setFont(f); | ||
9 | tmp->addWidget(qtv); | ||
10 | qtv->setText(tabtext); | ||
11 | if (fs) showMaximized(); | ||
12 | else if (parent != NULL) | ||
13 | { | ||
14 | resize(parent->size()); | ||
15 | move(parent->pos()); | ||
16 | } | ||
17 | } | ||
diff --git a/noncore/apps/opie-reader/TableDialog.h b/noncore/apps/opie-reader/TableDialog.h new file mode 100644 index 0000000..2257a81 --- a/dev/null +++ b/noncore/apps/opie-reader/TableDialog.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef __TABLEDIALOG_H | ||
2 | #define __TABLEDIALOG_H | ||
3 | |||
4 | #include <qdialog.h> | ||
5 | #include <qtextview.h> | ||
6 | #include <qlayout.h> | ||
7 | |||
8 | class CTableDialog : public QDialog | ||
9 | { | ||
10 | Q_OBJECT | ||
11 | #ifndef USEQPE | ||
12 | void keyPressEvent(QKeyEvent* e) | ||
13 | { | ||
14 | switch (e->key()) | ||
15 | { | ||
16 | case Key_Escape: | ||
17 | e->accept(); | ||
18 | reject(); | ||
19 | break; | ||
20 | case Key_Space: | ||
21 | case Key_Return: | ||
22 | e->accept(); | ||
23 | accept(); | ||
24 | break; | ||
25 | default: | ||
26 | QWidget::keyPressEvent(e); | ||
27 | } | ||
28 | } | ||
29 | #endif | ||
30 | public: | ||
31 | CTableDialog(const QFont& f, const QString& tabtext, bool fs = true, QWidget* parent = 0, const char* name = 0); | ||
32 | ~CTableDialog() {} | ||
33 | }; | ||
34 | #endif // CPREFS_H | ||
diff --git a/noncore/apps/opie-reader/ToolbarPrefs.h b/noncore/apps/opie-reader/ToolbarPrefs.h index 0bdae6b..9df8940 100644 --- a/noncore/apps/opie-reader/ToolbarPrefs.h +++ b/noncore/apps/opie-reader/ToolbarPrefs.h | |||
@@ -1,267 +1,266 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form interface generated from reading ui file 'Prefs.ui' | 2 | ** Form interface generated from reading ui file 'Prefs.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Feb 11 23:53:32 2003 | 4 | ** Created: Tue Feb 11 23:53:32 2003 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #ifndef CTOOLBARPREFS_H | 9 | #ifndef CTOOLBARPREFS_H |
10 | #define CTOOLBARPREFS_H | 10 | #define CTOOLBARPREFS_H |
11 | |||
11 | #include <qvariant.h> | 12 | #include <qvariant.h> |
12 | #include <qwidget.h> | 13 | #include <qwidget.h> |
13 | #include <qtabdialog.h> | 14 | #include <qtabdialog.h> |
14 | #include <qtabwidget.h> | 15 | #include <qtabwidget.h> |
15 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
16 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
17 | #include <qcombobox.h> | 18 | #include <qcombobox.h> |
18 | #include <qlineedit.h> | 19 | #include <qlineedit.h> |
19 | #ifdef USEQPE | 20 | #ifdef USEQPE |
20 | #include <qpe/menubutton.h> | 21 | #include <qpe/menubutton.h> |
21 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
22 | #else | 23 | #else |
23 | #include "preferences.h" | 24 | #include "preferences.h" |
24 | #endif | 25 | #endif |
25 | //#ifdef OPIE | ||
26 | #define USECOMBO | 26 | #define USECOMBO |
27 | //#endif | ||
28 | 27 | ||
29 | class QVBoxLayout; | 28 | class QVBoxLayout; |
30 | class QHBoxLayout; | 29 | class QHBoxLayout; |
31 | class QGridLayout; | 30 | class QGridLayout; |
32 | //class QCheckBox; | 31 | //class QCheckBox; |
33 | class QLabel; | 32 | class QLabel; |
34 | //class QSpinBox; | 33 | //class QSpinBox; |
35 | /* | 34 | /* |
36 | class CBarPrefs1 : public QWidget | 35 | class CBarPrefs1 : public QWidget |
37 | { | 36 | { |
38 | Q_OBJECT | 37 | Q_OBJECT |
39 | 38 | ||
40 | Config& config; | 39 | Config& config; |
41 | QCheckBox *open, *close, *info, *twotouch,*find,*scroll,*navigation,*page,*startend,*jump,*pageline; | 40 | QCheckBox *open, *close, *info, *twotouch,*find,*scroll,*navigation,*page,*startend,*jump,*pageline; |
42 | 41 | ||
43 | bool m_isChanged; | 42 | bool m_isChanged; |
44 | 43 | ||
45 | private slots: | 44 | private slots: |
46 | void isChanged(int _v) { m_isChanged = true; } | 45 | void isChanged(int _v) { m_isChanged = true; } |
47 | 46 | ||
48 | public: | 47 | public: |
49 | CBarPrefs1( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 48 | CBarPrefs1( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
50 | ~CBarPrefs1(); | 49 | ~CBarPrefs1(); |
51 | void saveall(); | 50 | void saveall(); |
52 | bool isChanged() { return m_isChanged; } | 51 | bool isChanged() { return m_isChanged; } |
53 | }; | 52 | }; |
54 | */ | 53 | */ |
55 | class CFileBarPrefs : public QWidget | 54 | class CFileBarPrefs : public QWidget |
56 | { | 55 | { |
57 | Q_OBJECT | 56 | Q_OBJECT |
58 | 57 | ||
59 | Config& config; | 58 | Config& config; |
60 | QCheckBox *open, *close, *info, *twotouch, *find, *scroll; | 59 | QCheckBox *open, *close, *info, *twotouch, *find, *scroll; |
61 | 60 | ||
62 | bool m_isChanged; | 61 | bool m_isChanged; |
63 | 62 | ||
64 | private slots: | 63 | private slots: |
65 | void isChanged(int _v) { m_isChanged = true; } | 64 | void isChanged(int _v) { m_isChanged = true; } |
66 | 65 | ||
67 | public: | 66 | public: |
68 | CFileBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 67 | CFileBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
69 | ~CFileBarPrefs(); | 68 | ~CFileBarPrefs(); |
70 | void saveall(); | 69 | void saveall(); |
71 | bool isChanged() { return m_isChanged; } | 70 | bool isChanged() { return m_isChanged; } |
72 | }; | 71 | }; |
73 | 72 | ||
74 | class CNavBarPrefs : public QWidget | 73 | class CNavBarPrefs : public QWidget |
75 | { | 74 | { |
76 | Q_OBJECT | 75 | Q_OBJECT |
77 | 76 | ||
78 | Config& config; | 77 | Config& config; |
79 | QCheckBox *scroll, *navback, *navhome, *navforward; | 78 | QCheckBox *scroll, *navback, *navhome, *navforward; |
80 | QCheckBox *pageup, *pagedown, *gotostart, *gotoend, *jump, *pageline; | 79 | QCheckBox *pageup, *pagedown, *gotostart, *gotoend, *jump, *pageline; |
81 | 80 | ||
82 | bool m_isChanged; | 81 | bool m_isChanged; |
83 | 82 | ||
84 | private slots: | 83 | private slots: |
85 | void isChanged(int _v) { m_isChanged = true; } | 84 | void isChanged(int _v) { m_isChanged = true; } |
86 | 85 | ||
87 | public: | 86 | public: |
88 | CNavBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 87 | CNavBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
89 | ~CNavBarPrefs(); | 88 | ~CNavBarPrefs(); |
90 | void saveall(); | 89 | void saveall(); |
91 | bool isChanged() { return m_isChanged; } | 90 | bool isChanged() { return m_isChanged; } |
92 | }; | 91 | }; |
93 | /* | 92 | /* |
94 | class CBarPrefs2 : public QWidget | 93 | class CBarPrefs2 : public QWidget |
95 | { | 94 | { |
96 | Q_OBJECT | 95 | Q_OBJECT |
97 | Config& config; | 96 | Config& config; |
98 | QCheckBox *fullscreen, *zoom, *setfont, *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *block, *indannotate, *encoding, *ideogram; | 97 | QCheckBox *fullscreen, *zoom, *setfont, *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *block, *indannotate, *encoding, *ideogram; |
99 | 98 | ||
100 | bool m_isChanged; | 99 | bool m_isChanged; |
101 | 100 | ||
102 | private slots: | 101 | private slots: |
103 | void isChanged(int _v) { m_isChanged = true; } | 102 | void isChanged(int _v) { m_isChanged = true; } |
104 | 103 | ||
105 | public: | 104 | public: |
106 | CBarPrefs2( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 105 | CBarPrefs2( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
107 | ~CBarPrefs2(); | 106 | ~CBarPrefs2(); |
108 | void saveall(); | 107 | void saveall(); |
109 | bool isChanged() { return m_isChanged; } | 108 | bool isChanged() { return m_isChanged; } |
110 | 109 | ||
111 | }; | 110 | }; |
112 | */ | 111 | */ |
113 | class CViewBarPrefs : public QWidget | 112 | class CViewBarPrefs : public QWidget |
114 | { | 113 | { |
115 | Q_OBJECT | 114 | Q_OBJECT |
116 | Config& config; | 115 | Config& config; |
117 | QCheckBox *fullscreen, *rotate, *zoomin, *zoomout, *setfont, *encoding, *ideogram, *invert; | 116 | QCheckBox *fullscreen, *rotate, *zoomin, *zoomout, *setfont, *encoding, *ideogram, *invert; |
118 | 117 | ||
119 | bool m_isChanged; | 118 | bool m_isChanged; |
120 | 119 | ||
121 | private slots: | 120 | private slots: |
122 | void isChanged(int _v) { m_isChanged = true; } | 121 | void isChanged(int _v) { m_isChanged = true; } |
123 | 122 | ||
124 | public: | 123 | public: |
125 | CViewBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 124 | CViewBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
126 | ~CViewBarPrefs(); | 125 | ~CViewBarPrefs(); |
127 | void saveall(); | 126 | void saveall(); |
128 | bool isChanged() { return m_isChanged; } | 127 | bool isChanged() { return m_isChanged; } |
129 | 128 | ||
130 | }; | 129 | }; |
131 | 130 | ||
132 | class CMarkBarPrefs : public QWidget | 131 | class CMarkBarPrefs : public QWidget |
133 | { | 132 | { |
134 | Q_OBJECT | 133 | Q_OBJECT |
135 | Config& config; | 134 | Config& config; |
136 | QCheckBox *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *startblock, *copyblock; | 135 | QCheckBox *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *startblock, *copyblock; |
137 | 136 | ||
138 | bool m_isChanged; | 137 | bool m_isChanged; |
139 | 138 | ||
140 | private slots: | 139 | private slots: |
141 | void isChanged(int _v) { m_isChanged = true; } | 140 | void isChanged(int _v) { m_isChanged = true; } |
142 | 141 | ||
143 | public: | 142 | public: |
144 | CMarkBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 143 | CMarkBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
145 | ~CMarkBarPrefs(); | 144 | ~CMarkBarPrefs(); |
146 | void saveall(); | 145 | void saveall(); |
147 | bool isChanged() { return m_isChanged; } | 146 | bool isChanged() { return m_isChanged; } |
148 | 147 | ||
149 | }; | 148 | }; |
150 | 149 | ||
151 | class CIndBarPrefs : public QWidget | 150 | class CIndBarPrefs : public QWidget |
152 | { | 151 | { |
153 | Q_OBJECT | 152 | Q_OBJECT |
154 | Config& config; | 153 | Config& config; |
155 | QCheckBox *indannotate; | 154 | QCheckBox *indannotate; |
156 | 155 | ||
157 | bool m_isChanged; | 156 | bool m_isChanged; |
158 | 157 | ||
159 | private slots: | 158 | private slots: |
160 | void isChanged(int _v) { m_isChanged = true; } | 159 | void isChanged(int _v) { m_isChanged = true; } |
161 | 160 | ||
162 | public: | 161 | public: |
163 | CIndBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 162 | CIndBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
164 | ~CIndBarPrefs(); | 163 | ~CIndBarPrefs(); |
165 | void saveall(); | 164 | void saveall(); |
166 | bool isChanged() { return m_isChanged; } | 165 | bool isChanged() { return m_isChanged; } |
167 | 166 | ||
168 | }; | 167 | }; |
169 | 168 | ||
170 | class CMiscBarPrefs : public QWidget | 169 | class CMiscBarPrefs : public QWidget |
171 | { | 170 | { |
172 | 171 | ||
173 | public: | 172 | public: |
174 | 173 | ||
175 | CMiscBarPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 174 | CMiscBarPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
176 | ~CMiscBarPrefs(); | 175 | ~CMiscBarPrefs(); |
177 | 176 | ||
178 | #ifdef USECOMBO | 177 | #ifdef USECOMBO |
179 | QComboBox *tbpolicy, *tbposition, *qtscroll, *localscroll; | 178 | QComboBox *tbpolicy, *tbposition, *qtscroll, *localscroll; |
180 | #else | 179 | #else |
181 | MenuButton *tbpolicy, *tbposition, *qtscroll, *localscroll; | 180 | MenuButton *tbpolicy, *tbposition, *qtscroll, *localscroll; |
182 | #endif | 181 | #endif |
183 | QCheckBox *tbmovable, *floating; | 182 | QCheckBox *tbmovable, *floating; |
184 | }; | 183 | }; |
185 | 184 | ||
186 | class CBarPrefs : public QDialog | 185 | class CBarPrefs : public QDialog |
187 | { | 186 | { |
188 | Q_OBJECT | 187 | Q_OBJECT |
189 | ; | 188 | ; |
190 | CMiscBarPrefs* misc; | 189 | CMiscBarPrefs* misc; |
191 | CFileBarPrefs* filebar; | 190 | CFileBarPrefs* filebar; |
192 | CNavBarPrefs* navbar; | 191 | CNavBarPrefs* navbar; |
193 | CViewBarPrefs* viewbar; | 192 | CViewBarPrefs* viewbar; |
194 | CMarkBarPrefs* markbar; | 193 | CMarkBarPrefs* markbar; |
195 | CIndBarPrefs* indbar; | 194 | CIndBarPrefs* indbar; |
196 | Config config; | 195 | Config config; |
197 | 196 | ||
198 | void keyPressEvent(QKeyEvent* e) | 197 | void keyPressEvent(QKeyEvent* e) |
199 | { | 198 | { |
200 | switch (e->key()) | 199 | switch (e->key()) |
201 | { | 200 | { |
202 | case Key_Escape: | 201 | case Key_Escape: |
203 | e->accept(); | 202 | e->accept(); |
204 | reject(); | 203 | reject(); |
205 | break; | 204 | break; |
206 | case Key_Space: | 205 | case Key_Space: |
207 | case Key_Return: | 206 | case Key_Return: |
208 | e->accept(); | 207 | e->accept(); |
209 | accept(); | 208 | accept(); |
210 | break; | 209 | break; |
211 | default: | 210 | default: |
212 | QWidget::keyPressEvent(e); | 211 | QWidget::keyPressEvent(e); |
213 | } | 212 | } |
214 | } | 213 | } |
215 | public: | 214 | public: |
216 | CBarPrefs(const QString& appdir, bool fs = true, QWidget* parent = 0, const char* name = 0); | 215 | CBarPrefs(const QString& appdir, bool fs = true, QWidget* parent = 0, const char* name = 0); |
217 | ~CBarPrefs() | 216 | ~CBarPrefs() |
218 | { | 217 | { |
219 | if (result()) | 218 | if (result()) |
220 | { | 219 | { |
221 | if (navbar->isChanged()) navbar->saveall(); | 220 | if (navbar->isChanged()) navbar->saveall(); |
222 | if (filebar->isChanged()) filebar->saveall(); | 221 | if (filebar->isChanged()) filebar->saveall(); |
223 | if (viewbar->isChanged()) viewbar->saveall(); | 222 | if (viewbar->isChanged()) viewbar->saveall(); |
224 | if (markbar->isChanged()) markbar->saveall(); | 223 | if (markbar->isChanged()) markbar->saveall(); |
225 | if (indbar->isChanged()) indbar->saveall(); | 224 | if (indbar->isChanged()) indbar->saveall(); |
226 | } | 225 | } |
227 | } | 226 | } |
228 | bool isChanged() | 227 | bool isChanged() |
229 | { | 228 | { |
230 | return | 229 | return |
231 | ( | 230 | ( |
232 | filebar->isChanged() | 231 | filebar->isChanged() |
233 | || | 232 | || |
234 | navbar->isChanged() | 233 | navbar->isChanged() |
235 | || | 234 | || |
236 | viewbar->isChanged() | 235 | viewbar->isChanged() |
237 | || | 236 | || |
238 | markbar->isChanged() | 237 | markbar->isChanged() |
239 | || | 238 | || |
240 | indbar->isChanged() | 239 | indbar->isChanged() |
241 | ); | 240 | ); |
242 | } | 241 | } |
243 | bool floating() { return misc->floating->isChecked(); } | 242 | bool floating() { return misc->floating->isChecked(); } |
244 | void floating(bool v) { misc->floating->setChecked(v); } | 243 | void floating(bool v) { misc->floating->setChecked(v); } |
245 | int tbpolicy() { return misc->tbpolicy->currentItem(); } | 244 | int tbpolicy() { return misc->tbpolicy->currentItem(); } |
246 | int qtscroll() { return misc->qtscroll->currentItem(); } | 245 | int qtscroll() { return misc->qtscroll->currentItem(); } |
247 | int localscroll() { return misc->localscroll->currentItem(); } | 246 | int localscroll() { return misc->localscroll->currentItem(); } |
248 | #ifdef USECOMBO | 247 | #ifdef USECOMBO |
249 | void tbpolicy(int v) { misc->tbpolicy->setCurrentItem(v); } | 248 | void tbpolicy(int v) { misc->tbpolicy->setCurrentItem(v); } |
250 | void qtscroll(int v) { misc->qtscroll->setCurrentItem(v); } | 249 | void qtscroll(int v) { misc->qtscroll->setCurrentItem(v); } |
251 | void localscroll(int v) { misc->localscroll->setCurrentItem(v); } | 250 | void localscroll(int v) { misc->localscroll->setCurrentItem(v); } |
252 | #else | 251 | #else |
253 | void tbpolicy(int v) { misc->tbpolicy->select(v); } | 252 | void tbpolicy(int v) { misc->tbpolicy->select(v); } |
254 | void qtscroll(int v) { misc->qtscroll->select(v); } | 253 | void qtscroll(int v) { misc->qtscroll->select(v); } |
255 | void localscroll(int v) { misc->localscroll->select(v); } | 254 | void localscroll(int v) { misc->localscroll->select(v); } |
256 | #endif | 255 | #endif |
257 | bool tbmovable() { return misc->tbmovable->isChecked(); } | 256 | bool tbmovable() { return misc->tbmovable->isChecked(); } |
258 | void tbmovable(bool v) { misc->tbmovable->setChecked(v); } | 257 | void tbmovable(bool v) { misc->tbmovable->setChecked(v); } |
259 | int tbposition() { return misc->tbposition->currentItem(); } | 258 | int tbposition() { return misc->tbposition->currentItem(); } |
260 | #ifdef USECOMBO | 259 | #ifdef USECOMBO |
261 | void tbposition(int v) { misc->tbposition->setCurrentItem(v); } | 260 | void tbposition(int v) { misc->tbposition->setCurrentItem(v); } |
262 | #else | 261 | #else |
263 | void tbposition(int v) { misc->tbposition->select(v); } | 262 | void tbposition(int v) { misc->tbposition->select(v); } |
264 | #endif | 263 | #endif |
265 | 264 | ||
266 | }; | 265 | }; |
267 | #endif // CPREFS_H | 266 | #endif // CPREFS_H |
diff --git a/noncore/apps/opie-reader/ZText.h b/noncore/apps/opie-reader/ZText.h index 199c7da..40b0f0a 100644 --- a/noncore/apps/opie-reader/ZText.h +++ b/noncore/apps/opie-reader/ZText.h | |||
@@ -1,115 +1,124 @@ | |||
1 | #ifndef __Text_h | 1 | #ifndef __Text_h |
2 | #define __Text_h | 2 | #define __Text_h |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <zlib.h> | 4 | #include <zlib.h> |
5 | #include <sys/stat.h> | 5 | #include <sys/stat.h> |
6 | #ifdef USEQPE | ||
7 | #include <qpe/global.h> | ||
8 | #endif | ||
9 | |||
6 | #include "CExpander.h" | 10 | #include "CExpander.h" |
7 | 11 | ||
8 | class Text: public CExpander { | 12 | class Text: public CExpander { |
9 | gzFile file; | 13 | gzFile file; |
10 | unsigned long fsize; | 14 | unsigned long fsize; |
11 | public: | 15 | public: |
12 | void suspend() | 16 | void suspend() |
13 | { | 17 | { |
14 | #ifdef USEQPE | 18 | #ifdef USEQPE |
15 | if (!bSuspended) | 19 | if (!bSuspended) |
16 | { | 20 | { |
17 | bSuspended = true; | 21 | bSuspended = true; |
18 | suspos = gztell(file); | 22 | suspos = gztell(file); |
19 | gzclose(file); | 23 | gzclose(file); |
20 | file = NULL; | 24 | file = NULL; |
21 | sustime = time(NULL); | 25 | sustime = time(NULL); |
22 | } | 26 | } |
23 | #endif | 27 | #endif |
24 | } | 28 | } |
25 | void unsuspend() | 29 | void unsuspend() |
26 | { | 30 | { |
27 | #ifdef USEQPE | 31 | #ifdef USEQPE |
28 | if (bSuspended) | 32 | if (bSuspended) |
29 | { | 33 | { |
30 | bSuspended = false; | 34 | bSuspended = false; |
31 | if (sustime != ((time_t)-1)) | 35 | if (sustime != ((time_t)-1)) |
32 | { | 36 | { |
33 | int delay = time(NULL) - sustime; | 37 | int delay = time(NULL) - sustime; |
34 | if (delay < 10) sleep(10-delay); | 38 | if (delay < 10) |
39 | { | ||
40 | Global::statusMessage("Stalling"); | ||
41 | sleep(10-delay); | ||
42 | } | ||
35 | } | 43 | } |
36 | file = gzopen(fname, "rb"); | 44 | file = gzopen(fname, "rb"); |
37 | for (int i = 0; file == NULL && i < 5; i++) | 45 | for (int i = 0; file == NULL && i < 5; i++) |
38 | { | 46 | { |
47 | Global::statusMessage("Stalling"); | ||
39 | sleep(5); | 48 | sleep(5); |
40 | file = gzopen(fname, "rb"); | 49 | file = gzopen(fname, "rb"); |
41 | } | 50 | } |
42 | if (file == NULL) | 51 | if (file == NULL) |
43 | { | 52 | { |
44 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); | 53 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); |
45 | exit(0); | 54 | exit(0); |
46 | } | 55 | } |
47 | suspos = gzseek(file, suspos, SEEK_SET); | 56 | suspos = gzseek(file, suspos, SEEK_SET); |
48 | } | 57 | } |
49 | #endif | 58 | #endif |
50 | } | 59 | } |
51 | Text() : file(NULL) {}; | 60 | Text() : file(NULL) {}; |
52 | virtual ~Text() | 61 | virtual ~Text() |
53 | { | 62 | { |
54 | if (file != NULL) | 63 | if (file != NULL) |
55 | { | 64 | { |
56 | #ifdef USEQPE | 65 | #ifdef USEQPE |
57 | unsuspend(); | 66 | unsuspend(); |
58 | #endif | 67 | #endif |
59 | gzclose(file); | 68 | gzclose(file); |
60 | } | 69 | } |
61 | } | 70 | } |
62 | int OpenFile(const char *src) | 71 | int OpenFile(const char *src) |
63 | { | 72 | { |
64 | if (file != NULL) gzclose(file); | 73 | if (file != NULL) gzclose(file); |
65 | struct stat _stat; | 74 | struct stat _stat; |
66 | stat(src,&_stat); | 75 | stat(src,&_stat); |
67 | fsize = _stat.st_size; | 76 | fsize = _stat.st_size; |
68 | return ((file = gzopen(src,"rb")) == NULL); | 77 | return ((file = gzopen(src,"rb")) == NULL); |
69 | } | 78 | } |
70 | int getch() | 79 | int getch() |
71 | { | 80 | { |
72 | #ifdef USEQPE | 81 | #ifdef USEQPE |
73 | unsuspend(); | 82 | unsuspend(); |
74 | #endif | 83 | #endif |
75 | return gzgetc(file); | 84 | return gzgetc(file); |
76 | } | 85 | } |
77 | unsigned int locate() | 86 | unsigned int locate() |
78 | { | 87 | { |
79 | #ifdef USEQPE | 88 | #ifdef USEQPE |
80 | unsuspend(); | 89 | unsuspend(); |
81 | #endif | 90 | #endif |
82 | return gztell(file); | 91 | return gztell(file); |
83 | } | 92 | } |
84 | void locate(unsigned int n) | 93 | void locate(unsigned int n) |
85 | { | 94 | { |
86 | #ifdef USEQPE | 95 | #ifdef USEQPE |
87 | unsuspend(); | 96 | unsuspend(); |
88 | #endif | 97 | #endif |
89 | gzseek(file,n,SEEK_SET); | 98 | gzseek(file,n,SEEK_SET); |
90 | } | 99 | } |
91 | bool hasrandomaccess() { return true; } | 100 | bool hasrandomaccess() { return true; } |
92 | void sizes(unsigned long& _file, unsigned long& _text) | 101 | void sizes(unsigned long& _file, unsigned long& _text) |
93 | { | 102 | { |
94 | _text = _file = fsize; | 103 | _text = _file = fsize; |
95 | FILE* f = fopen(fname, "rb"); | 104 | FILE* f = fopen(fname, "rb"); |
96 | if (f != NULL) | 105 | if (f != NULL) |
97 | { | 106 | { |
98 | unsigned char mn[2]; | 107 | unsigned char mn[2]; |
99 | fread(mn, 1, 2, f); | 108 | fread(mn, 1, 2, f); |
100 | if ((mn[0] == 31) && (mn[1] == 139)) | 109 | if ((mn[0] == 31) && (mn[1] == 139)) |
101 | { | 110 | { |
102 | int tmp = sizeof(_text); | 111 | int tmp = sizeof(_text); |
103 | fseek(f,-tmp,SEEK_END); | 112 | fseek(f,-tmp,SEEK_END); |
104 | fread(&_text, sizeof(_text), 1, f); | 113 | fread(&_text, sizeof(_text), 1, f); |
105 | } | 114 | } |
106 | fclose(f); | 115 | fclose(f); |
107 | } | 116 | } |
108 | } | 117 | } |
109 | MarkupType PreferredMarkup() | 118 | MarkupType PreferredMarkup() |
110 | { | 119 | { |
111 | return cTEXT; | 120 | return cTEXT; |
112 | } | 121 | } |
113 | QString about() { return QString("Text/gzipped text codec (c) Tim Wentford"); } | 122 | QString about() { return QString("Text/gzipped text codec (c) Tim Wentford"); } |
114 | }; | 123 | }; |
115 | #endif | 124 | #endif |
diff --git a/noncore/apps/opie-reader/arith.h b/noncore/apps/opie-reader/arith.h index 19ca646..59b2ea9 100644 --- a/noncore/apps/opie-reader/arith.h +++ b/noncore/apps/opie-reader/arith.h | |||
@@ -1,43 +1,41 @@ | |||
1 | /* | 1 | /* |
2 | * Encodage & décodage arithmétique | 2 | * Encodage & décodage arithmétique |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef ARITH_H | 5 | #ifndef ARITH_H |
6 | 6 | ||
7 | #define ARITH_H | 7 | #define ARITH_H |
8 | 8 | ||
9 | #include "utypes.h" | 9 | #include "utypes.h" |
10 | #include <stdio.h> | 10 | #include <stdio.h> |
11 | 11 | ||
12 | class ppm_expander; | ||
13 | |||
12 | class PPM_ReadBuf | 14 | class PPM_ReadBuf |
13 | { | 15 | { |
14 | FILE *my_file_in; | 16 | FILE *my_file_in; |
17 | ppm_expander* parent; | ||
15 | public: | 18 | public: |
16 | PPM_ReadBuf(FILE* f) : my_file_in(f) {} | 19 | PPM_ReadBuf(FILE* f, ppm_expander* _parent) : my_file_in(f), parent(_parent) {} |
17 | UINT readbuf(UCHAR *buf,UINT len) | 20 | UINT readbuf(UCHAR *buf,UINT len); |
18 | { | ||
19 | UINT len1; | ||
20 | len1=fread(buf,1,len,my_file_in); | ||
21 | return len1; | ||
22 | } | ||
23 | }; | 21 | }; |
24 | 22 | ||
25 | class ArithClass | 23 | class ArithClass |
26 | { | 24 | { |
27 | 25 | ||
28 | UCHAR *ainbuf; | 26 | UCHAR *ainbuf; |
29 | UCHAR *apinbuf,*aendinbuf; | 27 | UCHAR *apinbuf,*aendinbuf; |
30 | UINT ainbufsize; | 28 | UINT ainbufsize; |
31 | USHORT avalue,alow,ahigh; | 29 | USHORT avalue,alow,ahigh; |
32 | PPM_ReadBuf* areadbuf; | 30 | PPM_ReadBuf* areadbuf; |
33 | UCHAR abitcnt; | 31 | UCHAR abitcnt; |
34 | USHORT abitbuf; | 32 | USHORT abitbuf; |
35 | 33 | ||
36 | public: | 34 | public: |
37 | void Arith_DecodeInit(PPM_ReadBuf* readbuf,UCHAR *buf,UINT bufsize); | 35 | void Arith_DecodeInit(PPM_ReadBuf* readbuf,UCHAR *buf,UINT bufsize); |
38 | UINT Arith_DecodeVal(UINT size); | 36 | UINT Arith_DecodeVal(UINT size); |
39 | void Arith_Decode(UINT min,UINT max,UINT size); | 37 | void Arith_Decode(UINT min,UINT max,UINT size); |
40 | void Arith_DecodeEnd(void); | 38 | void Arith_DecodeEnd(void); |
41 | 39 | ||
42 | }; | 40 | }; |
43 | #endif | 41 | #endif |
diff --git a/noncore/apps/opie-reader/arrierego.cpp b/noncore/apps/opie-reader/arrierego.cpp new file mode 100644 index 0000000..be2a3fa --- a/dev/null +++ b/noncore/apps/opie-reader/arrierego.cpp | |||
@@ -0,0 +1,188 @@ | |||
1 | #ifdef USENEF | ||
2 | #include <qimage.h> | ||
3 | #include "arrierego.h" | ||
4 | |||
5 | struct CArriere_dataRecord | ||
6 | { | ||
7 | UInt16 uid; | ||
8 | UInt16 nParagraphs; | ||
9 | UInt32 size; | ||
10 | UInt8 type; | ||
11 | UInt8 reserved; | ||
12 | }; | ||
13 | |||
14 | int CArriere::HeaderSize() | ||
15 | { | ||
16 | return 10; | ||
17 | } | ||
18 | |||
19 | void CArriere::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved) | ||
20 | { | ||
21 | CArriere_dataRecord thishdr; | ||
22 | unsuspend(); | ||
23 | fread(&thishdr, 1, HeaderSize(), fin); | ||
24 | uid = ntohs(thishdr.uid); | ||
25 | nParagraphs = ntohs(thishdr.nParagraphs); | ||
26 | size = ntohl(thishdr.size); | ||
27 | type = thishdr.type; | ||
28 | reserved = thishdr.reserved; | ||
29 | // qDebug("UID:%u Paras:%u Size:%u Type:%u Reserved:%u", uid, nParagraphs, size, (unsigned int)type, (unsigned int)reserved); | ||
30 | // for (int i = 0; i < sizeof(thishdr); i++) | ||
31 | //printf("%d %x\n", i, (int)(((char *)(&thishdr))[i])); | ||
32 | } | ||
33 | |||
34 | bool CArriere::CorrectDecoder() | ||
35 | { | ||
36 | char * type = (char*)(&(head.type)); | ||
37 | for (int i = 0; i < 8; ++i) qDebug("%c", type[i]); | ||
38 | return (memcmp(&head.type, "ArriereG", 8) == 0); | ||
39 | } | ||
40 | |||
41 | int CArriere::bgetch() | ||
42 | { | ||
43 | int ch = EOF; | ||
44 | if (bufferpos >= buffercontent) | ||
45 | { | ||
46 | if (bufferrec >= ntohs(head.recordList.numRecords) - 1) | ||
47 | { | ||
48 | return EOF; | ||
49 | } | ||
50 | if (isEndOfSection(bufferrec)) | ||
51 | { | ||
52 | return EOF; | ||
53 | } | ||
54 | if (!expand(bufferrec+1)) | ||
55 | { | ||
56 | return EOF; | ||
57 | } | ||
58 | mystyle.unset(); | ||
59 | if (m_ParaOffsets[m_nextParaIndex] == 0) | ||
60 | { | ||
61 | while (m_ParaOffsets[m_nextParaIndex+1] == 0) | ||
62 | { | ||
63 | m_nextParaIndex++; | ||
64 | } | ||
65 | } | ||
66 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); | ||
67 | } | ||
68 | if (bufferpos == m_nextPara) | ||
69 | { | ||
70 | while (bufferpos == m_nextPara) | ||
71 | { | ||
72 | m_nextParaIndex++; | ||
73 | if (m_nextParaIndex == m_nParas) | ||
74 | { | ||
75 | m_nextPara = -1; | ||
76 | } | ||
77 | else | ||
78 | { | ||
79 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | ||
80 | } | ||
81 | } | ||
82 | mystyle.unset(); | ||
83 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); | ||
84 | if (m_lastBreak == locate()) | ||
85 | { | ||
86 | currentpos++; | ||
87 | ch = expandedtextbuffer[bufferpos++]; | ||
88 | } | ||
89 | else | ||
90 | { | ||
91 | ch = 10; | ||
92 | } | ||
93 | } | ||
94 | else | ||
95 | { | ||
96 | currentpos++; | ||
97 | ch = expandedtextbuffer[bufferpos++]; | ||
98 | } | ||
99 | return ch; | ||
100 | } | ||
101 | |||
102 | tchar CArriere::getch(bool fast) | ||
103 | { | ||
104 | mystyle.clearPicture(); | ||
105 | return getch_base(fast); | ||
106 | } | ||
107 | |||
108 | /* | ||
109 | void CArriere::setlink(QString& fn, const QString& wrd) | ||
110 | { | ||
111 | fn = wrd; | ||
112 | } | ||
113 | */ | ||
114 | |||
115 | QImage* CArriere::imagefromdata(UInt8* imgbuffer, UInt32 imgsize) | ||
116 | { | ||
117 | QByteArray arr; | ||
118 | arr.assign((const char*)imgbuffer, imgsize); | ||
119 | |||
120 | QImage* qimage = new QImage(arr); | ||
121 | |||
122 | return qimage; | ||
123 | } | ||
124 | |||
125 | void CArriere::start2endSection() | ||
126 | { | ||
127 | m_currentstart = NEFstartSection(); | ||
128 | m_currentend = NEFendSection(); | ||
129 | } | ||
130 | |||
131 | unsigned long CArriere::NEFstartSection() | ||
132 | { | ||
133 | //inefficient - Should calc start/end of section on entry to section? | ||
134 | UInt16 thishdr_uid, thishdr_nParagraphs; | ||
135 | UInt32 thishdr_size; | ||
136 | UInt8 thishdr_type, thishdr_reserved; | ||
137 | unsigned long textlength = currentpos-bufferpos; | ||
138 | for (UInt16 recptr = bufferrec-1; recptr >= 1; recptr--) | ||
139 | { | ||
140 | gotorecordnumber(recptr); | ||
141 | //qDebug("recptr:%u", recptr); | ||
142 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | ||
143 | if (thishdr_type < 2) | ||
144 | { | ||
145 | if ((thishdr_reserved && continuation_bit) == 0) break; | ||
146 | textlength -= thishdr_size; | ||
147 | //qDebug("Textlength:%u, reserved:%u, recptr:%u", textlength, thishdr_reserved, recptr); | ||
148 | } | ||
149 | } | ||
150 | return textlength; | ||
151 | } | ||
152 | |||
153 | unsigned long CArriere::NEFendSection() | ||
154 | { | ||
155 | //inefficient - Should calc start/end of section on entry to section? | ||
156 | unsigned long textlength = currentpos-bufferpos+buffercontent; | ||
157 | gotorecordnumber(bufferrec); | ||
158 | UInt16 thishdr_uid, thishdr_nParagraphs; | ||
159 | UInt32 thishdr_size; | ||
160 | UInt8 thishdr_type, thishdr_reserved; | ||
161 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | ||
162 | if ((thishdr_reserved && continuation_bit) != 0) | ||
163 | { | ||
164 | for (UInt16 recptr = bufferrec+1; recptr < ntohs(head.recordList.numRecords); recptr++) | ||
165 | { | ||
166 | gotorecordnumber(recptr); | ||
167 | UInt16 thishdr_uid, thishdr_nParagraphs; | ||
168 | UInt32 thishdr_size; | ||
169 | UInt8 thishdr_type, thishdr_reserved; | ||
170 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | ||
171 | //qDebug("recptr %u bufferrec %u type %u m_reserved %u", recptr, bufferrec, typ | ||
172 | if (thishdr_type < 2) | ||
173 | { | ||
174 | textlength += thishdr_size; | ||
175 | if ((thishdr_reserved && continuation_bit) == 0) break; | ||
176 | } | ||
177 | } | ||
178 | } | ||
179 | return textlength; | ||
180 | } | ||
181 | |||
182 | #ifndef __STATIC | ||
183 | extern "C" | ||
184 | { | ||
185 | CExpander* newcodec() { return new CArriere; } | ||
186 | } | ||
187 | #endif | ||
188 | #endif | ||
diff --git a/noncore/apps/opie-reader/arrierego.h b/noncore/apps/opie-reader/arrierego.h new file mode 100644 index 0000000..5d6e2d0 --- a/dev/null +++ b/noncore/apps/opie-reader/arrierego.h | |||
@@ -0,0 +1,37 @@ | |||
1 | #if (!defined(__ARRIEREGO_H)) && defined(USENEF) | ||
2 | #define __ARRIEREGO_H | ||
3 | #include "plucker_base.h" | ||
4 | |||
5 | #ifdef LOCALPICTURES | ||
6 | class QScrollView; | ||
7 | class QWidget; | ||
8 | #endif | ||
9 | |||
10 | class CArriere : public CPlucker_base | ||
11 | { | ||
12 | protected: | ||
13 | bool isEndOfSection(int thisrec) | ||
14 | { | ||
15 | return !m_bufferisreserved; | ||
16 | } | ||
17 | unsigned long NEFstartSection(); | ||
18 | unsigned long NEFendSection(); | ||
19 | void setbuffersize() | ||
20 | { | ||
21 | compressedbuffersize = buffersize = 64*1024; | ||
22 | } | ||
23 | void GetHeader(UInt16&, UInt16&, UInt32&, UInt8&, UInt8&); | ||
24 | int HeaderSize(); | ||
25 | int bgetch(); | ||
26 | tchar getch(bool); | ||
27 | |||
28 | bool CorrectDecoder(); | ||
29 | // void setlink(QString&, const QString&); | ||
30 | QImage* imagefromdata(UInt8*, UInt32); | ||
31 | unsigned char m_reserved; | ||
32 | public: | ||
33 | void start2endSection(); | ||
34 | QString about() { return CPlucker_base::about()+QString("\nArriereGo codec (c) Tim Wentford"); } | ||
35 | }; | ||
36 | |||
37 | #endif | ||
diff --git a/noncore/apps/opie-reader/cbkmkselector.h b/noncore/apps/opie-reader/cbkmkselector.h index 42951e5..ec0c6e8 100644 --- a/noncore/apps/opie-reader/cbkmkselector.h +++ b/noncore/apps/opie-reader/cbkmkselector.h | |||
@@ -1,43 +1,89 @@ | |||
1 | #include <qwidget.h> | 1 | #include <qwidget.h> |
2 | #include <qlistbox.h> | 2 | #include <qlistbox.h> |
3 | #include <qpushbutton.h> | 3 | #include <qpushbutton.h> |
4 | #include <qlayout.h> | 4 | #include <qlayout.h> |
5 | 5 | ||
6 | class CBkmkSelectorItem : public QListBoxText | ||
7 | { | ||
8 | int m_ref; | ||
9 | public: | ||
10 | CBkmkSelectorItem(const QString& _t, int ref) : QListBoxText(_t), m_ref(ref) | ||
11 | { | ||
12 | } | ||
13 | int reference() { return m_ref; } | ||
14 | }; | ||
15 | |||
6 | class CBkmkSelector : public QWidget | 16 | class CBkmkSelector : public QWidget |
7 | { | 17 | { |
8 | 18 | ||
9 | Q_OBJECT | 19 | Q_OBJECT |
10 | 20 | ||
11 | QListBox* bkmkselector; | 21 | QListBox* bkmkselector; |
12 | QPushButton* exitButton; | 22 | QPushButton* exitButton; |
13 | 23 | /* | |
24 | void keyPressEvent ( QKeyEvent * e ) | ||
25 | { | ||
26 | if ((e->key() == Key_Return) || (e->key() == Key_Space)) | ||
27 | { | ||
28 | emit selected(reinterpret_cast<CBkmkSelectorItem*>(bkmkselector->item(bkmkselector->currentItem()))->reference()); | ||
29 | e->accept(); | ||
30 | } | ||
31 | else | ||
32 | { | ||
33 | e->ignore(); | ||
34 | } | ||
35 | } | ||
36 | */ | ||
14 | signals: | 37 | signals: |
15 | void selected(int i); | 38 | void selected(int i); |
16 | void cancelled(); | 39 | void cancelled(); |
17 | private slots: | 40 | private slots: |
18 | void slotSelected(QListBoxItem* t) { emit selected(bkmkselector->index(t)); } | 41 | void slotSelected(QListBoxItem* t) |
19 | void slotSelected(int t) { emit selected(t); } | 42 | { |
43 | if (t != NULL) | ||
44 | { | ||
45 | emit selected(reinterpret_cast<CBkmkSelectorItem*>(t)->reference()); | ||
46 | } | ||
47 | } | ||
48 | //void slotSelected(int t) { emit selected(t); } | ||
20 | void slotCancel() { emit cancelled(); } | 49 | void slotCancel() { emit cancelled(); } |
50 | void slotSort() | ||
51 | { | ||
52 | bkmkselector->sort(); | ||
53 | #ifdef USEQPE | ||
54 | setCurrentItem(bkmkselector->currentItem()); | ||
55 | #endif | ||
56 | } | ||
21 | public: | 57 | public: |
22 | CBkmkSelector( QWidget *parent=0, const char *name=0, WFlags f = 0) : | 58 | CBkmkSelector( QWidget *parent=0, const char *name=0, WFlags f = 0) : |
23 | QWidget(parent, name, f) | 59 | QWidget(parent, name, f) |
24 | { | 60 | { |
25 | 61 | ||
26 | // QFont f("unifont", 16); | 62 | // QFont f("unifont", 16); |
27 | // setFont( f ); | 63 | // setFont( f ); |
28 | 64 | ||
29 | QVBoxLayout* grid = new QVBoxLayout(this); | 65 | QVBoxLayout* grid = new QVBoxLayout(this); |
30 | bkmkselector = new QListBox(this, "Bookmarks"); | 66 | QHBoxLayout* hgrid = new QHBoxLayout(); |
31 | exitButton = new QPushButton("Cancel", this); | 67 | bkmkselector = new QListBox(this, tr("Bookmarks")); |
32 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( slotSelected(int) ) ); | 68 | QPushButton* _sort = new QPushButton(tr("Sort"), this); |
69 | connect(_sort, SIGNAL(clicked()), this, SLOT( slotSort() ) ); | ||
70 | exitButton = new QPushButton(tr("Cancel"), this); | ||
71 | // connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( slotSelected(int) ) ); | ||
33 | connect(bkmkselector, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) ); | 72 | connect(bkmkselector, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) ); |
73 | connect(bkmkselector, SIGNAL( returnPressed(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) ); | ||
34 | connect(exitButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) ); | 74 | connect(exitButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) ); |
35 | grid->addWidget(bkmkselector,1); | 75 | grid->addWidget(bkmkselector,1); |
36 | grid->addWidget(exitButton); | 76 | grid->addLayout(hgrid); |
77 | hgrid->addWidget(_sort); | ||
78 | hgrid->addWidget(exitButton); | ||
37 | } | 79 | } |
38 | void clear() { bkmkselector->clear(); } | 80 | void clear() { bkmkselector->clear(); } |
39 | void insertItem(const QString& item) { bkmkselector->insertItem(item); } | 81 | void insertItem(const QString& _item, int ref) |
82 | { | ||
83 | CBkmkSelectorItem* item = new CBkmkSelectorItem(_item, ref); | ||
84 | bkmkselector->insertItem(item); | ||
85 | } | ||
40 | QString text(int index) const { return bkmkselector->text(index); } | 86 | QString text(int index) const { return bkmkselector->text(index); } |
41 | void setText(const QString& _l) { exitButton->setText(_l); } | 87 | void setText(const QString& _l) { exitButton->setText(_l); } |
88 | void setCurrentItem(int _i) { bkmkselector->setCurrentItem(_i); } | ||
42 | }; | 89 | }; |
43 | |||
diff --git a/noncore/apps/opie-reader/config.in b/noncore/apps/opie-reader/config.in index 9f80a93..04ff2f1 100644 --- a/noncore/apps/opie-reader/config.in +++ b/noncore/apps/opie-reader/config.in | |||
@@ -1,4 +1,8 @@ | |||
1 | config OPIE-READER | 1 | config OPIE-READER |
2 | boolean "opie-reader (E-Text reader)" | 2 | boolean "opie-reader (E-Text reader)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI |
5 | |||
6 | source noncore/apps/opie-reader/FliteDyn/config.in | ||
7 | source noncore/apps/opie-reader/FliteDyn16/config.in | ||
8 | |||
diff --git a/noncore/apps/opie-reader/decompress.cpp b/noncore/apps/opie-reader/decompress.cpp new file mode 100644 index 0000000..9bfec49 --- a/dev/null +++ b/noncore/apps/opie-reader/decompress.cpp | |||
@@ -0,0 +1,95 @@ | |||
1 | #include <string.h> | ||
2 | #include "decompress.h" | ||
3 | #include <zlib.h> | ||
4 | #include <stdlib.h> | ||
5 | |||
6 | size_t UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) | ||
7 | { | ||
8 | z_stream zstream; | ||
9 | memset(&zstream,sizeof(zstream),0); | ||
10 | zstream.next_in = compressedbuffer; | ||
11 | zstream.next_out = tgtbuffer; | ||
12 | zstream.avail_out = bsize; | ||
13 | zstream.avail_in = reclen; | ||
14 | |||
15 | int keylen = 0; | ||
16 | |||
17 | zstream.zalloc = Z_NULL; | ||
18 | zstream.zfree = Z_NULL; | ||
19 | zstream.opaque = Z_NULL; | ||
20 | |||
21 | // printf("Initialising\n"); | ||
22 | |||
23 | inflateInit(&zstream); | ||
24 | int err = 0; | ||
25 | do { | ||
26 | if ( zstream.avail_in == 0 && 0 < keylen ) { | ||
27 | zstream.next_in = compressedbuffer + keylen; | ||
28 | zstream.avail_in = reclen - keylen; | ||
29 | keylen = 0; | ||
30 | } | ||
31 | zstream.next_out = tgtbuffer; | ||
32 | zstream.avail_out = bsize; | ||
33 | |||
34 | err = inflate( &zstream, Z_SYNC_FLUSH ); | ||
35 | |||
36 | ////qDebug("err:%d - %u", err, zstream.avail_in); | ||
37 | |||
38 | } while ( err == Z_OK ); | ||
39 | |||
40 | inflateEnd(&zstream); | ||
41 | return zstream.total_out; | ||
42 | } | ||
43 | |||
44 | #if defined(__STATIC) && defined(USENEF) | ||
45 | #include "Model.h" | ||
46 | size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t) | ||
47 | { | ||
48 | if (strcmp(_s, "PluckerDecompress3") == 0) | ||
49 | { | ||
50 | return PluckerDecompress3; | ||
51 | } | ||
52 | if (strcmp(_s, "PluckerDecompress4") == 0) | ||
53 | { | ||
54 | return PluckerDecompress4; | ||
55 | } | ||
56 | if (strcmp(_s, "RebDecompress") == 0) | ||
57 | { | ||
58 | return RebDecompress; | ||
59 | } | ||
60 | return NULL; | ||
61 | } | ||
62 | #else | ||
63 | |||
64 | #include "qfileinfo.h" | ||
65 | |||
66 | #include <dlfcn.h> | ||
67 | |||
68 | size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t) | ||
69 | { | ||
70 | #ifdef USEQPE | ||
71 | #ifdef OPIE | ||
72 | QString codecpath(getenv("OPIEDIR")); | ||
73 | #else | ||
74 | QString codecpath(getenv("QTDIR")); | ||
75 | #endif | ||
76 | codecpath += "/plugins/reader/support/libpluckerdecompress.so"; | ||
77 | #else | ||
78 | QString codecpath(getenv("READERDIR")); | ||
79 | codecpath += "/support/libpluckerdecompress.so"; | ||
80 | #endif | ||
81 | qDebug("Codec:%s", (const char*)codecpath); | ||
82 | if (QFile::exists(codecpath)) | ||
83 | { | ||
84 | qDebug("Codec:%s", (const char*)codecpath); | ||
85 | void* handle = dlopen(codecpath, RTLD_LAZY); | ||
86 | if (handle == 0) | ||
87 | { | ||
88 | qDebug("Can't find codec:%s", dlerror()); | ||
89 | return NULL; | ||
90 | } | ||
91 | return (size_t (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s); | ||
92 | } | ||
93 | return NULL; | ||
94 | } | ||
95 | #endif | ||
diff --git a/noncore/apps/opie-reader/decompress.h b/noncore/apps/opie-reader/decompress.h new file mode 100644 index 0000000..400685f --- a/dev/null +++ b/noncore/apps/opie-reader/decompress.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #include "mytypes.h" | ||
2 | |||
3 | size_t UnZip(UInt8* compressedbuffer,size_t reclen,UInt8* tgtbuffer,size_t bsize); | ||
4 | |||
5 | size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t); | ||
diff --git a/noncore/apps/opie-reader/ebookcodec.h b/noncore/apps/opie-reader/ebookcodec.h index f6e2daf..4229fb9 100644 --- a/noncore/apps/opie-reader/ebookcodec.h +++ b/noncore/apps/opie-reader/ebookcodec.h | |||
@@ -1,118 +1,131 @@ | |||
1 | #include "CExpander.h" | 1 | #include "CExpander.h" |
2 | 2 | ||
3 | #include <qfileinfo.h> | 3 | #include <qfileinfo.h> |
4 | #include <qdir.h> | 4 | #include <qdir.h> |
5 | 5 | ||
6 | #ifdef USEQPE | 6 | #ifdef USEQPE |
7 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
8 | #endif | 8 | #endif |
9 | 9 | ||
10 | #include "util.h" | ||
11 | |||
12 | #ifndef __STATIC | 10 | #ifndef __STATIC |
13 | #include <dlfcn.h> | 11 | #include <dlfcn.h> |
14 | class ebookcodec : public CExpander_Interface | 12 | class ebookcodec : public CExpander_Interface |
15 | { | 13 | { |
16 | CExpander *codec; | 14 | CExpander *codec; |
17 | void *handle; | 15 | void *handle; |
18 | int status; | 16 | int status; |
19 | public: | 17 | public: |
18 | QString getTableAsHtml(unsigned long loc) { return codec->getTableAsHtml(loc); } | ||
20 | QString about() | 19 | QString about() |
21 | { | 20 | { |
22 | return QString("Plug-in ebook codec interface (c) Tim Wentford\n")+codec->about(); | 21 | return QString("Plug-in ebook codec interface (c) Tim Wentford\n")+codec->about(); |
23 | } | 22 | } |
24 | ebookcodec(const QString& _s) : codec(NULL), handle(NULL), status(0) | 23 | ebookcodec(const QString& _s) : codec(NULL), handle(NULL), status(0) |
25 | { | 24 | { |
26 | QString codecpath(QTReaderUtil::getPluginPath()); | 25 | #ifdef USEQPE |
26 | #ifdef OPIE | ||
27 | QString codecpath(getenv("OPIEDIR")); | ||
28 | #else | ||
29 | QString codecpath(getenv("QTDIR")); | ||
30 | #endif | ||
31 | codecpath += "/plugins/reader/codecs/"; | ||
32 | #else | ||
33 | QString codecpath(getenv("READERDIR")); | ||
34 | codecpath += "/codecs/"; | ||
35 | #endif | ||
27 | codecpath += _s; | 36 | codecpath += _s; |
28 | if (QFile::exists(codecpath)) | 37 | if (QFile::exists(codecpath)) |
29 | { | 38 | { |
30 | qDebug("Codec:%s", (const char*)codecpath); | 39 | qDebug("Codec:%s", (const char*)codecpath); |
31 | handle = dlopen(codecpath, RTLD_LAZY); | 40 | handle = dlopen(codecpath, RTLD_LAZY); |
32 | if (handle == 0) | 41 | if (handle == 0) |
33 | { | 42 | { |
34 | /* | 43 | /* |
35 | QString wrn(dlerror()); | 44 | QString wrn(dlerror()); |
36 | QString fmt; | 45 | QString fmt; |
37 | while (wrn.length() > 10) | 46 | while (wrn.length() > 10) |
38 | { | 47 | { |
39 | fmt += wrn.left(10); | 48 | fmt += wrn.left(10); |
40 | fmt += '\n'; | 49 | fmt += '\n'; |
41 | wrn = wrn.right(wrn.length()-10); | 50 | wrn = wrn.right(wrn.length()-10); |
42 | } | 51 | } |
43 | fmt += wrn; | 52 | fmt += wrn; |
44 | QMessageBox::warning(NULL, PROGNAME, fmt); | 53 | QMessageBox::warning(NULL, PROGNAME, fmt); |
45 | */ | 54 | */ |
46 | qDebug("Can't find codec:%s", dlerror()); | 55 | qDebug("Can't find codec:%s", dlerror()); |
47 | status = -10; | 56 | status = -10; |
48 | return; | 57 | return; |
49 | } | 58 | } |
50 | CExpander* (*newcodec)(); | 59 | CExpander* (*newcodec)(); |
51 | newcodec = (CExpander* (*)())dlsym(handle, "newcodec"); | 60 | newcodec = (CExpander* (*)())dlsym(handle, "newcodec"); |
52 | if (newcodec == NULL) | 61 | if (newcodec == NULL) |
53 | { | 62 | { |
54 | qDebug("Can't find newcodec"); | 63 | qDebug("Can't find newcodec"); |
55 | status = -20; | 64 | status = -20; |
56 | return; | 65 | return; |
57 | } | 66 | } |
58 | codec = (*newcodec)(); | 67 | codec = (*newcodec)(); |
59 | } | 68 | } |
60 | else | 69 | else |
61 | { | 70 | { |
62 | qDebug("Can't find codec"); | 71 | qDebug("Can't find codec"); |
63 | } | 72 | } |
64 | if (codec == NULL) | 73 | if (codec == NULL) |
65 | { | 74 | { |
66 | qDebug("Can't do newcodec"); | 75 | qDebug("Can't do newcodec"); |
67 | status = -30; | 76 | status = -30; |
68 | return; | 77 | return; |
69 | } | 78 | } |
70 | } | 79 | } |
71 | virtual ~ebookcodec() | 80 | virtual ~ebookcodec() |
72 | { | 81 | { |
73 | if (codec != NULL) delete codec; | 82 | if (codec != NULL) delete codec; |
74 | if (handle != NULL) dlclose(handle); | 83 | if (handle != NULL) dlclose(handle); |
75 | } | 84 | } |
76 | size_t getHome() { return codec->getHome(); } | 85 | size_t getHome() { return codec->getHome(); } |
77 | #ifdef USEQPE | 86 | #ifdef USEQPE |
78 | void suspend() { codec->suspend(); } | 87 | void suspend() { codec->suspend(); } |
79 | void unsuspend() { codec->unsuspend(); } | 88 | void unsuspend() { codec->unsuspend(); } |
80 | void suspend(FILE*& fin) { codec->suspend(fin); } | 89 | void suspend(FILE*& fin) { codec->suspend(fin); } |
81 | void unsuspend(FILE*& fin) { codec->unsuspend(fin); } | 90 | void unsuspend(FILE*& fin) { codec->unsuspend(fin); } |
82 | #endif | 91 | #endif |
83 | unsigned int locate() { return codec->locate(); } | 92 | unsigned int locate() { return codec->locate(); } |
84 | void locate(unsigned int n) { codec->locate(n); } | 93 | void locate(unsigned int n) { codec->locate(n); } |
85 | bool hasrandomaccess() { return codec->hasrandomaccess(); } | 94 | bool hasrandomaccess() { return codec->hasrandomaccess(); } |
86 | void sizes(unsigned long& file, unsigned long& text) | 95 | void sizes(unsigned long& file, unsigned long& text) |
87 | { | 96 | { |
88 | codec->sizes(file, text); | 97 | codec->sizes(file, text); |
89 | //qDebug("Codec sizes:(%u, %u)", file, text); | 98 | //qDebug("Codec sizes:(%u, %u)", file, text); |
90 | } | 99 | } |
91 | CList<Bkmk>* getbkmklist() { return codec->getbkmklist(); } | 100 | CList<Bkmk>* getbkmklist() { return codec->getbkmklist(); } |
92 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) { codec->getch(ch, sty, pos); } | 101 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) { codec->getch(ch, sty, pos); } |
93 | int getch() { return codec->getch(); } | 102 | int getch() { return codec->getch(); } |
94 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) { return codec->hyperlink(n, noff, wrd, nm); } | 103 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) { return codec->hyperlink(n, noff, wrd, nm); } |
95 | MarkupType PreferredMarkup() { return codec->PreferredMarkup(); } | 104 | MarkupType PreferredMarkup() { return codec->PreferredMarkup(); } |
96 | void saveposn(size_t posn) { codec->saveposn(posn); } | 105 | void saveposn(size_t posn) { codec->saveposn(posn); } |
97 | void writeposn(size_t posn) { codec->writeposn(posn); } | 106 | void writeposn(size_t posn) { codec->writeposn(posn); } |
98 | linkType forward(size_t& loc) { return codec->forward(loc); } | 107 | linkType forward(size_t& loc) { return codec->forward(loc); } |
99 | linkType back(size_t& loc) { return codec->back(loc); } | 108 | linkType back(size_t& loc) { return codec->back(loc); } |
100 | bool hasnavigation() { return codec->hasnavigation(); } | 109 | bool hasnavigation() { return codec->hasnavigation(); } |
101 | void start2endSection() { codec->start2endSection(); } | 110 | void start2endSection() { codec->start2endSection(); } |
102 | QImage* getPicture(unsigned long tgt) { return codec->getPicture(tgt); } | 111 | QImage* getPicture(unsigned long tgt) { return codec->getPicture(tgt); } |
103 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) { return codec->setSaveData(data, len, src, srclen); } | 112 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) { return codec->setSaveData(data, len, src, srclen); } |
104 | void putSaveData(unsigned char*& src, unsigned short& srclen) { codec->putSaveData(src, srclen); } | 113 | void putSaveData(unsigned char*& src, unsigned short& srclen) { codec->putSaveData(src, srclen); } |
105 | void setContinuous(bool _b) { codec->setContinuous(_b); } | 114 | void setContinuous(bool _b) { codec->setContinuous(_b); } |
106 | void setwidth(int w) { codec->setwidth(w); } | 115 | void setwidth(int w) { codec->setwidth(w); } |
107 | unsigned long startSection() { return codec->startSection(); } | 116 | unsigned long startSection() { return codec->startSection(); } |
108 | unsigned long endSection() { return codec->endSection(); } | 117 | unsigned long endSection() { return codec->endSection(); } |
109 | int openfile(const char *src) | 118 | int openfile(const char *src) |
110 | { | 119 | { |
111 | //qDebug("ebook openfile:%s", src); | 120 | //qDebug("ebook openfile:%s", src); |
112 | return (status != 0) ? status : codec->openfile(src); | 121 | return (status != 0) ? status : codec->openfile(src); |
113 | } | 122 | } |
114 | int getwidth() { return codec->getwidth(); } | 123 | int getwidth() { return codec->getwidth(); } |
115 | QImage* getPicture(const QString& href) { return codec->getPicture(href); } | 124 | QImage* getPicture(const QString& href) { return codec->getPicture(href); } |
116 | bool getFile(const QString& href) { return codec->getFile(href); } | 125 | bool getFile(const QString& href, const QString& nm) { return codec->getFile(href, nm); } |
126 | bool findanchor(const QString& nm) | ||
127 | { | ||
128 | return codec->findanchor(nm); | ||
129 | } | ||
117 | }; | 130 | }; |
118 | #endif | 131 | #endif |
diff --git a/noncore/apps/opie-reader/fileBrowser.cpp b/noncore/apps/opie-reader/fileBrowser.cpp index 2291c85..c8c371a 100644 --- a/noncore/apps/opie-reader/fileBrowser.cpp +++ b/noncore/apps/opie-reader/fileBrowser.cpp | |||
@@ -1,288 +1,288 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | 2 | ||
3 | Derived from a file browser which was | 3 | Derived from a file browser which was |
4 | 4 | ||
5 | ** copyright 2001 ljp ljp@llornkcor.com | 5 | ** copyright 2001 ljp ljp@llornkcor.com |
6 | 6 | ||
7 | Extensive modification by Tim Wentford to allow it to work in rotated mode | 7 | Extensive modification by Tim Wentford to allow it to work in rotated mode |
8 | 8 | ||
9 | ****************************************************************************/ | 9 | ****************************************************************************/ |
10 | #include "fileBrowser.h" | 10 | #include "fileBrowser.h" |
11 | 11 | ||
12 | #include "QtrListView.h" | 12 | #include "QtrListView.h" |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
15 | #include <qfile.h> | 15 | #include <qfile.h> |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #ifndef _WINDOWS | 17 | #ifndef _WINDOWS |
18 | #include <unistd.h> | 18 | #include <unistd.h> |
19 | #endif | 19 | #endif |
20 | #include <qlayout.h> | 20 | #include <qlayout.h> |
21 | #ifdef _WINDOWS | 21 | #ifdef _WINDOWS |
22 | #include <direct.h> | 22 | #include <direct.h> |
23 | #endif | 23 | #endif |
24 | 24 | ||
25 | fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) | 25 | fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) |
26 | : QDialog( parent, name, true, | 26 | : QDialog( parent, name, true, |
27 | fl/* | WStyle_Customize | WStyle_Tool*/), | 27 | fl/* | WStyle_Customize | WStyle_Tool*/), |
28 | filterspec(QDir::All) | 28 | filterspec(QDir::All) |
29 | { | 29 | { |
30 | // showMaximized(); | 30 | // showMaximized(); |
31 | if ( !name ) | 31 | if ( !name ) |
32 | setName( "fileBrowser" ); | 32 | setName( "fileBrowser" ); |
33 | setCaption(tr( "Browse for file" ) ); | 33 | setCaption(tr( "Browse for file" ) ); |
34 | filterStr=filter; | 34 | filterStr=filter; |
35 | 35 | ||
36 | buttonOk = new QPushButton( this, "buttonOk" ); | 36 | buttonOk = new QPushButton( this, "buttonOk" ); |
37 | // buttonOk->setFixedSize( 25, 25 ); | 37 | // buttonOk->setFixedSize( 25, 25 ); |
38 | buttonOk->setAutoDefault( false ); | 38 | buttonOk->setAutoDefault( false ); |
39 | buttonOk->setText( tr( "/" ) ); | 39 | buttonOk->setText( tr( "/" ) ); |
40 | 40 | ||
41 | buttonShowHidden = new QPushButton( this, "buttonShowHidden" ); | 41 | buttonShowHidden = new QPushButton( this, "buttonShowHidden" ); |
42 | // buttonShowHidden->setFixedSize( 50, 25 ); | 42 | // buttonShowHidden->setFixedSize( 50, 25 ); |
43 | buttonShowHidden->setText( tr( "Hidden" ) ); | 43 | buttonShowHidden->setText( tr( "Hidden" ) ); |
44 | buttonShowHidden->setAutoDefault( false ); | 44 | buttonShowHidden->setAutoDefault( false ); |
45 | buttonShowHidden->setToggleButton( true ); | 45 | buttonShowHidden->setToggleButton( true ); |
46 | buttonShowHidden->setOn( false ); | 46 | buttonShowHidden->setOn( false ); |
47 | 47 | ||
48 | dirLabel = new QLabel(this, "DirLabel"); | 48 | dirLabel = new QLabel(this, "DirLabel"); |
49 | dirLabel->setAlignment(AlignLeft | AlignVCenter | ExpandTabs | WordBreak); | 49 | dirLabel->setAlignment(AlignLeft | AlignVCenter | ExpandTabs | WordBreak); |
50 | dirLabel->setText(currentDir.canonicalPath()); | 50 | dirLabel->setText(currentDir.canonicalPath()); |
51 | 51 | ||
52 | ListView = new QtrListView( this, "ListView" ); | 52 | ListView = new QtrListView( this, "ListView" ); |
53 | ListView->addColumn( tr( "Name" ) ); | 53 | ListView->addColumn( tr( "Name" ) ); |
54 | ListView->setSorting( 2, FALSE); | 54 | ListView->setSorting( 2, FALSE); |
55 | ListView->addColumn( tr( "Size" ) ); | 55 | ListView->addColumn( tr( "Size" ) ); |
56 | ListView->setSelectionMode(QListView::Single); | 56 | ListView->setSelectionMode(QListView::Single); |
57 | ListView->setAllColumnsShowFocus( TRUE ); | 57 | ListView->setAllColumnsShowFocus( TRUE ); |
58 | ListView->setColumnWidthMode(0, QListView::Manual); | 58 | ListView->setColumnWidthMode(0, ((modal) ? QListView::Manual : QListView::Maximum)); |
59 | ListView->setColumnWidthMode(1, QListView::Manual); | 59 | ListView->setColumnWidthMode(1, QListView::Manual); |
60 | 60 | ||
61 | // signals and slots connections | 61 | // signals and slots connections |
62 | connect( buttonShowHidden, SIGNAL( toggled(bool) ), this, SLOT( setHidden(bool) ) ); | 62 | connect( buttonShowHidden, SIGNAL( toggled(bool) ), this, SLOT( setHidden(bool) ) ); |
63 | connect( buttonOk, SIGNAL( clicked() ), this, SLOT( OnRoot() ) ); | 63 | connect( buttonOk, SIGNAL( clicked() ), this, SLOT( OnRoot() ) ); |
64 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); | 64 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); |
65 | connect( ListView, SIGNAL(clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 65 | connect( ListView, SIGNAL(clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
66 | connect( ListView, SIGNAL(OnOKButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 66 | connect( ListView, SIGNAL(OnOKButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
67 | connect( ListView, SIGNAL(OnCentreButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 67 | connect( ListView, SIGNAL(OnCentreButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
68 | connect( ListView, SIGNAL(OnCancelButton()), SLOT(OnCancel()) ); | 68 | connect( ListView, SIGNAL(OnCancelButton()), SLOT(OnCancel()) ); |
69 | 69 | ||
70 | QVBoxLayout* grid = new QVBoxLayout(this); | 70 | QVBoxLayout* grid = new QVBoxLayout(this); |
71 | grid->addWidget(dirLabel); | 71 | grid->addWidget(dirLabel); |
72 | QHBoxLayout* hgrid = new QHBoxLayout(grid); | 72 | QHBoxLayout* hgrid = new QHBoxLayout(grid); |
73 | 73 | ||
74 | QPushButton* bt = new QPushButton( this ); | 74 | QPushButton* bt = new QPushButton( this ); |
75 | bt->setText( tr( "SD" ) ); | 75 | bt->setText( tr( "SD" ) ); |
76 | connect( bt, SIGNAL( clicked() ), this, SLOT( onSD() ) ); | 76 | connect( bt, SIGNAL( clicked() ), this, SLOT( onSD() ) ); |
77 | hgrid->addWidget(bt); | 77 | hgrid->addWidget(bt); |
78 | 78 | ||
79 | bt = new QPushButton( this ); | 79 | bt = new QPushButton( this ); |
80 | bt->setText( tr( "CF" ) ); | 80 | bt->setText( tr( "CF" ) ); |
81 | connect( bt, SIGNAL( clicked() ), this, SLOT( onCF() ) ); | 81 | connect( bt, SIGNAL( clicked() ), this, SLOT( onCF() ) ); |
82 | hgrid->addWidget(bt); | 82 | hgrid->addWidget(bt); |
83 | 83 | ||
84 | bt = new QPushButton( this ); | 84 | bt = new QPushButton( this ); |
85 | bt->setText( tr( "Home" ) ); | 85 | bt->setText( tr( "Home" ) ); |
86 | connect( bt, SIGNAL( clicked() ), this, SLOT( onHome() ) ); | 86 | connect( bt, SIGNAL( clicked() ), this, SLOT( onHome() ) ); |
87 | hgrid->addWidget(bt); | 87 | hgrid->addWidget(bt); |
88 | 88 | ||
89 | hgrid->addWidget(buttonOk); | 89 | hgrid->addWidget(buttonOk); |
90 | hgrid->addWidget(buttonShowHidden); | 90 | hgrid->addWidget(buttonShowHidden); |
91 | grid->addWidget(ListView,1); | 91 | grid->addWidget(ListView,1); |
92 | if (allownew) | 92 | if (allownew) |
93 | { | 93 | { |
94 | m_filename = new QLineEdit(this); | 94 | m_filename = new QLineEdit(this); |
95 | grid->addWidget(m_filename); | 95 | grid->addWidget(m_filename); |
96 | connect( m_filename, SIGNAL( returnPressed() ), this, SLOT( onReturn() )); | 96 | connect( m_filename, SIGNAL( returnPressed() ), this, SLOT( onReturn() )); |
97 | } | 97 | } |
98 | else | 98 | else |
99 | { | 99 | { |
100 | m_filename = NULL; | 100 | m_filename = NULL; |
101 | } | 101 | } |
102 | 102 | ||
103 | if (QFileInfo(iPath).exists()) | 103 | if (QFileInfo(iPath).exists()) |
104 | { | 104 | { |
105 | currentDir.setPath(iPath); | 105 | currentDir.setPath(iPath); |
106 | #ifdef _WINDOWS | 106 | #ifdef _WINDOWS |
107 | _chdir(iPath.latin1()); | 107 | _chdir(iPath.latin1()); |
108 | #else | 108 | #else |
109 | chdir(iPath.latin1()); | 109 | chdir(iPath.latin1()); |
110 | #endif | 110 | #endif |
111 | } | 111 | } |
112 | else | 112 | else |
113 | { | 113 | { |
114 | currentDir.setPath(QDir::currentDirPath()); | 114 | currentDir.setPath(QDir::currentDirPath()); |
115 | chdir(QDir::currentDirPath().latin1()); | 115 | chdir(QDir::currentDirPath().latin1()); |
116 | } | 116 | } |
117 | 117 | ||
118 | populateList(); | 118 | populateList(); |
119 | 119 | ||
120 | if (modal) showMaximized(); | 120 | if (modal) showMaximized(); |
121 | } | 121 | } |
122 | 122 | ||
123 | void fileBrowser::resizeEvent(QResizeEvent* e) | 123 | void fileBrowser::resizeEvent(QResizeEvent* e) |
124 | { | 124 | { |
125 | ListView->setColumnWidth(1,(ListView->width())/4); | 125 | ListView->setColumnWidth(1,(ListView->width())/4); |
126 | ListView->setColumnWidth(0,ListView->width()-20-ListView->columnWidth(1)); | 126 | ListView->setColumnWidth(0,ListView->width()-20-ListView->columnWidth(1)); |
127 | } | 127 | } |
128 | 128 | ||
129 | fileBrowser::~fileBrowser() | 129 | fileBrowser::~fileBrowser() |
130 | { | 130 | { |
131 | } | 131 | } |
132 | 132 | ||
133 | 133 | ||
134 | void fileBrowser::populateList() | 134 | void fileBrowser::populateList() |
135 | { | 135 | { |
136 | ListView->clear(); | 136 | ListView->clear(); |
137 | ////qDebug(currentDir.canonicalPath()); | 137 | ////qDebug(currentDir.canonicalPath()); |
138 | // currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); | 138 | // currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); |
139 | currentDir.setFilter( filterspec ); | 139 | currentDir.setFilter( filterspec ); |
140 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 140 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
141 | currentDir.setMatchAllDirs(TRUE); | 141 | currentDir.setMatchAllDirs(TRUE); |
142 | 142 | ||
143 | currentDir.setNameFilter(filterStr); | 143 | currentDir.setNameFilter(filterStr); |
144 | // currentDir.setNameFilter("*.txt;*.etx"); | 144 | // currentDir.setNameFilter("*.txt;*.etx"); |
145 | QString fileL, fileS; | 145 | QString fileL, fileS; |
146 | const QFileInfoList *list = currentDir.entryInfoList(); | 146 | const QFileInfoList *list = currentDir.entryInfoList(); |
147 | QFileInfoListIterator it(*list); | 147 | QFileInfoListIterator it(*list); |
148 | QFileInfo *fi; | 148 | QFileInfo *fi; |
149 | while ( (fi=it.current()) ) | 149 | while ( (fi=it.current()) ) |
150 | { | 150 | { |
151 | if (fi->fileName() != ".") | 151 | if (fi->fileName() != ".") |
152 | { | 152 | { |
153 | fileS.sprintf( "%10li", fi->size() ); | 153 | fileS.sprintf( "%10li", fi->size() ); |
154 | fileL.sprintf( "%s",fi->fileName().data() ); | 154 | fileL.sprintf( "%s",fi->fileName().data() ); |
155 | if( fi->isDir() ) | 155 | if( fi->isDir() ) |
156 | { | 156 | { |
157 | fileL+="/"; | 157 | fileL+="/"; |
158 | } | 158 | } |
159 | else | 159 | else |
160 | { | 160 | { |
161 | //// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 161 | //// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
162 | } | 162 | } |
163 | new QListViewItem( ListView,fileL,fileS ); | 163 | new QListViewItem( ListView,fileL,fileS ); |
164 | } | 164 | } |
165 | ++it; | 165 | ++it; |
166 | } | 166 | } |
167 | ListView->setSorting( 2, FALSE); | 167 | ListView->setSorting( 2, FALSE); |
168 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); | 168 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); |
169 | ListView->setFocus(); | 169 | ListView->setFocus(); |
170 | } | 170 | } |
171 | 171 | ||
172 | void fileBrowser::upDir() | 172 | void fileBrowser::upDir() |
173 | { | 173 | { |
174 | //// qDebug(currentDir.canonicalPath()); | 174 | //// qDebug(currentDir.canonicalPath()); |
175 | } | 175 | } |
176 | 176 | ||
177 | void fileBrowser::listClicked(QListViewItem *selectedItem) | 177 | void fileBrowser::listClicked(QListViewItem *selectedItem) |
178 | { | 178 | { |
179 | if (selectedItem == NULL) return; | 179 | if (selectedItem == NULL) return; |
180 | QString strItem=selectedItem->text(0); | 180 | QString strItem=selectedItem->text(0); |
181 | 181 | ||
182 | //// qDebug("%s", (const char*)strItem); | 182 | //// qDebug("%s", (const char*)strItem); |
183 | 183 | ||
184 | 184 | ||
185 | QString strSize=selectedItem->text(1); | 185 | QString strSize=selectedItem->text(1); |
186 | 186 | ||
187 | strSize.stripWhiteSpace(); | 187 | strSize.stripWhiteSpace(); |
188 | 188 | ||
189 | bool ok; | 189 | bool ok; |
190 | 190 | ||
191 | QFileInfo fi(strItem); | 191 | QFileInfo fi(strItem); |
192 | while (fi.isSymLink()) fi.setFile(fi.readLink()); | 192 | while (fi.isSymLink()) fi.setFile(fi.readLink()); |
193 | if (fi.isDir()) | 193 | if (fi.isDir()) |
194 | { | 194 | { |
195 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 195 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
196 | 196 | ||
197 | if(QDir(strItem).exists()) | 197 | if(QDir(strItem).exists()) |
198 | { | 198 | { |
199 | currentDir.cd(strItem, TRUE); | 199 | currentDir.cd(strItem, TRUE); |
200 | populateList(); | 200 | populateList(); |
201 | } | 201 | } |
202 | } else | 202 | } else |
203 | { | 203 | { |
204 | QListViewItem *selectedItem = ListView->selectedItem(); | 204 | QListViewItem *selectedItem = ListView->selectedItem(); |
205 | if (selectedItem == NULL) | 205 | if (selectedItem == NULL) |
206 | { | 206 | { |
207 | filename = ""; | 207 | filename = ""; |
208 | } | 208 | } |
209 | else | 209 | else |
210 | { | 210 | { |
211 | filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+selectedItem->text(0)); | 211 | filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+selectedItem->text(0)); |
212 | } | 212 | } |
213 | OnOK(); | 213 | OnOK(); |
214 | } | 214 | } |
215 | chdir(strItem.latin1()); | 215 | chdir(strItem.latin1()); |
216 | // | 216 | // |
217 | 217 | ||
218 | } | 218 | } |
219 | 219 | ||
220 | // you may want to switch these 2 functions. I like single clicks | 220 | // you may want to switch these 2 functions. I like single clicks |
221 | void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) | 221 | void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) |
222 | { | 222 | { |
223 | } | 223 | } |
224 | 224 | ||
225 | QString fileBrowser::getCurrentFile() | 225 | QString fileBrowser::getCurrentFile() |
226 | { | 226 | { |
227 | return filename; | 227 | return filename; |
228 | } | 228 | } |
229 | 229 | ||
230 | void fileBrowser::OnOK() | 230 | void fileBrowser::OnOK() |
231 | { | 231 | { |
232 | accept(); | 232 | accept(); |
233 | } | 233 | } |
234 | 234 | ||
235 | void fileBrowser::OnRoot() | 235 | void fileBrowser::OnRoot() |
236 | { | 236 | { |
237 | setdir("/"); | 237 | setdir("/"); |
238 | } | 238 | } |
239 | 239 | ||
240 | void fileBrowser::OnCancel() | 240 | void fileBrowser::OnCancel() |
241 | { | 241 | { |
242 | reject(); | 242 | reject(); |
243 | } | 243 | } |
244 | 244 | ||
245 | void fileBrowser::setHidden(bool _hidden) | 245 | void fileBrowser::setHidden(bool _hidden) |
246 | { | 246 | { |
247 | if (_hidden) | 247 | if (_hidden) |
248 | filterspec = QDir::All | QDir::Hidden; | 248 | filterspec = QDir::All | QDir::Hidden; |
249 | else | 249 | else |
250 | filterspec = QDir::All; | 250 | filterspec = QDir::All; |
251 | populateList(); | 251 | populateList(); |
252 | } | 252 | } |
253 | 253 | ||
254 | void fileBrowser::onReturn() | 254 | void fileBrowser::onReturn() |
255 | { | 255 | { |
256 | QListViewItem *selectedItem = ListView->selectedItem(); | 256 | QListViewItem *selectedItem = ListView->selectedItem(); |
257 | if (selectedItem == NULL) | 257 | if (selectedItem == NULL) |
258 | { | 258 | { |
259 | filename = m_filename->text(); | 259 | filename = m_filename->text(); |
260 | } | 260 | } |
261 | else | 261 | else |
262 | { | 262 | { |
263 | filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+m_filename->text()); | 263 | filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+m_filename->text()); |
264 | } | 264 | } |
265 | OnOK(); | 265 | OnOK(); |
266 | } | 266 | } |
267 | 267 | ||
268 | void fileBrowser::onCF() | 268 | void fileBrowser::onCF() |
269 | { | 269 | { |
270 | setdir("/mnt/cf"); | 270 | setdir("/mnt/cf"); |
271 | } | 271 | } |
272 | 272 | ||
273 | void fileBrowser::onSD() | 273 | void fileBrowser::onSD() |
274 | { | 274 | { |
275 | setdir("/mnt/card"); | 275 | setdir("/mnt/card"); |
276 | } | 276 | } |
277 | 277 | ||
278 | void fileBrowser::onHome() | 278 | void fileBrowser::onHome() |
279 | { | 279 | { |
280 | setdir(QDir::homeDirPath()); | 280 | setdir(QDir::homeDirPath()); |
281 | } | 281 | } |
282 | 282 | ||
283 | void fileBrowser::setdir(const QString& s) | 283 | void fileBrowser::setdir(const QString& s) |
284 | { | 284 | { |
285 | currentDir.cd(s, TRUE); | 285 | currentDir.cd(s, TRUE); |
286 | populateList(); | 286 | populateList(); |
287 | chdir(s); | 287 | chdir(s); |
288 | } | 288 | } |
diff --git a/noncore/apps/opie-reader/flitecmd.cpp b/noncore/apps/opie-reader/flitecmd.cpp new file mode 100644 index 0000000..bb7e303 --- a/dev/null +++ b/noncore/apps/opie-reader/flitecmd.cpp | |||
@@ -0,0 +1,43 @@ | |||
1 | #include <unistd.h> | ||
2 | #include <sys/types.h> | ||
3 | #include <sys/wait.h> | ||
4 | #include <errno.h> | ||
5 | #include "flitecmd.h" | ||
6 | |||
7 | void CFliteCmd::output(const QString& txt) | ||
8 | { | ||
9 | pid_t pid; | ||
10 | if ((pid = fork()) <0) | ||
11 | { | ||
12 | qDebug("No memory"); | ||
13 | } | ||
14 | else if (pid == 0) | ||
15 | { | ||
16 | execlp("flite", "flite", "-t", (const char*)txt, NULL); | ||
17 | _exit(127); | ||
18 | qDebug("Can't find flite"); | ||
19 | } | ||
20 | else | ||
21 | { | ||
22 | int status; | ||
23 | while (waitpid(pid, &status, 0) < 0) | ||
24 | { | ||
25 | if (errno != EINTR) | ||
26 | { | ||
27 | qDebug("Error from flite"); | ||
28 | break; | ||
29 | } | ||
30 | } | ||
31 | qDebug("flite status:%d", status); | ||
32 | } | ||
33 | } | ||
34 | |||
35 | QString CFliteCmd::about() | ||
36 | { | ||
37 | return QString("FliteCmd output codec (c) Tim Wentford\n"); | ||
38 | } | ||
39 | |||
40 | extern "C" | ||
41 | { | ||
42 | COutput* newcodec() { return new CFliteCmd; } | ||
43 | } | ||
diff --git a/noncore/apps/opie-reader/flitecmd.h b/noncore/apps/opie-reader/flitecmd.h new file mode 100644 index 0000000..10f9710 --- a/dev/null +++ b/noncore/apps/opie-reader/flitecmd.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #include "outputcodec.h" | ||
2 | |||
3 | class CFliteCmd : public COutput | ||
4 | { | ||
5 | public: | ||
6 | CFliteCmd() {} | ||
7 | ~CFliteCmd() {} | ||
8 | QString about(); | ||
9 | void output(const QString& _o); | ||
10 | }; | ||
diff --git a/noncore/apps/opie-reader/flitedyn.cpp b/noncore/apps/opie-reader/flitedyn.cpp new file mode 100644 index 0000000..c268cd4 --- a/dev/null +++ b/noncore/apps/opie-reader/flitedyn.cpp | |||
@@ -0,0 +1,29 @@ | |||
1 | #include "flitedyn.h" | ||
2 | |||
3 | cst_voice *CFliteDyn::m_voice = NULL; | ||
4 | |||
5 | CFliteDyn::CFliteDyn() | ||
6 | { | ||
7 | if (m_voice == NULL) | ||
8 | { | ||
9 | qDebug("Constucting flite"); | ||
10 | flite_init(); | ||
11 | m_voice = register_cmu_us_kal(); | ||
12 | } | ||
13 | } | ||
14 | |||
15 | QString CFliteDyn::about() | ||
16 | { | ||
17 | return QString("FliteDyn output codec (c) Tim Wentford\n"); | ||
18 | } | ||
19 | |||
20 | void CFliteDyn::output(const QString& _o) | ||
21 | { | ||
22 | float tm = flite_text_to_speech((const char*)_o, m_voice, "play"); | ||
23 | qDebug("Produced %g seconds of speech", tm); | ||
24 | } | ||
25 | |||
26 | extern "C" | ||
27 | { | ||
28 | COutput* newcodec() { return new CFliteDyn; } | ||
29 | } | ||
diff --git a/noncore/apps/opie-reader/flitedyn.h b/noncore/apps/opie-reader/flitedyn.h new file mode 100644 index 0000000..4455048 --- a/dev/null +++ b/noncore/apps/opie-reader/flitedyn.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #include "outputcodec.h" | ||
2 | extern "C" | ||
3 | { | ||
4 | #include <flite.h> | ||
5 | cst_voice *register_cmu_us_kal(); | ||
6 | } | ||
7 | |||
8 | class CFliteDyn : public COutput | ||
9 | { | ||
10 | static cst_voice *m_voice; | ||
11 | public: | ||
12 | CFliteDyn(); | ||
13 | ~CFliteDyn() {} | ||
14 | QString about(); | ||
15 | void output(const QString& _o); | ||
16 | }; | ||
diff --git a/noncore/apps/opie-reader/iSilo.cpp b/noncore/apps/opie-reader/iSilo.cpp index 5f14b96..1f727fe 100644 --- a/noncore/apps/opie-reader/iSilo.cpp +++ b/noncore/apps/opie-reader/iSilo.cpp | |||
@@ -1,638 +1,639 @@ | |||
1 | #include "iSilo.h" | 1 | #include "iSilo.h" |
2 | #ifdef _WINDOWS | 2 | #ifdef _WINDOWS |
3 | #include <winsock.h> | 3 | #include <winsock.h> |
4 | #endif | 4 | #endif |
5 | u_int8_t *rodata = (u_int8_t *) | 5 | u_int8_t *rodata = (u_int8_t *) |
6 | "\x10\x11\x12\x00\x08\x07\x09\x06\x0a\x05\x0b\x04\x0c\x03\x0d\x02\x0e\x01\x0f"; | 6 | "\x10\x11\x12\x00\x08\x07\x09\x06\x0a\x05\x0b\x04\x0c\x03\x0d\x02\x0e\x01\x0f"; |
7 | 7 | ||
8 | u_int16_t *rsize_min = (u_int16_t *) | 8 | u_int16_t *rsize_min = (u_int16_t *) |
9 | "\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0d" | 9 | "\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0d" |
10 | "\x00\x0f\x00\x11\x00\x13\x00\x17\x00\x1b\x00\x1f\x00\x23\x00\x2b\x00\x33\x00" | 10 | "\x00\x0f\x00\x11\x00\x13\x00\x17\x00\x1b\x00\x1f\x00\x23\x00\x2b\x00\x33\x00" |
11 | "\x3b\x00\x43\x00\x53\x00\x63\x00\x73\x00\x83\x00\xa3\x00\xc3\x00\xe3\x00\x02" | 11 | "\x3b\x00\x43\x00\x53\x00\x63\x00\x73\x00\x83\x00\xa3\x00\xc3\x00\xe3\x00\x02" |
12 | "\x01"; | 12 | "\x01"; |
13 | 13 | ||
14 | u_int8_t *rsize_delta = (u_int8_t *) | 14 | u_int8_t *rsize_delta = (u_int8_t *) |
15 | "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x01\x01\x02\x02\x02\x02\x03\x03\x03" | 15 | "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x01\x01\x02\x02\x02\x02\x03\x03\x03" |
16 | "\x03\x04\x04\x04\x04\x05\x05\x05\x05\x00"; | 16 | "\x03\x04\x04\x04\x04\x05\x05\x05\x05\x00"; |
17 | 17 | ||
18 | u_int16_t *rpos_min = (u_int16_t *) | 18 | u_int16_t *rpos_min = (u_int16_t *) |
19 | "\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x07\x00\x09\x00\x0d\x00\x11\x00\x19" | 19 | "\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x07\x00\x09\x00\x0d\x00\x11\x00\x19" |
20 | "\x00\x21\x00\x31\x00\x41\x00\x61\x00\x81\x00\xc1\x00\x01\x01\x81\x01\x01\x02" | 20 | "\x00\x21\x00\x31\x00\x41\x00\x61\x00\x81\x00\xc1\x00\x01\x01\x81\x01\x01\x02" |
21 | "\x01\x03\x01\x04\x01\x06\x01\x08\x01\x0c\x01\x10\x01\x18\x01\x20\x01\x30\x01" | 21 | "\x01\x03\x01\x04\x01\x06\x01\x08\x01\x0c\x01\x10\x01\x18\x01\x20\x01\x30\x01" |
22 | "\x40\x01\x60"; | 22 | "\x40\x01\x60"; |
23 | 23 | ||
24 | u_int8_t *rpos_delta = (u_int8_t *) | 24 | u_int8_t *rpos_delta = (u_int8_t *) |
25 | "\x00\x00\x00\x00\x01\x01\x02\x02\x03\x03\x04\x04\x05\x05\x06\x06\x07\x07" | 25 | "\x00\x00\x00\x00\x01\x01\x02\x02\x03\x03\x04\x04\x05\x05\x06\x06\x07\x07" |
26 | "\x08\x08\x09\x09\x0a\x0a\x0b\x0b\x0c\x0c\x0d\x0d"; | 26 | "\x08\x08\x09\x09\x0a\x0a\x0b\x0b\x0c\x0c\x0d\x0d"; |
27 | 27 | ||
28 | void iSilo::init_tables(void) | 28 | void iSilo::init_tables(void) |
29 | { | 29 | { |
30 | int i; | 30 | int i; |
31 | u_int16_t j; | 31 | u_int16_t j; |
32 | return; | 32 | return; |
33 | for (i = 0; i < 3; i++) | 33 | for (i = 0; i < 3; i++) |
34 | rodata[i] = 0x10 + i; | 34 | rodata[i] = 0x10 + i; |
35 | rodata[3] = 0; | 35 | rodata[3] = 0; |
36 | for (i = 4; i < 19; i = i + 2) | 36 | for (i = 4; i < 19; i = i + 2) |
37 | rodata[i] = 8 + (i-4)/2; | 37 | rodata[i] = 8 + (i-4)/2; |
38 | for (i = 5; i < 19; i = i + 2) | 38 | for (i = 5; i < 19; i = i + 2) |
39 | rodata[i] = 7 - (i-5)/2; | 39 | rodata[i] = 7 - (i-5)/2; |
40 | 40 | ||
41 | memset(rsize_delta, 0, 29); | 41 | memset(rsize_delta, 0, 29); |
42 | for (i = 4; i < 29; i++) { | 42 | for (i = 4; i < 29; i++) { |
43 | rsize_delta[i] = (i - 4) >> 2; | 43 | rsize_delta[i] = (i - 4) >> 2; |
44 | } | 44 | } |
45 | memset(rpos_delta, 0, 30); | 45 | memset(rpos_delta, 0, 30); |
46 | for (i = 2; i < 30; i++) { | 46 | for (i = 2; i < 30; i++) { |
47 | rpos_delta[i] = (i - 2) >> 1; | 47 | rpos_delta[i] = (i - 2) >> 1; |
48 | } | 48 | } |
49 | j = 3; | 49 | j = 3; |
50 | for (i = 0; i < 29; i++) { | 50 | for (i = 0; i < 29; i++) { |
51 | rsize_min[i] = j; | 51 | rsize_min[i] = j; |
52 | j += 1 << rsize_delta[i]; | 52 | j += 1 << rsize_delta[i]; |
53 | } | 53 | } |
54 | j = 1; | 54 | j = 1; |
55 | for (i = 0; i < 30; i++) { | 55 | for (i = 0; i < 30; i++) { |
56 | rpos_min[i] = j; | 56 | rpos_min[i] = j; |
57 | j += 1 << rpos_delta[i]; | 57 | j += 1 << rpos_delta[i]; |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | /* read num bits from the file descriptor */ | 61 | /* read num bits from the file descriptor */ |
62 | 62 | ||
63 | int iSilo::code2tree(struct s_huffman *h) { | 63 | int iSilo::code2tree(struct s_huffman *h) { |
64 | struct s_tree *t, *tmp; | 64 | struct s_tree *t, *tmp; |
65 | u_int32_t i; | 65 | u_int32_t i; |
66 | int j, b; | 66 | int j, b; |
67 | 67 | ||
68 | t = new s_tree(); | 68 | t = new s_tree(); |
69 | h->tree = t; | 69 | h->tree = t; |
70 | if (t == NULL) return -1; | 70 | if (t == NULL) return -1; |
71 | memset(t, 0, sizeof(struct s_tree)); | 71 | memset(t, 0, sizeof(struct s_tree)); |
72 | t->value = (u_int32_t)-1; | 72 | t->value = (u_int32_t)-1; |
73 | for (i = 0; i < h->num; i++) { | 73 | for (i = 0; i < h->num; i++) { |
74 | tmp = t; | 74 | tmp = t; |
75 | for (j = 0; j < h->size[i]; j++) { | 75 | for (j = 0; j < h->size[i]; j++) { |
76 | b = (h->code[i] >> j) & 1; | 76 | b = (h->code[i] >> j) & 1; |
77 | if (tmp->branch[b] == NULL) { | 77 | if (tmp->branch[b] == NULL) { |
78 | tmp->branch[b] =new s_tree(); | 78 | tmp->branch[b] =new s_tree(); |
79 | if (tmp->branch[b] == NULL) return(-1); | 79 | if (tmp->branch[b] == NULL) return(-1); |
80 | memset(tmp->branch[b], 0, sizeof(struct s_tree)); | 80 | memset(tmp->branch[b], 0, sizeof(struct s_tree)); |
81 | tmp->value = (u_int32_t)-1; | 81 | tmp->value = (u_int32_t)-1; |
82 | } | 82 | } |
83 | tmp = tmp->branch[b]; | 83 | tmp = tmp->branch[b]; |
84 | } | 84 | } |
85 | if (h->size[i] > 0) tmp->value = i; | 85 | if (h->size[i] > 0) tmp->value = i; |
86 | } | 86 | } |
87 | return (0); | 87 | return (0); |
88 | } | 88 | } |
89 | 89 | ||
90 | u_int32_t iSilo::swap_bits(u_int32_t n, int num) { | 90 | u_int32_t iSilo::swap_bits(u_int32_t n, int num) { |
91 | n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xaaaaaaaa); | 91 | n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xaaaaaaaa); |
92 | n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xcccccccc); | 92 | n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xcccccccc); |
93 | n = ((n >> 4) & 0x0f0f0f0f) | ((n << 4) & 0xf0f0f0f0); | 93 | n = ((n >> 4) & 0x0f0f0f0f) | ((n << 4) & 0xf0f0f0f0); |
94 | n = ((n >> 8) & 0x00ff00ff) | ((n << 8) & 0xff00ff00); | 94 | n = ((n >> 8) & 0x00ff00ff) | ((n << 8) & 0xff00ff00); |
95 | n = ((n >> 16) & 0x0000ffff) | ((n << 16) & 0xffff0000); | 95 | n = ((n >> 16) & 0x0000ffff) | ((n << 16) & 0xffff0000); |
96 | n >>= (32 - num); | 96 | n >>= (32 - num); |
97 | return(n); | 97 | return(n); |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | u_int32_t *iSilo::huffman_get(struct s_huffman *h) | 101 | u_int32_t *iSilo::huffman_get(struct s_huffman *h) |
102 | { | 102 | { |
103 | int b; | 103 | int b; |
104 | struct s_tree *t = h->tree; | 104 | struct s_tree *t = h->tree; |
105 | 105 | ||
106 | while (t->value == -1) { | 106 | while (t->value == -1) { |
107 | b = get_bits(1); | 107 | b = get_bits(1); |
108 | if (t->branch[b] == NULL) { | 108 | if (t->branch[b] == NULL) { |
109 | return(NULL); | 109 | return(NULL); |
110 | } | 110 | } |
111 | t = t->branch[b]; | 111 | t = t->branch[b]; |
112 | } | 112 | } |
113 | return (&t->value); | 113 | return (&t->value); |
114 | } | 114 | } |
115 | 115 | ||
116 | int iSilo::size2code(struct s_huffman *h) { | 116 | int iSilo::size2code(struct s_huffman *h) { |
117 | u_int8_t i, sk, max = 0; | 117 | u_int8_t i, sk, max = 0; |
118 | u_int16_t sc, c; | 118 | u_int16_t sc, c; |
119 | u_int32_t j, k, l; | 119 | u_int32_t j, k, l; |
120 | int skip; | 120 | int skip; |
121 | 121 | ||
122 | for (l = 0; l < h->num; l++) { | 122 | for (l = 0; l < h->num; l++) { |
123 | if (h->size[l] > max) max = h->size[l]; | 123 | if (h->size[l] > max) max = h->size[l]; |
124 | } | 124 | } |
125 | 125 | ||
126 | for (i = 1; i <= max; i++) { | 126 | for (i = 1; i <= max; i++) { |
127 | sc = 0; | 127 | sc = 0; |
128 | c = 0; | 128 | c = 0; |
129 | for (j = 0; j < h->num; j++) { | 129 | for (j = 0; j < h->num; j++) { |
130 | if (h->size[j] == i) { | 130 | if (h->size[j] == i) { |
131 | do { | 131 | do { |
132 | skip = 0; | 132 | skip = 0; |
133 | for (k = 0; k < h->num; k++) { | 133 | for (k = 0; k < h->num; k++) { |
134 | sk = h->size[k]; | 134 | sk = h->size[k]; |
135 | 135 | ||
136 | if ((sk < i) && (sk != 0) && !((h->code[k] ^ c) & ((1 << sk)-1))) { | 136 | if ((sk < i) && (sk != 0) && !((h->code[k] ^ c) & ((1 << sk)-1))) { |
137 | if ((c + 1) == (1 << i)) { | 137 | if ((c + 1) == (1 << i)) { |
138 | return -1; | 138 | return -1; |
139 | } | 139 | } |
140 | sc += 1 << (i-sk); | 140 | sc += 1 << (i-sk); |
141 | c = swap_bits(sc, i); | 141 | c = swap_bits(sc, i); |
142 | skip = 1; | 142 | skip = 1; |
143 | break; | 143 | break; |
144 | } | 144 | } |
145 | } | 145 | } |
146 | } while (skip); | 146 | } while (skip); |
147 | h->code[j] = c; | 147 | h->code[j] = c; |
148 | sc++; | 148 | sc++; |
149 | c = swap_bits(sc, i); | 149 | c = swap_bits(sc, i); |
150 | } | 150 | } |
151 | } | 151 | } |
152 | } | 152 | } |
153 | return(0); | 153 | return(0); |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | struct s_huffman *iSilo::huffman_create(u_int32_t num) { | 157 | struct s_huffman *iSilo::huffman_create(u_int32_t num) { |
158 | struct s_huffman *h; | 158 | struct s_huffman *h; |
159 | h = new s_huffman(); | 159 | h = new s_huffman(); |
160 | h->tree = new s_tree(); | 160 | h->tree = new s_tree(); |
161 | memset(h->tree, 0, sizeof(struct s_tree)); | 161 | memset(h->tree, 0, sizeof(struct s_tree)); |
162 | h->tree->value = (u_int32_t)-1; | 162 | h->tree->value = (u_int32_t)-1; |
163 | h->num = num; | 163 | h->num = num; |
164 | h->code = new u_int16_t[num]; | 164 | h->code = new u_int16_t[num]; |
165 | h->size = new u_int8_t[num]; | 165 | h->size = new u_int8_t[num]; |
166 | memset(h->size, 0, num); | 166 | memset(h->size, 0, num); |
167 | memset(h->code, 0, num*2); | 167 | memset(h->code, 0, num*2); |
168 | return (h); | 168 | return (h); |
169 | } | 169 | } |
170 | 170 | ||
171 | void iSilo::kill_tree(struct s_tree *tree) { | 171 | void iSilo::kill_tree(struct s_tree *tree) { |
172 | if (tree == NULL) { | 172 | if (tree == NULL) { |
173 | return; | 173 | return; |
174 | } | 174 | } |
175 | kill_tree(tree->branch[0]); | 175 | kill_tree(tree->branch[0]); |
176 | kill_tree(tree->branch[1]); | 176 | kill_tree(tree->branch[1]); |
177 | delete tree; | 177 | delete tree; |
178 | } | 178 | } |
179 | 179 | ||
180 | void iSilo::kill_huffman(struct s_huffman *h) { | 180 | void iSilo::kill_huffman(struct s_huffman *h) { |
181 | if (h == NULL) { | 181 | if (h == NULL) { |
182 | return; | 182 | return; |
183 | } | 183 | } |
184 | kill_tree(h->tree); | 184 | kill_tree(h->tree); |
185 | delete h->code; | 185 | delete h->code; |
186 | delete h->size; | 186 | delete h->size; |
187 | delete h; | 187 | delete h; |
188 | } | 188 | } |
189 | 189 | ||
190 | int iSilo::read_size(struct s_huffman *prev, struct s_huffman *h) { | 190 | int iSilo::read_size(struct s_huffman *prev, struct s_huffman *h) { |
191 | u_int32_t *j; | 191 | u_int32_t *j; |
192 | u_int32_t i, n; | 192 | u_int32_t i, n; |
193 | int s_ok = 0, ls = 0; | 193 | int s_ok = 0, ls = 0; |
194 | 194 | ||
195 | for (i = 0;i < h->num;) { | 195 | for (i = 0;i < h->num;) { |
196 | j = huffman_get(prev); | 196 | j = huffman_get(prev); |
197 | if (j == NULL) | 197 | if (j == NULL) |
198 | return(-1); | 198 | return(-1); |
199 | switch(*j) { | 199 | switch(*j) { |
200 | case HM_MEDIUM: | 200 | case HM_MEDIUM: |
201 | n = get_swapped(3) + 3; /* n bytes of 0 */ | 201 | n = get_swapped(3) + 3; /* n bytes of 0 */ |
202 | memset(h->size + i, 0, n); | 202 | memset(h->size + i, 0, n); |
203 | i += n; | 203 | i += n; |
204 | break; | 204 | break; |
205 | case HM_LONG: | 205 | case HM_LONG: |
206 | n = get_swapped(7) + 11; /* n bytes of 0 */ | 206 | n = get_swapped(7) + 11; /* n bytes of 0 */ |
207 | memset(h->size + i, 0, n); | 207 | memset(h->size + i, 0, n); |
208 | i += n; | 208 | i += n; |
209 | break; | 209 | break; |
210 | case HM_SHORT: | 210 | case HM_SHORT: |
211 | if (!s_ok) { | 211 | if (!s_ok) { |
212 | return(-1); | 212 | return(-1); |
213 | } | 213 | } |
214 | n = get_swapped(2) + 3; /* n+1 bytes of ls */ | 214 | n = get_swapped(2) + 3; /* n+1 bytes of ls */ |
215 | memset(h->size + i, ls, n); | 215 | memset(h->size + i, ls, n); |
216 | i += n; | 216 | i += n; |
217 | break; | 217 | break; |
218 | default: | 218 | default: |
219 | h->size[i] = *j; | 219 | h->size[i] = *j; |
220 | ls = *j; | 220 | ls = *j; |
221 | i++; | 221 | i++; |
222 | break; | 222 | break; |
223 | } | 223 | } |
224 | if ((*j == HM_LONG) || (*j == HM_MEDIUM)) { | 224 | if ((*j == HM_LONG) || (*j == HM_MEDIUM)) { |
225 | s_ok = 0; | 225 | s_ok = 0; |
226 | } else { | 226 | } else { |
227 | s_ok = 1; | 227 | s_ok = 1; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | return(0); | 230 | return(0); |
231 | } | 231 | } |
232 | 232 | ||
233 | void iSilo::mymemcpy(u_int8_t *dst, u_int8_t *src, u_int32_t num) { | 233 | void iSilo::mymemcpy(u_int8_t *dst, u_int8_t *src, u_int32_t num) { |
234 | u_int32_t i; | 234 | u_int32_t i; |
235 | for (i = 0; i < num; i++) { | 235 | for (i = 0; i < num; i++) { |
236 | dst[i] = src[i]; | 236 | dst[i] = src[i]; |
237 | } | 237 | } |
238 | } | 238 | } |
239 | /* return size or -1 for error */ | 239 | /* return size or -1 for error */ |
240 | 240 | ||
241 | int iSilo::read_tree(struct s_huffman *prev, struct s_huffman *curr) { | 241 | int iSilo::read_tree(struct s_huffman *prev, struct s_huffman *curr) { |
242 | if (read_size(prev, curr) == -1) | 242 | if (read_size(prev, curr) == -1) |
243 | return(-1); | 243 | return(-1); |
244 | if (size2code(curr) == -1) | 244 | if (size2code(curr) == -1) |
245 | return(-1); | 245 | return(-1); |
246 | if (code2tree(curr) == -1) | 246 | if (code2tree(curr) == -1) |
247 | return(-1); | 247 | return(-1); |
248 | return(0); | 248 | return(0); |
249 | } | 249 | } |
250 | bool iSilo::reset_trees() | 250 | bool iSilo::reset_trees() |
251 | { | 251 | { |
252 | get_bits(0); /* flush buffer */ | 252 | get_bits(0); /* flush buffer */ |
253 | /* This is a Table record so we reload the tables */ | 253 | /* This is a Table record so we reload the tables */ |
254 | kill_huffman(lz); | 254 | kill_huffman(lz); |
255 | kill_huffman(text); | 255 | kill_huffman(text); |
256 | kill_huffman(master); | 256 | kill_huffman(master); |
257 | 257 | ||
258 | master = huffman_create(19); | 258 | master = huffman_create(19); |
259 | text = huffman_create(get_swapped(5) + 257); | 259 | text = huffman_create(get_swapped(5) + 257); |
260 | lz = huffman_create(get_swapped(5) + 1); | 260 | lz = huffman_create(get_swapped(5) + 1); |
261 | int rdmax = get_swapped(4) + 4; | 261 | int rdmax = get_swapped(4) + 4; |
262 | 262 | ||
263 | for (int i = 0; i < rdmax; i++) | 263 | for (int i = 0; i < rdmax; i++) |
264 | { | 264 | { |
265 | master->size[rodata[i]] = get_swapped(3); | 265 | master->size[rodata[i]] = get_swapped(3); |
266 | } | 266 | } |
267 | 267 | ||
268 | if (size2code(master) == -1) { | 268 | if (size2code(master) == -1) { |
269 | qDebug("size2code(master) error: size-table is incompatible"); | 269 | qDebug("size2code(master) error: size-table is incompatible"); |
270 | return false; | 270 | return false; |
271 | } | 271 | } |
272 | 272 | ||
273 | code2tree(master); | 273 | code2tree(master); |
274 | 274 | ||
275 | if (read_tree(master, text) == -1) { | 275 | if (read_tree(master, text) == -1) { |
276 | qDebug("read_tree() failed (format incorrect?)"); | 276 | qDebug("read_tree() failed (format incorrect?)"); |
277 | return false; | 277 | return false; |
278 | } | 278 | } |
279 | 279 | ||
280 | if (read_tree(master, lz) == -1) { | 280 | if (read_tree(master, lz) == -1) { |
281 | qDebug("read_tree() failed (format incorrect?)"); | 281 | qDebug("read_tree() failed (format incorrect?)"); |
282 | return false;; | 282 | return false;; |
283 | } | 283 | } |
284 | return true; | 284 | return true; |
285 | } | 285 | } |
286 | u_int32_t iSilo::get_bits(int num) { | 286 | u_int32_t iSilo::get_bits(int num) { |
287 | int i, r; | 287 | int i, r; |
288 | u_int32_t result = 0; | 288 | u_int32_t result = 0; |
289 | 289 | ||
290 | if (num == 0) { | 290 | if (num == 0) { |
291 | pos = 0; | 291 | pos = 0; |
292 | return(0); | 292 | return(0); |
293 | } | 293 | } |
294 | 294 | ||
295 | for (i = 0; i < num; i++) { | 295 | for (i = 0; i < num; i++) { |
296 | if (pos == 0) { | 296 | if (pos == 0) { |
297 | unsuspend(); | ||
297 | r = fread(buf, sizeof(u_int32_t), 256, fin); | 298 | r = fread(buf, sizeof(u_int32_t), 256, fin); |
298 | if (r <= 0) { | 299 | if (r <= 0) { |
299 | qDebug("ERROR: Unexpected end of file"); | 300 | qDebug("ERROR: Unexpected end of file"); |
300 | exit(-1); /* FIXME */ | 301 | exit(-1); /* FIXME */ |
301 | } | 302 | } |
302 | pos = 32*256; | 303 | pos = 32*256; |
303 | } | 304 | } |
304 | 305 | ||
305 | pos--; | 306 | pos--; |
306 | result <<= 1; | 307 | result <<= 1; |
307 | result |= (ntohl(buf[255 - (pos/32)]) >> (31-(pos % 32))) & 1; | 308 | result |= (ntohl(buf[255 - (pos/32)]) >> (31-(pos % 32))) & 1; |
308 | } | 309 | } |
309 | return(result); | 310 | return(result); |
310 | } | 311 | } |
311 | u_int32_t iSilo::get_swapped(int num) { | 312 | u_int32_t iSilo::get_swapped(int num) { |
312 | return(swap_bits(get_bits(num),num)); | 313 | return(swap_bits(get_bits(num),num)); |
313 | } | 314 | } |
314 | int iSilo::read_text() { | 315 | int iSilo::read_text() { |
315 | u_int32_t *j; | 316 | u_int32_t *j; |
316 | u_int32_t k, l, bp, idx; | 317 | u_int32_t k, l, bp, idx; |
317 | for (bp = 0; bp < buffer_size;) { | 318 | for (bp = 0; bp < buffer_size;) { |
318 | j = huffman_get(text); | 319 | j = huffman_get(text); |
319 | if (j == NULL) | 320 | if (j == NULL) |
320 | return(-1); | 321 | return(-1); |
321 | if (*j == 256) { | 322 | if (*j == 256) { |
322 | break; | 323 | break; |
323 | } | 324 | } |
324 | if (*j >= 257) { | 325 | if (*j >= 257) { |
325 | idx = *j - 257; | 326 | idx = *j - 257; |
326 | k = rsize_min[idx]; | 327 | k = rsize_min[idx]; |
327 | if (rsize_delta[idx] != 0) { | 328 | if (rsize_delta[idx] != 0) { |
328 | k += get_swapped(rsize_delta[idx]); | 329 | k += get_swapped(rsize_delta[idx]); |
329 | } | 330 | } |
330 | j = huffman_get(lz); | 331 | j = huffman_get(lz); |
331 | if (j == NULL) | 332 | if (j == NULL) |
332 | return(-1); | 333 | return(-1); |
333 | l = rpos_min[*j]; | 334 | l = rpos_min[*j]; |
334 | if (rpos_delta[*j] != 0) { | 335 | if (rpos_delta[*j] != 0) { |
335 | l += get_swapped(rpos_delta[*j]); | 336 | l += get_swapped(rpos_delta[*j]); |
336 | } | 337 | } |
337 | if (k <= l) { | 338 | if (k <= l) { |
338 | memcpy(buffer + bp, buffer + bp - l, k); | 339 | memcpy(buffer + bp, buffer + bp - l, k); |
339 | } else { | 340 | } else { |
340 | mymemcpy(buffer + bp, buffer + bp - l, k); | 341 | mymemcpy(buffer + bp, buffer + bp - l, k); |
341 | } | 342 | } |
342 | bp += k; | 343 | bp += k; |
343 | } else { | 344 | } else { |
344 | buffer[bp] = *j; | 345 | buffer[bp] = *j; |
345 | bp++; | 346 | bp++; |
346 | } | 347 | } |
347 | } | 348 | } |
348 | return(bp); | 349 | return(bp); |
349 | } | 350 | } |
350 | u_int32_t iSilo::getreccode() | 351 | u_int32_t iSilo::getreccode() |
351 | { | 352 | { |
352 | u_int32_t offset, rec_code; | 353 | u_int32_t offset, rec_code; |
353 | gotorecordnumber(cur_rec); | 354 | gotorecordnumber(cur_rec); |
354 | if (fread(&rec_code, sizeof(rec_code), 1, fin) != 1) | 355 | if (fread(&rec_code, sizeof(rec_code), 1, fin) != 1) |
355 | { | 356 | { |
356 | qDebug("short read"); | 357 | qDebug("short read"); |
357 | return 0xff; | 358 | return 0xff; |
358 | } | 359 | } |
359 | return rec_code; | 360 | return rec_code; |
360 | } | 361 | } |
361 | bool iSilo::process_record() | 362 | bool iSilo::process_record() |
362 | { | 363 | { |
363 | u_int32_t rec_code = getreccode(); | 364 | u_int32_t rec_code = getreccode(); |
364 | if (((rec_code & 0xFF) == 0) && (cur_rec != 0)) | 365 | if (((rec_code & 0xFF) == 0) && (cur_rec != 0)) |
365 | { | 366 | { |
366 | return false; | 367 | return false; |
367 | } | 368 | } |
368 | else | 369 | else |
369 | { | 370 | { |
370 | /* process text */ | 371 | /* process text */ |
371 | if ((cur_rec % 9) == 1) | 372 | if ((cur_rec % 9) == 1) |
372 | { | 373 | { |
373 | bsize = 0; | 374 | bsize = 0; |
374 | if (!reset_trees()) return false; | 375 | if (!reset_trees()) return false; |
375 | cur_rec++; | 376 | cur_rec++; |
376 | rec_code = getreccode(); | 377 | rec_code = getreccode(); |
377 | if (((rec_code & 0xFF) == 0) && (cur_rec != 0)) | 378 | if (((rec_code & 0xFF) == 0) && (cur_rec != 0)) |
378 | { | 379 | { |
379 | return false; | 380 | return false; |
380 | } | 381 | } |
381 | } | 382 | } |
382 | if (cur_rec != 0) | 383 | if (cur_rec != 0) |
383 | { | 384 | { |
384 | /* This is a Data record so we decode text using the table */ | 385 | /* This is a Data record so we decode text using the table */ |
385 | get_bits(0); | 386 | get_bits(0); |
386 | bsize = read_text(); | 387 | bsize = read_text(); |
387 | } /* end of text processing */ | 388 | } /* end of text processing */ |
388 | } | 389 | } |
389 | return true; | 390 | return true; |
390 | } | 391 | } |
391 | iSilo::~iSilo() | 392 | iSilo::~iSilo() |
392 | { | 393 | { |
393 | kill_huffman(master); | 394 | kill_huffman(master); |
394 | kill_huffman(lz); | 395 | kill_huffman(lz); |
395 | kill_huffman(text); | 396 | kill_huffman(text); |
396 | if (attr != NULL) | 397 | if (attr != NULL) |
397 | { | 398 | { |
398 | delete [] attr; | 399 | delete [] attr; |
399 | attr = NULL; | 400 | attr = NULL; |
400 | } | 401 | } |
401 | } | 402 | } |
402 | int iSilo::getch() | 403 | int iSilo::getch() |
403 | { | 404 | { |
404 | if (filepos >= textsize) | 405 | if (filepos >= textsize) |
405 | { | 406 | { |
406 | // qDebug("File end at record %u", cur_rec); | 407 | // qDebug("File end at record %u", cur_rec); |
407 | return EOF; | 408 | return EOF; |
408 | } | 409 | } |
409 | if (current_pos >= bsize) | 410 | if (current_pos >= bsize) |
410 | { | 411 | { |
411 | cur_rec++; | 412 | cur_rec++; |
412 | if (!process_record()) return EOF; | 413 | if (!process_record()) return EOF; |
413 | current_pos = 0; | 414 | current_pos = 0; |
414 | } | 415 | } |
415 | filepos++; | 416 | filepos++; |
416 | while (attr != NULL && filepos > attr[current_attr].offset) | 417 | while (attr != NULL && filepos > attr[current_attr].offset) |
417 | { | 418 | { |
418 | mystyle.unset(); | 419 | mystyle.unset(); |
419 | u_int16_t a = attr[current_attr].value; | 420 | u_int16_t a = attr[current_attr].value; |
420 | // qDebug("Handling attr:%x at pos:%u", a, filepos); | 421 | // qDebug("Handling attr:%x at pos:%u", a, filepos); |
421 | if ((a & 0x1) != 0) | 422 | if ((a & 0x1) != 0) |
422 | { | 423 | { |
423 | mystyle.setBold(); | 424 | mystyle.setBold(); |
424 | } | 425 | } |
425 | if ((a & 0xe) != 0) | 426 | if ((a & 0xe) != 0) |
426 | { | 427 | { |
427 | qDebug("Unknown attribute:%x (%x)", a & 0xe, a); | 428 | qDebug("Unknown attribute:%x (%x)", a & 0xe, a); |
428 | } | 429 | } |
429 | if ((a & 0x10) != 0) | 430 | if ((a & 0x10) != 0) |
430 | { | 431 | { |
431 | mystyle.setCentreJustify(); | 432 | mystyle.setCentreJustify(); |
432 | } | 433 | } |
433 | else if ((a & 0x20) != 0) | 434 | else if ((a & 0x20) != 0) |
434 | { | 435 | { |
435 | mystyle.setRightJustify(); | 436 | mystyle.setRightJustify(); |
436 | } | 437 | } |
437 | else | 438 | else |
438 | { | 439 | { |
439 | mystyle.setLeftJustify(); | 440 | mystyle.setLeftJustify(); |
440 | } | 441 | } |
441 | if ((a & 0x40) != 0) | 442 | if ((a & 0x40) != 0) |
442 | { | 443 | { |
443 | qDebug("Unknown attribute:%x (%x)", a & 0x40, a); | 444 | qDebug("Unknown attribute:%x (%x)", a & 0x40, a); |
444 | } | 445 | } |
445 | if ((a & 0x80) != 0) | 446 | if ((a & 0x80) != 0) |
446 | { | 447 | { |
447 | mystyle.setLeftMargin(10); | 448 | mystyle.setLeftMargin(10); |
448 | mystyle.setRightMargin(10); | 449 | mystyle.setRightMargin(10); |
449 | } | 450 | } |
450 | switch (a & 0xf00) | 451 | switch (a & 0xf00) |
451 | { | 452 | { |
452 | case 0x300: | 453 | case 0x300: |
453 | mystyle.setFontSize(0); | 454 | mystyle.setFontSize(0); |
454 | break; | 455 | break; |
455 | case 0xd00: | 456 | case 0xd00: |
456 | mystyle.setFontSize(1); | 457 | mystyle.setFontSize(1); |
457 | break; | 458 | break; |
458 | case 0xe00: | 459 | case 0xe00: |
459 | mystyle.setFontSize(2); | 460 | mystyle.setFontSize(2); |
460 | break; | 461 | break; |
461 | case 0xf00: | 462 | case 0xf00: |
462 | mystyle.setFontSize(3); | 463 | mystyle.setFontSize(3); |
463 | break; | 464 | break; |
464 | default: | 465 | default: |
465 | mystyle.setFontSize(0); | 466 | mystyle.setFontSize(0); |
466 | qDebug("Not sure of font size:%x (%x)", a & 0xf00, a); | 467 | qDebug("Not sure of font size:%x (%x)", a & 0xf00, a); |
467 | break; | 468 | break; |
468 | } | 469 | } |
469 | if ((a & 0x1000) != 0) | 470 | if ((a & 0x1000) != 0) |
470 | { | 471 | { |
471 | mystyle.setMono(); | 472 | mystyle.setMono(); |
472 | } | 473 | } |
473 | if ((a & 0x2000) != 0) | 474 | if ((a & 0x2000) != 0) |
474 | { | 475 | { |
475 | mystyle.setItalic(); | 476 | mystyle.setItalic(); |
476 | } | 477 | } |
477 | if ((a & 0x4000) != 0) | 478 | if ((a & 0x4000) != 0) |
478 | { | 479 | { |
479 | qDebug("Unknown attribute:%x (%x)", a & 0x4000, a); | 480 | qDebug("Unknown attribute:%x (%x)", a & 0x4000, a); |
480 | } | 481 | } |
481 | if ((a & 0x8000) != 0) | 482 | if ((a & 0x8000) != 0) |
482 | { | 483 | { |
483 | mystyle.setUnderline(); | 484 | mystyle.setUnderline(); |
484 | } | 485 | } |
485 | current_attr++; | 486 | current_attr++; |
486 | if (current_attr >= attr_num) | 487 | if (current_attr >= attr_num) |
487 | { | 488 | { |
488 | attr_rec++; | 489 | attr_rec++; |
489 | read_attr(); | 490 | read_attr(); |
490 | } | 491 | } |
491 | } | 492 | } |
492 | return buffer[current_pos++]; | 493 | return buffer[current_pos++]; |
493 | } | 494 | } |
494 | 495 | ||
495 | void iSilo::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 496 | void iSilo::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
496 | { | 497 | { |
497 | pos = filepos; | 498 | pos = filepos; |
498 | ch = getch(); | 499 | ch = getch(); |
499 | sty = mystyle; | 500 | sty = mystyle; |
500 | } | 501 | } |
501 | 502 | ||
502 | int iSilo::OpenFile(const char* src) | 503 | int iSilo::OpenFile(const char* src) |
503 | { | 504 | { |
504 | struct stat _stat; | 505 | struct stat _stat; |
505 | stat(src,&_stat); | 506 | stat(src,&_stat); |
506 | filesize = _stat.st_size; | 507 | filesize = _stat.st_size; |
507 | pos = 0; | 508 | pos = 0; |
508 | cur_rec = 0; | 509 | cur_rec = 0; |
509 | buffer_size = 4096; | 510 | buffer_size = 4096; |
510 | current_pos = 0; | 511 | current_pos = 0; |
511 | bsize = 0; | 512 | bsize = 0; |
512 | filepos = 0; | 513 | filepos = 0; |
513 | 514 | ||
514 | if (!Cpdb::openpdbfile(src)) | 515 | if (!Cpdb::openpdbfile(src)) |
515 | { | 516 | { |
516 | return -1; | 517 | return -1; |
517 | } | 518 | } |
518 | if (head.creator != 0x6F476F54 // 'ToGo' | 519 | if (head.creator != 0x6F476F54 // 'ToGo' |
519 | || head.type != 0x6F476F54) // 'ToGo') | 520 | || head.type != 0x6F476F54) // 'ToGo') |
520 | { | 521 | { |
521 | return -1; | 522 | return -1; |
522 | } | 523 | } |
523 | qDebug("There is %u records in this PDB file", ntohs(head.recordList.numRecords)); | 524 | qDebug("There is %u records in this PDB file", ntohs(head.recordList.numRecords)); |
524 | init_tables(); | 525 | init_tables(); |
525 | gotorecordnumber(0); | 526 | gotorecordnumber(0); |
526 | fread(buffer,1,12,fin); | 527 | fread(buffer,1,12,fin); |
527 | fread(&textsize, sizeof(textsize), 1, fin); | 528 | fread(&textsize, sizeof(textsize), 1, fin); |
528 | textsize = ntohl(textsize); | 529 | textsize = ntohl(textsize); |
529 | fread(buffer,1,4,fin); | 530 | fread(buffer,1,4,fin); |
530 | fread(&attr_start,sizeof(attr_start),1,fin); | 531 | fread(&attr_start,sizeof(attr_start),1,fin); |
531 | attr_start = ntohs(attr_start); | 532 | attr_start = ntohs(attr_start); |
532 | fread(buffer,1,2,fin); | 533 | fread(buffer,1,2,fin); |
533 | fread(&attr_end,sizeof(attr_end),1,fin); | 534 | fread(&attr_end,sizeof(attr_end),1,fin); |
534 | attr_end = ntohs(attr_end); | 535 | attr_end = ntohs(attr_end); |
535 | attr_rec = attr_start; | 536 | attr_rec = attr_start; |
536 | attr = NULL; | 537 | attr = NULL; |
537 | pos_hi = 0xffff; | 538 | pos_hi = 0xffff; |
538 | last_pos = 0xffff; | 539 | last_pos = 0xffff; |
539 | last_value = 0xffff; | 540 | last_value = 0xffff; |
540 | read_attr(); | 541 | read_attr(); |
541 | return 0; | 542 | return 0; |
542 | } | 543 | } |
543 | 544 | ||
544 | void iSilo::read_attr() | 545 | void iSilo::read_attr() |
545 | { | 546 | { |
546 | // qDebug("read_attr:<%u, %u, %u>", attr_rec, attr_start, attr_end); | 547 | // qDebug("read_attr:<%u, %u, %u>", attr_rec, attr_start, attr_end); |
547 | current_attr = 0; | 548 | current_attr = 0; |
548 | if (attr != NULL) | 549 | if (attr != NULL) |
549 | { | 550 | { |
550 | delete [] attr; | 551 | delete [] attr; |
551 | attr = NULL; | 552 | attr = NULL; |
552 | } | 553 | } |
553 | if (attr_rec >= attr_start && attr_rec < attr_end) | 554 | if (attr_rec >= attr_start && attr_rec < attr_end) |
554 | { | 555 | { |
555 | gotorecordnumber(attr_rec); | 556 | gotorecordnumber(attr_rec); |
556 | fread(buffer, 1, 4, fin); | 557 | fread(buffer, 1, 4, fin); |
557 | fread(&attr_num, sizeof(attr_num), 1, fin); | 558 | fread(&attr_num, sizeof(attr_num), 1, fin); |
558 | attr_num = ntohs(attr_num)+1; | 559 | attr_num = ntohs(attr_num)+1; |
559 | attr = new s_attrib[attr_num]; | 560 | attr = new s_attrib[attr_num]; |
560 | for (int j = 0; j < attr_num; j++) | 561 | for (int j = 0; j < attr_num; j++) |
561 | { | 562 | { |
562 | fread(&attr[j].offset, 2, 1, fin); | 563 | fread(&attr[j].offset, 2, 1, fin); |
563 | attr[j].offset = htons(attr[j].offset); | 564 | attr[j].offset = htons(attr[j].offset); |
564 | } | 565 | } |
565 | #ifdef _WINDOWS | 566 | #ifdef _WINDOWS |
566 | for (j = 0; j < attr_num; j++) | 567 | for (j = 0; j < attr_num; j++) |
567 | #else | 568 | #else |
568 | for (int j = 0; j < attr_num; j++) | 569 | for (int j = 0; j < attr_num; j++) |
569 | #endif | 570 | #endif |
570 | { | 571 | { |
571 | fread(&attr[j].value, 2, 1, fin); | 572 | fread(&attr[j].value, 2, 1, fin); |
572 | if (attr[j].offset < last_pos) | 573 | if (attr[j].offset < last_pos) |
573 | { | 574 | { |
574 | pos_hi++; | 575 | pos_hi++; |
575 | } | 576 | } |
576 | 577 | ||
577 | if ((attr[j].offset == last_pos) && (attr[j].value == last_value)) | 578 | if ((attr[j].offset == last_pos) && (attr[j].value == last_value)) |
578 | { | 579 | { |
579 | pos_hi++; | 580 | pos_hi++; |
580 | } | 581 | } |
581 | 582 | ||
582 | last_pos = attr[j].offset; | 583 | last_pos = attr[j].offset; |
583 | attr[j].offset |= ((u_int32_t)pos_hi) << 16; | 584 | attr[j].offset |= ((u_int32_t)pos_hi) << 16; |
584 | last_value = attr[j].value; | 585 | last_value = attr[j].value; |
585 | } | 586 | } |
586 | current_attr = 0; | 587 | current_attr = 0; |
587 | // last_value = attr[attr_num-1].value; | 588 | // last_value = attr[attr_num-1].value; |
588 | // qDebug("Next attr:%u (%u)", attr[current_attr].offset, filepos); | 589 | // qDebug("Next attr:%u (%u)", attr[current_attr].offset, filepos); |
589 | // qDebug("Next attr:%x (%x)", attr[current_attr].offset, filepos); | 590 | // qDebug("Next attr:%x (%x)", attr[current_attr].offset, filepos); |
590 | } | 591 | } |
591 | } | 592 | } |
592 | 593 | ||
593 | void iSilo::locate(unsigned int n) | 594 | void iSilo::locate(unsigned int n) |
594 | { | 595 | { |
595 | // qDebug("Locating %u", n); | 596 | // qDebug("Locating %u", n); |
596 | if (n >= textsize) n = 0; | 597 | if (n >= textsize) n = 0; |
597 | pos = 0; | 598 | pos = 0; |
598 | buffer_size = 4096; | 599 | buffer_size = 4096; |
599 | current_pos = 0; | 600 | current_pos = 0; |
600 | bsize = 0; | 601 | bsize = 0; |
601 | /* Brute force | 602 | /* Brute force |
602 | cur_rec = 0; | 603 | cur_rec = 0; |
603 | filepos = 0; | 604 | filepos = 0; |
604 | */ // Fast | 605 | */ // Fast |
605 | filepos = n - n % (8*buffer_size); | 606 | filepos = n - n % (8*buffer_size); |
606 | cur_rec = 9*(n/(8*buffer_size)); | 607 | cur_rec = 9*(n/(8*buffer_size)); |
607 | // End of fast | 608 | // End of fast |
608 | pos_hi = 0xffff; | 609 | pos_hi = 0xffff; |
609 | last_pos = 0xffff; | 610 | last_pos = 0xffff; |
610 | last_value = 0xffff; | 611 | last_value = 0xffff; |
611 | attr_rec = attr_start; | 612 | attr_rec = attr_start; |
612 | read_attr(); | 613 | read_attr(); |
613 | // While loop added for fast locate | 614 | // While loop added for fast locate |
614 | while (attr != NULL && attr[attr_num-1].offset < filepos) | 615 | while (attr != NULL && attr[attr_num-1].offset < filepos) |
615 | { | 616 | { |
616 | attr_rec++; | 617 | attr_rec++; |
617 | read_attr(); | 618 | read_attr(); |
618 | } | 619 | } |
619 | 620 | ||
620 | while (filepos < n) | 621 | while (filepos < n) |
621 | { | 622 | { |
622 | getch(); | 623 | getch(); |
623 | } | 624 | } |
624 | } | 625 | } |
625 | /* | 626 | /* |
626 | if (!process_record()) return EOF; | 627 | if (!process_record()) return EOF; |
627 | current_pos = 0; | 628 | current_pos = 0; |
628 | */ | 629 | */ |
629 | 630 | ||
630 | QString iSilo::about() | 631 | QString iSilo::about() |
631 | { | 632 | { |
632 | return QString("iSilo codec (c) Tim Wentford, based on code supplied by an anonymous donor"); | 633 | return QString("iSilo codec (c) Tim Wentford, based on code supplied by an anonymous donor"); |
633 | } | 634 | } |
634 | 635 | ||
635 | extern "C" | 636 | extern "C" |
636 | { | 637 | { |
637 | CExpander* newcodec() { return new iSilo; } | 638 | CExpander* newcodec() { return new iSilo; } |
638 | } | 639 | } |
diff --git a/noncore/apps/opie-reader/linktype.h b/noncore/apps/opie-reader/linktype.h index 23c24ac..a23d345 100644 --- a/noncore/apps/opie-reader/linktype.h +++ b/noncore/apps/opie-reader/linktype.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef __LINKTYPE_H | 1 | #ifndef __LINKTYPE_H |
2 | #define __LINKTYPE_H | 2 | #define __LINKTYPE_H |
3 | 3 | ||
4 | typedef unsigned int linkType; | 4 | typedef unsigned int linkType; |
5 | const linkType eNone = 0, eLink = 1, ePicture = 2, eFile = 4; | 5 | const linkType eNone = 0, eLink = 1, ePicture = 2, eFile = 4, eTable = 8; |
6 | 6 | ||
7 | #endif | 7 | #endif |
diff --git a/noncore/apps/opie-reader/main.cpp b/noncore/apps/opie-reader/main.cpp index af276da..2be6045 100644 --- a/noncore/apps/opie-reader/main.cpp +++ b/noncore/apps/opie-reader/main.cpp | |||
@@ -1,49 +1,50 @@ | |||
1 | |||
1 | #ifdef USEQPE | 2 | #ifdef USEQPE |
2 | #include <qpe/qpeapplication.h> | 3 | #include <qpe/qpeapplication.h> |
3 | #else | 4 | #else |
4 | #include <qapplication.h> | 5 | #include <qapplication.h> |
5 | #endif | 6 | #endif |
6 | #include "QTReaderApp.h" | 7 | #include "QTReaderApp.h" |
7 | 8 | ||
8 | #include "signal.h" | 9 | #include "signal.h" |
9 | #include "stdio.h" | 10 | #include "stdio.h" |
10 | #include "time.h" | 11 | #include "time.h" |
11 | 12 | ||
12 | 13 | ||
13 | #ifdef USEQPE | 14 | #ifdef USEQPE |
14 | QTReaderApp* app = NULL; | 15 | QTReaderApp* app = NULL; |
15 | 16 | ||
16 | void handler(int signum) | 17 | void handler(int signum) |
17 | { | 18 | { |
18 | if (app != NULL) | 19 | if (app != NULL) |
19 | { | 20 | { |
20 | app->suspend(); | 21 | app->suspend(); |
21 | app->saveprefs(); | 22 | app->saveprefs(); |
22 | } | 23 | } |
23 | signal(signum, handler); | 24 | signal(signum, handler); |
24 | } | 25 | } |
25 | #endif | 26 | #endif |
26 | 27 | ||
27 | int main( int argc, char ** argv ) | 28 | int main( int argc, char ** argv ) |
28 | { | 29 | { |
29 | 30 | ||
30 | #ifdef USEQPE | 31 | #ifdef USEQPE |
31 | signal(SIGCONT, handler); | 32 | signal(SIGCONT, handler); |
32 | QPEApplication a( argc, argv ); | 33 | QPEApplication a( argc, argv ); |
33 | QTReaderApp m; | 34 | QTReaderApp m; |
34 | a.showMainDocumentWidget( &m ); | 35 | a.showMainDocumentWidget( &m ); |
35 | app = &m; | 36 | app = &m; |
36 | #else | 37 | #else |
37 | QApplication a( argc, argv ); | 38 | QApplication a( argc, argv ); |
38 | QTReaderApp m; | 39 | QTReaderApp m; |
39 | a.setMainWidget( &m ); | 40 | a.setMainWidget( &m ); |
40 | if (argc > 1) | 41 | if (argc > 1) |
41 | { | 42 | { |
42 | m.setDocument(argv[1]); | 43 | m.setDocument(argv[1]); |
43 | } | 44 | } |
44 | #endif | 45 | #endif |
45 | 46 | ||
46 | 47 | ||
47 | return a.exec(); | 48 | return a.exec(); |
48 | } | 49 | } |
49 | 50 | ||
diff --git a/noncore/apps/opie-reader/mytypes.h b/noncore/apps/opie-reader/mytypes.h new file mode 100644 index 0000000..ea60db3 --- a/dev/null +++ b/noncore/apps/opie-reader/mytypes.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef __MYTYPES_H__ | ||
2 | #define __MYTYPES_H__ | ||
3 | typedef unsigned char UInt8; | ||
4 | typedef unsigned short UInt16; | ||
5 | typedef signed short Int16; | ||
6 | typedef unsigned long UInt32; | ||
7 | #endif | ||
8 | |||
diff --git a/noncore/apps/opie-reader/opie-reader.pro b/noncore/apps/opie-reader/opie-reader.pro index 170f7fa..47980e1 100644 --- a/noncore/apps/opie-reader/opie-reader.pro +++ b/noncore/apps/opie-reader/opie-reader.pro | |||
@@ -1,16 +1,24 @@ | |||
1 | TEMPLATE = subdirs | 1 | TEMPLATE = subdirs |
2 | SUBDIRS = pluckerbaselib \ | 2 | SUBDIRS = pluckerbaselib \ |
3 | codeclib \ | 3 | codeclib \ |
4 | pdblib \ | 4 | pdblib \ |
5 | PluckerCodec \ | 5 | PluckerCodec \ |
6 | AportisCodec \ | 6 | AportisCodec \ |
7 | CHM \ | 7 | CHM \ |
8 | HTMLFilter \ | 8 | HTMLFilter \ |
9 | WeaselCodec \ | 9 | WeaselCodec \ |
10 | iSiloCodec \ | 10 | iSiloCodec \ |
11 | ppmsCodec \ | 11 | ppmsCodec \ |
12 | FliteCmd \ | ||
13 | pluckerdecompress \ | ||
14 | ArriereCodec \ | ||
15 | RebCodec \ | ||
12 | reader | 16 | reader |
13 | 17 | ||
18 | # these are added only built if enabled in "make menuconfig" | ||
19 | # FliteDyn | ||
20 | # FliteDyn16 | ||
21 | |||
14 | include( $(OPIEDIR)/include.pro ) | 22 | include( $(OPIEDIR)/include.pro ) |
15 | 23 | ||
16 | 24 | ||
diff --git a/noncore/apps/opie-reader/outputcodec.h b/noncore/apps/opie-reader/outputcodec.h new file mode 100644 index 0000000..727575c --- a/dev/null +++ b/noncore/apps/opie-reader/outputcodec.h | |||
@@ -0,0 +1,84 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include <qfileinfo.h> | ||
3 | #include <qdir.h> | ||
4 | |||
5 | #ifdef USEQPE | ||
6 | #include <qpe/global.h> | ||
7 | #endif | ||
8 | |||
9 | class COutput | ||
10 | { | ||
11 | public: | ||
12 | virtual ~COutput() {} | ||
13 | virtual void output(const QString&) = 0; | ||
14 | virtual QString about() = 0; | ||
15 | }; | ||
16 | |||
17 | #ifndef __STATIC | ||
18 | #include <dlfcn.h> | ||
19 | class outputcodec : public COutput | ||
20 | { | ||
21 | COutput *codec; | ||
22 | void *handle; | ||
23 | int status; | ||
24 | public: | ||
25 | void output(const QString& q) { codec->output(q); } | ||
26 | QString about() | ||
27 | { | ||
28 | return QString("Plug-in output codec interface (c) Tim Wentford\n")+codec->about(); | ||
29 | } | ||
30 | outputcodec(const QString& _s) : codec(NULL), handle(NULL), status(-1) | ||
31 | { | ||
32 | #ifdef USEQPE | ||
33 | #ifdef OPIE | ||
34 | QString codecpath(getenv("OPIEDIR")); | ||
35 | #else | ||
36 | QString codecpath(getenv("QTDIR")); | ||
37 | #endif | ||
38 | codecpath += "/plugins/reader/outcodecs/lib"; | ||
39 | #else | ||
40 | QString codecpath(getenv("READERDIR")); | ||
41 | codecpath += "/outcodecs/lib"; | ||
42 | #endif | ||
43 | codecpath += _s; | ||
44 | codecpath += ".so"; | ||
45 | if (QFile::exists(codecpath)) | ||
46 | { | ||
47 | qDebug("Codec:%s", (const char*)codecpath); | ||
48 | handle = dlopen(codecpath, RTLD_LAZY); | ||
49 | if (handle == 0) | ||
50 | { | ||
51 | qDebug("Can't find codec:%s", dlerror()); | ||
52 | status = -10; | ||
53 | return; | ||
54 | } | ||
55 | COutput* (*newcodec)(); | ||
56 | newcodec = (COutput* (*)())dlsym(handle, "newcodec"); | ||
57 | if (newcodec == NULL) | ||
58 | { | ||
59 | qDebug("Can't find newcodec"); | ||
60 | status = -20; | ||
61 | return; | ||
62 | } | ||
63 | codec = (*newcodec)(); | ||
64 | status = 0; | ||
65 | } | ||
66 | else | ||
67 | { | ||
68 | qDebug("Can't find codec:%s", (const char*)codecpath); | ||
69 | } | ||
70 | if (codec == NULL) | ||
71 | { | ||
72 | qDebug("Can't do newcodec"); | ||
73 | status = -30; | ||
74 | return; | ||
75 | } | ||
76 | } | ||
77 | virtual ~outputcodec() | ||
78 | { | ||
79 | if (codec != NULL) delete codec; | ||
80 | if (handle != NULL) dlclose(handle); | ||
81 | } | ||
82 | int getStatus() { return status; } | ||
83 | }; | ||
84 | #endif | ||
diff --git a/noncore/apps/opie-reader/pdb.cpp b/noncore/apps/opie-reader/pdb.cpp index 6719af4..a13b33d 100644 --- a/noncore/apps/opie-reader/pdb.cpp +++ b/noncore/apps/opie-reader/pdb.cpp | |||
@@ -1,89 +1,90 @@ | |||
1 | #include "pdb.h" | 1 | #include "pdb.h" |
2 | #ifdef _WINDOWS | 2 | #ifdef _WINDOWS |
3 | #include <winsock2.h> | 3 | #include <winsock2.h> |
4 | #endif | 4 | #endif |
5 | 5 | ||
6 | |||
7 | #ifdef USEQPE | 6 | #ifdef USEQPE |
8 | void Cpdb::suspend() | 7 | void Cpdb::suspend() |
9 | { | 8 | { |
10 | CExpander::suspend(fin); | 9 | CExpander::suspend(fin); |
11 | } | 10 | } |
12 | void Cpdb::unsuspend() | 11 | void Cpdb::unsuspend() |
13 | { | 12 | { |
14 | CExpander::unsuspend(fin); | 13 | CExpander::unsuspend(fin); |
15 | } | 14 | } |
16 | #endif | 15 | #endif |
17 | 16 | ||
18 | Cpdb::~Cpdb() | 17 | Cpdb::~Cpdb() |
19 | { | 18 | { |
20 | if (fin != NULL) | 19 | if (fin != NULL) |
21 | { | 20 | { |
22 | #ifdef USEQPE | 21 | #ifdef USEQPE |
23 | unsuspend(); | 22 | unsuspend(); |
24 | #endif | 23 | #endif |
25 | fclose(fin); | 24 | fclose(fin); |
26 | } | 25 | } |
27 | } | 26 | } |
28 | 27 | ||
29 | size_t Cpdb::recordpos(int n) | 28 | size_t Cpdb::recordpos(int n) |
30 | { | 29 | { |
31 | UInt16 mxn = ntohs(head.recordList.numRecords); | 30 | UInt16 mxn = ntohs(head.recordList.numRecords); |
32 | if (n >= mxn) | 31 | if (n >= mxn) |
33 | { | 32 | { |
34 | return file_length; | 33 | return file_length; |
35 | } | 34 | } |
36 | else | 35 | else |
37 | { | 36 | { |
38 | size_t dataoffset = sizeof(DatabaseHdrType) - sizeof(UInt16); | 37 | size_t dataoffset = sizeof(DatabaseHdrType) - sizeof(UInt16); |
39 | dataoffset += /*dataoffset%4 + */ sizeof(RecordListType) * n; | 38 | dataoffset += /*dataoffset%4 + */ sizeof(RecordListType) * n; |
39 | unsuspend(); | ||
40 | fseek(fin, dataoffset, SEEK_SET); | 40 | fseek(fin, dataoffset, SEEK_SET); |
41 | RecordListType hdr; | 41 | RecordListType hdr; |
42 | fread(&hdr, 1, sizeof(hdr), fin); | 42 | fread(&hdr, 1, sizeof(hdr), fin); |
43 | return ntohl(hdr.nextRecordListID); | 43 | return ntohl(hdr.nextRecordListID); |
44 | } | 44 | } |
45 | 45 | ||
46 | } | 46 | } |
47 | 47 | ||
48 | size_t Cpdb::recordlength(int n) | 48 | size_t Cpdb::recordlength(int n) |
49 | { | 49 | { |
50 | return recordpos(n+1)-recordpos(n); | 50 | return recordpos(n+1)-recordpos(n); |
51 | } | 51 | } |
52 | 52 | ||
53 | void Cpdb::gotorecordnumber(int n) | 53 | void Cpdb::gotorecordnumber(int n) |
54 | { | 54 | { |
55 | unsuspend(); | ||
55 | fseek(fin, recordpos(n), SEEK_SET); | 56 | fseek(fin, recordpos(n), SEEK_SET); |
56 | } | 57 | } |
57 | 58 | ||
58 | bool Cpdb::openpdbfile(const char *src) | 59 | bool Cpdb::openpdbfile(const char *src) |
59 | { | 60 | { |
60 | //qDebug("cpdb openfile:%s", src); | 61 | //qDebug("cpdb openfile:%s", src); |
61 | 62 | ||
62 | // printf("In openfile\n"); | 63 | // printf("In openfile\n"); |
63 | // printf("closing fin:%x\n",fin); | 64 | // printf("closing fin:%x\n",fin); |
64 | if (fin != NULL) fclose(fin); | 65 | if (fin != NULL) fclose(fin); |
65 | // printf("opening fin\n"); | 66 | // printf("opening fin\n"); |
66 | fin = fopen(src,"rb"); | 67 | fin = fopen(src,"rb"); |
67 | 68 | ||
68 | if (fin==0) | 69 | if (fin==0) |
69 | { | 70 | { |
70 | return false; | 71 | return false; |
71 | } | 72 | } |
72 | 73 | ||
73 | // just holds the first few chars of the file | 74 | // just holds the first few chars of the file |
74 | //char buf[0x100]; | 75 | //char buf[0x100]; |
75 | struct stat _stat; | 76 | struct stat _stat; |
76 | stat(src,&_stat); | 77 | stat(src,&_stat); |
77 | file_length = _stat.st_size; | 78 | file_length = _stat.st_size; |
78 | // fseek(fin,0,SEEK_END); | 79 | // fseek(fin,0,SEEK_END); |
79 | // file_length = ftell(fin); | 80 | // file_length = ftell(fin); |
80 | 81 | ||
81 | fseek(fin,0,SEEK_SET); | 82 | fseek(fin,0,SEEK_SET); |
82 | 83 | ||
83 | fread(&head, 1, sizeof(head), fin); | 84 | fread(&head, 1, sizeof(head), fin); |
84 | 85 | ||
85 | qDebug("Database name:%s", head.name); | 86 | //qDebug("Database name:%s", head.name); |
86 | qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); | 87 | //qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); |
87 | 88 | ||
88 | return true; | 89 | return true; |
89 | } | 90 | } |
diff --git a/noncore/apps/opie-reader/pdb.h b/noncore/apps/opie-reader/pdb.h index 7458919..a0abd1b 100644 --- a/noncore/apps/opie-reader/pdb.h +++ b/noncore/apps/opie-reader/pdb.h | |||
@@ -1,100 +1,101 @@ | |||
1 | 1 | ||
2 | /* | 2 | /* |
3 | * This header file defines some structures and types normally found in the | 3 | * This header file defines some structures and types normally found in the |
4 | * Palm SDK. However, I don't want to require the presense of the SDK for a | 4 | * Palm SDK. However, I don't want to require the presense of the SDK for a |
5 | * small utility since most Palm owners won't have it. | 5 | * small utility since most Palm owners won't have it. |
6 | * | 6 | * |
7 | * $Id$ | 7 | * $Id$ |
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #ifndef __PDB_H__ | 11 | #ifndef __PDB_H__ |
12 | #define __PDB_H__ | 12 | #define __PDB_H__ |
13 | 13 | ||
14 | #ifndef _WINDOWS | 14 | #ifndef _WINDOWS |
15 | #include <netinet/in.h> | 15 | #include <netinet/in.h> |
16 | #endif | 16 | #endif |
17 | #include <stdio.h> | 17 | #include <stdio.h> |
18 | |||
18 | #include "CExpander.h" | 19 | #include "CExpander.h" |
19 | 20 | ||
20 | /* Normal Palm typedefs */ | 21 | /* Normal Palm typedefs */ |
21 | typedef unsigned char UInt8; | 22 | #include "mytypes.h" |
22 | typedef unsigned short UInt16; | ||
23 | typedef signed short Int16; | ||
24 | typedef unsigned long UInt32; | ||
25 | typedef UInt32 LocalID; | 23 | typedef UInt32 LocalID; |
26 | 24 | ||
27 | /* Max length of DB name */ | 25 | /* Max length of DB name */ |
28 | #define dmDBNameLength 0x20 | 26 | #define dmDBNameLength 0x20 |
29 | 27 | ||
30 | 28 | ||
31 | /************************************************************ | 29 | /************************************************************ |
32 | * Structure of a Record entry | 30 | * Structure of a Record entry |
33 | *************************************************************/ | 31 | *************************************************************/ |
34 | typedef struct { | 32 | typedef struct { |
35 | LocalID localChunkID; // local chunkID of a record | 33 | LocalID localChunkID; // local chunkID of a record |
36 | UInt8 attributes; // record attributes; | 34 | UInt8 attributes; // record attributes; |
37 | UInt8 uniqueID[3]; // unique ID of record; should | 35 | UInt8 uniqueID[3]; // unique ID of record; should |
38 | // not be 0 for a legal record. | 36 | // not be 0 for a legal record. |
39 | } RecordEntryType; | 37 | } RecordEntryType; |
40 | 38 | ||
41 | 39 | ||
42 | /************************************************************ | 40 | /************************************************************ |
43 | * Structure of a record list extension. This is used if all | 41 | * Structure of a record list extension. This is used if all |
44 | * the database record/resource entries of a database can't fit into | 42 | * the database record/resource entries of a database can't fit into |
45 | * the database header. | 43 | * the database header. |
46 | *************************************************************/ | 44 | *************************************************************/ |
47 | typedef struct { | 45 | typedef struct { |
48 | LocalID nextRecordListID; // local chunkID of next list | 46 | LocalID nextRecordListID; // local chunkID of next list |
49 | UInt16 numRecords; // number of records in this list | 47 | UInt16 numRecords; // number of records in this list |
50 | UInt16 firstEntry; // array of Record/Rsrc entries | 48 | UInt16 firstEntry; // array of Record/Rsrc entries |
51 | // starts here | 49 | // starts here |
52 | } RecordListType; | 50 | } RecordListType; |
53 | 51 | ||
54 | 52 | ||
55 | /************************************************************ | 53 | /************************************************************ |
56 | * Structure of a Database Header | 54 | * Structure of a Database Header |
57 | *************************************************************/ | 55 | *************************************************************/ |
58 | typedef struct { | 56 | typedef struct { |
59 | UInt8 name[dmDBNameLength]; // name of database | 57 | UInt8 name[dmDBNameLength]; // name of database |
60 | UInt16 attributes; // database attributes | 58 | UInt16 attributes; // database attributes |
61 | UInt16 version; // version of database | 59 | UInt16 version; // version of database |
62 | UInt32 creationDate; // creation date of database | 60 | UInt32 creationDate; // creation date of database |
63 | UInt32 modificationDate; // latest modification date | 61 | UInt32 modificationDate; // latest modification date |
64 | UInt32 lastBackupDate; // latest backup date | 62 | UInt32 lastBackupDate; // latest backup date |
65 | UInt32 modificationNumber; // modification number of database | 63 | UInt32 modificationNumber; // modification number of database |
66 | LocalID appInfoID; // application specific info | 64 | LocalID appInfoID; // application specific info |
67 | LocalID sortInfoID; // app specific sorting info | 65 | LocalID sortInfoID; // app specific sorting info |
68 | UInt32 type; // database type | 66 | UInt32 type; // database type |
69 | UInt32 creator; // database creator | 67 | UInt32 creator; // database creator |
70 | UInt32 uniqueIDSeed; // used to generate unique IDs. | 68 | UInt32 uniqueIDSeed; // used to generate unique IDs. |
71 | // Note that only the low order | 69 | // Note that only the low order |
72 | // 3 bytes of this is used (in | 70 | // 3 bytes of this is used (in |
73 | // RecordEntryType.uniqueID). | 71 | // RecordEntryType.uniqueID). |
74 | // We are keeping 4 bytes for | 72 | // We are keeping 4 bytes for |
75 | // alignment purposes. | 73 | // alignment purposes. |
76 | RecordListType recordList; // first record list | 74 | RecordListType recordList; // first record list |
77 | } DatabaseHdrType; | 75 | } DatabaseHdrType; |
78 | 76 | ||
79 | 77 | ||
80 | class Cpdb : public CExpander | 78 | class Cpdb : public CExpander |
81 | { | 79 | { |
82 | protected: | 80 | protected: |
83 | size_t file_length; | 81 | size_t file_length; |
84 | FILE* fin; | 82 | FILE* fin; |
85 | size_t recordpos(int); | 83 | size_t recordpos(int); |
86 | size_t recordlength(int); | 84 | size_t recordlength(int); |
87 | void gotorecordnumber(int); | 85 | void gotorecordnumber(int); |
88 | DatabaseHdrType head; | 86 | DatabaseHdrType head; |
89 | bool openpdbfile(const char* src); | 87 | bool openpdbfile(const char* src); |
90 | Cpdb() : fin(NULL) {} | 88 | Cpdb() : fin(NULL) {} |
91 | ~Cpdb(); | 89 | ~Cpdb(); |
92 | #ifdef USEQPE | 90 | #ifdef USEQPE |
93 | void suspend(); | 91 | void suspend(); |
94 | void unsuspend(); | 92 | void unsuspend(); |
93 | #else | ||
94 | void suspend() {} | ||
95 | void unsuspend() {} | ||
95 | #endif | 96 | #endif |
96 | public: | 97 | public: |
97 | virtual void sizes(unsigned long& _file, unsigned long& _text) = 0; | 98 | virtual void sizes(unsigned long& _file, unsigned long& _text) = 0; |
98 | }; | 99 | }; |
99 | #endif | 100 | #endif |
100 | 101 | ||
diff --git a/noncore/apps/opie-reader/plucker_base.cpp b/noncore/apps/opie-reader/plucker_base.cpp index d7d538f..51c7fa7 100644 --- a/noncore/apps/opie-reader/plucker_base.cpp +++ b/noncore/apps/opie-reader/plucker_base.cpp | |||
@@ -1,1408 +1,1528 @@ | |||
1 | #include "usenef.h" | ||
2 | #include <stdio.h> | 1 | #include <stdio.h> |
3 | #include <string.h> | 2 | #include <string.h> |
4 | #include <qmessagebox.h> | 3 | #include <qmessagebox.h> |
5 | #include <qpixmap.h> | 4 | #include <qpixmap.h> |
6 | #ifdef USEQPE | 5 | #ifdef USEQPE |
7 | #include <qpe/qcopenvelope_qws.h> | 6 | #include <qpe/qcopenvelope_qws.h> |
8 | #endif /* USEQPE */ | 7 | #endif /* USEQPE */ |
9 | #ifdef LOCALPICTURES | 8 | #ifdef LOCALPICTURES |
10 | #include <qscrollview.h> | 9 | #include <qscrollview.h> |
11 | #endif | 10 | #endif |
12 | #ifdef USEQPE | 11 | #ifdef USEQPE |
13 | #include <qpe/global.h> | 12 | #include <qpe/global.h> |
14 | #endif /* USEQPE */ | 13 | #endif /* USEQPE */ |
15 | #include <qclipboard.h> | 14 | #include <qclipboard.h> |
16 | #ifndef USEQPE | 15 | #ifndef USEQPE |
17 | #include <qapplication.h> | 16 | #include <qapplication.h> |
18 | #else /* USEQPE */ | 17 | #else /* USEQPE */ |
19 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
20 | #endif /* USEQPE */ | 19 | #endif /* USEQPE */ |
21 | #include <qimage.h> | 20 | #include <qimage.h> |
22 | 21 | ||
23 | #include "plucker_base.h" | 22 | #include "plucker_base.h" |
24 | #include "Aportis.h" | 23 | #include "Aportis.h" |
25 | #include "hrule.h" | 24 | #include "hrule.h" |
26 | #include "util.h" | 25 | #include "decompress.h" |
27 | 26 | ||
28 | const UInt8 CPlucker_base::continuation_bit = 1; | 27 | const UInt8 CPlucker_base::continuation_bit = 1; |
29 | 28 | ||
30 | CPlucker_base::CPlucker_base() : | 29 | CPlucker_base::CPlucker_base() : |
31 | #ifdef LOCALPICTURES | 30 | #ifdef LOCALPICTURES |
32 | m_viewer(NULL), | 31 | m_viewer(NULL), |
33 | m_picture(NULL), | 32 | m_picture(NULL), |
34 | #endif | 33 | #endif |
35 | expandedtextbuffer(NULL), | 34 | expandedtextbuffer(NULL), |
36 | compressedtextbuffer(NULL), | 35 | compressedtextbuffer(NULL), |
37 | bufferrec(-1), | 36 | bufferrec(-1), |
38 | m_offset(0) | 37 | m_offset(0) |
39 | //, urls(NULL) | 38 | //, urls(NULL) |
40 | { /*printf("constructing:%x\n",fin);*/ } | 39 | { /*printf("constructing:%x\n",fin);*/ } |
41 | 40 | ||
42 | 41 | ||
43 | void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buffersize) | 42 | void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buffersize) |
44 | { | 43 | { |
45 | if (type%2 == 0) | 44 | unsuspend(); |
45 | if ((type%2 == 0) && (type != 14)) | ||
46 | { | 46 | { |
47 | fread(buffer, reclen, sizeof(char), fin); | 47 | fread(buffer, reclen, sizeof(char), fin); |
48 | } | 48 | } |
49 | else | 49 | else |
50 | { | 50 | { |
51 | UInt8* readbuffer = NULL; | 51 | UInt8* readbuffer = NULL; |
52 | if (reclen > compressedbuffersize) | 52 | if (reclen > compressedbuffersize) |
53 | { | 53 | { |
54 | readbuffer = new UInt8[reclen]; | 54 | readbuffer = new UInt8[reclen]; |
55 | } | 55 | } |
56 | else | 56 | else |
57 | { | 57 | { |
58 | readbuffer = compressedtextbuffer; | 58 | readbuffer = compressedtextbuffer; |
59 | } | 59 | } |
60 | if (readbuffer != NULL) | 60 | if (readbuffer != NULL) |
61 | { | 61 | { |
62 | fread(readbuffer, reclen, sizeof(char), fin); | 62 | fread(readbuffer, reclen, sizeof(char), fin); |
63 | (*m_decompress)(readbuffer, reclen, buffer, buffersize); | 63 | (*m_decompress)(readbuffer, reclen, buffer, buffersize); |
64 | if (reclen > compressedbuffersize) | 64 | if (reclen > compressedbuffersize) |
65 | { | 65 | { |
66 | delete [] readbuffer; | 66 | delete [] readbuffer; |
67 | } | 67 | } |
68 | } | 68 | } |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | void CPlucker_base::sizes(unsigned long& _file, unsigned long& _text) | 72 | void CPlucker_base::sizes(unsigned long& _file, unsigned long& _text) |
73 | { | 73 | { |
74 | _file = file_length; | 74 | _file = file_length; |
75 | if (textlength == 0) | 75 | if (textlength == 0) |
76 | { | 76 | { |
77 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 77 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
78 | { | 78 | { |
79 | gotorecordnumber(recptr); | 79 | gotorecordnumber(recptr); |
80 | UInt16 thishdr_uid, thishdr_nParagraphs; | 80 | UInt16 thishdr_uid, thishdr_nParagraphs; |
81 | UInt32 thishdr_size; | 81 | UInt32 thishdr_size; |
82 | UInt8 thishdr_type, thishdr_reserved; | 82 | UInt8 thishdr_type, thishdr_reserved; |
83 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 83 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
84 | if (thishdr_type < 2) textlength += thishdr_size; | 84 | if (thishdr_type < 2) textlength += thishdr_size; |
85 | } | 85 | } |
86 | } | 86 | } |
87 | _text = textlength; | 87 | _text = textlength; |
88 | //ntohl(hdr0.size); | 88 | //ntohl(hdr0.size); |
89 | } | 89 | } |
90 | 90 | ||
91 | char* CPlucker_base::geturl(UInt16 tgt) | 91 | char* CPlucker_base::geturl(UInt16 tgt) |
92 | { | 92 | { |
93 | char * pRet = NULL; | 93 | char * pRet = NULL; |
94 | gotorecordnumber(0); | 94 | gotorecordnumber(0); |
95 | fread(&hdr0, 1, 6, fin); | 95 | fread(&hdr0, 1, 6, fin); |
96 | unsigned int nrecs = ntohs(hdr0.nRecords); | 96 | unsigned int nrecs = ntohs(hdr0.nRecords); |
97 | //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); | 97 | //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); |
98 | UInt16 urlid = 0; | 98 | UInt16 urlid = 0; |
99 | bool urlsfound = false; | 99 | bool urlsfound = false; |
100 | char* urls = NULL; | 100 | char* urls = NULL; |
101 | size_t urlsize = 0; | 101 | size_t urlsize = 0; |
102 | for (unsigned int i = 0; i < nrecs; i++) | 102 | for (unsigned int i = 0; i < nrecs; i++) |
103 | { | 103 | { |
104 | UInt16 id, name; | 104 | UInt16 id, name; |
105 | fread(&name, 1, sizeof(name), fin); | 105 | fread(&name, 1, sizeof(name), fin); |
106 | fread(&id, 1, sizeof(id), fin); | 106 | fread(&id, 1, sizeof(id), fin); |
107 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); | 107 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); |
108 | if (ntohs(name) == 2) | 108 | if (ntohs(name) == 2) |
109 | { | 109 | { |
110 | urlsfound = true; | 110 | urlsfound = true; |
111 | urlid = id; | 111 | urlid = id; |
112 | //qDebug("Found url index:%d", ntohs(urlid)); | 112 | //qDebug("Found url index:%d", ntohs(urlid)); |
113 | } | 113 | } |
114 | ////qDebug("%x", id); | 114 | ////qDebug("%x", id); |
115 | } | 115 | } |
116 | if (urlsfound) | 116 | if (urlsfound) |
117 | { | 117 | { |
118 | unsigned short recptr = finduid(ntohs(urlid)); | 118 | unsigned short recptr = finduid(ntohs(urlid)); |
119 | if (recptr != 0) | 119 | if (recptr != 0) |
120 | { | 120 | { |
121 | gotorecordnumber(recptr); | 121 | gotorecordnumber(recptr); |
122 | UInt16 thishdr_uid, thishdr_nParagraphs; | 122 | UInt16 thishdr_uid, thishdr_nParagraphs; |
123 | UInt32 thishdr_size; | 123 | UInt32 thishdr_size; |
124 | UInt8 thishdr_type, thishdr_reserved; | 124 | UInt8 thishdr_type, thishdr_reserved; |
125 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 125 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
126 | UInt16 urlctr = 0; | 126 | UInt16 urlctr = 0; |
127 | while (1) | 127 | while (1) |
128 | { | 128 | { |
129 | UInt16 tctr; | 129 | UInt16 tctr; |
130 | fread(&tctr, 1, sizeof(tctr), fin); | 130 | fread(&tctr, 1, sizeof(tctr), fin); |
131 | fread(&urlid, 1, sizeof(urlid), fin); | 131 | fread(&urlid, 1, sizeof(urlid), fin); |
132 | tctr = ntohs(tctr); | 132 | tctr = ntohs(tctr); |
133 | //qDebug("tgt:%u urlctr:%u tctr:%u", tgt, urlctr, tctr); | 133 | //qDebug("tgt:%u urlctr:%u tctr:%u", tgt, urlctr, tctr); |
134 | if (tctr >= tgt) | 134 | if (tctr >= tgt) |
135 | { | 135 | { |
136 | break; | 136 | break; |
137 | } | 137 | } |
138 | urlctr = tctr; | 138 | urlctr = tctr; |
139 | } | 139 | } |
140 | //qDebug("urls are in %d", ntohs(urlid)); | 140 | //qDebug("urls are in %d", ntohs(urlid)); |
141 | recptr = finduid(ntohs(urlid)); | 141 | recptr = finduid(ntohs(urlid)); |
142 | if (recptr != 0) | 142 | if (recptr != 0) |
143 | { | 143 | { |
144 | UInt32 reclen = recordlength(recptr) - HeaderSize(); | 144 | UInt32 reclen = recordlength(recptr) - HeaderSize(); |
145 | gotorecordnumber(recptr); | 145 | gotorecordnumber(recptr); |
146 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 146 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
147 | //qDebug("Found urls:%x",thishdr_type); | 147 | //qDebug("Found urls:%x",thishdr_type); |
148 | urlsize = thishdr_size; | 148 | urlsize = thishdr_size; |
149 | urls = new char[urlsize]; | 149 | urls = new char[urlsize]; |
150 | Expand(reclen, thishdr_type, (UInt8*)urls, urlsize); | 150 | Expand(reclen, thishdr_type, (UInt8*)urls, urlsize); |
151 | char* ptr = urls; | 151 | char* ptr = urls; |
152 | int rn = urlctr+1; | 152 | int rn = urlctr+1; |
153 | while (ptr - urls < urlsize) | 153 | while (ptr - urls < urlsize) |
154 | { | 154 | { |
155 | if (rn == tgt) | 155 | if (rn == tgt) |
156 | { | 156 | { |
157 | //qDebug("URL:%s", ptr); | 157 | //qDebug("URL:%s", ptr); |
158 | int len = strlen(ptr)+1; | 158 | int len = strlen(ptr)+1; |
159 | pRet = new char[len]; | 159 | pRet = new char[len]; |
160 | memcpy(pRet, ptr, len); | 160 | memcpy(pRet, ptr, len); |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | ptr += strlen(ptr)+1; | 163 | ptr += strlen(ptr)+1; |
164 | rn++; | 164 | rn++; |
165 | } | 165 | } |
166 | delete [] urls; | 166 | delete [] urls; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | } | 169 | } |
170 | else | 170 | else |
171 | { | 171 | { |
172 | pRet = NULL; | 172 | pRet = NULL; |
173 | } | 173 | } |
174 | return pRet; | 174 | return pRet; |
175 | } | 175 | } |
176 | 176 | ||
177 | CPlucker_base::~CPlucker_base() | 177 | CPlucker_base::~CPlucker_base() |
178 | { | 178 | { |
179 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; | 179 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; |
180 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; | 180 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; |
181 | #ifdef LOCALPICTURES | 181 | #ifdef LOCALPICTURES |
182 | if (m_viewer != NULL) delete m_viewer; | 182 | if (m_viewer != NULL) delete m_viewer; |
183 | #endif | 183 | #endif |
184 | } | 184 | } |
185 | 185 | ||
186 | int CPlucker_base::getch() { return getch(false); } | 186 | int CPlucker_base::getch() { return getch(false); } |
187 | 187 | ||
188 | void CPlucker_base::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 188 | void CPlucker_base::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
189 | { | 189 | { |
190 | pos = locate(); | 190 | pos = locate(); |
191 | ch = getch(false); | 191 | ch = getch(false); |
192 | sty = mystyle; | 192 | sty = mystyle; |
193 | } | 193 | } |
194 | 194 | ||
195 | unsigned int CPlucker_base::locate() | 195 | unsigned int CPlucker_base::locate() |
196 | { | 196 | { |
197 | return currentpos; | 197 | return currentpos; |
198 | /* | 198 | /* |
199 | UInt16 thisrec = 1; | 199 | UInt16 thisrec = 1; |
200 | unsigned long locpos = 0; | 200 | unsigned long locpos = 0; |
201 | gotorecordnumber(thisrec); | 201 | gotorecordnumber(thisrec); |
202 | UInt16 thishdr_uid, thishdr_nParagraphs; | 202 | UInt16 thishdr_uid, thishdr_nParagraphs; |
203 | UInt32 thishdr_size; | 203 | UInt32 thishdr_size; |
204 | UInt8 thishdr_type, thishdr_reserved; | 204 | UInt8 thishdr_type, thishdr_reserved; |
205 | while (thisrec < bufferrec) | 205 | while (thisrec < bufferrec) |
206 | { | 206 | { |
207 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 207 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
208 | if (thishdr_type < 2) locpos += thishdr_size; | 208 | if (thishdr_type < 2) locpos += thishdr_size; |
209 | thisrec++; | 209 | thisrec++; |
210 | gotorecordnumber(thisrec); | 210 | gotorecordnumber(thisrec); |
211 | } | 211 | } |
212 | return locpos+bufferpos; | 212 | return locpos+bufferpos; |
213 | */ | 213 | */ |
214 | } | 214 | } |
215 | 215 | ||
216 | void CPlucker_base::locate(unsigned int n) | 216 | void CPlucker_base::locate(unsigned int n) |
217 | { | 217 | { |
218 | 218 | ||
219 | // clock_t start = clock(); | 219 | // clock_t start = clock(); |
220 | if (n >= currentpos-bufferpos && n < currentpos - bufferpos + buffercontent) | 220 | if (n >= currentpos-bufferpos && n < currentpos - bufferpos + buffercontent) |
221 | { | 221 | { |
222 | currentpos -= bufferpos; | 222 | currentpos -= bufferpos; |
223 | expand(bufferrec); | 223 | expand(bufferrec); |
224 | while (currentpos < n && bufferpos < buffercontent) getch_base(true); | 224 | while (currentpos < n && bufferpos < buffercontent) getch_base(true); |
225 | return; | 225 | return; |
226 | } | 226 | } |
227 | /* | 227 | /* |
228 | 228 | ||
229 | UInt32 textlength = currentpos - bufferpos; | 229 | UInt32 textlength = currentpos - bufferpos; |
230 | UInt16 recptr = bufferrec; | 230 | UInt16 recptr = bufferrec; |
231 | if (n < textlength/2) | 231 | if (n < textlength/2) |
232 | { | 232 | { |
233 | textlength = 0; | 233 | textlength = 0; |
234 | UInt16 thishdr_uid, thishdr_nParagraphs; | 234 | UInt16 thishdr_uid, thishdr_nParagraphs; |
235 | UInt32 thishdr_size = buffercontent; | 235 | UInt32 thishdr_size = buffercontent; |
236 | UInt8 thishdr_type, thishdr_reserved; | 236 | UInt8 thishdr_type, thishdr_reserved; |
237 | for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 237 | for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
238 | { | 238 | { |
239 | gotorecordnumber(recptr); | 239 | gotorecordnumber(recptr); |
240 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 240 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
241 | if (thishdr_type < 2) | 241 | if (thishdr_type < 2) |
242 | { | 242 | { |
243 | textlength += thishdr_size; | 243 | textlength += thishdr_size; |
244 | if (textlength > n) | 244 | if (textlength > n) |
245 | { | 245 | { |
246 | textlength -= thishdr_size; | 246 | textlength -= thishdr_size; |
247 | break; | 247 | break; |
248 | } | 248 | } |
249 | } | 249 | } |
250 | } | 250 | } |
251 | } | 251 | } |
252 | else if (n < textlength) | 252 | else if (n < textlength) |
253 | { | 253 | { |
254 | UInt16 thishdr_uid, thishdr_nParagraphs; | 254 | UInt16 thishdr_uid, thishdr_nParagraphs; |
255 | UInt32 thishdr_size; | 255 | UInt32 thishdr_size; |
256 | UInt8 thishdr_type, thishdr_reserved; | 256 | UInt8 thishdr_type, thishdr_reserved; |
257 | while (n < textlength && recptr > 1) | 257 | while (n < textlength && recptr > 1) |
258 | { | 258 | { |
259 | recptr--; | 259 | recptr--; |
260 | gotorecordnumber(recptr); | 260 | gotorecordnumber(recptr); |
261 | //qDebug("recptr:%u", recptr); | 261 | //qDebug("recptr:%u", recptr); |
262 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 262 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
263 | if (thishdr_type < 2) | 263 | if (thishdr_type < 2) |
264 | { | 264 | { |
265 | textlength -= thishdr_size; | 265 | textlength -= thishdr_size; |
266 | } | 266 | } |
267 | } | 267 | } |
268 | } | 268 | } |
269 | else | 269 | else |
270 | { | 270 | { |
271 | UInt16 thishdr_uid, thishdr_nParagraphs; | 271 | UInt16 thishdr_uid, thishdr_nParagraphs; |
272 | UInt32 thishdr_size = buffercontent; | 272 | UInt32 thishdr_size = buffercontent; |
273 | UInt8 thishdr_type, thishdr_reserved; | 273 | UInt8 thishdr_type, thishdr_reserved; |
274 | while (n > textlength + thishdr_size && recptr < ntohs(head.recordList.numRecords)-1) | 274 | while (n > textlength + thishdr_size && recptr < ntohs(head.recordList.numRecords)-1) |
275 | { | 275 | { |
276 | textlength += thishdr_size; | 276 | textlength += thishdr_size; |
277 | recptr++; | 277 | recptr++; |
278 | gotorecordnumber(recptr); | 278 | gotorecordnumber(recptr); |
279 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 279 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
280 | if (!(thishdr_type < 2)) | 280 | if (!(thishdr_type < 2)) |
281 | { | 281 | { |
282 | thishdr_size = 0; | 282 | thishdr_size = 0; |
283 | } | 283 | } |
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | */ | 287 | */ |
288 | UInt16 thisrec = 0; | 288 | UInt16 thisrec = 0; |
289 | unsigned long locpos = 0; | 289 | unsigned long locpos = 0; |
290 | unsigned long bs = 0; | 290 | unsigned long bs = 0; |
291 | UInt16 thishdr_uid, thishdr_nParagraphs; | 291 | UInt16 thishdr_uid, thishdr_nParagraphs; |
292 | UInt32 thishdr_size; | 292 | UInt32 thishdr_size; |
293 | UInt8 thishdr_type, thishdr_reserved; | 293 | UInt8 thishdr_type, thishdr_reserved; |
294 | do | 294 | do |
295 | { | 295 | { |
296 | thisrec++; | 296 | thisrec++; |
297 | locpos += bs; | 297 | locpos += bs; |
298 | gotorecordnumber(thisrec); | 298 | gotorecordnumber(thisrec); |
299 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 299 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
300 | if (thishdr_type < 2) | 300 | if (thishdr_type < 2) |
301 | { | 301 | { |
302 | bs = thishdr_size; | 302 | bs = thishdr_size; |
303 | } | 303 | } |
304 | else | 304 | else |
305 | { | 305 | { |
306 | bs = 0; | 306 | bs = 0; |
307 | } | 307 | } |
308 | } while (locpos + bs <= n); | 308 | } while (locpos + bs < n); |
309 | 309 | ||
310 | // qDebug("Time(2): %u", clock()-start); | 310 | // qDebug("Time(2): %u", clock()-start); |
311 | /* | 311 | /* |
312 | if (recptr != thisrec) | 312 | if (recptr != thisrec) |
313 | { | 313 | { |
314 | qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec); | 314 | qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec); |
315 | UInt16 thishdr_uid, thishdr_nParagraphs; | 315 | UInt16 thishdr_uid, thishdr_nParagraphs; |
316 | UInt32 thishdr_size = buffercontent; | 316 | UInt32 thishdr_size = buffercontent; |
317 | UInt8 thishdr_type, thishdr_reserved; | 317 | UInt8 thishdr_type, thishdr_reserved; |
318 | for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 318 | for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
319 | { | 319 | { |
320 | gotorecordnumber(recptr); | 320 | gotorecordnumber(recptr); |
321 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 321 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
322 | // qDebug("UID:%u Paras:%u Size:%u Type:%u Reserved:%u", thishdr_uid, thishdr_nParagraphs, thishdr_size, (unsigned int)thishdr_type, (unsigned int)thishdr_reserved); | 322 | // qDebug("UID:%u Paras:%u Size:%u Type:%u Reserved:%u", thishdr_uid, thishdr_nParagraphs, thishdr_size, (unsigned int)thishdr_type, (unsigned int)thishdr_reserved); |
323 | } | 323 | } |
324 | //QApplication::exit ( 100 ); | 324 | //QApplication::exit ( 100 ); |
325 | } | 325 | } |
326 | */ | 326 | */ |
327 | currentpos = locpos; | 327 | currentpos = locpos; |
328 | expand(thisrec); | 328 | expand(thisrec); |
329 | while (currentpos < n && bufferpos < buffercontent) getch_base(true); | 329 | while (currentpos < n && bufferpos < buffercontent) getch_base(true); |
330 | 330 | ||
331 | /* // This is faster but the alignment attribute doesn't get set 8^( | 331 | /* // This is faster but the alignment attribute doesn't get set 8^( |
332 | bufferpos = n-locpos; | 332 | bufferpos = n-locpos; |
333 | currentpos = n; | 333 | currentpos = n; |
334 | while (bufferpos >= m_nextPara && m_nextPara >= 0) | 334 | while (bufferpos >= m_nextPara && m_nextPara >= 0) |
335 | { | 335 | { |
336 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; | 336 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; |
337 | m_nextParaIndex++; | 337 | m_nextParaIndex++; |
338 | if (m_nextParaIndex == m_nParas) | 338 | if (m_nextParaIndex == m_nParas) |
339 | { | 339 | { |
340 | m_nextPara = -1; | 340 | m_nextPara = -1; |
341 | } | 341 | } |
342 | else | 342 | else |
343 | { | 343 | { |
344 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | 344 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; |
345 | } | 345 | } |
346 | } | 346 | } |
347 | */ | 347 | */ |
348 | } | 348 | } |
349 | 349 | ||
350 | bool CPlucker_base::expand(int thisrec) | 350 | bool CPlucker_base::expand(int thisrec) |
351 | { | 351 | { |
352 | mystyle.unset(); | 352 | mystyle.unset(); |
353 | if (bufferrec != thisrec) | 353 | if (bufferrec != thisrec) |
354 | { | 354 | { |
355 | size_t reclen = recordlength(thisrec); | 355 | size_t reclen = recordlength(thisrec); |
356 | gotorecordnumber(thisrec); | 356 | gotorecordnumber(thisrec); |
357 | UInt16 thishdr_uid, thishdr_nParagraphs; | 357 | UInt16 thishdr_uid, thishdr_nParagraphs; |
358 | UInt32 thishdr_size; | 358 | UInt32 thishdr_size; |
359 | UInt8 thishdr_type, thishdr_reserved; | 359 | UInt8 thishdr_type, thishdr_reserved; |
360 | while (1) | 360 | while (1) |
361 | { | 361 | { |
362 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 362 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
363 | //qDebug("This (%d) type is %d, uid is %u", thisrec, thishdr_type, thishdr_uid); | 363 | //qDebug("This (%d) type is %d, uid is %u", thisrec, thishdr_type, thishdr_uid); |
364 | if (thishdr_type < 2) break; | 364 | if (thishdr_type < 2) break; |
365 | //qDebug("Skipping paragraph of type %d", thishdr_type); | 365 | //qDebug("Skipping paragraph of type %d", thishdr_type); |
366 | if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; | 366 | if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; |
367 | reclen = recordlength(thisrec); | 367 | reclen = recordlength(thisrec); |
368 | gotorecordnumber(thisrec); | 368 | gotorecordnumber(thisrec); |
369 | } | 369 | } |
370 | m_nParas = thishdr_nParagraphs; | 370 | m_nParas = thishdr_nParagraphs; |
371 | m_bufferisreserved = (thishdr_reserved != 0); | 371 | m_bufferisreserved = (thishdr_reserved != 0); |
372 | //qDebug("It has %u paragraphs and is %u bytes", thishdr_nParagraphs, thishdr_size); | 372 | //qDebug("It has %u paragraphs and is %u bytes", thishdr_nParagraphs, thishdr_size); |
373 | uid = thishdr_uid; | 373 | uid = thishdr_uid; |
374 | // gotorecordnumber(thisrec); | 374 | // gotorecordnumber(thisrec); |
375 | // fread(expandedtextbuffer,1,10,fin); | 375 | // fread(expandedtextbuffer,1,10,fin); |
376 | for (int i = 0; i < m_nParas; i++) | 376 | for (int i = 0; i < m_nParas; i++) |
377 | { | 377 | { |
378 | UInt16 ubytes, attrs; | 378 | UInt16 ubytes, attrs; |
379 | fread(&ubytes, 1, sizeof(ubytes), fin); | 379 | fread(&ubytes, 1, sizeof(ubytes), fin); |
380 | fread(&attrs, 1, sizeof(attrs), fin); | 380 | fread(&attrs, 1, sizeof(attrs), fin); |
381 | m_ParaOffsets[i] = ntohs(ubytes); | 381 | m_ParaOffsets[i] = ntohs(ubytes); |
382 | m_ParaAttrs[i] = ntohs(attrs); | 382 | m_ParaAttrs[i] = ntohs(attrs); |
383 | ////qDebug("Bytes %u, Attr %x", ntohs(ubytes), ntohs(attrs)); | 383 | ////qDebug("Bytes %u, Attr %x", ntohs(ubytes), ntohs(attrs)); |
384 | } | 384 | } |
385 | 385 | ||
386 | reclen -= HeaderSize()+4*m_nParas; | 386 | reclen -= HeaderSize()+4*m_nParas; |
387 | 387 | ||
388 | buffercontent = thishdr_size; | 388 | buffercontent = thishdr_size; |
389 | 389 | ||
390 | if (thishdr_size > buffersize) | 390 | if (thishdr_size > buffersize) |
391 | { | 391 | { |
392 | delete [] expandedtextbuffer; | 392 | delete [] expandedtextbuffer; |
393 | buffersize = thishdr_size; | 393 | buffersize = thishdr_size; |
394 | expandedtextbuffer = new UInt8[buffersize]; | 394 | expandedtextbuffer = new UInt8[buffersize]; |
395 | } | 395 | } |
396 | Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent); | 396 | Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent); |
397 | bufferrec = thisrec; | 397 | bufferrec = thisrec; |
398 | } | 398 | } |
399 | 399 | ||
400 | 400 | ||
401 | if (m_nParas > 0) | 401 | if (m_nParas > 0) |
402 | { | 402 | { |
403 | m_nextPara = m_ParaOffsets[0]; | 403 | m_nextPara = m_ParaOffsets[0]; |
404 | //qDebug("First offset = %u", m_nextPara); | 404 | //qDebug("First offset = %u", m_nextPara); |
405 | m_nextParaIndex = 0; | 405 | m_nextParaIndex = 0; |
406 | } | 406 | } |
407 | else | 407 | else |
408 | { | 408 | { |
409 | m_nextPara = -1; | 409 | m_nextPara = -1; |
410 | } | 410 | } |
411 | bufferpos = 0; | 411 | bufferpos = 0; |
412 | //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size); | 412 | //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size); |
413 | return true; | 413 | return true; |
414 | } | 414 | } |
415 | 415 | /* | |
416 | void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) | 416 | void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) |
417 | { | 417 | { |
418 | z_stream zstream; | 418 | z_stream zstream; |
419 | memset(&zstream,sizeof(zstream),0); | 419 | memset(&zstream,sizeof(zstream),0); |
420 | zstream.next_in = compressedbuffer; | 420 | zstream.next_in = compressedbuffer; |
421 | zstream.next_out = tgtbuffer; | 421 | zstream.next_out = tgtbuffer; |
422 | zstream.avail_out = bsize; | 422 | zstream.avail_out = bsize; |
423 | zstream.avail_in = reclen; | 423 | zstream.avail_in = reclen; |
424 | 424 | ||
425 | int keylen = 0; | 425 | int keylen = 0; |
426 | 426 | ||
427 | zstream.zalloc = Z_NULL; | 427 | zstream.zalloc = Z_NULL; |
428 | zstream.zfree = Z_NULL; | 428 | zstream.zfree = Z_NULL; |
429 | zstream.opaque = Z_NULL; | 429 | zstream.opaque = Z_NULL; |
430 | 430 | ||
431 | // printf("Initialising\n"); | 431 | // printf("Initialising\n"); |
432 | 432 | ||
433 | inflateInit(&zstream); | 433 | inflateInit(&zstream); |
434 | int err = 0; | 434 | int err = 0; |
435 | do { | 435 | do { |
436 | if ( zstream.avail_in == 0 && 0 < keylen ) { | 436 | if ( zstream.avail_in == 0 && 0 < keylen ) { |
437 | zstream.next_in = compressedbuffer + keylen; | 437 | zstream.next_in = compressedbuffer + keylen; |
438 | zstream.avail_in = reclen - keylen; | 438 | zstream.avail_in = reclen - keylen; |
439 | keylen = 0; | 439 | keylen = 0; |
440 | } | 440 | } |
441 | zstream.next_out = tgtbuffer; | 441 | zstream.next_out = tgtbuffer; |
442 | zstream.avail_out = bsize; | 442 | zstream.avail_out = bsize; |
443 | 443 | ||
444 | err = inflate( &zstream, Z_SYNC_FLUSH ); | 444 | err = inflate( &zstream, Z_SYNC_FLUSH ); |
445 | 445 | ||
446 | ////qDebug("err:%d - %u", err, zstream.avail_in); | 446 | ////qDebug("err:%d - %u", err, zstream.avail_in); |
447 | 447 | ||
448 | } while ( err == Z_OK ); | 448 | } while ( err == Z_OK ); |
449 | 449 | ||
450 | inflateEnd(&zstream); | 450 | inflateEnd(&zstream); |
451 | } | 451 | } |
452 | 452 | */ | |
453 | void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) | 453 | size_t CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) |
454 | { | 454 | { |
455 | // UInt16 headerSize; | 455 | // UInt16 headerSize; |
456 | UInt16 docSize; | 456 | UInt16 docSize; |
457 | UInt16 i; | 457 | UInt16 i; |
458 | UInt16 j; | 458 | UInt16 j; |
459 | UInt16 k; | 459 | UInt16 k; |
460 | 460 | ||
461 | UInt8 *inBuf = compressedbuffer; | 461 | UInt8 *inBuf = compressedbuffer; |
462 | UInt8 *outBuf = tgtbuffer; | 462 | UInt8 *outBuf = tgtbuffer; |
463 | 463 | ||
464 | // headerSize = sizeof( Header ) + record->paragraphs * sizeof( Paragraph ); | 464 | // headerSize = sizeof( Header ) + record->paragraphs * sizeof( Paragraph ); |
465 | docSize = reclen; | 465 | docSize = reclen; |
466 | 466 | ||
467 | j = 0; | 467 | j = 0; |
468 | k = 0; | 468 | k = 0; |
469 | while ( j < docSize ) { | 469 | while ( j < docSize ) { |
470 | i = 0; | 470 | i = 0; |
471 | while ( i < bsize && j < docSize ) { | 471 | while ( i < bsize && j < docSize ) { |
472 | UInt16 c; | 472 | UInt16 c; |
473 | 473 | ||
474 | c = (UInt16) inBuf[ j++ ]; | 474 | c = (UInt16) inBuf[ j++ ]; |
475 | if ( 0 < c && c < 9 ) { | 475 | if ( 0 < c && c < 9 ) { |
476 | while ( 0 < c-- ) | 476 | while ( 0 < c-- ) |
477 | outBuf[ i++ ] = inBuf[ j++ ]; | 477 | outBuf[ i++ ] = inBuf[ j++ ]; |
478 | } | 478 | } |
479 | else if ( c < 0x80 ) | 479 | else if ( c < 0x80 ) |
480 | outBuf[ i++ ] = c; | 480 | outBuf[ i++ ] = c; |
481 | else if ( 0xc0 <= c ) { | 481 | else if ( 0xc0 <= c ) { |
482 | outBuf[ i++ ] = ' '; | 482 | outBuf[ i++ ] = ' '; |
483 | outBuf[ i++ ] = c ^ 0x80; | 483 | outBuf[ i++ ] = c ^ 0x80; |
484 | } | 484 | } |
485 | else { | 485 | else { |
486 | Int16 m; | 486 | Int16 m; |
487 | Int16 n; | 487 | Int16 n; |
488 | 488 | ||
489 | c <<= 8; | 489 | c <<= 8; |
490 | c += inBuf[ j++ ]; | 490 | c += inBuf[ j++ ]; |
491 | 491 | ||
492 | m = ( c & 0x3fff ) >> COUNT_BITS; | 492 | m = ( c & 0x3fff ) >> COUNT_BITS; |
493 | n = c & ( ( 1 << COUNT_BITS ) - 1 ); | 493 | n = c & ( ( 1 << COUNT_BITS ) - 1 ); |
494 | n += 2; | 494 | n += 2; |
495 | 495 | ||
496 | do { | 496 | do { |
497 | outBuf[ i ] = outBuf[ i - m ]; | 497 | outBuf[ i ] = outBuf[ i - m ]; |
498 | i++; | 498 | i++; |
499 | } while ( 0 < n-- ); | 499 | } while ( 0 < n-- ); |
500 | } | 500 | } |
501 | } | 501 | } |
502 | k += bsize; | 502 | k += bsize; |
503 | } | 503 | } |
504 | return i; | ||
504 | } | 505 | } |
505 | 506 | ||
506 | void CPlucker_base::home() | 507 | void CPlucker_base::home() |
507 | { | 508 | { |
508 | currentpos = 0; | 509 | currentpos = 0; |
509 | expand(1); | 510 | expand(1); |
510 | } | 511 | } |
511 | 512 | ||
512 | CList<Bkmk>* CPlucker_base::getbkmklist() | 513 | CList<Bkmk>* CPlucker_base::getbkmklist() |
513 | { | 514 | { |
514 | /* | 515 | /* |
515 | UInt16 thishdr_uid, thishdr_nParagraphs; | 516 | UInt16 thishdr_uid, thishdr_nParagraphs; |
516 | UInt32 thishdr_size; | 517 | UInt32 thishdr_size; |
517 | UInt8 thishdr_type, thishdr_reserved; | 518 | UInt8 thishdr_type, thishdr_reserved; |
518 | 519 | ||
519 | for (int i = 1; i < ntohs(head.recordList.numRecords); i++) | 520 | for (int i = 1; i < ntohs(head.recordList.numRecords); i++) |
520 | { | 521 | { |
521 | gotorecordnumber(i); | 522 | gotorecordnumber(i); |
522 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 523 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
523 | if (thishdr_type == 8) | 524 | if (thishdr_type == 8) |
524 | { | 525 | { |
525 | UInt16 n; | 526 | UInt16 n; |
526 | fread(&n, 1, sizeof(n), fin); | 527 | fread(&n, 1, sizeof(n), fin); |
527 | n = ntohs(n); | 528 | n = ntohs(n); |
528 | //qDebug("Found %u bookmarks", n); | 529 | //qDebug("Found %u bookmarks", n); |
529 | } | 530 | } |
530 | //qDebug("Found:%d, %u", i , thishdr_type); | 531 | //qDebug("Found:%d, %u", i , thishdr_type); |
531 | } | 532 | } |
532 | */ | 533 | */ |
533 | return NULL; | 534 | return NULL; |
534 | } | 535 | } |
535 | 536 | ||
536 | #include <qnamespace.h> | 537 | #include <qnamespace.h> |
537 | 538 | ||
538 | QImage* CPlucker_base::expandimg(UInt16 tgt, bool border) | 539 | QImage* CPlucker_base::expandimg(UInt16 tgt, bool border) |
539 | { | 540 | { |
540 | QImage* qimage = getimg(tgt); | 541 | QImage* qimage = getimg(tgt); |
541 | QImage* ret; | 542 | QImage* ret; |
542 | if (qimage == NULL) return NULL; | 543 | if (qimage == NULL) return NULL; |
543 | if (border) | 544 | if (border) |
544 | { | 545 | { |
545 | QPixmap* image = new QPixmap(0,0); | 546 | QPixmap* image = new QPixmap(0,0); |
546 | image->convertFromImage(*qimage); | 547 | image->convertFromImage(*qimage); |
547 | delete qimage; | 548 | delete qimage; |
548 | QPixmap* pret = new QPixmap(image->width()+4, image->height()+4); | 549 | QPixmap* pret = new QPixmap(image->width()+4, image->height()+4); |
549 | pret->fill(Qt::red); | 550 | pret->fill(Qt::red); |
550 | bitBlt(pret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP); | 551 | bitBlt(pret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP); |
551 | delete image; | 552 | delete image; |
552 | ret = new QImage(pret->convertToImage()); | 553 | ret = new QImage(pret->convertToImage()); |
553 | } | 554 | } |
554 | else | 555 | else |
555 | { | 556 | { |
556 | ret = qimage; | 557 | ret = qimage; |
557 | } | 558 | } |
558 | return ret; | 559 | return ret; |
559 | } | 560 | } |
560 | 561 | ||
561 | #ifdef _BUFFERPICS | 562 | #ifdef _BUFFERPICS |
562 | #include <qmap.h> | 563 | #include <qmap.h> |
563 | #endif | 564 | #endif |
564 | 565 | ||
565 | QImage* CPlucker_base::getPicture(unsigned long tgt) | 566 | QImage* CPlucker_base::getPicture(unsigned long tgt) |
566 | { | 567 | { |
567 | #ifdef _BUFFERPICS | 568 | #ifdef _BUFFERPICS |
568 | static QMap<unsigned long, QPixmap> pix; | 569 | static QMap<unsigned long, QPixmap> pix; |
569 | QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt); | 570 | QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt); |
570 | if (t == pix.end()) | 571 | if (t == pix.end()) |
571 | { | 572 | { |
572 | pix[tgt] = *expandimg(tgt); | 573 | pix[tgt] = *expandimg(tgt); |
573 | return &pix[tgt]; | 574 | return &pix[tgt]; |
574 | } | 575 | } |
575 | else | 576 | else |
576 | return &(t.data()); | 577 | return &(t.data()); |
577 | #else | 578 | #else |
578 | return expandimg(tgt >> 16); | 579 | return expandimg(tgt >> 16); |
579 | #endif | 580 | #endif |
580 | } | 581 | } |
581 | 582 | ||
582 | #ifdef LOCALPICTURES | 583 | #ifdef LOCALPICTURES |
583 | #include <unistd.h> | 584 | #include <unistd.h> |
584 | #include <qpe/global.h> | 585 | #include <qpe/global.h> |
585 | void CPlucker_base::showimg(UInt16 tgt) | 586 | void CPlucker_base::showimg(UInt16 tgt) |
586 | { | 587 | { |
587 | //qDebug("Crassssssh!"); | 588 | //qDebug("Crassssssh!"); |
588 | QPixmap* qimage = expandimg(tgt); | 589 | QPixmap* qimage = expandimg(tgt); |
589 | m_picture->setFixedSize(qimage->size()); | 590 | m_picture->setFixedSize(qimage->size()); |
590 | m_picture->setBackgroundPixmap(*qimage); | 591 | m_picture->setBackgroundPixmap(*qimage); |
591 | delete qimage; | 592 | delete qimage; |
592 | m_viewer->show(); | 593 | m_viewer->show(); |
593 | 594 | ||
594 | /* | 595 | /* |
595 | char tmp[] = "uqtreader.XXXXXX"; | 596 | char tmp[] = "uqtreader.XXXXXX"; |
596 | QImage* qimage = getimg(tgt); | 597 | QImage* qimage = getimg(tgt); |
597 | QPixmap* image = new QPixmap(0,0); | 598 | QPixmap* image = new QPixmap(0,0); |
598 | // //qDebug("New image"); | 599 | // //qDebug("New image"); |
599 | image->convertFromImage(*qimage); | 600 | image->convertFromImage(*qimage); |
600 | delete qimage; | 601 | delete qimage; |
601 | char tmpfile[sizeof(tmp)+1]; | 602 | char tmpfile[sizeof(tmp)+1]; |
602 | strcpy(tmpfile,tmp); | 603 | strcpy(tmpfile,tmp); |
603 | int f = mkstemp(tmpfile); | 604 | int f = mkstemp(tmpfile); |
604 | close(f); | 605 | close(f); |
605 | //qDebug("TMPFILE:%s", tmpfile); | 606 | //qDebug("TMPFILE:%s", tmpfile); |
606 | if (image->save(tmpfile,"PNG")) | 607 | if (image->save(tmpfile,"PNG")) |
607 | { | 608 | { |
608 | QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)"); | 609 | QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)"); |
609 | e << QString(tmpfile); | 610 | e << QString(tmpfile); |
610 | } | 611 | } |
611 | Global::statusMessage("Opening image"); | 612 | Global::statusMessage("Opening image"); |
612 | sleep(5); | 613 | sleep(5); |
613 | delete image; | 614 | delete image; |
614 | unlink(tmpfile); | 615 | unlink(tmpfile); |
615 | */ | 616 | */ |
616 | } | 617 | } |
617 | 618 | ||
618 | #endif | 619 | #endif |
619 | 620 | ||
620 | unsigned short CPlucker_base::finduid(unsigned short urlid) | 621 | unsigned short CPlucker_base::finduid(unsigned short urlid) |
621 | { | 622 | { |
622 | // //qDebug("Finding %u", urlid); | 623 | // //qDebug("Finding %u", urlid); |
623 | unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); | 624 | unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); |
624 | unsigned short jmid = (jmin+jmax) >> 1; | 625 | unsigned short jmid = (jmin+jmax) >> 1; |
625 | while (jmax - jmin > 1) | 626 | while (jmax - jmin > 1) |
626 | { | 627 | { |
627 | gotorecordnumber(jmid); | 628 | gotorecordnumber(jmid); |
628 | UInt16 thishdr_uid, thishdr_nParagraphs; | 629 | UInt16 thishdr_uid, thishdr_nParagraphs; |
629 | UInt32 thishdr_size; | 630 | UInt32 thishdr_size; |
630 | UInt8 thishdr_type, thishdr_reserved; | 631 | UInt8 thishdr_type, thishdr_reserved; |
631 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 632 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
632 | unsigned short luid = thishdr_uid; | 633 | unsigned short luid = thishdr_uid; |
633 | ////qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); | 634 | ////qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); |
634 | if (luid == urlid) | 635 | if (luid == urlid) |
635 | { | 636 | { |
636 | return jmid; | 637 | return jmid; |
637 | } | 638 | } |
638 | if (luid < urlid) | 639 | if (luid < urlid) |
639 | { | 640 | { |
640 | jmin = jmid; | 641 | jmin = jmid; |
641 | } | 642 | } |
642 | else | 643 | else |
643 | { | 644 | { |
644 | jmax = jmid; | 645 | jmax = jmid; |
645 | } | 646 | } |
646 | jmid = (jmin+jmax) >> 1; | 647 | jmid = (jmin+jmax) >> 1; |
647 | } | 648 | } |
648 | gotorecordnumber(jmin); | 649 | gotorecordnumber(jmin); |
649 | UInt16 thishdr_uid, thishdr_nParagraphs; | 650 | UInt16 thishdr_uid, thishdr_nParagraphs; |
650 | UInt32 thishdr_size; | 651 | UInt32 thishdr_size; |
651 | UInt8 thishdr_type, thishdr_reserved; | 652 | UInt8 thishdr_type, thishdr_reserved; |
652 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 653 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
653 | unsigned short luid = thishdr_uid; | 654 | unsigned short luid = thishdr_uid; |
654 | //qDebug("jmin at end:%u,%u", jmin, luid); | 655 | //qDebug("jmin at end:%u,%u", jmin, luid); |
655 | if (luid == urlid) | 656 | if (luid == urlid) |
656 | { | 657 | { |
657 | return jmin; | 658 | return jmin; |
658 | } | 659 | } |
659 | gotorecordnumber(jmax); | 660 | gotorecordnumber(jmax); |
660 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 661 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
661 | luid = thishdr_uid; | 662 | luid = thishdr_uid; |
662 | //qDebug("jmax at end:%u,%u", jmax, luid); | 663 | //qDebug("jmax at end:%u,%u", jmax, luid); |
663 | if (luid == urlid) | 664 | if (luid == urlid) |
664 | { | 665 | { |
665 | return jmax; | 666 | return jmax; |
666 | } | 667 | } |
667 | //qDebug("Couldn't find %u", urlid); | 668 | //qDebug("Couldn't find %u", urlid); |
668 | return 0; // Not found! | 669 | return 0; // Not found! |
669 | } | 670 | } |
670 | 671 | ||
671 | #include <qnamespace.h> | 672 | #include <qnamespace.h> |
672 | 673 | ||
673 | void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | 674 | void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) |
674 | { | 675 | { |
675 | unsigned short sz = 0; | 676 | unsigned short sz = 0; |
676 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | 677 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) |
677 | { | 678 | { |
678 | sz++; | 679 | sz++; |
679 | } | 680 | } |
680 | size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long); | 681 | size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long); |
681 | unsigned char* newdata = new unsigned char[newlen]; | 682 | unsigned char* newdata = new unsigned char[newlen]; |
682 | unsigned char* pdata = newdata; | 683 | unsigned char* pdata = newdata; |
683 | memcpy(newdata, src, srclen); | 684 | memcpy(newdata, src, srclen); |
684 | newdata += srclen; | 685 | newdata += srclen; |
685 | memcpy(newdata, &sz, sizeof(sz)); | 686 | memcpy(newdata, &sz, sizeof(sz)); |
686 | newdata += sizeof(sz); | 687 | newdata += sizeof(sz); |
687 | #ifdef _WINDOWS | 688 | #ifdef _WINDOWS |
688 | for (it = visited.begin(); it != visited.end(); it++) | 689 | for (it = visited.begin(); it != visited.end(); it++) |
689 | #else | 690 | #else |
690 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | 691 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) |
691 | #endif | 692 | #endif |
692 | { | 693 | { |
693 | unsigned long t = *it; | 694 | unsigned long t = *it; |
694 | //qDebug("[%u]", t); | 695 | //qDebug("[%u]", t); |
695 | memcpy(newdata, &t, sizeof(t)); | 696 | memcpy(newdata, &t, sizeof(t)); |
696 | newdata += sizeof(t); | 697 | newdata += sizeof(t); |
697 | } | 698 | } |
698 | m_nav.setSaveData(data, len, pdata, newlen); | 699 | m_nav.setSaveData(data, len, pdata, newlen); |
699 | delete [] pdata; | 700 | delete [] pdata; |
700 | } | 701 | } |
701 | 702 | ||
702 | void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen) | 703 | void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen) |
703 | { | 704 | { |
704 | unsigned short sz; | 705 | unsigned short sz; |
705 | if (srclen >= sizeof(sz)) | 706 | if (srclen >= sizeof(sz)) |
706 | { | 707 | { |
707 | memcpy(&sz, src, sizeof(sz)); | 708 | memcpy(&sz, src, sizeof(sz)); |
708 | src += sizeof(sz); | 709 | src += sizeof(sz); |
709 | srclen -= sizeof(sz); | 710 | srclen -= sizeof(sz); |
710 | } | 711 | } |
711 | for (int i = 0; i < sz; i++) | 712 | for (int i = 0; i < sz; i++) |
712 | { | 713 | { |
713 | unsigned long t; | 714 | unsigned long t; |
714 | if (srclen >= sizeof(t)) | 715 | if (srclen >= sizeof(t)) |
715 | { | 716 | { |
716 | memcpy(&t, src, sizeof(t)); | 717 | memcpy(&t, src, sizeof(t)); |
717 | // qDebug("[%u]", t); | 718 | // qDebug("[%u]", t); |
718 | visited.push_front(t); | 719 | visited.push_front(t); |
719 | src += sizeof(t); | 720 | src += sizeof(t); |
720 | srclen -= sizeof(t); | 721 | srclen -= sizeof(t); |
721 | } | 722 | } |
722 | else | 723 | else |
723 | { | 724 | { |
724 | QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself"); | 725 | QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself"); |
725 | break; | 726 | break; |
726 | } | 727 | } |
727 | } | 728 | } |
728 | m_nav.putSaveData(src, srclen); | 729 | m_nav.putSaveData(src, srclen); |
729 | } | 730 | } |
730 | 731 | ||
731 | int CPlucker_base::OpenFile(const char *src) | 732 | int CPlucker_base::OpenFile(const char *src) |
732 | { | 733 | { |
733 | qDebug("plucker openfile:%s", src); | 734 | qDebug("plucker openfile:%s", src); |
734 | m_lastBreak = 0; | 735 | m_lastBreak = 0; |
735 | if (!Cpdb::openpdbfile(src)) | 736 | if (!Cpdb::openpdbfile(src)) |
736 | { | 737 | { |
737 | return -1; | 738 | return -1; |
738 | } | 739 | } |
739 | 740 | ||
740 | if (!CorrectDecoder()) return -1; | 741 | if (!CorrectDecoder()) return -1; |
741 | 742 | ||
742 | gotorecordnumber(0); | 743 | gotorecordnumber(0); |
743 | fread(&hdr0, 1, 6, fin); | 744 | fread(&hdr0, 1, 6, fin); |
744 | qDebug("Compression type:%u", ntohs(hdr0.version)); | 745 | qDebug("Compression type:%u", ntohs(hdr0.version)); |
745 | 746 | ||
746 | 747 | ||
747 | switch (ntohs(hdr0.version)) | 748 | switch (ntohs(hdr0.version)) |
748 | { | 749 | { |
749 | case 2: | 750 | case 2: |
750 | m_decompress = UnZip; | 751 | m_decompress = UnZip; |
751 | break; | 752 | break; |
752 | case 1: | 753 | case 1: |
753 | m_decompress = UnDoc; | 754 | m_decompress = UnDoc; |
754 | break; | 755 | break; |
755 | #ifdef USENEF | 756 | #ifdef USENEF |
756 | case 3: | 757 | case 3: |
757 | m_decompress = getdecompressor("PluckerDecompress3"); | 758 | m_decompress = getdecompressor("PluckerDecompress3"); |
758 | break; | 759 | break; |
759 | case 4: | 760 | case 4: |
760 | m_decompress = getdecompressor("PluckerDecompress4"); | 761 | m_decompress = getdecompressor("PluckerDecompress4"); |
761 | break; | 762 | break; |
762 | #endif | 763 | #endif |
763 | default: | 764 | default: |
764 | m_decompress = NULL; | 765 | m_decompress = NULL; |
765 | } | 766 | } |
766 | if (m_decompress == NULL) return -1; | 767 | if (m_decompress == NULL) return -1; |
767 | 768 | ||
768 | setbuffersize(); | 769 | setbuffersize(); |
769 | compressedtextbuffer = new UInt8[compressedbuffersize]; | 770 | compressedtextbuffer = new UInt8[compressedbuffersize]; |
770 | expandedtextbuffer = new UInt8[buffersize]; | 771 | expandedtextbuffer = new UInt8[buffersize]; |
771 | 772 | ||
772 | unsigned int nrecs = ntohs(hdr0.nRecords); | 773 | unsigned int nrecs = ntohs(hdr0.nRecords); |
773 | qDebug("Version %u, no. reserved recs %u", ntohs(hdr0.version), nrecs); | 774 | qDebug("Version %u, no. reserved recs %u", ntohs(hdr0.version), nrecs); |
774 | textlength = ntohl(head.sortInfoID); | 775 | textlength = ntohl(head.sortInfoID); |
775 | qDebug("Textlength at startup:%u", textlength); | 776 | qDebug("Textlength at startup:%u", textlength); |
776 | UInt16 homerecid = 1; | 777 | UInt16 homerecid = 1; |
777 | for (unsigned int i = 0; i < nrecs; i++) | 778 | for (unsigned int i = 0; i < nrecs; i++) |
778 | { | 779 | { |
779 | UInt16 id, name; | 780 | UInt16 id, name; |
780 | fread(&name, 1, sizeof(name), fin); | 781 | fread(&name, 1, sizeof(name), fin); |
781 | fread(&id, 1, sizeof(id), fin); | 782 | fread(&id, 1, sizeof(id), fin); |
782 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); | 783 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); |
783 | if (ntohs(name) == 0) homerecid = ntohs(id); | 784 | if (ntohs(name) == 0) homerecid = ntohs(id); |
784 | } | 785 | } |
785 | 786 | ||
786 | textlength = 0; | 787 | textlength = 0; |
787 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 788 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
788 | { | 789 | { |
789 | gotorecordnumber(recptr); | 790 | gotorecordnumber(recptr); |
790 | UInt16 thishdr_uid, thishdr_nParagraphs; | 791 | UInt16 thishdr_uid, thishdr_nParagraphs; |
791 | UInt32 thishdr_size; | 792 | UInt32 thishdr_size; |
792 | UInt8 thishdr_type, thishdr_reserved; | 793 | UInt8 thishdr_type, thishdr_reserved; |
793 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 794 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
794 | if (thishdr_uid == homerecid) | 795 | if (thishdr_uid == homerecid) |
795 | { | 796 | { |
796 | m_homepos = textlength; | 797 | m_homepos = textlength; |
797 | break; | 798 | break; |
798 | } | 799 | } |
799 | if (thishdr_type < 2) textlength += thishdr_size; | 800 | if (thishdr_type < 2) textlength += thishdr_size; |
800 | } | 801 | } |
801 | qDebug("Found home"); | 802 | qDebug("Found home"); |
802 | textlength = 0; | 803 | textlength = 0; |
803 | home(); | 804 | home(); |
804 | qDebug("Gone home"); | 805 | qDebug("Gone home"); |
805 | #ifdef LOCALPICTURES | 806 | #ifdef LOCALPICTURES |
806 | if (m_viewer == NULL) | 807 | if (m_viewer == NULL) |
807 | { | 808 | { |
808 | m_viewer = new QScrollView(NULL); | 809 | m_viewer = new QScrollView(NULL); |
809 | m_picture = new QWidget(m_viewer->viewport()); | 810 | m_picture = new QWidget(m_viewer->viewport()); |
810 | m_viewer->addChild(m_picture); | 811 | m_viewer->addChild(m_picture); |
811 | } | 812 | } |
812 | #endif | 813 | #endif |
813 | return 0; | 814 | return 0; |
814 | 815 | ||
815 | } | 816 | } |
816 | 817 | ||
817 | QImage* CPlucker_base::getimg(UInt16 tgt) | 818 | QImage* CPlucker_base::getimg(UInt16 tgt) |
818 | { | 819 | { |
819 | size_t reclen; | 820 | size_t reclen; |
820 | UInt16 thisrec = finduid(tgt); | 821 | UInt16 thisrec = finduid(tgt); |
821 | qDebug("getimg:Found %u from uid:%u", thisrec, tgt); | 822 | qDebug("getimg:Found %u from uid:%u", thisrec, tgt); |
822 | reclen = recordlength(thisrec); | 823 | reclen = recordlength(thisrec); |
823 | gotorecordnumber(thisrec); | 824 | gotorecordnumber(thisrec); |
824 | UInt16 thishdr_uid, thishdr_nParagraphs; | 825 | UInt16 thishdr_uid, thishdr_nParagraphs; |
825 | UInt32 thishdr_size; | 826 | UInt32 thishdr_size; |
826 | UInt8 thishdr_type, thishdr_reserved; | 827 | UInt8 thishdr_type, thishdr_reserved; |
827 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 828 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
828 | if (thishdr_type == 15) | 829 | if (thishdr_type == 15) |
829 | { | 830 | { |
830 | char *buffer = new char[thishdr_size]; | 831 | char *buffer = new char[thishdr_size]; |
831 | fread(buffer, thishdr_size, sizeof(char), fin); | 832 | fread(buffer, thishdr_size, sizeof(char), fin); |
832 | unsigned short tmp; | 833 | unsigned short tmp; |
833 | memcpy(&tmp, buffer, sizeof(tmp)); | 834 | memcpy(&tmp, buffer, sizeof(tmp)); |
834 | unsigned short cols = ntohs(tmp); | 835 | unsigned short cols = ntohs(tmp); |
835 | memcpy(&tmp, buffer+sizeof(tmp), sizeof(tmp)); | 836 | memcpy(&tmp, buffer+sizeof(tmp), sizeof(tmp)); |
836 | unsigned short rows = ntohs(tmp); | 837 | unsigned short rows = ntohs(tmp); |
837 | qDebug("Found a picture of type:%u [%u,%u]", thishdr_type, rows, cols); | 838 | qDebug("Found a picture of type:%u [%u,%u]", thishdr_type, rows, cols); |
838 | QImage*** images; | 839 | QImage*** images; |
839 | images = new QImage**[rows]; | 840 | images = new QImage**[rows]; |
840 | #ifdef _WINDOWS | 841 | #ifdef _WINDOWS |
841 | int i; | 842 | int i; |
842 | for (i = 0; i < rows; i++) | 843 | for (i = 0; i < rows; i++) |
843 | #else | 844 | #else |
844 | for (int i = 0; i < rows; i++) | 845 | for (int i = 0; i < rows; i++) |
845 | #endif | 846 | #endif |
846 | { | 847 | { |
847 | images[i] = new QImage*[cols]; | 848 | images[i] = new QImage*[cols]; |
848 | } | 849 | } |
849 | int height = 0; | 850 | int height = 0; |
850 | int width = 0; | 851 | int width = 0; |
851 | #ifdef _WINDOWS | 852 | #ifdef _WINDOWS |
852 | for (i = 0; i < rows; i++) | 853 | for (i = 0; i < rows; i++) |
853 | #else | 854 | #else |
854 | for (int i = 0; i < rows; i++) | 855 | for (int i = 0; i < rows; i++) |
855 | #endif | 856 | #endif |
856 | { | 857 | { |
857 | width = 0; | 858 | width = 0; |
858 | for (int j = 0; j < cols; j++) | 859 | for (int j = 0; j < cols; j++) |
859 | { | 860 | { |
860 | memcpy(&tmp, buffer+(i*cols+j+2)*sizeof(tmp), sizeof(tmp)); | 861 | memcpy(&tmp, buffer+(i*cols+j+2)*sizeof(tmp), sizeof(tmp)); |
861 | unsigned short uid = ntohs(tmp); | 862 | unsigned short uid = ntohs(tmp); |
862 | images[i][j] = getimg(uid); | 863 | images[i][j] = getimg(uid); |
863 | width += images[i][j]->width(); | 864 | width += images[i][j]->width(); |
864 | } | 865 | } |
865 | height += images[i][0]->height(); | 866 | height += images[i][0]->height(); |
866 | } | 867 | } |
867 | delete [] buffer; | 868 | delete [] buffer; |
868 | QPixmap pm(width, height); | 869 | QPixmap pm(width, height); |
869 | int hoffset = 0; | 870 | int hoffset = 0; |
870 | #ifdef _WINDOWS | 871 | #ifdef _WINDOWS |
871 | for (i = 0; i < rows; i++) | 872 | for (i = 0; i < rows; i++) |
872 | #else | 873 | #else |
873 | for (int i = 0; i < rows; i++) | 874 | for (int i = 0; i < rows; i++) |
874 | #endif | 875 | #endif |
875 | { | 876 | { |
876 | int woffset = 0; | 877 | int woffset = 0; |
877 | int delht = images[i][0]->height(); | 878 | int delht = images[i][0]->height(); |
878 | for (int j = 0; j < cols; j++) | 879 | for (int j = 0; j < cols; j++) |
879 | { | 880 | { |
880 | QPixmap pm2; | 881 | QPixmap pm2; |
881 | pm2.convertFromImage(*(images[i][j])); | 882 | pm2.convertFromImage(*(images[i][j])); |
882 | delete images[i][j]; | 883 | delete images[i][j]; |
883 | bitBlt(&pm, woffset, hoffset, &pm2, 0, 0, pm2.width(), pm2.height()); | 884 | bitBlt(&pm, woffset, hoffset, &pm2, 0, 0, pm2.width(), pm2.height()); |
884 | woffset += pm2.width(); | 885 | woffset += pm2.width(); |
885 | } | 886 | } |
886 | hoffset += delht; | 887 | hoffset += delht; |
887 | } | 888 | } |
888 | #ifdef _WINDOWS | 889 | #ifdef _WINDOWS |
889 | for (i = 0; i < rows; i++) | 890 | for (i = 0; i < rows; i++) |
890 | #else | 891 | #else |
891 | for (int i = 0; i < rows; i++) | 892 | for (int i = 0; i < rows; i++) |
892 | #endif | 893 | #endif |
893 | { | 894 | { |
894 | delete [] images[i]; | 895 | delete [] images[i]; |
895 | } | 896 | } |
896 | delete [] images; | 897 | delete [] images; |
897 | return new QImage(pm.convertToImage()); | 898 | return new QImage(pm.convertToImage()); |
898 | } | 899 | } |
899 | else | 900 | else |
900 | { | 901 | { |
901 | qDebug("Found a picture of type:%u", thishdr_type); | 902 | qDebug("Found a picture of type:%u", thishdr_type); |
902 | reclen -= HeaderSize(); | 903 | reclen -= HeaderSize(); |
903 | 904 | ||
904 | UInt32 imgsize = thishdr_size; | 905 | UInt32 imgsize = thishdr_size; |
905 | UInt8* imgbuffer = new UInt8[imgsize]; | 906 | UInt8* imgbuffer = new UInt8[imgsize]; |
906 | 907 | ||
907 | Expand(reclen, thishdr_type, imgbuffer, imgsize); | 908 | Expand(reclen, thishdr_type, imgbuffer, imgsize); |
908 | 909 | ||
909 | return imagefromdata(imgbuffer, imgsize); | 910 | return imagefromdata(imgbuffer, imgsize); |
910 | } | 911 | } |
911 | } | 912 | } |
912 | 913 | ||
913 | linkType CPlucker_base::hyperlink(unsigned int n, unsigned int offset, QString& wrd, QString&) | 914 | linkType CPlucker_base::hyperlink(unsigned int n, unsigned int offset, QString& wrd, QString&) |
914 | { | 915 | { |
915 | visited.push_front(n); | 916 | visited.push_front(n); |
916 | UInt16 tuid = (n >> 16); | 917 | UInt16 tuid = (n >> 16); |
917 | n &= 0xffff; | 918 | n &= 0xffff; |
918 | char *turl = geturl(tuid); | 919 | char *turl = geturl(tuid); |
919 | if (turl != NULL) | 920 | if (turl != NULL) |
920 | { | 921 | { |
921 | qDebug("URL in PB:%s", turl); | 922 | qDebug("URL in PB:%s", turl); |
922 | wrd = turl; | 923 | wrd = turl; |
923 | delete [] turl; | 924 | delete [] turl; |
924 | } | 925 | } |
925 | else | 926 | else |
926 | { | 927 | { |
927 | wrd.truncate(0); | 928 | wrd.truncate(0); |
928 | } | 929 | } |
929 | qDebug("Hyper: UID:%u, Para:%u, Offset:%u", tuid, n, offset); | 930 | qDebug("Hyper: UID:%u, Para:%u, Offset:%u", tuid, n, offset); |
930 | UInt16 thisrec = 1; | 931 | UInt16 thisrec = 1; |
931 | currentpos = 0; | 932 | currentpos = 0; |
932 | gotorecordnumber(thisrec); | 933 | gotorecordnumber(thisrec); |
933 | UInt16 thishdr_uid, thishdr_nParagraphs; | 934 | UInt16 thishdr_uid, thishdr_nParagraphs; |
934 | UInt32 thishdr_size; | 935 | UInt32 thishdr_size; |
935 | UInt8 thishdr_type, thishdr_reserved; | 936 | UInt8 thishdr_type, thishdr_reserved; |
936 | while (1) | 937 | while (1) |
937 | { | 938 | { |
938 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 939 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
939 | if (tuid == thishdr_uid) break; | 940 | if (tuid == thishdr_uid) break; |
940 | if (thishdr_type < 2) currentpos += thishdr_size; | 941 | if (thishdr_type < 2) currentpos += thishdr_size; |
941 | ////qDebug("hyper-cp:%u", currentpos); | 942 | ////qDebug("hyper-cp:%u", currentpos); |
942 | thisrec++; | 943 | thisrec++; |
943 | if (thisrec >= ntohs(head.recordList.numRecords)) | 944 | if (thisrec >= ntohs(head.recordList.numRecords)) |
944 | { | 945 | { |
945 | if (wrd.isEmpty()) | 946 | if (wrd.isEmpty()) |
946 | { | 947 | { |
947 | QMessageBox::information(NULL, | 948 | QMessageBox::information(NULL, |
948 | QString(PROGNAME), | 949 | QString(PROGNAME), |
949 | QString("Couldn't find link") | 950 | QString("Couldn't find link") |
950 | ); | 951 | ); |
951 | } | 952 | } |
952 | else | 953 | else |
953 | { | 954 | { |
954 | #ifdef USEQPE | 955 | #ifdef USEQPE |
955 | if (wrd.length() > 10) | 956 | if (wrd.length() > 10) |
956 | { | 957 | { |
957 | Global::statusMessage(wrd.left(8) + ".."); | 958 | Global::statusMessage(wrd.left(8) + ".."); |
958 | } | 959 | } |
959 | else | 960 | else |
960 | { | 961 | { |
961 | Global::statusMessage(wrd); | 962 | Global::statusMessage(wrd); |
962 | } | 963 | } |
963 | #else | 964 | #else |
964 | #endif /* USEQPE */ | 965 | #endif /* USEQPE */ |
965 | //qDebug("Link:%s", (const char*)wrd); | 966 | //qDebug("Link:%s", (const char*)wrd); |
966 | // setlink(fn, wrd); | 967 | // setlink(fn, wrd); |
967 | } | 968 | } |
968 | return eNone; | 969 | return eNone; |
969 | } | 970 | } |
970 | gotorecordnumber(thisrec); | 971 | gotorecordnumber(thisrec); |
971 | } | 972 | } |
972 | if (thishdr_type > 1) | 973 | if (thishdr_type > 1) |
973 | { | 974 | { |
974 | if (thishdr_type == 4) | 975 | if (thishdr_type == 4) |
975 | { | 976 | { |
976 | QMessageBox::information(NULL, | 977 | QMessageBox::information(NULL, |
977 | QString(PROGNAME), | 978 | QString(PROGNAME), |
978 | QString("Mailto links\nnot yet supported (2)")); | 979 | QString("Mailto links\nnot yet supported (2)")); |
979 | } | 980 | } |
980 | else | 981 | else |
981 | { | 982 | { |
982 | if (thishdr_type > 3 && thishdr_type != 15) | 983 | if (thishdr_type > 3 && thishdr_type != 15) |
983 | { | 984 | { |
984 | QMessageBox::information(NULL, | 985 | QMessageBox::information(NULL, |
985 | QString(PROGNAME), | 986 | QString(PROGNAME), |
986 | QString("External links\nnot yet supported (2)") | 987 | QString("External links\nnot yet supported (2)") |
987 | ); | 988 | ); |
988 | return eNone; | 989 | return eNone; |
989 | } | 990 | } |
990 | else | 991 | else |
991 | { | 992 | { |
992 | #ifdef LOCALPICTURES | 993 | #ifdef LOCALPICTURES |
993 | showimg(tuid); | 994 | showimg(tuid); |
994 | #else | 995 | #else |
995 | return ePicture; | 996 | return ePicture; |
996 | #endif | 997 | #endif |
997 | } | 998 | } |
998 | } | 999 | } |
999 | return eNone; | 1000 | return eNone; |
1000 | } | 1001 | } |
1001 | /* | 1002 | /* |
1002 | if (thishdr_type == 2 || thishdr_type == 3) | 1003 | if (thishdr_type == 2 || thishdr_type == 3) |
1003 | { | 1004 | { |
1004 | expandimg(thisrec); | 1005 | expandimg(thisrec); |
1005 | 1006 | ||
1006 | } | 1007 | } |
1007 | */ | 1008 | */ |
1008 | else | 1009 | else |
1009 | { | 1010 | { |
1010 | expand(thisrec); | 1011 | expand(thisrec); |
1011 | unsigned int paraoffset = offset; | 1012 | unsigned int paraoffset = offset; |
1012 | // unsigned int noff = 0; | 1013 | // unsigned int noff = 0; |
1013 | if (n != 0) | 1014 | if (n != 0) |
1014 | { | 1015 | { |
1015 | if (n >= m_nParas) | 1016 | if (n >= m_nParas) |
1016 | { | 1017 | { |
1017 | QMessageBox::information(NULL, | 1018 | QMessageBox::information(NULL, |
1018 | QString(PROGNAME), | 1019 | QString(PROGNAME), |
1019 | QString("Error in link\nPara # too big") | 1020 | QString("Error in link\nPara # too big") |
1020 | ); | 1021 | ); |
1021 | return eNone; | 1022 | return eNone; |
1022 | } | 1023 | } |
1023 | unsigned int noff = 0; | 1024 | unsigned int noff = 0; |
1024 | for (unsigned int i = 0; i < n; i++) noff += m_ParaOffsets[i]; | 1025 | for (unsigned int i = 0; i < n; i++) noff += m_ParaOffsets[i]; |
1025 | 1026 | ||
1026 | paraoffset += noff; | 1027 | paraoffset += noff; |
1027 | } | 1028 | } |
1028 | if (paraoffset > thishdr_size) | 1029 | if (paraoffset > thishdr_size) |
1029 | { | 1030 | { |
1030 | QMessageBox::information(NULL, | 1031 | QMessageBox::information(NULL, |
1031 | QString(PROGNAME), | 1032 | QString(PROGNAME), |
1032 | QString("Error in link\nOffset too big") | 1033 | QString("Error in link\nOffset too big") |
1033 | ); | 1034 | ); |
1034 | return eNone; | 1035 | return eNone; |
1035 | } | 1036 | } |
1036 | while (bufferpos < paraoffset && bufferpos < buffercontent) getch_base(true); | 1037 | while (bufferpos < paraoffset && bufferpos < buffercontent) getch_base(true); |
1037 | //qDebug("Hyper:<%u,%u,%u>", paraoffset, bufferpos, currentpos); | 1038 | //qDebug("Hyper:<%u,%u,%u>", paraoffset, bufferpos, currentpos); |
1038 | /* // This is faster but the alignment doesn't get set | 1039 | /* // This is faster but the alignment doesn't get set |
1039 | mystyle.unset(); | 1040 | mystyle.unset(); |
1040 | bufferpos = n; | 1041 | bufferpos = n; |
1041 | currentpos += n; | 1042 | currentpos += n; |
1042 | while (bufferpos >= m_nextPara && m_nextPara >= 0) | 1043 | while (bufferpos >= m_nextPara && m_nextPara >= 0) |
1043 | { | 1044 | { |
1044 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; | 1045 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; |
1045 | m_nextParaIndex++; | 1046 | m_nextParaIndex++; |
1046 | if (m_nextParaIndex == m_nParas) | 1047 | if (m_nextParaIndex == m_nParas) |
1047 | { | 1048 | { |
1048 | m_nextPara = -1; | 1049 | m_nextPara = -1; |
1049 | } | 1050 | } |
1050 | else | 1051 | else |
1051 | { | 1052 | { |
1052 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | 1053 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; |
1053 | } | 1054 | } |
1054 | } | 1055 | } |
1055 | */ | 1056 | */ |
1056 | } | 1057 | } |
1057 | return eLink; | 1058 | return eLink; |
1058 | } | 1059 | } |
1060 | QString CPlucker_base::getTableAsHtml(unsigned long tgt) | ||
1061 | { | ||
1062 | qDebug("CPlucker_base::getTableAsHtml:%u", tgt); | ||
1063 | size_t reclen; | ||
1064 | UInt16 thisrec = finduid(tgt); | ||
1065 | qDebug("getimg:Found %u from uid:%u", thisrec, tgt); | ||
1066 | reclen = recordlength(thisrec); | ||
1067 | gotorecordnumber(thisrec); | ||
1068 | UInt16 thishdr_uid, thishdr_nParagraphs; | ||
1069 | UInt32 thishdr_size; | ||
1070 | UInt8 thishdr_type, thishdr_reserved; | ||
1071 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | ||
1072 | qDebug("Found a table of type:%u", thishdr_type); | ||
1073 | reclen -= HeaderSize(); | ||
1074 | UInt32 imgsize = thishdr_size; | ||
1075 | UInt8* imgbuffer = new UInt8[imgsize]; | ||
1076 | Expand(reclen, thishdr_type, imgbuffer, imgsize); | ||
1077 | |||
1078 | QString ret; | ||
1079 | |||
1080 | UInt16 size, columns, rows; | ||
1081 | UInt8 depth, border; | ||
1082 | UInt32 borderColour, linkColour; | ||
1083 | UInt8* dp(imgbuffer); | ||
1084 | |||
1085 | memcpy(&size, dp, sizeof(size)); | ||
1086 | size = ntohs(size); | ||
1087 | dp += sizeof(size); | ||
1088 | memcpy(&columns, dp, sizeof(columns)); | ||
1089 | columns = ntohs(columns); | ||
1090 | dp += sizeof(columns); | ||
1091 | memcpy(&rows, dp, sizeof(rows)); | ||
1092 | rows = ntohs(rows); | ||
1093 | dp += sizeof(rows); | ||
1094 | qDebug("Rows:%u Cols:%u", rows, columns); | ||
1095 | |||
1096 | memcpy(&depth, dp, sizeof(depth)); | ||
1097 | dp += sizeof(depth); | ||
1098 | memcpy(&border, dp, sizeof(border)); | ||
1099 | dp += sizeof(border); | ||
1100 | |||
1101 | qDebug("Depth:%u, Border:%u", depth, border); | ||
1102 | |||
1103 | memcpy(&borderColour, dp, sizeof(borderColour)); | ||
1104 | dp += sizeof(borderColour); | ||
1105 | memcpy(&linkColour, dp, sizeof(linkColour)); | ||
1106 | dp += sizeof(linkColour); | ||
1107 | |||
1108 | qDebug("Colours: border:%x, link:%x", borderColour, linkColour); | ||
1109 | |||
1110 | if (border) | ||
1111 | { | ||
1112 | ret = "<table border>"; | ||
1113 | } | ||
1114 | else | ||
1115 | { | ||
1116 | ret = "<table>"; | ||
1117 | } | ||
1118 | bool firstrow = true; | ||
1119 | bool firstcol = true; | ||
1120 | while (dp < imgbuffer+imgsize) | ||
1121 | { | ||
1122 | UInt8 ch = *dp++; | ||
1123 | if (ch == 0x00) | ||
1124 | { | ||
1125 | ch = *dp++; | ||
1126 | if (ch == 0x90) | ||
1127 | { | ||
1128 | if (firstrow) | ||
1129 | { | ||
1130 | ret += "<tr>"; | ||
1131 | firstrow = false; | ||
1132 | firstcol = true; | ||
1133 | } | ||
1134 | else | ||
1135 | { | ||
1136 | ret += "</tr><tr>"; | ||
1137 | } | ||
1138 | } | ||
1139 | else if (ch == 0x97) | ||
1140 | { | ||
1141 | if (firstcol) | ||
1142 | { | ||
1143 | ret += "<td"; | ||
1144 | firstcol = false; | ||
1145 | } | ||
1146 | else | ||
1147 | { | ||
1148 | ret += "</td><td"; | ||
1149 | } | ||
1150 | UInt8 align; | ||
1151 | UInt16 imgid; | ||
1152 | UInt8 cols, rows; | ||
1153 | UInt16 len; | ||
1154 | memcpy(&align, dp, sizeof(align)); | ||
1155 | dp += sizeof(align); | ||
1156 | memcpy(&imgid, dp, sizeof(imgid)); | ||
1157 | dp += sizeof(imgid); | ||
1158 | imgid = ntohs(imgid); | ||
1159 | memcpy(&cols, dp, sizeof(cols)); | ||
1160 | dp += sizeof(cols); | ||
1161 | memcpy(&rows, dp, sizeof(rows)); | ||
1162 | dp += sizeof(rows); | ||
1163 | memcpy(&len, dp, sizeof(len)); | ||
1164 | dp += sizeof(len); | ||
1165 | len = ntohs(len); | ||
1166 | switch (align) | ||
1167 | { | ||
1168 | case 1: | ||
1169 | ret += " align=right"; | ||
1170 | break; | ||
1171 | case 2: | ||
1172 | ret += " align=center"; | ||
1173 | break; | ||
1174 | case 3: | ||
1175 | ret += " align=justify"; | ||
1176 | break; | ||
1177 | case 0: | ||
1178 | break; | ||
1179 | default: | ||
1180 | qDebug("Unknown table cell alignment:%u", align); | ||
1181 | } | ||
1182 | if (cols != 1) | ||
1183 | { | ||
1184 | QString num; | ||
1185 | num.setNum(cols); | ||
1186 | ret += " colspan="; | ||
1187 | ret += num; | ||
1188 | } | ||
1189 | if (rows != 1) | ||
1190 | { | ||
1191 | QString num; | ||
1192 | num.setNum(rows); | ||
1193 | ret += " rowspan="; | ||
1194 | ret += num; | ||
1195 | } | ||
1196 | ret += ">"; | ||
1197 | } | ||
1198 | else | ||
1199 | { | ||
1200 | dp += (ch & 7); | ||
1201 | } | ||
1202 | } | ||
1203 | else | ||
1204 | { | ||
1205 | ret += QChar(ch); | ||
1206 | } | ||
1207 | } | ||
1208 | |||
1209 | ret += "</td></tr></table>"; | ||
1210 | delete [] imgbuffer; | ||
1211 | return ret; | ||
1212 | } | ||
1059 | 1213 | ||
1060 | tchar CPlucker_base::getch_base(bool fast) | 1214 | tchar CPlucker_base::getch_base(bool fast) |
1061 | { | 1215 | { |
1216 | mystyle.setTable(0xffffffff); | ||
1062 | int ch = bgetch(); | 1217 | int ch = bgetch(); |
1063 | while (ch == 0) | 1218 | while (ch == 0) |
1064 | { | 1219 | { |
1065 | ch = bgetch(); | 1220 | ch = bgetch(); |
1066 | ////qDebug("Function:%x", ch); | 1221 | ////qDebug("Function:%x", ch); |
1067 | switch (ch) | 1222 | switch (ch) |
1068 | { | 1223 | { |
1069 | case 0x38: | 1224 | case 0x38: |
1070 | // //qDebug("Break:%u", locate()); | 1225 | // //qDebug("Break:%u", locate()); |
1071 | if (m_lastBreak == locate()) | 1226 | if (m_lastBreak == locate()) |
1072 | { | 1227 | { |
1073 | ch = bgetch(); | 1228 | ch = bgetch(); |
1074 | } | 1229 | } |
1075 | else | 1230 | else |
1076 | { | 1231 | { |
1077 | ch = 10; | 1232 | ch = 10; |
1078 | } | 1233 | } |
1079 | m_lastBreak = locate(); | 1234 | m_lastBreak = locate(); |
1080 | break; | 1235 | break; |
1081 | case 0x0a: | 1236 | case 0x0a: |
1082 | case 0x0c: | 1237 | case 0x0c: |
1083 | { | 1238 | { |
1084 | unsigned long ln = 0; | 1239 | unsigned long ln = 0; |
1085 | int skip = ch & 7; | 1240 | int skip = ch & 7; |
1086 | for (int i = 0; i < 2; i++) | 1241 | for (int i = 0; i < 2; i++) |
1087 | { | 1242 | { |
1088 | int ch = bgetch(); | 1243 | int ch = bgetch(); |
1089 | ln = (ln << 8) + ch; | 1244 | ln = (ln << 8) + ch; |
1090 | // //qDebug("ch:%d, ln:%u", ch, ln); | 1245 | // //qDebug("ch:%d, ln:%u", ch, ln); |
1091 | } | 1246 | } |
1092 | if (skip == 2) | 1247 | if (skip == 2) |
1093 | { | 1248 | { |
1094 | ln <<= 16; | 1249 | ln <<= 16; |
1095 | } | 1250 | } |
1096 | else | 1251 | else |
1097 | { | 1252 | { |
1098 | for (int i = 0; i < 2; i++) | 1253 | for (int i = 0; i < 2; i++) |
1099 | { | 1254 | { |
1100 | int ch = bgetch(); | 1255 | int ch = bgetch(); |
1101 | ln = (ln << 8) + ch; | 1256 | ln = (ln << 8) + ch; |
1102 | // //qDebug("ch:%d, ln:%u", ch, ln); | 1257 | // //qDebug("ch:%d, ln:%u", ch, ln); |
1103 | } | 1258 | } |
1104 | } | 1259 | } |
1105 | // //qDebug("ln:%u", ln); | 1260 | // //qDebug("ln:%u", ln); |
1106 | mystyle.setLink(true); | 1261 | mystyle.setLink(true); |
1107 | mystyle.setData(ln); | 1262 | mystyle.setData(ln); |
1108 | // mystyle.setColour(255, 0, 0); | 1263 | // mystyle.setColour(255, 0, 0); |
1109 | bool hasseen = false; | 1264 | bool hasseen = false; |
1110 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | 1265 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) |
1111 | { | 1266 | { |
1112 | if (*it == ln) | 1267 | if (*it == ln) |
1113 | { | 1268 | { |
1114 | hasseen = true; | 1269 | hasseen = true; |
1115 | break; | 1270 | break; |
1116 | } | 1271 | } |
1117 | } | 1272 | } |
1118 | if (hasseen) | 1273 | if (hasseen) |
1119 | { | 1274 | { |
1120 | mystyle.setStrikethru(); | 1275 | mystyle.setStrikethru(); |
1121 | } | 1276 | } |
1122 | else | ||
1123 | { | ||
1124 | mystyle.setUnderline(); | ||
1125 | } | ||
1126 | mystyle.setOffset(m_offset); | 1277 | mystyle.setOffset(m_offset); |
1127 | m_offset = 0; | 1278 | m_offset = 0; |
1128 | ch = bgetch(); | 1279 | ch = bgetch(); |
1129 | } | 1280 | } |
1130 | break; | 1281 | break; |
1131 | case 0x08: | 1282 | case 0x08: |
1132 | ch = bgetch(); | 1283 | ch = bgetch(); |
1133 | // mystyle.setColour(0, 0, 0); | 1284 | // mystyle.setColour(0, 0, 0); |
1134 | mystyle.unsetUnderline(); | 1285 | mystyle.unsetUnderline(); |
1135 | mystyle.unsetStrikethru(); | 1286 | mystyle.unsetStrikethru(); |
1136 | mystyle.setLink(false); | 1287 | mystyle.setLink(false); |
1137 | mystyle.setData(0); | 1288 | mystyle.setData(0); |
1138 | break; | 1289 | break; |
1139 | case 0x40: | 1290 | case 0x40: |
1140 | mystyle.setItalic(); | 1291 | mystyle.setItalic(); |
1141 | ch = bgetch(); | 1292 | ch = bgetch(); |
1142 | break; | 1293 | break; |
1143 | case 0x48: | 1294 | case 0x48: |
1144 | mystyle.unsetItalic(); | 1295 | mystyle.unsetItalic(); |
1145 | ch = bgetch(); | 1296 | ch = bgetch(); |
1146 | break; | 1297 | break; |
1147 | case 0x11: | 1298 | case 0x11: |
1148 | { | 1299 | { |
1149 | ch = bgetch(); | 1300 | ch = bgetch(); |
1150 | // //qDebug("Font:%d",ch); | 1301 | // //qDebug("Font:%d",ch); |
1151 | mystyle.setVOffset(0); | 1302 | mystyle.setVOffset(0); |
1152 | mystyle.unsetMono(); | 1303 | mystyle.unsetMono(); |
1153 | mystyle.unsetBold(); | 1304 | mystyle.unsetBold(); |
1154 | switch (ch) | 1305 | switch (ch) |
1155 | { | 1306 | { |
1156 | case 0: | 1307 | case 0: |
1157 | mystyle.setFontSize(0); | 1308 | mystyle.setFontSize(0); |
1158 | break; | 1309 | break; |
1159 | case 1: | 1310 | case 1: |
1160 | mystyle.setFontSize(3); | 1311 | mystyle.setFontSize(3); |
1161 | mystyle.setBold(); | 1312 | mystyle.setBold(); |
1162 | break; | 1313 | break; |
1163 | case 2: | 1314 | case 2: |
1164 | mystyle.setFontSize(2); | 1315 | mystyle.setFontSize(2); |
1165 | mystyle.setBold(); | 1316 | mystyle.setBold(); |
1166 | break; | 1317 | break; |
1167 | case 3: | 1318 | case 3: |
1168 | mystyle.setFontSize(1); | 1319 | mystyle.setFontSize(1); |
1169 | mystyle.setBold(); | 1320 | mystyle.setBold(); |
1170 | break; | 1321 | break; |
1171 | case 4: | 1322 | case 4: |
1172 | mystyle.setFontSize(0); | 1323 | mystyle.setFontSize(0); |
1173 | mystyle.setBold(); | 1324 | mystyle.setBold(); |
1174 | break; | 1325 | break; |
1175 | case 5: | 1326 | case 5: |
1176 | mystyle.setFontSize(0); | 1327 | mystyle.setFontSize(0); |
1177 | mystyle.setBold(); | 1328 | mystyle.setBold(); |
1178 | break; | 1329 | break; |
1179 | case 6: | 1330 | case 6: |
1180 | mystyle.setFontSize(0); | 1331 | mystyle.setFontSize(0); |
1181 | mystyle.setBold(); | 1332 | mystyle.setBold(); |
1182 | break; | 1333 | break; |
1183 | case 7: | 1334 | case 7: |
1184 | mystyle.setFontSize(0); | 1335 | mystyle.setFontSize(0); |
1185 | mystyle.setBold(); | 1336 | mystyle.setBold(); |
1186 | break; | 1337 | break; |
1187 | case 8: // should be fixed width | 1338 | case 8: // should be fixed width |
1188 | //qDebug("Trying fixed width"); | 1339 | //qDebug("Trying fixed width"); |
1189 | mystyle.setFontSize(0); | 1340 | mystyle.setFontSize(0); |
1190 | mystyle.setMono(); | 1341 | mystyle.setMono(); |
1191 | break; | 1342 | break; |
1192 | case 9: | 1343 | case 9: |
1193 | // mystyle.setFontSize(mystyle.getFontSize()); | 1344 | // mystyle.setFontSize(mystyle.getFontSize()); |
1194 | mystyle.setFontSize(-1); | 1345 | mystyle.setFontSize(-1); |
1195 | break; | 1346 | break; |
1196 | case 10: | 1347 | case 10: |
1197 | mystyle.setFontSize(-2); | 1348 | mystyle.setFontSize(-2); |
1198 | mystyle.setVOffset(1); | 1349 | mystyle.setVOffset(1); |
1199 | break; | 1350 | break; |
1200 | case 11: | 1351 | case 11: |
1201 | mystyle.setFontSize(-2); | 1352 | mystyle.setFontSize(-2); |
1202 | mystyle.setVOffset(-1); | 1353 | mystyle.setVOffset(-1); |
1203 | break; | 1354 | break; |
1204 | default: | 1355 | default: |
1205 | qDebug("Unrecognised font"); | 1356 | qDebug("Unrecognised font"); |
1206 | break; | 1357 | break; |
1207 | } | 1358 | } |
1208 | ch = bgetch(); | 1359 | ch = bgetch(); |
1209 | } | 1360 | } |
1210 | break; | 1361 | break; |
1211 | case 0x29: | 1362 | case 0x29: |
1212 | ch = bgetch(); | 1363 | ch = bgetch(); |
1213 | switch (ch) | 1364 | switch (ch) |
1214 | { | 1365 | { |
1215 | case 0: | 1366 | case 0: |
1216 | mystyle.setLeftJustify(); | 1367 | mystyle.setLeftJustify(); |
1217 | // //qDebug("left"); | 1368 | // //qDebug("left"); |
1218 | break; | 1369 | break; |
1219 | case 1: | 1370 | case 1: |
1220 | mystyle.setRightJustify(); | 1371 | mystyle.setRightJustify(); |
1221 | // //qDebug("right"); | 1372 | // //qDebug("right"); |
1222 | break; | 1373 | break; |
1223 | case 2: | 1374 | case 2: |
1224 | mystyle.setCentreJustify(); | 1375 | mystyle.setCentreJustify(); |
1225 | // //qDebug("centre"); | 1376 | // //qDebug("centre"); |
1226 | break; | 1377 | break; |
1227 | case 3: | 1378 | case 3: |
1228 | mystyle.setFullJustify(); | 1379 | mystyle.setFullJustify(); |
1229 | // //qDebug("full"); | 1380 | // //qDebug("full"); |
1230 | break; | 1381 | break; |
1231 | 1382 | ||
1232 | } | 1383 | } |
1233 | ch = bgetch(); | 1384 | ch = bgetch(); |
1234 | break; | 1385 | break; |
1235 | case 0x53: | 1386 | case 0x53: |
1236 | { | 1387 | { |
1237 | int r = bgetch(); | 1388 | int r = bgetch(); |
1238 | int g = bgetch(); | 1389 | int g = bgetch(); |
1239 | int b = bgetch(); | 1390 | int b = bgetch(); |
1240 | mystyle.setColour(r,g,b); | 1391 | mystyle.setColour(r,g,b); |
1241 | ch = bgetch(); | 1392 | ch = bgetch(); |
1242 | } | 1393 | } |
1243 | break; | 1394 | break; |
1244 | case 0x1a: | 1395 | case 0x1a: |
1245 | case 0x5c: | 1396 | case 0x5c: |
1246 | { | 1397 | { |
1247 | bool hasalternate = (ch == 0x5c); | 1398 | bool hasalternate = (ch == 0x5c); |
1248 | UInt16 ir = bgetch(); | 1399 | UInt16 ir = bgetch(); |
1249 | ir = (ir << 8) + bgetch(); | 1400 | ir = (ir << 8) + bgetch(); |
1250 | if (hasalternate) | 1401 | if (hasalternate) |
1251 | { | 1402 | { |
1252 | //qDebug("Alternate image:%x", ir); | 1403 | //qDebug("Alternate image:%x", ir); |
1253 | UInt16 ir2 = bgetch(); | 1404 | UInt16 ir2 = bgetch(); |
1254 | ir2 = (ir2 << 8) + bgetch(); | 1405 | ir2 = (ir2 << 8) + bgetch(); |
1255 | if (!fast) mystyle.setPicture(true, expandimg(ir2, true), true, ir << 16); | 1406 | if (!fast) mystyle.setPicture(true, expandimg(ir2, true), true, ir << 16); |
1256 | #ifdef LOCALPICTURES | 1407 | #ifdef LOCALPICTURES |
1257 | UInt32 ln = ir; | 1408 | UInt32 ln = ir; |
1258 | ln <<= 16; | 1409 | ln <<= 16; |
1259 | mystyle.setLink(true); | 1410 | mystyle.setLink(true); |
1260 | mystyle.setData(ln); | 1411 | mystyle.setData(ln); |
1261 | #endif | 1412 | #endif |
1262 | } | 1413 | } |
1263 | else | 1414 | else |
1264 | { | 1415 | { |
1265 | if (!fast) mystyle.setPicture(true, expandimg(ir)); | 1416 | if (!fast) mystyle.setPicture(true, expandimg(ir)); |
1266 | } | 1417 | } |
1267 | // if (mystyle.getLink()) qDebug("Picture link!"); | 1418 | // if (mystyle.getLink()) qDebug("Picture link!"); |
1268 | ch = '#'; | 1419 | ch = '#'; |
1269 | } | 1420 | } |
1270 | // ch = bgetch(); | 1421 | // ch = bgetch(); |
1271 | break; | 1422 | break; |
1272 | case 0x33: | 1423 | case 0x33: |
1273 | { | 1424 | { |
1274 | UInt8 h = bgetch(); | 1425 | UInt8 h = bgetch(); |
1275 | UInt8 wc = bgetch(); | 1426 | UInt8 wc = bgetch(); |
1276 | UInt8 pc = bgetch(); | 1427 | UInt8 pc = bgetch(); |
1277 | UInt16 w = wc; | 1428 | UInt16 w = wc; |
1278 | // //qDebug("h,w,pc [%u, %u, %u]", h, w, pc); | 1429 | // //qDebug("h,w,pc [%u, %u, %u]", h, w, pc); |
1279 | if (w == 0) | 1430 | if (w == 0) |
1280 | { | 1431 | { |
1281 | w = (m_scrWidth*(unsigned long)pc)/100; | 1432 | w = (m_scrWidth*(unsigned long)pc)/100; |
1282 | } | 1433 | } |
1283 | if (w == 0) w = m_scrWidth; | 1434 | if (w == 0) w = m_scrWidth; |
1284 | mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); | 1435 | mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); |
1285 | // if (mystyle.getLink()) //qDebug("hRule link!"); | 1436 | // if (mystyle.getLink()) //qDebug("hRule link!"); |
1286 | ch = '#'; | 1437 | ch = '#'; |
1287 | } | 1438 | } |
1288 | break; | 1439 | break; |
1289 | case 0x60: | 1440 | case 0x60: |
1290 | mystyle.setUnderline(); | 1441 | mystyle.setUnderline(); |
1291 | ch = bgetch(); | 1442 | ch = bgetch(); |
1292 | break; | 1443 | break; |
1293 | case 0x68: | 1444 | case 0x68: |
1294 | mystyle.unsetUnderline(); | 1445 | mystyle.unsetUnderline(); |
1295 | ch = bgetch(); | 1446 | ch = bgetch(); |
1296 | break; | 1447 | break; |
1297 | case 0x22: | 1448 | case 0x22: |
1298 | ch = bgetch(); | 1449 | ch = bgetch(); |
1299 | mystyle.setLeftMargin(ch); | 1450 | mystyle.setLeftMargin(ch); |
1300 | // //qDebug("Left margin:%d", ch); | 1451 | // //qDebug("Left margin:%d", ch); |
1301 | ch = bgetch(); | 1452 | ch = bgetch(); |
1302 | mystyle.setRightMargin(ch); | 1453 | mystyle.setRightMargin(ch); |
1303 | // //qDebug("Right margin:%d", ch); | 1454 | // //qDebug("Right margin:%d", ch); |
1304 | ch = bgetch(); | 1455 | ch = bgetch(); |
1305 | break; | 1456 | break; |
1306 | case 0x70: | 1457 | case 0x70: |
1307 | mystyle.setStrikethru(); | 1458 | mystyle.setStrikethru(); |
1308 | ch = bgetch(); | 1459 | ch = bgetch(); |
1309 | break; | 1460 | break; |
1310 | case 0x78: | 1461 | case 0x78: |
1311 | mystyle.unsetStrikethru(); | 1462 | mystyle.unsetStrikethru(); |
1312 | ch = bgetch(); | 1463 | ch = bgetch(); |
1313 | break; | 1464 | break; |
1314 | case 0x83: | 1465 | case 0x83: |
1315 | { | 1466 | { |
1316 | int tlen = bgetch(); | 1467 | int tlen = bgetch(); |
1317 | ch = bgetch(); | 1468 | ch = bgetch(); |
1318 | ch <<= 8; | 1469 | ch <<= 8; |
1319 | ch |= (tchar)bgetch(); | 1470 | ch |= (tchar)bgetch(); |
1320 | for (int i = 0; i < tlen; i++) bgetch(); | 1471 | for (int i = 0; i < tlen; i++) bgetch(); |
1321 | //qDebug("Function 83"); | 1472 | //qDebug("Function 83"); |
1322 | } | 1473 | } |
1323 | break; | 1474 | break; |
1324 | case 0x9a: | 1475 | case 0x9a: |
1325 | { | 1476 | { |
1326 | m_offset = 255*bgetch(); | 1477 | m_offset = 255*bgetch(); |
1327 | m_offset += bgetch(); | 1478 | m_offset += bgetch(); |
1328 | qDebug("Found offset:%u", m_offset); | 1479 | qDebug("Found offset:%u", m_offset); |
1329 | ch = bgetch(); | 1480 | ch = bgetch(); |
1330 | } | 1481 | } |
1331 | break; | 1482 | break; |
1483 | case 0x92: | ||
1484 | { | ||
1485 | ch = bgetch(); | ||
1486 | ch <<= 8; | ||
1487 | ch |= (tchar)bgetch(); | ||
1488 | mystyle.setTable(ch); | ||
1489 | ch = 0x16e5; | ||
1490 | } | ||
1491 | break; | ||
1332 | case 0x85: | 1492 | case 0x85: |
1333 | default: | 1493 | default: |
1334 | qDebug("Function:%x NOT IMPLEMENTED", ch); | 1494 | qDebug("Function:%x NOT IMPLEMENTED", ch); |
1335 | { | 1495 | { |
1336 | int skip = ch & 7; | 1496 | int skip = ch & 7; |
1337 | for (int i = 0; i < skip; i++) | 1497 | for (int i = 0; i < skip; i++) |
1338 | { | 1498 | { |
1339 | ch = bgetch(); | 1499 | ch = bgetch(); |
1340 | //qDebug("Arg %d, %d", i, ch); | 1500 | //qDebug("Arg %d, %d", i, ch); |
1341 | } | 1501 | } |
1342 | ch = bgetch(); | 1502 | ch = bgetch(); |
1343 | } | 1503 | } |
1344 | } | 1504 | } |
1345 | } | 1505 | } |
1346 | 1506 | ||
1347 | if (m_lastIsBreak && !mystyle.isMono()) | 1507 | if (m_lastIsBreak && !mystyle.isMono()) |
1348 | { | 1508 | { |
1349 | while (ch == ' ') | 1509 | while (ch == ' ') |
1350 | { | 1510 | { |
1351 | ch = getch(false); | 1511 | ch = getch(false); |
1352 | } | 1512 | } |
1353 | } | 1513 | } |
1354 | 1514 | ||
1355 | m_lastIsBreak = (ch == 10); | 1515 | m_lastIsBreak = (ch == 10); |
1356 | 1516 | ||
1357 | return (ch == EOF) ? UEOF : ch; | 1517 | return (ch == EOF) ? UEOF : ch; |
1358 | } | 1518 | } |
1359 | 1519 | ||
1360 | #if defined(__STATIC) && defined(USENEF) | ||
1361 | #include "Model.h" | ||
1362 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) | ||
1363 | { | ||
1364 | if (_s == "PluckerDecompress3") | ||
1365 | { | ||
1366 | return PluckerDecompress3; | ||
1367 | } | ||
1368 | if (_s == "PluckerDecompress4") | ||
1369 | { | ||
1370 | return PluckerDecompress4; | ||
1371 | } | ||
1372 | return NULL; | ||
1373 | } | ||
1374 | #else | ||
1375 | |||
1376 | #include "qfileinfo.h" | ||
1377 | |||
1378 | #include <dlfcn.h> | ||
1379 | |||
1380 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) | ||
1381 | { | ||
1382 | QString codecpath(QTReaderUtil::getPluginPath("support")); | ||
1383 | codecpath += "/libpluckerdecompress.so"; | ||
1384 | qDebug("Codec:%s", (const char*)codecpath); | ||
1385 | if (QFile::exists(codecpath)) | ||
1386 | { | ||
1387 | qDebug("Codec:%s", (const char*)codecpath); | ||
1388 | void* handle = dlopen(codecpath, RTLD_LAZY); | ||
1389 | if (handle == 0) | ||
1390 | { | ||
1391 | qDebug("Can't find codec:%s", dlerror()); | ||
1392 | return NULL; | ||
1393 | } | ||
1394 | return (void (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s); | ||
1395 | } | ||
1396 | return NULL; | ||
1397 | } | ||
1398 | #endif | ||
1399 | |||
1400 | QString CPlucker_base::about() | 1520 | QString CPlucker_base::about() |
1401 | { | 1521 | { |
1402 | QString abt = "Plucker base codec (c) Tim Wentford"; | 1522 | QString abt = "Plucker base codec (c) Tim Wentford"; |
1403 | if (m_decompress != UnDoc && m_decompress != UnZip) | 1523 | if (m_decompress != UnDoc && m_decompress != UnZip) |
1404 | { | 1524 | { |
1405 | abt += "\nSpecial decompression (c) Tim Wentford"; | 1525 | abt += "\nSpecial decompression (c) Tim Wentford (ppmd by Dmitry Shkarin"; |
1406 | } | 1526 | } |
1407 | return abt; | 1527 | return abt; |
1408 | } | 1528 | } |
diff --git a/noncore/apps/opie-reader/plucker_base.h b/noncore/apps/opie-reader/plucker_base.h index 8d74cc2..2b57986 100644 --- a/noncore/apps/opie-reader/plucker_base.h +++ b/noncore/apps/opie-reader/plucker_base.h | |||
@@ -1,115 +1,116 @@ | |||
1 | #ifndef __PLUCKER_BASE_H | 1 | #ifndef __PLUCKER_BASE_H |
2 | #define __PLUCKER_BASE_H | 2 | #define __PLUCKER_BASE_H |
3 | 3 | ||
4 | #include "CExpander.h" | 4 | #include "CExpander.h" |
5 | #include <zlib.h> | 5 | #include <zlib.h> |
6 | #include "ztxt.h" | 6 | #include "ztxt.h" |
7 | #include "pdb.h" | 7 | #include "pdb.h" |
8 | #include "CBuffer.h" | 8 | #include "CBuffer.h" |
9 | #include "my_list.h" | 9 | #include "my_list.h" |
10 | #include "Navigation.h" | 10 | #include "Navigation.h" |
11 | #include "hrule.h" | 11 | #include "hrule.h" |
12 | 12 | ||
13 | struct CPlucker_record0 | 13 | struct CPlucker_record0 |
14 | { | 14 | { |
15 | UInt16 uid; | 15 | UInt16 uid; |
16 | UInt16 version; | 16 | UInt16 version; |
17 | UInt16 nRecords; | 17 | UInt16 nRecords; |
18 | }; | 18 | }; |
19 | 19 | ||
20 | struct CPluckerbkmk | 20 | struct CPluckerbkmk |
21 | { | 21 | { |
22 | UInt32 offset; | 22 | UInt32 offset; |
23 | tchar title[MAX_BMRK_LENGTH]; | 23 | tchar title[MAX_BMRK_LENGTH]; |
24 | }; | 24 | }; |
25 | 25 | ||
26 | #ifdef LOCALPICTURES | 26 | #ifdef LOCALPICTURES |
27 | class QScrollView; | 27 | class QScrollView; |
28 | class QWidget; | 28 | class QWidget; |
29 | #endif | 29 | #endif |
30 | class QString; | 30 | class QString; |
31 | 31 | ||
32 | class CPlucker_base : public Cpdb | 32 | class CPlucker_base : public Cpdb |
33 | { | 33 | { |
34 | protected: | 34 | protected: |
35 | static const UInt8 continuation_bit; | 35 | static const UInt8 continuation_bit; |
36 | virtual void setbuffersize() = 0; | 36 | virtual void setbuffersize() = 0; |
37 | virtual void GetHeader(UInt16&, UInt16&, UInt32&, UInt8&, UInt8&) = 0; | 37 | virtual void GetHeader(UInt16&, UInt16&, UInt32&, UInt8&, UInt8&) = 0; |
38 | virtual int HeaderSize() = 0; | 38 | virtual int HeaderSize() = 0; |
39 | unsigned short finduid(unsigned short); | 39 | unsigned short finduid(unsigned short); |
40 | char* geturl(UInt16); | 40 | char* geturl(UInt16); |
41 | void Expand(UInt32, UInt8, UInt8*, UInt32); | 41 | void Expand(UInt32, UInt8, UInt8*, UInt32); |
42 | CList<unsigned long> visited; | 42 | CList<unsigned long> visited; |
43 | bool m_lastIsBreak; | 43 | bool m_lastIsBreak; |
44 | #ifdef LOCALPICTURES | 44 | #ifdef LOCALPICTURES |
45 | QScrollView* m_viewer; | 45 | QScrollView* m_viewer; |
46 | QWidget* m_picture; | 46 | QWidget* m_picture; |
47 | #endif | 47 | #endif |
48 | size_t textlength, m_lastBreak, m_offset; | 48 | size_t textlength, m_lastBreak, m_offset; |
49 | UInt16 uid; | 49 | UInt16 uid; |
50 | int m_nextPara, m_nextParaIndex; | 50 | int m_nextPara, m_nextParaIndex; |
51 | CBufferFace<UInt16> m_ParaOffsets; | 51 | CBufferFace<UInt16> m_ParaOffsets; |
52 | CBufferFace<UInt16> m_ParaAttrs; | 52 | CBufferFace<UInt16> m_ParaAttrs; |
53 | UInt16 m_nParas; | 53 | UInt16 m_nParas; |
54 | CStyle mystyle; | 54 | CStyle mystyle; |
55 | // bool bInit; | 55 | // bool bInit; |
56 | UInt32 buffersize; | 56 | UInt32 buffersize; |
57 | UInt32 compressedbuffersize; | 57 | UInt32 compressedbuffersize; |
58 | UInt32 buffercontent; | 58 | UInt32 buffercontent; |
59 | UInt8* expandedtextbuffer; | 59 | UInt8* expandedtextbuffer; |
60 | UInt8* compressedtextbuffer; | 60 | UInt8* compressedtextbuffer; |
61 | // char* urls; | 61 | // char* urls; |
62 | // size_t urlsize; | 62 | // size_t urlsize; |
63 | size_t bufferpos; | 63 | size_t bufferpos; |
64 | int bufferrec; | 64 | int bufferrec; |
65 | CPlucker_record0 hdr0; | 65 | CPlucker_record0 hdr0; |
66 | bool m_bufferisreserved; | 66 | bool m_bufferisreserved; |
67 | size_t currentpos; | 67 | size_t currentpos; |
68 | bool expand(int); | 68 | bool expand(int); |
69 | static void UnZip(UInt8*, size_t, UInt8*, size_t); | 69 | //static void UnZip(UInt8*, size_t, UInt8*, size_t); |
70 | static void UnDoc(UInt8*, size_t, UInt8*, size_t); | 70 | static size_t UnDoc(UInt8*, size_t, UInt8*, size_t); |
71 | |||
72 | size_t (*m_decompress)(UInt8*, size_t, UInt8*, size_t); | ||
71 | 73 | ||
72 | void (*m_decompress)(UInt8*, size_t, UInt8*, size_t); | ||
73 | void (*getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t); | ||
74 | #ifdef LOCALPICTURES | 74 | #ifdef LOCALPICTURES |
75 | void showimg(UInt16 tgt); | 75 | void showimg(UInt16 tgt); |
76 | #endif | 76 | #endif |
77 | QImage* getimg(UInt16 tgt); | 77 | QImage* getimg(UInt16 tgt); |
78 | QImage* expandimg(UInt16 tgt, bool border=false); | 78 | QImage* expandimg(UInt16 tgt, bool border=false); |
79 | void home(); | 79 | void home(); |
80 | virtual int bgetch() = 0; | 80 | virtual int bgetch() = 0; |
81 | CNavigation m_nav; | 81 | CNavigation m_nav; |
82 | public: | 82 | public: |
83 | QString about(); | 83 | QString about(); |
84 | QImage* getPicture(unsigned long tgt); | 84 | QImage* getPicture(unsigned long tgt); |
85 | void sizes(unsigned long& _file, unsigned long& _text); | 85 | void sizes(unsigned long& _file, unsigned long& _text); |
86 | bool hasrandomaccess() { return true; } | 86 | bool hasrandomaccess() { return true; } |
87 | virtual ~CPlucker_base(); | 87 | virtual ~CPlucker_base(); |
88 | CPlucker_base(); | 88 | CPlucker_base(); |
89 | int OpenFile(const char *src); | 89 | int OpenFile(const char *src); |
90 | virtual tchar getch(bool) = 0; | 90 | virtual tchar getch(bool) = 0; |
91 | tchar getch_base(bool); | 91 | tchar getch_base(bool); |
92 | int getch(); | 92 | int getch(); |
93 | void getch(tchar&, CStyle&, unsigned long& pos); | 93 | void getch(tchar&, CStyle&, unsigned long& pos); |
94 | unsigned int locate(); | 94 | unsigned int locate(); |
95 | void locate(unsigned int n); | 95 | void locate(unsigned int n); |
96 | CList<Bkmk>* getbkmklist(); | 96 | CList<Bkmk>* getbkmklist(); |
97 | linkType hyperlink(unsigned int, unsigned int, QString&, QString&); | 97 | linkType hyperlink(unsigned int, unsigned int, QString&, QString&); |
98 | MarkupType PreferredMarkup() | 98 | MarkupType PreferredMarkup() |
99 | { | 99 | { |
100 | return cNONE; | 100 | return cNONE; |
101 | } | 101 | } |
102 | void saveposn(size_t posn) { m_nav.saveposn(posn); } | 102 | void saveposn(size_t posn) { m_nav.saveposn(posn); } |
103 | void writeposn(size_t posn) { m_nav.writeposn(posn); } | 103 | void writeposn(size_t posn) { m_nav.writeposn(posn); } |
104 | linkType forward(size_t& loc) { return (m_nav.forward(loc)) ? eLink : eNone; } | 104 | linkType forward(size_t& loc) { return (m_nav.forward(loc)) ? eLink : eNone; } |
105 | linkType back(size_t& loc) { return (m_nav.back(loc)) ? eLink : eNone; } | 105 | linkType back(size_t& loc) { return (m_nav.back(loc)) ? eLink : eNone; } |
106 | bool hasnavigation() { return true; } | 106 | bool hasnavigation() { return true; } |
107 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen); | 107 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen); |
108 | void putSaveData(unsigned char*& src, unsigned short& srclen); | 108 | void putSaveData(unsigned char*& src, unsigned short& srclen); |
109 | 109 | ||
110 | virtual bool CorrectDecoder() = 0; | 110 | virtual bool CorrectDecoder() = 0; |
111 | // virtual void setlink(QString&, const QString&) = 0; | 111 | // virtual void setlink(QString&, const QString&) = 0; |
112 | virtual QImage* imagefromdata(UInt8*, UInt32) = 0; | 112 | virtual QImage* imagefromdata(UInt8*, UInt32) = 0; |
113 | QString getTableAsHtml(unsigned long loc); | ||
113 | }; | 114 | }; |
114 | 115 | ||
115 | #endif | 116 | #endif |
diff --git a/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro b/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro index a66dc44..0212d84 100644 --- a/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro +++ b/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro | |||
@@ -1,18 +1,19 @@ | |||
1 | DEFINES += OPIE USEQPE | 1 | DEFINES += OPIE USEQPE |
2 | VPATH = .. | 2 | VPATH = .. |
3 | TEMPLATE= lib | 3 | TEMPLATE= lib |
4 | CONFIG = qt warn_on release dll | 4 | CONFIG = qt warn_on release dll |
5 | HEADERS = pdb.h \ | 5 | HEADERS = pdb.h \ |
6 | util.h | 6 | util.h |
7 | 7 | ||
8 | SOURCES = plucker_base.cpp | 8 | SOURCES = plucker_base.cpp \ |
9 | decompress.cpp | ||
9 | 10 | ||
10 | INTERFACES= | 11 | INTERFACES= |
11 | DESTDIR = $(OPIEDIR)/lib | 12 | DESTDIR = $(OPIEDIR)/lib |
12 | TARGET = reader_pluckerbase | 13 | TARGET = reader_pluckerbase |
13 | LIBS += -ldl | 14 | LIBS += -ldl |
14 | 15 | ||
15 | INCLUDEPATH+= $(OPIEDIR)/include | 16 | INCLUDEPATH+= $(OPIEDIR)/include |
16 | DEPENDPATH+= $(OPIEDIR)/include | 17 | DEPENDPATH+= $(OPIEDIR)/include |
17 | 18 | ||
18 | include( $(OPIEDIR)/include.pro ) | 19 | include( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/pluckerdecompress/.cvsignore b/noncore/apps/opie-reader/pluckerdecompress/.cvsignore new file mode 100644 index 0000000..1810ee0 --- a/dev/null +++ b/noncore/apps/opie-reader/pluckerdecompress/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile | ||
2 | config.in | ||
3 | moc_* | ||
4 | .moc | ||
5 | .obj | ||
diff --git a/noncore/apps/opie-reader/pluckerdecompress/pluckerdecompress.pro b/noncore/apps/opie-reader/pluckerdecompress/pluckerdecompress.pro new file mode 100644 index 0000000..c1b7686 --- a/dev/null +++ b/noncore/apps/opie-reader/pluckerdecompress/pluckerdecompress.pro | |||
@@ -0,0 +1,17 @@ | |||
1 | DEFINES += OPIE USEQPE | ||
2 | VPATH = .. | ||
3 | TEMPLATE= lib | ||
4 | CONFIG = qt warn_on release dll | ||
5 | HEADERS = CSource.h Model.h Coder.h SubAlloc.h | ||
6 | |||
7 | SOURCES = Model.cpp | ||
8 | |||
9 | |||
10 | INTERFACES= | ||
11 | DESTDIR = $(OPIEDIR)/plugins/reader/support | ||
12 | TARGET = pluckerdecompress | ||
13 | |||
14 | INCLUDEPATH+= $(OPIEDIR)/include | ||
15 | DEPENDPATH += $(OPIEDIR)/include | ||
16 | |||
17 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/noncore/apps/opie-reader/ppm_expander.cpp b/noncore/apps/opie-reader/ppm_expander.cpp index 2a4318b..61ef90e 100644 --- a/noncore/apps/opie-reader/ppm_expander.cpp +++ b/noncore/apps/opie-reader/ppm_expander.cpp | |||
@@ -1,115 +1,124 @@ | |||
1 | /* | 1 | /* |
2 | * Interface pour le programme de compression | 2 | * Interface pour le programme de compression |
3 | * (c) 1995 Fabrice Bellard | 3 | * (c) 1995 Fabrice Bellard |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | //#include <unistd.h> | 7 | //#include <unistd.h> |
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <string.h> | 9 | #include <string.h> |
10 | #include <time.h> | 10 | #include <time.h> |
11 | 11 | ||
12 | /*************************************************************************** | 12 | /*************************************************************************** |
13 | * Interface avec les routines de compression | 13 | * Interface avec les routines de compression |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #define METHOD_NB 2 /* nombre total de méthodes de compression */ | 16 | #define METHOD_NB 2 /* nombre total de méthodes de compression */ |
17 | 17 | ||
18 | #define METHOD_STORE 0 | 18 | #define METHOD_STORE 0 |
19 | #define METHOD_PPM 1 | 19 | #define METHOD_PPM 1 |
20 | 20 | ||
21 | 21 | ||
22 | #define DEFAULT_SUFFIX ".st" /* extension par défault */ | 22 | #define DEFAULT_SUFFIX ".st" /* extension par défault */ |
23 | /* signature en début de fichier */ | 23 | /* signature en début de fichier */ |
24 | #define STAT_MAGIC_SIZE 4 | 24 | #define STAT_MAGIC_SIZE 4 |
25 | char stat_magic[STAT_MAGIC_SIZE]={'P','P','M','S'}; | 25 | char stat_magic[STAT_MAGIC_SIZE]={'P','P','M','S'}; |
26 | 26 | ||
27 | #include "ppm_expander.h" | 27 | #include "ppm_expander.h" |
28 | 28 | ||
29 | ppm_expander::~ppm_expander() { | 29 | ppm_expander::~ppm_expander() { |
30 | if (needppmend) ppm.PPM_End(); | 30 | if (needppmend) ppm.PPM_End(); |
31 | ppm.arith.Arith_DecodeEnd(); | 31 | ppm.arith.Arith_DecodeEnd(); |
32 | if (buf_in!=NULL) delete [] buf_in; | 32 | if (buf_in!=NULL) delete [] buf_in; |
33 | if (buf_out!=NULL) delete [] buf_out; | 33 | if (buf_out!=NULL) delete [] buf_out; |
34 | if (my_read_buf != NULL) delete my_read_buf; | 34 | if (my_read_buf != NULL) delete my_read_buf; |
35 | if (my_file_in != NULL) fclose(my_file_in); | 35 | if (my_file_in != NULL) fclose(my_file_in); |
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"); |
41 | my_read_buf = new PPM_ReadBuf(my_file_in); | 41 | my_read_buf = new PPM_ReadBuf(my_file_in, this); |
42 | return home(); | 42 | return home(); |
43 | } | 43 | } |
44 | 44 | ||
45 | void ppm_expander::sizes(unsigned long& file, unsigned long& text) | 45 | void ppm_expander::sizes(unsigned long& file, unsigned long& text) |
46 | { | 46 | { |
47 | struct stat _stat; | 47 | struct stat _stat; |
48 | fstat(fileno(my_file_in),&_stat); | 48 | fstat(fileno(my_file_in),&_stat); |
49 | file = _stat.st_size; | 49 | file = _stat.st_size; |
50 | text = numblocks*blocksize; | 50 | text = numblocks*blocksize; |
51 | } | 51 | } |
52 | 52 | ||
53 | int ppm_expander::home() | 53 | int ppm_expander::home() |
54 | { | 54 | { |
55 | fseek(my_file_in,0, SEEK_SET); | 55 | fseek(my_file_in,0, SEEK_SET); |
56 | unsigned char header[STAT_MAGIC_SIZE]; | 56 | unsigned char header[STAT_MAGIC_SIZE]; |
57 | size_t len=fread(header,1,STAT_MAGIC_SIZE,my_file_in); | 57 | size_t len=fread(header,1,STAT_MAGIC_SIZE,my_file_in); |
58 | if (strncmp((char*)header,stat_magic,STAT_MAGIC_SIZE)!=0) { | 58 | if (strncmp((char*)header,stat_magic,STAT_MAGIC_SIZE)!=0) { |
59 | return 1; | 59 | return 1; |
60 | } | 60 | } |
61 | if (len!=(STAT_MAGIC_SIZE)) { | 61 | if (len!=(STAT_MAGIC_SIZE)) { |
62 | return 1; | 62 | return 1; |
63 | } | 63 | } |
64 | if (fread(&maxnode,sizeof(maxnode),1,my_file_in) != 1) return 1; | 64 | if (fread(&maxnode,sizeof(maxnode),1,my_file_in) != 1) return 1; |
65 | if (fread(&blocksize,sizeof(blocksize),1,my_file_in) != 1) return 1; | 65 | if (fread(&blocksize,sizeof(blocksize),1,my_file_in) != 1) return 1; |
66 | if (fread(&numblocks,sizeof(numblocks),1,my_file_in) != 1) return 1; | 66 | if (fread(&numblocks,sizeof(numblocks),1,my_file_in) != 1) return 1; |
67 | //fprintf(stderr,"<%u,%u,%u>\n",maxnode,blocksize,numblocks); | 67 | //fprintf(stderr,"<%u,%u,%u>\n",maxnode,blocksize,numblocks); |
68 | locate(0,0); | 68 | locate(0,0); |
69 | outbytes = 0; | 69 | outbytes = 0; |
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | void ppm_expander::locate(unsigned int n) { | 73 | void ppm_expander::locate(unsigned int n) { |
74 | locate(n/blocksize, n%blocksize); | 74 | locate(n/blocksize, n%blocksize); |
75 | outbytes = n; | 75 | outbytes = n; |
76 | } | 76 | } |
77 | 77 | ||
78 | void ppm_expander::locate(unsigned short block, unsigned int n) | 78 | void ppm_expander::locate(unsigned short block, unsigned int n) |
79 | { | 79 | { |
80 | if (needppmend) | 80 | if (needppmend) |
81 | { | 81 | { |
82 | ppm.PPM_End(); | 82 | ppm.PPM_End(); |
83 | needppmend = false; | 83 | needppmend = false; |
84 | } | 84 | } |
85 | size_t fpos; | 85 | size_t fpos; |
86 | fseek(my_file_in,STAT_MAGIC_SIZE+sizeof(maxnode)+sizeof(blocksize)+sizeof(numblocks)+block*sizeof(fpos),SEEK_SET); | 86 | fseek(my_file_in,STAT_MAGIC_SIZE+sizeof(maxnode)+sizeof(blocksize)+sizeof(numblocks)+block*sizeof(fpos),SEEK_SET); |
87 | fread(&fpos,sizeof(fpos),1,my_file_in); | 87 | fread(&fpos,sizeof(fpos),1,my_file_in); |
88 | fseek(my_file_in,fpos,SEEK_SET); | 88 | fseek(my_file_in,fpos,SEEK_SET); |
89 | 89 | ||
90 | ppm.arith.Arith_DecodeInit(my_read_buf,buf_in,bufsize); | 90 | ppm.arith.Arith_DecodeInit(my_read_buf,buf_in,bufsize); |
91 | int err=ppm.PPM_Init(maxnode); | 91 | int err=ppm.PPM_Init(maxnode); |
92 | needppmend = true; | 92 | needppmend = true; |
93 | curblock = block; | 93 | curblock = block; |
94 | for (int i = 0; i < n; i++) getch(); | 94 | for (int i = 0; i < n; i++) getch(); |
95 | } | 95 | } |
96 | 96 | ||
97 | int ppm_expander::getch() { | 97 | int ppm_expander::getch() { |
98 | if (curblock >= numblocks) return EOF; | 98 | if (curblock >= numblocks) return EOF; |
99 | int c=ppm.PPM_Decode(); | 99 | int c=ppm.PPM_Decode(); |
100 | if (c == SYM_EOF) | 100 | if (c == SYM_EOF) |
101 | { | 101 | { |
102 | if (++curblock >= numblocks) return EOF; | 102 | if (++curblock >= numblocks) return EOF; |
103 | locate(curblock,0); | 103 | locate(curblock,0); |
104 | c = ppm.PPM_Decode(); | 104 | c = ppm.PPM_Decode(); |
105 | } | 105 | } |
106 | outbytes++; | 106 | outbytes++; |
107 | return (c==SYM_EOF) ? EOF : c; | 107 | return (c==SYM_EOF) ? EOF : c; |
108 | } | 108 | } |
109 | 109 | ||
110 | UINT PPM_ReadBuf::readbuf(UCHAR *buf,UINT len) | ||
111 | { | ||
112 | UINT len1; | ||
113 | parent->unsuspend(); | ||
114 | len1=fread(buf,1,len,my_file_in); | ||
115 | return len1; | ||
116 | } | ||
117 | |||
118 | |||
110 | #ifndef __STATIC | 119 | #ifndef __STATIC |
111 | extern "C" | 120 | extern "C" |
112 | { | 121 | { |
113 | CExpander* newcodec() { return new ppm_expander; } | 122 | CExpander* newcodec() { return new ppm_expander; } |
114 | } | 123 | } |
115 | #endif | 124 | #endif |
diff --git a/noncore/apps/opie-reader/ppm_expander.h b/noncore/apps/opie-reader/ppm_expander.h index ccc89c2..c5f8a17 100644 --- a/noncore/apps/opie-reader/ppm_expander.h +++ b/noncore/apps/opie-reader/ppm_expander.h | |||
@@ -1,61 +1,64 @@ | |||
1 | #ifndef __ppm_expander_h | 1 | #ifndef __ppm_expander_h |
2 | #define __ppm_expander_h | 2 | #define __ppm_expander_h |
3 | 3 | ||
4 | #include "CExpander.h" | 4 | #include "CExpander.h" |
5 | #include <sys/stat.h> | 5 | #include <sys/stat.h> |
6 | 6 | ||
7 | 7 | ||
8 | #include "utypes.h" | 8 | #include "utypes.h" |
9 | #include "ppm.h" | 9 | #include "ppm.h" |
10 | #include "arith.h" | ||
11 | 10 | ||
11 | class PPM_ReadBuf; | ||
12 | 12 | ||
13 | #define SYM_EOF 256 | 13 | #define SYM_EOF 256 |
14 | 14 | ||
15 | class ppm_expander : public CExpander { | 15 | class ppm_expander : public CExpander { |
16 | UCHAR *buf_in,*buf_out; | 16 | UCHAR *buf_in,*buf_out; |
17 | unsigned int bufsize; | 17 | unsigned int bufsize; |
18 | unsigned int outbytes; | 18 | unsigned int outbytes; |
19 | unsigned long blocksize; | 19 | unsigned long blocksize; |
20 | unsigned short numblocks; | 20 | unsigned short numblocks; |
21 | unsigned short curblock; | 21 | unsigned short curblock; |
22 | unsigned short maxnode; | 22 | unsigned short maxnode; |
23 | bool needppmend; | 23 | bool needppmend; |
24 | int home(); | 24 | int home(); |
25 | FILE* my_file_in; | 25 | FILE* my_file_in; |
26 | PPM_ReadBuf* my_read_buf; | 26 | PPM_ReadBuf* my_read_buf; |
27 | ppm_worker ppm; | 27 | ppm_worker ppm; |
28 | public: | 28 | public: |
29 | QString about() { return QString("ppms Codec (c) Tim Wentford\nCompression code (c) Fabrice Bellard"); } | 29 | QString about() { return QString("ppms Codec (c) Tim Wentford\nCompression code (c) Fabrice Bellard"); } |
30 | #ifdef USEQPE | 30 | #ifdef USEQPE |
31 | void suspend() | 31 | void suspend() |
32 | { | 32 | { |
33 | CExpander::suspend(my_file_in); | 33 | CExpander::suspend(my_file_in); |
34 | } | 34 | } |
35 | void unsuspend() | 35 | void unsuspend() |
36 | { | 36 | { |
37 | CExpander::unsuspend(my_file_in); | 37 | CExpander::unsuspend(my_file_in); |
38 | } | 38 | } |
39 | #else | ||
40 | void suspend() {} | ||
41 | void unsuspend() {} | ||
39 | #endif | 42 | #endif |
40 | ppm_expander() : needppmend(false), my_file_in(NULL), my_read_buf(NULL) | 43 | ppm_expander() : needppmend(false), my_file_in(NULL), my_read_buf(NULL) |
41 | { | 44 | { |
42 | bufsize = 1024; | 45 | bufsize = 1024; |
43 | buf_in = new UCHAR[bufsize]; | 46 | buf_in = new UCHAR[bufsize]; |
44 | buf_out = new UCHAR[bufsize]; | 47 | buf_out = new UCHAR[bufsize]; |
45 | outbytes = 0; | 48 | outbytes = 0; |
46 | } | 49 | } |
47 | int OpenFile(const char* infile); | 50 | int OpenFile(const char* infile); |
48 | int getch(); | 51 | int getch(); |
49 | void locate(unsigned short block, unsigned int n); | 52 | void locate(unsigned short block, unsigned int n); |
50 | virtual ~ppm_expander(); | 53 | virtual ~ppm_expander(); |
51 | unsigned int locate() { return outbytes; } | 54 | unsigned int locate() { return outbytes; } |
52 | void locate(unsigned int n); | 55 | void locate(unsigned int n); |
53 | bool hasrandomaccess() { return (numblocks > 1); } | 56 | bool hasrandomaccess() { return (numblocks > 1); } |
54 | void sizes(unsigned long& file, unsigned long& text); | 57 | void sizes(unsigned long& file, unsigned long& text); |
55 | MarkupType PreferredMarkup() | 58 | MarkupType PreferredMarkup() |
56 | { | 59 | { |
57 | return cTEXT; | 60 | return cTEXT; |
58 | } | 61 | } |
59 | }; | 62 | }; |
60 | 63 | ||
61 | #endif | 64 | #endif |
diff --git a/noncore/apps/opie-reader/preferences.cpp b/noncore/apps/opie-reader/preferences.cpp index 0f59a22..67960ed 100755 --- a/noncore/apps/opie-reader/preferences.cpp +++ b/noncore/apps/opie-reader/preferences.cpp | |||
@@ -1,104 +1,105 @@ | |||
1 | |||
1 | #ifndef USEQPE | 2 | #ifndef USEQPE |
2 | 3 | ||
3 | #include "preferences.h" | 4 | #include "preferences.h" |
4 | 5 | ||
5 | #include <qfile.h> | 6 | #include <qfile.h> |
6 | #include <qtextstream.h> | 7 | #include <qtextstream.h> |
7 | 8 | ||
8 | Config::Config(const QString& _fn) : fname(_fn) | 9 | Config::Config(const QString& _fn) : fname(_fn) |
9 | { | 10 | { |
10 | // qDebug("Config::Config:%s", (const char*)fname); | 11 | // qDebug("Config::Config:%s", (const char*)fname); |
11 | QFile fl(fname); | 12 | QFile fl(fname); |
12 | if (fl.open(IO_ReadOnly)) | 13 | if (fl.open(IO_ReadOnly)) |
13 | { | 14 | { |
14 | QTextStream t(&fl); | 15 | QTextStream t(&fl); |
15 | QString key, value; | 16 | QString key, value; |
16 | while (!t.eof()) | 17 | while (!t.eof()) |
17 | { | 18 | { |
18 | QString data = t.readLine(); | 19 | QString data = t.readLine(); |
19 | int colon = data.find(':'); | 20 | int colon = data.find(':'); |
20 | if (colon > 0) | 21 | if (colon > 0) |
21 | { | 22 | { |
22 | QString key = data.left(colon); | 23 | QString key = data.left(colon); |
23 | QString value = data.right(data.length()-colon-1); | 24 | QString value = data.right(data.length()-colon-1); |
24 | values[key] = value; | 25 | values[key] = value; |
25 | } | 26 | } |
26 | } | 27 | } |
27 | fl.close(); | 28 | fl.close(); |
28 | } | 29 | } |
29 | // read entries into values | 30 | // read entries into values |
30 | } | 31 | } |
31 | Config::~Config() | 32 | Config::~Config() |
32 | { | 33 | { |
33 | // qDebug("Config::~Config:%s", (const char*)fname); | 34 | // qDebug("Config::~Config:%s", (const char*)fname); |
34 | QFile fl(fname); | 35 | QFile fl(fname); |
35 | if (fl.open(IO_WriteOnly)) | 36 | if (fl.open(IO_WriteOnly)) |
36 | { | 37 | { |
37 | QTextStream t(&fl); | 38 | QTextStream t(&fl); |
38 | for (QMap<QString,QString>::Iterator iter = values.begin(); | 39 | for (QMap<QString,QString>::Iterator iter = values.begin(); |
39 | iter != values.end(); | 40 | iter != values.end(); |
40 | iter++) | 41 | iter++) |
41 | { | 42 | { |
42 | t << iter.key() << ':' << iter.data() << '\n'; | 43 | t << iter.key() << ':' << iter.data() << '\n'; |
43 | } | 44 | } |
44 | fl.close(); | 45 | fl.close(); |
45 | } | 46 | } |
46 | } | 47 | } |
47 | QString Config::readEntry(const QString& key, const QString& deflt) | 48 | QString Config::readEntry(const QString& key, const QString& deflt) |
48 | { | 49 | { |
49 | QMap<QString,QString>::Iterator iter = values.find(key); | 50 | QMap<QString,QString>::Iterator iter = values.find(key); |
50 | if (iter != values.end()) | 51 | if (iter != values.end()) |
51 | { | 52 | { |
52 | return iter.data(); | 53 | return iter.data(); |
53 | } | 54 | } |
54 | else | 55 | else |
55 | { | 56 | { |
56 | return deflt; | 57 | return deflt; |
57 | } | 58 | } |
58 | } | 59 | } |
59 | bool Config::readBoolEntry(const QString& key, const bool deflt) | 60 | bool Config::readBoolEntry(const QString& key, const bool deflt) |
60 | { | 61 | { |
61 | bool ok; | 62 | bool ok; |
62 | QMap<QString,QString>::Iterator iter = values.find(key); | 63 | QMap<QString,QString>::Iterator iter = values.find(key); |
63 | if (iter != values.end()) | 64 | if (iter != values.end()) |
64 | { | 65 | { |
65 | int ret = iter.data().toInt(&ok); | 66 | int ret = iter.data().toInt(&ok); |
66 | return ((ok) ? !!ret : deflt); | 67 | return ((ok) ? !!ret : deflt); |
67 | } | 68 | } |
68 | else | 69 | else |
69 | { | 70 | { |
70 | return deflt; | 71 | return deflt; |
71 | } | 72 | } |
72 | } | 73 | } |
73 | int Config::readNumEntry(const QString& key, const int deflt) | 74 | int Config::readNumEntry(const QString& key, const int deflt) |
74 | { | 75 | { |
75 | bool ok; | 76 | bool ok; |
76 | QMap<QString,QString>::Iterator iter = values.find(key); | 77 | QMap<QString,QString>::Iterator iter = values.find(key); |
77 | if (iter != values.end()) | 78 | if (iter != values.end()) |
78 | { | 79 | { |
79 | int ret = iter.data().toInt(&ok); | 80 | int ret = iter.data().toInt(&ok); |
80 | return ((ok) ? ret : deflt); | 81 | return ((ok) ? ret : deflt); |
81 | } | 82 | } |
82 | else | 83 | else |
83 | { | 84 | { |
84 | return deflt; | 85 | return deflt; |
85 | } | 86 | } |
86 | } | 87 | } |
87 | void Config::writeEntry(const QString& key, const QString& value) | 88 | void Config::writeEntry(const QString& key, const QString& value) |
88 | { | 89 | { |
89 | values[key] = value; | 90 | values[key] = value; |
90 | } | 91 | } |
91 | 92 | ||
92 | void Config::writeEntry(const QString& key, const bool value) | 93 | void Config::writeEntry(const QString& key, const bool value) |
93 | { | 94 | { |
94 | values[key] = (value) ? "1" : "0"; | 95 | values[key] = (value) ? "1" : "0"; |
95 | } | 96 | } |
96 | 97 | ||
97 | void Config::writeEntry(const QString& key, const int value) | 98 | void Config::writeEntry(const QString& key, const int value) |
98 | { | 99 | { |
99 | QString rhs; | 100 | QString rhs; |
100 | rhs.setNum(value); | 101 | rhs.setNum(value); |
101 | values[key] = rhs; | 102 | values[key] = rhs; |
102 | } | 103 | } |
103 | 104 | ||
104 | #endif | 105 | #endif |
diff --git a/noncore/apps/opie-reader/preferences.h b/noncore/apps/opie-reader/preferences.h index aeb2a84..39959d4 100644 --- a/noncore/apps/opie-reader/preferences.h +++ b/noncore/apps/opie-reader/preferences.h | |||
@@ -1,26 +1,26 @@ | |||
1 | #ifndef USEQPE | 1 | #ifndef USEQPE |
2 | #ifndef __PREFERENCES_H | 2 | #ifndef __PREFERENCES_H |
3 | #define __PREFERENCES_H | 3 | #define __PREFERENCES_H |
4 | 4 | ||
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | #include <qmap.h> | 6 | #include <qmap.h> |
7 | 7 | ||
8 | class Config | 8 | class Config |
9 | { | 9 | { |
10 | QMap<QString, QString> values; | 10 | QMap<QString, QString> values; |
11 | QString fname; | 11 | QString fname; |
12 | public: | 12 | public: |
13 | Config(const QString& fname); | 13 | Config(const QString& fname); |
14 | ~Config(); | 14 | ~Config(); |
15 | void setGroup(const QString& s) { } | 15 | void setGroup(const QString& s) { } |
16 | QString readEntry(const QString&, const QString&); | 16 | QString readEntry(const QString&, const QString&); |
17 | bool readBoolEntry(const QString&, const bool); | 17 | bool readBoolEntry(const QString&, const bool); |
18 | int readNumEntry(const QString&, const int); | 18 | int readNumEntry(const QString&, const int); |
19 | 19 | ||
20 | void writeEntry(const QString&, const QString&); | 20 | void writeEntry(const QString&, const QString&); |
21 | void writeEntry(const QString&, const bool); | 21 | void writeEntry(const QString&, const bool); |
22 | void writeEntry(const QString&, const int); | 22 | void writeEntry(const QString&, const int); |
23 | }; | 23 | }; |
24 | 24 | ||
25 | #endif // PREFERENCES | 25 | #endif // PREFERENCES |
26 | #endif | 26 | #endif |
diff --git a/noncore/apps/opie-reader/reader.staticpro b/noncore/apps/opie-reader/reader.staticpro deleted file mode 100644 index 78ea8fb..0000000 --- a/noncore/apps/opie-reader/reader.staticpro +++ b/dev/null | |||
@@ -1,108 +0,0 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG = qt warn_off debug | ||
3 | HEADERS = Aportis.h \ | ||
4 | Bkmks.h \ | ||
5 | BuffDoc.h \ | ||
6 | ButtonPrefs.h \ | ||
7 | CAnnoEdit.h \ | ||
8 | CBuffer.h \ | ||
9 | CDrawBuffer.h \ | ||
10 | CEncoding.h \ | ||
11 | CEncoding_tables.h \ | ||
12 | CExpander.h \ | ||
13 | CFilter.h \ | ||
14 | CloseDialog.h \ | ||
15 | Filedata.h \ | ||
16 | FixedFont.h \ | ||
17 | FontControl.h \ | ||
18 | GraphicWin.h \ | ||
19 | Markups.h \ | ||
20 | Navigation.h \ | ||
21 | Palm2QImage.h \ | ||
22 | Prefs.h \ | ||
23 | QFloatBar.h \ | ||
24 | QTReader.h \ | ||
25 | QTReaderApp.h \ | ||
26 | QtrListView.h \ | ||
27 | Queue.h \ | ||
28 | StyleConsts.h \ | ||
29 | ToolbarPrefs.h \ | ||
30 | URLDialog.h \ | ||
31 | ZText.h \ | ||
32 | arith.h \ | ||
33 | cbkmkselector.h \ | ||
34 | config.h \ | ||
35 | fileBrowser.h \ | ||
36 | infowin.h \ | ||
37 | linktype.h \ | ||
38 | my_list.h \ | ||
39 | names.h \ | ||
40 | QSTATICREADERINC/opie.h \ | ||
41 | pdb.h \ | ||
42 | plucker_base.h \ | ||
43 | plucker.h \ | ||
44 | ppm.h \ | ||
45 | ppm_expander.h \ | ||
46 | preferences.h \ | ||
47 | QSTATICREADERINC/static.h \ | ||
48 | usenef.h \ | ||
49 | QSTATICREADERINC/useqpe.h \ | ||
50 | ustring.h \ | ||
51 | utypes.h \ | ||
52 | version.h \ | ||
53 | ztxt.h | ||
54 | |||
55 | SOURCES = Aportis.cpp \ | ||
56 | Bkmks.cpp \ | ||
57 | BuffDoc.cpp \ | ||
58 | ButtonPrefs.cpp \ | ||
59 | CAnnoEdit.cpp \ | ||
60 | CBuffer.cpp \ | ||
61 | CDrawBuffer.cpp \ | ||
62 | CEncoding.cpp \ | ||
63 | CEncoding_tables.cpp \ | ||
64 | CExpander.cpp \ | ||
65 | CFilter.cpp \ | ||
66 | CHM.cpp \ | ||
67 | CRegExp.cpp \ | ||
68 | CloseDialog.cpp \ | ||
69 | FontControl.cpp \ | ||
70 | GraphicWin.cpp \ | ||
71 | Navigation.cpp \ | ||
72 | Palm2QImage.cpp \ | ||
73 | Prefs.cpp \ | ||
74 | QTReader.cpp \ | ||
75 | QTReaderApp.cpp \ | ||
76 | QtrListView.cpp \ | ||
77 | StyleConsts.cpp \ | ||
78 | ToolbarPrefs.cpp \ | ||
79 | URLDialog.cpp \ | ||
80 | arith_d.cpp \ | ||
81 | chm_lib.c \ | ||
82 | fileBrowser.cpp \ | ||
83 | hrule.cpp \ | ||
84 | infowin.cpp \ | ||
85 | iSilo.cpp \ | ||
86 | lzx.c \ | ||
87 | main.cpp \ | ||
88 | orkey.cpp \ | ||
89 | pdb.cpp \ | ||
90 | plucker.cpp \ | ||
91 | plucker_base.cpp \ | ||
92 | ppm.cpp \ | ||
93 | ppm_expander.cpp \ | ||
94 | preferences.cpp \ | ||
95 | striphtml.cpp \ | ||
96 | util.cpp \ | ||
97 | version.cpp \ | ||
98 | ztxt.cpp | ||
99 | |||
100 | INTERFACES= | ||
101 | DESTDIR = QSTATICREADEROBJS | ||
102 | INCLUDEPATH+= QSTATICREADERINC | ||
103 | DEPENDPATH+= QSTATICREADERINC | ||
104 | OBJECTS_DIR = QSTATICREADEROBJS | ||
105 | MOC_DIR = QSTATICREADERMOCS | ||
106 | TARGET = uqtreader | ||
107 | #LIBS += -lqpe | ||
108 | |||
diff --git a/noncore/apps/opie-reader/reader.staticzpro b/noncore/apps/opie-reader/reader.staticzpro deleted file mode 100644 index 861eb88..0000000 --- a/noncore/apps/opie-reader/reader.staticzpro +++ b/dev/null | |||
@@ -1,108 +0,0 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG = qt warn_on release | ||
3 | HEADERS = Aportis.h \ | ||
4 | Bkmks.h \ | ||
5 | BuffDoc.h \ | ||
6 | ButtonPrefs.h \ | ||
7 | CAnnoEdit.h \ | ||
8 | CBuffer.h \ | ||
9 | CDrawBuffer.h \ | ||
10 | CEncoding.h \ | ||
11 | CEncoding_tables.h \ | ||
12 | CExpander.h \ | ||
13 | CFilter.h \ | ||
14 | CloseDialog.h \ | ||
15 | Filedata.h \ | ||
16 | FixedFont.h \ | ||
17 | FontControl.h \ | ||
18 | GraphicWin.h \ | ||
19 | Markups.h \ | ||
20 | Navigation.h \ | ||
21 | Palm2QImage.h \ | ||
22 | Prefs.h \ | ||
23 | QFloatBar.h \ | ||
24 | QTReader.h \ | ||
25 | QTReaderApp.h \ | ||
26 | QtrListView.h \ | ||
27 | Queue.h \ | ||
28 | StateData.h \ | ||
29 | StyleConsts.h \ | ||
30 | ToolbarPrefs.h \ | ||
31 | URLDialog.h \ | ||
32 | ZText.h \ | ||
33 | arith.h \ | ||
34 | cbkmkselector.h \ | ||
35 | config.h \ | ||
36 | fileBrowser.h \ | ||
37 | infowin.h \ | ||
38 | linktype.h \ | ||
39 | my_list.h \ | ||
40 | names.h \ | ||
41 | ZSTATICREADERINC/opie.h \ | ||
42 | pdb.h \ | ||
43 | plucker_base.h \ | ||
44 | plucker.h \ | ||
45 | ppm.h \ | ||
46 | ppm_expander.h \ | ||
47 | preferences.h \ | ||
48 | ZSTATICREADERINC/static.h \ | ||
49 | usenef.h \ | ||
50 | ZSTATICREADERINC/useqpe.h \ | ||
51 | ustring.h \ | ||
52 | utypes.h \ | ||
53 | version.h \ | ||
54 | ztxt.h | ||
55 | |||
56 | SOURCES = Aportis.cpp \ | ||
57 | Bkmks.cpp \ | ||
58 | BuffDoc.cpp \ | ||
59 | ButtonPrefs.cpp \ | ||
60 | CAnnoEdit.cpp \ | ||
61 | CBuffer.cpp \ | ||
62 | CDrawBuffer.cpp \ | ||
63 | CEncoding.cpp \ | ||
64 | CEncoding_tables.cpp \ | ||
65 | CExpander.cpp \ | ||
66 | CFilter.cpp \ | ||
67 | CHM.cpp \ | ||
68 | CRegExp.cpp \ | ||
69 | CloseDialog.cpp \ | ||
70 | FontControl.cpp \ | ||
71 | GraphicWin.cpp \ | ||
72 | Navigation.cpp \ | ||
73 | Palm2QImage.cpp \ | ||
74 | Prefs.cpp \ | ||
75 | QTReader.cpp \ | ||
76 | QTReaderApp.cpp \ | ||
77 | QtrListView.cpp \ | ||
78 | StyleConsts.cpp \ | ||
79 | ToolbarPrefs.cpp \ | ||
80 | URLDialog.cpp \ | ||
81 | arith_d.cpp \ | ||
82 | chm_lib.c \ | ||
83 | fileBrowser.cpp \ | ||
84 | hrule.cpp \ | ||
85 | infowin.cpp \ | ||
86 | iSilo.cpp \ | ||
87 | lzx.c \ | ||
88 | main.cpp \ | ||
89 | orkey.cpp \ | ||
90 | pdb.cpp \ | ||
91 | plucker.cpp \ | ||
92 | plucker_base.cpp \ | ||
93 | ppm.cpp \ | ||
94 | ppm_expander.cpp \ | ||
95 | striphtml.cpp \ | ||
96 | util.cpp \ | ||
97 | version.cpp \ | ||
98 | ztxt.cpp | ||
99 | |||
100 | INTERFACES= | ||
101 | DESTDIR = ZSTATICREADEROBJS | ||
102 | INCLUDEPATH+= ZSTATICREADERINC | ||
103 | DEPENDPATH+= ZSTATICREADERINC | ||
104 | OBJECTS_DIR = ZSTATICREADEROBJS | ||
105 | MOC_DIR = ZSTATICREADERMOCS | ||
106 | TARGET = uqtreader | ||
107 | LIBS += -lqpe | ||
108 | |||
diff --git a/noncore/apps/opie-reader/reader/reader.pro b/noncore/apps/opie-reader/reader/reader.pro index 6349ea7..dc6a5dd 100644 --- a/noncore/apps/opie-reader/reader/reader.pro +++ b/noncore/apps/opie-reader/reader/reader.pro | |||
@@ -1,87 +1,88 @@ | |||
1 | DEFINES += OPIE USEQPE | 1 | DEFINES += OPIE USEQPE |
2 | VPATH = .. | 2 | VPATH = .. |
3 | TEMPLATE= app | 3 | TEMPLATE= app |
4 | CONFIG = qt warn_on release | 4 | CONFIG = qt warn_on release |
5 | HEADERS = Aportis.h \ | 5 | HEADERS = Aportis.h \ |
6 | Bkmks.h \ | 6 | Bkmks.h \ |
7 | BuffDoc.h \ | 7 | BuffDoc.h \ |
8 | ButtonPrefs.h \ | 8 | ButtonPrefs.h \ |
9 | CAnnoEdit.h \ | 9 | CAnnoEdit.h \ |
10 | CBuffer.h \ | 10 | CBuffer.h \ |
11 | CDrawBuffer.h \ | 11 | CDrawBuffer.h \ |
12 | CEncoding.h \ | 12 | CEncoding.h \ |
13 | CEncoding_tables.h \ | 13 | CEncoding_tables.h \ |
14 | CExpander.h \ | 14 | CExpander.h \ |
15 | CFilter.h \ | 15 | CFilter.h \ |
16 | CloseDialog.h \ | 16 | CloseDialog.h \ |
17 | Filedata.h \ | 17 | Filedata.h \ |
18 | FixedFont.h \ | 18 | FixedFont.h \ |
19 | FontControl.h \ | 19 | FontControl.h \ |
20 | GraphicWin.h \ | 20 | GraphicWin.h \ |
21 | Markups.h \ | 21 | Markups.h \ |
22 | Navigation.h \ | 22 | Navigation.h \ |
23 | Palm2QImage.h \ | 23 | Palm2QImage.h \ |
24 | Prefs.h \ | 24 | Prefs.h \ |
25 | PPMd.h \ | 25 | PPMd.h \ |
26 | PPMdType.h \ | 26 | PPMdType.h \ |
27 | QFloatBar.h \ | 27 | QFloatBar.h \ |
28 | QTReader.h \ | 28 | QTReader.h \ |
29 | QTReaderApp.h \ | 29 | QTReaderApp.h \ |
30 | QtrListView.h \ | 30 | QtrListView.h \ |
31 | Queue.h \ | 31 | Queue.h \ |
32 | StyleConsts.h \ | 32 | StyleConsts.h \ |
33 | TableDialog.h \ | ||
33 | ToolbarPrefs.h \ | 34 | ToolbarPrefs.h \ |
34 | URLDialog.h \ | 35 | URLDialog.h \ |
35 | ZText.h \ | 36 | ZText.h \ |
36 | arith.h \ | 37 | arith.h \ |
37 | cbkmkselector.h \ | 38 | cbkmkselector.h \ |
38 | config.h \ | 39 | config.h \ |
39 | fileBrowser.h \ | 40 | fileBrowser.h \ |
40 | infowin.h \ | 41 | infowin.h \ |
41 | linktype.h \ | 42 | linktype.h \ |
42 | my_list.h \ | 43 | my_list.h \ |
43 | names.h \ | 44 | names.h \ |
44 | pdb.h \ | 45 | pdb.h \ |
45 | plucker.h \ | 46 | plucker.h \ |
46 | plucker_base.h \ | 47 | plucker_base.h \ |
47 | ppm.h \ | 48 | ppm.h \ |
48 | ppm_expander.h \ | 49 | ppm_expander.h \ |
49 | usenef.h \ | ||
50 | ustring.h \ | 50 | ustring.h \ |
51 | util.h \ | 51 | util.h \ |
52 | utypes.h \ | 52 | utypes.h \ |
53 | version.h \ | 53 | version.h \ |
54 | ztxt.h | 54 | ztxt.h |
55 | 55 | ||
56 | SOURCES = BuffDoc.cpp \ | 56 | SOURCES = BuffDoc.cpp \ |
57 | ButtonPrefs.cpp \ | 57 | ButtonPrefs.cpp \ |
58 | CAnnoEdit.cpp \ | 58 | CAnnoEdit.cpp \ |
59 | CDrawBuffer.cpp \ | 59 | CDrawBuffer.cpp \ |
60 | CEncoding.cpp \ | 60 | CEncoding.cpp \ |
61 | CEncoding_tables.cpp \ | 61 | CEncoding_tables.cpp \ |
62 | CFilter.cpp \ | 62 | CFilter.cpp \ |
63 | CRegExp.cpp \ | 63 | CRegExp.cpp \ |
64 | CloseDialog.cpp \ | 64 | CloseDialog.cpp \ |
65 | FontControl.cpp \ | 65 | FontControl.cpp \ |
66 | GraphicWin.cpp \ | 66 | GraphicWin.cpp \ |
67 | Prefs.cpp \ | 67 | Prefs.cpp \ |
68 | QTReader.cpp \ | 68 | QTReader.cpp \ |
69 | QTReaderApp.cpp \ | 69 | QTReaderApp.cpp \ |
70 | QtrListView.cpp \ | 70 | QtrListView.cpp \ |
71 | TableDialog.cpp \ | ||
71 | ToolbarPrefs.cpp \ | 72 | ToolbarPrefs.cpp \ |
72 | URLDialog.cpp \ | 73 | URLDialog.cpp \ |
73 | fileBrowser.cpp \ | 74 | fileBrowser.cpp \ |
74 | infowin.cpp \ | 75 | infowin.cpp \ |
75 | main.cpp \ | 76 | main.cpp \ |
76 | orkey.cpp \ | 77 | orkey.cpp \ |
77 | util.cpp \ | 78 | util.cpp \ |
78 | version.cpp | 79 | version.cpp |
79 | 80 | ||
80 | INTERFACES= | 81 | INTERFACES= |
81 | DESTDIR = $(OPIEDIR)/bin | 82 | DESTDIR = $(OPIEDIR)/bin |
82 | INCLUDEPATH+= $(OPIEDIR)/include | 83 | INCLUDEPATH+= $(OPIEDIR)/include |
83 | DEPENDPATH+= $(OPIEDIR)/include | 84 | DEPENDPATH+= $(OPIEDIR)/include |
84 | TARGET = opie-reader | 85 | TARGET = opie-reader |
85 | LIBS += -lopiecore2 -lopieui2 -lqpe -lreader_codec | 86 | LIBS += -lopiecore2 -lopieui2 -lqpe -lreader_codec |
86 | 87 | ||
87 | include( $(OPIEDIR)/include.pro ) | 88 | include( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/setn.sh b/noncore/apps/opie-reader/setn.sh deleted file mode 100644 index ad9409f..0000000 --- a/noncore/apps/opie-reader/setn.sh +++ b/dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | red='\e[0;31m' | ||
2 | RED='\e[1;31m' | ||
3 | blue='\e[0;34m' | ||
4 | BLUE='\e[1;34m' | ||
5 | cyan='\e[0;36m' | ||
6 | CYAN='\e[1;36m' | ||
7 | NC='\e[0m' # No Color | ||
8 | |||
9 | if test -z $OLDPATH; then | ||
10 | export OLDPATH=$PATH | ||
11 | fi | ||
12 | |||
13 | if test -z $OLD_LD_LIBRARY_PATH; then | ||
14 | export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH | ||
15 | fi | ||
16 | |||
17 | #export QPEDIR=/opt/Qtopia | ||
18 | export QTDIR=/home/tim/nevyos/qt-embedded-free-3.1.1 | ||
19 | export PATH=$QTDIR/bin:$OLDPATH | ||
20 | export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-generic-g++ | ||
21 | export LD_LIBRARY_PATH=$QTDIR/lib:$OLD_LD_LIBRARY_PATH | ||
22 | |||
23 | #PS1="[${cyan}\T$NC][${RED}Laptop${NC}]\W> " | ||
24 | #PS1="[${RED}NevyOS${NC}]\W> " | ||
25 | PS1="[NevyOS]\W> " | ||
26 | |||
27 | echo -e \\n${RED}NevyOS${NC} environment configured\\n | ||
diff --git a/noncore/apps/opie-reader/seto.sh b/noncore/apps/opie-reader/seto.sh deleted file mode 100644 index c1d1dd1..0000000 --- a/noncore/apps/opie-reader/seto.sh +++ b/dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | red='\e[0;31m' | ||
2 | RED='\e[1;31m' | ||
3 | blue='\e[0;34m' | ||
4 | BLUE='\e[1;34m' | ||
5 | cyan='\e[0;36m' | ||
6 | CYAN='\e[1;36m' | ||
7 | NC='\e[0m' # No Color | ||
8 | |||
9 | if test -z $OLDPATH; then | ||
10 | export OLDPATH=$PATH | ||
11 | fi | ||
12 | |||
13 | if test -z $OLD_LD_LIBRARY_PATH; then | ||
14 | export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH | ||
15 | fi | ||
16 | |||
17 | export QPEDIR=/opt/Qtopia/opie | ||
18 | export QTDIR=/opt/Qtopia/opie | ||
19 | export PATH=$QTDIR/bin:/usr/local/arm/3.3/bin:$OLDPATH | ||
20 | export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-opie-g++ | ||
21 | #export LD_LIBRARY_PATH=$QTDIR/lib:$OLD_LD_LIBRARY_PATH | ||
22 | |||
23 | PS1="[Opie]\W> " | ||
24 | |||
25 | echo -e \\n${RED}Opie${NC} environment configured\\n | ||
diff --git a/noncore/apps/opie-reader/setqt.sh b/noncore/apps/opie-reader/setqt.sh deleted file mode 100644 index 1b7e7b7..0000000 --- a/noncore/apps/opie-reader/setqt.sh +++ b/dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | red='\e[0;31m' | ||
2 | RED='\e[1;31m' | ||
3 | blue='\e[0;34m' | ||
4 | BLUE='\e[1;34m' | ||
5 | cyan='\e[0;36m' | ||
6 | CYAN='\e[1;36m' | ||
7 | NC='\e[0m' # No Color | ||
8 | |||
9 | if test -z $OLDPATH; then | ||
10 | export OLDPATH=$PATH | ||
11 | fi | ||
12 | |||
13 | if test -z $OLD_LD_LIBRARY_PATH; then | ||
14 | export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH | ||
15 | fi | ||
16 | |||
17 | #export QPEDIR=/opt/Qtopia | ||
18 | export QTDIR=/usr/lib/qt3 | ||
19 | export PATH=$QTDIR/bin:$OLDPATH | ||
20 | #export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-generic-g++ | ||
21 | |||
22 | export READERDIR=/home/tim/uqtreader | ||
23 | export LD_LIBRARY_PATH=$READERDIR/lib:$OLD_LD_LIBRARY_PATH | ||
24 | |||
25 | |||
26 | #PS1="[${cyan}\T$NC][${RED}Laptop${NC}]\W> " | ||
27 | #PS1="[${RED}NevyOS${NC}]\W> " | ||
28 | PS1="[QT]\W> " | ||
29 | |||
30 | echo -e \\n${RED}QT${NC} environment configured\\n | ||
diff --git a/noncore/apps/opie-reader/setws.sh b/noncore/apps/opie-reader/setws.sh deleted file mode 100644 index 61aeccb..0000000 --- a/noncore/apps/opie-reader/setws.sh +++ b/dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | red='\e[0;31m' | ||
2 | RED='\e[1;31m' | ||
3 | blue='\e[0;34m' | ||
4 | BLUE='\e[1;34m' | ||
5 | cyan='\e[0;36m' | ||
6 | CYAN='\e[1;36m' | ||
7 | NC='\e[0m' # No Color | ||
8 | |||
9 | if test -z $OLDPATH; then | ||
10 | export OLDPATH=$PATH | ||
11 | fi | ||
12 | |||
13 | if test -z $OLD_LD_LIBRARY_PATH; then | ||
14 | export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH | ||
15 | fi | ||
16 | |||
17 | export QPEDIR=/opt/Qtopia | ||
18 | export QTDIR=/opt/Qtopia | ||
19 | export PATH=$QTDIR/bin:$OLDPATH | ||
20 | export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-generic-g++ | ||
21 | export LD_LIBRARY_PATH=$QTDIR/lib:$OLD_LD_LIBRARY_PATH | ||
22 | |||
23 | #PS1="[${cyan}\T$NC][${RED}Laptop${NC}]\W> " | ||
24 | #PS1="[${RED}Laptop${NC}]\W> " | ||
25 | PS1="[Laptop]\W> " | ||
26 | |||
27 | echo -e \\n${RED}Laptop${NC} environment configured\\n | ||
diff --git a/noncore/apps/opie-reader/setz.sh b/noncore/apps/opie-reader/setz.sh deleted file mode 100644 index e2fa4cd..0000000 --- a/noncore/apps/opie-reader/setz.sh +++ b/dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | red='\e[0;31m' | ||
2 | RED='\e[1;31m' | ||
3 | blue='\e[0;34m' | ||
4 | BLUE='\e[1;34m' | ||
5 | cyan='\e[0;36m' | ||
6 | CYAN='\e[1;36m' | ||
7 | NC='\e[0m' # No Color | ||
8 | |||
9 | if test -z $OLDPATH; then | ||
10 | export OLDPATH=$PATH | ||
11 | fi | ||
12 | |||
13 | if test -z $OLD_LD_LIBRARY_PATH; then | ||
14 | export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH | ||
15 | fi | ||
16 | |||
17 | export QPEDIR=/opt/Qtopia/sharp | ||
18 | export QTDIR=/opt/Qtopia/sharp | ||
19 | export PATH=$QTDIR/bin:/usr/local/arm/bin:$OLDPATH | ||
20 | export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-sharp-g++ | ||
21 | export LD_LIBRARY_PATH=$QTDIR/lib:$OLD_LD_LIBRARY_PATH | ||
22 | |||
23 | PS1="[Zaurus]\W> " | ||
24 | |||
25 | echo -e \\n${RED}Zaurus${NC} environment configured\\n | ||
diff --git a/noncore/apps/opie-reader/striphtml.cpp b/noncore/apps/opie-reader/striphtml.cpp index e86402b..c434dbb 100644 --- a/noncore/apps/opie-reader/striphtml.cpp +++ b/noncore/apps/opie-reader/striphtml.cpp | |||
@@ -1,1248 +1,1414 @@ | |||
1 | #include <qmap.h> | 1 | #include <qmap.h> |
2 | #include <qfileinfo.h> | 2 | #include <qfileinfo.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qdir.h> | 4 | #include <qdir.h> |
5 | #ifdef USEQPE | 5 | #ifdef USEQPE |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | #endif | 7 | #endif |
8 | #include "CDrawBuffer.h" | 8 | #include "CDrawBuffer.h" |
9 | #include "striphtml.h" | 9 | #include "striphtml.h" |
10 | #include "hrule.h" | 10 | #include "hrule.h" |
11 | #include "util.h" | ||
12 | 11 | ||
13 | #include <qregexp.h> | 12 | #include <qregexp.h> |
14 | #include <qimage.h> | 13 | #include <qimage.h> |
15 | #include <qpixmap.h> | 14 | #include <qpixmap.h> |
16 | //#include <qprogressdialog.h> | 15 | //#include <qprogressdialog.h> |
17 | //#include <qapplication.h> | 16 | //#include <qapplication.h> |
18 | 17 | ||
19 | static unsigned char h2i(unsigned char c) | 18 | static unsigned char h2i(unsigned char c) |
20 | { | 19 | { |
21 | unsigned char ret = 0; | 20 | unsigned char ret = 0; |
22 | if ('0' <= c && c <= '9') | 21 | if ('0' <= c && c <= '9') |
23 | { | 22 | { |
24 | ret = c - '0'; | 23 | ret = c - '0'; |
25 | } | 24 | } |
26 | else if ('a' <= c && c <= 'f') | 25 | else if ('a' <= c && c <= 'f') |
27 | { | 26 | { |
28 | ret = c - 'a' + 10; | 27 | ret = c - 'a' + 10; |
29 | } | 28 | } |
30 | return ret; | 29 | return ret; |
31 | } | 30 | } |
32 | 31 | ||
33 | static void parse_color(const QString& attr, unsigned char& r, unsigned char& g, unsigned char& b) | 32 | static void parse_color(const QString& attr, unsigned char& r, unsigned char& g, unsigned char& b) |
34 | { | 33 | { |
35 | r = g = b = 0; | 34 | r = g = b = 0; |
36 | if (attr.length() >= 7 && attr[0] == '#') | 35 | if (attr.length() >= 7 && attr[0] == '#') |
37 | { | 36 | { |
38 | r = h2i(attr[1].unicode()); | 37 | r = h2i(attr[1].unicode()); |
39 | r = 16*r + h2i(attr[2].unicode()); | 38 | r = 16*r + h2i(attr[2].unicode()); |
40 | g = h2i(attr[3].unicode()); | 39 | g = h2i(attr[3].unicode()); |
41 | g = 16*g + h2i(attr[4].unicode()); | 40 | g = 16*g + h2i(attr[4].unicode()); |
42 | b = h2i(attr[5].unicode()); | 41 | b = h2i(attr[5].unicode()); |
43 | b = 16*b + h2i(attr[6].unicode()); | 42 | b = 16*b + h2i(attr[6].unicode()); |
44 | } | 43 | } |
45 | else if (attr == "red") | 44 | else if (attr == "red") |
46 | { | 45 | { |
47 | r = 255; | 46 | r = 255; |
48 | } | 47 | } |
49 | else if (attr == "green") | 48 | else if (attr == "green") |
50 | { | 49 | { |
51 | g = 255; | 50 | g = 255; |
52 | } | 51 | } |
53 | else if (attr == "blue") | 52 | else if (attr == "blue") |
54 | { | 53 | { |
55 | b = 255; | 54 | b = 255; |
56 | } | 55 | } |
57 | else if (attr == "white") | 56 | else if (attr == "white") |
58 | { | 57 | { |
59 | r = g = b = 255; | 58 | r = g = b = 255; |
60 | } | 59 | } |
61 | else if (attr == "black") | 60 | else if (attr == "black") |
62 | { | 61 | { |
63 | r = g = b = 0; | 62 | r = g = b = 0; |
64 | } | 63 | } |
65 | else | 64 | else |
66 | { | 65 | { |
67 | qDebug("Don't understand colour \"%s\"", (const char*)attr); | 66 | qDebug("Don't understand colour \"%s\"", (const char*)attr); |
68 | } | 67 | } |
69 | } | 68 | } |
70 | 69 | ||
71 | CNavigation_base<htmlmark> striphtml::m_nav; | 70 | CNavigation_base<htmlmark> striphtml::m_nav; |
72 | 71 | ||
73 | void striphtml::skipblock(const QString& _ent) | 72 | void striphtml::skipblock(const QString& _ent) |
74 | { | 73 | { |
75 | tchar ch = '>'; | 74 | tchar ch = '>'; |
76 | CStyle dummy; | 75 | CStyle dummy; |
77 | QString ent; | 76 | QString ent; |
78 | unsigned long pos; | 77 | unsigned long pos; |
79 | do | 78 | do |
80 | { | 79 | { |
81 | while (ch != '<' && ch != UEOF) | 80 | while (ch != '<' && ch != UEOF) |
82 | { | 81 | { |
83 | mygetch(ch, dummy, pos); | 82 | mygetch(ch, dummy, pos); |
84 | } | 83 | } |
85 | 84 | ||
86 | ch = skip_ws(); | 85 | ch = skip_ws(); |
87 | 86 | ||
88 | ent = getname(ch, " >").lower(); | 87 | ent = getname(ch, " >").lower(); |
89 | qDebug("Skipblock:%s", (const char*)ent); | 88 | qDebug("Skipblock:%s", (const char*)ent); |
90 | } while (ent != _ent && ch != UEOF); | 89 | } while (ent != _ent && ch != UEOF); |
91 | } | 90 | } |
92 | 91 | ||
93 | void striphtml::locate(unsigned int n) | 92 | void striphtml::reset() |
94 | { | 93 | { |
95 | m_inblock = false; | 94 | m_inblock = false; |
96 | text_q = ""; | 95 | text_q = ""; |
96 | q = ""; | ||
97 | tablenesteddepth = 0; | ||
97 | forcecentre = false; | 98 | forcecentre = false; |
98 | ignorespace = false; | 99 | ignorespace = false; |
100 | indent = 0; | ||
99 | while (!stylestack.isEmpty()) stylestack.pop(); | 101 | while (!stylestack.isEmpty()) stylestack.pop(); |
100 | currentstyle.unset(); | 102 | currentstyle.unset(); |
103 | } | ||
104 | |||
105 | void striphtml::locate(unsigned int n) | ||
106 | { | ||
101 | qDebug("striphtml:locating:%u", n); | 107 | qDebug("striphtml:locating:%u", n); |
108 | reset(); | ||
102 | parent->locate(n); | 109 | parent->locate(n); |
103 | } | 110 | } |
104 | 111 | ||
105 | int striphtml::getpara(CBuffer& buff, unsigned long& startpos) | 112 | int striphtml::getpara(CBuffer& buff, unsigned long& startpos) |
106 | { | 113 | { |
107 | tchar ch; | 114 | tchar ch; |
108 | CStyle sty; | 115 | CStyle sty; |
109 | unsigned long pos; | 116 | unsigned long pos; |
110 | int i = 0; | 117 | int i = 0; |
111 | parent->getch(ch, sty, startpos); | 118 | parent->getch(ch, sty, startpos); |
112 | pos = startpos; | 119 | pos = startpos; |
113 | while (1) | 120 | while (1) |
114 | { | 121 | { |
115 | if (ch == 10 && !isPre) | 122 | if (ch == 10 && !isPre) |
116 | { | 123 | { |
117 | ch = ' '; | 124 | ch = ' '; |
118 | } | 125 | } |
119 | if (ch == UEOF) | 126 | if (ch == UEOF) |
120 | { | 127 | { |
121 | // qDebug("EOF:%d:%u", i, pos); | 128 | // qDebug("EOF:%d:%u", i, pos); |
122 | buff[i] = 0; | 129 | buff[i] = 0; |
123 | if (i == 0) | 130 | if (i == 0) |
124 | { | 131 | { |
125 | i = -1; | 132 | i = -1; |
126 | } | 133 | } |
127 | return i; | 134 | return i; |
128 | } | 135 | } |
129 | else if (ch == '<') | 136 | else if (ch == '<') |
130 | { | 137 | { |
131 | tchar ch2 = skip_ws(); | 138 | tchar ch2 = skip_ws(); |
132 | QString ent = getname(ch2, " >"); | 139 | QString ent = getname(ch2, " >"); |
133 | ent = ent.lower(); | 140 | ent = ent.lower(); |
134 | // qDebug("ent:%s", (const char*)ent); | 141 | // qDebug("ent:%s", (const char*)ent); |
135 | if (ent == "a") | 142 | if (ent == "a") |
136 | { | 143 | { |
137 | buff[i++] = '<'; | 144 | buff[i++] = '<'; |
138 | buff[i++] = 'a'; | 145 | buff[i++] = 'a'; |
139 | buff[i++] = ch2; | 146 | buff[i++] = ch2; |
140 | // buff[i] = 0; qDebug("ANCHOR:%s", (const char*)toQString(buff.data())); | 147 | // buff[i] = 0; qDebug("ANCHOR:%s", (const char*)toQString(buff.data())); |
141 | } | 148 | } |
142 | else if (ent == "/a") | 149 | else if (ent == "/a") |
143 | { | 150 | { |
144 | buff[i++] = '<'; | 151 | buff[i++] = '<'; |
145 | buff[i++] = '/'; | 152 | buff[i++] = '/'; |
146 | buff[i++] = 'a'; | 153 | buff[i++] = 'a'; |
147 | buff[i++] = ch2; | 154 | buff[i++] = ch2; |
148 | // buff[i] = 0; qDebug("/ANCHOR:%s", (const char*)toQString(buff.data())); | 155 | // buff[i] = 0; qDebug("/ANCHOR:%s", (const char*)toQString(buff.data())); |
149 | } | 156 | } |
150 | else if (ent == "div") | 157 | else if (ent == "div") |
151 | { | 158 | { |
152 | // buff[i] = 0; qDebug("DIV:%s", (const char*)toQString(buff.data())); | 159 | // buff[i] = 0; qDebug("DIV:%s", (const char*)toQString(buff.data())); |
153 | if (i == 0) | 160 | if (i == 0) |
154 | { | 161 | { |
155 | buff[i++] = '<'; | 162 | buff[i++] = '<'; |
156 | buff[i++] = 'd'; | 163 | buff[i++] = 'd'; |
157 | buff[i++] = 'i'; | 164 | buff[i++] = 'i'; |
158 | buff[i++] = 'v'; | 165 | buff[i++] = 'v'; |
159 | buff[i++] = ' '; | 166 | buff[i++] = ' '; |
160 | buff[i++] = ch2; | 167 | buff[i++] = ch2; |
161 | while (ch2 != '>' && ch2 != UEOF && i < 2048) | 168 | while (ch2 != '>' && ch2 != UEOF && i < 2048) |
162 | { | 169 | { |
163 | parent->getch(ch2, sty, pos); | 170 | parent->getch(ch2, sty, pos); |
164 | buff[i++] = ch2; | 171 | buff[i++] = ch2; |
165 | } | 172 | } |
166 | } | 173 | } |
167 | else | 174 | else |
168 | { | 175 | { |
169 | locate(pos); | 176 | locate(pos); |
170 | } | 177 | } |
171 | buff[i++] = 0; | 178 | buff[i++] = 0; |
172 | // qDebug("DIV:%s", (const char*)toQString(buff.data())); | 179 | // qDebug("DIV:%s", (const char*)toQString(buff.data())); |
173 | return i; | 180 | return i; |
174 | } | 181 | } |
175 | else if (ent == "p" || (ent[0] == 'h' && ent.length() == 2 && QString("123456789").find(ent[1]) != -1)) | 182 | else if (ent == "p" || (ent[0] == 'h' && ent.length() == 2 && QString("123456789").find(ent[1]) != -1)) |
176 | { | 183 | { |
177 | buff[i++] = 0; | 184 | buff[i++] = 0; |
178 | while (ch2 != '>' && ch2 != UEOF) | 185 | while (ch2 != '>' && ch2 != UEOF) |
179 | { | 186 | { |
180 | parent->getch(ch2, sty, pos); | 187 | parent->getch(ch2, sty, pos); |
181 | } | 188 | } |
182 | return i; | 189 | return i; |
183 | } | 190 | } |
184 | else | 191 | else |
185 | { | 192 | { |
186 | while (ch2 != '>' && ch2 != UEOF) | 193 | while (ch2 != '>' && ch2 != UEOF) |
187 | { | 194 | { |
188 | parent->getch(ch2, sty, pos); | 195 | parent->getch(ch2, sty, pos); |
189 | } | 196 | } |
190 | } | 197 | } |
191 | } | 198 | } |
192 | else | 199 | else |
193 | { | 200 | { |
194 | buff[i++] = ch; | 201 | buff[i++] = ch; |
195 | } | 202 | } |
196 | parent->getch(ch, sty, pos); | 203 | parent->getch(ch, sty, pos); |
197 | } | 204 | } |
198 | } | 205 | } |
199 | 206 | ||
200 | QString striphtml::dehtml(const QString& _info) | 207 | QString striphtml::dehtml(const QString& _info) |
201 | { | 208 | { |
202 | QString info; | 209 | QString info; |
203 | for (int i = 0; i < _info.length(); i++) | 210 | for (int i = 0; i < _info.length(); i++) |
204 | { | 211 | { |
205 | tchar ch = _info[i]; | 212 | tchar ch = _info[i]; |
206 | if (ch == '%') | 213 | if (ch == '%') |
207 | { | 214 | { |
208 | ch = 0; | 215 | ch = 0; |
209 | for (int j = 0; j < 2; j++) | 216 | for (int j = 0; j < 2; j++) |
210 | { | 217 | { |
211 | ch <<= 4; | 218 | ch <<= 4; |
212 | tchar ch1 = _info[++i]; | 219 | tchar ch1 = _info[++i]; |
213 | if ('0' <= ch1 && ch1 <= '9') | 220 | if ('0' <= ch1 && ch1 <= '9') |
214 | { | 221 | { |
215 | ch += ch1 - '0'; | 222 | ch += ch1 - '0'; |
216 | } | 223 | } |
217 | else if ('a' <= ch1 && ch1 <= 'f') | 224 | else if ('a' <= ch1 && ch1 <= 'f') |
218 | { | 225 | { |
219 | ch += ch1 - 'a' + 10; | 226 | ch += ch1 - 'a' + 10; |
220 | } | 227 | } |
221 | else if ('A' <= ch1 && ch1 <= 'F') | 228 | else if ('A' <= ch1 && ch1 <= 'F') |
222 | { | 229 | { |
223 | ch += ch1 - 'A' + 10; | 230 | ch += ch1 - 'A' + 10; |
224 | } | 231 | } |
225 | } | 232 | } |
226 | } | 233 | } |
227 | info += ch; | 234 | info += ch; |
228 | } | 235 | } |
229 | return info; | 236 | return info; |
230 | } | 237 | } |
231 | 238 | ||
232 | bool striphtml::findanchor(const QString& _info) | 239 | bool striphtml::findanchor(const QString& _info) |
233 | { | 240 | { |
234 | // QProgressDialog dlg("Finding link...", QString::null, 0, NULL, "progress", true); | 241 | // QProgressDialog dlg("Finding link...", QString::null, 0, NULL, "progress", true); |
235 | // QProgressBar dlg(0); | 242 | // QProgressBar dlg(0); |
243 | if (parent->findanchor(_info)) | ||
244 | { | ||
245 | reset(); | ||
246 | return true; | ||
247 | } | ||
248 | qDebug("Using html find"); | ||
249 | parent->locate(parent->startSection()); | ||
236 | #if defined(USEQPE) || defined(_WINDOWS) | 250 | #if defined(USEQPE) || defined(_WINDOWS) |
237 | QString info; | 251 | QString info; |
238 | for (int i = 0; i < _info.length(); i++) | 252 | for (int i = 0; i < _info.length(); i++) |
239 | { | 253 | { |
240 | tchar ch = _info[i]; | 254 | tchar ch = _info[i]; |
241 | if (QString(".^$[]*+?").find(ch) != -1) | 255 | if (QString(".^$[]*+?").find(ch) != -1) |
242 | { | 256 | { |
243 | info += '\\'; | 257 | info += '\\'; |
244 | } | 258 | } |
245 | info += ch; | 259 | info += ch; |
246 | } | 260 | } |
247 | #else | 261 | #else |
248 | QString info = QRegExp::escape(_info); | 262 | QString info = QRegExp::escape(_info); |
249 | #endif | 263 | #endif |
250 | qDebug("Adjusted searchstring:%s", (const char*)info); | 264 | qDebug("Adjusted searchstring:%s", (const char*)info); |
251 | QString sname("<[Aa][^>]*[ \t]+[Nn][Aa][Mm][Ee][ \t]*=[ \t]*\"?"); | 265 | QString sname("<[Aa][^>]*[ \t]+[Nn][Aa][Mm][Ee][ \t]*=[ \t]*\"?"); |
252 | sname += info + "\"?[ \t>]"; | 266 | sname += info + "\"?[ \t>]"; |
253 | QString sid("<[A-Za-z][^>]*[ \t]+[Ii][Dd][ \t]*=[ \t]*\"?"); | 267 | QString sid("<[A-Za-z][^>]*[ \t]+[Ii][Dd][ \t]*=[ \t]*\"?"); |
254 | sid += info+"\"?[ \t>]"; | 268 | sid += info+"\"?[ \t>]"; |
255 | #ifdef USEQPE | 269 | #ifdef USEQPE |
256 | QRegExp name(sname); | 270 | QRegExp name(sname); |
257 | QRegExp id(sid); | 271 | QRegExp id(sid); |
258 | #else | 272 | #else |
259 | QRegExp name(sname+"|"+sid); | 273 | QRegExp name(sname+"|"+sid); |
260 | #endif | 274 | #endif |
261 | bool ret = true; | 275 | bool ret = true; |
262 | locate(0); | 276 | locate(0); |
263 | unsigned long pos = 0; | 277 | unsigned long pos = 0; |
264 | unsigned long startpos = 0; | 278 | unsigned long startpos = 0; |
265 | int offset; | 279 | int offset; |
266 | CBuffer test; | 280 | CBuffer test; |
267 | qDebug("striphtml::findanchor"); | 281 | qDebug("striphtml::findanchor"); |
268 | // dlg.show(); | 282 | // dlg.show(); |
269 | if (getpara(test, pos) >= 0) | 283 | if (getpara(test, pos) >= 0) |
270 | { | 284 | { |
271 | while (1) | 285 | while (1) |
272 | { | 286 | { |
273 | // qApp->processEvents(); | 287 | // qApp->processEvents(); |
274 | if ((offset = name.match(toQString(test.data()))) != -1) break; | 288 | if ((offset = name.match(toQString(test.data()))) != -1) break; |
275 | #ifdef USEQPE | 289 | #ifdef USEQPE |
276 | if ((offset = id.match(toQString(test.data()))) != -1) break; | 290 | if ((offset = id.match(toQString(test.data()))) != -1) break; |
277 | #endif | 291 | #endif |
278 | if (getpara(test, pos) < 0) | 292 | if (getpara(test, pos) < 0) |
279 | { | 293 | { |
280 | locate(startpos); | 294 | locate(startpos); |
281 | qDebug("Not found"); | 295 | qDebug("Not found"); |
282 | return false; | 296 | return false; |
283 | } | 297 | } |
284 | } | 298 | } |
285 | locate(pos); | 299 | locate(pos); |
286 | qDebug("Found"); | 300 | qDebug("Found"); |
287 | ret = true; | 301 | ret = true; |
288 | } | 302 | } |
289 | else | 303 | else |
290 | { | 304 | { |
291 | locate(startpos); | 305 | locate(startpos); |
292 | qDebug("Not found"); | 306 | qDebug("Not found"); |
293 | ret = false; | 307 | ret = false; |
294 | } | 308 | } |
295 | return ret; | 309 | return ret; |
296 | } | 310 | } |
297 | 311 | ||
298 | striphtml::striphtml(const QString& _s) : entmap(NULL), isPre(false), currentid(0), lastch(0), currentfile(_s), indent(0), forcecentre(false), m_inblock(false), m_bchm(false), ignorespace(false) | 312 | striphtml::striphtml(const QString& _s) : entmap(NULL), isPre(false), currentid(0), lastch(0), currentfile(_s), indent(0), forcecentre(false), m_inblock(false), m_bchm(false), ignorespace(false), tablenesteddepth(0) |
299 | { | 313 | { |
300 | href2filepos = new QMap<QString, unsigned long>; | 314 | href2filepos = new QMap<QString, unsigned long>; |
301 | id2href = new QMap<unsigned long, QString>; | 315 | id2href = new QMap<unsigned long, QString>; |
302 | } | 316 | } |
303 | 317 | ||
304 | striphtml::~striphtml() | 318 | striphtml::~striphtml() |
305 | { | 319 | { |
306 | if (entmap != NULL) delete entmap; | 320 | if (entmap != NULL) delete entmap; |
307 | delete href2filepos; | 321 | delete href2filepos; |
308 | delete id2href; | 322 | delete id2href; |
309 | } | 323 | } |
310 | 324 | ||
311 | void striphtml::initentmap() | 325 | void striphtml::initentmap() |
312 | { | 326 | { |
313 | entmap = new QMap<QString, tchar>; | 327 | entmap = new QMap<QString, tchar>; |
314 | QString fname(QTReaderUtil::getPluginPath("data")); | 328 | #ifdef USEQPE |
329 | #ifdef OPIE | ||
330 | QString fname(getenv("OPIEDIR")); | ||
331 | #else | ||
332 | QString fname(getenv("QTDIR")); | ||
333 | #endif | ||
334 | fname += "/plugins/reader/data"; | ||
335 | #else | ||
336 | QString fname(getenv("READERDIR")); | ||
337 | fname += "/data"; | ||
338 | #endif | ||
315 | QFileInfo fi; | 339 | QFileInfo fi; |
316 | fi.setFile(fname, "HTMLentities"); | 340 | fi.setFile(fname, "HTMLentities"); |
317 | if (fi.exists()) | 341 | if (fi.exists()) |
318 | { | 342 | { |
319 | fname = fi.absFilePath(); | 343 | fname = fi.absFilePath(); |
320 | 344 | ||
321 | QFile fl(fname); | 345 | QFile fl(fname); |
322 | if (fl.open(IO_ReadOnly)) | 346 | if (fl.open(IO_ReadOnly)) |
323 | { | 347 | { |
324 | QTextStream t(&fl); | 348 | QTextStream t(&fl); |
325 | QString key, value; | 349 | QString key, value; |
326 | while (!t.eof()) | 350 | while (!t.eof()) |
327 | { | 351 | { |
328 | QString data = t.readLine(); | 352 | QString data = t.readLine(); |
329 | int colon = data.find(':'); | 353 | int colon = data.find(':'); |
330 | if (colon > 0) | 354 | if (colon > 0) |
331 | { | 355 | { |
332 | QString key = data.left(colon); | 356 | QString key = data.left(colon); |
333 | QString value = data.right(data.length()-colon-1); | 357 | QString value = data.right(data.length()-colon-1); |
334 | bool ok; | 358 | bool ok; |
335 | int ret = value.toInt(&ok); | 359 | int ret = value.toInt(&ok); |
336 | if (ok) | 360 | if (ok) |
337 | { | 361 | { |
338 | (*entmap)[key] = ret; | 362 | (*entmap)[key] = ret; |
339 | } | 363 | } |
340 | } | 364 | } |
341 | } | 365 | } |
342 | fl.close(); | 366 | fl.close(); |
343 | } | 367 | } |
344 | } | 368 | } |
345 | } | 369 | } |
346 | 370 | ||
347 | unsigned short striphtml::skip_ws() | 371 | unsigned short striphtml::skip_ws() |
348 | { | 372 | { |
349 | tchar ch; | 373 | tchar ch; |
350 | CStyle sty; | 374 | CStyle sty; |
351 | unsigned long dummy; | 375 | unsigned long dummy; |
352 | do | 376 | do |
353 | { | 377 | { |
354 | mygetch(ch, sty, dummy); | 378 | mygetch(ch, sty, dummy); |
355 | } | 379 | } |
356 | while (ch < 33 && ch != UEOF); | 380 | while (ch < 33 && ch != UEOF); |
357 | return ch; | 381 | return ch; |
358 | } | 382 | } |
359 | 383 | ||
360 | unsigned short striphtml::skip_ws_end() | 384 | unsigned short striphtml::skip_ws_end() |
361 | { | 385 | { |
362 | unsigned long dummy; | 386 | unsigned long dummy; |
363 | return skip_ws_end(dummy); | 387 | return skip_ws_end(dummy); |
364 | } | 388 | } |
365 | 389 | ||
366 | unsigned short striphtml::skip_ws_end(unsigned long& pos) | 390 | unsigned short striphtml::skip_ws_end(unsigned long& pos) |
367 | { | 391 | { |
368 | tchar ch; | 392 | tchar ch; |
369 | CStyle sty; | 393 | CStyle sty; |
370 | do | 394 | do |
371 | { | 395 | { |
372 | mygetch(ch, sty, pos); | 396 | mygetch(ch, sty, pos); |
373 | } | 397 | } |
374 | while (ch != '>' && ch != UEOF); | 398 | while (ch != '>' && ch != UEOF); |
375 | return ch; | 399 | return ch; |
376 | } | 400 | } |
377 | 401 | ||
378 | QString striphtml::getname(tchar& ch, const QString& nd) | 402 | QString striphtml::getname(tchar& ch, const QString& nd) |
379 | { | 403 | { |
380 | QString nm = ""; | 404 | QString nm = ""; |
381 | // nm += ch; | 405 | // nm += ch; |
382 | CStyle sty; | 406 | CStyle sty; |
383 | unsigned long dummy; | 407 | unsigned long dummy; |
384 | while (1) | 408 | while (1) |
385 | { | 409 | { |
386 | // if ( QChar(ch).isLetterOrNumber() ) | 410 | // if ( QChar(ch).isLetterOrNumber() ) |
387 | if (ch != UEOF && nd.find(ch, 0, false) == -1 && nm.length() < 2048) | 411 | if (ch != UEOF && nd.find(ch, 0, false) == -1 && nm.length() < 2048) |
388 | { | 412 | { |
389 | nm += ch; | 413 | nm += ch; |
390 | } | 414 | } |
391 | else | 415 | else |
392 | { | 416 | { |
393 | break; | 417 | break; |
394 | } | 418 | } |
395 | mygetch(ch, sty, dummy); | 419 | mygetch(ch, sty, dummy); |
396 | } | 420 | } |
397 | return nm; | 421 | return nm; |
398 | } | 422 | } |
399 | 423 | ||
400 | QString striphtml::getattr(tchar& ch) | 424 | QString striphtml::getattr(tchar& ch) |
401 | { | 425 | { |
402 | QString ref; | 426 | QString ref; |
403 | CStyle sty; | 427 | CStyle sty; |
404 | unsigned long pos; | 428 | unsigned long pos; |
405 | if (ch == ' ') ch = skip_ws(); | 429 | if (ch == ' ') ch = skip_ws(); |
406 | if (ch == '=') | 430 | if (ch == '=') |
407 | { | 431 | { |
408 | ch = skip_ws(); | 432 | ch = skip_ws(); |
409 | if (ch == '"') | 433 | if (ch == '"') |
410 | { | 434 | { |
411 | mygetch(ch, sty, pos); | 435 | mygetch(ch, sty, pos); |
412 | ref = getname(ch, "\""); | 436 | ref = getname(ch, "\""); |
413 | ch = skip_ws(); | 437 | ch = skip_ws(); |
414 | } | 438 | } |
439 | else if (ch == '\'') | ||
440 | { | ||
441 | mygetch(ch, sty, pos); | ||
442 | ref = getname(ch, "\'"); | ||
443 | ch = skip_ws(); | ||
444 | } | ||
415 | else | 445 | else |
416 | { | 446 | { |
417 | ref = getname(ch, " >"); | 447 | ref = getname(ch, " >"); |
418 | if (ch == ' ') ch = skip_ws(); | 448 | if (ch == ' ') ch = skip_ws(); |
419 | } | 449 | } |
420 | } | 450 | } |
421 | return ref; | 451 | return ref; |
422 | } | 452 | } |
423 | 453 | ||
424 | linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString& nm) | 454 | linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString& nm) |
425 | { | 455 | { |
426 | #if defined(USEQPE) || defined(_WINDOWS) | 456 | #if defined(USEQPE) || defined(_WINDOWS) |
427 | QMap<unsigned long, QString>::Iterator hrefit = id2href->find(n); | 457 | QMap<unsigned long, QString>::Iterator hrefit = id2href->find(n); |
428 | #else | 458 | #else |
429 | QMap<unsigned long, QString>::iterator hrefit = id2href->find(n); | 459 | QMap<unsigned long, QString>::iterator hrefit = id2href->find(n); |
430 | #endif | 460 | #endif |
431 | if (hrefit == id2href->end()) | 461 | if (hrefit == id2href->end()) |
432 | { | 462 | { |
433 | return eNone; | 463 | return eNone; |
434 | } | 464 | } |
435 | QString href = *hrefit; | 465 | QString href = *hrefit; |
436 | #if defined(USEQPE) || defined(_WINDOWS) | 466 | #if defined(USEQPE) || defined(_WINDOWS) |
437 | QMap<QString, unsigned long>::Iterator fpit = href2filepos->find(href); | 467 | QMap<QString, unsigned long>::Iterator fpit = href2filepos->find(href); |
438 | #else | 468 | #else |
439 | QMap<QString, unsigned long>::iterator fpit = href2filepos->find(href); | 469 | QMap<QString, unsigned long>::iterator fpit = href2filepos->find(href); |
440 | #endif | 470 | #endif |
441 | if (fpit == href2filepos->end()) | 471 | if (fpit == href2filepos->end()) |
442 | { | 472 | { |
443 | if (href == "history.back()") | 473 | if (href == "history.back()") |
444 | { | 474 | { |
445 | QString fc = currentfile; | 475 | QString fc = currentfile; |
446 | unsigned long loc; | 476 | unsigned long loc; |
447 | htmlmark m(fc, loc); | 477 | htmlmark m(fc, loc); |
448 | linkType ret = (m_nav.back(m)) ? eFile : eNone; | 478 | linkType ret = (m_nav.back(m)) ? eFile : eNone; |
449 | if (fc == m.filename()) | 479 | if (fc == m.filename()) |
450 | { | 480 | { |
451 | if ((ret & eFile) != 0) | 481 | if ((ret & eFile) != 0) |
452 | { | 482 | { |
453 | locate(m.posn()); | 483 | locate(m.posn()); |
454 | return eLink; | 484 | return eLink; |
455 | } | 485 | } |
456 | } | 486 | } |
457 | return eNone; | 487 | return eNone; |
458 | } | 488 | } |
459 | qDebug("Searching for %s", (const char*)href); | 489 | qDebug("Searching for %s", (const char*)href); |
460 | 490 | ||
461 | 491 | ||
462 | QString file, name; | 492 | QString file, name; |
463 | 493 | ||
464 | int colon = href.find('#'); | 494 | int colon = href.find('#'); |
465 | if (colon >= 0) | 495 | if (colon >= 0) |
466 | { | 496 | { |
467 | file = dehtml(href.left(colon)); | 497 | file = dehtml(href.left(colon)); |
468 | name = dehtml(href.right(href.length()-colon-1)); | 498 | name = dehtml(href.right(href.length()-colon-1)); |
469 | } | 499 | } |
470 | else | 500 | else |
471 | { | 501 | { |
472 | file = dehtml(href); | 502 | file = dehtml(href); |
473 | } | 503 | } |
474 | 504 | ||
475 | qDebug("File:%s", (const char*)file); | 505 | qDebug("File:%s", (const char*)file); |
476 | qDebug("Name:%s", (const char*)name); | 506 | qDebug("Name:%s", (const char*)name); |
477 | 507 | ||
478 | 508 | ||
479 | if (file.isEmpty()) | 509 | if (file.isEmpty()) |
480 | { | 510 | { |
511 | if (parent->findanchor(name)) | ||
512 | { | ||
513 | reset(); | ||
514 | return eLink; | ||
515 | } | ||
481 | fpit = href2filepos->find(name); | 516 | fpit = href2filepos->find(name); |
482 | if (fpit != href2filepos->end()) | 517 | if (fpit != href2filepos->end()) |
483 | { | 518 | { |
484 | locate(*fpit); | 519 | locate(*fpit); |
485 | return eLink; | 520 | return eLink; |
486 | } | 521 | } |
487 | else | 522 | else |
488 | { | 523 | { |
489 | // nm = QString("<a[^>]*name[ \t]*=[ \t]*\"") + name + "\""; | 524 | // nm = QString("<a[^>]*name[ \t]*=[ \t]*\"") + name + "\""; |
490 | qDebug("Do a search for:%s", (const char*)name); | 525 | qDebug("Do a search for:%s", (const char*)name); |
491 | parent->locate(0); | ||
492 | findanchor(name); | 526 | findanchor(name); |
493 | return eLink; | 527 | return eLink; |
494 | } | 528 | } |
495 | } | 529 | } |
496 | else | 530 | else |
497 | // if (href.find('#') == -1) | 531 | // if (href.find('#') == -1) |
498 | { | 532 | { |
499 | if (m_bchm) | 533 | if (m_bchm) |
500 | { | 534 | { |
501 | w = "/"+file; | 535 | w = file; |
502 | nm = name; | 536 | nm = name; |
503 | return eFile; | 537 | return eFile; |
504 | } | 538 | } |
505 | else | 539 | else |
506 | { | 540 | { |
507 | QFileInfo f(currentfile); | 541 | QFileInfo f(currentfile); |
508 | QFileInfo f1(f.dir(true), file); | 542 | QFileInfo f1(f.dir(true), file); |
509 | if (f1.exists()) | 543 | if (f1.exists()) |
510 | { | 544 | { |
511 | w = f1.absFilePath(); | 545 | w = f1.absFilePath(); |
512 | nm = name; | 546 | nm = name; |
513 | } | 547 | } |
514 | else | 548 | else |
515 | { | 549 | { |
516 | w = file; | 550 | w = file; |
517 | } | 551 | } |
518 | return (f1.exists() ? eFile : eNone); | 552 | return (f1.exists() ? eFile : eNone); |
519 | } | 553 | } |
520 | } | 554 | } |
521 | return eNone; | 555 | return eNone; |
522 | } | 556 | } |
523 | locate(*fpit); | 557 | locate(*fpit); |
524 | // parent->locate((*href2filepos)[(*id2href)[n]]); | 558 | // parent->locate((*href2filepos)[(*id2href)[n]]); |
525 | return eLink; | 559 | return eLink; |
526 | } | 560 | } |
527 | /* | 561 | /* |
528 | unsigned short striphtml::parse_m() | 562 | unsigned short striphtml::parse_m() |
529 | { | 563 | { |
530 | tchar ch; | 564 | tchar ch; |
531 | CStyle sty; | 565 | CStyle sty; |
532 | unsigned long dummy; | 566 | unsigned long dummy; |
533 | mygetch(ch, sty, dummy); | 567 | mygetch(ch, sty, dummy); |
534 | if (ch == 'm' || ch == 'M') | 568 | if (ch == 'm' || ch == 'M') |
535 | { | 569 | { |
536 | ch = skip_ws_end(); | 570 | ch = skip_ws_end(); |
537 | if (ch == '>') | 571 | if (ch == '>') |
538 | { | 572 | { |
539 | return 0; | 573 | return 0; |
540 | } | 574 | } |
541 | } | 575 | } |
542 | return ch; | 576 | return ch; |
543 | } | 577 | } |
544 | */ | 578 | */ |
545 | 579 | ||
546 | void striphtml::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) | 580 | void striphtml::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) |
547 | { | 581 | { |
548 | if (!text_q.isEmpty() && !m_inblock) | 582 | if (!text_q.isEmpty() && !m_inblock) |
549 | { | 583 | { |
550 | ch = text_q[0].unicode(); | 584 | ch = text_q[0].unicode(); |
551 | text_q = text_q.right(text_q.length()-1); | 585 | text_q = text_q.right(text_q.length()-1); |
552 | } | 586 | } |
553 | else | 587 | else |
554 | { | 588 | { |
555 | parent->getch(ch, sty, pos); | 589 | parent->getch(ch, sty, pos); |
556 | if (ch == '<') | 590 | if (ch == '<') |
557 | { | 591 | { |
558 | m_inblock = true; | 592 | m_inblock = true; |
559 | } | 593 | } |
560 | if (ch == '>') | 594 | if (ch == '>') |
561 | { | 595 | { |
562 | m_inblock = false; | 596 | m_inblock = false; |
563 | } | 597 | } |
564 | } | 598 | } |
565 | if (ch == 10 && !isPre) | 599 | if (ch == 10 && !isPre) |
566 | { | 600 | { |
601 | #ifdef REMOVE_LF_BEFORE_ENDTAG | ||
602 | parent->getch(ch, sty, pos); | ||
603 | if (ch == '<') | ||
604 | { | ||
605 | parent->getch(ch, sty, pos); | ||
606 | if (ch == '/') | ||
607 | { | ||
608 | ch = '<'; | ||
609 | text_q += '/'; | ||
610 | } | ||
611 | else | ||
612 | { | ||
613 | text_q += '<'; | ||
614 | text_q += ch; | ||
615 | ch = ' '; | ||
616 | } | ||
617 | } | ||
618 | else | ||
619 | { | ||
620 | text_q += ch; | ||
621 | ch = ' '; | ||
622 | } | ||
623 | #else | ||
567 | ch = ' '; | 624 | ch = ' '; |
625 | #endif | ||
568 | } | 626 | } |
569 | } | 627 | } |
570 | 628 | ||
571 | void striphtml::parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long pos) | 629 | void striphtml::parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long pos) |
572 | { | 630 | { |
573 | /* | 631 | /* |
574 | int count = 0; | 632 | int count = 0; |
575 | for (CList<CStyle>::iterator iter = stylestack.begin(); iter != stylestack.end(); ++iter) | 633 | for (CList<CStyle>::iterator iter = stylestack.begin(); iter != stylestack.end(); ++iter) |
576 | { | 634 | { |
577 | count++; | 635 | count++; |
578 | } | 636 | } |
579 | qDebug("Currently have %u styles", count); | 637 | qDebug("Currently have %u styles", count); |
580 | */ | 638 | */ |
581 | if (stylestack.isEmpty()) | 639 | if (stylestack.isEmpty()) |
582 | { | 640 | { |
583 | currentstyle.unset(); | 641 | currentstyle.unset(); |
584 | } | 642 | } |
585 | else | 643 | else |
586 | { | 644 | { |
587 | qDebug("Using stack style"); | ||
588 | currentstyle = stylestack.first(); | 645 | currentstyle = stylestack.first(); |
589 | } | 646 | } |
590 | if (forcecentre) | 647 | if (forcecentre) |
591 | { | 648 | { |
592 | currentstyle.setCentreJustify(); | 649 | currentstyle.setCentreJustify(); |
593 | } | 650 | } |
594 | if (ch == ' ') ch = skip_ws(); | 651 | if (ch == ' ') ch = skip_ws(); |
595 | while (ch != '>' && ch != UEOF) | 652 | while (ch != '>' && ch != UEOF) |
596 | { | 653 | { |
597 | QString ent = getname(ch, " =>").lower(); | 654 | QString ent = getname(ch, " =>").lower(); |
598 | QString attr = getattr(ch).lower(); | 655 | QString attr = getattr(ch).lower(); |
599 | //qDebug("(Paragraph)Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 656 | //qDebug("(Paragraph)Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
600 | if (ent == "align") | 657 | if (ent == "align") |
601 | { | 658 | { |
602 | if (attr == "center") | 659 | if (attr == "center") |
603 | { | 660 | { |
604 | currentstyle.setCentreJustify(); | 661 | currentstyle.setCentreJustify(); |
605 | } | 662 | } |
606 | if (attr == "right") | 663 | if (attr == "right") |
607 | { | 664 | { |
608 | currentstyle.setRightJustify(); | 665 | currentstyle.setRightJustify(); |
609 | } | 666 | } |
667 | if (attr == "justify") | ||
668 | { | ||
669 | currentstyle.setFullJustify(); | ||
670 | } | ||
610 | } | 671 | } |
611 | if (ent == "id") | 672 | if (ent == "id") |
612 | { | 673 | { |
613 | (*href2filepos)[attr] = pos; | 674 | (*href2filepos)[attr] = pos; |
614 | } | 675 | } |
615 | if (ent == "bgcolor") | 676 | if (ent == "bgcolor") |
616 | { | 677 | { |
617 | qDebug("Got paper colour:%s", (const char*)attr); | 678 | qDebug("Got paper colour:%s", (const char*)attr); |
618 | unsigned char r,g,b; | 679 | unsigned char r,g,b; |
619 | parse_color(attr, r, g, b); | 680 | parse_color(attr, r, g, b); |
620 | currentstyle.setPaper(r, g, b); | 681 | currentstyle.setPaper(r, g, b); |
621 | } | 682 | } |
622 | if (ent == "color") | 683 | if (ent == "color") |
623 | { | 684 | { |
624 | qDebug("Got foreground colour:%s", (const char*)attr); | 685 | qDebug("Got foreground colour:%s", (const char*)attr); |
625 | unsigned char r,g,b; | 686 | unsigned char r,g,b; |
626 | parse_color(attr, r, g, b); | 687 | parse_color(attr, r, g, b); |
627 | currentstyle.setColour(r, g, b); | 688 | currentstyle.setColour(r, g, b); |
628 | } | 689 | } |
629 | if (ch == ' ') ch = skip_ws(); | 690 | if (ch == ' ') ch = skip_ws(); |
630 | } | 691 | } |
631 | ch = 10; | 692 | ch = 10; |
632 | } | 693 | } |
633 | 694 | ||
634 | void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 695 | void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
635 | { | 696 | { |
636 | currentstyle.clearPicture(); | 697 | currentstyle.clearPicture(); |
637 | if (!q.isEmpty()) | 698 | if (!q.isEmpty()) |
638 | { | 699 | { |
639 | ch = q[0].unicode(); | 700 | ch = q[0].unicode(); |
640 | if (ch == '-') | 701 | if (ch == '-') |
641 | { | 702 | { |
642 | tchar w = q[1].unicode(); | 703 | tchar w = q[1].unicode(); |
643 | tchar h = q[2].unicode(); | 704 | tchar h = q[2].unicode(); |
644 | unsigned char r = q[3].unicode(); | 705 | unsigned char r = q[3].unicode(); |
645 | unsigned char g = q[4].unicode(); | 706 | unsigned char g = q[4].unicode(); |
646 | unsigned char b = q[5].unicode(); | 707 | unsigned char b = q[5].unicode(); |
647 | ch = '#'; | 708 | ch = '#'; |
648 | //qDebug("html:hrule<%u, %u>", w, h); | 709 | //qDebug("html:hrule<%u, %u>", w, h); |
649 | currentstyle.setPicture(false, hRule(w,h,r,g,b)); | 710 | currentstyle.setPicture(false, hRule(w,h,r,g,b)); |
650 | q = q.right(q.length()-6); | 711 | q = q.right(q.length()-6); |
651 | } | 712 | } |
652 | else | 713 | else |
653 | { | 714 | { |
654 | q = q.right(q.length()-1); | 715 | q = q.right(q.length()-1); |
655 | } | 716 | } |
656 | sty = currentstyle; | 717 | sty = currentstyle; |
718 | lastch = ch; | ||
657 | return; | 719 | return; |
658 | } | 720 | } |
659 | do | 721 | do |
660 | { | 722 | { |
661 | unsigned long npos; | 723 | unsigned long npos; |
662 | CStyle dummy; | 724 | CStyle dummy; |
663 | mygetch(ch, dummy, pos); | 725 | mygetch(ch, dummy, pos); |
664 | // if (ch == 10 && !isPre) ch = ' '; | ||
665 | while (ch == '<' && ch != UEOF) | 726 | while (ch == '<' && ch != UEOF) |
666 | { | 727 | { |
667 | ch = skip_ws(); | 728 | ch = skip_ws(); |
668 | |||
669 | QString ent = getname(ch, " >").lower(); | 729 | QString ent = getname(ch, " >").lower(); |
670 | 730 | ||
671 | // qDebug("Entity:%s", (const char*)ent); | 731 | // qDebug("Entity:%s", (const char*)ent); |
672 | 732 | ||
673 | if (ent == "a"/* || ent == "reference"*/) | 733 | if (ent == "a"/* || ent == "reference"*/) |
674 | { | 734 | { |
675 | if (ch == ' ') ch = skip_ws(); | 735 | if (ch == ' ') ch = skip_ws(); |
676 | bool fileposfound = false; | 736 | bool fileposfound = false; |
677 | bool ishref = false; | 737 | bool ishref = false; |
678 | unsigned int filepos = 0; | 738 | unsigned int filepos = 0; |
679 | QString ref, name; | 739 | QString ref, name; |
680 | while (ch != '>' && ch != UEOF) | 740 | while (ch != '>' && ch != UEOF) |
681 | { | 741 | { |
682 | QString ent = getname(ch, " =>").lower(); | 742 | QString ent = getname(ch, " =>").lower(); |
683 | QString attr = getattr(ch); | 743 | QString attr = getattr(ch); |
684 | qDebug("<A>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 744 | //qDebug("<A>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
685 | if (ent == "name") | 745 | if (ent == "name") |
686 | { | 746 | { |
687 | name = attr; | 747 | name = attr; |
688 | } | 748 | } |
689 | if (ent == "onclick") | 749 | if (ent == "onclick") |
690 | { | 750 | { |
691 | int st = attr.find('\''); | 751 | int st = attr.find('\''); |
692 | int nd = attr.findRev('\''); | 752 | int nd = attr.findRev('\''); |
693 | ref = attr.mid(st+1, nd-st-1); | 753 | ref = attr.mid(st+1, nd-st-1); |
694 | ishref = true; | 754 | ishref = true; |
695 | qDebug("Onclick:%s", (const char*)ref); | 755 | qDebug("Onclick:%s", (const char*)ref); |
696 | } | 756 | } |
697 | if (ent == "href") | 757 | if (ent == "href") |
698 | { | 758 | { |
699 | ishref = true; | 759 | ishref = true; |
700 | ref = attr; | 760 | ref = attr; |
701 | } | 761 | } |
702 | if (ent == "filepos") | 762 | if (ent == "filepos") |
703 | { | 763 | { |
704 | filepos = attr.toUInt(&fileposfound); | 764 | filepos = attr.toUInt(&fileposfound); |
705 | if (ref.isEmpty()) | 765 | if (ref.isEmpty()) |
706 | { | 766 | { |
707 | ishref = true; | 767 | ishref = true; |
708 | ref = attr; | 768 | ref = attr; |
709 | } | 769 | } |
710 | } | 770 | } |
711 | if (ent == "title") | 771 | if (ent == "title") |
712 | { | 772 | { |
713 | text_q = attr + "</a><p>"; | 773 | text_q = attr + "</a><p>"; |
714 | } | 774 | } |
715 | qDebug("<a %s=%s>", (const char*)ent, (const char*)ref); | 775 | //qDebug("<a %s=%s>", (const char*)ent, (const char*)ref); |
716 | } | 776 | } |
717 | if (ishref) | 777 | if (ishref) |
718 | { | 778 | { |
719 | currentstyle.setColour(0,0,255); | 779 | currentstyle.setColour(0,0,255); |
720 | currentstyle.setLink(true); | 780 | currentstyle.setLink(true); |
721 | currentstyle.setData(currentid); | 781 | currentstyle.setData(currentid); |
722 | if (!text_q.isEmpty()) | 782 | if (!text_q.isEmpty()) |
723 | { | 783 | { |
724 | currentstyle.setBold(); | 784 | currentstyle.setBold(); |
725 | currentstyle.setCentreJustify(); | 785 | currentstyle.setCentreJustify(); |
726 | } | 786 | } |
727 | (*id2href)[currentid] = ref; | 787 | (*id2href)[currentid] = ref; |
728 | currentid++; | 788 | currentid++; |
729 | 789 | ||
730 | 790 | ||
731 | if (fileposfound) | 791 | if (fileposfound) |
732 | { | 792 | { |
733 | (*href2filepos)[ref] = filepos; | 793 | (*href2filepos)[ref] = filepos; |
734 | } | 794 | } |
735 | } | 795 | } |
736 | if (!name.isEmpty()) | 796 | if (!name.isEmpty()) |
737 | { | 797 | { |
738 | (*href2filepos)[name] = pos; | 798 | (*href2filepos)[name] = pos; |
739 | } | 799 | } |
740 | } | 800 | } |
741 | else if (ent == "p") | 801 | else if (ent == "p") |
742 | { | 802 | { |
743 | parse_paragraph(currentstyle, ch, pos); | 803 | parse_paragraph(currentstyle, ch, pos); |
744 | currentstyle.setExtraSpace(3); | 804 | currentstyle.setExtraSpace(3); |
745 | continue; | 805 | continue; |
746 | } | 806 | } |
747 | else if (ent == "div") | 807 | else if (ent == "div") |
748 | { | 808 | { |
749 | parse_paragraph(currentstyle, ch, pos); | 809 | parse_paragraph(currentstyle, ch, pos); |
750 | stylestack.push_front(currentstyle); | 810 | stylestack.push_front(currentstyle); |
751 | //indent = 0; | 811 | currentstyle.setExtraSpace(16); |
812 | //indent = 0; | ||
752 | continue; | 813 | continue; |
753 | } | 814 | } |
754 | else if (ent == "sup") | 815 | else if (ent == "sup") |
755 | { | 816 | { |
756 | currentstyle.setVOffset(-1); | 817 | currentstyle.setVOffset(-1); |
757 | } | 818 | } |
758 | else if (ent == "sup") | 819 | else if (ent == "sup") |
759 | { | 820 | { |
760 | currentstyle.setVOffset(1); | 821 | currentstyle.setVOffset(1); |
761 | } | 822 | } |
762 | else if (ent == "/sup" || ent == "/sub") | 823 | else if (ent == "/sup" || ent == "/sub") |
763 | { | 824 | { |
764 | currentstyle.setVOffset(0); | 825 | currentstyle.setVOffset(0); |
765 | } | 826 | } |
766 | else if (ent == "span") | 827 | else if (ent == "span") |
767 | { | 828 | { |
768 | if (ch == ' ') ch = skip_ws(); | 829 | if (ch == ' ') ch = skip_ws(); |
769 | while (ch != '>' && ch != UEOF) | 830 | while (ch != '>' && ch != UEOF) |
770 | { | 831 | { |
771 | QString ent = getname(ch, " =>").lower(); | 832 | QString ent = getname(ch, " =>").lower(); |
772 | QString attr = getattr(ch).lower(); | 833 | QString attr = getattr(ch).lower(); |
773 | if (ent == "bgcolor") | 834 | if (ent == "bgcolor") |
774 | { | 835 | { |
775 | qDebug("Got background colour:%s", (const char*)attr); | 836 | qDebug("Got background colour:%s", (const char*)attr); |
776 | unsigned char r,g,b; | 837 | unsigned char r,g,b; |
777 | parse_color(attr, r, g, b); | 838 | parse_color(attr, r, g, b); |
778 | currentstyle.setBackground(r, g, b); | 839 | currentstyle.setBackground(r, g, b); |
779 | } | 840 | } |
780 | if (ent == "color") | 841 | if (ent == "color") |
781 | { | 842 | { |
782 | qDebug("Got foreground colour:%s", (const char*)attr); | 843 | qDebug("Got foreground colour:%s", (const char*)attr); |
783 | unsigned char r,g,b; | 844 | unsigned char r,g,b; |
784 | parse_color(attr, r, g, b); | 845 | parse_color(attr, r, g, b); |
785 | currentstyle.setColour(r, g, b); | 846 | currentstyle.setColour(r, g, b); |
786 | } | 847 | } |
787 | } | 848 | } |
788 | stylestack.push_front(currentstyle); | 849 | stylestack.push_front(currentstyle); |
789 | } | 850 | } |
790 | else if (ent == "/span") | 851 | else if (ent == "/span") |
791 | { | 852 | { |
792 | if (ch != '>') ch = skip_ws_end(); | 853 | if (ch != '>') ch = skip_ws_end(); |
793 | currentstyle.setBackground(255, 255, 255); | 854 | currentstyle.setBackground(255, 255, 255); |
794 | currentstyle.setColour(0, 0, 0); | 855 | currentstyle.setColour(0, 0, 0); |
795 | if (!stylestack.isEmpty()) | 856 | if (!stylestack.isEmpty()) |
796 | { | 857 | { |
797 | stylestack.pop(); | 858 | stylestack.pop(); |
798 | } | 859 | } |
799 | } | 860 | } |
800 | else if (ent == "pre") | 861 | else if (ent == "pre") |
801 | { | 862 | { |
802 | isPre = true; | 863 | isPre = true; |
864 | currentstyle.setNoJustify(); | ||
803 | currentstyle.setMono(); | 865 | currentstyle.setMono(); |
804 | } | 866 | } |
805 | else if (ent == "tt") | 867 | else if (ent == "tt") |
806 | { | 868 | { |
807 | currentstyle.setMono(); | 869 | currentstyle.setMono(); |
808 | } | 870 | } |
809 | else if (ent == "b" || ent == "strong") | 871 | else if (ent == "b" || ent == "strong") |
810 | { | 872 | { |
811 | currentstyle.setBold(); | 873 | currentstyle.setBold(); |
812 | } | 874 | } |
813 | else if (ent == "u") | 875 | else if (ent == "u") |
814 | { | 876 | { |
815 | currentstyle.setUnderline(); | 877 | currentstyle.setUnderline(); |
816 | } | 878 | } |
817 | else if (ent == "/u") | 879 | else if (ent == "/u") |
818 | { | 880 | { |
819 | currentstyle.unsetUnderline(); | 881 | currentstyle.unsetUnderline(); |
820 | } | 882 | } |
821 | else if (ent == "blockquote") | 883 | else if (ent == "blockquote") |
822 | { | 884 | { |
823 | if (ch != '>') ch = skip_ws_end(); | 885 | if (ch != '>') ch = skip_ws_end(); |
824 | ch = 10; | 886 | ch = 10; |
887 | currentstyle.setExtraSpace(0); | ||
825 | currentstyle.setLeftMargin(30); | 888 | currentstyle.setLeftMargin(30); |
826 | currentstyle.setRightMargin(30); | 889 | currentstyle.setRightMargin(30); |
827 | continue; | 890 | continue; |
828 | } | 891 | } |
829 | else if (ent == "br" || ent == "br/") | 892 | else if (ent == "br" || ent == "br/") |
830 | { | 893 | { |
831 | if (ch != '>') ch = skip_ws_end(); | 894 | if (ch != '>') ch = skip_ws_end(); |
832 | ch = 10; | 895 | ch = 10; |
896 | currentstyle.setExtraSpace(0); | ||
897 | lastch = 0; | ||
833 | continue; | 898 | continue; |
834 | } | 899 | } |
835 | else if (ent == "mbp:pagebreak") | 900 | else if (ent == "mbp:pagebreak") |
836 | { | 901 | { |
837 | /* | 902 | /* |
838 | if (ch != '>') ch = skip_ws_end(pos); | 903 | if (ch != '>') ch = skip_ws_end(pos); |
839 | q += 10; | 904 | q += 10; |
840 | q += QChar(UEOF); | 905 | q += QChar(UEOF); |
841 | ch = 10; | 906 | ch = 10; |
842 | continue; | 907 | continue; |
843 | */ | 908 | */ |
844 | ch = 6; | 909 | ch = 6; |
845 | // currentstyle.setTop(); | 910 | // currentstyle.setTop(); |
846 | continue; | 911 | continue; |
847 | } | 912 | } |
848 | else if (ent == "center") | 913 | else if (ent == "center") |
849 | { | 914 | { |
850 | //forcecentre = true; | 915 | //forcecentre = true; |
851 | qDebug("setting centre"); | 916 | qDebug("setting centre"); |
852 | currentstyle.setCentreJustify(); | 917 | currentstyle.setCentreJustify(); |
853 | ch = 10; | 918 | ch = 10; |
854 | continue; | 919 | continue; |
855 | } | 920 | } |
856 | else if (ent == "/center") | 921 | else if (ent == "/center") |
857 | { | 922 | { |
858 | qDebug("unsetting centre"); | 923 | qDebug("unsetting centre"); |
859 | forcecentre = false; | 924 | forcecentre = false; |
860 | } | 925 | } |
861 | else if (ent == "li") | 926 | else if (ent == "li") |
862 | { | 927 | { |
863 | if (ch != '>') ch = skip_ws_end(); | 928 | if (ch != '>') ch = skip_ws_end(); |
929 | lastch = 0; | ||
864 | ch = 10; | 930 | ch = 10; |
865 | if (m_listtype[indent % m_cmaxdepth] == 1) | 931 | if (m_listtype[indent % m_cmaxdepth] == 1) |
866 | { | 932 | { |
867 | q.setNum(m_ctr[indent % m_cmaxdepth]++); | 933 | q.setNum(m_ctr[indent % m_cmaxdepth]++); |
868 | } | 934 | } |
869 | else | 935 | else |
870 | { | 936 | { |
871 | q += QChar(8226); | 937 | q += QChar(8226); |
872 | } | 938 | } |
873 | q += ' '; | 939 | q += ' '; |
874 | currentstyle.setLeftMargin(6*indent); | 940 | currentstyle.setLeftMargin(6*indent); |
875 | qDebug("Setting indent:%d", indent); | 941 | qDebug("Setting indent:%d", indent); |
876 | continue; | 942 | continue; |
877 | } | 943 | } |
878 | else if (ent == "ul") | 944 | else if (ent == "ul") |
879 | { | 945 | { |
880 | indent++; | 946 | indent++; |
881 | m_listtype[indent % m_cmaxdepth] = 0; | 947 | m_listtype[indent % m_cmaxdepth] = 0; |
882 | } | 948 | } |
883 | else if (ent == "/ul") | 949 | else if (ent == "/ul") |
884 | { | 950 | { |
885 | indent--; | 951 | indent--; |
886 | } | 952 | } |
887 | else if (ent == "ol") | 953 | else if (ent == "ol") |
888 | { | 954 | { |
889 | indent++; | 955 | indent++; |
890 | m_listtype[indent % m_cmaxdepth] = 1; | 956 | m_listtype[indent % m_cmaxdepth] = 1; |
891 | m_ctr[indent % m_cmaxdepth] = 1; | 957 | m_ctr[indent % m_cmaxdepth] = 1; |
892 | } | 958 | } |
893 | else if (ent == "/ol") | 959 | else if (ent == "/ol") |
894 | { | 960 | { |
895 | indent--; | 961 | indent--; |
896 | } | 962 | } |
897 | else if (ent == "i") | 963 | else if (ent == "i") |
898 | { | 964 | { |
899 | currentstyle.setItalic(); | 965 | currentstyle.setItalic(); |
900 | } | 966 | } |
901 | else if (ent == "em") | 967 | else if (ent == "em") |
902 | { | 968 | { |
903 | currentstyle.setItalic(); | 969 | currentstyle.setItalic(); |
904 | } | 970 | } |
905 | else if (ent == "small") | 971 | else if (ent == "small") |
906 | { | 972 | { |
907 | currentstyle.setFontSize(-2); | 973 | currentstyle.setFontSize(-2); |
908 | } | 974 | } |
909 | else if (ent == "/small") | 975 | else if (ent == "/small") |
910 | { | 976 | { |
911 | currentstyle.setFontSize(0); | 977 | currentstyle.setFontSize(0); |
912 | } | 978 | } |
913 | else if (ent == "big") | 979 | else if (ent == "big") |
914 | { | 980 | { |
915 | currentstyle.setFontSize(2); | 981 | currentstyle.setFontSize(2); |
916 | } | 982 | } |
917 | else if (ent == "/big") | 983 | else if (ent == "/big") |
918 | { | 984 | { |
919 | currentstyle.setFontSize(0); | 985 | currentstyle.setFontSize(0); |
920 | } | 986 | } |
987 | else if (ent[0] == '/' && ent[1] == 'h' && ent.length() == 3 && QString("123456789").find(ent[2]) != -1) | ||
988 | { | ||
989 | parse_paragraph(currentstyle, ch, pos); | ||
990 | currentstyle.setExtraSpace(3); | ||
991 | continue; | ||
992 | } | ||
921 | else if (ent[0] == 'h' && ent.length() == 2 && QString("123456789").find(ent[1]) != -1) | 993 | else if (ent[0] == 'h' && ent.length() == 2 && QString("123456789").find(ent[1]) != -1) |
922 | { | 994 | { |
923 | indent = 0; | 995 | indent = 0; |
924 | if (ent[1] == '1') | 996 | if (ent[1] == '1') |
925 | { | 997 | { |
926 | parse_paragraph(currentstyle, ch, pos); | 998 | parse_paragraph(currentstyle, ch, pos); |
927 | currentstyle.setFontSize(3); | 999 | currentstyle.setFontSize(3); |
928 | currentstyle.setExtraSpace(8); | 1000 | currentstyle.setExtraSpace(8); |
929 | currentstyle.setBold(); | 1001 | currentstyle.setBold(); |
930 | // currentstyle.setExtraSpace(10); | 1002 | // currentstyle.setExtraSpace(10); |
931 | continue; | ||
932 | } | 1003 | } |
933 | else if (ent[1] == '2') | 1004 | else if (ent[1] == '2') |
934 | { | 1005 | { |
935 | parse_paragraph(currentstyle, ch, pos); | 1006 | parse_paragraph(currentstyle, ch, pos); |
936 | currentstyle.setFontSize(2); | 1007 | currentstyle.setFontSize(2); |
937 | currentstyle.setExtraSpace(6); | 1008 | currentstyle.setExtraSpace(6); |
938 | currentstyle.setBold(); | 1009 | currentstyle.setBold(); |
939 | // currentstyle.setExtraSpace(10); | 1010 | // currentstyle.setExtraSpace(10); |
940 | continue; | ||
941 | } | 1011 | } |
942 | else if (ent[1] == '3') | 1012 | else if (ent[1] == '3') |
943 | { | 1013 | { |
944 | parse_paragraph(currentstyle, ch, pos); | 1014 | parse_paragraph(currentstyle, ch, pos); |
945 | currentstyle.setFontSize(1); | 1015 | currentstyle.setFontSize(1); |
946 | currentstyle.setExtraSpace(4); | 1016 | currentstyle.setExtraSpace(4); |
947 | currentstyle.setBold(); | 1017 | currentstyle.setBold(); |
948 | // currentstyle.setExtraSpace(10); | 1018 | // currentstyle.setExtraSpace(10); |
949 | continue; | ||
950 | } | 1019 | } |
951 | else | 1020 | else |
952 | { | 1021 | { |
953 | parse_paragraph(currentstyle, ch, pos); | 1022 | parse_paragraph(currentstyle, ch, pos); |
954 | currentstyle.setExtraSpace(4); | 1023 | currentstyle.setExtraSpace(4); |
955 | currentstyle.setBold(); | 1024 | currentstyle.setBold(); |
956 | // currentstyle.setExtraSpace(10); | 1025 | // currentstyle.setExtraSpace(10); |
957 | continue; | ||
958 | } | 1026 | } |
1027 | ch = 10; | ||
1028 | continue; | ||
959 | } | 1029 | } |
960 | 1030 | ||
961 | 1031 | ||
962 | else if (ent == "/a") | 1032 | else if (ent == "/a") |
963 | { | 1033 | { |
964 | currentstyle.setColour(0,0,0); | 1034 | currentstyle.setColour(0,0,0); |
965 | currentstyle.setLink(false); | 1035 | currentstyle.setLink(false); |
966 | } | 1036 | } |
967 | else if (ent == "/pre") | 1037 | else if (ent == "/pre") |
968 | { | 1038 | { |
969 | currentstyle.unsetMono(); | 1039 | currentstyle.unsetMono(); |
970 | isPre = false; | 1040 | isPre = false; |
971 | } | 1041 | } |
972 | else if (ent == "/tt") | 1042 | else if (ent == "/tt") |
973 | { | 1043 | { |
974 | currentstyle.unsetMono(); | 1044 | currentstyle.unsetMono(); |
975 | } | 1045 | } |
976 | else if (ent == "/b" || ent == "/strong") | 1046 | else if (ent == "/b" || ent == "/strong") |
977 | { | 1047 | { |
978 | currentstyle.unsetBold(); | 1048 | currentstyle.unsetBold(); |
979 | } | 1049 | } |
980 | else if (ent == "/i") | 1050 | else if (ent == "/i") |
981 | { | 1051 | { |
982 | currentstyle.unsetItalic(); | 1052 | currentstyle.unsetItalic(); |
983 | } | 1053 | } |
984 | else if (ent == "/em") | 1054 | else if (ent == "/em") |
985 | { | 1055 | { |
986 | currentstyle.unsetItalic(); | 1056 | currentstyle.unsetItalic(); |
987 | } | 1057 | } |
988 | else if (ent == "/div") | 1058 | else if (ent == "/div") |
989 | { | 1059 | { |
990 | currentstyle.unset(); | 1060 | currentstyle.unset(); |
991 | if (ch != '>') ch = skip_ws_end(); | 1061 | if (ch != '>') ch = skip_ws_end(); |
992 | ch = 10; | 1062 | ch = 10; |
993 | if (!stylestack.isEmpty()) | 1063 | if (!stylestack.isEmpty()) |
994 | { | 1064 | { |
995 | stylestack.pop(); | 1065 | stylestack.pop(); |
996 | } | 1066 | } |
997 | continue; | 1067 | continue; |
998 | } | 1068 | } |
999 | else if (ent == "tr") | 1069 | else if (ent == "tr") |
1000 | { | 1070 | { |
1001 | if (ch != '>') ch = skip_ws_end(); | 1071 | if (ch != '>') ch = skip_ws_end(); |
1002 | ch = 10; | 1072 | ch = 10; |
1003 | q += '-'; | 1073 | q += '-'; |
1004 | q += QChar(parent->getwidth()); | 1074 | q += QChar(parent->getwidth()); |
1005 | q += 2; | 1075 | q += 2; |
1006 | q += '\0'; | 1076 | q += '\0'; |
1007 | q += '\0'; | 1077 | q += '\0'; |
1008 | q += '\0'; | 1078 | q += '\0'; |
1009 | continue; | 1079 | continue; |
1010 | } | 1080 | } |
1011 | else if (ent == "td") | 1081 | else if (ent == "td") |
1012 | { | 1082 | { |
1013 | if (ch != '>') ch = skip_ws_end(); | 1083 | if (ch != '>') ch = skip_ws_end(); |
1014 | ignorespace = false; | 1084 | ignorespace = false; |
1015 | } | 1085 | } |
1016 | else if (ent == "/td") | 1086 | else if (ent == "/td") |
1017 | { | 1087 | { |
1018 | ignorespace = true; | 1088 | ignorespace = true; |
1019 | // parse_paragraph(currentstyle, ch, pos); | 1089 | // parse_paragraph(currentstyle, ch, pos); |
1020 | //stylestack.push_front(currentstyle); | 1090 | //stylestack.push_front(currentstyle); |
1021 | if (ch != '>') ch = skip_ws_end(); | 1091 | if (ch != '>') ch = skip_ws_end(); |
1022 | // ch = '|'; | 1092 | // ch = '|'; |
1023 | //continue; | 1093 | //continue; |
1024 | ch = 10; | 1094 | ch = 10; |
1025 | q += '-'; | 1095 | q += '-'; |
1026 | q += QChar(parent->getwidth()); | 1096 | q += QChar(parent->getwidth()); |
1027 | q += 1; | 1097 | q += 1; |
1028 | q += '\0'; | 1098 | q += '\0'; |
1029 | q += '\0'; | 1099 | q += '\0'; |
1030 | q += '\0'; | 1100 | q += '\0'; |
1031 | continue; | 1101 | continue; |
1032 | } | 1102 | } |
1033 | /* | 1103 | /* |
1034 | else if (ent == "/td") | 1104 | else if (ent == "/td") |
1035 | { | 1105 | { |
1036 | currentstyle.unset(); | 1106 | currentstyle.unset(); |
1037 | if (ch != '>') ch = skip_ws_end(); | 1107 | if (ch != '>') ch = skip_ws_end(); |
1038 | if (!stylestack.isEmpty()) | 1108 | if (!stylestack.isEmpty()) |
1039 | { | 1109 | { |
1040 | stylestack.pop(); | 1110 | stylestack.pop(); |
1041 | } | 1111 | } |
1042 | // ch = 10; | 1112 | // ch = 10; |
1043 | continue; | 1113 | continue; |
1044 | } | 1114 | } |
1045 | */ | 1115 | */ |
1046 | else if (ent[0] == '/' && ent.length() == 3 && ent[1] == 'h' && QString("123456789").find(ent[2]) != -1) | 1116 | else if (ent[0] == '/' && ent.length() == 3 && ent[1] == 'h' && QString("123456789").find(ent[2]) != -1) |
1047 | { | 1117 | { |
1048 | currentstyle.unset(); | 1118 | currentstyle.unset(); |
1049 | if (ch != '>') ch = skip_ws_end(); | 1119 | if (ch != '>') ch = skip_ws_end(); |
1050 | ch = 10; | 1120 | //ch = 10; |
1051 | continue; | 1121 | //continue; |
1052 | } | 1122 | } |
1053 | |||
1054 | |||
1055 | |||
1056 | else if (ent == "table" || ent == "/table") | 1123 | else if (ent == "table" || ent == "/table") |
1057 | { | 1124 | { |
1058 | currentstyle.unset(); | 1125 | currentstyle.unset(); |
1059 | ignorespace = (ent == "table"); | 1126 | ignorespace = (ent == "table"); |
1127 | if (ent == "table") | ||
1128 | { | ||
1129 | if (tablenesteddepth++ == 0) currentstyle.setTable(pos); | ||
1130 | } | ||
1131 | else | ||
1132 | { | ||
1133 | if (--tablenesteddepth <= 0) | ||
1134 | { | ||
1135 | tablenesteddepth = 0; | ||
1136 | currentstyle.setTable(0xffffffff); | ||
1137 | } | ||
1138 | } | ||
1060 | if (ch == ' ') ch = skip_ws(); | 1139 | if (ch == ' ') ch = skip_ws(); |
1061 | while (ch != '>' && ch != UEOF) | 1140 | while (ch != '>' && ch != UEOF) |
1062 | { | 1141 | { |
1063 | QString ent = getname(ch, " =>").lower(); | 1142 | QString ent = getname(ch, " =>").lower(); |
1064 | QString attr = getattr(ch); | 1143 | QString attr = getattr(ch); |
1065 | qDebug("<table>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 1144 | qDebug("<table>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
1066 | } | 1145 | } |
1067 | if (ch != '>') ch = skip_ws_end(); | 1146 | if (ch != '>') ch = skip_ws_end(); |
1068 | 1147 | ||
1148 | currentstyle.setLeftMargin(6*tablenesteddepth); | ||
1149 | |||
1150 | |||
1151 | lastch = 0; // Anything but 10 | ||
1069 | ch = 10; | 1152 | ch = 10; |
1070 | q += '-'; | 1153 | q += '-'; |
1071 | q += QChar(parent->getwidth()); | 1154 | q += QChar(parent->getwidth()); |
1072 | q += 2; | 1155 | q += 3; |
1073 | q += '\0'; | 1156 | q += '\0'; |
1074 | q += '\0'; | 1157 | q += '\0'; |
1075 | q += '\0'; | 1158 | q += '\0'; |
1076 | continue; | 1159 | continue; |
1077 | } | 1160 | } |
1078 | else if (ent == "hr") | 1161 | else if (ent == "hr") |
1079 | { | 1162 | { |
1163 | //bool isPageBreak = false; | ||
1080 | if (ch == ' ') ch = skip_ws(); | 1164 | if (ch == ' ') ch = skip_ws(); |
1081 | // if (stylestack.isEmpty()) | ||
1082 | // { | ||
1083 | currentstyle.unset(); | ||
1084 | // } | ||
1085 | /* | ||
1086 | else | ||
1087 | { | ||
1088 | qDebug("Using stack style"); | ||
1089 | currentstyle = stylestack.first(); | ||
1090 | } | ||
1091 | */ | ||
1092 | unsigned char red = 0, green = 0, blue = 0; | 1165 | unsigned char red = 0, green = 0, blue = 0; |
1093 | while (ch != '>' && ch != UEOF) | 1166 | while (ch != '>' && ch != UEOF) |
1094 | { | 1167 | { |
1095 | QString ent = getname(ch, " =>").lower(); | 1168 | QString ent = getname(ch, " =>").lower(); |
1096 | QString attr = getattr(ch); | 1169 | QString attr = getattr(ch); |
1097 | if (ent == "color") | 1170 | if (ent == "color") |
1098 | { | 1171 | { |
1099 | parse_color(attr, red, green, blue); | 1172 | parse_color(attr, red, green, blue); |
1100 | } | 1173 | } |
1174 | /* | ||
1175 | if (ent == "size") | ||
1176 | { | ||
1177 | if (attr == "0") | ||
1178 | { | ||
1179 | isPageBreak = true; | ||
1180 | } | ||
1181 | } | ||
1182 | */ | ||
1101 | qDebug("<hr>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 1183 | qDebug("<hr>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
1102 | } | 1184 | } |
1103 | if (ch != '>') ch = skip_ws_end(); | 1185 | if (ch != '>') ch = skip_ws_end(); |
1104 | ch = 10; | 1186 | /* |
1105 | q += '-'; | 1187 | if (isPageBreak) |
1106 | q += QChar(parent->getwidth()); | 1188 | { |
1107 | q += 3; | 1189 | ch = UEOF; |
1108 | q += red; | 1190 | } |
1109 | q += green; | 1191 | else |
1110 | q += blue; | 1192 | { |
1193 | */ | ||
1194 | // if (stylestack.isEmpty()) | ||
1195 | // { | ||
1196 | currentstyle.unset(); | ||
1197 | // } | ||
1198 | /* | ||
1199 | else | ||
1200 | { | ||
1201 | qDebug("Using stack style"); | ||
1202 | currentstyle = stylestack.first(); | ||
1203 | } | ||
1204 | */ | ||
1205 | lastch = 0; //Anything but 10 or ' ' | ||
1206 | ch = 10; | ||
1207 | q += '-'; | ||
1208 | q += QChar(parent->getwidth()); | ||
1209 | q += 3; | ||
1210 | q += red; | ||
1211 | q += green; | ||
1212 | q += blue; | ||
1213 | |||
1111 | continue; | 1214 | continue; |
1112 | } | 1215 | } |
1113 | 1216 | ||
1114 | 1217 | ||
1115 | 1218 | ||
1116 | else if (ent == "img") | 1219 | else if (ent == "img") |
1117 | { | 1220 | { |
1118 | if (ch == ' ') ch = skip_ws(); | 1221 | if (ch == ' ') ch = skip_ws(); |
1119 | while (ch != '>' && ch != UEOF) | 1222 | while (ch != '>' && ch != UEOF) |
1120 | { | 1223 | { |
1121 | QString ent = getname(ch, " =>").lower(); | 1224 | QString ent = getname(ch, " =>").lower(); |
1122 | QString attr = getattr(ch); | 1225 | QString attr = getattr(ch); |
1123 | qDebug("<img>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 1226 | qDebug("<img>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
1124 | if (ent == "src") | 1227 | if (ent == "src") |
1125 | { | 1228 | { |
1229 | /* | ||
1126 | if (m_bchm) | 1230 | if (m_bchm) |
1127 | { | 1231 | { |
1128 | QImage* img = parent->getPicture(attr); | 1232 | QImage* img = parent->getPicture(attr); |
1129 | if (img != NULL) | 1233 | if (img != NULL) |
1130 | { | 1234 | { |
1131 | currentstyle.setPicture(true, img); | 1235 | currentstyle.setPicture(true, img); |
1132 | } | 1236 | } |
1133 | } | 1237 | } |
1238 | */ | ||
1239 | |||
1240 | |||
1241 | QImage* img = parent->getPicture(attr); | ||
1242 | if (img != NULL) | ||
1243 | { | ||
1244 | currentstyle.setPicture(true, img); | ||
1245 | } | ||
1134 | else | 1246 | else |
1135 | { | 1247 | { |
1136 | QFileInfo f(currentfile); | 1248 | QFileInfo f(currentfile); |
1137 | QFileInfo f1(f.dir(true), attr); | 1249 | QFileInfo f1(f.dir(true), attr); |
1138 | QPixmap pm; | 1250 | QPixmap pm; |
1139 | if (pm.load(f1.absFilePath())) | 1251 | if (pm.load(f1.absFilePath())) |
1140 | { | 1252 | { |
1141 | QImage* img = new QImage(pm.convertToImage()); | 1253 | QImage* img = new QImage(pm.convertToImage()); |
1142 | currentstyle.setPicture(true, img); | 1254 | currentstyle.setPicture(true, img); |
1143 | } | 1255 | } |
1144 | } | 1256 | } |
1145 | } | 1257 | } |
1146 | if (ent == "recindex") | 1258 | if (ent == "recindex") |
1147 | { | 1259 | { |
1148 | bool ok; | 1260 | bool ok; |
1149 | unsigned int picindex = attr.toUInt(&ok); | 1261 | unsigned int picindex = attr.toUInt(&ok); |
1150 | qDebug("Looking for image at %u", picindex); | 1262 | qDebug("Looking for image at %u", picindex); |
1151 | QImage* img = parent->getPicture(picindex); | 1263 | QImage* img = parent->getPicture(picindex); |
1152 | if (img != NULL) | 1264 | if (img != NULL) |
1153 | { | 1265 | { |
1154 | currentstyle.setPicture(true, img); | 1266 | currentstyle.setPicture(true, img); |
1155 | } | 1267 | } |
1156 | else | 1268 | else |
1157 | { | 1269 | { |
1158 | qDebug("No image found"); | 1270 | qDebug("No image found"); |
1159 | } | 1271 | } |
1160 | } | 1272 | } |
1161 | } | 1273 | } |
1162 | if (ch != '>') ch = skip_ws_end(); | 1274 | if (ch != '>') ch = skip_ws_end(); |
1163 | ch = '#'; | 1275 | ch = '#'; |
1164 | break; | 1276 | break; |
1165 | } | 1277 | } |
1166 | else if (ent.left(2) == "dc") | 1278 | else if (ent.left(2) == "dc") |
1167 | { | 1279 | { |
1168 | QString nd("/"); | 1280 | QString nd("/"); |
1169 | skipblock(nd+ent); | 1281 | skipblock(nd+ent); |
1170 | } | 1282 | } |
1171 | else if (ent == "metadata") | 1283 | else if (ent == "metadata") |
1172 | { | 1284 | { |
1173 | // skipblock("/metadata"); | 1285 | // skipblock("/metadata"); |
1174 | } | 1286 | } |
1287 | else if (ent == "title") | ||
1288 | { | ||
1289 | skipblock("/title"); | ||
1290 | } | ||
1291 | else if (ent == "head") | ||
1292 | { | ||
1293 | skipblock("/head"); | ||
1294 | } | ||
1175 | /* | 1295 | /* |
1176 | else if (ent == "metadata") | 1296 | else if (ent == "metadata") |
1177 | { | 1297 | { |
1178 | currentstyle.setFontSize(-2); | 1298 | currentstyle.setFontSize(-2); |
1179 | } | 1299 | } |
1180 | else if (ent == "/metadata") | 1300 | else if (ent == "/metadata") |
1181 | { | 1301 | { |
1182 | currentstyle.unset(); | 1302 | currentstyle.unset(); |
1183 | ch = 10; | 1303 | ch = 10; |
1184 | continue; | 1304 | continue; |
1185 | } | 1305 | } |
1186 | */ | 1306 | */ |
1187 | else | 1307 | else |
1188 | { | 1308 | { |
1189 | if (ent[0] != '/') | 1309 | if (ent[0] != '/') |
1190 | qDebug("Not handling:%s", (const char*)ent); | 1310 | qDebug("Not handling:%s", (const char*)ent); |
1191 | } | 1311 | } |
1192 | 1312 | ||
1193 | if (ch != '>') ch = skip_ws_end(); | 1313 | if (ch != '>') ch = skip_ws_end(); |
1194 | mygetch(ch, dummy, npos); | 1314 | if (ent[0] == '/') |
1315 | mygetch(ch, dummy, pos); | ||
1316 | else | ||
1317 | mygetch(ch, dummy, npos); | ||
1195 | } | 1318 | } |
1196 | if (ch == '&') | 1319 | if (ch == '&') |
1197 | { | 1320 | { |
1198 | mygetch(ch, dummy, npos); | 1321 | mygetch(ch, dummy, npos); |
1199 | if (ch == '#') | 1322 | if (ch == '#') |
1200 | { | 1323 | { |
1201 | int id = 0; | 1324 | int id = 0; |
1202 | mygetch(ch, dummy, npos); | 1325 | mygetch(ch, dummy, npos); |
1203 | while (ch != ';' && ch != UEOF) | 1326 | while (ch != ';' && ch != UEOF) |
1204 | { | 1327 | { |
1205 | id = 10*id+ch-'0'; | 1328 | id = 10*id+ch-'0'; |
1206 | mygetch(ch, dummy, npos); | 1329 | mygetch(ch, dummy, npos); |
1207 | } | 1330 | } |
1208 | ch = id; | 1331 | ch = id; |
1209 | } | 1332 | } |
1210 | else | 1333 | else |
1211 | { | 1334 | { |
1212 | QString en; | 1335 | QString en; |
1213 | en += ch; | 1336 | en += ch; |
1214 | mygetch(ch, dummy, npos); | 1337 | mygetch(ch, dummy, npos); |
1215 | while (ch != ';' && ch != UEOF) | 1338 | while (ch != ';' && ch != UEOF) |
1216 | { | 1339 | { |
1217 | en += ch; | 1340 | en += ch; |
1218 | mygetch(ch, dummy, npos); | 1341 | mygetch(ch, dummy, npos); |
1219 | } | 1342 | } |
1220 | if (entmap == NULL) initentmap(); | 1343 | if (entmap == NULL) initentmap(); |
1221 | #if defined(USEQPE) || defined(_WINDOWS) | 1344 | #if defined(USEQPE) || defined(_WINDOWS) |
1222 | QMap<QString, tchar>::Iterator it = entmap->find(en); | 1345 | QMap<QString, tchar>::Iterator it = entmap->find(en); |
1223 | #else | 1346 | #else |
1224 | QMap<QString, tchar>::iterator it = entmap->find(en); | 1347 | QMap<QString, tchar>::iterator it = entmap->find(en); |
1225 | #endif | 1348 | #endif |
1226 | if (it != entmap->end()) | 1349 | if (it != entmap->end()) |
1227 | { | 1350 | { |
1228 | ch = *it; | 1351 | ch = *it; |
1229 | } | 1352 | } |
1230 | else | 1353 | else |
1231 | { | 1354 | { |
1232 | ch = '.'; | 1355 | ch = '.'; |
1233 | } | 1356 | } |
1234 | } | 1357 | } |
1235 | } | 1358 | } |
1236 | // sty = (dummy == ucFontBase) ? currentstyle : dummy; | 1359 | // sty = (dummy == ucFontBase) ? currentstyle : dummy; |
1360 | if (lastch == 10 && ch == 10 && sty.getExtraSpace() > currentstyle.getExtraSpace()) | ||
1361 | { | ||
1362 | currentstyle.setExtraSpace(sty.getExtraSpace()); | ||
1363 | } | ||
1237 | sty = currentstyle; | 1364 | sty = currentstyle; |
1238 | } | 1365 | } |
1239 | while (!isPre && (lastch == ' ' || lastch == 10 || ignorespace) && ch == ' '); | 1366 | while (!isPre && (((lastch == ' ' || lastch == 10 || ignorespace) && ch == ' ') || ((ch == 10) && (lastch == 10)))); |
1240 | // lastch = ch; | 1367 | // lastch = ch; |
1241 | lastch = ch; | 1368 | lastch = ch; |
1242 | return; | 1369 | return; |
1243 | } | 1370 | } |
1244 | 1371 | ||
1372 | QString striphtml::getTableAsHtml(unsigned long loc) | ||
1373 | { | ||
1374 | qDebug("striphtml::getTableAsHtml"); | ||
1375 | QString ret; | ||
1376 | tchar ch(0); | ||
1377 | CStyle sty; | ||
1378 | unsigned long pos; | ||
1379 | locate(loc); | ||
1380 | int endpos(0); | ||
1381 | QString endmarker("</table>"); | ||
1382 | QString startmarker("<table"); | ||
1383 | int startpos(0); | ||
1384 | int depth(0); | ||
1385 | while (ch != UEOF) | ||
1386 | { | ||
1387 | parent->getch(ch, sty, pos); | ||
1388 | QChar qc(ch); | ||
1389 | ret += qc; | ||
1390 | if (qc.lower() == endmarker[endpos]) | ||
1391 | { | ||
1392 | if ((++endpos >= endmarker.length()) && (--depth <= 0)) break; | ||
1393 | } | ||
1394 | else | ||
1395 | { | ||
1396 | endpos = 0; | ||
1397 | } | ||
1398 | if (qc.lower() == startmarker[startpos]) | ||
1399 | { | ||
1400 | if (++startpos >= startmarker.length()) ++depth; | ||
1401 | } | ||
1402 | else | ||
1403 | { | ||
1404 | startpos = 0; | ||
1405 | } | ||
1406 | } | ||
1407 | return ret; | ||
1408 | } | ||
1409 | |||
1410 | |||
1245 | extern "C" | 1411 | extern "C" |
1246 | { | 1412 | { |
1247 | CFilter* newfilter(const QString& s) { return new striphtml(s); } | 1413 | CFilter* newfilter(const QString& s) { return new striphtml(s); } |
1248 | } | 1414 | } |
diff --git a/noncore/apps/opie-reader/striphtml.h b/noncore/apps/opie-reader/striphtml.h index 42e2b7e..b1f7c0a 100644 --- a/noncore/apps/opie-reader/striphtml.h +++ b/noncore/apps/opie-reader/striphtml.h | |||
@@ -1,93 +1,96 @@ | |||
1 | #ifndef __STRIPHTML_H | 1 | #ifndef __STRIPHTML_H |
2 | #define __STRIPHTML_H | 2 | #define __STRIPHTML_H |
3 | 3 | ||
4 | #include "CFilter.h" | 4 | #include "CFilter.h" |
5 | #include "Navigation.h" | 5 | #include "Navigation.h" |
6 | #include "CBuffer.h" | 6 | #include "CBuffer.h" |
7 | #include "CExpander.h" | 7 | #include "CExpander.h" |
8 | #include "my_list.h" | 8 | #include "my_list.h" |
9 | 9 | ||
10 | class striphtml : public CFilter | 10 | class striphtml : public CFilter |
11 | { | 11 | { |
12 | void reset(); | ||
12 | bool ignorespace; | 13 | bool ignorespace; |
13 | bool m_bchm; | 14 | bool m_bchm; |
15 | int tablenesteddepth; | ||
14 | CList<CStyle> stylestack; | 16 | CList<CStyle> stylestack; |
15 | static CNavigation_base<htmlmark> m_nav; | 17 | static CNavigation_base<htmlmark> m_nav; |
16 | QMap<QString, tchar>* entmap; | 18 | QMap<QString, tchar>* entmap; |
17 | CStyle currentstyle; | 19 | CStyle currentstyle; |
18 | bool isPre; | 20 | bool isPre; |
19 | unsigned short skip_ws(); | 21 | unsigned short skip_ws(); |
20 | unsigned short skip_ws_end(); | 22 | unsigned short skip_ws_end(); |
21 | unsigned short skip_ws_end(unsigned long&); | 23 | unsigned short skip_ws_end(unsigned long&); |
22 | unsigned short parse_m(); | 24 | unsigned short parse_m(); |
23 | QMap<QString, unsigned long>* href2filepos; | 25 | QMap<QString, unsigned long>* href2filepos; |
24 | QMap<unsigned long, QString>* id2href; | 26 | QMap<unsigned long, QString>* id2href; |
25 | unsigned long currentid; | 27 | unsigned long currentid; |
26 | tchar lastch; | 28 | tchar lastch; |
27 | QString currentfile; | 29 | QString currentfile; |
28 | QString q; | 30 | QString q; |
29 | bool forcecentre, m_inblock; | 31 | bool forcecentre, m_inblock; |
30 | QString text_q; | 32 | QString text_q; |
31 | int indent; | 33 | int indent; |
32 | int m_listtype[m_cmaxdepth]; | 34 | int m_listtype[m_cmaxdepth]; |
33 | int m_ctr[m_cmaxdepth]; | 35 | int m_ctr[m_cmaxdepth]; |
34 | void mygetch(tchar& ch, CStyle& sty, unsigned long& pos); | 36 | void mygetch(tchar& ch, CStyle& sty, unsigned long& pos); |
35 | void initentmap(); | 37 | void initentmap(); |
36 | QString getname(tchar& ch, const QString& nd); | 38 | QString getname(tchar& ch, const QString& nd); |
37 | void skipblock(const QString&); | 39 | void skipblock(const QString&); |
38 | QString getattr(tchar&); | 40 | QString getattr(tchar&); |
39 | QString dehtml(const QString& _info); | 41 | QString dehtml(const QString& _info); |
40 | void parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long); | 42 | void parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long); |
41 | int getpara(CBuffer&, unsigned long&); | 43 | int getpara(CBuffer&, unsigned long&); |
42 | public: | 44 | public: |
43 | QString about() { return QString("HTML filter (c) Tim Wentford\n")+parent->about(); } | 45 | QString about() { return QString("HTML filter (c) Tim Wentford\n")+parent->about(); } |
44 | striphtml(const QString&); | 46 | striphtml(const QString&); |
45 | ~striphtml(); | 47 | ~striphtml(); |
46 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 48 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
47 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm); | 49 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm); |
48 | bool findanchor(const QString&); | 50 | bool findanchor(const QString&); |
49 | 51 | ||
50 | 52 | ||
51 | void saveposn(const QString& f, size_t posn) { m_nav.saveposn(htmlmark(f, posn)); } | 53 | void saveposn(const QString& f, size_t posn) { m_nav.saveposn(htmlmark(f, posn)); } |
52 | void writeposn(const QString& f, size_t posn) { m_nav.writeposn(htmlmark(f, posn)); } | 54 | void writeposn(const QString& f, size_t posn) { m_nav.writeposn(htmlmark(f, posn)); } |
53 | linkType forward(QString& f, size_t& loc) | 55 | linkType forward(QString& f, size_t& loc) |
54 | { | 56 | { |
55 | htmlmark m(f, loc); | 57 | htmlmark m(f, loc); |
56 | linkType ret = (m_nav.forward(m)) ? eFile : eNone; | 58 | linkType ret = (m_nav.forward(m)) ? eFile : eNone; |
57 | if (f == m.filename()) | 59 | if (f == m.filename()) |
58 | { | 60 | { |
59 | if (ret == eFile) | 61 | if (ret == eFile) |
60 | { | 62 | { |
61 | ret = eLink; | 63 | ret = eLink; |
62 | } | 64 | } |
63 | } | 65 | } |
64 | else | 66 | else |
65 | { | 67 | { |
66 | f = m.filename(); | 68 | f = m.filename(); |
67 | } | 69 | } |
68 | loc = m.posn(); | 70 | loc = m.posn(); |
69 | return ret; | 71 | return ret; |
70 | } | 72 | } |
71 | linkType back(QString& f, size_t& loc) | 73 | linkType back(QString& f, size_t& loc) |
72 | { | 74 | { |
73 | htmlmark m(f, loc); | 75 | htmlmark m(f, loc); |
74 | linkType ret = (m_nav.back(m)) ? eFile : eNone; | 76 | linkType ret = (m_nav.back(m)) ? eFile : eNone; |
75 | if (f == m.filename()) | 77 | if (f == m.filename()) |
76 | { | 78 | { |
77 | if (ret == eFile) | 79 | if (ret == eFile) |
78 | { | 80 | { |
79 | ret = eLink; | 81 | ret = eLink; |
80 | } | 82 | } |
81 | } | 83 | } |
82 | else | 84 | else |
83 | { | 85 | { |
84 | f = m.filename(); | 86 | f = m.filename(); |
85 | } | 87 | } |
86 | loc = m.posn(); | 88 | loc = m.posn(); |
87 | return ret; | 89 | return ret; |
88 | } | 90 | } |
89 | bool hasnavigation() { return true; } | 91 | bool hasnavigation() { return true; } |
90 | virtual void locate(unsigned int n); | 92 | virtual void locate(unsigned int n); |
91 | void setchm(bool _b) { m_bchm = _b; } | 93 | void setchm(bool _b) { m_bchm = _b; } |
94 | QString getTableAsHtml(unsigned long loc); | ||
92 | }; | 95 | }; |
93 | #endif | 96 | #endif |
diff --git a/noncore/apps/opie-reader/update-gcc3.sh b/noncore/apps/opie-reader/update-gcc3.sh deleted file mode 100755 index f604e42..0000000 --- a/noncore/apps/opie-reader/update-gcc3.sh +++ b/dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | touch infowin.cpp | ||
3 | for f in *lib.omak; do make -f $f; done | ||
4 | for f in *.omak; do make -f $f; done | ||
5 | for f in *.omak; do make -f $f; done | ||
6 | cp /home/tim/codecreader/opie-reader.desktop $QTDIR/apps/Applications/ | ||
7 | cp /home/tim/codecreader/pics/* $QTDIR/pics/opie-reader/ | ||
8 | cp /home/tim/codecreader/opie-pics/* $QTDIR/pics/opie-reader/ | ||
9 | cp HTMLentities $QTDIR/plugins/reader/data/ | ||
10 | rm $QTDIR/help/html/*reader*.html | ||
11 | cp /home/tim/codecreader/help/*.html $QTDIR/help/html/ | ||
12 | rm $QTDIR/help/html/*reader*.html | ||
13 | cp /home/tim/codecreader/help/*.html $QTDIR/help/html/ | ||
14 | rm -f $QTDIR/lib/libreader*.so | ||
15 | rm -f $QTDIR/lib/libreader*.so.1 | ||
16 | for f in $QTDIR/lib/libreader*.1.0.0 ; do mv -f $f $QTDIR/lib/`basename $f .1.0.0`.1 ; done | ||
17 | rm -f $QTDIR/lib/libreader*.so.1.* | ||
18 | |||
19 | /home/tim/bin/zstrip.sh $QTDIR/bin/reader | ||
20 | for f in $QTDIR/lib/libreader* ; do /home/tim/bin/zstrip.sh $f; done | ||
21 | |||
22 | for SUBDIR in codecs support filters | ||
23 | do | ||
24 | CDIR=$QTDIR/plugins/reader/$SUBDIR | ||
25 | rm -f $CDIR/*.so | ||
26 | for f in $CDIR/*.1.0.0 ; do mv -f $f $CDIR/`basename $f .1.0.0` ; done | ||
27 | rm -f $CDIR/*.so.* | ||
28 | for f in $CDIR/*.so ; do /home/tim/bin/zstrip.sh $f ; done | ||
29 | done | ||
30 | rm -f opie-reader-gcc3_*.ipk | ||
31 | rm -f full/opie-reader-gcc3_*.ipk | ||
32 | rm -f partial/opie-reader-gcc3_*.ipk | ||
33 | mkipks opie-reader-gcc3.control | ||
34 | cp opie-reader-gcc3_*.ipk full/ | ||
35 | for f in opie-reader-gcc3_*.ipk | ||
36 | do | ||
37 | cp $f full/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk | ||
38 | done | ||
39 | rm $QTDIR/plugins/reader/support/libpluckerdecompress.so | ||
40 | rm $QTDIR/plugins/reader/codecs/libArriereGo.so | ||
41 | rm $QTDIR/plugins/reader/codecs/libNEF.so | ||
42 | mkipks opie-reader-gcc3.control | ||
43 | cp opie-reader-gcc3_*.ipk partial/ | ||
44 | for f in opie-reader-gcc3_*.ipk | ||
45 | do | ||
46 | cp $f partial/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk | ||
47 | done | ||
diff --git a/noncore/apps/opie-reader/update-opie.sh b/noncore/apps/opie-reader/update-opie.sh deleted file mode 100755 index 261ef46..0000000 --- a/noncore/apps/opie-reader/update-opie.sh +++ b/dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | touch infowin.cpp | ||
3 | for f in *lib.zmak; do make -f $f; done | ||
4 | for f in *.zmak; do make -f $f; done | ||
5 | for f in *.zmak; do make -f $f; done | ||
6 | cp /home/tim/codecreader/pics/* $QTDIR/pics/opie-reader/ | ||
7 | cp /home/tim/codecreader/opie-pics/* $QTDIR/pics/opie-reader/ | ||
8 | cp HTMLentities $QTDIR/plugins/reader/data/ | ||
9 | rm $QTDIR/help/html/*reader*.html | ||
10 | cp /home/tim/codecreader/help/*.html $QTDIR/help/html/ | ||
11 | rm -f $QTDIR/lib/libreader*.so | ||
12 | rm -f $QTDIR/lib/libreader*.so.1 | ||
13 | for f in $QTDIR/lib/libreader*.1.0.0 ; do mv -f $f $QTDIR/lib/`basename $f .1.0.0`.1 ; done | ||
14 | rm -f $QTDIR/lib/libreader*.so.1.* | ||
15 | |||
16 | /home/tim/bin/zstrip.sh $QTDIR/bin/uqtreader | ||
17 | rm -f $QTDIR/bin/reader | ||
18 | mv $QTDIR/bin/uqtreader $QTDIR/bin/reader | ||
19 | for f in $QTDIR/lib/libreader* ; do /home/tim/bin/zstrip.sh $f; done | ||
20 | for SUBDIR in codecs support filters | ||
21 | do | ||
22 | CDIR=$QTDIR/plugins/reader/$SUBDIR | ||
23 | rm -f $CDIR/*.so | ||
24 | for f in $CDIR/*.1.0.0 ; do mv -f $f $CDIR/`basename $f .1.0.0` ; done | ||
25 | rm -f $CDIR/*.so.* | ||
26 | for f in $CDIR/*.so ; do zstrip.sh $f ; done | ||
27 | done | ||
28 | rm -f opie-reader-opie_*.ipk | ||
29 | rm -f full/opie-reader-opie_*.ipk | ||
30 | rm -f partial/opie-reader-opie_*.ipk | ||
31 | mkipks opie-reader-opie.control | ||
32 | cp opie-reader-opie_*.ipk full/ | ||
33 | for f in opie-reader-opie_*.ipk | ||
34 | do | ||
35 | cp $f full/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk | ||
36 | done | ||
37 | rm $QTDIR/plugins/reader/support/libpluckerdecompress.so | ||
38 | rm $QTDIR/plugins/reader/codecs/libArriereGo.so | ||
39 | rm $QTDIR/plugins/reader/codecs/libNEF.so | ||
40 | mkipks opie-reader-opie.control | ||
41 | cp opie-reader-opie_*.ipk partial/ | ||
42 | for f in opie-reader-opie_*.ipk | ||
43 | do | ||
44 | cp $f partial/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk | ||
45 | done | ||
diff --git a/noncore/apps/opie-reader/update.sh b/noncore/apps/opie-reader/update.sh deleted file mode 100755 index 61b8a5e..0000000 --- a/noncore/apps/opie-reader/update.sh +++ b/dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | touch infowin.cpp | ||
3 | for f in *lib.zmak; do make -f $f; done | ||
4 | for f in *.zmak; do make -f $f; done | ||
5 | for f in *.zmak; do make -f $f; done | ||
6 | cp /home/tim/codecreader/uqtreader*.desktop /opt/Qtopia/apps/Applications/ | ||
7 | cp /home/tim/codecreader/pics/* /opt/Qtopia/pics/opie-reader/ | ||
8 | cp /home/tim/codecreader/uqtreader*.desktop $QTDIR/apps/Applications/ | ||
9 | cp /home/tim/codecreader/opie-reader.desktop $QTDIR/apps/Applications/ | ||
10 | cp /home/tim/codecreader/pics/* $QTDIR/pics/opie-reader/ | ||
11 | cp HTMLentities $QTDIR/plugins/reader/data/ | ||
12 | rm $QTDIR/help/html/*reader*.html | ||
13 | cp /home/tim/codecreader/help/*.html $QTDIR/help/html/ | ||
14 | rm -f $QTDIR/lib/libreader*.so | ||
15 | rm -f $QTDIR/lib/libreader*.so.1 | ||
16 | for f in $QTDIR/lib/libreader*.1.0.0 ; do mv -f $f $QTDIR/lib/`basename $f .1.0.0`.1 ; done | ||
17 | rm -f $QTDIR/lib/libreader*.so.1.* | ||
18 | |||
19 | /home/tim/bin/zstrip.sh $QTDIR/bin/uqtreader | ||
20 | for f in $QTDIR/lib/libreader* ; do /home/tim/bin/zstrip.sh $f; done | ||
21 | |||
22 | for SUBDIR in codecs support filters | ||
23 | do | ||
24 | CDIR=$QTDIR/plugins/reader/$SUBDIR | ||
25 | rm -f $CDIR/*.so | ||
26 | for f in $CDIR/*.1.0.0 ; do mv -f $f $CDIR/`basename $f .1.0.0` ; done | ||
27 | rm -f $CDIR/*.so.* | ||
28 | for f in $CDIR/*.so ; do /home/tim/bin/zstrip.sh $f ; done | ||
29 | done | ||
30 | rm -f opie-reader_*.ipk | ||
31 | rm -f full/opie-reader_*.ipk | ||
32 | rm -f partial/opie-reader_*.ipk | ||
33 | mkipks opie-reader.control | ||
34 | cp opie-reader_*.ipk full/ | ||
35 | for f in opie-reader_*.ipk | ||
36 | do | ||
37 | cp $f full/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk | ||
38 | done | ||
39 | rm $QTDIR/plugins/reader/support/libpluckerdecompress.so | ||
40 | rm $QTDIR/plugins/reader/codecs/libArriereGo.so | ||
41 | rm $QTDIR/plugins/reader/codecs/libNEF.so | ||
42 | mkipks opie-reader.control | ||
43 | cp opie-reader_*.ipk partial/ | ||
44 | for f in opie-reader_*.ipk | ||
45 | do | ||
46 | cp $f partial/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk | ||
47 | done | ||
diff --git a/noncore/apps/opie-reader/usenef.h b/noncore/apps/opie-reader/usenef.h deleted file mode 100644 index 57898cb..0000000 --- a/noncore/apps/opie-reader/usenef.h +++ b/dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | #ifndef __USENEF_H | ||
2 | #define __USENEF_H | ||
3 | |||
4 | //#define USENEF | ||
5 | |||
6 | #endif | ||
diff --git a/noncore/apps/opie-reader/util.cpp b/noncore/apps/opie-reader/util.cpp index a736f8b..2ca1cc8 100644 --- a/noncore/apps/opie-reader/util.cpp +++ b/noncore/apps/opie-reader/util.cpp | |||
@@ -1,36 +1,45 @@ | |||
1 | #include "util.h" | 1 | #include "util.h" |
2 | #include <limits.h> | ||
2 | 3 | ||
3 | QString filesize(unsigned long l) | 4 | QString filesize(unsigned long l) |
4 | { | 5 | { |
5 | char units[] = { 'K', 'M', 'G' }; | 6 | char units[] = { 'K', 'M', 'G' }; |
6 | int iu = 0; | 7 | int iu = 0; |
7 | while (l > 999 && iu < sizeof(units)) | 8 | while (l > 999 && iu < sizeof(units)) |
8 | { | 9 | { |
9 | l = (l+512)/1024; | 10 | l = (l+512)/1024; |
10 | iu++; | 11 | iu++; |
11 | } | 12 | } |
12 | QString ret = QString::number(l); | 13 | QString ret = QString::number(l); |
13 | if (iu != 0) | 14 | if (iu != 0) |
14 | { | 15 | { |
15 | ret += QChar(units[iu-1]); | 16 | ret += QChar(units[iu-1]); |
16 | } | 17 | } |
17 | return ret; | 18 | return ret; |
18 | } | 19 | } |
19 | 20 | ||
20 | QString percent(unsigned long pos, unsigned long len) | 21 | QString percent(unsigned long pos, unsigned long len) |
21 | { | 22 | { |
22 | unsigned long permil = 0; | 23 | unsigned long permil = 0; |
23 | if (len != 0) | 24 | if (len != 0) |
24 | { | 25 | { |
25 | permil = (1000*pos+len/2)/len; | 26 | if (pos > UINT_MAX/1000) |
27 | { | ||
28 | unsigned long l1 = (len+500)/1000; | ||
29 | permil = (pos+l1/2)/l1; | ||
30 | } | ||
31 | else | ||
32 | { | ||
33 | permil = (1000*pos+len/2)/len; | ||
34 | } | ||
26 | } | 35 | } |
27 | unsigned long percen = permil/10; | 36 | unsigned long percen = permil/10; |
28 | unsigned long frac = permil - 10*percen; | 37 | unsigned long frac = permil - 10*percen; |
29 | return QString::number(percen) + "." + QString::number(frac); | 38 | return QString::number(percen) + "." + QString::number(frac); |
30 | } | 39 | } |
31 | 40 | ||
32 | QString fmt(unsigned long pos, unsigned long len) | 41 | QString fmt(unsigned long pos, unsigned long len) |
33 | { | 42 | { |
34 | QString ret = filesize(pos) + "/" + filesize(len) + " : " + percent(pos,len) +"%"; | 43 | QString ret = filesize(pos) + "/" + filesize(len) + " : " + percent(pos,len) +"%"; |
35 | return ret; | 44 | return ret; |
36 | } | 45 | } |
diff --git a/noncore/apps/opie-reader/util.h b/noncore/apps/opie-reader/util.h index f831ead..3964b5e 100644 --- a/noncore/apps/opie-reader/util.h +++ b/noncore/apps/opie-reader/util.h | |||
@@ -1,57 +1,9 @@ | |||
1 | #ifndef __UTIL_H | 1 | #ifndef __UTIL_H |
2 | #define __UTIL_H | 2 | #define __UTIL_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qdir.h> | ||
6 | #include <stdlib.h> | ||
7 | 5 | ||
8 | QString filesize(unsigned long l); | 6 | QString filesize(unsigned long l); |
9 | QString percent(unsigned long pos, unsigned long len); | 7 | QString percent(unsigned long pos, unsigned long len); |
10 | QString fmt(unsigned long pos, unsigned long len); | 8 | QString fmt(unsigned long pos, unsigned long len); |
11 | |||
12 | /** | ||
13 | * class with utility inline function(s) | ||
14 | * (in contrast to global functions they become available by just | ||
15 | * including util.h) | ||
16 | */ | ||
17 | class QTReaderUtil | ||
18 | { | ||
19 | public: | ||
20 | |||
21 | /** | ||
22 | * searches for a specific direcory inside OpieReader installation | ||
23 | * | ||
24 | * @param subdir name of sub directory inside installation directory which is needed | ||
25 | * @return full path name including that sub directory | ||
26 | * | ||
27 | * search order is (on all platforms): | ||
28 | * - OPIEDIR | ||
29 | * - QTDIR | ||
30 | * - READERDIR | ||
31 | */ | ||
32 | static QString getPluginPath( const char *subdir = "codecs/" ) | ||
33 | { | ||
34 | QString dirname; | ||
35 | dirname = getenv("OPIEDIR"); | ||
36 | dirname += "/plugins/reader/"; | ||
37 | dirname += subdir; | ||
38 | if (QDir(dirname).exists()) | ||
39 | return dirname; | ||
40 | |||
41 | dirname = getenv("QTDIR"); | ||
42 | dirname += "/plugins/reader/"; | ||
43 | dirname += subdir; | ||
44 | if (QDir(dirname).exists()) | ||
45 | return dirname; | ||
46 | |||
47 | dirname = getenv("READERDIR"); | ||
48 | dirname += "/"; | ||
49 | dirname += subdir; | ||
50 | if (QDir(dirname).exists()) | ||
51 | return dirname; | ||
52 | |||
53 | return ""; | ||
54 | } | ||
55 | }; | ||
56 | |||
57 | #endif | 9 | #endif |
diff --git a/noncore/apps/opie-reader/version.cpp b/noncore/apps/opie-reader/version.cpp index 9d92abe..aafb3d8 100644 --- a/noncore/apps/opie-reader/version.cpp +++ b/noncore/apps/opie-reader/version.cpp | |||
@@ -1,29 +1,62 @@ | |||
1 | #include "version.h" | 1 | #include "version.h" |
2 | #include "names.h" | 2 | #include "names.h" |
3 | #include <qmessagebox.h> | 3 | #include <qmessagebox.h> |
4 | 4 | ||
5 | bool CheckVersion(int& major, int& bkmktype, char& minor) | 5 | #include <qmultilineedit.h> |
6 | #include <qlayout.h> | ||
7 | #include <qtextview.h> | ||
8 | class versionbox : public QDialog | ||
9 | { | ||
10 | public: | ||
11 | versionbox(const QString& txt, QWidget* parent = NULL) : QDialog(parent, NULL, true) | ||
12 | { | ||
13 | setCaption(tr( "New Features" )); | ||
14 | QVBoxLayout* v = new QVBoxLayout(this); | ||
15 | /* | ||
16 | QMultiLineEdit* box = new QMultiLineEdit(this); | ||
17 | v->addWidget(box); | ||
18 | box->setReadOnly(true); | ||
19 | box->setWordWrap(QMultiLineEdit::WidgetWidth); | ||
20 | box->setText(txt); | ||
21 | */ | ||
22 | QTextView* box = new QTextView(this); | ||
23 | v->addWidget(box); | ||
24 | box->setText(txt); | ||
25 | #ifdef USEQPE | ||
26 | showMaximized(); | ||
27 | #endif | ||
28 | } | ||
29 | }; | ||
30 | |||
31 | bool CheckVersion(int& major, int& bkmktype, char& minor, QWidget* pnt) | ||
6 | { | 32 | { |
7 | if ( | 33 | if ( |
8 | (major != MAJOR) | 34 | (major != MAJOR) |
9 | || | 35 | || |
10 | (bkmktype != BKMKTYPE) | 36 | (bkmktype != BKMKTYPE) |
11 | || | 37 | || |
12 | (minor != MINOR) | 38 | (minor != MINOR) |
13 | ) | 39 | ) |
14 | { | 40 | { |
15 | major = MAJOR; | 41 | major = MAJOR; |
16 | bkmktype = BKMKTYPE; | 42 | bkmktype = BKMKTYPE; |
17 | minor = MINOR; | 43 | minor = MINOR; |
18 | 44 | versionbox v( | |
19 | QMessageBox::warning(NULL, PROGNAME, | 45 | "<h2>New Features</h2>" |
20 | "New Features in this version\n\n\n" | 46 | "<h3>Support for custom version of rbmake</h3>" |
21 | "Relative margin settings\n" | 47 | "<h3>Mini scrollbar now acts more like a QT scrollbar.</h3>" |
22 | "Cyrillic hyphenation"); | 48 | "<p>The handle can be dragged to jump to a \"random\" location and tapping to either side of the handle does page up/down</p>" |
49 | "<p>Line up/down is done by tapping in the margins to either end of the scroll bar (left/right margins for a horizontal scrollbar, top/bottom for a vertical scrollbar).</p>" | ||
50 | "<p>The toolbar now stays hidden if you hide it.</p>" | ||
51 | "<p>Better support for tables. Tapping on a table brings up a table viewer. The inline display of the linearised table can be toggled using the Inline Table option" | ||
52 | , | ||
53 | pnt | ||
54 | ); | ||
55 | v.exec(); | ||
23 | return true; | 56 | return true; |
24 | } | 57 | } |
25 | else | 58 | else |
26 | { | 59 | { |
27 | return false; | 60 | return false; |
28 | } | 61 | } |
29 | } | 62 | } |
diff --git a/noncore/apps/opie-reader/version.h b/noncore/apps/opie-reader/version.h index dcf0692..486d152 100644 --- a/noncore/apps/opie-reader/version.h +++ b/noncore/apps/opie-reader/version.h | |||
@@ -1,9 +1,9 @@ | |||
1 | #ifndef __VERSION_H | 1 | #ifndef __VERSION_H |
2 | #define __VERSION_H | 2 | #define __VERSION_H |
3 | 3 | ||
4 | #define MAJOR 0 | 4 | #define MAJOR 0 |
5 | #define BKMKTYPE 7 | 5 | #define BKMKTYPE 7 |
6 | #define MINOR 'g' | 6 | #define MINOR 'i' |
7 | #define RELEASE_TYPE "beta" | 7 | #define RELEASE_TYPE "beta" |
8 | 8 | ||
9 | #endif | 9 | #endif |
diff --git a/noncore/apps/opie-reader/ztxt.cpp b/noncore/apps/opie-reader/ztxt.cpp index 35db05e..e04eaa0 100644 --- a/noncore/apps/opie-reader/ztxt.cpp +++ b/noncore/apps/opie-reader/ztxt.cpp | |||
@@ -1,173 +1,176 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <string.h> | 2 | #include <string.h> |
3 | #include "ztxt.h" | 3 | #include "ztxt.h" |
4 | #include "my_list.h" | 4 | #include "my_list.h" |
5 | #include "Bkmks.h" | 5 | #include "Bkmks.h" |
6 | 6 | ||
7 | ztxt::ztxt() : bInit(false), expandedtextbuffer(NULL), compressedtextbuffer(NULL) { /*printf("constructing:%x\n",fin);*/ } | 7 | ztxt::ztxt() : bInit(false), expandedtextbuffer(NULL), compressedtextbuffer(NULL) { /*printf("constructing:%x\n",fin);*/ } |
8 | 8 | ||
9 | 9 | ||
10 | int ztxt::OpenFile(const char *src) | 10 | int ztxt::OpenFile(const char *src) |
11 | { | 11 | { |
12 | if (!Cpdb::openpdbfile(src)) | 12 | if (!Cpdb::openpdbfile(src)) |
13 | { | 13 | { |
14 | return -1; | 14 | return -1; |
15 | } | 15 | } |
16 | 16 | ||
17 | //printf("Okay %u\n", 4); | 17 | //printf("Okay %u\n", 4); |
18 | 18 | ||
19 | if (head.type != ZTXT_ID) return -1; | 19 | if (head.type != ZTXT_ID) return -1; |
20 | 20 | ||
21 | gotorecordnumber(0); | 21 | gotorecordnumber(0); |
22 | fread(&hdr0, 1, sizeof(hdr0), fin); | 22 | fread(&hdr0, 1, sizeof(hdr0), fin); |
23 | //printf("Okay %u\n", 5); | 23 | //printf("Okay %u\n", 5); |
24 | buffersize = ntohl(hdr0.size); | 24 | buffersize = ntohl(hdr0.size); |
25 | compressedtextbuffer = new UInt8[buffersize]; | 25 | compressedtextbuffer = new UInt8[buffersize]; |
26 | expandedtextbuffer = new UInt8[buffersize]; | 26 | expandedtextbuffer = new UInt8[buffersize]; |
27 | //printf("Okay %u\n", 6); | 27 | //printf("Okay %u\n", 6); |
28 | 28 | ||
29 | home(); | 29 | home(); |
30 | //printf("Okay %u\n", 7); | 30 | //printf("Okay %u\n", 7); |
31 | 31 | ||
32 | // printf("Returning 0\n"); | 32 | // printf("Returning 0\n"); |
33 | 33 | ||
34 | return 0; | 34 | return 0; |
35 | } | 35 | } |
36 | 36 | ||
37 | int ztxt::getch() | 37 | int ztxt::getch() |
38 | { | 38 | { |
39 | if (bufferpos >= buffercontent) | 39 | if (bufferpos >= buffercontent) |
40 | { | 40 | { |
41 | size_t reclen = recordlength(++bufferrec); | 41 | size_t reclen = recordlength(++bufferrec); |
42 | if (reclen == 0) return -1; | 42 | if (reclen == 0) return -1; |
43 | gotorecordnumber(bufferrec); | 43 | gotorecordnumber(bufferrec); |
44 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | 44 | fread(compressedtextbuffer, reclen, sizeof(char), fin); |
45 | 45 | ||
46 | zstream.next_in = compressedtextbuffer; | 46 | zstream.next_in = compressedtextbuffer; |
47 | zstream.next_out = expandedtextbuffer; | 47 | zstream.next_out = expandedtextbuffer; |
48 | zstream.avail_out = buffersize; | 48 | zstream.avail_out = buffersize; |
49 | zstream.avail_in = reclen; | 49 | zstream.avail_in = reclen; |
50 | 50 | ||
51 | int ret = inflate(&zstream, Z_SYNC_FLUSH); | 51 | int ret = inflate(&zstream, Z_SYNC_FLUSH); |
52 | buffercontent = buffersize - zstream.avail_out; | 52 | buffercontent = buffersize - zstream.avail_out; |
53 | bufferpos = 0; | 53 | bufferpos = 0; |
54 | 54 | ||
55 | } | 55 | } |
56 | currentpos++; | 56 | currentpos++; |
57 | return expandedtextbuffer[bufferpos++]; | 57 | return expandedtextbuffer[bufferpos++]; |
58 | } | 58 | } |
59 | 59 | ||
60 | unsigned int ztxt::locate() | 60 | unsigned int ztxt::locate() |
61 | { | 61 | { |
62 | return currentpos; | 62 | return currentpos; |
63 | } | 63 | } |
64 | 64 | ||
65 | void ztxt::locate(unsigned int n) | 65 | void ztxt::locate(unsigned int n) |
66 | { | 66 | { |
67 | 67 | ||
68 | if (hasrandomaccess()) | 68 | if (hasrandomaccess()) |
69 | { | 69 | { |
70 | unsuspend(); | ||
70 | bufferrec = n / ntohs(hdr0.recordSize) + 1; | 71 | bufferrec = n / ntohs(hdr0.recordSize) + 1; |
71 | if (bufferrec == 1) | 72 | if (bufferrec == 1) |
72 | { | 73 | { |
73 | inflateEnd(&zstream); | 74 | inflateEnd(&zstream); |
74 | } | 75 | } |
75 | size_t reclen = recordlength(bufferrec); | 76 | size_t reclen = recordlength(bufferrec); |
76 | if (reclen == 0) return; | 77 | if (reclen == 0) return; |
77 | gotorecordnumber(bufferrec); | 78 | gotorecordnumber(bufferrec); |
78 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | 79 | fread(compressedtextbuffer, reclen, sizeof(char), fin); |
79 | 80 | ||
80 | zstream.next_in = compressedtextbuffer; | 81 | zstream.next_in = compressedtextbuffer; |
81 | zstream.next_out = expandedtextbuffer; | 82 | zstream.next_out = expandedtextbuffer; |
82 | zstream.avail_out = buffersize; | 83 | zstream.avail_out = buffersize; |
83 | zstream.avail_in = reclen; | 84 | zstream.avail_in = reclen; |
84 | 85 | ||
85 | if (bufferrec == 1) | 86 | if (bufferrec == 1) |
86 | { | 87 | { |
87 | zstream.zalloc = Z_NULL; | 88 | zstream.zalloc = Z_NULL; |
88 | zstream.zfree = Z_NULL; | 89 | zstream.zfree = Z_NULL; |
89 | zstream.opaque = Z_NULL; | 90 | zstream.opaque = Z_NULL; |
90 | 91 | ||
91 | inflateInit(&zstream); | 92 | inflateInit(&zstream); |
92 | } | 93 | } |
93 | 94 | ||
94 | 95 | ||
95 | int ret = inflate(&zstream, Z_SYNC_FLUSH); | 96 | int ret = inflate(&zstream, Z_SYNC_FLUSH); |
96 | buffercontent = buffersize - zstream.avail_out; | 97 | buffercontent = buffersize - zstream.avail_out; |
97 | bufferpos = 0; | 98 | bufferpos = 0; |
98 | currentpos = n - n % ntohs(hdr0.recordSize); | 99 | currentpos = n - n % ntohs(hdr0.recordSize); |
99 | while (currentpos < n) getch(); | 100 | while (currentpos < n) getch(); |
100 | } | 101 | } |
101 | else | 102 | else |
102 | { | 103 | { |
103 | home(); | 104 | home(); |
104 | while (currentpos < n && getch() != EOF); | 105 | while (currentpos < n && getch() != EOF); |
105 | } | 106 | } |
106 | } | 107 | } |
107 | 108 | ||
108 | void ztxt::home() | 109 | void ztxt::home() |
109 | { | 110 | { |
111 | unsuspend(); | ||
110 | if (bInit) | 112 | if (bInit) |
111 | { | 113 | { |
112 | inflateEnd(&zstream); | 114 | inflateEnd(&zstream); |
113 | } | 115 | } |
114 | bInit = true; | 116 | bInit = true; |
115 | size_t reclen = recordlength(1); | 117 | size_t reclen = recordlength(1); |
116 | gotorecordnumber(1); | 118 | gotorecordnumber(1); |
117 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | 119 | fread(compressedtextbuffer, reclen, sizeof(char), fin); |
118 | 120 | ||
119 | zstream.next_in = compressedtextbuffer; | 121 | zstream.next_in = compressedtextbuffer; |
120 | zstream.next_out = expandedtextbuffer; | 122 | zstream.next_out = expandedtextbuffer; |
121 | zstream.avail_out = buffersize; | 123 | zstream.avail_out = buffersize; |
122 | zstream.avail_in = reclen; | 124 | zstream.avail_in = reclen; |
123 | 125 | ||
124 | zstream.zalloc = Z_NULL; | 126 | zstream.zalloc = Z_NULL; |
125 | zstream.zfree = Z_NULL; | 127 | zstream.zfree = Z_NULL; |
126 | zstream.opaque = Z_NULL; | 128 | zstream.opaque = Z_NULL; |
127 | 129 | ||
128 | // printf("Initialising\n"); | 130 | // printf("Initialising\n"); |
129 | 131 | ||
130 | inflateInit(&zstream); | 132 | inflateInit(&zstream); |
131 | 133 | ||
132 | int ret = inflate(&zstream, Z_SYNC_FLUSH); | 134 | int ret = inflate(&zstream, Z_SYNC_FLUSH); |
133 | // printf("Inflate : %d\n", ret); | 135 | // printf("Inflate : %d\n", ret); |
134 | bufferpos = 0; | 136 | bufferpos = 0; |
135 | bufferrec = 1; | 137 | bufferrec = 1; |
136 | currentpos = 0; | 138 | currentpos = 0; |
137 | buffercontent = buffersize - zstream.avail_out; | 139 | buffercontent = buffersize - zstream.avail_out; |
138 | //printf("buffercontent:%u\n", buffercontent); | 140 | //printf("buffercontent:%u\n", buffercontent); |
139 | } | 141 | } |
140 | 142 | ||
141 | CList<Bkmk>* ztxt::getbkmklist() | 143 | CList<Bkmk>* ztxt::getbkmklist() |
142 | { | 144 | { |
143 | UInt16 recno = ntohs(hdr0.bookmarkRecord); | 145 | UInt16 recno = ntohs(hdr0.bookmarkRecord); |
144 | 146 | ||
145 | // printf("Bookmarks - record %d contains %d\n", recno, ntohs(hdr0.numBookmarks)); | 147 | // printf("Bookmarks - record %d contains %d\n", recno, ntohs(hdr0.numBookmarks)); |
146 | 148 | ||
147 | if (recno == 0) return NULL; | 149 | if (recno == 0) return NULL; |
148 | 150 | ||
149 | CList<Bkmk>* t = new CList<Bkmk>; | 151 | CList<Bkmk>* t = new CList<Bkmk>; |
152 | unsuspend(); | ||
150 | size_t cur = ftell(fin); | 153 | size_t cur = ftell(fin); |
151 | gotorecordnumber(recno); | 154 | gotorecordnumber(recno); |
152 | for (int i = 0; i < ntohs(hdr0.numBookmarks); i++) | 155 | for (int i = 0; i < ntohs(hdr0.numBookmarks); i++) |
153 | { | 156 | { |
154 | zTXTbkmk bkmk; | 157 | zTXTbkmk bkmk; |
155 | if (fread(&bkmk, sizeof(bkmk), 1, fin) != 1) break; | 158 | if (fread(&bkmk, sizeof(bkmk), 1, fin) != 1) break; |
156 | // printf("Bookmark number:%d:%.20s\n", i, bkmk.title); | 159 | // printf("Bookmark number:%d:%.20s\n", i, bkmk.title); |
157 | tchar title[MAX_BMRK_LENGTH]; | 160 | tchar title[MAX_BMRK_LENGTH]; |
158 | for (int j = 0; j < MAX_BMRK_LENGTH; j++) | 161 | for (int j = 0; j < MAX_BMRK_LENGTH; j++) |
159 | { | 162 | { |
160 | title[j] = bkmk.title[j]; | 163 | title[j] = bkmk.title[j]; |
161 | } | 164 | } |
162 | t->push_back(Bkmk(title, NULL, ntohl(bkmk.offset))); | 165 | t->push_back(Bkmk(title, NULL, ntohl(bkmk.offset))); |
163 | } | 166 | } |
164 | fseek(fin, cur, SEEK_SET); | 167 | fseek(fin, cur, SEEK_SET); |
165 | return t; | 168 | return t; |
166 | } | 169 | } |
167 | 170 | ||
168 | #ifndef __STATIC | 171 | #ifndef __STATIC |
169 | extern "C" | 172 | extern "C" |
170 | { | 173 | { |
171 | CExpander* newcodec() { return new ztxt; } | 174 | CExpander* newcodec() { return new ztxt; } |
172 | } | 175 | } |
173 | #endif | 176 | #endif |