author | pohly <pohly> | 2004-08-26 05:57:55 (UTC) |
---|---|---|
committer | pohly <pohly> | 2004-08-26 05:57:55 (UTC) |
commit | 3f36482d9a6c096fdf5d8ab8831eb736746c0565 (patch) (unidiff) | |
tree | fb213ba05e20c9a02bca3d805f8f5c96c1c45da0 | |
parent | e00962edd9d4be58c6184e5b6c5f6ef07f449689 (diff) | |
download | opie-3f36482d9a6c096fdf5d8ab8831eb736746c0565.zip opie-3f36482d9a6c096fdf5d8ab8831eb736746c0565.tar.gz opie-3f36482d9a6c096fdf5d8ab8831eb736746c0565.tar.bz2 |
removed obsolete static.h and useqpe.h
44 files changed, 21 insertions, 61 deletions
diff --git a/noncore/apps/opie-reader/Aportis.cpp b/noncore/apps/opie-reader/Aportis.cpp index 7528e78..353996c 100644 --- a/noncore/apps/opie-reader/Aportis.cpp +++ b/noncore/apps/opie-reader/Aportis.cpp | |||
@@ -1,455 +1,454 @@ | |||
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 | #include "static.h" | ||
7 | 6 | ||
8 | Aportis::Aportis() : peanutfile(false) { /*printf("constructing:%x\n",fin);*/ } | 7 | Aportis::Aportis() : peanutfile(false) { /*printf("constructing:%x\n",fin);*/ } |
9 | 8 | ||
10 | void Aportis::dePeanut(int& ch) | 9 | void Aportis::dePeanut(int& ch) |
11 | { | 10 | { |
12 | if (peanutfile && ch != EOF) | 11 | if (peanutfile && ch != EOF) |
13 | { | 12 | { |
14 | unsigned char c = ch; | 13 | unsigned char c = ch; |
15 | if (peanutfile) c ^= 0xa5; | 14 | if (peanutfile) c ^= 0xa5; |
16 | ch = c; | 15 | ch = c; |
17 | } | 16 | } |
18 | } | 17 | } |
19 | 18 | ||
20 | CList<Bkmk>* Aportis::getbkmklist() | 19 | CList<Bkmk>* Aportis::getbkmklist() |
21 | { | 20 | { |
22 | /* | 21 | /* |
23 | if (peanutfile) | 22 | if (peanutfile) |
24 | { | 23 | { |
25 | if (nRecs2 > nRecs) | 24 | if (nRecs2 > nRecs) |
26 | { | 25 | { |
27 | CList<Bkmk>* t = new CList<Bkmk>; | 26 | CList<Bkmk>* t = new CList<Bkmk>; |
28 | for (int i = nRecs; i < nRecs2; i++) | 27 | for (int i = nRecs; i < nRecs2; i++) |
29 | { | 28 | { |
30 | char name[17]; | 29 | char name[17]; |
31 | name[16] = '\0'; | 30 | name[16] = '\0'; |
32 | // qDebug("Record:%d, Length:%u",i,recordlength(i)); | 31 | // qDebug("Record:%d, Length:%u",i,recordlength(i)); |
33 | gotorecordnumber(i); | 32 | gotorecordnumber(i); |
34 | fread(name,1,16,fin); | 33 | fread(name,1,16,fin); |
35 | unsigned long lcn; | 34 | unsigned long lcn; |
36 | fread(&lcn,sizeof(lcn),1,fin); | 35 | fread(&lcn,sizeof(lcn),1,fin); |
37 | lcn ^= 0xa5a5a5a5; | 36 | lcn ^= 0xa5a5a5a5; |
38 | lcn = SwapLong(lcn); | 37 | lcn = SwapLong(lcn); |
39 | // qDebug("Bookmark:%s:%u", name,lcn); | 38 | // qDebug("Bookmark:%s:%u", name,lcn); |
40 | tchar tname[17]; | 39 | tchar tname[17]; |
41 | memset(tname, 0, sizeof(tname)); | 40 | memset(tname, 0, sizeof(tname)); |
42 | for (int i = 0; name[i] != 0; i++) | 41 | for (int i = 0; name[i] != 0; i++) |
43 | { | 42 | { |
44 | tname[i] = name[i] ^ 0xa5; | 43 | tname[i] = name[i] ^ 0xa5; |
45 | } | 44 | } |
46 | t->push_back(Bkmk(tname, NULL, lcn)); | 45 | t->push_back(Bkmk(tname, NULL, lcn)); |
47 | } | 46 | } |
48 | return t; | 47 | return t; |
49 | } | 48 | } |
50 | else | 49 | else |
51 | { | 50 | { |
52 | return NULL; | 51 | return NULL; |
53 | } | 52 | } |
54 | } | 53 | } |
55 | */ | 54 | */ |
56 | if (bCompressed != 4) return NULL; | 55 | if (bCompressed != 4) return NULL; |
57 | CList<Bkmk>* t = new CList<Bkmk>; | 56 | CList<Bkmk>* t = new CList<Bkmk>; |
58 | size_t cur = ftell(fin); | 57 | size_t cur = ftell(fin); |
59 | for (int i = 0; i < nRecs2; i++) | 58 | for (int i = 0; i < nRecs2; i++) |
60 | { | 59 | { |
61 | DWORD dwPos; | 60 | DWORD dwPos; |
62 | fseek(fin, 0x56 + 8*i, SEEK_SET); | 61 | fseek(fin, 0x56 + 8*i, SEEK_SET); |
63 | fread(&dwPos, 4, 1, fin); | 62 | fread(&dwPos, 4, 1, fin); |
64 | dwPos = SwapLong(dwPos); | 63 | dwPos = SwapLong(dwPos); |
65 | fseek(fin,dwPos,SEEK_SET); | 64 | fseek(fin,dwPos,SEEK_SET); |
66 | unsigned char ch; | 65 | unsigned char ch; |
67 | fread(&ch,1,1,fin); | 66 | fread(&ch,1,1,fin); |
68 | if (ch != 241) | 67 | if (ch != 241) |
69 | { | 68 | { |
70 | char name[17]; | 69 | char name[17]; |
71 | name[16] = '\0'; | 70 | name[16] = '\0'; |
72 | fseek(fin,dwPos,SEEK_SET); | 71 | fseek(fin,dwPos,SEEK_SET); |
73 | fread(name,1,16,fin); | 72 | fread(name,1,16,fin); |
74 | unsigned long lcn; | 73 | unsigned long lcn; |
75 | fread(&lcn,sizeof(lcn),1,fin); | 74 | fread(&lcn,sizeof(lcn),1,fin); |
76 | lcn = SwapLong(lcn); | 75 | lcn = SwapLong(lcn); |
77 | #ifdef _UNICODE | 76 | #ifdef _UNICODE |
78 | tchar tname[17]; | 77 | tchar tname[17]; |
79 | memset(tname, 0, sizeof(tname)); | 78 | memset(tname, 0, sizeof(tname)); |
80 | for (int i = 0; name[i] != 0; i++) | 79 | for (int i = 0; name[i] != 0; i++) |
81 | { | 80 | { |
82 | tname[i] = name[i]; | 81 | tname[i] = name[i]; |
83 | } | 82 | } |
84 | t->push_back(Bkmk(tname, NULL, lcn)); | 83 | t->push_back(Bkmk(tname, NULL, lcn)); |
85 | #else | 84 | #else |
86 | t->push_back(Bkmk(name,lcn)); | 85 | t->push_back(Bkmk(name,lcn)); |
87 | #endif | 86 | #endif |
88 | } | 87 | } |
89 | } | 88 | } |
90 | fseek(fin, cur, SEEK_SET); | 89 | fseek(fin, cur, SEEK_SET); |
91 | return t; | 90 | return t; |
92 | } | 91 | } |
93 | 92 | ||
94 | int Aportis::OpenFile(const char *src) | 93 | int Aportis::OpenFile(const char *src) |
95 | { | 94 | { |
96 | // printf("In openfile\n"); | 95 | // printf("In openfile\n"); |
97 | int ret = 0; | 96 | int ret = 0; |
98 | html = false; | 97 | html = false; |
99 | mobiimagerec = 0; | 98 | mobiimagerec = 0; |
100 | if (!Cpdb::openpdbfile(src)) return -1; | 99 | if (!Cpdb::openpdbfile(src)) return -1; |
101 | 100 | ||
102 | if (head.creator == 0x64414552 // 'dAER' | 101 | if (head.creator == 0x64414552 // 'dAER' |
103 | || head.type == 0x74584554) // 'tXET') | 102 | || head.type == 0x74584554) // 'tXET') |
104 | { | 103 | { |
105 | } | 104 | } |
106 | else if (memcmp(&head.creator, "PPrs", 4) == 0 && memcmp(&head.type, "PNRd", 4) == 0) | 105 | else if (memcmp(&head.creator, "PPrs", 4) == 0 && memcmp(&head.type, "PNRd", 4) == 0) |
107 | { | 106 | { |
108 | peanutfile = true; | 107 | peanutfile = true; |
109 | } | 108 | } |
110 | else if (memcmp(&head.creator, "MOBI", 4) == 0 && memcmp(&head.type, "BOOK", 4) == 0) | 109 | else if (memcmp(&head.creator, "MOBI", 4) == 0 && memcmp(&head.type, "BOOK", 4) == 0) |
111 | { | 110 | { |
112 | html = true; | 111 | html = true; |
113 | unsigned char vsn; | 112 | unsigned char vsn; |
114 | fseek(fin, recordpos(0)+39, SEEK_SET); | 113 | fseek(fin, recordpos(0)+39, SEEK_SET); |
115 | fread(&vsn, 1, sizeof(vsn), fin); | 114 | fread(&vsn, 1, sizeof(vsn), fin); |
116 | qDebug("Mobi version:%x", vsn); | 115 | qDebug("Mobi version:%x", vsn); |
117 | if (vsn > 2) | 116 | if (vsn > 2) |
118 | { | 117 | { |
119 | fseek(fin, recordpos(0)+110, SEEK_SET); | 118 | fseek(fin, recordpos(0)+110, SEEK_SET); |
120 | fread(&mobiimagerec, 1, sizeof(mobiimagerec), fin); | 119 | fread(&mobiimagerec, 1, sizeof(mobiimagerec), fin); |
121 | mobiimagerec = ntohs(mobiimagerec)-1; | 120 | mobiimagerec = ntohs(mobiimagerec)-1; |
122 | } | 121 | } |
123 | } | 122 | } |
124 | else | 123 | else |
125 | { | 124 | { |
126 | return -2; | 125 | return -2; |
127 | } | 126 | } |
128 | 127 | ||
129 | nRecs2 = nRecs = SwapWord(head.recordList.numRecords) - 1; | 128 | nRecs2 = nRecs = SwapWord(head.recordList.numRecords) - 1; |
130 | 129 | ||
131 | struct stat _stat; | 130 | struct stat _stat; |
132 | stat(src,&_stat); | 131 | stat(src,&_stat); |
133 | dwLen = _stat.st_size; | 132 | dwLen = _stat.st_size; |
134 | 133 | ||
135 | //fseek(fin,0,SEEK_END); | 134 | //fseek(fin,0,SEEK_END); |
136 | //dwLen = ftell(fin); | 135 | //dwLen = ftell(fin); |
137 | 136 | ||
138 | if (peanutfile) | 137 | if (peanutfile) |
139 | { | 138 | { |
140 | 139 | ||
141 | PeanutHeader hdr0; | 140 | PeanutHeader hdr0; |
142 | gotorecordnumber(0); | 141 | gotorecordnumber(0); |
143 | fread(&hdr0, sizeof(hdr0), 1, fin); | 142 | fread(&hdr0, sizeof(hdr0), 1, fin); |
144 | // qDebug("Version:%x", ntohs(hdr0.Version)); | 143 | // qDebug("Version:%x", ntohs(hdr0.Version)); |
145 | if (hdr0.Version && 0x0200) | 144 | if (hdr0.Version && 0x0200) |
146 | { | 145 | { |
147 | bCompressed = 2; | 146 | bCompressed = 2; |
148 | } | 147 | } |
149 | else | 148 | else |
150 | { | 149 | { |
151 | bCompressed = 1; | 150 | bCompressed = 1; |
152 | } | 151 | } |
153 | BlockSize = 4096; | 152 | BlockSize = 4096; |
154 | nRecs = SwapWord(hdr0.Records)-1; | 153 | nRecs = SwapWord(hdr0.Records)-1; |
155 | dwTLen = nRecs*BlockSize; | 154 | dwTLen = nRecs*BlockSize; |
156 | } | 155 | } |
157 | else | 156 | else |
158 | { | 157 | { |
159 | gotorecordnumber(0); | 158 | gotorecordnumber(0); |
160 | tDocRecord0 hdr0; | 159 | tDocRecord0 hdr0; |
161 | fread(&hdr0, sizeof(hdr0), 1, fin); | 160 | fread(&hdr0, sizeof(hdr0), 1, fin); |
162 | bCompressed = SwapWord(hdr0.wVersion); | 161 | bCompressed = SwapWord(hdr0.wVersion); |
163 | if (bCompressed!=1 && bCompressed!=2 && bCompressed != 4) { | 162 | if (bCompressed!=1 && bCompressed!=2 && bCompressed != 4) { |
164 | qDebug("ERROR:Unrecognised compression type in Aportis:%u", bCompressed); | 163 | qDebug("ERROR:Unrecognised compression type in Aportis:%u", bCompressed); |
165 | ret = bCompressed; | 164 | ret = bCompressed; |
166 | bCompressed = 2; | 165 | bCompressed = 2; |
167 | } | 166 | } |
168 | switch (bCompressed) | 167 | switch (bCompressed) |
169 | { | 168 | { |
170 | case 4: | 169 | case 4: |
171 | { | 170 | { |
172 | dwTLen = 0; | 171 | dwTLen = 0; |
173 | int i; | 172 | int i; |
174 | for (i = 0; i < nRecs; i++) | 173 | for (i = 0; i < nRecs; i++) |
175 | { | 174 | { |
176 | unsigned int bs = GetBS(i); | 175 | unsigned int bs = GetBS(i); |
177 | if (bs == 0) break; | 176 | if (bs == 0) break; |
178 | else dwTLen += bs; | 177 | else dwTLen += bs; |
179 | } | 178 | } |
180 | nRecs = i; | 179 | nRecs = i; |
181 | BlockSize = 0; | 180 | BlockSize = 0; |
182 | } | 181 | } |
183 | break; | 182 | break; |
184 | case 1: | 183 | case 1: |
185 | case 2: | 184 | case 2: |
186 | default: | 185 | default: |
187 | nRecs = SwapWord(hdr0.wNumRecs); | 186 | nRecs = SwapWord(hdr0.wNumRecs); |
188 | if (mobiimagerec == 0 || mobiimagerec > nRecs2) mobiimagerec = nRecs; | 187 | if (mobiimagerec == 0 || mobiimagerec > nRecs2) mobiimagerec = nRecs; |
189 | dwTLen = SwapLong(hdr0.dwStoryLen); | 188 | dwTLen = SwapLong(hdr0.dwStoryLen); |
190 | BlockSize = SwapWord(hdr0.wRecSize); | 189 | BlockSize = SwapWord(hdr0.wRecSize); |
191 | if (BlockSize == 0) | 190 | if (BlockSize == 0) |
192 | { | 191 | { |
193 | BlockSize = 4096; | 192 | BlockSize = 4096; |
194 | printf("WARNING: Blocksize not set in source file\n"); | 193 | printf("WARNING: Blocksize not set in source file\n"); |
195 | } | 194 | } |
196 | } | 195 | } |
197 | } | 196 | } |
198 | 197 | ||
199 | qDebug("Mobi image rec:%u", mobiimagerec); | 198 | qDebug("Mobi image rec:%u", mobiimagerec); |
200 | 199 | ||
201 | // this is the main record buffer | 200 | // this is the main record buffer |
202 | // it knows how to stretch to accomodate the decompress | 201 | // it knows how to stretch to accomodate the decompress |
203 | currentrec = 0; | 202 | currentrec = 0; |
204 | cbptr = 0; | 203 | cbptr = 0; |
205 | outptr = 0; | 204 | outptr = 0; |
206 | refreshbuffer(); | 205 | refreshbuffer(); |
207 | if (!html) | 206 | if (!html) |
208 | { | 207 | { |
209 | int c; | 208 | int c; |
210 | char htmltag[] = "<HTML>"; | 209 | char htmltag[] = "<HTML>"; |
211 | char *p = htmltag; | 210 | char *p = htmltag; |
212 | while (1) | 211 | while (1) |
213 | { | 212 | { |
214 | c = getch(); | 213 | c = getch(); |
215 | char ch = *p++; | 214 | char ch = *p++; |
216 | if (ch == 0) | 215 | if (ch == 0) |
217 | { | 216 | { |
218 | html = true; | 217 | html = true; |
219 | break; | 218 | break; |
220 | } | 219 | } |
221 | if (c != ch) | 220 | if (c != ch) |
222 | { | 221 | { |
223 | html = false; | 222 | html = false; |
224 | break; | 223 | break; |
225 | } | 224 | } |
226 | } | 225 | } |
227 | currentrec = 0; | 226 | currentrec = 0; |
228 | cbptr = 0; | 227 | cbptr = 0; |
229 | outptr = 0; | 228 | outptr = 0; |
230 | refreshbuffer(); | 229 | refreshbuffer(); |
231 | } | 230 | } |
232 | /* | 231 | /* |
233 | for (int i = 0; i < nRecs2; i++) | 232 | for (int i = 0; i < nRecs2; i++) |
234 | { | 233 | { |
235 | qDebug("Record:%u - %u bytes at position %x", i, recordlength(i), recordpos(i)); | 234 | qDebug("Record:%u - %u bytes at position %x", i, recordlength(i), recordpos(i)); |
236 | } | 235 | } |
237 | */ | 236 | */ |
238 | 237 | ||
239 | qDebug("Number of records:[%u,%u]", nRecs, nRecs2); | 238 | qDebug("Number of records:[%u,%u]", nRecs, nRecs2); |
240 | return ret; | 239 | return ret; |
241 | } | 240 | } |
242 | 241 | ||
243 | int Aportis::getch() | 242 | int Aportis::getch() |
244 | { | 243 | { |
245 | if (bCompressed == 1) | 244 | if (bCompressed == 1) |
246 | { | 245 | { |
247 | if ((dwRecLen == 0) && !refreshbuffer()) return EOF; | 246 | if ((dwRecLen == 0) && !refreshbuffer()) return EOF; |
248 | else | 247 | else |
249 | { | 248 | { |
250 | int c = getc(fin); | 249 | int c = getc(fin); |
251 | dePeanut(c); | 250 | dePeanut(c); |
252 | dwRecLen--; | 251 | dwRecLen--; |
253 | currentpos++; | 252 | currentpos++; |
254 | return c; | 253 | return c; |
255 | } | 254 | } |
256 | } | 255 | } |
257 | if (outptr != cbptr) | 256 | if (outptr != cbptr) |
258 | { | 257 | { |
259 | currentpos++; | 258 | currentpos++; |
260 | return (circbuf[outptr = (outptr + 1) % 2048]); | 259 | return (circbuf[outptr = (outptr + 1) % 2048]); |
261 | } | 260 | } |
262 | if ((dwRecLen == 0) && !refreshbuffer()) return EOF; | 261 | if ((dwRecLen == 0) && !refreshbuffer()) return EOF; |
263 | currentpos++; | 262 | currentpos++; |
264 | int c; | 263 | int c; |
265 | 264 | ||
266 | // take a char from the input buffer | 265 | // take a char from the input buffer |
267 | c = getc(fin); | 266 | c = getc(fin); |
268 | dePeanut(c); | 267 | dePeanut(c); |
269 | dwRecLen--; | 268 | dwRecLen--; |
270 | // separate the char into zones: 0, 1...8, 9...0x7F, 0x80...0xBF, 0xC0...0xFF | 269 | // separate the char into zones: 0, 1...8, 9...0x7F, 0x80...0xBF, 0xC0...0xFF |
271 | 270 | ||
272 | // codes 1...8 mean copy that many chars; for accented chars & binary | 271 | // codes 1...8 mean copy that many chars; for accented chars & binary |
273 | if (c == 0) | 272 | if (c == 0) |
274 | { | 273 | { |
275 | circbuf[outptr = cbptr = (cbptr+1)%2048] = c; | 274 | circbuf[outptr = cbptr = (cbptr+1)%2048] = c; |
276 | return c; | 275 | return c; |
277 | } | 276 | } |
278 | else if (c >= 0x09 && c <= 0x7F) | 277 | else if (c >= 0x09 && c <= 0x7F) |
279 | { | 278 | { |
280 | circbuf[outptr = cbptr = (cbptr+1)%2048] = c; | 279 | circbuf[outptr = cbptr = (cbptr+1)%2048] = c; |
281 | return c; | 280 | return c; |
282 | } | 281 | } |
283 | else if (c >= 0x01 && c <= 0x08) | 282 | else if (c >= 0x01 && c <= 0x08) |
284 | { | 283 | { |
285 | dwRecLen -= c; | 284 | dwRecLen -= c; |
286 | while(c--) | 285 | while(c--) |
287 | { | 286 | { |
288 | int c = getc(fin); | 287 | int c = getc(fin); |
289 | dePeanut(c); | 288 | dePeanut(c); |
290 | circbuf[cbptr = (cbptr+1)%2048] = c; | 289 | circbuf[cbptr = (cbptr+1)%2048] = c; |
291 | } | 290 | } |
292 | return circbuf[outptr = (outptr+1)%2048]; | 291 | return circbuf[outptr = (outptr+1)%2048]; |
293 | } | 292 | } |
294 | else if (c >= 0x80 && c <= 0xBF) | 293 | else if (c >= 0x80 && c <= 0xBF) |
295 | { | 294 | { |
296 | int m,n; | 295 | int m,n; |
297 | c <<= 8; | 296 | c <<= 8; |
298 | int c1 = getc(fin); | 297 | int c1 = getc(fin); |
299 | dePeanut(c1); | 298 | dePeanut(c1); |
300 | c += c1; | 299 | c += c1; |
301 | dwRecLen--; | 300 | dwRecLen--; |
302 | m = (c & 0x3FFF) >> COUNT_BITS; | 301 | m = (c & 0x3FFF) >> COUNT_BITS; |
303 | n = c & ((1<<COUNT_BITS) - 1); | 302 | n = c & ((1<<COUNT_BITS) - 1); |
304 | n += 3; | 303 | n += 3; |
305 | while (n--) | 304 | while (n--) |
306 | { | 305 | { |
307 | cbptr = (cbptr+1)%2048; | 306 | cbptr = (cbptr+1)%2048; |
308 | circbuf[cbptr] = circbuf[(cbptr+2048-m)%2048]; | 307 | circbuf[cbptr] = circbuf[(cbptr+2048-m)%2048]; |
309 | } | 308 | } |
310 | return circbuf[outptr = (outptr+1)%2048]; | 309 | return circbuf[outptr = (outptr+1)%2048]; |
311 | } | 310 | } |
312 | else if (c >= 0xC0 && c <= 0xFF) | 311 | else if (c >= 0xC0 && c <= 0xFF) |
313 | { | 312 | { |
314 | circbuf[cbptr = (cbptr+1)%2048] = ' '; | 313 | circbuf[cbptr = (cbptr+1)%2048] = ' '; |
315 | circbuf[cbptr = (cbptr+1)%2048] = c^0x80; | 314 | circbuf[cbptr = (cbptr+1)%2048] = c^0x80; |
316 | return circbuf[outptr = (outptr+1)%2048]; | 315 | return circbuf[outptr = (outptr+1)%2048]; |
317 | } | 316 | } |
318 | } | 317 | } |
319 | 318 | ||
320 | unsigned int Aportis::GetBS(unsigned int bn) | 319 | unsigned int Aportis::GetBS(unsigned int bn) |
321 | { | 320 | { |
322 | DWORD dwPos; | 321 | DWORD dwPos; |
323 | WORD fs; | 322 | WORD fs; |
324 | 323 | ||
325 | fseek(fin, 0x56 + 8*bn, SEEK_SET); | 324 | fseek(fin, 0x56 + 8*bn, SEEK_SET); |
326 | fread(&dwPos, 4, 1, fin); | 325 | fread(&dwPos, 4, 1, fin); |
327 | dwPos = SwapLong(dwPos); | 326 | dwPos = SwapLong(dwPos); |
328 | fseek(fin,dwPos,SEEK_SET); | 327 | fseek(fin,dwPos,SEEK_SET); |
329 | 328 | ||
330 | // gotorecordnumber(bn+1); | 329 | // gotorecordnumber(bn+1); |
331 | unsigned char ch; | 330 | unsigned char ch; |
332 | fread(&ch,1,1,fin); | 331 | fread(&ch,1,1,fin); |
333 | if (ch == 241) | 332 | if (ch == 241) |
334 | { | 333 | { |
335 | fread(&fs,sizeof(fs),1,fin); | 334 | fread(&fs,sizeof(fs),1,fin); |
336 | fs = SwapWord(fs); | 335 | fs = SwapWord(fs); |
337 | } | 336 | } |
338 | else | 337 | else |
339 | fs = 0; | 338 | fs = 0; |
340 | return fs; | 339 | return fs; |
341 | } | 340 | } |
342 | 341 | ||
343 | unsigned int Aportis::locate() | 342 | unsigned int Aportis::locate() |
344 | { | 343 | { |
345 | if (bCompressed == 4) | 344 | if (bCompressed == 4) |
346 | { | 345 | { |
347 | size_t cur = ftell(fin); | 346 | size_t cur = ftell(fin); |
348 | unsigned int clen = 0; | 347 | unsigned int clen = 0; |
349 | for (unsigned int i = 0; i < currentrec-1; i++) | 348 | for (unsigned int i = 0; i < currentrec-1; i++) |
350 | { | 349 | { |
351 | unsigned int bs = GetBS(i); | 350 | unsigned int bs = GetBS(i); |
352 | if (bs == 0) break; | 351 | if (bs == 0) break; |
353 | clen += bs; | 352 | clen += bs; |
354 | } | 353 | } |
355 | fseek(fin,cur,SEEK_SET); | 354 | fseek(fin,cur,SEEK_SET); |
356 | return clen+currentpos; | 355 | return clen+currentpos; |
357 | } | 356 | } |
358 | else | 357 | else |
359 | return (currentrec-1)*BlockSize+currentpos; | 358 | return (currentrec-1)*BlockSize+currentpos; |
360 | } | 359 | } |
361 | 360 | ||
362 | void Aportis::locate(unsigned int n) | 361 | void Aportis::locate(unsigned int n) |
363 | { | 362 | { |
364 | unsigned int offset; | 363 | unsigned int offset; |
365 | // currentrec = (n >> OFFBITS); | 364 | // currentrec = (n >> OFFBITS); |
366 | switch (bCompressed) | 365 | switch (bCompressed) |
367 | { | 366 | { |
368 | case 4: | 367 | case 4: |
369 | { | 368 | { |
370 | DWORD clen = 0; | 369 | DWORD clen = 0; |
371 | offset = n; | 370 | offset = n; |
372 | unsigned int i; | 371 | unsigned int i; |
373 | for (i = 0; i < nRecs; i++) | 372 | for (i = 0; i < nRecs; i++) |
374 | { | 373 | { |
375 | unsigned int bs = GetBS(i); | 374 | unsigned int bs = GetBS(i); |
376 | if (bs == 0) break; | 375 | if (bs == 0) break; |
377 | clen += bs; | 376 | clen += bs; |
378 | if (clen > n) break; | 377 | if (clen > n) break; |
379 | offset = n - clen; | 378 | offset = n - clen; |
380 | } | 379 | } |
381 | currentrec = i; | 380 | currentrec = i; |
382 | } | 381 | } |
383 | break; | 382 | break; |
384 | case 1: | 383 | case 1: |
385 | case 2: | 384 | case 2: |
386 | default: | 385 | default: |
387 | currentrec = n / BlockSize; | 386 | currentrec = n / BlockSize; |
388 | offset = n % BlockSize; | 387 | offset = n % BlockSize; |
389 | } | 388 | } |
390 | 389 | ||
391 | outptr = cbptr; | 390 | outptr = cbptr; |
392 | refreshbuffer(); | 391 | refreshbuffer(); |
393 | while (currentpos < offset && getch() != EOF); | 392 | while (currentpos < offset && getch() != EOF); |
394 | } | 393 | } |
395 | 394 | ||
396 | bool Aportis::refreshbuffer() | 395 | bool Aportis::refreshbuffer() |
397 | { | 396 | { |
398 | if (currentrec < nRecs) | 397 | if (currentrec < nRecs) |
399 | { | 398 | { |
400 | dwRecLen = recordlength(currentrec+1); | 399 | dwRecLen = recordlength(currentrec+1); |
401 | gotorecordnumber(currentrec+1); | 400 | gotorecordnumber(currentrec+1); |
402 | if (bCompressed == 4) | 401 | if (bCompressed == 4) |
403 | { | 402 | { |
404 | unsigned char t[3]; | 403 | unsigned char t[3]; |
405 | fread(t,1,3,fin); | 404 | fread(t,1,3,fin); |
406 | if (t[0] != 241) | 405 | if (t[0] != 241) |
407 | { | 406 | { |
408 | printf("You shouldn't be here!\n"); | 407 | printf("You shouldn't be here!\n"); |
409 | return false; | 408 | return false; |
410 | } | 409 | } |
411 | dwRecLen -= 3; | 410 | dwRecLen -= 3; |
412 | } | 411 | } |
413 | /* | 412 | /* |
414 | int n = fread(t.buf, 1, dwRecLen, fin); | 413 | int n = fread(t.buf, 1, dwRecLen, fin); |
415 | t.len = n; | 414 | t.len = n; |
416 | // if(bCompressed) | 415 | // if(bCompressed) |
417 | t.Decompress(); | 416 | t.Decompress(); |
418 | 417 | ||
419 | t.buf[t.Len()] = '\0'; | 418 | t.buf[t.Len()] = '\0'; |
420 | */ | 419 | */ |
421 | currentpos = 0; | 420 | currentpos = 0; |
422 | currentrec++; | 421 | currentrec++; |
423 | return true; | 422 | return true; |
424 | } | 423 | } |
425 | else { | 424 | else { |
426 | return false; | 425 | return false; |
427 | } | 426 | } |
428 | } | 427 | } |
429 | 428 | ||
430 | #include <qimage.h> | 429 | #include <qimage.h> |
431 | 430 | ||
432 | QImage* Aportis::getPicture(unsigned long tgt) | 431 | QImage* Aportis::getPicture(unsigned long tgt) |
433 | { | 432 | { |
434 | unsigned short tgtrec = tgt+mobiimagerec; | 433 | unsigned short tgtrec = tgt+mobiimagerec; |
435 | if (tgtrec > nRecs2) return NULL; | 434 | if (tgtrec > nRecs2) return NULL; |
436 | size_t cur = ftell(fin); | 435 | size_t cur = ftell(fin); |
437 | unsigned short reclen = recordlength(tgtrec); | 436 | unsigned short reclen = recordlength(tgtrec); |
438 | gotorecordnumber(tgtrec); | 437 | gotorecordnumber(tgtrec); |
439 | UInt8* imgbuffer = new UInt8[reclen]; | 438 | UInt8* imgbuffer = new UInt8[reclen]; |
440 | fread(imgbuffer, 1, reclen, fin); | 439 | fread(imgbuffer, 1, reclen, fin); |
441 | QByteArray arr; | 440 | QByteArray arr; |
442 | arr.assign((const char*)imgbuffer, reclen); | 441 | arr.assign((const char*)imgbuffer, reclen); |
443 | 442 | ||
444 | QImage* qimage = new QImage(arr); | 443 | QImage* qimage = new QImage(arr); |
445 | fseek(fin, cur, SEEK_SET); | 444 | fseek(fin, cur, SEEK_SET); |
446 | 445 | ||
447 | return qimage; | 446 | return qimage; |
448 | } | 447 | } |
449 | 448 | ||
450 | #ifndef __STATIC | 449 | #ifndef __STATIC |
451 | extern "C" | 450 | extern "C" |
452 | { | 451 | { |
453 | CExpander* newcodec() { return new Aportis; } | 452 | CExpander* newcodec() { return new Aportis; } |
454 | } | 453 | } |
455 | #endif | 454 | #endif |
diff --git a/noncore/apps/opie-reader/AportisCodec/AportisCodec.pro b/noncore/apps/opie-reader/AportisCodec/AportisCodec.pro index 4b61a7a..fcab192 100644 --- a/noncore/apps/opie-reader/AportisCodec/AportisCodec.pro +++ b/noncore/apps/opie-reader/AportisCodec/AportisCodec.pro | |||
@@ -1,30 +1,29 @@ | |||
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 = Aportis.h \ | 5 | HEADERS = Aportis.h \ |
6 | CExpander.h \ | 6 | CExpander.h \ |
7 | ../OREADERINC/useqpe.h \ | ||
8 | config.h \ | 7 | config.h \ |
9 | ustring.h \ | 8 | ustring.h \ |
10 | StyleConsts.h \ | 9 | StyleConsts.h \ |
11 | Markups.h \ | 10 | Markups.h \ |
12 | names.h \ | 11 | names.h \ |
13 | linktype.h \ | 12 | linktype.h \ |
14 | pdb.h \ | 13 | pdb.h \ |
15 | my_list.h \ | 14 | my_list.h \ |
16 | Bkmks.h \ | 15 | Bkmks.h \ |
17 | Filedata.h | 16 | Filedata.h |
18 | 17 | ||
19 | SOURCES = Aportis.cpp | 18 | SOURCES = Aportis.cpp |
20 | 19 | ||
21 | 20 | ||
22 | INTERFACES= | 21 | INTERFACES= |
23 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | 22 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs |
24 | TARGET = Aportis | 23 | TARGET = Aportis |
25 | LIBS += -lreader_pdb -lreader_codec | 24 | LIBS += -lreader_pdb -lreader_codec |
26 | 25 | ||
27 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 26 | INCLUDEPATH+= $(OPIEDIR)/include |
28 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 27 | DEPENDPATH+= $(OPIEDIR)/include |
29 | 28 | ||
30 | include ( $(OPIEDIR)/include.pro ) \ No newline at end of file | 29 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/BuffDoc.cpp b/noncore/apps/opie-reader/BuffDoc.cpp index 22934f9..1f0a524 100644 --- a/noncore/apps/opie-reader/BuffDoc.cpp +++ b/noncore/apps/opie-reader/BuffDoc.cpp | |||
@@ -1,710 +1,708 @@ | |||
1 | #include "static.h" | ||
2 | #include "names.h" | 1 | #include "names.h" |
3 | 2 | ||
4 | #define NEWLINEBREAK | 3 | #define NEWLINEBREAK |
5 | #define INCREMENTALWIDTH | 4 | #define INCREMENTALWIDTH |
6 | 5 | ||
7 | #include "useqpe.h" | ||
8 | #include "usenef.h" | 6 | #include "usenef.h" |
9 | #include "BuffDoc.h" | 7 | #include "BuffDoc.h" |
10 | #include "config.h" | 8 | #include "config.h" |
11 | #include "CDrawBuffer.h" | 9 | #include "CDrawBuffer.h" |
12 | #include "ZText.h" | 10 | #include "ZText.h" |
13 | #include "ebookcodec.h" | 11 | #include "ebookcodec.h" |
14 | 12 | ||
15 | #ifdef __STATIC | 13 | #ifdef __STATIC |
16 | #include "Aportis.h" | 14 | #include "Aportis.h" |
17 | #include "CHM.h" | 15 | #include "CHM.h" |
18 | #include "ppm_expander.h" | 16 | #include "ppm_expander.h" |
19 | #include "ztxt.h" | 17 | #include "ztxt.h" |
20 | #include "plucker.h" | 18 | #include "plucker.h" |
21 | #ifdef USENEF | 19 | #ifdef USENEF |
22 | #include "nef.h" | 20 | #include "nef.h" |
23 | #include "arrierego.h" | 21 | #include "arrierego.h" |
24 | #endif | 22 | #endif |
25 | #include "iSilo.h" | 23 | #include "iSilo.h" |
26 | #endif | 24 | #endif |
27 | 25 | ||
28 | 26 | ||
29 | 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) |
30 | { | 28 | { |
31 | linkType bRet = eNone; | 29 | linkType bRet = eNone; |
32 | if (exp != NULL) | 30 | if (exp != NULL) |
33 | { | 31 | { |
34 | bRet = filt->hyperlink(n, noff, wrd, nm); | 32 | bRet = filt->hyperlink(n, noff, wrd, nm); |
35 | if ((bRet & eLink) != 0) | 33 | if ((bRet & eLink) != 0) |
36 | { | 34 | { |
37 | lastword.empty(); | 35 | lastword.empty(); |
38 | lastsizes[0] = laststartline = n; | 36 | lastsizes[0] = laststartline = n; |
39 | #ifdef NEWLINEBREAK | 37 | #ifdef NEWLINEBREAK |
40 | lastispara = false; | 38 | lastispara = false; |
41 | #else | 39 | #else |
42 | lastispara = false; | 40 | lastispara = false; |
43 | #endif | 41 | #endif |
44 | lastsizes[0] = laststartline = exp->locate(); | 42 | lastsizes[0] = laststartline = exp->locate(); |
45 | } | 43 | } |
46 | } | 44 | } |
47 | return bRet; | 45 | return bRet; |
48 | } | 46 | } |
49 | 47 | ||
50 | void BuffDoc::locate(unsigned int n) | 48 | void BuffDoc::locate(unsigned int n) |
51 | { | 49 | { |
52 | // //qDebug("BuffDoc:locating:%u",n); | 50 | // //qDebug("BuffDoc:locating:%u",n); |
53 | lastword.empty(); | 51 | lastword.empty(); |
54 | lastsizes[0] = laststartline = n; | 52 | lastsizes[0] = laststartline = n; |
55 | #ifdef NEWLINEBREAK | 53 | #ifdef NEWLINEBREAK |
56 | lastispara = false; | 54 | lastispara = false; |
57 | #else | 55 | #else |
58 | lastispara = false; | 56 | lastispara = false; |
59 | #endif | 57 | #endif |
60 | // tchar linebuf[1024]; | 58 | // tchar linebuf[1024]; |
61 | if (exp != NULL) filt->locate(n); | 59 | if (exp != NULL) filt->locate(n); |
62 | // //qDebug("BuffDoc:Located"); | 60 | // //qDebug("BuffDoc:Located"); |
63 | } | 61 | } |
64 | 62 | ||
65 | static bool isletter(unsigned short c) | 63 | static bool isletter(unsigned short c) |
66 | { | 64 | { |
67 | if ('a' <= c && c <= 'z') return true; | 65 | if ('a' <= c && c <= 'z') return true; |
68 | if ('A' <= c && c <= 'Z') return true; | 66 | if ('A' <= c && c <= 'Z') return true; |
69 | // Cyrillic letters | 67 | // Cyrillic letters |
70 | if (0x400 <= c && c <= 0x52F) return true; | 68 | if (0x400 <= c && c <= 0x52F) return true; |
71 | return false; | 69 | return false; |
72 | } | 70 | } |
73 | 71 | ||
74 | static bool isvowel(unsigned short c) // Only want lower case vowels | 72 | static bool isvowel(unsigned short c) // Only want lower case vowels |
75 | { | 73 | { |
76 | switch (c) | 74 | switch (c) |
77 | { | 75 | { |
78 | case 'a': | 76 | case 'a': |
79 | case 'e': | 77 | case 'e': |
80 | case 'i': | 78 | case 'i': |
81 | case 'o': | 79 | case 'o': |
82 | case 'u': | 80 | case 'u': |
83 | // Cyrillic vowels | 81 | // Cyrillic vowels |
84 | case 0x430: | 82 | case 0x430: |
85 | case 0x435: | 83 | case 0x435: |
86 | case 0x438: | 84 | case 0x438: |
87 | case 0x43E: | 85 | case 0x43E: |
88 | case 0x443: | 86 | case 0x443: |
89 | case 0x44B: | 87 | case 0x44B: |
90 | case 0x44D: | 88 | case 0x44D: |
91 | case 0x44E: | 89 | case 0x44E: |
92 | case 0x44F: | 90 | case 0x44F: |
93 | case 0x451: | 91 | case 0x451: |
94 | 92 | ||
95 | case 0x450: | 93 | case 0x450: |
96 | case 0x454: | 94 | case 0x454: |
97 | case 0x456: | 95 | case 0x456: |
98 | case 0x457: | 96 | case 0x457: |
99 | case 0x45D: | 97 | case 0x45D: |
100 | 98 | ||
101 | case 0x463: | 99 | case 0x463: |
102 | 100 | ||
103 | case 0x4AF: | 101 | case 0x4AF: |
104 | case 0x4B1: | 102 | case 0x4B1: |
105 | case 0x4D1: | 103 | case 0x4D1: |
106 | case 0x4D3: | 104 | case 0x4D3: |
107 | 105 | ||
108 | case 0x4D5: | 106 | case 0x4D5: |
109 | case 0x4D7: | 107 | case 0x4D7: |
110 | case 0x4E3: | 108 | case 0x4E3: |
111 | case 0x4E5: | 109 | case 0x4E5: |
112 | case 0x4E7: | 110 | case 0x4E7: |
113 | case 0x4E9: | 111 | case 0x4E9: |
114 | case 0x4EB: | 112 | case 0x4EB: |
115 | case 0x4ED: | 113 | case 0x4ED: |
116 | case 0x4EF: | 114 | case 0x4EF: |
117 | case 0x4F1: | 115 | case 0x4F1: |
118 | case 0x4F3: | 116 | case 0x4F3: |
119 | case 0x4F9: | 117 | case 0x4F9: |
120 | return true; | 118 | return true; |
121 | default: | 119 | default: |
122 | return ((0xe0 <= c) && (c <= 0xfc) && (c != 0xf1) && (c != 0xf7) && (c != 0xe7)); | 120 | return ((0xe0 <= c) && (c <= 0xfc) && (c != 0xf1) && (c != 0xf7) && (c != 0xe7)); |
123 | } | 121 | } |
124 | } | 122 | } |
125 | 123 | ||
126 | inline bool isconsonant(unsigned short c) | 124 | inline bool isconsonant(unsigned short c) |
127 | { | 125 | { |
128 | switch( c ) | 126 | switch( c ) |
129 | { | 127 | { |
130 | // Some cyrillic letters are neither vowels, nor consonants, or otherwise | 128 | // Some cyrillic letters are neither vowels, nor consonants, or otherwise |
131 | // the letters no word can start from. | 129 | // the letters no word can start from. |
132 | case 0x439: | 130 | case 0x439: |
133 | case 0x44A: | 131 | case 0x44A: |
134 | case 0x44C: | 132 | case 0x44C: |
135 | 133 | ||
136 | case 0x45E: | 134 | case 0x45E: |
137 | 135 | ||
138 | return false; | 136 | return false; |
139 | 137 | ||
140 | default: | 138 | default: |
141 | return (isletter(c) && !isvowel(c)); | 139 | return (isletter(c) && !isvowel(c)); |
142 | } | 140 | } |
143 | return (isletter(c) && !isvowel(c)); | 141 | return (isletter(c) && !isvowel(c)); |
144 | } | 142 | } |
145 | 143 | ||
146 | #ifdef NEWLINEBREAK | 144 | #ifdef NEWLINEBREAK |
147 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht) | 145 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht) |
148 | { | 146 | { |
149 | bool moreleft = true; | 147 | bool moreleft = true; |
150 | bool margindone = false; | 148 | bool margindone = false; |
151 | int isCentred = -1; | 149 | int isCentred = -1; |
152 | int w = wth-(_lborder+_rborder); | 150 | int w = wth-(_lborder+_rborder); |
153 | tchar ch = 32; | 151 | tchar ch = 32; |
154 | CStyle cs; | 152 | CStyle cs; |
155 | buff->empty(); | 153 | buff->empty(); |
156 | if (exp == NULL) | 154 | if (exp == NULL) |
157 | { | 155 | { |
158 | buff->empty(); | 156 | buff->empty(); |
159 | buff->setEof(); | 157 | buff->setEof(); |
160 | return false; | 158 | return false; |
161 | } | 159 | } |
162 | int len = 0; | 160 | int len = 0; |
163 | if (lastword.length() > 0) | 161 | if (lastword.length() > 0) |
164 | { | 162 | { |
165 | if (isCentred < 0) | 163 | if (isCentred < 0) |
166 | { | 164 | { |
167 | isCentred = (lastword.firststyle().getJustify() == m_AlignCentre) ? 1 : 0; | 165 | isCentred = (lastword.firststyle().getJustify() == m_AlignCentre) ? 1 : 0; |
168 | } | 166 | } |
169 | *buff = lastword; | 167 | *buff = lastword; |
170 | cs = lastword.laststyle(); | 168 | cs = lastword.laststyle(); |
171 | w -= buff->leftMargin() + buff->rightMargin(); | 169 | w -= buff->leftMargin() + buff->rightMargin(); |
172 | margindone = true; | 170 | margindone = true; |
173 | len = lastword.length(); | 171 | len = lastword.length(); |
174 | } | 172 | } |
175 | else buff->empty(); | 173 | else buff->empty(); |
176 | lastword.empty(); | 174 | lastword.empty(); |
177 | unsigned int slen = buff->width(availht, len); | 175 | unsigned int slen = buff->width(availht, len); |
178 | if (lastispara) buff->setstartpara(); | 176 | if (lastispara) buff->setstartpara(); |
179 | int nospaces = 0; | 177 | int nospaces = 0; |
180 | while (1) | 178 | while (1) |
181 | { | 179 | { |
182 | getch(ch, cs, lastsizes[len]); | 180 | getch(ch, cs, lastsizes[len]); |
183 | if (isCentred < 0) | 181 | if (isCentred < 0) |
184 | { | 182 | { |
185 | isCentred = (cs.getJustify() == m_AlignCentre) ? 1 : 0; | 183 | isCentred = (cs.getJustify() == m_AlignCentre) ? 1 : 0; |
186 | } | 184 | } |
187 | if (ch == 10 && len == 0 && !lastispara) | 185 | if (ch == 10 && len == 0 && !lastispara) |
188 | { | 186 | { |
189 | getch(ch, cs, lastsizes[len]); | 187 | getch(ch, cs, lastsizes[len]); |
190 | buff->setstartpara(); | 188 | buff->setstartpara(); |
191 | } | 189 | } |
192 | if (ch == UEOF) | 190 | if (ch == UEOF) |
193 | { | 191 | { |
194 | buff->setendpara(cs); | 192 | buff->setendpara(cs); |
195 | if (len == 0) | 193 | if (len == 0) |
196 | { | 194 | { |
197 | buff->setEof(); | 195 | buff->setEof(); |
198 | moreleft = false; | 196 | moreleft = false; |
199 | } | 197 | } |
200 | laststartline = exp->locate(); | 198 | laststartline = exp->locate(); |
201 | break; | 199 | break; |
202 | } | 200 | } |
203 | if (ch == 10) | 201 | if (ch == 10) |
204 | { | 202 | { |
205 | buff->setendpara(cs); | 203 | buff->setendpara(cs); |
206 | lastispara = true; | 204 | lastispara = true; |
207 | laststartline = exp->locate(); | 205 | laststartline = exp->locate(); |
208 | break; | 206 | break; |
209 | } | 207 | } |
210 | if (ch == 6) | 208 | if (ch == 6) |
211 | { | 209 | { |
212 | buff->setendpara(cs); | 210 | buff->setendpara(cs); |
213 | buff->setBop(); | 211 | buff->setBop(); |
214 | lastispara = true; | 212 | lastispara = true; |
215 | laststartline = exp->locate(); | 213 | laststartline = exp->locate(); |
216 | break; | 214 | break; |
217 | } | 215 | } |
218 | lastispara = false; | 216 | lastispara = false; |
219 | buff->addch(ch, cs); | 217 | buff->addch(ch, cs); |
220 | if (ch == ' ') | 218 | if (ch == ' ') |
221 | { | 219 | { |
222 | nospaces++; | 220 | nospaces++; |
223 | } | 221 | } |
224 | len++; | 222 | len++; |
225 | if (!margindone) | 223 | if (!margindone) |
226 | { | 224 | { |
227 | w -= buff->leftMargin() + buff->rightMargin(); | 225 | w -= buff->leftMargin() + buff->rightMargin(); |
228 | margindone = true; | 226 | margindone = true; |
229 | } | 227 | } |
230 | #ifdef INCREMENTALWIDTH | 228 | #ifdef INCREMENTALWIDTH |
231 | if ((slen += buff->charwidth(len-1, cs)) > w) | 229 | if ((slen += buff->charwidth(len-1, cs)) > w) |
232 | #else | 230 | #else |
233 | if ((slen = buff->width(availht, len)) > w) | 231 | if ((slen = buff->width(availht, len)) > w) |
234 | #endif | 232 | #endif |
235 | { | 233 | { |
236 | if (ch == ' ' || len == 1) | 234 | if (ch == ' ' || len == 1) |
237 | { | 235 | { |
238 | if (ch == ' ') buff->truncate(len-1); | 236 | if (ch == ' ') buff->truncate(len-1); |
239 | laststartline = exp->locate(); | 237 | laststartline = exp->locate(); |
240 | break; | 238 | break; |
241 | } | 239 | } |
242 | else // should do a backward search for spaces, first. | 240 | else // should do a backward search for spaces, first. |
243 | { | 241 | { |
244 | int lastk = len-4; | 242 | int lastk = len-4; |
245 | for (int i = len-2; i > 0; i--) | 243 | for (int i = len-2; i > 0; i--) |
246 | { | 244 | { |
247 | if ( | 245 | if ( |
248 | (((*buff)[i] == 0x2014) && isletter((*buff)[i+1])) | 246 | (((*buff)[i] == 0x2014) && isletter((*buff)[i+1])) |
249 | || | 247 | || |
250 | ((*buff)[i] == '-') | 248 | ((*buff)[i] == '-') |
251 | // ((*buff)[i] == '-' && !(((*buff)[i-1] == '-') || ((*buff)[i+1] == '-'))) | 249 | // ((*buff)[i] == '-' && !(((*buff)[i-1] == '-') || ((*buff)[i+1] == '-'))) |
252 | ) | 250 | ) |
253 | { | 251 | { |
254 | (*buff)[len] = 0; | 252 | (*buff)[len] = 0; |
255 | lastword.setright(*buff, i+1); | 253 | lastword.setright(*buff, i+1); |
256 | buff->truncate(i+1); | 254 | buff->truncate(i+1); |
257 | (*buff)[i+1] = '\0'; | 255 | (*buff)[i+1] = '\0'; |
258 | laststartline = lastsizes[i+1]; | 256 | laststartline = lastsizes[i+1]; |
259 | // buff->resize(); | 257 | // buff->resize(); |
260 | for (int j = 0; j < lastword.length(); j++) | 258 | for (int j = 0; j < lastword.length(); j++) |
261 | { | 259 | { |
262 | lastsizes[j] = lastsizes[j+i+1]; | 260 | lastsizes[j] = lastsizes[j+i+1]; |
263 | } | 261 | } |
264 | return true; | 262 | return true; |
265 | } | 263 | } |
266 | 264 | ||
267 | //if (hyphenate && (m_hyphenthreshold+1)*i < m_hyphenthreshold*len) | 265 | //if (hyphenate && (m_hyphenthreshold+1)*i < m_hyphenthreshold*len) |
268 | // We end up with i+1 characters instead of len-1 | 266 | // We end up with i+1 characters instead of len-1 |
269 | // Thus we are removing len - 1 - (i + 1) = len-i-2 | 267 | // Thus we are removing len - 1 - (i + 1) = len-i-2 |
270 | // The space characters will be stretched to cover | 268 | // The space characters will be stretched to cover |
271 | // nospaces to nospaces + len - i - 2 | 269 | // nospaces to nospaces + len - i - 2 |
272 | // The stretch factor is hence | 270 | // The stretch factor is hence |
273 | // (nospaces+len-i-2)/nospaces | 271 | // (nospaces+len-i-2)/nospaces |
274 | if (hyphenate && !isCentred && ( 100*(nospaces+len-i-2) > (100+m_hyphenthreshold)*nospaces )) | 272 | if (hyphenate && !isCentred && ( 100*(nospaces+len-i-2) > (100+m_hyphenthreshold)*nospaces )) |
275 | { | 273 | { |
276 | /* | 274 | /* |
277 | if (m_customhyphen) | 275 | if (m_customhyphen) |
278 | { | 276 | { |
279 | for (int k = lastk; k >= i && k >= 2; k--) | 277 | for (int k = lastk; k >= i && k >= 2; k--) |
280 | { | 278 | { |
281 | if ( | 279 | if ( |
282 | isletter((*buff)[k+3]) | 280 | isletter((*buff)[k+3]) |
283 | && | 281 | && |
284 | isletter((*buff)[k+2]) | 282 | isletter((*buff)[k+2]) |
285 | && | 283 | && |
286 | isvowel((*buff)[k+1]) | 284 | isvowel((*buff)[k+1]) |
287 | && | 285 | && |
288 | isconsonant((*buff)[k]) | 286 | isconsonant((*buff)[k]) |
289 | && | 287 | && |
290 | isletter((*buff)[k-1]) | 288 | isletter((*buff)[k-1]) |
291 | && | 289 | && |
292 | isletter((*buff)[k-2]) | 290 | isletter((*buff)[k-2]) |
293 | ) | 291 | ) |
294 | { | 292 | { |
295 | (*buff)[len] = 0; | 293 | (*buff)[len] = 0; |
296 | lastword.setright(*buff, k+1); | 294 | lastword.setright(*buff, k+1); |
297 | buff->truncate(k+2); | 295 | buff->truncate(k+2); |
298 | (*buff)[k+1] = '-'; | 296 | (*buff)[k+1] = '-'; |
299 | (*buff)[k+2] = '\0'; | 297 | (*buff)[k+2] = '\0'; |
300 | laststartline = lastsizes[k+1]; | 298 | laststartline = lastsizes[k+1]; |
301 | buff->resize(); | 299 | buff->resize(); |
302 | for (int j = 0; j < lastword.length(); j++) | 300 | for (int j = 0; j < lastword.length(); j++) |
303 | { | 301 | { |
304 | lastsizes[j] = lastsizes[j+k+1]; | 302 | lastsizes[j] = lastsizes[j+k+1]; |
305 | } | 303 | } |
306 | return true; | 304 | return true; |
307 | } | 305 | } |
308 | } | 306 | } |
309 | } | 307 | } |
310 | else | 308 | else |
311 | */ | 309 | */ |
312 | { | 310 | { |
313 | for (int k = lastk; k >= i && k >= 1; k--) | 311 | for (int k = lastk; k >= i && k >= 1; k--) |
314 | { | 312 | { |
315 | if ( | 313 | if ( |
316 | /* | 314 | /* |
317 | ( | 315 | ( |
318 | k < len-3 | 316 | k < len-3 |
319 | && | 317 | && |
320 | k >= 1 | 318 | k >= 1 |
321 | && | 319 | && |
322 | isletter((*buff)[k+3]) | 320 | isletter((*buff)[k+3]) |
323 | && | 321 | && |
324 | isletter((*buff)[k+2]) | 322 | isletter((*buff)[k+2]) |
325 | && | 323 | && |
326 | isconsonant((*buff)[k+1]) | 324 | isconsonant((*buff)[k+1]) |
327 | && | 325 | && |
328 | ((*buff)[k+1] != 'y') | 326 | ((*buff)[k+1] != 'y') |
329 | && | 327 | && |
330 | ((*buff)[k+1] != 'h') | 328 | ((*buff)[k+1] != 'h') |
331 | && | 329 | && |
332 | isconsonant((*buff)[k]) | 330 | isconsonant((*buff)[k]) |
333 | && | 331 | && |
334 | ((*buff)[k] != 'h') | 332 | ((*buff)[k] != 'h') |
335 | && | 333 | && |
336 | isletter((*buff)[k-1]) | 334 | isletter((*buff)[k-1]) |
337 | ) | 335 | ) |
338 | || | 336 | || |
339 | */ | 337 | */ |
340 | ( | 338 | ( |
341 | isletter((*buff)[k+3]) | 339 | isletter((*buff)[k+3]) |
342 | && | 340 | && |
343 | isletter((*buff)[k+2]) | 341 | isletter((*buff)[k+2]) |
344 | && | 342 | && |
345 | isconsonant((*buff)[k+1]) | 343 | isconsonant((*buff)[k+1]) |
346 | && | 344 | && |
347 | ((*buff)[k+1] != 'y') | 345 | ((*buff)[k+1] != 'y') |
348 | && | 346 | && |
349 | isletter((*buff)[k]) | 347 | isletter((*buff)[k]) |
350 | && | 348 | && |
351 | ((*buff)[k] != 'h') | 349 | ((*buff)[k] != 'h') |
352 | && | 350 | && |
353 | isletter((*buff)[k-1]) | 351 | isletter((*buff)[k-1]) |
354 | && // Do not hyphenate when the first part ends with a vowel, | 352 | && // Do not hyphenate when the first part ends with a vowel, |
355 | // and the second starts with the two consonants. | 353 | // and the second starts with the two consonants. |
356 | // Examples: "co-nsona-nts" -> "con-sonants", | 354 | // Examples: "co-nsona-nts" -> "con-sonants", |
357 | // "hy-phenation" -> "hyp-henation" etc. | 355 | // "hy-phenation" -> "hyp-henation" etc. |
358 | !( isvowel( (*buff)[k] ) && isconsonant( (*buff)[k+2] ) ) | 356 | !( isvowel( (*buff)[k] ) && isconsonant( (*buff)[k+2] ) ) |
359 | ) | 357 | ) |
360 | ) | 358 | ) |
361 | { | 359 | { |
362 | (*buff)[len] = 0; | 360 | (*buff)[len] = 0; |
363 | lastword.setright(*buff, k+1); | 361 | lastword.setright(*buff, k+1); |
364 | buff->truncate(k+2); | 362 | buff->truncate(k+2); |
365 | (*buff)[k+1] = '-'; | 363 | (*buff)[k+1] = '-'; |
366 | (*buff)[k+2] = '\0'; | 364 | (*buff)[k+2] = '\0'; |
367 | laststartline = lastsizes[k+1]; | 365 | laststartline = lastsizes[k+1]; |
368 | // buff->resize(); | 366 | // buff->resize(); |
369 | for (int j = 0; j < lastword.length(); j++) | 367 | for (int j = 0; j < lastword.length(); j++) |
370 | { | 368 | { |
371 | lastsizes[j] = lastsizes[j+k+1]; | 369 | lastsizes[j] = lastsizes[j+k+1]; |
372 | } | 370 | } |
373 | return true; | 371 | return true; |
374 | } | 372 | } |
375 | } | 373 | } |
376 | } | 374 | } |
377 | lastk = i; | 375 | lastk = i; |
378 | } | 376 | } |
379 | if ((*buff)[i] == ' ') | 377 | if ((*buff)[i] == ' ') |
380 | { | 378 | { |
381 | (*buff)[len] = 0; | 379 | (*buff)[len] = 0; |
382 | lastword.setright(*buff, i+1); | 380 | lastword.setright(*buff, i+1); |
383 | buff->truncate(i); | 381 | buff->truncate(i); |
384 | (*buff)[i] = '\0'; | 382 | (*buff)[i] = '\0'; |
385 | laststartline = lastsizes[i+1]; | 383 | laststartline = lastsizes[i+1]; |
386 | // buff->resize(); | 384 | // buff->resize(); |
387 | for (int j = 0; j < lastword.length(); j++) | 385 | for (int j = 0; j < lastword.length(); j++) |
388 | { | 386 | { |
389 | lastsizes[j] = lastsizes[j+i+1]; | 387 | lastsizes[j] = lastsizes[j+i+1]; |
390 | } | 388 | } |
391 | return true; | 389 | return true; |
392 | } | 390 | } |
393 | } | 391 | } |
394 | laststartline = lastsizes[len-1]; | 392 | laststartline = lastsizes[len-1]; |
395 | (*buff)[len] = 0; | 393 | (*buff)[len] = 0; |
396 | lastword.setright(*buff, len - 1); | 394 | lastword.setright(*buff, len - 1); |
397 | buff->truncate(len-1); | 395 | buff->truncate(len-1); |
398 | buff->addch('-', cs); | 396 | buff->addch('-', cs); |
399 | for (int j = 0; j < lastword.length(); j++) | 397 | for (int j = 0; j < lastword.length(); j++) |
400 | { | 398 | { |
401 | lastsizes[j] = lastsizes[j+len]; | 399 | lastsizes[j] = lastsizes[j+len]; |
402 | } | 400 | } |
403 | break; | 401 | break; |
404 | } | 402 | } |
405 | } | 403 | } |
406 | } | 404 | } |
407 | (*buff)[len] = '\0'; | 405 | (*buff)[len] = '\0'; |
408 | // buff->resize(); | 406 | // buff->resize(); |
409 | return moreleft; | 407 | return moreleft; |
410 | } | 408 | } |
411 | #else | 409 | #else |
412 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned short _lborder, unsigned short _rborder) | 410 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned short _lborder, unsigned short _rborder) |
413 | { | 411 | { |
414 | bool margindone = false; | 412 | bool margindone = false; |
415 | int w = wth-(_lborder+_rborder); | 413 | int w = wth-(_lborder+_rborder); |
416 | tchar ch = 32; | 414 | tchar ch = 32; |
417 | CStyle cs; | 415 | CStyle cs; |
418 | buff->empty(); | 416 | buff->empty(); |
419 | if (exp == NULL) | 417 | if (exp == NULL) |
420 | { | 418 | { |
421 | //(*buff)[0] = '\0'; | 419 | //(*buff)[0] = '\0'; |
422 | buff->empty(); | 420 | buff->empty(); |
423 | return false; | 421 | return false; |
424 | } | 422 | } |
425 | int len = 0, lastcheck = 0; | 423 | int len = 0, lastcheck = 0; |
426 | if (lastword.length() > 0) | 424 | if (lastword.length() > 0) |
427 | { | 425 | { |
428 | *buff = lastword; | 426 | *buff = lastword; |
429 | cs = lastword.laststyle(); | 427 | cs = lastword.laststyle(); |
430 | w -= buff->leftMargin() + buff->rightMargin(); | 428 | w -= buff->leftMargin() + buff->rightMargin(); |
431 | margindone = true; | 429 | margindone = true; |
432 | } | 430 | } |
433 | else buff->empty(); | 431 | else buff->empty(); |
434 | // //qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); | 432 | // //qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); |
435 | lastcheck = len = buff->length(); | 433 | lastcheck = len = buff->length(); |
436 | unsigned int slen = buff->width(availht, len); | 434 | unsigned int slen = buff->width(availht, len); |
437 | if (slen > w) | 435 | if (slen > w) |
438 | { | 436 | { |
439 | for ( ; len > 1; len--) | 437 | for ( ; len > 1; len--) |
440 | { | 438 | { |
441 | if (buff->width(availht, len) < w) break; | 439 | if (buff->width(availht, len) < w) break; |
442 | } | 440 | } |
443 | // lastword = buff->data() + len - 1; | 441 | // lastword = buff->data() + len - 1; |
444 | laststartline = lastsizes[len-1]; | 442 | laststartline = lastsizes[len-1]; |
445 | for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1]; | 443 | for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1]; |
446 | // (*buff)[len-1] = '-'; | 444 | // (*buff)[len-1] = '-'; |
447 | if (len > 2) | 445 | if (len > 2) |
448 | { | 446 | { |
449 | lastword.setright(*buff, len - 1); | 447 | lastword.setright(*buff, len - 1); |
450 | buff->truncate(len-1); | 448 | buff->truncate(len-1); |
451 | buff->addch('-', cs); | 449 | buff->addch('-', cs); |
452 | (*buff)[len] = '\0'; | 450 | (*buff)[len] = '\0'; |
453 | } | 451 | } |
454 | 452 | ||
455 | else | 453 | else |
456 | { | 454 | { |
457 | lastword.empty(); | 455 | lastword.empty(); |
458 | (*buff)[len] = '\0'; | 456 | (*buff)[len] = '\0'; |
459 | } | 457 | } |
460 | // buff->resize(); | 458 | // buff->resize(); |
461 | return true; | 459 | return true; |
462 | } | 460 | } |
463 | if (lastispara) | 461 | if (lastispara) |
464 | { | 462 | { |
465 | lastispara = false; | 463 | lastispara = false; |
466 | // lastword[0] = '\0'; | 464 | // lastword[0] = '\0'; |
467 | lastword.empty(); | 465 | lastword.empty(); |
468 | len = buff->length(); | 466 | len = buff->length(); |
469 | while (buff->width(availht, len) > w) len--; | 467 | while (buff->width(availht, len) > w) len--; |
470 | // (*buff)[len] = '\0'; | 468 | // (*buff)[len] = '\0'; |
471 | buff->truncate(len); | 469 | buff->truncate(len); |
472 | laststartline = exp->locate(); | 470 | laststartline = exp->locate(); |
473 | // buff->resize(); | 471 | // buff->resize(); |
474 | return true; | 472 | return true; |
475 | } | 473 | } |
476 | lastispara = false; | 474 | lastispara = false; |
477 | for (int i = 0; i < len; i++) allsizes[i] = lastsizes[i]; | 475 | for (int i = 0; i < len; i++) allsizes[i] = lastsizes[i]; |
478 | while (slen < w) | 476 | while (slen < w) |
479 | { | 477 | { |
480 | lastcheck = len; | 478 | lastcheck = len; |
481 | getch(ch, cs, allsizes[len]); | 479 | getch(ch, cs, allsizes[len]); |
482 | while (ch != ' ' && ch != '\012' && ch != UEOF && len < 128) | 480 | while (ch != ' ' && ch != '\012' && ch != UEOF && len < 128) |
483 | { | 481 | { |
484 | len++; | 482 | len++; |
485 | buff->addch(ch,cs); | 483 | buff->addch(ch,cs); |
486 | getch(ch, cs, allsizes[len]); | 484 | getch(ch, cs, allsizes[len]); |
487 | } | 485 | } |
488 | (*buff)[len] = 0; | 486 | (*buff)[len] = 0; |
489 | slen = buff->width(availht, len); | 487 | slen = buff->width(availht, len); |
490 | len++; | 488 | len++; |
491 | buff->addch(' ', cs); | 489 | buff->addch(' ', cs); |
492 | if (!margindone) | 490 | if (!margindone) |
493 | { | 491 | { |
494 | w -= buff->leftMargin() + buff->rightMargin(); | 492 | w -= buff->leftMargin() + buff->rightMargin(); |
495 | margindone = true; | 493 | margindone = true; |
496 | } | 494 | } |
497 | allsizes[len] = exp->locate(); | 495 | allsizes[len] = exp->locate(); |
498 | if (slen < w && ch != ' ') | 496 | if (slen < w && ch != ' ') |
499 | { | 497 | { |
500 | lastcheck = len; | 498 | lastcheck = len; |
501 | break; | 499 | break; |
502 | } | 500 | } |
503 | lastispara = (ch == '\012'); | 501 | lastispara = (ch == '\012'); |
504 | } | 502 | } |
505 | (*buff)[len] = '\0'; | 503 | (*buff)[len] = '\0'; |
506 | // lastword = buff->data()+lastcheck; | 504 | // lastword = buff->data()+lastcheck; |
507 | #ifdef _WINDOWS | 505 | #ifdef _WINDOWS |
508 | lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); | 506 | lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); |
509 | { | 507 | { |
510 | int i; | 508 | int i; |
511 | for (i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; | 509 | for (i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; |
512 | } | 510 | } |
513 | #else | 511 | #else |
514 | lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); | 512 | lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); |
515 | for (int i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; | 513 | for (int i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; |
516 | #endif | 514 | #endif |
517 | if (lastcheck > 0) | 515 | if (lastcheck > 0) |
518 | { | 516 | { |
519 | laststartline = allsizes[lastcheck]; | 517 | laststartline = allsizes[lastcheck]; |
520 | // (*buff)[lastcheck-1] = '\0'; | 518 | // (*buff)[lastcheck-1] = '\0'; |
521 | buff->truncate(lastcheck-1); | 519 | buff->truncate(lastcheck-1); |
522 | } | 520 | } |
523 | else | 521 | else |
524 | { | 522 | { |
525 | laststartline = (lastcheck == len) ? exp->locate() : allsizes[lastcheck+1]; | 523 | laststartline = (lastcheck == len) ? exp->locate() : allsizes[lastcheck+1]; |
526 | // (*buff)[lastcheck] = '\0'; | 524 | // (*buff)[lastcheck] = '\0'; |
527 | buff->truncate(lastcheck); | 525 | buff->truncate(lastcheck); |
528 | } | 526 | } |
529 | // buff->frig(); | 527 | // buff->frig(); |
530 | // buff->resize(); | 528 | // buff->resize(); |
531 | if (ch == UEOF && buff->length() == 0) | 529 | if (ch == UEOF && buff->length() == 0) |
532 | { | 530 | { |
533 | buff->setEof(); | 531 | buff->setEof(); |
534 | return false; | 532 | return false; |
535 | } | 533 | } |
536 | return true; | 534 | return true; |
537 | } | 535 | } |
538 | #endif | 536 | #endif |
539 | 537 | ||
540 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw, unsigned short _lborder, unsigned short _rborder, int availht) | 538 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw, unsigned short _lborder, unsigned short _rborder, int availht) |
541 | { | 539 | { |
542 | int w = wth-(_lborder+_rborder); | 540 | int w = wth-(_lborder+_rborder); |
543 | buff->empty(); | 541 | buff->empty(); |
544 | if (exp == NULL) | 542 | if (exp == NULL) |
545 | { | 543 | { |
546 | return false; | 544 | return false; |
547 | } | 545 | } |
548 | tchar ch; | 546 | tchar ch; |
549 | CStyle cs; | 547 | CStyle cs; |
550 | int i = 1; | 548 | int i = 1; |
551 | int offset = buff->offset(w,0,0,availht); | 549 | int offset = buff->offset(w,0,0,availht); |
552 | while (i*cw < w-offset) | 550 | while (i*cw < w-offset) |
553 | { | 551 | { |
554 | unsigned long dummy; | 552 | unsigned long dummy; |
555 | getch(ch, cs, dummy); | 553 | getch(ch, cs, dummy); |
556 | if (ch == '\12' || ch == UEOF) break; | 554 | if (ch == '\12' || ch == UEOF) break; |
557 | buff->addch(ch,cs); | 555 | buff->addch(ch,cs); |
558 | i++; | 556 | i++; |
559 | } | 557 | } |
560 | buff->truncate(i); | 558 | buff->truncate(i); |
561 | laststartline = exp->locate(); | 559 | laststartline = exp->locate(); |
562 | // buff->resize(); | 560 | // buff->resize(); |
563 | return (ch != UEOF); | 561 | return (ch != UEOF); |
564 | } | 562 | } |
565 | 563 | ||
566 | int BuffDoc::openfile(QWidget* _parent, const char *src) | 564 | int BuffDoc::openfile(QWidget* _parent, const char *src) |
567 | { | 565 | { |
568 | if (exp != NULL) delete exp; | 566 | if (exp != NULL) delete exp; |
569 | exp = NULL; | 567 | exp = NULL; |
570 | 568 | ||
571 | #ifdef __STATIC | 569 | #ifdef __STATIC |
572 | exp = new Aportis; | 570 | exp = new Aportis; |
573 | int ret = exp->openfile(src); | 571 | int ret = exp->openfile(src); |
574 | if (ret == -1) | 572 | if (ret == -1) |
575 | { | 573 | { |
576 | delete exp; | 574 | delete exp; |
577 | exp = NULL; | 575 | exp = NULL; |
578 | return ret; | 576 | return ret; |
579 | } | 577 | } |
580 | if (ret == -2) | 578 | if (ret == -2) |
581 | { | 579 | { |
582 | 580 | ||
583 | delete exp; | 581 | delete exp; |
584 | exp = new ztxt; | 582 | exp = new ztxt; |
585 | ret = exp->openfile(src); | 583 | ret = exp->openfile(src); |
586 | } | 584 | } |
587 | /* | 585 | /* |
588 | } | 586 | } |
589 | if (ret != 0) | 587 | if (ret != 0) |
590 | { | 588 | { |
591 | delete exp; | 589 | delete exp; |
592 | exp = new ebookcodec("Aportis"); | 590 | exp = new ebookcodec("Aportis"); |
593 | ret = exp->openfile(src); | 591 | ret = exp->openfile(src); |
594 | if (ret == 0) qDebug("Aportis format"); | 592 | if (ret == 0) qDebug("Aportis format"); |
595 | } | 593 | } |
596 | */ | 594 | */ |
597 | #ifdef USENEF | 595 | #ifdef USENEF |
598 | if (ret != 0) | 596 | if (ret != 0) |
599 | { | 597 | { |
600 | 598 | ||
601 | delete exp; | 599 | delete exp; |
602 | exp = new CArriere; | 600 | exp = new CArriere; |
603 | ret = exp->openfile(src); | 601 | ret = exp->openfile(src); |
604 | if (ret == 0) qDebug("Arriere format"); | 602 | if (ret == 0) qDebug("Arriere format"); |
605 | } | 603 | } |
606 | if (ret != 0) | 604 | if (ret != 0) |
607 | { | 605 | { |
608 | 606 | ||
609 | delete exp; | 607 | delete exp; |
610 | exp = new CNEF; | 608 | exp = new CNEF; |
611 | ret = exp->openfile(src); | 609 | ret = exp->openfile(src); |
612 | if (ret == 0) qDebug("NEF format"); | 610 | if (ret == 0) qDebug("NEF format"); |
613 | } | 611 | } |
614 | #endif | 612 | #endif |
615 | if (ret != 0) | 613 | if (ret != 0) |
616 | { | 614 | { |
617 | 615 | ||
618 | delete exp; | 616 | delete exp; |
619 | exp = new CPlucker; | 617 | exp = new CPlucker; |
620 | ret = exp->openfile(src); | 618 | ret = exp->openfile(src); |
621 | } | 619 | } |
622 | if (ret != 0) | 620 | if (ret != 0) |
623 | { | 621 | { |
624 | 622 | ||
625 | delete exp; | 623 | delete exp; |
626 | exp = new CHM; | 624 | exp = new CHM; |
627 | ret = exp->openfile(src); | 625 | ret = exp->openfile(src); |
628 | } | 626 | } |
629 | if (ret != 0) | 627 | if (ret != 0) |
630 | { | 628 | { |
631 | 629 | ||
632 | delete exp; | 630 | delete exp; |
633 | exp = new iSilo; | 631 | exp = new iSilo; |
634 | ret = exp->openfile(src); | 632 | ret = exp->openfile(src); |
635 | } | 633 | } |
636 | if (ret != 0) | 634 | if (ret != 0) |
637 | { | 635 | { |
638 | delete exp; | 636 | delete exp; |
639 | //qDebug("Trying ppms"); | 637 | //qDebug("Trying ppms"); |
640 | exp = new ppm_expander; | 638 | exp = new ppm_expander; |
641 | ret = exp->openfile(src); | 639 | ret = exp->openfile(src); |
642 | } | 640 | } |
643 | if (ret != 0) | 641 | if (ret != 0) |
644 | { | 642 | { |
645 | delete exp; | 643 | delete exp; |
646 | exp = new Text; | 644 | exp = new Text; |
647 | // //qDebug("Trying text"); | 645 | // //qDebug("Trying text"); |
648 | ret = exp->openfile(src); | 646 | ret = exp->openfile(src); |
649 | if (ret == 0) qDebug("Text format"); | 647 | if (ret == 0) qDebug("Text format"); |
650 | } | 648 | } |
651 | 649 | ||
652 | if (ret != 0) | 650 | if (ret != 0) |
653 | { | 651 | { |
654 | delete exp; | 652 | delete exp; |
655 | QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file"); | 653 | QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file"); |
656 | return ret; | 654 | return ret; |
657 | } | 655 | } |
658 | // //qDebug("Doing final open:%x:%x",exp,filt); | 656 | // //qDebug("Doing final open:%x:%x",exp,filt); |
659 | #else | 657 | #else |
660 | QString codecpath(QTReaderUtil::getPluginPath()); | 658 | QString codecpath(QTReaderUtil::getPluginPath()); |
661 | QDir d(codecpath, "*.so"); | 659 | QDir d(codecpath, "*.so"); |
662 | 660 | ||
663 | if (d.exists()) | 661 | if (d.exists()) |
664 | { | 662 | { |
665 | 663 | ||
666 | const QFileInfoList *list = d.entryInfoList(); | 664 | const QFileInfoList *list = d.entryInfoList(); |
667 | QFileInfoListIterator it( *list ); // create list iterator | 665 | QFileInfoListIterator it( *list ); // create list iterator |
668 | QFileInfo *fi; // pointer for traversing | 666 | QFileInfo *fi; // pointer for traversing |
669 | 667 | ||
670 | int ret = -1; | 668 | int ret = -1; |
671 | while ( ret != 0 && (fi=it.current()) ) | 669 | while ( ret != 0 && (fi=it.current()) ) |
672 | { // for each file... | 670 | { // for each file... |
673 | if (exp != NULL) delete exp; | 671 | if (exp != NULL) delete exp; |
674 | qDebug("Trying %s", (const char*)fi->fileName()); | 672 | qDebug("Trying %s", (const char*)fi->fileName()); |
675 | exp = new ebookcodec(fi->fileName()); | 673 | exp = new ebookcodec(fi->fileName()); |
676 | ret = exp->openfile(src); | 674 | ret = exp->openfile(src); |
677 | ++it; | 675 | ++it; |
678 | } | 676 | } |
679 | qDebug("Buffdoc:Finished opening"); | 677 | qDebug("Buffdoc:Finished opening"); |
680 | if (ret != 0) | 678 | if (ret != 0) |
681 | { | 679 | { |
682 | if (exp != NULL) delete exp; | 680 | if (exp != NULL) delete exp; |
683 | exp = new Text; | 681 | exp = new Text; |
684 | ret = exp->openfile(src); | 682 | ret = exp->openfile(src); |
685 | } | 683 | } |
686 | } | 684 | } |
687 | else | 685 | else |
688 | { | 686 | { |
689 | if (exp != NULL) delete exp; | 687 | if (exp != NULL) delete exp; |
690 | exp = new Text; | 688 | exp = new Text; |
691 | exp->openfile(src); | 689 | exp->openfile(src); |
692 | } | 690 | } |
693 | #endif | 691 | #endif |
694 | lastword.empty(); | 692 | lastword.empty(); |
695 | lastsizes[0] = laststartline = 0; | 693 | lastsizes[0] = laststartline = 0; |
696 | #ifdef NEWLINEBREAK | 694 | #ifdef NEWLINEBREAK |
697 | lastispara = false; | 695 | lastispara = false; |
698 | #else | 696 | #else |
699 | lastispara = false; | 697 | lastispara = false; |
700 | #endif | 698 | #endif |
701 | exp->locate(exp->getHome()); | 699 | exp->locate(exp->getHome()); |
702 | filt->setsource(exp); | 700 | filt->setsource(exp); |
703 | qDebug("BuffDoc:file opened"); | 701 | qDebug("BuffDoc:file opened"); |
704 | return 0; | 702 | return 0; |
705 | } | 703 | } |
706 | 704 | ||
707 | QString BuffDoc::about() | 705 | QString BuffDoc::about() |
708 | { | 706 | { |
709 | return QString("Buffered Decompressor (c) Tim Wentford\nHyphenation algorithm (c) Tim Wentford\n (Cyrillic support by Konstantin Isakov\n")+filt->about(); | 707 | return QString("Buffered Decompressor (c) Tim Wentford\nHyphenation algorithm (c) Tim Wentford\n (Cyrillic support by Konstantin Isakov\n")+filt->about(); |
710 | } | 708 | } |
diff --git a/noncore/apps/opie-reader/BuffDoc.h b/noncore/apps/opie-reader/BuffDoc.h index a7dd7bf..2b4fb57 100644 --- a/noncore/apps/opie-reader/BuffDoc.h +++ b/noncore/apps/opie-reader/BuffDoc.h | |||
@@ -1,144 +1,143 @@ | |||
1 | #ifndef __BuffDoc_h | 1 | #ifndef __BuffDoc_h |
2 | #define __BuffDoc_h | 2 | #define __BuffDoc_h |
3 | 3 | ||
4 | #include "useqpe.h" | ||
5 | #include "CDrawBuffer.h" | 4 | #include "CDrawBuffer.h" |
6 | #include "CFilter.h" | 5 | #include "CFilter.h" |
7 | #include "CExpander.h" | 6 | #include "CExpander.h" |
8 | #include <qfontmetrics.h> | 7 | #include <qfontmetrics.h> |
9 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
10 | 9 | ||
11 | class BuffDoc | 10 | class BuffDoc |
12 | { | 11 | { |
13 | CDrawBuffer lastword; | 12 | CDrawBuffer lastword; |
14 | CSizeBuffer lastsizes, allsizes; | 13 | CSizeBuffer lastsizes, allsizes; |
15 | size_t laststartline; | 14 | size_t laststartline; |
16 | bool lastispara; | 15 | bool lastispara; |
17 | CExpander_Interface* exp; | 16 | CExpander_Interface* exp; |
18 | CFilterChain* filt; | 17 | CFilterChain* filt; |
19 | int m_hyphenthreshold; | 18 | int m_hyphenthreshold; |
20 | // bool m_customhyphen; | 19 | // bool m_customhyphen; |
21 | public: | 20 | public: |
22 | QString about(); | 21 | QString about(); |
23 | bool findanchor(const QString& nm) | 22 | bool findanchor(const QString& nm) |
24 | { | 23 | { |
25 | return filt->findanchor(nm); | 24 | return filt->findanchor(nm); |
26 | } | 25 | } |
27 | // void setCustomHyphen(bool _v) { m_customhyphen = _v; } | 26 | // void setCustomHyphen(bool _v) { m_customhyphen = _v; } |
28 | // bool getCustomHyphen() { return m_customhyphen; } | 27 | // bool getCustomHyphen() { return m_customhyphen; } |
29 | void setHyphenThreshold(int _v) { m_hyphenthreshold = _v; } | 28 | void setHyphenThreshold(int _v) { m_hyphenthreshold = _v; } |
30 | 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) |
31 | { | 30 | { |
32 | if (exp == NULL) | 31 | if (exp == NULL) |
33 | { | 32 | { |
34 | data = NULL; | 33 | data = NULL; |
35 | len = 0; | 34 | len = 0; |
36 | } | 35 | } |
37 | else | 36 | else |
38 | { | 37 | { |
39 | exp->setSaveData(data, len, src, srclen); | 38 | exp->setSaveData(data, len, src, srclen); |
40 | } | 39 | } |
41 | } | 40 | } |
42 | void putSaveData(unsigned char*& src, unsigned short& srclen) | 41 | void putSaveData(unsigned char*& src, unsigned short& srclen) |
43 | { | 42 | { |
44 | if (exp != NULL) | 43 | if (exp != NULL) |
45 | { | 44 | { |
46 | exp->putSaveData(src, srclen); | 45 | exp->putSaveData(src, srclen); |
47 | } | 46 | } |
48 | } | 47 | } |
49 | #ifdef USEQPE | 48 | #ifdef USEQPE |
50 | void suspend() { if (exp != NULL) exp->suspend(); } | 49 | void suspend() { if (exp != NULL) exp->suspend(); } |
51 | void unsuspend() { if (exp != NULL) exp->unsuspend(); } | 50 | void unsuspend() { if (exp != NULL) exp->unsuspend(); } |
52 | #else | 51 | #else |
53 | void suspend() {} | 52 | void suspend() {} |
54 | void unsuspend() {} | 53 | void unsuspend() {} |
55 | #endif | 54 | #endif |
56 | ~BuffDoc() | 55 | ~BuffDoc() |
57 | { | 56 | { |
58 | delete filt; | 57 | delete filt; |
59 | delete exp; | 58 | delete exp; |
60 | } | 59 | } |
61 | BuffDoc() | 60 | BuffDoc() |
62 | { | 61 | { |
63 | exp = NULL; | 62 | exp = NULL; |
64 | filt = NULL; | 63 | filt = NULL; |
65 | lastword.empty(); | 64 | lastword.empty(); |
66 | // // qDebug("Buffdoc created"); | 65 | // // qDebug("Buffdoc created"); |
67 | } | 66 | } |
68 | bool empty() { return (exp == NULL); } | 67 | bool empty() { return (exp == NULL); } |
69 | void setfilter(CFilterChain* _f) | 68 | void setfilter(CFilterChain* _f) |
70 | { | 69 | { |
71 | if (filt != NULL) delete filt; | 70 | if (filt != NULL) delete filt; |
72 | filt = _f; | 71 | filt = _f; |
73 | filt->setsource(exp); | 72 | filt->setsource(exp); |
74 | } | 73 | } |
75 | CList<Bkmk>* getbkmklist() { return exp->getbkmklist(); } | 74 | CList<Bkmk>* getbkmklist() { return exp->getbkmklist(); } |
76 | bool hasrandomaccess() { return (exp == NULL) ? false : exp->hasrandomaccess(); } | 75 | bool hasrandomaccess() { return (exp == NULL) ? false : exp->hasrandomaccess(); } |
77 | bool iseol() { return (lastword[0] == '\0'); } | 76 | bool iseol() { return (lastword[0] == '\0'); } |
78 | int openfile(QWidget* _parent, const char *src); | 77 | int openfile(QWidget* _parent, const char *src); |
79 | tchar getch() | 78 | tchar getch() |
80 | { | 79 | { |
81 | tchar ch = UEOF; | 80 | tchar ch = UEOF; |
82 | CStyle sty; | 81 | CStyle sty; |
83 | if (exp != NULL) | 82 | if (exp != NULL) |
84 | { | 83 | { |
85 | unsigned long dummy; | 84 | unsigned long dummy; |
86 | filt->getch(ch, sty, dummy); | 85 | filt->getch(ch, sty, dummy); |
87 | } | 86 | } |
88 | return ch; | 87 | return ch; |
89 | } | 88 | } |
90 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 89 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
91 | { | 90 | { |
92 | if (exp != NULL) | 91 | if (exp != NULL) |
93 | { | 92 | { |
94 | filt->getch(ch, sty, pos); | 93 | filt->getch(ch, sty, pos); |
95 | } | 94 | } |
96 | else | 95 | else |
97 | ch = UEOF; | 96 | ch = UEOF; |
98 | } | 97 | } |
99 | void setwidth(int w) { if (exp != NULL) exp->setwidth(w); } | 98 | void setwidth(int w) { if (exp != NULL) exp->setwidth(w); } |
100 | QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); } | 99 | QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); } |
101 | unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); } | 100 | unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); } |
102 | unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); } | 101 | unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); } |
103 | unsigned int locate() { return (exp == NULL) ? 0 : laststartline; } | 102 | unsigned int locate() { return (exp == NULL) ? 0 : laststartline; } |
104 | unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); } | 103 | unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); } |
105 | void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); } | 104 | void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); } |
106 | MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); } | 105 | MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); } |
107 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); | 106 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); |
108 | size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); } | 107 | size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); } |
109 | void locate(unsigned int n); | 108 | void locate(unsigned int n); |
110 | bool getline(CDrawBuffer* buff, int w, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht); | 109 | bool getline(CDrawBuffer* buff, int w, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht); |
111 | bool getline(CDrawBuffer* buff, int w, int cw, unsigned short _lborder, unsigned short _rborder, int availht); | 110 | bool getline(CDrawBuffer* buff, int w, int cw, unsigned short _lborder, unsigned short _rborder, int availht); |
112 | void sizes(unsigned long& fs, unsigned long& ts) | 111 | void sizes(unsigned long& fs, unsigned long& ts) |
113 | { | 112 | { |
114 | if (exp != NULL) | 113 | if (exp != NULL) |
115 | { | 114 | { |
116 | exp->sizes(fs,ts); | 115 | exp->sizes(fs,ts); |
117 | } | 116 | } |
118 | else | 117 | else |
119 | { | 118 | { |
120 | fs = ts = 0; | 119 | fs = ts = 0; |
121 | } | 120 | } |
122 | } | 121 | } |
123 | int getpara(CBuffer& buff) | 122 | int getpara(CBuffer& buff) |
124 | { | 123 | { |
125 | tchar ch; | 124 | tchar ch; |
126 | int i = 0; | 125 | int i = 0; |
127 | while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch; | 126 | while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch; |
128 | buff[i] = '\0'; | 127 | buff[i] = '\0'; |
129 | if (i == 0 && ch == UEOF) i = -1; | 128 | if (i == 0 && ch == UEOF) i = -1; |
130 | laststartline = exp->locate(); | 129 | laststartline = exp->locate(); |
131 | return i; | 130 | return i; |
132 | } | 131 | } |
133 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } | 132 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } |
134 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } | 133 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } |
135 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } | 134 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } |
136 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } | 135 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } |
137 | bool hasnavigation() { return filt->hasnavigation(); } | 136 | bool hasnavigation() { return filt->hasnavigation(); } |
138 | bool getFile(QString href) | 137 | bool getFile(QString href) |
139 | { | 138 | { |
140 | return (exp == NULL) ? false : exp->getFile(href); | 139 | return (exp == NULL) ? false : exp->getFile(href); |
141 | } | 140 | } |
142 | }; | 141 | }; |
143 | 142 | ||
144 | #endif | 143 | #endif |
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp index caccf1b..bfb3027 100644 --- a/noncore/apps/opie-reader/CDrawBuffer.cpp +++ b/noncore/apps/opie-reader/CDrawBuffer.cpp | |||
@@ -1,863 +1,862 @@ | |||
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 | #include "useqpe.h" | ||
8 | 7 | ||
9 | CDrawBuffer::~CDrawBuffer() | 8 | CDrawBuffer::~CDrawBuffer() |
10 | { | 9 | { |
11 | while (!segs.isEmpty()) segs.erase(0); | 10 | while (!segs.isEmpty()) segs.erase(0); |
12 | } | 11 | } |
13 | 12 | ||
14 | void CDrawBuffer::setright(CDrawBuffer& rhs, int f) | 13 | void CDrawBuffer::setright(CDrawBuffer& rhs, int f) |
15 | { | 14 | { |
16 | int i; | 15 | int i; |
17 | len = rhs.len; | 16 | len = rhs.len; |
18 | fc = rhs.fc; | 17 | fc = rhs.fc; |
19 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; | 18 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
20 | while (!segs.isEmpty()) | 19 | while (!segs.isEmpty()) |
21 | { | 20 | { |
22 | segs.erase(0); | 21 | segs.erase(0); |
23 | } | 22 | } |
24 | 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(); ) |
25 | { | 24 | { |
26 | CList<textsegment>::iterator next = iter; | 25 | CList<textsegment>::iterator next = iter; |
27 | iter++; | 26 | iter++; |
28 | if (iter == rhs.segs.end() || iter->start > f) | 27 | if (iter == rhs.segs.end() || iter->start > f) |
29 | { | 28 | { |
30 | int st = next->start-f; | 29 | int st = next->start-f; |
31 | if (st < 0) st = 0; | 30 | if (st < 0) st = 0; |
32 | 31 | ||
33 | CStyle _style = next->style; | 32 | CStyle _style = next->style; |
34 | segs.push_back(textsegment(st,next->style)); | 33 | segs.push_back(textsegment(st,next->style)); |
35 | } | 34 | } |
36 | } | 35 | } |
37 | 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]; |
38 | (*this)[i-f] = '\0'; | 37 | (*this)[i-f] = '\0'; |
39 | len = i; | 38 | len = i; |
40 | } | 39 | } |
41 | 40 | ||
42 | CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) | 41 | CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) |
43 | { | 42 | { |
44 | int i; | 43 | int i; |
45 | // //qDebug("Trying 2"); | 44 | // //qDebug("Trying 2"); |
46 | len = rhs.len; | 45 | len = rhs.len; |
47 | m_ascent = rhs.m_ascent; | 46 | m_ascent = rhs.m_ascent; |
48 | m_descent = rhs.m_descent; | 47 | m_descent = rhs.m_descent; |
49 | m_lineSpacing = rhs.m_lineSpacing; | 48 | m_lineSpacing = rhs.m_lineSpacing; |
50 | m_lineExtraSpacing = rhs.m_lineExtraSpacing; | 49 | m_lineExtraSpacing = rhs.m_lineExtraSpacing; |
51 | m_showPartial = rhs.m_showPartial; | 50 | m_showPartial = rhs.m_showPartial; |
52 | while (!segs.isEmpty()) | 51 | while (!segs.isEmpty()) |
53 | { | 52 | { |
54 | segs.erase(0); | 53 | segs.erase(0); |
55 | } | 54 | } |
56 | 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++) |
57 | { | 56 | { |
58 | segs.push_back(*iter); | 57 | segs.push_back(*iter); |
59 | } | 58 | } |
60 | for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; | 59 | for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; |
61 | (*this)[i] = '\0'; | 60 | (*this)[i] = '\0'; |
62 | len = i; | 61 | len = i; |
63 | // //qDebug("Tried 2"); | 62 | // //qDebug("Tried 2"); |
64 | return *this; | 63 | return *this; |
65 | } | 64 | } |
66 | 65 | ||
67 | CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) | 66 | CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) |
68 | { | 67 | { |
69 | int i; | 68 | int i; |
70 | while (!segs.isEmpty()) | 69 | while (!segs.isEmpty()) |
71 | { | 70 | { |
72 | segs.erase(0); | 71 | segs.erase(0); |
73 | } | 72 | } |
74 | segs.push_back(textsegment(0, CStyle())); | 73 | segs.push_back(textsegment(0, CStyle())); |
75 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; | 74 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; |
76 | (*this)[i] = '\0'; | 75 | (*this)[i] = '\0'; |
77 | len = i; | 76 | len = i; |
78 | return *this; | 77 | return *this; |
79 | } | 78 | } |
80 | 79 | ||
81 | void CDrawBuffer::empty() | 80 | void CDrawBuffer::empty() |
82 | { | 81 | { |
83 | m_bSop = false; | 82 | m_bSop = false; |
84 | m_bEop = false; | 83 | m_bEop = false; |
85 | m_bBop = false; | 84 | m_bBop = false; |
86 | len = 0; | 85 | len = 0; |
87 | (*this)[0] = 0; | 86 | (*this)[0] = 0; |
88 | while (!segs.isEmpty()) | 87 | while (!segs.isEmpty()) |
89 | { | 88 | { |
90 | segs.erase(0); | 89 | segs.erase(0); |
91 | } | 90 | } |
92 | segs.push_back(textsegment(0,CStyle())); | 91 | segs.push_back(textsegment(0,CStyle())); |
93 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; | 92 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
94 | m_bEof = false; | 93 | m_bEof = false; |
95 | } | 94 | } |
96 | 95 | ||
97 | void CDrawBuffer::setendpara(const CStyle& _style/* = ucFontBase*/) | 96 | void CDrawBuffer::setendpara(const CStyle& _style/* = ucFontBase*/) |
98 | { | 97 | { |
99 | m_bEop = true; | 98 | m_bEop = true; |
100 | if (len == 0) | 99 | if (len == 0) |
101 | { | 100 | { |
102 | segs.first().start = 0; | 101 | segs.first().start = 0; |
103 | segs.first().style = _style; | 102 | segs.first().style = _style; |
104 | } | 103 | } |
105 | } | 104 | } |
106 | 105 | ||
107 | void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) | 106 | void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) |
108 | { | 107 | { |
109 | if (len == 0) | 108 | if (len == 0) |
110 | { | 109 | { |
111 | segs.first().start = 0; | 110 | segs.first().start = 0; |
112 | segs.first().style = _style; | 111 | segs.first().style = _style; |
113 | } | 112 | } |
114 | else if (_style != segs.last().style) | 113 | else if (_style != segs.last().style) |
115 | { | 114 | { |
116 | segs.push_back(textsegment(len, _style)); | 115 | segs.push_back(textsegment(len, _style)); |
117 | } | 116 | } |
118 | (*this)[len++] = ch; | 117 | (*this)[len++] = ch; |
119 | } | 118 | } |
120 | 119 | ||
121 | void CDrawBuffer::truncate(int n) | 120 | void CDrawBuffer::truncate(int n) |
122 | { | 121 | { |
123 | len = n; | 122 | len = n; |
124 | (*this)[n] = 0; | 123 | (*this)[n] = 0; |
125 | } | 124 | } |
126 | 125 | ||
127 | 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) |
128 | { | 127 | { |
129 | int gzoom = fc->gzoom(); | 128 | int gzoom = fc->gzoom(); |
130 | int currentx = 0, end = 0; | 129 | int currentx = 0, end = 0; |
131 | QString text = (numchars < 0) ? toQString(data()) : toQString(data(), numchars); | 130 | QString text = (numchars < 0) ? toQString(data()) : toQString(data(), numchars); |
132 | CList<textsegment>::iterator textstart = segs.begin(); | 131 | CList<textsegment>::iterator textstart = segs.begin(); |
133 | int extraspace = 0; | 132 | int extraspace = 0; |
134 | bool just = (onscreen && !m_bEop && textstart->style.getJustify() == m_AlignJustify); | 133 | bool just = (onscreen && !m_bEop && textstart->style.getJustify() == m_AlignJustify); |
135 | int spaces = 0; | 134 | int spaces = 0; |
136 | int spacesofar = 0; | 135 | int spacesofar = 0; |
137 | int spacenumber = 0; | 136 | int spacenumber = 0; |
138 | int nonspace = 0; | 137 | int nonspace = 0; |
139 | if (just) | 138 | if (just) |
140 | { | 139 | { |
141 | for (int i = 0; i < len; i++) | 140 | for (int i = 0; i < len; i++) |
142 | { | 141 | { |
143 | if ((*this)[i] != ' ') | 142 | if ((*this)[i] != ' ') |
144 | { | 143 | { |
145 | nonspace = i; | 144 | nonspace = i; |
146 | break; | 145 | break; |
147 | } | 146 | } |
148 | } | 147 | } |
149 | #ifdef _WINDOWS | 148 | #ifdef _WINDOWS |
150 | for (i = nonspace; i < len; i++) | 149 | for (i = nonspace; i < len; i++) |
151 | #else | 150 | #else |
152 | for (int i = nonspace; i < len; i++) | 151 | for (int i = nonspace; i < len; i++) |
153 | #endif | 152 | #endif |
154 | { | 153 | { |
155 | if ((*this)[i] == ' ') | 154 | if ((*this)[i] == ' ') |
156 | { | 155 | { |
157 | spaces++; | 156 | spaces++; |
158 | } | 157 | } |
159 | } | 158 | } |
160 | if (spaces == 0) | 159 | if (spaces == 0) |
161 | { | 160 | { |
162 | just = false; | 161 | just = false; |
163 | } | 162 | } |
164 | else | 163 | else |
165 | { | 164 | { |
166 | extraspace = (scwidth - (_lborder+_rborder) - rightMargin() - leftMargin() - width(availht)); | 165 | extraspace = (scwidth - (_lborder+_rborder) - rightMargin() - leftMargin() - width(availht)); |
167 | if (extraspace == 0) just = false; | 166 | if (extraspace == 0) just = false; |
168 | } | 167 | } |
169 | } | 168 | } |
170 | CList<textsegment>::iterator textend = textstart; | 169 | CList<textsegment>::iterator textend = textstart; |
171 | do | 170 | do |
172 | { | 171 | { |
173 | textend++; | 172 | textend++; |
174 | end = (textend != segs.end()) ? textend->start : len; | 173 | end = (textend != segs.end()) ? textend->start : len; |
175 | if (numchars >= 0 && end > numchars) | 174 | if (numchars >= 0 && end > numchars) |
176 | { | 175 | { |
177 | end = numchars; | 176 | end = numchars; |
178 | } | 177 | } |
179 | CStyle currentstyle = textstart->style; | 178 | CStyle currentstyle = textstart->style; |
180 | if (currentstyle.isPicture()) | 179 | if (currentstyle.isPicture()) |
181 | { | 180 | { |
182 | if (currentstyle.canScale()) | 181 | if (currentstyle.canScale()) |
183 | { | 182 | { |
184 | int ht = (gzoom*currentstyle.getPicture()->height())/100; | 183 | int ht = (gzoom*currentstyle.getPicture()->height())/100; |
185 | int wt = (gzoom*currentstyle.getPicture()->width())/100; | 184 | int wt = (gzoom*currentstyle.getPicture()->width())/100; |
186 | if (ht > availht) | 185 | if (ht > availht) |
187 | { | 186 | { |
188 | wt = (wt*availht)/ht; | 187 | wt = (wt*availht)/ht; |
189 | } | 188 | } |
190 | currentx += wt; | 189 | currentx += wt; |
191 | } | 190 | } |
192 | else | 191 | else |
193 | { | 192 | { |
194 | currentx += currentstyle.getPicture()->width(); | 193 | currentx += currentstyle.getPicture()->width(); |
195 | } | 194 | } |
196 | } | 195 | } |
197 | else | 196 | else |
198 | { | 197 | { |
199 | if (currentstyle.isMono() && !fc->hasCourier()) | 198 | if (currentstyle.isMono() && !fc->hasCourier()) |
200 | { | 199 | { |
201 | int cw = (7*fc->getsize(currentstyle))/10; | 200 | int cw = (7*fc->getsize(currentstyle))/10; |
202 | currentx += cw*(end-textstart->start); | 201 | currentx += cw*(end-textstart->start); |
203 | } | 202 | } |
204 | else | 203 | else |
205 | { | 204 | { |
206 | 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()) ); |
207 | // f.setUnderline(currentstyle.isUnderline()); | 206 | // f.setUnderline(currentstyle.isUnderline()); |
208 | QString str = text.mid(textstart->start, end-textstart->start); | 207 | QString str = text.mid(textstart->start, end-textstart->start); |
209 | QFontMetrics fm(f); | 208 | QFontMetrics fm(f); |
210 | if (just) | 209 | if (just) |
211 | { | 210 | { |
212 | int lastspace = -1; | 211 | int lastspace = -1; |
213 | int nsp = 0; | 212 | int nsp = 0; |
214 | int cx = currentx; | 213 | int cx = currentx; |
215 | while ((nsp = str.find(" ", lastspace+1)) >= 0) | 214 | while ((nsp = str.find(" ", lastspace+1)) >= 0) |
216 | { | 215 | { |
217 | if (nsp > nonspace) | 216 | if (nsp > nonspace) |
218 | { | 217 | { |
219 | spacenumber++; | 218 | spacenumber++; |
220 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; | 219 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; |
221 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 220 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
222 | int lw = fm.width(nstr); | 221 | int lw = fm.width(nstr); |
223 | cx += lw+nexttoadd; | 222 | cx += lw+nexttoadd; |
224 | spacesofar += nexttoadd; | 223 | spacesofar += nexttoadd; |
225 | lastspace = nsp; | 224 | lastspace = nsp; |
226 | } | 225 | } |
227 | else | 226 | else |
228 | { | 227 | { |
229 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 228 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
230 | // 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); |
231 | int lw = fm.width(nstr); | 230 | int lw = fm.width(nstr); |
232 | cx += lw; | 231 | cx += lw; |
233 | lastspace = nsp; | 232 | lastspace = nsp; |
234 | } | 233 | } |
235 | } | 234 | } |
236 | QString nstr = str.right(str.length()-1-lastspace); | 235 | QString nstr = str.right(str.length()-1-lastspace); |
237 | cx += fm.width(nstr); | 236 | cx += fm.width(nstr); |
238 | currentx = cx; | 237 | currentx = cx; |
239 | } | 238 | } |
240 | else | 239 | else |
241 | { | 240 | { |
242 | currentx += fm.width(str); | 241 | currentx += fm.width(str); |
243 | } | 242 | } |
244 | } | 243 | } |
245 | } | 244 | } |
246 | textstart = textend; | 245 | textstart = textend; |
247 | } | 246 | } |
248 | while (textend != segs.end() && end != numchars && textstart->start < len); | 247 | while (textend != segs.end() && end != numchars && textstart->start < len); |
249 | return currentx; | 248 | return currentx; |
250 | } | 249 | } |
251 | 250 | ||
252 | int CDrawBuffer::charwidth(int numchars, CStyle& currentstyle) | 251 | int CDrawBuffer::charwidth(int numchars, CStyle& currentstyle) |
253 | { | 252 | { |
254 | if (currentstyle.isPicture()) | 253 | if (currentstyle.isPicture()) |
255 | { | 254 | { |
256 | int gzoom = fc->gzoom(); | 255 | int gzoom = fc->gzoom(); |
257 | if (currentstyle.canScale()) | 256 | if (currentstyle.canScale()) |
258 | { | 257 | { |
259 | return (gzoom*currentstyle.getPicture()->width())/100; | 258 | return (gzoom*currentstyle.getPicture()->width())/100; |
260 | } | 259 | } |
261 | else | 260 | else |
262 | { | 261 | { |
263 | return currentstyle.getPicture()->width(); | 262 | return currentstyle.getPicture()->width(); |
264 | } | 263 | } |
265 | } | 264 | } |
266 | else | 265 | else |
267 | { | 266 | { |
268 | if (currentstyle.isMono() && !fc->hasCourier()) | 267 | if (currentstyle.isMono() && !fc->hasCourier()) |
269 | { | 268 | { |
270 | return (7*fc->getsize(currentstyle))/10; | 269 | return (7*fc->getsize(currentstyle))/10; |
271 | } | 270 | } |
272 | else | 271 | else |
273 | { | 272 | { |
274 | QString text = QChar((data())[numchars]); | 273 | QString text = QChar((data())[numchars]); |
275 | 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()) ); |
276 | // f.setUnderline(currentstyle.isUnderline()); | 275 | // f.setUnderline(currentstyle.isUnderline()); |
277 | QFontMetrics fm(f); | 276 | QFontMetrics fm(f); |
278 | return fm.width(text); | 277 | return fm.width(text); |
279 | } | 278 | } |
280 | } | 279 | } |
281 | return 0; | 280 | return 0; |
282 | } | 281 | } |
283 | 282 | ||
284 | int CDrawBuffer::charwidth(int numchars) | 283 | int CDrawBuffer::charwidth(int numchars) |
285 | { | 284 | { |
286 | int gzoom = fc->gzoom(); | 285 | int gzoom = fc->gzoom(); |
287 | int end = 0; | 286 | int end = 0; |
288 | QString text = QChar((data())[numchars]); | 287 | QString text = QChar((data())[numchars]); |
289 | CList<textsegment>::iterator textstart = segs.begin(); | 288 | CList<textsegment>::iterator textstart = segs.begin(); |
290 | CList<textsegment>::iterator textend = textstart; | 289 | CList<textsegment>::iterator textend = textstart; |
291 | do | 290 | do |
292 | { | 291 | { |
293 | textend++; | 292 | textend++; |
294 | end = (textend != segs.end()) ? textend->start : len; | 293 | end = (textend != segs.end()) ? textend->start : len; |
295 | if (end <= numchars) | 294 | if (end <= numchars) |
296 | { | 295 | { |
297 | textstart = textend; | 296 | textstart = textend; |
298 | continue; | 297 | continue; |
299 | } | 298 | } |
300 | if (numchars >= 0 && end > numchars) | 299 | if (numchars >= 0 && end > numchars) |
301 | { | 300 | { |
302 | end = numchars; | 301 | end = numchars; |
303 | } | 302 | } |
304 | CStyle currentstyle = textstart->style; | 303 | CStyle currentstyle = textstart->style; |
305 | if (currentstyle.isPicture()) | 304 | if (currentstyle.isPicture()) |
306 | { | 305 | { |
307 | if (currentstyle.canScale()) | 306 | if (currentstyle.canScale()) |
308 | { | 307 | { |
309 | return (gzoom*currentstyle.getPicture()->width())/100; | 308 | return (gzoom*currentstyle.getPicture()->width())/100; |
310 | } | 309 | } |
311 | else | 310 | else |
312 | { | 311 | { |
313 | return currentstyle.getPicture()->width(); | 312 | return currentstyle.getPicture()->width(); |
314 | } | 313 | } |
315 | } | 314 | } |
316 | else | 315 | else |
317 | { | 316 | { |
318 | if (currentstyle.isMono() && !fc->hasCourier()) | 317 | if (currentstyle.isMono() && !fc->hasCourier()) |
319 | { | 318 | { |
320 | return (7*fc->getsize(currentstyle))/10; | 319 | return (7*fc->getsize(currentstyle))/10; |
321 | } | 320 | } |
322 | else | 321 | else |
323 | { | 322 | { |
324 | 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()) ); |
325 | // f.setUnderline(currentstyle.isUnderline()); | 324 | // f.setUnderline(currentstyle.isUnderline()); |
326 | QFontMetrics fm(f); | 325 | QFontMetrics fm(f); |
327 | return fm.width(text); | 326 | return fm.width(text); |
328 | } | 327 | } |
329 | } | 328 | } |
330 | textstart = textend; | 329 | textstart = textend; |
331 | } | 330 | } |
332 | while (textend != segs.end() /* && end != numchars*/ && textstart->start < len); | 331 | while (textend != segs.end() /* && end != numchars*/ && textstart->start < len); |
333 | return 0; | 332 | return 0; |
334 | } | 333 | } |
335 | 334 | ||
336 | 335 | ||
337 | 336 | ||
338 | int CDrawBuffer::leftMargin() | 337 | int CDrawBuffer::leftMargin() |
339 | { | 338 | { |
340 | 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; |
341 | } | 340 | } |
342 | 341 | ||
343 | int CDrawBuffer::rightMargin() | 342 | int CDrawBuffer::rightMargin() |
344 | { | 343 | { |
345 | 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; |
346 | } | 345 | } |
347 | 346 | ||
348 | 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) |
349 | { | 348 | { |
350 | int currentx = _lborder; | 349 | int currentx = _lborder; |
351 | switch(segs.begin()->style.getJustify()) | 350 | switch(segs.begin()->style.getJustify()) |
352 | { | 351 | { |
353 | case m_AlignRight: | 352 | case m_AlignRight: |
354 | { | 353 | { |
355 | currentx = scwidth - _rborder - rightMargin() - width(availht); | 354 | currentx = scwidth - _rborder - rightMargin() - width(availht); |
356 | } | 355 | } |
357 | break; | 356 | break; |
358 | case m_AlignCentre: | 357 | case m_AlignCentre: |
359 | { | 358 | { |
360 | currentx = ( | 359 | currentx = ( |
361 | scwidth - _lborder -_rborder + | 360 | scwidth - _lborder -_rborder + |
362 | leftMargin() - rightMargin() | 361 | leftMargin() - rightMargin() |
363 | - width(availht))/2 + _lborder; | 362 | - width(availht))/2 + _lborder; |
364 | } | 363 | } |
365 | break; | 364 | break; |
366 | case m_AlignJustify: | 365 | case m_AlignJustify: |
367 | case m_AlignLeft: | 366 | case m_AlignLeft: |
368 | currentx = _lborder + leftMargin(); | 367 | currentx = _lborder + leftMargin(); |
369 | break; | 368 | break; |
370 | } | 369 | } |
371 | return currentx; | 370 | return currentx; |
372 | } | 371 | } |
373 | 372 | ||
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) | 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) |
375 | { | 374 | { |
376 | CList<textsegment>::iterator textstart = segs.begin(); | 375 | CList<textsegment>::iterator textstart = segs.begin(); |
377 | QColor paperColour = QColor(qRgb(textstart->style.pRed(), | 376 | QColor paperColour = QColor(qRgb(textstart->style.pRed(), |
378 | textstart->style.pGreen(), | 377 | textstart->style.pGreen(), |
379 | textstart->style.pBlue())); | 378 | textstart->style.pBlue())); |
380 | 379 | ||
381 | Highlight(_p, !(paperColour == _bg), _lborder, _y, scwidth-(_lborder+_rborder), paperColour); | 380 | Highlight(_p, !(paperColour == _bg), _lborder, _y, scwidth-(_lborder+_rborder), paperColour); |
382 | // Highlight(_p, true, _lborder, _y, scwidth-(_lborder+_rborder), paperColour); | 381 | // Highlight(_p, true, _lborder, _y, scwidth-(_lborder+_rborder), paperColour); |
383 | int gzoom = fc->gzoom(); | 382 | int gzoom = fc->gzoom(); |
384 | int currentx = offset(scwidth, _lborder, _rborder, availht); | 383 | int currentx = offset(scwidth, _lborder, _rborder, availht); |
385 | if (!m_hastext) | 384 | if (!m_hastext) |
386 | { | 385 | { |
387 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); iter++) | 386 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); iter++) |
388 | { | 387 | { |
389 | CStyle currentstyle = iter->style; | 388 | CStyle currentstyle = iter->style; |
390 | if (currentstyle.isPicture()) | 389 | if (currentstyle.isPicture()) |
391 | { | 390 | { |
392 | CStyle currentstyle = segs.begin()->style; | 391 | CStyle currentstyle = segs.begin()->style; |
393 | int ht = (gzoom*currentstyle.getPicture()->height())/100; | 392 | int ht = (gzoom*currentstyle.getPicture()->height())/100; |
394 | int wt = (gzoom*currentstyle.getPicture()->width())/100; | 393 | int wt = (gzoom*currentstyle.getPicture()->width())/100; |
395 | bool willscale = false; | 394 | bool willscale = false; |
396 | if (ht > availht) | 395 | if (ht > availht) |
397 | { | 396 | { |
398 | wt = (wt*availht)/ht; | 397 | wt = (wt*availht)/ht; |
399 | ht = availht; | 398 | ht = availht; |
400 | willscale = true; | 399 | willscale = true; |
401 | } | 400 | } |
402 | 401 | ||
403 | QPixmap pc; | 402 | QPixmap pc; |
404 | if ((willscale || gzoom != 100) && currentstyle.canScale()) | 403 | if ((willscale || gzoom != 100) && currentstyle.canScale()) |
405 | { | 404 | { |
406 | QImage im = currentstyle.getPicture()->smoothScale(wt,ht); | 405 | QImage im = currentstyle.getPicture()->smoothScale(wt,ht); |
407 | pc.convertFromImage(im); | 406 | pc.convertFromImage(im); |
408 | } | 407 | } |
409 | else | 408 | else |
410 | { | 409 | { |
411 | pc.convertFromImage(*currentstyle.getPicture()); | 410 | pc.convertFromImage(*currentstyle.getPicture()); |
412 | } | 411 | } |
413 | int yoffset = pc.height()/2; | 412 | int yoffset = pc.height()/2; |
414 | _p->drawPixmap( currentx, _y-yoffset, pc ); | 413 | _p->drawPixmap( currentx, _y-yoffset, pc ); |
415 | currentx += pc.width(); | 414 | currentx += pc.width(); |
416 | } | 415 | } |
417 | } | 416 | } |
418 | return; | 417 | return; |
419 | } | 418 | } |
420 | QString text = toQString(data()); | 419 | QString text = toQString(data()); |
421 | int extraspace = 0; | 420 | int extraspace = 0; |
422 | bool just = (!m_bEop && textstart->style.getJustify() == m_AlignJustify); | 421 | bool just = (!m_bEop && textstart->style.getJustify() == m_AlignJustify); |
423 | int spaces = 0; | 422 | int spaces = 0; |
424 | int spacesofar = 0; | 423 | int spacesofar = 0; |
425 | int spacenumber = 0; | 424 | int spacenumber = 0; |
426 | int nonspace = 0; | 425 | int nonspace = 0; |
427 | if (just) | 426 | if (just) |
428 | { | 427 | { |
429 | for (int i = 0; i < len; i++) | 428 | for (int i = 0; i < len; i++) |
430 | { | 429 | { |
431 | if ((*this)[i] != ' ') | 430 | if ((*this)[i] != ' ') |
432 | { | 431 | { |
433 | nonspace = i; | 432 | nonspace = i; |
434 | break; | 433 | break; |
435 | } | 434 | } |
436 | } | 435 | } |
437 | #ifdef _WINDOWS | 436 | #ifdef _WINDOWS |
438 | for (i = nonspace; i < len; i++) | 437 | for (i = nonspace; i < len; i++) |
439 | #else | 438 | #else |
440 | for (int i = nonspace; i < len; i++) | 439 | for (int i = nonspace; i < len; i++) |
441 | #endif | 440 | #endif |
442 | { | 441 | { |
443 | if ((*this)[i] == ' ') | 442 | if ((*this)[i] == ' ') |
444 | { | 443 | { |
445 | spaces++; | 444 | spaces++; |
446 | } | 445 | } |
447 | } | 446 | } |
448 | if (spaces == 0) | 447 | if (spaces == 0) |
449 | { | 448 | { |
450 | just = false; | 449 | just = false; |
451 | } | 450 | } |
452 | else | 451 | else |
453 | { | 452 | { |
454 | extraspace = (scwidth - (_lborder+_rborder) - rightMargin() - leftMargin() - width(availht)); | 453 | extraspace = (scwidth - (_lborder+_rborder) - rightMargin() - leftMargin() - width(availht)); |
455 | if (extraspace == 0) just = false; | 454 | if (extraspace == 0) just = false; |
456 | } | 455 | } |
457 | } | 456 | } |
458 | CList<textsegment>::iterator textend = textstart; | 457 | CList<textsegment>::iterator textend = textstart; |
459 | 458 | ||
460 | bool drawBackground = false; | 459 | bool drawBackground = false; |
461 | do | 460 | do |
462 | { | 461 | { |
463 | textend++; | 462 | textend++; |
464 | int end = (textend != segs.end()) ? textend->start : len; | 463 | int end = (textend != segs.end()) ? textend->start : len; |
465 | CStyle currentstyle = textstart->style; | 464 | CStyle currentstyle = textstart->style; |
466 | /* | 465 | /* |
467 | bool drawBackground = ( | 466 | bool drawBackground = ( |
468 | currentstyle.bRed() != 255 | 467 | currentstyle.bRed() != 255 |
469 | || | 468 | || |
470 | currentstyle.bGreen() != 255 | 469 | currentstyle.bGreen() != 255 |
471 | || | 470 | || |
472 | currentstyle.bBlue() != 255 | 471 | currentstyle.bBlue() != 255 |
473 | ); | 472 | ); |
474 | */ | 473 | */ |
475 | QColor bgColour = QColor(qRgb(currentstyle.bRed(), | 474 | QColor bgColour = QColor(qRgb(currentstyle.bRed(), |
476 | currentstyle.bGreen(), | 475 | currentstyle.bGreen(), |
477 | currentstyle.bBlue())); | 476 | currentstyle.bBlue())); |
478 | drawBackground = !(bgColour == _bg); | 477 | drawBackground = !(bgColour == _bg); |
479 | 478 | ||
480 | // if (drawBackground) qDebug("Drawing background"); | 479 | // if (drawBackground) qDebug("Drawing background"); |
481 | 480 | ||
482 | QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 481 | QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
483 | //f.setUnderline(currentstyle.isUnderline()); | 482 | //f.setUnderline(currentstyle.isUnderline()); |
484 | //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); | 483 | //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); |
485 | _p->setFont(f); | 484 | _p->setFont(f); |
486 | QString str = text.mid(textstart->start, end-textstart->start); | 485 | QString str = text.mid(textstart->start, end-textstart->start); |
487 | #if defined(OPIE) || !defined(USEQPE) | 486 | #if defined(OPIE) || !defined(USEQPE) |
488 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100)); | 487 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100)); |
489 | #else | 488 | #else |
490 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); | 489 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); |
491 | #endif | 490 | #endif |
492 | int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2; | 491 | int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2; |
493 | 492 | ||
494 | if (_bMono) | 493 | if (_bMono) |
495 | { | 494 | { |
496 | 495 | ||
497 | Highlight(_p, drawBackground, currentx, _y, str.length()*_charWidth, bgColour); | 496 | Highlight(_p, drawBackground, currentx, _y, str.length()*_charWidth, bgColour); |
498 | if (currentstyle.isUnderline()) | 497 | if (currentstyle.isUnderline()) |
499 | { | 498 | { |
500 | _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset); | 499 | _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset); |
501 | } | 500 | } |
502 | if (currentstyle.isStrikethru()) | 501 | if (currentstyle.isStrikethru()) |
503 | { | 502 | { |
504 | int ascent = fc->ascent(currentstyle)/3; | 503 | int ascent = fc->ascent(currentstyle)/3; |
505 | _p->drawLine( currentx, _y-ascent+voffset, currentx + str.length()*_charWidth, _y-ascent+voffset); | 504 | _p->drawLine( currentx, _y-ascent+voffset, currentx + str.length()*_charWidth, _y-ascent+voffset); |
506 | } | 505 | } |
507 | for (int i = 0; i < str.length(); i++) | 506 | for (int i = 0; i < str.length(); i++) |
508 | { | 507 | { |
509 | _p->drawText( currentx + i*_charWidth, _y+voffset, QString(str[i])); | 508 | _p->drawText( currentx + i*_charWidth, _y+voffset, QString(str[i])); |
510 | } | 509 | } |
511 | currentx += str.length()*_charWidth; | 510 | currentx += str.length()*_charWidth; |
512 | } | 511 | } |
513 | else | 512 | else |
514 | { | 513 | { |
515 | if (currentstyle.isPicture()) | 514 | if (currentstyle.isPicture()) |
516 | { | 515 | { |
517 | int ht = (gzoom*currentstyle.getPicture()->height())/100; | 516 | int ht = (gzoom*currentstyle.getPicture()->height())/100; |
518 | int wt = (gzoom*currentstyle.getPicture()->width())/100; | 517 | int wt = (gzoom*currentstyle.getPicture()->width())/100; |
519 | bool willscale = false; | 518 | bool willscale = false; |
520 | if (ht > availht) | 519 | if (ht > availht) |
521 | { | 520 | { |
522 | wt = (wt*availht)/ht; | 521 | wt = (wt*availht)/ht; |
523 | ht = availht; | 522 | ht = availht; |
524 | willscale = true; | 523 | willscale = true; |
525 | } | 524 | } |
526 | int ascent = fc->ascent(currentstyle)/2; | 525 | int ascent = fc->ascent(currentstyle)/2; |
527 | int yoffset = ht/2 + ascent; | 526 | int yoffset = ht/2 + ascent; |
528 | 527 | ||
529 | QPixmap pc; | 528 | QPixmap pc; |
530 | if ((willscale || gzoom != 100) && currentstyle.canScale()) | 529 | if ((willscale || gzoom != 100) && currentstyle.canScale()) |
531 | { | 530 | { |
532 | QImage im = currentstyle.getPicture()->smoothScale(wt,ht); | 531 | QImage im = currentstyle.getPicture()->smoothScale(wt,ht); |
533 | pc.convertFromImage(im); | 532 | pc.convertFromImage(im); |
534 | } | 533 | } |
535 | else | 534 | else |
536 | { | 535 | { |
537 | pc.convertFromImage(*currentstyle.getPicture()); | 536 | pc.convertFromImage(*currentstyle.getPicture()); |
538 | } | 537 | } |
539 | _p->drawPixmap( currentx, _y-yoffset, pc ); | 538 | _p->drawPixmap( currentx, _y-yoffset, pc ); |
540 | currentx += wt; | 539 | currentx += wt; |
541 | } | 540 | } |
542 | else | 541 | else |
543 | { | 542 | { |
544 | if (currentstyle.isMono() && !fc->hasCourier()) | 543 | if (currentstyle.isMono() && !fc->hasCourier()) |
545 | { | 544 | { |
546 | int cw = (7*fc->getsize(currentstyle))/10; | 545 | int cw = (7*fc->getsize(currentstyle))/10; |
547 | int w = cw*(end-textstart->start); | 546 | int w = cw*(end-textstart->start); |
548 | Highlight(_p, drawBackground, currentx, _y, w, bgColour); | 547 | Highlight(_p, drawBackground, currentx, _y, w, bgColour); |
549 | if (currentstyle.isUnderline()) | 548 | if (currentstyle.isUnderline()) |
550 | { | 549 | { |
551 | _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset); | 550 | _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset); |
552 | } | 551 | } |
553 | if (currentstyle.isStrikethru()) | 552 | if (currentstyle.isStrikethru()) |
554 | { | 553 | { |
555 | int ascent = fc->ascent(currentstyle)/3; | 554 | int ascent = fc->ascent(currentstyle)/3; |
556 | _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset); | 555 | _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset); |
557 | } | 556 | } |
558 | QString str = text.mid(textstart->start, end-textstart->start); | 557 | QString str = text.mid(textstart->start, end-textstart->start); |
559 | 558 | ||
560 | for (unsigned int i = 0; i < str.length(); i++) | 559 | for (unsigned int i = 0; i < str.length(); i++) |
561 | { | 560 | { |
562 | #ifdef _WINDOWS | 561 | #ifdef _WINDOWS |
563 | _p->drawText( currentx, _y+voffset, QString(str.at(i))); | 562 | _p->drawText( currentx, _y+voffset, QString(str.at(i))); |
564 | #else | 563 | #else |
565 | _p->drawText( currentx, _y+voffset, QString(str[i])); | 564 | _p->drawText( currentx, _y+voffset, QString(str[i])); |
566 | #endif | 565 | #endif |
567 | currentx += cw; | 566 | currentx += cw; |
568 | } | 567 | } |
569 | } | 568 | } |
570 | else | 569 | else |
571 | { | 570 | { |
572 | QFontMetrics fm(f); | 571 | QFontMetrics fm(f); |
573 | int w; | 572 | int w; |
574 | if (just) | 573 | if (just) |
575 | { | 574 | { |
576 | int lastspace = -1; | 575 | int lastspace = -1; |
577 | int nsp = 0; | 576 | int nsp = 0; |
578 | int cx = currentx; | 577 | int cx = currentx; |
579 | while ((nsp = str.find(" ", lastspace+1)) >= 0) | 578 | while ((nsp = str.find(" ", lastspace+1)) >= 0) |
580 | { | 579 | { |
581 | if (nsp+textstart->start >= nonspace) | 580 | if (nsp+textstart->start >= nonspace) |
582 | { | 581 | { |
583 | spacenumber++; | 582 | spacenumber++; |
584 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; | 583 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; |
585 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 584 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
586 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); | 585 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); |
587 | int lw = fm.width(nstr); | 586 | int lw = fm.width(nstr); |
588 | Highlight(_p, drawBackground, cx, _y, lw, bgColour); | 587 | Highlight(_p, drawBackground, cx, _y, lw, bgColour); |
589 | _p->drawText( cx, _y+voffset, nstr); | 588 | _p->drawText( cx, _y+voffset, nstr); |
590 | Highlight(_p, drawBackground, cx+lw, _y, nexttoadd, bgColour); | 589 | Highlight(_p, drawBackground, cx+lw, _y, nexttoadd, bgColour); |
591 | cx += lw+nexttoadd; | 590 | cx += lw+nexttoadd; |
592 | spacesofar += nexttoadd; | 591 | spacesofar += nexttoadd; |
593 | lastspace = nsp; | 592 | lastspace = nsp; |
594 | } | 593 | } |
595 | else | 594 | else |
596 | { | 595 | { |
597 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 596 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
598 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); | 597 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); |
599 | int lw = fm.width(nstr); | 598 | int lw = fm.width(nstr); |
600 | Highlight(_p, drawBackground, cx, _y, lw, bgColour); | 599 | Highlight(_p, drawBackground, cx, _y, lw, bgColour); |
601 | _p->drawText( cx, _y+voffset, nstr); | 600 | _p->drawText( cx, _y+voffset, nstr); |
602 | cx += lw; | 601 | cx += lw; |
603 | lastspace = nsp; | 602 | lastspace = nsp; |
604 | } | 603 | } |
605 | } | 604 | } |
606 | QString nstr = str.right(str.length()-1-lastspace); | 605 | QString nstr = str.right(str.length()-1-lastspace); |
607 | int lw = fm.width(nstr); | 606 | int lw = fm.width(nstr); |
608 | Highlight(_p, drawBackground, cx, _y, lw, bgColour); | 607 | Highlight(_p, drawBackground, cx, _y, lw, bgColour); |
609 | _p->drawText( cx, _y+voffset, nstr); | 608 | _p->drawText( cx, _y+voffset, nstr); |
610 | cx += lw; | 609 | cx += lw; |
611 | w = cx - currentx; | 610 | w = cx - currentx; |
612 | } | 611 | } |
613 | else | 612 | else |
614 | { | 613 | { |
615 | int lw = fm.width(str); | 614 | int lw = fm.width(str); |
616 | Highlight(_p, drawBackground, currentx, _y, lw, bgColour); | 615 | Highlight(_p, drawBackground, currentx, _y, lw, bgColour); |
617 | _p->drawText( currentx, _y+voffset, str); | 616 | _p->drawText( currentx, _y+voffset, str); |
618 | w = lw; | 617 | w = lw; |
619 | } | 618 | } |
620 | if (currentstyle.isUnderline()) | 619 | if (currentstyle.isUnderline()) |
621 | { | 620 | { |
622 | _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset); | 621 | _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset); |
623 | } | 622 | } |
624 | if (currentstyle.isStrikethru()) | 623 | if (currentstyle.isStrikethru()) |
625 | { | 624 | { |
626 | int ascent = fc->ascent(currentstyle)/3; | 625 | int ascent = fc->ascent(currentstyle)/3; |
627 | _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset); | 626 | _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset); |
628 | } | 627 | } |
629 | currentx += w; | 628 | currentx += w; |
630 | } | 629 | } |
631 | } | 630 | } |
632 | } | 631 | } |
633 | textstart = textend; | 632 | textstart = textend; |
634 | } | 633 | } |
635 | while (textend != segs.end() && textstart->start < len); | 634 | while (textend != segs.end() && textstart->start < len); |
636 | /* | 635 | /* |
637 | if (firstColour == bgColour) | 636 | if (firstColour == bgColour) |
638 | { | 637 | { |
639 | Highlight(_p, drawBackground, currentx, _y, scwidth - (currentx + _lborder + _rborder), bgColour); | 638 | Highlight(_p, drawBackground, currentx, _y, scwidth - (currentx + _lborder + _rborder), bgColour); |
640 | } | 639 | } |
641 | */ | 640 | */ |
642 | } | 641 | } |
643 | 642 | ||
644 | void CDrawBuffer::Highlight(QPainter* _p, bool drawBackground, int _x, int _y, int w, QColor bgColour) | 643 | void CDrawBuffer::Highlight(QPainter* _p, bool drawBackground, int _x, int _y, int w, QColor bgColour) |
645 | { | 644 | { |
646 | if (drawBackground) | 645 | if (drawBackground) |
647 | { | 646 | { |
648 | _p->fillRect(_x, _y-m_ascent, w, m_lineSpacing, bgColour); | 647 | _p->fillRect(_x, _y-m_ascent, w, m_lineSpacing, bgColour); |
649 | } | 648 | } |
650 | } | 649 | } |
651 | 650 | ||
652 | CStyle CDrawBuffer::laststyle() | 651 | CStyle CDrawBuffer::laststyle() |
653 | { | 652 | { |
654 | return segs.last().style; | 653 | return segs.last().style; |
655 | } | 654 | } |
656 | 655 | ||
657 | CStyle CDrawBuffer::firststyle() | 656 | CStyle CDrawBuffer::firststyle() |
658 | { | 657 | { |
659 | return segs.first().style; | 658 | return segs.first().style; |
660 | } | 659 | } |
661 | 660 | ||
662 | linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*& img) | 661 | linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*& img) |
663 | { | 662 | { |
664 | linkType ret = eNone; | 663 | linkType ret = eNone; |
665 | int end = 0; | 664 | int end = 0; |
666 | CStyle currentstyle; | 665 | CStyle currentstyle; |
667 | CList<textsegment>::iterator textstart = segs.begin(); | 666 | CList<textsegment>::iterator textstart = segs.begin(); |
668 | CList<textsegment>::iterator textend = textstart; | 667 | CList<textsegment>::iterator textend = textstart; |
669 | do | 668 | do |
670 | { | 669 | { |
671 | textend++; | 670 | textend++; |
672 | end = (textend != segs.end()) ? textend->start : len; | 671 | end = (textend != segs.end()) ? textend->start : len; |
673 | currentstyle = textstart->style; | 672 | currentstyle = textstart->style; |
674 | /* | 673 | /* |
675 | if (currentstyle.isPicture()) qDebug("Passed thru picture"); | 674 | if (currentstyle.isPicture()) qDebug("Passed thru picture"); |
676 | if (currentstyle.getLink()) qDebug("Passed thru link"); | 675 | if (currentstyle.getLink()) qDebug("Passed thru link"); |
677 | //qDebug("islink:%d - %d", numchars, end); | 676 | //qDebug("islink:%d - %d", numchars, end); |
678 | */ | 677 | */ |
679 | textstart = textend; | 678 | textstart = textend; |
680 | } | 679 | } |
681 | while (textend != segs.end() && end <= numchars); | 680 | while (textend != segs.end() && end <= numchars); |
682 | img = currentstyle.getPicture(); | 681 | img = currentstyle.getPicture(); |
683 | if (currentstyle.getPictureLink()) | 682 | if (currentstyle.getPictureLink()) |
684 | { | 683 | { |
685 | pictgt = currentstyle.getPictureLinkData(); | 684 | pictgt = currentstyle.getPictureLinkData(); |
686 | ret |= ePicture; | 685 | ret |= ePicture; |
687 | } | 686 | } |
688 | if (currentstyle.getLink()) | 687 | if (currentstyle.getLink()) |
689 | { | 688 | { |
690 | tgt = currentstyle.getData(); | 689 | tgt = currentstyle.getData(); |
691 | offset = currentstyle.getOffset(); | 690 | offset = currentstyle.getOffset(); |
692 | ret |= eLink; | 691 | ret |= eLink; |
693 | } | 692 | } |
694 | return ret; | 693 | return ret; |
695 | } | 694 | } |
696 | 695 | ||
697 | void CDrawBuffer::resize(int availht) | 696 | void CDrawBuffer::resize(int availht) |
698 | { | 697 | { |
699 | int gzoom = fc->gzoom(); | 698 | int gzoom = fc->gzoom(); |
700 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; | 699 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
701 | /* | 700 | /* |
702 | int t_ascent = 0; | 701 | int t_ascent = 0; |
703 | int t_descent = 0; | 702 | int t_descent = 0; |
704 | int t_lineExtraSpacing = 0; | 703 | int t_lineExtraSpacing = 0; |
705 | */ | 704 | */ |
706 | int t_lineSpacing = 0; | 705 | int t_lineSpacing = 0; |
707 | m_hastext = false; | 706 | m_hastext = false; |
708 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) | 707 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) |
709 | { | 708 | { |
710 | CStyle _style = iter->style; | 709 | CStyle _style = iter->style; |
711 | if (!_style.isPicture()) | 710 | if (!_style.isPicture()) |
712 | { | 711 | { |
713 | m_hastext = true; | 712 | m_hastext = true; |
714 | break; | 713 | break; |
715 | } | 714 | } |
716 | iter++; | 715 | iter++; |
717 | } | 716 | } |
718 | if (m_hastext) | 717 | if (m_hastext) |
719 | { | 718 | { |
720 | 719 | ||
721 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) | 720 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) |
722 | { | 721 | { |
723 | CList<textsegment>::iterator next = iter; | 722 | CList<textsegment>::iterator next = iter; |
724 | iter++; | 723 | iter++; |
725 | int st = next->start; | 724 | int st = next->start; |
726 | if (st < 0) st = 0; | 725 | if (st < 0) st = 0; |
727 | 726 | ||
728 | CStyle _style = next->style; | 727 | CStyle _style = next->style; |
729 | 728 | ||
730 | int linespacing, ascent, descent, extra; | 729 | int linespacing, ascent, descent, extra; |
731 | 730 | ||
732 | ascent = fc->ascent(_style); | 731 | ascent = fc->ascent(_style); |
733 | descent = fc->descent(_style); | 732 | descent = fc->descent(_style); |
734 | linespacing = fc->lineSpacing(_style); | 733 | linespacing = fc->lineSpacing(_style); |
735 | extra = linespacing - ascent - descent; | 734 | extra = linespacing - ascent - descent; |
736 | /* | 735 | /* |
737 | if (ascent > t_ascent) t_ascent = ascent; | 736 | if (ascent > t_ascent) t_ascent = ascent; |
738 | if (descent > t_descent) t_descent = descent; | 737 | if (descent > t_descent) t_descent = descent; |
739 | if (extra > t_lineExtraSpacing) t_lineExtraSpacing = extra; | 738 | if (extra > t_lineExtraSpacing) t_lineExtraSpacing = extra; |
740 | t_lineSpacing = t_ascent+t_descent+t_lineExtraSpacing; | 739 | t_lineSpacing = t_ascent+t_descent+t_lineExtraSpacing; |
741 | */ | 740 | */ |
742 | if (linespacing > t_lineSpacing) t_lineSpacing = linespacing; | 741 | if (linespacing > t_lineSpacing) t_lineSpacing = linespacing; |
743 | if (_style.isPicture()) | 742 | if (_style.isPicture()) |
744 | { | 743 | { |
745 | int ht = (gzoom*_style.getPicture()->height())/100; | 744 | int ht = (gzoom*_style.getPicture()->height())/100; |
746 | int wt = (gzoom*_style.getPicture()->width())/100; | 745 | int wt = (gzoom*_style.getPicture()->width())/100; |
747 | 746 | ||
748 | bool willscale = false; | 747 | bool willscale = false; |
749 | if (ht > availht) | 748 | if (ht > availht) |
750 | { | 749 | { |
751 | wt = (wt*availht)/ht; | 750 | wt = (wt*availht)/ht; |
752 | ht = availht; | 751 | ht = availht; |
753 | willscale = true; | 752 | willscale = true; |
754 | } | 753 | } |
755 | if (willscale || _style.canScale()) | 754 | if (willscale || _style.canScale()) |
756 | { | 755 | { |
757 | descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2; | 756 | descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2; |
758 | ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2; | 757 | ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2; |
759 | } | 758 | } |
760 | } | 759 | } |
761 | 760 | ||
762 | /* | 761 | /* |
763 | else if (fc != NULL) | 762 | else if (fc != NULL) |
764 | { | 763 | { |
765 | ascent = fc->ascent(_style); | 764 | ascent = fc->ascent(_style); |
766 | descent = fc->descent(_style); | 765 | descent = fc->descent(_style); |
767 | linespacing = fc->lineSpacing(_style); | 766 | linespacing = fc->lineSpacing(_style); |
768 | extra = linespacing - ascent - descent; | 767 | extra = linespacing - ascent - descent; |
769 | } | 768 | } |
770 | */ | 769 | */ |
771 | if (ascent > m_ascent) m_ascent = ascent; | 770 | if (ascent > m_ascent) m_ascent = ascent; |
772 | if (descent > m_descent) m_descent = descent; | 771 | if (descent > m_descent) m_descent = descent; |
773 | if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; | 772 | if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; |
774 | m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; | 773 | m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; |
775 | } | 774 | } |
776 | m_showPartial = (m_lineSpacing > t_lineSpacing); | 775 | m_showPartial = (m_lineSpacing > t_lineSpacing); |
777 | int lead = fc->getlead(); | 776 | int lead = fc->getlead(); |
778 | if (lead != 0) | 777 | if (lead != 0) |
779 | { | 778 | { |
780 | int xt = (lead*t_lineSpacing+5)/10; | 779 | int xt = (lead*t_lineSpacing+5)/10; |
781 | m_lineExtraSpacing += xt; | 780 | m_lineExtraSpacing += xt; |
782 | m_lineSpacing += xt; | 781 | m_lineSpacing += xt; |
783 | } | 782 | } |
784 | if (m_bSop) | 783 | if (m_bSop) |
785 | { | 784 | { |
786 | int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10; | 785 | int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10; |
787 | //qDebug("ExtraSpace:%d", xt); | 786 | //qDebug("ExtraSpace:%d", xt); |
788 | m_ascent += xt; | 787 | m_ascent += xt; |
789 | m_lineSpacing += xt; | 788 | m_lineSpacing += xt; |
790 | } | 789 | } |
791 | } | 790 | } |
792 | else | 791 | else |
793 | { | 792 | { |
794 | m_showPartial = true; | 793 | m_showPartial = true; |
795 | int maxheight = 0; | 794 | int maxheight = 0; |
796 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); iter++) | 795 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); iter++) |
797 | { | 796 | { |
798 | CStyle _style = iter->style; | 797 | CStyle _style = iter->style; |
799 | if (_style.isPicture()) | 798 | if (_style.isPicture()) |
800 | { | 799 | { |
801 | int ht = 0; | 800 | int ht = 0; |
802 | if (_style.canScale()) | 801 | if (_style.canScale()) |
803 | { | 802 | { |
804 | ht = ((gzoom*_style.getPicture()->height())/100); | 803 | ht = ((gzoom*_style.getPicture()->height())/100); |
805 | } | 804 | } |
806 | else | 805 | else |
807 | { | 806 | { |
808 | ht = _style.getPicture()->height(); | 807 | ht = _style.getPicture()->height(); |
809 | } | 808 | } |
810 | if (ht > availht) | 809 | if (ht > availht) |
811 | { | 810 | { |
812 | ht = availht; | 811 | ht = availht; |
813 | } | 812 | } |
814 | if (ht > maxheight) maxheight = ht; | 813 | if (ht > maxheight) maxheight = ht; |
815 | } | 814 | } |
816 | } | 815 | } |
817 | m_ascent = maxheight/2; | 816 | m_ascent = maxheight/2; |
818 | m_descent = maxheight-m_ascent; | 817 | m_descent = maxheight-m_ascent; |
819 | m_lineExtraSpacing = 0; | 818 | m_lineExtraSpacing = 0; |
820 | m_lineSpacing = m_ascent+m_descent; | 819 | m_lineSpacing = m_ascent+m_descent; |
821 | } | 820 | } |
822 | } | 821 | } |
823 | 822 | ||
824 | CStyle* CDrawBuffer::getNextLink(int& offset) | 823 | CStyle* CDrawBuffer::getNextLink(int& offset) |
825 | { | 824 | { |
826 | CStyle* ret = NULL; | 825 | CStyle* ret = NULL; |
827 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); ++iter) | 826 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); ++iter) |
828 | { | 827 | { |
829 | if (offset < iter->start && iter->style.getLink()) | 828 | if (offset < iter->start && iter->style.getLink()) |
830 | { | 829 | { |
831 | ret = &(iter->style); | 830 | ret = &(iter->style); |
832 | offset = iter->start; | 831 | offset = iter->start; |
833 | qDebug("Found a link at offset %d!", offset); | 832 | qDebug("Found a link at offset %d!", offset); |
834 | break; | 833 | break; |
835 | } | 834 | } |
836 | } | 835 | } |
837 | return ret; | 836 | return ret; |
838 | } | 837 | } |
839 | 838 | ||
840 | int CDrawBuffer::invertLink(int offset) | 839 | int CDrawBuffer::invertLink(int offset) |
841 | { | 840 | { |
842 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); ++iter) | 841 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); ++iter) |
843 | { | 842 | { |
844 | if (offset <= iter->start && iter->style.getLink()) | 843 | if (offset <= iter->start && iter->style.getLink()) |
845 | { | 844 | { |
846 | iter->style.invert(); | 845 | iter->style.invert(); |
847 | unsigned long currentvalue = iter->style.getData(); | 846 | unsigned long currentvalue = iter->style.getData(); |
848 | qDebug("Link data %u", currentvalue); | 847 | qDebug("Link data %u", currentvalue); |
849 | CList<textsegment>::iterator next = iter; | 848 | CList<textsegment>::iterator next = iter; |
850 | ++next; | 849 | ++next; |
851 | while (next != segs.end() && (currentvalue == next->style.getData()) && next->style.getLink()) | 850 | while (next != segs.end() && (currentvalue == next->style.getData()) && next->style.getLink()) |
852 | { | 851 | { |
853 | next->style.invert(); | 852 | next->style.invert(); |
854 | offset = next->start; | 853 | offset = next->start; |
855 | iter++; | 854 | iter++; |
856 | next++; | 855 | next++; |
857 | } | 856 | } |
858 | return offset; | 857 | return offset; |
859 | } | 858 | } |
860 | } | 859 | } |
861 | qDebug("Failed to invert"); | 860 | qDebug("Failed to invert"); |
862 | return offset; | 861 | return offset; |
863 | } | 862 | } |
diff --git a/noncore/apps/opie-reader/CExpander.h b/noncore/apps/opie-reader/CExpander.h index e9aaf79..7fa84f9 100644 --- a/noncore/apps/opie-reader/CExpander.h +++ b/noncore/apps/opie-reader/CExpander.h | |||
@@ -1,149 +1,148 @@ | |||
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 "useqpe.h" | ||
12 | #include "config.h" | 11 | #include "config.h" |
13 | #include "StyleConsts.h" | 12 | #include "StyleConsts.h" |
14 | #include "Markups.h" | 13 | #include "Markups.h" |
15 | #include "names.h" | 14 | #include "names.h" |
16 | #include "linktype.h" | 15 | #include "linktype.h" |
17 | 16 | ||
18 | class QImage; | 17 | class QImage; |
19 | class Bkmk; | 18 | class Bkmk; |
20 | class QString; | 19 | class QString; |
21 | 20 | ||
22 | template<class T> | 21 | template<class T> |
23 | class CList; | 22 | class CList; |
24 | 23 | ||
25 | class CCharacterSource | 24 | class CCharacterSource |
26 | { | 25 | { |
27 | public: | 26 | public: |
28 | virtual void getch(tchar&, CStyle&, unsigned long&) = 0; | 27 | virtual void getch(tchar&, CStyle&, unsigned long&) = 0; |
29 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString&, QString& nm) = 0; | 28 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString&, QString& nm) = 0; |
30 | virtual void locate(unsigned int n) = 0; | 29 | virtual void locate(unsigned int n) = 0; |
31 | virtual bool findanchor(const QString& nm) = 0; | 30 | virtual bool findanchor(const QString& nm) = 0; |
32 | virtual void saveposn(const QString& f, size_t posn) = 0; | 31 | virtual void saveposn(const QString& f, size_t posn) = 0; |
33 | virtual void writeposn(const QString& f, size_t posn) = 0; | 32 | virtual void writeposn(const QString& f, size_t posn) = 0; |
34 | virtual linkType forward(QString& f, size_t& loc) = 0; | 33 | virtual linkType forward(QString& f, size_t& loc) = 0; |
35 | virtual linkType back(QString& f, size_t& loc) = 0; | 34 | virtual linkType back(QString& f, size_t& loc) = 0; |
36 | virtual bool hasnavigation() = 0; | 35 | virtual bool hasnavigation() = 0; |
37 | virtual int getwidth() = 0; | 36 | virtual int getwidth() = 0; |
38 | virtual QImage* getPicture(unsigned long) = 0; | 37 | virtual QImage* getPicture(unsigned long) = 0; |
39 | virtual QImage* getPicture(const QString& href) = 0; | 38 | virtual QImage* getPicture(const QString& href) = 0; |
40 | virtual bool getFile(const QString& href) = 0; | 39 | virtual bool getFile(const QString& href) = 0; |
41 | virtual QString about() = 0; | 40 | virtual QString about() = 0; |
42 | }; | 41 | }; |
43 | 42 | ||
44 | class CExpander_Interface | 43 | class CExpander_Interface |
45 | { | 44 | { |
46 | public: | 45 | public: |
47 | #ifdef USEQPE | 46 | #ifdef USEQPE |
48 | virtual void suspend() = 0; | 47 | virtual void suspend() = 0; |
49 | virtual void unsuspend() = 0; | 48 | virtual void unsuspend() = 0; |
50 | #endif | 49 | #endif |
51 | virtual QString about() = 0; | 50 | virtual QString about() = 0; |
52 | virtual size_t getHome() = 0; | 51 | virtual size_t getHome() = 0; |
53 | //CExpander_Interface(); | 52 | //CExpander_Interface(); |
54 | //virtual ~CExpander_Interface(); | 53 | //virtual ~CExpander_Interface(); |
55 | virtual int openfile(const char *src) = 0; | 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 unsigned int locate() = 0; | 56 | virtual unsigned int locate() = 0; |
58 | virtual void locate(unsigned int n) = 0; | 57 | virtual void locate(unsigned int n) = 0; |
59 | virtual bool hasrandomaccess() = 0; | 58 | virtual bool hasrandomaccess() = 0; |
60 | virtual void sizes(unsigned long& file, unsigned long& text) = 0; | 59 | virtual void sizes(unsigned long& file, unsigned long& text) = 0; |
61 | virtual CList<Bkmk>* getbkmklist() { return NULL; } | 60 | virtual CList<Bkmk>* getbkmklist() { return NULL; } |
62 | virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos) = 0; | 61 | virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos) = 0; |
63 | virtual int getch() = 0; | 62 | virtual int getch() = 0; |
64 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) = 0; | 63 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) = 0; |
65 | virtual MarkupType PreferredMarkup() = 0; | 64 | virtual MarkupType PreferredMarkup() = 0; |
66 | virtual void saveposn(size_t posn) {} | 65 | virtual void saveposn(size_t posn) {} |
67 | virtual void writeposn(size_t posn) {} | 66 | virtual void writeposn(size_t posn) {} |
68 | virtual linkType forward(size_t& loc) { return eNone; } | 67 | virtual linkType forward(size_t& loc) { return eNone; } |
69 | virtual linkType back(size_t& loc) { return eNone; } | 68 | virtual linkType back(size_t& loc) { return eNone; } |
70 | virtual bool hasnavigation() { return false; } | 69 | virtual bool hasnavigation() { return false; } |
71 | virtual unsigned long startSection() = 0; | 70 | virtual unsigned long startSection() = 0; |
72 | virtual unsigned long endSection() = 0; | 71 | virtual unsigned long endSection() = 0; |
73 | virtual void start2endSection() = 0; | 72 | virtual void start2endSection() = 0; |
74 | virtual QImage* getPicture(unsigned long tgt) { return NULL; } | 73 | virtual QImage* getPicture(unsigned long tgt) { return NULL; } |
75 | virtual void setContinuous(bool _b) = 0; | 74 | virtual void setContinuous(bool _b) = 0; |
76 | #ifdef USEQPE | 75 | #ifdef USEQPE |
77 | virtual void suspend(FILE*& fin) = 0; | 76 | virtual void suspend(FILE*& fin) = 0; |
78 | virtual void unsuspend(FILE*& fin) = 0; | 77 | virtual void unsuspend(FILE*& fin) = 0; |
79 | #endif | 78 | #endif |
80 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) = 0; | 79 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) = 0; |
81 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen) = 0; | 80 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen) = 0; |
82 | virtual void setwidth(int w) = 0; | 81 | virtual void setwidth(int w) = 0; |
83 | // bool findstring(const QString& info); | 82 | // bool findstring(const QString& info); |
84 | // int getpara(CBuffer& buff); | 83 | // int getpara(CBuffer& buff); |
85 | virtual int getwidth() = 0; | 84 | virtual int getwidth() = 0; |
86 | virtual QImage* getPicture(const QString& href) = 0; | 85 | virtual QImage* getPicture(const QString& href) = 0; |
87 | virtual bool getFile(const QString& href) = 0; | 86 | virtual bool getFile(const QString& href) = 0; |
88 | }; | 87 | }; |
89 | 88 | ||
90 | class CExpander : public CExpander_Interface | 89 | class CExpander : public CExpander_Interface |
91 | { | 90 | { |
92 | protected: | 91 | protected: |
93 | size_t m_homepos; | 92 | size_t m_homepos; |
94 | bool m_continuous; | 93 | bool m_continuous; |
95 | char* fname; | 94 | char* fname; |
96 | bool bSuspended; | 95 | bool bSuspended; |
97 | size_t suspos; | 96 | size_t suspos; |
98 | time_t sustime; | 97 | time_t sustime; |
99 | int m_scrWidth; | 98 | int m_scrWidth; |
100 | unsigned long m_currentstart, m_currentend; | 99 | unsigned long m_currentstart, m_currentend; |
101 | public: | 100 | public: |
102 | #ifdef USEQPE | 101 | #ifdef USEQPE |
103 | virtual void suspend() = 0; | 102 | virtual void suspend() = 0; |
104 | virtual void unsuspend() = 0; | 103 | virtual void unsuspend() = 0; |
105 | #endif | 104 | #endif |
106 | size_t getHome(); | 105 | size_t getHome(); |
107 | CExpander(); | 106 | CExpander(); |
108 | virtual ~CExpander(); | 107 | virtual ~CExpander(); |
109 | int openfile(const char *src); | 108 | int openfile(const char *src); |
110 | virtual int OpenFile(const char *src) = 0; | 109 | virtual int OpenFile(const char *src) = 0; |
111 | virtual unsigned int locate() = 0; | 110 | virtual unsigned int locate() = 0; |
112 | virtual void locate(unsigned int n) = 0; | 111 | virtual void locate(unsigned int n) = 0; |
113 | virtual bool hasrandomaccess() = 0; | 112 | virtual bool hasrandomaccess() = 0; |
114 | virtual void sizes(unsigned long& file, unsigned long& text) = 0; | 113 | virtual void sizes(unsigned long& file, unsigned long& text) = 0; |
115 | virtual CList<Bkmk>* getbkmklist() { return NULL; } | 114 | virtual CList<Bkmk>* getbkmklist() { return NULL; } |
116 | virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 115 | virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
117 | virtual int getch() = 0; | 116 | virtual int getch() = 0; |
118 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); | 117 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); |
119 | virtual MarkupType PreferredMarkup() = 0; | 118 | virtual MarkupType PreferredMarkup() = 0; |
120 | virtual void saveposn(size_t posn) {} | 119 | virtual void saveposn(size_t posn) {} |
121 | virtual void writeposn(size_t posn) {} | 120 | virtual void writeposn(size_t posn) {} |
122 | virtual linkType forward(size_t& loc) { return eNone; } | 121 | virtual linkType forward(size_t& loc) { return eNone; } |
123 | virtual linkType back(size_t& loc) { return eNone; } | 122 | virtual linkType back(size_t& loc) { return eNone; } |
124 | virtual bool hasnavigation() { return false; } | 123 | virtual bool hasnavigation() { return false; } |
125 | unsigned long startSection(); | 124 | unsigned long startSection(); |
126 | unsigned long endSection(); | 125 | unsigned long endSection(); |
127 | virtual void start2endSection(); | 126 | virtual void start2endSection(); |
128 | virtual QImage* getPicture(unsigned long tgt) { return NULL; } | 127 | virtual QImage* getPicture(unsigned long tgt) { return NULL; } |
129 | void setContinuous(bool _b) { m_continuous = _b; } | 128 | void setContinuous(bool _b) { m_continuous = _b; } |
130 | #ifdef USEQPE | 129 | #ifdef USEQPE |
131 | virtual void suspend(FILE*& fin); | 130 | virtual void suspend(FILE*& fin); |
132 | virtual void unsuspend(FILE*& fin); | 131 | virtual void unsuspend(FILE*& fin); |
133 | #endif | 132 | #endif |
134 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen); | 133 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen); |
135 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen); | 134 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen); |
136 | void setwidth(int w) | 135 | void setwidth(int w) |
137 | { | 136 | { |
138 | m_scrWidth = w; | 137 | m_scrWidth = w; |
139 | } | 138 | } |
140 | int getwidth() | 139 | int getwidth() |
141 | { | 140 | { |
142 | return m_scrWidth; | 141 | return m_scrWidth; |
143 | } | 142 | } |
144 | // bool findstring(const QString& info); | 143 | // bool findstring(const QString& info); |
145 | // int getpara(CBuffer& buff); | 144 | // int getpara(CBuffer& buff); |
146 | virtual QImage* getPicture(const QString& href) { return NULL; } | 145 | virtual QImage* getPicture(const QString& href) { return NULL; } |
147 | virtual bool getFile(const QString& href) { return false; } | 146 | virtual bool getFile(const QString& href) { return false; } |
148 | }; | 147 | }; |
149 | #endif | 148 | #endif |
diff --git a/noncore/apps/opie-reader/CFilter.cpp b/noncore/apps/opie-reader/CFilter.cpp index 6f76e9a..6d94d70 100644 --- a/noncore/apps/opie-reader/CFilter.cpp +++ b/noncore/apps/opie-reader/CFilter.cpp | |||
@@ -1,815 +1,814 @@ | |||
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 | #include "useqpe.h" | ||
6 | #ifdef USEQPE | 5 | #ifdef USEQPE |
7 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
8 | #endif | 7 | #endif |
9 | #include "CDrawBuffer.h" | 8 | #include "CDrawBuffer.h" |
10 | #include "CFilter.h" | 9 | #include "CFilter.h" |
11 | #include "hrule.h" | 10 | #include "hrule.h" |
12 | #include "util.h" | 11 | #include "util.h" |
13 | 12 | ||
14 | #include <qregexp.h> | 13 | #include <qregexp.h> |
15 | #include <qimage.h> | 14 | #include <qimage.h> |
16 | #include <qpixmap.h> | 15 | #include <qpixmap.h> |
17 | //#include <qprogressdialog.h> | 16 | //#include <qprogressdialog.h> |
18 | //#include <qapplication.h> | 17 | //#include <qapplication.h> |
19 | 18 | ||
20 | void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) | 19 | void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) |
21 | { | 20 | { |
22 | if (uselast) | 21 | if (uselast) |
23 | { | 22 | { |
24 | ch = lastchar; | 23 | ch = lastchar; |
25 | uselast = false; | 24 | uselast = false; |
26 | } | 25 | } |
27 | else | 26 | else |
28 | { | 27 | { |
29 | parent->getch(ch, sty, pos); | 28 | parent->getch(ch, sty, pos); |
30 | } | 29 | } |
31 | } | 30 | } |
32 | 31 | ||
33 | void textfmt::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 32 | void textfmt::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
34 | { | 33 | { |
35 | mygetch(ch, sty, pos); | 34 | mygetch(ch, sty, pos); |
36 | do | 35 | do |
37 | { | 36 | { |
38 | sty = currentstyle; | 37 | sty = currentstyle; |
39 | switch (ch) | 38 | switch (ch) |
40 | { | 39 | { |
41 | case 10: | 40 | case 10: |
42 | currentstyle.unset(); | 41 | currentstyle.unset(); |
43 | sty = currentstyle; | 42 | sty = currentstyle; |
44 | break; | 43 | break; |
45 | // Use this if you want to replace -- by em-dash | 44 | // Use this if you want to replace -- by em-dash |
46 | case '-': | 45 | case '-': |
47 | // parent->getch(ch, sty); | 46 | // parent->getch(ch, sty); |
48 | mygetch(ch, sty, pos); | 47 | mygetch(ch, sty, pos); |
49 | if (ch == '-') | 48 | if (ch == '-') |
50 | { | 49 | { |
51 | ch = 0x2014; | 50 | ch = 0x2014; |
52 | } | 51 | } |
53 | else | 52 | else |
54 | { | 53 | { |
55 | lastchar = ch; | 54 | lastchar = ch; |
56 | uselast = true; | 55 | uselast = true; |
57 | ch = '-'; | 56 | ch = '-'; |
58 | } | 57 | } |
59 | break; | 58 | break; |
60 | case '*': | 59 | case '*': |
61 | if (currentstyle.isBold()) | 60 | if (currentstyle.isBold()) |
62 | { | 61 | { |
63 | // Already bold - time to turn it off? | 62 | // Already bold - time to turn it off? |
64 | // 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 |
65 | // QChar c(lastchar); | 64 | // QChar c(lastchar); |
66 | // if ((lastchar != '*') && (c.isPunct() || c.isLetterOrNumber())) | 65 | // if ((lastchar != '*') && (c.isPunct() || c.isLetterOrNumber())) |
67 | if (lastchar != '*') | 66 | if (lastchar != '*') |
68 | { | 67 | { |
69 | currentstyle.unsetBold(); | 68 | currentstyle.unsetBold(); |
70 | CStyle dummy; | 69 | CStyle dummy; |
71 | // parent->getch(ch, dummy); | 70 | // parent->getch(ch, dummy); |
72 | mygetch(ch, dummy, pos); | 71 | mygetch(ch, dummy, pos); |
73 | } | 72 | } |
74 | } | 73 | } |
75 | else | 74 | else |
76 | { | 75 | { |
77 | // not bold - time to turn it on? | 76 | // not bold - time to turn it on? |
78 | CStyle dummy; | 77 | CStyle dummy; |
79 | // parent->getch(ch, dummy); | 78 | // parent->getch(ch, dummy); |
80 | mygetch(ch, dummy, pos); | 79 | mygetch(ch, dummy, pos); |
81 | QChar c(ch); | 80 | QChar c(ch); |
82 | if ((ch != '*') && (c.isPunct() || c.isLetterOrNumber())) | 81 | if ((ch != '*') && (c.isPunct() || c.isLetterOrNumber())) |
83 | { | 82 | { |
84 | currentstyle.setBold(); | 83 | currentstyle.setBold(); |
85 | } | 84 | } |
86 | else | 85 | else |
87 | { | 86 | { |
88 | lastchar = ch; | 87 | lastchar = ch; |
89 | uselast = true; | 88 | uselast = true; |
90 | ch = '*'; | 89 | ch = '*'; |
91 | } | 90 | } |
92 | 91 | ||
93 | } | 92 | } |
94 | break; | 93 | break; |
95 | case '_': | 94 | case '_': |
96 | if (currentstyle.isItalic()) | 95 | if (currentstyle.isItalic()) |
97 | { | 96 | { |
98 | // Already bold - time to turn it off? | 97 | // Already bold - time to turn it off? |
99 | // 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 |
100 | // QChar c(lastchar); | 99 | // QChar c(lastchar); |
101 | // if ((lastchar != '_') && (c.isPunct() || c.isLetterOrNumber())) | 100 | // if ((lastchar != '_') && (c.isPunct() || c.isLetterOrNumber())) |
102 | if (lastchar != '_') | 101 | if (lastchar != '_') |
103 | { | 102 | { |
104 | currentstyle.unsetItalic(); | 103 | currentstyle.unsetItalic(); |
105 | CStyle dummy; | 104 | CStyle dummy; |
106 | // parent->getch(ch, dummy); | 105 | // parent->getch(ch, dummy); |
107 | mygetch(ch, dummy, pos); | 106 | mygetch(ch, dummy, pos); |
108 | } | 107 | } |
109 | } | 108 | } |
110 | else | 109 | else |
111 | { | 110 | { |
112 | // not bold - time to turn it on? | 111 | // not bold - time to turn it on? |
113 | CStyle dummy; | 112 | CStyle dummy; |
114 | // parent->getch(ch, dummy); | 113 | // parent->getch(ch, dummy); |
115 | mygetch(ch, dummy, pos); | 114 | mygetch(ch, dummy, pos); |
116 | QChar c(ch); | 115 | QChar c(ch); |
117 | if ((ch != '_') && (c.isPunct() || c.isLetterOrNumber())) | 116 | if ((ch != '_') && (c.isPunct() || c.isLetterOrNumber())) |
118 | { | 117 | { |
119 | currentstyle.setItalic(); | 118 | currentstyle.setItalic(); |
120 | } | 119 | } |
121 | else | 120 | else |
122 | { | 121 | { |
123 | lastchar = ch; | 122 | lastchar = ch; |
124 | uselast = true; | 123 | uselast = true; |
125 | ch = '_'; | 124 | ch = '_'; |
126 | } | 125 | } |
127 | 126 | ||
128 | } | 127 | } |
129 | break; | 128 | break; |
130 | } | 129 | } |
131 | } | 130 | } |
132 | while (sty != currentstyle); | 131 | while (sty != currentstyle); |
133 | if (!uselast) lastchar = ch; | 132 | if (!uselast) lastchar = ch; |
134 | return; | 133 | return; |
135 | } | 134 | } |
136 | 135 | ||
137 | void remap::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 136 | void remap::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
138 | { | 137 | { |
139 | if (q[offset] != 0) | 138 | if (q[offset] != 0) |
140 | { | 139 | { |
141 | q[offset++]; | 140 | q[offset++]; |
142 | sty = currentstyle; | 141 | sty = currentstyle; |
143 | return; | 142 | return; |
144 | } | 143 | } |
145 | parent->getch(ch, sty, pos); | 144 | parent->getch(ch, sty, pos); |
146 | switch (ch) | 145 | switch (ch) |
147 | { | 146 | { |
148 | case 0x201a: | 147 | case 0x201a: |
149 | ch = '\''; | 148 | ch = '\''; |
150 | break; | 149 | break; |
151 | case 0x0192: | 150 | case 0x0192: |
152 | ch = 'f'; | 151 | ch = 'f'; |
153 | break; | 152 | break; |
154 | case 0x201e: | 153 | case 0x201e: |
155 | ch = '"'; | 154 | ch = '"'; |
156 | break; | 155 | break; |
157 | case 0x2026: | 156 | case 0x2026: |
158 | offset = 0; | 157 | offset = 0; |
159 | q[0] = '.'; | 158 | q[0] = '.'; |
160 | q[1] = '.'; | 159 | q[1] = '.'; |
161 | q[2] = 0; | 160 | q[2] = 0; |
162 | ch = '.'; // should be ... | 161 | ch = '.'; // should be ... |
163 | break; | 162 | break; |
164 | case 0x0160: | 163 | case 0x0160: |
165 | ch = 'S'; | 164 | ch = 'S'; |
166 | break; | 165 | break; |
167 | case 0x2039: | 166 | case 0x2039: |
168 | ch = '<'; | 167 | ch = '<'; |
169 | break; | 168 | break; |
170 | case 0x0152: | 169 | case 0x0152: |
171 | offset = 0; | 170 | offset = 0; |
172 | q[0] = 'E'; | 171 | q[0] = 'E'; |
173 | q[1] = 0; | 172 | q[1] = 0; |
174 | ch = 'O'; | 173 | ch = 'O'; |
175 | break; | 174 | break; |
176 | case 0x017d: | 175 | case 0x017d: |
177 | ch = 'Z'; | 176 | ch = 'Z'; |
178 | break; | 177 | break; |
179 | case 0x2018: | 178 | case 0x2018: |
180 | ch = '\''; | 179 | ch = '\''; |
181 | break; | 180 | break; |
182 | case 0x2019: | 181 | case 0x2019: |
183 | ch = '\''; | 182 | ch = '\''; |
184 | break; | 183 | break; |
185 | case 0x201c: | 184 | case 0x201c: |
186 | ch = '"'; | 185 | ch = '"'; |
187 | break; | 186 | break; |
188 | case 0x201d: | 187 | case 0x201d: |
189 | ch = '"'; | 188 | ch = '"'; |
190 | break; | 189 | break; |
191 | case 0x2022: | 190 | case 0x2022: |
192 | ch = '>'; | 191 | ch = '>'; |
193 | break; | 192 | break; |
194 | case 0x2013: | 193 | case 0x2013: |
195 | ch = '-'; | 194 | ch = '-'; |
196 | break; | 195 | break; |
197 | case 0x2014: | 196 | case 0x2014: |
198 | offset = 0; | 197 | offset = 0; |
199 | q[0] = '-'; | 198 | q[0] = '-'; |
200 | q[1] = 0; | 199 | q[1] = 0; |
201 | ch = '-'; // should be -- | 200 | ch = '-'; // should be -- |
202 | break; | 201 | break; |
203 | case 0x02dc: | 202 | case 0x02dc: |
204 | ch = '~'; | 203 | ch = '~'; |
205 | break; | 204 | break; |
206 | case 0x0161: | 205 | case 0x0161: |
207 | ch = 's'; | 206 | ch = 's'; |
208 | break; | 207 | break; |
209 | case 0x203a: | 208 | case 0x203a: |
210 | ch = '>'; | 209 | ch = '>'; |
211 | break; | 210 | break; |
212 | case 0x0153: | 211 | case 0x0153: |
213 | offset = 0; | 212 | offset = 0; |
214 | q[0] = 'e'; | 213 | q[0] = 'e'; |
215 | q[1] = 0; | 214 | q[1] = 0; |
216 | ch = 'o';// should be oe | 215 | ch = 'o';// should be oe |
217 | break; | 216 | break; |
218 | /* | 217 | /* |
219 | case 0x0009: // tab | 218 | case 0x0009: // tab |
220 | offset = 0; | 219 | offset = 0; |
221 | q[0] = ' '; | 220 | q[0] = ' '; |
222 | q[1] = 0; | 221 | q[1] = 0; |
223 | ch = ' '; | 222 | ch = ' '; |
224 | break; | 223 | break; |
225 | */ | 224 | */ |
226 | case 0x017e: | 225 | case 0x017e: |
227 | ch = 'z'; | 226 | ch = 'z'; |
228 | break; | 227 | break; |
229 | case 0x0178: | 228 | case 0x0178: |
230 | ch = 'Y'; | 229 | ch = 'Y'; |
231 | break; | 230 | break; |
232 | } | 231 | } |
233 | currentstyle = sty; | 232 | currentstyle = sty; |
234 | } | 233 | } |
235 | 234 | ||
236 | void PeanutFormatter::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 235 | void PeanutFormatter::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
237 | { | 236 | { |
238 | CStyle dummy; | 237 | CStyle dummy; |
239 | currentstyle.setColour(0,0,0); | 238 | currentstyle.setColour(0,0,0); |
240 | parent->getch(ch, dummy, pos); | 239 | parent->getch(ch, dummy, pos); |
241 | while (ch == '\\') | 240 | while (ch == '\\') |
242 | { | 241 | { |
243 | parent->getch(ch, dummy, pos); | 242 | parent->getch(ch, dummy, pos); |
244 | if (ch == '\\') break; | 243 | if (ch == '\\') break; |
245 | switch(ch) | 244 | switch(ch) |
246 | { | 245 | { |
247 | case 'a': | 246 | case 'a': |
248 | { | 247 | { |
249 | int code = 0; | 248 | int code = 0; |
250 | for (int i = 0; i < 3; i++) | 249 | for (int i = 0; i < 3; i++) |
251 | { | 250 | { |
252 | parent->getch(ch, dummy, pos); | 251 | parent->getch(ch, dummy, pos); |
253 | code = 10*code + ch - '0'; | 252 | code = 10*code + ch - '0'; |
254 | } | 253 | } |
255 | ch = code; | 254 | ch = code; |
256 | } | 255 | } |
257 | break; | 256 | break; |
258 | case 'v': | 257 | case 'v': |
259 | { | 258 | { |
260 | while (1) | 259 | while (1) |
261 | { | 260 | { |
262 | parent->getch(ch, dummy, pos); | 261 | parent->getch(ch, dummy, pos); |
263 | if (ch == '\\') | 262 | if (ch == '\\') |
264 | { | 263 | { |
265 | parent->getch(ch, dummy, pos); | 264 | parent->getch(ch, dummy, pos); |
266 | if (ch == 'v') | 265 | if (ch == 'v') |
267 | { | 266 | { |
268 | parent->getch(ch, dummy, pos); | 267 | parent->getch(ch, dummy, pos); |
269 | break; | 268 | break; |
270 | } | 269 | } |
271 | } | 270 | } |
272 | } | 271 | } |
273 | } | 272 | } |
274 | break; | 273 | break; |
275 | case 's': | 274 | case 's': |
276 | case 'n': | 275 | case 'n': |
277 | currentstyle.setFontSize(0); | 276 | currentstyle.setFontSize(0); |
278 | parent->getch(ch,dummy, pos); | 277 | parent->getch(ch,dummy, pos); |
279 | break; | 278 | break; |
280 | case 'p': | 279 | case 'p': |
281 | currentstyle.unset(); | 280 | currentstyle.unset(); |
282 | // parent->getch(ch,dummy); | 281 | // parent->getch(ch,dummy); |
283 | ch = 10; | 282 | ch = 10; |
284 | break; | 283 | break; |
285 | case 'l': | 284 | case 'l': |
286 | if (currentstyle.getFontSize() == 1) | 285 | if (currentstyle.getFontSize() == 1) |
287 | { | 286 | { |
288 | currentstyle.setFontSize(0); | 287 | currentstyle.setFontSize(0); |
289 | } | 288 | } |
290 | else | 289 | else |
291 | { | 290 | { |
292 | currentstyle.setFontSize(1); | 291 | currentstyle.setFontSize(1); |
293 | } | 292 | } |
294 | parent->getch(ch, dummy, pos); | 293 | parent->getch(ch, dummy, pos); |
295 | break; | 294 | break; |
296 | case 'x': | 295 | case 'x': |
297 | if (currentstyle.getFontSize() == 0) | 296 | if (currentstyle.getFontSize() == 0) |
298 | { | 297 | { |
299 | // currentstyle.unset(); | 298 | // currentstyle.unset(); |
300 | // currentstyle.setBold(); | 299 | // currentstyle.setBold(); |
301 | currentstyle.setFontSize(1); | 300 | currentstyle.setFontSize(1); |
302 | } | 301 | } |
303 | else | 302 | else |
304 | { | 303 | { |
305 | currentstyle.unset(); | 304 | currentstyle.unset(); |
306 | } | 305 | } |
307 | // parent->getch(ch, dummy); | 306 | // parent->getch(ch, dummy); |
308 | ch = 10; | 307 | ch = 10; |
309 | break; | 308 | break; |
310 | case 'i': | 309 | case 'i': |
311 | if (currentstyle.isItalic()) | 310 | if (currentstyle.isItalic()) |
312 | { | 311 | { |
313 | currentstyle.unsetItalic(); | 312 | currentstyle.unsetItalic(); |
314 | } | 313 | } |
315 | else | 314 | else |
316 | { | 315 | { |
317 | currentstyle.setItalic(); | 316 | currentstyle.setItalic(); |
318 | } | 317 | } |
319 | parent->getch(ch, dummy, pos); | 318 | parent->getch(ch, dummy, pos); |
320 | break; | 319 | break; |
321 | case 'b': | 320 | case 'b': |
322 | case 'B': | 321 | case 'B': |
323 | if (currentstyle.isBold()) | 322 | if (currentstyle.isBold()) |
324 | { | 323 | { |
325 | currentstyle.unsetBold(); | 324 | currentstyle.unsetBold(); |
326 | } | 325 | } |
327 | else | 326 | else |
328 | { | 327 | { |
329 | currentstyle.setBold(); | 328 | currentstyle.setBold(); |
330 | } | 329 | } |
331 | parent->getch(ch, dummy, pos); | 330 | parent->getch(ch, dummy, pos); |
332 | break; | 331 | break; |
333 | case 'c': | 332 | case 'c': |
334 | if (currentstyle.getJustify() == m_AlignCentre) | 333 | if (currentstyle.getJustify() == m_AlignCentre) |
335 | { | 334 | { |
336 | currentstyle.setLeftJustify(); | 335 | currentstyle.setLeftJustify(); |
337 | } | 336 | } |
338 | else | 337 | else |
339 | { | 338 | { |
340 | currentstyle.setCentreJustify(); | 339 | currentstyle.setCentreJustify(); |
341 | } | 340 | } |
342 | parent->getch(ch, dummy, pos); | 341 | parent->getch(ch, dummy, pos); |
343 | break; | 342 | break; |
344 | case 'r': | 343 | case 'r': |
345 | if (currentstyle.getJustify() == m_AlignRight) | 344 | if (currentstyle.getJustify() == m_AlignRight) |
346 | { | 345 | { |
347 | currentstyle.setLeftJustify(); | 346 | currentstyle.setLeftJustify(); |
348 | } | 347 | } |
349 | else | 348 | else |
350 | { | 349 | { |
351 | currentstyle.setRightJustify(); | 350 | currentstyle.setRightJustify(); |
352 | } | 351 | } |
353 | parent->getch(ch, dummy, pos); | 352 | parent->getch(ch, dummy, pos); |
354 | break; | 353 | break; |
355 | default: | 354 | default: |
356 | currentstyle.setColour(255,0,0); | 355 | currentstyle.setColour(255,0,0); |
357 | } | 356 | } |
358 | } | 357 | } |
359 | sty = currentstyle; | 358 | sty = currentstyle; |
360 | } | 359 | } |
361 | 360 | ||
362 | void OnePara::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 361 | void OnePara::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
363 | { | 362 | { |
364 | parent->getch(ch, sty, pos); | 363 | parent->getch(ch, sty, pos); |
365 | if (m_lastchar == 10) | 364 | if (m_lastchar == 10) |
366 | { | 365 | { |
367 | while (ch == 10) parent->getch(ch, sty, pos); | 366 | while (ch == 10) parent->getch(ch, sty, pos); |
368 | } | 367 | } |
369 | m_lastchar = ch; | 368 | m_lastchar = ch; |
370 | } | 369 | } |
371 | 370 | ||
372 | void repalm::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 371 | void repalm::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
373 | { | 372 | { |
374 | parent->getch(ch, sty, pos); | 373 | parent->getch(ch, sty, pos); |
375 | switch (ch) | 374 | switch (ch) |
376 | { | 375 | { |
377 | case 0x80: | 376 | case 0x80: |
378 | ch = 0x20ac; | 377 | ch = 0x20ac; |
379 | break; | 378 | break; |
380 | case 0x82: | 379 | case 0x82: |
381 | ch = 0x201a; | 380 | ch = 0x201a; |
382 | break; | 381 | break; |
383 | case 0x83: | 382 | case 0x83: |
384 | ch = 0x0192; | 383 | ch = 0x0192; |
385 | break; | 384 | break; |
386 | case 0x84: | 385 | case 0x84: |
387 | ch = 0x201e; | 386 | ch = 0x201e; |
388 | break; | 387 | break; |
389 | case 0x85: | 388 | case 0x85: |
390 | ch = 0x2026; | 389 | ch = 0x2026; |
391 | break; | 390 | break; |
392 | case 0x86: | 391 | case 0x86: |
393 | ch = 0x2020; | 392 | ch = 0x2020; |
394 | break; | 393 | break; |
395 | case 0x87: | 394 | case 0x87: |
396 | ch = 0x2021; | 395 | ch = 0x2021; |
397 | break; | 396 | break; |
398 | case 0x88: | 397 | case 0x88: |
399 | ch = 0x02c6; | 398 | ch = 0x02c6; |
400 | break; | 399 | break; |
401 | case 0x89: | 400 | case 0x89: |
402 | ch = 0x2030; | 401 | ch = 0x2030; |
403 | break; | 402 | break; |
404 | case 0x8a: | 403 | case 0x8a: |
405 | ch = 0x0160; | 404 | ch = 0x0160; |
406 | break; | 405 | break; |
407 | case 0x8b: | 406 | case 0x8b: |
408 | ch = 0x2039; | 407 | ch = 0x2039; |
409 | break; | 408 | break; |
410 | case 0x8c: | 409 | case 0x8c: |
411 | ch = 0x0152; | 410 | ch = 0x0152; |
412 | break; | 411 | break; |
413 | /* | 412 | /* |
414 | case 0x8e: | 413 | case 0x8e: |
415 | ch = 0x017d; | 414 | ch = 0x017d; |
416 | break; | 415 | break; |
417 | */ | 416 | */ |
418 | case 0x91: | 417 | case 0x91: |
419 | ch = 0x2018; | 418 | ch = 0x2018; |
420 | break; | 419 | break; |
421 | case 0x92: | 420 | case 0x92: |
422 | ch = 0x2019; | 421 | ch = 0x2019; |
423 | break; | 422 | break; |
424 | case 0x93: | 423 | case 0x93: |
425 | ch = 0x201c; | 424 | ch = 0x201c; |
426 | break; | 425 | break; |
427 | case 0x94: | 426 | case 0x94: |
428 | ch = 0x201d; | 427 | ch = 0x201d; |
429 | break; | 428 | break; |
430 | case 0x95: | 429 | case 0x95: |
431 | ch = 0x2022; | 430 | ch = 0x2022; |
432 | break; | 431 | break; |
433 | case 0x96: | 432 | case 0x96: |
434 | ch = 0x2013; | 433 | ch = 0x2013; |
435 | break; | 434 | break; |
436 | case 0x97: | 435 | case 0x97: |
437 | ch = 0x2014; | 436 | ch = 0x2014; |
438 | break; | 437 | break; |
439 | case 0x98: | 438 | case 0x98: |
440 | ch = 0x02dc; | 439 | ch = 0x02dc; |
441 | break; | 440 | break; |
442 | case 0x99: | 441 | case 0x99: |
443 | ch = 0x2122; | 442 | ch = 0x2122; |
444 | break; | 443 | break; |
445 | case 0x9a: | 444 | case 0x9a: |
446 | ch = 0x0161; | 445 | ch = 0x0161; |
447 | break; | 446 | break; |
448 | case 0x9b: | 447 | case 0x9b: |
449 | ch = 0x203a; | 448 | ch = 0x203a; |
450 | break; | 449 | break; |
451 | case 0x9c: | 450 | case 0x9c: |
452 | ch = 0x0153; | 451 | ch = 0x0153; |
453 | break; | 452 | break; |
454 | case 0x9e: | 453 | case 0x9e: |
455 | ch = 0x017e; | 454 | ch = 0x017e; |
456 | break; | 455 | break; |
457 | case 0x9f: | 456 | case 0x9f: |
458 | ch = 0x0178; | 457 | ch = 0x0178; |
459 | break; | 458 | break; |
460 | case 0x18: | 459 | case 0x18: |
461 | ch = 0x2026; | 460 | ch = 0x2026; |
462 | break; | 461 | break; |
463 | case 0x19: | 462 | case 0x19: |
464 | ch = 0x2007; | 463 | ch = 0x2007; |
465 | break; | 464 | break; |
466 | case 0x8d: | 465 | case 0x8d: |
467 | ch = 0x2662; | 466 | ch = 0x2662; |
468 | break; | 467 | break; |
469 | case 0x8e: | 468 | case 0x8e: |
470 | ch = 0x2663; | 469 | ch = 0x2663; |
471 | break; | 470 | break; |
472 | case 0x8f: | 471 | case 0x8f: |
473 | ch = 0x2661; | 472 | ch = 0x2661; |
474 | break; | 473 | break; |
475 | case 0x90: | 474 | case 0x90: |
476 | ch = 0x2660; | 475 | ch = 0x2660; |
477 | break; | 476 | break; |
478 | default: | 477 | default: |
479 | break; | 478 | break; |
480 | } | 479 | } |
481 | } | 480 | } |
482 | 481 | ||
483 | //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 }; |
484 | //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 }; |
485 | 484 | ||
486 | void DePluck::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 485 | void DePluck::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
487 | { | 486 | { |
488 | if (m_buffed > 0) | 487 | if (m_buffed > 0) |
489 | { | 488 | { |
490 | sty = m_laststyle; | 489 | sty = m_laststyle; |
491 | ch = nextpart[m_current++]; | 490 | ch = nextpart[m_current++]; |
492 | if (m_current == m_buffed) | 491 | if (m_current == m_buffed) |
493 | { | 492 | { |
494 | m_current = m_buffed = 0; | 493 | m_current = m_buffed = 0; |
495 | } | 494 | } |
496 | } | 495 | } |
497 | else | 496 | else |
498 | { | 497 | { |
499 | if (m_buffer != 0) | 498 | if (m_buffer != 0) |
500 | { | 499 | { |
501 | ch = m_buffer; | 500 | ch = m_buffer; |
502 | m_buffer = 0; | 501 | m_buffer = 0; |
503 | return; | 502 | return; |
504 | } | 503 | } |
505 | unsigned long lnk, lnkoff; | 504 | unsigned long lnk, lnkoff; |
506 | do | 505 | do |
507 | { | 506 | { |
508 | if (nextpart[m_buffed] == 0) break; | 507 | if (nextpart[m_buffed] == 0) break; |
509 | parent->getch(ch, sty, pos); | 508 | parent->getch(ch, sty, pos); |
510 | m_laststyle = sty; | 509 | m_laststyle = sty; |
511 | if (sty.getLink()) | 510 | if (sty.getLink()) |
512 | { | 511 | { |
513 | lnk = sty.getData(); | 512 | lnk = sty.getData(); |
514 | lnkoff = sty.getOffset(); | 513 | lnkoff = sty.getOffset(); |
515 | } | 514 | } |
516 | } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed); | 515 | } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed); |
517 | m_current = 0; | 516 | m_current = 0; |
518 | if (nextpart[m_buffed] == 0) | 517 | if (nextpart[m_buffed] == 0) |
519 | { | 518 | { |
520 | m_buffed = 0; | 519 | m_buffed = 0; |
521 | QString dmy, dmy2; | 520 | QString dmy, dmy2; |
522 | parent->hyperlink(lnk, lnkoff, dmy, dmy2); | 521 | parent->hyperlink(lnk, lnkoff, dmy, dmy2); |
523 | do | 522 | do |
524 | { | 523 | { |
525 | parent->getch(ch, sty, pos); | 524 | parent->getch(ch, sty, pos); |
526 | } | 525 | } |
527 | while (ch != 10); | 526 | while (ch != 10); |
528 | parent->getch(ch, sty, pos); | 527 | parent->getch(ch, sty, pos); |
529 | } | 528 | } |
530 | else if (m_buffed > 0) | 529 | else if (m_buffed > 0) |
531 | { | 530 | { |
532 | m_buffer = ch; | 531 | m_buffer = ch; |
533 | ch = nextpart[0]; | 532 | ch = nextpart[0]; |
534 | if (m_buffed == 1) | 533 | if (m_buffed == 1) |
535 | { | 534 | { |
536 | m_buffed = 0; | 535 | m_buffed = 0; |
537 | } | 536 | } |
538 | else m_current = 1; | 537 | else m_current = 1; |
539 | } | 538 | } |
540 | } | 539 | } |
541 | 540 | ||
542 | return; | 541 | return; |
543 | } | 542 | } |
544 | 543 | ||
545 | 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) |
546 | { | 545 | { |
547 | } | 546 | } |
548 | 547 | ||
549 | #include "Bkmks.h" | 548 | #include "Bkmks.h" |
550 | #include "QTReader.h" | 549 | #include "QTReader.h" |
551 | 550 | ||
552 | void HighlightFilter::refresh(unsigned long pos) | 551 | void HighlightFilter::refresh(unsigned long pos) |
553 | { | 552 | { |
554 | bkmks = pReader->Bkmklist(); | 553 | bkmks = pReader->Bkmklist(); |
555 | 554 | ||
556 | red = green = blue = 255; | 555 | red = green = blue = 255; |
557 | 556 | ||
558 | if (bkmks == NULL) | 557 | if (bkmks == NULL) |
559 | { | 558 | { |
560 | lastpos = 0; | 559 | lastpos = 0; |
561 | nextpos = 0xffffffff; | 560 | nextpos = 0xffffffff; |
562 | } | 561 | } |
563 | else | 562 | else |
564 | { | 563 | { |
565 | lastpos = 0; | 564 | lastpos = 0; |
566 | nextpos = 0xffffffff; | 565 | nextpos = 0xffffffff; |
567 | for (CList<Bkmk>::iterator i = bkmks->begin(); i != bkmks->end(); i++) | 566 | for (CList<Bkmk>::iterator i = bkmks->begin(); i != bkmks->end(); i++) |
568 | { | 567 | { |
569 | if ((*i).value() <= pos && pos < (*i).value2()) | 568 | if ((*i).value() <= pos && pos < (*i).value2()) |
570 | { | 569 | { |
571 | red = i->red(); | 570 | red = i->red(); |
572 | green = i->green(); | 571 | green = i->green(); |
573 | blue = i->blue(); | 572 | blue = i->blue(); |
574 | lastpos = (*i).value(); | 573 | lastpos = (*i).value(); |
575 | nextpos = (*i).value2(); | 574 | nextpos = (*i).value2(); |
576 | break; | 575 | break; |
577 | } | 576 | } |
578 | if ((*i).value() > pos) | 577 | if ((*i).value() > pos) |
579 | { | 578 | { |
580 | nextpos = (*i).value(); | 579 | nextpos = (*i).value(); |
581 | break; | 580 | break; |
582 | } | 581 | } |
583 | lastpos = (*i).value(); | 582 | lastpos = (*i).value(); |
584 | } | 583 | } |
585 | } | 584 | } |
586 | } | 585 | } |
587 | 586 | ||
588 | void HighlightFilter::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 587 | void HighlightFilter::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
589 | { | 588 | { |
590 | parent->getch(ch, sty, pos); | 589 | parent->getch(ch, sty, pos); |
591 | if (bkmks != pReader->Bkmklist() || pos <= lastpos || pos >= nextpos) | 590 | if (bkmks != pReader->Bkmklist() || pos <= lastpos || pos >= nextpos) |
592 | { | 591 | { |
593 | // qDebug("Recalc <%lu, %lu, %lu>", lastpos, pos, nextpos); | 592 | // qDebug("Recalc <%lu, %lu, %lu>", lastpos, pos, nextpos); |
594 | refresh(pos); | 593 | refresh(pos); |
595 | // qDebug("Recalc(2) <%lu, %lu, %lu>", lastpos, pos, nextpos); | 594 | // qDebug("Recalc(2) <%lu, %lu, %lu>", lastpos, pos, nextpos); |
596 | } | 595 | } |
597 | int r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); | 596 | int r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); |
598 | if (r == 255 && g == 255 && b == 255) | 597 | if (r == 255 && g == 255 && b == 255) |
599 | { | 598 | { |
600 | sty.setBackground(red, green, blue); | 599 | sty.setBackground(red, green, blue); |
601 | } | 600 | } |
602 | } | 601 | } |
603 | 602 | ||
604 | void kern::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 603 | void kern::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
605 | { | 604 | { |
606 | if (uselast) | 605 | if (uselast) |
607 | { | 606 | { |
608 | ch = lastchar; | 607 | ch = lastchar; |
609 | sty = laststy; | 608 | sty = laststy; |
610 | uselast = false; | 609 | uselast = false; |
611 | return; | 610 | return; |
612 | } | 611 | } |
613 | else | 612 | else |
614 | { | 613 | { |
615 | parent->getch(ch, sty, pos); | 614 | parent->getch(ch, sty, pos); |
616 | } | 615 | } |
617 | switch (ch) | 616 | switch (ch) |
618 | { | 617 | { |
619 | case 'f': | 618 | case 'f': |
620 | { | 619 | { |
621 | tchar savedchar = 'f'; | 620 | tchar savedchar = 'f'; |
622 | parent->getch(ch, sty, pos); | 621 | parent->getch(ch, sty, pos); |
623 | switch (ch) | 622 | switch (ch) |
624 | { | 623 | { |
625 | case 'i': | 624 | case 'i': |
626 | ch = (251 << 8) + 1; | 625 | ch = (251 << 8) + 1; |
627 | break; | 626 | break; |
628 | case 'l': | 627 | case 'l': |
629 | ch = (251 << 8) + 2; | 628 | ch = (251 << 8) + 2; |
630 | break; | 629 | break; |
631 | default: | 630 | default: |
632 | lastchar = ch; | 631 | lastchar = ch; |
633 | uselast = true; | 632 | uselast = true; |
634 | laststy = sty; | 633 | laststy = sty; |
635 | ch = savedchar; | 634 | ch = savedchar; |
636 | } | 635 | } |
637 | } | 636 | } |
638 | break; | 637 | break; |
639 | default: | 638 | default: |
640 | break; | 639 | break; |
641 | } | 640 | } |
642 | } | 641 | } |
643 | 642 | ||
644 | class ErrorFilter : public CFilter | 643 | class ErrorFilter : public CFilter |
645 | { | 644 | { |
646 | QString error; | 645 | QString error; |
647 | int currentpos; | 646 | int currentpos; |
648 | public: | 647 | public: |
649 | ErrorFilter(const QString& _s) : error(_s), currentpos(0) {} | 648 | ErrorFilter(const QString& _s) : error(_s), currentpos(0) {} |
650 | ~ErrorFilter() {} | 649 | ~ErrorFilter() {} |
651 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 650 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
652 | { | 651 | { |
653 | if (currentpos == error.length()) | 652 | if (currentpos == error.length()) |
654 | { | 653 | { |
655 | ch = UEOF; | 654 | ch = UEOF; |
656 | currentpos = 0; | 655 | currentpos = 0; |
657 | } | 656 | } |
658 | else | 657 | else |
659 | { | 658 | { |
660 | ch = error[currentpos++].unicode(); | 659 | ch = error[currentpos++].unicode(); |
661 | } | 660 | } |
662 | } | 661 | } |
663 | QString about() { return parent->about(); } | 662 | QString about() { return parent->about(); } |
664 | }; | 663 | }; |
665 | 664 | ||
666 | #ifndef __STATIC | 665 | #ifndef __STATIC |
667 | 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) |
668 | { | 667 | { |
669 | QString filterpath(QTReaderUtil::getPluginPath("filters/lib")); | 668 | QString filterpath(QTReaderUtil::getPluginPath("filters/lib")); |
670 | filterpath += nm; | 669 | filterpath += nm; |
671 | filterpath += ".so"; | 670 | filterpath += ".so"; |
672 | if (QFile::exists(filterpath)) | 671 | if (QFile::exists(filterpath)) |
673 | { | 672 | { |
674 | qDebug("Filter:%s", (const char*)filterpath); | 673 | qDebug("Filter:%s", (const char*)filterpath); |
675 | handle = dlopen(filterpath, RTLD_LAZY); | 674 | handle = dlopen(filterpath, RTLD_LAZY); |
676 | if (handle == 0) | 675 | if (handle == 0) |
677 | { | 676 | { |
678 | qDebug("Can't find filter:%s", dlerror()); | 677 | qDebug("Can't find filter:%s", dlerror()); |
679 | // status = -10; | 678 | // status = -10; |
680 | filt = new ErrorFilter(QString("Can't find plugin:")+nm); | 679 | filt = new ErrorFilter(QString("Can't find plugin:")+nm); |
681 | return; | 680 | return; |
682 | } | 681 | } |
683 | CFilter* (*newfilter)(const QString&); | 682 | CFilter* (*newfilter)(const QString&); |
684 | newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); | 683 | newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); |
685 | if (newfilter == NULL) | 684 | if (newfilter == NULL) |
686 | { | 685 | { |
687 | qDebug("Can't find newfilter"); | 686 | qDebug("Can't find newfilter"); |
688 | filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm); | 687 | filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm); |
689 | return; | 688 | return; |
690 | } | 689 | } |
691 | filt = (*newfilter)(optional); | 690 | filt = (*newfilter)(optional); |
692 | } | 691 | } |
693 | else | 692 | else |
694 | { | 693 | { |
695 | qDebug("No filter path"); | 694 | qDebug("No filter path"); |
696 | filt = new ErrorFilter(QString("No filter plugins installed:")+nm); | 695 | filt = new ErrorFilter(QString("No filter plugins installed:")+nm); |
697 | } | 696 | } |
698 | if (filt == NULL) | 697 | if (filt == NULL) |
699 | { | 698 | { |
700 | qDebug("Can't do newfilter"); | 699 | qDebug("Can't do newfilter"); |
701 | filt = new ErrorFilter(QString("Filter creation failed:")+nm); | 700 | filt = new ErrorFilter(QString("Filter creation failed:")+nm); |
702 | return; | 701 | return; |
703 | } | 702 | } |
704 | } | 703 | } |
705 | #endif | 704 | #endif |
706 | 705 | ||
707 | void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 706 | void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
708 | { | 707 | { |
709 | parent->getch(ch, sty, pos); | 708 | parent->getch(ch, sty, pos); |
710 | int r,g,b; | 709 | int r,g,b; |
711 | r = 255 - sty.Red(), g = 255 - sty.Green(), b = 255 - sty.Blue(); | 710 | r = 255 - sty.Red(), g = 255 - sty.Green(), b = 255 - sty.Blue(); |
712 | sty.setColour(r,g,b); | 711 | sty.setColour(r,g,b); |
713 | r = 255 - sty.bRed(), g = 255 - sty.bGreen(), b = 255 - sty.bBlue(); | 712 | r = 255 - sty.bRed(), g = 255 - sty.bGreen(), b = 255 - sty.bBlue(); |
714 | sty.setBackground(r,g,b); | 713 | sty.setBackground(r,g,b); |
715 | r = 255 - sty.pRed(), g = 255 - sty.pGreen(), b = 255 - sty.pBlue(); | 714 | r = 255 - sty.pRed(), g = 255 - sty.pGreen(), b = 255 - sty.pBlue(); |
716 | sty.setPaper(r,g,b); | 715 | sty.setPaper(r,g,b); |
717 | } | 716 | } |
718 | /* | 717 | /* |
719 | void makeNegative::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 718 | void makeNegative::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
720 | { | 719 | { |
721 | parent->getch(ch, sty, pos); | 720 | parent->getch(ch, sty, pos); |
722 | QColor fg(sty.Red(), sty.Green(), sty.Blue()); | 721 | QColor fg(sty.Red(), sty.Green(), sty.Blue()); |
723 | int h,s,v; | 722 | int h,s,v; |
724 | fg.hsv(&h,&s,&v); | 723 | fg.hsv(&h,&s,&v); |
725 | fg.setHsv(h,s,255-v); | 724 | fg.setHsv(h,s,255-v); |
726 | int r,g,b; | 725 | int r,g,b; |
727 | fg.rgb(&r,&g,&b); | 726 | fg.rgb(&r,&g,&b); |
728 | sty.setColour(r,g,b); | 727 | sty.setColour(r,g,b); |
729 | 728 | ||
730 | fg = QColor(sty.bRed(), sty.bGreen(), sty.bBlue()); | 729 | fg = QColor(sty.bRed(), sty.bGreen(), sty.bBlue()); |
731 | fg.hsv(&h,&s,&v); | 730 | fg.hsv(&h,&s,&v); |
732 | fg.setHsv(h,s,255-v); | 731 | fg.setHsv(h,s,255-v); |
733 | fg.rgb(&r,&g,&b); | 732 | fg.rgb(&r,&g,&b); |
734 | sty.setBackground(r,g,b); | 733 | sty.setBackground(r,g,b); |
735 | } | 734 | } |
736 | */ | 735 | */ |
737 | void setbg::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 736 | void setbg::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
738 | { | 737 | { |
739 | parent->getch(ch, sty, pos); | 738 | parent->getch(ch, sty, pos); |
740 | int r = sty.pRed(), g = sty.pGreen(), b = sty.pBlue(); | 739 | int r = sty.pRed(), g = sty.pGreen(), b = sty.pBlue(); |
741 | if (r == 255 && g == 255 && b == 255) | 740 | if (r == 255 && g == 255 && b == 255) |
742 | { | 741 | { |
743 | sty.setPaper(m_r,m_g,m_b); | 742 | sty.setPaper(m_r,m_g,m_b); |
744 | } | 743 | } |
745 | else | 744 | else |
746 | { | 745 | { |
747 | qDebug("We have background [%x%x%x]", r, g, b); | 746 | qDebug("We have background [%x%x%x]", r, g, b); |
748 | } | 747 | } |
749 | r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); | 748 | r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); |
750 | if (r == 255 && g == 255 && b == 255) | 749 | if (r == 255 && g == 255 && b == 255) |
751 | { | 750 | { |
752 | sty.setBackground(m_r,m_g,m_b); | 751 | sty.setBackground(m_r,m_g,m_b); |
753 | } | 752 | } |
754 | else | 753 | else |
755 | { | 754 | { |
756 | qDebug("We have background [%x%x%x]", r, g, b); | 755 | qDebug("We have background [%x%x%x]", r, g, b); |
757 | } | 756 | } |
758 | } | 757 | } |
759 | 758 | ||
760 | void setfg::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 759 | void setfg::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
761 | { | 760 | { |
762 | parent->getch(ch, sty, pos); | 761 | parent->getch(ch, sty, pos); |
763 | int r = sty.Red(), g = sty.Green(), b = sty.Blue(); | 762 | int r = sty.Red(), g = sty.Green(), b = sty.Blue(); |
764 | if (r == 0 && g == 0 && b == 0) | 763 | if (r == 0 && g == 0 && b == 0) |
765 | { | 764 | { |
766 | sty.setColour(m_r,m_g,m_b); | 765 | sty.setColour(m_r,m_g,m_b); |
767 | } | 766 | } |
768 | } | 767 | } |
769 | 768 | ||
770 | #include "CRegExp.h" | 769 | #include "CRegExp.h" |
771 | 770 | ||
772 | repara::repara(const QString& pat) : tch(0) | 771 | repara::repara(const QString& pat) : tch(0) |
773 | { | 772 | { |
774 | // QString pat("{\\n[A-Z\"]}"); | 773 | // QString pat("{\\n[A-Z\"]}"); |
775 | flt = new CRegExpFilt(pat, false); | 774 | flt = new CRegExpFilt(pat, false); |
776 | qDebug("Construction done"); | 775 | qDebug("Construction done"); |
777 | } | 776 | } |
778 | 777 | ||
779 | repara::~repara() | 778 | repara::~repara() |
780 | { | 779 | { |
781 | delete flt; | 780 | delete flt; |
782 | } | 781 | } |
783 | 782 | ||
784 | void repara::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 783 | void repara::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
785 | { | 784 | { |
786 | if (flt->empty()) | 785 | if (flt->empty()) |
787 | { | 786 | { |
788 | while (flt->empty()) | 787 | while (flt->empty()) |
789 | { | 788 | { |
790 | parent->getch(ch, sty, pos); | 789 | parent->getch(ch, sty, pos); |
791 | flt->addch(ch); | 790 | flt->addch(ch); |
792 | } | 791 | } |
793 | } | 792 | } |
794 | ch = flt->pop(); | 793 | ch = flt->pop(); |
795 | /* | 794 | /* |
796 | parent->getch(ch, sty, pos); | 795 | parent->getch(ch, sty, pos); |
797 | if (ch == 10 || ch == ' ') | 796 | if (ch == 10 || ch == ' ') |
798 | { | 797 | { |
799 | if (tch == 10) | 798 | if (tch == 10) |
800 | { | 799 | { |
801 | tch = ch; | 800 | tch = ch; |
802 | ch = 10; | 801 | ch = 10; |
803 | return; | 802 | return; |
804 | } | 803 | } |
805 | else | 804 | else |
806 | { | 805 | { |
807 | tch = ch; | 806 | tch = ch; |
808 | ch = ' '; | 807 | ch = ' '; |
809 | return; | 808 | return; |
810 | } | 809 | } |
811 | } | 810 | } |
812 | tch = ch; | 811 | tch = ch; |
813 | */ | 812 | */ |
814 | return; | 813 | return; |
815 | } | 814 | } |
diff --git a/noncore/apps/opie-reader/CFilter.h b/noncore/apps/opie-reader/CFilter.h index cec9618..174e6b4 100644 --- a/noncore/apps/opie-reader/CFilter.h +++ b/noncore/apps/opie-reader/CFilter.h | |||
@@ -1,475 +1,474 @@ | |||
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 | }; | 22 | }; |
23 | 23 | ||
24 | class CFilter : public CFilter_IFace | 24 | class CFilter : public CFilter_IFace |
25 | { | 25 | { |
26 | protected: | 26 | protected: |
27 | CCharacterSource* parent; | 27 | CCharacterSource* parent; |
28 | public: | 28 | public: |
29 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) | 29 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) |
30 | { | 30 | { |
31 | return parent->hyperlink(n,noff,w,nm); | 31 | return parent->hyperlink(n,noff,w,nm); |
32 | } | 32 | } |
33 | CFilter() : parent(NULL) {} | 33 | CFilter() : parent(NULL) {} |
34 | void setparent(CCharacterSource* p) { parent = p; } | 34 | void setparent(CCharacterSource* p) { parent = p; } |
35 | CCharacterSource* getparent() { return parent; } | 35 | CCharacterSource* getparent() { return parent; } |
36 | virtual ~CFilter() {}; | 36 | virtual ~CFilter() {}; |
37 | virtual void locate(unsigned int n) | 37 | virtual void locate(unsigned int n) |
38 | { | 38 | { |
39 | parent->locate(n); | 39 | parent->locate(n); |
40 | } | 40 | } |
41 | virtual bool findanchor(const QString& nm) | 41 | virtual bool findanchor(const QString& nm) |
42 | { | 42 | { |
43 | return parent->findanchor(nm); | 43 | return parent->findanchor(nm); |
44 | } | 44 | } |
45 | virtual void saveposn(const QString& f, size_t posn) { parent->saveposn(f, posn); } | 45 | 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); } | 46 | 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); } | 47 | 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); } | 48 | virtual linkType back(QString& f, size_t& loc) { return parent->back(f, loc); } |
49 | virtual bool hasnavigation() { return parent->hasnavigation(); } | 49 | virtual bool hasnavigation() { return parent->hasnavigation(); } |
50 | virtual int getwidth() { return parent->getwidth(); } | 50 | virtual int getwidth() { return parent->getwidth(); } |
51 | QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); } | 51 | QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); } |
52 | QImage* getPicture(const QString& href) { return parent->getPicture(href); } | 52 | QImage* getPicture(const QString& href) { return parent->getPicture(href); } |
53 | bool getFile(const QString& href) { return parent->getFile(href); } | 53 | bool getFile(const QString& href) { return parent->getFile(href); } |
54 | }; | 54 | }; |
55 | 55 | ||
56 | class CFilterChain | 56 | class CFilterChain |
57 | { | 57 | { |
58 | CExpander_Interface* expander; | 58 | CExpander_Interface* expander; |
59 | CEncoding* encoder; | 59 | CEncoding* encoder; |
60 | CFilter_IFace* first; | 60 | CFilter_IFace* first; |
61 | CCharacterSource* front; | 61 | CCharacterSource* front; |
62 | public: | 62 | public: |
63 | CFilterChain(CEncoding* _e) : encoder(_e), first(NULL), front(_e) {}; | 63 | CFilterChain(CEncoding* _e) : encoder(_e), first(NULL), front(_e) {}; |
64 | ~CFilterChain() | 64 | ~CFilterChain() |
65 | { | 65 | { |
66 | CCharacterSource* p = front; | 66 | CCharacterSource* p = front; |
67 | while (p != encoder) | 67 | while (p != encoder) |
68 | { | 68 | { |
69 | CFilter_IFace* pnext = (CFilter_IFace*)p; | 69 | CFilter_IFace* pnext = (CFilter_IFace*)p; |
70 | p = ((CFilter_IFace*)p)->getparent(); | 70 | p = ((CFilter_IFace*)p)->getparent(); |
71 | delete pnext; | 71 | delete pnext; |
72 | } | 72 | } |
73 | delete encoder; | 73 | delete encoder; |
74 | } | 74 | } |
75 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) | 75 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) |
76 | { | 76 | { |
77 | return front->hyperlink(n, noff, wrd, nm); | 77 | return front->hyperlink(n, noff, wrd, nm); |
78 | } | 78 | } |
79 | void locate(unsigned int n) | 79 | void locate(unsigned int n) |
80 | { | 80 | { |
81 | front->locate(n); | 81 | front->locate(n); |
82 | } | 82 | } |
83 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 83 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
84 | { | 84 | { |
85 | front->getch(ch, sty, pos); | 85 | front->getch(ch, sty, pos); |
86 | } | 86 | } |
87 | void addfilter(CFilter_IFace* p) | 87 | void addfilter(CFilter_IFace* p) |
88 | { | 88 | { |
89 | if (first == NULL) | 89 | if (first == NULL) |
90 | { | 90 | { |
91 | front = first = p; | 91 | front = first = p; |
92 | p->setparent(encoder); | 92 | p->setparent(encoder); |
93 | } | 93 | } |
94 | else | 94 | else |
95 | { | 95 | { |
96 | p->setparent(front); | 96 | p->setparent(front); |
97 | front = p; | 97 | front = p; |
98 | } | 98 | } |
99 | } | 99 | } |
100 | void setsource(CExpander_Interface* p) | 100 | void setsource(CExpander_Interface* p) |
101 | { | 101 | { |
102 | expander = p; | 102 | expander = p; |
103 | encoder->setparent(p); | 103 | encoder->setparent(p); |
104 | } | 104 | } |
105 | void setencoder(CEncoding* p) | 105 | void setencoder(CEncoding* p) |
106 | { | 106 | { |
107 | delete encoder; | 107 | delete encoder; |
108 | encoder = p; | 108 | encoder = p; |
109 | first->setparent(p); | 109 | first->setparent(p); |
110 | encoder->setparent(expander); | 110 | encoder->setparent(expander); |
111 | } | 111 | } |
112 | bool findanchor(const QString& nm) | 112 | bool findanchor(const QString& nm) |
113 | { | 113 | { |
114 | return front->findanchor(nm); | 114 | return front->findanchor(nm); |
115 | } | 115 | } |
116 | void saveposn(const QString& f, size_t posn) { front->saveposn(f, posn); } | 116 | 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); } | 117 | 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); } | 118 | 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); } | 119 | linkType back(QString& f, size_t& loc) { return front->back(f, loc); } |
120 | bool hasnavigation() { return front->hasnavigation(); } | 120 | bool hasnavigation() { return front->hasnavigation(); } |
121 | QString about() { return QString("Filter chain (c) Tim Wentford\n")+front->about(); } | 121 | QString about() { return QString("Filter chain (c) Tim Wentford\n")+front->about(); } |
122 | }; | 122 | }; |
123 | 123 | ||
124 | class stripcr : public CFilter | 124 | class stripcr : public CFilter |
125 | { | 125 | { |
126 | public: | 126 | public: |
127 | stripcr() {} | 127 | stripcr() {} |
128 | ~stripcr() {} | 128 | ~stripcr() {} |
129 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 129 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
130 | { | 130 | { |
131 | do | 131 | do |
132 | { | 132 | { |
133 | parent->getch(ch, sty, pos); | 133 | parent->getch(ch, sty, pos); |
134 | } | 134 | } |
135 | while (ch == 13); | 135 | while (ch == 13); |
136 | } | 136 | } |
137 | QString about() { return QString("StripCR filter (c) Tim Wentford\n")+parent->about(); } | 137 | QString about() { return QString("StripCR filter (c) Tim Wentford\n")+parent->about(); } |
138 | }; | 138 | }; |
139 | 139 | ||
140 | class dehyphen : public CFilter | 140 | class dehyphen : public CFilter |
141 | { | 141 | { |
142 | bool m_bCharWaiting; | 142 | bool m_bCharWaiting; |
143 | tchar m_nextChar; | 143 | tchar m_nextChar; |
144 | CStyle m_nextSty; | 144 | CStyle m_nextSty; |
145 | public: | 145 | public: |
146 | dehyphen() : m_bCharWaiting(false) {} | 146 | dehyphen() : m_bCharWaiting(false) {} |
147 | ~dehyphen() {} | 147 | ~dehyphen() {} |
148 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 148 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
149 | { | 149 | { |
150 | if (m_bCharWaiting) | 150 | if (m_bCharWaiting) |
151 | { | 151 | { |
152 | m_bCharWaiting = false; | 152 | m_bCharWaiting = false; |
153 | ch = m_nextChar; | 153 | ch = m_nextChar; |
154 | sty = m_nextSty; | 154 | sty = m_nextSty; |
155 | return; | 155 | return; |
156 | } | 156 | } |
157 | parent->getch(ch, sty, pos); | 157 | parent->getch(ch, sty, pos); |
158 | if (ch != '-') return; | 158 | if (ch != '-') return; |
159 | parent->getch(m_nextChar, m_nextSty, pos); | 159 | parent->getch(m_nextChar, m_nextSty, pos); |
160 | if (m_nextChar != 10) | 160 | if (m_nextChar != 10) |
161 | { | 161 | { |
162 | m_bCharWaiting = true; | 162 | m_bCharWaiting = true; |
163 | ch = '-'; | 163 | ch = '-'; |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | parent->getch(ch, sty, pos); | 166 | parent->getch(ch, sty, pos); |
167 | } | 167 | } |
168 | QString about() { return QString("Hyphenation filter (c) Tim Wentford\n")+parent->about(); } | 168 | QString about() { return QString("Hyphenation filter (c) Tim Wentford\n")+parent->about(); } |
169 | }; | 169 | }; |
170 | 170 | ||
171 | template<class A, class B>class QMap; | 171 | template<class A, class B>class QMap; |
172 | 172 | ||
173 | const int m_cmaxdepth = 8; | 173 | const int m_cmaxdepth = 8; |
174 | 174 | ||
175 | class htmlmark | 175 | class htmlmark |
176 | { | 176 | { |
177 | QString file; | 177 | QString file; |
178 | size_t pos; | 178 | size_t pos; |
179 | public: | 179 | public: |
180 | htmlmark() : file(), pos(0) {} | 180 | htmlmark() : file(), pos(0) {} |
181 | htmlmark(const QString& _f, size_t _p) : file(_f), pos(_p) {} | 181 | htmlmark(const QString& _f, size_t _p) : file(_f), pos(_p) {} |
182 | QString filename() { return file; } | 182 | QString filename() { return file; } |
183 | size_t posn() { return pos; } | 183 | size_t posn() { return pos; } |
184 | }; | 184 | }; |
185 | 185 | ||
186 | class unindent : public CFilter | 186 | class unindent : public CFilter |
187 | { | 187 | { |
188 | tchar lc; | 188 | tchar lc; |
189 | public: | 189 | public: |
190 | unindent() : lc(0) {} | 190 | unindent() : lc(0) {} |
191 | ~unindent() {} | 191 | ~unindent() {} |
192 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 192 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
193 | { | 193 | { |
194 | if (lc == 10) | 194 | if (lc == 10) |
195 | { | 195 | { |
196 | do | 196 | do |
197 | { | 197 | { |
198 | parent->getch(ch, sty, pos); | 198 | parent->getch(ch, sty, pos); |
199 | } | 199 | } |
200 | while (ch == ' '); | 200 | while (ch == ' '); |
201 | } | 201 | } |
202 | else parent->getch(ch, sty, pos); | 202 | else parent->getch(ch, sty, pos); |
203 | lc = ch; | 203 | lc = ch; |
204 | return; | 204 | return; |
205 | } | 205 | } |
206 | QString about() { return QString("Unindent filter (c) Tim Wentford\n")+parent->about(); } | 206 | QString about() { return QString("Unindent filter (c) Tim Wentford\n")+parent->about(); } |
207 | }; | 207 | }; |
208 | 208 | ||
209 | class CRegExpFilt; | 209 | class CRegExpFilt; |
210 | class repara : public CFilter | 210 | class repara : public CFilter |
211 | { | 211 | { |
212 | tchar tch; | 212 | tchar tch; |
213 | CRegExpFilt* flt; | 213 | CRegExpFilt* flt; |
214 | public: | 214 | public: |
215 | repara(const QString&); | 215 | repara(const QString&); |
216 | ~repara(); | 216 | ~repara(); |
217 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 217 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
218 | QString about() { return QString("Reparagraph filter (c) Tim Wentford\n")+parent->about(); } | 218 | QString about() { return QString("Reparagraph filter (c) Tim Wentford\n")+parent->about(); } |
219 | }; | 219 | }; |
220 | 220 | ||
221 | class indenter : public CFilter | 221 | class indenter : public CFilter |
222 | { | 222 | { |
223 | int amnt; | 223 | int amnt; |
224 | int indent; | 224 | int indent; |
225 | CStyle lsty; | 225 | CStyle lsty; |
226 | public: | 226 | public: |
227 | indenter(int _a=5) : amnt(_a), indent(0) {} | 227 | indenter(int _a=5) : amnt(_a), indent(0) {} |
228 | ~indenter() {} | 228 | ~indenter() {} |
229 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 229 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
230 | { | 230 | { |
231 | if (indent > 0) | 231 | if (indent > 0) |
232 | { | 232 | { |
233 | indent--; | 233 | indent--; |
234 | ch = ' '; | 234 | ch = ' '; |
235 | sty = lsty; | 235 | sty = lsty; |
236 | return; | 236 | return; |
237 | } | 237 | } |
238 | parent->getch(ch, sty, pos); | 238 | parent->getch(ch, sty, pos); |
239 | if (ch == 10) | 239 | if (ch == 10) |
240 | { | 240 | { |
241 | indent = amnt; | 241 | indent = amnt; |
242 | lsty = sty; | 242 | lsty = sty; |
243 | } | 243 | } |
244 | return; | 244 | return; |
245 | } | 245 | } |
246 | QString about() { return QString("Indentation filter (c) Tim Wentford\n")+parent->about(); } | 246 | QString about() { return QString("Indentation filter (c) Tim Wentford\n")+parent->about(); } |
247 | }; | 247 | }; |
248 | 248 | ||
249 | class dblspce : public CFilter | 249 | class dblspce : public CFilter |
250 | { | 250 | { |
251 | bool lastlf; | 251 | bool lastlf; |
252 | CStyle lsty; | 252 | CStyle lsty; |
253 | public: | 253 | public: |
254 | dblspce() : lastlf(false) {} | 254 | dblspce() : lastlf(false) {} |
255 | ~dblspce() {} | 255 | ~dblspce() {} |
256 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 256 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
257 | { | 257 | { |
258 | if (lastlf) | 258 | if (lastlf) |
259 | { | 259 | { |
260 | lastlf = false; | 260 | lastlf = false; |
261 | ch = 10; | 261 | ch = 10; |
262 | sty = lsty; | 262 | sty = lsty; |
263 | return; | 263 | return; |
264 | } | 264 | } |
265 | parent->getch(ch, sty, pos); | 265 | parent->getch(ch, sty, pos); |
266 | if (lastlf = (ch == 10)) | 266 | if (lastlf = (ch == 10)) |
267 | { | 267 | { |
268 | lsty = sty; | 268 | lsty = sty; |
269 | } | 269 | } |
270 | return; | 270 | return; |
271 | } | 271 | } |
272 | QString about() { return QString("Double space (c) Tim Wentford\n")+parent->about(); } | 272 | QString about() { return QString("Double space (c) Tim Wentford\n")+parent->about(); } |
273 | }; | 273 | }; |
274 | 274 | ||
275 | class textfmt : public CFilter | 275 | class textfmt : public CFilter |
276 | { | 276 | { |
277 | CStyle currentstyle; | 277 | CStyle currentstyle; |
278 | tchar lastchar; | 278 | tchar lastchar; |
279 | bool uselast; | 279 | bool uselast; |
280 | void mygetch(tchar&, CStyle&, unsigned long& pos); | 280 | void mygetch(tchar&, CStyle&, unsigned long& pos); |
281 | public: | 281 | public: |
282 | textfmt() : lastchar(0), uselast(false) {} | 282 | textfmt() : lastchar(0), uselast(false) {} |
283 | ~textfmt() {} | 283 | ~textfmt() {} |
284 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 284 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
285 | QString about() { return QString("Text formatting filter (c) Tim Wentford\n")+parent->about(); } | 285 | QString about() { return QString("Text formatting filter (c) Tim Wentford\n")+parent->about(); } |
286 | }; | 286 | }; |
287 | 287 | ||
288 | class embolden : public CFilter | 288 | class embolden : public CFilter |
289 | { | 289 | { |
290 | public: | 290 | public: |
291 | embolden() {} | 291 | embolden() {} |
292 | ~embolden() {} | 292 | ~embolden() {} |
293 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 293 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
294 | { | 294 | { |
295 | parent->getch(ch, sty, pos); | 295 | parent->getch(ch, sty, pos); |
296 | sty.setBold(); | 296 | sty.setBold(); |
297 | } | 297 | } |
298 | QString about() { return QString("Emboldening filter (c) Tim Wentford\n")+parent->about(); } | 298 | QString about() { return QString("Emboldening filter (c) Tim Wentford\n")+parent->about(); } |
299 | }; | 299 | }; |
300 | 300 | ||
301 | class remap : public CFilter | 301 | class remap : public CFilter |
302 | { | 302 | { |
303 | tchar q[3]; | 303 | tchar q[3]; |
304 | int offset; | 304 | int offset; |
305 | CStyle currentstyle; | 305 | CStyle currentstyle; |
306 | public: | 306 | public: |
307 | remap() : offset(0) { q[0] = 0; } | 307 | remap() : offset(0) { q[0] = 0; } |
308 | ~remap() {} | 308 | ~remap() {} |
309 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 309 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
310 | QString about() { return QString("Character remapping filter (c) Tim Wentford\n")+parent->about(); } | 310 | QString about() { return QString("Character remapping filter (c) Tim Wentford\n")+parent->about(); } |
311 | }; | 311 | }; |
312 | 312 | ||
313 | class PeanutFormatter : public CFilter | 313 | class PeanutFormatter : public CFilter |
314 | { | 314 | { |
315 | CStyle currentstyle; | 315 | CStyle currentstyle; |
316 | public: | 316 | public: |
317 | ~PeanutFormatter() {} | 317 | ~PeanutFormatter() {} |
318 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 318 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
319 | QString about() { return QString("PML filter (c) Tim Wentford\n")+parent->about(); } | 319 | QString about() { return QString("PML filter (c) Tim Wentford\n")+parent->about(); } |
320 | }; | 320 | }; |
321 | 321 | ||
322 | class OnePara : public CFilter | 322 | class OnePara : public CFilter |
323 | { | 323 | { |
324 | tchar m_lastchar; | 324 | tchar m_lastchar; |
325 | public: | 325 | public: |
326 | OnePara() : m_lastchar(0) {} | 326 | OnePara() : m_lastchar(0) {} |
327 | ~OnePara() {} | 327 | ~OnePara() {} |
328 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 328 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
329 | QString about() { return QString("Single space filter (c) Tim Wentford\n")+parent->about(); } | 329 | QString about() { return QString("Single space filter (c) Tim Wentford\n")+parent->about(); } |
330 | }; | 330 | }; |
331 | 331 | ||
332 | class DePluck : public CFilter | 332 | class DePluck : public CFilter |
333 | { | 333 | { |
334 | tchar* nextpart; | 334 | tchar* nextpart; |
335 | tchar m_buffer; | 335 | tchar m_buffer; |
336 | int m_buffed; | 336 | int m_buffed; |
337 | int m_current; | 337 | int m_current; |
338 | bool m_debuff; | 338 | bool m_debuff; |
339 | CStyle m_laststyle; | 339 | CStyle m_laststyle; |
340 | public: | 340 | public: |
341 | DePluck(tchar* t) : nextpart(t), m_buffer(0), m_buffed(0), m_current(0), m_debuff(false) {} | 341 | DePluck(tchar* t) : nextpart(t), m_buffer(0), m_buffed(0), m_current(0), m_debuff(false) {} |
342 | ~DePluck() {} | 342 | ~DePluck() {} |
343 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 343 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
344 | QString about() { return QString("Depluck filter (c) Tim Wentford\n")+parent->about(); } | 344 | QString about() { return QString("Depluck filter (c) Tim Wentford\n")+parent->about(); } |
345 | }; | 345 | }; |
346 | 346 | ||
347 | class repalm : public CFilter | 347 | class repalm : public CFilter |
348 | { | 348 | { |
349 | public: | 349 | public: |
350 | ~repalm() {} | 350 | ~repalm() {} |
351 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 351 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
352 | QString about() { return QString("Repalm filter (c) Tim Wentford\n")+parent->about(); } | 352 | QString about() { return QString("Repalm filter (c) Tim Wentford\n")+parent->about(); } |
353 | }; | 353 | }; |
354 | 354 | ||
355 | class FullJust : public CFilter | 355 | class FullJust : public CFilter |
356 | { | 356 | { |
357 | public: | 357 | public: |
358 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 358 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
359 | { | 359 | { |
360 | parent->getch(ch, sty, pos); | 360 | parent->getch(ch, sty, pos); |
361 | if (sty.getJustify() == m_AlignLeft) sty.setFullJustify(); | 361 | if (sty.getJustify() == m_AlignLeft) sty.setFullJustify(); |
362 | } | 362 | } |
363 | QString about() { return QString("Full justification filter (c) Tim Wentford\n")+parent->about(); } | 363 | QString about() { return QString("Full justification filter (c) Tim Wentford\n")+parent->about(); } |
364 | }; | 364 | }; |
365 | /* | 365 | /* |
366 | class AddSpace : public CFilter | 366 | class AddSpace : public CFilter |
367 | { | 367 | { |
368 | unsigned char m_espc; | 368 | unsigned char m_espc; |
369 | public: | 369 | public: |
370 | AddSpace(unsigned char s) : m_espc(s) {} | 370 | AddSpace(unsigned char s) : m_espc(s) {} |
371 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 371 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
372 | { | 372 | { |
373 | parent->getch(ch, sty, pos); | 373 | parent->getch(ch, sty, pos); |
374 | sty.setExtraSpace(m_espc); | 374 | sty.setExtraSpace(m_espc); |
375 | } | 375 | } |
376 | }; | 376 | }; |
377 | */ | 377 | */ |
378 | 378 | ||
379 | class QTReader; | 379 | class QTReader; |
380 | 380 | ||
381 | class HighlightFilter : public CFilter | 381 | class HighlightFilter : public CFilter |
382 | { | 382 | { |
383 | QTReader* pReader; | 383 | QTReader* pReader; |
384 | unsigned long lastpos, nextpos; | 384 | unsigned long lastpos, nextpos; |
385 | unsigned char red, green, blue; | 385 | unsigned char red, green, blue; |
386 | CList<Bkmk>* bkmks; | 386 | CList<Bkmk>* bkmks; |
387 | public: | 387 | public: |
388 | HighlightFilter(QTReader*); | 388 | HighlightFilter(QTReader*); |
389 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 389 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
390 | void refresh(unsigned long); | 390 | void refresh(unsigned long); |
391 | QString about() { return QString("High-lighting filter (c) Tim Wentford\n")+parent->about(); } | 391 | QString about() { return QString("High-lighting filter (c) Tim Wentford\n")+parent->about(); } |
392 | }; | 392 | }; |
393 | 393 | ||
394 | #include "static.h" | ||
395 | #ifndef __STATIC | 394 | #ifndef __STATIC |
396 | #include <dlfcn.h> | 395 | #include <dlfcn.h> |
397 | 396 | ||
398 | class ExternFilter : public CFilter_IFace | 397 | class ExternFilter : public CFilter_IFace |
399 | { | 398 | { |
400 | CFilter* filt; | 399 | CFilter* filt; |
401 | void *handle; | 400 | void *handle; |
402 | public: | 401 | public: |
403 | linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) | 402 | linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) |
404 | { | 403 | { |
405 | return filt->hyperlink(n, noff, w, nm); | 404 | return filt->hyperlink(n, noff, w, nm); |
406 | } | 405 | } |
407 | void setparent(CCharacterSource* p) { filt->setparent(p); } | 406 | void setparent(CCharacterSource* p) { filt->setparent(p); } |
408 | ExternFilter(const QString& nm, const QString& optional); | 407 | ExternFilter(const QString& nm, const QString& optional); |
409 | ~ExternFilter() | 408 | ~ExternFilter() |
410 | { | 409 | { |
411 | if (filt != NULL) delete filt; | 410 | if (filt != NULL) delete filt; |
412 | if (handle != NULL) dlclose(handle); | 411 | if (handle != NULL) dlclose(handle); |
413 | } | 412 | } |
414 | void locate(unsigned int n) { filt->locate(n); } | 413 | void locate(unsigned int n) { filt->locate(n); } |
415 | bool findanchor(const QString& nm) { return filt->findanchor(nm); } | 414 | bool findanchor(const QString& nm) { return filt->findanchor(nm); } |
416 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } | 415 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } |
417 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } | 416 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } |
418 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } | 417 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } |
419 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } | 418 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } |
420 | bool hasnavigation() { return filt->hasnavigation(); } | 419 | bool hasnavigation() { return filt->hasnavigation(); } |
421 | int getwidth() { return filt->getwidth(); } | 420 | int getwidth() { return filt->getwidth(); } |
422 | CCharacterSource* getparent() { return filt->getparent(); } | 421 | CCharacterSource* getparent() { return filt->getparent(); } |
423 | void getch(tchar& c, CStyle& s, unsigned long& l) { filt->getch(c, s, l); } | 422 | void getch(tchar& c, CStyle& s, unsigned long& l) { filt->getch(c, s, l); } |
424 | QImage* getPicture(unsigned long tgt) { return filt->getPicture(tgt); } | 423 | QImage* getPicture(unsigned long tgt) { return filt->getPicture(tgt); } |
425 | CFilter* filter() { return filt; } | 424 | CFilter* filter() { return filt; } |
426 | QImage* getPicture(const QString& href) { return filt->getPicture(href); } | 425 | QImage* getPicture(const QString& href) { return filt->getPicture(href); } |
427 | bool getFile(const QString& href) { return filt->getFile(href); } | 426 | bool getFile(const QString& href) { return filt->getFile(href); } |
428 | QString about() { return QString("Filter plug-in (c) Tim Wentford\n")+filt->about(); } | 427 | QString about() { return QString("Filter plug-in (c) Tim Wentford\n")+filt->about(); } |
429 | }; | 428 | }; |
430 | #endif | 429 | #endif |
431 | 430 | ||
432 | class kern : public CFilter | 431 | class kern : public CFilter |
433 | { | 432 | { |
434 | tchar lastchar; | 433 | tchar lastchar; |
435 | bool uselast; | 434 | bool uselast; |
436 | CStyle laststy; | 435 | CStyle laststy; |
437 | public: | 436 | public: |
438 | kern() : lastchar(0), uselast(false) {} | 437 | kern() : lastchar(0), uselast(false) {} |
439 | ~kern() {} | 438 | ~kern() {} |
440 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 439 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
441 | QString about() { return QString("Kerning filter (c) Tim Wentford\n")+parent->about(); } | 440 | QString about() { return QString("Kerning filter (c) Tim Wentford\n")+parent->about(); } |
442 | }; | 441 | }; |
443 | 442 | ||
444 | class makeInverse : public CFilter | 443 | class makeInverse : public CFilter |
445 | { | 444 | { |
446 | public: | 445 | public: |
447 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 446 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
448 | QString about() { return QString("Colourmap inversion filter (c) Tim Wentford\n")+parent->about(); } | 447 | QString about() { return QString("Colourmap inversion filter (c) Tim Wentford\n")+parent->about(); } |
449 | }; | 448 | }; |
450 | /* | 449 | /* |
451 | class makeNegative : public CFilter | 450 | class makeNegative : public CFilter |
452 | { | 451 | { |
453 | public: | 452 | public: |
454 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 453 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
455 | }; | 454 | }; |
456 | */ | 455 | */ |
457 | class setbg : public CFilter | 456 | class setbg : public CFilter |
458 | { | 457 | { |
459 | int m_r, m_g, m_b; | 458 | int m_r, m_g, m_b; |
460 | public: | 459 | public: |
461 | setbg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} | 460 | setbg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} |
462 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 461 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
463 | QString about() { return QString("Background colour filter (c) Tim Wentford\n")+parent->about(); } | 462 | QString about() { return QString("Background colour filter (c) Tim Wentford\n")+parent->about(); } |
464 | }; | 463 | }; |
465 | 464 | ||
466 | class setfg : public CFilter | 465 | class setfg : public CFilter |
467 | { | 466 | { |
468 | int m_r, m_g, m_b; | 467 | int m_r, m_g, m_b; |
469 | public: | 468 | public: |
470 | setfg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} | 469 | setfg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} |
471 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 470 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
472 | QString about() { return QString("Foreground colour filter (c) Tim Wentford\n")+parent->about(); } | 471 | QString about() { return QString("Foreground colour filter (c) Tim Wentford\n")+parent->about(); } |
473 | }; | 472 | }; |
474 | 473 | ||
475 | #endif | 474 | #endif |
diff --git a/noncore/apps/opie-reader/CHM.cpp b/noncore/apps/opie-reader/CHM.cpp index 9d1eb87..88d53bf 100644 --- a/noncore/apps/opie-reader/CHM.cpp +++ b/noncore/apps/opie-reader/CHM.cpp | |||
@@ -1,380 +1,379 @@ | |||
1 | #include "CHM.h" | 1 | #include "CHM.h" |
2 | #include "chm_lib.h" | 2 | #include "chm_lib.h" |
3 | #include "static.h" | ||
4 | #include <qstring.h> | 3 | #include <qstring.h> |
5 | #include <qstringlist.h> | 4 | #include <qstringlist.h> |
6 | #include <stdio.h> | 5 | #include <stdio.h> |
7 | #include <qimage.h> | 6 | #include <qimage.h> |
8 | #include <qpixmap.h> | 7 | #include <qpixmap.h> |
9 | 8 | ||
10 | #ifndef __STATIC | 9 | #ifndef __STATIC |
11 | extern "C" | 10 | extern "C" |
12 | { | 11 | { |
13 | CExpander* newcodec() { return new CHM; } | 12 | CExpander* newcodec() { return new CHM; } |
14 | } | 13 | } |
15 | #endif | 14 | #endif |
16 | 15 | ||
17 | static int _print_ui_index(struct chmFile *h, struct chmUnitInfo *ui, | 16 | static int _print_ui_index(struct chmFile *h, struct chmUnitInfo *ui, |
18 | void *context) | 17 | void *context) |
19 | { | 18 | { |
20 | CHM *chm = (CHM *)context; | 19 | CHM *chm = (CHM *)context; |
21 | QString temp = "<tr>"; | 20 | QString temp = "<tr>"; |
22 | char buff[1024]; | 21 | char buff[1024]; |
23 | sprintf( buff,"<td align=right>%8d\n</td><td><a href=\"%s\">%s</a></td></tr>",(int)ui->length, ui->path, ui->path); | 22 | sprintf( buff,"<td align=right>%8d\n</td><td><a href=\"%s\">%s</a></td></tr>",(int)ui->length, ui->path, ui->path); |
24 | temp += buff; | 23 | temp += buff; |
25 | chm->addContent(temp); | 24 | chm->addContent(temp); |
26 | return CHM_ENUMERATOR_CONTINUE; | 25 | return CHM_ENUMERATOR_CONTINUE; |
27 | } | 26 | } |
28 | 27 | ||
29 | static int _get_hhc (struct chmFile *h, struct chmUnitInfo *ui, | 28 | static int _get_hhc (struct chmFile *h, struct chmUnitInfo *ui, |
30 | void *context) | 29 | void *context) |
31 | { | 30 | { |
32 | CHM *chm = (CHM *)context; | 31 | CHM *chm = (CHM *)context; |
33 | QString PathName = ui->path; | 32 | QString PathName = ui->path; |
34 | if (PathName.find(".hhc") > -1) { | 33 | if (PathName.find(".hhc") > -1) { |
35 | chm->setPath(PathName); | 34 | chm->setPath(PathName); |
36 | } | 35 | } |
37 | return CHM_ENUMERATOR_CONTINUE; | 36 | return CHM_ENUMERATOR_CONTINUE; |
38 | } | 37 | } |
39 | 38 | ||
40 | CHM::CHM() { | 39 | CHM::CHM() { |
41 | chmFile = NULL; | 40 | chmFile = NULL; |
42 | chmPath = ""; | 41 | chmPath = ""; |
43 | chmHHCPath = ""; | 42 | chmHHCPath = ""; |
44 | chmBuffer = ""; | 43 | chmBuffer = ""; |
45 | bufpos = 0; | 44 | bufpos = 0; |
46 | } | 45 | } |
47 | 46 | ||
48 | CHM::~CHM() { | 47 | CHM::~CHM() { |
49 | if (chmFile != NULL) | 48 | if (chmFile != NULL) |
50 | chm_close(chmFile); | 49 | chm_close(chmFile); |
51 | } | 50 | } |
52 | 51 | ||
53 | void CHM::suspend() { | 52 | void CHM::suspend() { |
54 | #ifdef USEQPE | 53 | #ifdef USEQPE |
55 | bSuspended = true; | 54 | bSuspended = true; |
56 | //suspos = gztell(file); | 55 | //suspos = gztell(file); |
57 | chm_close(chmFile); | 56 | chm_close(chmFile); |
58 | chmFile = NULL; | 57 | chmFile = NULL; |
59 | sustime = time(NULL); | 58 | sustime = time(NULL); |
60 | #endif | 59 | #endif |
61 | } | 60 | } |
62 | 61 | ||
63 | void CHM::unsuspend() { | 62 | void CHM::unsuspend() { |
64 | #ifdef USEQPE | 63 | #ifdef USEQPE |
65 | if (bSuspended) | 64 | if (bSuspended) |
66 | { | 65 | { |
67 | bSuspended = false; | 66 | bSuspended = false; |
68 | int delay = time(NULL) - sustime; | 67 | int delay = time(NULL) - sustime; |
69 | if (delay < 10) | 68 | if (delay < 10) |
70 | sleep(10-delay); | 69 | sleep(10-delay); |
71 | chmFile = chm_open(fname); | 70 | chmFile = chm_open(fname); |
72 | for (int i = 0; chmFile == NULL && i < 5; i++) { | 71 | for (int i = 0; chmFile == NULL && i < 5; i++) { |
73 | sleep(5); | 72 | sleep(5); |
74 | chmFile = chm_open(fname); | 73 | chmFile = chm_open(fname); |
75 | } | 74 | } |
76 | if (chmFile == NULL) { | 75 | if (chmFile == NULL) { |
77 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); | 76 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); |
78 | exit(0); | 77 | exit(0); |
79 | } | 78 | } |
80 | //suspos = gzseek(file, suspos, SEEK_SET); | 79 | //suspos = gzseek(file, suspos, SEEK_SET); |
81 | } | 80 | } |
82 | #endif | 81 | #endif |
83 | } | 82 | } |
84 | 83 | ||
85 | void CHM::addContent(QString content) { | 84 | void CHM::addContent(QString content) { |
86 | chmBuffer += content; | 85 | chmBuffer += content; |
87 | } | 86 | } |
88 | 87 | ||
89 | void CHM::FillHomeContent() { | 88 | void CHM::FillHomeContent() { |
90 | if (chmHHCPath != "") { | 89 | if (chmHHCPath != "") { |
91 | const char *ext; | 90 | const char *ext; |
92 | char buffer[65536]; | 91 | char buffer[65536]; |
93 | unsigned int swath, offset; | 92 | unsigned int swath, offset; |
94 | QString tmp=""; | 93 | QString tmp=""; |
95 | QString HTML=""; | 94 | QString HTML=""; |
96 | /* try to find the file */ | 95 | /* try to find the file */ |
97 | const char *filename = (const char *)chmHHCPath; | 96 | const char *filename = (const char *)chmHHCPath; |
98 | if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) | 97 | if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) |
99 | { | 98 | { |
100 | chmBuffer = "HELP"; | 99 | chmBuffer = "HELP"; |
101 | fsize = chmBuffer.length(); | 100 | fsize = chmBuffer.length(); |
102 | return; | 101 | return; |
103 | } | 102 | } |
104 | m_homestart = m_ui.start; | 103 | m_homestart = m_ui.start; |
105 | m_homeend = m_homestart + m_ui.length; | 104 | m_homeend = m_homestart + m_ui.length; |
106 | swath = 65536; | 105 | swath = 65536; |
107 | offset = 0; | 106 | offset = 0; |
108 | fsize = m_ui.length; | 107 | fsize = m_ui.length; |
109 | while (offset < m_ui.length) | 108 | while (offset < m_ui.length) |
110 | { | 109 | { |
111 | if ((m_ui.length - offset) < 65536) | 110 | if ((m_ui.length - offset) < 65536) |
112 | swath = m_ui.length - offset; | 111 | swath = m_ui.length - offset; |
113 | else | 112 | else |
114 | swath = 65536; | 113 | swath = 65536; |
115 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); | 114 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); |
116 | tmp += buffer; | 115 | tmp += buffer; |
117 | offset += swath; | 116 | offset += swath; |
118 | } | 117 | } |
119 | HTML +="<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN>\r\n"; | 118 | HTML +="<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN>\r\n"; |
120 | HTML +="<HTML>\r\n"; | 119 | HTML +="<HTML>\r\n"; |
121 | HTML +="<BODY>\r\n"; | 120 | HTML +="<BODY>\r\n"; |
122 | HTML +="<h2>Home Page</h2>\r\n"; | 121 | HTML +="<h2>Home Page</h2>\r\n"; |
123 | HTML +="<h3>\r\n"; | 122 | HTML +="<h3>\r\n"; |
124 | QStringList qsl = QStringList::split("\r\n",tmp); | 123 | QStringList qsl = QStringList::split("\r\n",tmp); |
125 | QString NameFind ="<param name=\"Name\" value=\""; | 124 | QString NameFind ="<param name=\"Name\" value=\""; |
126 | QString LocalFind = "<param name=\"Local\" value=\""; | 125 | QString LocalFind = "<param name=\"Local\" value=\""; |
127 | QString ULOpenFind = "<UL>"; | 126 | QString ULOpenFind = "<UL>"; |
128 | QString LIOpenFind = "<LI>"; | 127 | QString LIOpenFind = "<LI>"; |
129 | QString ULCloseFind = "</UL>"; | 128 | QString ULCloseFind = "</UL>"; |
130 | QString Name = ""; | 129 | QString Name = ""; |
131 | QString Local = ""; | 130 | QString Local = ""; |
132 | for ( QStringList::Iterator it = qsl.begin(); it != qsl.end(); ++it ) { | 131 | for ( QStringList::Iterator it = qsl.begin(); it != qsl.end(); ++it ) { |
133 | QString Line = (*it); | 132 | QString Line = (*it); |
134 | int NamePos = Line.find( NameFind); | 133 | int NamePos = Line.find( NameFind); |
135 | int LocalPos = Line.find( LocalFind); | 134 | int LocalPos = Line.find( LocalFind); |
136 | if (NamePos > -1) { | 135 | if (NamePos > -1) { |
137 | Name = Line.mid(NamePos+NameFind.length(),Line.length()); | 136 | Name = Line.mid(NamePos+NameFind.length(),Line.length()); |
138 | Name = Name.left(Name.length() - 2); | 137 | Name = Name.left(Name.length() - 2); |
139 | } | 138 | } |
140 | if (LocalPos > -1) { | 139 | if (LocalPos > -1) { |
141 | Local = Line.mid(LocalPos+LocalFind.length(),Line.length()); | 140 | Local = Line.mid(LocalPos+LocalFind.length(),Line.length()); |
142 | Local = Local.left(Local.length() - 2); | 141 | Local = Local.left(Local.length() - 2); |
143 | if (Name != "") { | 142 | if (Name != "") { |
144 | HTML += "<br>\r\n<a href="; | 143 | HTML += "<br>\r\n<a href="; |
145 | HTML += Local; | 144 | HTML += Local; |
146 | HTML += ">"; | 145 | HTML += ">"; |
147 | HTML += Name; | 146 | HTML += Name; |
148 | HTML += "</a>\r\n"; | 147 | HTML += "</a>\r\n"; |
149 | Name = ""; | 148 | Name = ""; |
150 | } | 149 | } |
151 | } | 150 | } |
152 | } | 151 | } |
153 | HTML +="</h3>"; | 152 | HTML +="</h3>"; |
154 | HTML +="</BODY>\r\n"; | 153 | HTML +="</BODY>\r\n"; |
155 | HTML +="</HTML>\r\n"; | 154 | HTML +="</HTML>\r\n"; |
156 | chmHomeBuffer = HTML; | 155 | chmHomeBuffer = HTML; |
157 | chmBuffer = HTML; | 156 | chmBuffer = HTML; |
158 | fsize = chmBuffer.length(); | 157 | fsize = chmBuffer.length(); |
159 | m_currentstart = m_ui.start; | 158 | m_currentstart = m_ui.start; |
160 | m_currentend = m_currentstart+chmBuffer.length(); | 159 | m_currentend = m_currentstart+chmBuffer.length(); |
161 | } | 160 | } |
162 | } | 161 | } |
163 | 162 | ||
164 | bool CHM::FillBuffer() | 163 | bool CHM::FillBuffer() |
165 | { | 164 | { |
166 | bool bRetVal = false; | 165 | bool bRetVal = false; |
167 | char buffer[65536]; | 166 | char buffer[65536]; |
168 | int swath, offset; | 167 | int swath, offset; |
169 | chmBuffer = ""; | 168 | chmBuffer = ""; |
170 | swath = 65536; | 169 | swath = 65536; |
171 | offset = 0; | 170 | offset = 0; |
172 | fsize = m_ui.length; | 171 | fsize = m_ui.length; |
173 | while (offset < m_ui.length) | 172 | while (offset < m_ui.length) |
174 | { | 173 | { |
175 | if ((m_ui.length - offset) < 65536) | 174 | if ((m_ui.length - offset) < 65536) |
176 | swath = m_ui.length - offset; | 175 | swath = m_ui.length - offset; |
177 | else | 176 | else |
178 | swath = 65536; | 177 | swath = 65536; |
179 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); | 178 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); |
180 | chmBuffer += buffer; | 179 | chmBuffer += buffer; |
181 | offset += swath; | 180 | offset += swath; |
182 | } | 181 | } |
183 | //There seems to be a ton of gobbledygook at the end that is reminiscent of the hhc file - remove it | 182 | //There seems to be a ton of gobbledygook at the end that is reminiscent of the hhc file - remove it |
184 | QString temp = chmBuffer.lower(); | 183 | QString temp = chmBuffer.lower(); |
185 | int lpos = temp.find("</html"); | 184 | int lpos = temp.find("</html"); |
186 | if (lpos > -1) { | 185 | if (lpos > -1) { |
187 | chmBuffer.truncate(lpos); | 186 | chmBuffer.truncate(lpos); |
188 | chmBuffer = chmBuffer+"</HTML>"; | 187 | chmBuffer = chmBuffer+"</HTML>"; |
189 | } | 188 | } |
190 | fsize = chmBuffer.length(); | 189 | fsize = chmBuffer.length(); |
191 | 190 | ||
192 | bufpos = 0; | 191 | bufpos = 0; |
193 | bRetVal = true; | 192 | bRetVal = true; |
194 | m_currentstart = m_ui.start; | 193 | m_currentstart = m_ui.start; |
195 | m_currentend = m_currentstart+chmBuffer.length(); | 194 | m_currentend = m_currentstart+chmBuffer.length(); |
196 | return bRetVal; | 195 | return bRetVal; |
197 | } | 196 | } |
198 | 197 | ||
199 | bool CHM::FillContent() { | 198 | bool CHM::FillContent() { |
200 | bool bRetVal = false; | 199 | bool bRetVal = false; |
201 | if (chmPath != "") { | 200 | if (chmPath != "") { |
202 | /* try to find the file */ | 201 | /* try to find the file */ |
203 | const char *filename = (const char *)chmPath; | 202 | const char *filename = (const char *)chmPath; |
204 | if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) | 203 | if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) |
205 | { | 204 | { |
206 | fsize = chmBuffer.length(); | 205 | fsize = chmBuffer.length(); |
207 | return bRetVal; | 206 | return bRetVal; |
208 | } | 207 | } |
209 | 208 | ||
210 | char buffer[65536]; | 209 | char buffer[65536]; |
211 | int swath, offset; | 210 | int swath, offset; |
212 | chmBuffer = ""; | 211 | chmBuffer = ""; |
213 | swath = 65536; | 212 | swath = 65536; |
214 | offset = 0; | 213 | offset = 0; |
215 | fsize = m_ui.length; | 214 | fsize = m_ui.length; |
216 | while (offset < m_ui.length) | 215 | while (offset < m_ui.length) |
217 | { | 216 | { |
218 | if ((m_ui.length - offset) < 65536) | 217 | if ((m_ui.length - offset) < 65536) |
219 | swath = m_ui.length - offset; | 218 | swath = m_ui.length - offset; |
220 | else | 219 | else |
221 | swath = 65536; | 220 | swath = 65536; |
222 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); | 221 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); |
223 | chmBuffer += buffer; | 222 | chmBuffer += buffer; |
224 | offset += swath; | 223 | offset += swath; |
225 | } | 224 | } |
226 | //There seems to be a ton of gobbledygook at the end that is reminiscent of the hhc file - remove it | 225 | //There seems to be a ton of gobbledygook at the end that is reminiscent of the hhc file - remove it |
227 | QString temp = chmBuffer.lower(); | 226 | QString temp = chmBuffer.lower(); |
228 | int lpos = temp.find("</html"); | 227 | int lpos = temp.find("</html"); |
229 | if (lpos > -1) { | 228 | if (lpos > -1) { |
230 | chmBuffer.truncate(lpos); | 229 | chmBuffer.truncate(lpos); |
231 | chmBuffer = chmBuffer+"</HTML>"; | 230 | chmBuffer = chmBuffer+"</HTML>"; |
232 | } | 231 | } |
233 | fsize = chmBuffer.length(); | 232 | fsize = chmBuffer.length(); |
234 | 233 | ||
235 | bufpos = 0; | 234 | bufpos = 0; |
236 | m_currentstart = m_ui.start; | 235 | m_currentstart = m_ui.start; |
237 | m_currentend = m_currentstart+chmBuffer.length(); | 236 | m_currentend = m_currentstart+chmBuffer.length(); |
238 | bRetVal = true; | 237 | bRetVal = true; |
239 | } | 238 | } |
240 | return bRetVal; | 239 | return bRetVal; |
241 | } | 240 | } |
242 | 241 | ||
243 | bool CHM::getFile(const QString& href) { | 242 | bool CHM::getFile(const QString& href) { |
244 | qDebug("Got:%s", (const char*)href); | 243 | qDebug("Got:%s", (const char*)href); |
245 | bool bRetVal = false; | 244 | bool bRetVal = false; |
246 | QString temp = chmPath; | 245 | QString temp = chmPath; |
247 | chmPath = href; | 246 | chmPath = href; |
248 | if (FillContent()) { | 247 | if (FillContent()) { |
249 | qDebug("Got it"); | 248 | qDebug("Got it"); |
250 | bRetVal = true; | 249 | bRetVal = true; |
251 | } else { | 250 | } else { |
252 | qDebug("Missed"); | 251 | qDebug("Missed"); |
253 | chmPath = temp; | 252 | chmPath = temp; |
254 | FillContent(); | 253 | FillContent(); |
255 | } | 254 | } |
256 | return bRetVal; | 255 | return bRetVal; |
257 | } | 256 | } |
258 | 257 | ||
259 | QImage *CHM::getPicture(const QString& href) { | 258 | QImage *CHM::getPicture(const QString& href) { |
260 | QImage *img = NULL; | 259 | QImage *img = NULL; |
261 | QString PicRef = "/"+href; | 260 | QString PicRef = "/"+href; |
262 | struct chmUnitInfo ui; | 261 | struct chmUnitInfo ui; |
263 | const char *ext; | 262 | const char *ext; |
264 | /* try to find the file */ | 263 | /* try to find the file */ |
265 | const char *filename = (const char *)PicRef; | 264 | const char *filename = (const char *)PicRef; |
266 | if (chm_resolve_object(chmFile, filename, &ui) != CHM_RESOLVE_SUCCESS) | 265 | if (chm_resolve_object(chmFile, filename, &ui) != CHM_RESOLVE_SUCCESS) |
267 | { | 266 | { |
268 | qDebug ("Could not resolve image"); | 267 | qDebug ("Could not resolve image"); |
269 | return img; | 268 | return img; |
270 | } | 269 | } |
271 | if (ui.length > 0) { | 270 | if (ui.length > 0) { |
272 | char *temp = new char[ui.length]; | 271 | char *temp = new char[ui.length]; |
273 | char buffer[65536]; | 272 | char buffer[65536]; |
274 | int swath, offset; | 273 | int swath, offset; |
275 | swath = 65536; | 274 | swath = 65536; |
276 | offset = 0; | 275 | offset = 0; |
277 | 276 | ||
278 | while (offset < ui.length) | 277 | while (offset < ui.length) |
279 | { | 278 | { |
280 | if ((ui.length - offset) < 65536) | 279 | if ((ui.length - offset) < 65536) |
281 | swath = ui.length - offset; | 280 | swath = ui.length - offset; |
282 | else | 281 | else |
283 | swath = 65536; | 282 | swath = 65536; |
284 | swath = (int)chm_retrieve_object(chmFile, &ui, (unsigned char *) buffer, offset, swath); | 283 | swath = (int)chm_retrieve_object(chmFile, &ui, (unsigned char *) buffer, offset, swath); |
285 | memcpy( (void *) (temp + offset), (void *)&buffer, swath ); | 284 | memcpy( (void *) (temp + offset), (void *)&buffer, swath ); |
286 | offset += swath; | 285 | offset += swath; |
287 | } | 286 | } |
288 | QByteArray qba; | 287 | QByteArray qba; |
289 | qba.setRawData( (const char *)temp, ui.length); | 288 | qba.setRawData( (const char *)temp, ui.length); |
290 | QPixmap qpm(qba); | 289 | QPixmap qpm(qba); |
291 | img = new QImage(qpm.convertToImage()); | 290 | img = new QImage(qpm.convertToImage()); |
292 | qba.resetRawData((const char *)temp, ui.length); | 291 | qba.resetRawData((const char *)temp, ui.length); |
293 | delete[] temp; | 292 | delete[] temp; |
294 | } | 293 | } |
295 | 294 | ||
296 | return img; | 295 | return img; |
297 | } | 296 | } |
298 | 297 | ||
299 | int CHM::OpenFile(const char *src) { | 298 | int CHM::OpenFile(const char *src) { |
300 | if (chmFile != NULL) chm_close(chmFile); | 299 | if (chmFile != NULL) chm_close(chmFile); |
301 | struct stat _stat; | 300 | struct stat _stat; |
302 | stat(src,&_stat); | 301 | stat(src,&_stat); |
303 | fsize = _stat.st_size; | 302 | fsize = _stat.st_size; |
304 | chmFile = chm_open(src); | 303 | chmFile = chm_open(src); |
305 | if (chmFile != NULL) { | 304 | if (chmFile != NULL) { |
306 | chm_enumerate(chmFile, | 305 | chm_enumerate(chmFile, |
307 | CHM_ENUMERATE_ALL, | 306 | CHM_ENUMERATE_ALL, |
308 | _get_hhc, | 307 | _get_hhc, |
309 | (void *)this); | 308 | (void *)this); |
310 | if ( chmPath != "") { | 309 | if ( chmPath != "") { |
311 | setHomePath(chmPath); | 310 | setHomePath(chmPath); |
312 | FillHomeContent(); | 311 | FillHomeContent(); |
313 | } | 312 | } |
314 | } | 313 | } |
315 | m_homepos = locate(); | 314 | m_homepos = locate(); |
316 | qDebug("Home:%u", m_homepos); | 315 | qDebug("Home:%u", m_homepos); |
317 | return (chmFile==NULL); | 316 | return (chmFile==NULL); |
318 | } | 317 | } |
319 | 318 | ||
320 | int CHM::getch() { | 319 | int CHM::getch() { |
321 | if ( (bufpos+1) >= chmBuffer.length() ) | 320 | if ( (bufpos+1) >= chmBuffer.length() ) |
322 | return EOF; | 321 | return EOF; |
323 | #ifdef _WINDOWS | 322 | #ifdef _WINDOWS |
324 | QChar letter = chmBuffer.at(bufpos++); | 323 | QChar letter = chmBuffer.at(bufpos++); |
325 | #else | 324 | #else |
326 | QChar letter = chmBuffer[bufpos++]; | 325 | QChar letter = chmBuffer[bufpos++]; |
327 | #endif | 326 | #endif |
328 | return (int)(char)letter; | 327 | return (int)(char)letter; |
329 | } | 328 | } |
330 | 329 | ||
331 | void CHM::getch(tchar& ch, CStyle& sty) | 330 | void CHM::getch(tchar& ch, CStyle& sty) |
332 | { | 331 | { |
333 | int ich = getch(); | 332 | int ich = getch(); |
334 | ch = (ich == EOF) ? UEOF : ich; | 333 | ch = (ich == EOF) ? UEOF : ich; |
335 | } | 334 | } |
336 | 335 | ||
337 | void CHM::start2endSection() | 336 | void CHM::start2endSection() |
338 | { | 337 | { |
339 | m_currentstart = m_ui.start; | 338 | m_currentstart = m_ui.start; |
340 | m_currentend = m_currentstart+chmBuffer.length(); | 339 | m_currentend = m_currentstart+chmBuffer.length(); |
341 | } | 340 | } |
342 | 341 | ||
343 | unsigned int CHM::locate() { | 342 | unsigned int CHM::locate() { |
344 | return m_currentstart+bufpos; | 343 | return m_currentstart+bufpos; |
345 | } | 344 | } |
346 | 345 | ||
347 | void CHM::locate(unsigned int n) { | 346 | void CHM::locate(unsigned int n) { |
348 | if (n == 0) n = m_homepos; | 347 | if (n == 0) n = m_homepos; |
349 | if (n >= m_homestart && n < m_homeend) | 348 | if (n >= m_homestart && n < m_homeend) |
350 | { | 349 | { |
351 | FillHomeContent(); | 350 | FillHomeContent(); |
352 | bufpos = n - m_homestart; | 351 | bufpos = n - m_homestart; |
353 | start2endSection(); | 352 | start2endSection(); |
354 | qDebug("Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); | 353 | qDebug("Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); |
355 | } | 354 | } |
356 | else if (n >= m_currentstart && n < m_currentend) | 355 | else if (n >= m_currentstart && n < m_currentend) |
357 | { | 356 | { |
358 | bufpos = n - m_currentstart; | 357 | bufpos = n - m_currentstart; |
359 | } | 358 | } |
360 | else if (CHM_RESOLVE_FAILURE == chm_resolve_location(chmFile, n/4, &m_ui)) | 359 | else if (CHM_RESOLVE_FAILURE == chm_resolve_location(chmFile, n/4, &m_ui)) |
361 | { | 360 | { |
362 | qDebug("Resolve failure"); | 361 | qDebug("Resolve failure"); |
363 | FillHomeContent(); | 362 | FillHomeContent(); |
364 | bufpos = 0; | 363 | bufpos = 0; |
365 | start2endSection(); | 364 | start2endSection(); |
366 | qDebug("Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); | 365 | qDebug("Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); |
367 | } | 366 | } |
368 | else | 367 | else |
369 | { | 368 | { |
370 | qDebug("Resolve success"); | 369 | qDebug("Resolve success"); |
371 | FillBuffer(); | 370 | FillBuffer(); |
372 | start2endSection(); | 371 | start2endSection(); |
373 | bufpos=n-m_currentstart; | 372 | bufpos=n-m_currentstart; |
374 | qDebug("Not Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); | 373 | qDebug("Not Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); |
375 | } | 374 | } |
376 | } | 375 | } |
377 | 376 | ||
378 | void CHM::sizes(unsigned long& _file, unsigned long& _text) { | 377 | void CHM::sizes(unsigned long& _file, unsigned long& _text) { |
379 | _text = _file = fsize; | 378 | _text = _file = fsize; |
380 | } | 379 | } |
diff --git a/noncore/apps/opie-reader/CHM.h b/noncore/apps/opie-reader/CHM.h index 7dac46f..001f7fc 100644 --- a/noncore/apps/opie-reader/CHM.h +++ b/noncore/apps/opie-reader/CHM.h | |||
@@ -1,68 +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 "useqpe.h" | ||
6 | #include "CExpander.h" | 5 | #include "CExpander.h" |
7 | #include "chm_lib.h" | 6 | #include "chm_lib.h" |
8 | #include "my_list.h" | 7 | #include "my_list.h" |
9 | #include "CExpander.h" | 8 | #include "CExpander.h" |
10 | 9 | ||
11 | struct Ref { | 10 | struct Ref { |
12 | QString RefName; | 11 | QString RefName; |
13 | QString RefLoc; | 12 | QString RefLoc; |
14 | int beginpos; | 13 | int beginpos; |
15 | int endpos; | 14 | int endpos; |
16 | }; | 15 | }; |
17 | 16 | ||
18 | struct Pic { | 17 | struct Pic { |
19 | QString RefName; | 18 | QString RefName; |
20 | QString RefLoc; | 19 | QString RefLoc; |
21 | int beginpos; | 20 | int beginpos; |
22 | int endpos; | 21 | int endpos; |
23 | }; | 22 | }; |
24 | 23 | ||
25 | class CHM : public CExpander | 24 | class CHM : public CExpander |
26 | { | 25 | { |
27 | void start2endSection(); | 26 | void start2endSection(); |
28 | struct chmUnitInfo m_ui; | 27 | struct chmUnitInfo m_ui; |
29 | struct chmFile *chmFile; | 28 | struct chmFile *chmFile; |
30 | chmUnitInfo chmui; | 29 | chmUnitInfo chmui; |
31 | //alloc a meg to buffer | 30 | //alloc a meg to buffer |
32 | QString chmHomeBuffer; | 31 | QString chmHomeBuffer; |
33 | QString chmBuffer; | 32 | QString chmBuffer; |
34 | QString chmPath; | 33 | QString chmPath; |
35 | QString chmHHCPath; | 34 | QString chmHHCPath; |
36 | unsigned int bufpos; | 35 | unsigned int bufpos; |
37 | unsigned long fsize; | 36 | unsigned long fsize; |
38 | unsigned long m_homestart, m_homeend; | 37 | unsigned long m_homestart, m_homeend; |
39 | public: | 38 | public: |
40 | void suspend(); | 39 | void suspend(); |
41 | void unsuspend(); | 40 | void unsuspend(); |
42 | bool hasnavigation() { return true; } | 41 | bool hasnavigation() { return true; } |
43 | 42 | ||
44 | CHM(); | 43 | CHM(); |
45 | virtual ~CHM(); | 44 | virtual ~CHM(); |
46 | int OpenFile(const char *src); | 45 | int OpenFile(const char *src); |
47 | int getch(); | 46 | int getch(); |
48 | unsigned int locate(); | 47 | unsigned int locate(); |
49 | void locate(unsigned int n); | 48 | void locate(unsigned int n); |
50 | bool hasrandomaccess() { return true; } | 49 | bool hasrandomaccess() { return true; } |
51 | void sizes(unsigned long& _file, unsigned long& _text); | 50 | void sizes(unsigned long& _file, unsigned long& _text); |
52 | void addContent(QString content); | 51 | void addContent(QString content); |
53 | void getch(tchar& ch, CStyle& sty); | 52 | void getch(tchar& ch, CStyle& sty); |
54 | void setPath(QString PathName) {chmPath = PathName;}; | 53 | void setPath(QString PathName) {chmPath = PathName;}; |
55 | void setHomePath(QString PathName) {chmHHCPath = PathName;}; | 54 | void setHomePath(QString PathName) {chmHHCPath = PathName;}; |
56 | 55 | ||
57 | MarkupType PreferredMarkup() { | 56 | MarkupType PreferredMarkup() { |
58 | return cCHM; | 57 | return cCHM; |
59 | } | 58 | } |
60 | bool getFile(const QString& href); | 59 | bool getFile(const QString& href); |
61 | QImage *getPicture(const QString& href); | 60 | QImage *getPicture(const QString& href); |
62 | 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"); } |
63 | private : | 62 | private : |
64 | bool FillBuffer(); | 63 | bool FillBuffer(); |
65 | bool FillContent(); | 64 | bool FillContent(); |
66 | void FillHomeContent(); | 65 | void FillHomeContent(); |
67 | }; | 66 | }; |
68 | #endif | 67 | #endif |
diff --git a/noncore/apps/opie-reader/CHM/CHM.pro b/noncore/apps/opie-reader/CHM/CHM.pro index 6ed86f6..d3a2a28 100644 --- a/noncore/apps/opie-reader/CHM/CHM.pro +++ b/noncore/apps/opie-reader/CHM/CHM.pro | |||
@@ -1,18 +1,18 @@ | |||
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 = CHM.h chm_lib.h lzx.h | 5 | HEADERS = CHM.h chm_lib.h lzx.h |
6 | 6 | ||
7 | SOURCES = CHM.cpp chm_lib.c lzx.c | 7 | SOURCES = CHM.cpp chm_lib.c lzx.c |
8 | 8 | ||
9 | 9 | ||
10 | INTERFACES= | 10 | INTERFACES= |
11 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | 11 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs |
12 | TARGET = CHM | 12 | TARGET = CHM |
13 | LIBS += -lreader_codec | 13 | LIBS += -lreader_codec |
14 | 14 | ||
15 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 15 | INCLUDEPATH+= $(OPIEDIR)/include |
16 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 16 | DEPENDPATH+= $(OPIEDIR)/include |
17 | 17 | ||
18 | include ( $(OPIEDIR)/include.pro ) \ No newline at end of file | 18 | include ( $(OPIEDIR)/include.pro ) \ No newline at end of file |
diff --git a/noncore/apps/opie-reader/CloseDialog.h b/noncore/apps/opie-reader/CloseDialog.h index 62e6423..54aaf1c 100644 --- a/noncore/apps/opie-reader/CloseDialog.h +++ b/noncore/apps/opie-reader/CloseDialog.h | |||
@@ -1,62 +1,61 @@ | |||
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 __CLOSEDIALOG_H | 9 | #ifndef __CLOSEDIALOG_H |
10 | #define __CLOSEDIALOG_H | 10 | #define __CLOSEDIALOG_H |
11 | 11 | ||
12 | #include "useqpe.h" | ||
13 | #include <qvariant.h> | 12 | #include <qvariant.h> |
14 | #include <qwidget.h> | 13 | #include <qwidget.h> |
15 | #include <qtabdialog.h> | 14 | #include <qtabdialog.h> |
16 | #include <qtabwidget.h> | 15 | #include <qtabwidget.h> |
17 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
18 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
19 | #include <qcombobox.h> | 18 | #include <qcombobox.h> |
20 | #include <qlineedit.h> | 19 | #include <qlineedit.h> |
21 | //#include <qpe/menubutton.h> | 20 | //#include <qpe/menubutton.h> |
22 | #include <qvbuttongroup.h> | 21 | #include <qvbuttongroup.h> |
23 | 22 | ||
24 | class QVBoxLayout; | 23 | class QVBoxLayout; |
25 | class QHBoxLayout; | 24 | class QHBoxLayout; |
26 | class QGridLayout; | 25 | class QGridLayout; |
27 | //class QCheckBox; | 26 | //class QCheckBox; |
28 | class QLabel; | 27 | class QLabel; |
29 | //class QSpinBox; | 28 | //class QSpinBox; |
30 | 29 | ||
31 | class CCloseDialog : public QDialog | 30 | class CCloseDialog : public QDialog |
32 | { | 31 | { |
33 | Q_OBJECT | 32 | Q_OBJECT |
34 | QCheckBox *file, *marks, *config; | 33 | QCheckBox *file, *marks, *config; |
35 | #ifndef USEQPE | 34 | #ifndef USEQPE |
36 | void keyPressEvent(QKeyEvent* e) | 35 | void keyPressEvent(QKeyEvent* e) |
37 | { | 36 | { |
38 | switch (e->key()) | 37 | switch (e->key()) |
39 | { | 38 | { |
40 | case Key_Escape: | 39 | case Key_Escape: |
41 | e->accept(); | 40 | e->accept(); |
42 | reject(); | 41 | reject(); |
43 | break; | 42 | break; |
44 | case Key_Space: | 43 | case Key_Space: |
45 | case Key_Return: | 44 | case Key_Return: |
46 | e->accept(); | 45 | e->accept(); |
47 | accept(); | 46 | accept(); |
48 | break; | 47 | break; |
49 | default: | 48 | default: |
50 | QWidget::keyPressEvent(e); | 49 | QWidget::keyPressEvent(e); |
51 | } | 50 | } |
52 | } | 51 | } |
53 | #endif | 52 | #endif |
54 | public: | 53 | public: |
55 | CCloseDialog(const QString&, bool fs = true, QWidget* parent = 0, const char* name = 0); | 54 | CCloseDialog(const QString&, bool fs = true, QWidget* parent = 0, const char* name = 0); |
56 | ~CCloseDialog() {} | 55 | ~CCloseDialog() {} |
57 | bool delFile() { return file->isChecked(); } | 56 | bool delFile() { return file->isChecked(); } |
58 | bool delMarks() { return marks->isChecked(); } | 57 | bool delMarks() { return marks->isChecked(); } |
59 | bool delConfig() { return config->isChecked(); } | 58 | bool delConfig() { return config->isChecked(); } |
60 | 59 | ||
61 | }; | 60 | }; |
62 | #endif // CPREFS_H | 61 | #endif // CPREFS_H |
diff --git a/noncore/apps/opie-reader/FontControl.cpp b/noncore/apps/opie-reader/FontControl.cpp index bbd9fe0..9bb3bc0 100644 --- a/noncore/apps/opie-reader/FontControl.cpp +++ b/noncore/apps/opie-reader/FontControl.cpp | |||
@@ -1,67 +1,66 @@ | |||
1 | #include <qfontdatabase.h> | 1 | #include <qfontdatabase.h> |
2 | #include "useqpe.h" | ||
3 | #include "FontControl.h" | 2 | #include "FontControl.h" |
4 | 3 | ||
5 | int FontControl::gzoom() | 4 | int FontControl::gzoom() |
6 | { | 5 | { |
7 | if (m_fixgraphics) | 6 | if (m_fixgraphics) |
8 | { | 7 | { |
9 | return 100; | 8 | return 100; |
10 | } | 9 | } |
11 | else | 10 | else |
12 | { | 11 | { |
13 | int ret; | 12 | int ret; |
14 | if (m_size == g_size) | 13 | if (m_size == g_size) |
15 | { | 14 | { |
16 | ret = m_fontsizes[m_size]*m_basesize; | 15 | ret = m_fontsizes[m_size]*m_basesize; |
17 | } | 16 | } |
18 | else if (g_size < 0) | 17 | else if (g_size < 0) |
19 | { | 18 | { |
20 | int f = -g_size; | 19 | int f = -g_size; |
21 | ret = (m_fontsizes[0]*m_basesize) >> (f/2); | 20 | ret = (m_fontsizes[0]*m_basesize) >> (f/2); |
22 | if (f%2) ret = (2*ret/3); | 21 | if (f%2) ret = (2*ret/3); |
23 | } | 22 | } |
24 | else | 23 | else |
25 | { | 24 | { |
26 | int f = g_size - m_maxsize + 1; | 25 | int f = g_size - m_maxsize + 1; |
27 | ret = (m_fontsizes[m_maxsize-1]*m_basesize) << (f/2); | 26 | ret = (m_fontsizes[m_maxsize-1]*m_basesize) << (f/2); |
28 | if (f%2) ret = (3*ret/2); | 27 | if (f%2) ret = (3*ret/2); |
29 | } | 28 | } |
30 | return ret; | 29 | return ret; |
31 | } | 30 | } |
32 | } | 31 | } |
33 | 32 | ||
34 | bool FontControl::ChangeFont(QString& n, int tgt) | 33 | bool FontControl::ChangeFont(QString& n, int tgt) |
35 | { | 34 | { |
36 | QValueList<int>::Iterator it; | 35 | QValueList<int>::Iterator it; |
37 | QFontDatabase fdb; | 36 | QFontDatabase fdb; |
38 | QValueList<int> sizes = fdb.pointSizes(n); | 37 | QValueList<int> sizes = fdb.pointSizes(n); |
39 | if (sizes.count() == 0) | 38 | if (sizes.count() == 0) |
40 | { | 39 | { |
41 | return false; | 40 | return false; |
42 | } | 41 | } |
43 | else | 42 | else |
44 | { | 43 | { |
45 | m_fontname = n; | 44 | m_fontname = n; |
46 | m_maxsize = sizes.count(); | 45 | m_maxsize = sizes.count(); |
47 | if (m_fontsizes != NULL) delete [] m_fontsizes; | 46 | if (m_fontsizes != NULL) delete [] m_fontsizes; |
48 | m_fontsizes = new int[m_maxsize]; | 47 | m_fontsizes = new int[m_maxsize]; |
49 | uint i = 0; | 48 | uint i = 0; |
50 | uint best = 0; | 49 | uint best = 0; |
51 | for (it = sizes.begin(); it != sizes.end(); it++) | 50 | for (it = sizes.begin(); it != sizes.end(); it++) |
52 | { | 51 | { |
53 | #if defined(OPIE) || !defined(USEQPE) | 52 | #if defined(OPIE) || !defined(USEQPE) |
54 | m_fontsizes[i] = (*it); | 53 | m_fontsizes[i] = (*it); |
55 | #else | 54 | #else |
56 | m_fontsizes[i] = (*it)/10; | 55 | m_fontsizes[i] = (*it)/10; |
57 | #endif | 56 | #endif |
58 | if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) | 57 | if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) |
59 | { | 58 | { |
60 | best = i; | 59 | best = i; |
61 | } | 60 | } |
62 | i++; | 61 | i++; |
63 | } | 62 | } |
64 | g_size = m_size = best; | 63 | g_size = m_size = best; |
65 | } | 64 | } |
66 | return true; | 65 | return true; |
67 | } | 66 | } |
diff --git a/noncore/apps/opie-reader/HTMLFilter/HTMLFilter.pro b/noncore/apps/opie-reader/HTMLFilter/HTMLFilter.pro index cc049a9..8eb6f17 100644 --- a/noncore/apps/opie-reader/HTMLFilter/HTMLFilter.pro +++ b/noncore/apps/opie-reader/HTMLFilter/HTMLFilter.pro | |||
@@ -1,20 +1,20 @@ | |||
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 = CFilter.h \ | 5 | HEADERS = CFilter.h \ |
6 | util.h | 6 | util.h |
7 | 7 | ||
8 | SOURCES = striphtml.cpp | 8 | SOURCES = striphtml.cpp |
9 | 9 | ||
10 | # copy data file to install directory | 10 | # copy data file to install directory |
11 | QMAKE_PRE_LINK = mkdir -p $(OPIEDIR)/plugins/reader/data && cp ../HTMLentities $(OPIEDIR)/plugins/reader/data/HTMLentities | 11 | QMAKE_PRE_LINK = mkdir -p $(OPIEDIR)/plugins/reader/data && cp ../HTMLentities $(OPIEDIR)/plugins/reader/data/HTMLentities |
12 | 12 | ||
13 | INTERFACES= | 13 | INTERFACES= |
14 | DESTDIR = $(OPIEDIR)/plugins/reader/filters | 14 | DESTDIR = $(OPIEDIR)/plugins/reader/filters |
15 | TARGET = HTMLfilter | 15 | TARGET = HTMLfilter |
16 | 16 | ||
17 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 17 | INCLUDEPATH+= $(OPIEDIR)/include |
18 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 18 | DEPENDPATH+= $(OPIEDIR)/include |
19 | 19 | ||
20 | include ( $(OPIEDIR)/include.pro ) | 20 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/Palm2QImage.cpp b/noncore/apps/opie-reader/Palm2QImage.cpp index c1b7b7a..c6907eb 100644 --- a/noncore/apps/opie-reader/Palm2QImage.cpp +++ b/noncore/apps/opie-reader/Palm2QImage.cpp | |||
@@ -1,299 +1,298 @@ | |||
1 | /* -*- mode: c; indent-tabs-mode: nil; -*- */ | 1 | /* -*- mode: c; indent-tabs-mode: nil; -*- */ |
2 | #include "useqpe.h" | ||
3 | #include <stdio.h> | 2 | #include <stdio.h> |
4 | #include <stdlib.h> | 3 | #include <stdlib.h> |
5 | #include <string.h> | 4 | #include <string.h> |
6 | #ifndef _WINDOWS | 5 | #ifndef _WINDOWS |
7 | #include <unistd.h> /* for link */ | 6 | #include <unistd.h> /* for link */ |
8 | #endif | 7 | #endif |
9 | #include <sys/types.h> | 8 | #include <sys/types.h> |
10 | #include <sys/stat.h> | 9 | #include <sys/stat.h> |
11 | #include <stdarg.h> | 10 | #include <stdarg.h> |
12 | 11 | ||
13 | #include <qimage.h> | 12 | #include <qimage.h> |
14 | 13 | ||
15 | /***********************************************************************/ | 14 | /***********************************************************************/ |
16 | /***********************************************************************/ | 15 | /***********************************************************************/ |
17 | /***** *****/ | 16 | /***** *****/ |
18 | /***** Code to decode the Palm image format to JPEG *****/ | 17 | /***** Code to decode the Palm image format to JPEG *****/ |
19 | /***** *****/ | 18 | /***** *****/ |
20 | /***********************************************************************/ | 19 | /***********************************************************************/ |
21 | /***********************************************************************/ | 20 | /***********************************************************************/ |
22 | 21 | ||
23 | #define READ_BIGENDIAN_SHORT(p) (((p)[0] << 8)|((p)[1])) | 22 | #define READ_BIGENDIAN_SHORT(p) (((p)[0] << 8)|((p)[1])) |
24 | #define READ_BIGENDIAN_LONG(p) (((p)[0] << 24)|((p)[1] << 16)|((p)[2] << 8)|((p)[3])) | 23 | #define READ_BIGENDIAN_LONG(p) (((p)[0] << 24)|((p)[1] << 16)|((p)[2] << 8)|((p)[3])) |
25 | 24 | ||
26 | #define PALM_IS_COMPRESSED_FLAG 0x8000 | 25 | #define PALM_IS_COMPRESSED_FLAG 0x8000 |
27 | #define PALM_HAS_COLORMAP_FLAG 0x4000 | 26 | #define PALM_HAS_COLORMAP_FLAG 0x4000 |
28 | #define PALM_HAS_TRANSPARENCY_FLAG 0x2000 | 27 | #define PALM_HAS_TRANSPARENCY_FLAG 0x2000 |
29 | #define PALM_DIRECT_COLOR_FLAG 0x0400 | 28 | #define PALM_DIRECT_COLOR_FLAG 0x0400 |
30 | #define PALM_4_BYTE_FIELD_FLAG 0x0200 | 29 | #define PALM_4_BYTE_FIELD_FLAG 0x0200 |
31 | 30 | ||
32 | #define PALM_COMPRESSION_SCANLINE 0x00 | 31 | #define PALM_COMPRESSION_SCANLINE 0x00 |
33 | #define PALM_COMPRESSION_RLE 0x01 | 32 | #define PALM_COMPRESSION_RLE 0x01 |
34 | #define PALM_COMPRESSION_PACKBITS 0x02 | 33 | #define PALM_COMPRESSION_PACKBITS 0x02 |
35 | #define PALM_COMPRESSION_NONE 0xFF | 34 | #define PALM_COMPRESSION_NONE 0xFF |
36 | 35 | ||
37 | #define PALM_COLORMAP_SIZE 232 | 36 | #define PALM_COLORMAP_SIZE 232 |
38 | 37 | ||
39 | typedef struct { | 38 | typedef struct { |
40 | unsigned char red; | 39 | unsigned char red; |
41 | unsigned char green; | 40 | unsigned char green; |
42 | unsigned char blue; | 41 | unsigned char blue; |
43 | } ColorMapEntry; | 42 | } ColorMapEntry; |
44 | 43 | ||
45 | static ColorMapEntry Palm8BitColormap[] = { | 44 | static ColorMapEntry Palm8BitColormap[] = { |
46 | { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 }, | 45 | { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 }, |
47 | { 255, 51, 255 }, { 255, 0, 255 }, { 255, 255, 204 }, { 255, 204, 204 }, | 46 | { 255, 51, 255 }, { 255, 0, 255 }, { 255, 255, 204 }, { 255, 204, 204 }, |
48 | { 255, 153, 204 }, { 255, 102, 204 }, { 255, 51, 204 }, { 255, 0, 204 }, | 47 | { 255, 153, 204 }, { 255, 102, 204 }, { 255, 51, 204 }, { 255, 0, 204 }, |
49 | { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 }, | 48 | { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 }, |
50 | { 255, 51, 153 }, { 255, 0, 153 }, { 204, 255, 255 }, { 204, 204, 255 }, | 49 | { 255, 51, 153 }, { 255, 0, 153 }, { 204, 255, 255 }, { 204, 204, 255 }, |
51 | { 204, 153, 255 }, { 204, 102, 255 }, { 204, 51, 255 }, { 204, 0, 255 }, | 50 | { 204, 153, 255 }, { 204, 102, 255 }, { 204, 51, 255 }, { 204, 0, 255 }, |
52 | { 204, 255, 204 }, { 204, 204, 204 }, { 204, 153, 204 }, { 204, 102, 204 }, | 51 | { 204, 255, 204 }, { 204, 204, 204 }, { 204, 153, 204 }, { 204, 102, 204 }, |
53 | { 204, 51, 204 }, { 204, 0, 204 }, { 204, 255, 153 }, { 204, 204, 153 }, | 52 | { 204, 51, 204 }, { 204, 0, 204 }, { 204, 255, 153 }, { 204, 204, 153 }, |
54 | { 204, 153, 153 }, { 204, 102, 153 }, { 204, 51, 153 }, { 204, 0, 153 }, | 53 | { 204, 153, 153 }, { 204, 102, 153 }, { 204, 51, 153 }, { 204, 0, 153 }, |
55 | { 153, 255, 255 }, { 153, 204, 255 }, { 153, 153, 255 }, { 153, 102, 255 }, | 54 | { 153, 255, 255 }, { 153, 204, 255 }, { 153, 153, 255 }, { 153, 102, 255 }, |
56 | { 153, 51, 255 }, { 153, 0, 255 }, { 153, 255, 204 }, { 153, 204, 204 }, | 55 | { 153, 51, 255 }, { 153, 0, 255 }, { 153, 255, 204 }, { 153, 204, 204 }, |
57 | { 153, 153, 204 }, { 153, 102, 204 }, { 153, 51, 204 }, { 153, 0, 204 }, | 56 | { 153, 153, 204 }, { 153, 102, 204 }, { 153, 51, 204 }, { 153, 0, 204 }, |
58 | { 153, 255, 153 }, { 153, 204, 153 }, { 153, 153, 153 }, { 153, 102, 153 }, | 57 | { 153, 255, 153 }, { 153, 204, 153 }, { 153, 153, 153 }, { 153, 102, 153 }, |
59 | { 153, 51, 153 }, { 153, 0, 153 }, { 102, 255, 255 }, { 102, 204, 255 }, | 58 | { 153, 51, 153 }, { 153, 0, 153 }, { 102, 255, 255 }, { 102, 204, 255 }, |
60 | { 102, 153, 255 }, { 102, 102, 255 }, { 102, 51, 255 }, { 102, 0, 255 }, | 59 | { 102, 153, 255 }, { 102, 102, 255 }, { 102, 51, 255 }, { 102, 0, 255 }, |
61 | { 102, 255, 204 }, { 102, 204, 204 }, { 102, 153, 204 }, { 102, 102, 204 }, | 60 | { 102, 255, 204 }, { 102, 204, 204 }, { 102, 153, 204 }, { 102, 102, 204 }, |
62 | { 102, 51, 204 }, { 102, 0, 204 }, { 102, 255, 153 }, { 102, 204, 153 }, | 61 | { 102, 51, 204 }, { 102, 0, 204 }, { 102, 255, 153 }, { 102, 204, 153 }, |
63 | { 102, 153, 153 }, { 102, 102, 153 }, { 102, 51, 153 }, { 102, 0, 153 }, | 62 | { 102, 153, 153 }, { 102, 102, 153 }, { 102, 51, 153 }, { 102, 0, 153 }, |
64 | { 51, 255, 255 }, { 51, 204, 255 }, { 51, 153, 255 }, { 51, 102, 255 }, | 63 | { 51, 255, 255 }, { 51, 204, 255 }, { 51, 153, 255 }, { 51, 102, 255 }, |
65 | { 51, 51, 255 }, { 51, 0, 255 }, { 51, 255, 204 }, { 51, 204, 204 }, | 64 | { 51, 51, 255 }, { 51, 0, 255 }, { 51, 255, 204 }, { 51, 204, 204 }, |
66 | { 51, 153, 204 }, { 51, 102, 204 }, { 51, 51, 204 }, { 51, 0, 204 }, | 65 | { 51, 153, 204 }, { 51, 102, 204 }, { 51, 51, 204 }, { 51, 0, 204 }, |
67 | { 51, 255, 153 }, { 51, 204, 153 }, { 51, 153, 153 }, { 51, 102, 153 }, | 66 | { 51, 255, 153 }, { 51, 204, 153 }, { 51, 153, 153 }, { 51, 102, 153 }, |
68 | { 51, 51, 153 }, { 51, 0, 153 }, { 0, 255, 255 }, { 0, 204, 255 }, | 67 | { 51, 51, 153 }, { 51, 0, 153 }, { 0, 255, 255 }, { 0, 204, 255 }, |
69 | { 0, 153, 255 }, { 0, 102, 255 }, { 0, 51, 255 }, { 0, 0, 255 }, | 68 | { 0, 153, 255 }, { 0, 102, 255 }, { 0, 51, 255 }, { 0, 0, 255 }, |
70 | { 0, 255, 204 }, { 0, 204, 204 }, { 0, 153, 204 }, { 0, 102, 204 }, | 69 | { 0, 255, 204 }, { 0, 204, 204 }, { 0, 153, 204 }, { 0, 102, 204 }, |
71 | { 0, 51, 204 }, { 0, 0, 204 }, { 0, 255, 153 }, { 0, 204, 153 }, | 70 | { 0, 51, 204 }, { 0, 0, 204 }, { 0, 255, 153 }, { 0, 204, 153 }, |
72 | { 0, 153, 153 }, { 0, 102, 153 }, { 0, 51, 153 }, { 0, 0, 153 }, | 71 | { 0, 153, 153 }, { 0, 102, 153 }, { 0, 51, 153 }, { 0, 0, 153 }, |
73 | { 255, 255, 102 }, { 255, 204, 102 }, { 255, 153, 102 }, { 255, 102, 102 }, | 72 | { 255, 255, 102 }, { 255, 204, 102 }, { 255, 153, 102 }, { 255, 102, 102 }, |
74 | { 255, 51, 102 }, { 255, 0, 102 }, { 255, 255, 51 }, { 255, 204, 51 }, | 73 | { 255, 51, 102 }, { 255, 0, 102 }, { 255, 255, 51 }, { 255, 204, 51 }, |
75 | { 255, 153, 51 }, { 255, 102, 51 }, { 255, 51, 51 }, { 255, 0, 51 }, | 74 | { 255, 153, 51 }, { 255, 102, 51 }, { 255, 51, 51 }, { 255, 0, 51 }, |
76 | { 255, 255, 0 }, { 255, 204, 0 }, { 255, 153, 0 }, { 255, 102, 0 }, | 75 | { 255, 255, 0 }, { 255, 204, 0 }, { 255, 153, 0 }, { 255, 102, 0 }, |
77 | { 255, 51, 0 }, { 255, 0, 0 }, { 204, 255, 102 }, { 204, 204, 102 }, | 76 | { 255, 51, 0 }, { 255, 0, 0 }, { 204, 255, 102 }, { 204, 204, 102 }, |
78 | { 204, 153, 102 }, { 204, 102, 102 }, { 204, 51, 102 }, { 204, 0, 102 }, | 77 | { 204, 153, 102 }, { 204, 102, 102 }, { 204, 51, 102 }, { 204, 0, 102 }, |
79 | { 204, 255, 51 }, { 204, 204, 51 }, { 204, 153, 51 }, { 204, 102, 51 }, | 78 | { 204, 255, 51 }, { 204, 204, 51 }, { 204, 153, 51 }, { 204, 102, 51 }, |
80 | { 204, 51, 51 }, { 204, 0, 51 }, { 204, 255, 0 }, { 204, 204, 0 }, | 79 | { 204, 51, 51 }, { 204, 0, 51 }, { 204, 255, 0 }, { 204, 204, 0 }, |
81 | { 204, 153, 0 }, { 204, 102, 0 }, { 204, 51, 0 }, { 204, 0, 0 }, | 80 | { 204, 153, 0 }, { 204, 102, 0 }, { 204, 51, 0 }, { 204, 0, 0 }, |
82 | { 153, 255, 102 }, { 153, 204, 102 }, { 153, 153, 102 }, { 153, 102, 102 }, | 81 | { 153, 255, 102 }, { 153, 204, 102 }, { 153, 153, 102 }, { 153, 102, 102 }, |
83 | { 153, 51, 102 }, { 153, 0, 102 }, { 153, 255, 51 }, { 153, 204, 51 }, | 82 | { 153, 51, 102 }, { 153, 0, 102 }, { 153, 255, 51 }, { 153, 204, 51 }, |
84 | { 153, 153, 51 }, { 153, 102, 51 }, { 153, 51, 51 }, { 153, 0, 51 }, | 83 | { 153, 153, 51 }, { 153, 102, 51 }, { 153, 51, 51 }, { 153, 0, 51 }, |
85 | { 153, 255, 0 }, { 153, 204, 0 }, { 153, 153, 0 }, { 153, 102, 0 }, | 84 | { 153, 255, 0 }, { 153, 204, 0 }, { 153, 153, 0 }, { 153, 102, 0 }, |
86 | { 153, 51, 0 }, { 153, 0, 0 }, { 102, 255, 102 }, { 102, 204, 102 }, | 85 | { 153, 51, 0 }, { 153, 0, 0 }, { 102, 255, 102 }, { 102, 204, 102 }, |
87 | { 102, 153, 102 }, { 102, 102, 102 }, { 102, 51, 102 }, { 102, 0, 102 }, | 86 | { 102, 153, 102 }, { 102, 102, 102 }, { 102, 51, 102 }, { 102, 0, 102 }, |
88 | { 102, 255, 51 }, { 102, 204, 51 }, { 102, 153, 51 }, { 102, 102, 51 }, | 87 | { 102, 255, 51 }, { 102, 204, 51 }, { 102, 153, 51 }, { 102, 102, 51 }, |
89 | { 102, 51, 51 }, { 102, 0, 51 }, { 102, 255, 0 }, { 102, 204, 0 }, | 88 | { 102, 51, 51 }, { 102, 0, 51 }, { 102, 255, 0 }, { 102, 204, 0 }, |
90 | { 102, 153, 0 }, { 102, 102, 0 }, { 102, 51, 0 }, { 102, 0, 0 }, | 89 | { 102, 153, 0 }, { 102, 102, 0 }, { 102, 51, 0 }, { 102, 0, 0 }, |
91 | { 51, 255, 102 }, { 51, 204, 102 }, { 51, 153, 102 }, { 51, 102, 102 }, | 90 | { 51, 255, 102 }, { 51, 204, 102 }, { 51, 153, 102 }, { 51, 102, 102 }, |
92 | { 51, 51, 102 }, { 51, 0, 102 }, { 51, 255, 51 }, { 51, 204, 51 }, | 91 | { 51, 51, 102 }, { 51, 0, 102 }, { 51, 255, 51 }, { 51, 204, 51 }, |
93 | { 51, 153, 51 }, { 51, 102, 51 }, { 51, 51, 51 }, { 51, 0, 51 }, | 92 | { 51, 153, 51 }, { 51, 102, 51 }, { 51, 51, 51 }, { 51, 0, 51 }, |
94 | { 51, 255, 0 }, { 51, 204, 0 }, { 51, 153, 0 }, { 51, 102, 0 }, | 93 | { 51, 255, 0 }, { 51, 204, 0 }, { 51, 153, 0 }, { 51, 102, 0 }, |
95 | { 51, 51, 0 }, { 51, 0, 0 }, { 0, 255, 102 }, { 0, 204, 102 }, | 94 | { 51, 51, 0 }, { 51, 0, 0 }, { 0, 255, 102 }, { 0, 204, 102 }, |
96 | { 0, 153, 102 }, { 0, 102, 102 }, { 0, 51, 102 }, { 0, 0, 102 }, | 95 | { 0, 153, 102 }, { 0, 102, 102 }, { 0, 51, 102 }, { 0, 0, 102 }, |
97 | { 0, 255, 51 }, { 0, 204, 51 }, { 0, 153, 51 }, { 0, 102, 51 }, | 96 | { 0, 255, 51 }, { 0, 204, 51 }, { 0, 153, 51 }, { 0, 102, 51 }, |
98 | { 0, 51, 51 }, { 0, 0, 51 }, { 0, 255, 0 }, { 0, 204, 0 }, | 97 | { 0, 51, 51 }, { 0, 0, 51 }, { 0, 255, 0 }, { 0, 204, 0 }, |
99 | { 0, 153, 0 }, { 0, 102, 0 }, { 0, 51, 0 }, { 17, 17, 17 }, | 98 | { 0, 153, 0 }, { 0, 102, 0 }, { 0, 51, 0 }, { 17, 17, 17 }, |
100 | { 34, 34, 34 }, { 68, 68, 68 }, { 85, 85, 85 }, { 119, 119, 119 }, | 99 | { 34, 34, 34 }, { 68, 68, 68 }, { 85, 85, 85 }, { 119, 119, 119 }, |
101 | { 136, 136, 136 }, { 170, 170, 170 }, { 187, 187, 187 }, { 221, 221, 221 }, | 100 | { 136, 136, 136 }, { 170, 170, 170 }, { 187, 187, 187 }, { 221, 221, 221 }, |
102 | { 238, 238, 238 }, { 192, 192, 192 }, { 128, 0, 0 }, { 128, 0, 128 }, | 101 | { 238, 238, 238 }, { 192, 192, 192 }, { 128, 0, 0 }, { 128, 0, 128 }, |
103 | { 0, 128, 0 }, { 0, 128, 128 }, { 0, 0, 0 }, { 0, 0, 0 }, | 102 | { 0, 128, 0 }, { 0, 128, 128 }, { 0, 0, 0 }, { 0, 0, 0 }, |
104 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 103 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
105 | { 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 }, |
106 | { 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 }, |
107 | { 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 }, |
108 | { 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 }, |
109 | { 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 }}; |
110 | 109 | ||
111 | static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }}; | 110 | static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }}; |
112 | 111 | ||
113 | static ColorMapEntry Palm2BitColormap[] = { | 112 | static ColorMapEntry Palm2BitColormap[] = { |
114 | { 255, 255, 255 }, { 192, 192, 192 }, { 128, 128, 128 }, { 0, 0, 0 }}; | 113 | { 255, 255, 255 }, { 192, 192, 192 }, { 128, 128, 128 }, { 0, 0, 0 }}; |
115 | 114 | ||
116 | static ColorMapEntry Palm4BitColormap[] = { | 115 | static ColorMapEntry Palm4BitColormap[] = { |
117 | { 255, 255, 255 }, { 238, 238, 238 }, { 221, 221, 221 }, { 204, 204, 204 }, | 116 | { 255, 255, 255 }, { 238, 238, 238 }, { 221, 221, 221 }, { 204, 204, 204 }, |
118 | { 187, 187, 187 }, { 170, 170, 170 }, { 153, 153, 153 }, { 136, 136, 136 }, | 117 | { 187, 187, 187 }, { 170, 170, 170 }, { 153, 153, 153 }, { 136, 136, 136 }, |
119 | { 119, 119, 119 }, { 102, 102, 102 }, { 85, 85, 85 }, { 68, 68, 68 }, | 118 | { 119, 119, 119 }, { 102, 102, 102 }, { 85, 85, 85 }, { 68, 68, 68 }, |
120 | { 51, 51, 51 }, { 34, 34, 34 }, { 17, 17, 17 }, { 0, 0, 0 }}; | 119 | { 51, 51, 51 }, { 34, 34, 34 }, { 17, 17, 17 }, { 0, 0, 0 }}; |
121 | 120 | ||
122 | QImage* Palm2QImage | 121 | QImage* Palm2QImage |
123 | (unsigned char *image_bytes_in, int byte_count_in) | 122 | (unsigned char *image_bytes_in, int byte_count_in) |
124 | { | 123 | { |
125 | unsigned int width, height, bytes_per_row, flags, next_depth_offset; | 124 | unsigned int width, height, bytes_per_row, flags, next_depth_offset; |
126 | unsigned int bits_per_pixel, version, transparent_index, compression_type, i, j, inval, inbit, mask, incount; | 125 | unsigned int bits_per_pixel, version, transparent_index, compression_type, i, j, inval, inbit, mask, incount; |
127 | unsigned int palm_red_bits, palm_green_bits, palm_blue_bits; | 126 | unsigned int palm_red_bits, palm_green_bits, palm_blue_bits; |
128 | unsigned char *palm_ptr, *x_ptr, *imagedata, *inbyte, *rowbuf, *lastrow, | 127 | unsigned char *palm_ptr, *x_ptr, *imagedata, *inbyte, *rowbuf, *lastrow, |
129 | *imagedatastart, *palmimage; | 128 | *imagedatastart, *palmimage; |
130 | ColorMapEntry *colormap; | 129 | ColorMapEntry *colormap; |
131 | 130 | ||
132 | palmimage = image_bytes_in; | 131 | palmimage = image_bytes_in; |
133 | width = READ_BIGENDIAN_SHORT(palmimage + 0); | 132 | width = READ_BIGENDIAN_SHORT(palmimage + 0); |
134 | height = READ_BIGENDIAN_SHORT(palmimage + 2); | 133 | height = READ_BIGENDIAN_SHORT(palmimage + 2); |
135 | bytes_per_row = READ_BIGENDIAN_SHORT(palmimage + 4); | 134 | bytes_per_row = READ_BIGENDIAN_SHORT(palmimage + 4); |
136 | flags = READ_BIGENDIAN_SHORT(palmimage + 6); | 135 | flags = READ_BIGENDIAN_SHORT(palmimage + 6); |
137 | bits_per_pixel = palmimage[8]; | 136 | bits_per_pixel = palmimage[8]; |
138 | version = palmimage[9]; | 137 | version = palmimage[9]; |
139 | next_depth_offset = READ_BIGENDIAN_SHORT(palmimage + 10); | 138 | next_depth_offset = READ_BIGENDIAN_SHORT(palmimage + 10); |
140 | transparent_index = palmimage[12]; | 139 | transparent_index = palmimage[12]; |
141 | compression_type = palmimage[13]; | 140 | compression_type = palmimage[13]; |
142 | /* bytes 14 and 15 are reserved by Palm and always 0 */ | 141 | /* bytes 14 and 15 are reserved by Palm and always 0 */ |
143 | 142 | ||
144 | #if 0 | 143 | #if 0 |
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); | 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); |
146 | #endif | 145 | #endif |
147 | 146 | ||
148 | if (compression_type == PALM_COMPRESSION_PACKBITS) { | 147 | if (compression_type == PALM_COMPRESSION_PACKBITS) { |
149 | // qDebug ("Image uses packbits compression; not yet supported"); | 148 | // qDebug ("Image uses packbits compression; not yet supported"); |
150 | return NULL; | 149 | return NULL; |
151 | } else if ((compression_type != PALM_COMPRESSION_NONE) && | 150 | } else if ((compression_type != PALM_COMPRESSION_NONE) && |
152 | (compression_type != PALM_COMPRESSION_RLE) && | 151 | (compression_type != PALM_COMPRESSION_RLE) && |
153 | (compression_type != PALM_COMPRESSION_SCANLINE)) { | 152 | (compression_type != PALM_COMPRESSION_SCANLINE)) { |
154 | // qDebug ("Image uses unknown compression, code 0x%x", compression_type); | 153 | // qDebug ("Image uses unknown compression, code 0x%x", compression_type); |
155 | return NULL; | 154 | return NULL; |
156 | } | 155 | } |
157 | 156 | ||
158 | /* as of PalmOS 4.0, there are 6 different kinds of Palm pixmaps: | 157 | /* as of PalmOS 4.0, there are 6 different kinds of Palm pixmaps: |
159 | 158 | ||
160 | 1, 2, or 4 bit grayscale | 159 | 1, 2, or 4 bit grayscale |
161 | 8-bit StaticColor using the Palm standard colormap | 160 | 8-bit StaticColor using the Palm standard colormap |
162 | 8-bit PseudoColor using a user-specified colormap | 161 | 8-bit PseudoColor using a user-specified colormap |
163 | 16-bit DirectColor using 5 bits for red, 6 for green, and 5 for blue | 162 | 16-bit DirectColor using 5 bits for red, 6 for green, and 5 for blue |
164 | 163 | ||
165 | Each of these can be compressed with one of four compression schemes, | 164 | Each of these can be compressed with one of four compression schemes, |
166 | "RLE", "Scanline", "PackBits", or none. | 165 | "RLE", "Scanline", "PackBits", or none. |
167 | 166 | ||
168 | We begin by constructing the colormap. | 167 | We begin by constructing the colormap. |
169 | */ | 168 | */ |
170 | 169 | ||
171 | if (flags & PALM_HAS_COLORMAP_FLAG) { | 170 | if (flags & PALM_HAS_COLORMAP_FLAG) { |
172 | // qDebug("Palm images with custom colormaps are not currently supported.\n"); | 171 | // qDebug("Palm images with custom colormaps are not currently supported.\n"); |
173 | return NULL; | 172 | return NULL; |
174 | } else if (bits_per_pixel == 1) { | 173 | } else if (bits_per_pixel == 1) { |
175 | colormap = Palm1BitColormap; | 174 | colormap = Palm1BitColormap; |
176 | imagedatastart = palmimage + 16; | 175 | imagedatastart = palmimage + 16; |
177 | } else if (bits_per_pixel == 2) { | 176 | } else if (bits_per_pixel == 2) { |
178 | colormap = Palm2BitColormap; | 177 | colormap = Palm2BitColormap; |
179 | imagedatastart = palmimage + 16; | 178 | imagedatastart = palmimage + 16; |
180 | } else if (bits_per_pixel == 4) { | 179 | } else if (bits_per_pixel == 4) { |
181 | colormap = Palm4BitColormap; | 180 | colormap = Palm4BitColormap; |
182 | imagedatastart = palmimage + 16; | 181 | imagedatastart = palmimage + 16; |
183 | } else if (bits_per_pixel == 8) { | 182 | } else if (bits_per_pixel == 8) { |
184 | colormap = Palm8BitColormap; | 183 | colormap = Palm8BitColormap; |
185 | imagedatastart = palmimage + 16; | 184 | imagedatastart = palmimage + 16; |
186 | } else if (bits_per_pixel == 16 && (flags & PALM_DIRECT_COLOR_FLAG)) { | 185 | } else if (bits_per_pixel == 16 && (flags & PALM_DIRECT_COLOR_FLAG)) { |
187 | colormap = NULL; | 186 | colormap = NULL; |
188 | palm_red_bits = palmimage[16]; | 187 | palm_red_bits = palmimage[16]; |
189 | palm_green_bits = palmimage[17]; | 188 | palm_green_bits = palmimage[17]; |
190 | palm_blue_bits = palmimage[18]; | 189 | palm_blue_bits = palmimage[18]; |
191 | // qDebug("Bits:%d, %d, %d", palm_red_bits, palm_green_bits, palm_blue_bits); | 190 | // qDebug("Bits:%d, %d, %d", palm_red_bits, palm_green_bits, palm_blue_bits); |
192 | if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) { | 191 | if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) { |
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); | 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); |
194 | return NULL; | 193 | return NULL; |
195 | } | 194 | } |
196 | if (bits_per_pixel > (8 * sizeof(unsigned long))) { | 195 | if (bits_per_pixel > (8 * sizeof(unsigned long))) { |
197 | // qDebug ("Can't handle this format DirectColor image -- too many bits per pixel (%d)\n", bits_per_pixel); | 196 | // qDebug ("Can't handle this format DirectColor image -- too many bits per pixel (%d)\n", bits_per_pixel); |
198 | return NULL; | 197 | return NULL; |
199 | } | 198 | } |
200 | imagedatastart = palmimage + 24; | 199 | imagedatastart = palmimage + 24; |
201 | } else { | 200 | } else { |
202 | // qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel); | 201 | // qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel); |
203 | return NULL; | 202 | return NULL; |
204 | } | 203 | } |
205 | 204 | ||
206 | #ifndef USEQPE | 205 | #ifndef USEQPE |
207 | QImage* qimage = new QImage(width, height, 32); | 206 | QImage* qimage = new QImage(width, height, 32); |
208 | #else | 207 | #else |
209 | QImage* qimage = new QImage(width, height, 16); | 208 | QImage* qimage = new QImage(width, height, 16); |
210 | #endif | 209 | #endif |
211 | 210 | ||
212 | /* row by row, uncompress the Palm image and copy it to the JPEG buffer */ | 211 | /* row by row, uncompress the Palm image and copy it to the JPEG buffer */ |
213 | rowbuf = new unsigned char[bytes_per_row * width]; | 212 | rowbuf = new unsigned char[bytes_per_row * width]; |
214 | lastrow = new unsigned char[bytes_per_row * width]; | 213 | lastrow = new unsigned char[bytes_per_row * width]; |
215 | 214 | ||
216 | for (i=0, palm_ptr = imagedatastart , x_ptr = imagedata; i < height; ++i) { | 215 | for (i=0, palm_ptr = imagedatastart , x_ptr = imagedata; i < height; ++i) { |
217 | // qDebug("inval:%x palm_ptr:%x x_ptr:%x bpr:%x", inval, palm_ptr, x_ptr, bytes_per_row); | 216 | // qDebug("inval:%x palm_ptr:%x x_ptr:%x bpr:%x", inval, palm_ptr, x_ptr, bytes_per_row); |
218 | 217 | ||
219 | /* first, uncompress the Palm image */ | 218 | /* first, uncompress the Palm image */ |
220 | if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_RLE)) { | 219 | if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_RLE)) { |
221 | for (j = 0; j < bytes_per_row; ) { | 220 | for (j = 0; j < bytes_per_row; ) { |
222 | incount = *palm_ptr++; | 221 | incount = *palm_ptr++; |
223 | inval = *palm_ptr++; | 222 | inval = *palm_ptr++; |
224 | memset(rowbuf + j, inval, incount); | 223 | memset(rowbuf + j, inval, incount); |
225 | j += incount; | 224 | j += incount; |
226 | } | 225 | } |
227 | } else if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_SCANLINE)) { | 226 | } else if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_SCANLINE)) { |
228 | for (j = 0; j < bytes_per_row; j += 8) { | 227 | for (j = 0; j < bytes_per_row; j += 8) { |
229 | incount = *palm_ptr++; | 228 | incount = *palm_ptr++; |
230 | inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8; | 229 | inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8; |
231 | for (inbit = 0; inbit < inval; inbit += 1) { | 230 | for (inbit = 0; inbit < inval; inbit += 1) { |
232 | if (incount & (1 << (7 - inbit))) | 231 | if (incount & (1 << (7 - inbit))) |
233 | rowbuf[j + inbit] = *palm_ptr++; | 232 | rowbuf[j + inbit] = *palm_ptr++; |
234 | else | 233 | else |
235 | rowbuf[j + inbit] = lastrow[j + inbit]; | 234 | rowbuf[j + inbit] = lastrow[j + inbit]; |
236 | } | 235 | } |
237 | } | 236 | } |
238 | memcpy (lastrow, rowbuf, bytes_per_row); | 237 | memcpy (lastrow, rowbuf, bytes_per_row); |
239 | } else if (((flags & PALM_IS_COMPRESSED_FLAG) && | 238 | } else if (((flags & PALM_IS_COMPRESSED_FLAG) && |
240 | (compression_type == PALM_COMPRESSION_NONE)) || | 239 | (compression_type == PALM_COMPRESSION_NONE)) || |
241 | ((flags & PALM_IS_COMPRESSED_FLAG) == 0)) | 240 | ((flags & PALM_IS_COMPRESSED_FLAG) == 0)) |
242 | { | 241 | { |
243 | memcpy (rowbuf, palm_ptr, bytes_per_row); | 242 | memcpy (rowbuf, palm_ptr, bytes_per_row); |
244 | palm_ptr += bytes_per_row; | 243 | palm_ptr += bytes_per_row; |
245 | } | 244 | } |
246 | else { | 245 | else { |
247 | qDebug("Case 4"); | 246 | qDebug("Case 4"); |
248 | qDebug("Is compressed:%s", ((flags & PALM_IS_COMPRESSED_FLAG) == 0) ? "false" : "true"); | 247 | qDebug("Is compressed:%s", ((flags & PALM_IS_COMPRESSED_FLAG) == 0) ? "false" : "true"); |
249 | qDebug("Has colourmap:%s", ((flags & PALM_HAS_COLORMAP_FLAG) == 0) ? "false" : "true"); | 248 | qDebug("Has colourmap:%s", ((flags & PALM_HAS_COLORMAP_FLAG) == 0) ? "false" : "true"); |
250 | qDebug("Has transparency:%s", ((flags & PALM_HAS_TRANSPARENCY_FLAG) == 0) ? "false" : "true"); | 249 | qDebug("Has transparency:%s", ((flags & PALM_HAS_TRANSPARENCY_FLAG) == 0) ? "false" : "true"); |
251 | qDebug("Direct colour:%s", ((flags & PALM_DIRECT_COLOR_FLAG) == 0) ? "false" : "true"); | 250 | qDebug("Direct colour:%s", ((flags & PALM_DIRECT_COLOR_FLAG) == 0) ? "false" : "true"); |
252 | qDebug("four byte field:%s", ((flags & PALM_4_BYTE_FIELD_FLAG) == 0) ? "false" : "true"); | 251 | qDebug("four byte field:%s", ((flags & PALM_4_BYTE_FIELD_FLAG) == 0) ? "false" : "true"); |
253 | memcpy (rowbuf, palm_ptr, bytes_per_row); | 252 | memcpy (rowbuf, palm_ptr, bytes_per_row); |
254 | palm_ptr += bytes_per_row; | 253 | palm_ptr += bytes_per_row; |
255 | } | 254 | } |
256 | /* next, write it to the GDK bitmap */ | 255 | /* next, write it to the GDK bitmap */ |
257 | if (colormap) { | 256 | if (colormap) { |
258 | mask = (1 << bits_per_pixel) - 1; | 257 | mask = (1 << bits_per_pixel) - 1; |
259 | for (inbit = 8 - bits_per_pixel, inbyte = rowbuf, j = 0; j < width; ++j) { | 258 | for (inbit = 8 - bits_per_pixel, inbyte = rowbuf, j = 0; j < width; ++j) { |
260 | inval = ((*inbyte) & (mask << inbit)) >> inbit; | 259 | inval = ((*inbyte) & (mask << inbit)) >> inbit; |
261 | /* correct for oddity of the 8-bit color Palm pixmap... */ | 260 | /* correct for oddity of the 8-bit color Palm pixmap... */ |
262 | if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231; | 261 | if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231; |
263 | /* now lookup the correct color and set the pixel in the GTK bitmap */ | 262 | /* now lookup the correct color and set the pixel in the GTK bitmap */ |
264 | QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue); | 263 | QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue); |
265 | qimage->setPixel(j, i, colour); | 264 | qimage->setPixel(j, i, colour); |
266 | if (!inbit) { | 265 | if (!inbit) { |
267 | ++inbyte; | 266 | ++inbyte; |
268 | inbit = 8 - bits_per_pixel; | 267 | inbit = 8 - bits_per_pixel; |
269 | } else { | 268 | } else { |
270 | inbit -= bits_per_pixel; | 269 | inbit -= bits_per_pixel; |
271 | } | 270 | } |
272 | } | 271 | } |
273 | } else if (!colormap && | 272 | } else if (!colormap && |
274 | bits_per_pixel == 16) { | 273 | bits_per_pixel == 16) { |
275 | for (inbyte = rowbuf, j = 0; j < width; ++j) { | 274 | for (inbyte = rowbuf, j = 0; j < width; ++j) { |
276 | inval = ((unsigned short)inbyte[0] << (unsigned short)8) | inbyte[1]; | 275 | inval = ((unsigned short)inbyte[0] << (unsigned short)8) | inbyte[1]; |
277 | 276 | ||
278 | /* | 277 | /* |
279 | qDebug ("pixel is %d,%d (%d:%d:%d)", | 278 | qDebug ("pixel is %d,%d (%d:%d:%d)", |
280 | j, i, | 279 | j, i, |
281 | ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), | 280 | ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), |
282 | ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), | 281 | ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), |
283 | ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); | 282 | ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); |
284 | */ | 283 | */ |
285 | QRgb colour = qRgb( | 284 | QRgb colour = qRgb( |
286 | ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), | 285 | ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), |
287 | ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), | 286 | ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), |
288 | ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); | 287 | ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); |
289 | qimage->setPixel(j, i, colour); | 288 | qimage->setPixel(j, i, colour); |
290 | inbyte += 2; | 289 | inbyte += 2; |
291 | } | 290 | } |
292 | } | 291 | } |
293 | } | 292 | } |
294 | 293 | ||
295 | delete [] rowbuf; | 294 | delete [] rowbuf; |
296 | delete [] lastrow; | 295 | delete [] lastrow; |
297 | 296 | ||
298 | return qimage; | 297 | return qimage; |
299 | } | 298 | } |
diff --git a/noncore/apps/opie-reader/PluckerCodec/PluckerCodec.pro b/noncore/apps/opie-reader/PluckerCodec/PluckerCodec.pro index 6ed4032..7042542 100644 --- a/noncore/apps/opie-reader/PluckerCodec/PluckerCodec.pro +++ b/noncore/apps/opie-reader/PluckerCodec/PluckerCodec.pro | |||
@@ -1,18 +1,18 @@ | |||
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 = plucker.h | 5 | HEADERS = plucker.h |
6 | 6 | ||
7 | SOURCES = plucker.cpp \ | 7 | SOURCES = plucker.cpp \ |
8 | Palm2QImage.cpp | 8 | Palm2QImage.cpp |
9 | 9 | ||
10 | INTERFACES= | 10 | INTERFACES= |
11 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | 11 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs |
12 | TARGET = Plucker | 12 | TARGET = Plucker |
13 | LIBS += -lreader_pdb -lreader_pluckerbase -lreader_codec | 13 | LIBS += -lreader_pdb -lreader_pluckerbase -lreader_codec |
14 | 14 | ||
15 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 15 | INCLUDEPATH+= $(OPIEDIR)/include |
16 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 16 | DEPENDPATH+= $(OPIEDIR)/include |
17 | 17 | ||
18 | include ( $(OPIEDIR)/include.pro ) | 18 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp index dfdba28..33884a0 100644 --- a/noncore/apps/opie-reader/QTReader.cpp +++ b/noncore/apps/opie-reader/QTReader.cpp | |||
@@ -1,2986 +1,2985 @@ | |||
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 "useqpe.h" | ||
14 | #include <qpainter.h> | 13 | #include <qpainter.h> |
15 | //#include <qdirectpainter_qws.h> | 14 | //#include <qdirectpainter_qws.h> |
16 | #include <qimage.h> | 15 | #include <qimage.h> |
17 | #include <qtimer.h> | 16 | #include <qtimer.h> |
18 | #include "config.h" | 17 | #include "config.h" |
19 | #include "QTReader.h" | 18 | #include "QTReader.h" |
20 | //#include "QTReaderApp.h" | 19 | //#include "QTReaderApp.h" |
21 | #include "CDrawBuffer.h" | 20 | #include "CDrawBuffer.h" |
22 | #ifdef USEQPE | 21 | #ifdef USEQPE |
23 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
24 | #endif | 23 | #endif |
25 | #include <math.h> | 24 | #include <math.h> |
26 | #include <ctype.h> | 25 | #include <ctype.h> |
27 | #include <stdio.h> //for sprintf | 26 | #include <stdio.h> //for sprintf |
28 | #ifdef USEQPE | 27 | #ifdef USEQPE |
29 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
30 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
31 | #include <qpe/global.h> | 30 | #include <qpe/global.h> |
32 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
33 | #endif | 32 | #endif |
34 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
35 | #include <qdir.h> | 34 | #include <qdir.h> |
36 | 35 | ||
37 | #ifdef _UNICODE | 36 | #ifdef _UNICODE |
38 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; | 37 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; |
39 | #else | 38 | #else |
40 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; | 39 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; |
41 | #endif | 40 | #endif |
42 | //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; | 41 | //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; |
43 | 42 | ||
44 | //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; | 43 | //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; |
45 | //const int QTReader::fontsizes[] = {10,16,17,22,0}; | 44 | //const int QTReader::fontsizes[] = {10,16,17,22,0}; |
46 | //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; | 45 | //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; |
47 | //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}; | 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}; |
48 | 47 | ||
49 | 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 }; | 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 }; |
50 | tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; | 49 | tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; |
51 | //tchar QTReader::jplucknextpart[] = { 10,'#',10,'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; | 50 | //tchar QTReader::jplucknextpart[] = { 10,'#',10,'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; |
52 | 51 | ||
53 | 52 | ||
54 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : | 53 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : |
55 | QWidget(parent, name, f), | 54 | QWidget(parent, name, f), |
56 | m_default_fg(0,0,0), | 55 | m_default_fg(0,0,0), |
57 | m_default_bg(255,255,255), | 56 | m_default_bg(255,255,255), |
58 | m_bg(255,255,255), | 57 | m_bg(255,255,255), |
59 | m_delay(100), | 58 | m_delay(100), |
60 | m_scrolldy1(0), | 59 | m_scrolldy1(0), |
61 | m_scrolldy2(0), | 60 | m_scrolldy2(0), |
62 | m_totalscroll(0), | 61 | m_totalscroll(0), |
63 | m_autoScroll(false), | 62 | m_autoScroll(false), |
64 | //textarray(NULL), | 63 | //textarray(NULL), |
65 | //locnarray(NULL), | 64 | //locnarray(NULL), |
66 | numlines(0), | 65 | numlines(0), |
67 | m_fontname("unifont"), | 66 | m_fontname("unifont"), |
68 | m_fm(NULL), | 67 | m_fm(NULL), |
69 | mouseUpOn(true), | 68 | mouseUpOn(true), |
70 | m_twotouch(true), | 69 | m_twotouch(true), |
71 | m_touchone(true), | 70 | m_touchone(true), |
72 | bDoUpdates(false), | 71 | bDoUpdates(false), |
73 | #ifdef _SCROLLPIPE | 72 | #ifdef _SCROLLPIPE |
74 | m_pipeout(NULL), | 73 | m_pipeout(NULL), |
75 | #endif | 74 | #endif |
76 | m_left_border(2), | 75 | m_left_border(2), |
77 | m_right_border(2), | 76 | m_right_border(2), |
78 | m_rotated(true), | 77 | m_rotated(true), |
79 | pBkmklist(NULL), | 78 | pBkmklist(NULL), |
80 | m_scrollpos(0), | 79 | m_scrollpos(0), |
81 | // bNegative(false), | 80 | // bNegative(false), |
82 | bInverse(false), | 81 | bInverse(false), |
83 | m_highlightfilter(NULL), | 82 | m_highlightfilter(NULL), |
84 | m_bgIsScaled(false), | 83 | m_bgIsScaled(false), |
85 | m_scrollstep(2), | 84 | m_scrollstep(2), |
86 | m_topmargin(5), | 85 | m_topmargin(5), |
87 | m_bottommargin(5), | 86 | m_bottommargin(5), |
88 | m_reparastring("{\\n[\\n ]}"), | 87 | m_reparastring("{\\n[\\n ]}"), |
89 | m_currentlinkstyle(NULL), | 88 | m_currentlinkstyle(NULL), |
90 | m_currentlinkoffset(-1), | 89 | m_currentlinkoffset(-1), |
91 | m_currentlink(-1) | 90 | m_currentlink(-1) |
92 | { | 91 | { |
93 | m_overlap = 1; | 92 | m_overlap = 1; |
94 | setKeyCompression ( true ); | 93 | setKeyCompression ( true ); |
95 | #ifdef DOUBLEBUFFER | 94 | #ifdef DOUBLEBUFFER |
96 | dbuff = new QPixmap(); | 95 | dbuff = new QPixmap(); |
97 | dbp = new QPainter(); | 96 | dbp = new QPainter(); |
98 | // if (painter->isActive()) painter->end(); | 97 | // if (painter->isActive()) painter->end(); |
99 | // painter->begin(frame); | 98 | // painter->begin(frame); |
100 | #endif | 99 | #endif |
101 | // init(); | 100 | // init(); |
102 | 101 | ||
103 | } | 102 | } |
104 | 103 | ||
105 | /* | 104 | /* |
106 | 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) : |
107 | QWidget(parent, name, f), | 106 | QWidget(parent, name, f), |
108 | m_textfont(0), | 107 | m_textfont(0), |
109 | m_textsize(1), | 108 | m_textsize(1), |
110 | textarray(NULL), | 109 | textarray(NULL), |
111 | numlines(0), | 110 | numlines(0), |
112 | bstripcr(true), | 111 | bstripcr(true), |
113 | bunindent(false), | 112 | bunindent(false), |
114 | brepara(false), | 113 | brepara(false), |
115 | bdblspce(false), | 114 | bdblspce(false), |
116 | btight(false), | 115 | btight(false), |
117 | bindenter(0), | 116 | bindenter(0), |
118 | m_fm(NULL) | 117 | m_fm(NULL) |
119 | { | 118 | { |
120 | init(); | 119 | init(); |
121 | // // qDebug("Load_file(1)"); | 120 | // // qDebug("Load_file(1)"); |
122 | load_file((const tchar*)filename); | 121 | load_file((const tchar*)filename); |
123 | } | 122 | } |
124 | */ | 123 | */ |
125 | 124 | ||
126 | /* | 125 | /* |
127 | void QTReader::mouseMoveEvent(QMouseEvent* _e) | 126 | void QTReader::mouseMoveEvent(QMouseEvent* _e) |
128 | { | 127 | { |
129 | 128 | ||
130 | mouseUpOn = !(_e->pos().x() == -1); | 129 | mouseUpOn = !(_e->pos().x() == -1); |
131 | 130 | ||
132 | qDebug("MouseMove:[%d, %d]", _e->pos().x(), _e->pos().y()); | 131 | qDebug("MouseMove:[%d, %d]", _e->pos().x(), _e->pos().y()); |
133 | } | 132 | } |
134 | */ | 133 | */ |
135 | long QTReader::real_delay() | 134 | long QTReader::real_delay() |
136 | { | 135 | { |
137 | return m_scrollstep*( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); | 136 | return m_scrollstep*( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); |
138 | } | 137 | } |
139 | 138 | ||
140 | void QTReader::mousePressEvent( QMouseEvent* _e ) | 139 | void QTReader::mousePressEvent( QMouseEvent* _e ) |
141 | { | 140 | { |
142 | buffdoc.unsuspend(); | 141 | buffdoc.unsuspend(); |
143 | int x, y, ht, wh; | 142 | int x, y, ht, wh; |
144 | if (m_rotated) | 143 | if (m_rotated) |
145 | { | 144 | { |
146 | x = _e->y(); | 145 | x = _e->y(); |
147 | y = width()-_e->x(); | 146 | y = width()-_e->x(); |
148 | ht = width(); | 147 | ht = width(); |
149 | wh = height(); | 148 | wh = height(); |
150 | } | 149 | } |
151 | else | 150 | else |
152 | { | 151 | { |
153 | x = _e->x(); | 152 | x = _e->x(); |
154 | y = _e->y(); | 153 | y = _e->y(); |
155 | ht = height(); | 154 | ht = height(); |
156 | wh = width(); | 155 | wh = width(); |
157 | } | 156 | } |
158 | if (_e->button() == RightButton) | 157 | if (_e->button() == RightButton) |
159 | { | 158 | { |
160 | //qDebug("MousePress"); | 159 | //qDebug("MousePress"); |
161 | mouseUpOn = false; | 160 | mouseUpOn = false; |
162 | if (m_swapmouse) | 161 | if (m_swapmouse) |
163 | { | 162 | { |
164 | int lineno = 0; | 163 | int lineno = 0; |
165 | /* | 164 | /* |
166 | int hgt = textarray[0]->lineSpacing(); | 165 | int hgt = textarray[0]->lineSpacing(); |
167 | while ((hgt < y) && (lineno < numlines)) | 166 | while ((hgt < y) && (lineno < numlines)) |
168 | { | 167 | { |
169 | hgt += textarray[++lineno]->lineSpacing(); | 168 | hgt += textarray[++lineno]->lineSpacing(); |
170 | } | 169 | } |
171 | */ | 170 | */ |
172 | size_t startpos, startoffset, tgt, tgtoffset, pictgt; | 171 | size_t startpos, startoffset, tgt, tgtoffset, pictgt; |
173 | QImage* img; | 172 | QImage* img; |
174 | getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img); | 173 | getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img); |
175 | processmousewordevent(startpos, startoffset, _e, lineno); | 174 | processmousewordevent(startpos, startoffset, _e, lineno); |
176 | } | 175 | } |
177 | else | 176 | else |
178 | processmousepositionevent(_e); | 177 | processmousepositionevent(_e); |
179 | } | 178 | } |
180 | } | 179 | } |
181 | 180 | ||
182 | void QTReader::processmousepositionevent( QMouseEvent* _e ) | 181 | void QTReader::processmousepositionevent( QMouseEvent* _e ) |
183 | { | 182 | { |
184 | int x, y, ht, wh; | 183 | int x, y, ht, wh; |
185 | if (m_rotated) | 184 | if (m_rotated) |
186 | { | 185 | { |
187 | x = _e->y(); | 186 | x = _e->y(); |
188 | y = width()-_e->x(); | 187 | y = width()-_e->x(); |
189 | ht = width(); | 188 | ht = width(); |
190 | wh = height(); | 189 | wh = height(); |
191 | } | 190 | } |
192 | else | 191 | else |
193 | { | 192 | { |
194 | x = _e->x(); | 193 | x = _e->x(); |
195 | y = _e->y(); | 194 | y = _e->y(); |
196 | ht = height(); | 195 | ht = height(); |
197 | wh = width(); | 196 | wh = width(); |
198 | } | 197 | } |
199 | if (buffdoc.hasnavigation()) | 198 | if (buffdoc.hasnavigation()) |
200 | { | 199 | { |
201 | if (y > (2*ht)/3) | 200 | if (y > (2*ht)/3) |
202 | { | 201 | { |
203 | goDown(); | 202 | goDown(); |
204 | } | 203 | } |
205 | else if (y < ht/3) | 204 | else if (y < ht/3) |
206 | { | 205 | { |
207 | goUp(); | 206 | goUp(); |
208 | } | 207 | } |
209 | else | 208 | else |
210 | { | 209 | { |
211 | if (x < wh/3) | 210 | if (x < wh/3) |
212 | { | 211 | { |
213 | goBack(); | 212 | goBack(); |
214 | } | 213 | } |
215 | else if (x > (2*wh)/3) | 214 | else if (x > (2*wh)/3) |
216 | { | 215 | { |
217 | goForward(); | 216 | goForward(); |
218 | } | 217 | } |
219 | else | 218 | else |
220 | { | 219 | { |
221 | goHome(); | 220 | goHome(); |
222 | } | 221 | } |
223 | } | 222 | } |
224 | } | 223 | } |
225 | else | 224 | else |
226 | { | 225 | { |
227 | if (y > ht/2) | 226 | if (y > ht/2) |
228 | { | 227 | { |
229 | goDown(); | 228 | goDown(); |
230 | } | 229 | } |
231 | else | 230 | else |
232 | { | 231 | { |
233 | goUp(); | 232 | goUp(); |
234 | } | 233 | } |
235 | } | 234 | } |
236 | } | 235 | } |
237 | 236 | ||
238 | void QTReader::goHome() | 237 | void QTReader::goHome() |
239 | { | 238 | { |
240 | if (buffdoc.hasnavigation()) | 239 | if (buffdoc.hasnavigation()) |
241 | { | 240 | { |
242 | size_t current=pagelocate(); | 241 | size_t current=pagelocate(); |
243 | size_t home=buffdoc.getHome(); | 242 | size_t home=buffdoc.getHome(); |
244 | if (current!=home) | 243 | if (current!=home) |
245 | { | 244 | { |
246 | buffdoc.saveposn(m_lastfile, current); | 245 | buffdoc.saveposn(m_lastfile, current); |
247 | locate(home); | 246 | locate(home); |
248 | } | 247 | } |
249 | } | 248 | } |
250 | else | 249 | else |
251 | locate(0); | 250 | locate(0); |
252 | } | 251 | } |
253 | 252 | ||
254 | void QTReader::goBack() | 253 | void QTReader::goBack() |
255 | { | 254 | { |
256 | if (buffdoc.hasnavigation()) | 255 | if (buffdoc.hasnavigation()) |
257 | { | 256 | { |
258 | size_t target = pagelocate(); | 257 | size_t target = pagelocate(); |
259 | QString nxt = m_lastfile; | 258 | QString nxt = m_lastfile; |
260 | buffdoc.writeposn(m_lastfile, target); | 259 | buffdoc.writeposn(m_lastfile, target); |
261 | linkType lt = buffdoc.back(nxt, target); | 260 | linkType lt = buffdoc.back(nxt, target); |
262 | if ((lt & eFile) != 0) | 261 | if ((lt & eFile) != 0) |
263 | { | 262 | { |
264 | if (nxt != m_lastfile) | 263 | if (nxt != m_lastfile) |
265 | { | 264 | { |
266 | emit NewFileRequest(nxt); | 265 | emit NewFileRequest(nxt); |
267 | } | 266 | } |
268 | locate(target); | 267 | locate(target); |
269 | } | 268 | } |
270 | else if ((lt & eLink) != 0) | 269 | else if ((lt & eLink) != 0) |
271 | { | 270 | { |
272 | locate(target); | 271 | locate(target); |
273 | } | 272 | } |
274 | } | 273 | } |
275 | } | 274 | } |
276 | 275 | ||
277 | void QTReader::goForward() | 276 | void QTReader::goForward() |
278 | { | 277 | { |
279 | if (buffdoc.hasnavigation()) | 278 | if (buffdoc.hasnavigation()) |
280 | { | 279 | { |
281 | size_t target = pagelocate(); | 280 | size_t target = pagelocate(); |
282 | QString nxt = m_lastfile; | 281 | QString nxt = m_lastfile; |
283 | linkType lt = buffdoc.forward(nxt, target); | 282 | linkType lt = buffdoc.forward(nxt, target); |
284 | if ((lt & eFile) != 0) | 283 | if ((lt & eFile) != 0) |
285 | { | 284 | { |
286 | if (nxt != m_lastfile) | 285 | if (nxt != m_lastfile) |
287 | { | 286 | { |
288 | emit NewFileRequest(nxt); | 287 | emit NewFileRequest(nxt); |
289 | } | 288 | } |
290 | locate(target); | 289 | locate(target); |
291 | } | 290 | } |
292 | else if ((lt & eLink) != 0) | 291 | else if ((lt & eLink) != 0) |
293 | { | 292 | { |
294 | locate(target); | 293 | locate(target); |
295 | } | 294 | } |
296 | } | 295 | } |
297 | } | 296 | } |
298 | 297 | ||
299 | 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) | 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) |
300 | { | 299 | { |
301 | int ht; | 300 | int ht; |
302 | if (m_scrolldy == m_topmargin) | 301 | if (m_scrolldy == m_topmargin) |
303 | { | 302 | { |
304 | lineno = 0; | 303 | lineno = 0; |
305 | ht = textarray[0]->lineSpacing()-m_scrolldy1 + m_topmargin; | 304 | ht = textarray[0]->lineSpacing()-m_scrolldy1 + m_topmargin; |
306 | } | 305 | } |
307 | else | 306 | else |
308 | { | 307 | { |
309 | if (y >= m_scrolldy) | 308 | if (y >= m_scrolldy) |
310 | { | 309 | { |
311 | lineno = 0; | 310 | lineno = 0; |
312 | ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy + m_topmargin; | 311 | ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy + m_topmargin; |
313 | } | 312 | } |
314 | else | 313 | else |
315 | { | 314 | { |
316 | lineno = 0; | 315 | lineno = 0; |
317 | ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy+m_topmargin; | 316 | ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy+m_topmargin; |
318 | while ((ht < h) && (lineno < numlines-1)) | 317 | while ((ht < h) && (lineno < numlines-1)) |
319 | { | 318 | { |
320 | ht += textarray[++lineno]->lineSpacing(); | 319 | ht += textarray[++lineno]->lineSpacing(); |
321 | } | 320 | } |
322 | ht = textarray[lineno]->lineSpacing(); | 321 | ht = textarray[lineno]->lineSpacing(); |
323 | } | 322 | } |
324 | } | 323 | } |
325 | while ((ht < y) && (lineno < numlines-1)) | 324 | while ((ht < y) && (lineno < numlines-1)) |
326 | { | 325 | { |
327 | ht += textarray[++lineno]->lineSpacing(); | 326 | ht += textarray[++lineno]->lineSpacing(); |
328 | } | 327 | } |
329 | if (ht < y && textarray[numlines]->showPartial()) lineno = numlines; | 328 | if (ht < y && textarray[numlines]->showPartial()) lineno = numlines; |
330 | start = locnarray[lineno]; | 329 | start = locnarray[lineno]; |
331 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; | 330 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; |
332 | if (m_bMonoSpaced) | 331 | if (m_bMonoSpaced) |
333 | { | 332 | { |
334 | offset = (x - textarray[lineno]->offset(w, m_left_border, m_right_border, availht))/m_charWidth; | 333 | offset = (x - textarray[lineno]->offset(w, m_left_border, m_right_border, availht))/m_charWidth; |
335 | } | 334 | } |
336 | else | 335 | else |
337 | { | 336 | { |
338 | int i; | 337 | int i; |
339 | CDrawBuffer* t = textarray[lineno]; | 338 | CDrawBuffer* t = textarray[lineno]; |
340 | x = x - t->offset(width(), m_left_border, m_right_border, availht); | 339 | x = x - t->offset(width(), m_left_border, m_right_border, availht); |
341 | for (i = t->length(); i > 0 && t->width(availht, i, true, w, m_left_border, m_right_border) > x; i--); | 340 | for (i = t->length(); i > 0 && t->width(availht, i, true, w, m_left_border, m_right_border) > x; i--); |
342 | offset = i; | 341 | offset = i; |
343 | } | 342 | } |
344 | return textarray[lineno]->getLinkType(offset, tgt, tgtoffset, pictgt, img); | 343 | return textarray[lineno]->getLinkType(offset, tgt, tgtoffset, pictgt, img); |
345 | } | 344 | } |
346 | 345 | ||
347 | void QTReader::suspend() | 346 | void QTReader::suspend() |
348 | { | 347 | { |
349 | buffdoc.suspend(); | 348 | buffdoc.suspend(); |
350 | /*#ifdef OPIE | 349 | /*#ifdef OPIE |
351 | if (memcmp("/mnt/", m_lastfile.latin1(), 5) == 0) buffdoc.suspend(); | 350 | if (memcmp("/mnt/", m_lastfile.latin1(), 5) == 0) buffdoc.suspend(); |
352 | #else | 351 | #else |
353 | if (memcmp("/usr/mnt.rom/", m_lastfile.latin1(), 13) == 0) buffdoc.suspend(); | 352 | if (memcmp("/usr/mnt.rom/", m_lastfile.latin1(), 13) == 0) buffdoc.suspend(); |
354 | #endif | 353 | #endif |
355 | */ | 354 | */ |
356 | } | 355 | } |
357 | 356 | ||
358 | void QTReader::setTwoTouch(bool _b) | 357 | void QTReader::setTwoTouch(bool _b) |
359 | { | 358 | { |
360 | setBackgroundColor( m_bg ); | 359 | setBackgroundColor( m_bg ); |
361 | m_twotouch = m_touchone = _b; | 360 | m_twotouch = m_touchone = _b; |
362 | } | 361 | } |
363 | 362 | ||
364 | void QTReader::setContinuous(bool _b) | 363 | void QTReader::setContinuous(bool _b) |
365 | { | 364 | { |
366 | buffdoc.unsuspend(); | 365 | buffdoc.unsuspend(); |
367 | buffdoc.setContinuous(m_continuousDocument = _b); | 366 | buffdoc.setContinuous(m_continuousDocument = _b); |
368 | } | 367 | } |
369 | 368 | ||
370 | void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno) | 369 | void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno) |
371 | { | 370 | { |
372 | unsigned long wrdstart, wrdend; | 371 | unsigned long wrdstart, wrdend; |
373 | QString wrd; | 372 | QString wrd; |
374 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; | 373 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; |
375 | if (m_twotouch) | 374 | if (m_twotouch) |
376 | { | 375 | { |
377 | if (m_touchone) | 376 | if (m_touchone) |
378 | { | 377 | { |
379 | m_touchone = false; | 378 | m_touchone = false; |
380 | m_startpos = startpos; | 379 | m_startpos = startpos; |
381 | m_startoffset = startoffset; | 380 | m_startoffset = startoffset; |
382 | setBackgroundColor( lightGray ); | 381 | setBackgroundColor( lightGray ); |
383 | } | 382 | } |
384 | else | 383 | else |
385 | { | 384 | { |
386 | m_touchone = true; | 385 | m_touchone = true; |
387 | setBackgroundColor( m_bg ); | 386 | setBackgroundColor( m_bg ); |
388 | size_t endpos, endoffset; | 387 | size_t endpos, endoffset; |
389 | endpos = startpos; | 388 | endpos = startpos; |
390 | endoffset = startoffset; | 389 | endoffset = startoffset; |
391 | size_t currentpos = locate(); | 390 | size_t currentpos = locate(); |
392 | if (endpos >= m_startpos) | 391 | if (endpos >= m_startpos) |
393 | { | 392 | { |
394 | jumpto(m_startpos); | 393 | jumpto(m_startpos); |
395 | for (int i = 0; i < m_startoffset; i++) | 394 | for (int i = 0; i < m_startoffset; i++) |
396 | { | 395 | { |
397 | getch(); | 396 | getch(); |
398 | } | 397 | } |
399 | wrdstart = buffdoc.explocate(); | 398 | wrdstart = buffdoc.explocate(); |
400 | if (m_startpos == endpos) | 399 | if (m_startpos == endpos) |
401 | { | 400 | { |
402 | for (int i = m_startoffset; i <= endoffset; i++) | 401 | for (int i = m_startoffset; i <= endoffset; i++) |
403 | { | 402 | { |
404 | wrd += QChar(getch()); | 403 | wrd += QChar(getch()); |
405 | } | 404 | } |
406 | } | 405 | } |
407 | else | 406 | else |
408 | { | 407 | { |
409 | while (buffdoc.explocate() <= endpos) | 408 | while (buffdoc.explocate() <= endpos) |
410 | { | 409 | { |
411 | wrd += QChar(getch()); | 410 | wrd += QChar(getch()); |
412 | } | 411 | } |
413 | for (int i = 0; i < endoffset; i++) | 412 | for (int i = 0; i < endoffset; i++) |
414 | { | 413 | { |
415 | wrd += QChar(getch()); | 414 | wrd += QChar(getch()); |
416 | } | 415 | } |
417 | } | 416 | } |
418 | wrdend = buffdoc.explocate(); | 417 | wrdend = buffdoc.explocate(); |
419 | jumpto(currentpos); | 418 | jumpto(currentpos); |
420 | } | 419 | } |
421 | } | 420 | } |
422 | } | 421 | } |
423 | else if (m_bMonoSpaced) | 422 | else if (m_bMonoSpaced) |
424 | { | 423 | { |
425 | int chno = (m_rotated) ? | 424 | int chno = (m_rotated) ? |
426 | (_e->y()-textarray[lineno]->offset(height(), m_left_border, m_right_border, availht))/m_charWidth | 425 | (_e->y()-textarray[lineno]->offset(height(), m_left_border, m_right_border, availht))/m_charWidth |
427 | : | 426 | : |
428 | (_e->x()-textarray[lineno]->offset(width(), m_left_border, m_right_border, availht))/m_charWidth; | 427 | (_e->x()-textarray[lineno]->offset(width(), m_left_border, m_right_border, availht))/m_charWidth; |
429 | if (chno < ustrlen(textarray[lineno]->data())) | 428 | if (chno < ustrlen(textarray[lineno]->data())) |
430 | { | 429 | { |
431 | wrd[0] = textarray[lineno]->data()[chno]; | 430 | wrd[0] = textarray[lineno]->data()[chno]; |
432 | } | 431 | } |
433 | } | 432 | } |
434 | else | 433 | else |
435 | { | 434 | { |
436 | CDrawBuffer* t = textarray[lineno]; | 435 | CDrawBuffer* t = textarray[lineno]; |
437 | int first = 0; | 436 | int first = 0; |
438 | int tgt = (m_rotated) ? | 437 | int tgt = (m_rotated) ? |
439 | _e->y() - t->offset(height(), m_left_border, m_right_border, availht) : | 438 | _e->y() - t->offset(height(), m_left_border, m_right_border, availht) : |
440 | _e->x() - t->offset(width(), m_left_border, m_right_border, availht); | 439 | _e->x() - t->offset(width(), m_left_border, m_right_border, availht); |
441 | while (1) | 440 | while (1) |
442 | { | 441 | { |
443 | int i = first+1; | 442 | int i = first+1; |
444 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; | 443 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; |
445 | while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; | 444 | while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; |
446 | if (t->width(availht, i, true, (m_rotated) ? height() : width(), m_left_border, m_right_border) > tgt) | 445 | if (t->width(availht, i, true, (m_rotated) ? height() : width(), m_left_border, m_right_border) > tgt) |
447 | { | 446 | { |
448 | wrd = toQString(t->data()+first, i - first); | 447 | wrd = toQString(t->data()+first, i - first); |
449 | // qDebug("Got %s", (const char *)wrd); | 448 | // qDebug("Got %s", (const char *)wrd); |
450 | break; | 449 | break; |
451 | } | 450 | } |
452 | while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; | 451 | while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; |
453 | if ((*t)[i] == 0) break; | 452 | if ((*t)[i] == 0) break; |
454 | first = i; | 453 | first = i; |
455 | } | 454 | } |
456 | } | 455 | } |
457 | if (!wrd.isEmpty()) | 456 | if (!wrd.isEmpty()) |
458 | { | 457 | { |
459 | qDebug("Selecteed:%s", (const char*)wrd); | 458 | qDebug("Selecteed:%s", (const char*)wrd); |
460 | if (m_twotouch) | 459 | if (m_twotouch) |
461 | { | 460 | { |
462 | emit OnWordSelected(wrd, wrdstart, wrdend, wrd); | 461 | emit OnWordSelected(wrd, wrdstart, wrdend, wrd); |
463 | } | 462 | } |
464 | else | 463 | else |
465 | { | 464 | { |
466 | QString line = toQString(textarray[lineno]->data()); | 465 | QString line = toQString(textarray[lineno]->data()); |
467 | emit OnWordSelected(wrd, locnarray[lineno], locnarray[lineno]+line.length(), line); | 466 | emit OnWordSelected(wrd, locnarray[lineno], locnarray[lineno]+line.length(), line); |
468 | } | 467 | } |
469 | } | 468 | } |
470 | } | 469 | } |
471 | 470 | ||
472 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | 471 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) |
473 | { | 472 | { |
474 | buffdoc.unsuspend(); | 473 | buffdoc.unsuspend(); |
475 | int x, y, ht, wh; | 474 | int x, y, ht, wh; |
476 | if (m_rotated) | 475 | if (m_rotated) |
477 | { | 476 | { |
478 | x = _e->y(); | 477 | x = _e->y(); |
479 | y = width()-_e->x(); | 478 | y = width()-_e->x(); |
480 | ht = width(); | 479 | ht = width(); |
481 | wh = height(); | 480 | wh = height(); |
482 | } | 481 | } |
483 | else | 482 | else |
484 | { | 483 | { |
485 | x = _e->x(); | 484 | x = _e->x(); |
486 | y = _e->y(); | 485 | y = _e->y(); |
487 | ht = height(); | 486 | ht = height(); |
488 | wh = width(); | 487 | wh = width(); |
489 | } | 488 | } |
490 | if (_e->button() == LeftButton) | 489 | if (_e->button() == LeftButton) |
491 | { | 490 | { |
492 | if (mouseUpOn) | 491 | if (mouseUpOn) |
493 | { | 492 | { |
494 | // qDebug("MouseRelease"); | 493 | // qDebug("MouseRelease"); |
495 | switch(m_scrollpos) | 494 | switch(m_scrollpos) |
496 | { | 495 | { |
497 | case 1: // Bottom | 496 | case 1: // Bottom |
498 | if (y > ht - 5) | 497 | if (y > ht - 5) |
499 | { | 498 | { |
500 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*x+wh/2)/wh); | 499 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*x+wh/2)/wh); |
501 | return; | 500 | return; |
502 | } | 501 | } |
503 | break; | 502 | break; |
504 | case 2: // right | 503 | case 2: // right |
505 | if (x > wh - m_right_border) | 504 | if (x > wh - m_right_border) |
506 | { | 505 | { |
507 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); | 506 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); |
508 | return; | 507 | return; |
509 | } | 508 | } |
510 | break; | 509 | break; |
511 | case 3: // left | 510 | case 3: // left |
512 | if (x < m_left_border) | 511 | if (x < m_left_border) |
513 | { | 512 | { |
514 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); | 513 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); |
515 | return; | 514 | return; |
516 | } | 515 | } |
517 | break; | 516 | break; |
518 | case 0: | 517 | case 0: |
519 | default: | 518 | default: |
520 | break; | 519 | break; |
521 | } | 520 | } |
522 | if (textarray[0] != NULL) | 521 | if (textarray[0] != NULL) |
523 | { | 522 | { |
524 | QString line; | 523 | QString line; |
525 | // int lineno = _e->y()/m_linespacing; | 524 | // int lineno = _e->y()/m_linespacing; |
526 | int lineno = 0; | 525 | int lineno = 0; |
527 | /* | 526 | /* |
528 | int ht = textarray[0]->lineSpacing(); | 527 | int ht = textarray[0]->lineSpacing(); |
529 | while ((ht < y) && (lineno < numlines)) | 528 | while ((ht < y) && (lineno < numlines)) |
530 | { | 529 | { |
531 | ht += textarray[++lineno]->lineSpacing(); | 530 | ht += textarray[++lineno]->lineSpacing(); |
532 | } | 531 | } |
533 | */ | 532 | */ |
534 | size_t startpos, startoffset, tgt, tgtoffset, pictgt; | 533 | size_t startpos, startoffset, tgt, tgtoffset, pictgt; |
535 | QImage* img; | 534 | QImage* img; |
536 | if (m_currentlinkstyle != NULL) | 535 | if (m_currentlinkstyle != NULL) |
537 | { | 536 | { |
538 | textarray[m_currentlink]->invertLink(m_currentlinkoffset); | 537 | textarray[m_currentlink]->invertLink(m_currentlinkoffset); |
539 | m_currentlinkstyle = NULL; | 538 | m_currentlinkstyle = NULL; |
540 | m_currentlink = -1; | 539 | m_currentlink = -1; |
541 | m_currentlinkoffset = -1; | 540 | m_currentlinkoffset = -1; |
542 | } | 541 | } |
543 | linkType glt = getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img); | 542 | linkType glt = getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img); |
544 | if ((glt & eLink) != 0) | 543 | if ((glt & eLink) != 0) |
545 | { | 544 | { |
546 | if ((glt & ePicture) != 0) | 545 | if ((glt & ePicture) != 0) |
547 | { | 546 | { |
548 | qDebug("Big Picture:%x", pictgt); | 547 | qDebug("Big Picture:%x", pictgt); |
549 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) | 548 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) |
550 | { | 549 | { |
551 | QImage* pm = buffdoc.getPicture(pictgt); | 550 | QImage* pm = buffdoc.getPicture(pictgt); |
552 | if (pm != NULL) | 551 | if (pm != NULL) |
553 | { | 552 | { |
554 | emit OnShowPicture(*pm); | 553 | emit OnShowPicture(*pm); |
555 | delete pm; | 554 | delete pm; |
556 | return; | 555 | return; |
557 | } | 556 | } |
558 | } | 557 | } |
559 | } | 558 | } |
560 | else if (img != NULL) | 559 | else if (img != NULL) |
561 | { | 560 | { |
562 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) | 561 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) |
563 | { | 562 | { |
564 | emit OnShowPicture(*img); | 563 | emit OnShowPicture(*img); |
565 | return; | 564 | return; |
566 | } | 565 | } |
567 | } | 566 | } |
568 | size_t saveposn = pagelocate(); | 567 | size_t saveposn = pagelocate(); |
569 | QString href, nm; | 568 | QString href, nm; |
570 | linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm); | 569 | linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm); |
571 | qDebug("URL(1):%s", (const char*)href); | 570 | qDebug("URL(1):%s", (const char*)href); |
572 | if ((lt & eFile) != 0) | 571 | if ((lt & eFile) != 0) |
573 | { | 572 | { |
574 | buffdoc.saveposn(m_lastfile, saveposn); | 573 | buffdoc.saveposn(m_lastfile, saveposn); |
575 | #ifdef USEQPE | 574 | #ifdef USEQPE |
576 | { | 575 | { |
577 | QCopEnvelope e("QPE/System", "busy()"); | 576 | QCopEnvelope e("QPE/System", "busy()"); |
578 | } | 577 | } |
579 | #endif | 578 | #endif |
580 | ResetScroll(); | 579 | ResetScroll(); |
581 | if (!href.isEmpty()) | 580 | if (!href.isEmpty()) |
582 | { | 581 | { |
583 | if (!buffdoc.getFile(href)) | 582 | if (!buffdoc.getFile(href)) |
584 | { | 583 | { |
585 | emit NewFileRequest(href); | 584 | emit NewFileRequest(href); |
586 | } | 585 | } |
587 | else | 586 | else |
588 | { | 587 | { |
589 | ResetScroll(); | 588 | ResetScroll(); |
590 | fillbuffer(); | 589 | fillbuffer(); |
591 | update(); | 590 | update(); |
592 | } | 591 | } |
593 | } | 592 | } |
594 | if (!nm.isEmpty()) | 593 | if (!nm.isEmpty()) |
595 | { | 594 | { |
596 | qDebug("QTReader:Finding %s", (const char*)nm); | 595 | qDebug("QTReader:Finding %s", (const char*)nm); |
597 | if (buffdoc.findanchor(nm)) | 596 | if (buffdoc.findanchor(nm)) |
598 | { | 597 | { |
599 | fillbuffer(); | 598 | fillbuffer(); |
600 | update(); | 599 | update(); |
601 | } | 600 | } |
602 | } | 601 | } |
603 | //fillbuffer(); | 602 | //fillbuffer(); |
604 | //update(); | 603 | //update(); |
605 | #ifdef USEQPE | 604 | #ifdef USEQPE |
606 | { | 605 | { |
607 | QCopEnvelope e("QPE/System", "notBusy()"); | 606 | QCopEnvelope e("QPE/System", "notBusy()"); |
608 | } | 607 | } |
609 | #endif | 608 | #endif |
610 | } | 609 | } |
611 | else if ((lt & eLink) != 0) | 610 | else if ((lt & eLink) != 0) |
612 | { | 611 | { |
613 | buffdoc.saveposn(m_lastfile, saveposn); | 612 | buffdoc.saveposn(m_lastfile, saveposn); |
614 | ResetScroll(); | 613 | ResetScroll(); |
615 | fillbuffer(); | 614 | fillbuffer(); |
616 | update(); | 615 | update(); |
617 | } | 616 | } |
618 | else | 617 | else |
619 | { | 618 | { |
620 | if ((lt & ePicture) != 0) | 619 | if ((lt & ePicture) != 0) |
621 | { | 620 | { |
622 | QImage* pm = buffdoc.getPicture(tgt); | 621 | QImage* pm = buffdoc.getPicture(tgt); |
623 | if (pm != NULL) | 622 | if (pm != NULL) |
624 | { | 623 | { |
625 | emit OnShowPicture(*pm); | 624 | emit OnShowPicture(*pm); |
626 | delete pm; | 625 | delete pm; |
627 | } | 626 | } |
628 | } | 627 | } |
629 | else | 628 | else |
630 | { | 629 | { |
631 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); | 630 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); |
632 | if (!href.isEmpty()) | 631 | if (!href.isEmpty()) |
633 | { | 632 | { |
634 | emit OnURLSelected(href, tgt); | 633 | emit OnURLSelected(href, tgt); |
635 | } | 634 | } |
636 | } | 635 | } |
637 | locate(pagelocate()); | 636 | locate(pagelocate()); |
638 | } | 637 | } |
639 | return; | 638 | return; |
640 | } | 639 | } |
641 | else if ((glt & ePicture) != 0) | 640 | else if ((glt & ePicture) != 0) |
642 | { | 641 | { |
643 | qDebug("Big Picture:%x", pictgt); | 642 | qDebug("Big Picture:%x", pictgt); |
644 | QImage* pm = buffdoc.getPicture(pictgt); | 643 | QImage* pm = buffdoc.getPicture(pictgt); |
645 | if (pm != NULL) | 644 | if (pm != NULL) |
646 | { | 645 | { |
647 | emit OnShowPicture(*pm); | 646 | emit OnShowPicture(*pm); |
648 | delete pm; | 647 | delete pm; |
649 | } | 648 | } |
650 | else | 649 | else |
651 | { | 650 | { |
652 | locate(pagelocate()); | 651 | locate(pagelocate()); |
653 | } | 652 | } |
654 | return; | 653 | return; |
655 | } | 654 | } |
656 | else if (img != NULL) | 655 | else if (img != NULL) |
657 | { | 656 | { |
658 | emit OnShowPicture(*img); | 657 | emit OnShowPicture(*img); |
659 | return; | 658 | return; |
660 | } | 659 | } |
661 | if (m_swapmouse) | 660 | if (m_swapmouse) |
662 | processmousepositionevent(_e); | 661 | processmousepositionevent(_e); |
663 | else | 662 | else |
664 | processmousewordevent(startpos, startoffset, _e, lineno); | 663 | processmousewordevent(startpos, startoffset, _e, lineno); |
665 | } | 664 | } |
666 | } | 665 | } |
667 | else | 666 | else |
668 | { | 667 | { |
669 | mouseUpOn = true; | 668 | mouseUpOn = true; |
670 | } | 669 | } |
671 | } | 670 | } |
672 | } | 671 | } |
673 | 672 | ||
674 | void QTReader::focusInEvent(QFocusEvent* e) | 673 | void QTReader::focusInEvent(QFocusEvent* e) |
675 | { | 674 | { |
676 | if (m_autoScroll) timer->start(real_delay(), false); | 675 | if (m_autoScroll) timer->start(real_delay(), false); |
677 | update(); | 676 | update(); |
678 | } | 677 | } |
679 | 678 | ||
680 | void QTReader::focusOutEvent(QFocusEvent* e) | 679 | void QTReader::focusOutEvent(QFocusEvent* e) |
681 | { | 680 | { |
682 | if (m_autoScroll) | 681 | if (m_autoScroll) |
683 | { | 682 | { |
684 | timer->stop(); | 683 | timer->stop(); |
685 | //m_scrolldy1 = m_scrolldy2 = 0; | 684 | //m_scrolldy1 = m_scrolldy2 = 0; |
686 | } | 685 | } |
687 | } | 686 | } |
688 | 687 | ||
689 | #include <qapplication.h> | 688 | #include <qapplication.h> |
690 | #include <qdrawutil.h> | 689 | #include <qdrawutil.h> |
691 | #ifndef _WINDOWS | 690 | #ifndef _WINDOWS |
692 | #include <unistd.h> | 691 | #include <unistd.h> |
693 | #endif | 692 | #endif |
694 | 693 | ||
695 | void QTReader::goDown() | 694 | void QTReader::goDown() |
696 | { | 695 | { |
697 | if (m_bpagemode) | 696 | if (m_bpagemode) |
698 | { | 697 | { |
699 | dopagedn(); | 698 | dopagedn(); |
700 | } | 699 | } |
701 | else | 700 | else |
702 | { | 701 | { |
703 | lineDown(); | 702 | lineDown(); |
704 | } | 703 | } |
705 | } | 704 | } |
706 | 705 | ||
707 | void QTReader::goUp() | 706 | void QTReader::goUp() |
708 | { | 707 | { |
709 | if (m_bpagemode) | 708 | if (m_bpagemode) |
710 | { | 709 | { |
711 | dopageup(); | 710 | dopageup(); |
712 | } | 711 | } |
713 | else | 712 | else |
714 | { | 713 | { |
715 | lineUp(); | 714 | lineUp(); |
716 | } | 715 | } |
717 | } | 716 | } |
718 | 717 | ||
719 | void QTReader::NavUp() | 718 | void QTReader::NavUp() |
720 | { | 719 | { |
721 | buffdoc.unsuspend(); | 720 | buffdoc.unsuspend(); |
722 | if (buffdoc.hasnavigation()) | 721 | if (buffdoc.hasnavigation()) |
723 | { | 722 | { |
724 | /* | 723 | /* |
725 | size_t target = pagelocate(); | 724 | size_t target = pagelocate(); |
726 | if (buffdoc.back(target)) | 725 | if (buffdoc.back(target)) |
727 | { | 726 | { |
728 | locate(target); | 727 | locate(target); |
729 | } | 728 | } |
730 | */ | 729 | */ |
731 | locate(buffdoc.startSection()); | 730 | locate(buffdoc.startSection()); |
732 | } | 731 | } |
733 | else | 732 | else |
734 | { | 733 | { |
735 | goUp(); | 734 | goUp(); |
736 | } | 735 | } |
737 | } | 736 | } |
738 | 737 | ||
739 | void QTReader::NavDown() | 738 | void QTReader::NavDown() |
740 | { | 739 | { |
741 | buffdoc.unsuspend(); | 740 | buffdoc.unsuspend(); |
742 | if (buffdoc.hasnavigation()) | 741 | if (buffdoc.hasnavigation()) |
743 | { | 742 | { |
744 | /* | 743 | /* |
745 | size_t target = pagelocate(); | 744 | size_t target = pagelocate(); |
746 | if (buffdoc.forward(target)) | 745 | if (buffdoc.forward(target)) |
747 | { | 746 | { |
748 | locate(target); | 747 | locate(target); |
749 | } | 748 | } |
750 | */ | 749 | */ |
751 | dopageup(buffdoc.endSection()); | 750 | dopageup(buffdoc.endSection()); |
752 | } | 751 | } |
753 | else | 752 | else |
754 | { | 753 | { |
755 | goDown(); | 754 | goDown(); |
756 | } | 755 | } |
757 | } | 756 | } |
758 | 757 | ||
759 | void QTReader::zoomin() | 758 | void QTReader::zoomin() |
760 | { | 759 | { |
761 | if (m_fontControl.increasesize()) | 760 | if (m_fontControl.increasesize()) |
762 | { | 761 | { |
763 | bool sc = m_autoScroll; | 762 | bool sc = m_autoScroll; |
764 | setautoscroll(false); | 763 | setautoscroll(false); |
765 | setfont(); | 764 | setfont(); |
766 | locate(pagelocate()); | 765 | locate(pagelocate()); |
767 | repaint(); | 766 | repaint(); |
768 | setautoscroll(sc); | 767 | setautoscroll(sc); |
769 | } | 768 | } |
770 | } | 769 | } |
771 | 770 | ||
772 | void QTReader::zoomout() | 771 | void QTReader::zoomout() |
773 | { | 772 | { |
774 | if (m_fontControl.decreasesize()) | 773 | if (m_fontControl.decreasesize()) |
775 | { | 774 | { |
776 | bool sc = m_autoScroll; | 775 | bool sc = m_autoScroll; |
777 | setautoscroll(false); | 776 | setautoscroll(false); |
778 | setfont(); | 777 | setfont(); |
779 | locate(pagelocate()); | 778 | locate(pagelocate()); |
780 | repaint(); | 779 | repaint(); |
781 | setautoscroll(sc); | 780 | setautoscroll(sc); |
782 | } | 781 | } |
783 | } | 782 | } |
784 | 783 | ||
785 | void QTReader::reduceScroll() | 784 | void QTReader::reduceScroll() |
786 | { | 785 | { |
787 | if (m_delay < 59049) | 786 | if (m_delay < 59049) |
788 | { | 787 | { |
789 | m_delay = (3*m_delay)/2; | 788 | m_delay = (3*m_delay)/2; |
790 | timer->changeInterval(real_delay()); | 789 | timer->changeInterval(real_delay()); |
791 | } | 790 | } |
792 | else | 791 | else |
793 | { | 792 | { |
794 | m_delay = 59049; | 793 | m_delay = 59049; |
795 | } | 794 | } |
796 | } | 795 | } |
797 | 796 | ||
798 | void QTReader::increaseScroll() | 797 | void QTReader::increaseScroll() |
799 | { | 798 | { |
800 | if (m_delay > 454) | 799 | if (m_delay > 454) |
801 | { | 800 | { |
802 | m_delay = (2*m_delay)/3; | 801 | m_delay = (2*m_delay)/3; |
803 | timer->changeInterval(real_delay()); | 802 | timer->changeInterval(real_delay()); |
804 | } | 803 | } |
805 | else | 804 | else |
806 | { | 805 | { |
807 | m_delay = 454; | 806 | m_delay = 454; |
808 | } | 807 | } |
809 | } | 808 | } |
810 | 809 | ||
811 | void QTReader::keyPressEvent(QKeyEvent* e) | 810 | void QTReader::keyPressEvent(QKeyEvent* e) |
812 | { | 811 | { |
813 | buffdoc.unsuspend(); | 812 | buffdoc.unsuspend(); |
814 | 813 | ||
815 | //((QTReaderApp*)parent()->parent())->handlekey(e); | 814 | //((QTReaderApp*)parent()->parent())->handlekey(e); |
816 | emit HandleKeyRequest(e); | 815 | emit HandleKeyRequest(e); |
817 | // e->ignore(); | 816 | // e->ignore(); |
818 | return; | 817 | return; |
819 | #ifdef _SCROLLPIPE | 818 | #ifdef _SCROLLPIPE |
820 | if (m_isPaused) | 819 | if (m_isPaused) |
821 | { | 820 | { |
822 | m_isPaused = false; | 821 | m_isPaused = false; |
823 | if (e->key() != Key_Space) | 822 | if (e->key() != Key_Space) |
824 | { | 823 | { |
825 | m_autoScroll = false; | 824 | m_autoScroll = false; |
826 | if (m_pipeout != NULL) | 825 | if (m_pipeout != NULL) |
827 | { | 826 | { |
828 | pclose(m_pipeout); | 827 | pclose(m_pipeout); |
829 | m_pipeout = NULL; | 828 | m_pipeout = NULL; |
830 | } | 829 | } |
831 | //((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); | 830 | //((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); |
832 | emit SetScrollState(m_autoScroll); | 831 | emit SetScrollState(m_autoScroll); |
833 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 832 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
834 | } | 833 | } |
835 | else | 834 | else |
836 | { | 835 | { |
837 | timer->start(real_delay(), false); | 836 | timer->start(real_delay(), false); |
838 | } | 837 | } |
839 | e->accept(); | 838 | e->accept(); |
840 | return; | 839 | return; |
841 | } | 840 | } |
842 | #endif | 841 | #endif |
843 | } | 842 | } |
844 | 843 | ||
845 | void QTReader::CalculateScrollParameters() | 844 | void QTReader::CalculateScrollParameters() |
846 | { | 845 | { |
847 | int bmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 846 | int bmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
848 | if (bmargin < m_bottommargin) bmargin = m_bottommargin; | 847 | if (bmargin < m_bottommargin) bmargin = m_bottommargin; |
849 | switch (m_scrolltype) | 848 | switch (m_scrolltype) |
850 | { | 849 | { |
851 | case 0: | 850 | case 0: |
852 | { | 851 | { |
853 | if (m_scrolldy == m_topmargin) | 852 | if (m_scrolldy == m_topmargin) |
854 | { | 853 | { |
855 | m_scrolldy1 = 0; | 854 | m_scrolldy1 = 0; |
856 | m_scrolldy2 = 0; | 855 | m_scrolldy2 = 0; |
857 | m_totalscroll = 0; | 856 | m_totalscroll = 0; |
858 | return; | 857 | return; |
859 | } | 858 | } |
860 | if (m_scrolldy < textarray[0]->lineSpacing()) | 859 | if (m_scrolldy < textarray[0]->lineSpacing()) |
861 | { | 860 | { |
862 | m_scrolldy2 = m_scrolldy; | 861 | m_scrolldy2 = m_scrolldy; |
863 | return; | 862 | return; |
864 | } | 863 | } |
865 | int ht = m_scrolldy - m_scrolldy1; | 864 | int ht = m_scrolldy - m_scrolldy1; |
866 | int i; | 865 | int i; |
867 | for (i = 0; (ht < ((m_rotated) ? width() : height())-bmargin) && (i < numlines); i++) | 866 | for (i = 0; (ht < ((m_rotated) ? width() : height())-bmargin) && (i < numlines); i++) |
868 | { | 867 | { |
869 | ht += textarray[i]->lineSpacing(); | 868 | ht += textarray[i]->lineSpacing(); |
870 | } | 869 | } |
871 | ht = 0; | 870 | ht = 0; |
872 | int j; | 871 | int j; |
873 | i--; | 872 | i--; |
874 | for (j = i; j < numlines; j++) | 873 | for (j = i; j < numlines; j++) |
875 | { | 874 | { |
876 | ht += textarray[j]->lineSpacing(); | 875 | ht += textarray[j]->lineSpacing(); |
877 | } | 876 | } |
878 | ht -= ( | 877 | ht -= ( |
879 | textarray[i]->lineExtraSpacing() | 878 | textarray[i]->lineExtraSpacing() |
880 | + | 879 | + |
881 | (i != 0) ? textarray[numlines-1]->lineExtraSpacing() : 0 | 880 | (i != 0) ? textarray[numlines-1]->lineExtraSpacing() : 0 |
882 | )/2-2; | 881 | )/2-2; |
883 | 882 | ||
884 | m_scrolldy2 = m_scrolldy-ht; | 883 | m_scrolldy2 = m_scrolldy-ht; |
885 | } | 884 | } |
886 | break; | 885 | break; |
887 | case 1: | 886 | case 1: |
888 | case 2: | 887 | case 2: |
889 | case 3: | 888 | case 3: |
890 | { | 889 | { |
891 | int ypos = m_topmargin; | 890 | int ypos = m_topmargin; |
892 | for (int i = 0; i < numlines; i++) | 891 | for (int i = 0; i < numlines; i++) |
893 | { | 892 | { |
894 | ypos += textarray[i]->lineSpacing(); | 893 | ypos += textarray[i]->lineSpacing(); |
895 | } | 894 | } |
896 | ypos -= ( | 895 | ypos -= ( |
897 | textarray[0]->lineExtraSpacing() | 896 | textarray[0]->lineExtraSpacing() |
898 | + | 897 | + |
899 | ((numlines > 1) ? textarray[numlines-1]->lineExtraSpacing() : 0) | 898 | ((numlines > 1) ? textarray[numlines-1]->lineExtraSpacing() : 0) |
900 | )/2 + | 899 | )/2 + |
901 | m_scrolldy1 - 2; | 900 | m_scrolldy1 - 2; |
902 | m_scrolldy2 = ((m_rotated) ? width() : height()) - ypos - bmargin; | 901 | m_scrolldy2 = ((m_rotated) ? width() : height()) - ypos - bmargin; |
903 | } | 902 | } |
904 | break; | 903 | break; |
905 | } | 904 | } |
906 | } | 905 | } |
907 | 906 | ||
908 | void QTReader::setautoscroll(bool _sc) | 907 | void QTReader::setautoscroll(bool _sc) |
909 | { | 908 | { |
910 | if (_sc == m_autoScroll) return; | 909 | if (_sc == m_autoScroll) return; |
911 | if (m_autoScroll) | 910 | if (m_autoScroll) |
912 | { | 911 | { |
913 | m_autoScroll = false; | 912 | m_autoScroll = false; |
914 | #ifdef USEQPE | 913 | #ifdef USEQPE |
915 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 914 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
916 | #endif | 915 | #endif |
917 | #ifdef _SCROLLPIPE | 916 | #ifdef _SCROLLPIPE |
918 | if (m_pipeout != NULL) | 917 | if (m_pipeout != NULL) |
919 | { | 918 | { |
920 | pclose(m_pipeout); | 919 | pclose(m_pipeout); |
921 | m_pipeout = NULL; | 920 | m_pipeout = NULL; |
922 | } | 921 | } |
923 | #endif | 922 | #endif |
924 | //m_scrolldy1 = 0; | 923 | //m_scrolldy1 = 0; |
925 | //refresh(); | 924 | //refresh(); |
926 | } | 925 | } |
927 | else | 926 | else |
928 | { | 927 | { |
929 | CDrawBuffer* reusebuffer = textarray[numlines]; | 928 | CDrawBuffer* reusebuffer = textarray[numlines]; |
930 | if (reusebuffer == NULL || reusebuffer->eof()) return; | 929 | if (reusebuffer == NULL || reusebuffer->eof()) return; |
931 | m_autoScroll = true; | 930 | m_autoScroll = true; |
932 | CalculateScrollParameters(); | 931 | CalculateScrollParameters(); |
933 | 932 | ||
934 | #ifdef _SCROLLPIPE | 933 | #ifdef _SCROLLPIPE |
935 | if (!m_pipetarget.isEmpty()) | 934 | if (!m_pipetarget.isEmpty()) |
936 | { | 935 | { |
937 | // qDebug("Opening pipe to %s", (const char*)m_pipetarget); | 936 | // qDebug("Opening pipe to %s", (const char*)m_pipetarget); |
938 | m_pipeout = popen((const char*)m_pipetarget, "w"); | 937 | m_pipeout = popen((const char*)m_pipetarget, "w"); |
939 | m_isPaused = false; | 938 | m_isPaused = false; |
940 | } | 939 | } |
941 | #endif | 940 | #endif |
942 | autoscroll(); | 941 | autoscroll(); |
943 | #ifdef USEQPE | 942 | #ifdef USEQPE |
944 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed | 943 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed |
945 | #endif | 944 | #endif |
946 | } | 945 | } |
947 | } | 946 | } |
948 | 947 | ||
949 | bool QTReader::getline(CDrawBuffer *buff) | 948 | bool QTReader::getline(CDrawBuffer *buff) |
950 | { | 949 | { |
951 | buffdoc.unsuspend(); | 950 | buffdoc.unsuspend(); |
952 | bool bRet; | 951 | bool bRet; |
953 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; | 952 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; |
954 | if (m_bMonoSpaced) | 953 | if (m_bMonoSpaced) |
955 | { | 954 | { |
956 | bRet = buffdoc.getline(buff ,(m_rotated) ? height() : width(), m_charWidth, m_left_border, m_right_border, availht); | 955 | bRet = buffdoc.getline(buff ,(m_rotated) ? height() : width(), m_charWidth, m_left_border, m_right_border, availht); |
957 | } | 956 | } |
958 | else | 957 | else |
959 | { | 958 | { |
960 | bRet = buffdoc.getline(buff, (m_rotated) ? height() : width(), m_left_border, m_right_border, hyphenate, availht); | 959 | bRet = buffdoc.getline(buff, (m_rotated) ? height() : width(), m_left_border, m_right_border, hyphenate, availht); |
961 | } | 960 | } |
962 | buff->resize(availht); | 961 | buff->resize(availht); |
963 | return bRet; | 962 | return bRet; |
964 | } | 963 | } |
965 | 964 | ||
966 | void QTReader::doscroll() | 965 | void QTReader::doscroll() |
967 | { | 966 | { |
968 | if (!m_autoScroll) | 967 | if (!m_autoScroll) |
969 | { | 968 | { |
970 | timer->stop(); | 969 | timer->stop(); |
971 | return; | 970 | return; |
972 | } | 971 | } |
973 | switch (m_scrolltype) | 972 | switch (m_scrolltype) |
974 | { | 973 | { |
975 | case 0: | 974 | case 0: |
976 | doinplacescroll(); | 975 | doinplacescroll(); |
977 | break; | 976 | break; |
978 | case 1: | 977 | case 1: |
979 | dorollingscroll(false); | 978 | dorollingscroll(false); |
980 | break; | 979 | break; |
981 | case 2: | 980 | case 2: |
982 | dorollingscroll(true); | 981 | dorollingscroll(true); |
983 | break; | 982 | break; |
984 | case 3: | 983 | case 3: |
985 | dostaticscroll(); | 984 | dostaticscroll(); |
986 | break; | 985 | break; |
987 | } | 986 | } |
988 | } | 987 | } |
989 | 988 | ||
990 | void QTReader::doinplacescroll() | 989 | void QTReader::doinplacescroll() |
991 | { | 990 | { |
992 | QPainter p( this ); | 991 | QPainter p( this ); |
993 | // p.setBackgroundMode(OpaqueMode); | 992 | // p.setBackgroundMode(OpaqueMode); |
994 | int wh, ht; | 993 | int wh, ht; |
995 | int bmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 994 | int bmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
996 | if (bmargin < m_bottommargin) bmargin = m_bottommargin; | 995 | if (bmargin < m_bottommargin) bmargin = m_bottommargin; |
997 | if (m_rotated) | 996 | if (m_rotated) |
998 | { | 997 | { |
999 | ht = width()-bmargin; | 998 | ht = width()-bmargin; |
1000 | wh = height(); | 999 | wh = height(); |
1001 | } | 1000 | } |
1002 | else | 1001 | else |
1003 | { | 1002 | { |
1004 | ht = height()-bmargin; | 1003 | ht = height()-bmargin; |
1005 | wh = width(); | 1004 | wh = width(); |
1006 | } | 1005 | } |
1007 | int lastdy = m_scrolldy; | 1006 | int lastdy = m_scrolldy; |
1008 | m_scrolldy += m_scrollstep; | 1007 | m_scrolldy += m_scrollstep; |
1009 | if ((m_scrolldy1 = m_scrolldy1+m_scrollstep) >= textarray[0]->lineSpacing()) | 1008 | if ((m_scrolldy1 = m_scrolldy1+m_scrollstep) >= textarray[0]->lineSpacing()) |
1010 | { | 1009 | { |
1011 | int ht = textarray[0]->lineSpacing(); | 1010 | int ht = textarray[0]->lineSpacing(); |
1012 | #ifdef _SCROLLPIPE | 1011 | #ifdef _SCROLLPIPE |
1013 | if (m_pipeout != NULL) | 1012 | if (m_pipeout != NULL) |
1014 | { | 1013 | { |
1015 | QString outstr = toQString(textarray[0]->data()); | 1014 | QString outstr = toQString(textarray[0]->data()); |
1016 | if (!outstr.isEmpty()) | 1015 | if (!outstr.isEmpty()) |
1017 | { | 1016 | { |
1018 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 1017 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
1019 | fflush(m_pipeout); | 1018 | fflush(m_pipeout); |
1020 | } | 1019 | } |
1021 | else if (m_pauseAfterEachPara) | 1020 | else if (m_pauseAfterEachPara) |
1022 | { | 1021 | { |
1023 | m_isPaused = true; | 1022 | m_isPaused = true; |
1024 | timer->stop(); | 1023 | timer->stop(); |
1025 | } | 1024 | } |
1026 | } | 1025 | } |
1027 | #endif | 1026 | #endif |
1028 | CDrawBuffer* buff = textarray[0]; | 1027 | CDrawBuffer* buff = textarray[0]; |
1029 | for (int i = 1; i <= numlines; i++) | 1028 | for (int i = 1; i <= numlines; i++) |
1030 | { | 1029 | { |
1031 | textarray[i-1] = textarray[i]; | 1030 | textarray[i-1] = textarray[i]; |
1032 | locnarray[i-1] = locnarray[i]; | 1031 | locnarray[i-1] = locnarray[i]; |
1033 | } | 1032 | } |
1034 | textarray[numlines] = buff; | 1033 | textarray[numlines] = buff; |
1035 | --numlines; | 1034 | --numlines; |
1036 | m_scrolldy1 -= ht; | 1035 | m_scrolldy1 -= ht; |
1037 | } | 1036 | } |
1038 | if ((m_scrolldy2 = m_scrolldy2+m_scrollstep) >= textarray[numlines]->lineSpacing()) | 1037 | if ((m_scrolldy2 = m_scrolldy2+m_scrollstep) >= textarray[numlines]->lineSpacing()) |
1039 | { | 1038 | { |
1040 | m_scrolldy2 -= textarray[numlines]->lineSpacing(); | 1039 | m_scrolldy2 -= textarray[numlines]->lineSpacing(); |
1041 | numlines++; | 1040 | numlines++; |
1042 | 1041 | ||
1043 | if (textarray[numlines] == NULL) | 1042 | if (textarray[numlines] == NULL) |
1044 | { | 1043 | { |
1045 | textarray[numlines] = new CDrawBuffer(&m_fontControl); | 1044 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
1046 | } | 1045 | } |
1047 | locnarray[numlines] = locate(); | 1046 | locnarray[numlines] = locate(); |
1048 | int ch = getline(textarray[numlines]); | 1047 | int ch = getline(textarray[numlines]); |
1049 | if (m_rotated) | 1048 | if (m_rotated) |
1050 | { | 1049 | { |
1051 | blitRot(width()-m_scrolldy, 0, height(), -1, textarray[numlines-1]); | 1050 | blitRot(width()-m_scrolldy, 0, height(), -1, textarray[numlines-1]); |
1052 | } | 1051 | } |
1053 | else | 1052 | else |
1054 | { | 1053 | { |
1055 | if (m_bgpm.isNull()) | 1054 | if (m_bgpm.isNull()) |
1056 | { | 1055 | { |
1057 | p.fillRect(m_left_border,m_scrolldy-textarray[numlines-1]->lineSpacing(),width()-(m_left_border+m_right_border),textarray[numlines-1]->lineSpacing(),m_bg); | 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); |
1058 | } | 1057 | } |
1059 | else | 1058 | else |
1060 | { | 1059 | { |
1061 | int h_tmp = textarray[numlines-1]->lineSpacing(); | 1060 | int h_tmp = textarray[numlines-1]->lineSpacing(); |
1062 | 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); | 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); |
1063 | } | 1062 | } |
1064 | 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); | 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); |
1065 | } | 1064 | } |
1066 | mylastpos = locate(); | 1065 | mylastpos = locate(); |
1067 | if (!ch) | 1066 | if (!ch) |
1068 | { | 1067 | { |
1069 | /* | 1068 | /* |
1070 | if (m_rotated) | 1069 | if (m_rotated) |
1071 | { | 1070 | { |
1072 | blitRot2(0,0,height(),width()-m_scrolldy,NULL); | 1071 | blitRot2(0,0,height(),width()-m_scrolldy,NULL); |
1073 | // blitRot2(0,0,0,height(),width()-m_scrolldy,NULL); | 1072 | // blitRot2(0,0,0,height(),width()-m_scrolldy,NULL); |
1074 | } | 1073 | } |
1075 | else | 1074 | else |
1076 | { | 1075 | { |
1077 | if (m_bgpm.isNull()) | 1076 | if (m_bgpm.isNull()) |
1078 | { | 1077 | { |
1079 | p.fillRect(0,m_scrolldy,width(),height()-m_scrolldy,m_bg); | 1078 | p.fillRect(0,m_scrolldy,width(),height()-m_scrolldy,m_bg); |
1080 | } | 1079 | } |
1081 | else | 1080 | else |
1082 | { | 1081 | { |
1083 | bitBlt(this, 0, m_scrolldy, dbuff, 0, m_scrolldy, width(), height()-m_scrolldy); | 1082 | bitBlt(this, 0, m_scrolldy, dbuff, 0, m_scrolldy, width(), height()-m_scrolldy); |
1084 | } | 1083 | } |
1085 | } | 1084 | } |
1086 | */ | 1085 | */ |
1087 | m_scrolldy = m_topmargin; | 1086 | m_scrolldy = m_topmargin; |
1088 | m_autoScroll = false; | 1087 | m_autoScroll = false; |
1089 | #ifdef _SCROLLPIPE | 1088 | #ifdef _SCROLLPIPE |
1090 | for (int i = 0; i < numlines; i++) | 1089 | for (int i = 0; i < numlines; i++) |
1091 | { | 1090 | { |
1092 | if (m_pipeout != NULL) | 1091 | if (m_pipeout != NULL) |
1093 | { | 1092 | { |
1094 | QString outstr = toQString(textarray[i]->data()); | 1093 | QString outstr = toQString(textarray[i]->data()); |
1095 | if (!outstr.isEmpty()) | 1094 | if (!outstr.isEmpty()) |
1096 | { | 1095 | { |
1097 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 1096 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
1098 | fflush(m_pipeout); | 1097 | fflush(m_pipeout); |
1099 | } | 1098 | } |
1100 | } | 1099 | } |
1101 | } | 1100 | } |
1102 | #endif | 1101 | #endif |
1103 | //((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); | 1102 | //((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); |
1104 | emit SetScrollState(m_autoScroll); | 1103 | emit SetScrollState(m_autoScroll); |
1105 | #ifdef USEQPE | 1104 | #ifdef USEQPE |
1106 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 1105 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
1107 | #endif | 1106 | #endif |
1108 | } | 1107 | } |
1109 | if (m_scrolldy > ht-textarray[numlines]->lineSpacing()) | 1108 | if (m_scrolldy > ht-textarray[numlines]->lineSpacing()) |
1110 | { | 1109 | { |
1111 | if (m_rotated) | 1110 | if (m_rotated) |
1112 | { | 1111 | { |
1113 | if (m_bgpm.isNull()) | 1112 | if (m_bgpm.isNull()) |
1114 | { | 1113 | { |
1115 | p.fillRect(bmargin, m_left_border, ht-m_scrolldy, wh-(m_left_border+m_right_border), m_bg); | 1114 | p.fillRect(bmargin, m_left_border, ht-m_scrolldy, wh-(m_left_border+m_right_border), m_bg); |
1116 | } | 1115 | } |
1117 | else | 1116 | else |
1118 | { | 1117 | { |
1119 | blitRot(bmargin, 0,height(), ht-m_scrolldy, NULL); | 1118 | blitRot(bmargin, 0,height(), ht-m_scrolldy, NULL); |
1120 | } | 1119 | } |
1121 | } | 1120 | } |
1122 | else | 1121 | else |
1123 | if (m_bgpm.isNull()) | 1122 | if (m_bgpm.isNull()) |
1124 | { | 1123 | { |
1125 | p.fillRect(m_left_border,m_scrolldy,width()-(m_left_border+m_right_border),height()-m_scrolldy,m_bg); | 1124 | p.fillRect(m_left_border,m_scrolldy,width()-(m_left_border+m_right_border),height()-m_scrolldy,m_bg); |
1126 | } | 1125 | } |
1127 | else | 1126 | else |
1128 | { | 1127 | { |
1129 | bitBlt(this,m_left_border,m_scrolldy,dbuff,m_left_border,m_scrolldy,width()-(m_left_border+m_right_border), height()-m_scrolldy); | 1128 | bitBlt(this,m_left_border,m_scrolldy,dbuff,m_left_border,m_scrolldy,width()-(m_left_border+m_right_border), height()-m_scrolldy); |
1130 | } | 1129 | } |
1131 | m_scrolldy = m_topmargin; | 1130 | m_scrolldy = m_topmargin; |
1132 | m_scrolldy2 = 0; | 1131 | m_scrolldy2 = 0; |
1133 | } | 1132 | } |
1134 | redrawScroll(&p); | 1133 | redrawScroll(&p); |
1135 | emitRedraw(); | 1134 | emitRedraw(); |
1136 | lastdy = -1; | 1135 | lastdy = -1; |
1137 | } | 1136 | } |
1138 | // else | 1137 | // else |
1139 | { | 1138 | { |
1140 | if (m_rotated) | 1139 | if (m_rotated) |
1141 | { | 1140 | { |
1142 | if (lastdy >= 0) | 1141 | if (lastdy >= 0) |
1143 | { | 1142 | { |
1144 | if (m_bgpm.isNull()) | 1143 | if (m_bgpm.isNull()) |
1145 | { | 1144 | { |
1146 | p.fillRect(width()-lastdy, m_left_border, m_scrollstep, wh-(m_left_border+m_right_border),m_bg); | 1145 | p.fillRect(width()-lastdy, m_left_border, m_scrollstep, wh-(m_left_border+m_right_border),m_bg); |
1147 | } | 1146 | } |
1148 | else | 1147 | else |
1149 | { | 1148 | { |
1150 | blitRot(width()-lastdy,m_left_border,wh-(m_left_border+m_right_border), m_scrollstep, NULL); | 1149 | blitRot(width()-lastdy,m_left_border,wh-(m_left_border+m_right_border), m_scrollstep, NULL); |
1151 | } | 1150 | } |
1152 | } | 1151 | } |
1153 | p.fillRect(width()-m_scrolldy, m_left_border, 1,wh-(m_left_border+m_right_border),m_scrollcolor); | 1152 | p.fillRect(width()-m_scrolldy, m_left_border, 1,wh-(m_left_border+m_right_border),m_scrollcolor); |
1154 | } | 1153 | } |
1155 | else | 1154 | else |
1156 | { | 1155 | { |
1157 | if (lastdy >= 0) | 1156 | if (lastdy >= 0) |
1158 | { | 1157 | { |
1159 | if (m_bgpm.isNull()) | 1158 | if (m_bgpm.isNull()) |
1160 | { | 1159 | { |
1161 | p.fillRect(m_left_border,lastdy,width()-(m_left_border+m_right_border),m_scrollstep,m_bg); | 1160 | p.fillRect(m_left_border,lastdy,width()-(m_left_border+m_right_border),m_scrollstep,m_bg); |
1162 | } | 1161 | } |
1163 | else | 1162 | else |
1164 | { | 1163 | { |
1165 | bitBlt(this, m_left_border, lastdy, dbuff, m_left_border, lastdy, width()-(m_left_border+m_right_border), m_scrollstep); | 1164 | bitBlt(this, m_left_border, lastdy, dbuff, m_left_border, lastdy, width()-(m_left_border+m_right_border), m_scrollstep); |
1166 | } | 1165 | } |
1167 | } | 1166 | } |
1168 | p.fillRect(m_left_border,m_scrolldy,width()-(m_left_border+m_right_border),1,m_scrollcolor); | 1167 | p.fillRect(m_left_border,m_scrolldy,width()-(m_left_border+m_right_border),1,m_scrollcolor); |
1169 | } | 1168 | } |
1170 | } | 1169 | } |
1171 | } | 1170 | } |
1172 | 1171 | ||
1173 | void QTReader::dorollingscroll(bool _statbord) | 1172 | void QTReader::dorollingscroll(bool _statbord) |
1174 | { | 1173 | { |
1175 | bool bredrawscroll = false; | 1174 | bool bredrawscroll = false; |
1176 | QPainter p( this ); | 1175 | QPainter p( this ); |
1177 | // 2 = right, 3 = left | 1176 | // 2 = right, 3 = left |
1178 | int tmargin = (_statbord) ? m_topmargin : 0; | 1177 | int tmargin = (_statbord) ? m_topmargin : 0; |
1179 | int lmargin = (m_scrollpos == 3 || _statbord) ? m_left_border : 0; | 1178 | int lmargin = (m_scrollpos == 3 || _statbord) ? m_left_border : 0; |
1180 | int rmargin = (m_scrollpos == 2 || _statbord) ? m_right_border : 0; | 1179 | int rmargin = (m_scrollpos == 2 || _statbord) ? m_right_border : 0; |
1181 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 1180 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
1182 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; | 1181 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; |
1183 | if (m_rotated) | 1182 | if (m_rotated) |
1184 | { | 1183 | { |
1185 | m_totalscroll = (m_totalscroll+m_scrollstep) % width(); | 1184 | m_totalscroll = (m_totalscroll+m_scrollstep) % width(); |
1186 | bitBlt(this, m_scrollstep+hmargin, lmargin, this, hmargin, lmargin, width()-tmargin-hmargin, height()-(lmargin+rmargin)); | 1185 | bitBlt(this, m_scrollstep+hmargin, lmargin, this, hmargin, lmargin, width()-tmargin-hmargin, height()-(lmargin+rmargin)); |
1187 | if (!m_bgpm.isNull()) | 1186 | if (!m_bgpm.isNull()) |
1188 | { | 1187 | { |
1189 | blitRot(hmargin, tmargin, height(), m_scrollstep, NULL); | 1188 | blitRot(hmargin, tmargin, height(), m_scrollstep, NULL); |
1190 | } | 1189 | } |
1191 | else | 1190 | else |
1192 | { | 1191 | { |
1193 | p.fillRect(hmargin, rmargin, m_scrollstep, height()-lmargin-rmargin, m_bg); | 1192 | p.fillRect(hmargin, rmargin, m_scrollstep, height()-lmargin-rmargin, m_bg); |
1194 | } | 1193 | } |
1195 | } | 1194 | } |
1196 | else | 1195 | else |
1197 | { | 1196 | { |
1198 | m_totalscroll = (m_totalscroll+m_scrollstep) % height(); | 1197 | m_totalscroll = (m_totalscroll+m_scrollstep) % height(); |
1199 | bitBlt(this,lmargin,tmargin,this,lmargin,tmargin+m_scrollstep,width()-(lmargin+rmargin),height() - tmargin - hmargin - m_scrollstep); | 1198 | bitBlt(this,lmargin,tmargin,this,lmargin,tmargin+m_scrollstep,width()-(lmargin+rmargin),height() - tmargin - hmargin - m_scrollstep); |
1200 | if (m_bgpm.isNull()) | 1199 | if (m_bgpm.isNull()) |
1201 | { | 1200 | { |
1202 | p.fillRect(0, height() - (m_scrollstep+1) - hmargin, width(), (m_scrollstep+1), m_bg); | 1201 | p.fillRect(0, height() - (m_scrollstep+1) - hmargin, width(), (m_scrollstep+1), m_bg); |
1203 | } | 1202 | } |
1204 | else | 1203 | else |
1205 | { | 1204 | { |
1206 | int loff = (_statbord) ? 0 : m_totalscroll; | 1205 | int loff = (_statbord) ? 0 : m_totalscroll; |
1207 | bitBlt(this,0,height() - (m_scrollstep+1) - hmargin, dbuff, 0, (loff+height() - (m_scrollstep+1) - hmargin) % height(), width(), (m_scrollstep+1)); | 1206 | bitBlt(this,0,height() - (m_scrollstep+1) - hmargin, dbuff, 0, (loff+height() - (m_scrollstep+1) - hmargin) % height(), width(), (m_scrollstep+1)); |
1208 | } | 1207 | } |
1209 | } | 1208 | } |
1210 | 1209 | ||
1211 | if ((m_scrolldy1 = m_scrolldy1+m_scrollstep) >= textarray[0]->lineSpacing()) | 1210 | if ((m_scrolldy1 = m_scrolldy1+m_scrollstep) >= textarray[0]->lineSpacing()) |
1212 | { | 1211 | { |
1213 | int ht = textarray[0]->lineSpacing(); | 1212 | int ht = textarray[0]->lineSpacing(); |
1214 | bredrawscroll = true; | 1213 | bredrawscroll = true; |
1215 | #ifdef _SCROLLPIPE | 1214 | #ifdef _SCROLLPIPE |
1216 | if (m_pipeout != NULL) | 1215 | if (m_pipeout != NULL) |
1217 | { | 1216 | { |
1218 | QString outstr = toQString(textarray[0]->data()); | 1217 | QString outstr = toQString(textarray[0]->data()); |
1219 | if (!outstr.isEmpty()) | 1218 | if (!outstr.isEmpty()) |
1220 | { | 1219 | { |
1221 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 1220 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
1222 | fflush(m_pipeout); | 1221 | fflush(m_pipeout); |
1223 | } | 1222 | } |
1224 | else if (m_pauseAfterEachPara) | 1223 | else if (m_pauseAfterEachPara) |
1225 | { | 1224 | { |
1226 | m_isPaused = true; | 1225 | m_isPaused = true; |
1227 | timer->stop(); | 1226 | timer->stop(); |
1228 | } | 1227 | } |
1229 | } | 1228 | } |
1230 | #endif | 1229 | #endif |
1231 | CDrawBuffer* buff = textarray[0]; | 1230 | CDrawBuffer* buff = textarray[0]; |
1232 | for (int i = 1; i <= numlines; i++) | 1231 | for (int i = 1; i <= numlines; i++) |
1233 | { | 1232 | { |
1234 | textarray[i-1] = textarray[i]; | 1233 | textarray[i-1] = textarray[i]; |
1235 | locnarray[i-1] = locnarray[i]; | 1234 | locnarray[i-1] = locnarray[i]; |
1236 | } | 1235 | } |
1237 | textarray[numlines] = buff; | 1236 | textarray[numlines] = buff; |
1238 | --numlines; | 1237 | --numlines; |
1239 | m_scrolldy1 -= ht; | 1238 | m_scrolldy1 -= ht; |
1240 | } | 1239 | } |
1241 | if ((m_scrolldy2 = m_scrolldy2+m_scrollstep) >= textarray[numlines]->lineSpacing()) | 1240 | if ((m_scrolldy2 = m_scrolldy2+m_scrollstep) >= textarray[numlines]->lineSpacing()) |
1242 | { | 1241 | { |
1243 | bredrawscroll = true; | 1242 | bredrawscroll = true; |
1244 | m_scrolldy2 -= textarray[numlines]->lineSpacing(); | 1243 | m_scrolldy2 -= textarray[numlines]->lineSpacing(); |
1245 | numlines++; | 1244 | numlines++; |
1246 | 1245 | ||
1247 | if (textarray[numlines] == NULL) | 1246 | if (textarray[numlines] == NULL) |
1248 | { | 1247 | { |
1249 | textarray[numlines] = new CDrawBuffer(&m_fontControl); | 1248 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
1250 | } | 1249 | } |
1251 | locnarray[numlines] = locate(); | 1250 | locnarray[numlines] = locate(); |
1252 | int ch = getline(textarray[numlines]); | 1251 | int ch = getline(textarray[numlines]); |
1253 | if (m_rotated) | 1252 | if (m_rotated) |
1254 | { | 1253 | { |
1255 | blitRot(hmargin, 0, height(), -1, textarray[numlines-1]); | 1254 | blitRot(hmargin, 0, height(), -1, textarray[numlines-1]); |
1256 | } | 1255 | } |
1257 | else | 1256 | else |
1258 | { | 1257 | { |
1259 | // 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); | 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); |
1260 | 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); | 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); |
1261 | 1260 | ||
1262 | } | 1261 | } |
1263 | mylastpos = locate(); | 1262 | mylastpos = locate(); |
1264 | if (!ch) | 1263 | if (!ch) |
1265 | { | 1264 | { |
1266 | redrawScroll(&p); | 1265 | redrawScroll(&p); |
1267 | emitRedraw(); | 1266 | emitRedraw(); |
1268 | m_autoScroll = false; | 1267 | m_autoScroll = false; |
1269 | #ifdef _SCROLLPIPE | 1268 | #ifdef _SCROLLPIPE |
1270 | for (int i = 0; i < numlines; i++) | 1269 | for (int i = 0; i < numlines; i++) |
1271 | { | 1270 | { |
1272 | if (m_pipeout != NULL) | 1271 | if (m_pipeout != NULL) |
1273 | { | 1272 | { |
1274 | QString outstr = toQString(textarray[i]->data()); | 1273 | QString outstr = toQString(textarray[i]->data()); |
1275 | if (!outstr.isEmpty()) | 1274 | if (!outstr.isEmpty()) |
1276 | { | 1275 | { |
1277 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 1276 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
1278 | fflush(m_pipeout); | 1277 | fflush(m_pipeout); |
1279 | } | 1278 | } |
1280 | } | 1279 | } |
1281 | } | 1280 | } |
1282 | #endif | 1281 | #endif |
1283 | emit SetScrollState(m_autoScroll); | 1282 | emit SetScrollState(m_autoScroll); |
1284 | #ifdef USEQPE | 1283 | #ifdef USEQPE |
1285 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 1284 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
1286 | #endif | 1285 | #endif |
1287 | return; | 1286 | return; |
1288 | } | 1287 | } |
1289 | } | 1288 | } |
1290 | if (!bredrawscroll && ((m_scrolldy2/m_scrollstep) % 10 == 5) && textarray[numlines]->showPartial()) | 1289 | if (!bredrawscroll && ((m_scrolldy2/m_scrollstep) % 10 == 5) && textarray[numlines]->showPartial()) |
1291 | { | 1290 | { |
1292 | if (m_rotated) | 1291 | if (m_rotated) |
1293 | { | 1292 | { |
1294 | blitRot(hmargin + m_scrolldy2 - textarray[numlines]->lineSpacing(), 0, height(), -1, textarray[numlines]); | 1293 | blitRot(hmargin + m_scrolldy2 - textarray[numlines]->lineSpacing(), 0, height(), -1, textarray[numlines]); |
1295 | } | 1294 | } |
1296 | else | 1295 | else |
1297 | { | 1296 | { |
1298 | 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); | 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); |
1299 | } | 1298 | } |
1300 | } | 1299 | } |
1301 | if (m_scrollpos != 0) | 1300 | if (m_scrollpos != 0) |
1302 | { | 1301 | { |
1303 | redrawScroll(&p); | 1302 | redrawScroll(&p); |
1304 | } | 1303 | } |
1305 | if (bredrawscroll) emitRedraw(); | 1304 | if (bredrawscroll) emitRedraw(); |
1306 | } | 1305 | } |
1307 | 1306 | ||
1308 | void QTReader::dostaticscroll() | 1307 | void QTReader::dostaticscroll() |
1309 | { | 1308 | { |
1310 | redrawall(); | 1309 | redrawall(); |
1311 | bool bredraw = false; | 1310 | bool bredraw = false; |
1312 | if ((m_scrolldy1 = m_scrolldy1+m_scrollstep) >= textarray[0]->lineSpacing()) | 1311 | if ((m_scrolldy1 = m_scrolldy1+m_scrollstep) >= textarray[0]->lineSpacing()) |
1313 | { | 1312 | { |
1314 | int ht = textarray[0]->lineSpacing(); | 1313 | int ht = textarray[0]->lineSpacing(); |
1315 | bredraw = true; | 1314 | bredraw = true; |
1316 | #ifdef _SCROLLPIPE | 1315 | #ifdef _SCROLLPIPE |
1317 | if (m_pipeout != NULL) | 1316 | if (m_pipeout != NULL) |
1318 | { | 1317 | { |
1319 | QString outstr = toQString(textarray[0]->data()); | 1318 | QString outstr = toQString(textarray[0]->data()); |
1320 | if (!outstr.isEmpty()) | 1319 | if (!outstr.isEmpty()) |
1321 | { | 1320 | { |
1322 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 1321 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
1323 | fflush(m_pipeout); | 1322 | fflush(m_pipeout); |
1324 | } | 1323 | } |
1325 | else if (m_pauseAfterEachPara) | 1324 | else if (m_pauseAfterEachPara) |
1326 | { | 1325 | { |
1327 | m_isPaused = true; | 1326 | m_isPaused = true; |
1328 | timer->stop(); | 1327 | timer->stop(); |
1329 | } | 1328 | } |
1330 | } | 1329 | } |
1331 | #endif | 1330 | #endif |
1332 | CDrawBuffer* buff = textarray[0]; | 1331 | CDrawBuffer* buff = textarray[0]; |
1333 | for (int i = 1; i <= numlines; i++) | 1332 | for (int i = 1; i <= numlines; i++) |
1334 | { | 1333 | { |
1335 | textarray[i-1] = textarray[i]; | 1334 | textarray[i-1] = textarray[i]; |
1336 | locnarray[i-1] = locnarray[i]; | 1335 | locnarray[i-1] = locnarray[i]; |
1337 | } | 1336 | } |
1338 | textarray[numlines] = buff; | 1337 | textarray[numlines] = buff; |
1339 | --numlines; | 1338 | --numlines; |
1340 | m_scrolldy1 -= ht; | 1339 | m_scrolldy1 -= ht; |
1341 | } | 1340 | } |
1342 | if ((m_scrolldy2 = m_scrolldy2 + m_scrollstep) >= textarray[numlines]->lineSpacing()) | 1341 | if ((m_scrolldy2 = m_scrolldy2 + m_scrollstep) >= textarray[numlines]->lineSpacing()) |
1343 | { | 1342 | { |
1344 | bredraw = true; | 1343 | bredraw = true; |
1345 | m_scrolldy2 -= textarray[numlines]->lineSpacing(); | 1344 | m_scrolldy2 -= textarray[numlines]->lineSpacing(); |
1346 | numlines++; | 1345 | numlines++; |
1347 | 1346 | ||
1348 | if (textarray[numlines] == NULL) | 1347 | if (textarray[numlines] == NULL) |
1349 | { | 1348 | { |
1350 | textarray[numlines] = new CDrawBuffer(&m_fontControl); | 1349 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
1351 | } | 1350 | } |
1352 | locnarray[numlines] = locate(); | 1351 | locnarray[numlines] = locate(); |
1353 | int ch = getline(textarray[numlines]); | 1352 | int ch = getline(textarray[numlines]); |
1354 | mylastpos = locate(); | 1353 | mylastpos = locate(); |
1355 | if (!ch) | 1354 | if (!ch) |
1356 | { | 1355 | { |
1357 | redrawall(); | 1356 | redrawall(); |
1358 | emitRedraw(); | 1357 | emitRedraw(); |
1359 | m_autoScroll = false; | 1358 | m_autoScroll = false; |
1360 | #ifdef _SCROLLPIPE | 1359 | #ifdef _SCROLLPIPE |
1361 | for (int i = 0; i < numlines; i++) | 1360 | for (int i = 0; i < numlines; i++) |
1362 | { | 1361 | { |
1363 | if (m_pipeout != NULL) | 1362 | if (m_pipeout != NULL) |
1364 | { | 1363 | { |
1365 | QString outstr = toQString(textarray[i]->data()); | 1364 | QString outstr = toQString(textarray[i]->data()); |
1366 | if (!outstr.isEmpty()) | 1365 | if (!outstr.isEmpty()) |
1367 | { | 1366 | { |
1368 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 1367 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
1369 | fflush(m_pipeout); | 1368 | fflush(m_pipeout); |
1370 | } | 1369 | } |
1371 | } | 1370 | } |
1372 | } | 1371 | } |
1373 | #endif | 1372 | #endif |
1374 | emit SetScrollState(m_autoScroll); | 1373 | emit SetScrollState(m_autoScroll); |
1375 | #ifdef USEQPE | 1374 | #ifdef USEQPE |
1376 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 1375 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
1377 | #endif | 1376 | #endif |
1378 | return; | 1377 | return; |
1379 | } | 1378 | } |
1380 | } | 1379 | } |
1381 | if (bredraw) emitRedraw(); | 1380 | if (bredraw) emitRedraw(); |
1382 | } | 1381 | } |
1383 | 1382 | ||
1384 | void QTReader::redrawScroll(QPainter* p) | 1383 | void QTReader::redrawScroll(QPainter* p) |
1385 | { | 1384 | { |
1386 | int offset = (m_scrolltype == 1) ? m_totalscroll : 0; | 1385 | int offset = (m_scrolltype == 1) ? m_totalscroll : 0; |
1387 | switch (m_scrollpos) | 1386 | switch (m_scrollpos) |
1388 | { | 1387 | { |
1389 | case 1: | 1388 | case 1: |
1390 | { | 1389 | { |
1391 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 1390 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
1392 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; | 1391 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; |
1393 | if (m_rotated) | 1392 | if (m_rotated) |
1394 | { | 1393 | { |
1395 | if (m_bgpm.isNull()) | 1394 | if (m_bgpm.isNull()) |
1396 | { | 1395 | { |
1397 | p->fillRect(0,0,hmargin,height(),m_bg); | 1396 | p->fillRect(0,0,hmargin,height(),m_bg); |
1398 | } | 1397 | } |
1399 | else | 1398 | else |
1400 | { | 1399 | { |
1401 | blitRot(0,0, height(), hmargin, NULL); | 1400 | blitRot(0,0, height(), hmargin, NULL); |
1402 | } | 1401 | } |
1403 | } | 1402 | } |
1404 | else | 1403 | else |
1405 | { | 1404 | { |
1406 | if (m_bgpm.isNull()) | 1405 | if (m_bgpm.isNull()) |
1407 | { | 1406 | { |
1408 | p->fillRect(0,height() - hmargin,width(),hmargin,m_bg); | 1407 | p->fillRect(0,height() - hmargin,width(),hmargin,m_bg); |
1409 | } | 1408 | } |
1410 | else | 1409 | else |
1411 | { | 1410 | { |
1412 | int toffset = (offset+height()-hmargin) % height(); | 1411 | int toffset = (offset+height()-hmargin) % height(); |
1413 | if (toffset+hmargin > height()) | 1412 | if (toffset+hmargin > height()) |
1414 | { | 1413 | { |
1415 | int fp = height()-toffset; | 1414 | int fp = height()-toffset; |
1416 | bitBlt(this, | 1415 | bitBlt(this, |
1417 | 0,height() - hmargin, | 1416 | 0,height() - hmargin, |
1418 | dbuff, | 1417 | dbuff, |
1419 | 0, toffset, width(), fp); | 1418 | 0, toffset, width(), fp); |
1420 | bitBlt(this, | 1419 | bitBlt(this, |
1421 | 0,height()-hmargin+fp, | 1420 | 0,height()-hmargin+fp, |
1422 | dbuff, | 1421 | dbuff, |
1423 | 0, 0, width(), hmargin-fp); | 1422 | 0, 0, width(), hmargin-fp); |
1424 | } | 1423 | } |
1425 | else | 1424 | else |
1426 | { | 1425 | { |
1427 | bitBlt(this, | 1426 | bitBlt(this, |
1428 | 0,height() - hmargin, | 1427 | 0,height() - hmargin, |
1429 | dbuff, | 1428 | dbuff, |
1430 | 0, toffset, width(), hmargin); | 1429 | 0, toffset, width(), hmargin); |
1431 | } | 1430 | } |
1432 | } | 1431 | } |
1433 | } | 1432 | } |
1434 | } | 1433 | } |
1435 | break; | 1434 | break; |
1436 | case 2: //right | 1435 | case 2: //right |
1437 | if (m_rotated) | 1436 | if (m_rotated) |
1438 | { | 1437 | { |
1439 | if (m_bgpm.isNull()) | 1438 | if (m_bgpm.isNull()) |
1440 | { | 1439 | { |
1441 | p->fillRect(0,height()-m_right_border,width(),m_right_border,m_bg); | 1440 | p->fillRect(0,height()-m_right_border,width(),m_right_border,m_bg); |
1442 | } | 1441 | } |
1443 | else | 1442 | else |
1444 | { | 1443 | { |
1445 | blitRot(0,height()-m_right_border, m_right_border, width(), NULL); | 1444 | blitRot(0,height()-m_right_border, m_right_border, width(), NULL); |
1446 | } | 1445 | } |
1447 | } | 1446 | } |
1448 | else | 1447 | else |
1449 | { | 1448 | { |
1450 | if (m_bgpm.isNull()) | 1449 | if (m_bgpm.isNull()) |
1451 | { | 1450 | { |
1452 | p->fillRect(width()-m_right_border,0,m_right_border,height(),m_bg); | 1451 | p->fillRect(width()-m_right_border,0,m_right_border,height(),m_bg); |
1453 | } | 1452 | } |
1454 | else | 1453 | else |
1455 | { | 1454 | { |
1456 | int x = width() - m_right_border; | 1455 | int x = width() - m_right_border; |
1457 | int fp = height()-offset; | 1456 | int fp = height()-offset; |
1458 | bitBlt(this, x, 0, dbuff, x, offset, m_right_border, fp); | 1457 | bitBlt(this, x, 0, dbuff, x, offset, m_right_border, fp); |
1459 | bitBlt(this, x, fp, dbuff, x, 0, m_right_border, height()-fp); | 1458 | bitBlt(this, x, fp, dbuff, x, 0, m_right_border, height()-fp); |
1460 | } | 1459 | } |
1461 | } | 1460 | } |
1462 | break; | 1461 | break; |
1463 | case 3: //left | 1462 | case 3: //left |
1464 | if (m_rotated) | 1463 | if (m_rotated) |
1465 | { | 1464 | { |
1466 | if (m_bgpm.isNull()) | 1465 | if (m_bgpm.isNull()) |
1467 | { | 1466 | { |
1468 | p->fillRect(0,0,width(),m_left_border,m_bg); | 1467 | p->fillRect(0,0,width(),m_left_border,m_bg); |
1469 | } | 1468 | } |
1470 | else | 1469 | else |
1471 | { | 1470 | { |
1472 | blitRot(0,0, m_left_border, width(), NULL); | 1471 | blitRot(0,0, m_left_border, width(), NULL); |
1473 | } | 1472 | } |
1474 | } | 1473 | } |
1475 | else | 1474 | else |
1476 | { | 1475 | { |
1477 | if (m_bgpm.isNull()) | 1476 | if (m_bgpm.isNull()) |
1478 | { | 1477 | { |
1479 | p->fillRect(0,0,m_left_border,height(),m_bg); | 1478 | p->fillRect(0,0,m_left_border,height(),m_bg); |
1480 | } | 1479 | } |
1481 | else | 1480 | else |
1482 | { | 1481 | { |
1483 | int fp = height()-offset; | 1482 | int fp = height()-offset; |
1484 | bitBlt(this, 0, 0, dbuff, 0, offset, m_left_border, fp); | 1483 | bitBlt(this, 0, 0, dbuff, 0, offset, m_left_border, fp); |
1485 | bitBlt(this, 0, fp, dbuff, 0, 0, m_left_border, height()-fp); | 1484 | bitBlt(this, 0, fp, dbuff, 0, 0, m_left_border, height()-fp); |
1486 | } | 1485 | } |
1487 | } | 1486 | } |
1488 | break; | 1487 | break; |
1489 | case 0: | 1488 | case 0: |
1490 | default: | 1489 | default: |
1491 | break; | 1490 | break; |
1492 | } | 1491 | } |
1493 | if (m_scrollpos != 0) DrawScroll(p, width(), height()); | 1492 | if (m_scrollpos != 0) DrawScroll(p, width(), height()); |
1494 | } | 1493 | } |
1495 | 1494 | ||
1496 | void QTReader::autoscroll() | 1495 | void QTReader::autoscroll() |
1497 | { | 1496 | { |
1498 | drawBackground(); | 1497 | drawBackground(); |
1499 | dbp->end(); | 1498 | dbp->end(); |
1500 | timer->start(real_delay(), false); | 1499 | timer->start(real_delay(), false); |
1501 | } | 1500 | } |
1502 | 1501 | ||
1503 | void QTReader::setfont() | 1502 | void QTReader::setfont() |
1504 | { | 1503 | { |
1505 | // m_fontControl.Change | 1504 | // m_fontControl.Change |
1506 | m_charWidth = (m_charpc*m_fontControl.currentsize())/100; | 1505 | m_charWidth = (m_charpc*m_fontControl.currentsize())/100; |
1507 | if (m_charWidth <= 0) m_charWidth = 1; | 1506 | if (m_charWidth <= 0) m_charWidth = 1; |
1508 | m_ascent = m_fontControl.ascent(); | 1507 | m_ascent = m_fontControl.ascent(); |
1509 | m_descent = m_fontControl.descent(); | 1508 | m_descent = m_fontControl.descent(); |
1510 | m_linespacing = m_fontControl.lineSpacing(); | 1509 | m_linespacing = m_fontControl.lineSpacing(); |
1511 | } | 1510 | } |
1512 | 1511 | ||
1513 | void QTReader::DrawStraight(QPainter* p, int w, int h) | 1512 | void QTReader::DrawStraight(QPainter* p, int w, int h) |
1514 | { | 1513 | { |
1515 | if (m_scrolldy == m_topmargin) | 1514 | if (m_scrolldy == m_topmargin) |
1516 | { | 1515 | { |
1517 | int ypos = textarray[0]->ascent()-m_scrolldy1+m_topmargin; | 1516 | int ypos = textarray[0]->ascent()-m_scrolldy1+m_topmargin; |
1518 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); | 1517 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); |
1519 | int i; | 1518 | int i; |
1520 | for (i = 1; i < numlines; i++) | 1519 | for (i = 1; i < numlines; i++) |
1521 | { | 1520 | { |
1522 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ | 1521 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ |
1523 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; | 1522 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; |
1524 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); | 1523 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); |
1525 | } | 1524 | } |
1526 | if (textarray[i]->showPartial()) | 1525 | if (textarray[i]->showPartial()) |
1527 | { | 1526 | { |
1528 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ | 1527 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ |
1529 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; | 1528 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; |
1530 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); | 1529 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); |
1531 | } | 1530 | } |
1532 | } | 1531 | } |
1533 | else | 1532 | else |
1534 | { | 1533 | { |
1535 | int ypos = textarray[0]->ascent()-m_scrolldy1+m_scrolldy+m_topmargin; | 1534 | int ypos = textarray[0]->ascent()-m_scrolldy1+m_scrolldy+m_topmargin; |
1536 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); | 1535 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); |
1537 | // p->fillRect(m_border, 0, w-2*m_border, m_scrolldy, m_bg); | 1536 | // p->fillRect(m_border, 0, w-2*m_border, m_scrolldy, m_bg); |
1538 | for (int i = 1; i < numlines; i++) | 1537 | for (int i = 1; i < numlines; i++) |
1539 | { | 1538 | { |
1540 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ | 1539 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ |
1541 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; | 1540 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; |
1542 | if (ypos+textarray[i]->descent() > h) | 1541 | if (ypos+textarray[i]->descent() > h) |
1543 | { | 1542 | { |
1544 | ypos = textarray[i]->ascent(); | 1543 | ypos = textarray[i]->ascent(); |
1545 | } | 1544 | } |
1546 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); | 1545 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, w, m_left_border, m_right_border, m_bg, h-m_topmargin-m_bottommargin); |
1547 | } | 1546 | } |
1548 | p->fillRect(m_left_border,m_scrolldy,w-(m_left_border+m_right_border),1,m_scrollcolor); | 1547 | p->fillRect(m_left_border,m_scrolldy,w-(m_left_border+m_right_border),1,m_scrollcolor); |
1549 | } | 1548 | } |
1550 | bool wasrotated = m_rotated; | 1549 | bool wasrotated = m_rotated; |
1551 | m_rotated = false; | 1550 | m_rotated = false; |
1552 | DrawScroll(p, w, h); | 1551 | DrawScroll(p, w, h); |
1553 | m_rotated = wasrotated; | 1552 | m_rotated = wasrotated; |
1554 | 1553 | ||
1555 | } | 1554 | } |
1556 | 1555 | ||
1557 | void QTReader::redrawall() | 1556 | void QTReader::redrawall() |
1558 | { | 1557 | { |
1559 | if (m_rotated) | 1558 | if (m_rotated) |
1560 | { | 1559 | { |
1561 | #ifdef DOUBLEBUFFER | 1560 | #ifdef DOUBLEBUFFER |
1562 | drawBackground(); | 1561 | drawBackground(); |
1563 | DrawStraight(dbp, height(), width()); | 1562 | DrawStraight(dbp, height(), width()); |
1564 | dbp->end(); | 1563 | dbp->end(); |
1565 | 1564 | ||
1566 | QWMatrix m; | 1565 | QWMatrix m; |
1567 | m.rotate(90); | 1566 | m.rotate(90); |
1568 | QPixmap rp = dbuff->xForm(m); | 1567 | QPixmap rp = dbuff->xForm(m); |
1569 | bitBlt(this, 0,0,&rp,0,0,-1,-1); | 1568 | bitBlt(this, 0,0,&rp,0,0,-1,-1); |
1570 | #else | 1569 | #else |
1571 | QPixmap dbuff(height(), width()); | 1570 | QPixmap dbuff(height(), width()); |
1572 | QPainter dbp(&dbuff); | 1571 | QPainter dbp(&dbuff); |
1573 | // dbp.setBackgroundMode(OpaqueMode); | 1572 | // dbp.setBackgroundMode(OpaqueMode); |
1574 | dbp.fillRect(dbuff.rect(), m_bg); | 1573 | dbp.fillRect(dbuff.rect(), m_bg); |
1575 | 1574 | ||
1576 | DrawStraight(&dbp, height(), width()); | 1575 | DrawStraight(&dbp, height(), width()); |
1577 | 1576 | ||
1578 | QWMatrix m; | 1577 | QWMatrix m; |
1579 | m.rotate(90); | 1578 | m.rotate(90); |
1580 | QPixmap rp = dbuff.xForm(m); | 1579 | QPixmap rp = dbuff.xForm(m); |
1581 | bitBlt(this, 0,0,&rp,0,0,-1,-1); | 1580 | bitBlt(this, 0,0,&rp,0,0,-1,-1); |
1582 | #endif | 1581 | #endif |
1583 | } | 1582 | } |
1584 | else | 1583 | else |
1585 | { | 1584 | { |
1586 | #ifdef DOUBLEBUFFER | 1585 | #ifdef DOUBLEBUFFER |
1587 | drawBackground(); | 1586 | drawBackground(); |
1588 | DrawStraight(dbp, width(), height()); | 1587 | DrawStraight(dbp, width(), height()); |
1589 | dbp->end(); | 1588 | dbp->end(); |
1590 | bitBlt(this, 0,0,dbuff,0,0,-1,-1); | 1589 | bitBlt(this, 0,0,dbuff,0,0,-1,-1); |
1591 | #else | 1590 | #else |
1592 | DrawStraight(p, width(), height()); | 1591 | DrawStraight(p, width(), height()); |
1593 | #endif | 1592 | #endif |
1594 | } | 1593 | } |
1595 | } | 1594 | } |
1596 | 1595 | ||
1597 | void QTReader::drawFonts() | 1596 | void QTReader::drawFonts() |
1598 | { | 1597 | { |
1599 | if (bDoUpdates) | 1598 | if (bDoUpdates) |
1600 | { | 1599 | { |
1601 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 1600 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
1602 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; | 1601 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; |
1603 | //qDebug("How refreshing..."); | 1602 | //qDebug("How refreshing..."); |
1604 | if (buffdoc.empty()) return; | 1603 | if (buffdoc.empty()) return; |
1605 | setfont(); | 1604 | setfont(); |
1606 | //if (!m_autoScroll) m_scrolldy1 = 0; | 1605 | //if (!m_autoScroll) m_scrolldy1 = 0; |
1607 | #ifdef ROTATION_ENABLED | 1606 | #ifdef ROTATION_ENABLED |
1608 | if (m_lastwidth != ((m_rotated) ? height() : width())) | 1607 | if (m_lastwidth != ((m_rotated) ? height() : width())) |
1609 | { | 1608 | { |
1610 | m_scrolldy = m_topmargin; | 1609 | m_scrolldy = m_topmargin; |
1611 | // qDebug("Not Optimised %d", m_lastwidth); | 1610 | // qDebug("Not Optimised %d", m_lastwidth); |
1612 | m_lastwidth = ((m_rotated) ? height() : width()); | 1611 | m_lastwidth = ((m_rotated) ? height() : width()); |
1613 | m_lastheight = ((m_rotated) ? width() : height()); | 1612 | m_lastheight = ((m_rotated) ? width() : height()); |
1614 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); | 1613 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); |
1615 | locate(pagelocate()); | 1614 | locate(pagelocate()); |
1616 | // qDebug("Not Optimised %d", m_lastwidth); | 1615 | // qDebug("Not Optimised %d", m_lastwidth); |
1617 | } | 1616 | } |
1618 | else | 1617 | else |
1619 | { | 1618 | { |
1620 | int newht = ((m_rotated) ? width() : height()); | 1619 | int newht = ((m_rotated) ? width() : height()); |
1621 | if (m_lastheight > newht) | 1620 | if (m_lastheight > newht) |
1622 | { | 1621 | { |
1623 | // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht); | 1622 | // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht); |
1624 | m_scrolldy = m_topmargin; | 1623 | m_scrolldy = m_topmargin; |
1625 | int ypos = m_scrolldy1+m_topmargin; | 1624 | int ypos = m_scrolldy1+m_topmargin; |
1626 | for (int i = 0; i < numlines; i++) | 1625 | for (int i = 0; i < numlines; i++) |
1627 | { | 1626 | { |
1628 | if ((ypos += textarray[i]->lineSpacing()) > newht - hmargin) | 1627 | if ((ypos += textarray[i]->lineSpacing()) > newht - hmargin) |
1629 | { | 1628 | { |
1630 | numlines = i; | 1629 | numlines = i; |
1631 | jumpto(mylastpos = locnarray[i+1]); | 1630 | jumpto(mylastpos = locnarray[i+1]); |
1632 | break; | 1631 | break; |
1633 | } | 1632 | } |
1634 | } | 1633 | } |
1635 | // qDebug("Optimised < %d", numlines); | 1634 | // qDebug("Optimised < %d", numlines); |
1636 | m_lastheight = newht; | 1635 | m_lastheight = newht; |
1637 | } | 1636 | } |
1638 | else if (m_lastheight < newht) | 1637 | else if (m_lastheight < newht) |
1639 | { | 1638 | { |
1640 | m_scrolldy = m_topmargin; | 1639 | m_scrolldy = m_topmargin; |
1641 | // qDebug("Optimised > %d", numlines); | 1640 | // qDebug("Optimised > %d", numlines); |
1642 | int ypos = m_scrolldy1+m_topmargin; | 1641 | int ypos = m_scrolldy1+m_topmargin; |
1643 | for (int i = 0; i <= numlines; i++) | 1642 | for (int i = 0; i <= numlines; i++) |
1644 | { | 1643 | { |
1645 | ypos += textarray[i]->lineSpacing(); | 1644 | ypos += textarray[i]->lineSpacing(); |
1646 | } | 1645 | } |
1647 | fillbuffer(numlines+1, ypos, newht); | 1646 | fillbuffer(numlines+1, ypos, newht); |
1648 | // qDebug("Optimised > %d", numlines); | 1647 | // qDebug("Optimised > %d", numlines); |
1649 | } | 1648 | } |
1650 | if (numlines > 0) | 1649 | if (numlines > 0) |
1651 | { | 1650 | { |
1652 | redrawall(); | 1651 | redrawall(); |
1653 | } | 1652 | } |
1654 | } | 1653 | } |
1655 | #else | 1654 | #else |
1656 | if (m_lastwidth != width()) | 1655 | if (m_lastwidth != width()) |
1657 | { | 1656 | { |
1658 | // qDebug("Not Optimised %d", m_lastwidth); | 1657 | // qDebug("Not Optimised %d", m_lastwidth); |
1659 | m_lastwidth = width(); | 1658 | m_lastwidth = width(); |
1660 | m_lastheight = height(); | 1659 | m_lastheight = height(); |
1661 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); | 1660 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); |
1662 | locate(pagelocate()); | 1661 | locate(pagelocate()); |
1663 | // qDebug("Not Optimised %d", m_lastwidth); | 1662 | // qDebug("Not Optimised %d", m_lastwidth); |
1664 | } | 1663 | } |
1665 | else | 1664 | else |
1666 | { | 1665 | { |
1667 | int newht = height(); | 1666 | int newht = height(); |
1668 | if (m_lastheight > newht) | 1667 | if (m_lastheight > newht) |
1669 | { | 1668 | { |
1670 | // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht); | 1669 | // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht); |
1671 | int ypos = m_topmargin; | 1670 | int ypos = m_topmargin; |
1672 | for (int i = 0; i < numlines; i++) | 1671 | for (int i = 0; i < numlines; i++) |
1673 | { | 1672 | { |
1674 | if ((ypos += textarray[i]->lineSpacing()) > newht - hmargin) | 1673 | if ((ypos += textarray[i]->lineSpacing()) > newht - hmargin) |
1675 | { | 1674 | { |
1676 | numlines = i; | 1675 | numlines = i; |
1677 | jumpto(mylastpos = locnarray[i+1]); | 1676 | jumpto(mylastpos = locnarray[i+1]); |
1678 | break; | 1677 | break; |
1679 | } | 1678 | } |
1680 | } | 1679 | } |
1681 | // qDebug("Optimised < %d", numlines); | 1680 | // qDebug("Optimised < %d", numlines); |
1682 | m_lastheight = newht; | 1681 | m_lastheight = newht; |
1683 | } | 1682 | } |
1684 | else if (m_lastheight < newht) | 1683 | else if (m_lastheight < newht) |
1685 | { | 1684 | { |
1686 | // qDebug("Optimised > %d", numlines); | 1685 | // qDebug("Optimised > %d", numlines); |
1687 | int ypos = m_topmargin; | 1686 | int ypos = m_topmargin; |
1688 | for (int i = 0; i <= numlines; i++) | 1687 | for (int i = 0; i <= numlines; i++) |
1689 | { | 1688 | { |
1690 | ypos += textarray[i]->lineSpacing(); | 1689 | ypos += textarray[i]->lineSpacing(); |
1691 | } | 1690 | } |
1692 | fillbuffer(numlines+1, ypos, newht); | 1691 | fillbuffer(numlines+1, ypos, newht); |
1693 | // qDebug("Optimised > %d", numlines); | 1692 | // qDebug("Optimised > %d", numlines); |
1694 | } | 1693 | } |
1695 | if (numlines > 0) | 1694 | if (numlines > 0) |
1696 | { | 1695 | { |
1697 | int ypos = textarray[0]->ascent()+m_topmargin; | 1696 | int ypos = textarray[0]->ascent()+m_topmargin; |
1698 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | 1697 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); |
1699 | // int last = (m_showlast) ? numlines : numlines-1; | 1698 | // int last = (m_showlast) ? numlines : numlines-1; |
1700 | // for (int i = 1; i <= last; i++) | 1699 | // for (int i = 1; i <= last; i++) |
1701 | for (int i = 1; i < numlines; i++) | 1700 | for (int i = 1; i < numlines; i++) |
1702 | { | 1701 | { |
1703 | // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; | 1702 | // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; |
1704 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ | 1703 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ |
1705 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; | 1704 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; |
1706 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | 1705 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); |
1707 | } | 1706 | } |
1708 | // mylastpos = locate(); | 1707 | // mylastpos = locate(); |
1709 | } | 1708 | } |
1710 | } | 1709 | } |
1711 | #endif | 1710 | #endif |
1712 | emitRedraw(); | 1711 | emitRedraw(); |
1713 | } | 1712 | } |
1714 | /* | 1713 | /* |
1715 | else | 1714 | else |
1716 | { | 1715 | { |
1717 | qDebug("Not so refreshing..."); | 1716 | qDebug("Not so refreshing..."); |
1718 | } | 1717 | } |
1719 | */ | 1718 | */ |
1720 | } | 1719 | } |
1721 | 1720 | ||
1722 | void QTReader::DrawScroll( QPainter *p, int _w, int _h ) | 1721 | void QTReader::DrawScroll( QPainter *p, int _w, int _h ) |
1723 | { | 1722 | { |
1724 | if (!buffdoc.empty()) | 1723 | if (!buffdoc.empty()) |
1725 | { | 1724 | { |
1726 | QBrush checkered = QBrush( Dense4Pattern ); | 1725 | QBrush checkered = QBrush( Dense4Pattern ); |
1727 | checkered.setColor(m_scrollbarcolor); | 1726 | checkered.setColor(m_scrollbarcolor); |
1728 | switch (m_scrollpos) | 1727 | switch (m_scrollpos) |
1729 | { | 1728 | { |
1730 | case 1: | 1729 | case 1: |
1731 | if (m_rotated) | 1730 | if (m_rotated) |
1732 | { | 1731 | { |
1733 | p->fillRect(0, 0, 2, _h, checkered); | 1732 | p->fillRect(0, 0, 2, _h, checkered); |
1734 | } | 1733 | } |
1735 | else | 1734 | else |
1736 | { | 1735 | { |
1737 | p->fillRect(0, _h-2, _w, 2, checkered); | 1736 | p->fillRect(0, _h-2, _w, 2, checkered); |
1738 | } | 1737 | } |
1739 | break; | 1738 | break; |
1740 | case 2: | 1739 | case 2: |
1741 | if (m_rotated) | 1740 | if (m_rotated) |
1742 | { | 1741 | { |
1743 | p->fillRect(0, _h-2, _w, 2, checkered); | 1742 | p->fillRect(0, _h-2, _w, 2, checkered); |
1744 | } | 1743 | } |
1745 | else | 1744 | else |
1746 | { | 1745 | { |
1747 | p->fillRect(_w-2, 0, 2, _h, checkered); | 1746 | p->fillRect(_w-2, 0, 2, _h, checkered); |
1748 | } | 1747 | } |
1749 | break; | 1748 | break; |
1750 | case 3: | 1749 | case 3: |
1751 | if (m_rotated) | 1750 | if (m_rotated) |
1752 | { | 1751 | { |
1753 | p->fillRect(0, 0, _w, 2, checkered); | 1752 | p->fillRect(0, 0, _w, 2, checkered); |
1754 | } | 1753 | } |
1755 | else | 1754 | else |
1756 | { | 1755 | { |
1757 | p->fillRect(0, 0, 2, _h, checkered); | 1756 | p->fillRect(0, 0, 2, _h, checkered); |
1758 | } | 1757 | } |
1759 | break; | 1758 | break; |
1760 | case 0: | 1759 | case 0: |
1761 | default: | 1760 | default: |
1762 | break; | 1761 | break; |
1763 | } | 1762 | } |
1764 | switch (m_scrollpos) | 1763 | switch (m_scrollpos) |
1765 | { | 1764 | { |
1766 | case 1: | 1765 | case 1: |
1767 | { | 1766 | { |
1768 | int ht; | 1767 | int ht; |
1769 | if (m_rotated) | 1768 | if (m_rotated) |
1770 | { | 1769 | { |
1771 | ht = _h; | 1770 | ht = _h; |
1772 | } | 1771 | } |
1773 | else | 1772 | else |
1774 | { | 1773 | { |
1775 | ht = _w; | 1774 | ht = _w; |
1776 | } | 1775 | } |
1777 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); | 1776 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); |
1778 | int mid = (ht*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); | 1777 | int mid = (ht*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); |
1779 | int sliderheight = ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize; | 1778 | int sliderheight = ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize; |
1780 | int sliderpos; | 1779 | int sliderpos; |
1781 | if (sliderheight < 10) | 1780 | if (sliderheight < 10) |
1782 | { | 1781 | { |
1783 | sliderheight = 10; | 1782 | sliderheight = 10; |
1784 | sliderpos = mid-5; | 1783 | sliderpos = mid-5; |
1785 | } | 1784 | } |
1786 | else | 1785 | else |
1787 | { | 1786 | { |
1788 | sliderpos = (ht*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize; | 1787 | sliderpos = (ht*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize; |
1789 | } | 1788 | } |
1790 | if (m_rotated) | 1789 | if (m_rotated) |
1791 | { | 1790 | { |
1792 | p->fillRect(0, sliderpos, 3, sliderheight, m_scrollbarcolor); | 1791 | p->fillRect(0, sliderpos, 3, sliderheight, m_scrollbarcolor); |
1793 | } | 1792 | } |
1794 | else | 1793 | else |
1795 | { | 1794 | { |
1796 | p->fillRect(sliderpos, _h-3, sliderheight, 3, m_scrollbarcolor); | 1795 | p->fillRect(sliderpos, _h-3, sliderheight, 3, m_scrollbarcolor); |
1797 | } | 1796 | } |
1798 | } | 1797 | } |
1799 | break; | 1798 | break; |
1800 | case 2: | 1799 | case 2: |
1801 | case 3: | 1800 | case 3: |
1802 | { | 1801 | { |
1803 | int ht; | 1802 | int ht; |
1804 | if (m_rotated) | 1803 | if (m_rotated) |
1805 | { | 1804 | { |
1806 | ht = _w; | 1805 | ht = _w; |
1807 | } | 1806 | } |
1808 | else | 1807 | else |
1809 | { | 1808 | { |
1810 | ht = _h; | 1809 | ht = _h; |
1811 | } | 1810 | } |
1812 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); | 1811 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); |
1813 | int mid = (ht*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); | 1812 | int mid = (ht*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); |
1814 | int sliderheight = ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize; | 1813 | int sliderheight = ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize; |
1815 | int sliderpos; | 1814 | int sliderpos; |
1816 | if (sliderheight < 10) | 1815 | if (sliderheight < 10) |
1817 | { | 1816 | { |
1818 | sliderheight = 10; | 1817 | sliderheight = 10; |
1819 | sliderpos = mid-5; | 1818 | sliderpos = mid-5; |
1820 | } | 1819 | } |
1821 | else | 1820 | else |
1822 | { | 1821 | { |
1823 | sliderpos = (ht*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize; | 1822 | sliderpos = (ht*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize; |
1824 | } | 1823 | } |
1825 | if (m_rotated) | 1824 | if (m_rotated) |
1826 | { | 1825 | { |
1827 | int hoff; | 1826 | int hoff; |
1828 | if (m_scrollpos == 2) //right | 1827 | if (m_scrollpos == 2) //right |
1829 | { | 1828 | { |
1830 | hoff = _h-3; | 1829 | hoff = _h-3; |
1831 | } | 1830 | } |
1832 | else | 1831 | else |
1833 | { | 1832 | { |
1834 | hoff = 0; | 1833 | hoff = 0; |
1835 | } | 1834 | } |
1836 | p->fillRect(ht-sliderpos-sliderheight, hoff, sliderheight, 3, m_scrollbarcolor); | 1835 | p->fillRect(ht-sliderpos-sliderheight, hoff, sliderheight, 3, m_scrollbarcolor); |
1837 | } | 1836 | } |
1838 | else | 1837 | else |
1839 | { | 1838 | { |
1840 | int hoff; | 1839 | int hoff; |
1841 | if (m_scrollpos == 2) //right | 1840 | if (m_scrollpos == 2) //right |
1842 | { | 1841 | { |
1843 | hoff = _w-3; | 1842 | hoff = _w-3; |
1844 | } | 1843 | } |
1845 | else | 1844 | else |
1846 | { | 1845 | { |
1847 | hoff = 0; | 1846 | hoff = 0; |
1848 | } | 1847 | } |
1849 | p->fillRect(hoff, sliderpos, 3, sliderheight, m_scrollbarcolor); | 1848 | p->fillRect(hoff, sliderpos, 3, sliderheight, m_scrollbarcolor); |
1850 | } | 1849 | } |
1851 | } | 1850 | } |
1852 | break; | 1851 | break; |
1853 | case 0: | 1852 | case 0: |
1854 | default: | 1853 | default: |
1855 | break; | 1854 | break; |
1856 | } | 1855 | } |
1857 | } | 1856 | } |
1858 | } | 1857 | } |
1859 | 1858 | ||
1860 | /* | 1859 | /* |
1861 | void QTReader::DrawScroll( QPainter *p ) | 1860 | void QTReader::DrawScroll( QPainter *p ) |
1862 | { | 1861 | { |
1863 | if (m_border > 5 && !buffdoc.empty()) | 1862 | if (m_border > 5 && !buffdoc.empty()) |
1864 | { | 1863 | { |
1865 | int ht, wh; | 1864 | int ht, wh; |
1866 | if (m_rotated) | 1865 | if (m_rotated) |
1867 | { | 1866 | { |
1868 | ht = width(); | 1867 | ht = width(); |
1869 | wh = height()g; | 1868 | wh = height()g; |
1870 | p->fillRect(0, wh-2, ht, 2, cyan); | 1869 | p->fillRect(0, wh-2, ht, 2, cyan); |
1871 | } | 1870 | } |
1872 | else | 1871 | else |
1873 | { | 1872 | { |
1874 | ht = height(); | 1873 | ht = height(); |
1875 | wh = width(); | 1874 | wh = width(); |
1876 | p->fillRect(wh-2, 0, 2, ht, cyan); | 1875 | p->fillRect(wh-2, 0, 2, ht, cyan); |
1877 | } | 1876 | } |
1878 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); | 1877 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); |
1879 | int mid = (ht*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); | 1878 | int mid = (ht*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); |
1880 | if (m_rotated) | 1879 | if (m_rotated) |
1881 | { | 1880 | { |
1882 | p->fillRect(ht-mid-5, wh-2, 10, 2, yellow); | 1881 | p->fillRect(ht-mid-5, wh-2, 10, 2, yellow); |
1883 | p->fillRect(ht-(ht*(locnarray[numlines]-buffdoc.startSection())+sectionsize/2)/sectionsize, wh-2, ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize, 2, magenta); | 1882 | p->fillRect(ht-(ht*(locnarray[numlines]-buffdoc.startSection())+sectionsize/2)/sectionsize, wh-2, ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize, 2, magenta); |
1884 | } | 1883 | } |
1885 | else | 1884 | else |
1886 | { | 1885 | { |
1887 | p->fillRect(wh-2, mid-5, 2, 10, yellow); | 1886 | p->fillRect(wh-2, mid-5, 2, 10, yellow); |
1888 | p->fillRect(wh-2, (ht*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize, 2, ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize, magenta); | 1887 | p->fillRect(wh-2, (ht*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize, 2, ((locnarray[numlines]-locnarray[0])*ht+sectionsize/2)/sectionsize, magenta); |
1889 | } | 1888 | } |
1890 | } | 1889 | } |
1891 | } | 1890 | } |
1892 | */ | 1891 | */ |
1893 | QString QTReader::firstword() | 1892 | QString QTReader::firstword() |
1894 | { | 1893 | { |
1895 | if (m_bMonoSpaced) | 1894 | if (m_bMonoSpaced) |
1896 | { | 1895 | { |
1897 | return toQString(textarray[0]->data()); | 1896 | return toQString(textarray[0]->data()); |
1898 | } | 1897 | } |
1899 | else | 1898 | else |
1900 | { | 1899 | { |
1901 | int start, end, len, j; | 1900 | int start, end, len, j; |
1902 | for (j = 0; j < numlines; j++) | 1901 | for (j = 0; j < numlines; j++) |
1903 | { | 1902 | { |
1904 | len = textarray[j]->length(); | 1903 | len = textarray[j]->length(); |
1905 | for (start = 0; start < len && !isalpha((*textarray[j])[start]); start++); | 1904 | for (start = 0; start < len && !isalpha((*textarray[j])[start]); start++); |
1906 | if (start < len) break; | 1905 | if (start < len) break; |
1907 | } | 1906 | } |
1908 | if (j < numlines) | 1907 | if (j < numlines) |
1909 | { | 1908 | { |
1910 | QString ret = ""; | 1909 | QString ret = ""; |
1911 | for (end = start; end < len && isalpha((*textarray[j])[end]); end++) | 1910 | for (end = start; end < len && isalpha((*textarray[j])[end]); end++) |
1912 | ret += (*textarray[j])[end]; | 1911 | ret += (*textarray[j])[end]; |
1913 | if (ret.isEmpty()) ret = "Current position"; | 1912 | if (ret.isEmpty()) ret = "Current position"; |
1914 | return ret; | 1913 | return ret; |
1915 | } | 1914 | } |
1916 | else | 1915 | else |
1917 | return "Current position"; | 1916 | return "Current position"; |
1918 | } | 1917 | } |
1919 | } | 1918 | } |
1920 | 1919 | ||
1921 | // | 1920 | // |
1922 | // Construct the QTReader with buttons. | 1921 | // Construct the QTReader with buttons. |
1923 | // | 1922 | // |
1924 | 1923 | ||
1925 | bool QTReader::ChangeFont(int tgt) | 1924 | bool QTReader::ChangeFont(int tgt) |
1926 | { | 1925 | { |
1927 | return m_fontControl.ChangeFont(m_fontname, tgt); | 1926 | return m_fontControl.ChangeFont(m_fontname, tgt); |
1928 | } | 1927 | } |
1929 | 1928 | ||
1930 | void QTReader::init() | 1929 | void QTReader::init() |
1931 | { | 1930 | { |
1932 | buffdoc.unsuspend(); | 1931 | buffdoc.unsuspend(); |
1933 | setBackgroundColor( m_bg ); | 1932 | setBackgroundColor( m_bg ); |
1934 | buffdoc.setfilter(getfilter()); | 1933 | buffdoc.setfilter(getfilter()); |
1935 | ChangeFont(m_textsize); | 1934 | ChangeFont(m_textsize); |
1936 | setFocusPolicy(QWidget::StrongFocus); | 1935 | setFocusPolicy(QWidget::StrongFocus); |
1937 | timer = new QTimer(this); | 1936 | timer = new QTimer(this); |
1938 | connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); | 1937 | connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); |
1939 | // QMessageBox::information(this, "init", m_lastfile, 1); | 1938 | // QMessageBox::information(this, "init", m_lastfile, 1); |
1940 | setfont(); | 1939 | setfont(); |
1941 | } | 1940 | } |
1942 | 1941 | ||
1943 | // | 1942 | // |
1944 | // Clean up | 1943 | // Clean up |
1945 | // | 1944 | // |
1946 | QTReader::~QTReader() | 1945 | QTReader::~QTReader() |
1947 | { | 1946 | { |
1948 | #ifdef DOUBLEBUFFER | 1947 | #ifdef DOUBLEBUFFER |
1949 | delete dbuff; | 1948 | delete dbuff; |
1950 | delete dbp; | 1949 | delete dbp; |
1951 | #endif | 1950 | #endif |
1952 | #ifdef USEQPE | 1951 | #ifdef USEQPE |
1953 | if (m_autoScroll) | 1952 | if (m_autoScroll) |
1954 | { | 1953 | { |
1955 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 1954 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
1956 | } | 1955 | } |
1957 | #endif | 1956 | #endif |
1958 | #ifdef _SCROLLPIPE | 1957 | #ifdef _SCROLLPIPE |
1959 | if (m_pipeout != NULL) | 1958 | if (m_pipeout != NULL) |
1960 | { | 1959 | { |
1961 | fclose(m_pipeout); | 1960 | fclose(m_pipeout); |
1962 | } | 1961 | } |
1963 | #endif | 1962 | #endif |
1964 | } | 1963 | } |
1965 | 1964 | ||
1966 | // | 1965 | // |
1967 | // Called when the print button is clicked. | 1966 | // Called when the print button is clicked. |
1968 | // | 1967 | // |
1969 | /* | 1968 | /* |
1970 | void QTReader::printIt() | 1969 | void QTReader::printIt() |
1971 | { | 1970 | { |
1972 | #ifndef QT_NO_PRINTER | 1971 | #ifndef QT_NO_PRINTER |
1973 | if ( printer->setup( this ) ) { | 1972 | if ( printer->setup( this ) ) { |
1974 | QPainter paint; | 1973 | QPainter paint; |
1975 | if ( !paint.begin( printer ) ) | 1974 | if ( !paint.begin( printer ) ) |
1976 | return; | 1975 | return; |
1977 | drawIt( &paint ); | 1976 | drawIt( &paint ); |
1978 | } | 1977 | } |
1979 | #endif | 1978 | #endif |
1980 | } | 1979 | } |
1981 | */ | 1980 | */ |
1982 | // | 1981 | // |
1983 | // Called when the widget needs to be updated. | 1982 | // Called when the widget needs to be updated. |
1984 | // | 1983 | // |
1985 | 1984 | ||
1986 | void QTReader::paintEvent( QPaintEvent * ) | 1985 | void QTReader::paintEvent( QPaintEvent * ) |
1987 | { | 1986 | { |
1988 | drawFonts(); | 1987 | drawFonts(); |
1989 | } | 1988 | } |
1990 | 1989 | ||
1991 | // | 1990 | // |
1992 | // Called when the widget has been resized. | 1991 | // Called when the widget has been resized. |
1993 | // Moves the button group to the upper right corner | 1992 | // Moves the button group to the upper right corner |
1994 | // of the widget. | 1993 | // of the widget. |
1995 | 1994 | ||
1996 | /* | 1995 | /* |
1997 | void QTReader::resizeEvent( QResizeEvent * ) | 1996 | void QTReader::resizeEvent( QResizeEvent * ) |
1998 | { | 1997 | { |
1999 | // // qDebug("resize:(%u,%u)", width(), height()); | 1998 | // // qDebug("resize:(%u,%u)", width(), height()); |
2000 | // bgroup->move( width()-bgroup->width(), 0 ); | 1999 | // bgroup->move( width()-bgroup->width(), 0 ); |
2001 | } | 2000 | } |
2002 | */ | 2001 | */ |
2003 | 2002 | ||
2004 | // | 2003 | // |
2005 | // Create and display our widget. | 2004 | // Create and display our widget. |
2006 | // | 2005 | // |
2007 | /* | 2006 | /* |
2008 | int main( int argc, tchar **argv ) | 2007 | int main( int argc, tchar **argv ) |
2009 | { | 2008 | { |
2010 | QApplication app( argc, argv ); | 2009 | QApplication app( argc, argv ); |
2011 | QTReader draw; | 2010 | QTReader draw; |
2012 | app.setMainWidget( &draw ); | 2011 | app.setMainWidget( &draw ); |
2013 | draw.setCaption("Qt Example - Drawdemo"); | 2012 | draw.setCaption("Qt Example - Drawdemo"); |
2014 | draw.show(); | 2013 | draw.show(); |
2015 | return app.exec(); | 2014 | return app.exec(); |
2016 | } | 2015 | } |
2017 | */ | 2016 | */ |
2018 | 2017 | ||
2019 | 2018 | ||
2020 | bool QTReader::locate(unsigned long n) { | 2019 | bool QTReader::locate(unsigned long n) { |
2021 | //printf("Locate\n"); | 2020 | //printf("Locate\n"); |
2022 | buffdoc.unsuspend(); | 2021 | buffdoc.unsuspend(); |
2023 | buffdoc.locate(n); | 2022 | buffdoc.locate(n); |
2024 | // // qDebug("&buffdoc.located"); | 2023 | // // qDebug("&buffdoc.located"); |
2025 | ResetScroll(); | 2024 | ResetScroll(); |
2026 | fillbuffer(); | 2025 | fillbuffer(); |
2027 | // // qDebug("&Buffer filled"); | 2026 | // // qDebug("&Buffer filled"); |
2028 | update(); | 2027 | update(); |
2029 | // // qDebug("&Located"); | 2028 | // // qDebug("&Located"); |
2030 | emitRedraw(); | 2029 | emitRedraw(); |
2031 | return true; | 2030 | return true; |
2032 | } | 2031 | } |
2033 | 2032 | ||
2034 | unsigned int QTReader::screenlines() | 2033 | unsigned int QTReader::screenlines() |
2035 | { | 2034 | { |
2036 | // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; | 2035 | // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; |
2037 | // return (height()-m_descent)/(m_linespacing); | 2036 | // return (height()-m_descent)/(m_linespacing); |
2038 | return (height()-2)/(m_linespacing); | 2037 | return (height()-2)/(m_linespacing); |
2039 | }; | 2038 | }; |
2040 | 2039 | ||
2041 | bool QTReader::fillbuffer(int reuse, int ht, int newht) | 2040 | bool QTReader::fillbuffer(int reuse, int ht, int newht) |
2042 | { | 2041 | { |
2043 | buffdoc.unsuspend(); | 2042 | buffdoc.unsuspend(); |
2044 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 2043 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
2045 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; | 2044 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; |
2046 | if (ht < 0) ht = m_topmargin; | 2045 | if (ht < 0) ht = m_topmargin; |
2047 | if (buffdoc.empty()) return false; | 2046 | if (buffdoc.empty()) return false; |
2048 | if (newht < 0) | 2047 | if (newht < 0) |
2049 | m_lastheight = (m_rotated) ? width() : height(); | 2048 | m_lastheight = (m_rotated) ? width() : height(); |
2050 | else | 2049 | else |
2051 | m_lastheight = newht; | 2050 | m_lastheight = newht; |
2052 | int ch; | 2051 | int ch; |
2053 | bool ret = false; | 2052 | bool ret = false; |
2054 | unsigned int oldpagepos = locnarray[reuse]; | 2053 | unsigned int oldpagepos = locnarray[reuse]; |
2055 | int lastypos = ht, ypos = ht; | 2054 | int lastypos = ht, ypos = ht; |
2056 | numlines = reuse; | 2055 | numlines = reuse; |
2057 | while (ypos < m_lastheight - hmargin || numlines < 2) | 2056 | while (ypos < m_lastheight - hmargin || numlines < 2) |
2058 | { | 2057 | { |
2059 | lastypos = ypos; | 2058 | lastypos = ypos; |
2060 | if (textarray[numlines] == NULL) | 2059 | if (textarray[numlines] == NULL) |
2061 | { | 2060 | { |
2062 | textarray[numlines] = new CDrawBuffer(&m_fontControl); | 2061 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
2063 | } | 2062 | } |
2064 | locnarray[numlines] = locate(); | 2063 | locnarray[numlines] = locate(); |
2065 | int ch = getline(textarray[numlines]); | 2064 | int ch = getline(textarray[numlines]); |
2066 | ypos += textarray[numlines]->lineSpacing(); | 2065 | ypos += textarray[numlines]->lineSpacing(); |
2067 | numlines++; | 2066 | numlines++; |
2068 | if (!ch) | 2067 | if (!ch) |
2069 | { | 2068 | { |
2070 | if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/) | 2069 | if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/) |
2071 | { | 2070 | { |
2072 | qDebug("FALSE"); | 2071 | qDebug("FALSE"); |
2073 | locate(oldpagepos); | 2072 | locate(oldpagepos); |
2074 | return false; | 2073 | return false; |
2075 | } | 2074 | } |
2076 | else | 2075 | else |
2077 | { | 2076 | { |
2078 | qDebug("TRUE"); | 2077 | qDebug("TRUE"); |
2079 | --numlines; | 2078 | --numlines; |
2080 | mylastpos = locate(); | 2079 | mylastpos = locate(); |
2081 | return true; | 2080 | return true; |
2082 | } | 2081 | } |
2083 | } | 2082 | } |
2084 | if (numlines > 1 && textarray[numlines-2]->isBop()) | 2083 | if (numlines > 1 && textarray[numlines-2]->isBop()) |
2085 | { | 2084 | { |
2086 | --numlines; | 2085 | --numlines; |
2087 | mylastpos = locate(); | 2086 | mylastpos = locate(); |
2088 | return true; | 2087 | return true; |
2089 | } | 2088 | } |
2090 | } | 2089 | } |
2091 | 2090 | ||
2092 | --numlines; | 2091 | --numlines; |
2093 | mylastpos = locate(); | 2092 | mylastpos = locate(); |
2094 | m_scrollpart = m_lastheight - lastypos - hmargin; | 2093 | m_scrollpart = m_lastheight - lastypos - hmargin; |
2095 | if (m_autoScroll) | 2094 | if (m_autoScroll) |
2096 | { | 2095 | { |
2097 | CalculateScrollParameters(); | 2096 | CalculateScrollParameters(); |
2098 | } | 2097 | } |
2099 | return true; | 2098 | return true; |
2100 | } | 2099 | } |
2101 | 2100 | ||
2102 | void QTReader::dopagedn() | 2101 | void QTReader::dopagedn() |
2103 | { | 2102 | { |
2104 | // qDebug("HEIGHT(2):%d", m_lastheight); | 2103 | // qDebug("HEIGHT(2):%d", m_lastheight); |
2105 | buffdoc.unsuspend(); | 2104 | buffdoc.unsuspend(); |
2106 | ResetScroll(); | 2105 | ResetScroll(); |
2107 | int skip = 0, ypos = m_topmargin; | 2106 | int skip = 0, ypos = m_topmargin; |
2108 | if (locate() != mylastpos) | 2107 | if (locate() != mylastpos) |
2109 | { | 2108 | { |
2110 | jumpto(mylastpos); | 2109 | jumpto(mylastpos); |
2111 | } | 2110 | } |
2112 | CDrawBuffer* reusebuffer = textarray[numlines]; | 2111 | CDrawBuffer* reusebuffer = textarray[numlines]; |
2113 | if (reusebuffer != NULL) | 2112 | if (reusebuffer != NULL) |
2114 | { | 2113 | { |
2115 | if (reusebuffer->eof()) return; | 2114 | if (reusebuffer->eof()) return; |
2116 | for (int i = 0; i <= m_overlap; i++) | 2115 | for (int i = 0; i <= m_overlap; i++) |
2117 | { | 2116 | { |
2118 | int offset = numlines - m_overlap + i; | 2117 | int offset = numlines - m_overlap + i; |
2119 | reusebuffer = textarray[offset]; | 2118 | reusebuffer = textarray[offset]; |
2120 | size_t reuselocn = locnarray[offset]; | 2119 | size_t reuselocn = locnarray[offset]; |
2121 | textarray[offset] = textarray[i]; | 2120 | textarray[offset] = textarray[i]; |
2122 | textarray[i] = reusebuffer; | 2121 | textarray[i] = reusebuffer; |
2123 | // reusebuffer->empty(); | 2122 | // reusebuffer->empty(); |
2124 | locnarray[offset] = locnarray[i]; | 2123 | locnarray[offset] = locnarray[i]; |
2125 | locnarray[i] = reuselocn; | 2124 | locnarray[i] = reuselocn; |
2126 | ypos += textarray[i]->lineSpacing(); | 2125 | ypos += textarray[i]->lineSpacing(); |
2127 | skip++; | 2126 | skip++; |
2128 | } | 2127 | } |
2129 | } | 2128 | } |
2130 | if (numlines <= 1) | 2129 | if (numlines <= 1) |
2131 | { | 2130 | { |
2132 | skip = 0; | 2131 | skip = 0; |
2133 | ypos = 0; | 2132 | ypos = 0; |
2134 | qDebug("Doing extra skip"); | 2133 | qDebug("Doing extra skip"); |
2135 | } | 2134 | } |
2136 | if (fillbuffer(skip, ypos)) | 2135 | if (fillbuffer(skip, ypos)) |
2137 | { | 2136 | { |
2138 | drawFonts(); | 2137 | drawFonts(); |
2139 | } | 2138 | } |
2140 | } | 2139 | } |
2141 | 2140 | ||
2142 | void QTReader::dopageup() | 2141 | void QTReader::dopageup() |
2143 | { | 2142 | { |
2144 | dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]); | 2143 | dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]); |
2145 | } | 2144 | } |
2146 | 2145 | ||
2147 | bool QTReader::synch(size_t start, size_t end) | 2146 | bool QTReader::synch(size_t start, size_t end) |
2148 | { | 2147 | { |
2149 | jumpto(start); | 2148 | jumpto(start); |
2150 | while (start++ < end) | 2149 | while (start++ < end) |
2151 | { | 2150 | { |
2152 | tchar ch = getch(); | 2151 | tchar ch = getch(); |
2153 | if (ch == 10) return true; | 2152 | if (ch == 10) return true; |
2154 | if (ch == UEOF) return false; | 2153 | if (ch == UEOF) return false; |
2155 | if (ch == 6) return false; | 2154 | if (ch == 6) return false; |
2156 | } | 2155 | } |
2157 | return false; | 2156 | return false; |
2158 | } | 2157 | } |
2159 | 2158 | ||
2160 | void QTReader::dopageup(unsigned int target) | 2159 | void QTReader::dopageup(unsigned int target) |
2161 | { | 2160 | { |
2162 | buffdoc.unsuspend(); | 2161 | buffdoc.unsuspend(); |
2163 | ResetScroll(); | 2162 | ResetScroll(); |
2164 | CBufferFace<CDrawBuffer*> buff; | 2163 | CBufferFace<CDrawBuffer*> buff; |
2165 | CBufferFace<size_t> loc; | 2164 | CBufferFace<size_t> loc; |
2166 | 2165 | ||
2167 | size_t delta, guess = 2*(locate()-pagelocate()), lastdelta = 0; | 2166 | size_t delta, guess = 2*(locate()-pagelocate()), lastdelta = 0; |
2168 | bool ch = true; | 2167 | bool ch = true; |
2169 | int nbfl, ypos = m_topmargin; | 2168 | int nbfl, ypos = m_topmargin; |
2170 | if (guess < 128) guess = 128; | 2169 | if (guess < 128) guess = 128; |
2171 | while (1) | 2170 | while (1) |
2172 | { | 2171 | { |
2173 | // qDebug("Guess:%u", guess); | 2172 | // qDebug("Guess:%u", guess); |
2174 | 2173 | ||
2175 | ch = true; | 2174 | ch = true; |
2176 | if (target < guess) | 2175 | if (target < guess) |
2177 | { | 2176 | { |
2178 | delta = 0; // 0 is a flag to say don't guess any more | 2177 | delta = 0; // 0 is a flag to say don't guess any more |
2179 | jumpto( (m_continuousDocument) ? 0 : buffdoc.startSection() ); | 2178 | jumpto( (m_continuousDocument) ? 0 : buffdoc.startSection() ); |
2180 | } | 2179 | } |
2181 | else if (!m_continuousDocument && (target - guess < buffdoc.startSection())) | 2180 | else if (!m_continuousDocument && (target - guess < buffdoc.startSection())) |
2182 | { | 2181 | { |
2183 | delta = 0; // 0 is a flag to say don't guess any more | 2182 | delta = 0; // 0 is a flag to say don't guess any more |
2184 | jumpto(buffdoc.startSection()); | 2183 | jumpto(buffdoc.startSection()); |
2185 | } | 2184 | } |
2186 | else | 2185 | else |
2187 | { | 2186 | { |
2188 | delta = guess; | 2187 | delta = guess; |
2189 | if (!synch(target-delta, target-lastdelta)) | 2188 | if (!synch(target-delta, target-lastdelta)) |
2190 | { | 2189 | { |
2191 | lastdelta = delta; | 2190 | lastdelta = delta; |
2192 | if (guess < 4000) | 2191 | if (guess < 4000) |
2193 | { | 2192 | { |
2194 | guess <<= 1; | 2193 | guess <<= 1; |
2195 | continue; | 2194 | continue; |
2196 | } | 2195 | } |
2197 | else | 2196 | else |
2198 | { | 2197 | { |
2199 | jumpto(target-delta); | 2198 | jumpto(target-delta); |
2200 | } | 2199 | } |
2201 | } | 2200 | } |
2202 | } | 2201 | } |
2203 | 2202 | ||
2204 | nbfl = 0; | 2203 | nbfl = 0; |
2205 | ypos = m_topmargin; | 2204 | ypos = m_topmargin; |
2206 | 2205 | ||
2207 | while (locate() < target) | 2206 | while (locate() < target) |
2208 | { | 2207 | { |
2209 | if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); | 2208 | if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); |
2210 | loc[nbfl] = locate(); | 2209 | loc[nbfl] = locate(); |
2211 | ch = getline(buff[nbfl]); | 2210 | ch = getline(buff[nbfl]); |
2212 | ypos += buff[nbfl]->lineSpacing(); | 2211 | ypos += buff[nbfl]->lineSpacing(); |
2213 | nbfl++; | 2212 | nbfl++; |
2214 | if (!ch) break; | 2213 | if (!ch) break; |
2215 | } | 2214 | } |
2216 | if (guess < 4000 && ypos < ((m_rotated) ? width() : height())-(m_bottommargin) && (delta != 0)) | 2215 | if (guess < 4000 && ypos < ((m_rotated) ? width() : height())-(m_bottommargin) && (delta != 0)) |
2217 | { | 2216 | { |
2218 | for (int i = 0; i < nbfl; i++) | 2217 | for (int i = 0; i < nbfl; i++) |
2219 | { | 2218 | { |
2220 | delete buff[i]; | 2219 | delete buff[i]; |
2221 | buff[i] = NULL; | 2220 | buff[i] = NULL; |
2222 | } | 2221 | } |
2223 | guess <<= 1; | 2222 | guess <<= 1; |
2224 | continue; | 2223 | continue; |
2225 | } | 2224 | } |
2226 | break; | 2225 | break; |
2227 | } | 2226 | } |
2228 | if (ch) | 2227 | if (ch) |
2229 | { | 2228 | { |
2230 | if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); | 2229 | if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); |
2231 | loc[nbfl] = locate(); | 2230 | loc[nbfl] = locate(); |
2232 | int ch = getline(buff[nbfl]); | 2231 | int ch = getline(buff[nbfl]); |
2233 | nbfl++; | 2232 | nbfl++; |
2234 | } | 2233 | } |
2235 | /* | 2234 | /* |
2236 | ypos = 0; | 2235 | ypos = 0; |
2237 | numlines = 0; | 2236 | numlines = 0; |
2238 | while (ypos < height() && numlines <= nbfl-1) | 2237 | while (ypos < height() && numlines <= nbfl-1) |
2239 | { | 2238 | { |
2240 | ypos += buff[nbfl - numlines - 1]->lineSpacing(); | 2239 | ypos += buff[nbfl - numlines - 1]->lineSpacing(); |
2241 | numlines++; | 2240 | numlines++; |
2242 | } | 2241 | } |
2243 | --numlines; | 2242 | --numlines; |
2244 | */ | 2243 | */ |
2245 | 2244 | ||
2246 | ypos = m_topmargin; | 2245 | ypos = m_topmargin; |
2247 | numlines = 0; | 2246 | numlines = 0; |
2248 | while (ypos < ((m_rotated) ? width() : height())-m_bottommargin && numlines+2 <= nbfl) | 2247 | while (ypos < ((m_rotated) ? width() : height())-m_bottommargin && numlines+2 <= nbfl) |
2249 | { | 2248 | { |
2250 | ypos += buff[nbfl - numlines - 2]->lineSpacing(); | 2249 | ypos += buff[nbfl - numlines - 2]->lineSpacing(); |
2251 | numlines++; | 2250 | numlines++; |
2252 | } | 2251 | } |
2253 | if (numlines > 0) --numlines; | 2252 | if (numlines > 0) --numlines; |
2254 | if (numlines == 0 && nbfl > 1) numlines = 1; | 2253 | if (numlines == 0 && nbfl > 1) numlines = 1; |
2255 | 2254 | ||
2256 | int offset = nbfl-1; | 2255 | int offset = nbfl-1; |
2257 | offset -= numlines; | 2256 | offset -= numlines; |
2258 | ypos = m_topmargin; | 2257 | ypos = m_topmargin; |
2259 | for (int i = 0; i <= numlines; i++) | 2258 | for (int i = 0; i <= numlines; i++) |
2260 | { | 2259 | { |
2261 | delete textarray[i]; | 2260 | delete textarray[i]; |
2262 | textarray[i] = buff[offset+i]; | 2261 | textarray[i] = buff[offset+i]; |
2263 | locnarray[i] = loc[offset + i]; | 2262 | locnarray[i] = loc[offset + i]; |
2264 | ypos += textarray[i]->lineSpacing(); | 2263 | ypos += textarray[i]->lineSpacing(); |
2265 | } | 2264 | } |
2266 | #ifdef _WINDOWS | 2265 | #ifdef _WINDOWS |
2267 | for (i = 0; i < nbfl - numlines - 1; i++) | 2266 | for (i = 0; i < nbfl - numlines - 1; i++) |
2268 | #else | 2267 | #else |
2269 | for (int i = 0; i < nbfl - numlines - 1; i++) | 2268 | for (int i = 0; i < nbfl - numlines - 1; i++) |
2270 | #endif | 2269 | #endif |
2271 | { | 2270 | { |
2272 | delete buff[i]; | 2271 | delete buff[i]; |
2273 | } | 2272 | } |
2274 | 2273 | ||
2275 | while (ypos < ((m_rotated) ? width() : height())-m_bottommargin) | 2274 | while (ypos < ((m_rotated) ? width() : height())-m_bottommargin) |
2276 | { | 2275 | { |
2277 | numlines++; | 2276 | numlines++; |
2278 | locnarray[numlines] = locate(); | 2277 | locnarray[numlines] = locate(); |
2279 | if (textarray[numlines] == NULL) textarray[numlines] = new CDrawBuffer(&m_fontControl); | 2278 | if (textarray[numlines] == NULL) textarray[numlines] = new CDrawBuffer(&m_fontControl); |
2280 | if (!getline(textarray[numlines])) break; | 2279 | if (!getline(textarray[numlines])) break; |
2281 | ypos += textarray[numlines]->lineSpacing(); | 2280 | ypos += textarray[numlines]->lineSpacing(); |
2282 | } | 2281 | } |
2283 | 2282 | ||
2284 | mylastpos = locate(); | 2283 | mylastpos = locate(); |
2285 | CalculateScrollParameters(); | 2284 | CalculateScrollParameters(); |
2286 | drawFonts(); | 2285 | drawFonts(); |
2287 | // repaint(); | 2286 | // repaint(); |
2288 | } | 2287 | } |
2289 | 2288 | ||
2290 | bool QTReader::load_file(const char *newfile, unsigned int _lcn) | 2289 | bool QTReader::load_file(const char *newfile, unsigned int _lcn) |
2291 | { | 2290 | { |
2292 | // QMessageBox::information(this, "Name", name, 1); | 2291 | // QMessageBox::information(this, "Name", name, 1); |
2293 | // QMessageBox::information(this, "load_file", newfile, 1); | 2292 | // QMessageBox::information(this, "load_file", newfile, 1); |
2294 | int prog = 0; | 2293 | int prog = 0; |
2295 | bool bRC = false; | 2294 | bool bRC = false; |
2296 | unsigned int lcn = _lcn; | 2295 | unsigned int lcn = _lcn; |
2297 | ResetScroll(); | 2296 | ResetScroll(); |
2298 | if (m_lastfile == newfile) | 2297 | if (m_lastfile == newfile) |
2299 | { | 2298 | { |
2300 | lcn = m_lastposn; | 2299 | lcn = m_lastposn; |
2301 | } | 2300 | } |
2302 | // QMessageBox::information(0, "Opening...", newfile); | 2301 | // QMessageBox::information(0, "Opening...", newfile); |
2303 | if (m_rotated) | 2302 | if (m_rotated) |
2304 | { | 2303 | { |
2305 | m_lastwidth = height(); | 2304 | m_lastwidth = height(); |
2306 | m_lastheight = width(); | 2305 | m_lastheight = width(); |
2307 | } | 2306 | } |
2308 | else | 2307 | else |
2309 | { | 2308 | { |
2310 | m_lastwidth = width(); | 2309 | m_lastwidth = width(); |
2311 | m_lastheight = height(); | 2310 | m_lastheight = height(); |
2312 | } | 2311 | } |
2313 | if (buffdoc.openfile(this,newfile) == 0) | 2312 | if (buffdoc.openfile(this,newfile) == 0) |
2314 | { | 2313 | { |
2315 | m_lastfile = newfile; | 2314 | m_lastfile = newfile; |
2316 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); | 2315 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); |
2317 | bRC = true; | 2316 | bRC = true; |
2318 | buffdoc.setContinuous(m_continuousDocument); | 2317 | buffdoc.setContinuous(m_continuousDocument); |
2319 | qDebug("buffdoc.openfile done"); | 2318 | qDebug("buffdoc.openfile done"); |
2320 | locate(lcn); | 2319 | locate(lcn); |
2321 | qDebug("buffdoc.locate done"); | 2320 | qDebug("buffdoc.locate done"); |
2322 | } | 2321 | } |
2323 | setfilter(getfilter()); | 2322 | setfilter(getfilter()); |
2324 | qDebug("Updated"); | 2323 | qDebug("Updated"); |
2325 | return bRC; | 2324 | return bRC; |
2326 | } | 2325 | } |
2327 | 2326 | ||
2328 | void QTReader::lineDown() | 2327 | void QTReader::lineDown() |
2329 | { | 2328 | { |
2330 | int ypos = m_topmargin; | 2329 | int ypos = m_topmargin; |
2331 | ResetScroll(); | 2330 | ResetScroll(); |
2332 | int offset = numlines; | 2331 | int offset = numlines; |
2333 | 2332 | ||
2334 | for (int i = 0; i <= numlines; i++) | 2333 | for (int i = 0; i <= numlines; i++) |
2335 | { | 2334 | { |
2336 | if ((ypos += textarray[numlines-i]->lineSpacing()) > ((m_rotated) ? width() : height())) | 2335 | if ((ypos += textarray[numlines-i]->lineSpacing()) > ((m_rotated) ? width() : height())) |
2337 | { | 2336 | { |
2338 | offset = i-1; | 2337 | offset = i-1; |
2339 | break; | 2338 | break; |
2340 | } | 2339 | } |
2341 | } | 2340 | } |
2342 | offset = numlines - offset; | 2341 | offset = numlines - offset; |
2343 | #ifdef _WINDOWS | 2342 | #ifdef _WINDOWS |
2344 | for (i = offset; i <= numlines; i++) | 2343 | for (i = offset; i <= numlines; i++) |
2345 | #else | 2344 | #else |
2346 | for (int i = offset; i <= numlines; i++) | 2345 | for (int i = offset; i <= numlines; i++) |
2347 | #endif | 2346 | #endif |
2348 | { | 2347 | { |
2349 | CDrawBuffer* buff = textarray[i-offset]; | 2348 | CDrawBuffer* buff = textarray[i-offset]; |
2350 | textarray[i-offset] = textarray[i]; | 2349 | textarray[i-offset] = textarray[i]; |
2351 | locnarray[i-offset] = locnarray[i]; | 2350 | locnarray[i-offset] = locnarray[i]; |
2352 | textarray[i] = buff; | 2351 | textarray[i] = buff; |
2353 | } | 2352 | } |
2354 | numlines = numlines - offset + 1; | 2353 | numlines = numlines - offset + 1; |
2355 | locnarray[numlines] = locate(); | 2354 | locnarray[numlines] = locate(); |
2356 | if (textarray[numlines] == NULL) | 2355 | if (textarray[numlines] == NULL) |
2357 | { | 2356 | { |
2358 | textarray[numlines] = new CDrawBuffer(&m_fontControl); | 2357 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
2359 | } | 2358 | } |
2360 | getline(textarray[numlines]); | 2359 | getline(textarray[numlines]); |
2361 | mylastpos = locate(); | 2360 | mylastpos = locate(); |
2362 | update(); | 2361 | update(); |
2363 | } | 2362 | } |
2364 | /* | 2363 | /* |
2365 | void QTReader::lineUp() | 2364 | void QTReader::lineUp() |
2366 | { | 2365 | { |
2367 | CBuffer** buff = textarray; | 2366 | CBuffer** buff = textarray; |
2368 | unsigned int *loc = new unsigned int[numlines]; | 2367 | unsigned int *loc = new unsigned int[numlines]; |
2369 | int cbptr = 0; | 2368 | int cbptr = 0; |
2370 | if (locate() != mylastpos) jumpto(mylastpos); | 2369 | if (locate() != mylastpos) jumpto(mylastpos); |
2371 | unsigned int target = locnarray[numlines-1]; | 2370 | unsigned int target = locnarray[numlines-1]; |
2372 | if (buffdoc.hasrandomaccess()) | 2371 | if (buffdoc.hasrandomaccess()) |
2373 | { | 2372 | { |
2374 | unsigned int delta = locate()-pagelocate(); | 2373 | unsigned int delta = locate()-pagelocate(); |
2375 | if (delta < 64) delta = 64; | 2374 | if (delta < 64) delta = 64; |
2376 | do | 2375 | do |
2377 | { | 2376 | { |
2378 | delta <<= 1; | 2377 | delta <<= 1; |
2379 | if (delta >= target) | 2378 | if (delta >= target) |
2380 | { | 2379 | { |
2381 | delta = target; | 2380 | delta = target; |
2382 | jumpto(0); | 2381 | jumpto(0); |
2383 | for (int i = 0; i < numlines; i++) | 2382 | for (int i = 0; i < numlines; i++) |
2384 | { | 2383 | { |
2385 | loc[i] = locate(); | 2384 | loc[i] = locate(); |
2386 | getline(buff[i]); | 2385 | getline(buff[i]); |
2387 | } | 2386 | } |
2388 | break; | 2387 | break; |
2389 | } | 2388 | } |
2390 | jumpto(target-delta); | 2389 | jumpto(target-delta); |
2391 | do | 2390 | do |
2392 | { | 2391 | { |
2393 | buffdoc.getline(buff[0],width()); | 2392 | buffdoc.getline(buff[0],width()); |
2394 | #ifdef WS | 2393 | #ifdef WS |
2395 | //printf("Trying:%s\n",buff[0]); | 2394 | //printf("Trying:%s\n",buff[0]); |
2396 | #endif | 2395 | #endif |
2397 | if (locate() > target) continue; | 2396 | if (locate() > target) continue; |
2398 | } | 2397 | } |
2399 | while (!buffdoc.iseol()); | 2398 | while (!buffdoc.iseol()); |
2400 | for (int i = 0; i < numlines; i++) | 2399 | for (int i = 0; i < numlines; i++) |
2401 | { | 2400 | { |
2402 | loc[i] = locate(); | 2401 | loc[i] = locate(); |
2403 | buffdoc.getline(buff[i],width()); | 2402 | buffdoc.getline(buff[i],width()); |
2404 | #ifdef WS | 2403 | #ifdef WS |
2405 | //printf("Filling:%s\n",buff[i]); | 2404 | //printf("Filling:%s\n",buff[i]); |
2406 | #endif | 2405 | #endif |
2407 | } | 2406 | } |
2408 | } | 2407 | } |
2409 | while (locate() >= target && delta < 4096); | 2408 | while (locate() >= target && delta < 4096); |
2410 | #ifdef WS | 2409 | #ifdef WS |
2411 | //printf("Delta:%u\n",delta); | 2410 | //printf("Delta:%u\n",delta); |
2412 | #endif | 2411 | #endif |
2413 | } | 2412 | } |
2414 | else | 2413 | else |
2415 | { | 2414 | { |
2416 | jumpto(0); | 2415 | jumpto(0); |
2417 | for (int i = 0; i < numlines; i++) | 2416 | for (int i = 0; i < numlines; i++) |
2418 | { | 2417 | { |
2419 | loc[i] = locate(); | 2418 | loc[i] = locate(); |
2420 | buffdoc.getline(buff[i],width()); | 2419 | buffdoc.getline(buff[i],width()); |
2421 | } | 2420 | } |
2422 | } | 2421 | } |
2423 | cbptr = 0; | 2422 | cbptr = 0; |
2424 | while (locate() < target) | 2423 | while (locate() < target) |
2425 | { | 2424 | { |
2426 | loc[cbptr] = locate(); | 2425 | loc[cbptr] = locate(); |
2427 | buffdoc.getline(buff[cbptr], width()); | 2426 | buffdoc.getline(buff[cbptr], width()); |
2428 | #ifdef WS | 2427 | #ifdef WS |
2429 | //printf("Adding:%s\n",buff[cbptr]->data()); | 2428 | //printf("Adding:%s\n",buff[cbptr]->data()); |
2430 | #endif | 2429 | #endif |
2431 | cbptr = (cbptr+1) % numlines; | 2430 | cbptr = (cbptr+1) % numlines; |
2432 | } | 2431 | } |
2433 | pagepos = loc[cbptr]; | 2432 | pagepos = loc[cbptr]; |
2434 | textarray = new CBuffer*[numlines]; | 2433 | textarray = new CBuffer*[numlines]; |
2435 | for (int i = 0; i < numlines; i++) | 2434 | for (int i = 0; i < numlines; i++) |
2436 | { | 2435 | { |
2437 | int j = (cbptr+i)%numlines; | 2436 | int j = (cbptr+i)%numlines; |
2438 | textarray[i] = buff[j]; | 2437 | textarray[i] = buff[j]; |
2439 | locnarray[i] = loc[j]; | 2438 | locnarray[i] = loc[j]; |
2440 | } | 2439 | } |
2441 | delete [] buff; | 2440 | delete [] buff; |
2442 | delete [] loc; | 2441 | delete [] loc; |
2443 | mylastpos = locate(); | 2442 | mylastpos = locate(); |
2444 | update(); | 2443 | update(); |
2445 | } | 2444 | } |
2446 | */ | 2445 | */ |
2447 | 2446 | ||
2448 | void QTReader::ResetScroll() | 2447 | void QTReader::ResetScroll() |
2449 | { | 2448 | { |
2450 | m_totalscroll = 0; | 2449 | m_totalscroll = 0; |
2451 | m_scrolldy1 = 0; | 2450 | m_scrolldy1 = 0; |
2452 | m_scrolldy = m_topmargin; | 2451 | m_scrolldy = m_topmargin; |
2453 | if (m_autoScroll && ((m_scrolltype == 0) || !m_bgpm.isNull())) | 2452 | if (m_autoScroll && ((m_scrolltype == 0) || !m_bgpm.isNull())) |
2454 | { | 2453 | { |
2455 | setautoscroll(false); | 2454 | setautoscroll(false); |
2456 | } | 2455 | } |
2457 | } | 2456 | } |
2458 | 2457 | ||
2459 | void QTReader::lineUp() | 2458 | void QTReader::lineUp() |
2460 | { | 2459 | { |
2461 | dopageup(locnarray[numlines-1]); | 2460 | dopageup(locnarray[numlines-1]); |
2462 | 2461 | ||
2463 | /* | 2462 | /* |
2464 | buffdoc.unsuspend(); | 2463 | buffdoc.unsuspend(); |
2465 | ResetScroll(); | 2464 | ResetScroll(); |
2466 | 2465 | ||
2467 | CDrawBuffer* buff = textarray[numlines]; | 2466 | CDrawBuffer* buff = textarray[numlines]; |
2468 | unsigned int loc; | 2467 | unsigned int loc; |
2469 | unsigned int end = locnarray[numlines]; | 2468 | unsigned int end = locnarray[numlines]; |
2470 | int cbptr = 0; | 2469 | int cbptr = 0; |
2471 | if (locate() != mylastpos) jumpto(mylastpos); | 2470 | if (locate() != mylastpos) jumpto(mylastpos); |
2472 | unsigned int target = locnarray[0]; | 2471 | unsigned int target = locnarray[0]; |
2473 | if (target == 0) return; | 2472 | if (target == 0) return; |
2474 | if (!m_continuousDocument && (target == buffdoc.startSection())) return; | 2473 | if (!m_continuousDocument && (target == buffdoc.startSection())) return; |
2475 | if (buffdoc.hasrandomaccess()) | 2474 | if (buffdoc.hasrandomaccess()) |
2476 | { | 2475 | { |
2477 | unsigned int delta = locate()-pagelocate(); | 2476 | unsigned int delta = locate()-pagelocate(); |
2478 | if (delta < 64) delta = 64; | 2477 | if (delta < 64) delta = 64; |
2479 | do | 2478 | do |
2480 | { | 2479 | { |
2481 | delta <<= 1; | 2480 | delta <<= 1; |
2482 | if (delta >= target) | 2481 | if (delta >= target) |
2483 | { | 2482 | { |
2484 | delta = target; | 2483 | delta = target; |
2485 | jumpto(0); | 2484 | jumpto(0); |
2486 | loc = locate(); | 2485 | loc = locate(); |
2487 | getline(buff); | 2486 | getline(buff); |
2488 | break; | 2487 | break; |
2489 | } | 2488 | } |
2490 | else if (!m_continuousDocument && (target - delta < buffdoc.startSection())) | 2489 | else if (!m_continuousDocument && (target - delta < buffdoc.startSection())) |
2491 | { | 2490 | { |
2492 | delta = target-buffdoc.startSection(); | 2491 | delta = target-buffdoc.startSection(); |
2493 | jumpto(buffdoc.startSection()); | 2492 | jumpto(buffdoc.startSection()); |
2494 | loc = locate(); | 2493 | loc = locate(); |
2495 | getline(buff); | 2494 | getline(buff); |
2496 | break; | 2495 | break; |
2497 | } | 2496 | } |
2498 | jumpto(target-delta); | 2497 | jumpto(target-delta); |
2499 | do | 2498 | do |
2500 | { | 2499 | { |
2501 | getline(buff); | 2500 | getline(buff); |
2502 | #ifdef WS | 2501 | #ifdef WS |
2503 | //printf("Trying:%s\n",buff[0]); | 2502 | //printf("Trying:%s\n",buff[0]); |
2504 | #endif | 2503 | #endif |
2505 | if (locate() > target) continue; | 2504 | if (locate() > target) continue; |
2506 | } | 2505 | } |
2507 | while (!buffdoc.iseol()); | 2506 | while (!buffdoc.iseol()); |
2508 | loc = locate(); | 2507 | loc = locate(); |
2509 | getline(buff); | 2508 | getline(buff); |
2510 | } | 2509 | } |
2511 | while (locate() >= target && delta < 4096); | 2510 | while (locate() >= target && delta < 4096); |
2512 | } | 2511 | } |
2513 | else | 2512 | else |
2514 | { | 2513 | { |
2515 | jumpto(0); | 2514 | jumpto(0); |
2516 | loc = locate(); | 2515 | loc = locate(); |
2517 | getline(buff); | 2516 | getline(buff); |
2518 | } | 2517 | } |
2519 | cbptr = 0; | 2518 | cbptr = 0; |
2520 | while (locate() < target) | 2519 | while (locate() < target) |
2521 | { | 2520 | { |
2522 | loc = locate(); | 2521 | loc = locate(); |
2523 | getline(buff); | 2522 | getline(buff); |
2524 | } | 2523 | } |
2525 | for (int i = numlines; i > 0; i--) | 2524 | for (int i = numlines; i > 0; i--) |
2526 | { | 2525 | { |
2527 | textarray[i] = textarray[i-1]; | 2526 | textarray[i] = textarray[i-1]; |
2528 | locnarray[i] = locnarray[i-1]; | 2527 | locnarray[i] = locnarray[i-1]; |
2529 | } | 2528 | } |
2530 | textarray[0] = buff; | 2529 | textarray[0] = buff; |
2531 | locnarray[0] = loc; | 2530 | locnarray[0] = loc; |
2532 | int start = numlines; | 2531 | int start = numlines; |
2533 | int ypos = m_topmargin; | 2532 | int ypos = m_topmargin; |
2534 | #ifdef _WINDOWS | 2533 | #ifdef _WINDOWS |
2535 | for (i = 0; i <= numlines; i++) | 2534 | for (i = 0; i <= numlines; i++) |
2536 | #else | 2535 | #else |
2537 | for (int i = 0; i <= numlines; i++) | 2536 | for (int i = 0; i <= numlines; i++) |
2538 | #endif | 2537 | #endif |
2539 | { | 2538 | { |
2540 | ypos += textarray[i]->lineSpacing(); | 2539 | ypos += textarray[i]->lineSpacing(); |
2541 | if (ypos > ((m_rotated) ? width() : height())) | 2540 | if (ypos > ((m_rotated) ? width() : height())) |
2542 | { | 2541 | { |
2543 | start = i; | 2542 | start = i; |
2544 | ypos -= textarray[i]->lineSpacing(); | 2543 | ypos -= textarray[i]->lineSpacing(); |
2545 | break; | 2544 | break; |
2546 | } | 2545 | } |
2547 | } | 2546 | } |
2548 | jumpto(locnarray[start]); | 2547 | jumpto(locnarray[start]); |
2549 | fillbuffer(start, ypos); | 2548 | fillbuffer(start, ypos); |
2550 | repaint(); | 2549 | repaint(); |
2551 | */ | 2550 | */ |
2552 | } | 2551 | } |
2553 | 2552 | ||
2554 | bool QTReader::empty() | 2553 | bool QTReader::empty() |
2555 | { | 2554 | { |
2556 | return buffdoc.empty(); | 2555 | return buffdoc.empty(); |
2557 | } | 2556 | } |
2558 | 2557 | ||
2559 | MarkupType QTReader::PreferredMarkup() | 2558 | MarkupType QTReader::PreferredMarkup() |
2560 | { | 2559 | { |
2561 | MarkupType m = buffdoc.PreferredMarkup(); | 2560 | MarkupType m = buffdoc.PreferredMarkup(); |
2562 | if (m == cTEXT) | 2561 | if (m == cTEXT) |
2563 | { | 2562 | { |
2564 | int ext = m_lastfile.findRev('.'); | 2563 | int ext = m_lastfile.findRev('.'); |
2565 | if (ext >= 0) | 2564 | if (ext >= 0) |
2566 | { | 2565 | { |
2567 | QString ft = m_lastfile.right(m_lastfile.length()-ext-1).upper(); | 2566 | QString ft = m_lastfile.right(m_lastfile.length()-ext-1).upper(); |
2568 | if (ft.left(3) == "HTM") | 2567 | if (ft.left(3) == "HTM") |
2569 | { | 2568 | { |
2570 | m = cHTML; | 2569 | m = cHTML; |
2571 | } | 2570 | } |
2572 | } | 2571 | } |
2573 | } | 2572 | } |
2574 | return m; | 2573 | return m; |
2575 | } | 2574 | } |
2576 | #ifdef DOUBLEBUFFER | 2575 | #ifdef DOUBLEBUFFER |
2577 | void QTReader::resizeEvent( QResizeEvent * p ) | 2576 | void QTReader::resizeEvent( QResizeEvent * p ) |
2578 | { | 2577 | { |
2579 | if (m_rotated) | 2578 | if (m_rotated) |
2580 | { | 2579 | { |
2581 | dbuff->resize(p->size().height(),p->size().width()); | 2580 | dbuff->resize(p->size().height(),p->size().width()); |
2582 | } | 2581 | } |
2583 | else | 2582 | else |
2584 | { | 2583 | { |
2585 | dbuff->resize(p->size()); | 2584 | dbuff->resize(p->size()); |
2586 | } | 2585 | } |
2587 | m_bgIsScaled = false; | 2586 | m_bgIsScaled = false; |
2588 | if (m_bgtype == bgStretched) | 2587 | if (m_bgtype == bgStretched) |
2589 | { | 2588 | { |
2590 | emit RefreshBitmap(); | 2589 | emit RefreshBitmap(); |
2591 | } | 2590 | } |
2592 | 2591 | ||
2593 | { | 2592 | { |
2594 | int h, w; | 2593 | int h, w; |
2595 | if (m_rotated) | 2594 | if (m_rotated) |
2596 | { | 2595 | { |
2597 | h = p->size().width(); | 2596 | h = p->size().width(); |
2598 | w = p->size().height(); | 2597 | w = p->size().height(); |
2599 | } | 2598 | } |
2600 | else | 2599 | else |
2601 | { | 2600 | { |
2602 | w = p->size().width(); | 2601 | w = p->size().width(); |
2603 | h = p->size().height(); | 2602 | h = p->size().height(); |
2604 | } | 2603 | } |
2605 | m_topmargin = (h*m_abstopmargin+500)/1000; | 2604 | m_topmargin = (h*m_abstopmargin+500)/1000; |
2606 | m_bottommargin = (h*m_absbottommargin+500)/1000; | 2605 | m_bottommargin = (h*m_absbottommargin+500)/1000; |
2607 | m_left_border = (w*m_absleft_border+500)/1000; | 2606 | m_left_border = (w*m_absleft_border+500)/1000; |
2608 | m_right_border = (w*m_absright_border+500)/1000; | 2607 | m_right_border = (w*m_absright_border+500)/1000; |
2609 | 2608 | ||
2610 | qDebug("Top margin:%u", m_topmargin ); | 2609 | qDebug("Top margin:%u", m_topmargin ); |
2611 | qDebug("Bottom margin:%u", m_bottommargin ); | 2610 | qDebug("Bottom margin:%u", m_bottommargin ); |
2612 | qDebug("Left margin:%u", m_left_border ); | 2611 | qDebug("Left margin:%u", m_left_border ); |
2613 | qDebug("Right margin:%u", m_right_border ); | 2612 | qDebug("Right margin:%u", m_right_border ); |
2614 | } | 2613 | } |
2615 | } | 2614 | } |
2616 | #endif | 2615 | #endif |
2617 | 2616 | ||
2618 | void QTReader::setrotated(bool sfs) | 2617 | void QTReader::setrotated(bool sfs) |
2619 | { | 2618 | { |
2620 | m_rotated = sfs; | 2619 | m_rotated = sfs; |
2621 | #ifdef DOUBLEBUFFER | 2620 | #ifdef DOUBLEBUFFER |
2622 | if (m_rotated) | 2621 | if (m_rotated) |
2623 | { | 2622 | { |
2624 | dbuff->resize(height(), width()); | 2623 | dbuff->resize(height(), width()); |
2625 | } | 2624 | } |
2626 | else | 2625 | else |
2627 | { | 2626 | { |
2628 | dbuff->resize(width(), height()); | 2627 | dbuff->resize(width(), height()); |
2629 | } | 2628 | } |
2630 | m_bgIsScaled = false; | 2629 | m_bgIsScaled = false; |
2631 | #endif | 2630 | #endif |
2632 | int h, w; | 2631 | int h, w; |
2633 | if (m_rotated) | 2632 | if (m_rotated) |
2634 | { | 2633 | { |
2635 | h = width(); | 2634 | h = width(); |
2636 | w = height(); | 2635 | w = height(); |
2637 | } | 2636 | } |
2638 | else | 2637 | else |
2639 | { | 2638 | { |
2640 | w = width(); | 2639 | w = width(); |
2641 | h = height(); | 2640 | h = height(); |
2642 | } | 2641 | } |
2643 | m_topmargin = (h*m_abstopmargin+500)/1000; | 2642 | m_topmargin = (h*m_abstopmargin+500)/1000; |
2644 | m_bottommargin = (h*m_absbottommargin+500)/1000; | 2643 | m_bottommargin = (h*m_absbottommargin+500)/1000; |
2645 | m_left_border = (w*m_absleft_border+500)/1000; | 2644 | m_left_border = (w*m_absleft_border+500)/1000; |
2646 | m_right_border = (w*m_absright_border+500)/1000; | 2645 | m_right_border = (w*m_absright_border+500)/1000; |
2647 | 2646 | ||
2648 | qDebug("Top margin:%u", m_topmargin ); | 2647 | qDebug("Top margin:%u", m_topmargin ); |
2649 | qDebug("Bottom margin:%u", m_bottommargin ); | 2648 | qDebug("Bottom margin:%u", m_bottommargin ); |
2650 | qDebug("Left margin:%u", m_left_border ); | 2649 | qDebug("Left margin:%u", m_left_border ); |
2651 | qDebug("Right margin:%u", m_right_border ); | 2650 | qDebug("Right margin:%u", m_right_border ); |
2652 | } | 2651 | } |
2653 | 2652 | ||
2654 | void QTReader::drawBackground() | 2653 | void QTReader::drawBackground() |
2655 | { | 2654 | { |
2656 | dbp->begin(dbuff); | 2655 | dbp->begin(dbuff); |
2657 | // dbp->setBackgroundMode(OpaqueMode); | 2656 | // dbp->setBackgroundMode(OpaqueMode); |
2658 | dbp->setBackgroundColor(m_bg); | 2657 | dbp->setBackgroundColor(m_bg); |
2659 | dbp->eraseRect(dbuff->rect()); | 2658 | dbp->eraseRect(dbuff->rect()); |
2660 | if (!m_bgpm.isNull()) | 2659 | if (!m_bgpm.isNull()) |
2661 | { | 2660 | { |
2662 | // dbp->setBackgroundMode(TransparentMode); | 2661 | // dbp->setBackgroundMode(TransparentMode); |
2663 | switch (m_bgtype) | 2662 | switch (m_bgtype) |
2664 | { | 2663 | { |
2665 | case bgCentred: | 2664 | case bgCentred: |
2666 | { | 2665 | { |
2667 | int w = (dbuff->rect().width()-m_bgpm.width())/2; | 2666 | int w = (dbuff->rect().width()-m_bgpm.width())/2; |
2668 | int h = (dbuff->rect().height()-m_bgpm.height())/2; | 2667 | int h = (dbuff->rect().height()-m_bgpm.height())/2; |
2669 | dbp->drawPixmap(w,h,m_bgpm); | 2668 | dbp->drawPixmap(w,h,m_bgpm); |
2670 | } | 2669 | } |
2671 | break; | 2670 | break; |
2672 | case bgTiled: | 2671 | case bgTiled: |
2673 | { | 2672 | { |
2674 | dbp->drawTiledPixmap(0,0,dbuff->rect().width(),dbuff->rect().height(),m_bgpm); | 2673 | dbp->drawTiledPixmap(0,0,dbuff->rect().width(),dbuff->rect().height(),m_bgpm); |
2675 | /* | 2674 | /* |
2676 | for (int h = 0; h < dbuff->rect().height(); h += m_bgpm.height()) | 2675 | for (int h = 0; h < dbuff->rect().height(); h += m_bgpm.height()) |
2677 | { | 2676 | { |
2678 | for (int w = 0; w < dbuff->rect().width(); w += m_bgpm.width()) | 2677 | for (int w = 0; w < dbuff->rect().width(); w += m_bgpm.width()) |
2679 | { | 2678 | { |
2680 | dbp->drawPixmap(w,h,m_bgpm); | 2679 | dbp->drawPixmap(w,h,m_bgpm); |
2681 | } | 2680 | } |
2682 | } | 2681 | } |
2683 | */ | 2682 | */ |
2684 | } | 2683 | } |
2685 | break; | 2684 | break; |
2686 | case bgStretched: | 2685 | case bgStretched: |
2687 | { | 2686 | { |
2688 | if (!m_bgIsScaled) | 2687 | if (!m_bgIsScaled) |
2689 | { | 2688 | { |
2690 | m_bgIsScaled = true; | 2689 | m_bgIsScaled = true; |
2691 | QImage im = m_bgpm.convertToImage(); | 2690 | QImage im = m_bgpm.convertToImage(); |
2692 | m_bgpm.convertFromImage(im.smoothScale(dbuff->rect().width(), dbuff->rect().height())); | 2691 | m_bgpm.convertFromImage(im.smoothScale(dbuff->rect().width(), dbuff->rect().height())); |
2693 | } | 2692 | } |
2694 | dbp->drawPixmap(0,0,m_bgpm); | 2693 | dbp->drawPixmap(0,0,m_bgpm); |
2695 | } | 2694 | } |
2696 | break; | 2695 | break; |
2697 | default: | 2696 | default: |
2698 | qDebug("Unknown background type"); | 2697 | qDebug("Unknown background type"); |
2699 | } | 2698 | } |
2700 | // dbp->setBackgroundMode(OpaqueMode); | 2699 | // dbp->setBackgroundMode(OpaqueMode); |
2701 | } | 2700 | } |
2702 | } | 2701 | } |
2703 | 2702 | ||
2704 | void QTReader::blitRot(int dx, int dy, int sw, int sh, CDrawBuffer* txt) | 2703 | void QTReader::blitRot(int dx, int dy, int sw, int sh, CDrawBuffer* txt) |
2705 | { | 2704 | { |
2706 | if (txt != NULL) | 2705 | if (txt != NULL) |
2707 | { | 2706 | { |
2708 | sh = txt->lineSpacing(); | 2707 | sh = txt->lineSpacing(); |
2709 | } | 2708 | } |
2710 | int sy = width()-dx-sh; | 2709 | int sy = width()-dx-sh; |
2711 | if (m_autoScroll && !(m_scrolltype == 0)) | 2710 | if (m_autoScroll && !(m_scrolltype == 0)) |
2712 | { | 2711 | { |
2713 | sy = (sy+m_totalscroll+1)%width(); | 2712 | sy = (sy+m_totalscroll+1)%width(); |
2714 | } | 2713 | } |
2715 | 2714 | ||
2716 | QPixmap pm(sw, sh); | 2715 | QPixmap pm(sw, sh); |
2717 | 2716 | ||
2718 | QPainter pd(&pm, this); | 2717 | QPainter pd(&pm, this); |
2719 | if (m_bgpm.isNull()) | 2718 | if (m_bgpm.isNull()) |
2720 | { | 2719 | { |
2721 | pd.eraseRect(pm.rect()); | 2720 | pd.eraseRect(pm.rect()); |
2722 | } | 2721 | } |
2723 | else | 2722 | else |
2724 | { | 2723 | { |
2725 | if (sy+pm.height() > dbuff->height()) | 2724 | if (sy+pm.height() > dbuff->height()) |
2726 | { | 2725 | { |
2727 | // pd.eraseRect(pm.rect()); | 2726 | // pd.eraseRect(pm.rect()); |
2728 | int fh = dbuff->height() - sy; | 2727 | int fh = dbuff->height() - sy; |
2729 | if (sy+fh > dbuff->height()) | 2728 | if (sy+fh > dbuff->height()) |
2730 | { | 2729 | { |
2731 | qDebug("Oh no!"); | 2730 | qDebug("Oh no!"); |
2732 | } | 2731 | } |
2733 | 2732 | ||
2734 | if (fh > pm.height()) | 2733 | if (fh > pm.height()) |
2735 | { | 2734 | { |
2736 | qDebug("Oh no! - 2"); | 2735 | qDebug("Oh no! - 2"); |
2737 | } | 2736 | } |
2738 | 2737 | ||
2739 | bitBlt(&pm,0,0,dbuff,dy,sy,pm.width(),fh); | 2738 | bitBlt(&pm,0,0,dbuff,dy,sy,pm.width(),fh); |
2740 | bitBlt(&pm,0,fh,dbuff,dy,0,pm.width(),pm.height()-fh); | 2739 | bitBlt(&pm,0,fh,dbuff,dy,0,pm.width(),pm.height()-fh); |
2741 | } | 2740 | } |
2742 | else | 2741 | else |
2743 | { | 2742 | { |
2744 | bitBlt(&pm,0,0,dbuff,dy,sy,pm.width(),pm.height()); | 2743 | bitBlt(&pm,0,0,dbuff,dy,sy,pm.width(),pm.height()); |
2745 | } | 2744 | } |
2746 | } | 2745 | } |
2747 | if (txt != NULL) | 2746 | if (txt != NULL) |
2748 | { | 2747 | { |
2749 | // txt->render(&pd, txt->lineSpacing() - txt->descent() - txt->lineExtraSpacing(), m_bMonoSpaced, m_charWidth, sw, m_left_border, m_right_border, m_bg); | 2748 | // txt->render(&pd, txt->lineSpacing() - txt->descent() - txt->lineExtraSpacing(), m_bMonoSpaced, m_charWidth, sw, m_left_border, m_right_border, m_bg); |
2750 | 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); | 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); |
2751 | } | 2750 | } |
2752 | QWMatrix m; | 2751 | QWMatrix m; |
2753 | m.rotate(90); | 2752 | m.rotate(90); |
2754 | QPixmap rp = pm.xForm(m); | 2753 | QPixmap rp = pm.xForm(m); |
2755 | /* | 2754 | /* |
2756 | p.drawPixmap(QPoint(dx, dy), rp); | 2755 | p.drawPixmap(QPoint(dx, dy), rp); |
2757 | */ | 2756 | */ |
2758 | bitBlt(this, dx, dy, &rp, 0, 0, -1, -1, CopyROP); | 2757 | bitBlt(this, dx, dy, &rp, 0, 0, -1, -1, CopyROP); |
2759 | } | 2758 | } |
2760 | 2759 | ||
2761 | QString QTReader::about() | 2760 | QString QTReader::about() |
2762 | { | 2761 | { |
2763 | return QString("QTReader widget (c) Tim Wentford\n")+buffdoc.about() + "\nMini-scrollbar by Markus Gritsch\nNavigation History fixes by Frantisek Dufka"; | 2762 | return QString("QTReader widget (c) Tim Wentford\n")+buffdoc.about() + "\nMini-scrollbar by Markus Gritsch\nNavigation History fixes by Frantisek Dufka"; |
2764 | } | 2763 | } |
2765 | 2764 | ||
2766 | void QTReader::getNextLink() | 2765 | void QTReader::getNextLink() |
2767 | { | 2766 | { |
2768 | if (m_scrolldy != 0) | 2767 | if (m_scrolldy != 0) |
2769 | { | 2768 | { |
2770 | setautoscroll(false); | 2769 | setautoscroll(false); |
2771 | ResetScroll(); | 2770 | ResetScroll(); |
2772 | redrawall(); | 2771 | redrawall(); |
2773 | } | 2772 | } |
2774 | bool redraw = false; | 2773 | bool redraw = false; |
2775 | bool found = false; | 2774 | bool found = false; |
2776 | if (m_currentlink >= 0) | 2775 | if (m_currentlink >= 0) |
2777 | { | 2776 | { |
2778 | m_currentlinkoffset = textarray[m_currentlink]->invertLink(m_currentlinkoffset); | 2777 | m_currentlinkoffset = textarray[m_currentlink]->invertLink(m_currentlinkoffset); |
2779 | if ((m_currentlinkstyle = textarray[m_currentlink]->getNextLink(m_currentlinkoffset)) != NULL) | 2778 | if ((m_currentlinkstyle = textarray[m_currentlink]->getNextLink(m_currentlinkoffset)) != NULL) |
2780 | { | 2779 | { |
2781 | qDebug("Found a link at %u", m_currentlinkoffset); | 2780 | qDebug("Found a link at %u", m_currentlinkoffset); |
2782 | int offset = textarray[m_currentlink]->invertLink(m_currentlinkoffset); | 2781 | int offset = textarray[m_currentlink]->invertLink(m_currentlinkoffset); |
2783 | qDebug("Finishes at %u", offset); | 2782 | qDebug("Finishes at %u", offset); |
2784 | found = true; | 2783 | found = true; |
2785 | } | 2784 | } |
2786 | redraw = true; | 2785 | redraw = true; |
2787 | drawSingleLine(m_currentlink); | 2786 | drawSingleLine(m_currentlink); |
2788 | // if (found) return; | 2787 | // if (found) return; |
2789 | } | 2788 | } |
2790 | if (!found) | 2789 | if (!found) |
2791 | { | 2790 | { |
2792 | m_currentlinkoffset = -1; | 2791 | m_currentlinkoffset = -1; |
2793 | for (int i = m_currentlink+1; i < numlines; ++i) | 2792 | for (int i = m_currentlink+1; i < numlines; ++i) |
2794 | { | 2793 | { |
2795 | if ((m_currentlinkstyle = textarray[i]->getNextLink(m_currentlinkoffset)) != NULL) | 2794 | if ((m_currentlinkstyle = textarray[i]->getNextLink(m_currentlinkoffset)) != NULL) |
2796 | { | 2795 | { |
2797 | m_currentlink = i; | 2796 | m_currentlink = i; |
2798 | qDebug("Found a link at %u", m_currentlinkoffset); | 2797 | qDebug("Found a link at %u", m_currentlinkoffset); |
2799 | int offset = textarray[m_currentlink]->invertLink(m_currentlinkoffset); | 2798 | int offset = textarray[m_currentlink]->invertLink(m_currentlinkoffset); |
2800 | qDebug("Finishes at %u", offset); | 2799 | qDebug("Finishes at %u", offset); |
2801 | //drawSingleLine(i); | 2800 | //drawSingleLine(i); |
2802 | redraw = true; | 2801 | redraw = true; |
2803 | found = true; | 2802 | found = true; |
2804 | drawSingleLine(m_currentlink); | 2803 | drawSingleLine(m_currentlink); |
2805 | break; | 2804 | break; |
2806 | } | 2805 | } |
2807 | } | 2806 | } |
2808 | } | 2807 | } |
2809 | if (redraw) | 2808 | if (redraw) |
2810 | { | 2809 | { |
2811 | // redrawall(); | 2810 | // redrawall(); |
2812 | } | 2811 | } |
2813 | if (!found) | 2812 | if (!found) |
2814 | { | 2813 | { |
2815 | m_currentlink = -1; | 2814 | m_currentlink = -1; |
2816 | m_currentlinkstyle = NULL; | 2815 | m_currentlinkstyle = NULL; |
2817 | m_currentlinkoffset = -1; | 2816 | m_currentlinkoffset = -1; |
2818 | dopagedn(); | 2817 | dopagedn(); |
2819 | } | 2818 | } |
2820 | } | 2819 | } |
2821 | 2820 | ||
2822 | void QTReader::emitRedraw() | 2821 | void QTReader::emitRedraw() |
2823 | { | 2822 | { |
2824 | m_currentlinkstyle = NULL; | 2823 | m_currentlinkstyle = NULL; |
2825 | m_currentlink = -1; | 2824 | m_currentlink = -1; |
2826 | m_currentlinkoffset = -1; | 2825 | m_currentlinkoffset = -1; |
2827 | emit OnRedraw(); | 2826 | emit OnRedraw(); |
2828 | }; | 2827 | }; |
2829 | 2828 | ||
2830 | void QTReader::drawSingleLine(int lineno) | 2829 | void QTReader::drawSingleLine(int lineno) |
2831 | { | 2830 | { |
2832 | QPainter p( this ); | 2831 | QPainter p( this ); |
2833 | int ypos = textarray[0]->ascent()+m_topmargin; | 2832 | int ypos = textarray[0]->ascent()+m_topmargin; |
2834 | if (lineno == 0) | 2833 | if (lineno == 0) |
2835 | { | 2834 | { |
2836 | if (m_rotated) | 2835 | if (m_rotated) |
2837 | { | 2836 | { |
2838 | blitRot(width()-(ypos+textarray[lineno]->descent()+textarray[lineno]->lineExtraSpacing()), 0, height(), -1, textarray[lineno]); | 2837 | blitRot(width()-(ypos+textarray[lineno]->descent()+textarray[lineno]->lineExtraSpacing()), 0, height(), -1, textarray[lineno]); |
2839 | } | 2838 | } |
2840 | else | 2839 | else |
2841 | { | 2840 | { |
2842 | if (m_bgpm.isNull()) | 2841 | if (m_bgpm.isNull()) |
2843 | { | 2842 | { |
2844 | p.fillRect(m_left_border,ypos-textarray[lineno]->ascent(),width()-(m_left_border+m_right_border),textarray[lineno]->lineSpacing(),m_bg); | 2843 | p.fillRect(m_left_border,ypos-textarray[lineno]->ascent(),width()-(m_left_border+m_right_border),textarray[lineno]->lineSpacing(),m_bg); |
2845 | } | 2844 | } |
2846 | else | 2845 | else |
2847 | { | 2846 | { |
2848 | 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()); | 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()); |
2849 | } | 2848 | } |
2850 | textarray[lineno]->render( &p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | 2849 | textarray[lineno]->render( &p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); |
2851 | } | 2850 | } |
2852 | } | 2851 | } |
2853 | for (int i = 1; i < numlines; i++) | 2852 | for (int i = 1; i < numlines; i++) |
2854 | { | 2853 | { |
2855 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ | 2854 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ |
2856 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; | 2855 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; |
2857 | if (i == lineno) | 2856 | if (i == lineno) |
2858 | { | 2857 | { |
2859 | if (m_rotated) | 2858 | if (m_rotated) |
2860 | { | 2859 | { |
2861 | blitRot(width()-(ypos+textarray[i]->descent()+textarray[i]->lineExtraSpacing()), 0, height(), -1, textarray[i]); | 2860 | blitRot(width()-(ypos+textarray[i]->descent()+textarray[i]->lineExtraSpacing()), 0, height(), -1, textarray[i]); |
2862 | } | 2861 | } |
2863 | else | 2862 | else |
2864 | { | 2863 | { |
2865 | if (m_bgpm.isNull()) | 2864 | if (m_bgpm.isNull()) |
2866 | { | 2865 | { |
2867 | p.fillRect(m_left_border,ypos-textarray[lineno]->ascent(),width()-(m_left_border+m_right_border),textarray[lineno]->lineSpacing(),m_bg); | 2866 | p.fillRect(m_left_border,ypos-textarray[lineno]->ascent(),width()-(m_left_border+m_right_border),textarray[lineno]->lineSpacing(),m_bg); |
2868 | } | 2867 | } |
2869 | else | 2868 | else |
2870 | { | 2869 | { |
2871 | 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()); | 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()); |
2872 | } | 2871 | } |
2873 | textarray[i]->render( &p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | 2872 | textarray[i]->render( &p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); |
2874 | } | 2873 | } |
2875 | } | 2874 | } |
2876 | } | 2875 | } |
2877 | } | 2876 | } |
2878 | 2877 | ||
2879 | 2878 | ||
2880 | void QTReader::gotoLink() | 2879 | void QTReader::gotoLink() |
2881 | { | 2880 | { |
2882 | if (m_currentlinkstyle == NULL) return; | 2881 | if (m_currentlinkstyle == NULL) return; |
2883 | textarray[m_currentlink]->invertLink(m_currentlinkoffset); | 2882 | textarray[m_currentlink]->invertLink(m_currentlinkoffset); |
2884 | size_t saveposn = pagelocate(); | 2883 | size_t saveposn = pagelocate(); |
2885 | QString href, nm; | 2884 | QString href, nm; |
2886 | unsigned long tgt = m_currentlinkstyle->getData(); | 2885 | unsigned long tgt = m_currentlinkstyle->getData(); |
2887 | unsigned long tgtoffset = m_currentlinkstyle->getOffset(); | 2886 | unsigned long tgtoffset = m_currentlinkstyle->getOffset(); |
2888 | linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm); | 2887 | linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm); |
2889 | qDebug("URL(1):%s", (const char*)href); | 2888 | qDebug("URL(1):%s", (const char*)href); |
2890 | if ((lt & eFile) != 0) | 2889 | if ((lt & eFile) != 0) |
2891 | { | 2890 | { |
2892 | buffdoc.saveposn(m_lastfile, saveposn); | 2891 | buffdoc.saveposn(m_lastfile, saveposn); |
2893 | #ifdef USEQPE | 2892 | #ifdef USEQPE |
2894 | { | 2893 | { |
2895 | QCopEnvelope e("QPE/System", "busy()"); | 2894 | QCopEnvelope e("QPE/System", "busy()"); |
2896 | } | 2895 | } |
2897 | #endif | 2896 | #endif |
2898 | ResetScroll(); | 2897 | ResetScroll(); |
2899 | if (!href.isEmpty()) | 2898 | if (!href.isEmpty()) |
2900 | { | 2899 | { |
2901 | if (!buffdoc.getFile(href)) | 2900 | if (!buffdoc.getFile(href)) |
2902 | { | 2901 | { |
2903 | emit NewFileRequest(href); | 2902 | emit NewFileRequest(href); |
2904 | } | 2903 | } |
2905 | else | 2904 | else |
2906 | { | 2905 | { |
2907 | ResetScroll(); | 2906 | ResetScroll(); |
2908 | fillbuffer(); | 2907 | fillbuffer(); |
2909 | update(); | 2908 | update(); |
2910 | } | 2909 | } |
2911 | } | 2910 | } |
2912 | if (!nm.isEmpty()) | 2911 | if (!nm.isEmpty()) |
2913 | { | 2912 | { |
2914 | qDebug("QTReader:Finding %s", (const char*)nm); | 2913 | qDebug("QTReader:Finding %s", (const char*)nm); |
2915 | if (buffdoc.findanchor(nm)) | 2914 | if (buffdoc.findanchor(nm)) |
2916 | { | 2915 | { |
2917 | fillbuffer(); | 2916 | fillbuffer(); |
2918 | update(); | 2917 | update(); |
2919 | } | 2918 | } |
2920 | } | 2919 | } |
2921 | //fillbuffer(); | 2920 | //fillbuffer(); |
2922 | //update(); | 2921 | //update(); |
2923 | #ifdef USEQPE | 2922 | #ifdef USEQPE |
2924 | { | 2923 | { |
2925 | QCopEnvelope e("QPE/System", "notBusy()"); | 2924 | QCopEnvelope e("QPE/System", "notBusy()"); |
2926 | } | 2925 | } |
2927 | #endif | 2926 | #endif |
2928 | } | 2927 | } |
2929 | else if ((lt & eLink) != 0) | 2928 | else if ((lt & eLink) != 0) |
2930 | { | 2929 | { |
2931 | buffdoc.saveposn(m_lastfile, saveposn); | 2930 | buffdoc.saveposn(m_lastfile, saveposn); |
2932 | ResetScroll(); | 2931 | ResetScroll(); |
2933 | fillbuffer(); | 2932 | fillbuffer(); |
2934 | update(); | 2933 | update(); |
2935 | } | 2934 | } |
2936 | else | 2935 | else |
2937 | { | 2936 | { |
2938 | if ((lt & ePicture) != 0) | 2937 | if ((lt & ePicture) != 0) |
2939 | { | 2938 | { |
2940 | QImage* pm = buffdoc.getPicture(tgt); | 2939 | QImage* pm = buffdoc.getPicture(tgt); |
2941 | if (pm != NULL) | 2940 | if (pm != NULL) |
2942 | { | 2941 | { |
2943 | emit OnShowPicture(*pm); | 2942 | emit OnShowPicture(*pm); |
2944 | delete pm; | 2943 | delete pm; |
2945 | } | 2944 | } |
2946 | } | 2945 | } |
2947 | else | 2946 | else |
2948 | { | 2947 | { |
2949 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); | 2948 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); |
2950 | if (!href.isEmpty()) | 2949 | if (!href.isEmpty()) |
2951 | { | 2950 | { |
2952 | emit OnURLSelected(href, tgt); | 2951 | emit OnURLSelected(href, tgt); |
2953 | } | 2952 | } |
2954 | } | 2953 | } |
2955 | locate(pagelocate()); | 2954 | locate(pagelocate()); |
2956 | } | 2955 | } |
2957 | m_currentlinkstyle = NULL; | 2956 | m_currentlinkstyle = NULL; |
2958 | m_currentlink = -1; | 2957 | m_currentlink = -1; |
2959 | m_currentlinkoffset = -1; | 2958 | m_currentlinkoffset = -1; |
2960 | } | 2959 | } |
2961 | 2960 | ||
2962 | void QTReader::refresh(bool full) | 2961 | void QTReader::refresh(bool full) |
2963 | { | 2962 | { |
2964 | int h, w; | 2963 | int h, w; |
2965 | if (m_rotated) | 2964 | if (m_rotated) |
2966 | { | 2965 | { |
2967 | h = width(); | 2966 | h = width(); |
2968 | w = height(); | 2967 | w = height(); |
2969 | } | 2968 | } |
2970 | else | 2969 | else |
2971 | { | 2970 | { |
2972 | w = width(); | 2971 | w = width(); |
2973 | h = height(); | 2972 | h = height(); |
2974 | } | 2973 | } |
2975 | m_topmargin = (h*m_abstopmargin+500)/1000; | 2974 | m_topmargin = (h*m_abstopmargin+500)/1000; |
2976 | m_bottommargin = (h*m_absbottommargin+500)/1000; | 2975 | m_bottommargin = (h*m_absbottommargin+500)/1000; |
2977 | m_left_border = (w*m_absleft_border+500)/1000; | 2976 | m_left_border = (w*m_absleft_border+500)/1000; |
2978 | m_right_border = (w*m_absright_border+500)/1000; | 2977 | m_right_border = (w*m_absright_border+500)/1000; |
2979 | 2978 | ||
2980 | qDebug("Top margin:%u", m_topmargin ); | 2979 | qDebug("Top margin:%u", m_topmargin ); |
2981 | qDebug("Bottom margin:%u", m_bottommargin ); | 2980 | qDebug("Bottom margin:%u", m_bottommargin ); |
2982 | qDebug("Left margin:%u", m_left_border ); | 2981 | qDebug("Left margin:%u", m_left_border ); |
2983 | qDebug("Right margin:%u", m_right_border ); | 2982 | qDebug("Right margin:%u", m_right_border ); |
2984 | if (full && m_highlightfilter) m_highlightfilter->refresh(pagelocate()); | 2983 | if (full && m_highlightfilter) m_highlightfilter->refresh(pagelocate()); |
2985 | locate(pagelocate()); | 2984 | locate(pagelocate()); |
2986 | } | 2985 | } |
diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h index 7b0ebc8..3bcdde4 100644 --- a/noncore/apps/opie-reader/QTReader.h +++ b/noncore/apps/opie-reader/QTReader.h | |||
@@ -1,416 +1,415 @@ | |||
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 "static.h" | ||
6 | #include <qwidget.h> | 5 | #include <qwidget.h> |
7 | //#include <qpainter.h> | 6 | //#include <qpainter.h> |
8 | #include "my_list.h" | 7 | #include "my_list.h" |
9 | #include "BuffDoc.h" | 8 | #include "BuffDoc.h" |
10 | #include "FontControl.h" | 9 | #include "FontControl.h" |
11 | 10 | ||
12 | //#include <qtimer.h> | 11 | //#include <qtimer.h> |
13 | 12 | ||
14 | class CDrawBuffer; | 13 | class CDrawBuffer; |
15 | //class CBuffer; | 14 | //class CBuffer; |
16 | #include <qpixmap.h> | 15 | #include <qpixmap.h> |
17 | class QPainter; | 16 | class QPainter; |
18 | class QTimer; | 17 | class QTimer; |
19 | class QImage; | 18 | class QImage; |
20 | 19 | ||
21 | #include "BGType.h" | 20 | #include "BGType.h" |
22 | #include "striphtml.h" | 21 | #include "striphtml.h" |
23 | 22 | ||
24 | #define ROTATION_ENABLED | 23 | #define ROTATION_ENABLED |
25 | #define SPECIALSCROLL | 24 | #define SPECIALSCROLL |
26 | #define DOUBLEBUFFER | 25 | #define DOUBLEBUFFER |
27 | #ifdef DOUBLEBUFFER | 26 | #ifdef DOUBLEBUFFER |
28 | class QPainter; | 27 | class QPainter; |
29 | #endif | 28 | #endif |
30 | 29 | ||
31 | class CStyle; | 30 | class CStyle; |
32 | 31 | ||
33 | class QTReader : public QWidget | 32 | class QTReader : public QWidget |
34 | { | 33 | { |
35 | Q_OBJECT | 34 | Q_OBJECT |
36 | friend class QTReaderApp; | 35 | friend class QTReaderApp; |
37 | #ifdef DOUBLEBUFFER | 36 | #ifdef DOUBLEBUFFER |
38 | QPixmap *dbuff; | 37 | QPixmap *dbuff; |
39 | QPainter* dbp; | 38 | QPainter* dbp; |
40 | #endif | 39 | #endif |
41 | void drawSingleLine(int lineno); | 40 | void drawSingleLine(int lineno); |
42 | void gotoLink(); | 41 | void gotoLink(); |
43 | void emitRedraw(); | 42 | void emitRedraw(); |
44 | CStyle* m_currentlinkstyle; | 43 | CStyle* m_currentlinkstyle; |
45 | int m_currentlink; | 44 | int m_currentlink; |
46 | int m_currentlinkoffset; | 45 | int m_currentlinkoffset; |
47 | QPixmap m_bgpm; | 46 | QPixmap m_bgpm; |
48 | bool m_bgIsScaled; | 47 | bool m_bgIsScaled; |
49 | bground m_bgtype; | 48 | bground m_bgtype; |
50 | int m_scrollpos; | 49 | int m_scrollpos; |
51 | unsigned short m_scrollstep; | 50 | unsigned short m_scrollstep; |
52 | void blitRot(int dx, int sx, int sw, int sh, CDrawBuffer* txt); | 51 | void blitRot(int dx, int sx, int sw, int sh, CDrawBuffer* txt); |
53 | void setBackgroundBitmap(const QPixmap& _pm, bground bg) | 52 | void setBackgroundBitmap(const QPixmap& _pm, bground bg) |
54 | { | 53 | { |
55 | m_bgpm = _pm; | 54 | m_bgpm = _pm; |
56 | m_bgtype = bg; | 55 | m_bgtype = bg; |
57 | m_bgIsScaled = false; | 56 | m_bgIsScaled = false; |
58 | } | 57 | } |
59 | 58 | ||
60 | QColor m_bg, m_default_bg, m_default_fg, m_negative_fg; | 59 | QColor m_bg, m_default_bg, m_default_fg, m_negative_fg; |
61 | static tchar pluckernextpart[]; | 60 | static tchar pluckernextpart[]; |
62 | static tchar jplucknextpart[]; | 61 | static tchar jplucknextpart[]; |
63 | CList<Bkmk>* pBkmklist; | 62 | CList<Bkmk>* pBkmklist; |
64 | void setHyphenThreshold(int _v) { buffdoc.setHyphenThreshold(_v); } | 63 | void setHyphenThreshold(int _v) { buffdoc.setHyphenThreshold(_v); } |
65 | void ResetScroll(); | 64 | void ResetScroll(); |
66 | void increaseScroll(); | 65 | void increaseScroll(); |
67 | void reduceScroll(); | 66 | void reduceScroll(); |
68 | void drawText(QPainter& p, int x, int y, tchar* text); | 67 | void drawText(QPainter& p, int x, int y, tchar* text); |
69 | void DrawScroll( QPainter *p, int w, int h ); | 68 | void DrawScroll( QPainter *p, int w, int h ); |
70 | void dorollingscroll(bool); | 69 | void dorollingscroll(bool); |
71 | void doinplacescroll(); | 70 | void doinplacescroll(); |
72 | void dostaticscroll(); | 71 | void dostaticscroll(); |
73 | void suspend(); | 72 | void suspend(); |
74 | void redrawScroll(QPainter* p); | 73 | void redrawScroll(QPainter* p); |
75 | int m_delay, m_scrolltype; | 74 | int m_delay, m_scrolltype; |
76 | unsigned int m_overlap; | 75 | unsigned int m_overlap; |
77 | bool m_autoScroll, m_swapmouse; | 76 | bool m_autoScroll, m_swapmouse; |
78 | void drawBackground(); | 77 | void drawBackground(); |
79 | #ifdef ROTATION_ENABLED | 78 | #ifdef ROTATION_ENABLED |
80 | bool m_rotated; | 79 | bool m_rotated; |
81 | void setrotated(bool); | 80 | void setrotated(bool); |
82 | #endif | 81 | #endif |
83 | void autoscroll(); | 82 | void autoscroll(); |
84 | QTimer* timer; | 83 | QTimer* timer; |
85 | int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart, m_totalscroll; | 84 | int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart, m_totalscroll; |
86 | void focusInEvent(QFocusEvent*); | 85 | void focusInEvent(QFocusEvent*); |
87 | void focusOutEvent(QFocusEvent*); | 86 | void focusOutEvent(QFocusEvent*); |
88 | void processmousepositionevent( QMouseEvent* _e ); | 87 | void processmousepositionevent( QMouseEvent* _e ); |
89 | void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno); | 88 | void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno); |
90 | bool ChangeFont(int); | 89 | bool ChangeFont(int); |
91 | bool getline(CDrawBuffer*); | 90 | bool getline(CDrawBuffer*); |
92 | int m_charWidth; | 91 | int m_charWidth; |
93 | int m_charpc; | 92 | int m_charpc; |
94 | unsigned short m_absleft_border, m_absright_border; | 93 | unsigned short m_absleft_border, m_absright_border; |
95 | unsigned short m_left_border, m_right_border; | 94 | unsigned short m_left_border, m_right_border; |
96 | FontControl m_fontControl; | 95 | FontControl m_fontControl; |
97 | void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); } | 96 | void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); } |
98 | unsigned char getBaseSize() { return m_fontControl.getBaseSize(); } | 97 | unsigned char getBaseSize() { return m_fontControl.getBaseSize(); } |
99 | #ifdef _SCROLLPIPE | 98 | #ifdef _SCROLLPIPE |
100 | FILE* m_pipeout; | 99 | FILE* m_pipeout; |
101 | QString m_pipetarget; | 100 | QString m_pipetarget; |
102 | bool m_isPaused; | 101 | bool m_isPaused; |
103 | bool m_pauseAfterEachPara; | 102 | bool m_pauseAfterEachPara; |
104 | #endif | 103 | #endif |
105 | public: | 104 | public: |
106 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); | 105 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); |
107 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); | 106 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); |
108 | ~QTReader(); | 107 | ~QTReader(); |
109 | QString about(); | 108 | QString about(); |
110 | CList<Bkmk>* Bkmklist() { return pBkmklist; } | 109 | CList<Bkmk>* Bkmklist() { return pBkmklist; } |
111 | void setBackground(const QColor& _c) | 110 | void setBackground(const QColor& _c) |
112 | { | 111 | { |
113 | m_default_bg = _c; | 112 | m_default_bg = _c; |
114 | reset_bg(); | 113 | reset_bg(); |
115 | } | 114 | } |
116 | void setForeground(const QColor& _c) | 115 | void setForeground(const QColor& _c) |
117 | { | 116 | { |
118 | m_default_fg = _c; | 117 | m_default_fg = _c; |
119 | int r,g,b; | 118 | int r,g,b; |
120 | m_default_fg.rgb(&r, &g, &b); | 119 | m_default_fg.rgb(&r, &g, &b); |
121 | r = 255-r; | 120 | r = 255-r; |
122 | g = 255-g; | 121 | g = 255-g; |
123 | b = 255-b; | 122 | b = 255-b; |
124 | m_negative_fg.setRgb(r,g,b); | 123 | m_negative_fg.setRgb(r,g,b); |
125 | } | 124 | } |
126 | void zoomin(); | 125 | void zoomin(); |
127 | void zoomout(); | 126 | void zoomout(); |
128 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | 127 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) |
129 | { | 128 | { |
130 | buffdoc.setSaveData(data, len, src, srclen); | 129 | buffdoc.setSaveData(data, len, src, srclen); |
131 | } | 130 | } |
132 | void putSaveData(unsigned char*& src, unsigned short& srclen) | 131 | void putSaveData(unsigned char*& src, unsigned short& srclen) |
133 | { | 132 | { |
134 | buffdoc.putSaveData(src, srclen); | 133 | buffdoc.putSaveData(src, srclen); |
135 | } | 134 | } |
136 | bool empty(); | 135 | bool empty(); |
137 | void setContinuous(bool _b); | 136 | void setContinuous(bool _b); |
138 | void toggle_autoscroll(); | 137 | void toggle_autoscroll(); |
139 | void setautoscroll(bool); | 138 | void setautoscroll(bool); |
140 | void disableAutoscroll() { m_autoScroll = false; } | 139 | void disableAutoscroll() { m_autoScroll = false; } |
141 | void copy() | 140 | void copy() |
142 | { | 141 | { |
143 | /* | 142 | /* |
144 | size_t nd = locate(); | 143 | size_t nd = locate(); |
145 | jumpto(m_mark); | 144 | jumpto(m_mark); |
146 | QString text; | 145 | QString text; |
147 | while (m_mark < nd) | 146 | while (m_mark < nd) |
148 | { | 147 | { |
149 | text += buffdoc.getch(); | 148 | text += buffdoc.getch(); |
150 | m_mark++; | 149 | m_mark++; |
151 | } | 150 | } |
152 | QApplication::clipboard()->setText(text); | 151 | QApplication::clipboard()->setText(text); |
153 | jumpto(nd); | 152 | jumpto(nd); |
154 | */ | 153 | */ |
155 | }; | 154 | }; |
156 | void clear() {}; | 155 | void clear() {}; |
157 | void setText(const QString& n, const QString& s) { m_string = n; load_file((const char*)s); }; | 156 | void setText(const QString& n, const QString& s) { m_string = n; load_file((const char*)s); }; |
158 | /* | 157 | /* |
159 | void setText(bool oldfile) | 158 | void setText(bool oldfile) |
160 | { | 159 | { |
161 | if (oldfile) | 160 | if (oldfile) |
162 | { | 161 | { |
163 | m_string = m_lastfile; | 162 | m_string = m_lastfile; |
164 | load_file((const tchar*)m_string); | 163 | load_file((const tchar*)m_string); |
165 | } | 164 | } |
166 | else | 165 | else |
167 | { | 166 | { |
168 | m_string = QString::null; | 167 | m_string = QString::null; |
169 | } | 168 | } |
170 | }; | 169 | }; |
171 | */ | 170 | */ |
172 | void setlead(int _lead) | 171 | void setlead(int _lead) |
173 | { | 172 | { |
174 | m_fontControl.setlead(_lead); | 173 | m_fontControl.setlead(_lead); |
175 | } | 174 | } |
176 | int getlead() | 175 | int getlead() |
177 | { | 176 | { |
178 | return m_fontControl.getlead(); | 177 | return m_fontControl.getlead(); |
179 | } | 178 | } |
180 | void setextraspace(int _lead) | 179 | void setextraspace(int _lead) |
181 | { | 180 | { |
182 | m_fontControl.setextraspace(_lead); | 181 | m_fontControl.setextraspace(_lead); |
183 | } | 182 | } |
184 | int getextraspace() | 183 | int getextraspace() |
185 | { | 184 | { |
186 | return m_fontControl.getextraspace(); | 185 | return m_fontControl.getextraspace(); |
187 | } | 186 | } |
188 | void setpagemode(bool _b) | 187 | void setpagemode(bool _b) |
189 | { | 188 | { |
190 | m_bpagemode = _b; | 189 | m_bpagemode = _b; |
191 | } | 190 | } |
192 | void setmono(bool _b) | 191 | void setmono(bool _b) |
193 | { | 192 | { |
194 | m_bMonoSpaced = _b; | 193 | m_bMonoSpaced = _b; |
195 | ChangeFont(m_fontControl.currentsize()); | 194 | ChangeFont(m_fontControl.currentsize()); |
196 | locate(pagelocate()); | 195 | locate(pagelocate()); |
197 | } | 196 | } |
198 | void setencoding(int _f) | 197 | void setencoding(int _f) |
199 | { | 198 | { |
200 | m_encd = _f; | 199 | m_encd = _f; |
201 | setfilter(getfilter()); | 200 | setfilter(getfilter()); |
202 | } | 201 | } |
203 | MarkupType PreferredMarkup(); | 202 | MarkupType PreferredMarkup(); |
204 | CEncoding* getencoding() | 203 | CEncoding* getencoding() |
205 | { | 204 | { |
206 | // qDebug("m_encd:%d", m_encd); | 205 | // qDebug("m_encd:%d", m_encd); |
207 | switch (m_encd) | 206 | switch (m_encd) |
208 | { | 207 | { |
209 | case 4: | 208 | case 4: |
210 | // qDebug("palm"); | 209 | // qDebug("palm"); |
211 | return new CPalm; | 210 | return new CPalm; |
212 | case 1: | 211 | case 1: |
213 | // qDebug("utf8"); | 212 | // qDebug("utf8"); |
214 | return new CUtf8; | 213 | return new CUtf8; |
215 | case 2: | 214 | case 2: |
216 | // qDebug("ucs16be"); | 215 | // qDebug("ucs16be"); |
217 | return new CUcs16be; | 216 | return new CUcs16be; |
218 | case 3: | 217 | case 3: |
219 | // qDebug("ucs16le"); | 218 | // qDebug("ucs16le"); |
220 | return new CUcs16le; | 219 | return new CUcs16le; |
221 | case 0: | 220 | case 0: |
222 | // qDebug("ascii"); | 221 | // qDebug("ascii"); |
223 | return new CAscii; | 222 | return new CAscii; |
224 | default: | 223 | default: |
225 | return new CGeneral8Bit(m_encd-MAX_ENCODING+1); | 224 | return new CGeneral8Bit(m_encd-MAX_ENCODING+1); |
226 | } | 225 | } |
227 | } | 226 | } |
228 | HighlightFilter* m_highlightfilter; | 227 | HighlightFilter* m_highlightfilter; |
229 | CFilterChain* getfilter() | 228 | CFilterChain* getfilter() |
230 | { | 229 | { |
231 | CFilterChain * filt = new CFilterChain(getencoding()); | 230 | CFilterChain * filt = new CFilterChain(getencoding()); |
232 | if (bstripcr) filt->addfilter(new stripcr); | 231 | if (bstripcr) filt->addfilter(new stripcr); |
233 | 232 | ||
234 | if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); | 233 | if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); |
235 | if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); | 234 | if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); |
236 | // if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); | 235 | // if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); |
237 | 236 | ||
238 | #ifdef __STATIC | 237 | #ifdef __STATIC |
239 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); | 238 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); |
240 | if (bautofmt && (PreferredMarkup() == cCHM)) | 239 | if (bautofmt && (PreferredMarkup() == cCHM)) |
241 | { | 240 | { |
242 | filt->addfilter(new striphtml(m_lastfile)); | 241 | filt->addfilter(new striphtml(m_lastfile)); |
243 | } | 242 | } |
244 | #else | 243 | #else |
245 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new ExternFilter("HTMLfilter", m_lastfile)); | 244 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new ExternFilter("HTMLfilter", m_lastfile)); |
246 | if (bautofmt && (PreferredMarkup() == cCHM)) | 245 | if (bautofmt && (PreferredMarkup() == cCHM)) |
247 | { | 246 | { |
248 | ExternFilter* f = new ExternFilter("HTMLfilter",m_lastfile); | 247 | ExternFilter* f = new ExternFilter("HTMLfilter",m_lastfile); |
249 | ((striphtml*)f->filter())->setchm(true); | 248 | ((striphtml*)f->filter())->setchm(true); |
250 | filt->addfilter(f); | 249 | filt->addfilter(f); |
251 | } | 250 | } |
252 | #endif | 251 | #endif |
253 | m_highlightfilter = new HighlightFilter(this); | 252 | m_highlightfilter = new HighlightFilter(this); |
254 | filt->addfilter(m_highlightfilter); | 253 | filt->addfilter(m_highlightfilter); |
255 | 254 | ||
256 | if (bdehyphen) filt->addfilter(new dehyphen); | 255 | if (bdehyphen) filt->addfilter(new dehyphen); |
257 | if (bunindent) filt->addfilter(new unindent); | 256 | if (bunindent) filt->addfilter(new unindent); |
258 | if (brepara) filt->addfilter(new repara(m_reparastring)); | 257 | if (brepara) filt->addfilter(new repara(m_reparastring)); |
259 | if (bonespace) filt->addfilter(new OnePara); | 258 | if (bonespace) filt->addfilter(new OnePara); |
260 | if (bindenter) filt->addfilter(new indenter(bindenter)); | 259 | if (bindenter) filt->addfilter(new indenter(bindenter)); |
261 | if (bdblspce) filt->addfilter(new dblspce); | 260 | if (bdblspce) filt->addfilter(new dblspce); |
262 | if (bdepluck) filt->addfilter(new DePluck(pluckernextpart)); | 261 | if (bdepluck) filt->addfilter(new DePluck(pluckernextpart)); |
263 | if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart)); | 262 | if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart)); |
264 | if (brepalm) filt->addfilter(new repalm); | 263 | if (brepalm) filt->addfilter(new repalm); |
265 | if (bkern) filt->addfilter(new kern); | 264 | if (bkern) filt->addfilter(new kern); |
266 | if (bremap) filt->addfilter(new remap); | 265 | if (bremap) filt->addfilter(new remap); |
267 | if (bmakebold) filt->addfilter(new embolden); | 266 | if (bmakebold) filt->addfilter(new embolden); |
268 | if (bfulljust) filt->addfilter(new FullJust); | 267 | if (bfulljust) filt->addfilter(new FullJust); |
269 | int r,g,b; | 268 | int r,g,b; |
270 | m_default_bg.rgb(&r, &g, &b); | 269 | m_default_bg.rgb(&r, &g, &b); |
271 | if (r != 255 || g != 255 || b != 255) | 270 | if (r != 255 || g != 255 || b != 255) |
272 | filt->addfilter(new setbg(r,g,b)); | 271 | filt->addfilter(new setbg(r,g,b)); |
273 | m_default_fg.rgb(&r, &g, &b); | 272 | m_default_fg.rgb(&r, &g, &b); |
274 | if (r != 0 || g != 0 || b != 0) | 273 | if (r != 0 || g != 0 || b != 0) |
275 | filt->addfilter(new setfg(r,g,b)); | 274 | filt->addfilter(new setfg(r,g,b)); |
276 | // if (bNegative) filt->addfilter(new makeNegative); | 275 | // if (bNegative) filt->addfilter(new makeNegative); |
277 | if (bInverse) filt->addfilter(new makeInverse); | 276 | if (bInverse) filt->addfilter(new makeInverse); |
278 | return filt; | 277 | return filt; |
279 | } | 278 | } |
280 | 279 | ||
281 | 280 | ||
282 | private slots: | 281 | private slots: |
283 | void dopageup(); | 282 | void dopageup(); |
284 | void lineDown(); | 283 | void lineDown(); |
285 | void lineUp(); | 284 | void lineUp(); |
286 | void dopagedn(); | 285 | void dopagedn(); |
287 | void goHome(); | 286 | void goHome(); |
288 | void goBack(); | 287 | void goBack(); |
289 | void goForward(); | 288 | void goForward(); |
290 | void doscroll(); | 289 | void doscroll(); |
291 | void paintEvent( QPaintEvent * ); | 290 | void paintEvent( QPaintEvent * ); |
292 | #ifdef DOUBLEBUFFER | 291 | #ifdef DOUBLEBUFFER |
293 | void resizeEvent( QResizeEvent * p ); | 292 | void resizeEvent( QResizeEvent * p ); |
294 | #endif | 293 | #endif |
295 | void keyPressEvent(QKeyEvent*); | 294 | void keyPressEvent(QKeyEvent*); |
296 | private: | 295 | private: |
297 | // void drawIt( QPainter * ); | 296 | // void drawIt( QPainter * ); |
298 | void redrawall(); | 297 | void redrawall(); |
299 | void drawFonts(); | 298 | void drawFonts(); |
300 | void DrawStraight(QPainter* p, int w, int h); | 299 | void DrawStraight(QPainter* p, int w, int h); |
301 | QColor m_scrollcolor, m_scrollbarcolor; | 300 | QColor m_scrollcolor, m_scrollbarcolor; |
302 | void setTwoTouch(bool _b); | 301 | void setTwoTouch(bool _b); |
303 | void init(); | 302 | void init(); |
304 | void mousePressEvent( QMouseEvent* ); | 303 | void mousePressEvent( QMouseEvent* ); |
305 | void mouseReleaseEvent( QMouseEvent* ); | 304 | void mouseReleaseEvent( QMouseEvent* ); |
306 | // void mouseDoubleClickEvent( QMouseEvent* ); | 305 | // void mouseDoubleClickEvent( QMouseEvent* ); |
307 | QString m_string, m_fontname, m_reparastring; | 306 | QString m_string, m_fontname, m_reparastring; |
308 | void setfont(); | 307 | void setfont(); |
309 | //myoutput stuff | 308 | //myoutput stuff |
310 | private: | 309 | private: |
311 | #ifdef SPECIALSCROLL | 310 | #ifdef SPECIALSCROLL |
312 | int m_scrolldy; | 311 | int m_scrolldy; |
313 | #endif | 312 | #endif |
314 | bool mouseUpOn; | 313 | bool mouseUpOn; |
315 | 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*&); | 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*&); |
316 | bool m_twotouch, m_touchone; | 315 | bool m_twotouch, m_touchone; |
317 | size_t m_startpos, m_startoffset; | 316 | size_t m_startpos, m_startoffset; |
318 | void dopageup(unsigned int); | 317 | void dopageup(unsigned int); |
319 | long real_delay(); | 318 | long real_delay(); |
320 | int m_textsize; | 319 | int m_textsize; |
321 | int m_lastwidth, m_lastheight; | 320 | int m_lastwidth, m_lastheight; |
322 | CBufferFace<CDrawBuffer*> textarray; | 321 | CBufferFace<CDrawBuffer*> textarray; |
323 | CBufferFace<size_t> locnarray; | 322 | CBufferFace<size_t> locnarray; |
324 | unsigned int numlines; | 323 | unsigned int numlines; |
325 | // bool m_showlast; | 324 | // bool m_showlast; |
326 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust, /*bNegative,*/ bInverse; | 325 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust, /*bNegative,*/ bInverse; |
327 | bool bkern, brepalm; | 326 | bool bkern, brepalm; |
328 | bool m_bpagemode, m_bMonoSpaced, m_continuousDocument; | 327 | bool m_bpagemode, m_bMonoSpaced, m_continuousDocument; |
329 | unsigned char bindenter; | 328 | unsigned char bindenter; |
330 | QString m_lastfile; | 329 | QString m_lastfile; |
331 | size_t m_lastposn; | 330 | size_t m_lastposn; |
332 | bool bDoUpdates; | 331 | bool bDoUpdates; |
333 | public: | 332 | public: |
334 | void setDoUpdates(bool b) { bDoUpdates = b; } | 333 | void setDoUpdates(bool b) { bDoUpdates = b; } |
335 | void setStripCR(bool b) { bstripcr = b; } | 334 | void setStripCR(bool b) { bstripcr = b; } |
336 | void NavUp(); | 335 | void NavUp(); |
337 | void NavDown(); | 336 | void NavDown(); |
338 | tchar getch() { return buffdoc.getch(); } | 337 | tchar getch() { return buffdoc.getch(); } |
339 | bool synch(size_t, size_t); | 338 | bool synch(size_t, size_t); |
340 | bool tight; | 339 | bool tight; |
341 | bool load_file(const char *newfile, unsigned int lcn=0); | 340 | bool load_file(const char *newfile, unsigned int lcn=0); |
342 | BuffDoc buffdoc; | 341 | BuffDoc buffdoc; |
343 | CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } | 342 | CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } |
344 | bool locate(unsigned long n); | 343 | bool locate(unsigned long n); |
345 | void jumpto(unsigned long n) { buffdoc.locate(n); } | 344 | void jumpto(unsigned long n) { buffdoc.locate(n); } |
346 | unsigned long locate() { return buffdoc.locate(); } | 345 | unsigned long locate() { return buffdoc.locate(); } |
347 | unsigned long explocate() { return buffdoc.explocate(); } | 346 | unsigned long explocate() { return buffdoc.explocate(); } |
348 | unsigned long pagelocate() { return locnarray[0]; } | 347 | unsigned long pagelocate() { return locnarray[0]; } |
349 | unsigned long mylastpos; | 348 | unsigned long mylastpos; |
350 | void getNextLink(); | 349 | void getNextLink(); |
351 | void setfilter(CFilterChain *f) { buffdoc.setfilter(f); if (bDoUpdates) locate(pagelocate()); } | 350 | void setfilter(CFilterChain *f) { buffdoc.setfilter(f); if (bDoUpdates) locate(pagelocate()); } |
352 | void restore() { jumpto(mylastpos); } | 351 | void restore() { jumpto(mylastpos); } |
353 | void goUp(); | 352 | void goUp(); |
354 | void refresh(bool full = false); | 353 | void refresh(bool full = false); |
355 | void goDown(); | 354 | void goDown(); |
356 | // bool bold; | 355 | // bool bold; |
357 | int textsize() { return m_textsize; } | 356 | int textsize() { return m_textsize; } |
358 | void textsize(int ts) { m_textsize = ts; } | 357 | void textsize(int ts) { m_textsize = ts; } |
359 | bool fillbuffer(int ru = 0, int ht = -1, int newht = -1); | 358 | bool fillbuffer(int ru = 0, int ht = -1, int newht = -1); |
360 | void CalculateScrollParameters(); | 359 | void CalculateScrollParameters(); |
361 | unsigned int screenlines(); | 360 | unsigned int screenlines(); |
362 | void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.sizes(fs,ts); } | 361 | void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.sizes(fs,ts); } |
363 | static const char *fonts[]; | 362 | static const char *fonts[]; |
364 | // unsigned int *fontsizes; | 363 | // unsigned int *fontsizes; |
365 | int m_ascent, m_descent, m_linespacing; | 364 | int m_ascent, m_descent, m_linespacing; |
366 | int m_topmargin, m_bottommargin; | 365 | int m_topmargin, m_bottommargin; |
367 | int m_abstopmargin, m_absbottommargin; | 366 | int m_abstopmargin, m_absbottommargin; |
368 | QFontMetrics* m_fm; | 367 | QFontMetrics* m_fm; |
369 | QString firstword(); | 368 | QString firstword(); |
370 | bool hyphenate; | 369 | bool hyphenate; |
371 | void reset_bg() | 370 | void reset_bg() |
372 | { | 371 | { |
373 | int r,g,b; | 372 | int r,g,b; |
374 | m_default_bg.rgb(&r, &g, &b); | 373 | m_default_bg.rgb(&r, &g, &b); |
375 | if (bInverse) | 374 | if (bInverse) |
376 | { | 375 | { |
377 | r = 255-r; | 376 | r = 255-r; |
378 | g = 255-g; | 377 | g = 255-g; |
379 | b = 255-b; | 378 | b = 255-b; |
380 | } | 379 | } |
381 | m_bg.setRgb(r,g,b); | 380 | m_bg.setRgb(r,g,b); |
382 | /* | 381 | /* |
383 | int h,s,v; | 382 | int h,s,v; |
384 | m_bg.hsv(&h, &s, &v); | 383 | m_bg.hsv(&h, &s, &v); |
385 | if (bNegative) | 384 | if (bNegative) |
386 | { | 385 | { |
387 | v = 255-v; | 386 | v = 255-v; |
388 | m_bg.setHsv(h,s,v); | 387 | m_bg.setHsv(h,s,v); |
389 | } | 388 | } |
390 | */ | 389 | */ |
391 | setBackgroundColor( m_bg ); | 390 | setBackgroundColor( m_bg ); |
392 | } | 391 | } |
393 | void setInverse(bool b) | 392 | void setInverse(bool b) |
394 | { | 393 | { |
395 | bInverse = b; | 394 | bInverse = b; |
396 | reset_bg(); | 395 | reset_bg(); |
397 | } | 396 | } |
398 | /* | 397 | /* |
399 | void setNegative() | 398 | void setNegative() |
400 | { | 399 | { |
401 | bNegative = !bNegative; | 400 | bNegative = !bNegative; |
402 | reset_bg(); | 401 | reset_bg(); |
403 | } | 402 | } |
404 | */ | 403 | */ |
405 | signals: | 404 | signals: |
406 | void OnRedraw(); | 405 | void OnRedraw(); |
407 | void OnWordSelected(const QString&, size_t, size_t, const QString&); | 406 | void OnWordSelected(const QString&, size_t, size_t, const QString&); |
408 | void OnShowPicture(QImage&); | 407 | void OnShowPicture(QImage&); |
409 | void OnURLSelected(const QString&, const size_t); | 408 | void OnURLSelected(const QString&, const size_t); |
410 | void NewFileRequest(const QString&); | 409 | void NewFileRequest(const QString&); |
411 | void HandleKeyRequest(QKeyEvent*); | 410 | void HandleKeyRequest(QKeyEvent*); |
412 | void SetScrollState(bool); | 411 | void SetScrollState(bool); |
413 | void RefreshBitmap(); | 412 | void RefreshBitmap(); |
414 | }; | 413 | }; |
415 | 414 | ||
416 | #endif | 415 | #endif |
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index ec7a29c..876b65a 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -1,4965 +1,4963 @@ | |||
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 | #include "useqpe.h" | ||
21 | #include <qregexp.h> | 20 | #include <qregexp.h> |
22 | #include <qclipboard.h> | 21 | #include <qclipboard.h> |
23 | #include <qwidgetstack.h> | 22 | #include <qwidgetstack.h> |
24 | #ifdef USEQPE | 23 | #ifdef USEQPE |
25 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
26 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
27 | #endif | 26 | #endif |
28 | #include <qmenubar.h> | 27 | #include <qmenubar.h> |
29 | #include <qtoolbar.h> | 28 | #include <qtoolbar.h> |
30 | #ifdef USEQPE | 29 | #ifdef USEQPE |
31 | #include <qpe/menubutton.h> | 30 | #include <qpe/menubutton.h> |
32 | #endif | 31 | #endif |
33 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
34 | #include <qpopupmenu.h> | 33 | #include <qpopupmenu.h> |
35 | #include <qaction.h> | 34 | #include <qaction.h> |
36 | #include <qapplication.h> | 35 | #include <qapplication.h> |
37 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
38 | #include <qtoolbutton.h> | 37 | #include <qtoolbutton.h> |
39 | #include <qspinbox.h> | 38 | #include <qspinbox.h> |
40 | #include <qobjectlist.h> | 39 | #include <qobjectlist.h> |
41 | #include <qstatusbar.h> | 40 | #include <qstatusbar.h> |
42 | #ifdef USEQPE | 41 | #ifdef USEQPE |
43 | #include <qpe/global.h> | 42 | #include <qpe/global.h> |
44 | #include <qpe/applnk.h> | 43 | #include <qpe/applnk.h> |
45 | #endif | 44 | #endif |
46 | #include <qfileinfo.h> | 45 | #include <qfileinfo.h> |
47 | #include <stdlib.h> //getenv | 46 | #include <stdlib.h> //getenv |
48 | #include <qprogressbar.h> | 47 | #include <qprogressbar.h> |
49 | #ifdef USEQPE | 48 | #ifdef USEQPE |
50 | #include <qpe/config.h> | 49 | #include <qpe/config.h> |
51 | #endif | 50 | #endif |
52 | #include <qbuttongroup.h> | 51 | #include <qbuttongroup.h> |
53 | #include <qradiobutton.h> | 52 | #include <qradiobutton.h> |
54 | #ifdef USEQPE | 53 | #ifdef USEQPE |
55 | #include <qpe/qcopenvelope_qws.h> | 54 | #include <qpe/qcopenvelope_qws.h> |
56 | #endif | 55 | #endif |
57 | #include "QTReader.h" | 56 | #include "QTReader.h" |
58 | #include "GraphicWin.h" | 57 | #include "GraphicWin.h" |
59 | #include "Bkmks.h" | 58 | #include "Bkmks.h" |
60 | #include "cbkmkselector.h" | 59 | #include "cbkmkselector.h" |
61 | #include "infowin.h" | 60 | #include "infowin.h" |
62 | #include "ToolbarPrefs.h" | 61 | #include "ToolbarPrefs.h" |
63 | #include "Prefs.h" | 62 | #include "Prefs.h" |
64 | #include "CAnnoEdit.h" | 63 | #include "CAnnoEdit.h" |
65 | #include "QFloatBar.h" | 64 | #include "QFloatBar.h" |
66 | #include "FixedFont.h" | 65 | #include "FixedFont.h" |
67 | #include "URLDialog.h" | 66 | #include "URLDialog.h" |
68 | #include "util.h" | 67 | #include "util.h" |
69 | #include <qfontdatabase.h> | 68 | #include <qfontdatabase.h> |
70 | #ifdef USEQPE | 69 | #ifdef USEQPE |
71 | #include <qpe/resource.h> | 70 | #include <qpe/resource.h> |
72 | #ifdef OPIE | 71 | #ifdef OPIE |
73 | //#include <qpe/applnk.h> | 72 | //#include <qpe/applnk.h> |
74 | #include <opie2/ofiledialog.h> | 73 | #include <opie2/ofiledialog.h> |
75 | using namespace Opie::Ui; | 74 | using namespace Opie::Ui; |
76 | #else | 75 | #else |
77 | #include "fileBrowser.h" | 76 | #include "fileBrowser.h" |
78 | #endif | 77 | #endif |
79 | #else | 78 | #else |
80 | #include "qfiledialog.h" | 79 | #include "qfiledialog.h" |
81 | #endif | 80 | #endif |
82 | 81 | ||
83 | #include "QTReaderApp.h" | 82 | #include "QTReaderApp.h" |
84 | #include "CDrawBuffer.h" | 83 | #include "CDrawBuffer.h" |
85 | #include "Filedata.h" | 84 | #include "Filedata.h" |
86 | #include "useqpe.h" | ||
87 | #include "names.h" | 85 | #include "names.h" |
88 | #include "CEncoding_tables.h" | 86 | #include "CEncoding_tables.h" |
89 | #include "CloseDialog.h" | 87 | #include "CloseDialog.h" |
90 | 88 | ||
91 | #include "ButtonPrefs.h" | 89 | #include "ButtonPrefs.h" |
92 | 90 | ||
93 | bool CheckVersion(int&, int&, char&); | 91 | bool CheckVersion(int&, int&, char&); |
94 | 92 | ||
95 | #ifdef _WINDOWS | 93 | #ifdef _WINDOWS |
96 | #define PICDIR "c:\\uqtreader\\pics\\" | 94 | #define PICDIR "c:\\uqtreader\\pics\\" |
97 | #else | 95 | #else |
98 | #ifdef USEQPE | 96 | #ifdef USEQPE |
99 | #define USEMSGS | 97 | #define USEMSGS |
100 | #define PICDIR "opie-reader/" | 98 | #define PICDIR "opie-reader/" |
101 | #else | 99 | #else |
102 | //#define PICDIR "/home/tim/uqtreader/pics/" | 100 | //#define PICDIR "/home/tim/uqtreader/pics/" |
103 | QString picdir() | 101 | QString picdir() |
104 | { | 102 | { |
105 | QString hd(getenv("READERDIR")); | 103 | QString hd(getenv("READERDIR")); |
106 | return hd + "/pics"; | 104 | return hd + "/pics"; |
107 | } | 105 | } |
108 | #define PICDIR picdir() | 106 | #define PICDIR picdir() |
109 | #endif | 107 | #endif |
110 | #endif | 108 | #endif |
111 | 109 | ||
112 | unsigned long QTReaderApp::m_uid = 0; | 110 | unsigned long QTReaderApp::m_uid = 0; |
113 | 111 | ||
114 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } | 112 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } |
115 | 113 | ||
116 | #ifdef USEQPE | 114 | #ifdef USEQPE |
117 | #define geticon(iconname) Resource::loadPixmap( iconname ) | 115 | #define geticon(iconname) Resource::loadPixmap( iconname ) |
118 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) | 116 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) |
119 | #else | 117 | #else |
120 | //#define geticon(iconname) QPixmap(PICDIR iconname ".png") | 118 | //#define geticon(iconname) QPixmap(PICDIR iconname ".png") |
121 | #define geticon(iconname) QPixmap(PICDIR +"/"+iconname+".png") | 119 | #define geticon(iconname) QPixmap(PICDIR +"/"+iconname+".png") |
122 | #define getmyicon(iconname) geticon(iconname) | 120 | #define getmyicon(iconname) geticon(iconname) |
123 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) | 121 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) |
124 | #endif | 122 | #endif |
125 | 123 | ||
126 | #ifndef _WINDOWS | 124 | #ifndef _WINDOWS |
127 | #include <unistd.h> | 125 | #include <unistd.h> |
128 | #endif | 126 | #endif |
129 | #include <stddef.h> | 127 | #include <stddef.h> |
130 | #ifndef _WINDOWS | 128 | #ifndef _WINDOWS |
131 | #include <dirent.h> | 129 | #include <dirent.h> |
132 | #endif | 130 | #endif |
133 | 131 | ||
134 | void QTReaderApp::listBkmkFiles() | 132 | void QTReaderApp::listBkmkFiles() |
135 | { | 133 | { |
136 | bkmkselector->clear(); | 134 | bkmkselector->clear(); |
137 | bkmkselector->setText("Cancel"); | 135 | bkmkselector->setText("Cancel"); |
138 | #ifndef USEQPE | 136 | #ifndef USEQPE |
139 | int cnt = 0; | 137 | int cnt = 0; |
140 | 138 | ||
141 | QDir d = QDir::home(); // "/" | 139 | QDir d = QDir::home(); // "/" |
142 | if ( !d.cd(APPDIR) ) { // "/tmp" | 140 | if ( !d.cd(APPDIR) ) { // "/tmp" |
143 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 141 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
144 | d = QDir::home(); | 142 | d = QDir::home(); |
145 | d.mkdir(APPDIR); | 143 | d.mkdir(APPDIR); |
146 | d.cd(APPDIR); | 144 | d.cd(APPDIR); |
147 | } | 145 | } |
148 | 146 | ||
149 | 147 | ||
150 | 148 | ||
151 | 149 | ||
152 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 150 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
153 | // d.setSorting( QDir::Size | QDir::Reversed ); | 151 | // d.setSorting( QDir::Size | QDir::Reversed ); |
154 | 152 | ||
155 | const QFileInfoList *list = d.entryInfoList(); | 153 | const QFileInfoList *list = d.entryInfoList(); |
156 | QFileInfoListIterator it( *list ); // create list iterator | 154 | QFileInfoListIterator it( *list ); // create list iterator |
157 | QFileInfo *fi; // pointer for traversing | 155 | QFileInfo *fi; // pointer for traversing |
158 | 156 | ||
159 | while ( (fi=it.current()) ) { // for each file... | 157 | while ( (fi=it.current()) ) { // for each file... |
160 | 158 | ||
161 | bkmkselector->insertItem(fi->fileName()); | 159 | bkmkselector->insertItem(fi->fileName()); |
162 | cnt++; | 160 | cnt++; |
163 | 161 | ||
164 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | 162 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); |
165 | ++it; // goto next list element | 163 | ++it; // goto next list element |
166 | } | 164 | } |
167 | 165 | ||
168 | #else /* USEQPE */ | 166 | #else /* USEQPE */ |
169 | int cnt = 0; | 167 | int cnt = 0; |
170 | DIR *d; | 168 | DIR *d; |
171 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); | 169 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); |
172 | 170 | ||
173 | while(1) | 171 | while(1) |
174 | { | 172 | { |
175 | struct dirent* de; | 173 | struct dirent* de; |
176 | struct stat buf; | 174 | struct stat buf; |
177 | de = readdir(d); | 175 | de = readdir(d); |
178 | if (de == NULL) break; | 176 | if (de == NULL) break; |
179 | 177 | ||
180 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 178 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) |
181 | { | 179 | { |
182 | bkmkselector->insertItem(de->d_name); | 180 | bkmkselector->insertItem(de->d_name); |
183 | cnt++; | 181 | cnt++; |
184 | } | 182 | } |
185 | } | 183 | } |
186 | 184 | ||
187 | closedir(d); | 185 | closedir(d); |
188 | #endif | 186 | #endif |
189 | if (cnt > 0) | 187 | if (cnt > 0) |
190 | { | 188 | { |
191 | //tjw menu->hide(); | 189 | //tjw menu->hide(); |
192 | 190 | ||
193 | 191 | ||
194 | editorStack->raiseWidget( bkmkselector ); | 192 | editorStack->raiseWidget( bkmkselector ); |
195 | hidetoolbars(); | 193 | hidetoolbars(); |
196 | m_nBkmkAction = cRmBkmkFile; | 194 | m_nBkmkAction = cRmBkmkFile; |
197 | } | 195 | } |
198 | else | 196 | else |
199 | QMessageBox::information(this, PROGNAME, "No bookmark files"); | 197 | QMessageBox::information(this, PROGNAME, "No bookmark files"); |
200 | } | 198 | } |
201 | 199 | ||
202 | void QTReaderApp::hidetoolbars() | 200 | void QTReaderApp::hidetoolbars() |
203 | { | 201 | { |
204 | if (m_scrollbar != NULL) m_scrollbar->hide(); | 202 | if (m_scrollbar != NULL) m_scrollbar->hide(); |
205 | if (m_prog != NULL) m_prog->hide(); | 203 | if (m_prog != NULL) m_prog->hide(); |
206 | 204 | ||
207 | #ifdef USEQPE | 205 | #ifdef USEQPE |
208 | menubar->hide(); | 206 | menubar->hide(); |
209 | #endif | 207 | #endif |
210 | 208 | ||
211 | if (m_scrollbar != NULL) m_scrollbar->hide(); | 209 | if (m_scrollbar != NULL) m_scrollbar->hide(); |
212 | 210 | ||
213 | if (fileBar != NULL) fileBar->hide(); | 211 | if (fileBar != NULL) fileBar->hide(); |
214 | if (viewBar != NULL) viewBar->hide(); | 212 | if (viewBar != NULL) viewBar->hide(); |
215 | if (navBar != NULL) navBar->hide(); | 213 | if (navBar != NULL) navBar->hide(); |
216 | if (markBar != NULL) markBar->hide(); | 214 | if (markBar != NULL) markBar->hide(); |
217 | if (m_fontVisible) m_fontBar->hide(); | 215 | if (m_fontVisible) m_fontBar->hide(); |
218 | if (regVisible) | 216 | if (regVisible) |
219 | { | 217 | { |
220 | #ifdef USEQPE | 218 | #ifdef USEQPE |
221 | Global::hideInputMethod(); | 219 | Global::hideInputMethod(); |
222 | #endif | 220 | #endif |
223 | regBar->hide(); | 221 | regBar->hide(); |
224 | } | 222 | } |
225 | if (searchVisible) | 223 | if (searchVisible) |
226 | { | 224 | { |
227 | #ifdef USEQPE | 225 | #ifdef USEQPE |
228 | Global::hideInputMethod(); | 226 | Global::hideInputMethod(); |
229 | #endif | 227 | #endif |
230 | searchBar->hide(); | 228 | searchBar->hide(); |
231 | } | 229 | } |
232 | } | 230 | } |
233 | 231 | ||
234 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | 232 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) |
235 | : QMainWindow( parent, name, f ), m_dontSave(false), | 233 | : QMainWindow( parent, name, f ), m_dontSave(false), |
236 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL), m_scrollbar(NULL), m_localscroll(2), m_hidebars(false), m_kmapchanged(false) | 234 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL), m_scrollbar(NULL), m_localscroll(2), m_hidebars(false), m_kmapchanged(false) |
237 | { | 235 | { |
238 | { | 236 | { |
239 | setKeyCompression ( true ); | 237 | setKeyCompression ( true ); |
240 | #ifndef USEQPE | 238 | #ifndef USEQPE |
241 | QDir d = QDir::home(); // "/" | 239 | QDir d = QDir::home(); // "/" |
242 | d.cd(APPDIR); | 240 | d.cd(APPDIR); |
243 | QFileInfo fi(d, ".keymap"); | 241 | QFileInfo fi(d, ".keymap"); |
244 | FILE* f = fopen((const char *)fi.absFilePath(), "r"); | 242 | FILE* f = fopen((const char *)fi.absFilePath(), "r"); |
245 | #else /* USEQPE */ | 243 | #else /* USEQPE */ |
246 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "r"); | 244 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "r"); |
247 | #endif /* USEQPE */ | 245 | #endif /* USEQPE */ |
248 | if (f != NULL) | 246 | if (f != NULL) |
249 | { | 247 | { |
250 | uint cnt; | 248 | uint cnt; |
251 | if ((fread(&cnt, sizeof(cnt), 1, f) != 0) && (cnt == KEYMAPVERSION)) | 249 | if ((fread(&cnt, sizeof(cnt), 1, f) != 0) && (cnt == KEYMAPVERSION)) |
252 | { | 250 | { |
253 | if (fread(&cnt, sizeof(cnt), 1, f) == 0) cnt = 0; | 251 | if (fread(&cnt, sizeof(cnt), 1, f) == 0) cnt = 0; |
254 | for (uint i = 0; i != cnt; i++) | 252 | for (uint i = 0; i != cnt; i++) |
255 | { | 253 | { |
256 | orKey key; | 254 | orKey key; |
257 | int data; | 255 | int data; |
258 | fread(&key, sizeof(key), 1, f); | 256 | fread(&key, sizeof(key), 1, f); |
259 | fread(&data, sizeof(data), 1, f); | 257 | fread(&data, sizeof(data), 1, f); |
260 | kmap[key] = data; | 258 | kmap[key] = data; |
261 | } | 259 | } |
262 | } | 260 | } |
263 | fclose(f); | 261 | fclose(f); |
264 | } | 262 | } |
265 | } | 263 | } |
266 | 264 | ||
267 | m_url_clipboard = false; | 265 | m_url_clipboard = false; |
268 | m_url_localfile = false; | 266 | m_url_localfile = false; |
269 | m_url_globalfile = false; | 267 | m_url_globalfile = false; |
270 | ftime(&m_lastkeytime); | 268 | ftime(&m_lastkeytime); |
271 | //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); | 269 | //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); |
272 | //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); | 270 | //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); |
273 | 271 | ||
274 | m_bcloseDisabled = true; | 272 | m_bcloseDisabled = true; |
275 | m_disableesckey = false; | 273 | m_disableesckey = false; |
276 | pBkmklist = NULL; | 274 | pBkmklist = NULL; |
277 | pOpenlist = NULL; | 275 | pOpenlist = NULL; |
278 | // doc = 0; | 276 | // doc = 0; |
279 | 277 | ||
280 | m_fBkmksChanged = false; | 278 | m_fBkmksChanged = false; |
281 | 279 | ||
282 | QString lang = getenv( "LANG" ); | 280 | QString lang = getenv( "LANG" ); |
283 | QString rot = getenv( "QWS_DISPLAY" ); | 281 | QString rot = getenv( "QWS_DISPLAY" ); |
284 | 282 | ||
285 | /* | 283 | /* |
286 | int m_rot = 0; | 284 | int m_rot = 0; |
287 | if (rot.contains("Rot90")) | 285 | if (rot.contains("Rot90")) |
288 | { | 286 | { |
289 | m_rot = 90; | 287 | m_rot = 90; |
290 | } | 288 | } |
291 | else if (rot.contains("Rot180")) | 289 | else if (rot.contains("Rot180")) |
292 | { | 290 | { |
293 | m_rot = 180; | 291 | m_rot = 180; |
294 | } | 292 | } |
295 | else if (rot.contains("Rot270")) | 293 | else if (rot.contains("Rot270")) |
296 | { | 294 | { |
297 | m_rot = 270; | 295 | m_rot = 270; |
298 | } | 296 | } |
299 | 297 | ||
300 | // qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); | 298 | // qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); |
301 | */ | 299 | */ |
302 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; | 300 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; |
303 | 301 | ||
304 | #ifdef USEQPE | 302 | #ifdef USEQPE |
305 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); | 303 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); |
306 | #else | 304 | #else |
307 | setIcon( QPixmap (PICDIR + "/uqtreader.png") ); | 305 | setIcon( QPixmap (PICDIR + "/uqtreader.png") ); |
308 | #endif /* USEQPE */ | 306 | #endif /* USEQPE */ |
309 | 307 | ||
310 | // QPEToolBar *bar = new QPEToolBar( this ); | 308 | // QPEToolBar *bar = new QPEToolBar( this ); |
311 | // menubar = new QPEToolBar( this ); | 309 | // menubar = new QPEToolBar( this ); |
312 | #ifdef USEQPE | 310 | #ifdef USEQPE |
313 | Config config( APPDIR ); | 311 | Config config( APPDIR ); |
314 | #else | 312 | #else |
315 | QDir d = QDir::home(); // "/" | 313 | QDir d = QDir::home(); // "/" |
316 | if ( !d.cd(APPDIR) ) { // "/tmp" | 314 | if ( !d.cd(APPDIR) ) { // "/tmp" |
317 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 315 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
318 | d = QDir::home(); | 316 | d = QDir::home(); |
319 | d.mkdir(APPDIR); | 317 | d.mkdir(APPDIR); |
320 | d.cd(APPDIR); | 318 | d.cd(APPDIR); |
321 | } | 319 | } |
322 | QFileInfo fi(d, INIFILE); | 320 | QFileInfo fi(d, INIFILE); |
323 | // qDebug("Path:%s", (const char*)fi.absFilePath()); | 321 | // qDebug("Path:%s", (const char*)fi.absFilePath()); |
324 | Config config(fi.absFilePath()); | 322 | Config config(fi.absFilePath()); |
325 | #endif | 323 | #endif |
326 | config.setGroup("Toolbar"); | 324 | config.setGroup("Toolbar"); |
327 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); | 325 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); |
328 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); | 326 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); |
329 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | 327 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); |
330 | m_qtscroll = config.readNumEntry("QTScrollBar", false); | 328 | m_qtscroll = config.readNumEntry("QTScrollBar", false); |
331 | m_localscroll = config.readNumEntry("LocalScrollBar", false); | 329 | m_localscroll = config.readNumEntry("LocalScrollBar", false); |
332 | 330 | ||
333 | // fileBar = new QToolBar("File", this); | 331 | // fileBar = new QToolBar("File", this); |
334 | // QToolBar* viewBar = new QToolBar("File", this); | 332 | // QToolBar* viewBar = new QToolBar("File", this); |
335 | // QToolBar* navBar = new QToolBar("File", this); | 333 | // QToolBar* navBar = new QToolBar("File", this); |
336 | // QToolBar* markBar = new QToolBar("File", this); | 334 | // QToolBar* markBar = new QToolBar("File", this); |
337 | 335 | ||
338 | #ifdef USEQPE | 336 | #ifdef USEQPE |
339 | menubar = new QToolBar("Menus", this, m_tbposition); | 337 | menubar = new QToolBar("Menus", this, m_tbposition); |
340 | mb = new QPEMenuBar( menubar ); | 338 | mb = new QPEMenuBar( menubar ); |
341 | #else | 339 | #else |
342 | mb = new QMenuBar( this ); | 340 | mb = new QMenuBar( this ); |
343 | #endif | 341 | #endif |
344 | 342 | ||
345 | #ifdef USEQPE | 343 | #ifdef USEQPE |
346 | QPopupMenu* tmp = new QPopupMenu(mb); | 344 | QPopupMenu* tmp = new QPopupMenu(mb); |
347 | mb->insertItem( geticon( "AppsIcon" ), tmp ); | 345 | mb->insertItem( geticon( "AppsIcon" ), tmp ); |
348 | #else | 346 | #else |
349 | QMenuBar* tmp = mb; | 347 | QMenuBar* tmp = mb; |
350 | #endif | 348 | #endif |
351 | 349 | ||
352 | QPopupMenu *file = new QPopupMenu( mb ); | 350 | QPopupMenu *file = new QPopupMenu( mb ); |
353 | tmp->insertItem( tr( "File" ), file ); | 351 | tmp->insertItem( tr( "File" ), file ); |
354 | 352 | ||
355 | QPopupMenu *navigation = new QPopupMenu(mb); | 353 | QPopupMenu *navigation = new QPopupMenu(mb); |
356 | tmp->insertItem( tr( "Navigation" ), navigation ); | 354 | tmp->insertItem( tr( "Navigation" ), navigation ); |
357 | 355 | ||
358 | QPopupMenu *view = new QPopupMenu( mb ); | 356 | QPopupMenu *view = new QPopupMenu( mb ); |
359 | tmp->insertItem( tr( "View" ), view ); | 357 | tmp->insertItem( tr( "View" ), view ); |
360 | 358 | ||
361 | QPopupMenu *marks = new QPopupMenu( this ); | 359 | QPopupMenu *marks = new QPopupMenu( this ); |
362 | tmp->insertItem( tr( "Marks" ), marks ); | 360 | tmp->insertItem( tr( "Marks" ), marks ); |
363 | 361 | ||
364 | QPopupMenu *settings = new QPopupMenu( this ); | 362 | QPopupMenu *settings = new QPopupMenu( this ); |
365 | tmp->insertItem( tr( "Settings" ), settings ); | 363 | tmp->insertItem( tr( "Settings" ), settings ); |
366 | 364 | ||
367 | // addToolBar(menubar, "Menus",QMainWindow::Top); | 365 | // addToolBar(menubar, "Menus",QMainWindow::Top); |
368 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); | 366 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); |
369 | 367 | ||
370 | // QPopupMenu *edit = new QPopupMenu( this ); | 368 | // QPopupMenu *edit = new QPopupMenu( this ); |
371 | 369 | ||
372 | /* | 370 | /* |
373 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 371 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
374 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 372 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
375 | a->addTo( bar ); | 373 | a->addTo( bar ); |
376 | a->addTo( file ); | 374 | a->addTo( file ); |
377 | */ | 375 | */ |
378 | QWidget* widge = new QWidget(this); | 376 | QWidget* widge = new QWidget(this); |
379 | setCentralWidget( widge ); | 377 | setCentralWidget( widge ); |
380 | QVBoxLayout* vlayout = new QVBoxLayout(widge); | 378 | QVBoxLayout* vlayout = new QVBoxLayout(widge); |
381 | m_layout = new QBoxLayout(QBoxLayout::LeftToRight); | 379 | m_layout = new QBoxLayout(QBoxLayout::LeftToRight); |
382 | m_prog = new QLabel(widge); | 380 | m_prog = new QLabel(widge); |
383 | vlayout->addLayout(m_layout, 1); | 381 | vlayout->addLayout(m_layout, 1); |
384 | vlayout->addWidget(m_prog); | 382 | vlayout->addWidget(m_prog); |
385 | 383 | ||
386 | editorStack = new QWidgetStack( widge ); | 384 | editorStack = new QWidgetStack( widge ); |
387 | // setCentralWidget( editorStack ); | 385 | // setCentralWidget( editorStack ); |
388 | 386 | ||
389 | searchVisible = FALSE; | 387 | searchVisible = FALSE; |
390 | regVisible = FALSE; | 388 | regVisible = FALSE; |
391 | m_fontVisible = false; | 389 | m_fontVisible = false; |
392 | 390 | ||
393 | m_buttonprefs = new CButtonPrefs(&kmap, this); | 391 | m_buttonprefs = new CButtonPrefs(&kmap, this); |
394 | editorStack->addWidget(m_buttonprefs, get_unique_id()); | 392 | editorStack->addWidget(m_buttonprefs, get_unique_id()); |
395 | connect( m_buttonprefs, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); | 393 | connect( m_buttonprefs, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); |
396 | 394 | ||
397 | 395 | ||
398 | m_annoWin = new CAnnoEdit(editorStack); | 396 | m_annoWin = new CAnnoEdit(editorStack); |
399 | editorStack->addWidget(m_annoWin, get_unique_id()); | 397 | editorStack->addWidget(m_annoWin, get_unique_id()); |
400 | connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); | 398 | connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); |
401 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); | 399 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); |
402 | 400 | ||
403 | m_infoWin = new infowin(editorStack); | 401 | m_infoWin = new infowin(editorStack); |
404 | editorStack->addWidget(m_infoWin, get_unique_id()); | 402 | editorStack->addWidget(m_infoWin, get_unique_id()); |
405 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); | 403 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); |
406 | 404 | ||
407 | m_graphicwin = new GraphicWin(editorStack); | 405 | m_graphicwin = new GraphicWin(editorStack); |
408 | editorStack->addWidget(m_graphicwin, get_unique_id()); | 406 | editorStack->addWidget(m_graphicwin, get_unique_id()); |
409 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); | 407 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); |
410 | 408 | ||
411 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); | 409 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); |
412 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); | 410 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); |
413 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); | 411 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); |
414 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); | 412 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); |
415 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); | 413 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); |
416 | editorStack->addWidget( bkmkselector, get_unique_id() ); | 414 | editorStack->addWidget( bkmkselector, get_unique_id() ); |
417 | 415 | ||
418 | /* | 416 | /* |
419 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); | 417 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); |
420 | connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); | 418 | connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); |
421 | 419 | ||
422 | editorStack->addWidget( importSelector, get_unique_id() ); | 420 | editorStack->addWidget( importSelector, get_unique_id() ); |
423 | 421 | ||
424 | // don't need the close visible, it is redundant... | 422 | // don't need the close visible, it is redundant... |
425 | importSelector->setCloseVisible( FALSE ); | 423 | importSelector->setCloseVisible( FALSE ); |
426 | */ | 424 | */ |
427 | // qDebug("Reading file list"); | 425 | // qDebug("Reading file list"); |
428 | readfilelist(); | 426 | readfilelist(); |
429 | 427 | ||
430 | reader = new QTReader( editorStack ); | 428 | reader = new QTReader( editorStack ); |
431 | 429 | ||
432 | reader->setDoUpdates(false); | 430 | reader->setDoUpdates(false); |
433 | 431 | ||
434 | #ifdef USEQPE | 432 | #ifdef USEQPE |
435 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); | 433 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); |
436 | #endif | 434 | #endif |
437 | 435 | ||
438 | // qDebug("Reading config"); | 436 | // qDebug("Reading config"); |
439 | // Config config( APPDIR ); | 437 | // Config config( APPDIR ); |
440 | config.setGroup( "View" ); | 438 | config.setGroup( "View" ); |
441 | m_debounce = config.readNumEntry("Debounce", 0); | 439 | m_debounce = config.readNumEntry("Debounce", 0); |
442 | m_buttonprefs->Debounce(m_debounce); | 440 | m_buttonprefs->Debounce(m_debounce); |
443 | #ifdef USEQPE | 441 | #ifdef USEQPE |
444 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); | 442 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); |
445 | #else | 443 | #else |
446 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); | 444 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); |
447 | #endif | 445 | #endif |
448 | reader->setStripCR(config.readBoolEntry( "StripCr", true )); | 446 | reader->setStripCR(config.readBoolEntry( "StripCr", true )); |
449 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | 447 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); |
450 | /* | 448 | /* |
451 | bool btmp = config.readBoolEntry("Negative", false); | 449 | bool btmp = config.readBoolEntry("Negative", false); |
452 | if (btmp) reader->setNegative(); | 450 | if (btmp) reader->setNegative(); |
453 | */ | 451 | */ |
454 | reader->bInverse = config.readBoolEntry("Inverse", false); | 452 | reader->bInverse = config.readBoolEntry("Inverse", false); |
455 | reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", false )); | 453 | reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", false )); |
456 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); | 454 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); |
457 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); | 455 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); |
458 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | 456 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); |
459 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | 457 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); |
460 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | 458 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); |
461 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 459 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); |
462 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 460 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
463 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | 461 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); |
464 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); | 462 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); |
465 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | 463 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); |
466 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 464 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
467 | reader->brepara = config.readBoolEntry( "Repara", false ); | 465 | reader->brepara = config.readBoolEntry( "Repara", false ); |
468 | reader->m_reparastring = config.readEntry( "ReparaString", "\\n{[\\n \\t]}"); | 466 | reader->m_reparastring = config.readEntry( "ReparaString", "\\n{[\\n \\t]}"); |
469 | m_bgtype = (bground)config.readNumEntry( "BackgroundType" , 0 ); | 467 | m_bgtype = (bground)config.readNumEntry( "BackgroundType" , 0 ); |
470 | m_themename = config.readEntry("Theme", QString::null ); | 468 | m_themename = config.readEntry("Theme", QString::null ); |
471 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | 469 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); |
472 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | 470 | reader->bindenter = config.readNumEntry( "Indent", 0 ); |
473 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | 471 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); |
474 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | 472 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); |
475 | reader->m_scrollstep = config.readNumEntry( "ScrollStep", 1); | 473 | reader->m_scrollstep = config.readNumEntry( "ScrollStep", 1); |
476 | 474 | ||
477 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | 475 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); |
478 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 476 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
479 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 477 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
480 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 478 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); |
481 | reader->m_rotated = config.readBoolEntry( "IsRotated", false ); | 479 | reader->m_rotated = config.readBoolEntry( "IsRotated", false ); |
482 | reader->m_scrolltype = config.readNumEntry( "ScrollType", 0 ); | 480 | reader->m_scrolltype = config.readNumEntry( "ScrollType", 0 ); |
483 | m_statusstring = config.readEntry("StatusContent", "%P%% Doc:%d/%D %p%% %z%%"); | 481 | m_statusstring = config.readEntry("StatusContent", "%P%% Doc:%d/%D %p%% %z%%"); |
484 | m_statusishidden = config.readBoolEntry("StatusHidden", false); | 482 | m_statusishidden = config.readBoolEntry("StatusHidden", false); |
485 | m_background = config.readNumEntry( "Background", 0 ); | 483 | m_background = config.readNumEntry( "Background", 0 ); |
486 | reader->setBackground(getcolour(m_background)); | 484 | reader->setBackground(getcolour(m_background)); |
487 | m_foreground = config.readNumEntry( "Foreground", 1 ); | 485 | m_foreground = config.readNumEntry( "Foreground", 1 ); |
488 | reader->setForeground(getcolour(m_foreground)); | 486 | reader->setForeground(getcolour(m_foreground)); |
489 | m_scrollcolor = config.readNumEntry( "ScrollColour", 5 ); | 487 | m_scrollcolor = config.readNumEntry( "ScrollColour", 5 ); |
490 | setscrollcolour(); | 488 | setscrollcolour(); |
491 | m_scrollbarcolor = config.readNumEntry( "ScrollBarColour", 5 ); | 489 | m_scrollbarcolor = config.readNumEntry( "ScrollBarColour", 5 ); |
492 | setscrollbarcolour(); | 490 | setscrollbarcolour(); |
493 | reader->hyphenate = config.readBoolEntry( "Hyphenate", false ); | 491 | reader->hyphenate = config.readBoolEntry( "Hyphenate", false ); |
494 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); | 492 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); |
495 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 493 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
496 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 494 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); |
497 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 495 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
498 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 496 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
499 | reader->m_abstopmargin = config.readNumEntry( "Top Margin", 100 ); | 497 | reader->m_abstopmargin = config.readNumEntry( "Top Margin", 100 ); |
500 | reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", 100 ); | 498 | reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", 100 ); |
501 | reader->m_absleft_border = config.readNumEntry( "Left Margin", 100 ); | 499 | reader->m_absleft_border = config.readNumEntry( "Left Margin", 100 ); |
502 | reader->m_absright_border = config.readNumEntry( "Right Margin", 100 ); | 500 | reader->m_absright_border = config.readNumEntry( "Right Margin", 100 ); |
503 | 501 | ||
504 | m_scrollishidden = config.readBoolEntry( "HideScrollBar", false ); | 502 | m_scrollishidden = config.readBoolEntry( "HideScrollBar", false ); |
505 | 503 | ||
506 | reader->brepalm = config.readBoolEntry( "Repalm", false ); | 504 | reader->brepalm = config.readBoolEntry( "Repalm", false ); |
507 | reader->bkern = config.readBoolEntry( "Kern", false ); | 505 | reader->bkern = config.readBoolEntry( "Kern", false ); |
508 | reader->bremap = config.readBoolEntry( "Remap", true ); | 506 | reader->bremap = config.readBoolEntry( "Remap", true ); |
509 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | 507 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); |
510 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | 508 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); |
511 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 509 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
512 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 510 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
513 | #ifdef _SCROLLPIPE | 511 | #ifdef _SCROLLPIPE |
514 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); | 512 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); |
515 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); | 513 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); |
516 | #endif | 514 | #endif |
517 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | 515 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); |
518 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | 516 | m_doAnnotation = config.readBoolEntry( "Annotation", false); |
519 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | 517 | m_doDictionary = config.readBoolEntry( "Dictionary", false); |
520 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | 518 | m_doClipboard = config.readBoolEntry( "Clipboard", false); |
521 | /* | 519 | /* |
522 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | 520 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); |
523 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); | 521 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); |
524 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); | 522 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); |
525 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); | 523 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); |
526 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); | 524 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); |
527 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); | 525 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); |
528 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | 526 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); |
529 | 527 | ||
530 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | 528 | m_leftScroll = config.readBoolEntry("LeftScroll", false); |
531 | m_rightScroll = config.readBoolEntry("RightScroll", false); | 529 | m_rightScroll = config.readBoolEntry("RightScroll", false); |
532 | m_upScroll = config.readBoolEntry("UpScroll", true); | 530 | m_upScroll = config.readBoolEntry("UpScroll", true); |
533 | m_downScroll = config.readBoolEntry("DownScroll", true); | 531 | m_downScroll = config.readBoolEntry("DownScroll", true); |
534 | */ | 532 | */ |
535 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); | 533 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); |
536 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); | 534 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); |
537 | reader->setHyphenThreshold(config.readNumEntry( "HyphenThreshold", 50 )); | 535 | reader->setHyphenThreshold(config.readNumEntry( "HyphenThreshold", 50 )); |
538 | // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false )); | 536 | // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false )); |
539 | #ifndef USEQPE | 537 | #ifndef USEQPE |
540 | config.setGroup( "Geometry" ); | 538 | config.setGroup( "Geometry" ); |
541 | setGeometry(0,0, | 539 | setGeometry(0,0, |
542 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), | 540 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), |
543 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); | 541 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); |
544 | move( | 542 | move( |
545 | config.readNumEntry( "x", 20 ), | 543 | config.readNumEntry( "x", 20 ), |
546 | config.readNumEntry( "y", 20 )); | 544 | config.readNumEntry( "y", 20 )); |
547 | #else | 545 | #else |
548 | m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", false); | 546 | m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", false); |
549 | #endif | 547 | #endif |
550 | 548 | ||
551 | 549 | ||
552 | 550 | ||
553 | setTwoTouch(m_twoTouch); | 551 | setTwoTouch(m_twoTouch); |
554 | 552 | ||
555 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); | 553 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); |
556 | 554 | ||
557 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); | 555 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); |
558 | connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, size_t, const QString&) ) ); | 556 | connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, size_t, const QString&) ) ); |
559 | connect( reader, SIGNAL( OnURLSelected(const QString&, const size_t) ), this, SLOT( OnURLSelected(const QString&, const size_t) ) ); | 557 | connect( reader, SIGNAL( OnURLSelected(const QString&, const size_t) ), this, SLOT( OnURLSelected(const QString&, const size_t) ) ); |
560 | connect( reader, SIGNAL( NewFileRequest(const QString&) ), this, SLOT( forceopen(const QString&) ) ); | 558 | connect( reader, SIGNAL( NewFileRequest(const QString&) ), this, SLOT( forceopen(const QString&) ) ); |
561 | connect( reader, SIGNAL( HandleKeyRequest(QKeyEvent*) ), this, SLOT( handlekey(QKeyEvent*) ) ); | 559 | connect( reader, SIGNAL( HandleKeyRequest(QKeyEvent*) ), this, SLOT( handlekey(QKeyEvent*) ) ); |
562 | connect( reader, SIGNAL( SetScrollState(bool) ), this, SLOT( setScrollState(bool) ) ); | 560 | connect( reader, SIGNAL( SetScrollState(bool) ), this, SLOT( setScrollState(bool) ) ); |
563 | connect( reader, SIGNAL(RefreshBitmap()), this, SLOT(setBackgroundBitmap())); | 561 | connect( reader, SIGNAL(RefreshBitmap()), this, SLOT(setBackgroundBitmap())); |
564 | editorStack->addWidget( reader, get_unique_id() ); | 562 | editorStack->addWidget( reader, get_unique_id() ); |
565 | 563 | ||
566 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); | 564 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); |
567 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); | 565 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); |
568 | m_preferences_action->addTo( settings ); | 566 | m_preferences_action->addTo( settings ); |
569 | 567 | ||
570 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); | 568 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); |
571 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); | 569 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); |
572 | m_saveconfig_action->addTo( settings ); | 570 | m_saveconfig_action->addTo( settings ); |
573 | 571 | ||
574 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); | 572 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); |
575 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); | 573 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); |
576 | m_loadconfig_action->addTo( settings ); | 574 | m_loadconfig_action->addTo( settings ); |
577 | 575 | ||
578 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); | 576 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); |
579 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); | 577 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); |
580 | m_tidyconfig_action->addTo( settings ); | 578 | m_tidyconfig_action->addTo( settings ); |
581 | 579 | ||
582 | settings->insertSeparator(); | 580 | settings->insertSeparator(); |
583 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); | 581 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); |
584 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); | 582 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); |
585 | m_toolbarprefs_action->addTo( settings ); | 583 | m_toolbarprefs_action->addTo( settings ); |
586 | 584 | ||
587 | m_buttonprefs_action = new QAction( tr( "Buttons" ), QString::null, 0, this, NULL); | 585 | m_buttonprefs_action = new QAction( tr( "Buttons" ), QString::null, 0, this, NULL); |
588 | connect( m_buttonprefs_action, SIGNAL( activated() ), this, SLOT( showbuttonprefs() ) ); | 586 | connect( m_buttonprefs_action, SIGNAL( activated() ), this, SLOT( showbuttonprefs() ) ); |
589 | m_buttonprefs_action->addTo( settings ); | 587 | m_buttonprefs_action->addTo( settings ); |
590 | 588 | ||
591 | m_loadtheme_action = new QAction( tr( "Load Theme" ), QString::null, 0, this, NULL); | 589 | m_loadtheme_action = new QAction( tr( "Load Theme" ), QString::null, 0, this, NULL); |
592 | connect( m_loadtheme_action, SIGNAL( activated() ), this, SLOT( LoadTheme() ) ); | 590 | connect( m_loadtheme_action, SIGNAL( activated() ), this, SLOT( LoadTheme() ) ); |
593 | m_loadtheme_action->addTo( settings ); | 591 | m_loadtheme_action->addTo( settings ); |
594 | 592 | ||
595 | m_repara_action = new QAction( tr( "EOP Marker" ), QString::null, 0, this, NULL); | 593 | m_repara_action = new QAction( tr( "EOP Marker" ), QString::null, 0, this, NULL); |
596 | connect( m_repara_action, SIGNAL( activated() ), this, SLOT( reparastring() ) ); | 594 | connect( m_repara_action, SIGNAL( activated() ), this, SLOT( reparastring() ) ); |
597 | m_repara_action->addTo(settings); | 595 | m_repara_action->addTo(settings); |
598 | 596 | ||
599 | #ifdef USEQPE | 597 | #ifdef USEQPE |
600 | m_grab_action = new QAction( tr( "Grab Buttons" ), QString::null, 0, this, NULL, true ); | 598 | m_grab_action = new QAction( tr( "Grab Buttons" ), QString::null, 0, this, NULL, true ); |
601 | connect( m_grab_action, SIGNAL( toggled(bool) ), this, SLOT( setgrab(bool) ) ); | 599 | connect( m_grab_action, SIGNAL( toggled(bool) ), this, SLOT( setgrab(bool) ) ); |
602 | m_grab_action->setOn(m_grabkeyboard); | 600 | m_grab_action->setOn(m_grabkeyboard); |
603 | m_grab_action->addTo( settings ); | 601 | m_grab_action->addTo( settings ); |
604 | #endif | 602 | #endif |
605 | 603 | ||
606 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); | 604 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); |
607 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 605 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
608 | m_open_action->addTo( file ); | 606 | m_open_action->addTo( file ); |
609 | 607 | ||
610 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); | 608 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); |
611 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); | 609 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); |
612 | m_close_action->addTo( file ); | 610 | m_close_action->addTo( file ); |
613 | 611 | ||
614 | #ifdef _SCRIPT | 612 | #ifdef _SCRIPT |
615 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); | 613 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); |
616 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); | 614 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); |
617 | a->addTo( file ); | 615 | a->addTo( file ); |
618 | #endif | 616 | #endif |
619 | /* | 617 | /* |
620 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); | 618 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); |
621 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); | 619 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); |
622 | a->addTo( file ); | 620 | a->addTo( file ); |
623 | 621 | ||
624 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); | 622 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); |
625 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 623 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
626 | a->addTo( filebar() ); | 624 | a->addTo( filebar() ); |
627 | a->addTo( edit ); | 625 | a->addTo( edit ); |
628 | */ | 626 | */ |
629 | 627 | ||
630 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); | 628 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); |
631 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); | 629 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); |
632 | m_info_action->addTo( file ); | 630 | m_info_action->addTo( file ); |
633 | 631 | ||
634 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); | 632 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); |
635 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); | 633 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); |
636 | m_touch_action->setOn(m_twoTouch); | 634 | m_touch_action->setOn(m_twoTouch); |
637 | m_touch_action->addTo( file ); | 635 | m_touch_action->addTo( file ); |
638 | 636 | ||
639 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); | 637 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); |
640 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 638 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
641 | file->insertSeparator(); | 639 | file->insertSeparator(); |
642 | // a->addTo( bar ); | 640 | // a->addTo( bar ); |
643 | m_find_action->addTo( file ); | 641 | m_find_action->addTo( file ); |
644 | 642 | ||
645 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); | 643 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); |
646 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); | 644 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); |
647 | m_exportlinks_action->addTo( file ); | 645 | m_exportlinks_action->addTo( file ); |
648 | 646 | ||
649 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); | 647 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); |
650 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); | 648 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); |
651 | m_scrollButton->addTo(navigation); | 649 | m_scrollButton->addTo(navigation); |
652 | m_scrollButton->setOn(false); | 650 | m_scrollButton->setOn(false); |
653 | 651 | ||
654 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); | 652 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); |
655 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); | 653 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); |
656 | m_start_action->addTo(navigation); | 654 | m_start_action->addTo(navigation); |
657 | 655 | ||
658 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); | 656 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); |
659 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); | 657 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); |
660 | m_end_action->addTo(navigation); | 658 | m_end_action->addTo(navigation); |
661 | 659 | ||
662 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); | 660 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); |
663 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); | 661 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); |
664 | m_jump_action->addTo(navigation); | 662 | m_jump_action->addTo(navigation); |
665 | 663 | ||
666 | m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); | 664 | m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); |
667 | connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); | 665 | connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); |
668 | m_pageline_action->addTo(navigation); | 666 | m_pageline_action->addTo(navigation); |
669 | m_pageline_action->setOn(reader->m_bpagemode); | 667 | m_pageline_action->setOn(reader->m_bpagemode); |
670 | 668 | ||
671 | m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); | 669 | m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); |
672 | connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); | 670 | connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); |
673 | m_pageup_action->addTo( navigation ); | 671 | m_pageup_action->addTo( navigation ); |
674 | 672 | ||
675 | m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); | 673 | m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); |
676 | connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 674 | connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
677 | m_pagedn_action->addTo( navigation ); | 675 | m_pagedn_action->addTo( navigation ); |
678 | 676 | ||
679 | m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 ); | 677 | m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 ); |
680 | connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) ); | 678 | connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) ); |
681 | m_back_action->addTo( navigation ); | 679 | m_back_action->addTo( navigation ); |
682 | 680 | ||
683 | m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 ); | 681 | m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 ); |
684 | connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) ); | 682 | connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) ); |
685 | m_home_action->addTo( navigation ); | 683 | m_home_action->addTo( navigation ); |
686 | 684 | ||
687 | m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 ); | 685 | m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 ); |
688 | connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) ); | 686 | connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) ); |
689 | m_forward_action->addTo( navigation ); | 687 | m_forward_action->addTo( navigation ); |
690 | 688 | ||
691 | /* | 689 | /* |
692 | a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); | 690 | a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); |
693 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 691 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
694 | a->addTo( file ); | 692 | a->addTo( file ); |
695 | 693 | ||
696 | a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); | 694 | a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); |
697 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 695 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
698 | a->addTo( file ); | 696 | a->addTo( file ); |
699 | */ | 697 | */ |
700 | 698 | ||
701 | // file->insertSeparator(); | 699 | // file->insertSeparator(); |
702 | 700 | ||
703 | #ifdef _SCROLLPIPE | 701 | #ifdef _SCROLLPIPE |
704 | 702 | ||
705 | QActionGroup* ag = new QActionGroup(this); | 703 | QActionGroup* ag = new QActionGroup(this); |
706 | ag->setExclusive(false); | 704 | ag->setExclusive(false); |
707 | spacemenu = new QPopupMenu(this); | 705 | spacemenu = new QPopupMenu(this); |
708 | file->insertItem( tr( "Scrolling" ), spacemenu ); | 706 | file->insertItem( tr( "Scrolling" ), spacemenu ); |
709 | 707 | ||
710 | a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL); | 708 | a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL); |
711 | connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) ); | 709 | connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) ); |
712 | 710 | ||
713 | a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true ); | 711 | a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true ); |
714 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) ); | 712 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) ); |
715 | a->setOn(reader->m_pauseAfterEachPara); | 713 | a->setOn(reader->m_pauseAfterEachPara); |
716 | 714 | ||
717 | ag->addTo(spacemenu); | 715 | ag->addTo(spacemenu); |
718 | // file->insertSeparator(); | 716 | // file->insertSeparator(); |
719 | 717 | ||
720 | #endif | 718 | #endif |
721 | 719 | ||
722 | /* | 720 | /* |
723 | a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); | 721 | a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); |
724 | connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); | 722 | connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); |
725 | a->addTo( file ); | 723 | a->addTo( file ); |
726 | */ | 724 | */ |
727 | 725 | ||
728 | /* | 726 | /* |
729 | a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 ); | 727 | a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 ); |
730 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 728 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
731 | a->addTo( fileBar ); | 729 | a->addTo( fileBar ); |
732 | a->addTo( edit ); | 730 | a->addTo( edit ); |
733 | */ | 731 | */ |
734 | 732 | ||
735 | // a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 ); | 733 | // a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 ); |
736 | 734 | ||
737 | m_fullscreen = false; | 735 | m_fullscreen = false; |
738 | m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true ); | 736 | m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true ); |
739 | connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); | 737 | connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); |
740 | m_actFullscreen->setOn(m_fullscreen); | 738 | m_actFullscreen->setOn(m_fullscreen); |
741 | m_actFullscreen->addTo( view ); | 739 | m_actFullscreen->addTo( view ); |
742 | 740 | ||
743 | m_rotate_action = new QAction( tr( "Rotate" ), geticon( "repeat" ), QString::null, 0, this, NULL, true ); | 741 | m_rotate_action = new QAction( tr( "Rotate" ), geticon( "repeat" ), QString::null, 0, this, NULL, true ); |
744 | connect( m_rotate_action, SIGNAL( toggled(bool) ), this, SLOT( setrotated(bool) ) ); | 742 | connect( m_rotate_action, SIGNAL( toggled(bool) ), this, SLOT( setrotated(bool) ) ); |
745 | m_rotate_action->setOn(reader->m_rotated); | 743 | m_rotate_action->setOn(reader->m_rotated); |
746 | m_rotate_action->addTo( view ); | 744 | m_rotate_action->addTo( view ); |
747 | 745 | ||
748 | m_inverse_action = new QAction( tr( "Invert" ), getmyicon( "invert" ), QString::null, 0, this, NULL, true ); | 746 | m_inverse_action = new QAction( tr( "Invert" ), getmyicon( "invert" ), QString::null, 0, this, NULL, true ); |
749 | connect( m_inverse_action, SIGNAL( toggled(bool) ), this, SLOT( setinverted(bool) ) ); | 747 | connect( m_inverse_action, SIGNAL( toggled(bool) ), this, SLOT( setinverted(bool) ) ); |
750 | m_inverse_action->setOn(reader->bInverse); | 748 | m_inverse_action->setOn(reader->bInverse); |
751 | m_inverse_action->addTo( view ); | 749 | m_inverse_action->addTo( view ); |
752 | 750 | ||
753 | view->insertSeparator(); | 751 | view->insertSeparator(); |
754 | 752 | ||
755 | m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this); | 753 | m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this); |
756 | connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) ); | 754 | connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) ); |
757 | m_zoomin_action->addTo( view ); | 755 | m_zoomin_action->addTo( view ); |
758 | 756 | ||
759 | m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this); | 757 | m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this); |
760 | connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) ); | 758 | connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) ); |
761 | m_zoomout_action->addTo( view ); | 759 | m_zoomout_action->addTo( view ); |
762 | 760 | ||
763 | view->insertSeparator(); | 761 | view->insertSeparator(); |
764 | m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this); | 762 | m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this); |
765 | connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) ); | 763 | connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) ); |
766 | m_setfont_action->addTo( view ); | 764 | m_setfont_action->addTo( view ); |
767 | 765 | ||
768 | view->insertSeparator(); | 766 | view->insertSeparator(); |
769 | m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); | 767 | m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); |
770 | connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); | 768 | connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); |
771 | m_setenc_action->addTo( view ); | 769 | m_setenc_action->addTo( view ); |
772 | 770 | ||
773 | m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); | 771 | m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); |
774 | connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 772 | connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
775 | m_setmono_action->addTo( view ); | 773 | m_setmono_action->addTo( view ); |
776 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 774 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
777 | 775 | ||
778 | 776 | ||
779 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); | 777 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); |
780 | // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); | 778 | // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); |
781 | 779 | ||
782 | 780 | ||
783 | 781 | ||
784 | // a->addTo( filebar() ); | 782 | // a->addTo( filebar() ); |
785 | // view->insertSeparator(); | 783 | // view->insertSeparator(); |
786 | 784 | ||
787 | /* | 785 | /* |
788 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); | 786 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); |
789 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 787 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
790 | a->setOn(reader->m_bMonoSpaced); | 788 | a->setOn(reader->m_bMonoSpaced); |
791 | a->addTo( view ); | 789 | a->addTo( view ); |
792 | */ | 790 | */ |
793 | /* | 791 | /* |
794 | a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); | 792 | a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); |
795 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); | 793 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); |
796 | a->addTo( view ); | 794 | a->addTo( view ); |
797 | */ | 795 | */ |
798 | 796 | ||
799 | m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); | 797 | m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); |
800 | connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); | 798 | connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); |
801 | m_mark_action->addTo( marks ); | 799 | m_mark_action->addTo( marks ); |
802 | 800 | ||
803 | m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); | 801 | m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); |
804 | connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); | 802 | connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); |
805 | m_annotate_action->addTo( marks ); | 803 | m_annotate_action->addTo( marks ); |
806 | 804 | ||
807 | m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); | 805 | m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); |
808 | connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); | 806 | connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); |
809 | m_goto_action->addTo( marks ); | 807 | m_goto_action->addTo( marks ); |
810 | 808 | ||
811 | m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); | 809 | m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); |
812 | connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); | 810 | connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); |
813 | m_delete_action->addTo( marks ); | 811 | m_delete_action->addTo( marks ); |
814 | 812 | ||
815 | m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); | 813 | m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); |
816 | connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); | 814 | connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); |
817 | marks->insertSeparator(); | 815 | marks->insertSeparator(); |
818 | m_autogen_action->addTo( marks ); | 816 | m_autogen_action->addTo( marks ); |
819 | 817 | ||
820 | m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); | 818 | m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); |
821 | connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); | 819 | connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); |
822 | m_clear_action->addTo( marks ); | 820 | m_clear_action->addTo( marks ); |
823 | 821 | ||
824 | m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); | 822 | m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); |
825 | connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); | 823 | connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); |
826 | m_save_action->addTo( marks ); | 824 | m_save_action->addTo( marks ); |
827 | 825 | ||
828 | m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); | 826 | m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); |
829 | connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); | 827 | connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); |
830 | marks->insertSeparator(); | 828 | marks->insertSeparator(); |
831 | m_tidy_action->addTo( marks ); | 829 | m_tidy_action->addTo( marks ); |
832 | 830 | ||
833 | m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); | 831 | m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); |
834 | connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); | 832 | connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); |
835 | marks->insertSeparator(); | 833 | marks->insertSeparator(); |
836 | m_startBlock_action->addTo( marks ); | 834 | m_startBlock_action->addTo( marks ); |
837 | 835 | ||
838 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); | 836 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); |
839 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 837 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
840 | m_endBlock_action->addTo( marks ); | 838 | m_endBlock_action->addTo( marks ); |
841 | 839 | ||
842 | m_bkmkAvail = NULL; | 840 | m_bkmkAvail = NULL; |
843 | 841 | ||
844 | 842 | ||
845 | setToolBarsMovable(m_tbmove); | 843 | setToolBarsMovable(m_tbmove); |
846 | addtoolbars(&config); | 844 | addtoolbars(&config); |
847 | 845 | ||
848 | pbar = new QProgressBar(this); | 846 | pbar = new QProgressBar(this); |
849 | pbar->hide(); | 847 | pbar->hide(); |
850 | 848 | ||
851 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 849 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
852 | 850 | ||
853 | searchBar->setHorizontalStretchable( TRUE ); | 851 | searchBar->setHorizontalStretchable( TRUE ); |
854 | 852 | ||
855 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | 853 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); |
856 | 854 | ||
857 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 855 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
858 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 856 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
859 | // searchEdit->setFont( f ); | 857 | // searchEdit->setFont( f ); |
860 | searchBar->setStretchableWidget( searchEdit ); | 858 | searchBar->setStretchableWidget( searchEdit ); |
861 | 859 | ||
862 | 860 | ||
863 | #ifdef __ISEARCH | 861 | #ifdef __ISEARCH |
864 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 862 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
865 | this, SLOT( search( const QString& ) ) ); | 863 | this, SLOT( search( const QString& ) ) ); |
866 | #else | 864 | #else |
867 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 865 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
868 | this, SLOT( search( ) ) ); | 866 | this, SLOT( search( ) ) ); |
869 | #endif | 867 | #endif |
870 | QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); | 868 | QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); |
871 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 869 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
872 | a->addTo( searchBar ); | 870 | a->addTo( searchBar ); |
873 | 871 | ||
874 | a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); | 872 | a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); |
875 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 873 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
876 | a->addTo( searchBar ); | 874 | a->addTo( searchBar ); |
877 | 875 | ||
878 | searchBar->hide(); | 876 | searchBar->hide(); |
879 | 877 | ||
880 | regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); | 878 | regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); |
881 | connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | 879 | connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); |
882 | 880 | ||
883 | regBar->setHorizontalStretchable( TRUE ); | 881 | regBar->setHorizontalStretchable( TRUE ); |
884 | 882 | ||
885 | regEdit = new QLineEdit( regBar, "regEdit" ); | 883 | regEdit = new QLineEdit( regBar, "regEdit" ); |
886 | // regEdit->setFont( f ); | 884 | // regEdit->setFont( f ); |
887 | 885 | ||
888 | regBar->setStretchableWidget( regEdit ); | 886 | regBar->setStretchableWidget( regEdit ); |
889 | 887 | ||
890 | connect( regEdit, SIGNAL( returnPressed( ) ), | 888 | connect( regEdit, SIGNAL( returnPressed( ) ), |
891 | this, SLOT( do_regaction() ) ); | 889 | this, SLOT( do_regaction() ) ); |
892 | 890 | ||
893 | a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); | 891 | a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); |
894 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); | 892 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); |
895 | a->addTo( regBar ); | 893 | a->addTo( regBar ); |
896 | 894 | ||
897 | a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); | 895 | a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); |
898 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); | 896 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); |
899 | a->addTo( regBar ); | 897 | a->addTo( regBar ); |
900 | 898 | ||
901 | regBar->hide(); | 899 | regBar->hide(); |
902 | 900 | ||
903 | m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); | 901 | m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); |
904 | 902 | ||
905 | m_fontBar->setHorizontalStretchable( TRUE ); | 903 | m_fontBar->setHorizontalStretchable( TRUE ); |
906 | 904 | ||
907 | // qDebug("Font selector"); | 905 | // qDebug("Font selector"); |
908 | m_fontSelector = new QComboBox(false, m_fontBar); | 906 | m_fontSelector = new QComboBox(false, m_fontBar); |
909 | m_fontBar->setStretchableWidget( m_fontSelector ); | 907 | m_fontBar->setStretchableWidget( m_fontSelector ); |
910 | { | 908 | { |
911 | QFontDatabase f; | 909 | QFontDatabase f; |
912 | QStringList flist = f.families(); | 910 | QStringList flist = f.families(); |
913 | bool realfont = false; | 911 | bool realfont = false; |
914 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 912 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
915 | { | 913 | { |
916 | if (reader->m_fontname == *nm) | 914 | if (reader->m_fontname == *nm) |
917 | { | 915 | { |
918 | realfont = true; | 916 | realfont = true; |
919 | } | 917 | } |
920 | if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); | 918 | if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); |
921 | } | 919 | } |
922 | if (!realfont) reader->m_fontname = flist[0]; | 920 | if (!realfont) reader->m_fontname = flist[0]; |
923 | } // delete the FontDatabase!!! | 921 | } // delete the FontDatabase!!! |
924 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), | 922 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), |
925 | this, SLOT( do_setfont(const QString&) ) ); | 923 | this, SLOT( do_setfont(const QString&) ) ); |
926 | connect( m_fontSelector, SIGNAL( activated(int ) ), | 924 | connect( m_fontSelector, SIGNAL( activated(int ) ), |
927 | this, SLOT( do_setencoding(int) ) ); | 925 | this, SLOT( do_setencoding(int) ) ); |
928 | 926 | ||
929 | m_fontBar->hide(); | 927 | m_fontBar->hide(); |
930 | m_fontVisible = false; | 928 | m_fontVisible = false; |
931 | #ifdef USEMSGS | 929 | #ifdef USEMSGS |
932 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), | 930 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), |
933 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); | 931 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); |
934 | #endif | 932 | #endif |
935 | // qDebug("Initing"); | 933 | // qDebug("Initing"); |
936 | 934 | ||
937 | m_layout->addWidget(editorStack); | 935 | m_layout->addWidget(editorStack); |
938 | if (m_qtscroll != 0) | 936 | if (m_qtscroll != 0) |
939 | { | 937 | { |
940 | /* | 938 | /* |
941 | m_scrollbar = new QToolBar( "Autogen", this, (m_localscrollbar) ? QMainWindow::Left : QMainWindow::Right, TRUE ); | 939 | m_scrollbar = new QToolBar( "Autogen", this, (m_localscrollbar) ? QMainWindow::Left : QMainWindow::Right, TRUE ); |
942 | 940 | ||
943 | m_scrollbar->setVerticalStretchable( TRUE ); | 941 | m_scrollbar->setVerticalStretchable( TRUE ); |
944 | */ | 942 | */ |
945 | scrollbar = m_scrollbar = new QScrollBar(QScrollBar::Vertical, widge); | 943 | scrollbar = m_scrollbar = new QScrollBar(QScrollBar::Vertical, widge); |
946 | m_layout->addWidget(scrollbar); | 944 | m_layout->addWidget(scrollbar); |
947 | scrollbar->setTracking(false); | 945 | scrollbar->setTracking(false); |
948 | //connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); | 946 | //connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); |
949 | //m_scrollbar->setStretchableWidget( scrollbar ); | 947 | //m_scrollbar->setStretchableWidget( scrollbar ); |
950 | if (m_scrollishidden) | 948 | if (m_scrollishidden) |
951 | { | 949 | { |
952 | m_scrollbar->hide(); | 950 | m_scrollbar->hide(); |
953 | } | 951 | } |
954 | else | 952 | else |
955 | { | 953 | { |
956 | m_scrollbar->show(); | 954 | m_scrollbar->show(); |
957 | } | 955 | } |
958 | 956 | ||
959 | setrotated(reader->m_rotated); | 957 | setrotated(reader->m_rotated); |
960 | } | 958 | } |
961 | else | 959 | else |
962 | { | 960 | { |
963 | m_scrollbar = NULL; | 961 | m_scrollbar = NULL; |
964 | } | 962 | } |
965 | setBackgroundBitmap(); | 963 | setBackgroundBitmap(); |
966 | m_inverse_action->setOn(reader->bInverse); | 964 | m_inverse_action->setOn(reader->bInverse); |
967 | reader->init(); | 965 | reader->init(); |
968 | 966 | ||
969 | // qDebug("Inited"); | 967 | // qDebug("Inited"); |
970 | // m_buttonAction[m_spaceTarget]->setOn(true); | 968 | // m_buttonAction[m_spaceTarget]->setOn(true); |
971 | // qDebug("fonting"); | 969 | // qDebug("fonting"); |
972 | do_setfont(reader->m_fontname); | 970 | do_setfont(reader->m_fontname); |
973 | // qDebug("fonted"); | 971 | // qDebug("fonted"); |
974 | QFont progfont(reader->m_fontname, reader->m_fontControl.getsize(0)); | 972 | QFont progfont(reader->m_fontname, reader->m_fontControl.getsize(0)); |
975 | m_prog->setFont( progfont ); | 973 | m_prog->setFont( progfont ); |
976 | if (m_statusishidden) m_prog->hide(); | 974 | if (m_statusishidden) m_prog->hide(); |
977 | if (!reader->m_lastfile.isEmpty()) | 975 | if (!reader->m_lastfile.isEmpty()) |
978 | { | 976 | { |
979 | //qDebug("doclnk"); | 977 | //qDebug("doclnk"); |
980 | //doc = new DocLnk(reader->m_lastfile); | 978 | //doc = new DocLnk(reader->m_lastfile); |
981 | //qDebug("doclnk done"); | 979 | //qDebug("doclnk done"); |
982 | if (pOpenlist != NULL) | 980 | if (pOpenlist != NULL) |
983 | { | 981 | { |
984 | 982 | ||
985 | /* | 983 | /* |
986 | int ind = 0; | 984 | int ind = 0; |
987 | Bkmk* p = (*pOpenlist)[ind]; | 985 | Bkmk* p = (*pOpenlist)[ind]; |
988 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | 986 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) |
989 | { | 987 | { |
990 | p = (*pOpenlist)[++ind]; | 988 | p = (*pOpenlist)[++ind]; |
991 | } | 989 | } |
992 | */ | 990 | */ |
993 | Bkmk* p = NULL; | 991 | Bkmk* p = NULL; |
994 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | 992 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) |
995 | { | 993 | { |
996 | p = iter.pContent(); | 994 | p = iter.pContent(); |
997 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) | 995 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) |
998 | { | 996 | { |
999 | break; | 997 | break; |
1000 | } | 998 | } |
1001 | // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); | 999 | // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); |
1002 | p = NULL; | 1000 | p = NULL; |
1003 | } | 1001 | } |
1004 | if (p != NULL) | 1002 | if (p != NULL) |
1005 | { | 1003 | { |
1006 | if (!openfrombkmk(p)) | 1004 | if (!openfrombkmk(p)) |
1007 | { | 1005 | { |
1008 | showEditTools(); | 1006 | showEditTools(); |
1009 | } | 1007 | } |
1010 | } | 1008 | } |
1011 | else | 1009 | else |
1012 | { | 1010 | { |
1013 | openFile( reader->m_lastfile ); | 1011 | openFile( reader->m_lastfile ); |
1014 | } | 1012 | } |
1015 | } | 1013 | } |
1016 | else | 1014 | else |
1017 | { | 1015 | { |
1018 | if (!reader->m_lastfile.isEmpty()) | 1016 | if (!reader->m_lastfile.isEmpty()) |
1019 | { | 1017 | { |
1020 | openFile( reader->m_lastfile ); | 1018 | openFile( reader->m_lastfile ); |
1021 | } | 1019 | } |
1022 | } | 1020 | } |
1023 | } | 1021 | } |
1024 | else | 1022 | else |
1025 | { | 1023 | { |
1026 | showEditTools(); | 1024 | showEditTools(); |
1027 | } | 1025 | } |
1028 | // qApp->processEvents(); | 1026 | // qApp->processEvents(); |
1029 | if (m_scrollbar == NULL || m_scrollbar->isHidden()) | 1027 | if (m_scrollbar == NULL || m_scrollbar->isHidden()) |
1030 | { | 1028 | { |
1031 | reader->m_scrollpos = m_localscroll; | 1029 | reader->m_scrollpos = m_localscroll; |
1032 | } | 1030 | } |
1033 | else | 1031 | else |
1034 | { | 1032 | { |
1035 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; | 1033 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; |
1036 | } | 1034 | } |
1037 | reader->bDoUpdates = true; | 1035 | reader->bDoUpdates = true; |
1038 | reader->update(); | 1036 | reader->update(); |
1039 | config.setGroup("Version"); | 1037 | config.setGroup("Version"); |
1040 | int major = config.readNumEntry("Major", 0); | 1038 | int major = config.readNumEntry("Major", 0); |
1041 | int bkmktype = config.readNumEntry("BkmkType", 0); | 1039 | int bkmktype = config.readNumEntry("BkmkType", 0); |
1042 | char minor = config.readNumEntry("Minor", 0); | 1040 | char minor = config.readNumEntry("Minor", 0); |
1043 | if (CheckVersion(major, bkmktype, minor)) | 1041 | if (CheckVersion(major, bkmktype, minor)) |
1044 | { | 1042 | { |
1045 | config.writeEntry("Major", major); | 1043 | config.writeEntry("Major", major); |
1046 | config.writeEntry("BkmkType", bkmktype); | 1044 | config.writeEntry("BkmkType", bkmktype); |
1047 | config.writeEntry("Minor", (int)minor); | 1045 | config.writeEntry("Minor", (int)minor); |
1048 | } | 1046 | } |
1049 | // qDebug("finished update"); | 1047 | // qDebug("finished update"); |
1050 | if (kmap.isEmpty()) | 1048 | if (kmap.isEmpty()) |
1051 | { | 1049 | { |
1052 | 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."); | 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."); |
1053 | 1051 | ||
1054 | m_buttonprefs->mapkey(Qt::NoButton, Key_Up, cesPageUp); | 1052 | m_buttonprefs->mapkey(Qt::NoButton, Key_Up, cesPageUp); |
1055 | m_buttonprefs->mapkey(Qt::NoButton, Key_Down, cesPageDown); | 1053 | m_buttonprefs->mapkey(Qt::NoButton, Key_Down, cesPageDown); |
1056 | 1054 | ||
1057 | m_buttonprefs->mapkey(Qt::NoButton, Key_Right, cesZoomIn); | 1055 | m_buttonprefs->mapkey(Qt::NoButton, Key_Right, cesZoomIn); |
1058 | m_buttonprefs->mapkey(Qt::NoButton, Key_Left, cesZoomOut); | 1056 | m_buttonprefs->mapkey(Qt::NoButton, Key_Left, cesZoomOut); |
1059 | 1057 | ||
1060 | showbuttonprefs(); | 1058 | showbuttonprefs(); |
1061 | } | 1059 | } |
1062 | } | 1060 | } |
1063 | 1061 | ||
1064 | void QTReaderApp::addtoolbars(Config* config) | 1062 | void QTReaderApp::addtoolbars(Config* config) |
1065 | { | 1063 | { |
1066 | config->setGroup("Toolbar"); | 1064 | config->setGroup("Toolbar"); |
1067 | 1065 | ||
1068 | if (fileBar != NULL) | 1066 | if (fileBar != NULL) |
1069 | { | 1067 | { |
1070 | #ifdef USEQPE | 1068 | #ifdef USEQPE |
1071 | if (fileBar != menubar) | 1069 | if (fileBar != menubar) |
1072 | { | 1070 | { |
1073 | fileBar->clear(); | 1071 | fileBar->clear(); |
1074 | } | 1072 | } |
1075 | else | 1073 | else |
1076 | { | 1074 | { |
1077 | m_preferences_action->removeFrom( filebar() ); | 1075 | m_preferences_action->removeFrom( filebar() ); |
1078 | m_open_action->removeFrom( filebar() ); | 1076 | m_open_action->removeFrom( filebar() ); |
1079 | m_close_action->removeFrom( filebar() ); | 1077 | m_close_action->removeFrom( filebar() ); |
1080 | m_info_action->removeFrom( filebar() ); | 1078 | m_info_action->removeFrom( filebar() ); |
1081 | m_touch_action->removeFrom( filebar() ); | 1079 | m_touch_action->removeFrom( filebar() ); |
1082 | m_find_action->removeFrom( filebar() ); | 1080 | m_find_action->removeFrom( filebar() ); |
1083 | } | 1081 | } |
1084 | #else | 1082 | #else |
1085 | fileBar->clear(); | 1083 | fileBar->clear(); |
1086 | #endif | 1084 | #endif |
1087 | } | 1085 | } |
1088 | 1086 | ||
1089 | m_preferences_action->addTo( filebar() ); | 1087 | m_preferences_action->addTo( filebar() ); |
1090 | addfilebar(config, "Open", m_open_action); | 1088 | addfilebar(config, "Open", m_open_action); |
1091 | addfilebar(config, "Close", m_close_action); | 1089 | addfilebar(config, "Close", m_close_action); |
1092 | addfilebar(config, "Info", m_info_action); | 1090 | addfilebar(config, "Info", m_info_action); |
1093 | addfilebar(config, "Two/One Touch", m_touch_action); | 1091 | addfilebar(config, "Two/One Touch", m_touch_action); |
1094 | addfilebar(config, "Find", m_find_action); | 1092 | addfilebar(config, "Find", m_find_action); |
1095 | 1093 | ||
1096 | if (navBar != NULL) | 1094 | if (navBar != NULL) |
1097 | { | 1095 | { |
1098 | #ifdef USEQPE | 1096 | #ifdef USEQPE |
1099 | if ((navBar == fileBar) && (fileBar == menubar)) | 1097 | if ((navBar == fileBar) && (fileBar == menubar)) |
1100 | #else | 1098 | #else |
1101 | if (navBar == fileBar) | 1099 | if (navBar == fileBar) |
1102 | #endif | 1100 | #endif |
1103 | { | 1101 | { |
1104 | m_scrollButton->removeFrom( navbar() ); | 1102 | m_scrollButton->removeFrom( navbar() ); |
1105 | m_start_action->removeFrom( navbar() ); | 1103 | m_start_action->removeFrom( navbar() ); |
1106 | m_end_action->removeFrom( navbar() ); | 1104 | m_end_action->removeFrom( navbar() ); |
1107 | m_jump_action->removeFrom( navbar() ); | 1105 | m_jump_action->removeFrom( navbar() ); |
1108 | m_pageline_action->removeFrom( navbar() ); | 1106 | m_pageline_action->removeFrom( navbar() ); |
1109 | m_pageup_action->removeFrom( navbar() ); | 1107 | m_pageup_action->removeFrom( navbar() ); |
1110 | m_pagedn_action->removeFrom( navbar() ); | 1108 | m_pagedn_action->removeFrom( navbar() ); |
1111 | m_back_action->removeFrom( navbar() ); | 1109 | m_back_action->removeFrom( navbar() ); |
1112 | m_home_action->removeFrom( navbar() ); | 1110 | m_home_action->removeFrom( navbar() ); |
1113 | m_forward_action->removeFrom( navbar() ); | 1111 | m_forward_action->removeFrom( navbar() ); |
1114 | } | 1112 | } |
1115 | else if (navBar != fileBar) | 1113 | else if (navBar != fileBar) |
1116 | { | 1114 | { |
1117 | navBar->clear(); | 1115 | navBar->clear(); |
1118 | } | 1116 | } |
1119 | } | 1117 | } |
1120 | 1118 | ||
1121 | addnavbar(config, "Scroll", m_scrollButton); | 1119 | addnavbar(config, "Scroll", m_scrollButton); |
1122 | addnavbar(config, "Goto Start", m_start_action); | 1120 | addnavbar(config, "Goto Start", m_start_action); |
1123 | addnavbar(config, "Goto End", m_end_action); | 1121 | addnavbar(config, "Goto End", m_end_action); |
1124 | 1122 | ||
1125 | addnavbar(config, "Jump", m_jump_action); | 1123 | addnavbar(config, "Jump", m_jump_action); |
1126 | addnavbar(config, "Page/Line Scroll", m_pageline_action); | 1124 | addnavbar(config, "Page/Line Scroll", m_pageline_action); |
1127 | 1125 | ||
1128 | addnavbar(config, "Page Up", m_pageup_action); | 1126 | addnavbar(config, "Page Up", m_pageup_action); |
1129 | addnavbar(config, "Page Down", m_pagedn_action); | 1127 | addnavbar(config, "Page Down", m_pagedn_action); |
1130 | 1128 | ||
1131 | addnavbar(config, "Back", m_back_action); | 1129 | addnavbar(config, "Back", m_back_action); |
1132 | addnavbar(config, "Home", m_home_action); | 1130 | addnavbar(config, "Home", m_home_action); |
1133 | addnavbar(config, "Forward", m_forward_action); | 1131 | addnavbar(config, "Forward", m_forward_action); |
1134 | 1132 | ||
1135 | if (viewBar != NULL) | 1133 | if (viewBar != NULL) |
1136 | { | 1134 | { |
1137 | #ifdef USEQPE | 1135 | #ifdef USEQPE |
1138 | if ((viewBar == fileBar) && (fileBar == menubar)) | 1136 | if ((viewBar == fileBar) && (fileBar == menubar)) |
1139 | #else | 1137 | #else |
1140 | if (viewBar == fileBar) | 1138 | if (viewBar == fileBar) |
1141 | #endif | 1139 | #endif |
1142 | { | 1140 | { |
1143 | m_actFullscreen->removeFrom( filebar() ); | 1141 | m_actFullscreen->removeFrom( filebar() ); |
1144 | m_rotate_action->removeFrom( viewbar() ); | 1142 | m_rotate_action->removeFrom( viewbar() ); |
1145 | m_inverse_action->removeFrom( viewbar() ); | 1143 | m_inverse_action->removeFrom( viewbar() ); |
1146 | m_zoomin_action->removeFrom( viewbar() ); | 1144 | m_zoomin_action->removeFrom( viewbar() ); |
1147 | m_zoomout_action->removeFrom( viewbar() ); | 1145 | m_zoomout_action->removeFrom( viewbar() ); |
1148 | m_setfont_action->removeFrom( viewbar() ); | 1146 | m_setfont_action->removeFrom( viewbar() ); |
1149 | m_setenc_action->removeFrom( viewbar() ); | 1147 | m_setenc_action->removeFrom( viewbar() ); |
1150 | m_setmono_action->removeFrom( viewbar() ); | 1148 | m_setmono_action->removeFrom( viewbar() ); |
1151 | } | 1149 | } |
1152 | else if (viewBar != fileBar) | 1150 | else if (viewBar != fileBar) |
1153 | { | 1151 | { |
1154 | viewBar->clear(); | 1152 | viewBar->clear(); |
1155 | } | 1153 | } |
1156 | } | 1154 | } |
1157 | 1155 | ||
1158 | addviewbar(config, "Fullscreen", m_actFullscreen); | 1156 | addviewbar(config, "Fullscreen", m_actFullscreen); |
1159 | addviewbar(config, "Rotate", m_rotate_action); | 1157 | addviewbar(config, "Rotate", m_rotate_action); |
1160 | addviewbar(config, "Invert Action", m_inverse_action); | 1158 | addviewbar(config, "Invert Action", m_inverse_action); |
1161 | addviewbar(config, "Zoom In", m_zoomin_action); | 1159 | addviewbar(config, "Zoom In", m_zoomin_action); |
1162 | addviewbar(config, "Zoom Out", m_zoomout_action); | 1160 | addviewbar(config, "Zoom Out", m_zoomout_action); |
1163 | addviewbar(config, "Set Font", m_setfont_action); | 1161 | addviewbar(config, "Set Font", m_setfont_action); |
1164 | addviewbar(config, "Encoding Select", m_setenc_action); | 1162 | addviewbar(config, "Encoding Select", m_setenc_action); |
1165 | addviewbar(config, "Ideogram Mode", m_setmono_action); | 1163 | addviewbar(config, "Ideogram Mode", m_setmono_action); |
1166 | 1164 | ||
1167 | if (markBar != NULL) | 1165 | if (markBar != NULL) |
1168 | { | 1166 | { |
1169 | #ifdef USEQPE | 1167 | #ifdef USEQPE |
1170 | if ((markBar == fileBar) && (fileBar == menubar)) | 1168 | if ((markBar == fileBar) && (fileBar == menubar)) |
1171 | #else | 1169 | #else |
1172 | if (markBar == fileBar) | 1170 | if (markBar == fileBar) |
1173 | #endif | 1171 | #endif |
1174 | { | 1172 | { |
1175 | m_mark_action->removeFrom( markbar() ); | 1173 | m_mark_action->removeFrom( markbar() ); |
1176 | m_annotate_action->removeFrom( markbar()); | 1174 | m_annotate_action->removeFrom( markbar()); |
1177 | m_goto_action->removeFrom( markbar() ); | 1175 | m_goto_action->removeFrom( markbar() ); |
1178 | m_delete_action->removeFrom( markbar() ); | 1176 | m_delete_action->removeFrom( markbar() ); |
1179 | m_autogen_action->removeFrom( markbar() ); | 1177 | m_autogen_action->removeFrom( markbar() ); |
1180 | m_clear_action->removeFrom( markbar() ); | 1178 | m_clear_action->removeFrom( markbar() ); |
1181 | m_save_action->removeFrom( markbar() ); | 1179 | m_save_action->removeFrom( markbar() ); |
1182 | m_tidy_action->removeFrom( markbar() ); | 1180 | m_tidy_action->removeFrom( markbar() ); |
1183 | m_startBlock_action->removeFrom( markbar() ); | 1181 | m_startBlock_action->removeFrom( markbar() ); |
1184 | m_endBlock_action->removeFrom( markbar() ); | 1182 | m_endBlock_action->removeFrom( markbar() ); |
1185 | } | 1183 | } |
1186 | else if (markBar != fileBar) | 1184 | else if (markBar != fileBar) |
1187 | { | 1185 | { |
1188 | markBar->clear(); | 1186 | markBar->clear(); |
1189 | } | 1187 | } |
1190 | } | 1188 | } |
1191 | addmarkbar(config, "Mark", m_mark_action); | 1189 | addmarkbar(config, "Mark", m_mark_action); |
1192 | addmarkbar(config, "Annotate", m_annotate_action); | 1190 | addmarkbar(config, "Annotate", m_annotate_action); |
1193 | addmarkbar(config, "Goto", m_goto_action); | 1191 | addmarkbar(config, "Goto", m_goto_action); |
1194 | addmarkbar(config, "Delete", m_delete_action); | 1192 | addmarkbar(config, "Delete", m_delete_action); |
1195 | addmarkbar(config, "Autogen", m_autogen_action); | 1193 | addmarkbar(config, "Autogen", m_autogen_action); |
1196 | addmarkbar(config, "Clear", m_clear_action); | 1194 | addmarkbar(config, "Clear", m_clear_action); |
1197 | addmarkbar(config, "Save", m_save_action); | 1195 | addmarkbar(config, "Save", m_save_action); |
1198 | addmarkbar(config, "Tidy", m_tidy_action); | 1196 | addmarkbar(config, "Tidy", m_tidy_action); |
1199 | addmarkbar(config, "Start Block", m_startBlock_action); | 1197 | addmarkbar(config, "Start Block", m_startBlock_action); |
1200 | addmarkbar(config, "Copy Block", m_endBlock_action); | 1198 | addmarkbar(config, "Copy Block", m_endBlock_action); |
1201 | if (checkbar(config, "Annotation indicator")) | 1199 | if (checkbar(config, "Annotation indicator")) |
1202 | { | 1200 | { |
1203 | if (m_bkmkAvail == NULL) | 1201 | if (m_bkmkAvail == NULL) |
1204 | { | 1202 | { |
1205 | m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 ); | 1203 | m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 ); |
1206 | connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); | 1204 | connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); |
1207 | 1205 | ||
1208 | m_bkmkAvail->setEnabled(false); | 1206 | m_bkmkAvail->setEnabled(false); |
1209 | } | 1207 | } |
1210 | QLabel *spacer = new QLabel(markBar, ""); | 1208 | QLabel *spacer = new QLabel(markBar, ""); |
1211 | markbar()->setStretchableWidget(spacer); | 1209 | markbar()->setStretchableWidget(spacer); |
1212 | m_bkmkAvail->removeFrom( markbar() ); | 1210 | m_bkmkAvail->removeFrom( markbar() ); |
1213 | m_bkmkAvail->addTo( markbar() ); | 1211 | m_bkmkAvail->addTo( markbar() ); |
1214 | } | 1212 | } |
1215 | else | 1213 | else |
1216 | { | 1214 | { |
1217 | if (m_bkmkAvail != NULL) | 1215 | if (m_bkmkAvail != NULL) |
1218 | { | 1216 | { |
1219 | m_bkmkAvail->removeFrom( markbar() ); | 1217 | m_bkmkAvail->removeFrom( markbar() ); |
1220 | delete m_bkmkAvail; | 1218 | delete m_bkmkAvail; |
1221 | m_bkmkAvail = NULL; | 1219 | m_bkmkAvail = NULL; |
1222 | } | 1220 | } |
1223 | } | 1221 | } |
1224 | } | 1222 | } |
1225 | 1223 | ||
1226 | bool QTReaderApp::checkbar(Config* _config, const QString& key) | 1224 | bool QTReaderApp::checkbar(Config* _config, const QString& key) |
1227 | { | 1225 | { |
1228 | return _config->readBoolEntry(key, false); | 1226 | return _config->readBoolEntry(key, false); |
1229 | } | 1227 | } |
1230 | 1228 | ||
1231 | 1229 | ||
1232 | QToolBar* QTReaderApp::filebar() | 1230 | QToolBar* QTReaderApp::filebar() |
1233 | { | 1231 | { |
1234 | if (fileBar == NULL) | 1232 | if (fileBar == NULL) |
1235 | { | 1233 | { |
1236 | switch (m_tbpol) | 1234 | switch (m_tbpol) |
1237 | { | 1235 | { |
1238 | #ifdef USEQPE | 1236 | #ifdef USEQPE |
1239 | case cesSingle: | 1237 | case cesSingle: |
1240 | // qDebug("Setting filebar to menubar"); | 1238 | // qDebug("Setting filebar to menubar"); |
1241 | fileBar = menubar; | 1239 | fileBar = menubar; |
1242 | break; | 1240 | break; |
1243 | #endif | 1241 | #endif |
1244 | default: | 1242 | default: |
1245 | qDebug("Incorrect toolbar policy set"); | 1243 | qDebug("Incorrect toolbar policy set"); |
1246 | case cesMenuTool: | 1244 | case cesMenuTool: |
1247 | case cesMultiple: | 1245 | case cesMultiple: |
1248 | // qDebug("Creating new file bar"); | 1246 | // qDebug("Creating new file bar"); |
1249 | fileBar = new QToolBar("File", this, m_tbposition); | 1247 | fileBar = new QToolBar("File", this, m_tbposition); |
1250 | break; | 1248 | break; |
1251 | } | 1249 | } |
1252 | //fileBar->setHorizontalStretchable( true ); | 1250 | //fileBar->setHorizontalStretchable( true ); |
1253 | } | 1251 | } |
1254 | return fileBar; | 1252 | return fileBar; |
1255 | } | 1253 | } |
1256 | QToolBar* QTReaderApp::viewbar() | 1254 | QToolBar* QTReaderApp::viewbar() |
1257 | { | 1255 | { |
1258 | if (viewBar == NULL) | 1256 | if (viewBar == NULL) |
1259 | { | 1257 | { |
1260 | switch (m_tbpol) | 1258 | switch (m_tbpol) |
1261 | { | 1259 | { |
1262 | case cesMultiple: | 1260 | case cesMultiple: |
1263 | viewBar = new QToolBar("View", this, m_tbposition); | 1261 | viewBar = new QToolBar("View", this, m_tbposition); |
1264 | break; | 1262 | break; |
1265 | default: | 1263 | default: |
1266 | qDebug("Incorrect toolbar policy set"); | 1264 | qDebug("Incorrect toolbar policy set"); |
1267 | #ifdef USEQPE | 1265 | #ifdef USEQPE |
1268 | case cesSingle: | 1266 | case cesSingle: |
1269 | #endif | 1267 | #endif |
1270 | case cesMenuTool: | 1268 | case cesMenuTool: |
1271 | viewBar = fileBar; | 1269 | viewBar = fileBar; |
1272 | break; | 1270 | break; |
1273 | } | 1271 | } |
1274 | } | 1272 | } |
1275 | return viewBar; | 1273 | return viewBar; |
1276 | } | 1274 | } |
1277 | QToolBar* QTReaderApp::navbar() | 1275 | QToolBar* QTReaderApp::navbar() |
1278 | { | 1276 | { |
1279 | if (navBar == NULL) | 1277 | if (navBar == NULL) |
1280 | { | 1278 | { |
1281 | switch (m_tbpol) | 1279 | switch (m_tbpol) |
1282 | { | 1280 | { |
1283 | case cesMultiple: | 1281 | case cesMultiple: |
1284 | // qDebug("Creating new nav bar"); | 1282 | // qDebug("Creating new nav bar"); |
1285 | navBar = new QToolBar("Navigation", this, m_tbposition); | 1283 | navBar = new QToolBar("Navigation", this, m_tbposition); |
1286 | break; | 1284 | break; |
1287 | default: | 1285 | default: |
1288 | qDebug("Incorrect toolbar policy set"); | 1286 | qDebug("Incorrect toolbar policy set"); |
1289 | #ifdef USEQPE | 1287 | #ifdef USEQPE |
1290 | case cesSingle: | 1288 | case cesSingle: |
1291 | #endif | 1289 | #endif |
1292 | case cesMenuTool: | 1290 | case cesMenuTool: |
1293 | navBar = fileBar; | 1291 | navBar = fileBar; |
1294 | // qDebug("Setting navbar to filebar"); | 1292 | // qDebug("Setting navbar to filebar"); |
1295 | break; | 1293 | break; |
1296 | } | 1294 | } |
1297 | } | 1295 | } |
1298 | return navBar; | 1296 | return navBar; |
1299 | } | 1297 | } |
1300 | QToolBar* QTReaderApp::markbar() | 1298 | QToolBar* QTReaderApp::markbar() |
1301 | { | 1299 | { |
1302 | if (markBar == NULL) | 1300 | if (markBar == NULL) |
1303 | { | 1301 | { |
1304 | switch (m_tbpol) | 1302 | switch (m_tbpol) |
1305 | { | 1303 | { |
1306 | case cesMultiple: | 1304 | case cesMultiple: |
1307 | markBar = new QToolBar("Marks", this, m_tbposition); | 1305 | markBar = new QToolBar("Marks", this, m_tbposition); |
1308 | break; | 1306 | break; |
1309 | default: | 1307 | default: |
1310 | qDebug("Incorrect toolbar policy set"); | 1308 | qDebug("Incorrect toolbar policy set"); |
1311 | #ifdef USEQPE | 1309 | #ifdef USEQPE |
1312 | case cesSingle: | 1310 | case cesSingle: |
1313 | #endif | 1311 | #endif |
1314 | case cesMenuTool: | 1312 | case cesMenuTool: |
1315 | markBar = fileBar; | 1313 | markBar = fileBar; |
1316 | break; | 1314 | break; |
1317 | } | 1315 | } |
1318 | } | 1316 | } |
1319 | return markBar; | 1317 | return markBar; |
1320 | } | 1318 | } |
1321 | 1319 | ||
1322 | void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) | 1320 | void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) |
1323 | { | 1321 | { |
1324 | if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); | 1322 | if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); |
1325 | } | 1323 | } |
1326 | void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) | 1324 | void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) |
1327 | { | 1325 | { |
1328 | if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); | 1326 | if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); |
1329 | } | 1327 | } |
1330 | void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) | 1328 | void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) |
1331 | { | 1329 | { |
1332 | if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); | 1330 | if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); |
1333 | } | 1331 | } |
1334 | void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) | 1332 | void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) |
1335 | { | 1333 | { |
1336 | if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); | 1334 | if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); |
1337 | } | 1335 | } |
1338 | 1336 | ||
1339 | void QTReaderApp::suspend() { reader->suspend(); } | 1337 | void QTReaderApp::suspend() { reader->suspend(); } |
1340 | 1338 | ||
1341 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | 1339 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) |
1342 | { | 1340 | { |
1343 | #ifndef USEMSGS | 1341 | #ifndef USEMSGS |
1344 | return; | 1342 | return; |
1345 | #else | 1343 | #else |
1346 | QString msg = QString::fromUtf8(_msg); | 1344 | QString msg = QString::fromUtf8(_msg); |
1347 | 1345 | ||
1348 | qDebug("Received:%s", (const char*)msg); | 1346 | qDebug("Received:%s", (const char*)msg); |
1349 | QDataStream stream( _data, IO_ReadOnly ); | 1347 | QDataStream stream( _data, IO_ReadOnly ); |
1350 | if ( msg == "suspend()" ) | 1348 | if ( msg == "suspend()" ) |
1351 | { | 1349 | { |
1352 | qDebug("Suspending"); | 1350 | qDebug("Suspending"); |
1353 | suspend(); | 1351 | suspend(); |
1354 | qDebug("Suspendedb"); | 1352 | qDebug("Suspendedb"); |
1355 | } | 1353 | } |
1356 | return; | 1354 | return; |
1357 | /* | 1355 | /* |
1358 | QDataStream stream( _data, IO_ReadOnly ); | 1356 | QDataStream stream( _data, IO_ReadOnly ); |
1359 | if ( msg == "info(QString)" ) | 1357 | if ( msg == "info(QString)" ) |
1360 | { | 1358 | { |
1361 | QString info; | 1359 | QString info; |
1362 | stream >> info; | 1360 | stream >> info; |
1363 | QMessageBox::information(this, PROGNAME, info); | 1361 | QMessageBox::information(this, PROGNAME, info); |
1364 | } | 1362 | } |
1365 | else if ( msg == "Update(int)" ) | 1363 | else if ( msg == "Update(int)" ) |
1366 | { | 1364 | { |
1367 | int info; | 1365 | int info; |
1368 | stream >> info; | 1366 | stream >> info; |
1369 | if (info) | 1367 | if (info) |
1370 | { | 1368 | { |
1371 | reader->bDoUpdates = true; | 1369 | reader->bDoUpdates = true; |
1372 | reader->refresh(); | 1370 | reader->refresh(); |
1373 | } | 1371 | } |
1374 | else | 1372 | else |
1375 | { | 1373 | { |
1376 | reader->bDoUpdates = false; | 1374 | reader->bDoUpdates = false; |
1377 | } | 1375 | } |
1378 | } | 1376 | } |
1379 | else if ( msg == "warn(QString)" ) | 1377 | else if ( msg == "warn(QString)" ) |
1380 | { | 1378 | { |
1381 | QString info; | 1379 | QString info; |
1382 | stream >> info; | 1380 | stream >> info; |
1383 | QMessageBox::warning(this, PROGNAME, info); | 1381 | QMessageBox::warning(this, PROGNAME, info); |
1384 | } | 1382 | } |
1385 | else if ( msg == "exit()" ) | 1383 | else if ( msg == "exit()" ) |
1386 | { | 1384 | { |
1387 | m_dontSave = true; | 1385 | m_dontSave = true; |
1388 | close(); | 1386 | close(); |
1389 | } | 1387 | } |
1390 | else if ( msg == "pageDown()" ) | 1388 | else if ( msg == "pageDown()" ) |
1391 | { | 1389 | { |
1392 | reader->dopagedn(); | 1390 | reader->dopagedn(); |
1393 | } | 1391 | } |
1394 | else if ( msg == "pageUp()" ) | 1392 | else if ( msg == "pageUp()" ) |
1395 | { | 1393 | { |
1396 | reader->dopageup(); | 1394 | reader->dopageup(); |
1397 | } | 1395 | } |
1398 | else if ( msg == "lineDown()" ) | 1396 | else if ( msg == "lineDown()" ) |
1399 | { | 1397 | { |
1400 | reader->lineDown(); | 1398 | reader->lineDown(); |
1401 | } | 1399 | } |
1402 | else if ( msg == "lineUp()" ) | 1400 | else if ( msg == "lineUp()" ) |
1403 | { | 1401 | { |
1404 | reader->lineUp(); | 1402 | reader->lineUp(); |
1405 | } | 1403 | } |
1406 | else if ( msg == "showText()" ) | 1404 | else if ( msg == "showText()" ) |
1407 | { | 1405 | { |
1408 | showEditTools(); | 1406 | showEditTools(); |
1409 | } | 1407 | } |
1410 | else if ( msg == "home()" ) | 1408 | else if ( msg == "home()" ) |
1411 | { | 1409 | { |
1412 | reader->goHome(); | 1410 | reader->goHome(); |
1413 | } | 1411 | } |
1414 | else if ( msg == "back()" ) | 1412 | else if ( msg == "back()" ) |
1415 | { | 1413 | { |
1416 | reader->goBack(); | 1414 | reader->goBack(); |
1417 | } | 1415 | } |
1418 | else if ( msg == "forward()" ) | 1416 | else if ( msg == "forward()" ) |
1419 | { | 1417 | { |
1420 | reader->goForward(); | 1418 | reader->goForward(); |
1421 | } | 1419 | } |
1422 | else if ( msg == "File/Open(QString)" ) | 1420 | else if ( msg == "File/Open(QString)" ) |
1423 | { | 1421 | { |
1424 | QString info; | 1422 | QString info; |
1425 | stream >> info; | 1423 | stream >> info; |
1426 | openFile( info ); | 1424 | openFile( info ); |
1427 | } | 1425 | } |
1428 | else if ( msg == "File/Info()" ) | 1426 | else if ( msg == "File/Info()" ) |
1429 | { | 1427 | { |
1430 | showinfo(); | 1428 | showinfo(); |
1431 | } | 1429 | } |
1432 | else if ( msg == "File/Action(QString)" ) | 1430 | else if ( msg == "File/Action(QString)" ) |
1433 | { | 1431 | { |
1434 | QString info; | 1432 | QString info; |
1435 | stream >> info; | 1433 | stream >> info; |
1436 | m_spaceTarget = ActNameToInt(info); | 1434 | m_spaceTarget = ActNameToInt(info); |
1437 | } | 1435 | } |
1438 | else if ( msg == "Navigation/Scroll(int)" ) | 1436 | else if ( msg == "Navigation/Scroll(int)" ) |
1439 | { | 1437 | { |
1440 | int info; | 1438 | int info; |
1441 | stream >> info; | 1439 | stream >> info; |
1442 | autoScroll(info); | 1440 | autoScroll(info); |
1443 | } | 1441 | } |
1444 | 1442 | ||
1445 | else if ( msg == "Navigation/GotoStart()" ) | 1443 | else if ( msg == "Navigation/GotoStart()" ) |
1446 | { | 1444 | { |
1447 | gotoStart(); | 1445 | gotoStart(); |
1448 | } | 1446 | } |
1449 | else if ( msg == "Navigation/GotoEnd()" ) | 1447 | else if ( msg == "Navigation/GotoEnd()" ) |
1450 | { | 1448 | { |
1451 | gotoEnd(); | 1449 | gotoEnd(); |
1452 | } | 1450 | } |
1453 | else if ( msg == "Navigation/Jump(int)" ) | 1451 | else if ( msg == "Navigation/Jump(int)" ) |
1454 | { | 1452 | { |
1455 | int info; | 1453 | int info; |
1456 | stream >> info; | 1454 | stream >> info; |
1457 | reader->locate(info); | 1455 | reader->locate(info); |
1458 | } | 1456 | } |
1459 | else if ( msg == "Navigation/Page/LineScroll(int)" ) | 1457 | else if ( msg == "Navigation/Page/LineScroll(int)" ) |
1460 | { | 1458 | { |
1461 | int info; | 1459 | int info; |
1462 | stream >> info; | 1460 | stream >> info; |
1463 | pagemode(info); | 1461 | pagemode(info); |
1464 | } | 1462 | } |
1465 | else if ( msg == "Navigation/SetOverlap(int)" ) | 1463 | else if ( msg == "Navigation/SetOverlap(int)" ) |
1466 | { | 1464 | { |
1467 | int info; | 1465 | int info; |
1468 | stream >> info; | 1466 | stream >> info; |
1469 | reader->m_overlap = info; | 1467 | reader->m_overlap = info; |
1470 | } | 1468 | } |
1471 | else if ( msg == "Navigation/SetMargin(int)" ) | 1469 | else if ( msg == "Navigation/SetMargin(int)" ) |
1472 | { | 1470 | { |
1473 | int info; | 1471 | int info; |
1474 | stream >> info; | 1472 | stream >> info; |
1475 | do_margin(info); | 1473 | do_margin(info); |
1476 | } | 1474 | } |
1477 | else if ( msg == "File/SetDictionary(QString)" ) | 1475 | else if ( msg == "File/SetDictionary(QString)" ) |
1478 | { | 1476 | { |
1479 | QString info; | 1477 | QString info; |
1480 | stream >> info; | 1478 | stream >> info; |
1481 | do_settarget(info); | 1479 | do_settarget(info); |
1482 | } | 1480 | } |
1483 | #ifdef _SCROLLPIPE | 1481 | #ifdef _SCROLLPIPE |
1484 | else if ( msg == "File/SetScrollTarget(QString)" ) | 1482 | else if ( msg == "File/SetScrollTarget(QString)" ) |
1485 | { | 1483 | { |
1486 | QString info; | 1484 | QString info; |
1487 | stream >> info; | 1485 | stream >> info; |
1488 | reader->m_pipetarget = info; | 1486 | reader->m_pipetarget = info; |
1489 | } | 1487 | } |
1490 | #endif | 1488 | #endif |
1491 | else if ( msg == "File/Two/OneTouch(int)" ) | 1489 | else if ( msg == "File/Two/OneTouch(int)" ) |
1492 | { | 1490 | { |
1493 | int info; | 1491 | int info; |
1494 | stream >> info; | 1492 | stream >> info; |
1495 | setTwoTouch(info); | 1493 | setTwoTouch(info); |
1496 | } | 1494 | } |
1497 | else if ( msg == "Target/Annotation(int)" ) | 1495 | else if ( msg == "Target/Annotation(int)" ) |
1498 | { | 1496 | { |
1499 | int info; | 1497 | int info; |
1500 | stream >> info; | 1498 | stream >> info; |
1501 | OnAnnotation(info); | 1499 | OnAnnotation(info); |
1502 | } | 1500 | } |
1503 | else if ( msg == "Target/Dictionary(int)" ) | 1501 | else if ( msg == "Target/Dictionary(int)" ) |
1504 | { | 1502 | { |
1505 | int info; | 1503 | int info; |
1506 | stream >> info; | 1504 | stream >> info; |
1507 | OnDictionary(info); | 1505 | OnDictionary(info); |
1508 | } | 1506 | } |
1509 | else if ( msg == "Target/Clipboard(int)" ) | 1507 | else if ( msg == "Target/Clipboard(int)" ) |
1510 | { | 1508 | { |
1511 | int info; | 1509 | int info; |
1512 | stream >> info; | 1510 | stream >> info; |
1513 | OnClipboard(info); | 1511 | OnClipboard(info); |
1514 | } | 1512 | } |
1515 | else if ( msg == "File/Find(QString)" ) | 1513 | else if ( msg == "File/Find(QString)" ) |
1516 | { | 1514 | { |
1517 | QString info; | 1515 | QString info; |
1518 | stream >> info; | 1516 | stream >> info; |
1519 | QRegExp arg(info); | 1517 | QRegExp arg(info); |
1520 | size_t pos = reader->pagelocate(); | 1518 | size_t pos = reader->pagelocate(); |
1521 | size_t start = pos; | 1519 | size_t start = pos; |
1522 | CDrawBuffer test(&(reader->m_fontControl)); | 1520 | CDrawBuffer test(&(reader->m_fontControl)); |
1523 | reader->getline(&test); | 1521 | reader->getline(&test); |
1524 | while (arg.match(toQString(test.data())) == -1) | 1522 | while (arg.match(toQString(test.data())) == -1) |
1525 | { | 1523 | { |
1526 | pos = reader->locate(); | 1524 | pos = reader->locate(); |
1527 | if (!reader->getline(&test)) | 1525 | if (!reader->getline(&test)) |
1528 | { | 1526 | { |
1529 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); | 1527 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); |
1530 | pos = start; | 1528 | pos = start; |
1531 | break; | 1529 | break; |
1532 | } | 1530 | } |
1533 | } | 1531 | } |
1534 | reader->locate(pos); | 1532 | reader->locate(pos); |
1535 | } | 1533 | } |
1536 | else if ( msg == "File/Fullscreen(int)" ) | 1534 | else if ( msg == "File/Fullscreen(int)" ) |
1537 | { | 1535 | { |
1538 | int info; | 1536 | int info; |
1539 | stream >> info; | 1537 | stream >> info; |
1540 | setfullscreen(info); | 1538 | setfullscreen(info); |
1541 | } | 1539 | } |
1542 | else if ( msg == "File/Continuous(int)" ) | 1540 | else if ( msg == "File/Continuous(int)" ) |
1543 | { | 1541 | { |
1544 | int info; | 1542 | int info; |
1545 | stream >> info; | 1543 | stream >> info; |
1546 | setcontinuous(info); | 1544 | setcontinuous(info); |
1547 | } | 1545 | } |
1548 | else if ( msg == "Markup(QString)" ) | 1546 | else if ( msg == "Markup(QString)" ) |
1549 | { | 1547 | { |
1550 | QString info; | 1548 | QString info; |
1551 | stream >> info; | 1549 | stream >> info; |
1552 | if (info == "Auto") | 1550 | if (info == "Auto") |
1553 | { | 1551 | { |
1554 | autofmt(true); | 1552 | autofmt(true); |
1555 | } | 1553 | } |
1556 | if (info == "None") | 1554 | if (info == "None") |
1557 | { | 1555 | { |
1558 | autofmt(false); | 1556 | autofmt(false); |
1559 | textfmt(false); | 1557 | textfmt(false); |
1560 | striphtml(false); | 1558 | striphtml(false); |
1561 | peanut(false); | 1559 | peanut(false); |
1562 | } | 1560 | } |
1563 | if (info == "Text") | 1561 | if (info == "Text") |
1564 | { | 1562 | { |
1565 | textfmt(true); | 1563 | textfmt(true); |
1566 | } | 1564 | } |
1567 | if (info == "HTML") | 1565 | if (info == "HTML") |
1568 | { | 1566 | { |
1569 | striphtml(true); | 1567 | striphtml(true); |
1570 | } | 1568 | } |
1571 | if (info == "Peanut/PML") | 1569 | if (info == "Peanut/PML") |
1572 | { | 1570 | { |
1573 | peanut(true); | 1571 | peanut(true); |
1574 | } | 1572 | } |
1575 | } | 1573 | } |
1576 | else if ( msg == "Layout/StripCR(int)" ) | 1574 | else if ( msg == "Layout/StripCR(int)" ) |
1577 | { | 1575 | { |
1578 | int info; | 1576 | int info; |
1579 | stream >> info; | 1577 | stream >> info; |
1580 | stripcr(info); | 1578 | stripcr(info); |
1581 | } | 1579 | } |
1582 | else if ( msg == "Layout/Dehyphen(int)" ) | 1580 | else if ( msg == "Layout/Dehyphen(int)" ) |
1583 | { | 1581 | { |
1584 | int info; | 1582 | int info; |
1585 | stream >> info; | 1583 | stream >> info; |
1586 | dehyphen(info); | 1584 | dehyphen(info); |
1587 | } | 1585 | } |
1588 | else if ( msg == "Layout/Depluck(int)" ) | 1586 | else if ( msg == "Layout/Depluck(int)" ) |
1589 | { | 1587 | { |
1590 | int info; | 1588 | int info; |
1591 | stream >> info; | 1589 | stream >> info; |
1592 | depluck(info); | 1590 | depluck(info); |
1593 | } | 1591 | } |
1594 | else if ( msg == "Layout/Dejpluck(int)" ) | 1592 | else if ( msg == "Layout/Dejpluck(int)" ) |
1595 | { | 1593 | { |
1596 | int info; | 1594 | int info; |
1597 | stream >> info; | 1595 | stream >> info; |
1598 | dejpluck(info); | 1596 | dejpluck(info); |
1599 | } | 1597 | } |
1600 | else if ( msg == "Layout/SingleSpace(int)" ) | 1598 | else if ( msg == "Layout/SingleSpace(int)" ) |
1601 | { | 1599 | { |
1602 | int info; | 1600 | int info; |
1603 | stream >> info; | 1601 | stream >> info; |
1604 | onespace(info); | 1602 | onespace(info); |
1605 | } | 1603 | } |
1606 | else if ( msg == "Layout/Repalm(int)" ) | 1604 | else if ( msg == "Layout/Repalm(int)" ) |
1607 | { | 1605 | { |
1608 | int info; | 1606 | int info; |
1609 | stream >> info; | 1607 | stream >> info; |
1610 | repalm(info); | 1608 | repalm(info); |
1611 | } | 1609 | } |
1612 | else if ( msg == "Layout/Unindent(int)" ) | 1610 | else if ( msg == "Layout/Unindent(int)" ) |
1613 | { | 1611 | { |
1614 | int info; | 1612 | int info; |
1615 | stream >> info; | 1613 | stream >> info; |
1616 | unindent(info); | 1614 | unindent(info); |
1617 | } | 1615 | } |
1618 | else if ( msg == "Layout/Re-paragraph(int)" ) | 1616 | else if ( msg == "Layout/Re-paragraph(int)" ) |
1619 | { | 1617 | { |
1620 | int info; | 1618 | int info; |
1621 | stream >> info; | 1619 | stream >> info; |
1622 | repara(info); | 1620 | repara(info); |
1623 | } | 1621 | } |
1624 | else if ( msg == "Layout/DoubleSpace(int)" ) | 1622 | else if ( msg == "Layout/DoubleSpace(int)" ) |
1625 | { | 1623 | { |
1626 | int info; | 1624 | int info; |
1627 | stream >> info; | 1625 | stream >> info; |
1628 | dblspce(info); | 1626 | dblspce(info); |
1629 | } | 1627 | } |
1630 | else if ( msg == "Layout/Indent(int)" ) | 1628 | else if ( msg == "Layout/Indent(int)" ) |
1631 | { | 1629 | { |
1632 | int info; | 1630 | int info; |
1633 | stream >> info; | 1631 | stream >> info; |
1634 | reader->bindenter = info; | 1632 | reader->bindenter = info; |
1635 | reader->setfilter(reader->getfilter()); | 1633 | reader->setfilter(reader->getfilter()); |
1636 | } | 1634 | } |
1637 | else if ( msg == "Layout/Remap(int)" ) | 1635 | else if ( msg == "Layout/Remap(int)" ) |
1638 | { | 1636 | { |
1639 | int info; | 1637 | int info; |
1640 | stream >> info; | 1638 | stream >> info; |
1641 | remap(info); | 1639 | remap(info); |
1642 | } | 1640 | } |
1643 | else if ( msg == "Layout/Embolden(int)" ) | 1641 | else if ( msg == "Layout/Embolden(int)" ) |
1644 | { | 1642 | { |
1645 | int info; | 1643 | int info; |
1646 | stream >> info; | 1644 | stream >> info; |
1647 | embolden(info); | 1645 | embolden(info); |
1648 | } | 1646 | } |
1649 | else if ( msg == "Format/Ideogram/Word(int)" ) | 1647 | else if ( msg == "Format/Ideogram/Word(int)" ) |
1650 | { | 1648 | { |
1651 | int info; | 1649 | int info; |
1652 | stream >> info; | 1650 | stream >> info; |
1653 | monospace(info); | 1651 | monospace(info); |
1654 | } | 1652 | } |
1655 | else if ( msg == "Format/SetWidth(int)" ) | 1653 | else if ( msg == "Format/SetWidth(int)" ) |
1656 | { | 1654 | { |
1657 | int info; | 1655 | int info; |
1658 | stream >> info; | 1656 | stream >> info; |
1659 | reader->m_charpc = info; | 1657 | reader->m_charpc = info; |
1660 | reader->setfont(); | 1658 | reader->setfont(); |
1661 | reader->refresh(); | 1659 | reader->refresh(); |
1662 | } | 1660 | } |
1663 | else if ( msg == "Format/SetFont(QString,int)" ) | 1661 | else if ( msg == "Format/SetFont(QString,int)" ) |
1664 | { | 1662 | { |
1665 | QString fontname; | 1663 | QString fontname; |
1666 | int size; | 1664 | int size; |
1667 | stream >> fontname; | 1665 | stream >> fontname; |
1668 | stream >> size; | 1666 | stream >> size; |
1669 | setfontHelper(fontname, size); | 1667 | setfontHelper(fontname, size); |
1670 | } | 1668 | } |
1671 | else if ( msg == "Marks/Autogen(QString)" ) | 1669 | else if ( msg == "Marks/Autogen(QString)" ) |
1672 | { | 1670 | { |
1673 | QString info; | 1671 | QString info; |
1674 | stream >> info; | 1672 | stream >> info; |
1675 | do_autogen(info); | 1673 | do_autogen(info); |
1676 | } | 1674 | } |
1677 | else if ( msg == "File/StartBlock()" ) | 1675 | else if ( msg == "File/StartBlock()" ) |
1678 | { | 1676 | { |
1679 | editMark(); | 1677 | editMark(); |
1680 | } | 1678 | } |
1681 | else if ( msg == "File/CopyBlock()" ) | 1679 | else if ( msg == "File/CopyBlock()" ) |
1682 | { | 1680 | { |
1683 | editCopy(); | 1681 | editCopy(); |
1684 | } | 1682 | } |
1685 | */ | 1683 | */ |
1686 | #endif | 1684 | #endif |
1687 | } | 1685 | } |
1688 | 1686 | ||
1689 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) | 1687 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) |
1690 | { | 1688 | { |
1691 | for (int i = 0; i < MAX_ACTIONS; i++) | 1689 | for (int i = 0; i < MAX_ACTIONS; i++) |
1692 | { | 1690 | { |
1693 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; | 1691 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; |
1694 | } | 1692 | } |
1695 | return cesAutoScroll; | 1693 | return cesAutoScroll; |
1696 | } | 1694 | } |
1697 | 1695 | ||
1698 | void QTReaderApp::setinverted(bool sfs) | 1696 | void QTReaderApp::setinverted(bool sfs) |
1699 | { | 1697 | { |
1700 | reader->setInverse(sfs); | 1698 | reader->setInverse(sfs); |
1701 | reader->setfilter(reader->getfilter()); | 1699 | reader->setfilter(reader->getfilter()); |
1702 | reader->refresh(); | 1700 | reader->refresh(); |
1703 | } | 1701 | } |
1704 | 1702 | ||
1705 | void QTReaderApp::setrotated(bool sfs) | 1703 | void QTReaderApp::setrotated(bool sfs) |
1706 | { | 1704 | { |
1707 | reader->setrotated(sfs); | 1705 | reader->setrotated(sfs); |
1708 | if (sfs) | 1706 | if (sfs) |
1709 | { | 1707 | { |
1710 | m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::BottomToTop : QBoxLayout::TopToBottom ); | 1708 | m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::BottomToTop : QBoxLayout::TopToBottom ); |
1711 | if (m_scrollbar != NULL) | 1709 | if (m_scrollbar != NULL) |
1712 | { | 1710 | { |
1713 | scrollbar->disconnect(); | 1711 | scrollbar->disconnect(); |
1714 | m_scrollbar->setOrientation(Qt::Horizontal); | 1712 | m_scrollbar->setOrientation(Qt::Horizontal); |
1715 | connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineUp()) ); | 1713 | connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineUp()) ); |
1716 | connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineDown()) ); | 1714 | connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineDown()) ); |
1717 | connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopageup()) ); | 1715 | connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopageup()) ); |
1718 | connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopagedn()) ); | 1716 | connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopagedn()) ); |
1719 | connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); | 1717 | connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); |
1720 | } | 1718 | } |
1721 | //reader->repaint(0, reader->m_left_border, reader->width(), reader->height()-2*reader->m_border); | 1719 | //reader->repaint(0, reader->m_left_border, reader->width(), reader->height()-2*reader->m_border); |
1722 | reader->repaint(); | 1720 | reader->repaint(); |
1723 | } | 1721 | } |
1724 | else | 1722 | else |
1725 | { | 1723 | { |
1726 | m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight ); | 1724 | m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight ); |
1727 | if (m_scrollbar != NULL) | 1725 | if (m_scrollbar != NULL) |
1728 | { | 1726 | { |
1729 | scrollbar->disconnect(); | 1727 | scrollbar->disconnect(); |
1730 | m_scrollbar->setOrientation(Qt::Vertical); | 1728 | m_scrollbar->setOrientation(Qt::Vertical); |
1731 | connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineDown()) ); | 1729 | connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineDown()) ); |
1732 | connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineUp()) ); | 1730 | connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineUp()) ); |
1733 | connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopagedn()) ); | 1731 | connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopagedn()) ); |
1734 | connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopageup()) ); | 1732 | connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopageup()) ); |
1735 | connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); | 1733 | connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); |
1736 | } | 1734 | } |
1737 | //reader->repaint(reader->m_border, 0, reader->width()-2*reader->m_border, reader->height()); | 1735 | //reader->repaint(reader->m_border, 0, reader->width()-2*reader->m_border, reader->height()); |
1738 | reader->repaint(); | 1736 | reader->repaint(); |
1739 | } | 1737 | } |
1740 | // reader->update(); | 1738 | // reader->update(); |
1741 | } | 1739 | } |
1742 | 1740 | ||
1743 | void QTReaderApp::setgrab(bool sfs) | 1741 | void QTReaderApp::setgrab(bool sfs) |
1744 | { | 1742 | { |
1745 | #ifdef USEQPE | 1743 | #ifdef USEQPE |
1746 | m_grabkeyboard = sfs; | 1744 | m_grabkeyboard = sfs; |
1747 | if (m_grabkeyboard) | 1745 | if (m_grabkeyboard) |
1748 | { | 1746 | { |
1749 | ((QPEApplication*)qApp)->grabKeyboard(); | 1747 | ((QPEApplication*)qApp)->grabKeyboard(); |
1750 | } | 1748 | } |
1751 | else | 1749 | else |
1752 | { | 1750 | { |
1753 | ((QPEApplication*)qApp)->ungrabKeyboard(); | 1751 | ((QPEApplication*)qApp)->ungrabKeyboard(); |
1754 | } | 1752 | } |
1755 | #endif | 1753 | #endif |
1756 | } | 1754 | } |
1757 | 1755 | ||
1758 | void QTReaderApp::setfullscreen(bool sfs) | 1756 | void QTReaderApp::setfullscreen(bool sfs) |
1759 | { | 1757 | { |
1760 | reader->bDoUpdates = false; | 1758 | reader->bDoUpdates = false; |
1761 | m_fullscreen = sfs; | 1759 | m_fullscreen = sfs; |
1762 | showEditTools(); | 1760 | showEditTools(); |
1763 | // qApp->processEvents(); | 1761 | // qApp->processEvents(); |
1764 | reader->bDoUpdates = true; | 1762 | reader->bDoUpdates = true; |
1765 | reader->update(); | 1763 | reader->update(); |
1766 | } | 1764 | } |
1767 | /* | 1765 | /* |
1768 | void QTReaderApp::buttonActionSelected(QAction* _a) | 1766 | void QTReaderApp::buttonActionSelected(QAction* _a) |
1769 | { | 1767 | { |
1770 | //// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); | 1768 | //// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); |
1771 | m_spaceTarget = ActNameToInt(_a->text()); | 1769 | m_spaceTarget = ActNameToInt(_a->text()); |
1772 | } | 1770 | } |
1773 | */ | 1771 | */ |
1774 | QTReaderApp::~QTReaderApp() | 1772 | QTReaderApp::~QTReaderApp() |
1775 | { | 1773 | { |
1776 | } | 1774 | } |
1777 | 1775 | ||
1778 | void QTReaderApp::autoScroll(bool _b) | 1776 | void QTReaderApp::autoScroll(bool _b) |
1779 | { | 1777 | { |
1780 | reader->setautoscroll(_b); | 1778 | reader->setautoscroll(_b); |
1781 | setScrollState(reader->m_autoScroll); | 1779 | setScrollState(reader->m_autoScroll); |
1782 | } | 1780 | } |
1783 | 1781 | ||
1784 | void QTReaderApp::zoomin() | 1782 | void QTReaderApp::zoomin() |
1785 | { | 1783 | { |
1786 | reader->zoomin(); | 1784 | reader->zoomin(); |
1787 | QFont f(reader->m_fontname, reader->m_fontControl.getsize(0)); | 1785 | QFont f(reader->m_fontname, reader->m_fontControl.getsize(0)); |
1788 | m_prog->setFont( f ); | 1786 | m_prog->setFont( f ); |
1789 | } | 1787 | } |
1790 | 1788 | ||
1791 | void QTReaderApp::zoomout() | 1789 | void QTReaderApp::zoomout() |
1792 | { | 1790 | { |
1793 | reader->zoomout(); | 1791 | reader->zoomout(); |
1794 | QFont f(reader->m_fontname, reader->m_fontControl.getsize(0)); | 1792 | QFont f(reader->m_fontname, reader->m_fontControl.getsize(0)); |
1795 | m_prog->setFont( f ); | 1793 | m_prog->setFont( f ); |
1796 | } | 1794 | } |
1797 | 1795 | ||
1798 | void QTReaderApp::clearBkmkList() | 1796 | void QTReaderApp::clearBkmkList() |
1799 | { | 1797 | { |
1800 | delete pBkmklist; | 1798 | delete pBkmklist; |
1801 | reader->pBkmklist = pBkmklist = NULL; | 1799 | reader->pBkmklist = pBkmklist = NULL; |
1802 | m_fBkmksChanged = false; | 1800 | m_fBkmksChanged = false; |
1803 | reader->refresh(true); | 1801 | reader->refresh(true); |
1804 | } | 1802 | } |
1805 | 1803 | ||
1806 | void QTReaderApp::fileClose() | 1804 | void QTReaderApp::fileClose() |
1807 | { | 1805 | { |
1808 | CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); | 1806 | CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); |
1809 | if (cd->exec()) | 1807 | if (cd->exec()) |
1810 | { | 1808 | { |
1811 | if (pOpenlist != NULL) | 1809 | if (pOpenlist != NULL) |
1812 | { | 1810 | { |
1813 | int ind = 0; | 1811 | int ind = 0; |
1814 | Bkmk* p = (*pOpenlist)[ind]; | 1812 | Bkmk* p = (*pOpenlist)[ind]; |
1815 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | 1813 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) |
1816 | { | 1814 | { |
1817 | p = (*pOpenlist)[++ind]; | 1815 | p = (*pOpenlist)[++ind]; |
1818 | } | 1816 | } |
1819 | if (p != NULL) pOpenlist->erase(ind); | 1817 | if (p != NULL) pOpenlist->erase(ind); |
1820 | if (cd->delFile()) | 1818 | if (cd->delFile()) |
1821 | { | 1819 | { |
1822 | unlink((const char*)reader->m_lastfile); | 1820 | unlink((const char*)reader->m_lastfile); |
1823 | } | 1821 | } |
1824 | if (cd->delMarks()) | 1822 | if (cd->delMarks()) |
1825 | { | 1823 | { |
1826 | #ifndef USEQPE | 1824 | #ifndef USEQPE |
1827 | QDir d = QDir::home(); // "/" | 1825 | QDir d = QDir::home(); // "/" |
1828 | d.cd(APPDIR); | 1826 | d.cd(APPDIR); |
1829 | d.remove(reader->m_string); | 1827 | d.remove(reader->m_string); |
1830 | #else /* USEQPE */ | 1828 | #else /* USEQPE */ |
1831 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 1829 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
1832 | #endif /* USEQPE */ | 1830 | #endif /* USEQPE */ |
1833 | } | 1831 | } |
1834 | if (cd->delConfig()) | 1832 | if (cd->delConfig()) |
1835 | { | 1833 | { |
1836 | #ifndef USEQPE | 1834 | #ifndef USEQPE |
1837 | QDir d = QDir::home(); // "/" | 1835 | QDir d = QDir::home(); // "/" |
1838 | d.cd(APPDIR "/configs"); | 1836 | d.cd(APPDIR "/configs"); |
1839 | d.remove(reader->m_string); | 1837 | d.remove(reader->m_string); |
1840 | #else /* USEQPE */ | 1838 | #else /* USEQPE */ |
1841 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); | 1839 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); |
1842 | #endif /* USEQPE */ | 1840 | #endif /* USEQPE */ |
1843 | } | 1841 | } |
1844 | } | 1842 | } |
1845 | 1843 | ||
1846 | fileOpen2(); | 1844 | fileOpen2(); |
1847 | } | 1845 | } |
1848 | delete cd; | 1846 | delete cd; |
1849 | } | 1847 | } |
1850 | 1848 | ||
1851 | void QTReaderApp::updatefileinfo() | 1849 | void QTReaderApp::updatefileinfo() |
1852 | { | 1850 | { |
1853 | if (reader->m_string.isEmpty()) return; | 1851 | if (reader->m_string.isEmpty()) return; |
1854 | if (reader->m_lastfile.isEmpty()) return; | 1852 | if (reader->m_lastfile.isEmpty()) return; |
1855 | tchar* nm = fromQString(reader->m_string); | 1853 | tchar* nm = fromQString(reader->m_string); |
1856 | tchar* fl = fromQString(reader->m_lastfile); | 1854 | tchar* fl = fromQString(reader->m_lastfile); |
1857 | // qDebug("Lastfile:%x", fl); | 1855 | // qDebug("Lastfile:%x", fl); |
1858 | bool notadded = true; | 1856 | bool notadded = true; |
1859 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; | 1857 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; |
1860 | else | 1858 | else |
1861 | { | 1859 | { |
1862 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | 1860 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) |
1863 | { | 1861 | { |
1864 | if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) | 1862 | if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) |
1865 | { | 1863 | { |
1866 | iter->value(reader->pagelocate()); | 1864 | iter->value(reader->pagelocate()); |
1867 | unsigned short dlen; | 1865 | unsigned short dlen; |
1868 | unsigned char* data; | 1866 | unsigned char* data; |
1869 | CFiledata fd(iter->anno()); | 1867 | CFiledata fd(iter->anno()); |
1870 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | 1868 | reader->setSaveData(data, dlen, fd.content(), fd.length()); |
1871 | // qDebug("Filedata(1):%u, %u", fd.length(), dlen); | 1869 | // qDebug("Filedata(1):%u, %u", fd.length(), dlen); |
1872 | // getstate(data, dlen); | 1870 | // getstate(data, dlen); |
1873 | iter->setAnno(data, dlen); | 1871 | iter->setAnno(data, dlen); |
1874 | notadded = false; | 1872 | notadded = false; |
1875 | delete [] data; | 1873 | delete [] data; |
1876 | break; | 1874 | break; |
1877 | } | 1875 | } |
1878 | } | 1876 | } |
1879 | } | 1877 | } |
1880 | // qDebug("Added?:%x", notadded); | 1878 | // qDebug("Added?:%x", notadded); |
1881 | if (notadded) | 1879 | if (notadded) |
1882 | { | 1880 | { |
1883 | struct stat fnstat; | 1881 | struct stat fnstat; |
1884 | stat((const char *)reader->m_lastfile, &fnstat); | 1882 | stat((const char *)reader->m_lastfile, &fnstat); |
1885 | CFiledata fd(fnstat.st_mtime, fl); | 1883 | CFiledata fd(fnstat.st_mtime, fl); |
1886 | unsigned short dlen; | 1884 | unsigned short dlen; |
1887 | unsigned char* data; | 1885 | unsigned char* data; |
1888 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | 1886 | reader->setSaveData(data, dlen, fd.content(), fd.length()); |
1889 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); | 1887 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); |
1890 | //qDebug("Filedata(2):%u, %u", fd.length(), dlen); | 1888 | //qDebug("Filedata(2):%u, %u", fd.length(), dlen); |
1891 | delete [] data; | 1889 | delete [] data; |
1892 | } | 1890 | } |
1893 | delete [] nm; | 1891 | delete [] nm; |
1894 | delete [] fl; | 1892 | delete [] fl; |
1895 | } | 1893 | } |
1896 | 1894 | ||
1897 | void QTReaderApp::fileOpen() | 1895 | void QTReaderApp::fileOpen() |
1898 | { | 1896 | { |
1899 | /* | 1897 | /* |
1900 | menu->hide(); | 1898 | menu->hide(); |
1901 | fileBar->hide(); | 1899 | fileBar->hide(); |
1902 | if (regVisible) regBar->hide(); | 1900 | if (regVisible) regBar->hide(); |
1903 | if (searchVisible) searchBar->hide(); | 1901 | if (searchVisible) searchBar->hide(); |
1904 | */ | 1902 | */ |
1905 | // qDebug("fileOpen"); | 1903 | // qDebug("fileOpen"); |
1906 | // if (!reader->m_lastfile.isEmpty()) | 1904 | // if (!reader->m_lastfile.isEmpty()) |
1907 | updatefileinfo(); | 1905 | updatefileinfo(); |
1908 | fileOpen2(); | 1906 | fileOpen2(); |
1909 | } | 1907 | } |
1910 | 1908 | ||
1911 | void QTReaderApp::fileOpen2() | 1909 | void QTReaderApp::fileOpen2() |
1912 | { | 1910 | { |
1913 | if (pBkmklist != NULL) | 1911 | if (pBkmklist != NULL) |
1914 | { | 1912 | { |
1915 | if (m_fBkmksChanged) | 1913 | if (m_fBkmksChanged) |
1916 | { | 1914 | { |
1917 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | 1915 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
1918 | savebkmks(); | 1916 | savebkmks(); |
1919 | } | 1917 | } |
1920 | delete pBkmklist; | 1918 | delete pBkmklist; |
1921 | reader->pBkmklist = pBkmklist = NULL; | 1919 | reader->pBkmklist = pBkmklist = NULL; |
1922 | m_fBkmksChanged = false; | 1920 | m_fBkmksChanged = false; |
1923 | } | 1921 | } |
1924 | reader->disableAutoscroll(); | 1922 | reader->disableAutoscroll(); |
1925 | /* | 1923 | /* |
1926 | editorStack->raiseWidget( fileSelector ); | 1924 | editorStack->raiseWidget( fileSelector ); |
1927 | fileSelector->reread(); | 1925 | fileSelector->reread(); |
1928 | */ | 1926 | */ |
1929 | bool usebrowser = true; | 1927 | bool usebrowser = true; |
1930 | if (pOpenlist != NULL) | 1928 | if (pOpenlist != NULL) |
1931 | { | 1929 | { |
1932 | m_nBkmkAction = cOpenFile; | 1930 | m_nBkmkAction = cOpenFile; |
1933 | if (listbkmk(pOpenlist, "Browse")) usebrowser = false; | 1931 | if (listbkmk(pOpenlist, "Browse")) usebrowser = false; |
1934 | } | 1932 | } |
1935 | if (usebrowser) | 1933 | if (usebrowser) |
1936 | { | 1934 | { |
1937 | QString fn = usefilebrowser(); | 1935 | QString fn = usefilebrowser(); |
1938 | //qApp->processEvents(); | 1936 | //qApp->processEvents(); |
1939 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 1937 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
1940 | { | 1938 | { |
1941 | openFile(fn); | 1939 | openFile(fn); |
1942 | } | 1940 | } |
1943 | reader->setFocus(); | 1941 | reader->setFocus(); |
1944 | } | 1942 | } |
1945 | // reader->refresh(); | 1943 | // reader->refresh(); |
1946 | // qDebug("HEIGHT:%d", reader->m_lastheight); | 1944 | // qDebug("HEIGHT:%d", reader->m_lastheight); |
1947 | } | 1945 | } |
1948 | 1946 | ||
1949 | QString QTReaderApp::usefilebrowser() | 1947 | QString QTReaderApp::usefilebrowser() |
1950 | { | 1948 | { |
1951 | #ifndef USEQPE | 1949 | #ifndef USEQPE |
1952 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); | 1950 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); |
1953 | return s; | 1951 | return s; |
1954 | #else | 1952 | #else |
1955 | QString fn; | 1953 | QString fn; |
1956 | #ifdef OPIE | 1954 | #ifdef OPIE |
1957 | QMap<QString, QStringList> mimeTypes; | 1955 | QMap<QString, QStringList> mimeTypes; |
1958 | QStringList etypes; | 1956 | QStringList etypes; |
1959 | etypes << "etext/*"; | 1957 | etypes << "etext/*"; |
1960 | mimeTypes.insert( tr("eText"), etypes ); | 1958 | mimeTypes.insert( tr("eText"), etypes ); |
1961 | QStringList types; | 1959 | QStringList types; |
1962 | types << "text/*"; | 1960 | types << "text/*"; |
1963 | mimeTypes.insert( tr("Text"), types ); | 1961 | mimeTypes.insert( tr("Text"), types ); |
1964 | mimeTypes.insert( tr("All"), "*/*" ); | 1962 | mimeTypes.insert( tr("All"), "*/*" ); |
1965 | fn = OFileDialog::getOpenFileName(OFileSelector::EXTENDED_ALL, QFileInfo(reader->m_lastfile).dirPath(true), QString::null, mimeTypes, 0, "OpieReader"); | 1963 | fn = OFileDialog::getOpenFileName(OFileSelector::EXTENDED_ALL, QFileInfo(reader->m_lastfile).dirPath(true), QString::null, mimeTypes, 0, "OpieReader"); |
1966 | #else | 1964 | #else |
1967 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, | 1965 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, |
1968 | 0, | 1966 | 0, |
1969 | // WStyle_Customize | WStyle_NoBorderEx, | 1967 | // WStyle_Customize | WStyle_NoBorderEx, |
1970 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); | 1968 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); |
1971 | 1969 | ||
1972 | 1970 | ||
1973 | if (fb->exec()) | 1971 | if (fb->exec()) |
1974 | { | 1972 | { |
1975 | fn = fb->getCurrentFile(); | 1973 | fn = fb->getCurrentFile(); |
1976 | } | 1974 | } |
1977 | // qDebug("Selected %s", (const char*)fn); | 1975 | // qDebug("Selected %s", (const char*)fn); |
1978 | delete fb; | 1976 | delete fb; |
1979 | #endif | 1977 | #endif |
1980 | showEditTools(); | 1978 | showEditTools(); |
1981 | return fn; | 1979 | return fn; |
1982 | #endif | 1980 | #endif |
1983 | } | 1981 | } |
1984 | 1982 | ||
1985 | void QTReaderApp::showgraphic(QImage& pm) | 1983 | void QTReaderApp::showgraphic(QImage& pm) |
1986 | { | 1984 | { |
1987 | m_graphicwin->setImage(pm); | 1985 | m_graphicwin->setImage(pm); |
1988 | editorStack->raiseWidget( m_graphicwin ); | 1986 | editorStack->raiseWidget( m_graphicwin ); |
1989 | hidetoolbars(); | 1987 | hidetoolbars(); |
1990 | m_graphicwin->setFocus(); | 1988 | m_graphicwin->setFocus(); |
1991 | } | 1989 | } |
1992 | 1990 | ||
1993 | void QTReaderApp::showbuttonprefs() | 1991 | void QTReaderApp::showbuttonprefs() |
1994 | { | 1992 | { |
1995 | editorStack->raiseWidget( m_buttonprefs ); | 1993 | editorStack->raiseWidget( m_buttonprefs ); |
1996 | hidetoolbars(); | 1994 | hidetoolbars(); |
1997 | m_buttonprefs->setFocus(); | 1995 | m_buttonprefs->setFocus(); |
1998 | m_kmapchanged = true; | 1996 | m_kmapchanged = true; |
1999 | } | 1997 | } |
2000 | 1998 | ||
2001 | void QTReaderApp::showprefs() | 1999 | void QTReaderApp::showprefs() |
2002 | { | 2000 | { |
2003 | CPrefs* prefwin = new CPrefs(reader->width(), !m_bFloatingDialog, this); | 2001 | CPrefs* prefwin = new CPrefs(reader->width(), !m_bFloatingDialog, this); |
2004 | 2002 | ||
2005 | // prefwin->Debounce(m_debounce); | 2003 | // prefwin->Debounce(m_debounce); |
2006 | prefwin->bgtype(m_bgtype); | 2004 | prefwin->bgtype(m_bgtype); |
2007 | prefwin->repalm(reader->brepalm); | 2005 | prefwin->repalm(reader->brepalm); |
2008 | prefwin->kern(reader->bkern); | 2006 | prefwin->kern(reader->bkern); |
2009 | prefwin->hyphenate(reader->hyphenate); | 2007 | prefwin->hyphenate(reader->hyphenate); |
2010 | // prefwin->customhyphen(reader->buffdoc.getCustomHyphen()); | 2008 | // prefwin->customhyphen(reader->buffdoc.getCustomHyphen()); |
2011 | prefwin->scrolltype(reader->m_scrolltype); | 2009 | prefwin->scrolltype(reader->m_scrolltype); |
2012 | prefwin->scrollstep(reader->m_scrollstep); | 2010 | prefwin->scrollstep(reader->m_scrollstep); |
2013 | prefwin->scrollcolor(m_scrollcolor); | 2011 | prefwin->scrollcolor(m_scrollcolor); |
2014 | prefwin->minibarcol(m_scrollbarcolor); | 2012 | prefwin->minibarcol(m_scrollbarcolor); |
2015 | prefwin->foreground(m_foreground); | 2013 | prefwin->foreground(m_foreground); |
2016 | prefwin->background(m_background); | 2014 | prefwin->background(m_background); |
2017 | prefwin->twotouch(m_twoTouch); | 2015 | prefwin->twotouch(m_twoTouch); |
2018 | prefwin->propfontchange(m_propogatefontchange); | 2016 | prefwin->propfontchange(m_propogatefontchange); |
2019 | prefwin->StripCR(reader->bstripcr); | 2017 | prefwin->StripCR(reader->bstripcr); |
2020 | prefwin->Dehyphen(reader->bdehyphen); | 2018 | prefwin->Dehyphen(reader->bdehyphen); |
2021 | prefwin->SingleSpace(reader->bonespace); | 2019 | prefwin->SingleSpace(reader->bonespace); |
2022 | prefwin->Unindent(reader->bunindent); | 2020 | prefwin->Unindent(reader->bunindent); |
2023 | prefwin->Reparagraph(reader->brepara); | 2021 | prefwin->Reparagraph(reader->brepara); |
2024 | prefwin->DoubleSpace(reader->bdblspce); | 2022 | prefwin->DoubleSpace(reader->bdblspce); |
2025 | prefwin->Remap(reader->bremap); | 2023 | prefwin->Remap(reader->bremap); |
2026 | prefwin->Embolden(reader->bmakebold); | 2024 | prefwin->Embolden(reader->bmakebold); |
2027 | prefwin->FullJustify(reader->bfulljust); | 2025 | prefwin->FullJustify(reader->bfulljust); |
2028 | // prefwin->Inverse(reader->bInverse); | 2026 | // prefwin->Inverse(reader->bInverse); |
2029 | // prefwin->Negative(reader->bNegative); | 2027 | // prefwin->Negative(reader->bNegative); |
2030 | prefwin->FixGraphics(reader->m_fontControl.FixGraphics()); | 2028 | prefwin->FixGraphics(reader->m_fontControl.FixGraphics()); |
2031 | prefwin->ParaLead(reader->getextraspace()); | 2029 | prefwin->ParaLead(reader->getextraspace()); |
2032 | prefwin->LineLead(reader->getlead()); | 2030 | prefwin->LineLead(reader->getlead()); |
2033 | prefwin->TopMargin(reader->m_abstopmargin); | 2031 | prefwin->TopMargin(reader->m_abstopmargin); |
2034 | prefwin->BottomMargin(reader->m_absbottommargin); | 2032 | prefwin->BottomMargin(reader->m_absbottommargin); |
2035 | prefwin->LeftMargin(reader->m_absleft_border); | 2033 | prefwin->LeftMargin(reader->m_absleft_border); |
2036 | prefwin->RightMargin(reader->m_absright_border); | 2034 | prefwin->RightMargin(reader->m_absright_border); |
2037 | prefwin->Indent(reader->bindenter); | 2035 | prefwin->Indent(reader->bindenter); |
2038 | if (reader->bautofmt) | 2036 | if (reader->bautofmt) |
2039 | { | 2037 | { |
2040 | prefwin->Markup(0); | 2038 | prefwin->Markup(0); |
2041 | } | 2039 | } |
2042 | else if (reader->btextfmt) | 2040 | else if (reader->btextfmt) |
2043 | { | 2041 | { |
2044 | prefwin->Markup(2); | 2042 | prefwin->Markup(2); |
2045 | } | 2043 | } |
2046 | else if (reader->bstriphtml) | 2044 | else if (reader->bstriphtml) |
2047 | { | 2045 | { |
2048 | prefwin->Markup(3); | 2046 | prefwin->Markup(3); |
2049 | } | 2047 | } |
2050 | else if (reader->bpeanut) | 2048 | else if (reader->bpeanut) |
2051 | { | 2049 | { |
2052 | prefwin->Markup(4); | 2050 | prefwin->Markup(4); |
2053 | } | 2051 | } |
2054 | else | 2052 | else |
2055 | { | 2053 | { |
2056 | prefwin->Markup(1); | 2054 | prefwin->Markup(1); |
2057 | } | 2055 | } |
2058 | prefwin->Depluck(reader->bdepluck); | 2056 | prefwin->Depluck(reader->bdepluck); |
2059 | prefwin->Dejpluck(reader->bdejpluck); | 2057 | prefwin->Dejpluck(reader->bdejpluck); |
2060 | prefwin->Continuous(reader->m_continuousDocument); | 2058 | prefwin->Continuous(reader->m_continuousDocument); |
2061 | 2059 | ||
2062 | prefwin->dictApplication(m_targetapp); | 2060 | prefwin->dictApplication(m_targetapp); |
2063 | prefwin->dictMessage(m_targetmsg); | 2061 | prefwin->dictMessage(m_targetmsg); |
2064 | 2062 | ||
2065 | /* | 2063 | /* |
2066 | prefwin->leftScroll(m_leftScroll); | 2064 | prefwin->leftScroll(m_leftScroll); |
2067 | prefwin->rightScroll(m_rightScroll); | 2065 | prefwin->rightScroll(m_rightScroll); |
2068 | prefwin->upScroll(m_upScroll); | 2066 | prefwin->upScroll(m_upScroll); |
2069 | prefwin->downScroll(m_downScroll); | 2067 | prefwin->downScroll(m_downScroll); |
2070 | */ | 2068 | */ |
2071 | 2069 | ||
2072 | prefwin->miscannotation(m_doAnnotation); | 2070 | prefwin->miscannotation(m_doAnnotation); |
2073 | prefwin->miscdictionary(m_doDictionary); | 2071 | prefwin->miscdictionary(m_doDictionary); |
2074 | prefwin->miscclipboard(m_doClipboard); | 2072 | prefwin->miscclipboard(m_doClipboard); |
2075 | 2073 | ||
2076 | prefwin->SwapMouse(reader->m_swapmouse); | 2074 | prefwin->SwapMouse(reader->m_swapmouse); |
2077 | 2075 | ||
2078 | prefwin->Font(reader->m_fontname); | 2076 | prefwin->Font(reader->m_fontname); |
2079 | 2077 | ||
2080 | prefwin->gfxsize(reader->getBaseSize()); | 2078 | prefwin->gfxsize(reader->getBaseSize()); |
2081 | 2079 | ||
2082 | prefwin->pageoverlap(reader->m_overlap); | 2080 | prefwin->pageoverlap(reader->m_overlap); |
2083 | 2081 | ||
2084 | prefwin->ideogram(reader->m_bMonoSpaced); | 2082 | prefwin->ideogram(reader->m_bMonoSpaced); |
2085 | 2083 | ||
2086 | prefwin->encoding(reader->m_encd); | 2084 | prefwin->encoding(reader->m_encd); |
2087 | 2085 | ||
2088 | prefwin->ideogramwidth(reader->m_charpc); | 2086 | prefwin->ideogramwidth(reader->m_charpc); |
2089 | 2087 | ||
2090 | if (prefwin->exec()) | 2088 | if (prefwin->exec()) |
2091 | { | 2089 | { |
2092 | // m_debounce = prefwin->Debounce(); | 2090 | // m_debounce = prefwin->Debounce(); |
2093 | reader->brepalm = prefwin->repalm(); | 2091 | reader->brepalm = prefwin->repalm(); |
2094 | reader->bkern = prefwin->kern(); | 2092 | reader->bkern = prefwin->kern(); |
2095 | reader->hyphenate = prefwin->hyphenate(); | 2093 | reader->hyphenate = prefwin->hyphenate(); |
2096 | // reader->buffdoc.setCustomHyphen(prefwin->customhyphen()); | 2094 | // reader->buffdoc.setCustomHyphen(prefwin->customhyphen()); |
2097 | reader->m_scrolltype = prefwin->scrolltype(); | 2095 | reader->m_scrolltype = prefwin->scrolltype(); |
2098 | reader->m_scrollstep = prefwin->scrollstep(); | 2096 | reader->m_scrollstep = prefwin->scrollstep(); |
2099 | m_scrollcolor = prefwin->scrollcolor(); | 2097 | m_scrollcolor = prefwin->scrollcolor(); |
2100 | setscrollcolour(); | 2098 | setscrollcolour(); |
2101 | m_scrollbarcolor = prefwin->minibarcol(); | 2099 | m_scrollbarcolor = prefwin->minibarcol(); |
2102 | setscrollbarcolour(); | 2100 | setscrollbarcolour(); |
2103 | m_foreground = prefwin->foreground(); | 2101 | m_foreground = prefwin->foreground(); |
2104 | reader->setForeground(getcolour(m_foreground)); | 2102 | reader->setForeground(getcolour(m_foreground)); |
2105 | m_background = prefwin->background(); | 2103 | m_background = prefwin->background(); |
2106 | reader->setBackground(getcolour(m_background)); | 2104 | reader->setBackground(getcolour(m_background)); |
2107 | m_twoTouch = prefwin->twotouch(); | 2105 | m_twoTouch = prefwin->twotouch(); |
2108 | reader->setTwoTouch(m_twoTouch); | 2106 | reader->setTwoTouch(m_twoTouch); |
2109 | m_touch_action->setOn(m_twoTouch); | 2107 | m_touch_action->setOn(m_twoTouch); |
2110 | 2108 | ||
2111 | reader->bstripcr = prefwin->StripCR(); | 2109 | reader->bstripcr = prefwin->StripCR(); |
2112 | reader->bdehyphen = prefwin->Dehyphen(); | 2110 | reader->bdehyphen = prefwin->Dehyphen(); |
2113 | reader->bonespace = prefwin->SingleSpace(); | 2111 | reader->bonespace = prefwin->SingleSpace(); |
2114 | reader->bunindent = prefwin->Unindent(); | 2112 | reader->bunindent = prefwin->Unindent(); |
2115 | reader->brepara = prefwin->Reparagraph(); | 2113 | reader->brepara = prefwin->Reparagraph(); |
2116 | reader->bdblspce = prefwin->DoubleSpace(); | 2114 | reader->bdblspce = prefwin->DoubleSpace(); |
2117 | reader->bremap = prefwin->Remap(); | 2115 | reader->bremap = prefwin->Remap(); |
2118 | reader->bmakebold = prefwin->Embolden(); | 2116 | reader->bmakebold = prefwin->Embolden(); |
2119 | reader->bfulljust = prefwin->FullJustify(); | 2117 | reader->bfulljust = prefwin->FullJustify(); |
2120 | //if (reader->bInverse != prefwin->Inverse()) reader->setInverse(prefwin->Inverse()); | 2118 | //if (reader->bInverse != prefwin->Inverse()) reader->setInverse(prefwin->Inverse()); |
2121 | //if (reader->bNegative != prefwin->Negative()) reader->setNegative(); | 2119 | //if (reader->bNegative != prefwin->Negative()) reader->setNegative(); |
2122 | reader->m_fontControl.FixGraphics(prefwin->FixGraphics()); | 2120 | reader->m_fontControl.FixGraphics(prefwin->FixGraphics()); |
2123 | 2121 | ||
2124 | reader->setextraspace(prefwin->ParaLead()); | 2122 | reader->setextraspace(prefwin->ParaLead()); |
2125 | reader->setlead(prefwin->LineLead()); | 2123 | reader->setlead(prefwin->LineLead()); |
2126 | reader->m_abstopmargin = prefwin->TopMargin(); | 2124 | reader->m_abstopmargin = prefwin->TopMargin(); |
2127 | reader->m_absbottommargin = prefwin->BottomMargin(); | 2125 | reader->m_absbottommargin = prefwin->BottomMargin(); |
2128 | reader->m_absleft_border = prefwin->LeftMargin(); | 2126 | reader->m_absleft_border = prefwin->LeftMargin(); |
2129 | reader->m_absright_border = prefwin->RightMargin(); | 2127 | reader->m_absright_border = prefwin->RightMargin(); |
2130 | reader->bindenter = prefwin->Indent(); | 2128 | reader->bindenter = prefwin->Indent(); |
2131 | reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; | 2129 | reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; |
2132 | switch (prefwin->Markup()) | 2130 | switch (prefwin->Markup()) |
2133 | { | 2131 | { |
2134 | case 0: | 2132 | case 0: |
2135 | reader->bautofmt = true; | 2133 | reader->bautofmt = true; |
2136 | break; | 2134 | break; |
2137 | case 1: | 2135 | case 1: |
2138 | break; | 2136 | break; |
2139 | case 2: | 2137 | case 2: |
2140 | reader->btextfmt = true; | 2138 | reader->btextfmt = true; |
2141 | break; | 2139 | break; |
2142 | case 3: | 2140 | case 3: |
2143 | reader->bstriphtml = true; | 2141 | reader->bstriphtml = true; |
2144 | break; | 2142 | break; |
2145 | case 4: | 2143 | case 4: |
2146 | reader->bpeanut = true; | 2144 | reader->bpeanut = true; |
2147 | break; | 2145 | break; |
2148 | default: | 2146 | default: |
2149 | qDebug("Format out of range"); | 2147 | qDebug("Format out of range"); |
2150 | } | 2148 | } |
2151 | reader->bdepluck = prefwin->Depluck(); | 2149 | reader->bdepluck = prefwin->Depluck(); |
2152 | reader->bdejpluck = prefwin->Dejpluck(); | 2150 | reader->bdejpluck = prefwin->Dejpluck(); |
2153 | reader->setContinuous(prefwin->Continuous()); | 2151 | reader->setContinuous(prefwin->Continuous()); |
2154 | 2152 | ||
2155 | /* | 2153 | /* |
2156 | m_leftScroll = prefwin->leftScroll(); | 2154 | m_leftScroll = prefwin->leftScroll(); |
2157 | m_rightScroll = prefwin->rightScroll(); | 2155 | m_rightScroll = prefwin->rightScroll(); |
2158 | m_upScroll = prefwin->upScroll(); | 2156 | m_upScroll = prefwin->upScroll(); |
2159 | m_downScroll = prefwin->downScroll(); | 2157 | m_downScroll = prefwin->downScroll(); |
2160 | */ | 2158 | */ |
2161 | m_targetapp = prefwin->dictApplication(); | 2159 | m_targetapp = prefwin->dictApplication(); |
2162 | m_targetmsg = prefwin->dictMessage(); | 2160 | m_targetmsg = prefwin->dictMessage(); |
2163 | 2161 | ||
2164 | m_doAnnotation = prefwin->miscannotation(); | 2162 | m_doAnnotation = prefwin->miscannotation(); |
2165 | m_doDictionary = prefwin->miscdictionary(); | 2163 | m_doDictionary = prefwin->miscdictionary(); |
2166 | m_doClipboard = prefwin->miscclipboard(); | 2164 | m_doClipboard = prefwin->miscclipboard(); |
2167 | reader->m_swapmouse = prefwin->SwapMouse(); | 2165 | reader->m_swapmouse = prefwin->SwapMouse(); |
2168 | reader->setBaseSize(prefwin->gfxsize()); | 2166 | reader->setBaseSize(prefwin->gfxsize()); |
2169 | reader->m_overlap = prefwin->pageoverlap(); | 2167 | reader->m_overlap = prefwin->pageoverlap(); |
2170 | reader->m_bMonoSpaced = prefwin->ideogram(); | 2168 | reader->m_bMonoSpaced = prefwin->ideogram(); |
2171 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 2169 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
2172 | reader->m_encd = prefwin->encoding(); | 2170 | reader->m_encd = prefwin->encoding(); |
2173 | reader->m_charpc = prefwin->ideogramwidth(); | 2171 | reader->m_charpc = prefwin->ideogramwidth(); |
2174 | 2172 | ||
2175 | if ( | 2173 | if ( |
2176 | reader->m_fontname != prefwin->Font() | 2174 | reader->m_fontname != prefwin->Font() |
2177 | || | 2175 | || |
2178 | m_propogatefontchange != prefwin->propfontchange()) | 2176 | m_propogatefontchange != prefwin->propfontchange()) |
2179 | { | 2177 | { |
2180 | m_propogatefontchange = prefwin->propfontchange(); | 2178 | m_propogatefontchange = prefwin->propfontchange(); |
2181 | setfontHelper(prefwin->Font()); | 2179 | setfontHelper(prefwin->Font()); |
2182 | } | 2180 | } |
2183 | if (m_bgtype != (bground)prefwin->bgtype()) | 2181 | if (m_bgtype != (bground)prefwin->bgtype()) |
2184 | { | 2182 | { |
2185 | m_bgtype = (bground)prefwin->bgtype(); | 2183 | m_bgtype = (bground)prefwin->bgtype(); |
2186 | setBackgroundBitmap(); | 2184 | setBackgroundBitmap(); |
2187 | } | 2185 | } |
2188 | delete prefwin; | 2186 | delete prefwin; |
2189 | reader->setfilter(reader->getfilter()); | 2187 | reader->setfilter(reader->getfilter()); |
2190 | reader->refresh(); | 2188 | reader->refresh(); |
2191 | } | 2189 | } |
2192 | else | 2190 | else |
2193 | { | 2191 | { |
2194 | delete prefwin; | 2192 | delete prefwin; |
2195 | } | 2193 | } |
2196 | } | 2194 | } |
2197 | 2195 | ||
2198 | void QTReaderApp::showtoolbarprefs() | 2196 | void QTReaderApp::showtoolbarprefs() |
2199 | { | 2197 | { |
2200 | #ifdef USEQPE | 2198 | #ifdef USEQPE |
2201 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); | 2199 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); |
2202 | #else | 2200 | #else |
2203 | QFileInfo fi; | 2201 | QFileInfo fi; |
2204 | QDir d = QDir::home(); // "/" | 2202 | QDir d = QDir::home(); // "/" |
2205 | if ( !d.cd(APPDIR) ) | 2203 | if ( !d.cd(APPDIR) ) |
2206 | { // "/tmp" | 2204 | { // "/tmp" |
2207 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | 2205 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
2208 | d = QDir::home(); | 2206 | d = QDir::home(); |
2209 | d.mkdir(APPDIR); | 2207 | d.mkdir(APPDIR); |
2210 | d.cd(APPDIR); | 2208 | d.cd(APPDIR); |
2211 | } | 2209 | } |
2212 | fi.setFile(d, INIFILE); | 2210 | fi.setFile(d, INIFILE); |
2213 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); | 2211 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); |
2214 | #endif | 2212 | #endif |
2215 | prefwin->tbpolicy(m_tbpolsave); | 2213 | prefwin->tbpolicy(m_tbpolsave); |
2216 | prefwin->tbposition(m_tbposition-2); | 2214 | prefwin->tbposition(m_tbposition-2); |
2217 | prefwin->tbmovable(m_tbmovesave); | 2215 | prefwin->tbmovable(m_tbmovesave); |
2218 | prefwin->floating(m_bFloatingDialog); | 2216 | prefwin->floating(m_bFloatingDialog); |
2219 | prefwin->qtscroll(m_qtscroll); | 2217 | prefwin->qtscroll(m_qtscroll); |
2220 | prefwin->localscroll(m_localscroll); | 2218 | prefwin->localscroll(m_localscroll); |
2221 | if (prefwin->exec()) | 2219 | if (prefwin->exec()) |
2222 | { | 2220 | { |
2223 | m_bFloatingDialog = prefwin->floating(); | 2221 | m_bFloatingDialog = prefwin->floating(); |
2224 | if ( | 2222 | if ( |
2225 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() | 2223 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() |
2226 | || | 2224 | || |
2227 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) | 2225 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) |
2228 | || | 2226 | || |
2229 | m_tbmovesave != prefwin->tbmovable() | 2227 | m_tbmovesave != prefwin->tbmovable() |
2230 | || | 2228 | || |
2231 | m_qtscroll != prefwin->qtscroll() | 2229 | m_qtscroll != prefwin->qtscroll() |
2232 | // || | 2230 | // || |
2233 | // m_localscrollbar != prefwin->scrollonleft() | 2231 | // m_localscrollbar != prefwin->scrollonleft() |
2234 | ) | 2232 | ) |
2235 | { | 2233 | { |
2236 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); | 2234 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); |
2237 | } | 2235 | } |
2238 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); | 2236 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); |
2239 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); | 2237 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); |
2240 | m_tbmovesave = prefwin->tbmovable(); | 2238 | m_tbmovesave = prefwin->tbmovable(); |
2241 | reader->m_scrollpos = m_localscroll = prefwin->localscroll(); | 2239 | reader->m_scrollpos = m_localscroll = prefwin->localscroll(); |
2242 | if (m_qtscroll != prefwin->qtscroll()) | 2240 | if (m_qtscroll != prefwin->qtscroll()) |
2243 | { | 2241 | { |
2244 | m_qtscroll = prefwin->qtscroll(); | 2242 | m_qtscroll = prefwin->qtscroll(); |
2245 | setrotated(reader->m_rotated); | 2243 | setrotated(reader->m_rotated); |
2246 | } | 2244 | } |
2247 | if (m_scrollbar == NULL || m_scrollbar->isHidden()) | 2245 | if (m_scrollbar == NULL || m_scrollbar->isHidden()) |
2248 | { | 2246 | { |
2249 | reader->m_scrollpos = m_localscroll; | 2247 | reader->m_scrollpos = m_localscroll; |
2250 | } | 2248 | } |
2251 | else | 2249 | else |
2252 | { | 2250 | { |
2253 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; | 2251 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; |
2254 | } | 2252 | } |
2255 | bool isChanged = prefwin->isChanged(); | 2253 | bool isChanged = prefwin->isChanged(); |
2256 | delete prefwin; | 2254 | delete prefwin; |
2257 | #ifdef USEQPE | 2255 | #ifdef USEQPE |
2258 | Config config( APPDIR ); | 2256 | Config config( APPDIR ); |
2259 | #else | 2257 | #else |
2260 | QFileInfo fi; | 2258 | QFileInfo fi; |
2261 | QDir d = QDir::home(); // "/" | 2259 | QDir d = QDir::home(); // "/" |
2262 | if ( !d.cd(APPDIR) ) | 2260 | if ( !d.cd(APPDIR) ) |
2263 | { // "/tmp" | 2261 | { // "/tmp" |
2264 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | 2262 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
2265 | d = QDir::home(); | 2263 | d = QDir::home(); |
2266 | d.mkdir(APPDIR); | 2264 | d.mkdir(APPDIR); |
2267 | d.cd(APPDIR); | 2265 | d.cd(APPDIR); |
2268 | } | 2266 | } |
2269 | fi.setFile(d, INIFILE); | 2267 | fi.setFile(d, INIFILE); |
2270 | Config config( fi.absFilePath() ); | 2268 | Config config( fi.absFilePath() ); |
2271 | #endif | 2269 | #endif |
2272 | if (isChanged) addtoolbars(&config); | 2270 | if (isChanged) addtoolbars(&config); |
2273 | } | 2271 | } |
2274 | else | 2272 | else |
2275 | { | 2273 | { |
2276 | delete prefwin; | 2274 | delete prefwin; |
2277 | } | 2275 | } |
2278 | } | 2276 | } |
2279 | 2277 | ||
2280 | void QTReaderApp::showinfo() | 2278 | void QTReaderApp::showinfo() |
2281 | { | 2279 | { |
2282 | unsigned long ds, fs, ts, pl, dl; | 2280 | unsigned long ds, fs, ts, pl, dl; |
2283 | if (reader->empty()) | 2281 | if (reader->empty()) |
2284 | { | 2282 | { |
2285 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 2283 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
2286 | } | 2284 | } |
2287 | else | 2285 | else |
2288 | { | 2286 | { |
2289 | reader->sizes(fs,ts); | 2287 | reader->sizes(fs,ts); |
2290 | ds = reader->buffdoc.endSection() - reader->buffdoc.startSection(); | 2288 | ds = reader->buffdoc.endSection() - reader->buffdoc.startSection(); |
2291 | pl = reader->pagelocate(); | 2289 | pl = reader->pagelocate(); |
2292 | dl = pl - reader->buffdoc.startSection(); | 2290 | dl = pl - reader->buffdoc.startSection(); |
2293 | m_infoWin->setFileSize(fs); | 2291 | m_infoWin->setFileSize(fs); |
2294 | m_infoWin->setTextSize(ts); | 2292 | m_infoWin->setTextSize(ts); |
2295 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); | 2293 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); |
2296 | m_infoWin->setLocation(pl); | 2294 | m_infoWin->setLocation(pl); |
2297 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); | 2295 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); |
2298 | m_infoWin->setDocSize(ds); | 2296 | m_infoWin->setDocSize(ds); |
2299 | m_infoWin->setDocLocation(dl); | 2297 | m_infoWin->setDocLocation(dl); |
2300 | m_infoWin->setDocRead((100*dl + (ds >> 1))/ds); | 2298 | m_infoWin->setDocRead((100*dl + (ds >> 1))/ds); |
2301 | m_infoWin->setZoom(reader->m_fontControl.currentsize()*10); | 2299 | m_infoWin->setZoom(reader->m_fontControl.currentsize()*10); |
2302 | m_infoWin->setAbout(QString("\nApplication (c) Tim Wentford\n")+reader->about()); | 2300 | m_infoWin->setAbout(QString("\nApplication (c) Tim Wentford\n")+reader->about()); |
2303 | editorStack->raiseWidget( m_infoWin ); | 2301 | editorStack->raiseWidget( m_infoWin ); |
2304 | hidetoolbars(); | 2302 | hidetoolbars(); |
2305 | m_infoWin->setFocus(); | 2303 | m_infoWin->setFocus(); |
2306 | } | 2304 | } |
2307 | } | 2305 | } |
2308 | 2306 | ||
2309 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn, size_t posn2) | 2307 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn, size_t posn2) |
2310 | { | 2308 | { |
2311 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; | 2309 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; |
2312 | #ifdef _UNICODE | 2310 | #ifdef _UNICODE |
2313 | CBuffer buff(name.length()+1); | 2311 | CBuffer buff(name.length()+1); |
2314 | int i; | 2312 | int i; |
2315 | for (i = 0; i < name.length(); i++) | 2313 | for (i = 0; i < name.length(); i++) |
2316 | { | 2314 | { |
2317 | buff[i] = name[i].unicode(); | 2315 | buff[i] = name[i].unicode(); |
2318 | } | 2316 | } |
2319 | buff[i] = 0; | 2317 | buff[i] = 0; |
2320 | CBuffer buff2(text.length()+1); | 2318 | CBuffer buff2(text.length()+1); |
2321 | for (i = 0; i < text.length(); i++) | 2319 | for (i = 0; i < text.length(); i++) |
2322 | { | 2320 | { |
2323 | buff2[i] = text[i].unicode(); | 2321 | buff2[i] = text[i].unicode(); |
2324 | } | 2322 | } |
2325 | buff2[i] = 0; | 2323 | buff2[i] = 0; |
2326 | Bkmk b(buff.data(), buff2.data(), posn, posn2); | 2324 | Bkmk b(buff.data(), buff2.data(), posn, posn2); |
2327 | QColor c = m_annoWin->getColor(); | 2325 | QColor c = m_annoWin->getColor(); |
2328 | int red,green,blue; | 2326 | int red,green,blue; |
2329 | c.rgb(&red, &green, &blue); | 2327 | c.rgb(&red, &green, &blue); |
2330 | b.red(red); | 2328 | b.red(red); |
2331 | b.green(green); | 2329 | b.green(green); |
2332 | b.blue(blue); | 2330 | b.blue(blue); |
2333 | pBkmklist->push_front(b); | 2331 | pBkmklist->push_front(b); |
2334 | #else | 2332 | #else |
2335 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); | 2333 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); |
2336 | #endif | 2334 | #endif |
2337 | m_fBkmksChanged = true; | 2335 | m_fBkmksChanged = true; |
2338 | pBkmklist->sort(); | 2336 | pBkmklist->sort(); |
2339 | } | 2337 | } |
2340 | 2338 | ||
2341 | void QTReaderApp::addAnno(const QString& name, const QString& text) | 2339 | void QTReaderApp::addAnno(const QString& name, const QString& text) |
2342 | { | 2340 | { |
2343 | if (m_annoIsEditing) | 2341 | if (m_annoIsEditing) |
2344 | { | 2342 | { |
2345 | if (name.isEmpty()) | 2343 | if (name.isEmpty()) |
2346 | { | 2344 | { |
2347 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); | 2345 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); |
2348 | } | 2346 | } |
2349 | else | 2347 | else |
2350 | { | 2348 | { |
2351 | addAnno(name, text, m_annoWin->getPosn(), m_annoWin->getPosn2()); | 2349 | addAnno(name, text, m_annoWin->getPosn(), m_annoWin->getPosn2()); |
2352 | } | 2350 | } |
2353 | showEditTools(); | 2351 | showEditTools(); |
2354 | } | 2352 | } |
2355 | else | 2353 | else |
2356 | { | 2354 | { |
2357 | if (m_annoWin->edited()) | 2355 | if (m_annoWin->edited()) |
2358 | { | 2356 | { |
2359 | CBuffer buff(text.length()+1); | 2357 | CBuffer buff(text.length()+1); |
2360 | int i; | 2358 | int i; |
2361 | for (i = 0; i < text.length(); i++) | 2359 | for (i = 0; i < text.length(); i++) |
2362 | { | 2360 | { |
2363 | buff[i] = text[i].unicode(); | 2361 | buff[i] = text[i].unicode(); |
2364 | } | 2362 | } |
2365 | buff[i] = 0; | 2363 | buff[i] = 0; |
2366 | m_fBkmksChanged = true; | 2364 | m_fBkmksChanged = true; |
2367 | m_anno->setAnno(buff.data()); | 2365 | m_anno->setAnno(buff.data()); |
2368 | } | 2366 | } |
2369 | QColor c = m_annoWin->getColor(); | 2367 | QColor c = m_annoWin->getColor(); |
2370 | int red,green,blue; | 2368 | int red,green,blue; |
2371 | c.rgb(&red, &green, &blue); | 2369 | c.rgb(&red, &green, &blue); |
2372 | m_anno->red(red); | 2370 | m_anno->red(red); |
2373 | m_anno->green(green); | 2371 | m_anno->green(green); |
2374 | m_anno->blue(blue); | 2372 | m_anno->blue(blue); |
2375 | bool found = findNextBookmark(m_anno->value()+1); | 2373 | bool found = findNextBookmark(m_anno->value()+1); |
2376 | if (found) | 2374 | if (found) |
2377 | { | 2375 | { |
2378 | m_annoWin->setName(toQString(m_anno->name())); | 2376 | m_annoWin->setName(toQString(m_anno->name())); |
2379 | m_annoWin->setAnno(toQString(m_anno->anno())); | 2377 | m_annoWin->setAnno(toQString(m_anno->anno())); |
2380 | m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); | 2378 | m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); |
2381 | } | 2379 | } |
2382 | else | 2380 | else |
2383 | { | 2381 | { |
2384 | showEditTools(); | 2382 | showEditTools(); |
2385 | } | 2383 | } |
2386 | } | 2384 | } |
2387 | } | 2385 | } |
2388 | 2386 | ||
2389 | bool QTReaderApp::findNextBookmark(size_t start) | 2387 | bool QTReaderApp::findNextBookmark(size_t start) |
2390 | { | 2388 | { |
2391 | bool found = false; | 2389 | bool found = false; |
2392 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) | 2390 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) |
2393 | { | 2391 | { |
2394 | if (iter->value() >= start) | 2392 | if (iter->value() >= start) |
2395 | { | 2393 | { |
2396 | if (iter->value() < reader->locate()) | 2394 | if (iter->value() < reader->locate()) |
2397 | { | 2395 | { |
2398 | found = true; | 2396 | found = true; |
2399 | m_anno = iter.pContent(); | 2397 | m_anno = iter.pContent(); |
2400 | } | 2398 | } |
2401 | break; | 2399 | break; |
2402 | } | 2400 | } |
2403 | } | 2401 | } |
2404 | return found; | 2402 | return found; |
2405 | } | 2403 | } |
2406 | 2404 | ||
2407 | void QTReaderApp::addanno() | 2405 | void QTReaderApp::addanno() |
2408 | { | 2406 | { |
2409 | if (reader->empty()) | 2407 | if (reader->empty()) |
2410 | { | 2408 | { |
2411 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 2409 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
2412 | } | 2410 | } |
2413 | else | 2411 | else |
2414 | { | 2412 | { |
2415 | m_annoWin->setName(""); | 2413 | m_annoWin->setName(""); |
2416 | m_annoWin->setAnno(""); | 2414 | m_annoWin->setAnno(""); |
2417 | m_annoWin->setPosn(reader->pagelocate()); | 2415 | m_annoWin->setPosn(reader->pagelocate()); |
2418 | m_annoIsEditing = true; | 2416 | m_annoIsEditing = true; |
2419 | editorStack->raiseWidget( m_annoWin ); | 2417 | editorStack->raiseWidget( m_annoWin ); |
2420 | hidetoolbars(); | 2418 | hidetoolbars(); |
2421 | #ifdef USEQPE | 2419 | #ifdef USEQPE |
2422 | Global::showInputMethod(); | 2420 | Global::showInputMethod(); |
2423 | #endif | 2421 | #endif |
2424 | m_annoWin->setFocus(); | 2422 | m_annoWin->setFocus(); |
2425 | } | 2423 | } |
2426 | } | 2424 | } |
2427 | 2425 | ||
2428 | void QTReaderApp::infoClose() | 2426 | void QTReaderApp::infoClose() |
2429 | { | 2427 | { |
2430 | m_debounce = m_buttonprefs->Debounce(); | 2428 | m_debounce = m_buttonprefs->Debounce(); |
2431 | if (m_kmapchanged) | 2429 | if (m_kmapchanged) |
2432 | { | 2430 | { |
2433 | m_kmapchanged = false; | 2431 | m_kmapchanged = false; |
2434 | #ifndef USEQPE | 2432 | #ifndef USEQPE |
2435 | QDir d = QDir::home(); // "/" | 2433 | QDir d = QDir::home(); // "/" |
2436 | d.cd(APPDIR); | 2434 | d.cd(APPDIR); |
2437 | QFileInfo fi(d, ".keymap"); | 2435 | QFileInfo fi(d, ".keymap"); |
2438 | FILE* f = fopen((const char *)fi.absFilePath(), "w"); | 2436 | FILE* f = fopen((const char *)fi.absFilePath(), "w"); |
2439 | #else /* USEQPE */ | 2437 | #else /* USEQPE */ |
2440 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "w"); | 2438 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "w"); |
2441 | #endif /* USEQPE */ | 2439 | #endif /* USEQPE */ |
2442 | if (f != NULL) | 2440 | if (f != NULL) |
2443 | { | 2441 | { |
2444 | uint cnt = KEYMAPVERSION; | 2442 | uint cnt = KEYMAPVERSION; |
2445 | fwrite(&cnt, sizeof(cnt), 1, f); | 2443 | fwrite(&cnt, sizeof(cnt), 1, f); |
2446 | cnt = kmap.count(); | 2444 | cnt = kmap.count(); |
2447 | fwrite(&cnt, sizeof(cnt), 1, f); | 2445 | fwrite(&cnt, sizeof(cnt), 1, f); |
2448 | for (QMap<orKey,int>::Iterator i = kmap.begin(); i != kmap.end(); i++) | 2446 | for (QMap<orKey,int>::Iterator i = kmap.begin(); i != kmap.end(); i++) |
2449 | { | 2447 | { |
2450 | orKey key = i.key(); | 2448 | orKey key = i.key(); |
2451 | int data = i.data(); | 2449 | int data = i.data(); |
2452 | fwrite(&key, sizeof(key), 1, f); | 2450 | fwrite(&key, sizeof(key), 1, f); |
2453 | fwrite(&data, sizeof(data), 1, f); | 2451 | fwrite(&data, sizeof(data), 1, f); |
2454 | qDebug("Saved %s as %u", (const char*)key.text(), data); | 2452 | qDebug("Saved %s as %u", (const char*)key.text(), data); |
2455 | } | 2453 | } |
2456 | fclose(f); | 2454 | fclose(f); |
2457 | } | 2455 | } |
2458 | } | 2456 | } |
2459 | showEditTools(); | 2457 | showEditTools(); |
2460 | } | 2458 | } |
2461 | 2459 | ||
2462 | /* | 2460 | /* |
2463 | void QTReaderApp::fileRevert() | 2461 | void QTReaderApp::fileRevert() |
2464 | { | 2462 | { |
2465 | clear(); | 2463 | clear(); |
2466 | fileOpen(); | 2464 | fileOpen(); |
2467 | } | 2465 | } |
2468 | 2466 | ||
2469 | void QTReaderApp::editCut() | 2467 | void QTReaderApp::editCut() |
2470 | { | 2468 | { |
2471 | #ifndef QT_NO_CLIPBOARD | 2469 | #ifndef QT_NO_CLIPBOARD |
2472 | editor->cut(); | 2470 | editor->cut(); |
2473 | #endif | 2471 | #endif |
2474 | } | 2472 | } |
2475 | */ | 2473 | */ |
2476 | void QTReaderApp::editMark() | 2474 | void QTReaderApp::editMark() |
2477 | { | 2475 | { |
2478 | m_savedpos = reader->pagelocate(); | 2476 | m_savedpos = reader->pagelocate(); |
2479 | } | 2477 | } |
2480 | 2478 | ||
2481 | void QTReaderApp::editCopy() | 2479 | void QTReaderApp::editCopy() |
2482 | { | 2480 | { |
2483 | QClipboard* cb = QApplication::clipboard(); | 2481 | QClipboard* cb = QApplication::clipboard(); |
2484 | QString text; | 2482 | QString text; |
2485 | int ch; | 2483 | int ch; |
2486 | unsigned long currentpos = reader->pagelocate(); | 2484 | unsigned long currentpos = reader->pagelocate(); |
2487 | unsigned long endpos = reader->locate(); | 2485 | unsigned long endpos = reader->locate(); |
2488 | if (m_savedpos == 0xffffffff) | 2486 | if (m_savedpos == 0xffffffff) |
2489 | { | 2487 | { |
2490 | m_savedpos = currentpos; | 2488 | m_savedpos = currentpos; |
2491 | } | 2489 | } |
2492 | reader->jumpto(m_savedpos); | 2490 | reader->jumpto(m_savedpos); |
2493 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) | 2491 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) |
2494 | { | 2492 | { |
2495 | text += ch; | 2493 | text += ch; |
2496 | } | 2494 | } |
2497 | cb->setText(text); | 2495 | cb->setText(text); |
2498 | reader->locate(currentpos); | 2496 | reader->locate(currentpos); |
2499 | m_savedpos = 0xffffffff; | 2497 | m_savedpos = 0xffffffff; |
2500 | } | 2498 | } |
2501 | 2499 | ||
2502 | void QTReaderApp::gotoStart() | 2500 | void QTReaderApp::gotoStart() |
2503 | { | 2501 | { |
2504 | reader->locate(reader->buffdoc.startSection()); | 2502 | reader->locate(reader->buffdoc.startSection()); |
2505 | } | 2503 | } |
2506 | 2504 | ||
2507 | void QTReaderApp::gotoEnd() | 2505 | void QTReaderApp::gotoEnd() |
2508 | { | 2506 | { |
2509 | reader->dopageup(reader->buffdoc.endSection()); | 2507 | reader->dopageup(reader->buffdoc.endSection()); |
2510 | } | 2508 | } |
2511 | 2509 | ||
2512 | void QTReaderApp::pageup() | 2510 | void QTReaderApp::pageup() |
2513 | { | 2511 | { |
2514 | reader->NavUp(); | 2512 | reader->NavUp(); |
2515 | } | 2513 | } |
2516 | 2514 | ||
2517 | void QTReaderApp::pagedn() | 2515 | void QTReaderApp::pagedn() |
2518 | { | 2516 | { |
2519 | reader->NavDown(); | 2517 | reader->NavDown(); |
2520 | } | 2518 | } |
2521 | 2519 | ||
2522 | void QTReaderApp::pagemode(bool _b) | 2520 | void QTReaderApp::pagemode(bool _b) |
2523 | { | 2521 | { |
2524 | reader->setpagemode(_b); | 2522 | reader->setpagemode(_b); |
2525 | } | 2523 | } |
2526 | 2524 | ||
2527 | /* | 2525 | /* |
2528 | void QTReaderApp::setspacing() | 2526 | void QTReaderApp::setspacing() |
2529 | { | 2527 | { |
2530 | m_nRegAction = cMonoSpace; | 2528 | m_nRegAction = cMonoSpace; |
2531 | char lcn[20]; | 2529 | char lcn[20]; |
2532 | sprintf(lcn, "%lu", reader->m_charpc); | 2530 | sprintf(lcn, "%lu", reader->m_charpc); |
2533 | regEdit->setText(lcn); | 2531 | regEdit->setText(lcn); |
2534 | do_regedit(); | 2532 | do_regedit(); |
2535 | } | 2533 | } |
2536 | */ | 2534 | */ |
2537 | void QTReaderApp::settarget() | 2535 | void QTReaderApp::settarget() |
2538 | { | 2536 | { |
2539 | m_nRegAction = cSetTarget; | 2537 | m_nRegAction = cSetTarget; |
2540 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) | 2538 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) |
2541 | + "/" | 2539 | + "/" |
2542 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); | 2540 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); |
2543 | regEdit->setText(text); | 2541 | regEdit->setText(text); |
2544 | do_regedit(); | 2542 | do_regedit(); |
2545 | } | 2543 | } |
2546 | 2544 | ||
2547 | /* | 2545 | /* |
2548 | void QTReaderApp::do_mono(const QString& lcn) | 2546 | void QTReaderApp::do_mono(const QString& lcn) |
2549 | { | 2547 | { |
2550 | bool ok; | 2548 | bool ok; |
2551 | unsigned long ulcn = lcn.toULong(&ok); | 2549 | unsigned long ulcn = lcn.toULong(&ok); |
2552 | if (ok) | 2550 | if (ok) |
2553 | { | 2551 | { |
2554 | reader->m_charpc = ulcn; | 2552 | reader->m_charpc = ulcn; |
2555 | reader->setfont(); | 2553 | reader->setfont(); |
2556 | reader->refresh(); | 2554 | reader->refresh(); |
2557 | //reader->setmono(true); | 2555 | //reader->setmono(true); |
2558 | } | 2556 | } |
2559 | else | 2557 | else |
2560 | QMessageBox::information(this, PROGNAME, "Must be a number"); | 2558 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
2561 | } | 2559 | } |
2562 | */ | 2560 | */ |
2563 | /* | 2561 | /* |
2564 | void QTReaderApp::editPaste() | 2562 | void QTReaderApp::editPaste() |
2565 | { | 2563 | { |
2566 | #ifndef QT_NO_CLIPBOARD | 2564 | #ifndef QT_NO_CLIPBOARD |
2567 | editor->paste(); | 2565 | editor->paste(); |
2568 | #endif | 2566 | #endif |
2569 | } | 2567 | } |
2570 | */ | 2568 | */ |
2571 | 2569 | ||
2572 | void QTReaderApp::editFind() | 2570 | void QTReaderApp::editFind() |
2573 | { | 2571 | { |
2574 | searchStart = reader->pagelocate(); | 2572 | searchStart = reader->pagelocate(); |
2575 | #ifdef __ISEARCH | 2573 | #ifdef __ISEARCH |
2576 | searchStack = new QStack<searchrecord>; | 2574 | searchStack = new QStack<searchrecord>; |
2577 | #endif | 2575 | #endif |
2578 | #ifdef USEQPE | 2576 | #ifdef USEQPE |
2579 | Global::showInputMethod(); | 2577 | Global::showInputMethod(); |
2580 | #endif | 2578 | #endif |
2581 | searchBar->show(); | 2579 | searchBar->show(); |
2582 | searchVisible = TRUE; | 2580 | searchVisible = TRUE; |
2583 | searchEdit->setFocus(); | 2581 | searchEdit->setFocus(); |
2584 | #ifdef __ISEARCH | 2582 | #ifdef __ISEARCH |
2585 | searchStack->push(new searchrecord("",reader->pagelocate())); | 2583 | searchStack->push(new searchrecord("",reader->pagelocate())); |
2586 | #endif | 2584 | #endif |
2587 | } | 2585 | } |
2588 | 2586 | ||
2589 | void QTReaderApp::findNext() | 2587 | void QTReaderApp::findNext() |
2590 | { | 2588 | { |
2591 | // // qDebug("findNext called\n"); | 2589 | // // qDebug("findNext called\n"); |
2592 | #ifdef __ISEARCH | 2590 | #ifdef __ISEARCH |
2593 | QString arg = searchEdit->text(); | 2591 | QString arg = searchEdit->text(); |
2594 | #else | 2592 | #else |
2595 | QRegExp arg = searchEdit->text(); | 2593 | QRegExp arg = searchEdit->text(); |
2596 | #endif | 2594 | #endif |
2597 | CDrawBuffer test(&(reader->m_fontControl)); | 2595 | CDrawBuffer test(&(reader->m_fontControl)); |
2598 | size_t start = reader->pagelocate(); | 2596 | size_t start = reader->pagelocate(); |
2599 | reader->jumpto(start); | 2597 | reader->jumpto(start); |
2600 | reader->getline(&test); | 2598 | reader->getline(&test); |
2601 | dosearch(start, test, arg); | 2599 | dosearch(start, test, arg); |
2602 | } | 2600 | } |
2603 | 2601 | ||
2604 | void QTReaderApp::findClose() | 2602 | void QTReaderApp::findClose() |
2605 | { | 2603 | { |
2606 | searchVisible = FALSE; | 2604 | searchVisible = FALSE; |
2607 | searchEdit->setText(""); | 2605 | searchEdit->setText(""); |
2608 | #ifdef USEQPE | 2606 | #ifdef USEQPE |
2609 | Global::hideInputMethod(); | 2607 | Global::hideInputMethod(); |
2610 | #endif | 2608 | #endif |
2611 | searchBar->hide(); | 2609 | searchBar->hide(); |
2612 | #ifdef __ISEARCH | 2610 | #ifdef __ISEARCH |
2613 | // searchStack = new QStack<searchrecord>; | 2611 | // searchStack = new QStack<searchrecord>; |
2614 | while (!searchStack->isEmpty()) | 2612 | while (!searchStack->isEmpty()) |
2615 | { | 2613 | { |
2616 | delete searchStack->pop(); | 2614 | delete searchStack->pop(); |
2617 | } | 2615 | } |
2618 | delete searchStack; | 2616 | delete searchStack; |
2619 | #endif | 2617 | #endif |
2620 | reader->setFocus(); | 2618 | reader->setFocus(); |
2621 | } | 2619 | } |
2622 | 2620 | ||
2623 | void QTReaderApp::regClose() | 2621 | void QTReaderApp::regClose() |
2624 | { | 2622 | { |
2625 | regVisible = FALSE; | 2623 | regVisible = FALSE; |
2626 | regEdit->setText(""); | 2624 | regEdit->setText(""); |
2627 | regBar->hide(); | 2625 | regBar->hide(); |
2628 | #ifdef USEQPE | 2626 | #ifdef USEQPE |
2629 | Global::hideInputMethod(); | 2627 | Global::hideInputMethod(); |
2630 | #endif | 2628 | #endif |
2631 | reader->setFocus(); | 2629 | reader->setFocus(); |
2632 | } | 2630 | } |
2633 | 2631 | ||
2634 | #ifdef __ISEARCH | 2632 | #ifdef __ISEARCH |
2635 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) | 2633 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) |
2636 | #else | 2634 | #else |
2637 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | 2635 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) |
2638 | #endif | 2636 | #endif |
2639 | { | 2637 | { |
2640 | bool ret = true; | 2638 | bool ret = true; |
2641 | unsigned long fs, ts; | 2639 | unsigned long fs, ts; |
2642 | reader->sizes(fs,ts); | 2640 | reader->sizes(fs,ts); |
2643 | size_t pos = reader->locate(); | 2641 | size_t pos = reader->locate(); |
2644 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); | 2642 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); |
2645 | pbar->show(); | 2643 | pbar->show(); |
2646 | pbar->raise(); | 2644 | pbar->raise(); |
2647 | pbar->reset(); | 2645 | pbar->reset(); |
2648 | int offset; | 2646 | int offset; |
2649 | int lastpc = (100*pos)/ts; | 2647 | int lastpc = (100*pos)/ts; |
2650 | pbar->setProgress(lastpc); | 2648 | pbar->setProgress(lastpc); |
2651 | // qApp->processEvents(); | 2649 | // qApp->processEvents(); |
2652 | if (reader->buffdoc.getpara(test) >= 0) | 2650 | if (reader->buffdoc.getpara(test) >= 0) |
2653 | { | 2651 | { |
2654 | reader->setFocus(); | 2652 | reader->setFocus(); |
2655 | #ifdef __ISEARCH | 2653 | #ifdef __ISEARCH |
2656 | while (strstr(test.data(),(const tchar*)arg) == NULL) | 2654 | while (strstr(test.data(),(const tchar*)arg) == NULL) |
2657 | #else | 2655 | #else |
2658 | #ifdef _UNICODE | 2656 | #ifdef _UNICODE |
2659 | while ((offset = arg.match(toQString(test.data()))) == -1) | 2657 | while ((offset = arg.match(toQString(test.data()))) == -1) |
2660 | #else | 2658 | #else |
2661 | while (arg.match(test.data()) == -1) | 2659 | while (arg.match(test.data()) == -1) |
2662 | #endif | 2660 | #endif |
2663 | #endif | 2661 | #endif |
2664 | { | 2662 | { |
2665 | pos = reader->locate(); | 2663 | pos = reader->locate(); |
2666 | int pc = (100*pos)/ts; | 2664 | int pc = (100*pos)/ts; |
2667 | if (pc != lastpc) | 2665 | if (pc != lastpc) |
2668 | { | 2666 | { |
2669 | pbar->setProgress(pc); | 2667 | pbar->setProgress(pc); |
2670 | qApp->processEvents(); | 2668 | qApp->processEvents(); |
2671 | reader->setFocus(); | 2669 | reader->setFocus(); |
2672 | lastpc = pc; | 2670 | lastpc = pc; |
2673 | } | 2671 | } |
2674 | 2672 | ||
2675 | if (reader->buffdoc.getpara(test) < 0) | 2673 | if (reader->buffdoc.getpara(test) < 0) |
2676 | { | 2674 | { |
2677 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2675 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2678 | pos = searchStart; | 2676 | pos = searchStart; |
2679 | else | 2677 | else |
2680 | pos = start; | 2678 | pos = start; |
2681 | findClose(); | 2679 | findClose(); |
2682 | pbar->hide(); | 2680 | pbar->hide(); |
2683 | reader->locate(pos); | 2681 | reader->locate(pos); |
2684 | return false; | 2682 | return false; |
2685 | } | 2683 | } |
2686 | } | 2684 | } |
2687 | // qDebug("Found it at %u:%u", pos, offset); | 2685 | // qDebug("Found it at %u:%u", pos, offset); |
2688 | pbar->hide(); | 2686 | pbar->hide(); |
2689 | // qDebug("Hid"); | 2687 | // qDebug("Hid"); |
2690 | reader->locate(pos+offset); | 2688 | reader->locate(pos+offset); |
2691 | // qDebug("Loacted"); | 2689 | // qDebug("Loacted"); |
2692 | // qDebug("page up"); | 2690 | // qDebug("page up"); |
2693 | ret = true; | 2691 | ret = true; |
2694 | } | 2692 | } |
2695 | else | 2693 | else |
2696 | { | 2694 | { |
2697 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2695 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2698 | pos = searchStart; | 2696 | pos = searchStart; |
2699 | else | 2697 | else |
2700 | pos = start; | 2698 | pos = start; |
2701 | ret = false; | 2699 | ret = false; |
2702 | findClose(); | 2700 | findClose(); |
2703 | } | 2701 | } |
2704 | return ret; | 2702 | return ret; |
2705 | } | 2703 | } |
2706 | 2704 | ||
2707 | #ifdef __ISEARCH | 2705 | #ifdef __ISEARCH |
2708 | void QTReaderApp::search(const QString & arg) | 2706 | void QTReaderApp::search(const QString & arg) |
2709 | { | 2707 | { |
2710 | searchrecord* ss = searchStack->top(); | 2708 | searchrecord* ss = searchStack->top(); |
2711 | CBuffer test; | 2709 | CBuffer test; |
2712 | size_t start = reader->pagelocate(); | 2710 | size_t start = reader->pagelocate(); |
2713 | bool haspopped = false; | 2711 | bool haspopped = false; |
2714 | while (arg.left(ss->s.length()) != ss->s) | 2712 | while (arg.left(ss->s.length()) != ss->s) |
2715 | { | 2713 | { |
2716 | haspopped = true; | 2714 | haspopped = true; |
2717 | start = ss->pos; | 2715 | start = ss->pos; |
2718 | // reader->locate(start); | 2716 | // reader->locate(start); |
2719 | searchStack->pop(); | 2717 | searchStack->pop(); |
2720 | delete ss; | 2718 | delete ss; |
2721 | } | 2719 | } |
2722 | if (haspopped) reader->locate(start); | 2720 | if (haspopped) reader->locate(start); |
2723 | /* | 2721 | /* |
2724 | if (arg.length() < ss->len) | 2722 | if (arg.length() < ss->len) |
2725 | { | 2723 | { |
2726 | start = ss->pos; | 2724 | start = ss->pos; |
2727 | reader->locate(start); | 2725 | reader->locate(start); |
2728 | searchStack->pop(); | 2726 | searchStack->pop(); |
2729 | delete ss; | 2727 | delete ss; |
2730 | } | 2728 | } |
2731 | */ | 2729 | */ |
2732 | else | 2730 | else |
2733 | { | 2731 | { |
2734 | start = reader->pagelocate(); | 2732 | start = reader->pagelocate(); |
2735 | reader->jumpto(start); | 2733 | reader->jumpto(start); |
2736 | searchStack->push(new searchrecord(arg,start)); | 2734 | searchStack->push(new searchrecord(arg,start)); |
2737 | } | 2735 | } |
2738 | dosearch(start, test, arg); | 2736 | dosearch(start, test, arg); |
2739 | } | 2737 | } |
2740 | #else | 2738 | #else |
2741 | void QTReaderApp::search() | 2739 | void QTReaderApp::search() |
2742 | { | 2740 | { |
2743 | findNext(); | 2741 | findNext(); |
2744 | } | 2742 | } |
2745 | #endif | 2743 | #endif |
2746 | 2744 | ||
2747 | void QTReaderApp::openFile( const QString &f ) | 2745 | void QTReaderApp::openFile( const QString &f ) |
2748 | { | 2746 | { |
2749 | // qDebug("File:%s", (const char*)f); | 2747 | // qDebug("File:%s", (const char*)f); |
2750 | // openFile(DocLnk(f)); | 2748 | // openFile(DocLnk(f)); |
2751 | //} | 2749 | //} |
2752 | // | 2750 | // |
2753 | //void QTReaderApp::openFile( const DocLnk &f ) | 2751 | //void QTReaderApp::openFile( const DocLnk &f ) |
2754 | //{ | 2752 | //{ |
2755 | clear(); | 2753 | clear(); |
2756 | QFileInfo fm(f); | 2754 | QFileInfo fm(f); |
2757 | if ( fm.exists() ) | 2755 | if ( fm.exists() ) |
2758 | { | 2756 | { |
2759 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); | 2757 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); |
2760 | #ifdef USEQPE | 2758 | #ifdef USEQPE |
2761 | if (fm.extension( FALSE ) == "desktop") | 2759 | if (fm.extension( FALSE ) == "desktop") |
2762 | { | 2760 | { |
2763 | DocLnk d(f); | 2761 | DocLnk d(f); |
2764 | QFileInfo fnew(d.file()); | 2762 | QFileInfo fnew(d.file()); |
2765 | fm = fnew; | 2763 | fm = fnew; |
2766 | if (!fm.exists()) return; | 2764 | if (!fm.exists()) return; |
2767 | } | 2765 | } |
2768 | #endif | 2766 | #endif |
2769 | clear(); | 2767 | clear(); |
2770 | reader->setText(fm.baseName(), fm.absFilePath()); | 2768 | reader->setText(fm.baseName(), fm.absFilePath()); |
2771 | m_loadedconfig = readconfig(APPDIR "/configs", reader->m_string, false); | 2769 | m_loadedconfig = readconfig(APPDIR "/configs", reader->m_string, false); |
2772 | qDebug("Showing tools"); | 2770 | qDebug("Showing tools"); |
2773 | showEditTools(); | 2771 | showEditTools(); |
2774 | qDebug("Shown tools"); | 2772 | qDebug("Shown tools"); |
2775 | readbkmks(); | 2773 | readbkmks(); |
2776 | qDebug("read markss"); | 2774 | qDebug("read markss"); |
2777 | m_savedpos = 0xffffffff; | 2775 | m_savedpos = 0xffffffff; |
2778 | } | 2776 | } |
2779 | else | 2777 | else |
2780 | { | 2778 | { |
2781 | QString msg = f; | 2779 | QString msg = f; |
2782 | msg += "\nFile does not exist"; | 2780 | msg += "\nFile does not exist"; |
2783 | QMessageBox::information(this, PROGNAME, msg); | 2781 | QMessageBox::information(this, PROGNAME, msg); |
2784 | reader->m_lastfile = QString::null; | 2782 | reader->m_lastfile = QString::null; |
2785 | } | 2783 | } |
2786 | 2784 | ||
2787 | } | 2785 | } |
2788 | /* | 2786 | /* |
2789 | void QTReaderApp::resizeEvent(QResizeEvent* e) | 2787 | void QTReaderApp::resizeEvent(QResizeEvent* e) |
2790 | { | 2788 | { |
2791 | if (m_fullscreen) | 2789 | if (m_fullscreen) |
2792 | { | 2790 | { |
2793 | showNormal(); | 2791 | showNormal(); |
2794 | showFullScreen(); | 2792 | showFullScreen(); |
2795 | } | 2793 | } |
2796 | } | 2794 | } |
2797 | */ | 2795 | */ |
2798 | void QTReaderApp::handlekey(QKeyEvent* e) | 2796 | void QTReaderApp::handlekey(QKeyEvent* e) |
2799 | { | 2797 | { |
2800 | // qDebug("Keypress event"); | 2798 | // qDebug("Keypress event"); |
2801 | timeb now; | 2799 | timeb now; |
2802 | ftime(&now); | 2800 | ftime(&now); |
2803 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; | 2801 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; |
2804 | if (etime < m_debounce) | 2802 | if (etime < m_debounce) |
2805 | { | 2803 | { |
2806 | return; | 2804 | return; |
2807 | } | 2805 | } |
2808 | switch(e->key()) | 2806 | switch(e->key()) |
2809 | { | 2807 | { |
2810 | case Key_Escape: | 2808 | case Key_Escape: |
2811 | // qDebug("escape event"); | 2809 | // qDebug("escape event"); |
2812 | if (m_disableesckey) | 2810 | if (m_disableesckey) |
2813 | { | 2811 | { |
2814 | m_disableesckey = false; | 2812 | m_disableesckey = false; |
2815 | } | 2813 | } |
2816 | else | 2814 | else |
2817 | { | 2815 | { |
2818 | m_bcloseDisabled = true; | 2816 | m_bcloseDisabled = true; |
2819 | if (m_fullscreen) | 2817 | if (m_fullscreen) |
2820 | { | 2818 | { |
2821 | m_actFullscreen->setOn(false); | 2819 | m_actFullscreen->setOn(false); |
2822 | e->accept(); | 2820 | e->accept(); |
2823 | } | 2821 | } |
2824 | else | 2822 | else |
2825 | { | 2823 | { |
2826 | // qDebug("escape action"); | 2824 | // qDebug("escape action"); |
2827 | doAction(e); | 2825 | doAction(e); |
2828 | } | 2826 | } |
2829 | } | 2827 | } |
2830 | break; | 2828 | break; |
2831 | /* | 2829 | /* |
2832 | case Key_Left: | 2830 | case Key_Left: |
2833 | { | 2831 | { |
2834 | if (reader->m_autoScroll) | 2832 | if (reader->m_autoScroll) |
2835 | { | 2833 | { |
2836 | reader->reduceScroll(); | 2834 | reader->reduceScroll(); |
2837 | } | 2835 | } |
2838 | else | 2836 | else |
2839 | { | 2837 | { |
2840 | doAction(e); | 2838 | doAction(e); |
2841 | } | 2839 | } |
2842 | } | 2840 | } |
2843 | break; | 2841 | break; |
2844 | case Key_Right: | 2842 | case Key_Right: |
2845 | { | 2843 | { |
2846 | if (reader->m_autoScroll) | 2844 | if (reader->m_autoScroll) |
2847 | { | 2845 | { |
2848 | reader->increaseScroll(); | 2846 | reader->increaseScroll(); |
2849 | } | 2847 | } |
2850 | else | 2848 | else |
2851 | { | 2849 | { |
2852 | doAction(e); | 2850 | doAction(e); |
2853 | } | 2851 | } |
2854 | } | 2852 | } |
2855 | break; | 2853 | break; |
2856 | case Key_Up: | 2854 | case Key_Up: |
2857 | { | 2855 | { |
2858 | if (reader->m_autoScroll) | 2856 | if (reader->m_autoScroll) |
2859 | { | 2857 | { |
2860 | reader->increaseScroll(); | 2858 | reader->increaseScroll(); |
2861 | } | 2859 | } |
2862 | else | 2860 | else |
2863 | { | 2861 | { |
2864 | doAction(e); | 2862 | doAction(e); |
2865 | } | 2863 | } |
2866 | } | 2864 | } |
2867 | break; | 2865 | break; |
2868 | case Key_Down: | 2866 | case Key_Down: |
2869 | { | 2867 | { |
2870 | if (reader->m_autoScroll) | 2868 | if (reader->m_autoScroll) |
2871 | { | 2869 | { |
2872 | reader->reduceScroll(); | 2870 | reader->reduceScroll(); |
2873 | } | 2871 | } |
2874 | else | 2872 | else |
2875 | { | 2873 | { |
2876 | doAction(e); | 2874 | doAction(e); |
2877 | } | 2875 | } |
2878 | } | 2876 | } |
2879 | break; | 2877 | break; |
2880 | */ | 2878 | */ |
2881 | default: | 2879 | default: |
2882 | { | 2880 | { |
2883 | doAction(e); | 2881 | doAction(e); |
2884 | } | 2882 | } |
2885 | 2883 | ||
2886 | /* | 2884 | /* |
2887 | QString msg("Key press was:"); | 2885 | QString msg("Key press was:"); |
2888 | QString key; | 2886 | QString key; |
2889 | msg += key.setNum(e->key()); | 2887 | msg += key.setNum(e->key()); |
2890 | QMessageBox::information(this, PROGNAME, msg); | 2888 | QMessageBox::information(this, PROGNAME, msg); |
2891 | */ | 2889 | */ |
2892 | } | 2890 | } |
2893 | ftime(&m_lastkeytime); | 2891 | ftime(&m_lastkeytime); |
2894 | } | 2892 | } |
2895 | 2893 | ||
2896 | #ifdef NEWFULLSCREEN | 2894 | #ifdef NEWFULLSCREEN |
2897 | void QTReaderApp::enableFullscreen() | 2895 | void QTReaderApp::enableFullscreen() |
2898 | { | 2896 | { |
2899 | setFixedSize(qApp->desktop()->size()); | 2897 | setFixedSize(qApp->desktop()->size()); |
2900 | showNormal(); | 2898 | showNormal(); |
2901 | reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); | 2899 | reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); |
2902 | showFullScreen(); | 2900 | showFullScreen(); |
2903 | } | 2901 | } |
2904 | 2902 | ||
2905 | void QTReaderApp::resizeEvent(QResizeEvent *) | 2903 | void QTReaderApp::resizeEvent(QResizeEvent *) |
2906 | { | 2904 | { |
2907 | if (m_fullscreen && (size() != qApp->desktop()->size())) | 2905 | if (m_fullscreen && (size() != qApp->desktop()->size())) |
2908 | { | 2906 | { |
2909 | enableFullscreen(); | 2907 | enableFullscreen(); |
2910 | } | 2908 | } |
2911 | } | 2909 | } |
2912 | 2910 | ||
2913 | void QTReaderApp::focusInEvent(QFocusEvent*) | 2911 | void QTReaderApp::focusInEvent(QFocusEvent*) |
2914 | { | 2912 | { |
2915 | if (m_fullscreen) | 2913 | if (m_fullscreen) |
2916 | { | 2914 | { |
2917 | enableFullscreen(); | 2915 | enableFullscreen(); |
2918 | raise(); | 2916 | raise(); |
2919 | } | 2917 | } |
2920 | } | 2918 | } |
2921 | #endif | 2919 | #endif |
2922 | 2920 | ||
2923 | void QTReaderApp::showEditTools() | 2921 | void QTReaderApp::showEditTools() |
2924 | { | 2922 | { |
2925 | // if ( !doc ) | 2923 | // if ( !doc ) |
2926 | //close(); | 2924 | //close(); |
2927 | if (m_fullscreen) | 2925 | if (m_fullscreen) |
2928 | { | 2926 | { |
2929 | #ifdef USEQPE | 2927 | #ifdef USEQPE |
2930 | if (menubar != NULL) menubar->hide(); | 2928 | if (menubar != NULL) menubar->hide(); |
2931 | #endif | 2929 | #endif |
2932 | if (fileBar != NULL) fileBar->hide(); | 2930 | if (fileBar != NULL) fileBar->hide(); |
2933 | if (viewBar != NULL) viewBar->hide(); | 2931 | if (viewBar != NULL) viewBar->hide(); |
2934 | if (navBar != NULL) navBar->hide(); | 2932 | if (navBar != NULL) navBar->hide(); |
2935 | if (markBar != NULL) markBar->hide(); | 2933 | if (markBar != NULL) markBar->hide(); |
2936 | if (m_prog != NULL) | 2934 | if (m_prog != NULL) |
2937 | { | 2935 | { |
2938 | // qDebug("Hiding status"); | 2936 | // qDebug("Hiding status"); |
2939 | m_prog->hide(); | 2937 | m_prog->hide(); |
2940 | } | 2938 | } |
2941 | searchBar->hide(); | 2939 | searchBar->hide(); |
2942 | regBar->hide(); | 2940 | regBar->hide(); |
2943 | #ifdef USEQPE | 2941 | #ifdef USEQPE |
2944 | Global::hideInputMethod(); | 2942 | Global::hideInputMethod(); |
2945 | #endif | 2943 | #endif |
2946 | if (m_scrollbar != NULL) m_scrollbar->hide(); | 2944 | if (m_scrollbar != NULL) m_scrollbar->hide(); |
2947 | m_fontBar->hide(); | 2945 | m_fontBar->hide(); |
2948 | //showNormal(); | 2946 | //showNormal(); |
2949 | #ifdef NEWFULLSCREEN | 2947 | #ifdef NEWFULLSCREEN |
2950 | enableFullscreen(); | 2948 | enableFullscreen(); |
2951 | #else | 2949 | #else |
2952 | showFullScreen(); | 2950 | showFullScreen(); |
2953 | #endif | 2951 | #endif |
2954 | } | 2952 | } |
2955 | else | 2953 | else |
2956 | { | 2954 | { |
2957 | //qDebug("him"); | 2955 | //qDebug("him"); |
2958 | #ifdef USEQPE | 2956 | #ifdef USEQPE |
2959 | Global::hideInputMethod(); | 2957 | Global::hideInputMethod(); |
2960 | #endif | 2958 | #endif |
2961 | //qDebug("eb"); | 2959 | //qDebug("eb"); |
2962 | if (m_scrollbar != NULL) | 2960 | if (m_scrollbar != NULL) |
2963 | { | 2961 | { |
2964 | if (m_scrollishidden) | 2962 | if (m_scrollishidden) |
2965 | { | 2963 | { |
2966 | m_scrollbar->hide(); | 2964 | m_scrollbar->hide(); |
2967 | } | 2965 | } |
2968 | else | 2966 | else |
2969 | { | 2967 | { |
2970 | m_scrollbar->show(); | 2968 | m_scrollbar->show(); |
2971 | } | 2969 | } |
2972 | } | 2970 | } |
2973 | if (!m_hidebars) | 2971 | if (!m_hidebars) |
2974 | { | 2972 | { |
2975 | #ifdef USEQPE | 2973 | #ifdef USEQPE |
2976 | menubar->show(); | 2974 | menubar->show(); |
2977 | #endif | 2975 | #endif |
2978 | if (fileBar != NULL) fileBar->show(); | 2976 | if (fileBar != NULL) fileBar->show(); |
2979 | if (viewBar != NULL) viewBar->show(); | 2977 | if (viewBar != NULL) viewBar->show(); |
2980 | if (navBar != NULL) navBar->show(); | 2978 | if (navBar != NULL) navBar->show(); |
2981 | if (markBar != NULL) markBar->show(); | 2979 | if (markBar != NULL) markBar->show(); |
2982 | if (m_prog != NULL && !m_statusishidden) | 2980 | if (m_prog != NULL && !m_statusishidden) |
2983 | { | 2981 | { |
2984 | // qDebug("Showing status"); | 2982 | // qDebug("Showing status"); |
2985 | m_prog->show(); | 2983 | m_prog->show(); |
2986 | // qDebug("Shown status"); | 2984 | // qDebug("Shown status"); |
2987 | } | 2985 | } |
2988 | // qDebug("Showing mb"); | 2986 | // qDebug("Showing mb"); |
2989 | mb->show(); | 2987 | mb->show(); |
2990 | } | 2988 | } |
2991 | if ( searchVisible ) | 2989 | if ( searchVisible ) |
2992 | { | 2990 | { |
2993 | #ifdef USEQPE | 2991 | #ifdef USEQPE |
2994 | Global::showInputMethod(); | 2992 | Global::showInputMethod(); |
2995 | #endif | 2993 | #endif |
2996 | searchBar->show(); | 2994 | searchBar->show(); |
2997 | } | 2995 | } |
2998 | if ( regVisible ) | 2996 | if ( regVisible ) |
2999 | { | 2997 | { |
3000 | #ifdef USEQPE | 2998 | #ifdef USEQPE |
3001 | Global::showInputMethod(); | 2999 | Global::showInputMethod(); |
3002 | #endif | 3000 | #endif |
3003 | regBar->show(); | 3001 | regBar->show(); |
3004 | } | 3002 | } |
3005 | if (m_fontVisible) m_fontBar->show(); | 3003 | if (m_fontVisible) m_fontBar->show(); |
3006 | //qDebug("sn"); | 3004 | //qDebug("sn"); |
3007 | showNormal(); | 3005 | showNormal(); |
3008 | //qDebug("sm"); | 3006 | //qDebug("sm"); |
3009 | #ifdef USEQPE | 3007 | #ifdef USEQPE |
3010 | showMaximized(); | 3008 | showMaximized(); |
3011 | #endif | 3009 | #endif |
3012 | //setCentralWidget(reader); | 3010 | //setCentralWidget(reader); |
3013 | } | 3011 | } |
3014 | 3012 | ||
3015 | // qDebug("uc"); | 3013 | // qDebug("uc"); |
3016 | updateCaption(); | 3014 | updateCaption(); |
3017 | // qDebug("rw"); | 3015 | // qDebug("rw"); |
3018 | editorStack->raiseWidget( reader ); | 3016 | editorStack->raiseWidget( reader ); |
3019 | // qDebug("sf"); | 3017 | // qDebug("sf"); |
3020 | reader->setFocus(); | 3018 | reader->setFocus(); |
3021 | // qDebug("ref"); | 3019 | // qDebug("ref"); |
3022 | reader->refresh(true); | 3020 | reader->refresh(true); |
3023 | // qDebug("done"); | 3021 | // qDebug("done"); |
3024 | } | 3022 | } |
3025 | /* | 3023 | /* |
3026 | void QTReaderApp::save() | 3024 | void QTReaderApp::save() |
3027 | { | 3025 | { |
3028 | if ( !doc ) | 3026 | if ( !doc ) |
3029 | return; | 3027 | return; |
3030 | if ( !editor->edited() ) | 3028 | if ( !editor->edited() ) |
3031 | return; | 3029 | return; |
3032 | 3030 | ||
3033 | QString rt = editor->text(); | 3031 | QString rt = editor->text(); |
3034 | QString pt = rt; | 3032 | QString pt = rt; |
3035 | 3033 | ||
3036 | if ( doc->name().isEmpty() ) { | 3034 | if ( doc->name().isEmpty() ) { |
3037 | unsigned ispace = pt.find( ' ' ); | 3035 | unsigned ispace = pt.find( ' ' ); |
3038 | unsigned ienter = pt.find( '\n' ); | 3036 | unsigned ienter = pt.find( '\n' ); |
3039 | int i = (ispace < ienter) ? ispace : ienter; | 3037 | int i = (ispace < ienter) ? ispace : ienter; |
3040 | QString docname; | 3038 | QString docname; |
3041 | if ( i == -1 ) { | 3039 | if ( i == -1 ) { |
3042 | if ( pt.isEmpty() ) | 3040 | if ( pt.isEmpty() ) |
3043 | docname = "Empty Text"; | 3041 | docname = "Empty Text"; |
3044 | else | 3042 | else |
3045 | docname = pt; | 3043 | docname = pt; |
3046 | } else { | 3044 | } else { |
3047 | docname = pt.left( i ); | 3045 | docname = pt.left( i ); |
3048 | } | 3046 | } |
3049 | doc->setName(docname); | 3047 | doc->setName(docname); |
3050 | } | 3048 | } |
3051 | FileManager fm; | 3049 | FileManager fm; |
3052 | fm.saveFile( *doc, rt ); | 3050 | fm.saveFile( *doc, rt ); |
3053 | } | 3051 | } |
3054 | */ | 3052 | */ |
3055 | 3053 | ||
3056 | void QTReaderApp::clear() | 3054 | void QTReaderApp::clear() |
3057 | { | 3055 | { |
3058 | // if (doc != 0) | 3056 | // if (doc != 0) |
3059 | // { | 3057 | // { |
3060 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); | 3058 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); |
3061 | //delete doc; | 3059 | //delete doc; |
3062 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); | 3060 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); |
3063 | //doc = 0; | 3061 | //doc = 0; |
3064 | // } | 3062 | // } |
3065 | reader->clear(); | 3063 | reader->clear(); |
3066 | } | 3064 | } |
3067 | 3065 | ||
3068 | void QTReaderApp::updateCaption() | 3066 | void QTReaderApp::updateCaption() |
3069 | { | 3067 | { |
3070 | // if ( !doc ) | 3068 | // if ( !doc ) |
3071 | //setCaption( tr("QTReader") ); | 3069 | //setCaption( tr("QTReader") ); |
3072 | // else { | 3070 | // else { |
3073 | //QString s = doc->name(); | 3071 | //QString s = doc->name(); |
3074 | //if ( s.isEmpty() ) | 3072 | //if ( s.isEmpty() ) |
3075 | // s = tr( "Unnamed" ); | 3073 | // s = tr( "Unnamed" ); |
3076 | setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) ); | 3074 | setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) ); |
3077 | // } | 3075 | // } |
3078 | } | 3076 | } |
3079 | 3077 | ||
3080 | void QTReaderApp::setDocument(const QString& fileref) | 3078 | void QTReaderApp::setDocument(const QString& fileref) |
3081 | { | 3079 | { |
3082 | //QMessageBox::information(0, "setDocument", fileref); | 3080 | //QMessageBox::information(0, "setDocument", fileref); |
3083 | openFile(fileref); | 3081 | openFile(fileref); |
3084 | // showEditTools(); | 3082 | // showEditTools(); |
3085 | } | 3083 | } |
3086 | 3084 | ||
3087 | void QTReaderApp::closeEvent( QCloseEvent *e ) | 3085 | void QTReaderApp::closeEvent( QCloseEvent *e ) |
3088 | { | 3086 | { |
3089 | // qDebug("Close event"); | 3087 | // qDebug("Close event"); |
3090 | if (m_fullscreen) | 3088 | if (m_fullscreen) |
3091 | { | 3089 | { |
3092 | m_fullscreen = false; | 3090 | m_fullscreen = false; |
3093 | showEditTools(); | 3091 | showEditTools(); |
3094 | e->ignore(); | 3092 | e->ignore(); |
3095 | } | 3093 | } |
3096 | else if (editorStack->visibleWidget() == m_buttonprefs) | 3094 | else if (editorStack->visibleWidget() == m_buttonprefs) |
3097 | { | 3095 | { |
3098 | m_buttonprefs->mapkey(Qt::NoButton, Key_Escape); | 3096 | m_buttonprefs->mapkey(Qt::NoButton, Key_Escape); |
3099 | e->ignore(); | 3097 | e->ignore(); |
3100 | } | 3098 | } |
3101 | else if (m_dontSave) | 3099 | else if (m_dontSave) |
3102 | { | 3100 | { |
3103 | e->accept(); | 3101 | e->accept(); |
3104 | } | 3102 | } |
3105 | else | 3103 | else |
3106 | { | 3104 | { |
3107 | if (editorStack->visibleWidget() == reader) | 3105 | if (editorStack->visibleWidget() == reader) |
3108 | { | 3106 | { |
3109 | if ((kmap.find(orKey(Qt::NoButton,Key_Escape,false)) != kmap.end()) && m_bcloseDisabled) | 3107 | if ((kmap.find(orKey(Qt::NoButton,Key_Escape,false)) != kmap.end()) && m_bcloseDisabled) |
3110 | { | 3108 | { |
3111 | //qDebug("Close disabled"); | 3109 | //qDebug("Close disabled"); |
3112 | m_bcloseDisabled = false; | 3110 | m_bcloseDisabled = false; |
3113 | e->ignore(); | 3111 | e->ignore(); |
3114 | } | 3112 | } |
3115 | else | 3113 | else |
3116 | { | 3114 | { |
3117 | if (m_fontVisible) | 3115 | if (m_fontVisible) |
3118 | { | 3116 | { |
3119 | m_fontBar->hide(); | 3117 | m_fontBar->hide(); |
3120 | m_fontVisible = false; | 3118 | m_fontVisible = false; |
3121 | e->ignore(); | 3119 | e->ignore(); |
3122 | return; | 3120 | return; |
3123 | } | 3121 | } |
3124 | if (regVisible) | 3122 | if (regVisible) |
3125 | { | 3123 | { |
3126 | regBar->hide(); | 3124 | regBar->hide(); |
3127 | #ifdef USEQPE | 3125 | #ifdef USEQPE |
3128 | Global::hideInputMethod(); | 3126 | Global::hideInputMethod(); |
3129 | #endif | 3127 | #endif |
3130 | regVisible = false; | 3128 | regVisible = false; |
3131 | e->ignore(); | 3129 | e->ignore(); |
3132 | return; | 3130 | return; |
3133 | } | 3131 | } |
3134 | if (searchVisible) | 3132 | if (searchVisible) |
3135 | { | 3133 | { |
3136 | searchBar->hide(); | 3134 | searchBar->hide(); |
3137 | #ifdef USEQPE | 3135 | #ifdef USEQPE |
3138 | Global::hideInputMethod(); | 3136 | Global::hideInputMethod(); |
3139 | #endif | 3137 | #endif |
3140 | searchVisible = false; | 3138 | searchVisible = false; |
3141 | e->ignore(); | 3139 | e->ignore(); |
3142 | return; | 3140 | return; |
3143 | } | 3141 | } |
3144 | if (m_fBkmksChanged && pBkmklist != NULL) | 3142 | if (m_fBkmksChanged && pBkmklist != NULL) |
3145 | { | 3143 | { |
3146 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | 3144 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
3147 | savebkmks(); | 3145 | savebkmks(); |
3148 | delete pBkmklist; | 3146 | delete pBkmklist; |
3149 | reader->pBkmklist = pBkmklist = NULL; | 3147 | reader->pBkmklist = pBkmklist = NULL; |
3150 | m_fBkmksChanged = false; | 3148 | m_fBkmksChanged = false; |
3151 | } | 3149 | } |
3152 | updatefileinfo(); | 3150 | updatefileinfo(); |
3153 | saveprefs(); | 3151 | saveprefs(); |
3154 | e->accept(); | 3152 | e->accept(); |
3155 | } | 3153 | } |
3156 | } | 3154 | } |
3157 | else | 3155 | else |
3158 | { | 3156 | { |
3159 | showEditTools(); | 3157 | showEditTools(); |
3160 | m_disableesckey = true; | 3158 | m_disableesckey = true; |
3161 | } | 3159 | } |
3162 | } | 3160 | } |
3163 | } | 3161 | } |
3164 | 3162 | ||
3165 | void QTReaderApp::do_gotomark() | 3163 | void QTReaderApp::do_gotomark() |
3166 | { | 3164 | { |
3167 | m_nBkmkAction = cGotoBkmk; | 3165 | m_nBkmkAction = cGotoBkmk; |
3168 | if (!listbkmk(pBkmklist)) | 3166 | if (!listbkmk(pBkmklist)) |
3169 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 3167 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
3170 | } | 3168 | } |
3171 | 3169 | ||
3172 | void QTReaderApp::do_delmark() | 3170 | void QTReaderApp::do_delmark() |
3173 | { | 3171 | { |
3174 | m_nBkmkAction = cDelBkmk; | 3172 | m_nBkmkAction = cDelBkmk; |
3175 | if (!listbkmk(pBkmklist)) | 3173 | if (!listbkmk(pBkmklist)) |
3176 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 3174 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
3177 | } | 3175 | } |
3178 | 3176 | ||
3179 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) | 3177 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) |
3180 | { | 3178 | { |
3181 | bkmkselector->clear(); | 3179 | bkmkselector->clear(); |
3182 | if (_lab.isEmpty()) | 3180 | if (_lab.isEmpty()) |
3183 | bkmkselector->setText("Cancel"); | 3181 | bkmkselector->setText("Cancel"); |
3184 | else | 3182 | else |
3185 | bkmkselector->setText(_lab); | 3183 | bkmkselector->setText(_lab); |
3186 | int cnt = 0; | 3184 | int cnt = 0; |
3187 | if (plist != NULL) | 3185 | if (plist != NULL) |
3188 | { | 3186 | { |
3189 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) | 3187 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) |
3190 | { | 3188 | { |
3191 | #ifdef _UNICODE | 3189 | #ifdef _UNICODE |
3192 | // qDebug("Item:%s", (const char*)toQString(i->name())); | 3190 | // qDebug("Item:%s", (const char*)toQString(i->name())); |
3193 | bkmkselector->insertItem(toQString(i->name())); | 3191 | bkmkselector->insertItem(toQString(i->name())); |
3194 | #else | 3192 | #else |
3195 | bkmkselector->insertItem(i->name()); | 3193 | bkmkselector->insertItem(i->name()); |
3196 | #endif | 3194 | #endif |
3197 | cnt++; | 3195 | cnt++; |
3198 | } | 3196 | } |
3199 | } | 3197 | } |
3200 | if (cnt > 0) | 3198 | if (cnt > 0) |
3201 | { | 3199 | { |
3202 | hidetoolbars(); | 3200 | hidetoolbars(); |
3203 | editorStack->raiseWidget( bkmkselector ); | 3201 | editorStack->raiseWidget( bkmkselector ); |
3204 | return true; | 3202 | return true; |
3205 | } | 3203 | } |
3206 | else | 3204 | else |
3207 | return false; | 3205 | return false; |
3208 | } | 3206 | } |
3209 | 3207 | ||
3210 | void QTReaderApp::do_autogen() | 3208 | void QTReaderApp::do_autogen() |
3211 | { | 3209 | { |
3212 | m_nRegAction = cAutoGen; | 3210 | m_nRegAction = cAutoGen; |
3213 | regEdit->setText(m_autogenstr); | 3211 | regEdit->setText(m_autogenstr); |
3214 | do_regedit(); | 3212 | do_regedit(); |
3215 | } | 3213 | } |
3216 | 3214 | ||
3217 | void QTReaderApp::do_regedit() | 3215 | void QTReaderApp::do_regedit() |
3218 | { | 3216 | { |
3219 | // fileBar->hide(); | 3217 | // fileBar->hide(); |
3220 | reader->bDoUpdates = false; | 3218 | reader->bDoUpdates = false; |
3221 | // qDebug("Showing regbar"); | 3219 | // qDebug("Showing regbar"); |
3222 | regBar->show(); | 3220 | regBar->show(); |
3223 | // qDebug("Showing kbd"); | 3221 | // qDebug("Showing kbd"); |
3224 | #ifdef USEQPE | 3222 | #ifdef USEQPE |
3225 | Global::showInputMethod(); | 3223 | Global::showInputMethod(); |
3226 | #endif | 3224 | #endif |
3227 | regVisible = true; | 3225 | regVisible = true; |
3228 | regEdit->setFocus(); | 3226 | regEdit->setFocus(); |
3229 | // qApp->processEvents(); | 3227 | // qApp->processEvents(); |
3230 | reader->bDoUpdates = true; | 3228 | reader->bDoUpdates = true; |
3231 | reader->update(); | 3229 | reader->update(); |
3232 | } | 3230 | } |
3233 | 3231 | ||
3234 | bool QTReaderApp::openfrombkmk(Bkmk* bk) | 3232 | bool QTReaderApp::openfrombkmk(Bkmk* bk) |
3235 | { | 3233 | { |
3236 | QString fn = toQString( | 3234 | QString fn = toQString( |
3237 | CFiledata(bk->anno()).name() | 3235 | CFiledata(bk->anno()).name() |
3238 | ); | 3236 | ); |
3239 | //qDebug("fileinfo"); | 3237 | //qDebug("fileinfo"); |
3240 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 3238 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
3241 | { | 3239 | { |
3242 | //qDebug("Opening"); | 3240 | //qDebug("Opening"); |
3243 | openFile(fn); | 3241 | openFile(fn); |
3244 | struct stat fnstat; | 3242 | struct stat fnstat; |
3245 | stat((const char *)reader->m_lastfile, &fnstat); | 3243 | stat((const char *)reader->m_lastfile, &fnstat); |
3246 | 3244 | ||
3247 | if (CFiledata(bk->anno()).date() | 3245 | if (CFiledata(bk->anno()).date() |
3248 | != fnstat.st_mtime) | 3246 | != fnstat.st_mtime) |
3249 | { | 3247 | { |
3250 | CFiledata fd(bk->anno()); | 3248 | CFiledata fd(bk->anno()); |
3251 | fd.setdate(fnstat.st_mtime); | 3249 | fd.setdate(fnstat.st_mtime); |
3252 | bk->value(0); | 3250 | bk->value(0); |
3253 | } | 3251 | } |
3254 | else | 3252 | else |
3255 | { | 3253 | { |
3256 | unsigned short svlen = bk->filedatalen(); | 3254 | unsigned short svlen = bk->filedatalen(); |
3257 | unsigned char* svdata = bk->filedata(); | 3255 | unsigned char* svdata = bk->filedata(); |
3258 | reader->putSaveData(svdata, svlen); | 3256 | reader->putSaveData(svdata, svlen); |
3259 | // setstate(svdata, svlen); | 3257 | // setstate(svdata, svlen); |
3260 | if (svlen != 0) | 3258 | if (svlen != 0) |
3261 | { | 3259 | { |
3262 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); | 3260 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); |
3263 | } | 3261 | } |
3264 | // qDebug("updating"); | 3262 | // qDebug("updating"); |
3265 | // showEditTools(); | 3263 | // showEditTools(); |
3266 | reader->locate(bk->value()); | 3264 | reader->locate(bk->value()); |
3267 | } | 3265 | } |
3268 | return true; | 3266 | return true; |
3269 | } | 3267 | } |
3270 | else | 3268 | else |
3271 | { | 3269 | { |
3272 | return false; | 3270 | return false; |
3273 | } | 3271 | } |
3274 | } | 3272 | } |
3275 | 3273 | ||
3276 | void QTReaderApp::gotobkmk(int ind) | 3274 | void QTReaderApp::gotobkmk(int ind) |
3277 | { | 3275 | { |
3278 | qDebug("gbkmk"); | 3276 | qDebug("gbkmk"); |
3279 | showEditTools(); | 3277 | showEditTools(); |
3280 | switch (m_nBkmkAction) | 3278 | switch (m_nBkmkAction) |
3281 | { | 3279 | { |
3282 | case cOpenFile: | 3280 | case cOpenFile: |
3283 | { | 3281 | { |
3284 | // qApp->processEvents(); | 3282 | // qApp->processEvents(); |
3285 | if (!openfrombkmk((*pOpenlist)[ind])) | 3283 | if (!openfrombkmk((*pOpenlist)[ind])) |
3286 | { | 3284 | { |
3287 | pOpenlist->erase(ind); | 3285 | pOpenlist->erase(ind); |
3288 | QMessageBox::information(this, PROGNAME, "Can't find file"); | 3286 | QMessageBox::information(this, PROGNAME, "Can't find file"); |
3289 | } | 3287 | } |
3290 | } | 3288 | } |
3291 | break; | 3289 | break; |
3292 | case cGotoBkmk: | 3290 | case cGotoBkmk: |
3293 | reader->buffdoc.saveposn(reader->m_lastfile, reader->pagelocate()); | 3291 | reader->buffdoc.saveposn(reader->m_lastfile, reader->pagelocate()); |
3294 | reader->locate((*pBkmklist)[ind]->value()); | 3292 | reader->locate((*pBkmklist)[ind]->value()); |
3295 | break; | 3293 | break; |
3296 | case cDelBkmk: | 3294 | case cDelBkmk: |
3297 | //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); | 3295 | //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); |
3298 | pBkmklist->erase(ind); | 3296 | pBkmklist->erase(ind); |
3299 | m_fBkmksChanged = true; | 3297 | m_fBkmksChanged = true; |
3300 | reader->refresh(true); | 3298 | reader->refresh(true); |
3301 | // pBkmklist->sort(); | 3299 | // pBkmklist->sort(); |
3302 | break; | 3300 | break; |
3303 | case cRmBkmkFile: | 3301 | case cRmBkmkFile: |
3304 | { | 3302 | { |
3305 | #ifndef USEQPE | 3303 | #ifndef USEQPE |
3306 | QDir d = QDir::home(); // "/" | 3304 | QDir d = QDir::home(); // "/" |
3307 | d.cd(APPDIR); | 3305 | d.cd(APPDIR); |
3308 | d.remove(bkmkselector->text(ind)); | 3306 | d.remove(bkmkselector->text(ind)); |
3309 | #else /* USEQPE */ | 3307 | #else /* USEQPE */ |
3310 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); | 3308 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); |
3311 | #endif /* USEQPE */ | 3309 | #endif /* USEQPE */ |
3312 | } | 3310 | } |
3313 | break; | 3311 | break; |
3314 | case cLdConfig: | 3312 | case cLdConfig: |
3315 | readconfig(APPDIR "/configs", bkmkselector->text(ind), false); | 3313 | readconfig(APPDIR "/configs", bkmkselector->text(ind), false); |
3316 | break; | 3314 | break; |
3317 | case cLdTheme: | 3315 | case cLdTheme: |
3318 | m_themename = bkmkselector->text(ind); | 3316 | m_themename = bkmkselector->text(ind); |
3319 | readconfig(QString(APPDIR "/Themes/")+m_themename , "config", false); | 3317 | readconfig(QString(APPDIR "/Themes/")+m_themename , "config", false); |
3320 | setBackgroundBitmap(); | 3318 | setBackgroundBitmap(); |
3321 | break; | 3319 | break; |
3322 | case cRmConfig: | 3320 | case cRmConfig: |
3323 | { | 3321 | { |
3324 | #ifndef USEQPE | 3322 | #ifndef USEQPE |
3325 | QDir d = QDir::home(); // "/" | 3323 | QDir d = QDir::home(); // "/" |
3326 | d.cd(APPDIR "/configs"); | 3324 | d.cd(APPDIR "/configs"); |
3327 | d.remove(bkmkselector->text(ind)); | 3325 | d.remove(bkmkselector->text(ind)); |
3328 | #else /* USEQPE */ | 3326 | #else /* USEQPE */ |
3329 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); | 3327 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); |
3330 | #endif /* USEQPE */ | 3328 | #endif /* USEQPE */ |
3331 | } | 3329 | } |
3332 | break; | 3330 | break; |
3333 | case cExportLinks: | 3331 | case cExportLinks: |
3334 | { | 3332 | { |
3335 | #ifndef USEQPE | 3333 | #ifndef USEQPE |
3336 | QDir d = QDir::home(); // "/" | 3334 | QDir d = QDir::home(); // "/" |
3337 | d.cd(APPDIR "/urls"); | 3335 | d.cd(APPDIR "/urls"); |
3338 | QFileInfo fi(d, bkmkselector->text(ind)); | 3336 | QFileInfo fi(d, bkmkselector->text(ind)); |
3339 | if (fi.exists()) | 3337 | if (fi.exists()) |
3340 | { | 3338 | { |
3341 | QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); | 3339 | QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); |
3342 | if (!outfile.isEmpty()) | 3340 | if (!outfile.isEmpty()) |
3343 | { | 3341 | { |
3344 | FILE* fout = fopen((const char *)outfile, "w"); | 3342 | FILE* fout = fopen((const char *)outfile, "w"); |
3345 | if (fout != NULL) | 3343 | if (fout != NULL) |
3346 | { | 3344 | { |
3347 | FILE* fin = fopen((const char *)fi.absFilePath(), "r"); | 3345 | FILE* fin = fopen((const char *)fi.absFilePath(), "r"); |
3348 | if (fin != NULL) | 3346 | if (fin != NULL) |
3349 | { | 3347 | { |
3350 | fprintf(fout, "<html><body>\n"); | 3348 | fprintf(fout, "<html><body>\n"); |
3351 | int ch = 0; | 3349 | int ch = 0; |
3352 | while ((ch = fgetc(fin)) != EOF) | 3350 | while ((ch = fgetc(fin)) != EOF) |
3353 | { | 3351 | { |
3354 | fputc(ch, fout); | 3352 | fputc(ch, fout); |
3355 | } | 3353 | } |
3356 | fclose(fin); | 3354 | fclose(fin); |
3357 | fprintf(fout, "</html></body>\n"); | 3355 | fprintf(fout, "</html></body>\n"); |
3358 | d.remove(bkmkselector->text(ind)); | 3356 | d.remove(bkmkselector->text(ind)); |
3359 | } | 3357 | } |
3360 | fclose(fout); | 3358 | fclose(fout); |
3361 | } | 3359 | } |
3362 | else | 3360 | else |
3363 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 3361 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
3364 | } | 3362 | } |
3365 | } | 3363 | } |
3366 | #else /* USEQPE */ | 3364 | #else /* USEQPE */ |
3367 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | 3365 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); |
3368 | if (fin != NULL) | 3366 | if (fin != NULL) |
3369 | { | 3367 | { |
3370 | bool allok = false; | 3368 | bool allok = false; |
3371 | #ifdef OPIE | 3369 | #ifdef OPIE |
3372 | QString outfile = OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, QString::null, QString::null, MimeTypes(), 0, "OpieReader"); | 3370 | QString outfile = OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, QString::null, QString::null, MimeTypes(), 0, "OpieReader"); |
3373 | if (!outfile.isEmpty()) | 3371 | if (!outfile.isEmpty()) |
3374 | { | 3372 | { |
3375 | FILE* fout = fopen((const char *)outfile, "w"); | 3373 | FILE* fout = fopen((const char *)outfile, "w"); |
3376 | if (fout != NULL) | 3374 | if (fout != NULL) |
3377 | { | 3375 | { |
3378 | fprintf(fout, "<html><body>\n"); | 3376 | fprintf(fout, "<html><body>\n"); |
3379 | int ch = 0; | 3377 | int ch = 0; |
3380 | while ((ch = fgetc(fin)) != EOF) | 3378 | while ((ch = fgetc(fin)) != EOF) |
3381 | { | 3379 | { |
3382 | fputc(ch, fout); | 3380 | fputc(ch, fout); |
3383 | } | 3381 | } |
3384 | fprintf(fout, "</html></body>\n"); | 3382 | fprintf(fout, "</html></body>\n"); |
3385 | fclose(fout); | 3383 | fclose(fout); |
3386 | allok = true; | 3384 | allok = true; |
3387 | } | 3385 | } |
3388 | else | 3386 | else |
3389 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 3387 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
3390 | } | 3388 | } |
3391 | fclose(fin); | 3389 | fclose(fin); |
3392 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); | 3390 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); |
3393 | #else | 3391 | #else |
3394 | fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); | 3392 | fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); |
3395 | if (fb->exec()) | 3393 | if (fb->exec()) |
3396 | { | 3394 | { |
3397 | QString outfile = fb->getCurrentFile(); | 3395 | QString outfile = fb->getCurrentFile(); |
3398 | FILE* fout = fopen((const char *)outfile, "w"); | 3396 | FILE* fout = fopen((const char *)outfile, "w"); |
3399 | if (fout != NULL) | 3397 | if (fout != NULL) |
3400 | { | 3398 | { |
3401 | fprintf(fout, "<html><body>\n"); | 3399 | fprintf(fout, "<html><body>\n"); |
3402 | int ch = 0; | 3400 | int ch = 0; |
3403 | while ((ch = fgetc(fin)) != EOF) | 3401 | while ((ch = fgetc(fin)) != EOF) |
3404 | { | 3402 | { |
3405 | fputc(ch, fout); | 3403 | fputc(ch, fout); |
3406 | } | 3404 | } |
3407 | fprintf(fout, "</html></body>\n"); | 3405 | fprintf(fout, "</html></body>\n"); |
3408 | fclose(fout); | 3406 | fclose(fout); |
3409 | allok = true; | 3407 | allok = true; |
3410 | } | 3408 | } |
3411 | else | 3409 | else |
3412 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 3410 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
3413 | } | 3411 | } |
3414 | delete fb; | 3412 | delete fb; |
3415 | fclose(fin); | 3413 | fclose(fin); |
3416 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); | 3414 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); |
3417 | #endif | 3415 | #endif |
3418 | } | 3416 | } |
3419 | else | 3417 | else |
3420 | { | 3418 | { |
3421 | QMessageBox::information(this, PROGNAME, "Couldn't open input"); | 3419 | QMessageBox::information(this, PROGNAME, "Couldn't open input"); |
3422 | } | 3420 | } |
3423 | 3421 | ||
3424 | /* | 3422 | /* |
3425 | CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); | 3423 | CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); |
3426 | int ret = f->exec(); | 3424 | int ret = f->exec(); |
3427 | qDebug("Return:%d", ret); | 3425 | qDebug("Return:%d", ret); |
3428 | DocLnk* doc = f->getDoc(); | 3426 | DocLnk* doc = f->getDoc(); |
3429 | if (doc != NULL) | 3427 | if (doc != NULL) |
3430 | { | 3428 | { |
3431 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | 3429 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); |
3432 | QString rt; | 3430 | QString rt; |
3433 | rt = "<html><body>\n"; | 3431 | rt = "<html><body>\n"; |
3434 | int ch = 0; | 3432 | int ch = 0; |
3435 | while ((ch = fgetc(fin)) != EOF) | 3433 | while ((ch = fgetc(fin)) != EOF) |
3436 | { | 3434 | { |
3437 | rt += (char)ch; | 3435 | rt += (char)ch; |
3438 | } | 3436 | } |
3439 | fclose(fin); | 3437 | fclose(fin); |
3440 | rt += "</html></body>\n"; | 3438 | rt += "</html></body>\n"; |
3441 | if ( doc->name().isEmpty() ) | 3439 | if ( doc->name().isEmpty() ) |
3442 | { | 3440 | { |
3443 | doc->setName(bkmkselector->text(ind)); | 3441 | doc->setName(bkmkselector->text(ind)); |
3444 | } | 3442 | } |
3445 | FileManager fm; | 3443 | FileManager fm; |
3446 | fm.saveFile( *doc, rt ); | 3444 | fm.saveFile( *doc, rt ); |
3447 | qDebug("YES"); | 3445 | qDebug("YES"); |
3448 | } | 3446 | } |
3449 | else | 3447 | else |
3450 | { | 3448 | { |
3451 | qDebug("NO"); | 3449 | qDebug("NO"); |
3452 | } | 3450 | } |
3453 | delete f; | 3451 | delete f; |
3454 | */ | 3452 | */ |
3455 | 3453 | ||
3456 | #endif /* USEQPE */ | 3454 | #endif /* USEQPE */ |
3457 | } | 3455 | } |
3458 | break; | 3456 | break; |
3459 | } | 3457 | } |
3460 | } | 3458 | } |
3461 | 3459 | ||
3462 | void QTReaderApp::cancelbkmk() | 3460 | void QTReaderApp::cancelbkmk() |
3463 | { | 3461 | { |
3464 | if (m_nBkmkAction == cOpenFile) | 3462 | if (m_nBkmkAction == cOpenFile) |
3465 | { | 3463 | { |
3466 | QString fn = usefilebrowser(); | 3464 | QString fn = usefilebrowser(); |
3467 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); | 3465 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); |
3468 | } | 3466 | } |
3469 | showEditTools(); | 3467 | showEditTools(); |
3470 | } | 3468 | } |
3471 | 3469 | ||
3472 | void QTReaderApp::reparastring() | 3470 | void QTReaderApp::reparastring() |
3473 | { | 3471 | { |
3474 | m_nRegAction = cRepara; | 3472 | m_nRegAction = cRepara; |
3475 | regEdit->setText(reader->m_reparastring); | 3473 | regEdit->setText(reader->m_reparastring); |
3476 | do_regedit(); | 3474 | do_regedit(); |
3477 | } | 3475 | } |
3478 | 3476 | ||
3479 | void QTReaderApp::do_reparastring(const QString& _lcn) | 3477 | void QTReaderApp::do_reparastring(const QString& _lcn) |
3480 | { | 3478 | { |
3481 | reader->m_reparastring = _lcn; | 3479 | reader->m_reparastring = _lcn; |
3482 | if (reader->brepara) | 3480 | if (reader->brepara) |
3483 | { | 3481 | { |
3484 | reader->bDoUpdates = true; | 3482 | reader->bDoUpdates = true; |
3485 | reader->setfilter(reader->getfilter()); | 3483 | reader->setfilter(reader->getfilter()); |
3486 | } | 3484 | } |
3487 | } | 3485 | } |
3488 | 3486 | ||
3489 | void QTReaderApp::jump() | 3487 | void QTReaderApp::jump() |
3490 | { | 3488 | { |
3491 | m_nRegAction = cJump; | 3489 | m_nRegAction = cJump; |
3492 | char lcn[20]; | 3490 | char lcn[20]; |
3493 | sprintf(lcn, "%lu", reader->pagelocate()); | 3491 | sprintf(lcn, "%lu", reader->pagelocate()); |
3494 | regEdit->setText(lcn); | 3492 | regEdit->setText(lcn); |
3495 | do_regedit(); | 3493 | do_regedit(); |
3496 | } | 3494 | } |
3497 | 3495 | ||
3498 | void QTReaderApp::do_jump(const QString& _lcn) | 3496 | void QTReaderApp::do_jump(const QString& _lcn) |
3499 | { | 3497 | { |
3500 | bool ok; | 3498 | bool ok; |
3501 | QString lcn = _lcn.stripWhiteSpace(); | 3499 | QString lcn = _lcn.stripWhiteSpace(); |
3502 | unsigned long ulcn = lcn.toULong(&ok); | 3500 | unsigned long ulcn = lcn.toULong(&ok); |
3503 | if (!ok) | 3501 | if (!ok) |
3504 | { | 3502 | { |
3505 | double pc = 0.0; | 3503 | double pc = 0.0; |
3506 | #ifdef _WINDOWS | 3504 | #ifdef _WINDOWS |
3507 | if (lcn.at(lcn.length()-1) == '%') | 3505 | if (lcn.at(lcn.length()-1) == '%') |
3508 | #else | 3506 | #else |
3509 | if (lcn[lcn.length()-1] == '%') | 3507 | if (lcn[lcn.length()-1] == '%') |
3510 | #endif | 3508 | #endif |
3511 | { | 3509 | { |
3512 | lcn = lcn.left(lcn.length()-1); | 3510 | lcn = lcn.left(lcn.length()-1); |
3513 | pc = lcn.toDouble(&ok); | 3511 | pc = lcn.toDouble(&ok); |
3514 | } | 3512 | } |
3515 | else | 3513 | else |
3516 | { | 3514 | { |
3517 | pc = lcn.toDouble(&ok); | 3515 | pc = lcn.toDouble(&ok); |
3518 | } | 3516 | } |
3519 | if (ok && 0 <= pc && pc <= 100) | 3517 | if (ok && 0 <= pc && pc <= 100) |
3520 | { | 3518 | { |
3521 | ulcn = (pc*(reader->buffdoc.endSection()-reader->buffdoc.startSection()))/100 + reader->buffdoc.startSection(); | 3519 | ulcn = (pc*(reader->buffdoc.endSection()-reader->buffdoc.startSection()))/100 + reader->buffdoc.startSection(); |
3522 | } | 3520 | } |
3523 | else | 3521 | else |
3524 | { | 3522 | { |
3525 | ok = false; | 3523 | ok = false; |
3526 | } | 3524 | } |
3527 | } | 3525 | } |
3528 | if (ok) | 3526 | if (ok) |
3529 | reader->locate(ulcn); | 3527 | reader->locate(ulcn); |
3530 | else | 3528 | else |
3531 | QMessageBox::information(this, PROGNAME, "Must be a number\nor a percentage"); | 3529 | QMessageBox::information(this, PROGNAME, "Must be a number\nor a percentage"); |
3532 | } | 3530 | } |
3533 | 3531 | ||
3534 | void QTReaderApp::do_regaction() | 3532 | void QTReaderApp::do_regaction() |
3535 | { | 3533 | { |
3536 | reader->bDoUpdates = false; | 3534 | reader->bDoUpdates = false; |
3537 | regBar->hide(); | 3535 | regBar->hide(); |
3538 | #ifdef USEQPE | 3536 | #ifdef USEQPE |
3539 | Global::hideInputMethod(); | 3537 | Global::hideInputMethod(); |
3540 | #endif | 3538 | #endif |
3541 | regVisible = false; | 3539 | regVisible = false; |
3542 | switch(m_nRegAction) | 3540 | switch(m_nRegAction) |
3543 | { | 3541 | { |
3544 | case cAutoGen: | 3542 | case cAutoGen: |
3545 | do_autogen(regEdit->text()); | 3543 | do_autogen(regEdit->text()); |
3546 | break; | 3544 | break; |
3547 | case cAddBkmk: | 3545 | case cAddBkmk: |
3548 | do_addbkmk(regEdit->text()); | 3546 | do_addbkmk(regEdit->text()); |
3549 | break; | 3547 | break; |
3550 | case cRepara: | 3548 | case cRepara: |
3551 | do_reparastring(regEdit->text()); | 3549 | do_reparastring(regEdit->text()); |
3552 | break; | 3550 | break; |
3553 | case cJump: | 3551 | case cJump: |
3554 | do_jump(regEdit->text()); | 3552 | do_jump(regEdit->text()); |
3555 | break; | 3553 | break; |
3556 | /* | 3554 | /* |
3557 | case cMonoSpace: | 3555 | case cMonoSpace: |
3558 | do_mono(regEdit->text()); | 3556 | do_mono(regEdit->text()); |
3559 | break; | 3557 | break; |
3560 | */ | 3558 | */ |
3561 | case cSetTarget: | 3559 | case cSetTarget: |
3562 | do_settarget(regEdit->text()); | 3560 | do_settarget(regEdit->text()); |
3563 | break; | 3561 | break; |
3564 | #ifdef _SCROLLPIPE | 3562 | #ifdef _SCROLLPIPE |
3565 | case cSetPipeTarget: | 3563 | case cSetPipeTarget: |
3566 | do_setpipetarget(regEdit->text()); | 3564 | do_setpipetarget(regEdit->text()); |
3567 | break; | 3565 | break; |
3568 | #endif | 3566 | #endif |
3569 | case cSetConfigName: | 3567 | case cSetConfigName: |
3570 | // qDebug("Saving config"); | 3568 | // qDebug("Saving config"); |
3571 | do_saveconfig(regEdit->text(), false); | 3569 | do_saveconfig(regEdit->text(), false); |
3572 | break; | 3570 | break; |
3573 | } | 3571 | } |
3574 | // reader->restore(); | 3572 | // reader->restore(); |
3575 | // fileBar->show(); | 3573 | // fileBar->show(); |
3576 | reader->setFocus(); | 3574 | reader->setFocus(); |
3577 | // qApp->processEvents(); | 3575 | // qApp->processEvents(); |
3578 | reader->bDoUpdates = true; | 3576 | reader->bDoUpdates = true; |
3579 | reader->update(); | 3577 | reader->update(); |
3580 | } | 3578 | } |
3581 | 3579 | ||
3582 | void QTReaderApp::do_settarget(const QString& _txt) | 3580 | void QTReaderApp::do_settarget(const QString& _txt) |
3583 | { | 3581 | { |
3584 | int ind = _txt.find('/'); | 3582 | int ind = _txt.find('/'); |
3585 | if (ind == -1) | 3583 | if (ind == -1) |
3586 | { | 3584 | { |
3587 | m_targetapp = ""; | 3585 | m_targetapp = ""; |
3588 | m_targetmsg = ""; | 3586 | m_targetmsg = ""; |
3589 | QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); | 3587 | QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); |
3590 | } | 3588 | } |
3591 | else | 3589 | else |
3592 | { | 3590 | { |
3593 | m_targetapp = _txt.left(ind); | 3591 | m_targetapp = _txt.left(ind); |
3594 | m_targetmsg = _txt.right(_txt.length()-ind-1); | 3592 | m_targetmsg = _txt.right(_txt.length()-ind-1); |
3595 | } | 3593 | } |
3596 | } | 3594 | } |
3597 | 3595 | ||
3598 | void QTReaderApp::chooseencoding() | 3596 | void QTReaderApp::chooseencoding() |
3599 | { | 3597 | { |
3600 | m_fontSelector->clear(); | 3598 | m_fontSelector->clear(); |
3601 | m_fontSelector->insertItem("Ascii"); | 3599 | m_fontSelector->insertItem("Ascii"); |
3602 | m_fontSelector->insertItem("UTF-8"); | 3600 | m_fontSelector->insertItem("UTF-8"); |
3603 | m_fontSelector->insertItem("UCS-2(BE)"); | 3601 | m_fontSelector->insertItem("UCS-2(BE)"); |
3604 | m_fontSelector->insertItem("USC-2(LE)"); | 3602 | m_fontSelector->insertItem("USC-2(LE)"); |
3605 | m_fontSelector->insertItem("Palm"); | 3603 | m_fontSelector->insertItem("Palm"); |
3606 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) | 3604 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) |
3607 | { | 3605 | { |
3608 | m_fontSelector->insertItem(iter->mime); | 3606 | m_fontSelector->insertItem(iter->mime); |
3609 | } // delete the FontDatabase!!! | 3607 | } // delete the FontDatabase!!! |
3610 | m_fontSelector->setCurrentItem (reader->m_encd); | 3608 | m_fontSelector->setCurrentItem (reader->m_encd); |
3611 | m_fontAction = cChooseEncoding; | 3609 | m_fontAction = cChooseEncoding; |
3612 | m_fontBar->show(); | 3610 | m_fontBar->show(); |
3613 | m_fontVisible = true; | 3611 | m_fontVisible = true; |
3614 | } | 3612 | } |
3615 | 3613 | ||
3616 | void QTReaderApp::setfont() | 3614 | void QTReaderApp::setfont() |
3617 | { | 3615 | { |
3618 | m_fontSelector->clear(); | 3616 | m_fontSelector->clear(); |
3619 | { | 3617 | { |
3620 | QFontDatabase f; | 3618 | QFontDatabase f; |
3621 | QStringList flist = f.families(); | 3619 | QStringList flist = f.families(); |
3622 | m_fontSelector->insertStringList(flist); | 3620 | m_fontSelector->insertStringList(flist); |
3623 | } // delete the FontDatabase!!! | 3621 | } // delete the FontDatabase!!! |
3624 | 3622 | ||
3625 | for (int i = 1; i <= m_fontSelector->count(); i++) | 3623 | for (int i = 1; i <= m_fontSelector->count(); i++) |
3626 | { | 3624 | { |
3627 | if (m_fontSelector->text(i) == reader->m_fontname) | 3625 | if (m_fontSelector->text(i) == reader->m_fontname) |
3628 | { | 3626 | { |
3629 | m_fontSelector->setCurrentItem(i); | 3627 | m_fontSelector->setCurrentItem(i); |
3630 | break; | 3628 | break; |
3631 | } | 3629 | } |
3632 | } | 3630 | } |
3633 | m_fontAction = cChooseFont; | 3631 | m_fontAction = cChooseFont; |
3634 | m_fontBar->show(); | 3632 | m_fontBar->show(); |
3635 | m_fontVisible = true; | 3633 | m_fontVisible = true; |
3636 | } | 3634 | } |
3637 | 3635 | ||
3638 | void QTReaderApp::setfontHelper(const QString& lcn, int size) | 3636 | void QTReaderApp::setfontHelper(const QString& lcn, int size) |
3639 | { | 3637 | { |
3640 | if (size == 0) size = reader->m_fontControl.currentsize(); | 3638 | if (size == 0) size = reader->m_fontControl.currentsize(); |
3641 | if (m_propogatefontchange) | 3639 | if (m_propogatefontchange) |
3642 | { | 3640 | { |
3643 | QFont f(lcn, 10); | 3641 | QFont f(lcn, 10); |
3644 | bkmkselector->setFont( f ); | 3642 | bkmkselector->setFont( f ); |
3645 | regEdit->setFont( f ); | 3643 | regEdit->setFont( f ); |
3646 | searchEdit->setFont( f ); | 3644 | searchEdit->setFont( f ); |
3647 | m_annoWin->setFont( f ); | 3645 | m_annoWin->setFont( f ); |
3648 | } | 3646 | } |
3649 | reader->m_fontname = lcn; | 3647 | reader->m_fontname = lcn; |
3650 | if (!reader->ChangeFont(size)) | 3648 | if (!reader->ChangeFont(size)) |
3651 | { | 3649 | { |
3652 | reader->ChangeFont(size); | 3650 | reader->ChangeFont(size); |
3653 | } | 3651 | } |
3654 | } | 3652 | } |
3655 | 3653 | ||
3656 | void QTReaderApp::do_setencoding(int i) | 3654 | void QTReaderApp::do_setencoding(int i) |
3657 | { | 3655 | { |
3658 | qDebug("setencoding:%d", i); | 3656 | qDebug("setencoding:%d", i); |
3659 | if (m_fontAction == cChooseEncoding) | 3657 | if (m_fontAction == cChooseEncoding) |
3660 | { | 3658 | { |
3661 | reader->setencoding(i); | 3659 | reader->setencoding(i); |
3662 | } | 3660 | } |
3663 | reader->refresh(); | 3661 | reader->refresh(); |
3664 | m_fontBar->hide(); | 3662 | m_fontBar->hide(); |
3665 | m_fontVisible = false; | 3663 | m_fontVisible = false; |
3666 | // qDebug("showedit"); | 3664 | // qDebug("showedit"); |
3667 | if (reader->isVisible()) showEditTools(); | 3665 | if (reader->isVisible()) showEditTools(); |
3668 | // qDebug("showeditdone"); | 3666 | // qDebug("showeditdone"); |
3669 | } | 3667 | } |
3670 | 3668 | ||
3671 | void QTReaderApp::do_setfont(const QString& lcn) | 3669 | void QTReaderApp::do_setfont(const QString& lcn) |
3672 | { | 3670 | { |
3673 | if (m_fontAction == cChooseFont) | 3671 | if (m_fontAction == cChooseFont) |
3674 | { | 3672 | { |
3675 | setfontHelper(lcn); | 3673 | setfontHelper(lcn); |
3676 | } | 3674 | } |
3677 | reader->refresh(); | 3675 | reader->refresh(); |
3678 | m_fontBar->hide(); | 3676 | m_fontBar->hide(); |
3679 | m_fontVisible = false; | 3677 | m_fontVisible = false; |
3680 | // qDebug("setfont"); | 3678 | // qDebug("setfont"); |
3681 | //if (reader->isVisible()) | 3679 | //if (reader->isVisible()) |
3682 | showEditTools(); | 3680 | showEditTools(); |
3683 | // qDebug("showeditdone"); | 3681 | // qDebug("showeditdone"); |
3684 | } | 3682 | } |
3685 | 3683 | ||
3686 | void QTReaderApp::do_autogen(const QString& regText) | 3684 | void QTReaderApp::do_autogen(const QString& regText) |
3687 | { | 3685 | { |
3688 | unsigned long fs, ts; | 3686 | unsigned long fs, ts; |
3689 | reader->sizes(fs,ts); | 3687 | reader->sizes(fs,ts); |
3690 | // // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); | 3688 | // // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); |
3691 | m_autogenstr = regText; | 3689 | m_autogenstr = regText; |
3692 | QRegExp re(regText); | 3690 | QRegExp re(regText); |
3693 | CBuffer buff; | 3691 | CBuffer buff; |
3694 | if (pBkmklist != NULL) delete pBkmklist; | 3692 | if (pBkmklist != NULL) delete pBkmklist; |
3695 | reader->pBkmklist = pBkmklist = new CList<Bkmk>; | 3693 | reader->pBkmklist = pBkmklist = new CList<Bkmk>; |
3696 | m_fBkmksChanged = true; | 3694 | m_fBkmksChanged = true; |
3697 | 3695 | ||
3698 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); | 3696 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); |
3699 | pbar->show(); | 3697 | pbar->show(); |
3700 | pbar->raise(); | 3698 | pbar->raise(); |
3701 | pbar->reset(); | 3699 | pbar->reset(); |
3702 | reader->update(); | 3700 | reader->update(); |
3703 | qApp->processEvents(); | 3701 | qApp->processEvents(); |
3704 | reader->setFocus(); | 3702 | reader->setFocus(); |
3705 | reader->jumpto(0); | 3703 | reader->jumpto(0); |
3706 | int lastpc = 0; | 3704 | int lastpc = 0; |
3707 | int i = 0; | 3705 | int i = 0; |
3708 | while (i >= 0) | 3706 | while (i >= 0) |
3709 | { | 3707 | { |
3710 | unsigned int lcn = reader->locate(); | 3708 | unsigned int lcn = reader->locate(); |
3711 | int pc = (100*lcn)/ts; | 3709 | int pc = (100*lcn)/ts; |
3712 | if (pc != lastpc) | 3710 | if (pc != lastpc) |
3713 | { | 3711 | { |
3714 | pbar->setProgress(pc); | 3712 | pbar->setProgress(pc); |
3715 | qApp->processEvents(); | 3713 | qApp->processEvents(); |
3716 | if (reader->locate() != lcn) reader->jumpto(lcn); | 3714 | if (reader->locate() != lcn) reader->jumpto(lcn); |
3717 | reader->setFocus(); | 3715 | reader->setFocus(); |
3718 | lastpc = pc; | 3716 | lastpc = pc; |
3719 | } | 3717 | } |
3720 | i = reader->buffdoc.getpara(buff); | 3718 | i = reader->buffdoc.getpara(buff); |
3721 | #ifdef _UNICODE | 3719 | #ifdef _UNICODE |
3722 | if (re.match(toQString(buff.data())) != -1) | 3720 | if (re.match(toQString(buff.data())) != -1) |
3723 | #else | 3721 | #else |
3724 | if (re.match(buff.data()) != -1) | 3722 | if (re.match(buff.data()) != -1) |
3725 | #endif | 3723 | #endif |
3726 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); | 3724 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); |
3727 | } | 3725 | } |
3728 | pBkmklist->sort(); | 3726 | pBkmklist->sort(); |
3729 | pbar->setProgress(100); | 3727 | pbar->setProgress(100); |
3730 | qApp->processEvents(); | 3728 | qApp->processEvents(); |
3731 | pbar->hide(); | 3729 | pbar->hide(); |
3732 | reader->refresh(); | 3730 | reader->refresh(); |
3733 | } | 3731 | } |
3734 | 3732 | ||
3735 | void QTReaderApp::saveprefs() | 3733 | void QTReaderApp::saveprefs() |
3736 | { | 3734 | { |
3737 | do_saveconfig( APPDIR, true ); | 3735 | do_saveconfig( APPDIR, true ); |
3738 | savefilelist(); | 3736 | savefilelist(); |
3739 | } | 3737 | } |
3740 | 3738 | ||
3741 | /* | 3739 | /* |
3742 | void QTReaderApp::oldFile() | 3740 | void QTReaderApp::oldFile() |
3743 | { | 3741 | { |
3744 | // qDebug("oldFile called"); | 3742 | // qDebug("oldFile called"); |
3745 | reader->setText(true); | 3743 | reader->setText(true); |
3746 | // qDebug("settext called"); | 3744 | // qDebug("settext called"); |
3747 | showEditTools(); | 3745 | showEditTools(); |
3748 | // qDebug("showedit called"); | 3746 | // qDebug("showedit called"); |
3749 | } | 3747 | } |
3750 | */ | 3748 | */ |
3751 | 3749 | ||
3752 | /* | 3750 | /* |
3753 | void info_cb(Fl_Widget* o, void* _data) | 3751 | void info_cb(Fl_Widget* o, void* _data) |
3754 | { | 3752 | { |
3755 | 3753 | ||
3756 | if (infowin == NULL) | 3754 | if (infowin == NULL) |
3757 | { | 3755 | { |
3758 | 3756 | ||
3759 | infowin = new Fl_Window(160,240); | 3757 | infowin = new Fl_Window(160,240); |
3760 | filename = new Fl_Output(45,5,110,14,"Filename"); | 3758 | filename = new Fl_Output(45,5,110,14,"Filename"); |
3761 | filesize = new Fl_Output(45,25,110,14,"Filesize"); | 3759 | filesize = new Fl_Output(45,25,110,14,"Filesize"); |
3762 | textsize = new Fl_Output(45,45,110,14,"Textsize"); | 3760 | textsize = new Fl_Output(45,45,110,14,"Textsize"); |
3763 | comprat = new CBar(45,65,110,14,"Ratio %"); | 3761 | comprat = new CBar(45,65,110,14,"Ratio %"); |
3764 | posn = new Fl_Output(45,85,110,14,"Location"); | 3762 | posn = new Fl_Output(45,85,110,14,"Location"); |
3765 | frcn = new CBar(45,105,110,14,"% Read"); | 3763 | frcn = new CBar(45,105,110,14,"% Read"); |
3766 | about = new Fl_Multiline_Output(5,125,150,90); | 3764 | about = new Fl_Multiline_Output(5,125,150,90); |
3767 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); | 3765 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); |
3768 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); | 3766 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); |
3769 | infowin->set_modal(); | 3767 | infowin->set_modal(); |
3770 | } | 3768 | } |
3771 | if (((reader_ui *)_data)->g_filename[0] != '\0') | 3769 | if (((reader_ui *)_data)->g_filename[0] != '\0') |
3772 | { | 3770 | { |
3773 | unsigned long fs,ts; | 3771 | unsigned long fs,ts; |
3774 | tchar sz[20]; | 3772 | tchar sz[20]; |
3775 | ((reader_ui *)_data)->input->sizes(fs,ts); | 3773 | ((reader_ui *)_data)->input->sizes(fs,ts); |
3776 | unsigned long pl = ((reader_ui *)_data)->input->locate(); | 3774 | unsigned long pl = ((reader_ui *)_data)->input->locate(); |
3777 | 3775 | ||
3778 | filename->value(((reader_ui *)_data)->g_filename); | 3776 | filename->value(((reader_ui *)_data)->g_filename); |
3779 | 3777 | ||
3780 | sprintf(sz,"%u",fs); | 3778 | sprintf(sz,"%u",fs); |
3781 | filesize->value(sz); | 3779 | filesize->value(sz); |
3782 | 3780 | ||
3783 | sprintf(sz,"%u",ts); | 3781 | sprintf(sz,"%u",ts); |
3784 | textsize->value(sz); | 3782 | textsize->value(sz); |
3785 | 3783 | ||
3786 | comprat->value(100-(100*fs + (ts >> 1))/ts); | 3784 | comprat->value(100-(100*fs + (ts >> 1))/ts); |
3787 | 3785 | ||
3788 | sprintf(sz,"%u",pl); | 3786 | sprintf(sz,"%u",pl); |
3789 | posn->value(sz); | 3787 | posn->value(sz); |
3790 | 3788 | ||
3791 | frcn->value((100*pl + (ts >> 1))/ts); | 3789 | frcn->value((100*pl + (ts >> 1))/ts); |
3792 | } | 3790 | } |
3793 | infowin->show(); | 3791 | infowin->show(); |
3794 | } | 3792 | } |
3795 | */ | 3793 | */ |
3796 | 3794 | ||
3797 | void QTReaderApp::savebkmks() | 3795 | void QTReaderApp::savebkmks() |
3798 | { | 3796 | { |
3799 | if (pBkmklist != NULL) | 3797 | if (pBkmklist != NULL) |
3800 | { | 3798 | { |
3801 | #ifndef USEQPE | 3799 | #ifndef USEQPE |
3802 | QDir d = QDir::home(); // "/" | 3800 | QDir d = QDir::home(); // "/" |
3803 | d.cd(APPDIR); | 3801 | d.cd(APPDIR); |
3804 | QFileInfo fi(d, reader->m_string); | 3802 | QFileInfo fi(d, reader->m_string); |
3805 | BkmkFile bf((const char *)fi.absFilePath(), true, true); | 3803 | BkmkFile bf((const char *)fi.absFilePath(), true, true); |
3806 | #else /* USEQPE */ | 3804 | #else /* USEQPE */ |
3807 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true, true); | 3805 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true, true); |
3808 | #endif /* USEQPE */ | 3806 | #endif /* USEQPE */ |
3809 | bf.write(*pBkmklist); | 3807 | bf.write(*pBkmklist); |
3810 | } | 3808 | } |
3811 | m_fBkmksChanged = false; | 3809 | m_fBkmksChanged = false; |
3812 | } | 3810 | } |
3813 | 3811 | ||
3814 | void QTReaderApp::readfilelist() | 3812 | void QTReaderApp::readfilelist() |
3815 | { | 3813 | { |
3816 | #ifndef USEQPE | 3814 | #ifndef USEQPE |
3817 | QDir d = QDir::home(); // "/" | 3815 | QDir d = QDir::home(); // "/" |
3818 | d.cd(APPDIR); | 3816 | d.cd(APPDIR); |
3819 | QFileInfo fi(d, ".openfiles"); | 3817 | QFileInfo fi(d, ".openfiles"); |
3820 | BkmkFile bf((const char *)fi.absFilePath(), false, false); | 3818 | BkmkFile bf((const char *)fi.absFilePath(), false, false); |
3821 | #else /* USEQPE */ | 3819 | #else /* USEQPE */ |
3822 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), false, false); | 3820 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), false, false); |
3823 | #endif /* USEQPE */ | 3821 | #endif /* USEQPE */ |
3824 | // qDebug("Reading open files"); | 3822 | // qDebug("Reading open files"); |
3825 | pOpenlist = bf.readall(); | 3823 | pOpenlist = bf.readall(); |
3826 | // if (pOpenlist != NULL) qDebug("...with success"); | 3824 | // if (pOpenlist != NULL) qDebug("...with success"); |
3827 | // else qDebug("...without success!"); | 3825 | // else qDebug("...without success!"); |
3828 | } | 3826 | } |
3829 | 3827 | ||
3830 | void QTReaderApp::savefilelist() | 3828 | void QTReaderApp::savefilelist() |
3831 | { | 3829 | { |
3832 | if (pOpenlist != NULL) | 3830 | if (pOpenlist != NULL) |
3833 | { | 3831 | { |
3834 | #ifndef USEQPE | 3832 | #ifndef USEQPE |
3835 | QDir d = QDir::home(); // "/" | 3833 | QDir d = QDir::home(); // "/" |
3836 | d.cd(APPDIR); | 3834 | d.cd(APPDIR); |
3837 | QFileInfo fi(d, ".openfiles"); | 3835 | QFileInfo fi(d, ".openfiles"); |
3838 | BkmkFile bf((const char *)fi.absFilePath(), true, false); | 3836 | BkmkFile bf((const char *)fi.absFilePath(), true, false); |
3839 | #else /* USEQPE */ | 3837 | #else /* USEQPE */ |
3840 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true, false); | 3838 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true, false); |
3841 | #endif /* USEQPE */ | 3839 | #endif /* USEQPE */ |
3842 | //qDebug("Writing open files"); | 3840 | //qDebug("Writing open files"); |
3843 | bf.write(*pOpenlist); | 3841 | bf.write(*pOpenlist); |
3844 | } | 3842 | } |
3845 | } | 3843 | } |
3846 | 3844 | ||
3847 | void QTReaderApp::readbkmks() | 3845 | void QTReaderApp::readbkmks() |
3848 | { | 3846 | { |
3849 | if (pBkmklist != NULL) | 3847 | if (pBkmklist != NULL) |
3850 | { | 3848 | { |
3851 | delete pBkmklist; | 3849 | delete pBkmklist; |
3852 | } | 3850 | } |
3853 | struct stat fnstat; | 3851 | struct stat fnstat; |
3854 | struct stat bkstat; | 3852 | struct stat bkstat; |
3855 | #ifndef USEQPE | 3853 | #ifndef USEQPE |
3856 | QDir d = QDir::home(); // "/" | 3854 | QDir d = QDir::home(); // "/" |
3857 | d.cd(APPDIR); | 3855 | d.cd(APPDIR); |
3858 | QFileInfo fi(d, reader->m_string); | 3856 | QFileInfo fi(d, reader->m_string); |
3859 | #endif /* ! USEQPE */ | 3857 | #endif /* ! USEQPE */ |
3860 | if ( | 3858 | if ( |
3861 | stat((const char *)reader->m_lastfile, &fnstat) == 0 | 3859 | stat((const char *)reader->m_lastfile, &fnstat) == 0 |
3862 | && | 3860 | && |
3863 | #ifndef USEQPE | 3861 | #ifndef USEQPE |
3864 | stat((const char *)fi.absFilePath(), &bkstat) == 0 | 3862 | stat((const char *)fi.absFilePath(), &bkstat) == 0 |
3865 | #else /* USEQPE */ | 3863 | #else /* USEQPE */ |
3866 | stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 | 3864 | stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 |
3867 | #endif /* USEQPE */ | 3865 | #endif /* USEQPE */ |
3868 | ) | 3866 | ) |
3869 | { | 3867 | { |
3870 | if (bkstat.st_mtime < fnstat.st_mtime) | 3868 | if (bkstat.st_mtime < fnstat.st_mtime) |
3871 | { | 3869 | { |
3872 | #ifndef USEQPE | 3870 | #ifndef USEQPE |
3873 | unlink((const char *)fi.absFilePath()); | 3871 | unlink((const char *)fi.absFilePath()); |
3874 | #else /* USEQPE */ | 3872 | #else /* USEQPE */ |
3875 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 3873 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
3876 | #endif /* USEQPE */ | 3874 | #endif /* USEQPE */ |
3877 | } | 3875 | } |
3878 | } | 3876 | } |
3879 | 3877 | ||
3880 | #ifndef USEQPE | 3878 | #ifndef USEQPE |
3881 | BkmkFile bf((const char *)fi.absFilePath(), false, true); | 3879 | BkmkFile bf((const char *)fi.absFilePath(), false, true); |
3882 | #else /* USEQPE */ | 3880 | #else /* USEQPE */ |
3883 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), false, true); | 3881 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), false, true); |
3884 | #endif /* USEQPE */ | 3882 | #endif /* USEQPE */ |
3885 | 3883 | ||
3886 | reader->pBkmklist = pBkmklist = bf.readall(); | 3884 | reader->pBkmklist = pBkmklist = bf.readall(); |
3887 | m_fBkmksChanged = bf.upgraded(); | 3885 | m_fBkmksChanged = bf.upgraded(); |
3888 | if (pBkmklist == NULL) | 3886 | if (pBkmklist == NULL) |
3889 | { | 3887 | { |
3890 | reader->pBkmklist = pBkmklist = reader->getbkmklist(); | 3888 | reader->pBkmklist = pBkmklist = reader->getbkmklist(); |
3891 | } | 3889 | } |
3892 | if (pBkmklist != NULL) | 3890 | if (pBkmklist != NULL) |
3893 | pBkmklist->sort(); | 3891 | pBkmklist->sort(); |
3894 | } | 3892 | } |
3895 | 3893 | ||
3896 | void QTReaderApp::addbkmk() | 3894 | void QTReaderApp::addbkmk() |
3897 | { | 3895 | { |
3898 | m_nRegAction = cAddBkmk; | 3896 | m_nRegAction = cAddBkmk; |
3899 | regEdit->setText(reader->firstword()); | 3897 | regEdit->setText(reader->firstword()); |
3900 | do_regedit(); | 3898 | do_regedit(); |
3901 | } | 3899 | } |
3902 | 3900 | ||
3903 | void QTReaderApp::do_addbkmk(const QString& text) | 3901 | void QTReaderApp::do_addbkmk(const QString& text) |
3904 | { | 3902 | { |
3905 | if (text.isEmpty()) | 3903 | if (text.isEmpty()) |
3906 | { | 3904 | { |
3907 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); | 3905 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); |
3908 | } | 3906 | } |
3909 | else | 3907 | else |
3910 | { | 3908 | { |
3911 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; | 3909 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; |
3912 | #ifdef _UNICODE | 3910 | #ifdef _UNICODE |
3913 | CBuffer buff; | 3911 | CBuffer buff; |
3914 | int i = 0; | 3912 | int i = 0; |
3915 | for (i = 0; i < text.length(); i++) | 3913 | for (i = 0; i < text.length(); i++) |
3916 | { | 3914 | { |
3917 | buff[i] = text[i].unicode(); | 3915 | buff[i] = text[i].unicode(); |
3918 | } | 3916 | } |
3919 | buff[i] = 0; | 3917 | buff[i] = 0; |
3920 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); | 3918 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); |
3921 | #else | 3919 | #else |
3922 | pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); | 3920 | pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); |
3923 | #endif | 3921 | #endif |
3924 | m_fBkmksChanged = true; | 3922 | m_fBkmksChanged = true; |
3925 | pBkmklist->sort(); | 3923 | pBkmklist->sort(); |
3926 | reader->refresh(true); | 3924 | reader->refresh(true); |
3927 | } | 3925 | } |
3928 | } | 3926 | } |
3929 | 3927 | ||
3930 | void QTReaderApp::UpdateStatus() | 3928 | void QTReaderApp::UpdateStatus() |
3931 | { | 3929 | { |
3932 | QString status; | 3930 | QString status; |
3933 | for (int i = 0; i < m_statusstring.length(); i++) | 3931 | for (int i = 0; i < m_statusstring.length(); i++) |
3934 | { | 3932 | { |
3935 | if (m_statusstring[i].unicode() == '%') | 3933 | if (m_statusstring[i].unicode() == '%') |
3936 | { | 3934 | { |
3937 | i++; | 3935 | i++; |
3938 | if (i < m_statusstring.length()) | 3936 | if (i < m_statusstring.length()) |
3939 | { | 3937 | { |
3940 | switch (m_statusstring[i].unicode()) | 3938 | switch (m_statusstring[i].unicode()) |
3941 | { | 3939 | { |
3942 | case 'F': | 3940 | case 'F': |
3943 | { | 3941 | { |
3944 | unsigned long fs,ts; | 3942 | unsigned long fs,ts; |
3945 | reader->sizes(fs,ts); | 3943 | reader->sizes(fs,ts); |
3946 | status += filesize(ts); | 3944 | status += filesize(ts); |
3947 | } | 3945 | } |
3948 | break; | 3946 | break; |
3949 | case 'f': | 3947 | case 'f': |
3950 | { | 3948 | { |
3951 | status += filesize(reader->pagelocate()); | 3949 | status += filesize(reader->pagelocate()); |
3952 | } | 3950 | } |
3953 | break; | 3951 | break; |
3954 | case 'D': | 3952 | case 'D': |
3955 | { | 3953 | { |
3956 | status += filesize(reader->buffdoc.endSection()-reader->buffdoc.startSection()); | 3954 | status += filesize(reader->buffdoc.endSection()-reader->buffdoc.startSection()); |
3957 | } | 3955 | } |
3958 | break; | 3956 | break; |
3959 | case 'd': | 3957 | case 'd': |
3960 | { | 3958 | { |
3961 | status += filesize(reader->pagelocate()-reader->buffdoc.startSection()); | 3959 | status += filesize(reader->pagelocate()-reader->buffdoc.startSection()); |
3962 | } | 3960 | } |
3963 | break; | 3961 | break; |
3964 | case 'P': | 3962 | case 'P': |
3965 | { | 3963 | { |
3966 | unsigned long fs,ts; | 3964 | unsigned long fs,ts; |
3967 | reader->sizes(fs,ts); | 3965 | reader->sizes(fs,ts); |
3968 | status += percent(reader->pagelocate(),ts); | 3966 | status += percent(reader->pagelocate(),ts); |
3969 | } | 3967 | } |
3970 | break; | 3968 | break; |
3971 | case 'p': | 3969 | case 'p': |
3972 | { | 3970 | { |
3973 | status += percent(reader->pagelocate()-reader->buffdoc.startSection(),reader->buffdoc.endSection()-reader->buffdoc.startSection()); | 3971 | status += percent(reader->pagelocate()-reader->buffdoc.startSection(),reader->buffdoc.endSection()-reader->buffdoc.startSection()); |
3974 | } | 3972 | } |
3975 | break; | 3973 | break; |
3976 | case 'z': | 3974 | case 'z': |
3977 | { | 3975 | { |
3978 | // qDebug("case d"); | 3976 | // qDebug("case d"); |
3979 | status += QString().setNum(reader->m_fontControl.currentsize()*10); | 3977 | status += QString().setNum(reader->m_fontControl.currentsize()*10); |
3980 | } | 3978 | } |
3981 | break; | 3979 | break; |
3982 | default: | 3980 | default: |
3983 | status += m_statusstring[i]; | 3981 | status += m_statusstring[i]; |
3984 | } | 3982 | } |
3985 | } | 3983 | } |
3986 | } | 3984 | } |
3987 | else | 3985 | else |
3988 | { | 3986 | { |
3989 | status += m_statusstring[i]; | 3987 | status += m_statusstring[i]; |
3990 | } | 3988 | } |
3991 | } | 3989 | } |
3992 | m_prog->setText(status); | 3990 | m_prog->setText(status); |
3993 | } | 3991 | } |
3994 | 3992 | ||
3995 | void QTReaderApp::OnRedraw() | 3993 | void QTReaderApp::OnRedraw() |
3996 | { | 3994 | { |
3997 | if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) | 3995 | if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) |
3998 | { | 3996 | { |
3999 | bool found = findNextBookmark(reader->pagelocate()); | 3997 | bool found = findNextBookmark(reader->pagelocate()); |
4000 | m_bkmkAvail->setEnabled(found); | 3998 | m_bkmkAvail->setEnabled(found); |
4001 | } | 3999 | } |
4002 | if (m_scrollbar != NULL) | 4000 | if (m_scrollbar != NULL) |
4003 | { | 4001 | { |
4004 | //qDebug("OnRedraw:[%u, %u]", reader->buffdoc.startSection(), reader->buffdoc.endSection()); | 4002 | //qDebug("OnRedraw:[%u, %u]", reader->buffdoc.startSection(), reader->buffdoc.endSection()); |
4005 | scrollbar->setRange(reader->buffdoc.startSection(), reader->buffdoc.endSection()-1); | 4003 | scrollbar->setRange(reader->buffdoc.startSection(), reader->buffdoc.endSection()-1); |
4006 | scrollbar->setPageStep(reader->locate()-reader->pagelocate()); | 4004 | scrollbar->setPageStep(reader->locate()-reader->pagelocate()); |
4007 | scrollbar->setValue((reader->m_rotated) ? | 4005 | scrollbar->setValue((reader->m_rotated) ? |
4008 | (reader->buffdoc.endSection() - reader->locate()+reader->buffdoc.startSection()) : | 4006 | (reader->buffdoc.endSection() - reader->locate()+reader->buffdoc.startSection()) : |
4009 | reader->pagelocate()); | 4007 | reader->pagelocate()); |
4010 | } | 4008 | } |
4011 | if (m_prog->isVisible()) | 4009 | if (m_prog->isVisible()) |
4012 | { | 4010 | { |
4013 | // qDebug("updating status"); | 4011 | // qDebug("updating status"); |
4014 | UpdateStatus(); | 4012 | UpdateStatus(); |
4015 | // qDebug("updated status"); | 4013 | // qDebug("updated status"); |
4016 | } | 4014 | } |
4017 | } | 4015 | } |
4018 | 4016 | ||
4019 | void QTReaderApp::showAnnotation() | 4017 | void QTReaderApp::showAnnotation() |
4020 | { | 4018 | { |
4021 | m_annoWin->setName(toQString(m_anno->name())); | 4019 | m_annoWin->setName(toQString(m_anno->name())); |
4022 | m_annoWin->setAnno(toQString(m_anno->anno())); | 4020 | m_annoWin->setAnno(toQString(m_anno->anno())); |
4023 | m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); | 4021 | m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); |
4024 | m_annoIsEditing = false; | 4022 | m_annoIsEditing = false; |
4025 | #ifdef USEQPE | 4023 | #ifdef USEQPE |
4026 | Global::showInputMethod(); | 4024 | Global::showInputMethod(); |
4027 | #endif | 4025 | #endif |
4028 | editorStack->raiseWidget( m_annoWin ); | 4026 | editorStack->raiseWidget( m_annoWin ); |
4029 | hidetoolbars(); | 4027 | hidetoolbars(); |
4030 | m_annoWin->setFocus(); | 4028 | m_annoWin->setFocus(); |
4031 | } | 4029 | } |
4032 | 4030 | ||
4033 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, size_t posn2, const QString& line) | 4031 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, size_t posn2, const QString& line) |
4034 | { | 4032 | { |
4035 | //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); | 4033 | //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); |
4036 | 4034 | ||
4037 | if (m_doClipboard) | 4035 | if (m_doClipboard) |
4038 | { | 4036 | { |
4039 | QClipboard* cb = QApplication::clipboard(); | 4037 | QClipboard* cb = QApplication::clipboard(); |
4040 | cb->setText(wrd); | 4038 | cb->setText(wrd); |
4041 | #ifdef USEQPE | 4039 | #ifdef USEQPE |
4042 | if (wrd.length() > 10) | 4040 | if (wrd.length() > 10) |
4043 | { | 4041 | { |
4044 | Global::statusMessage(wrd.left(8) + ".."); | 4042 | Global::statusMessage(wrd.left(8) + ".."); |
4045 | } | 4043 | } |
4046 | else | 4044 | else |
4047 | { | 4045 | { |
4048 | Global::statusMessage(wrd); | 4046 | Global::statusMessage(wrd); |
4049 | } | 4047 | } |
4050 | #endif | 4048 | #endif |
4051 | } | 4049 | } |
4052 | if (m_doAnnotation) | 4050 | if (m_doAnnotation) |
4053 | { | 4051 | { |
4054 | //addAnno(wrd, "Need to be able to edit this", posn); | 4052 | //addAnno(wrd, "Need to be able to edit this", posn); |
4055 | m_annoWin->setName(line); | 4053 | m_annoWin->setName(line); |
4056 | m_annoWin->setAnno(""); | 4054 | m_annoWin->setAnno(""); |
4057 | m_annoWin->setPosn(posn); | 4055 | m_annoWin->setPosn(posn); |
4058 | m_annoWin->setPosn2(posn2); | 4056 | m_annoWin->setPosn2(posn2); |
4059 | m_annoIsEditing = true; | 4057 | m_annoIsEditing = true; |
4060 | #ifdef USEQPE | 4058 | #ifdef USEQPE |
4061 | Global::showInputMethod(); | 4059 | Global::showInputMethod(); |
4062 | #endif | 4060 | #endif |
4063 | editorStack->raiseWidget( m_annoWin ); | 4061 | editorStack->raiseWidget( m_annoWin ); |
4064 | hidetoolbars(); | 4062 | hidetoolbars(); |
4065 | } | 4063 | } |
4066 | #ifdef USEQPE | 4064 | #ifdef USEQPE |
4067 | if (m_doDictionary) | 4065 | if (m_doDictionary) |
4068 | { | 4066 | { |
4069 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) | 4067 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) |
4070 | { | 4068 | { |
4071 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); | 4069 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); |
4072 | e << wrd; | 4070 | e << wrd; |
4073 | } | 4071 | } |
4074 | } | 4072 | } |
4075 | #endif | 4073 | #endif |
4076 | } | 4074 | } |
4077 | 4075 | ||
4078 | void QTReaderApp::doAction(QKeyEvent* e) | 4076 | void QTReaderApp::doAction(QKeyEvent* e) |
4079 | { | 4077 | { |
4080 | QMap<orKey,int>::Iterator f = kmap.end(); | 4078 | QMap<orKey,int>::Iterator f = kmap.end(); |
4081 | 4079 | ||
4082 | if (reader->m_autoScroll) | 4080 | if (reader->m_autoScroll) |
4083 | { | 4081 | { |
4084 | f = kmap.find(orKey(e->state(), e->key(), true)); | 4082 | f = kmap.find(orKey(e->state(), e->key(), true)); |
4085 | } | 4083 | } |
4086 | if (f == kmap.end()) | 4084 | if (f == kmap.end()) |
4087 | { | 4085 | { |
4088 | f = kmap.find(orKey(e->state(), e->key(), false)); | 4086 | f = kmap.find(orKey(e->state(), e->key(), false)); |
4089 | } | 4087 | } |
4090 | 4088 | ||
4091 | if (f == kmap.end()) | 4089 | if (f == kmap.end()) |
4092 | { | 4090 | { |
4093 | qDebug("doaction (no action) : %d %d %d", e->key(), e->state(), f.data()); | 4091 | qDebug("doaction (no action) : %d %d %d", e->key(), e->state(), f.data()); |
4094 | e->ignore(); | 4092 | e->ignore(); |
4095 | } | 4093 | } |
4096 | else | 4094 | else |
4097 | { | 4095 | { |
4098 | qDebug("doaction (some action) : %d %d %d", e->key(), e->state(), f.data()); | 4096 | qDebug("doaction (some action) : %d %d %d", e->key(), e->state(), f.data()); |
4099 | ActionTypes a = (ActionTypes)f.data(); | 4097 | ActionTypes a = (ActionTypes)f.data(); |
4100 | e->accept(); | 4098 | e->accept(); |
4101 | //qDebug("Accepted"); | 4099 | //qDebug("Accepted"); |
4102 | switch (a) | 4100 | switch (a) |
4103 | { | 4101 | { |
4104 | case cesGotoLink: | 4102 | case cesGotoLink: |
4105 | { | 4103 | { |
4106 | reader->gotoLink(); | 4104 | reader->gotoLink(); |
4107 | } | 4105 | } |
4108 | break; | 4106 | break; |
4109 | case cesNextLink: | 4107 | case cesNextLink: |
4110 | { | 4108 | { |
4111 | reader->getNextLink(); | 4109 | reader->getNextLink(); |
4112 | } | 4110 | } |
4113 | break; | 4111 | break; |
4114 | case cesInvertColours: | 4112 | case cesInvertColours: |
4115 | m_inverse_action->setOn(!reader->bInverse); | 4113 | m_inverse_action->setOn(!reader->bInverse); |
4116 | break; | 4114 | break; |
4117 | case cesToggleBars: | 4115 | case cesToggleBars: |
4118 | m_hidebars = !m_hidebars; | 4116 | m_hidebars = !m_hidebars; |
4119 | if (m_hidebars) | 4117 | if (m_hidebars) |
4120 | { | 4118 | { |
4121 | #ifdef USEQPE | 4119 | #ifdef USEQPE |
4122 | menubar->hide(); | 4120 | menubar->hide(); |
4123 | #endif | 4121 | #endif |
4124 | if (fileBar != NULL) fileBar->hide(); | 4122 | if (fileBar != NULL) fileBar->hide(); |
4125 | if (viewBar != NULL) viewBar->hide(); | 4123 | if (viewBar != NULL) viewBar->hide(); |
4126 | if (navBar != NULL) navBar->hide(); | 4124 | if (navBar != NULL) navBar->hide(); |
4127 | if (markBar != NULL) markBar->hide(); | 4125 | if (markBar != NULL) markBar->hide(); |
4128 | mb->hide(); | 4126 | mb->hide(); |
4129 | } | 4127 | } |
4130 | else | 4128 | else |
4131 | { | 4129 | { |
4132 | #ifdef USEQPE | 4130 | #ifdef USEQPE |
4133 | menubar->show(); | 4131 | menubar->show(); |
4134 | #endif | 4132 | #endif |
4135 | if (fileBar != NULL) fileBar->show(); | 4133 | if (fileBar != NULL) fileBar->show(); |
4136 | if (viewBar != NULL) viewBar->show(); | 4134 | if (viewBar != NULL) viewBar->show(); |
4137 | if (navBar != NULL) navBar->show(); | 4135 | if (navBar != NULL) navBar->show(); |
4138 | if (markBar != NULL) markBar->show(); | 4136 | if (markBar != NULL) markBar->show(); |
4139 | mb->show(); | 4137 | mb->show(); |
4140 | } | 4138 | } |
4141 | break; | 4139 | break; |
4142 | case cesToggleScrollBar: | 4140 | case cesToggleScrollBar: |
4143 | if (m_scrollbar != NULL) | 4141 | if (m_scrollbar != NULL) |
4144 | { | 4142 | { |
4145 | if (m_scrollbar->isHidden()) | 4143 | if (m_scrollbar->isHidden()) |
4146 | { | 4144 | { |
4147 | m_scrollishidden = false; | 4145 | m_scrollishidden = false; |
4148 | m_scrollbar->show(); | 4146 | m_scrollbar->show(); |
4149 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; | 4147 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; |
4150 | } | 4148 | } |
4151 | else | 4149 | else |
4152 | { | 4150 | { |
4153 | m_scrollishidden = true; | 4151 | m_scrollishidden = true; |
4154 | m_scrollbar->hide(); | 4152 | m_scrollbar->hide(); |
4155 | reader->m_scrollpos = m_localscroll; | 4153 | reader->m_scrollpos = m_localscroll; |
4156 | } | 4154 | } |
4157 | } | 4155 | } |
4158 | break; | 4156 | break; |
4159 | case cesToggleStatusBar: | 4157 | case cesToggleStatusBar: |
4160 | if (m_prog != NULL) | 4158 | if (m_prog != NULL) |
4161 | { | 4159 | { |
4162 | if (m_prog->isHidden()) | 4160 | if (m_prog->isHidden()) |
4163 | { | 4161 | { |
4164 | m_statusishidden = false; | 4162 | m_statusishidden = false; |
4165 | m_prog->show(); | 4163 | m_prog->show(); |
4166 | } | 4164 | } |
4167 | else | 4165 | else |
4168 | { | 4166 | { |
4169 | m_statusishidden = true; | 4167 | m_statusishidden = true; |
4170 | m_prog->hide(); | 4168 | m_prog->hide(); |
4171 | } | 4169 | } |
4172 | } | 4170 | } |
4173 | break; | 4171 | break; |
4174 | case cesOpenFile: | 4172 | case cesOpenFile: |
4175 | { | 4173 | { |
4176 | qDebug("Open file"); | 4174 | qDebug("Open file"); |
4177 | fileOpen(); | 4175 | fileOpen(); |
4178 | } | 4176 | } |
4179 | break; | 4177 | break; |
4180 | case cesAutoScroll: | 4178 | case cesAutoScroll: |
4181 | { | 4179 | { |
4182 | reader->setautoscroll(!reader->m_autoScroll); | 4180 | reader->setautoscroll(!reader->m_autoScroll); |
4183 | setScrollState(reader->m_autoScroll); | 4181 | setScrollState(reader->m_autoScroll); |
4184 | } | 4182 | } |
4185 | break; | 4183 | break; |
4186 | case cesActionMark: | 4184 | case cesActionMark: |
4187 | { | 4185 | { |
4188 | addbkmk(); | 4186 | addbkmk(); |
4189 | } | 4187 | } |
4190 | break; | 4188 | break; |
4191 | case cesFullScreen: | 4189 | case cesFullScreen: |
4192 | { | 4190 | { |
4193 | m_actFullscreen->setOn(!m_fullscreen); | 4191 | m_actFullscreen->setOn(!m_fullscreen); |
4194 | } | 4192 | } |
4195 | break; | 4193 | break; |
4196 | case cesRotate: | 4194 | case cesRotate: |
4197 | { | 4195 | { |
4198 | m_rotate_action->setOn(!reader->m_rotated); | 4196 | m_rotate_action->setOn(!reader->m_rotated); |
4199 | } | 4197 | } |
4200 | break; | 4198 | break; |
4201 | case cesActionAnno: | 4199 | case cesActionAnno: |
4202 | { | 4200 | { |
4203 | addanno(); | 4201 | addanno(); |
4204 | } | 4202 | } |
4205 | break; | 4203 | break; |
4206 | case cesZoomIn: | 4204 | case cesZoomIn: |
4207 | zoomin(); | 4205 | zoomin(); |
4208 | break; | 4206 | break; |
4209 | case cesZoomOut: | 4207 | case cesZoomOut: |
4210 | zoomout(); | 4208 | zoomout(); |
4211 | break; | 4209 | break; |
4212 | case cesBack: | 4210 | case cesBack: |
4213 | reader->goBack(); | 4211 | reader->goBack(); |
4214 | break; | 4212 | break; |
4215 | case cesForward: | 4213 | case cesForward: |
4216 | reader->goForward(); | 4214 | reader->goForward(); |
4217 | break; | 4215 | break; |
4218 | case cesHome: | 4216 | case cesHome: |
4219 | reader->goHome(); | 4217 | reader->goHome(); |
4220 | break; | 4218 | break; |
4221 | case cesPageUp: | 4219 | case cesPageUp: |
4222 | reader->dopageup(); | 4220 | reader->dopageup(); |
4223 | /* | 4221 | /* |
4224 | ftime(&m_lastkeytime); | 4222 | ftime(&m_lastkeytime); |
4225 | m_fndelay = m_debounce; | 4223 | m_fndelay = m_debounce; |
4226 | // | 4224 | // |
4227 | { | 4225 | { |
4228 | timeb now; | 4226 | timeb now; |
4229 | ftime(&now); | 4227 | ftime(&now); |
4230 | m_fndelay = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm+100; | 4228 | m_fndelay = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm+100; |
4231 | } | 4229 | } |
4232 | */ | 4230 | */ |
4233 | break; | 4231 | break; |
4234 | case cesPageDown: | 4232 | case cesPageDown: |
4235 | reader->dopagedn(); | 4233 | reader->dopagedn(); |
4236 | /* | 4234 | /* |
4237 | ftime(&m_lastkeytime); | 4235 | ftime(&m_lastkeytime); |
4238 | m_fndelay = m_debounce; | 4236 | m_fndelay = m_debounce; |
4239 | // | 4237 | // |
4240 | if (m_debounce != 0) | 4238 | if (m_debounce != 0) |
4241 | { | 4239 | { |
4242 | timeb now; | 4240 | timeb now; |
4243 | ftime(&now); | 4241 | ftime(&now); |
4244 | m_fndelay = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm+10; | 4242 | m_fndelay = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm+10; |
4245 | } | 4243 | } |
4246 | */ | 4244 | */ |
4247 | break; | 4245 | break; |
4248 | case cesLineUp: | 4246 | case cesLineUp: |
4249 | reader->lineUp(); | 4247 | reader->lineUp(); |
4250 | break; | 4248 | break; |
4251 | case cesLineDown: | 4249 | case cesLineDown: |
4252 | reader->lineDown(); | 4250 | reader->lineDown(); |
4253 | break; | 4251 | break; |
4254 | case cesStartDoc: | 4252 | case cesStartDoc: |
4255 | gotoStart(); | 4253 | gotoStart(); |
4256 | break; | 4254 | break; |
4257 | case cesEndDoc: | 4255 | case cesEndDoc: |
4258 | gotoEnd(); | 4256 | gotoEnd(); |
4259 | break; | 4257 | break; |
4260 | case cesScrollMore: | 4258 | case cesScrollMore: |
4261 | reader->increaseScroll(); | 4259 | reader->increaseScroll(); |
4262 | break; | 4260 | break; |
4263 | case cesScrollLess: | 4261 | case cesScrollLess: |
4264 | reader->reduceScroll(); | 4262 | reader->reduceScroll(); |
4265 | break; | 4263 | break; |
4266 | default: | 4264 | default: |
4267 | qDebug("Unknown ActionType:%u", a); | 4265 | qDebug("Unknown ActionType:%u", a); |
4268 | break; | 4266 | break; |
4269 | } | 4267 | } |
4270 | } | 4268 | } |
4271 | } | 4269 | } |
4272 | 4270 | ||
4273 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } | 4271 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } |
4274 | void QTReaderApp::restoreFocus() { reader->setFocus(); } | 4272 | void QTReaderApp::restoreFocus() { reader->setFocus(); } |
4275 | 4273 | ||
4276 | void QTReaderApp::SaveConfig() | 4274 | void QTReaderApp::SaveConfig() |
4277 | { | 4275 | { |
4278 | m_nRegAction = cSetConfigName; | 4276 | m_nRegAction = cSetConfigName; |
4279 | regEdit->setText(reader->m_string); | 4277 | regEdit->setText(reader->m_string); |
4280 | do_regedit(); | 4278 | do_regedit(); |
4281 | } | 4279 | } |
4282 | 4280 | ||
4283 | void QTReaderApp::do_saveconfig(const QString& _txt, bool full) | 4281 | void QTReaderApp::do_saveconfig(const QString& _txt, bool full) |
4284 | { | 4282 | { |
4285 | // qDebug("do_saveconfig:%s", (const char*)_txt); | 4283 | // qDebug("do_saveconfig:%s", (const char*)_txt); |
4286 | #ifdef USEQPE | 4284 | #ifdef USEQPE |
4287 | QString configname; | 4285 | QString configname; |
4288 | Config::Domain dom; | 4286 | Config::Domain dom; |
4289 | 4287 | ||
4290 | if (full) | 4288 | if (full) |
4291 | { | 4289 | { |
4292 | configname = _txt; | 4290 | configname = _txt; |
4293 | dom = Config::User; | 4291 | dom = Config::User; |
4294 | } | 4292 | } |
4295 | else | 4293 | else |
4296 | { | 4294 | { |
4297 | configname = Global::applicationFileName(APPDIR "/configs", _txt); | 4295 | configname = Global::applicationFileName(APPDIR "/configs", _txt); |
4298 | dom = Config::File; | 4296 | dom = Config::File; |
4299 | } | 4297 | } |
4300 | 4298 | ||
4301 | Config config(configname, dom); | 4299 | Config config(configname, dom); |
4302 | config.setGroup( "View" ); | 4300 | config.setGroup( "View" ); |
4303 | 4301 | ||
4304 | #else | 4302 | #else |
4305 | QFileInfo fi; | 4303 | QFileInfo fi; |
4306 | if (full) | 4304 | if (full) |
4307 | { | 4305 | { |
4308 | // qDebug("full:%s", (const char*)_txt); | 4306 | // qDebug("full:%s", (const char*)_txt); |
4309 | QDir d = QDir::home(); // "/" | 4307 | QDir d = QDir::home(); // "/" |
4310 | if ( !d.cd(_txt) ) | 4308 | if ( !d.cd(_txt) ) |
4311 | { // "/tmp" | 4309 | { // "/tmp" |
4312 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); | 4310 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); |
4313 | d = QDir::home(); | 4311 | d = QDir::home(); |
4314 | d.mkdir(_txt); | 4312 | d.mkdir(_txt); |
4315 | d.cd(_txt); | 4313 | d.cd(_txt); |
4316 | } | 4314 | } |
4317 | fi.setFile(d, INIFILE); | 4315 | fi.setFile(d, INIFILE); |
4318 | } | 4316 | } |
4319 | else | 4317 | else |
4320 | { | 4318 | { |
4321 | QDir d = QDir::home(); // "/" | 4319 | QDir d = QDir::home(); // "/" |
4322 | if ( !d.cd(APPDIR) ) | 4320 | if ( !d.cd(APPDIR) ) |
4323 | { // "/tmp" | 4321 | { // "/tmp" |
4324 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 4322 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
4325 | d = QDir::home(); | 4323 | d = QDir::home(); |
4326 | d.mkdir(APPDIR); | 4324 | d.mkdir(APPDIR); |
4327 | d.cd(APPDIR); | 4325 | d.cd(APPDIR); |
4328 | } | 4326 | } |
4329 | if ( !d.cd("configs") ) | 4327 | if ( !d.cd("configs") ) |
4330 | { // "/tmp" | 4328 | { // "/tmp" |
4331 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); | 4329 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); |
4332 | d = QDir::home(); | 4330 | d = QDir::home(); |
4333 | d.cd(APPDIR); | 4331 | d.cd(APPDIR); |
4334 | d.mkdir("configs"); | 4332 | d.mkdir("configs"); |
4335 | d.cd("configs"); | 4333 | d.cd("configs"); |
4336 | } | 4334 | } |
4337 | fi.setFile(d, _txt); | 4335 | fi.setFile(d, _txt); |
4338 | } | 4336 | } |
4339 | //qDebug("Path:%s", (const char*)fi.absFilePath()); | 4337 | //qDebug("Path:%s", (const char*)fi.absFilePath()); |
4340 | Config config(fi.absFilePath()); | 4338 | Config config(fi.absFilePath()); |
4341 | #endif | 4339 | #endif |
4342 | 4340 | ||
4343 | 4341 | ||
4344 | config.writeEntry( "StripCr", reader->bstripcr ); | 4342 | config.writeEntry( "StripCr", reader->bstripcr ); |
4345 | config.writeEntry( "AutoFmt", reader->bautofmt ); | 4343 | config.writeEntry( "AutoFmt", reader->bautofmt ); |
4346 | config.writeEntry( "TextFmt", reader->btextfmt ); | 4344 | config.writeEntry( "TextFmt", reader->btextfmt ); |
4347 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 4345 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
4348 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 4346 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
4349 | config.writeEntry( "Depluck", reader->bdepluck ); | 4347 | config.writeEntry( "Depluck", reader->bdepluck ); |
4350 | config.writeEntry( "Dejpluck", reader->bdejpluck ); | 4348 | config.writeEntry( "Dejpluck", reader->bdejpluck ); |
4351 | config.writeEntry( "OneSpace", reader->bonespace ); | 4349 | config.writeEntry( "OneSpace", reader->bonespace ); |
4352 | config.writeEntry( "Unindent", reader->bunindent ); | 4350 | config.writeEntry( "Unindent", reader->bunindent ); |
4353 | config.writeEntry( "Repara", reader->brepara ); | 4351 | config.writeEntry( "Repara", reader->brepara ); |
4354 | config.writeEntry( "ReparaString", reader->m_reparastring); | 4352 | config.writeEntry( "ReparaString", reader->m_reparastring); |
4355 | config.writeEntry( "BackgroundType" , (int)m_bgtype ); | 4353 | config.writeEntry( "BackgroundType" , (int)m_bgtype ); |
4356 | config.writeEntry( "Theme", m_themename ); | 4354 | config.writeEntry( "Theme", m_themename ); |
4357 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | 4355 | config.writeEntry( "DoubleSpace", reader->bdblspce ); |
4358 | config.writeEntry( "Indent", reader->bindenter ); | 4356 | config.writeEntry( "Indent", reader->bindenter ); |
4359 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | 4357 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); |
4360 | config.writeEntry( "ScrollDelay", reader->m_delay); | 4358 | config.writeEntry( "ScrollDelay", reader->m_delay); |
4361 | config.writeEntry( "ScrollStep", reader->m_scrollstep); | 4359 | config.writeEntry( "ScrollStep", reader->m_scrollstep); |
4362 | config.writeEntry( "ScrollType", reader->m_scrolltype ); | 4360 | config.writeEntry( "ScrollType", reader->m_scrolltype ); |
4363 | if (full) | 4361 | if (full) |
4364 | { | 4362 | { |
4365 | config.writeEntry("Debounce", m_debounce); | 4363 | config.writeEntry("Debounce", m_debounce); |
4366 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | 4364 | config.writeEntry("FloatDialogs", m_bFloatingDialog); |
4367 | reader->m_lastposn = reader->pagelocate(); | 4365 | reader->m_lastposn = reader->pagelocate(); |
4368 | config.writeEntry( "LastFile", reader->m_lastfile ); | 4366 | config.writeEntry( "LastFile", reader->m_lastfile ); |
4369 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 4367 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
4370 | } | 4368 | } |
4371 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 4369 | config.writeEntry( "PageMode", reader->m_bpagemode ); |
4372 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 4370 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); |
4373 | config.writeEntry( "SwapMouse", reader->m_swapmouse); | 4371 | config.writeEntry( "SwapMouse", reader->m_swapmouse); |
4374 | config.writeEntry( "IsRotated", reader->m_rotated ); | 4372 | config.writeEntry( "IsRotated", reader->m_rotated ); |
4375 | config.writeEntry("StatusContent", m_statusstring); | 4373 | config.writeEntry("StatusContent", m_statusstring); |
4376 | config.writeEntry("StatusHidden", m_statusishidden); | 4374 | config.writeEntry("StatusHidden", m_statusishidden); |
4377 | config.writeEntry( "Background", m_background ); | 4375 | config.writeEntry( "Background", m_background ); |
4378 | config.writeEntry( "Foreground", m_foreground ); | 4376 | config.writeEntry( "Foreground", m_foreground ); |
4379 | config.writeEntry( "ScrollColour", m_scrollcolor ); | 4377 | config.writeEntry( "ScrollColour", m_scrollcolor ); |
4380 | config.writeEntry( "ScrollBarColour", m_scrollbarcolor ); | 4378 | config.writeEntry( "ScrollBarColour", m_scrollbarcolor ); |
4381 | config.writeEntry( "Hyphenate", reader->hyphenate ); | 4379 | config.writeEntry( "Hyphenate", reader->hyphenate ); |
4382 | // config.writeEntry( "CustomHyphen", reader->buffdoc.getCustomHyphen() ); | 4380 | // config.writeEntry( "CustomHyphen", reader->buffdoc.getCustomHyphen() ); |
4383 | config.writeEntry( "Fontname", reader->m_fontname ); | 4381 | config.writeEntry( "Fontname", reader->m_fontname ); |
4384 | config.writeEntry( "Encoding", reader->m_encd ); | 4382 | config.writeEntry( "Encoding", reader->m_encd ); |
4385 | config.writeEntry( "CharSpacing", reader->m_charpc ); | 4383 | config.writeEntry( "CharSpacing", reader->m_charpc ); |
4386 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | 4384 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); |
4387 | config.writeEntry( "Top Margin", (int)reader->m_abstopmargin ); | 4385 | config.writeEntry( "Top Margin", (int)reader->m_abstopmargin ); |
4388 | config.writeEntry( "Bottom Margin", (int)reader->m_absbottommargin ); | 4386 | config.writeEntry( "Bottom Margin", (int)reader->m_absbottommargin ); |
4389 | config.writeEntry( "Left Margin", (int)reader->m_absleft_border ); | 4387 | config.writeEntry( "Left Margin", (int)reader->m_absleft_border ); |
4390 | config.writeEntry( "Right Margin", (int)reader->m_absright_border ); | 4388 | config.writeEntry( "Right Margin", (int)reader->m_absright_border ); |
4391 | config.writeEntry( "TargetApp", m_targetapp ); | 4389 | config.writeEntry( "TargetApp", m_targetapp ); |
4392 | config.writeEntry( "TargetMsg", m_targetmsg ); | 4390 | config.writeEntry( "TargetMsg", m_targetmsg ); |
4393 | #ifdef _SCROLLPIPE | 4391 | #ifdef _SCROLLPIPE |
4394 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); | 4392 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); |
4395 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | 4393 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); |
4396 | #endif | 4394 | #endif |
4397 | config.writeEntry( "TwoTouch", m_twoTouch ); | 4395 | config.writeEntry( "TwoTouch", m_twoTouch ); |
4398 | config.writeEntry( "Annotation", m_doAnnotation); | 4396 | config.writeEntry( "Annotation", m_doAnnotation); |
4399 | config.writeEntry( "Dictionary", m_doDictionary); | 4397 | config.writeEntry( "Dictionary", m_doDictionary); |
4400 | config.writeEntry( "Clipboard", m_doClipboard); | 4398 | config.writeEntry( "Clipboard", m_doClipboard); |
4401 | /* | 4399 | /* |
4402 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 4400 | config.writeEntry( "SpaceTarget", m_spaceTarget); |
4403 | config.writeEntry( "EscapeTarget", m_escapeTarget); | 4401 | config.writeEntry( "EscapeTarget", m_escapeTarget); |
4404 | config.writeEntry( "ReturnTarget", m_returnTarget); | 4402 | config.writeEntry( "ReturnTarget", m_returnTarget); |
4405 | config.writeEntry( "LeftTarget", m_leftTarget); | 4403 | config.writeEntry( "LeftTarget", m_leftTarget); |
4406 | config.writeEntry( "RightTarget", m_rightTarget); | 4404 | config.writeEntry( "RightTarget", m_rightTarget); |
4407 | config.writeEntry( "UpTarget", m_upTarget); | 4405 | config.writeEntry( "UpTarget", m_upTarget); |
4408 | config.writeEntry( "DownTarget", m_downTarget); | 4406 | config.writeEntry( "DownTarget", m_downTarget); |
4409 | config.writeEntry("LeftScroll", m_leftScroll); | 4407 | config.writeEntry("LeftScroll", m_leftScroll); |
4410 | config.writeEntry("RightScroll", m_rightScroll); | 4408 | config.writeEntry("RightScroll", m_rightScroll); |
4411 | config.writeEntry("UpScroll", m_upScroll); | 4409 | config.writeEntry("UpScroll", m_upScroll); |
4412 | config.writeEntry("DownScroll", m_downScroll); | 4410 | config.writeEntry("DownScroll", m_downScroll); |
4413 | */ | 4411 | */ |
4414 | config.writeEntry( "Repalm", reader->brepalm ); | 4412 | config.writeEntry( "Repalm", reader->brepalm ); |
4415 | config.writeEntry( "HideScrollBar", m_scrollishidden ); | 4413 | config.writeEntry( "HideScrollBar", m_scrollishidden ); |
4416 | config.writeEntry( "Kern", reader->bkern ); | 4414 | config.writeEntry( "Kern", reader->bkern ); |
4417 | config.writeEntry( "Remap", reader->bremap ); | 4415 | config.writeEntry( "Remap", reader->bremap ); |
4418 | config.writeEntry( "Peanut", reader->bpeanut ); | 4416 | config.writeEntry( "Peanut", reader->bpeanut ); |
4419 | config.writeEntry( "MakeBold", reader->bmakebold ); | 4417 | config.writeEntry( "MakeBold", reader->bmakebold ); |
4420 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | 4418 | config.writeEntry( "Continuous", reader->m_continuousDocument ); |
4421 | config.writeEntry( "FullJust", reader->bfulljust ); | 4419 | config.writeEntry( "FullJust", reader->bfulljust ); |
4422 | // config.writeEntry( "Negative", reader->bNegative ); | 4420 | // config.writeEntry( "Negative", reader->bNegative ); |
4423 | config.writeEntry( "Inverse", reader->bInverse ); | 4421 | config.writeEntry( "Inverse", reader->bInverse ); |
4424 | config.writeEntry( "FixGraphics", reader->m_fontControl.FixGraphics()); | 4422 | config.writeEntry( "FixGraphics", reader->m_fontControl.FixGraphics()); |
4425 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); | 4423 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); |
4426 | config.writeEntry( "ExtraLead", reader->getlead() ); | 4424 | config.writeEntry( "ExtraLead", reader->getlead() ); |
4427 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); | 4425 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); |
4428 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); | 4426 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); |
4429 | #ifdef USEQPE | 4427 | #ifdef USEQPE |
4430 | config.writeEntry( "GrabKeyboard", m_grabkeyboard ); | 4428 | config.writeEntry( "GrabKeyboard", m_grabkeyboard ); |
4431 | #endif | 4429 | #endif |
4432 | if (full) | 4430 | if (full) |
4433 | { | 4431 | { |
4434 | config.setGroup( "Toolbar" ); | 4432 | config.setGroup( "Toolbar" ); |
4435 | config.writeEntry("QTScrollBar", m_qtscroll); | 4433 | config.writeEntry("QTScrollBar", m_qtscroll); |
4436 | config.writeEntry("LocalScrollBar", m_localscroll); | 4434 | config.writeEntry("LocalScrollBar", m_localscroll); |
4437 | config.writeEntry("Movable", m_tbmovesave); | 4435 | config.writeEntry("Movable", m_tbmovesave); |
4438 | config.writeEntry("Policy", m_tbpolsave); | 4436 | config.writeEntry("Policy", m_tbpolsave); |
4439 | config.writeEntry("Position", m_tbposition); | 4437 | config.writeEntry("Position", m_tbposition); |
4440 | #ifndef USEQPE | 4438 | #ifndef USEQPE |
4441 | if (!isMaximized() && !isMinimized()) | 4439 | if (!isMaximized() && !isMinimized()) |
4442 | { | 4440 | { |
4443 | config.setGroup( "Geometry" ); | 4441 | config.setGroup( "Geometry" ); |
4444 | config.writeEntry( "x", x() ); | 4442 | config.writeEntry( "x", x() ); |
4445 | config.writeEntry( "y", y() ); | 4443 | config.writeEntry( "y", y() ); |
4446 | config.writeEntry( "width", width() ); | 4444 | config.writeEntry( "width", width() ); |
4447 | config.writeEntry( "height", height() ); | 4445 | config.writeEntry( "height", height() ); |
4448 | } | 4446 | } |
4449 | #endif | 4447 | #endif |
4450 | } | 4448 | } |
4451 | } | 4449 | } |
4452 | 4450 | ||
4453 | #ifdef _SCROLLPIPE | 4451 | #ifdef _SCROLLPIPE |
4454 | void QTReaderApp::setpipetarget() | 4452 | void QTReaderApp::setpipetarget() |
4455 | { | 4453 | { |
4456 | m_nRegAction = cSetPipeTarget; | 4454 | m_nRegAction = cSetPipeTarget; |
4457 | QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget; | 4455 | QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget; |
4458 | regEdit->setText(text); | 4456 | regEdit->setText(text); |
4459 | do_regedit(); | 4457 | do_regedit(); |
4460 | } | 4458 | } |
4461 | 4459 | ||
4462 | void QTReaderApp::do_setpipetarget(const QString& _txt) | 4460 | void QTReaderApp::do_setpipetarget(const QString& _txt) |
4463 | { | 4461 | { |
4464 | reader->m_pipetarget = _txt; | 4462 | reader->m_pipetarget = _txt; |
4465 | } | 4463 | } |
4466 | 4464 | ||
4467 | void QTReaderApp::setpause(bool sfs) | 4465 | void QTReaderApp::setpause(bool sfs) |
4468 | { | 4466 | { |
4469 | reader->m_pauseAfterEachPara = sfs; | 4467 | reader->m_pauseAfterEachPara = sfs; |
4470 | } | 4468 | } |
4471 | #endif | 4469 | #endif |
4472 | 4470 | ||
4473 | void QTReaderApp::monospace(bool _b) | 4471 | void QTReaderApp::monospace(bool _b) |
4474 | { | 4472 | { |
4475 | reader->setmono(_b); | 4473 | reader->setmono(_b); |
4476 | } | 4474 | } |
4477 | 4475 | ||
4478 | bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool full=false) | 4476 | bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool full=false) |
4479 | { | 4477 | { |
4480 | #ifdef USEQPE | 4478 | #ifdef USEQPE |
4481 | QString configname; | 4479 | QString configname; |
4482 | Config::Domain dom; | 4480 | Config::Domain dom; |
4483 | 4481 | ||
4484 | if (full) | 4482 | if (full) |
4485 | { | 4483 | { |
4486 | configname = _txt; | 4484 | configname = _txt; |
4487 | dom = Config::User; | 4485 | dom = Config::User; |
4488 | } | 4486 | } |
4489 | else | 4487 | else |
4490 | { | 4488 | { |
4491 | configname = Global::applicationFileName(dirname, _txt); | 4489 | configname = Global::applicationFileName(dirname, _txt); |
4492 | QFileInfo fm(configname); | 4490 | QFileInfo fm(configname); |
4493 | if ( !fm.exists() ) return false; | 4491 | if ( !fm.exists() ) return false; |
4494 | dom = Config::File; | 4492 | dom = Config::File; |
4495 | } | 4493 | } |
4496 | 4494 | ||
4497 | Config config(configname, dom); | 4495 | Config config(configname, dom); |
4498 | config.setGroup( "View" ); | 4496 | config.setGroup( "View" ); |
4499 | 4497 | ||
4500 | #else | 4498 | #else |
4501 | QString fullname; | 4499 | QString fullname; |
4502 | if (full) | 4500 | if (full) |
4503 | { | 4501 | { |
4504 | fullname = QDir::homeDirPath() + "/" + _txt + "/" + INIFILE; | 4502 | fullname = QDir::homeDirPath() + "/" + _txt + "/" + INIFILE; |
4505 | } | 4503 | } |
4506 | else | 4504 | else |
4507 | { | 4505 | { |
4508 | fullname = QDir::homeDirPath() + "/" + dirname + "/" + _txt; | 4506 | fullname = QDir::homeDirPath() + "/" + dirname + "/" + _txt; |
4509 | } | 4507 | } |
4510 | if (!QFile::exists(fullname)) return false; | 4508 | if (!QFile::exists(fullname)) return false; |
4511 | 4509 | ||
4512 | Config config(fullname); | 4510 | Config config(fullname); |
4513 | #endif | 4511 | #endif |
4514 | if (full) | 4512 | if (full) |
4515 | { | 4513 | { |
4516 | config.setGroup("Toolbar"); | 4514 | config.setGroup("Toolbar"); |
4517 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", m_tbmovesave); | 4515 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", m_tbmovesave); |
4518 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", m_tbpolsave); | 4516 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", m_tbpolsave); |
4519 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", m_tbposition); | 4517 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", m_tbposition); |
4520 | } | 4518 | } |
4521 | config.setGroup( "View" ); | 4519 | config.setGroup( "View" ); |
4522 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", m_bFloatingDialog); | 4520 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", m_bFloatingDialog); |
4523 | reader->bstripcr = config.readBoolEntry( "StripCr", reader->bstripcr ); | 4521 | reader->bstripcr = config.readBoolEntry( "StripCr", reader->bstripcr ); |
4524 | reader->bfulljust = config.readBoolEntry( "FullJust", reader->bfulljust ); | 4522 | reader->bfulljust = config.readBoolEntry( "FullJust", reader->bfulljust ); |
4525 | reader->bInverse = config.readBoolEntry( "Inverse", reader->bInverse ); | 4523 | reader->bInverse = config.readBoolEntry( "Inverse", reader->bInverse ); |
4526 | // reader->bNegative = config.readBoolEntry( "Negative", false ); | 4524 | // reader->bNegative = config.readBoolEntry( "Negative", false ); |
4527 | reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", reader->m_fontControl.FixGraphics() )); | 4525 | reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", reader->m_fontControl.FixGraphics() )); |
4528 | reader->setextraspace(config.readNumEntry( "ExtraSpace", reader->getextraspace() )); | 4526 | reader->setextraspace(config.readNumEntry( "ExtraSpace", reader->getextraspace() )); |
4529 | reader->setlead(config.readNumEntry( "ExtraLead", reader->getlead() )); | 4527 | reader->setlead(config.readNumEntry( "ExtraLead", reader->getlead() )); |
4530 | reader->btextfmt = config.readBoolEntry( "TextFmt", reader->btextfmt ); | 4528 | reader->btextfmt = config.readBoolEntry( "TextFmt", reader->btextfmt ); |
4531 | reader->bautofmt = config.readBoolEntry( "AutoFmt", reader->bautofmt ); | 4529 | reader->bautofmt = config.readBoolEntry( "AutoFmt", reader->bautofmt ); |
4532 | reader->bstriphtml = config.readBoolEntry( "StripHtml", reader->bstriphtml ); | 4530 | reader->bstriphtml = config.readBoolEntry( "StripHtml", reader->bstriphtml ); |
4533 | reader->bpeanut = config.readBoolEntry( "Peanut", reader->bpeanut ); | 4531 | reader->bpeanut = config.readBoolEntry( "Peanut", reader->bpeanut ); |
4534 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", reader->bdehyphen ); | 4532 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", reader->bdehyphen ); |
4535 | reader->bdepluck = config.readBoolEntry( "Depluck", reader->bdepluck ); | 4533 | reader->bdepluck = config.readBoolEntry( "Depluck", reader->bdepluck ); |
4536 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", reader->bdejpluck ); | 4534 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", reader->bdejpluck ); |
4537 | reader->bonespace = config.readBoolEntry( "OneSpace", reader->bonespace ); | 4535 | reader->bonespace = config.readBoolEntry( "OneSpace", reader->bonespace ); |
4538 | reader->bunindent = config.readBoolEntry( "Unindent", reader->bunindent ); | 4536 | reader->bunindent = config.readBoolEntry( "Unindent", reader->bunindent ); |
4539 | reader->brepara = config.readBoolEntry( "Repara", reader->brepara ); | 4537 | reader->brepara = config.readBoolEntry( "Repara", reader->brepara ); |
4540 | reader->m_reparastring = config.readEntry( "ReparaString", reader->m_reparastring); | 4538 | reader->m_reparastring = config.readEntry( "ReparaString", reader->m_reparastring); |
4541 | m_bgtype = (bground)config.readNumEntry( "BackgroundType" , m_bgtype ); | 4539 | m_bgtype = (bground)config.readNumEntry( "BackgroundType" , m_bgtype ); |
4542 | m_themename = config.readEntry("Theme", m_themename ); | 4540 | m_themename = config.readEntry("Theme", m_themename ); |
4543 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", reader->bdblspce ); | 4541 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", reader->bdblspce ); |
4544 | reader->bindenter = config.readNumEntry( "Indent", reader->bindenter ); | 4542 | reader->bindenter = config.readNumEntry( "Indent", reader->bindenter ); |
4545 | reader->m_textsize = config.readNumEntry( "FontSize", reader->m_textsize ); | 4543 | reader->m_textsize = config.readNumEntry( "FontSize", reader->m_textsize ); |
4546 | reader->m_delay = config.readNumEntry( "ScrollDelay", reader->m_delay); | 4544 | reader->m_delay = config.readNumEntry( "ScrollDelay", reader->m_delay); |
4547 | reader->m_scrollstep = config.readNumEntry( "ScrollStep", reader->m_scrollstep); | 4545 | reader->m_scrollstep = config.readNumEntry( "ScrollStep", reader->m_scrollstep); |
4548 | reader->m_scrolltype = config.readNumEntry( "ScrollType", reader->m_scrolltype); | 4546 | reader->m_scrolltype = config.readNumEntry( "ScrollType", reader->m_scrolltype); |
4549 | if (full) | 4547 | if (full) |
4550 | { | 4548 | { |
4551 | reader->m_lastfile = config.readEntry( "LastFile", reader->m_lastfile ); | 4549 | reader->m_lastfile = config.readEntry( "LastFile", reader->m_lastfile ); |
4552 | reader->m_lastposn = config.readNumEntry( "LastPosn", reader->m_lastposn ); | 4550 | reader->m_lastposn = config.readNumEntry( "LastPosn", reader->m_lastposn ); |
4553 | } | 4551 | } |
4554 | reader->m_bpagemode = config.readBoolEntry( "PageMode", reader->m_bpagemode ); | 4552 | reader->m_bpagemode = config.readBoolEntry( "PageMode", reader->m_bpagemode ); |
4555 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", reader->m_bMonoSpaced); | 4553 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", reader->m_bMonoSpaced); |
4556 | reader->m_rotated = config.readBoolEntry( "IsRotated", reader->m_rotated ); | 4554 | reader->m_rotated = config.readBoolEntry( "IsRotated", reader->m_rotated ); |
4557 | m_statusstring = config.readEntry("StatusContent", m_statusstring); | 4555 | m_statusstring = config.readEntry("StatusContent", m_statusstring); |
4558 | m_statusishidden = config.readBoolEntry("StatusHidden", m_statusishidden); | 4556 | m_statusishidden = config.readBoolEntry("StatusHidden", m_statusishidden); |
4559 | m_background = config.readNumEntry( "Background", m_background ); | 4557 | m_background = config.readNumEntry( "Background", m_background ); |
4560 | reader->setBackground(getcolour(m_background)); | 4558 | reader->setBackground(getcolour(m_background)); |
4561 | m_foreground = config.readNumEntry( "Foreground", m_foreground ); | 4559 | m_foreground = config.readNumEntry( "Foreground", m_foreground ); |
4562 | reader->setForeground(getcolour(m_foreground)); | 4560 | reader->setForeground(getcolour(m_foreground)); |
4563 | m_scrollcolor = config.readNumEntry( "ScrollColour", m_scrollcolor); | 4561 | m_scrollcolor = config.readNumEntry( "ScrollColour", m_scrollcolor); |
4564 | setscrollcolour(); | 4562 | setscrollcolour(); |
4565 | m_scrollbarcolor = config.readNumEntry( "ScrollBarColour", m_scrollbarcolor); | 4563 | m_scrollbarcolor = config.readNumEntry( "ScrollBarColour", m_scrollbarcolor); |
4566 | setscrollbarcolour(); | 4564 | setscrollbarcolour(); |
4567 | reader->hyphenate = config.readBoolEntry( "Hyphenate", reader->hyphenate ); | 4565 | reader->hyphenate = config.readBoolEntry( "Hyphenate", reader->hyphenate ); |
4568 | // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false )); | 4566 | // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false )); |
4569 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", reader->m_swapmouse); | 4567 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", reader->m_swapmouse); |
4570 | reader->m_fontname = config.readEntry( "Fontname", reader->m_fontname ); | 4568 | reader->m_fontname = config.readEntry( "Fontname", reader->m_fontname ); |
4571 | reader->m_encd = config.readNumEntry( "Encoding", reader->m_encd ); | 4569 | reader->m_encd = config.readNumEntry( "Encoding", reader->m_encd ); |
4572 | reader->m_charpc = config.readNumEntry( "CharSpacing", reader->m_charpc ); | 4570 | reader->m_charpc = config.readNumEntry( "CharSpacing", reader->m_charpc ); |
4573 | reader->m_overlap = config.readNumEntry( "Overlap", reader->m_overlap ); | 4571 | reader->m_overlap = config.readNumEntry( "Overlap", reader->m_overlap ); |
4574 | reader->m_abstopmargin = config.readNumEntry( "Top Margin", reader->m_abstopmargin ); | 4572 | reader->m_abstopmargin = config.readNumEntry( "Top Margin", reader->m_abstopmargin ); |
4575 | reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", reader->m_absbottommargin ); | 4573 | reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", reader->m_absbottommargin ); |
4576 | reader->m_absleft_border = config.readNumEntry( "Left Margin", reader->m_absleft_border ); | 4574 | reader->m_absleft_border = config.readNumEntry( "Left Margin", reader->m_absleft_border ); |
4577 | reader->m_absright_border = config.readNumEntry( "Right Margin", reader->m_absright_border ); | 4575 | reader->m_absright_border = config.readNumEntry( "Right Margin", reader->m_absright_border ); |
4578 | m_scrollishidden = config.readBoolEntry( "HideScrollBar", m_scrollishidden ); | 4576 | m_scrollishidden = config.readBoolEntry( "HideScrollBar", m_scrollishidden ); |
4579 | reader->brepalm = config.readBoolEntry( "Repalm", reader->brepalm ); | 4577 | reader->brepalm = config.readBoolEntry( "Repalm", reader->brepalm ); |
4580 | reader->bkern = config.readBoolEntry( "Kern", reader->bkern ); | 4578 | reader->bkern = config.readBoolEntry( "Kern", reader->bkern ); |
4581 | reader->bremap = config.readBoolEntry( "Remap", reader->bremap ); | 4579 | reader->bremap = config.readBoolEntry( "Remap", reader->bremap ); |
4582 | reader->bmakebold = config.readBoolEntry( "MakeBold", reader->bmakebold ); | 4580 | reader->bmakebold = config.readBoolEntry( "MakeBold", reader->bmakebold ); |
4583 | reader->setContinuous(config.readBoolEntry( "Continuous", reader->m_continuousDocument )); | 4581 | reader->setContinuous(config.readBoolEntry( "Continuous", reader->m_continuousDocument )); |
4584 | m_targetapp = config.readEntry( "TargetApp", m_targetapp ); | 4582 | m_targetapp = config.readEntry( "TargetApp", m_targetapp ); |
4585 | m_targetmsg = config.readEntry( "TargetMsg", m_targetmsg ); | 4583 | m_targetmsg = config.readEntry( "TargetMsg", m_targetmsg ); |
4586 | #ifdef _SCROLLPIPE | 4584 | #ifdef _SCROLLPIPE |
4587 | reader->m_pipetarget = config.readEntry( "PipeTarget", reader->m_pipetarget ); | 4585 | reader->m_pipetarget = config.readEntry( "PipeTarget", reader->m_pipetarget ); |
4588 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | 4586 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); |
4589 | #endif | 4587 | #endif |
4590 | m_twoTouch = config.readBoolEntry( "TwoTouch", m_twoTouch); | 4588 | m_twoTouch = config.readBoolEntry( "TwoTouch", m_twoTouch); |
4591 | m_doAnnotation = config.readBoolEntry( "Annotation", m_doAnnotation); | 4589 | m_doAnnotation = config.readBoolEntry( "Annotation", m_doAnnotation); |
4592 | m_doDictionary = config.readBoolEntry( "Dictionary", m_doDictionary); | 4590 | m_doDictionary = config.readBoolEntry( "Dictionary", m_doDictionary); |
4593 | m_doClipboard = config.readBoolEntry( "Clipboard", m_doClipboard); | 4591 | m_doClipboard = config.readBoolEntry( "Clipboard", m_doClipboard); |
4594 | #ifdef USEQPE | 4592 | #ifdef USEQPE |
4595 | m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", m_grabkeyboard); | 4593 | m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", m_grabkeyboard); |
4596 | #endif | 4594 | #endif |
4597 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", m_propogatefontchange); | 4595 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", m_propogatefontchange); |
4598 | reader->setBaseSize(config.readNumEntry( "Basesize", reader->getBaseSize() )); | 4596 | reader->setBaseSize(config.readNumEntry( "Basesize", reader->getBaseSize() )); |
4599 | reader->setTwoTouch(m_twoTouch); | 4597 | reader->setTwoTouch(m_twoTouch); |
4600 | 4598 | ||
4601 | m_touch_action->setOn(m_twoTouch); | 4599 | m_touch_action->setOn(m_twoTouch); |
4602 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 4600 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
4603 | setfontHelper(reader->m_fontname); | 4601 | setfontHelper(reader->m_fontname); |
4604 | if (full) | 4602 | if (full) |
4605 | { | 4603 | { |
4606 | addtoolbars(&config); | 4604 | addtoolbars(&config); |
4607 | } | 4605 | } |
4608 | reader->setfilter(reader->getfilter()); | 4606 | reader->setfilter(reader->getfilter()); |
4609 | reader->refresh(); | 4607 | reader->refresh(); |
4610 | return true; | 4608 | return true; |
4611 | } | 4609 | } |
4612 | 4610 | ||
4613 | bool QTReaderApp::PopulateConfig(const char* tgtdir, bool usedirs) | 4611 | bool QTReaderApp::PopulateConfig(const char* tgtdir, bool usedirs) |
4614 | { | 4612 | { |
4615 | bkmkselector->clear(); | 4613 | bkmkselector->clear(); |
4616 | bkmkselector->setText("Cancel"); | 4614 | bkmkselector->setText("Cancel"); |
4617 | #ifndef USEQPE | 4615 | #ifndef USEQPE |
4618 | int cnt = 0; | 4616 | int cnt = 0; |
4619 | 4617 | ||
4620 | QDir d = QDir::home(); // "/" | 4618 | QDir d = QDir::home(); // "/" |
4621 | if ( !d.cd(APPDIR) ) { // "/tmp" | 4619 | if ( !d.cd(APPDIR) ) { // "/tmp" |
4622 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 4620 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
4623 | d = QDir::home(); | 4621 | d = QDir::home(); |
4624 | d.mkdir(APPDIR); | 4622 | d.mkdir(APPDIR); |
4625 | d.cd(APPDIR); | 4623 | d.cd(APPDIR); |
4626 | } | 4624 | } |
4627 | if ( !d.cd(tgtdir) ) { // "/tmp" | 4625 | if ( !d.cd(tgtdir) ) { // "/tmp" |
4628 | qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir ); | 4626 | qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir ); |
4629 | d = QDir::home(); | 4627 | d = QDir::home(); |
4630 | d.mkdir(tgtdir); | 4628 | d.mkdir(tgtdir); |
4631 | d.cd(tgtdir); | 4629 | d.cd(tgtdir); |
4632 | } | 4630 | } |
4633 | d.setFilter( ((usedirs) ? QDir::Dirs : QDir::Files) | QDir::NoSymLinks ); | 4631 | d.setFilter( ((usedirs) ? QDir::Dirs : QDir::Files) | QDir::NoSymLinks ); |
4634 | // d.setSorting( QDir::Size | QDir::Reversed ); | 4632 | // d.setSorting( QDir::Size | QDir::Reversed ); |
4635 | 4633 | ||
4636 | const QFileInfoList *list = d.entryInfoList(); | 4634 | const QFileInfoList *list = d.entryInfoList(); |
4637 | QFileInfoListIterator it( *list ); // create list iterator | 4635 | QFileInfoListIterator it( *list ); // create list iterator |
4638 | QFileInfo *fi; // pointer for traversing | 4636 | QFileInfo *fi; // pointer for traversing |
4639 | 4637 | ||
4640 | while ( (fi=it.current()) ) { // for each file... | 4638 | while ( (fi=it.current()) ) { // for each file... |
4641 | 4639 | ||
4642 | bkmkselector->insertItem(fi->fileName()); | 4640 | bkmkselector->insertItem(fi->fileName()); |
4643 | cnt++; | 4641 | cnt++; |
4644 | 4642 | ||
4645 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | 4643 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); |
4646 | ++it; // goto next list element | 4644 | ++it; // goto next list element |
4647 | } | 4645 | } |
4648 | 4646 | ||
4649 | #else /* USEQPE */ | 4647 | #else /* USEQPE */ |
4650 | int cnt = 0; | 4648 | int cnt = 0; |
4651 | DIR *d; | 4649 | DIR *d; |
4652 | char* finaldir; | 4650 | char* finaldir; |
4653 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; | 4651 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; |
4654 | strcpy(finaldir, APPDIR); | 4652 | strcpy(finaldir, APPDIR); |
4655 | strcat(finaldir, "/"); | 4653 | strcat(finaldir, "/"); |
4656 | strcat(finaldir, tgtdir); | 4654 | strcat(finaldir, tgtdir); |
4657 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); | 4655 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); |
4658 | 4656 | ||
4659 | while(1) | 4657 | while(1) |
4660 | { | 4658 | { |
4661 | struct dirent* de; | 4659 | struct dirent* de; |
4662 | struct stat buf; | 4660 | struct stat buf; |
4663 | de = readdir(d); | 4661 | de = readdir(d); |
4664 | if (de == NULL) break; | 4662 | if (de == NULL) break; |
4665 | 4663 | ||
4666 | if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && ((usedirs && S_ISDIR(buf.st_mode)) || (!usedirs && S_ISREG(buf.st_mode)))) | 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)))) |
4667 | { | 4665 | { |
4668 | bkmkselector->insertItem(de->d_name); | 4666 | bkmkselector->insertItem(de->d_name); |
4669 | cnt++; | 4667 | cnt++; |
4670 | } | 4668 | } |
4671 | } | 4669 | } |
4672 | delete [] finaldir; | 4670 | delete [] finaldir; |
4673 | closedir(d); | 4671 | closedir(d); |
4674 | #endif | 4672 | #endif |
4675 | return (cnt > 0); | 4673 | return (cnt > 0); |
4676 | } | 4674 | } |
4677 | 4675 | ||
4678 | void QTReaderApp::LoadTheme() | 4676 | void QTReaderApp::LoadTheme() |
4679 | { | 4677 | { |
4680 | if (PopulateConfig("Themes", true)) | 4678 | if (PopulateConfig("Themes", true)) |
4681 | { | 4679 | { |
4682 | editorStack->raiseWidget( bkmkselector ); | 4680 | editorStack->raiseWidget( bkmkselector ); |
4683 | hidetoolbars(); | 4681 | hidetoolbars(); |
4684 | m_nBkmkAction = cLdTheme; | 4682 | m_nBkmkAction = cLdTheme; |
4685 | } | 4683 | } |
4686 | else | 4684 | else |
4687 | QMessageBox::information(this, PROGNAME, "No config files"); | 4685 | QMessageBox::information(this, PROGNAME, "No config files"); |
4688 | } | 4686 | } |
4689 | 4687 | ||
4690 | void QTReaderApp::LoadConfig() | 4688 | void QTReaderApp::LoadConfig() |
4691 | { | 4689 | { |
4692 | if (PopulateConfig("configs")) | 4690 | if (PopulateConfig("configs")) |
4693 | { | 4691 | { |
4694 | editorStack->raiseWidget( bkmkselector ); | 4692 | editorStack->raiseWidget( bkmkselector ); |
4695 | hidetoolbars(); | 4693 | hidetoolbars(); |
4696 | m_nBkmkAction = cLdConfig; | 4694 | m_nBkmkAction = cLdConfig; |
4697 | } | 4695 | } |
4698 | else | 4696 | else |
4699 | QMessageBox::information(this, PROGNAME, "No config files"); | 4697 | QMessageBox::information(this, PROGNAME, "No config files"); |
4700 | } | 4698 | } |
4701 | 4699 | ||
4702 | void QTReaderApp::TidyConfig() | 4700 | void QTReaderApp::TidyConfig() |
4703 | { | 4701 | { |
4704 | if (PopulateConfig("configs")) | 4702 | if (PopulateConfig("configs")) |
4705 | { | 4703 | { |
4706 | editorStack->raiseWidget( bkmkselector ); | 4704 | editorStack->raiseWidget( bkmkselector ); |
4707 | hidetoolbars(); | 4705 | hidetoolbars(); |
4708 | m_nBkmkAction = cRmConfig; | 4706 | m_nBkmkAction = cRmConfig; |
4709 | } | 4707 | } |
4710 | else | 4708 | else |
4711 | QMessageBox::information(this, PROGNAME, "No config files"); | 4709 | QMessageBox::information(this, PROGNAME, "No config files"); |
4712 | } | 4710 | } |
4713 | 4711 | ||
4714 | void QTReaderApp::ExportLinks() | 4712 | void QTReaderApp::ExportLinks() |
4715 | { | 4713 | { |
4716 | if (PopulateConfig("urls")) | 4714 | if (PopulateConfig("urls")) |
4717 | { | 4715 | { |
4718 | editorStack->raiseWidget( bkmkselector ); | 4716 | editorStack->raiseWidget( bkmkselector ); |
4719 | hidetoolbars(); | 4717 | hidetoolbars(); |
4720 | m_nBkmkAction = cExportLinks; | 4718 | m_nBkmkAction = cExportLinks; |
4721 | } | 4719 | } |
4722 | else | 4720 | else |
4723 | QMessageBox::information(this, PROGNAME, "No url files"); | 4721 | QMessageBox::information(this, PROGNAME, "No url files"); |
4724 | } | 4722 | } |
4725 | 4723 | ||
4726 | void QTReaderApp::OnURLSelected(const QString& href, const size_t tgt) | 4724 | void QTReaderApp::OnURLSelected(const QString& href, const size_t tgt) |
4727 | { | 4725 | { |
4728 | #ifndef USEQPE | 4726 | #ifndef USEQPE |
4729 | qDebug("URL:%s", (const char*)href); | 4727 | qDebug("URL:%s", (const char*)href); |
4730 | int col = href.find(':'); | 4728 | int col = href.find(':'); |
4731 | if (col > 0) | 4729 | if (col > 0) |
4732 | { | 4730 | { |
4733 | QString type = href.left(col); | 4731 | QString type = href.left(col); |
4734 | qDebug("Type:%s", (const char*)type); | 4732 | qDebug("Type:%s", (const char*)type); |
4735 | } | 4733 | } |
4736 | else | 4734 | else |
4737 | { | 4735 | { |
4738 | qDebug("No type"); | 4736 | qDebug("No type"); |
4739 | } | 4737 | } |
4740 | #else | 4738 | #else |
4741 | if (href.isEmpty()) | 4739 | if (href.isEmpty()) |
4742 | { | 4740 | { |
4743 | QMessageBox::information(this, PROGNAME, "No URL information supplied"); | 4741 | QMessageBox::information(this, PROGNAME, "No URL information supplied"); |
4744 | } | 4742 | } |
4745 | else | 4743 | else |
4746 | { | 4744 | { |
4747 | CURLDialog* urld = new CURLDialog(href, false, this); | 4745 | CURLDialog* urld = new CURLDialog(href, false, this); |
4748 | urld->clipboard(m_url_clipboard); | 4746 | urld->clipboard(m_url_clipboard); |
4749 | urld->localfile(m_url_localfile); | 4747 | urld->localfile(m_url_localfile); |
4750 | urld->globalfile(m_url_globalfile); | 4748 | urld->globalfile(m_url_globalfile); |
4751 | if (urld->exec()) | 4749 | if (urld->exec()) |
4752 | { | 4750 | { |
4753 | m_url_clipboard = urld->clipboard(); | 4751 | m_url_clipboard = urld->clipboard(); |
4754 | m_url_localfile = urld->localfile(); | 4752 | m_url_localfile = urld->localfile(); |
4755 | m_url_globalfile = urld->globalfile(); | 4753 | m_url_globalfile = urld->globalfile(); |
4756 | if (m_url_clipboard) | 4754 | if (m_url_clipboard) |
4757 | { | 4755 | { |
4758 | QClipboard* cb = QApplication::clipboard(); | 4756 | QClipboard* cb = QApplication::clipboard(); |
4759 | cb->setText(href); | 4757 | cb->setText(href); |
4760 | qDebug("<a href=\"%s\">%s</a>", (const char*)href, (const char*)href); | 4758 | qDebug("<a href=\"%s\">%s</a>", (const char*)href, (const char*)href); |
4761 | } | 4759 | } |
4762 | if (m_url_localfile) | 4760 | if (m_url_localfile) |
4763 | { | 4761 | { |
4764 | writeUrl(reader->m_string, href); | 4762 | writeUrl(reader->m_string, href); |
4765 | } | 4763 | } |
4766 | if (m_url_globalfile) | 4764 | if (m_url_globalfile) |
4767 | { | 4765 | { |
4768 | writeUrl("GlobalURLFile", href); | 4766 | writeUrl("GlobalURLFile", href); |
4769 | } | 4767 | } |
4770 | } | 4768 | } |
4771 | delete urld; | 4769 | delete urld; |
4772 | } | 4770 | } |
4773 | #endif | 4771 | #endif |
4774 | } | 4772 | } |
4775 | 4773 | ||
4776 | void QTReaderApp::writeUrl(const QString& file, const QString& href) | 4774 | void QTReaderApp::writeUrl(const QString& file, const QString& href) |
4777 | { | 4775 | { |
4778 | QString filename; | 4776 | QString filename; |
4779 | #ifdef USEQPE | 4777 | #ifdef USEQPE |
4780 | filename = Global::applicationFileName(APPDIR "/urls", file); | 4778 | filename = Global::applicationFileName(APPDIR "/urls", file); |
4781 | #else | 4779 | #else |
4782 | QFileInfo fi; | 4780 | QFileInfo fi; |
4783 | QDir d = QDir::home(); // "/" | 4781 | QDir d = QDir::home(); // "/" |
4784 | if ( !d.cd(APPDIR) ) | 4782 | if ( !d.cd(APPDIR) ) |
4785 | { // "/tmp" | 4783 | { // "/tmp" |
4786 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 4784 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
4787 | d = QDir::home(); | 4785 | d = QDir::home(); |
4788 | d.mkdir(APPDIR); | 4786 | d.mkdir(APPDIR); |
4789 | d.cd(APPDIR); | 4787 | d.cd(APPDIR); |
4790 | } | 4788 | } |
4791 | if ( !d.cd("urls") ) | 4789 | if ( !d.cd("urls") ) |
4792 | { // "/tmp" | 4790 | { // "/tmp" |
4793 | qWarning( "Cannot find the \"~/" APPDIR "/urls\" directory" ); | 4791 | qWarning( "Cannot find the \"~/" APPDIR "/urls\" directory" ); |
4794 | d = QDir::home(); | 4792 | d = QDir::home(); |
4795 | d.cd(APPDIR); | 4793 | d.cd(APPDIR); |
4796 | d.mkdir("urls"); | 4794 | d.mkdir("urls"); |
4797 | d.cd("urls"); | 4795 | d.cd("urls"); |
4798 | } | 4796 | } |
4799 | fi.setFile(d, file); | 4797 | fi.setFile(d, file); |
4800 | filename = fi.absFilePath(); | 4798 | filename = fi.absFilePath(); |
4801 | #endif | 4799 | #endif |
4802 | FILE* fout = fopen(filename, "a"); | 4800 | FILE* fout = fopen(filename, "a"); |
4803 | if (fout != NULL) | 4801 | if (fout != NULL) |
4804 | { | 4802 | { |
4805 | fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href); | 4803 | fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href); |
4806 | fclose(fout); | 4804 | fclose(fout); |
4807 | } | 4805 | } |
4808 | else | 4806 | else |
4809 | { | 4807 | { |
4810 | QMessageBox::warning(this, PROGNAME, "Problem with writing URL"); | 4808 | QMessageBox::warning(this, PROGNAME, "Problem with writing URL"); |
4811 | } | 4809 | } |
4812 | } | 4810 | } |
4813 | 4811 | ||
4814 | QColor QTReaderApp::getcolour(int _c) | 4812 | QColor QTReaderApp::getcolour(int _c) |
4815 | { | 4813 | { |
4816 | QColor c = white; | 4814 | QColor c = white; |
4817 | switch (_c) | 4815 | switch (_c) |
4818 | { | 4816 | { |
4819 | case 0: | 4817 | case 0: |
4820 | c = white; | 4818 | c = white; |
4821 | break; | 4819 | break; |
4822 | case 1: | 4820 | case 1: |
4823 | c = black; | 4821 | c = black; |
4824 | break; | 4822 | break; |
4825 | case 2: | 4823 | case 2: |
4826 | c = darkGray; | 4824 | c = darkGray; |
4827 | break; | 4825 | break; |
4828 | case 3: | 4826 | case 3: |
4829 | c = gray; | 4827 | c = gray; |
4830 | break; | 4828 | break; |
4831 | case 4: | 4829 | case 4: |
4832 | c = lightGray; | 4830 | c = lightGray; |
4833 | break; | 4831 | break; |
4834 | case 5: | 4832 | case 5: |
4835 | c = red; | 4833 | c = red; |
4836 | break; | 4834 | break; |
4837 | case 6: | 4835 | case 6: |
4838 | c = green; | 4836 | c = green; |
4839 | break; | 4837 | break; |
4840 | case 7: | 4838 | case 7: |
4841 | c = blue; | 4839 | c = blue; |
4842 | break; | 4840 | break; |
4843 | case 8: | 4841 | case 8: |
4844 | c = cyan; | 4842 | c = cyan; |
4845 | break; | 4843 | break; |
4846 | case 9: | 4844 | case 9: |
4847 | c = magenta; | 4845 | c = magenta; |
4848 | break; | 4846 | break; |
4849 | case 10: | 4847 | case 10: |
4850 | c = yellow; | 4848 | c = yellow; |
4851 | break; | 4849 | break; |
4852 | case 11: | 4850 | case 11: |
4853 | c = darkRed; | 4851 | c = darkRed; |
4854 | break; | 4852 | break; |
4855 | case 12: | 4853 | case 12: |
4856 | c = darkGreen; | 4854 | c = darkGreen; |
4857 | break; | 4855 | break; |
4858 | case 13: | 4856 | case 13: |
4859 | c = darkBlue; | 4857 | c = darkBlue; |
4860 | break; | 4858 | break; |
4861 | case 14: | 4859 | case 14: |
4862 | c = darkCyan; | 4860 | c = darkCyan; |
4863 | break; | 4861 | break; |
4864 | case 15: | 4862 | case 15: |
4865 | c = darkMagenta; | 4863 | c = darkMagenta; |
4866 | break; | 4864 | break; |
4867 | case 16: | 4865 | case 16: |
4868 | c = darkYellow; | 4866 | c = darkYellow; |
4869 | break; | 4867 | break; |
4870 | default: | 4868 | default: |
4871 | c = lightGray; | 4869 | c = lightGray; |
4872 | break; | 4870 | break; |
4873 | } | 4871 | } |
4874 | return c; | 4872 | return c; |
4875 | } | 4873 | } |
4876 | 4874 | ||
4877 | void QTReaderApp::setscrollcolour() | 4875 | void QTReaderApp::setscrollcolour() |
4878 | { | 4876 | { |
4879 | /* | 4877 | /* |
4880 | QColor xc = getcolour(m_scrollcolor); | 4878 | QColor xc = getcolour(m_scrollcolor); |
4881 | int r,g,b; | 4879 | int r,g,b; |
4882 | xc.rgb(&r,&g,&b); | 4880 | xc.rgb(&r,&g,&b); |
4883 | reader->m_scrollcolor.setRgb(255^r, 255^g, 255^b); | 4881 | reader->m_scrollcolor.setRgb(255^r, 255^g, 255^b); |
4884 | */ | 4882 | */ |
4885 | reader->m_scrollcolor = getcolour(m_scrollcolor); | 4883 | reader->m_scrollcolor = getcolour(m_scrollcolor); |
4886 | } | 4884 | } |
4887 | 4885 | ||
4888 | void QTReaderApp::setscrollbarcolour() | 4886 | void QTReaderApp::setscrollbarcolour() |
4889 | { | 4887 | { |
4890 | /* | 4888 | /* |
4891 | QColor xc = getcolour(m_scrollcolor); | 4889 | QColor xc = getcolour(m_scrollcolor); |
4892 | int r,g,b; | 4890 | int r,g,b; |
4893 | xc.rgb(&r,&g,&b); | 4891 | xc.rgb(&r,&g,&b); |
4894 | reader->m_scrollcolor.setRgb(255^r, 255^g, 255^b); | 4892 | reader->m_scrollcolor.setRgb(255^r, 255^g, 255^b); |
4895 | */ | 4893 | */ |
4896 | reader->m_scrollbarcolor = getcolour(m_scrollbarcolor); | 4894 | reader->m_scrollbarcolor = getcolour(m_scrollbarcolor); |
4897 | } | 4895 | } |
4898 | 4896 | ||
4899 | void QTReaderApp::forceopen(const QString& filename) | 4897 | void QTReaderApp::forceopen(const QString& filename) |
4900 | { | 4898 | { |
4901 | /* | 4899 | /* |
4902 | QFileInfo fi(reader->m_lastfile); | 4900 | QFileInfo fi(reader->m_lastfile); |
4903 | fi = QFileInfo(filename); | 4901 | fi = QFileInfo(filename); |
4904 | QString flnm = fi.absFilePath(); | 4902 | QString flnm = fi.absFilePath(); |
4905 | */ | 4903 | */ |
4906 | if (!filename.isEmpty()) | 4904 | if (!filename.isEmpty()) |
4907 | { | 4905 | { |
4908 | updatefileinfo(); | 4906 | updatefileinfo(); |
4909 | if (pBkmklist != NULL) | 4907 | if (pBkmklist != NULL) |
4910 | { | 4908 | { |
4911 | if (m_fBkmksChanged) | 4909 | if (m_fBkmksChanged) |
4912 | { | 4910 | { |
4913 | savebkmks(); | 4911 | savebkmks(); |
4914 | } | 4912 | } |
4915 | delete pBkmklist; | 4913 | delete pBkmklist; |
4916 | pBkmklist = NULL; | 4914 | pBkmklist = NULL; |
4917 | m_fBkmksChanged = false; | 4915 | m_fBkmksChanged = false; |
4918 | } | 4916 | } |
4919 | reader->disableAutoscroll(); | 4917 | reader->disableAutoscroll(); |
4920 | openFile(filename); | 4918 | openFile(filename); |
4921 | reader->setFocus(); | 4919 | reader->setFocus(); |
4922 | } | 4920 | } |
4923 | } | 4921 | } |
4924 | 4922 | ||
4925 | void QTReaderApp::actionscroll(int v) | 4923 | void QTReaderApp::actionscroll(int v) |
4926 | { | 4924 | { |
4927 | if (reader->m_rotated) | 4925 | if (reader->m_rotated) |
4928 | { | 4926 | { |
4929 | reader->dopageup(reader->buffdoc.startSection()+reader->buffdoc.endSection()-v); | 4927 | reader->dopageup(reader->buffdoc.startSection()+reader->buffdoc.endSection()-v); |
4930 | } | 4928 | } |
4931 | else | 4929 | else |
4932 | { | 4930 | { |
4933 | /* | 4931 | /* |
4934 | if (reader->pagelocate() < v) | 4932 | if (reader->pagelocate() < v) |
4935 | { | 4933 | { |
4936 | while (reader->pagelocate() < v) reader->lineDown(); | 4934 | while (reader->pagelocate() < v) reader->lineDown(); |
4937 | } | 4935 | } |
4938 | else | 4936 | else |
4939 | */ | 4937 | */ |
4940 | reader->locate(v); | 4938 | reader->locate(v); |
4941 | } | 4939 | } |
4942 | } | 4940 | } |
4943 | 4941 | ||
4944 | void QTReaderApp::setBackgroundBitmap() | 4942 | void QTReaderApp::setBackgroundBitmap() |
4945 | { | 4943 | { |
4946 | #ifdef USEQPE | 4944 | #ifdef USEQPE |
4947 | QString file = APPDIR "/Themes/"; | 4945 | QString file = APPDIR "/Themes/"; |
4948 | file += m_themename; | 4946 | file += m_themename; |
4949 | QString tgt = Global::applicationFileName(file,"background"); | 4947 | QString tgt = Global::applicationFileName(file,"background"); |
4950 | #else | 4948 | #else |
4951 | QString tgt(QDir::homeDirPath()); | 4949 | QString tgt(QDir::homeDirPath()); |
4952 | tgt += QString("/" APPDIR "/Themes/") + m_themename + "/background"; | 4950 | tgt += QString("/" APPDIR "/Themes/") + m_themename + "/background"; |
4953 | #endif | 4951 | #endif |
4954 | qDebug("Trying to load %s", (const char *)tgt); | 4952 | qDebug("Trying to load %s", (const char *)tgt); |
4955 | QPixmap pm(tgt); | 4953 | QPixmap pm(tgt); |
4956 | reader->setBackgroundBitmap(pm, m_bgtype); | 4954 | reader->setBackgroundBitmap(pm, m_bgtype); |
4957 | } | 4955 | } |
4958 | 4956 | ||
4959 | /* | 4957 | /* |
4960 | 4958 | ||
4961 | myChannel = new QCopChannel( "QPE/FooBar", this ); | 4959 | myChannel = new QCopChannel( "QPE/FooBar", this ); |
4962 | connect( myChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 4960 | connect( myChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
4963 | this, SLOT(fooBarMessage( const QCString &, const QByteArray &)) ); | 4961 | this, SLOT(fooBarMessage( const QCString &, const QByteArray &)) ); |
4964 | 4962 | ||
4965 | */ | 4963 | */ |
diff --git a/noncore/apps/opie-reader/QTReaderApp.h b/noncore/apps/opie-reader/QTReaderApp.h index 5ecc42d..ad47fc9 100644 --- a/noncore/apps/opie-reader/QTReaderApp.h +++ b/noncore/apps/opie-reader/QTReaderApp.h | |||
@@ -1,485 +1,484 @@ | |||
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 "useqpe.h" | ||
30 | #include <sys/timeb.h> | 29 | #include <sys/timeb.h> |
31 | #include <qmainwindow.h> | 30 | #include <qmainwindow.h> |
32 | #include "CExpander.h" | 31 | #include "CExpander.h" |
33 | #include "CEncoding.h" | 32 | #include "CEncoding.h" |
34 | #include <qlist.h> | 33 | #include <qlist.h> |
35 | //#include <qpe/filemanager.h> | 34 | //#include <qpe/filemanager.h> |
36 | #include <qmap.h> | 35 | #include <qmap.h> |
37 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
38 | #include <qstack.h> | 37 | #include <qstack.h> |
39 | #include <qlistbox.h> | 38 | #include <qlistbox.h> |
40 | #ifdef USEQPE | 39 | #ifdef USEQPE |
41 | #include <qpe/qpeapplication.h> | 40 | #include <qpe/qpeapplication.h> |
42 | #endif | 41 | #endif |
43 | #include "orkey.h" | 42 | #include "orkey.h" |
44 | //#include "Queue.h" | 43 | //#include "Queue.h" |
45 | #include "BGType.h" | 44 | #include "BGType.h" |
46 | 45 | ||
47 | class QBoxLayout; | 46 | class QBoxLayout; |
48 | class QWidgetStack; | 47 | class QWidgetStack; |
49 | class QToolButton; | 48 | class QToolButton; |
50 | class QPopupMenu; | 49 | class QPopupMenu; |
51 | class QToolBar; | 50 | class QToolBar; |
52 | #ifdef USEQPE | 51 | #ifdef USEQPE |
53 | class QPEToolBar; | 52 | class QPEToolBar; |
54 | class QPEMenuBar; | 53 | class QPEMenuBar; |
55 | #endif | 54 | #endif |
56 | class QScrollBar; | 55 | class QScrollBar; |
57 | class CBkmkSelector; | 56 | class CBkmkSelector; |
58 | class QProgressBar; | 57 | class QProgressBar; |
59 | class QAction; | 58 | class QAction; |
60 | class CAnnoEdit; | 59 | class CAnnoEdit; |
61 | class QFloatBar; | 60 | class QFloatBar; |
62 | class CDrawBuffer; | 61 | class CDrawBuffer; |
63 | class QTReader; | 62 | class QTReader; |
64 | class QImage; | 63 | class QImage; |
65 | class Config; | 64 | class Config; |
66 | class CButtonPrefs; | 65 | class CButtonPrefs; |
67 | 66 | ||
68 | #ifdef USEQPE | 67 | #ifdef USEQPE |
69 | enum ToolbarPolicy | 68 | enum ToolbarPolicy |
70 | { | 69 | { |
71 | cesSingle = 0, | 70 | cesSingle = 0, |
72 | cesMenuTool, | 71 | cesMenuTool, |
73 | cesMultiple | 72 | cesMultiple |
74 | }; | 73 | }; |
75 | #else | 74 | #else |
76 | enum ToolbarPolicy | 75 | enum ToolbarPolicy |
77 | { | 76 | { |
78 | cesMenuTool = 0, | 77 | cesMenuTool = 0, |
79 | cesMultiple | 78 | cesMultiple |
80 | }; | 79 | }; |
81 | #endif | 80 | #endif |
82 | 81 | ||
83 | enum regedit_type | 82 | enum regedit_type |
84 | { | 83 | { |
85 | cAutoGen, | 84 | cAutoGen, |
86 | cAddBkmk, | 85 | cAddBkmk, |
87 | cJump, | 86 | cJump, |
88 | cMonoSpace, | 87 | cMonoSpace, |
89 | cSetTarget, | 88 | cSetTarget, |
90 | #ifdef _SCROLLPIPE | 89 | #ifdef _SCROLLPIPE |
91 | cSetPipeTarget, | 90 | cSetPipeTarget, |
92 | #endif | 91 | #endif |
93 | cSetConfigName, | 92 | cSetConfigName, |
94 | cMargin, | 93 | cMargin, |
95 | cExtraSpace, | 94 | cExtraSpace, |
96 | cExtraLead, | 95 | cExtraLead, |
97 | cRepara | 96 | cRepara |
98 | }; | 97 | }; |
99 | 98 | ||
100 | enum bkmk_action | 99 | enum bkmk_action |
101 | { | 100 | { |
102 | cOpenFile, | 101 | cOpenFile, |
103 | cGotoBkmk, | 102 | cGotoBkmk, |
104 | cDelBkmk, | 103 | cDelBkmk, |
105 | cRmBkmkFile, | 104 | cRmBkmkFile, |
106 | cLdConfig, | 105 | cLdConfig, |
107 | cRmConfig, | 106 | cRmConfig, |
108 | cExportLinks, | 107 | cExportLinks, |
109 | cLdTheme | 108 | cLdTheme |
110 | }; | 109 | }; |
111 | 110 | ||
112 | enum fontselector_action | 111 | enum fontselector_action |
113 | { | 112 | { |
114 | cChooseFont, | 113 | cChooseFont, |
115 | cChooseEncoding | 114 | cChooseEncoding |
116 | }; | 115 | }; |
117 | 116 | ||
118 | #ifdef __ISEARCH | 117 | #ifdef __ISEARCH |
119 | struct searchrecord | 118 | struct searchrecord |
120 | { | 119 | { |
121 | QString s; | 120 | QString s; |
122 | size_t pos; | 121 | size_t pos; |
123 | searchrecord(const QString& _s, size_t _pos) : s(_s), pos(_pos) {} | 122 | searchrecord(const QString& _s, size_t _pos) : s(_s), pos(_pos) {} |
124 | }; | 123 | }; |
125 | #endif | 124 | #endif |
126 | 125 | ||
127 | class infowin; | 126 | class infowin; |
128 | class GraphicWin; | 127 | class GraphicWin; |
129 | 128 | ||
130 | class QTReaderApp : public QMainWindow | 129 | class QTReaderApp : public QMainWindow |
131 | { | 130 | { |
132 | Q_OBJECT | 131 | Q_OBJECT |
133 | 132 | ||
134 | QColor getcolour(int c); | 133 | QColor getcolour(int c); |
135 | 134 | ||
136 | QMap<orKey, int> kmap; | 135 | QMap<orKey, int> kmap; |
137 | unsigned long m_savedpos; | 136 | unsigned long m_savedpos; |
138 | int m_debounce; | 137 | int m_debounce; |
139 | bool m_kmapchanged; | 138 | bool m_kmapchanged; |
140 | bground m_bgtype; | 139 | bground m_bgtype; |
141 | timeb m_lastkeytime; | 140 | timeb m_lastkeytime; |
142 | QScrollBar* m_scrollbar; | 141 | QScrollBar* m_scrollbar; |
143 | QScrollBar* scrollbar; | 142 | QScrollBar* scrollbar; |
144 | int m_qtscroll, m_localscroll; | 143 | int m_qtscroll, m_localscroll; |
145 | bool m_hidebars, m_scrollishidden, m_statusishidden; | 144 | bool m_hidebars, m_scrollishidden, m_statusishidden; |
146 | QBoxLayout *m_layout; | 145 | QBoxLayout *m_layout; |
147 | QLabel* m_prog; | 146 | QLabel* m_prog; |
148 | bool m_annoIsEditing; | 147 | bool m_annoIsEditing; |
149 | bool m_propogatefontchange, m_bFloatingDialog; | 148 | bool m_propogatefontchange, m_bFloatingDialog; |
150 | bool m_url_clipboard, m_url_localfile, m_url_globalfile; | 149 | bool m_url_clipboard, m_url_localfile, m_url_globalfile; |
151 | CButtonPrefs* m_buttonprefs; | 150 | CButtonPrefs* m_buttonprefs; |
152 | fontselector_action m_fontAction; | 151 | fontselector_action m_fontAction; |
153 | void doAction(QKeyEvent* e); | 152 | void doAction(QKeyEvent* e); |
154 | 153 | ||
155 | public: | 154 | public: |
156 | QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 155 | QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
157 | ~QTReaderApp(); | 156 | ~QTReaderApp(); |
158 | 157 | ||
159 | void hideEvent(QHideEvent*) | 158 | void hideEvent(QHideEvent*) |
160 | { | 159 | { |
161 | #ifdef USEQPE | 160 | #ifdef USEQPE |
162 | if (m_grabkeyboard) | 161 | if (m_grabkeyboard) |
163 | { | 162 | { |
164 | ((QPEApplication*)qApp)->ungrabKeyboard(); | 163 | ((QPEApplication*)qApp)->ungrabKeyboard(); |
165 | } | 164 | } |
166 | #endif | 165 | #endif |
167 | suspend(); | 166 | suspend(); |
168 | } | 167 | } |
169 | #ifdef USEQPE | 168 | #ifdef USEQPE |
170 | void showEvent(QShowEvent*) | 169 | void showEvent(QShowEvent*) |
171 | { | 170 | { |
172 | if (m_grabkeyboard) | 171 | if (m_grabkeyboard) |
173 | { | 172 | { |
174 | ((QPEApplication*)qApp)->grabKeyboard(); | 173 | ((QPEApplication*)qApp)->grabKeyboard(); |
175 | } | 174 | } |
176 | } | 175 | } |
177 | #endif | 176 | #endif |
178 | void suspend(); | 177 | void suspend(); |
179 | void openFile( const QString & ); | 178 | void openFile( const QString & ); |
180 | 179 | ||
181 | 180 | ||
182 | protected: | 181 | protected: |
183 | void setfontHelper(const QString& lcn, int size = 0); | 182 | void setfontHelper(const QString& lcn, int size = 0); |
184 | QAction* m_bkmkAvail, *m_actFullscreen; | 183 | QAction* m_bkmkAvail, *m_actFullscreen; |
185 | CAnnoEdit* m_annoWin; | 184 | CAnnoEdit* m_annoWin; |
186 | Bkmk* m_anno; | 185 | Bkmk* m_anno; |
187 | int m_scrollcolor, m_scrollbarcolor, m_background, m_foreground; | 186 | int m_scrollcolor, m_scrollbarcolor, m_background, m_foreground; |
188 | // void resizeEvent(QResizeEvent* e); | 187 | // void resizeEvent(QResizeEvent* e); |
189 | void closeEvent( QCloseEvent *e ); | 188 | void closeEvent( QCloseEvent *e ); |
190 | #ifdef NEWFULLSCREEN | 189 | #ifdef NEWFULLSCREEN |
191 | void resizeEvent(QResizeEvent *); | 190 | void resizeEvent(QResizeEvent *); |
192 | void focusInEvent(QFocusEvent*); | 191 | void focusInEvent(QFocusEvent*); |
193 | void enableFullscreen(); | 192 | void enableFullscreen(); |
194 | #endif | 193 | #endif |
195 | void readbkmks(); | 194 | void readbkmks(); |
196 | void do_mono(const QString&); | 195 | void do_mono(const QString&); |
197 | void do_jump(const QString&); | 196 | void do_jump(const QString&); |
198 | void do_reparastring(const QString&); | 197 | void do_reparastring(const QString&); |
199 | void do_settarget(const QString&); | 198 | void do_settarget(const QString&); |
200 | #ifdef _SCROLLPIPE | 199 | #ifdef _SCROLLPIPE |
201 | //void do_setpipetarget(const QString&); | 200 | //void do_setpipetarget(const QString&); |
202 | #endif | 201 | #endif |
203 | void do_saveconfig(const QString&, bool); | 202 | void do_saveconfig(const QString&, bool); |
204 | bool readconfig(const QString&, const QString&, bool); | 203 | bool readconfig(const QString&, const QString&, bool); |
205 | bool PopulateConfig(const char*, bool usedirs = false); | 204 | bool PopulateConfig(const char*, bool usedirs = false); |
206 | ActionTypes ActNameToInt(const QString&); | 205 | ActionTypes ActNameToInt(const QString&); |
207 | #ifdef USEQPE | 206 | #ifdef USEQPE |
208 | bool m_grabkeyboard; | 207 | bool m_grabkeyboard; |
209 | #endif | 208 | #endif |
210 | bool m_doAnnotation; | 209 | bool m_doAnnotation; |
211 | bool m_doDictionary; | 210 | bool m_doDictionary; |
212 | bool m_doClipboard; | 211 | bool m_doClipboard; |
213 | bool m_fullscreen; | 212 | bool m_fullscreen; |
214 | bool m_loadedconfig; | 213 | bool m_loadedconfig; |
215 | public: | 214 | public: |
216 | void saveprefs(); | 215 | void saveprefs(); |
217 | public slots: | 216 | public slots: |
218 | void setBackgroundBitmap(); | 217 | void setBackgroundBitmap(); |
219 | void UpdateStatus(); | 218 | void UpdateStatus(); |
220 | void setScrollState(bool _b); | 219 | void setScrollState(bool _b); |
221 | void handlekey(QKeyEvent* e); | 220 | void handlekey(QKeyEvent* e); |
222 | void forceopen(const QString& filename); | 221 | void forceopen(const QString& filename); |
223 | void setDocument(const QString&); | 222 | void setDocument(const QString&); |
224 | private slots: | 223 | private slots: |
225 | #ifdef _SCRIPT | 224 | #ifdef _SCRIPT |
226 | // void RunScript(); | 225 | // void RunScript(); |
227 | #endif | 226 | #endif |
228 | void actionscroll(int v); | 227 | void actionscroll(int v); |
229 | void SaveConfig(); | 228 | void SaveConfig(); |
230 | void LoadTheme(); | 229 | void LoadTheme(); |
231 | void LoadConfig(); | 230 | void LoadConfig(); |
232 | void TidyConfig(); | 231 | void TidyConfig(); |
233 | void ExportLinks(); | 232 | void ExportLinks(); |
234 | void zoomin(); | 233 | void zoomin(); |
235 | void zoomout(); | 234 | void zoomout(); |
236 | void chooseencoding(); | 235 | void chooseencoding(); |
237 | void setfullscreen(bool sfs); | 236 | void setfullscreen(bool sfs); |
238 | void setrotated(bool sfs); | 237 | void setrotated(bool sfs); |
239 | void setinverted(bool sfs); | 238 | void setinverted(bool sfs); |
240 | void setgrab(bool sfs); | 239 | void setgrab(bool sfs); |
241 | // void setcontinuous(bool sfs); | 240 | // void setcontinuous(bool sfs); |
242 | void setTwoTouch(bool _b); | 241 | void setTwoTouch(bool _b); |
243 | void restoreFocus(); | 242 | void restoreFocus(); |
244 | void OnAnnotation(bool _b) | 243 | void OnAnnotation(bool _b) |
245 | { | 244 | { |
246 | m_doAnnotation = _b; | 245 | m_doAnnotation = _b; |
247 | } | 246 | } |
248 | void OnDictionary(bool _b) | 247 | void OnDictionary(bool _b) |
249 | { | 248 | { |
250 | m_doDictionary = _b; | 249 | m_doDictionary = _b; |
251 | } | 250 | } |
252 | void OnClipboard(bool _b) | 251 | void OnClipboard(bool _b) |
253 | { | 252 | { |
254 | m_doClipboard = _b; | 253 | m_doClipboard = _b; |
255 | } | 254 | } |
256 | void OnWordSelected(const QString&, size_t, size_t, const QString&); | 255 | void OnWordSelected(const QString&, size_t, size_t, const QString&); |
257 | void OnURLSelected(const QString& href, const size_t tgt); | 256 | void OnURLSelected(const QString& href, const size_t tgt); |
258 | void showgraphic(QImage&); | 257 | void showgraphic(QImage&); |
259 | void addAnno(const QString&, const QString&, size_t, size_t); | 258 | void addAnno(const QString&, const QString&, size_t, size_t); |
260 | void addAnno(const QString&, const QString&); | 259 | void addAnno(const QString&, const QString&); |
261 | void addanno(); | 260 | void addanno(); |
262 | void showAnnotation(); | 261 | void showAnnotation(); |
263 | void do_setencoding(int i); | 262 | void do_setencoding(int i); |
264 | void do_setfont(const QString&); | 263 | void do_setfont(const QString&); |
265 | //void buttonActionSelected(QAction*); | 264 | //void buttonActionSelected(QAction*); |
266 | void msgHandler(const QCString&, const QByteArray&); | 265 | void msgHandler(const QCString&, const QByteArray&); |
267 | void monospace(bool); | 266 | void monospace(bool); |
268 | void jump(); | 267 | void jump(); |
269 | void reparastring(); | 268 | void reparastring(); |
270 | void settarget(); | 269 | void settarget(); |
271 | #ifdef _SCROLLPIPE | 270 | #ifdef _SCROLLPIPE |
272 | //void setpipetarget(); | 271 | //void setpipetarget(); |
273 | //void setpause(bool); | 272 | //void setpause(bool); |
274 | #endif | 273 | #endif |
275 | //void setspacing(); | 274 | //void setspacing(); |
276 | void setfont(); | 275 | void setfont(); |
277 | void clearBkmkList(); | 276 | void clearBkmkList(); |
278 | void listBkmkFiles(); | 277 | void listBkmkFiles(); |
279 | void editMark(); | 278 | void editMark(); |
280 | void autoScroll(bool); | 279 | void autoScroll(bool); |
281 | void addbkmk(); | 280 | void addbkmk(); |
282 | void savebkmks(); | 281 | void savebkmks(); |
283 | //void importFiles(); | 282 | //void importFiles(); |
284 | void showprefs(); | 283 | void showprefs(); |
285 | void showtoolbarprefs(); | 284 | void showtoolbarprefs(); |
286 | void showbuttonprefs(); | 285 | void showbuttonprefs(); |
287 | void infoClose(); | 286 | void infoClose(); |
288 | // void oldFile(); | 287 | // void oldFile(); |
289 | void showinfo(); | 288 | void showinfo(); |
290 | 289 | ||
291 | // void indentplus(); | 290 | // void indentplus(); |
292 | // void indentminus(); | 291 | // void indentminus(); |
293 | 292 | ||
294 | void fileOpen(); | 293 | void fileOpen(); |
295 | void fileClose(); | 294 | void fileClose(); |
296 | 295 | ||
297 | void editCopy(); | 296 | void editCopy(); |
298 | void editFind(); | 297 | void editFind(); |
299 | 298 | ||
300 | void gotoStart(); | 299 | void gotoStart(); |
301 | void gotoEnd(); | 300 | void gotoEnd(); |
302 | 301 | ||
303 | void pageup(); | 302 | void pageup(); |
304 | void pagedn(); | 303 | void pagedn(); |
305 | 304 | ||
306 | void findNext(); | 305 | void findNext(); |
307 | void findClose(); | 306 | void findClose(); |
308 | 307 | ||
309 | void regClose(); | 308 | void regClose(); |
310 | 309 | ||
311 | #ifdef __ISEARCH | 310 | #ifdef __ISEARCH |
312 | // void search( const QString& ); | 311 | // void search( const QString& ); |
313 | #else | 312 | #else |
314 | void search(); | 313 | void search(); |
315 | #endif | 314 | #endif |
316 | 315 | ||
317 | void showEditTools(); | 316 | void showEditTools(); |
318 | 317 | ||
319 | // void stripcr(bool); | 318 | // void stripcr(bool); |
320 | // void setfulljust(bool); | 319 | // void setfulljust(bool); |
321 | // void onespace(bool); | 320 | // void onespace(bool); |
322 | // void repalm(bool); | 321 | // void repalm(bool); |
323 | // void peanut(bool _b); | 322 | // void peanut(bool _b); |
324 | // void remap(bool); | 323 | // void remap(bool); |
325 | // void embolden(bool); | 324 | // void embolden(bool); |
326 | // void autofmt(bool); | 325 | // void autofmt(bool); |
327 | // void textfmt(bool); | 326 | // void textfmt(bool); |
328 | // void striphtml(bool); | 327 | // void striphtml(bool); |
329 | // void dehyphen(bool); | 328 | // void dehyphen(bool); |
330 | // void depluck(bool); | 329 | // void depluck(bool); |
331 | // void dejpluck(bool); | 330 | // void dejpluck(bool); |
332 | // void unindent(bool); | 331 | // void unindent(bool); |
333 | // void repara(bool); | 332 | // void repara(bool); |
334 | // void dblspce(bool); | 333 | // void dblspce(bool); |
335 | void pagemode(bool); | 334 | void pagemode(bool); |
336 | // void gotobkmk(const QString& bm); | 335 | // void gotobkmk(const QString& bm); |
337 | void gotobkmk(int); | 336 | void gotobkmk(int); |
338 | void cancelbkmk(); | 337 | void cancelbkmk(); |
339 | void do_gotomark(); | 338 | void do_gotomark(); |
340 | void do_delmark(); | 339 | void do_delmark(); |
341 | void do_autogen(); | 340 | void do_autogen(); |
342 | void do_regaction(); | 341 | void do_regaction(); |
343 | void OnRedraw(); | 342 | void OnRedraw(); |
344 | 343 | ||
345 | private: | 344 | private: |
346 | void setscrollcolour(); | 345 | void setscrollcolour(); |
347 | void setscrollbarcolour(); | 346 | void setscrollbarcolour(); |
348 | void writeUrl(const QString& file, const QString& href); | 347 | void writeUrl(const QString& file, const QString& href); |
349 | QAction *m_preferences_action, *m_open_action, *m_close_action; | 348 | QAction *m_preferences_action, *m_open_action, *m_close_action; |
350 | QAction *m_info_action, *m_touch_action, *m_find_action, *m_start_action; | 349 | QAction *m_info_action, *m_touch_action, *m_find_action, *m_start_action; |
351 | QAction *m_end_action, *m_jump_action, *m_pageline_action; | 350 | QAction *m_end_action, *m_jump_action, *m_pageline_action; |
352 | QAction *m_pageup_action, *m_pagedn_action, *m_back_action; | 351 | QAction *m_pageup_action, *m_pagedn_action, *m_back_action; |
353 | QAction *m_home_action, *m_forward_action, *m_zoomin_action; | 352 | QAction *m_home_action, *m_forward_action, *m_zoomin_action; |
354 | QAction *m_zoomout_action, *m_setfont_action, *m_mark_action; | 353 | QAction *m_zoomout_action, *m_setfont_action, *m_mark_action; |
355 | QAction *m_annotate_action, *m_goto_action, *m_delete_action; | 354 | QAction *m_annotate_action, *m_goto_action, *m_delete_action; |
356 | QAction *m_autogen_action, *m_clear_action, *m_save_action; | 355 | QAction *m_autogen_action, *m_clear_action, *m_save_action; |
357 | QAction *m_tidy_action, *m_startBlock_action, *m_endBlock_action; | 356 | QAction *m_tidy_action, *m_startBlock_action, *m_endBlock_action; |
358 | QAction *m_setenc_action, *m_setmono_action, *m_saveconfig_action; | 357 | QAction *m_setenc_action, *m_setmono_action, *m_saveconfig_action; |
359 | QAction *m_loadconfig_action, *m_loadtheme_action, *m_toolbarprefs_action, *m_tidyconfig_action; | 358 | QAction *m_loadconfig_action, *m_loadtheme_action, *m_toolbarprefs_action, *m_tidyconfig_action; |
360 | QAction *m_exportlinks_action, *m_rotate_action, *m_buttonprefs_action, *m_inverse_action; | 359 | QAction *m_exportlinks_action, *m_rotate_action, *m_buttonprefs_action, *m_inverse_action; |
361 | QAction *m_repara_action; | 360 | QAction *m_repara_action; |
362 | #ifdef USEQPE | 361 | #ifdef USEQPE |
363 | QAction *m_grab_action; | 362 | QAction *m_grab_action; |
364 | #endif | 363 | #endif |
365 | void addtoolbars(Config* config); | 364 | void addtoolbars(Config* config); |
366 | ToolbarPolicy m_tbpol, m_tbpolsave; | 365 | ToolbarPolicy m_tbpol, m_tbpolsave; |
367 | ToolBarDock m_tbposition; | 366 | ToolBarDock m_tbposition; |
368 | bool m_tbmove, m_tbmovesave; | 367 | bool m_tbmove, m_tbmovesave; |
369 | QToolBar* filebar(); | 368 | QToolBar* filebar(); |
370 | QToolBar* viewbar(); | 369 | QToolBar* viewbar(); |
371 | QToolBar* navbar(); | 370 | QToolBar* navbar(); |
372 | QToolBar* markbar(); | 371 | QToolBar* markbar(); |
373 | void hidetoolbars(); | 372 | void hidetoolbars(); |
374 | void addfilebar(Config* _config, const QString& key, QAction* a); | 373 | void addfilebar(Config* _config, const QString& key, QAction* a); |
375 | void addviewbar(Config* _config, const QString& key, QAction* a); | 374 | void addviewbar(Config* _config, const QString& key, QAction* a); |
376 | void addnavbar(Config* _config, const QString& key, QAction* a); | 375 | void addnavbar(Config* _config, const QString& key, QAction* a); |
377 | void addmarkbar(Config* _config, const QString& key, QAction* a); | 376 | void addmarkbar(Config* _config, const QString& key, QAction* a); |
378 | bool checkbar(Config* _config, const QString& key); | 377 | bool checkbar(Config* _config, const QString& key); |
379 | #ifdef _SCRIPT | 378 | #ifdef _SCRIPT |
380 | void SaveScript(const char* sname); | 379 | void SaveScript(const char* sname); |
381 | #endif | 380 | #endif |
382 | /* | 381 | /* |
383 | void setstate(unsigned char* _sd, unsigned short _sdlen); | 382 | void setstate(unsigned char* _sd, unsigned short _sdlen); |
384 | void getstate(unsigned char*& data, unsigned short& len); | 383 | void getstate(unsigned char*& data, unsigned short& len); |
385 | */ | 384 | */ |
386 | void fileOpen2(); | 385 | void fileOpen2(); |
387 | void readfilelist(); | 386 | void readfilelist(); |
388 | void savefilelist(); | 387 | void savefilelist(); |
389 | void updatefileinfo(); | 388 | void updatefileinfo(); |
390 | bool openfrombkmk(Bkmk*); | 389 | bool openfrombkmk(Bkmk*); |
391 | QString m_targetapp, m_targetmsg, m_statusstring, m_themename; | 390 | QString m_targetapp, m_targetmsg, m_statusstring, m_themename; |
392 | bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null); | 391 | bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null); |
393 | QString usefilebrowser(); | 392 | QString usefilebrowser(); |
394 | void do_regedit(); | 393 | void do_regedit(); |
395 | void colorChanged( const QColor &c ); | 394 | void colorChanged( const QColor &c ); |
396 | void clear(); | 395 | void clear(); |
397 | void updateCaption(); | 396 | void updateCaption(); |
398 | void do_autogen(const QString&); | 397 | void do_autogen(const QString&); |
399 | void do_addbkmk(const QString&); | 398 | void do_addbkmk(const QString&); |
400 | bool findNextBookmark(size_t start); | 399 | bool findNextBookmark(size_t start); |
401 | 400 | ||
402 | private: | 401 | private: |
403 | 402 | ||
404 | QAction* m_scrollButton; | 403 | QAction* m_scrollButton; |
405 | 404 | ||
406 | QAction* m_buttonAction[MAX_ACTIONS]; | 405 | QAction* m_buttonAction[MAX_ACTIONS]; |
407 | 406 | ||
408 | CBkmkSelector* bkmkselector; | 407 | CBkmkSelector* bkmkselector; |
409 | 408 | ||
410 | // ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget, | 409 | // ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget, |
411 | //m_upTarget, m_downTarget; | 410 | //m_upTarget, m_downTarget; |
412 | //bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll; | 411 | //bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll; |
413 | bool m_bcloseDisabled, m_disableesckey; | 412 | bool m_bcloseDisabled, m_disableesckey; |
414 | size_t searchStart; | 413 | size_t searchStart; |
415 | #ifdef __ISEARCH | 414 | #ifdef __ISEARCH |
416 | QStack<searchrecord>* searchStack; | 415 | QStack<searchrecord>* searchStack; |
417 | bool dosearch(size_t start, CDrawBuffer& test, const QString& arg); | 416 | bool dosearch(size_t start, CDrawBuffer& test, const QString& arg); |
418 | #else | 417 | #else |
419 | bool dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg); | 418 | bool dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg); |
420 | #endif | 419 | #endif |
421 | QWidgetStack *editorStack; | 420 | QWidgetStack *editorStack; |
422 | QTReader* reader; | 421 | QTReader* reader; |
423 | QComboBox* m_fontSelector; | 422 | QComboBox* m_fontSelector; |
424 | // QPEToolBar /* *menu,*/ *fileBar; | 423 | // QPEToolBar /* *menu,*/ *fileBar; |
425 | #ifdef USEQPE | 424 | #ifdef USEQPE |
426 | QToolBar *menubar; | 425 | QToolBar *menubar; |
427 | #endif | 426 | #endif |
428 | QToolBar *fileBar, *navBar, *viewBar, *markBar; | 427 | QToolBar *fileBar, *navBar, *viewBar, *markBar; |
429 | #ifdef USEQPE | 428 | #ifdef USEQPE |
430 | QPEMenuBar *mb; | 429 | QPEMenuBar *mb; |
431 | #else | 430 | #else |
432 | QMenuBar *mb; | 431 | QMenuBar *mb; |
433 | #endif | 432 | #endif |
434 | QFloatBar *searchBar, *regBar/*, *m_fontBar*/; | 433 | QFloatBar *searchBar, *regBar/*, *m_fontBar*/; |
435 | QToolBar /* *searchBar, *regBar,*/ *m_fontBar; | 434 | QToolBar /* *searchBar, *regBar,*/ *m_fontBar; |
436 | QLineEdit *searchEdit, *regEdit; | 435 | QLineEdit *searchEdit, *regEdit; |
437 | bool searchVisible; | 436 | bool searchVisible; |
438 | bool regVisible; | 437 | bool regVisible; |
439 | bool m_fontVisible, m_twoTouch; | 438 | bool m_fontVisible, m_twoTouch; |
440 | static unsigned long m_uid; | 439 | static unsigned long m_uid; |
441 | long unsigned get_unique_id() { return m_uid++; } | 440 | long unsigned get_unique_id() { return m_uid++; } |
442 | /* | 441 | /* |
443 | void resizeEvent( QResizeEvent * r) | 442 | void resizeEvent( QResizeEvent * r) |
444 | { | 443 | { |
445 | // qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height()); | 444 | // qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height()); |
446 | // qDebug("resize:(%u,%u)", r->size().width(), r->size().height()); | 445 | // qDebug("resize:(%u,%u)", r->size().width(), r->size().height()); |
447 | // bgroup->move( width()-bgroup->width(), 0 ); | 446 | // bgroup->move( width()-bgroup->width(), 0 ); |
448 | } | 447 | } |
449 | */ | 448 | */ |
450 | CList<Bkmk>* pBkmklist; | 449 | CList<Bkmk>* pBkmklist; |
451 | CList<Bkmk>* pOpenlist; | 450 | CList<Bkmk>* pOpenlist; |
452 | infowin* m_infoWin; | 451 | infowin* m_infoWin; |
453 | GraphicWin* m_graphicwin; | 452 | GraphicWin* m_graphicwin; |
454 | QProgressBar* pbar; | 453 | QProgressBar* pbar; |
455 | bool m_fBkmksChanged; | 454 | bool m_fBkmksChanged; |
456 | // int m_nRegAction; | 455 | // int m_nRegAction; |
457 | regedit_type m_nRegAction; | 456 | regedit_type m_nRegAction; |
458 | bkmk_action m_nBkmkAction; | 457 | bkmk_action m_nBkmkAction; |
459 | QString m_autogenstr; | 458 | QString m_autogenstr; |
460 | bool m_dontSave; | 459 | bool m_dontSave; |
461 | }; | 460 | }; |
462 | 461 | ||
463 | //const int cAutoGen = 0; | 462 | //const int cAutoGen = 0; |
464 | //const int cAddBkmk = 1; | 463 | //const int cAddBkmk = 1; |
465 | //const int cDelBkmk = 2; | 464 | //const int cDelBkmk = 2; |
466 | //const int cGotoBkmk = 3; | 465 | //const int cGotoBkmk = 3; |
467 | //const int cRmBkmkFile = 4; | 466 | //const int cRmBkmkFile = 4; |
468 | //const int cJump = 5; | 467 | //const int cJump = 5; |
469 | //const int cMonoSpace = 6; | 468 | //const int cMonoSpace = 6; |
470 | //const int cOverlap = 7; | 469 | //const int cOverlap = 7; |
471 | //const int cSetTarget = 8; | 470 | //const int cSetTarget = 8; |
472 | //const int cOpenFile = 9; | 471 | //const int cOpenFile = 9; |
473 | //const int cSetPipeTarget = 10; | 472 | //const int cSetPipeTarget = 10; |
474 | //const int cSetConfigName = 11; | 473 | //const int cSetConfigName = 11; |
475 | //const int cMargin = 12; | 474 | //const int cMargin = 12; |
476 | //const int cExtraSpace = 14; | 475 | //const int cExtraSpace = 14; |
477 | //const int cExtraLead = 15; | 476 | //const int cExtraLead = 15; |
478 | //const int cGfxSize = 16; | 477 | //const int cGfxSize = 16; |
479 | //const int cChooseFont = 2; | 478 | //const int cChooseFont = 2; |
480 | //const int cChooseEncoding = 1; | 479 | //const int cChooseEncoding = 1; |
481 | 480 | ||
482 | #endif | 481 | #endif |
483 | 482 | ||
484 | 483 | ||
485 | 484 | ||
diff --git a/noncore/apps/opie-reader/ToolbarPrefs.cpp b/noncore/apps/opie-reader/ToolbarPrefs.cpp index 5cf220a..56c4e9b 100644 --- a/noncore/apps/opie-reader/ToolbarPrefs.cpp +++ b/noncore/apps/opie-reader/ToolbarPrefs.cpp | |||
@@ -1,547 +1,546 @@ | |||
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 "useqpe.h" | ||
10 | #include "ToolbarPrefs.h" | 9 | #include "ToolbarPrefs.h" |
11 | 10 | ||
12 | #include <qcheckbox.h> | 11 | #include <qcheckbox.h> |
13 | #include <qlabel.h> | 12 | #include <qlabel.h> |
14 | #include <qpushbutton.h> | 13 | #include <qpushbutton.h> |
15 | #include <qspinbox.h> | 14 | #include <qspinbox.h> |
16 | #include <qlayout.h> | 15 | #include <qlayout.h> |
17 | #include <qvariant.h> | 16 | #include <qvariant.h> |
18 | #include <qtooltip.h> | 17 | #include <qtooltip.h> |
19 | #include <qwhatsthis.h> | 18 | #include <qwhatsthis.h> |
20 | #include <qcombobox.h> | 19 | #include <qcombobox.h> |
21 | #include <qbuttongroup.h> | 20 | #include <qbuttongroup.h> |
22 | #include <qlineedit.h> | 21 | #include <qlineedit.h> |
23 | #ifdef USEQPE | 22 | #ifdef USEQPE |
24 | #include <qpe/menubutton.h> | 23 | #include <qpe/menubutton.h> |
25 | #endif | 24 | #endif |
26 | 25 | ||
27 | CBarPrefs::CBarPrefs(const QString& appdir, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true), config( appdir ) | 26 | CBarPrefs::CBarPrefs(const QString& appdir, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true), config( appdir ) |
28 | { | 27 | { |
29 | setCaption(tr( "Toolbar Settings" ) ); | 28 | setCaption(tr( "Toolbar Settings" ) ); |
30 | QTabWidget* td = new QTabWidget(this); | 29 | QTabWidget* td = new QTabWidget(this); |
31 | misc = new CMiscBarPrefs(this); | 30 | misc = new CMiscBarPrefs(this); |
32 | filebar = new CFileBarPrefs(config, this); | 31 | filebar = new CFileBarPrefs(config, this); |
33 | navbar = new CNavBarPrefs(config, this); | 32 | navbar = new CNavBarPrefs(config, this); |
34 | viewbar = new CViewBarPrefs(config, this); | 33 | viewbar = new CViewBarPrefs(config, this); |
35 | markbar = new CMarkBarPrefs(config, this); | 34 | markbar = new CMarkBarPrefs(config, this); |
36 | indbar = new CIndBarPrefs(config, this); | 35 | indbar = new CIndBarPrefs(config, this); |
37 | td->addTab(filebar, tr("File")); | 36 | td->addTab(filebar, tr("File")); |
38 | td->addTab(navbar, tr("Navigation")); | 37 | td->addTab(navbar, tr("Navigation")); |
39 | td->addTab(viewbar, tr("View")); | 38 | td->addTab(viewbar, tr("View")); |
40 | td->addTab(markbar, tr("Marks")); | 39 | td->addTab(markbar, tr("Marks")); |
41 | td->addTab(indbar, tr("Indicators")); | 40 | td->addTab(indbar, tr("Indicators")); |
42 | td->addTab(misc, tr("Policy")); | 41 | td->addTab(misc, tr("Policy")); |
43 | QVBoxLayout* v = new QVBoxLayout(this); | 42 | QVBoxLayout* v = new QVBoxLayout(this); |
44 | v->addWidget(td); | 43 | v->addWidget(td); |
45 | 44 | ||
46 | if (fs) showMaximized(); | 45 | if (fs) showMaximized(); |
47 | } | 46 | } |
48 | 47 | ||
49 | /* | 48 | /* |
50 | CBarPrefs1::CBarPrefs1( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 49 | CBarPrefs1::CBarPrefs1( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
51 | : QWidget( parent, name, fl ), config(_config) | 50 | : QWidget( parent, name, fl ), config(_config) |
52 | { | 51 | { |
53 | config.setGroup( "Toolbar" ); | 52 | config.setGroup( "Toolbar" ); |
54 | QVBoxLayout* vb = new QVBoxLayout(this); | 53 | QVBoxLayout* vb = new QVBoxLayout(this); |
55 | 54 | ||
56 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "File", this); | 55 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "File", this); |
57 | vb->addWidget(bg); | 56 | vb->addWidget(bg); |
58 | 57 | ||
59 | open = new QCheckBox( tr("Open"), bg ); | 58 | open = new QCheckBox( tr("Open"), bg ); |
60 | open->setChecked(config.readBoolEntry( "Open", false )); | 59 | open->setChecked(config.readBoolEntry( "Open", false )); |
61 | connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 60 | connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
62 | close = new QCheckBox( tr("Close"), bg ); | 61 | close = new QCheckBox( tr("Close"), bg ); |
63 | close->setChecked(config.readBoolEntry( "Close", false )); | 62 | close->setChecked(config.readBoolEntry( "Close", false )); |
64 | connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 63 | connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
65 | info = new QCheckBox( tr("Info"), bg ); | 64 | info = new QCheckBox( tr("Info"), bg ); |
66 | info->setChecked(config.readBoolEntry( "Info", false )); | 65 | info->setChecked(config.readBoolEntry( "Info", false )); |
67 | connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 66 | connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
68 | twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); | 67 | twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); |
69 | twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); | 68 | twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); |
70 | connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 69 | connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
71 | find = new QCheckBox( tr("Find"), bg ); | 70 | find = new QCheckBox( tr("Find"), bg ); |
72 | find->setChecked(config.readBoolEntry( "Find", false )); | 71 | find->setChecked(config.readBoolEntry( "Find", false )); |
73 | connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 72 | connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
74 | 73 | ||
75 | bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); | 74 | bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); |
76 | vb->addWidget(bg); | 75 | vb->addWidget(bg); |
77 | scroll = new QCheckBox( tr("Scroll"), bg ); | 76 | scroll = new QCheckBox( tr("Scroll"), bg ); |
78 | scroll->setChecked(config.readBoolEntry( "Scroll", false )); | 77 | scroll->setChecked(config.readBoolEntry( "Scroll", false )); |
79 | connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 78 | connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
80 | navigation = new QCheckBox( tr("Back/Home/Forward"), bg ); | 79 | navigation = new QCheckBox( tr("Back/Home/Forward"), bg ); |
81 | navigation->setChecked(config.readBoolEntry( "Back/Home/Forward", false )); | 80 | navigation->setChecked(config.readBoolEntry( "Back/Home/Forward", false )); |
82 | connect(navigation, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 81 | connect(navigation, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
83 | page = new QCheckBox( tr("Page\nUp/Down"), bg ); | 82 | page = new QCheckBox( tr("Page\nUp/Down"), bg ); |
84 | page->setChecked(config.readBoolEntry( "Page Up/Down", false )); | 83 | page->setChecked(config.readBoolEntry( "Page Up/Down", false )); |
85 | connect(page, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 84 | connect(page, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
86 | startend = new QCheckBox( tr("Goto Start/End"), bg ); | 85 | startend = new QCheckBox( tr("Goto Start/End"), bg ); |
87 | startend->setChecked(config.readBoolEntry( "Goto Start/End", false )); | 86 | startend->setChecked(config.readBoolEntry( "Goto Start/End", false )); |
88 | connect(startend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 87 | connect(startend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
89 | jump = new QCheckBox( tr("Jump"), bg ); | 88 | jump = new QCheckBox( tr("Jump"), bg ); |
90 | jump->setChecked(config.readBoolEntry( "Jump", false )); | 89 | jump->setChecked(config.readBoolEntry( "Jump", false )); |
91 | connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 90 | connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
92 | pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); | 91 | pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); |
93 | pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); | 92 | pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); |
94 | connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 93 | connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
95 | m_isChanged = false; | 94 | m_isChanged = false; |
96 | } | 95 | } |
97 | 96 | ||
98 | void CBarPrefs1::saveall() | 97 | void CBarPrefs1::saveall() |
99 | { | 98 | { |
100 | config.setGroup( "Toolbar" ); | 99 | config.setGroup( "Toolbar" ); |
101 | config.writeEntry( "Open", open->isChecked()); | 100 | config.writeEntry( "Open", open->isChecked()); |
102 | config.writeEntry( "Close", close->isChecked()); | 101 | config.writeEntry( "Close", close->isChecked()); |
103 | config.writeEntry( "Info", info->isChecked()); | 102 | config.writeEntry( "Info", info->isChecked()); |
104 | config.writeEntry( "Two/One Touch", twotouch->isChecked()); | 103 | config.writeEntry( "Two/One Touch", twotouch->isChecked()); |
105 | config.writeEntry( "Find", find->isChecked()); | 104 | config.writeEntry( "Find", find->isChecked()); |
106 | config.writeEntry( "Scroll", scroll->isChecked()); | 105 | config.writeEntry( "Scroll", scroll->isChecked()); |
107 | config.writeEntry( "Back/Home/Forward", navigation->isChecked()); | 106 | config.writeEntry( "Back/Home/Forward", navigation->isChecked()); |
108 | config.writeEntry( "Page Up/Down", page->isChecked()); | 107 | config.writeEntry( "Page Up/Down", page->isChecked()); |
109 | config.writeEntry( "Goto Start/End", startend->isChecked()); | 108 | config.writeEntry( "Goto Start/End", startend->isChecked()); |
110 | config.writeEntry( "Jump", jump->isChecked()); | 109 | config.writeEntry( "Jump", jump->isChecked()); |
111 | config.writeEntry( "Page/Line Scroll", pageline->isChecked()); | 110 | config.writeEntry( "Page/Line Scroll", pageline->isChecked()); |
112 | } | 111 | } |
113 | 112 | ||
114 | CBarPrefs1::~CBarPrefs1() | 113 | CBarPrefs1::~CBarPrefs1() |
115 | { | 114 | { |
116 | } | 115 | } |
117 | */ | 116 | */ |
118 | /* | 117 | /* |
119 | CBarPrefs2::CBarPrefs2( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 118 | CBarPrefs2::CBarPrefs2( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
120 | : QWidget( parent, name, fl ), config(_config) | 119 | : QWidget( parent, name, fl ), config(_config) |
121 | { | 120 | { |
122 | QVBoxLayout* vb = new QVBoxLayout(this); | 121 | QVBoxLayout* vb = new QVBoxLayout(this); |
123 | 122 | ||
124 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "View", this); | 123 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "View", this); |
125 | vb->addWidget(bg); | 124 | vb->addWidget(bg); |
126 | 125 | ||
127 | config.setGroup( "Toolbar" ); | 126 | config.setGroup( "Toolbar" ); |
128 | 127 | ||
129 | fullscreen = new QCheckBox( tr("Fullscreen"), bg ); | 128 | fullscreen = new QCheckBox( tr("Fullscreen"), bg ); |
130 | fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); | 129 | fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); |
131 | connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 130 | connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
132 | rotate = new QCheckBox( tr("Rotate"), bg ); | 131 | rotate = new QCheckBox( tr("Rotate"), bg ); |
133 | rotate->setChecked(config.readBoolEntry( "Rotate", false )); | 132 | rotate->setChecked(config.readBoolEntry( "Rotate", false )); |
134 | connect(rotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 133 | connect(rotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
135 | 134 | ||
136 | invert = new QCheckBox( tr("Invert"), bg ); | 135 | invert = new QCheckBox( tr("Invert"), bg ); |
137 | invert->setChecked(config.readBoolEntry( "Invert Action", false )); | 136 | invert->setChecked(config.readBoolEntry( "Invert Action", false )); |
138 | connect(invert, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 137 | connect(invert, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
139 | 138 | ||
140 | zoom = new QCheckBox( tr("Zoom"), bg ); | 139 | zoom = new QCheckBox( tr("Zoom"), bg ); |
141 | zoom->setChecked(config.readBoolEntry( "Zoom In/Out", false )); | 140 | zoom->setChecked(config.readBoolEntry( "Zoom In/Out", false )); |
142 | connect(zoom, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 141 | connect(zoom, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
143 | setfont = new QCheckBox( tr("Set Font"), bg ); | 142 | setfont = new QCheckBox( tr("Set Font"), bg ); |
144 | setfont->setChecked(config.readBoolEntry( "Set Font", false )); | 143 | setfont->setChecked(config.readBoolEntry( "Set Font", false )); |
145 | connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 144 | connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
146 | 145 | ||
147 | encoding = new QCheckBox( tr("Encoding"), bg ); | 146 | encoding = new QCheckBox( tr("Encoding"), bg ); |
148 | encoding->setChecked(config.readBoolEntry("Encoding Select", false)); | 147 | encoding->setChecked(config.readBoolEntry("Encoding Select", false)); |
149 | connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 148 | connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
150 | ideogram = new QCheckBox( tr("Ideogram"), bg ); | 149 | ideogram = new QCheckBox( tr("Ideogram"), bg ); |
151 | ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); | 150 | ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); |
152 | connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 151 | connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
153 | 152 | ||
154 | bg = new QGroupBox(3, Qt::Horizontal, "Marks", this); | 153 | bg = new QGroupBox(3, Qt::Horizontal, "Marks", this); |
155 | vb->addWidget(bg); | 154 | vb->addWidget(bg); |
156 | mark = new QCheckBox( tr("Bookmark"), bg ); | 155 | mark = new QCheckBox( tr("Bookmark"), bg ); |
157 | mark->setChecked(config.readBoolEntry( "Mark", false )); | 156 | mark->setChecked(config.readBoolEntry( "Mark", false )); |
158 | connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 157 | connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
159 | annotate = new QCheckBox( tr("Annotate"), bg ); | 158 | annotate = new QCheckBox( tr("Annotate"), bg ); |
160 | annotate->setChecked(config.readBoolEntry( "Annotate", false )); | 159 | annotate->setChecked(config.readBoolEntry( "Annotate", false )); |
161 | connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 160 | connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
162 | go_to = new QCheckBox( tr("Goto"), bg ); | 161 | go_to = new QCheckBox( tr("Goto"), bg ); |
163 | go_to->setChecked(config.readBoolEntry( "Goto", false )); | 162 | go_to->setChecked(config.readBoolEntry( "Goto", false )); |
164 | connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 163 | connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
165 | Delete = new QCheckBox( tr("Delete"), bg ); | 164 | Delete = new QCheckBox( tr("Delete"), bg ); |
166 | Delete->setChecked(config.readBoolEntry( "Delete", false )); | 165 | Delete->setChecked(config.readBoolEntry( "Delete", false )); |
167 | connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 166 | connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
168 | autogen = new QCheckBox( tr("Autogen"), bg ); | 167 | autogen = new QCheckBox( tr("Autogen"), bg ); |
169 | autogen->setChecked(config.readBoolEntry( "Autogen", false )); | 168 | autogen->setChecked(config.readBoolEntry( "Autogen", false )); |
170 | connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 169 | connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
171 | clear = new QCheckBox( tr("Clear"), bg ); | 170 | clear = new QCheckBox( tr("Clear"), bg ); |
172 | clear->setChecked(config.readBoolEntry( "Clear", false )); | 171 | clear->setChecked(config.readBoolEntry( "Clear", false )); |
173 | connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 172 | connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
174 | save = new QCheckBox( tr("Save"), bg ); | 173 | save = new QCheckBox( tr("Save"), bg ); |
175 | save->setChecked(config.readBoolEntry( "Save", false )); | 174 | save->setChecked(config.readBoolEntry( "Save", false )); |
176 | connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 175 | connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
177 | tidy = new QCheckBox( tr("Tidy"), bg ); | 176 | tidy = new QCheckBox( tr("Tidy"), bg ); |
178 | tidy->setChecked(config.readBoolEntry( "Tidy", false )); | 177 | tidy->setChecked(config.readBoolEntry( "Tidy", false )); |
179 | connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 178 | connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
180 | block = new QCheckBox( tr("Mark/Copy"), bg ); | 179 | block = new QCheckBox( tr("Mark/Copy"), bg ); |
181 | block->setChecked(config.readBoolEntry( "Start/Copy Block", false )); | 180 | block->setChecked(config.readBoolEntry( "Start/Copy Block", false )); |
182 | connect(block, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 181 | connect(block, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
183 | 182 | ||
184 | bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); | 183 | bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); |
185 | vb->addWidget(bg); | 184 | vb->addWidget(bg); |
186 | indannotate = new QCheckBox( tr("Annotation"), bg ); | 185 | indannotate = new QCheckBox( tr("Annotation"), bg ); |
187 | indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); | 186 | indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); |
188 | connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 187 | connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
189 | m_isChanged = false; | 188 | m_isChanged = false; |
190 | } | 189 | } |
191 | 190 | ||
192 | void CBarPrefs2::saveall() | 191 | void CBarPrefs2::saveall() |
193 | { | 192 | { |
194 | config.setGroup( "Toolbar" ); | 193 | config.setGroup( "Toolbar" ); |
195 | config.writeEntry( "Fullscreen", fullscreen->isChecked()); | 194 | config.writeEntry( "Fullscreen", fullscreen->isChecked()); |
196 | config.writeEntry( "Rotate", rotate->isChecked()); | 195 | config.writeEntry( "Rotate", rotate->isChecked()); |
197 | config.writeEntry( "Invert Action", invert->isChecked()); | 196 | config.writeEntry( "Invert Action", invert->isChecked()); |
198 | config.writeEntry( "Zoom In/Out", zoom->isChecked()); | 197 | config.writeEntry( "Zoom In/Out", zoom->isChecked()); |
199 | config.writeEntry( "Set Font", setfont->isChecked()); | 198 | config.writeEntry( "Set Font", setfont->isChecked()); |
200 | config.writeEntry("Encoding Select", encoding->isChecked()); | 199 | config.writeEntry("Encoding Select", encoding->isChecked()); |
201 | config.writeEntry("Ideogram Mode", ideogram->isChecked()); | 200 | config.writeEntry("Ideogram Mode", ideogram->isChecked()); |
202 | 201 | ||
203 | config.writeEntry( "Mark", mark->isChecked()); | 202 | config.writeEntry( "Mark", mark->isChecked()); |
204 | config.writeEntry( "Annotate", annotate->isChecked()); | 203 | config.writeEntry( "Annotate", annotate->isChecked()); |
205 | config.writeEntry( "Goto", go_to->isChecked()); | 204 | config.writeEntry( "Goto", go_to->isChecked()); |
206 | config.writeEntry( "Delete", Delete->isChecked()); | 205 | config.writeEntry( "Delete", Delete->isChecked()); |
207 | config.writeEntry( "Autogen", autogen->isChecked()); | 206 | config.writeEntry( "Autogen", autogen->isChecked()); |
208 | config.writeEntry( "Clear", clear->isChecked()); | 207 | config.writeEntry( "Clear", clear->isChecked()); |
209 | config.writeEntry( "Save", save->isChecked()); | 208 | config.writeEntry( "Save", save->isChecked()); |
210 | config.writeEntry( "Tidy", tidy->isChecked()); | 209 | config.writeEntry( "Tidy", tidy->isChecked()); |
211 | config.writeEntry( "Start/Copy Block", block->isChecked()); | 210 | config.writeEntry( "Start/Copy Block", block->isChecked()); |
212 | config.writeEntry( "Annotation indicator", indannotate->isChecked()); | 211 | config.writeEntry( "Annotation indicator", indannotate->isChecked()); |
213 | } | 212 | } |
214 | 213 | ||
215 | CBarPrefs2::~CBarPrefs2() | 214 | CBarPrefs2::~CBarPrefs2() |
216 | { | 215 | { |
217 | } | 216 | } |
218 | */ | 217 | */ |
219 | 218 | ||
220 | CFileBarPrefs::CFileBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 219 | CFileBarPrefs::CFileBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
221 | : QWidget( parent, name, fl ), config(_config) | 220 | : QWidget( parent, name, fl ), config(_config) |
222 | { | 221 | { |
223 | config.setGroup( "Toolbar" ); | 222 | config.setGroup( "Toolbar" ); |
224 | QVBoxLayout* vb = new QVBoxLayout(this); | 223 | QVBoxLayout* vb = new QVBoxLayout(this); |
225 | 224 | ||
226 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "File", this); | 225 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "File", this); |
227 | vb->addWidget(bg); | 226 | vb->addWidget(bg); |
228 | 227 | ||
229 | open = new QCheckBox( tr("Open"), bg ); | 228 | open = new QCheckBox( tr("Open"), bg ); |
230 | open->setChecked(config.readBoolEntry( "Open", false )); | 229 | open->setChecked(config.readBoolEntry( "Open", false )); |
231 | connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 230 | connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
232 | close = new QCheckBox( tr("Close"), bg ); | 231 | close = new QCheckBox( tr("Close"), bg ); |
233 | close->setChecked(config.readBoolEntry( "Close", false )); | 232 | close->setChecked(config.readBoolEntry( "Close", false )); |
234 | connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 233 | connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
235 | info = new QCheckBox( tr("Info"), bg ); | 234 | info = new QCheckBox( tr("Info"), bg ); |
236 | info->setChecked(config.readBoolEntry( "Info", false )); | 235 | info->setChecked(config.readBoolEntry( "Info", false )); |
237 | connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 236 | connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
238 | twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); | 237 | twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); |
239 | twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); | 238 | twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); |
240 | connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 239 | connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
241 | find = new QCheckBox( tr("Find"), bg ); | 240 | find = new QCheckBox( tr("Find"), bg ); |
242 | find->setChecked(config.readBoolEntry( "Find", false )); | 241 | find->setChecked(config.readBoolEntry( "Find", false )); |
243 | connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 242 | connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
244 | m_isChanged = false; | 243 | m_isChanged = false; |
245 | } | 244 | } |
246 | 245 | ||
247 | void CFileBarPrefs::saveall() | 246 | void CFileBarPrefs::saveall() |
248 | { | 247 | { |
249 | config.setGroup( "Toolbar" ); | 248 | config.setGroup( "Toolbar" ); |
250 | config.writeEntry( "Open", open->isChecked()); | 249 | config.writeEntry( "Open", open->isChecked()); |
251 | config.writeEntry( "Close", close->isChecked()); | 250 | config.writeEntry( "Close", close->isChecked()); |
252 | config.writeEntry( "Info", info->isChecked()); | 251 | config.writeEntry( "Info", info->isChecked()); |
253 | config.writeEntry( "Two/One Touch", twotouch->isChecked()); | 252 | config.writeEntry( "Two/One Touch", twotouch->isChecked()); |
254 | config.writeEntry( "Find", find->isChecked()); | 253 | config.writeEntry( "Find", find->isChecked()); |
255 | } | 254 | } |
256 | 255 | ||
257 | CFileBarPrefs::~CFileBarPrefs() | 256 | CFileBarPrefs::~CFileBarPrefs() |
258 | { | 257 | { |
259 | } | 258 | } |
260 | 259 | ||
261 | CNavBarPrefs::CNavBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 260 | CNavBarPrefs::CNavBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
262 | : QWidget( parent, name, fl ), config(_config) | 261 | : QWidget( parent, name, fl ), config(_config) |
263 | { | 262 | { |
264 | config.setGroup( "Toolbar" ); | 263 | config.setGroup( "Toolbar" ); |
265 | QVBoxLayout* vb = new QVBoxLayout(this); | 264 | QVBoxLayout* vb = new QVBoxLayout(this); |
266 | 265 | ||
267 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); | 266 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); |
268 | vb->addWidget(bg); | 267 | vb->addWidget(bg); |
269 | scroll = new QCheckBox( tr("Scroll"), bg ); | 268 | scroll = new QCheckBox( tr("Scroll"), bg ); |
270 | scroll->setChecked(config.readBoolEntry( "Scroll", false )); | 269 | scroll->setChecked(config.readBoolEntry( "Scroll", false )); |
271 | connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 270 | connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
272 | 271 | ||
273 | navback = new QCheckBox( tr("Back"), bg ); | 272 | navback = new QCheckBox( tr("Back"), bg ); |
274 | navback->setChecked(config.readBoolEntry( "Back", false )); | 273 | navback->setChecked(config.readBoolEntry( "Back", false )); |
275 | connect(navback, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 274 | connect(navback, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
276 | navhome = new QCheckBox( tr("Home"), bg ); | 275 | navhome = new QCheckBox( tr("Home"), bg ); |
277 | navhome->setChecked(config.readBoolEntry( "Home", false )); | 276 | navhome->setChecked(config.readBoolEntry( "Home", false )); |
278 | connect(navhome, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 277 | connect(navhome, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
279 | navforward = new QCheckBox( tr("Forward"), bg ); | 278 | navforward = new QCheckBox( tr("Forward"), bg ); |
280 | navforward->setChecked(config.readBoolEntry( "Forward", false )); | 279 | navforward->setChecked(config.readBoolEntry( "Forward", false )); |
281 | connect(navforward, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 280 | connect(navforward, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
282 | 281 | ||
283 | pageup = new QCheckBox( tr("Page Up"), bg ); | 282 | pageup = new QCheckBox( tr("Page Up"), bg ); |
284 | pageup->setChecked(config.readBoolEntry( "Page Up", false )); | 283 | pageup->setChecked(config.readBoolEntry( "Page Up", false )); |
285 | connect(pageup, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 284 | connect(pageup, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
286 | pagedown = new QCheckBox( tr("Page Down"), bg ); | 285 | pagedown = new QCheckBox( tr("Page Down"), bg ); |
287 | pagedown->setChecked(config.readBoolEntry( "Page Down", false )); | 286 | pagedown->setChecked(config.readBoolEntry( "Page Down", false )); |
288 | connect(pagedown, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 287 | connect(pagedown, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
289 | gotostart = new QCheckBox( tr("Goto Start"), bg ); | 288 | gotostart = new QCheckBox( tr("Goto Start"), bg ); |
290 | gotostart->setChecked(config.readBoolEntry( "Goto Start", false )); | 289 | gotostart->setChecked(config.readBoolEntry( "Goto Start", false )); |
291 | connect(gotostart, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 290 | connect(gotostart, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
292 | gotoend = new QCheckBox( tr("Goto End"), bg ); | 291 | gotoend = new QCheckBox( tr("Goto End"), bg ); |
293 | gotoend->setChecked(config.readBoolEntry( "Goto End", false )); | 292 | gotoend->setChecked(config.readBoolEntry( "Goto End", false )); |
294 | connect(gotoend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 293 | connect(gotoend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
295 | jump = new QCheckBox( tr("Jump"), bg ); | 294 | jump = new QCheckBox( tr("Jump"), bg ); |
296 | jump->setChecked(config.readBoolEntry( "Jump", false )); | 295 | jump->setChecked(config.readBoolEntry( "Jump", false )); |
297 | connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 296 | connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
298 | pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); | 297 | pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); |
299 | pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); | 298 | pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); |
300 | connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 299 | connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
301 | m_isChanged = false; | 300 | m_isChanged = false; |
302 | } | 301 | } |
303 | 302 | ||
304 | void CNavBarPrefs::saveall() | 303 | void CNavBarPrefs::saveall() |
305 | { | 304 | { |
306 | config.setGroup( "Toolbar" ); | 305 | config.setGroup( "Toolbar" ); |
307 | config.writeEntry( "Scroll", scroll->isChecked()); | 306 | config.writeEntry( "Scroll", scroll->isChecked()); |
308 | config.writeEntry( "Back", navback->isChecked()); | 307 | config.writeEntry( "Back", navback->isChecked()); |
309 | config.writeEntry( "Home", navhome->isChecked()); | 308 | config.writeEntry( "Home", navhome->isChecked()); |
310 | config.writeEntry( "Forward", navforward->isChecked()); | 309 | config.writeEntry( "Forward", navforward->isChecked()); |
311 | config.writeEntry( "Page Up", pageup->isChecked()); | 310 | config.writeEntry( "Page Up", pageup->isChecked()); |
312 | config.writeEntry( "Page Down", pagedown->isChecked()); | 311 | config.writeEntry( "Page Down", pagedown->isChecked()); |
313 | config.writeEntry( "Goto Start", gotostart->isChecked()); | 312 | config.writeEntry( "Goto Start", gotostart->isChecked()); |
314 | config.writeEntry( "Goto End", gotoend->isChecked()); | 313 | config.writeEntry( "Goto End", gotoend->isChecked()); |
315 | config.writeEntry( "Jump", jump->isChecked()); | 314 | config.writeEntry( "Jump", jump->isChecked()); |
316 | config.writeEntry( "Page/Line Scroll", pageline->isChecked()); | 315 | config.writeEntry( "Page/Line Scroll", pageline->isChecked()); |
317 | } | 316 | } |
318 | 317 | ||
319 | CNavBarPrefs::~CNavBarPrefs() | 318 | CNavBarPrefs::~CNavBarPrefs() |
320 | { | 319 | { |
321 | } | 320 | } |
322 | 321 | ||
323 | CViewBarPrefs::CViewBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 322 | CViewBarPrefs::CViewBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
324 | : QWidget( parent, name, fl ), config(_config) | 323 | : QWidget( parent, name, fl ), config(_config) |
325 | { | 324 | { |
326 | QVBoxLayout* vb = new QVBoxLayout(this); | 325 | QVBoxLayout* vb = new QVBoxLayout(this); |
327 | 326 | ||
328 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "View", this); | 327 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "View", this); |
329 | vb->addWidget(bg); | 328 | vb->addWidget(bg); |
330 | 329 | ||
331 | config.setGroup( "Toolbar" ); | 330 | config.setGroup( "Toolbar" ); |
332 | 331 | ||
333 | fullscreen = new QCheckBox( tr("Fullscreen"), bg ); | 332 | fullscreen = new QCheckBox( tr("Fullscreen"), bg ); |
334 | fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); | 333 | fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); |
335 | connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 334 | connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
336 | rotate = new QCheckBox( tr("Rotate"), bg ); | 335 | rotate = new QCheckBox( tr("Rotate"), bg ); |
337 | rotate->setChecked(config.readBoolEntry( "Rotate", false )); | 336 | rotate->setChecked(config.readBoolEntry( "Rotate", false )); |
338 | connect(rotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 337 | connect(rotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
339 | 338 | ||
340 | invert = new QCheckBox( tr("Invert"), bg ); | 339 | invert = new QCheckBox( tr("Invert"), bg ); |
341 | invert->setChecked(config.readBoolEntry( "Invert Action", false )); | 340 | invert->setChecked(config.readBoolEntry( "Invert Action", false )); |
342 | connect(invert, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 341 | connect(invert, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
343 | 342 | ||
344 | zoomin = new QCheckBox( tr("Zoom In"), bg ); | 343 | zoomin = new QCheckBox( tr("Zoom In"), bg ); |
345 | zoomin->setChecked(config.readBoolEntry( "Zoom In", false )); | 344 | zoomin->setChecked(config.readBoolEntry( "Zoom In", false )); |
346 | connect(zoomin, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 345 | connect(zoomin, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
347 | zoomout = new QCheckBox( tr("Zoom Out"), bg ); | 346 | zoomout = new QCheckBox( tr("Zoom Out"), bg ); |
348 | zoomout->setChecked(config.readBoolEntry( "Zoom Out", false )); | 347 | zoomout->setChecked(config.readBoolEntry( "Zoom Out", false )); |
349 | connect(zoomout, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 348 | connect(zoomout, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
350 | setfont = new QCheckBox( tr("Set Font"), bg ); | 349 | setfont = new QCheckBox( tr("Set Font"), bg ); |
351 | setfont->setChecked(config.readBoolEntry( "Set Font", false )); | 350 | setfont->setChecked(config.readBoolEntry( "Set Font", false )); |
352 | connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 351 | connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
353 | 352 | ||
354 | encoding = new QCheckBox( tr("Encoding"), bg ); | 353 | encoding = new QCheckBox( tr("Encoding"), bg ); |
355 | encoding->setChecked(config.readBoolEntry("Encoding Select", false)); | 354 | encoding->setChecked(config.readBoolEntry("Encoding Select", false)); |
356 | connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 355 | connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
357 | ideogram = new QCheckBox( tr("Ideogram"), bg ); | 356 | ideogram = new QCheckBox( tr("Ideogram"), bg ); |
358 | ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); | 357 | ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); |
359 | connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 358 | connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
360 | m_isChanged = false; | 359 | m_isChanged = false; |
361 | } | 360 | } |
362 | 361 | ||
363 | void CViewBarPrefs::saveall() | 362 | void CViewBarPrefs::saveall() |
364 | { | 363 | { |
365 | config.setGroup( "Toolbar" ); | 364 | config.setGroup( "Toolbar" ); |
366 | config.writeEntry( "Fullscreen", fullscreen->isChecked()); | 365 | config.writeEntry( "Fullscreen", fullscreen->isChecked()); |
367 | config.writeEntry( "Rotate", rotate->isChecked()); | 366 | config.writeEntry( "Rotate", rotate->isChecked()); |
368 | config.writeEntry( "Invert Action", invert->isChecked()); | 367 | config.writeEntry( "Invert Action", invert->isChecked()); |
369 | config.writeEntry( "Zoom In", zoomin->isChecked()); | 368 | config.writeEntry( "Zoom In", zoomin->isChecked()); |
370 | config.writeEntry( "Zoom Out", zoomout->isChecked()); | 369 | config.writeEntry( "Zoom Out", zoomout->isChecked()); |
371 | config.writeEntry( "Set Font", setfont->isChecked()); | 370 | config.writeEntry( "Set Font", setfont->isChecked()); |
372 | config.writeEntry("Encoding Select", encoding->isChecked()); | 371 | config.writeEntry("Encoding Select", encoding->isChecked()); |
373 | config.writeEntry("Ideogram Mode", ideogram->isChecked()); | 372 | config.writeEntry("Ideogram Mode", ideogram->isChecked()); |
374 | } | 373 | } |
375 | 374 | ||
376 | CViewBarPrefs::~CViewBarPrefs() | 375 | CViewBarPrefs::~CViewBarPrefs() |
377 | { | 376 | { |
378 | } | 377 | } |
379 | 378 | ||
380 | CMarkBarPrefs::CMarkBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 379 | CMarkBarPrefs::CMarkBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
381 | : QWidget( parent, name, fl ), config(_config) | 380 | : QWidget( parent, name, fl ), config(_config) |
382 | { | 381 | { |
383 | QVBoxLayout* vb = new QVBoxLayout(this); | 382 | QVBoxLayout* vb = new QVBoxLayout(this); |
384 | 383 | ||
385 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Marks", this); | 384 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Marks", this); |
386 | vb->addWidget(bg); | 385 | vb->addWidget(bg); |
387 | mark = new QCheckBox( tr("Bookmark"), bg ); | 386 | mark = new QCheckBox( tr("Bookmark"), bg ); |
388 | mark->setChecked(config.readBoolEntry( "Mark", false )); | 387 | mark->setChecked(config.readBoolEntry( "Mark", false )); |
389 | connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 388 | connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
390 | annotate = new QCheckBox( tr("Annotate"), bg ); | 389 | annotate = new QCheckBox( tr("Annotate"), bg ); |
391 | annotate->setChecked(config.readBoolEntry( "Annotate", false )); | 390 | annotate->setChecked(config.readBoolEntry( "Annotate", false )); |
392 | connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 391 | connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
393 | go_to = new QCheckBox( tr("Goto"), bg ); | 392 | go_to = new QCheckBox( tr("Goto"), bg ); |
394 | go_to->setChecked(config.readBoolEntry( "Goto", false )); | 393 | go_to->setChecked(config.readBoolEntry( "Goto", false )); |
395 | connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 394 | connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
396 | Delete = new QCheckBox( tr("Delete"), bg ); | 395 | Delete = new QCheckBox( tr("Delete"), bg ); |
397 | Delete->setChecked(config.readBoolEntry( "Delete", false )); | 396 | Delete->setChecked(config.readBoolEntry( "Delete", false )); |
398 | connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 397 | connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
399 | autogen = new QCheckBox( tr("Autogen"), bg ); | 398 | autogen = new QCheckBox( tr("Autogen"), bg ); |
400 | autogen->setChecked(config.readBoolEntry( "Autogen", false )); | 399 | autogen->setChecked(config.readBoolEntry( "Autogen", false )); |
401 | connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 400 | connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
402 | clear = new QCheckBox( tr("Clear"), bg ); | 401 | clear = new QCheckBox( tr("Clear"), bg ); |
403 | clear->setChecked(config.readBoolEntry( "Clear", false )); | 402 | clear->setChecked(config.readBoolEntry( "Clear", false )); |
404 | connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 403 | connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
405 | save = new QCheckBox( tr("Save"), bg ); | 404 | save = new QCheckBox( tr("Save"), bg ); |
406 | save->setChecked(config.readBoolEntry( "Save", false )); | 405 | save->setChecked(config.readBoolEntry( "Save", false )); |
407 | connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 406 | connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
408 | tidy = new QCheckBox( tr("Tidy"), bg ); | 407 | tidy = new QCheckBox( tr("Tidy"), bg ); |
409 | tidy->setChecked(config.readBoolEntry( "Tidy", false )); | 408 | tidy->setChecked(config.readBoolEntry( "Tidy", false )); |
410 | connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 409 | connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
411 | startblock = new QCheckBox( tr("Mark Block"), bg ); | 410 | startblock = new QCheckBox( tr("Mark Block"), bg ); |
412 | startblock->setChecked(config.readBoolEntry( "Start Block", false )); | 411 | startblock->setChecked(config.readBoolEntry( "Start Block", false )); |
413 | connect(startblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 412 | connect(startblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
414 | copyblock = new QCheckBox( tr("Copy Block"), bg ); | 413 | copyblock = new QCheckBox( tr("Copy Block"), bg ); |
415 | copyblock->setChecked(config.readBoolEntry( "Copy Block", false )); | 414 | copyblock->setChecked(config.readBoolEntry( "Copy Block", false )); |
416 | connect(copyblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 415 | connect(copyblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
417 | m_isChanged = false; | 416 | m_isChanged = false; |
418 | } | 417 | } |
419 | 418 | ||
420 | void CMarkBarPrefs::saveall() | 419 | void CMarkBarPrefs::saveall() |
421 | { | 420 | { |
422 | config.setGroup( "Toolbar" ); | 421 | config.setGroup( "Toolbar" ); |
423 | config.writeEntry( "Mark", mark->isChecked()); | 422 | config.writeEntry( "Mark", mark->isChecked()); |
424 | config.writeEntry( "Annotate", annotate->isChecked()); | 423 | config.writeEntry( "Annotate", annotate->isChecked()); |
425 | config.writeEntry( "Goto", go_to->isChecked()); | 424 | config.writeEntry( "Goto", go_to->isChecked()); |
426 | config.writeEntry( "Delete", Delete->isChecked()); | 425 | config.writeEntry( "Delete", Delete->isChecked()); |
427 | config.writeEntry( "Autogen", autogen->isChecked()); | 426 | config.writeEntry( "Autogen", autogen->isChecked()); |
428 | config.writeEntry( "Clear", clear->isChecked()); | 427 | config.writeEntry( "Clear", clear->isChecked()); |
429 | config.writeEntry( "Save", save->isChecked()); | 428 | config.writeEntry( "Save", save->isChecked()); |
430 | config.writeEntry( "Tidy", tidy->isChecked()); | 429 | config.writeEntry( "Tidy", tidy->isChecked()); |
431 | config.writeEntry( "Start Block", startblock->isChecked()); | 430 | config.writeEntry( "Start Block", startblock->isChecked()); |
432 | config.writeEntry( "Copy Block", copyblock->isChecked()); | 431 | config.writeEntry( "Copy Block", copyblock->isChecked()); |
433 | } | 432 | } |
434 | 433 | ||
435 | CMarkBarPrefs::~CMarkBarPrefs() | 434 | CMarkBarPrefs::~CMarkBarPrefs() |
436 | { | 435 | { |
437 | } | 436 | } |
438 | 437 | ||
439 | CMiscBarPrefs::CMiscBarPrefs( QWidget* parent, const char* name, WFlags fl ) | 438 | CMiscBarPrefs::CMiscBarPrefs( QWidget* parent, const char* name, WFlags fl ) |
440 | : QWidget( parent, name, fl ) | 439 | : QWidget( parent, name, fl ) |
441 | { | 440 | { |
442 | 441 | ||
443 | QGridLayout* hl = new QGridLayout(this,2,2); | 442 | QGridLayout* hl = new QGridLayout(this,2,2); |
444 | 443 | ||
445 | hl->setMargin( 0 ); | 444 | hl->setMargin( 0 ); |
446 | 445 | ||
447 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Dialogs", this); | 446 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Dialogs", this); |
448 | floating = new QCheckBox(gb); | 447 | floating = new QCheckBox(gb); |
449 | floating->setText(tr("Floating")); | 448 | floating->setText(tr("Floating")); |
450 | hl->addWidget( gb, 0, 0 ); | 449 | hl->addWidget( gb, 0, 0 ); |
451 | 450 | ||
452 | 451 | ||
453 | gb = new QGroupBox(1, Qt::Horizontal, "Bars (Restart)", this); | 452 | gb = new QGroupBox(1, Qt::Horizontal, "Bars (Restart)", this); |
454 | 453 | ||
455 | // QLabel* ql = new QLabel("Restart to apply changes", gb); | 454 | // QLabel* ql = new QLabel("Restart to apply changes", gb); |
456 | // TextLabel = new QLabel( gb ); | 455 | // TextLabel = new QLabel( gb ); |
457 | // TextLabel->setText( tr( "Policy" ) ); | 456 | // TextLabel->setText( tr( "Policy" ) ); |
458 | 457 | ||
459 | #ifdef USECOMBO | 458 | #ifdef USECOMBO |
460 | tbpolicy = new QComboBox(gb); | 459 | tbpolicy = new QComboBox(gb); |
461 | #else | 460 | #else |
462 | tbpolicy = new MenuButton(gb); | 461 | tbpolicy = new MenuButton(gb); |
463 | #endif | 462 | #endif |
464 | tbpolicy->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 463 | tbpolicy->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
465 | #ifdef USEQPE | 464 | #ifdef USEQPE |
466 | tbpolicy->insertItem(tr("Single bar")); | 465 | tbpolicy->insertItem(tr("Single bar")); |
467 | tbpolicy->insertItem(tr("Menu/tool bar")); | 466 | tbpolicy->insertItem(tr("Menu/tool bar")); |
468 | tbpolicy->insertItem(tr("Multiple bars")); | 467 | tbpolicy->insertItem(tr("Multiple bars")); |
469 | #else | 468 | #else |
470 | tbpolicy->insertItem(tr("Single bar")); | 469 | tbpolicy->insertItem(tr("Single bar")); |
471 | tbpolicy->insertItem(tr("Multiple bars")); | 470 | tbpolicy->insertItem(tr("Multiple bars")); |
472 | #endif | 471 | #endif |
473 | 472 | ||
474 | #ifdef USECOMBO | 473 | #ifdef USECOMBO |
475 | tbposition = new QComboBox(gb); | 474 | tbposition = new QComboBox(gb); |
476 | #else | 475 | #else |
477 | tbposition = new MenuButton(gb); | 476 | tbposition = new MenuButton(gb); |
478 | #endif | 477 | #endif |
479 | tbposition->insertItem(tr("Top")); | 478 | tbposition->insertItem(tr("Top")); |
480 | tbposition->insertItem(tr("Bottom")); | 479 | tbposition->insertItem(tr("Bottom")); |
481 | tbposition->insertItem(tr("Right")); | 480 | tbposition->insertItem(tr("Right")); |
482 | tbposition->insertItem(tr("Left")); | 481 | tbposition->insertItem(tr("Left")); |
483 | tbposition->insertItem(tr("Minimised")); | 482 | tbposition->insertItem(tr("Minimised")); |
484 | 483 | ||
485 | tbmovable = new QCheckBox( tr("Movable"), gb ); | 484 | tbmovable = new QCheckBox( tr("Movable"), gb ); |
486 | 485 | ||
487 | hl->addWidget(gb, 0, 1); | 486 | hl->addWidget(gb, 0, 1); |
488 | 487 | ||
489 | gb = new QGroupBox(1, Qt::Horizontal, "QT Scroll Bar", this); | 488 | gb = new QGroupBox(1, Qt::Horizontal, "QT Scroll Bar", this); |
490 | 489 | ||
491 | #ifdef USECOMBO | 490 | #ifdef USECOMBO |
492 | qtscroll = new QComboBox(gb); | 491 | qtscroll = new QComboBox(gb); |
493 | #else | 492 | #else |
494 | qtscroll = new MenuButton(gb); | 493 | qtscroll = new MenuButton(gb); |
495 | #endif | 494 | #endif |
496 | qtscroll->insertItem(tr("None")); | 495 | qtscroll->insertItem(tr("None")); |
497 | qtscroll->insertItem(tr("Right")); | 496 | qtscroll->insertItem(tr("Right")); |
498 | qtscroll->insertItem(tr("Left")); | 497 | qtscroll->insertItem(tr("Left")); |
499 | 498 | ||
500 | hl->addWidget(gb, 1, 0); | 499 | hl->addWidget(gb, 1, 0); |
501 | gb = new QGroupBox(1, Qt::Horizontal, "Miniscroll", this); | 500 | gb = new QGroupBox(1, Qt::Horizontal, "Miniscroll", this); |
502 | 501 | ||
503 | #ifdef USECOMBO | 502 | #ifdef USECOMBO |
504 | localscroll = new QComboBox(gb); | 503 | localscroll = new QComboBox(gb); |
505 | #else | 504 | #else |
506 | localscroll = new MenuButton(gb); | 505 | localscroll = new MenuButton(gb); |
507 | #endif | 506 | #endif |
508 | localscroll->insertItem(tr("None")); | 507 | localscroll->insertItem(tr("None")); |
509 | localscroll->insertItem(tr("Bottom")); | 508 | localscroll->insertItem(tr("Bottom")); |
510 | localscroll->insertItem(tr("Right")); | 509 | localscroll->insertItem(tr("Right")); |
511 | localscroll->insertItem(tr("Left")); | 510 | localscroll->insertItem(tr("Left")); |
512 | 511 | ||
513 | //scrollonleft = new QCheckBox( tr("... on Left"), gb ); | 512 | //scrollonleft = new QCheckBox( tr("... on Left"), gb ); |
514 | // ch->setChecked(config.readBoolEntry( "Movable", false )); | 513 | // ch->setChecked(config.readBoolEntry( "Movable", false )); |
515 | 514 | ||
516 | hl->addWidget(gb, 1, 1); | 515 | hl->addWidget(gb, 1, 1); |
517 | 516 | ||
518 | } | 517 | } |
519 | 518 | ||
520 | CMiscBarPrefs::~CMiscBarPrefs() | 519 | CMiscBarPrefs::~CMiscBarPrefs() |
521 | { | 520 | { |
522 | // no need to delete child widgets, Qt does it all for us | 521 | // no need to delete child widgets, Qt does it all for us |
523 | } | 522 | } |
524 | 523 | ||
525 | 524 | ||
526 | CIndBarPrefs::CIndBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 525 | CIndBarPrefs::CIndBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
527 | : QWidget( parent, name, fl ), config(_config) | 526 | : QWidget( parent, name, fl ), config(_config) |
528 | { | 527 | { |
529 | QVBoxLayout* vb = new QVBoxLayout(this); | 528 | QVBoxLayout* vb = new QVBoxLayout(this); |
530 | 529 | ||
531 | QGroupBox* bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); | 530 | QGroupBox* bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); |
532 | vb->addWidget(bg); | 531 | vb->addWidget(bg); |
533 | indannotate = new QCheckBox( tr("Annotation"), bg ); | 532 | indannotate = new QCheckBox( tr("Annotation"), bg ); |
534 | indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); | 533 | indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); |
535 | connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 534 | connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
536 | m_isChanged = false; | 535 | m_isChanged = false; |
537 | } | 536 | } |
538 | 537 | ||
539 | void CIndBarPrefs::saveall() | 538 | void CIndBarPrefs::saveall() |
540 | { | 539 | { |
541 | config.setGroup( "Toolbar" ); | 540 | config.setGroup( "Toolbar" ); |
542 | config.writeEntry( "Annotation indicator", indannotate->isChecked()); | 541 | config.writeEntry( "Annotation indicator", indannotate->isChecked()); |
543 | } | 542 | } |
544 | 543 | ||
545 | CIndBarPrefs::~CIndBarPrefs() | 544 | CIndBarPrefs::~CIndBarPrefs() |
546 | { | 545 | { |
547 | } | 546 | } |
diff --git a/noncore/apps/opie-reader/ToolbarPrefs.h b/noncore/apps/opie-reader/ToolbarPrefs.h index a2686e5..0bdae6b 100644 --- a/noncore/apps/opie-reader/ToolbarPrefs.h +++ b/noncore/apps/opie-reader/ToolbarPrefs.h | |||
@@ -1,269 +1,267 @@ | |||
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 | #include "useqpe.h" | ||
12 | #include <qvariant.h> | 11 | #include <qvariant.h> |
13 | #include <qwidget.h> | 12 | #include <qwidget.h> |
14 | #include <qtabdialog.h> | 13 | #include <qtabdialog.h> |
15 | #include <qtabwidget.h> | 14 | #include <qtabwidget.h> |
16 | #include <qspinbox.h> | 15 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
18 | #include <qcombobox.h> | 17 | #include <qcombobox.h> |
19 | #include <qlineedit.h> | 18 | #include <qlineedit.h> |
20 | #ifdef USEQPE | 19 | #ifdef USEQPE |
21 | #include <qpe/menubutton.h> | 20 | #include <qpe/menubutton.h> |
22 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
23 | #else | 22 | #else |
24 | #include "preferences.h" | 23 | #include "preferences.h" |
25 | #endif | 24 | #endif |
26 | //#include "opie.h" | ||
27 | //#ifdef OPIE | 25 | //#ifdef OPIE |
28 | #define USECOMBO | 26 | #define USECOMBO |
29 | //#endif | 27 | //#endif |
30 | 28 | ||
31 | class QVBoxLayout; | 29 | class QVBoxLayout; |
32 | class QHBoxLayout; | 30 | class QHBoxLayout; |
33 | class QGridLayout; | 31 | class QGridLayout; |
34 | //class QCheckBox; | 32 | //class QCheckBox; |
35 | class QLabel; | 33 | class QLabel; |
36 | //class QSpinBox; | 34 | //class QSpinBox; |
37 | /* | 35 | /* |
38 | class CBarPrefs1 : public QWidget | 36 | class CBarPrefs1 : public QWidget |
39 | { | 37 | { |
40 | Q_OBJECT | 38 | Q_OBJECT |
41 | 39 | ||
42 | Config& config; | 40 | Config& config; |
43 | QCheckBox *open, *close, *info, *twotouch,*find,*scroll,*navigation,*page,*startend,*jump,*pageline; | 41 | QCheckBox *open, *close, *info, *twotouch,*find,*scroll,*navigation,*page,*startend,*jump,*pageline; |
44 | 42 | ||
45 | bool m_isChanged; | 43 | bool m_isChanged; |
46 | 44 | ||
47 | private slots: | 45 | private slots: |
48 | void isChanged(int _v) { m_isChanged = true; } | 46 | void isChanged(int _v) { m_isChanged = true; } |
49 | 47 | ||
50 | public: | 48 | public: |
51 | CBarPrefs1( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 49 | CBarPrefs1( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
52 | ~CBarPrefs1(); | 50 | ~CBarPrefs1(); |
53 | void saveall(); | 51 | void saveall(); |
54 | bool isChanged() { return m_isChanged; } | 52 | bool isChanged() { return m_isChanged; } |
55 | }; | 53 | }; |
56 | */ | 54 | */ |
57 | class CFileBarPrefs : public QWidget | 55 | class CFileBarPrefs : public QWidget |
58 | { | 56 | { |
59 | Q_OBJECT | 57 | Q_OBJECT |
60 | 58 | ||
61 | Config& config; | 59 | Config& config; |
62 | QCheckBox *open, *close, *info, *twotouch, *find, *scroll; | 60 | QCheckBox *open, *close, *info, *twotouch, *find, *scroll; |
63 | 61 | ||
64 | bool m_isChanged; | 62 | bool m_isChanged; |
65 | 63 | ||
66 | private slots: | 64 | private slots: |
67 | void isChanged(int _v) { m_isChanged = true; } | 65 | void isChanged(int _v) { m_isChanged = true; } |
68 | 66 | ||
69 | public: | 67 | public: |
70 | CFileBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 68 | CFileBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
71 | ~CFileBarPrefs(); | 69 | ~CFileBarPrefs(); |
72 | void saveall(); | 70 | void saveall(); |
73 | bool isChanged() { return m_isChanged; } | 71 | bool isChanged() { return m_isChanged; } |
74 | }; | 72 | }; |
75 | 73 | ||
76 | class CNavBarPrefs : public QWidget | 74 | class CNavBarPrefs : public QWidget |
77 | { | 75 | { |
78 | Q_OBJECT | 76 | Q_OBJECT |
79 | 77 | ||
80 | Config& config; | 78 | Config& config; |
81 | QCheckBox *scroll, *navback, *navhome, *navforward; | 79 | QCheckBox *scroll, *navback, *navhome, *navforward; |
82 | QCheckBox *pageup, *pagedown, *gotostart, *gotoend, *jump, *pageline; | 80 | QCheckBox *pageup, *pagedown, *gotostart, *gotoend, *jump, *pageline; |
83 | 81 | ||
84 | bool m_isChanged; | 82 | bool m_isChanged; |
85 | 83 | ||
86 | private slots: | 84 | private slots: |
87 | void isChanged(int _v) { m_isChanged = true; } | 85 | void isChanged(int _v) { m_isChanged = true; } |
88 | 86 | ||
89 | public: | 87 | public: |
90 | CNavBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 88 | CNavBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
91 | ~CNavBarPrefs(); | 89 | ~CNavBarPrefs(); |
92 | void saveall(); | 90 | void saveall(); |
93 | bool isChanged() { return m_isChanged; } | 91 | bool isChanged() { return m_isChanged; } |
94 | }; | 92 | }; |
95 | /* | 93 | /* |
96 | class CBarPrefs2 : public QWidget | 94 | class CBarPrefs2 : public QWidget |
97 | { | 95 | { |
98 | Q_OBJECT | 96 | Q_OBJECT |
99 | Config& config; | 97 | Config& config; |
100 | QCheckBox *fullscreen, *zoom, *setfont, *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *block, *indannotate, *encoding, *ideogram; | 98 | QCheckBox *fullscreen, *zoom, *setfont, *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *block, *indannotate, *encoding, *ideogram; |
101 | 99 | ||
102 | bool m_isChanged; | 100 | bool m_isChanged; |
103 | 101 | ||
104 | private slots: | 102 | private slots: |
105 | void isChanged(int _v) { m_isChanged = true; } | 103 | void isChanged(int _v) { m_isChanged = true; } |
106 | 104 | ||
107 | public: | 105 | public: |
108 | CBarPrefs2( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 106 | CBarPrefs2( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
109 | ~CBarPrefs2(); | 107 | ~CBarPrefs2(); |
110 | void saveall(); | 108 | void saveall(); |
111 | bool isChanged() { return m_isChanged; } | 109 | bool isChanged() { return m_isChanged; } |
112 | 110 | ||
113 | }; | 111 | }; |
114 | */ | 112 | */ |
115 | class CViewBarPrefs : public QWidget | 113 | class CViewBarPrefs : public QWidget |
116 | { | 114 | { |
117 | Q_OBJECT | 115 | Q_OBJECT |
118 | Config& config; | 116 | Config& config; |
119 | QCheckBox *fullscreen, *rotate, *zoomin, *zoomout, *setfont, *encoding, *ideogram, *invert; | 117 | QCheckBox *fullscreen, *rotate, *zoomin, *zoomout, *setfont, *encoding, *ideogram, *invert; |
120 | 118 | ||
121 | bool m_isChanged; | 119 | bool m_isChanged; |
122 | 120 | ||
123 | private slots: | 121 | private slots: |
124 | void isChanged(int _v) { m_isChanged = true; } | 122 | void isChanged(int _v) { m_isChanged = true; } |
125 | 123 | ||
126 | public: | 124 | public: |
127 | CViewBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 125 | CViewBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
128 | ~CViewBarPrefs(); | 126 | ~CViewBarPrefs(); |
129 | void saveall(); | 127 | void saveall(); |
130 | bool isChanged() { return m_isChanged; } | 128 | bool isChanged() { return m_isChanged; } |
131 | 129 | ||
132 | }; | 130 | }; |
133 | 131 | ||
134 | class CMarkBarPrefs : public QWidget | 132 | class CMarkBarPrefs : public QWidget |
135 | { | 133 | { |
136 | Q_OBJECT | 134 | Q_OBJECT |
137 | Config& config; | 135 | Config& config; |
138 | QCheckBox *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *startblock, *copyblock; | 136 | QCheckBox *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *startblock, *copyblock; |
139 | 137 | ||
140 | bool m_isChanged; | 138 | bool m_isChanged; |
141 | 139 | ||
142 | private slots: | 140 | private slots: |
143 | void isChanged(int _v) { m_isChanged = true; } | 141 | void isChanged(int _v) { m_isChanged = true; } |
144 | 142 | ||
145 | public: | 143 | public: |
146 | CMarkBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 144 | CMarkBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
147 | ~CMarkBarPrefs(); | 145 | ~CMarkBarPrefs(); |
148 | void saveall(); | 146 | void saveall(); |
149 | bool isChanged() { return m_isChanged; } | 147 | bool isChanged() { return m_isChanged; } |
150 | 148 | ||
151 | }; | 149 | }; |
152 | 150 | ||
153 | class CIndBarPrefs : public QWidget | 151 | class CIndBarPrefs : public QWidget |
154 | { | 152 | { |
155 | Q_OBJECT | 153 | Q_OBJECT |
156 | Config& config; | 154 | Config& config; |
157 | QCheckBox *indannotate; | 155 | QCheckBox *indannotate; |
158 | 156 | ||
159 | bool m_isChanged; | 157 | bool m_isChanged; |
160 | 158 | ||
161 | private slots: | 159 | private slots: |
162 | void isChanged(int _v) { m_isChanged = true; } | 160 | void isChanged(int _v) { m_isChanged = true; } |
163 | 161 | ||
164 | public: | 162 | public: |
165 | CIndBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 163 | CIndBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
166 | ~CIndBarPrefs(); | 164 | ~CIndBarPrefs(); |
167 | void saveall(); | 165 | void saveall(); |
168 | bool isChanged() { return m_isChanged; } | 166 | bool isChanged() { return m_isChanged; } |
169 | 167 | ||
170 | }; | 168 | }; |
171 | 169 | ||
172 | class CMiscBarPrefs : public QWidget | 170 | class CMiscBarPrefs : public QWidget |
173 | { | 171 | { |
174 | 172 | ||
175 | public: | 173 | public: |
176 | 174 | ||
177 | CMiscBarPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 175 | CMiscBarPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
178 | ~CMiscBarPrefs(); | 176 | ~CMiscBarPrefs(); |
179 | 177 | ||
180 | #ifdef USECOMBO | 178 | #ifdef USECOMBO |
181 | QComboBox *tbpolicy, *tbposition, *qtscroll, *localscroll; | 179 | QComboBox *tbpolicy, *tbposition, *qtscroll, *localscroll; |
182 | #else | 180 | #else |
183 | MenuButton *tbpolicy, *tbposition, *qtscroll, *localscroll; | 181 | MenuButton *tbpolicy, *tbposition, *qtscroll, *localscroll; |
184 | #endif | 182 | #endif |
185 | QCheckBox *tbmovable, *floating; | 183 | QCheckBox *tbmovable, *floating; |
186 | }; | 184 | }; |
187 | 185 | ||
188 | class CBarPrefs : public QDialog | 186 | class CBarPrefs : public QDialog |
189 | { | 187 | { |
190 | Q_OBJECT | 188 | Q_OBJECT |
191 | ; | 189 | ; |
192 | CMiscBarPrefs* misc; | 190 | CMiscBarPrefs* misc; |
193 | CFileBarPrefs* filebar; | 191 | CFileBarPrefs* filebar; |
194 | CNavBarPrefs* navbar; | 192 | CNavBarPrefs* navbar; |
195 | CViewBarPrefs* viewbar; | 193 | CViewBarPrefs* viewbar; |
196 | CMarkBarPrefs* markbar; | 194 | CMarkBarPrefs* markbar; |
197 | CIndBarPrefs* indbar; | 195 | CIndBarPrefs* indbar; |
198 | Config config; | 196 | Config config; |
199 | 197 | ||
200 | void keyPressEvent(QKeyEvent* e) | 198 | void keyPressEvent(QKeyEvent* e) |
201 | { | 199 | { |
202 | switch (e->key()) | 200 | switch (e->key()) |
203 | { | 201 | { |
204 | case Key_Escape: | 202 | case Key_Escape: |
205 | e->accept(); | 203 | e->accept(); |
206 | reject(); | 204 | reject(); |
207 | break; | 205 | break; |
208 | case Key_Space: | 206 | case Key_Space: |
209 | case Key_Return: | 207 | case Key_Return: |
210 | e->accept(); | 208 | e->accept(); |
211 | accept(); | 209 | accept(); |
212 | break; | 210 | break; |
213 | default: | 211 | default: |
214 | QWidget::keyPressEvent(e); | 212 | QWidget::keyPressEvent(e); |
215 | } | 213 | } |
216 | } | 214 | } |
217 | public: | 215 | public: |
218 | CBarPrefs(const QString& appdir, bool fs = true, QWidget* parent = 0, const char* name = 0); | 216 | CBarPrefs(const QString& appdir, bool fs = true, QWidget* parent = 0, const char* name = 0); |
219 | ~CBarPrefs() | 217 | ~CBarPrefs() |
220 | { | 218 | { |
221 | if (result()) | 219 | if (result()) |
222 | { | 220 | { |
223 | if (navbar->isChanged()) navbar->saveall(); | 221 | if (navbar->isChanged()) navbar->saveall(); |
224 | if (filebar->isChanged()) filebar->saveall(); | 222 | if (filebar->isChanged()) filebar->saveall(); |
225 | if (viewbar->isChanged()) viewbar->saveall(); | 223 | if (viewbar->isChanged()) viewbar->saveall(); |
226 | if (markbar->isChanged()) markbar->saveall(); | 224 | if (markbar->isChanged()) markbar->saveall(); |
227 | if (indbar->isChanged()) indbar->saveall(); | 225 | if (indbar->isChanged()) indbar->saveall(); |
228 | } | 226 | } |
229 | } | 227 | } |
230 | bool isChanged() | 228 | bool isChanged() |
231 | { | 229 | { |
232 | return | 230 | return |
233 | ( | 231 | ( |
234 | filebar->isChanged() | 232 | filebar->isChanged() |
235 | || | 233 | || |
236 | navbar->isChanged() | 234 | navbar->isChanged() |
237 | || | 235 | || |
238 | viewbar->isChanged() | 236 | viewbar->isChanged() |
239 | || | 237 | || |
240 | markbar->isChanged() | 238 | markbar->isChanged() |
241 | || | 239 | || |
242 | indbar->isChanged() | 240 | indbar->isChanged() |
243 | ); | 241 | ); |
244 | } | 242 | } |
245 | bool floating() { return misc->floating->isChecked(); } | 243 | bool floating() { return misc->floating->isChecked(); } |
246 | void floating(bool v) { misc->floating->setChecked(v); } | 244 | void floating(bool v) { misc->floating->setChecked(v); } |
247 | int tbpolicy() { return misc->tbpolicy->currentItem(); } | 245 | int tbpolicy() { return misc->tbpolicy->currentItem(); } |
248 | int qtscroll() { return misc->qtscroll->currentItem(); } | 246 | int qtscroll() { return misc->qtscroll->currentItem(); } |
249 | int localscroll() { return misc->localscroll->currentItem(); } | 247 | int localscroll() { return misc->localscroll->currentItem(); } |
250 | #ifdef USECOMBO | 248 | #ifdef USECOMBO |
251 | void tbpolicy(int v) { misc->tbpolicy->setCurrentItem(v); } | 249 | void tbpolicy(int v) { misc->tbpolicy->setCurrentItem(v); } |
252 | void qtscroll(int v) { misc->qtscroll->setCurrentItem(v); } | 250 | void qtscroll(int v) { misc->qtscroll->setCurrentItem(v); } |
253 | void localscroll(int v) { misc->localscroll->setCurrentItem(v); } | 251 | void localscroll(int v) { misc->localscroll->setCurrentItem(v); } |
254 | #else | 252 | #else |
255 | void tbpolicy(int v) { misc->tbpolicy->select(v); } | 253 | void tbpolicy(int v) { misc->tbpolicy->select(v); } |
256 | void qtscroll(int v) { misc->qtscroll->select(v); } | 254 | void qtscroll(int v) { misc->qtscroll->select(v); } |
257 | void localscroll(int v) { misc->localscroll->select(v); } | 255 | void localscroll(int v) { misc->localscroll->select(v); } |
258 | #endif | 256 | #endif |
259 | bool tbmovable() { return misc->tbmovable->isChecked(); } | 257 | bool tbmovable() { return misc->tbmovable->isChecked(); } |
260 | void tbmovable(bool v) { misc->tbmovable->setChecked(v); } | 258 | void tbmovable(bool v) { misc->tbmovable->setChecked(v); } |
261 | int tbposition() { return misc->tbposition->currentItem(); } | 259 | int tbposition() { return misc->tbposition->currentItem(); } |
262 | #ifdef USECOMBO | 260 | #ifdef USECOMBO |
263 | void tbposition(int v) { misc->tbposition->setCurrentItem(v); } | 261 | void tbposition(int v) { misc->tbposition->setCurrentItem(v); } |
264 | #else | 262 | #else |
265 | void tbposition(int v) { misc->tbposition->select(v); } | 263 | void tbposition(int v) { misc->tbposition->select(v); } |
266 | #endif | 264 | #endif |
267 | 265 | ||
268 | }; | 266 | }; |
269 | #endif // CPREFS_H | 267 | #endif // CPREFS_H |
diff --git a/noncore/apps/opie-reader/URLDialog.h b/noncore/apps/opie-reader/URLDialog.h index 1bcc4bd..792d13a 100644 --- a/noncore/apps/opie-reader/URLDialog.h +++ b/noncore/apps/opie-reader/URLDialog.h | |||
@@ -1,65 +1,64 @@ | |||
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 __URLDIALOG_H | 9 | #ifndef __URLDIALOG_H |
10 | #define __URLDIALOG_H | 10 | #define __URLDIALOG_H |
11 | 11 | ||
12 | #include "useqpe.h" | ||
13 | #include <qvariant.h> | 12 | #include <qvariant.h> |
14 | #include <qwidget.h> | 13 | #include <qwidget.h> |
15 | #include <qtabdialog.h> | 14 | #include <qtabdialog.h> |
16 | #include <qtabwidget.h> | 15 | #include <qtabwidget.h> |
17 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
18 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
19 | #include <qcombobox.h> | 18 | #include <qcombobox.h> |
20 | #include <qlineedit.h> | 19 | #include <qlineedit.h> |
21 | //#include <qpe/menubutton.h> | 20 | //#include <qpe/menubutton.h> |
22 | #include <qvbuttongroup.h> | 21 | #include <qvbuttongroup.h> |
23 | 22 | ||
24 | class QVBoxLayout; | 23 | class QVBoxLayout; |
25 | class QHBoxLayout; | 24 | class QHBoxLayout; |
26 | class QGridLayout; | 25 | class QGridLayout; |
27 | //class QCheckBox; | 26 | //class QCheckBox; |
28 | class QLabel; | 27 | class QLabel; |
29 | //class QSpinBox; | 28 | //class QSpinBox; |
30 | 29 | ||
31 | class CURLDialog : public QDialog | 30 | class CURLDialog : public QDialog |
32 | { | 31 | { |
33 | Q_OBJECT | 32 | Q_OBJECT |
34 | QCheckBox *m_localfile, *m_globalfile, *m_clipboard; | 33 | QCheckBox *m_localfile, *m_globalfile, *m_clipboard; |
35 | #ifndef USEQPE | 34 | #ifndef USEQPE |
36 | void keyPressEvent(QKeyEvent* e) | 35 | void keyPressEvent(QKeyEvent* e) |
37 | { | 36 | { |
38 | switch (e->key()) | 37 | switch (e->key()) |
39 | { | 38 | { |
40 | case Key_Escape: | 39 | case Key_Escape: |
41 | e->accept(); | 40 | e->accept(); |
42 | reject(); | 41 | reject(); |
43 | break; | 42 | break; |
44 | case Key_Space: | 43 | case Key_Space: |
45 | case Key_Return: | 44 | case Key_Return: |
46 | e->accept(); | 45 | e->accept(); |
47 | accept(); | 46 | accept(); |
48 | break; | 47 | break; |
49 | default: | 48 | default: |
50 | QWidget::keyPressEvent(e); | 49 | QWidget::keyPressEvent(e); |
51 | } | 50 | } |
52 | } | 51 | } |
53 | #endif | 52 | #endif |
54 | public: | 53 | public: |
55 | CURLDialog(const QString&, bool fs = true, QWidget* parent = 0, const char* name = 0); | 54 | CURLDialog(const QString&, bool fs = true, QWidget* parent = 0, const char* name = 0); |
56 | ~CURLDialog() {} | 55 | ~CURLDialog() {} |
57 | bool clipboard() { return m_clipboard->isChecked(); } | 56 | bool clipboard() { return m_clipboard->isChecked(); } |
58 | bool localfile() { return m_localfile->isChecked(); } | 57 | bool localfile() { return m_localfile->isChecked(); } |
59 | bool globalfile() { return m_globalfile->isChecked(); } | 58 | bool globalfile() { return m_globalfile->isChecked(); } |
60 | void clipboard(bool _b) { m_clipboard->setChecked(_b); } | 59 | void clipboard(bool _b) { m_clipboard->setChecked(_b); } |
61 | void localfile(bool _b) { m_localfile->setChecked(_b); } | 60 | void localfile(bool _b) { m_localfile->setChecked(_b); } |
62 | void globalfile(bool _b) { m_globalfile->setChecked(_b); } | 61 | void globalfile(bool _b) { m_globalfile->setChecked(_b); } |
63 | 62 | ||
64 | }; | 63 | }; |
65 | #endif // CPREFS_H | 64 | #endif // CPREFS_H |
diff --git a/noncore/apps/opie-reader/WeaselCodec/WeaselCodec.pro b/noncore/apps/opie-reader/WeaselCodec/WeaselCodec.pro index 61e7dc9..f20bdc6 100644 --- a/noncore/apps/opie-reader/WeaselCodec/WeaselCodec.pro +++ b/noncore/apps/opie-reader/WeaselCodec/WeaselCodec.pro | |||
@@ -1,17 +1,17 @@ | |||
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 = ztxt.h | 5 | HEADERS = ztxt.h |
6 | 6 | ||
7 | SOURCES = ztxt.cpp | 7 | SOURCES = ztxt.cpp |
8 | 8 | ||
9 | INTERFACES= | 9 | INTERFACES= |
10 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | 10 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs |
11 | TARGET = Weasel | 11 | TARGET = Weasel |
12 | LIBS += -lreader_pdb -lreader_codec | 12 | LIBS += -lreader_pdb -lreader_codec |
13 | 13 | ||
14 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 14 | INCLUDEPATH+= $(OPIEDIR)/include |
15 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 15 | DEPENDPATH+= $(OPIEDIR)/include |
16 | 16 | ||
17 | include ( $(OPIEDIR)/include.pro ) | 17 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/ZText.h b/noncore/apps/opie-reader/ZText.h index 06e3bf8..199c7da 100644 --- a/noncore/apps/opie-reader/ZText.h +++ b/noncore/apps/opie-reader/ZText.h | |||
@@ -1,116 +1,115 @@ | |||
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 | #include "useqpe.h" | ||
7 | #include "CExpander.h" | 6 | #include "CExpander.h" |
8 | 7 | ||
9 | class Text: public CExpander { | 8 | class Text: public CExpander { |
10 | gzFile file; | 9 | gzFile file; |
11 | unsigned long fsize; | 10 | unsigned long fsize; |
12 | public: | 11 | public: |
13 | void suspend() | 12 | void suspend() |
14 | { | 13 | { |
15 | #ifdef USEQPE | 14 | #ifdef USEQPE |
16 | if (!bSuspended) | 15 | if (!bSuspended) |
17 | { | 16 | { |
18 | bSuspended = true; | 17 | bSuspended = true; |
19 | suspos = gztell(file); | 18 | suspos = gztell(file); |
20 | gzclose(file); | 19 | gzclose(file); |
21 | file = NULL; | 20 | file = NULL; |
22 | sustime = time(NULL); | 21 | sustime = time(NULL); |
23 | } | 22 | } |
24 | #endif | 23 | #endif |
25 | } | 24 | } |
26 | void unsuspend() | 25 | void unsuspend() |
27 | { | 26 | { |
28 | #ifdef USEQPE | 27 | #ifdef USEQPE |
29 | if (bSuspended) | 28 | if (bSuspended) |
30 | { | 29 | { |
31 | bSuspended = false; | 30 | bSuspended = false; |
32 | if (sustime != ((time_t)-1)) | 31 | if (sustime != ((time_t)-1)) |
33 | { | 32 | { |
34 | int delay = time(NULL) - sustime; | 33 | int delay = time(NULL) - sustime; |
35 | if (delay < 10) sleep(10-delay); | 34 | if (delay < 10) sleep(10-delay); |
36 | } | 35 | } |
37 | file = gzopen(fname, "rb"); | 36 | file = gzopen(fname, "rb"); |
38 | for (int i = 0; file == NULL && i < 5; i++) | 37 | for (int i = 0; file == NULL && i < 5; i++) |
39 | { | 38 | { |
40 | sleep(5); | 39 | sleep(5); |
41 | file = gzopen(fname, "rb"); | 40 | file = gzopen(fname, "rb"); |
42 | } | 41 | } |
43 | if (file == NULL) | 42 | if (file == NULL) |
44 | { | 43 | { |
45 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); | 44 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); |
46 | exit(0); | 45 | exit(0); |
47 | } | 46 | } |
48 | suspos = gzseek(file, suspos, SEEK_SET); | 47 | suspos = gzseek(file, suspos, SEEK_SET); |
49 | } | 48 | } |
50 | #endif | 49 | #endif |
51 | } | 50 | } |
52 | Text() : file(NULL) {}; | 51 | Text() : file(NULL) {}; |
53 | virtual ~Text() | 52 | virtual ~Text() |
54 | { | 53 | { |
55 | if (file != NULL) | 54 | if (file != NULL) |
56 | { | 55 | { |
57 | #ifdef USEQPE | 56 | #ifdef USEQPE |
58 | unsuspend(); | 57 | unsuspend(); |
59 | #endif | 58 | #endif |
60 | gzclose(file); | 59 | gzclose(file); |
61 | } | 60 | } |
62 | } | 61 | } |
63 | int OpenFile(const char *src) | 62 | int OpenFile(const char *src) |
64 | { | 63 | { |
65 | if (file != NULL) gzclose(file); | 64 | if (file != NULL) gzclose(file); |
66 | struct stat _stat; | 65 | struct stat _stat; |
67 | stat(src,&_stat); | 66 | stat(src,&_stat); |
68 | fsize = _stat.st_size; | 67 | fsize = _stat.st_size; |
69 | return ((file = gzopen(src,"rb")) == NULL); | 68 | return ((file = gzopen(src,"rb")) == NULL); |
70 | } | 69 | } |
71 | int getch() | 70 | int getch() |
72 | { | 71 | { |
73 | #ifdef USEQPE | 72 | #ifdef USEQPE |
74 | unsuspend(); | 73 | unsuspend(); |
75 | #endif | 74 | #endif |
76 | return gzgetc(file); | 75 | return gzgetc(file); |
77 | } | 76 | } |
78 | unsigned int locate() | 77 | unsigned int locate() |
79 | { | 78 | { |
80 | #ifdef USEQPE | 79 | #ifdef USEQPE |
81 | unsuspend(); | 80 | unsuspend(); |
82 | #endif | 81 | #endif |
83 | return gztell(file); | 82 | return gztell(file); |
84 | } | 83 | } |
85 | void locate(unsigned int n) | 84 | void locate(unsigned int n) |
86 | { | 85 | { |
87 | #ifdef USEQPE | 86 | #ifdef USEQPE |
88 | unsuspend(); | 87 | unsuspend(); |
89 | #endif | 88 | #endif |
90 | gzseek(file,n,SEEK_SET); | 89 | gzseek(file,n,SEEK_SET); |
91 | } | 90 | } |
92 | bool hasrandomaccess() { return true; } | 91 | bool hasrandomaccess() { return true; } |
93 | void sizes(unsigned long& _file, unsigned long& _text) | 92 | void sizes(unsigned long& _file, unsigned long& _text) |
94 | { | 93 | { |
95 | _text = _file = fsize; | 94 | _text = _file = fsize; |
96 | FILE* f = fopen(fname, "rb"); | 95 | FILE* f = fopen(fname, "rb"); |
97 | if (f != NULL) | 96 | if (f != NULL) |
98 | { | 97 | { |
99 | unsigned char mn[2]; | 98 | unsigned char mn[2]; |
100 | fread(mn, 1, 2, f); | 99 | fread(mn, 1, 2, f); |
101 | if ((mn[0] == 31) && (mn[1] == 139)) | 100 | if ((mn[0] == 31) && (mn[1] == 139)) |
102 | { | 101 | { |
103 | int tmp = sizeof(_text); | 102 | int tmp = sizeof(_text); |
104 | fseek(f,-tmp,SEEK_END); | 103 | fseek(f,-tmp,SEEK_END); |
105 | fread(&_text, sizeof(_text), 1, f); | 104 | fread(&_text, sizeof(_text), 1, f); |
106 | } | 105 | } |
107 | fclose(f); | 106 | fclose(f); |
108 | } | 107 | } |
109 | } | 108 | } |
110 | MarkupType PreferredMarkup() | 109 | MarkupType PreferredMarkup() |
111 | { | 110 | { |
112 | return cTEXT; | 111 | return cTEXT; |
113 | } | 112 | } |
114 | QString about() { return QString("Text/gzipped text codec (c) Tim Wentford"); } | 113 | QString about() { return QString("Text/gzipped text codec (c) Tim Wentford"); } |
115 | }; | 114 | }; |
116 | #endif | 115 | #endif |
diff --git a/noncore/apps/opie-reader/codeclib/codeclib.pro b/noncore/apps/opie-reader/codeclib/codeclib.pro index 6adcda8..c24767b 100644 --- a/noncore/apps/opie-reader/codeclib/codeclib.pro +++ b/noncore/apps/opie-reader/codeclib/codeclib.pro | |||
@@ -1,17 +1,17 @@ | |||
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 | 6 | ||
7 | SOURCES = CExpander.cpp CBuffer.cpp StyleConsts.cpp \ | 7 | SOURCES = CExpander.cpp CBuffer.cpp StyleConsts.cpp \ |
8 | hrule.cpp Navigation.cpp Bkmks.cpp | 8 | hrule.cpp Navigation.cpp Bkmks.cpp |
9 | 9 | ||
10 | INTERFACES= | 10 | INTERFACES= |
11 | DESTDIR = $(OPIEDIR)/lib | 11 | DESTDIR = $(OPIEDIR)/lib |
12 | TARGET = reader_codec | 12 | TARGET = reader_codec |
13 | 13 | ||
14 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 14 | INCLUDEPATH+= $(OPIEDIR)/include |
15 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 15 | DEPENDPATH+= $(OPIEDIR)/include |
16 | 16 | ||
17 | include ( $(OPIEDIR)/include.pro ) | 17 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/ebookcodec.h b/noncore/apps/opie-reader/ebookcodec.h index b341e55..f6e2daf 100644 --- a/noncore/apps/opie-reader/ebookcodec.h +++ b/noncore/apps/opie-reader/ebookcodec.h | |||
@@ -1,120 +1,118 @@ | |||
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 | #include "useqpe.h" | ||
7 | #ifdef USEQPE | 6 | #ifdef USEQPE |
8 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
9 | #endif | 8 | #endif |
10 | 9 | ||
11 | #include "util.h" | 10 | #include "util.h" |
12 | 11 | ||
13 | #include "static.h" | ||
14 | #ifndef __STATIC | 12 | #ifndef __STATIC |
15 | #include <dlfcn.h> | 13 | #include <dlfcn.h> |
16 | class ebookcodec : public CExpander_Interface | 14 | class ebookcodec : public CExpander_Interface |
17 | { | 15 | { |
18 | CExpander *codec; | 16 | CExpander *codec; |
19 | void *handle; | 17 | void *handle; |
20 | int status; | 18 | int status; |
21 | public: | 19 | public: |
22 | QString about() | 20 | QString about() |
23 | { | 21 | { |
24 | return QString("Plug-in ebook codec interface (c) Tim Wentford\n")+codec->about(); | 22 | return QString("Plug-in ebook codec interface (c) Tim Wentford\n")+codec->about(); |
25 | } | 23 | } |
26 | ebookcodec(const QString& _s) : codec(NULL), handle(NULL), status(0) | 24 | ebookcodec(const QString& _s) : codec(NULL), handle(NULL), status(0) |
27 | { | 25 | { |
28 | QString codecpath(QTReaderUtil::getPluginPath()); | 26 | QString codecpath(QTReaderUtil::getPluginPath()); |
29 | codecpath += _s; | 27 | codecpath += _s; |
30 | if (QFile::exists(codecpath)) | 28 | if (QFile::exists(codecpath)) |
31 | { | 29 | { |
32 | qDebug("Codec:%s", (const char*)codecpath); | 30 | qDebug("Codec:%s", (const char*)codecpath); |
33 | handle = dlopen(codecpath, RTLD_LAZY); | 31 | handle = dlopen(codecpath, RTLD_LAZY); |
34 | if (handle == 0) | 32 | if (handle == 0) |
35 | { | 33 | { |
36 | /* | 34 | /* |
37 | QString wrn(dlerror()); | 35 | QString wrn(dlerror()); |
38 | QString fmt; | 36 | QString fmt; |
39 | while (wrn.length() > 10) | 37 | while (wrn.length() > 10) |
40 | { | 38 | { |
41 | fmt += wrn.left(10); | 39 | fmt += wrn.left(10); |
42 | fmt += '\n'; | 40 | fmt += '\n'; |
43 | wrn = wrn.right(wrn.length()-10); | 41 | wrn = wrn.right(wrn.length()-10); |
44 | } | 42 | } |
45 | fmt += wrn; | 43 | fmt += wrn; |
46 | QMessageBox::warning(NULL, PROGNAME, fmt); | 44 | QMessageBox::warning(NULL, PROGNAME, fmt); |
47 | */ | 45 | */ |
48 | qDebug("Can't find codec:%s", dlerror()); | 46 | qDebug("Can't find codec:%s", dlerror()); |
49 | status = -10; | 47 | status = -10; |
50 | return; | 48 | return; |
51 | } | 49 | } |
52 | CExpander* (*newcodec)(); | 50 | CExpander* (*newcodec)(); |
53 | newcodec = (CExpander* (*)())dlsym(handle, "newcodec"); | 51 | newcodec = (CExpander* (*)())dlsym(handle, "newcodec"); |
54 | if (newcodec == NULL) | 52 | if (newcodec == NULL) |
55 | { | 53 | { |
56 | qDebug("Can't find newcodec"); | 54 | qDebug("Can't find newcodec"); |
57 | status = -20; | 55 | status = -20; |
58 | return; | 56 | return; |
59 | } | 57 | } |
60 | codec = (*newcodec)(); | 58 | codec = (*newcodec)(); |
61 | } | 59 | } |
62 | else | 60 | else |
63 | { | 61 | { |
64 | qDebug("Can't find codec"); | 62 | qDebug("Can't find codec"); |
65 | } | 63 | } |
66 | if (codec == NULL) | 64 | if (codec == NULL) |
67 | { | 65 | { |
68 | qDebug("Can't do newcodec"); | 66 | qDebug("Can't do newcodec"); |
69 | status = -30; | 67 | status = -30; |
70 | return; | 68 | return; |
71 | } | 69 | } |
72 | } | 70 | } |
73 | virtual ~ebookcodec() | 71 | virtual ~ebookcodec() |
74 | { | 72 | { |
75 | if (codec != NULL) delete codec; | 73 | if (codec != NULL) delete codec; |
76 | if (handle != NULL) dlclose(handle); | 74 | if (handle != NULL) dlclose(handle); |
77 | } | 75 | } |
78 | size_t getHome() { return codec->getHome(); } | 76 | size_t getHome() { return codec->getHome(); } |
79 | #ifdef USEQPE | 77 | #ifdef USEQPE |
80 | void suspend() { codec->suspend(); } | 78 | void suspend() { codec->suspend(); } |
81 | void unsuspend() { codec->unsuspend(); } | 79 | void unsuspend() { codec->unsuspend(); } |
82 | void suspend(FILE*& fin) { codec->suspend(fin); } | 80 | void suspend(FILE*& fin) { codec->suspend(fin); } |
83 | void unsuspend(FILE*& fin) { codec->unsuspend(fin); } | 81 | void unsuspend(FILE*& fin) { codec->unsuspend(fin); } |
84 | #endif | 82 | #endif |
85 | unsigned int locate() { return codec->locate(); } | 83 | unsigned int locate() { return codec->locate(); } |
86 | void locate(unsigned int n) { codec->locate(n); } | 84 | void locate(unsigned int n) { codec->locate(n); } |
87 | bool hasrandomaccess() { return codec->hasrandomaccess(); } | 85 | bool hasrandomaccess() { return codec->hasrandomaccess(); } |
88 | void sizes(unsigned long& file, unsigned long& text) | 86 | void sizes(unsigned long& file, unsigned long& text) |
89 | { | 87 | { |
90 | codec->sizes(file, text); | 88 | codec->sizes(file, text); |
91 | //qDebug("Codec sizes:(%u, %u)", file, text); | 89 | //qDebug("Codec sizes:(%u, %u)", file, text); |
92 | } | 90 | } |
93 | CList<Bkmk>* getbkmklist() { return codec->getbkmklist(); } | 91 | CList<Bkmk>* getbkmklist() { return codec->getbkmklist(); } |
94 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) { codec->getch(ch, sty, pos); } | 92 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) { codec->getch(ch, sty, pos); } |
95 | int getch() { return codec->getch(); } | 93 | int getch() { return codec->getch(); } |
96 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) { return codec->hyperlink(n, noff, wrd, nm); } | 94 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) { return codec->hyperlink(n, noff, wrd, nm); } |
97 | MarkupType PreferredMarkup() { return codec->PreferredMarkup(); } | 95 | MarkupType PreferredMarkup() { return codec->PreferredMarkup(); } |
98 | void saveposn(size_t posn) { codec->saveposn(posn); } | 96 | void saveposn(size_t posn) { codec->saveposn(posn); } |
99 | void writeposn(size_t posn) { codec->writeposn(posn); } | 97 | void writeposn(size_t posn) { codec->writeposn(posn); } |
100 | linkType forward(size_t& loc) { return codec->forward(loc); } | 98 | linkType forward(size_t& loc) { return codec->forward(loc); } |
101 | linkType back(size_t& loc) { return codec->back(loc); } | 99 | linkType back(size_t& loc) { return codec->back(loc); } |
102 | bool hasnavigation() { return codec->hasnavigation(); } | 100 | bool hasnavigation() { return codec->hasnavigation(); } |
103 | void start2endSection() { codec->start2endSection(); } | 101 | void start2endSection() { codec->start2endSection(); } |
104 | QImage* getPicture(unsigned long tgt) { return codec->getPicture(tgt); } | 102 | QImage* getPicture(unsigned long tgt) { return codec->getPicture(tgt); } |
105 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) { return codec->setSaveData(data, len, src, srclen); } | 103 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) { return codec->setSaveData(data, len, src, srclen); } |
106 | void putSaveData(unsigned char*& src, unsigned short& srclen) { codec->putSaveData(src, srclen); } | 104 | void putSaveData(unsigned char*& src, unsigned short& srclen) { codec->putSaveData(src, srclen); } |
107 | void setContinuous(bool _b) { codec->setContinuous(_b); } | 105 | void setContinuous(bool _b) { codec->setContinuous(_b); } |
108 | void setwidth(int w) { codec->setwidth(w); } | 106 | void setwidth(int w) { codec->setwidth(w); } |
109 | unsigned long startSection() { return codec->startSection(); } | 107 | unsigned long startSection() { return codec->startSection(); } |
110 | unsigned long endSection() { return codec->endSection(); } | 108 | unsigned long endSection() { return codec->endSection(); } |
111 | int openfile(const char *src) | 109 | int openfile(const char *src) |
112 | { | 110 | { |
113 | //qDebug("ebook openfile:%s", src); | 111 | //qDebug("ebook openfile:%s", src); |
114 | return (status != 0) ? status : codec->openfile(src); | 112 | return (status != 0) ? status : codec->openfile(src); |
115 | } | 113 | } |
116 | int getwidth() { return codec->getwidth(); } | 114 | int getwidth() { return codec->getwidth(); } |
117 | QImage* getPicture(const QString& href) { return codec->getPicture(href); } | 115 | QImage* getPicture(const QString& href) { return codec->getPicture(href); } |
118 | bool getFile(const QString& href) { return codec->getFile(href); } | 116 | bool getFile(const QString& href) { return codec->getFile(href); } |
119 | }; | 117 | }; |
120 | #endif | 118 | #endif |
diff --git a/noncore/apps/opie-reader/iSiloCodec/iSiloCodec.pro b/noncore/apps/opie-reader/iSiloCodec/iSiloCodec.pro index 78d5a49..5cf075e 100644 --- a/noncore/apps/opie-reader/iSiloCodec/iSiloCodec.pro +++ b/noncore/apps/opie-reader/iSiloCodec/iSiloCodec.pro | |||
@@ -1,19 +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 = Aportis.h | 5 | #HEADERS = Aportis.h |
6 | 6 | ||
7 | SOURCES = iSilo.cpp | 7 | SOURCES = iSilo.cpp |
8 | 8 | ||
9 | 9 | ||
10 | INTERFACES= | 10 | INTERFACES= |
11 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | 11 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs |
12 | TARGET = iSilo | 12 | TARGET = iSilo |
13 | LIBS += -lreader_pdb -lreader_codec | 13 | LIBS += -lreader_pdb -lreader_codec |
14 | 14 | ||
15 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 15 | INCLUDEPATH+= $(OPIEDIR)/include |
16 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 16 | DEPENDPATH+= $(OPIEDIR)/include |
17 | 17 | ||
18 | include ( $(OPIEDIR)/include.pro ) | 18 | include ( $(OPIEDIR)/include.pro ) |
19 | 19 | ||
diff --git a/noncore/apps/opie-reader/main.cpp b/noncore/apps/opie-reader/main.cpp index 3e1f5e7..af276da 100644 --- a/noncore/apps/opie-reader/main.cpp +++ b/noncore/apps/opie-reader/main.cpp | |||
@@ -1,50 +1,49 @@ | |||
1 | #include "useqpe.h" | ||
2 | #ifdef USEQPE | 1 | #ifdef USEQPE |
3 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
4 | #else | 3 | #else |
5 | #include <qapplication.h> | 4 | #include <qapplication.h> |
6 | #endif | 5 | #endif |
7 | #include "QTReaderApp.h" | 6 | #include "QTReaderApp.h" |
8 | 7 | ||
9 | #include "signal.h" | 8 | #include "signal.h" |
10 | #include "stdio.h" | 9 | #include "stdio.h" |
11 | #include "time.h" | 10 | #include "time.h" |
12 | 11 | ||
13 | 12 | ||
14 | #ifdef USEQPE | 13 | #ifdef USEQPE |
15 | QTReaderApp* app = NULL; | 14 | QTReaderApp* app = NULL; |
16 | 15 | ||
17 | void handler(int signum) | 16 | void handler(int signum) |
18 | { | 17 | { |
19 | if (app != NULL) | 18 | if (app != NULL) |
20 | { | 19 | { |
21 | app->suspend(); | 20 | app->suspend(); |
22 | app->saveprefs(); | 21 | app->saveprefs(); |
23 | } | 22 | } |
24 | signal(signum, handler); | 23 | signal(signum, handler); |
25 | } | 24 | } |
26 | #endif | 25 | #endif |
27 | 26 | ||
28 | int main( int argc, char ** argv ) | 27 | int main( int argc, char ** argv ) |
29 | { | 28 | { |
30 | 29 | ||
31 | #ifdef USEQPE | 30 | #ifdef USEQPE |
32 | signal(SIGCONT, handler); | 31 | signal(SIGCONT, handler); |
33 | QPEApplication a( argc, argv ); | 32 | QPEApplication a( argc, argv ); |
34 | QTReaderApp m; | 33 | QTReaderApp m; |
35 | a.showMainDocumentWidget( &m ); | 34 | a.showMainDocumentWidget( &m ); |
36 | app = &m; | 35 | app = &m; |
37 | #else | 36 | #else |
38 | QApplication a( argc, argv ); | 37 | QApplication a( argc, argv ); |
39 | QTReaderApp m; | 38 | QTReaderApp m; |
40 | a.setMainWidget( &m ); | 39 | a.setMainWidget( &m ); |
41 | if (argc > 1) | 40 | if (argc > 1) |
42 | { | 41 | { |
43 | m.setDocument(argv[1]); | 42 | m.setDocument(argv[1]); |
44 | } | 43 | } |
45 | #endif | 44 | #endif |
46 | 45 | ||
47 | 46 | ||
48 | return a.exec(); | 47 | return a.exec(); |
49 | } | 48 | } |
50 | 49 | ||
diff --git a/noncore/apps/opie-reader/pdb.cpp b/noncore/apps/opie-reader/pdb.cpp index 39551cc..6719af4 100644 --- a/noncore/apps/opie-reader/pdb.cpp +++ b/noncore/apps/opie-reader/pdb.cpp | |||
@@ -1,90 +1,89 @@ | |||
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 | #include "useqpe.h" | ||
7 | 6 | ||
8 | #ifdef USEQPE | 7 | #ifdef USEQPE |
9 | void Cpdb::suspend() | 8 | void Cpdb::suspend() |
10 | { | 9 | { |
11 | CExpander::suspend(fin); | 10 | CExpander::suspend(fin); |
12 | } | 11 | } |
13 | void Cpdb::unsuspend() | 12 | void Cpdb::unsuspend() |
14 | { | 13 | { |
15 | CExpander::unsuspend(fin); | 14 | CExpander::unsuspend(fin); |
16 | } | 15 | } |
17 | #endif | 16 | #endif |
18 | 17 | ||
19 | Cpdb::~Cpdb() | 18 | Cpdb::~Cpdb() |
20 | { | 19 | { |
21 | if (fin != NULL) | 20 | if (fin != NULL) |
22 | { | 21 | { |
23 | #ifdef USEQPE | 22 | #ifdef USEQPE |
24 | unsuspend(); | 23 | unsuspend(); |
25 | #endif | 24 | #endif |
26 | fclose(fin); | 25 | fclose(fin); |
27 | } | 26 | } |
28 | } | 27 | } |
29 | 28 | ||
30 | size_t Cpdb::recordpos(int n) | 29 | size_t Cpdb::recordpos(int n) |
31 | { | 30 | { |
32 | UInt16 mxn = ntohs(head.recordList.numRecords); | 31 | UInt16 mxn = ntohs(head.recordList.numRecords); |
33 | if (n >= mxn) | 32 | if (n >= mxn) |
34 | { | 33 | { |
35 | return file_length; | 34 | return file_length; |
36 | } | 35 | } |
37 | else | 36 | else |
38 | { | 37 | { |
39 | size_t dataoffset = sizeof(DatabaseHdrType) - sizeof(UInt16); | 38 | size_t dataoffset = sizeof(DatabaseHdrType) - sizeof(UInt16); |
40 | dataoffset += /*dataoffset%4 + */ sizeof(RecordListType) * n; | 39 | dataoffset += /*dataoffset%4 + */ sizeof(RecordListType) * n; |
41 | fseek(fin, dataoffset, SEEK_SET); | 40 | fseek(fin, dataoffset, SEEK_SET); |
42 | RecordListType hdr; | 41 | RecordListType hdr; |
43 | fread(&hdr, 1, sizeof(hdr), fin); | 42 | fread(&hdr, 1, sizeof(hdr), fin); |
44 | return ntohl(hdr.nextRecordListID); | 43 | return ntohl(hdr.nextRecordListID); |
45 | } | 44 | } |
46 | 45 | ||
47 | } | 46 | } |
48 | 47 | ||
49 | size_t Cpdb::recordlength(int n) | 48 | size_t Cpdb::recordlength(int n) |
50 | { | 49 | { |
51 | return recordpos(n+1)-recordpos(n); | 50 | return recordpos(n+1)-recordpos(n); |
52 | } | 51 | } |
53 | 52 | ||
54 | void Cpdb::gotorecordnumber(int n) | 53 | void Cpdb::gotorecordnumber(int n) |
55 | { | 54 | { |
56 | fseek(fin, recordpos(n), SEEK_SET); | 55 | fseek(fin, recordpos(n), SEEK_SET); |
57 | } | 56 | } |
58 | 57 | ||
59 | bool Cpdb::openpdbfile(const char *src) | 58 | bool Cpdb::openpdbfile(const char *src) |
60 | { | 59 | { |
61 | //qDebug("cpdb openfile:%s", src); | 60 | //qDebug("cpdb openfile:%s", src); |
62 | 61 | ||
63 | // printf("In openfile\n"); | 62 | // printf("In openfile\n"); |
64 | // printf("closing fin:%x\n",fin); | 63 | // printf("closing fin:%x\n",fin); |
65 | if (fin != NULL) fclose(fin); | 64 | if (fin != NULL) fclose(fin); |
66 | // printf("opening fin\n"); | 65 | // printf("opening fin\n"); |
67 | fin = fopen(src,"rb"); | 66 | fin = fopen(src,"rb"); |
68 | 67 | ||
69 | if (fin==0) | 68 | if (fin==0) |
70 | { | 69 | { |
71 | return false; | 70 | return false; |
72 | } | 71 | } |
73 | 72 | ||
74 | // just holds the first few chars of the file | 73 | // just holds the first few chars of the file |
75 | //char buf[0x100]; | 74 | //char buf[0x100]; |
76 | struct stat _stat; | 75 | struct stat _stat; |
77 | stat(src,&_stat); | 76 | stat(src,&_stat); |
78 | file_length = _stat.st_size; | 77 | file_length = _stat.st_size; |
79 | // fseek(fin,0,SEEK_END); | 78 | // fseek(fin,0,SEEK_END); |
80 | // file_length = ftell(fin); | 79 | // file_length = ftell(fin); |
81 | 80 | ||
82 | fseek(fin,0,SEEK_SET); | 81 | fseek(fin,0,SEEK_SET); |
83 | 82 | ||
84 | fread(&head, 1, sizeof(head), fin); | 83 | fread(&head, 1, sizeof(head), fin); |
85 | 84 | ||
86 | qDebug("Database name:%s", head.name); | 85 | qDebug("Database name:%s", head.name); |
87 | qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); | 86 | qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); |
88 | 87 | ||
89 | return true; | 88 | return true; |
90 | } | 89 | } |
diff --git a/noncore/apps/opie-reader/pdb.h b/noncore/apps/opie-reader/pdb.h index 7a6580d..7458919 100644 --- a/noncore/apps/opie-reader/pdb.h +++ b/noncore/apps/opie-reader/pdb.h | |||
@@ -1,101 +1,100 @@ | |||
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 | #include "useqpe.h" | ||
19 | #include "CExpander.h" | 18 | #include "CExpander.h" |
20 | 19 | ||
21 | /* Normal Palm typedefs */ | 20 | /* Normal Palm typedefs */ |
22 | typedef unsigned char UInt8; | 21 | typedef unsigned char UInt8; |
23 | typedef unsigned short UInt16; | 22 | typedef unsigned short UInt16; |
24 | typedef signed short Int16; | 23 | typedef signed short Int16; |
25 | typedef unsigned long UInt32; | 24 | typedef unsigned long UInt32; |
26 | typedef UInt32 LocalID; | 25 | typedef UInt32 LocalID; |
27 | 26 | ||
28 | /* Max length of DB name */ | 27 | /* Max length of DB name */ |
29 | #define dmDBNameLength 0x20 | 28 | #define dmDBNameLength 0x20 |
30 | 29 | ||
31 | 30 | ||
32 | /************************************************************ | 31 | /************************************************************ |
33 | * Structure of a Record entry | 32 | * Structure of a Record entry |
34 | *************************************************************/ | 33 | *************************************************************/ |
35 | typedef struct { | 34 | typedef struct { |
36 | LocalID localChunkID; // local chunkID of a record | 35 | LocalID localChunkID; // local chunkID of a record |
37 | UInt8 attributes; // record attributes; | 36 | UInt8 attributes; // record attributes; |
38 | UInt8 uniqueID[3]; // unique ID of record; should | 37 | UInt8 uniqueID[3]; // unique ID of record; should |
39 | // not be 0 for a legal record. | 38 | // not be 0 for a legal record. |
40 | } RecordEntryType; | 39 | } RecordEntryType; |
41 | 40 | ||
42 | 41 | ||
43 | /************************************************************ | 42 | /************************************************************ |
44 | * Structure of a record list extension. This is used if all | 43 | * Structure of a record list extension. This is used if all |
45 | * the database record/resource entries of a database can't fit into | 44 | * the database record/resource entries of a database can't fit into |
46 | * the database header. | 45 | * the database header. |
47 | *************************************************************/ | 46 | *************************************************************/ |
48 | typedef struct { | 47 | typedef struct { |
49 | LocalID nextRecordListID; // local chunkID of next list | 48 | LocalID nextRecordListID; // local chunkID of next list |
50 | UInt16 numRecords; // number of records in this list | 49 | UInt16 numRecords; // number of records in this list |
51 | UInt16 firstEntry; // array of Record/Rsrc entries | 50 | UInt16 firstEntry; // array of Record/Rsrc entries |
52 | // starts here | 51 | // starts here |
53 | } RecordListType; | 52 | } RecordListType; |
54 | 53 | ||
55 | 54 | ||
56 | /************************************************************ | 55 | /************************************************************ |
57 | * Structure of a Database Header | 56 | * Structure of a Database Header |
58 | *************************************************************/ | 57 | *************************************************************/ |
59 | typedef struct { | 58 | typedef struct { |
60 | UInt8 name[dmDBNameLength]; // name of database | 59 | UInt8 name[dmDBNameLength]; // name of database |
61 | UInt16 attributes; // database attributes | 60 | UInt16 attributes; // database attributes |
62 | UInt16 version; // version of database | 61 | UInt16 version; // version of database |
63 | UInt32 creationDate; // creation date of database | 62 | UInt32 creationDate; // creation date of database |
64 | UInt32 modificationDate; // latest modification date | 63 | UInt32 modificationDate; // latest modification date |
65 | UInt32 lastBackupDate; // latest backup date | 64 | UInt32 lastBackupDate; // latest backup date |
66 | UInt32 modificationNumber; // modification number of database | 65 | UInt32 modificationNumber; // modification number of database |
67 | LocalID appInfoID; // application specific info | 66 | LocalID appInfoID; // application specific info |
68 | LocalID sortInfoID; // app specific sorting info | 67 | LocalID sortInfoID; // app specific sorting info |
69 | UInt32 type; // database type | 68 | UInt32 type; // database type |
70 | UInt32 creator; // database creator | 69 | UInt32 creator; // database creator |
71 | UInt32 uniqueIDSeed; // used to generate unique IDs. | 70 | UInt32 uniqueIDSeed; // used to generate unique IDs. |
72 | // Note that only the low order | 71 | // Note that only the low order |
73 | // 3 bytes of this is used (in | 72 | // 3 bytes of this is used (in |
74 | // RecordEntryType.uniqueID). | 73 | // RecordEntryType.uniqueID). |
75 | // We are keeping 4 bytes for | 74 | // We are keeping 4 bytes for |
76 | // alignment purposes. | 75 | // alignment purposes. |
77 | RecordListType recordList; // first record list | 76 | RecordListType recordList; // first record list |
78 | } DatabaseHdrType; | 77 | } DatabaseHdrType; |
79 | 78 | ||
80 | 79 | ||
81 | class Cpdb : public CExpander | 80 | class Cpdb : public CExpander |
82 | { | 81 | { |
83 | protected: | 82 | protected: |
84 | size_t file_length; | 83 | size_t file_length; |
85 | FILE* fin; | 84 | FILE* fin; |
86 | size_t recordpos(int); | 85 | size_t recordpos(int); |
87 | size_t recordlength(int); | 86 | size_t recordlength(int); |
88 | void gotorecordnumber(int); | 87 | void gotorecordnumber(int); |
89 | DatabaseHdrType head; | 88 | DatabaseHdrType head; |
90 | bool openpdbfile(const char* src); | 89 | bool openpdbfile(const char* src); |
91 | Cpdb() : fin(NULL) {} | 90 | Cpdb() : fin(NULL) {} |
92 | ~Cpdb(); | 91 | ~Cpdb(); |
93 | #ifdef USEQPE | 92 | #ifdef USEQPE |
94 | void suspend(); | 93 | void suspend(); |
95 | void unsuspend(); | 94 | void unsuspend(); |
96 | #endif | 95 | #endif |
97 | public: | 96 | public: |
98 | virtual void sizes(unsigned long& _file, unsigned long& _text) = 0; | 97 | virtual void sizes(unsigned long& _file, unsigned long& _text) = 0; |
99 | }; | 98 | }; |
100 | #endif | 99 | #endif |
101 | 100 | ||
diff --git a/noncore/apps/opie-reader/pdblib/pdblib.pro b/noncore/apps/opie-reader/pdblib/pdblib.pro index cb861a8..830d988 100644 --- a/noncore/apps/opie-reader/pdblib/pdblib.pro +++ b/noncore/apps/opie-reader/pdblib/pdblib.pro | |||
@@ -1,16 +1,16 @@ | |||
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 | 6 | ||
7 | SOURCES = pdb.cpp | 7 | SOURCES = pdb.cpp |
8 | 8 | ||
9 | INTERFACES= | 9 | INTERFACES= |
10 | DESTDIR = $(OPIEDIR)/lib | 10 | DESTDIR = $(OPIEDIR)/lib |
11 | TARGET = reader_pdb | 11 | TARGET = reader_pdb |
12 | 12 | ||
13 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 13 | INCLUDEPATH+= $(OPIEDIR)/include |
14 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 14 | DEPENDPATH+= $(OPIEDIR)/include |
15 | 15 | ||
16 | include ( $(OPIEDIR)/include.pro ) | 16 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/plucker.cpp b/noncore/apps/opie-reader/plucker.cpp index d1ccd6f..4ea807a 100644 --- a/noncore/apps/opie-reader/plucker.cpp +++ b/noncore/apps/opie-reader/plucker.cpp | |||
@@ -1,231 +1,229 @@ | |||
1 | #include "useqpe.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 | 7 | #endif |
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 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
15 | #else | 14 | #else |
16 | #include <qapplication.h> | 15 | #include <qapplication.h> |
17 | #endif | 16 | #endif |
18 | #include <qclipboard.h> | 17 | #include <qclipboard.h> |
19 | 18 | ||
20 | #include "plucker.h" | 19 | #include "plucker.h" |
21 | #include "Aportis.h" | 20 | #include "Aportis.h" |
22 | #include "Palm2QImage.h" | 21 | #include "Palm2QImage.h" |
23 | #include "static.h" | ||
24 | 22 | ||
25 | 23 | ||
26 | struct CPlucker_dataRecord | 24 | struct CPlucker_dataRecord |
27 | { | 25 | { |
28 | UInt16 uid; | 26 | UInt16 uid; |
29 | UInt16 nParagraphs; | 27 | UInt16 nParagraphs; |
30 | UInt16 size; | 28 | UInt16 size; |
31 | UInt8 type; | 29 | UInt8 type; |
32 | UInt8 reserved; | 30 | UInt8 reserved; |
33 | }; | 31 | }; |
34 | 32 | ||
35 | int CPlucker::HeaderSize() | 33 | int CPlucker::HeaderSize() |
36 | { | 34 | { |
37 | return sizeof(CPlucker_dataRecord); | 35 | return sizeof(CPlucker_dataRecord); |
38 | } | 36 | } |
39 | 37 | ||
40 | void CPlucker::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved) | 38 | void CPlucker::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved) |
41 | { | 39 | { |
42 | CPlucker_dataRecord thishdr; | 40 | CPlucker_dataRecord thishdr; |
43 | fread(&thishdr, 1, HeaderSize(), fin); | 41 | fread(&thishdr, 1, HeaderSize(), fin); |
44 | uid = ntohs(thishdr.uid); | 42 | uid = ntohs(thishdr.uid); |
45 | nParagraphs = ntohs(thishdr.nParagraphs); | 43 | nParagraphs = ntohs(thishdr.nParagraphs); |
46 | size = ntohs(thishdr.size); | 44 | size = ntohs(thishdr.size); |
47 | type = thishdr.type; | 45 | type = thishdr.type; |
48 | reserved = thishdr.reserved; | 46 | reserved = thishdr.reserved; |
49 | } | 47 | } |
50 | 48 | ||
51 | CPlucker::CPlucker() | 49 | CPlucker::CPlucker() |
52 | { /*printf("constructing:%x\n",fin);*/ | 50 | { /*printf("constructing:%x\n",fin);*/ |
53 | EOPPhase = 0; | 51 | EOPPhase = 0; |
54 | } | 52 | } |
55 | 53 | ||
56 | bool CPlucker::CorrectDecoder() | 54 | bool CPlucker::CorrectDecoder() |
57 | { | 55 | { |
58 | return (memcmp(&head.type, "DataPlkr", 8) == 0); | 56 | return (memcmp(&head.type, "DataPlkr", 8) == 0); |
59 | } | 57 | } |
60 | 58 | ||
61 | int CPlucker::bgetch() | 59 | int CPlucker::bgetch() |
62 | { | 60 | { |
63 | int ch = EOF; | 61 | int ch = EOF; |
64 | if (bufferpos >= buffercontent) | 62 | if (bufferpos >= buffercontent) |
65 | { | 63 | { |
66 | if (isEndOfSection(bufferrec)) | 64 | if (isEndOfSection(bufferrec)) |
67 | { | 65 | { |
68 | if (!m_continuous) return EOF; | 66 | if (!m_continuous) return EOF; |
69 | } | 67 | } |
70 | if (bufferrec >= ntohs(head.recordList.numRecords) - 1) | 68 | if (bufferrec >= ntohs(head.recordList.numRecords) - 1) |
71 | { | 69 | { |
72 | return EOF; | 70 | return EOF; |
73 | } | 71 | } |
74 | if (!expand(bufferrec+1)) | 72 | if (!expand(bufferrec+1)) |
75 | { | 73 | { |
76 | return EOF; | 74 | return EOF; |
77 | } | 75 | } |
78 | mystyle.unset(); | 76 | mystyle.unset(); |
79 | if (m_ParaOffsets[m_nextParaIndex] == 0) | 77 | if (m_ParaOffsets[m_nextParaIndex] == 0) |
80 | { | 78 | { |
81 | while (m_ParaOffsets[m_nextParaIndex+1] == 0) | 79 | while (m_ParaOffsets[m_nextParaIndex+1] == 0) |
82 | { | 80 | { |
83 | // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); | 81 | // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
84 | m_nextParaIndex++; | 82 | m_nextParaIndex++; |
85 | } | 83 | } |
86 | } | 84 | } |
87 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); | 85 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); |
88 | //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); | 86 | //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
89 | ch = 10; | 87 | ch = 10; |
90 | if (m_continuous) EOPPhase = 4; | 88 | if (m_continuous) EOPPhase = 4; |
91 | } | 89 | } |
92 | else if (bufferpos == m_nextPara) | 90 | else if (bufferpos == m_nextPara) |
93 | { | 91 | { |
94 | while (bufferpos == m_nextPara) | 92 | while (bufferpos == m_nextPara) |
95 | { | 93 | { |
96 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; | 94 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; |
97 | m_nextParaIndex++; | 95 | m_nextParaIndex++; |
98 | // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); | 96 | // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
99 | if (m_nextParaIndex == m_nParas) | 97 | if (m_nextParaIndex == m_nParas) |
100 | { | 98 | { |
101 | m_nextPara = -1; | 99 | m_nextPara = -1; |
102 | } | 100 | } |
103 | else | 101 | else |
104 | { | 102 | { |
105 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | 103 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; |
106 | } | 104 | } |
107 | } | 105 | } |
108 | mystyle.unset(); | 106 | mystyle.unset(); |
109 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); | 107 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); |
110 | //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); | 108 | //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
111 | if (m_lastBreak == locate()) | 109 | if (m_lastBreak == locate()) |
112 | { | 110 | { |
113 | currentpos++; | 111 | currentpos++; |
114 | ch = expandedtextbuffer[bufferpos++]; | 112 | ch = expandedtextbuffer[bufferpos++]; |
115 | } | 113 | } |
116 | else | 114 | else |
117 | { | 115 | { |
118 | ch = 10; | 116 | ch = 10; |
119 | } | 117 | } |
120 | } | 118 | } |
121 | else | 119 | else |
122 | { | 120 | { |
123 | currentpos++; | 121 | currentpos++; |
124 | ch = expandedtextbuffer[bufferpos++]; | 122 | ch = expandedtextbuffer[bufferpos++]; |
125 | } | 123 | } |
126 | return ch; | 124 | return ch; |
127 | } | 125 | } |
128 | 126 | ||
129 | tchar CPlucker::getch(bool fast) | 127 | tchar CPlucker::getch(bool fast) |
130 | { | 128 | { |
131 | mystyle.clearPicture(); | 129 | mystyle.clearPicture(); |
132 | 130 | ||
133 | if (EOPPhase > 0) | 131 | if (EOPPhase > 0) |
134 | { | 132 | { |
135 | int ch = 10; | 133 | int ch = 10; |
136 | switch (EOPPhase) | 134 | switch (EOPPhase) |
137 | { | 135 | { |
138 | case 4: | 136 | case 4: |
139 | if (!fast) mystyle.setPicture(false, hRule(100,5)); | 137 | if (!fast) mystyle.setPicture(false, hRule(100,5)); |
140 | mystyle.setCentreJustify(); | 138 | mystyle.setCentreJustify(); |
141 | ch = '#'; | 139 | ch = '#'; |
142 | break; | 140 | break; |
143 | case 3: | 141 | case 3: |
144 | mystyle.setFontSize(3); | 142 | mystyle.setFontSize(3); |
145 | ch = 10; | 143 | ch = 10; |
146 | break; | 144 | break; |
147 | case 2: | 145 | case 2: |
148 | ch = 10; | 146 | ch = 10; |
149 | break; | 147 | break; |
150 | case 1: | 148 | case 1: |
151 | mystyle.unset(); | 149 | mystyle.unset(); |
152 | default: | 150 | default: |
153 | ch = 10; | 151 | ch = 10; |
154 | } | 152 | } |
155 | EOPPhase--; | 153 | EOPPhase--; |
156 | return ch; | 154 | return ch; |
157 | } | 155 | } |
158 | 156 | ||
159 | return getch_base(fast); | 157 | return getch_base(fast); |
160 | } | 158 | } |
161 | 159 | ||
162 | QImage* CPlucker::imagefromdata(UInt8* imgbuffer, UInt32 imgsize) | 160 | QImage* CPlucker::imagefromdata(UInt8* imgbuffer, UInt32 imgsize) |
163 | { | 161 | { |
164 | QImage* qimage = Palm2QImage(imgbuffer, imgsize); | 162 | QImage* qimage = Palm2QImage(imgbuffer, imgsize); |
165 | delete [] imgbuffer; | 163 | delete [] imgbuffer; |
166 | return qimage; | 164 | return qimage; |
167 | } | 165 | } |
168 | 166 | ||
169 | void CPlucker::start2endSection() // to plucker base | 167 | void CPlucker::start2endSection() // to plucker base |
170 | { | 168 | { |
171 | m_currentstart = NEFstartSection(); | 169 | m_currentstart = NEFstartSection(); |
172 | m_currentend = NEFendSection(); | 170 | m_currentend = NEFendSection(); |
173 | } | 171 | } |
174 | 172 | ||
175 | unsigned long CPlucker::NEFstartSection() // virtual in plucker base - differs only in obsoleted nef so move implementation | 173 | unsigned long CPlucker::NEFstartSection() // virtual in plucker base - differs only in obsoleted nef so move implementation |
176 | { | 174 | { |
177 | //inefficient - Should calc start/end of section on entry to section? | 175 | //inefficient - Should calc start/end of section on entry to section? |
178 | UInt16 thishdr_uid, thishdr_nParagraphs; | 176 | UInt16 thishdr_uid, thishdr_nParagraphs; |
179 | UInt32 thishdr_size; | 177 | UInt32 thishdr_size; |
180 | UInt8 thishdr_type, thishdr_reserved; | 178 | UInt8 thishdr_type, thishdr_reserved; |
181 | unsigned long textlength = currentpos-bufferpos; | 179 | unsigned long textlength = currentpos-bufferpos; |
182 | for (UInt16 recptr = bufferrec-1; recptr >= 1; recptr--) | 180 | for (UInt16 recptr = bufferrec-1; recptr >= 1; recptr--) |
183 | { | 181 | { |
184 | gotorecordnumber(recptr); | 182 | gotorecordnumber(recptr); |
185 | //qDebug("recptr:%u", recptr); | 183 | //qDebug("recptr:%u", recptr); |
186 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 184 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
187 | if (thishdr_type < 2) | 185 | if (thishdr_type < 2) |
188 | { | 186 | { |
189 | if ((thishdr_reserved && continuation_bit) == 0) break; | 187 | if ((thishdr_reserved && continuation_bit) == 0) break; |
190 | textlength -= thishdr_size; | 188 | textlength -= thishdr_size; |
191 | //qDebug("Textlength:%u, reserved:%u, recptr:%u", textlength, thishdr_reserved, recptr); | 189 | //qDebug("Textlength:%u, reserved:%u, recptr:%u", textlength, thishdr_reserved, recptr); |
192 | } | 190 | } |
193 | } | 191 | } |
194 | return textlength; | 192 | return textlength; |
195 | } | 193 | } |
196 | 194 | ||
197 | unsigned long CPlucker::NEFendSection() // virtual in plucker base - differs only in obsoleted nef so move implementation | 195 | unsigned long CPlucker::NEFendSection() // virtual in plucker base - differs only in obsoleted nef so move implementation |
198 | { | 196 | { |
199 | //inefficient - Should calc start/end of section on entry to section? | 197 | //inefficient - Should calc start/end of section on entry to section? |
200 | unsigned long textlength = currentpos-bufferpos+buffercontent; | 198 | unsigned long textlength = currentpos-bufferpos+buffercontent; |
201 | gotorecordnumber(bufferrec); | 199 | gotorecordnumber(bufferrec); |
202 | UInt16 thishdr_uid, thishdr_nParagraphs; | 200 | UInt16 thishdr_uid, thishdr_nParagraphs; |
203 | UInt32 thishdr_size; | 201 | UInt32 thishdr_size; |
204 | UInt8 thishdr_type, thishdr_reserved; | 202 | UInt8 thishdr_type, thishdr_reserved; |
205 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 203 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
206 | if ((thishdr_reserved && continuation_bit) != 0) | 204 | if ((thishdr_reserved && continuation_bit) != 0) |
207 | { | 205 | { |
208 | for (UInt16 recptr = bufferrec+1; recptr < ntohs(head.recordList.numRecords); recptr++) | 206 | for (UInt16 recptr = bufferrec+1; recptr < ntohs(head.recordList.numRecords); recptr++) |
209 | { | 207 | { |
210 | gotorecordnumber(recptr); | 208 | gotorecordnumber(recptr); |
211 | UInt16 thishdr_uid, thishdr_nParagraphs; | 209 | UInt16 thishdr_uid, thishdr_nParagraphs; |
212 | UInt32 thishdr_size; | 210 | UInt32 thishdr_size; |
213 | UInt8 thishdr_type, thishdr_reserved; | 211 | UInt8 thishdr_type, thishdr_reserved; |
214 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 212 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
215 | //qDebug("recptr %u bufferrec %u type %u m_reserved %u", recptr, bufferrec, typ | 213 | //qDebug("recptr %u bufferrec %u type %u m_reserved %u", recptr, bufferrec, typ |
216 | if (thishdr_type < 2) | 214 | if (thishdr_type < 2) |
217 | { | 215 | { |
218 | textlength += thishdr_size; | 216 | textlength += thishdr_size; |
219 | if ((thishdr_reserved && continuation_bit) == 0) break; | 217 | if ((thishdr_reserved && continuation_bit) == 0) break; |
220 | } | 218 | } |
221 | } | 219 | } |
222 | } | 220 | } |
223 | return textlength; | 221 | return textlength; |
224 | } | 222 | } |
225 | 223 | ||
226 | #ifndef __STATIC | 224 | #ifndef __STATIC |
227 | extern "C" | 225 | extern "C" |
228 | { | 226 | { |
229 | CExpander* newcodec() { return new CPlucker; } | 227 | CExpander* newcodec() { return new CPlucker; } |
230 | } | 228 | } |
231 | #endif | 229 | #endif |
diff --git a/noncore/apps/opie-reader/plucker_base.cpp b/noncore/apps/opie-reader/plucker_base.cpp index 0b7fae8..d7d538f 100644 --- a/noncore/apps/opie-reader/plucker_base.cpp +++ b/noncore/apps/opie-reader/plucker_base.cpp | |||
@@ -1,1411 +1,1408 @@ | |||
1 | #include "useqpe.h" | ||
2 | #include "usenef.h" | 1 | #include "usenef.h" |
3 | #include <stdio.h> | 2 | #include <stdio.h> |
4 | #include <string.h> | 3 | #include <string.h> |
5 | #include <qmessagebox.h> | 4 | #include <qmessagebox.h> |
6 | #include <qpixmap.h> | 5 | #include <qpixmap.h> |
7 | #ifdef USEQPE | 6 | #ifdef USEQPE |
8 | #include <qpe/qcopenvelope_qws.h> | 7 | #include <qpe/qcopenvelope_qws.h> |
9 | #endif /* USEQPE */ | 8 | #endif /* USEQPE */ |
10 | #ifdef LOCALPICTURES | 9 | #ifdef LOCALPICTURES |
11 | #include <qscrollview.h> | 10 | #include <qscrollview.h> |
12 | #endif | 11 | #endif |
13 | #ifdef USEQPE | 12 | #ifdef USEQPE |
14 | #include <qpe/global.h> | 13 | #include <qpe/global.h> |
15 | #endif /* USEQPE */ | 14 | #endif /* USEQPE */ |
16 | #include <qclipboard.h> | 15 | #include <qclipboard.h> |
17 | #ifndef USEQPE | 16 | #ifndef USEQPE |
18 | #include <qapplication.h> | 17 | #include <qapplication.h> |
19 | #else /* USEQPE */ | 18 | #else /* USEQPE */ |
20 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
21 | #endif /* USEQPE */ | 20 | #endif /* USEQPE */ |
22 | #include <qimage.h> | 21 | #include <qimage.h> |
23 | 22 | ||
24 | #include "static.h" | ||
25 | #include "plucker_base.h" | 23 | #include "plucker_base.h" |
26 | #include "Aportis.h" | 24 | #include "Aportis.h" |
27 | #include "hrule.h" | 25 | #include "hrule.h" |
28 | #include "util.h" | 26 | #include "util.h" |
29 | 27 | ||
30 | const UInt8 CPlucker_base::continuation_bit = 1; | 28 | const UInt8 CPlucker_base::continuation_bit = 1; |
31 | 29 | ||
32 | CPlucker_base::CPlucker_base() : | 30 | CPlucker_base::CPlucker_base() : |
33 | #ifdef LOCALPICTURES | 31 | #ifdef LOCALPICTURES |
34 | m_viewer(NULL), | 32 | m_viewer(NULL), |
35 | m_picture(NULL), | 33 | m_picture(NULL), |
36 | #endif | 34 | #endif |
37 | expandedtextbuffer(NULL), | 35 | expandedtextbuffer(NULL), |
38 | compressedtextbuffer(NULL), | 36 | compressedtextbuffer(NULL), |
39 | bufferrec(-1), | 37 | bufferrec(-1), |
40 | m_offset(0) | 38 | m_offset(0) |
41 | //, urls(NULL) | 39 | //, urls(NULL) |
42 | { /*printf("constructing:%x\n",fin);*/ } | 40 | { /*printf("constructing:%x\n",fin);*/ } |
43 | 41 | ||
44 | 42 | ||
45 | void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buffersize) | 43 | void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buffersize) |
46 | { | 44 | { |
47 | if (type%2 == 0) | 45 | if (type%2 == 0) |
48 | { | 46 | { |
49 | fread(buffer, reclen, sizeof(char), fin); | 47 | fread(buffer, reclen, sizeof(char), fin); |
50 | } | 48 | } |
51 | else | 49 | else |
52 | { | 50 | { |
53 | UInt8* readbuffer = NULL; | 51 | UInt8* readbuffer = NULL; |
54 | if (reclen > compressedbuffersize) | 52 | if (reclen > compressedbuffersize) |
55 | { | 53 | { |
56 | readbuffer = new UInt8[reclen]; | 54 | readbuffer = new UInt8[reclen]; |
57 | } | 55 | } |
58 | else | 56 | else |
59 | { | 57 | { |
60 | readbuffer = compressedtextbuffer; | 58 | readbuffer = compressedtextbuffer; |
61 | } | 59 | } |
62 | if (readbuffer != NULL) | 60 | if (readbuffer != NULL) |
63 | { | 61 | { |
64 | fread(readbuffer, reclen, sizeof(char), fin); | 62 | fread(readbuffer, reclen, sizeof(char), fin); |
65 | (*m_decompress)(readbuffer, reclen, buffer, buffersize); | 63 | (*m_decompress)(readbuffer, reclen, buffer, buffersize); |
66 | if (reclen > compressedbuffersize) | 64 | if (reclen > compressedbuffersize) |
67 | { | 65 | { |
68 | delete [] readbuffer; | 66 | delete [] readbuffer; |
69 | } | 67 | } |
70 | } | 68 | } |
71 | } | 69 | } |
72 | } | 70 | } |
73 | 71 | ||
74 | void CPlucker_base::sizes(unsigned long& _file, unsigned long& _text) | 72 | void CPlucker_base::sizes(unsigned long& _file, unsigned long& _text) |
75 | { | 73 | { |
76 | _file = file_length; | 74 | _file = file_length; |
77 | if (textlength == 0) | 75 | if (textlength == 0) |
78 | { | 76 | { |
79 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 77 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
80 | { | 78 | { |
81 | gotorecordnumber(recptr); | 79 | gotorecordnumber(recptr); |
82 | UInt16 thishdr_uid, thishdr_nParagraphs; | 80 | UInt16 thishdr_uid, thishdr_nParagraphs; |
83 | UInt32 thishdr_size; | 81 | UInt32 thishdr_size; |
84 | UInt8 thishdr_type, thishdr_reserved; | 82 | UInt8 thishdr_type, thishdr_reserved; |
85 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 83 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
86 | if (thishdr_type < 2) textlength += thishdr_size; | 84 | if (thishdr_type < 2) textlength += thishdr_size; |
87 | } | 85 | } |
88 | } | 86 | } |
89 | _text = textlength; | 87 | _text = textlength; |
90 | //ntohl(hdr0.size); | 88 | //ntohl(hdr0.size); |
91 | } | 89 | } |
92 | 90 | ||
93 | char* CPlucker_base::geturl(UInt16 tgt) | 91 | char* CPlucker_base::geturl(UInt16 tgt) |
94 | { | 92 | { |
95 | char * pRet = NULL; | 93 | char * pRet = NULL; |
96 | gotorecordnumber(0); | 94 | gotorecordnumber(0); |
97 | fread(&hdr0, 1, 6, fin); | 95 | fread(&hdr0, 1, 6, fin); |
98 | unsigned int nrecs = ntohs(hdr0.nRecords); | 96 | unsigned int nrecs = ntohs(hdr0.nRecords); |
99 | //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); | 97 | //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); |
100 | UInt16 urlid = 0; | 98 | UInt16 urlid = 0; |
101 | bool urlsfound = false; | 99 | bool urlsfound = false; |
102 | char* urls = NULL; | 100 | char* urls = NULL; |
103 | size_t urlsize = 0; | 101 | size_t urlsize = 0; |
104 | for (unsigned int i = 0; i < nrecs; i++) | 102 | for (unsigned int i = 0; i < nrecs; i++) |
105 | { | 103 | { |
106 | UInt16 id, name; | 104 | UInt16 id, name; |
107 | fread(&name, 1, sizeof(name), fin); | 105 | fread(&name, 1, sizeof(name), fin); |
108 | fread(&id, 1, sizeof(id), fin); | 106 | fread(&id, 1, sizeof(id), fin); |
109 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); | 107 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); |
110 | if (ntohs(name) == 2) | 108 | if (ntohs(name) == 2) |
111 | { | 109 | { |
112 | urlsfound = true; | 110 | urlsfound = true; |
113 | urlid = id; | 111 | urlid = id; |
114 | //qDebug("Found url index:%d", ntohs(urlid)); | 112 | //qDebug("Found url index:%d", ntohs(urlid)); |
115 | } | 113 | } |
116 | ////qDebug("%x", id); | 114 | ////qDebug("%x", id); |
117 | } | 115 | } |
118 | if (urlsfound) | 116 | if (urlsfound) |
119 | { | 117 | { |
120 | unsigned short recptr = finduid(ntohs(urlid)); | 118 | unsigned short recptr = finduid(ntohs(urlid)); |
121 | if (recptr != 0) | 119 | if (recptr != 0) |
122 | { | 120 | { |
123 | gotorecordnumber(recptr); | 121 | gotorecordnumber(recptr); |
124 | UInt16 thishdr_uid, thishdr_nParagraphs; | 122 | UInt16 thishdr_uid, thishdr_nParagraphs; |
125 | UInt32 thishdr_size; | 123 | UInt32 thishdr_size; |
126 | UInt8 thishdr_type, thishdr_reserved; | 124 | UInt8 thishdr_type, thishdr_reserved; |
127 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 125 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
128 | UInt16 urlctr = 0; | 126 | UInt16 urlctr = 0; |
129 | while (1) | 127 | while (1) |
130 | { | 128 | { |
131 | UInt16 tctr; | 129 | UInt16 tctr; |
132 | fread(&tctr, 1, sizeof(tctr), fin); | 130 | fread(&tctr, 1, sizeof(tctr), fin); |
133 | fread(&urlid, 1, sizeof(urlid), fin); | 131 | fread(&urlid, 1, sizeof(urlid), fin); |
134 | tctr = ntohs(tctr); | 132 | tctr = ntohs(tctr); |
135 | //qDebug("tgt:%u urlctr:%u tctr:%u", tgt, urlctr, tctr); | 133 | //qDebug("tgt:%u urlctr:%u tctr:%u", tgt, urlctr, tctr); |
136 | if (tctr >= tgt) | 134 | if (tctr >= tgt) |
137 | { | 135 | { |
138 | break; | 136 | break; |
139 | } | 137 | } |
140 | urlctr = tctr; | 138 | urlctr = tctr; |
141 | } | 139 | } |
142 | //qDebug("urls are in %d", ntohs(urlid)); | 140 | //qDebug("urls are in %d", ntohs(urlid)); |
143 | recptr = finduid(ntohs(urlid)); | 141 | recptr = finduid(ntohs(urlid)); |
144 | if (recptr != 0) | 142 | if (recptr != 0) |
145 | { | 143 | { |
146 | UInt32 reclen = recordlength(recptr) - HeaderSize(); | 144 | UInt32 reclen = recordlength(recptr) - HeaderSize(); |
147 | gotorecordnumber(recptr); | 145 | gotorecordnumber(recptr); |
148 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 146 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
149 | //qDebug("Found urls:%x",thishdr_type); | 147 | //qDebug("Found urls:%x",thishdr_type); |
150 | urlsize = thishdr_size; | 148 | urlsize = thishdr_size; |
151 | urls = new char[urlsize]; | 149 | urls = new char[urlsize]; |
152 | Expand(reclen, thishdr_type, (UInt8*)urls, urlsize); | 150 | Expand(reclen, thishdr_type, (UInt8*)urls, urlsize); |
153 | char* ptr = urls; | 151 | char* ptr = urls; |
154 | int rn = urlctr+1; | 152 | int rn = urlctr+1; |
155 | while (ptr - urls < urlsize) | 153 | while (ptr - urls < urlsize) |
156 | { | 154 | { |
157 | if (rn == tgt) | 155 | if (rn == tgt) |
158 | { | 156 | { |
159 | //qDebug("URL:%s", ptr); | 157 | //qDebug("URL:%s", ptr); |
160 | int len = strlen(ptr)+1; | 158 | int len = strlen(ptr)+1; |
161 | pRet = new char[len]; | 159 | pRet = new char[len]; |
162 | memcpy(pRet, ptr, len); | 160 | memcpy(pRet, ptr, len); |
163 | break; | 161 | break; |
164 | } | 162 | } |
165 | ptr += strlen(ptr)+1; | 163 | ptr += strlen(ptr)+1; |
166 | rn++; | 164 | rn++; |
167 | } | 165 | } |
168 | delete [] urls; | 166 | delete [] urls; |
169 | } | 167 | } |
170 | } | 168 | } |
171 | } | 169 | } |
172 | else | 170 | else |
173 | { | 171 | { |
174 | pRet = NULL; | 172 | pRet = NULL; |
175 | } | 173 | } |
176 | return pRet; | 174 | return pRet; |
177 | } | 175 | } |
178 | 176 | ||
179 | CPlucker_base::~CPlucker_base() | 177 | CPlucker_base::~CPlucker_base() |
180 | { | 178 | { |
181 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; | 179 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; |
182 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; | 180 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; |
183 | #ifdef LOCALPICTURES | 181 | #ifdef LOCALPICTURES |
184 | if (m_viewer != NULL) delete m_viewer; | 182 | if (m_viewer != NULL) delete m_viewer; |
185 | #endif | 183 | #endif |
186 | } | 184 | } |
187 | 185 | ||
188 | int CPlucker_base::getch() { return getch(false); } | 186 | int CPlucker_base::getch() { return getch(false); } |
189 | 187 | ||
190 | void CPlucker_base::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 188 | void CPlucker_base::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
191 | { | 189 | { |
192 | pos = locate(); | 190 | pos = locate(); |
193 | ch = getch(false); | 191 | ch = getch(false); |
194 | sty = mystyle; | 192 | sty = mystyle; |
195 | } | 193 | } |
196 | 194 | ||
197 | unsigned int CPlucker_base::locate() | 195 | unsigned int CPlucker_base::locate() |
198 | { | 196 | { |
199 | return currentpos; | 197 | return currentpos; |
200 | /* | 198 | /* |
201 | UInt16 thisrec = 1; | 199 | UInt16 thisrec = 1; |
202 | unsigned long locpos = 0; | 200 | unsigned long locpos = 0; |
203 | gotorecordnumber(thisrec); | 201 | gotorecordnumber(thisrec); |
204 | UInt16 thishdr_uid, thishdr_nParagraphs; | 202 | UInt16 thishdr_uid, thishdr_nParagraphs; |
205 | UInt32 thishdr_size; | 203 | UInt32 thishdr_size; |
206 | UInt8 thishdr_type, thishdr_reserved; | 204 | UInt8 thishdr_type, thishdr_reserved; |
207 | while (thisrec < bufferrec) | 205 | while (thisrec < bufferrec) |
208 | { | 206 | { |
209 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 207 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
210 | if (thishdr_type < 2) locpos += thishdr_size; | 208 | if (thishdr_type < 2) locpos += thishdr_size; |
211 | thisrec++; | 209 | thisrec++; |
212 | gotorecordnumber(thisrec); | 210 | gotorecordnumber(thisrec); |
213 | } | 211 | } |
214 | return locpos+bufferpos; | 212 | return locpos+bufferpos; |
215 | */ | 213 | */ |
216 | } | 214 | } |
217 | 215 | ||
218 | void CPlucker_base::locate(unsigned int n) | 216 | void CPlucker_base::locate(unsigned int n) |
219 | { | 217 | { |
220 | 218 | ||
221 | // clock_t start = clock(); | 219 | // clock_t start = clock(); |
222 | if (n >= currentpos-bufferpos && n < currentpos - bufferpos + buffercontent) | 220 | if (n >= currentpos-bufferpos && n < currentpos - bufferpos + buffercontent) |
223 | { | 221 | { |
224 | currentpos -= bufferpos; | 222 | currentpos -= bufferpos; |
225 | expand(bufferrec); | 223 | expand(bufferrec); |
226 | while (currentpos < n && bufferpos < buffercontent) getch_base(true); | 224 | while (currentpos < n && bufferpos < buffercontent) getch_base(true); |
227 | return; | 225 | return; |
228 | } | 226 | } |
229 | /* | 227 | /* |
230 | 228 | ||
231 | UInt32 textlength = currentpos - bufferpos; | 229 | UInt32 textlength = currentpos - bufferpos; |
232 | UInt16 recptr = bufferrec; | 230 | UInt16 recptr = bufferrec; |
233 | if (n < textlength/2) | 231 | if (n < textlength/2) |
234 | { | 232 | { |
235 | textlength = 0; | 233 | textlength = 0; |
236 | UInt16 thishdr_uid, thishdr_nParagraphs; | 234 | UInt16 thishdr_uid, thishdr_nParagraphs; |
237 | UInt32 thishdr_size = buffercontent; | 235 | UInt32 thishdr_size = buffercontent; |
238 | UInt8 thishdr_type, thishdr_reserved; | 236 | UInt8 thishdr_type, thishdr_reserved; |
239 | for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 237 | for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
240 | { | 238 | { |
241 | gotorecordnumber(recptr); | 239 | gotorecordnumber(recptr); |
242 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 240 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
243 | if (thishdr_type < 2) | 241 | if (thishdr_type < 2) |
244 | { | 242 | { |
245 | textlength += thishdr_size; | 243 | textlength += thishdr_size; |
246 | if (textlength > n) | 244 | if (textlength > n) |
247 | { | 245 | { |
248 | textlength -= thishdr_size; | 246 | textlength -= thishdr_size; |
249 | break; | 247 | break; |
250 | } | 248 | } |
251 | } | 249 | } |
252 | } | 250 | } |
253 | } | 251 | } |
254 | else if (n < textlength) | 252 | else if (n < textlength) |
255 | { | 253 | { |
256 | UInt16 thishdr_uid, thishdr_nParagraphs; | 254 | UInt16 thishdr_uid, thishdr_nParagraphs; |
257 | UInt32 thishdr_size; | 255 | UInt32 thishdr_size; |
258 | UInt8 thishdr_type, thishdr_reserved; | 256 | UInt8 thishdr_type, thishdr_reserved; |
259 | while (n < textlength && recptr > 1) | 257 | while (n < textlength && recptr > 1) |
260 | { | 258 | { |
261 | recptr--; | 259 | recptr--; |
262 | gotorecordnumber(recptr); | 260 | gotorecordnumber(recptr); |
263 | //qDebug("recptr:%u", recptr); | 261 | //qDebug("recptr:%u", recptr); |
264 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 262 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
265 | if (thishdr_type < 2) | 263 | if (thishdr_type < 2) |
266 | { | 264 | { |
267 | textlength -= thishdr_size; | 265 | textlength -= thishdr_size; |
268 | } | 266 | } |
269 | } | 267 | } |
270 | } | 268 | } |
271 | else | 269 | else |
272 | { | 270 | { |
273 | UInt16 thishdr_uid, thishdr_nParagraphs; | 271 | UInt16 thishdr_uid, thishdr_nParagraphs; |
274 | UInt32 thishdr_size = buffercontent; | 272 | UInt32 thishdr_size = buffercontent; |
275 | UInt8 thishdr_type, thishdr_reserved; | 273 | UInt8 thishdr_type, thishdr_reserved; |
276 | while (n > textlength + thishdr_size && recptr < ntohs(head.recordList.numRecords)-1) | 274 | while (n > textlength + thishdr_size && recptr < ntohs(head.recordList.numRecords)-1) |
277 | { | 275 | { |
278 | textlength += thishdr_size; | 276 | textlength += thishdr_size; |
279 | recptr++; | 277 | recptr++; |
280 | gotorecordnumber(recptr); | 278 | gotorecordnumber(recptr); |
281 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 279 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
282 | if (!(thishdr_type < 2)) | 280 | if (!(thishdr_type < 2)) |
283 | { | 281 | { |
284 | thishdr_size = 0; | 282 | thishdr_size = 0; |
285 | } | 283 | } |
286 | } | 284 | } |
287 | } | 285 | } |
288 | 286 | ||
289 | */ | 287 | */ |
290 | UInt16 thisrec = 0; | 288 | UInt16 thisrec = 0; |
291 | unsigned long locpos = 0; | 289 | unsigned long locpos = 0; |
292 | unsigned long bs = 0; | 290 | unsigned long bs = 0; |
293 | UInt16 thishdr_uid, thishdr_nParagraphs; | 291 | UInt16 thishdr_uid, thishdr_nParagraphs; |
294 | UInt32 thishdr_size; | 292 | UInt32 thishdr_size; |
295 | UInt8 thishdr_type, thishdr_reserved; | 293 | UInt8 thishdr_type, thishdr_reserved; |
296 | do | 294 | do |
297 | { | 295 | { |
298 | thisrec++; | 296 | thisrec++; |
299 | locpos += bs; | 297 | locpos += bs; |
300 | gotorecordnumber(thisrec); | 298 | gotorecordnumber(thisrec); |
301 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 299 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
302 | if (thishdr_type < 2) | 300 | if (thishdr_type < 2) |
303 | { | 301 | { |
304 | bs = thishdr_size; | 302 | bs = thishdr_size; |
305 | } | 303 | } |
306 | else | 304 | else |
307 | { | 305 | { |
308 | bs = 0; | 306 | bs = 0; |
309 | } | 307 | } |
310 | } while (locpos + bs <= n); | 308 | } while (locpos + bs <= n); |
311 | 309 | ||
312 | // qDebug("Time(2): %u", clock()-start); | 310 | // qDebug("Time(2): %u", clock()-start); |
313 | /* | 311 | /* |
314 | if (recptr != thisrec) | 312 | if (recptr != thisrec) |
315 | { | 313 | { |
316 | qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec); | 314 | qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec); |
317 | UInt16 thishdr_uid, thishdr_nParagraphs; | 315 | UInt16 thishdr_uid, thishdr_nParagraphs; |
318 | UInt32 thishdr_size = buffercontent; | 316 | UInt32 thishdr_size = buffercontent; |
319 | UInt8 thishdr_type, thishdr_reserved; | 317 | UInt8 thishdr_type, thishdr_reserved; |
320 | for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 318 | for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
321 | { | 319 | { |
322 | gotorecordnumber(recptr); | 320 | gotorecordnumber(recptr); |
323 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 321 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
324 | // 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); |
325 | } | 323 | } |
326 | //QApplication::exit ( 100 ); | 324 | //QApplication::exit ( 100 ); |
327 | } | 325 | } |
328 | */ | 326 | */ |
329 | currentpos = locpos; | 327 | currentpos = locpos; |
330 | expand(thisrec); | 328 | expand(thisrec); |
331 | while (currentpos < n && bufferpos < buffercontent) getch_base(true); | 329 | while (currentpos < n && bufferpos < buffercontent) getch_base(true); |
332 | 330 | ||
333 | /* // 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^( |
334 | bufferpos = n-locpos; | 332 | bufferpos = n-locpos; |
335 | currentpos = n; | 333 | currentpos = n; |
336 | while (bufferpos >= m_nextPara && m_nextPara >= 0) | 334 | while (bufferpos >= m_nextPara && m_nextPara >= 0) |
337 | { | 335 | { |
338 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; | 336 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; |
339 | m_nextParaIndex++; | 337 | m_nextParaIndex++; |
340 | if (m_nextParaIndex == m_nParas) | 338 | if (m_nextParaIndex == m_nParas) |
341 | { | 339 | { |
342 | m_nextPara = -1; | 340 | m_nextPara = -1; |
343 | } | 341 | } |
344 | else | 342 | else |
345 | { | 343 | { |
346 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | 344 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; |
347 | } | 345 | } |
348 | } | 346 | } |
349 | */ | 347 | */ |
350 | } | 348 | } |
351 | 349 | ||
352 | bool CPlucker_base::expand(int thisrec) | 350 | bool CPlucker_base::expand(int thisrec) |
353 | { | 351 | { |
354 | mystyle.unset(); | 352 | mystyle.unset(); |
355 | if (bufferrec != thisrec) | 353 | if (bufferrec != thisrec) |
356 | { | 354 | { |
357 | size_t reclen = recordlength(thisrec); | 355 | size_t reclen = recordlength(thisrec); |
358 | gotorecordnumber(thisrec); | 356 | gotorecordnumber(thisrec); |
359 | UInt16 thishdr_uid, thishdr_nParagraphs; | 357 | UInt16 thishdr_uid, thishdr_nParagraphs; |
360 | UInt32 thishdr_size; | 358 | UInt32 thishdr_size; |
361 | UInt8 thishdr_type, thishdr_reserved; | 359 | UInt8 thishdr_type, thishdr_reserved; |
362 | while (1) | 360 | while (1) |
363 | { | 361 | { |
364 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 362 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
365 | //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); |
366 | if (thishdr_type < 2) break; | 364 | if (thishdr_type < 2) break; |
367 | //qDebug("Skipping paragraph of type %d", thishdr_type); | 365 | //qDebug("Skipping paragraph of type %d", thishdr_type); |
368 | if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; | 366 | if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; |
369 | reclen = recordlength(thisrec); | 367 | reclen = recordlength(thisrec); |
370 | gotorecordnumber(thisrec); | 368 | gotorecordnumber(thisrec); |
371 | } | 369 | } |
372 | m_nParas = thishdr_nParagraphs; | 370 | m_nParas = thishdr_nParagraphs; |
373 | m_bufferisreserved = (thishdr_reserved != 0); | 371 | m_bufferisreserved = (thishdr_reserved != 0); |
374 | //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); |
375 | uid = thishdr_uid; | 373 | uid = thishdr_uid; |
376 | // gotorecordnumber(thisrec); | 374 | // gotorecordnumber(thisrec); |
377 | // fread(expandedtextbuffer,1,10,fin); | 375 | // fread(expandedtextbuffer,1,10,fin); |
378 | for (int i = 0; i < m_nParas; i++) | 376 | for (int i = 0; i < m_nParas; i++) |
379 | { | 377 | { |
380 | UInt16 ubytes, attrs; | 378 | UInt16 ubytes, attrs; |
381 | fread(&ubytes, 1, sizeof(ubytes), fin); | 379 | fread(&ubytes, 1, sizeof(ubytes), fin); |
382 | fread(&attrs, 1, sizeof(attrs), fin); | 380 | fread(&attrs, 1, sizeof(attrs), fin); |
383 | m_ParaOffsets[i] = ntohs(ubytes); | 381 | m_ParaOffsets[i] = ntohs(ubytes); |
384 | m_ParaAttrs[i] = ntohs(attrs); | 382 | m_ParaAttrs[i] = ntohs(attrs); |
385 | ////qDebug("Bytes %u, Attr %x", ntohs(ubytes), ntohs(attrs)); | 383 | ////qDebug("Bytes %u, Attr %x", ntohs(ubytes), ntohs(attrs)); |
386 | } | 384 | } |
387 | 385 | ||
388 | reclen -= HeaderSize()+4*m_nParas; | 386 | reclen -= HeaderSize()+4*m_nParas; |
389 | 387 | ||
390 | buffercontent = thishdr_size; | 388 | buffercontent = thishdr_size; |
391 | 389 | ||
392 | if (thishdr_size > buffersize) | 390 | if (thishdr_size > buffersize) |
393 | { | 391 | { |
394 | delete [] expandedtextbuffer; | 392 | delete [] expandedtextbuffer; |
395 | buffersize = thishdr_size; | 393 | buffersize = thishdr_size; |
396 | expandedtextbuffer = new UInt8[buffersize]; | 394 | expandedtextbuffer = new UInt8[buffersize]; |
397 | } | 395 | } |
398 | Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent); | 396 | Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent); |
399 | bufferrec = thisrec; | 397 | bufferrec = thisrec; |
400 | } | 398 | } |
401 | 399 | ||
402 | 400 | ||
403 | if (m_nParas > 0) | 401 | if (m_nParas > 0) |
404 | { | 402 | { |
405 | m_nextPara = m_ParaOffsets[0]; | 403 | m_nextPara = m_ParaOffsets[0]; |
406 | //qDebug("First offset = %u", m_nextPara); | 404 | //qDebug("First offset = %u", m_nextPara); |
407 | m_nextParaIndex = 0; | 405 | m_nextParaIndex = 0; |
408 | } | 406 | } |
409 | else | 407 | else |
410 | { | 408 | { |
411 | m_nextPara = -1; | 409 | m_nextPara = -1; |
412 | } | 410 | } |
413 | bufferpos = 0; | 411 | bufferpos = 0; |
414 | //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size); | 412 | //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size); |
415 | return true; | 413 | return true; |
416 | } | 414 | } |
417 | 415 | ||
418 | 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) |
419 | { | 417 | { |
420 | z_stream zstream; | 418 | z_stream zstream; |
421 | memset(&zstream,sizeof(zstream),0); | 419 | memset(&zstream,sizeof(zstream),0); |
422 | zstream.next_in = compressedbuffer; | 420 | zstream.next_in = compressedbuffer; |
423 | zstream.next_out = tgtbuffer; | 421 | zstream.next_out = tgtbuffer; |
424 | zstream.avail_out = bsize; | 422 | zstream.avail_out = bsize; |
425 | zstream.avail_in = reclen; | 423 | zstream.avail_in = reclen; |
426 | 424 | ||
427 | int keylen = 0; | 425 | int keylen = 0; |
428 | 426 | ||
429 | zstream.zalloc = Z_NULL; | 427 | zstream.zalloc = Z_NULL; |
430 | zstream.zfree = Z_NULL; | 428 | zstream.zfree = Z_NULL; |
431 | zstream.opaque = Z_NULL; | 429 | zstream.opaque = Z_NULL; |
432 | 430 | ||
433 | // printf("Initialising\n"); | 431 | // printf("Initialising\n"); |
434 | 432 | ||
435 | inflateInit(&zstream); | 433 | inflateInit(&zstream); |
436 | int err = 0; | 434 | int err = 0; |
437 | do { | 435 | do { |
438 | if ( zstream.avail_in == 0 && 0 < keylen ) { | 436 | if ( zstream.avail_in == 0 && 0 < keylen ) { |
439 | zstream.next_in = compressedbuffer + keylen; | 437 | zstream.next_in = compressedbuffer + keylen; |
440 | zstream.avail_in = reclen - keylen; | 438 | zstream.avail_in = reclen - keylen; |
441 | keylen = 0; | 439 | keylen = 0; |
442 | } | 440 | } |
443 | zstream.next_out = tgtbuffer; | 441 | zstream.next_out = tgtbuffer; |
444 | zstream.avail_out = bsize; | 442 | zstream.avail_out = bsize; |
445 | 443 | ||
446 | err = inflate( &zstream, Z_SYNC_FLUSH ); | 444 | err = inflate( &zstream, Z_SYNC_FLUSH ); |
447 | 445 | ||
448 | ////qDebug("err:%d - %u", err, zstream.avail_in); | 446 | ////qDebug("err:%d - %u", err, zstream.avail_in); |
449 | 447 | ||
450 | } while ( err == Z_OK ); | 448 | } while ( err == Z_OK ); |
451 | 449 | ||
452 | inflateEnd(&zstream); | 450 | inflateEnd(&zstream); |
453 | } | 451 | } |
454 | 452 | ||
455 | void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) | 453 | void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) |
456 | { | 454 | { |
457 | // UInt16 headerSize; | 455 | // UInt16 headerSize; |
458 | UInt16 docSize; | 456 | UInt16 docSize; |
459 | UInt16 i; | 457 | UInt16 i; |
460 | UInt16 j; | 458 | UInt16 j; |
461 | UInt16 k; | 459 | UInt16 k; |
462 | 460 | ||
463 | UInt8 *inBuf = compressedbuffer; | 461 | UInt8 *inBuf = compressedbuffer; |
464 | UInt8 *outBuf = tgtbuffer; | 462 | UInt8 *outBuf = tgtbuffer; |
465 | 463 | ||
466 | // headerSize = sizeof( Header ) + record->paragraphs * sizeof( Paragraph ); | 464 | // headerSize = sizeof( Header ) + record->paragraphs * sizeof( Paragraph ); |
467 | docSize = reclen; | 465 | docSize = reclen; |
468 | 466 | ||
469 | j = 0; | 467 | j = 0; |
470 | k = 0; | 468 | k = 0; |
471 | while ( j < docSize ) { | 469 | while ( j < docSize ) { |
472 | i = 0; | 470 | i = 0; |
473 | while ( i < bsize && j < docSize ) { | 471 | while ( i < bsize && j < docSize ) { |
474 | UInt16 c; | 472 | UInt16 c; |
475 | 473 | ||
476 | c = (UInt16) inBuf[ j++ ]; | 474 | c = (UInt16) inBuf[ j++ ]; |
477 | if ( 0 < c && c < 9 ) { | 475 | if ( 0 < c && c < 9 ) { |
478 | while ( 0 < c-- ) | 476 | while ( 0 < c-- ) |
479 | outBuf[ i++ ] = inBuf[ j++ ]; | 477 | outBuf[ i++ ] = inBuf[ j++ ]; |
480 | } | 478 | } |
481 | else if ( c < 0x80 ) | 479 | else if ( c < 0x80 ) |
482 | outBuf[ i++ ] = c; | 480 | outBuf[ i++ ] = c; |
483 | else if ( 0xc0 <= c ) { | 481 | else if ( 0xc0 <= c ) { |
484 | outBuf[ i++ ] = ' '; | 482 | outBuf[ i++ ] = ' '; |
485 | outBuf[ i++ ] = c ^ 0x80; | 483 | outBuf[ i++ ] = c ^ 0x80; |
486 | } | 484 | } |
487 | else { | 485 | else { |
488 | Int16 m; | 486 | Int16 m; |
489 | Int16 n; | 487 | Int16 n; |
490 | 488 | ||
491 | c <<= 8; | 489 | c <<= 8; |
492 | c += inBuf[ j++ ]; | 490 | c += inBuf[ j++ ]; |
493 | 491 | ||
494 | m = ( c & 0x3fff ) >> COUNT_BITS; | 492 | m = ( c & 0x3fff ) >> COUNT_BITS; |
495 | n = c & ( ( 1 << COUNT_BITS ) - 1 ); | 493 | n = c & ( ( 1 << COUNT_BITS ) - 1 ); |
496 | n += 2; | 494 | n += 2; |
497 | 495 | ||
498 | do { | 496 | do { |
499 | outBuf[ i ] = outBuf[ i - m ]; | 497 | outBuf[ i ] = outBuf[ i - m ]; |
500 | i++; | 498 | i++; |
501 | } while ( 0 < n-- ); | 499 | } while ( 0 < n-- ); |
502 | } | 500 | } |
503 | } | 501 | } |
504 | k += bsize; | 502 | k += bsize; |
505 | } | 503 | } |
506 | } | 504 | } |
507 | 505 | ||
508 | void CPlucker_base::home() | 506 | void CPlucker_base::home() |
509 | { | 507 | { |
510 | currentpos = 0; | 508 | currentpos = 0; |
511 | expand(1); | 509 | expand(1); |
512 | } | 510 | } |
513 | 511 | ||
514 | CList<Bkmk>* CPlucker_base::getbkmklist() | 512 | CList<Bkmk>* CPlucker_base::getbkmklist() |
515 | { | 513 | { |
516 | /* | 514 | /* |
517 | UInt16 thishdr_uid, thishdr_nParagraphs; | 515 | UInt16 thishdr_uid, thishdr_nParagraphs; |
518 | UInt32 thishdr_size; | 516 | UInt32 thishdr_size; |
519 | UInt8 thishdr_type, thishdr_reserved; | 517 | UInt8 thishdr_type, thishdr_reserved; |
520 | 518 | ||
521 | for (int i = 1; i < ntohs(head.recordList.numRecords); i++) | 519 | for (int i = 1; i < ntohs(head.recordList.numRecords); i++) |
522 | { | 520 | { |
523 | gotorecordnumber(i); | 521 | gotorecordnumber(i); |
524 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 522 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
525 | if (thishdr_type == 8) | 523 | if (thishdr_type == 8) |
526 | { | 524 | { |
527 | UInt16 n; | 525 | UInt16 n; |
528 | fread(&n, 1, sizeof(n), fin); | 526 | fread(&n, 1, sizeof(n), fin); |
529 | n = ntohs(n); | 527 | n = ntohs(n); |
530 | //qDebug("Found %u bookmarks", n); | 528 | //qDebug("Found %u bookmarks", n); |
531 | } | 529 | } |
532 | //qDebug("Found:%d, %u", i , thishdr_type); | 530 | //qDebug("Found:%d, %u", i , thishdr_type); |
533 | } | 531 | } |
534 | */ | 532 | */ |
535 | return NULL; | 533 | return NULL; |
536 | } | 534 | } |
537 | 535 | ||
538 | #include <qnamespace.h> | 536 | #include <qnamespace.h> |
539 | 537 | ||
540 | QImage* CPlucker_base::expandimg(UInt16 tgt, bool border) | 538 | QImage* CPlucker_base::expandimg(UInt16 tgt, bool border) |
541 | { | 539 | { |
542 | QImage* qimage = getimg(tgt); | 540 | QImage* qimage = getimg(tgt); |
543 | QImage* ret; | 541 | QImage* ret; |
544 | if (qimage == NULL) return NULL; | 542 | if (qimage == NULL) return NULL; |
545 | if (border) | 543 | if (border) |
546 | { | 544 | { |
547 | QPixmap* image = new QPixmap(0,0); | 545 | QPixmap* image = new QPixmap(0,0); |
548 | image->convertFromImage(*qimage); | 546 | image->convertFromImage(*qimage); |
549 | delete qimage; | 547 | delete qimage; |
550 | QPixmap* pret = new QPixmap(image->width()+4, image->height()+4); | 548 | QPixmap* pret = new QPixmap(image->width()+4, image->height()+4); |
551 | pret->fill(Qt::red); | 549 | pret->fill(Qt::red); |
552 | bitBlt(pret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP); | 550 | bitBlt(pret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP); |
553 | delete image; | 551 | delete image; |
554 | ret = new QImage(pret->convertToImage()); | 552 | ret = new QImage(pret->convertToImage()); |
555 | } | 553 | } |
556 | else | 554 | else |
557 | { | 555 | { |
558 | ret = qimage; | 556 | ret = qimage; |
559 | } | 557 | } |
560 | return ret; | 558 | return ret; |
561 | } | 559 | } |
562 | 560 | ||
563 | #ifdef _BUFFERPICS | 561 | #ifdef _BUFFERPICS |
564 | #include <qmap.h> | 562 | #include <qmap.h> |
565 | #endif | 563 | #endif |
566 | 564 | ||
567 | QImage* CPlucker_base::getPicture(unsigned long tgt) | 565 | QImage* CPlucker_base::getPicture(unsigned long tgt) |
568 | { | 566 | { |
569 | #ifdef _BUFFERPICS | 567 | #ifdef _BUFFERPICS |
570 | static QMap<unsigned long, QPixmap> pix; | 568 | static QMap<unsigned long, QPixmap> pix; |
571 | QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt); | 569 | QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt); |
572 | if (t == pix.end()) | 570 | if (t == pix.end()) |
573 | { | 571 | { |
574 | pix[tgt] = *expandimg(tgt); | 572 | pix[tgt] = *expandimg(tgt); |
575 | return &pix[tgt]; | 573 | return &pix[tgt]; |
576 | } | 574 | } |
577 | else | 575 | else |
578 | return &(t.data()); | 576 | return &(t.data()); |
579 | #else | 577 | #else |
580 | return expandimg(tgt >> 16); | 578 | return expandimg(tgt >> 16); |
581 | #endif | 579 | #endif |
582 | } | 580 | } |
583 | 581 | ||
584 | #ifdef LOCALPICTURES | 582 | #ifdef LOCALPICTURES |
585 | #include <unistd.h> | 583 | #include <unistd.h> |
586 | #include <qpe/global.h> | 584 | #include <qpe/global.h> |
587 | void CPlucker_base::showimg(UInt16 tgt) | 585 | void CPlucker_base::showimg(UInt16 tgt) |
588 | { | 586 | { |
589 | //qDebug("Crassssssh!"); | 587 | //qDebug("Crassssssh!"); |
590 | QPixmap* qimage = expandimg(tgt); | 588 | QPixmap* qimage = expandimg(tgt); |
591 | m_picture->setFixedSize(qimage->size()); | 589 | m_picture->setFixedSize(qimage->size()); |
592 | m_picture->setBackgroundPixmap(*qimage); | 590 | m_picture->setBackgroundPixmap(*qimage); |
593 | delete qimage; | 591 | delete qimage; |
594 | m_viewer->show(); | 592 | m_viewer->show(); |
595 | 593 | ||
596 | /* | 594 | /* |
597 | char tmp[] = "uqtreader.XXXXXX"; | 595 | char tmp[] = "uqtreader.XXXXXX"; |
598 | QImage* qimage = getimg(tgt); | 596 | QImage* qimage = getimg(tgt); |
599 | QPixmap* image = new QPixmap(0,0); | 597 | QPixmap* image = new QPixmap(0,0); |
600 | // //qDebug("New image"); | 598 | // //qDebug("New image"); |
601 | image->convertFromImage(*qimage); | 599 | image->convertFromImage(*qimage); |
602 | delete qimage; | 600 | delete qimage; |
603 | char tmpfile[sizeof(tmp)+1]; | 601 | char tmpfile[sizeof(tmp)+1]; |
604 | strcpy(tmpfile,tmp); | 602 | strcpy(tmpfile,tmp); |
605 | int f = mkstemp(tmpfile); | 603 | int f = mkstemp(tmpfile); |
606 | close(f); | 604 | close(f); |
607 | //qDebug("TMPFILE:%s", tmpfile); | 605 | //qDebug("TMPFILE:%s", tmpfile); |
608 | if (image->save(tmpfile,"PNG")) | 606 | if (image->save(tmpfile,"PNG")) |
609 | { | 607 | { |
610 | QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)"); | 608 | QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)"); |
611 | e << QString(tmpfile); | 609 | e << QString(tmpfile); |
612 | } | 610 | } |
613 | Global::statusMessage("Opening image"); | 611 | Global::statusMessage("Opening image"); |
614 | sleep(5); | 612 | sleep(5); |
615 | delete image; | 613 | delete image; |
616 | unlink(tmpfile); | 614 | unlink(tmpfile); |
617 | */ | 615 | */ |
618 | } | 616 | } |
619 | 617 | ||
620 | #endif | 618 | #endif |
621 | 619 | ||
622 | unsigned short CPlucker_base::finduid(unsigned short urlid) | 620 | unsigned short CPlucker_base::finduid(unsigned short urlid) |
623 | { | 621 | { |
624 | // //qDebug("Finding %u", urlid); | 622 | // //qDebug("Finding %u", urlid); |
625 | unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); | 623 | unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); |
626 | unsigned short jmid = (jmin+jmax) >> 1; | 624 | unsigned short jmid = (jmin+jmax) >> 1; |
627 | while (jmax - jmin > 1) | 625 | while (jmax - jmin > 1) |
628 | { | 626 | { |
629 | gotorecordnumber(jmid); | 627 | gotorecordnumber(jmid); |
630 | UInt16 thishdr_uid, thishdr_nParagraphs; | 628 | UInt16 thishdr_uid, thishdr_nParagraphs; |
631 | UInt32 thishdr_size; | 629 | UInt32 thishdr_size; |
632 | UInt8 thishdr_type, thishdr_reserved; | 630 | UInt8 thishdr_type, thishdr_reserved; |
633 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 631 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
634 | unsigned short luid = thishdr_uid; | 632 | unsigned short luid = thishdr_uid; |
635 | ////qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); | 633 | ////qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); |
636 | if (luid == urlid) | 634 | if (luid == urlid) |
637 | { | 635 | { |
638 | return jmid; | 636 | return jmid; |
639 | } | 637 | } |
640 | if (luid < urlid) | 638 | if (luid < urlid) |
641 | { | 639 | { |
642 | jmin = jmid; | 640 | jmin = jmid; |
643 | } | 641 | } |
644 | else | 642 | else |
645 | { | 643 | { |
646 | jmax = jmid; | 644 | jmax = jmid; |
647 | } | 645 | } |
648 | jmid = (jmin+jmax) >> 1; | 646 | jmid = (jmin+jmax) >> 1; |
649 | } | 647 | } |
650 | gotorecordnumber(jmin); | 648 | gotorecordnumber(jmin); |
651 | UInt16 thishdr_uid, thishdr_nParagraphs; | 649 | UInt16 thishdr_uid, thishdr_nParagraphs; |
652 | UInt32 thishdr_size; | 650 | UInt32 thishdr_size; |
653 | UInt8 thishdr_type, thishdr_reserved; | 651 | UInt8 thishdr_type, thishdr_reserved; |
654 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 652 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
655 | unsigned short luid = thishdr_uid; | 653 | unsigned short luid = thishdr_uid; |
656 | //qDebug("jmin at end:%u,%u", jmin, luid); | 654 | //qDebug("jmin at end:%u,%u", jmin, luid); |
657 | if (luid == urlid) | 655 | if (luid == urlid) |
658 | { | 656 | { |
659 | return jmin; | 657 | return jmin; |
660 | } | 658 | } |
661 | gotorecordnumber(jmax); | 659 | gotorecordnumber(jmax); |
662 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 660 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
663 | luid = thishdr_uid; | 661 | luid = thishdr_uid; |
664 | //qDebug("jmax at end:%u,%u", jmax, luid); | 662 | //qDebug("jmax at end:%u,%u", jmax, luid); |
665 | if (luid == urlid) | 663 | if (luid == urlid) |
666 | { | 664 | { |
667 | return jmax; | 665 | return jmax; |
668 | } | 666 | } |
669 | //qDebug("Couldn't find %u", urlid); | 667 | //qDebug("Couldn't find %u", urlid); |
670 | return 0; // Not found! | 668 | return 0; // Not found! |
671 | } | 669 | } |
672 | 670 | ||
673 | #include <qnamespace.h> | 671 | #include <qnamespace.h> |
674 | 672 | ||
675 | void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | 673 | void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) |
676 | { | 674 | { |
677 | unsigned short sz = 0; | 675 | unsigned short sz = 0; |
678 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | 676 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) |
679 | { | 677 | { |
680 | sz++; | 678 | sz++; |
681 | } | 679 | } |
682 | size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long); | 680 | size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long); |
683 | unsigned char* newdata = new unsigned char[newlen]; | 681 | unsigned char* newdata = new unsigned char[newlen]; |
684 | unsigned char* pdata = newdata; | 682 | unsigned char* pdata = newdata; |
685 | memcpy(newdata, src, srclen); | 683 | memcpy(newdata, src, srclen); |
686 | newdata += srclen; | 684 | newdata += srclen; |
687 | memcpy(newdata, &sz, sizeof(sz)); | 685 | memcpy(newdata, &sz, sizeof(sz)); |
688 | newdata += sizeof(sz); | 686 | newdata += sizeof(sz); |
689 | #ifdef _WINDOWS | 687 | #ifdef _WINDOWS |
690 | for (it = visited.begin(); it != visited.end(); it++) | 688 | for (it = visited.begin(); it != visited.end(); it++) |
691 | #else | 689 | #else |
692 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | 690 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) |
693 | #endif | 691 | #endif |
694 | { | 692 | { |
695 | unsigned long t = *it; | 693 | unsigned long t = *it; |
696 | //qDebug("[%u]", t); | 694 | //qDebug("[%u]", t); |
697 | memcpy(newdata, &t, sizeof(t)); | 695 | memcpy(newdata, &t, sizeof(t)); |
698 | newdata += sizeof(t); | 696 | newdata += sizeof(t); |
699 | } | 697 | } |
700 | m_nav.setSaveData(data, len, pdata, newlen); | 698 | m_nav.setSaveData(data, len, pdata, newlen); |
701 | delete [] pdata; | 699 | delete [] pdata; |
702 | } | 700 | } |
703 | 701 | ||
704 | void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen) | 702 | void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen) |
705 | { | 703 | { |
706 | unsigned short sz; | 704 | unsigned short sz; |
707 | if (srclen >= sizeof(sz)) | 705 | if (srclen >= sizeof(sz)) |
708 | { | 706 | { |
709 | memcpy(&sz, src, sizeof(sz)); | 707 | memcpy(&sz, src, sizeof(sz)); |
710 | src += sizeof(sz); | 708 | src += sizeof(sz); |
711 | srclen -= sizeof(sz); | 709 | srclen -= sizeof(sz); |
712 | } | 710 | } |
713 | for (int i = 0; i < sz; i++) | 711 | for (int i = 0; i < sz; i++) |
714 | { | 712 | { |
715 | unsigned long t; | 713 | unsigned long t; |
716 | if (srclen >= sizeof(t)) | 714 | if (srclen >= sizeof(t)) |
717 | { | 715 | { |
718 | memcpy(&t, src, sizeof(t)); | 716 | memcpy(&t, src, sizeof(t)); |
719 | // qDebug("[%u]", t); | 717 | // qDebug("[%u]", t); |
720 | visited.push_front(t); | 718 | visited.push_front(t); |
721 | src += sizeof(t); | 719 | src += sizeof(t); |
722 | srclen -= sizeof(t); | 720 | srclen -= sizeof(t); |
723 | } | 721 | } |
724 | else | 722 | else |
725 | { | 723 | { |
726 | QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself"); | 724 | QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself"); |
727 | break; | 725 | break; |
728 | } | 726 | } |
729 | } | 727 | } |
730 | m_nav.putSaveData(src, srclen); | 728 | m_nav.putSaveData(src, srclen); |
731 | } | 729 | } |
732 | 730 | ||
733 | int CPlucker_base::OpenFile(const char *src) | 731 | int CPlucker_base::OpenFile(const char *src) |
734 | { | 732 | { |
735 | qDebug("plucker openfile:%s", src); | 733 | qDebug("plucker openfile:%s", src); |
736 | m_lastBreak = 0; | 734 | m_lastBreak = 0; |
737 | if (!Cpdb::openpdbfile(src)) | 735 | if (!Cpdb::openpdbfile(src)) |
738 | { | 736 | { |
739 | return -1; | 737 | return -1; |
740 | } | 738 | } |
741 | 739 | ||
742 | if (!CorrectDecoder()) return -1; | 740 | if (!CorrectDecoder()) return -1; |
743 | 741 | ||
744 | gotorecordnumber(0); | 742 | gotorecordnumber(0); |
745 | fread(&hdr0, 1, 6, fin); | 743 | fread(&hdr0, 1, 6, fin); |
746 | qDebug("Compression type:%u", ntohs(hdr0.version)); | 744 | qDebug("Compression type:%u", ntohs(hdr0.version)); |
747 | 745 | ||
748 | 746 | ||
749 | switch (ntohs(hdr0.version)) | 747 | switch (ntohs(hdr0.version)) |
750 | { | 748 | { |
751 | case 2: | 749 | case 2: |
752 | m_decompress = UnZip; | 750 | m_decompress = UnZip; |
753 | break; | 751 | break; |
754 | case 1: | 752 | case 1: |
755 | m_decompress = UnDoc; | 753 | m_decompress = UnDoc; |
756 | break; | 754 | break; |
757 | #ifdef USENEF | 755 | #ifdef USENEF |
758 | case 3: | 756 | case 3: |
759 | m_decompress = getdecompressor("PluckerDecompress3"); | 757 | m_decompress = getdecompressor("PluckerDecompress3"); |
760 | break; | 758 | break; |
761 | case 4: | 759 | case 4: |
762 | m_decompress = getdecompressor("PluckerDecompress4"); | 760 | m_decompress = getdecompressor("PluckerDecompress4"); |
763 | break; | 761 | break; |
764 | #endif | 762 | #endif |
765 | default: | 763 | default: |
766 | m_decompress = NULL; | 764 | m_decompress = NULL; |
767 | } | 765 | } |
768 | if (m_decompress == NULL) return -1; | 766 | if (m_decompress == NULL) return -1; |
769 | 767 | ||
770 | setbuffersize(); | 768 | setbuffersize(); |
771 | compressedtextbuffer = new UInt8[compressedbuffersize]; | 769 | compressedtextbuffer = new UInt8[compressedbuffersize]; |
772 | expandedtextbuffer = new UInt8[buffersize]; | 770 | expandedtextbuffer = new UInt8[buffersize]; |
773 | 771 | ||
774 | unsigned int nrecs = ntohs(hdr0.nRecords); | 772 | unsigned int nrecs = ntohs(hdr0.nRecords); |
775 | qDebug("Version %u, no. reserved recs %u", ntohs(hdr0.version), nrecs); | 773 | qDebug("Version %u, no. reserved recs %u", ntohs(hdr0.version), nrecs); |
776 | textlength = ntohl(head.sortInfoID); | 774 | textlength = ntohl(head.sortInfoID); |
777 | qDebug("Textlength at startup:%u", textlength); | 775 | qDebug("Textlength at startup:%u", textlength); |
778 | UInt16 homerecid = 1; | 776 | UInt16 homerecid = 1; |
779 | for (unsigned int i = 0; i < nrecs; i++) | 777 | for (unsigned int i = 0; i < nrecs; i++) |
780 | { | 778 | { |
781 | UInt16 id, name; | 779 | UInt16 id, name; |
782 | fread(&name, 1, sizeof(name), fin); | 780 | fread(&name, 1, sizeof(name), fin); |
783 | fread(&id, 1, sizeof(id), fin); | 781 | fread(&id, 1, sizeof(id), fin); |
784 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); | 782 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); |
785 | if (ntohs(name) == 0) homerecid = ntohs(id); | 783 | if (ntohs(name) == 0) homerecid = ntohs(id); |
786 | } | 784 | } |
787 | 785 | ||
788 | textlength = 0; | 786 | textlength = 0; |
789 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 787 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
790 | { | 788 | { |
791 | gotorecordnumber(recptr); | 789 | gotorecordnumber(recptr); |
792 | UInt16 thishdr_uid, thishdr_nParagraphs; | 790 | UInt16 thishdr_uid, thishdr_nParagraphs; |
793 | UInt32 thishdr_size; | 791 | UInt32 thishdr_size; |
794 | UInt8 thishdr_type, thishdr_reserved; | 792 | UInt8 thishdr_type, thishdr_reserved; |
795 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 793 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
796 | if (thishdr_uid == homerecid) | 794 | if (thishdr_uid == homerecid) |
797 | { | 795 | { |
798 | m_homepos = textlength; | 796 | m_homepos = textlength; |
799 | break; | 797 | break; |
800 | } | 798 | } |
801 | if (thishdr_type < 2) textlength += thishdr_size; | 799 | if (thishdr_type < 2) textlength += thishdr_size; |
802 | } | 800 | } |
803 | qDebug("Found home"); | 801 | qDebug("Found home"); |
804 | textlength = 0; | 802 | textlength = 0; |
805 | home(); | 803 | home(); |
806 | qDebug("Gone home"); | 804 | qDebug("Gone home"); |
807 | #ifdef LOCALPICTURES | 805 | #ifdef LOCALPICTURES |
808 | if (m_viewer == NULL) | 806 | if (m_viewer == NULL) |
809 | { | 807 | { |
810 | m_viewer = new QScrollView(NULL); | 808 | m_viewer = new QScrollView(NULL); |
811 | m_picture = new QWidget(m_viewer->viewport()); | 809 | m_picture = new QWidget(m_viewer->viewport()); |
812 | m_viewer->addChild(m_picture); | 810 | m_viewer->addChild(m_picture); |
813 | } | 811 | } |
814 | #endif | 812 | #endif |
815 | return 0; | 813 | return 0; |
816 | 814 | ||
817 | } | 815 | } |
818 | 816 | ||
819 | QImage* CPlucker_base::getimg(UInt16 tgt) | 817 | QImage* CPlucker_base::getimg(UInt16 tgt) |
820 | { | 818 | { |
821 | size_t reclen; | 819 | size_t reclen; |
822 | UInt16 thisrec = finduid(tgt); | 820 | UInt16 thisrec = finduid(tgt); |
823 | qDebug("getimg:Found %u from uid:%u", thisrec, tgt); | 821 | qDebug("getimg:Found %u from uid:%u", thisrec, tgt); |
824 | reclen = recordlength(thisrec); | 822 | reclen = recordlength(thisrec); |
825 | gotorecordnumber(thisrec); | 823 | gotorecordnumber(thisrec); |
826 | UInt16 thishdr_uid, thishdr_nParagraphs; | 824 | UInt16 thishdr_uid, thishdr_nParagraphs; |
827 | UInt32 thishdr_size; | 825 | UInt32 thishdr_size; |
828 | UInt8 thishdr_type, thishdr_reserved; | 826 | UInt8 thishdr_type, thishdr_reserved; |
829 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 827 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
830 | if (thishdr_type == 15) | 828 | if (thishdr_type == 15) |
831 | { | 829 | { |
832 | char *buffer = new char[thishdr_size]; | 830 | char *buffer = new char[thishdr_size]; |
833 | fread(buffer, thishdr_size, sizeof(char), fin); | 831 | fread(buffer, thishdr_size, sizeof(char), fin); |
834 | unsigned short tmp; | 832 | unsigned short tmp; |
835 | memcpy(&tmp, buffer, sizeof(tmp)); | 833 | memcpy(&tmp, buffer, sizeof(tmp)); |
836 | unsigned short cols = ntohs(tmp); | 834 | unsigned short cols = ntohs(tmp); |
837 | memcpy(&tmp, buffer+sizeof(tmp), sizeof(tmp)); | 835 | memcpy(&tmp, buffer+sizeof(tmp), sizeof(tmp)); |
838 | unsigned short rows = ntohs(tmp); | 836 | unsigned short rows = ntohs(tmp); |
839 | qDebug("Found a picture of type:%u [%u,%u]", thishdr_type, rows, cols); | 837 | qDebug("Found a picture of type:%u [%u,%u]", thishdr_type, rows, cols); |
840 | QImage*** images; | 838 | QImage*** images; |
841 | images = new QImage**[rows]; | 839 | images = new QImage**[rows]; |
842 | #ifdef _WINDOWS | 840 | #ifdef _WINDOWS |
843 | int i; | 841 | int i; |
844 | for (i = 0; i < rows; i++) | 842 | for (i = 0; i < rows; i++) |
845 | #else | 843 | #else |
846 | for (int i = 0; i < rows; i++) | 844 | for (int i = 0; i < rows; i++) |
847 | #endif | 845 | #endif |
848 | { | 846 | { |
849 | images[i] = new QImage*[cols]; | 847 | images[i] = new QImage*[cols]; |
850 | } | 848 | } |
851 | int height = 0; | 849 | int height = 0; |
852 | int width = 0; | 850 | int width = 0; |
853 | #ifdef _WINDOWS | 851 | #ifdef _WINDOWS |
854 | for (i = 0; i < rows; i++) | 852 | for (i = 0; i < rows; i++) |
855 | #else | 853 | #else |
856 | for (int i = 0; i < rows; i++) | 854 | for (int i = 0; i < rows; i++) |
857 | #endif | 855 | #endif |
858 | { | 856 | { |
859 | width = 0; | 857 | width = 0; |
860 | for (int j = 0; j < cols; j++) | 858 | for (int j = 0; j < cols; j++) |
861 | { | 859 | { |
862 | memcpy(&tmp, buffer+(i*cols+j+2)*sizeof(tmp), sizeof(tmp)); | 860 | memcpy(&tmp, buffer+(i*cols+j+2)*sizeof(tmp), sizeof(tmp)); |
863 | unsigned short uid = ntohs(tmp); | 861 | unsigned short uid = ntohs(tmp); |
864 | images[i][j] = getimg(uid); | 862 | images[i][j] = getimg(uid); |
865 | width += images[i][j]->width(); | 863 | width += images[i][j]->width(); |
866 | } | 864 | } |
867 | height += images[i][0]->height(); | 865 | height += images[i][0]->height(); |
868 | } | 866 | } |
869 | delete [] buffer; | 867 | delete [] buffer; |
870 | QPixmap pm(width, height); | 868 | QPixmap pm(width, height); |
871 | int hoffset = 0; | 869 | int hoffset = 0; |
872 | #ifdef _WINDOWS | 870 | #ifdef _WINDOWS |
873 | for (i = 0; i < rows; i++) | 871 | for (i = 0; i < rows; i++) |
874 | #else | 872 | #else |
875 | for (int i = 0; i < rows; i++) | 873 | for (int i = 0; i < rows; i++) |
876 | #endif | 874 | #endif |
877 | { | 875 | { |
878 | int woffset = 0; | 876 | int woffset = 0; |
879 | int delht = images[i][0]->height(); | 877 | int delht = images[i][0]->height(); |
880 | for (int j = 0; j < cols; j++) | 878 | for (int j = 0; j < cols; j++) |
881 | { | 879 | { |
882 | QPixmap pm2; | 880 | QPixmap pm2; |
883 | pm2.convertFromImage(*(images[i][j])); | 881 | pm2.convertFromImage(*(images[i][j])); |
884 | delete images[i][j]; | 882 | delete images[i][j]; |
885 | bitBlt(&pm, woffset, hoffset, &pm2, 0, 0, pm2.width(), pm2.height()); | 883 | bitBlt(&pm, woffset, hoffset, &pm2, 0, 0, pm2.width(), pm2.height()); |
886 | woffset += pm2.width(); | 884 | woffset += pm2.width(); |
887 | } | 885 | } |
888 | hoffset += delht; | 886 | hoffset += delht; |
889 | } | 887 | } |
890 | #ifdef _WINDOWS | 888 | #ifdef _WINDOWS |
891 | for (i = 0; i < rows; i++) | 889 | for (i = 0; i < rows; i++) |
892 | #else | 890 | #else |
893 | for (int i = 0; i < rows; i++) | 891 | for (int i = 0; i < rows; i++) |
894 | #endif | 892 | #endif |
895 | { | 893 | { |
896 | delete [] images[i]; | 894 | delete [] images[i]; |
897 | } | 895 | } |
898 | delete [] images; | 896 | delete [] images; |
899 | return new QImage(pm.convertToImage()); | 897 | return new QImage(pm.convertToImage()); |
900 | } | 898 | } |
901 | else | 899 | else |
902 | { | 900 | { |
903 | qDebug("Found a picture of type:%u", thishdr_type); | 901 | qDebug("Found a picture of type:%u", thishdr_type); |
904 | reclen -= HeaderSize(); | 902 | reclen -= HeaderSize(); |
905 | 903 | ||
906 | UInt32 imgsize = thishdr_size; | 904 | UInt32 imgsize = thishdr_size; |
907 | UInt8* imgbuffer = new UInt8[imgsize]; | 905 | UInt8* imgbuffer = new UInt8[imgsize]; |
908 | 906 | ||
909 | Expand(reclen, thishdr_type, imgbuffer, imgsize); | 907 | Expand(reclen, thishdr_type, imgbuffer, imgsize); |
910 | 908 | ||
911 | return imagefromdata(imgbuffer, imgsize); | 909 | return imagefromdata(imgbuffer, imgsize); |
912 | } | 910 | } |
913 | } | 911 | } |
914 | 912 | ||
915 | linkType CPlucker_base::hyperlink(unsigned int n, unsigned int offset, QString& wrd, QString&) | 913 | linkType CPlucker_base::hyperlink(unsigned int n, unsigned int offset, QString& wrd, QString&) |
916 | { | 914 | { |
917 | visited.push_front(n); | 915 | visited.push_front(n); |
918 | UInt16 tuid = (n >> 16); | 916 | UInt16 tuid = (n >> 16); |
919 | n &= 0xffff; | 917 | n &= 0xffff; |
920 | char *turl = geturl(tuid); | 918 | char *turl = geturl(tuid); |
921 | if (turl != NULL) | 919 | if (turl != NULL) |
922 | { | 920 | { |
923 | qDebug("URL in PB:%s", turl); | 921 | qDebug("URL in PB:%s", turl); |
924 | wrd = turl; | 922 | wrd = turl; |
925 | delete [] turl; | 923 | delete [] turl; |
926 | } | 924 | } |
927 | else | 925 | else |
928 | { | 926 | { |
929 | wrd.truncate(0); | 927 | wrd.truncate(0); |
930 | } | 928 | } |
931 | qDebug("Hyper: UID:%u, Para:%u, Offset:%u", tuid, n, offset); | 929 | qDebug("Hyper: UID:%u, Para:%u, Offset:%u", tuid, n, offset); |
932 | UInt16 thisrec = 1; | 930 | UInt16 thisrec = 1; |
933 | currentpos = 0; | 931 | currentpos = 0; |
934 | gotorecordnumber(thisrec); | 932 | gotorecordnumber(thisrec); |
935 | UInt16 thishdr_uid, thishdr_nParagraphs; | 933 | UInt16 thishdr_uid, thishdr_nParagraphs; |
936 | UInt32 thishdr_size; | 934 | UInt32 thishdr_size; |
937 | UInt8 thishdr_type, thishdr_reserved; | 935 | UInt8 thishdr_type, thishdr_reserved; |
938 | while (1) | 936 | while (1) |
939 | { | 937 | { |
940 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 938 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
941 | if (tuid == thishdr_uid) break; | 939 | if (tuid == thishdr_uid) break; |
942 | if (thishdr_type < 2) currentpos += thishdr_size; | 940 | if (thishdr_type < 2) currentpos += thishdr_size; |
943 | ////qDebug("hyper-cp:%u", currentpos); | 941 | ////qDebug("hyper-cp:%u", currentpos); |
944 | thisrec++; | 942 | thisrec++; |
945 | if (thisrec >= ntohs(head.recordList.numRecords)) | 943 | if (thisrec >= ntohs(head.recordList.numRecords)) |
946 | { | 944 | { |
947 | if (wrd.isEmpty()) | 945 | if (wrd.isEmpty()) |
948 | { | 946 | { |
949 | QMessageBox::information(NULL, | 947 | QMessageBox::information(NULL, |
950 | QString(PROGNAME), | 948 | QString(PROGNAME), |
951 | QString("Couldn't find link") | 949 | QString("Couldn't find link") |
952 | ); | 950 | ); |
953 | } | 951 | } |
954 | else | 952 | else |
955 | { | 953 | { |
956 | #ifdef USEQPE | 954 | #ifdef USEQPE |
957 | if (wrd.length() > 10) | 955 | if (wrd.length() > 10) |
958 | { | 956 | { |
959 | Global::statusMessage(wrd.left(8) + ".."); | 957 | Global::statusMessage(wrd.left(8) + ".."); |
960 | } | 958 | } |
961 | else | 959 | else |
962 | { | 960 | { |
963 | Global::statusMessage(wrd); | 961 | Global::statusMessage(wrd); |
964 | } | 962 | } |
965 | #else | 963 | #else |
966 | #endif /* USEQPE */ | 964 | #endif /* USEQPE */ |
967 | //qDebug("Link:%s", (const char*)wrd); | 965 | //qDebug("Link:%s", (const char*)wrd); |
968 | // setlink(fn, wrd); | 966 | // setlink(fn, wrd); |
969 | } | 967 | } |
970 | return eNone; | 968 | return eNone; |
971 | } | 969 | } |
972 | gotorecordnumber(thisrec); | 970 | gotorecordnumber(thisrec); |
973 | } | 971 | } |
974 | if (thishdr_type > 1) | 972 | if (thishdr_type > 1) |
975 | { | 973 | { |
976 | if (thishdr_type == 4) | 974 | if (thishdr_type == 4) |
977 | { | 975 | { |
978 | QMessageBox::information(NULL, | 976 | QMessageBox::information(NULL, |
979 | QString(PROGNAME), | 977 | QString(PROGNAME), |
980 | QString("Mailto links\nnot yet supported (2)")); | 978 | QString("Mailto links\nnot yet supported (2)")); |
981 | } | 979 | } |
982 | else | 980 | else |
983 | { | 981 | { |
984 | if (thishdr_type > 3 && thishdr_type != 15) | 982 | if (thishdr_type > 3 && thishdr_type != 15) |
985 | { | 983 | { |
986 | QMessageBox::information(NULL, | 984 | QMessageBox::information(NULL, |
987 | QString(PROGNAME), | 985 | QString(PROGNAME), |
988 | QString("External links\nnot yet supported (2)") | 986 | QString("External links\nnot yet supported (2)") |
989 | ); | 987 | ); |
990 | return eNone; | 988 | return eNone; |
991 | } | 989 | } |
992 | else | 990 | else |
993 | { | 991 | { |
994 | #ifdef LOCALPICTURES | 992 | #ifdef LOCALPICTURES |
995 | showimg(tuid); | 993 | showimg(tuid); |
996 | #else | 994 | #else |
997 | return ePicture; | 995 | return ePicture; |
998 | #endif | 996 | #endif |
999 | } | 997 | } |
1000 | } | 998 | } |
1001 | return eNone; | 999 | return eNone; |
1002 | } | 1000 | } |
1003 | /* | 1001 | /* |
1004 | if (thishdr_type == 2 || thishdr_type == 3) | 1002 | if (thishdr_type == 2 || thishdr_type == 3) |
1005 | { | 1003 | { |
1006 | expandimg(thisrec); | 1004 | expandimg(thisrec); |
1007 | 1005 | ||
1008 | } | 1006 | } |
1009 | */ | 1007 | */ |
1010 | else | 1008 | else |
1011 | { | 1009 | { |
1012 | expand(thisrec); | 1010 | expand(thisrec); |
1013 | unsigned int paraoffset = offset; | 1011 | unsigned int paraoffset = offset; |
1014 | // unsigned int noff = 0; | 1012 | // unsigned int noff = 0; |
1015 | if (n != 0) | 1013 | if (n != 0) |
1016 | { | 1014 | { |
1017 | if (n >= m_nParas) | 1015 | if (n >= m_nParas) |
1018 | { | 1016 | { |
1019 | QMessageBox::information(NULL, | 1017 | QMessageBox::information(NULL, |
1020 | QString(PROGNAME), | 1018 | QString(PROGNAME), |
1021 | QString("Error in link\nPara # too big") | 1019 | QString("Error in link\nPara # too big") |
1022 | ); | 1020 | ); |
1023 | return eNone; | 1021 | return eNone; |
1024 | } | 1022 | } |
1025 | unsigned int noff = 0; | 1023 | unsigned int noff = 0; |
1026 | for (unsigned int i = 0; i < n; i++) noff += m_ParaOffsets[i]; | 1024 | for (unsigned int i = 0; i < n; i++) noff += m_ParaOffsets[i]; |
1027 | 1025 | ||
1028 | paraoffset += noff; | 1026 | paraoffset += noff; |
1029 | } | 1027 | } |
1030 | if (paraoffset > thishdr_size) | 1028 | if (paraoffset > thishdr_size) |
1031 | { | 1029 | { |
1032 | QMessageBox::information(NULL, | 1030 | QMessageBox::information(NULL, |
1033 | QString(PROGNAME), | 1031 | QString(PROGNAME), |
1034 | QString("Error in link\nOffset too big") | 1032 | QString("Error in link\nOffset too big") |
1035 | ); | 1033 | ); |
1036 | return eNone; | 1034 | return eNone; |
1037 | } | 1035 | } |
1038 | while (bufferpos < paraoffset && bufferpos < buffercontent) getch_base(true); | 1036 | while (bufferpos < paraoffset && bufferpos < buffercontent) getch_base(true); |
1039 | //qDebug("Hyper:<%u,%u,%u>", paraoffset, bufferpos, currentpos); | 1037 | //qDebug("Hyper:<%u,%u,%u>", paraoffset, bufferpos, currentpos); |
1040 | /* // This is faster but the alignment doesn't get set | 1038 | /* // This is faster but the alignment doesn't get set |
1041 | mystyle.unset(); | 1039 | mystyle.unset(); |
1042 | bufferpos = n; | 1040 | bufferpos = n; |
1043 | currentpos += n; | 1041 | currentpos += n; |
1044 | while (bufferpos >= m_nextPara && m_nextPara >= 0) | 1042 | while (bufferpos >= m_nextPara && m_nextPara >= 0) |
1045 | { | 1043 | { |
1046 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; | 1044 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; |
1047 | m_nextParaIndex++; | 1045 | m_nextParaIndex++; |
1048 | if (m_nextParaIndex == m_nParas) | 1046 | if (m_nextParaIndex == m_nParas) |
1049 | { | 1047 | { |
1050 | m_nextPara = -1; | 1048 | m_nextPara = -1; |
1051 | } | 1049 | } |
1052 | else | 1050 | else |
1053 | { | 1051 | { |
1054 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | 1052 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; |
1055 | } | 1053 | } |
1056 | } | 1054 | } |
1057 | */ | 1055 | */ |
1058 | } | 1056 | } |
1059 | return eLink; | 1057 | return eLink; |
1060 | } | 1058 | } |
1061 | 1059 | ||
1062 | tchar CPlucker_base::getch_base(bool fast) | 1060 | tchar CPlucker_base::getch_base(bool fast) |
1063 | { | 1061 | { |
1064 | int ch = bgetch(); | 1062 | int ch = bgetch(); |
1065 | while (ch == 0) | 1063 | while (ch == 0) |
1066 | { | 1064 | { |
1067 | ch = bgetch(); | 1065 | ch = bgetch(); |
1068 | ////qDebug("Function:%x", ch); | 1066 | ////qDebug("Function:%x", ch); |
1069 | switch (ch) | 1067 | switch (ch) |
1070 | { | 1068 | { |
1071 | case 0x38: | 1069 | case 0x38: |
1072 | // //qDebug("Break:%u", locate()); | 1070 | // //qDebug("Break:%u", locate()); |
1073 | if (m_lastBreak == locate()) | 1071 | if (m_lastBreak == locate()) |
1074 | { | 1072 | { |
1075 | ch = bgetch(); | 1073 | ch = bgetch(); |
1076 | } | 1074 | } |
1077 | else | 1075 | else |
1078 | { | 1076 | { |
1079 | ch = 10; | 1077 | ch = 10; |
1080 | } | 1078 | } |
1081 | m_lastBreak = locate(); | 1079 | m_lastBreak = locate(); |
1082 | break; | 1080 | break; |
1083 | case 0x0a: | 1081 | case 0x0a: |
1084 | case 0x0c: | 1082 | case 0x0c: |
1085 | { | 1083 | { |
1086 | unsigned long ln = 0; | 1084 | unsigned long ln = 0; |
1087 | int skip = ch & 7; | 1085 | int skip = ch & 7; |
1088 | for (int i = 0; i < 2; i++) | 1086 | for (int i = 0; i < 2; i++) |
1089 | { | 1087 | { |
1090 | int ch = bgetch(); | 1088 | int ch = bgetch(); |
1091 | ln = (ln << 8) + ch; | 1089 | ln = (ln << 8) + ch; |
1092 | // //qDebug("ch:%d, ln:%u", ch, ln); | 1090 | // //qDebug("ch:%d, ln:%u", ch, ln); |
1093 | } | 1091 | } |
1094 | if (skip == 2) | 1092 | if (skip == 2) |
1095 | { | 1093 | { |
1096 | ln <<= 16; | 1094 | ln <<= 16; |
1097 | } | 1095 | } |
1098 | else | 1096 | else |
1099 | { | 1097 | { |
1100 | for (int i = 0; i < 2; i++) | 1098 | for (int i = 0; i < 2; i++) |
1101 | { | 1099 | { |
1102 | int ch = bgetch(); | 1100 | int ch = bgetch(); |
1103 | ln = (ln << 8) + ch; | 1101 | ln = (ln << 8) + ch; |
1104 | // //qDebug("ch:%d, ln:%u", ch, ln); | 1102 | // //qDebug("ch:%d, ln:%u", ch, ln); |
1105 | } | 1103 | } |
1106 | } | 1104 | } |
1107 | // //qDebug("ln:%u", ln); | 1105 | // //qDebug("ln:%u", ln); |
1108 | mystyle.setLink(true); | 1106 | mystyle.setLink(true); |
1109 | mystyle.setData(ln); | 1107 | mystyle.setData(ln); |
1110 | // mystyle.setColour(255, 0, 0); | 1108 | // mystyle.setColour(255, 0, 0); |
1111 | bool hasseen = false; | 1109 | bool hasseen = false; |
1112 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | 1110 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) |
1113 | { | 1111 | { |
1114 | if (*it == ln) | 1112 | if (*it == ln) |
1115 | { | 1113 | { |
1116 | hasseen = true; | 1114 | hasseen = true; |
1117 | break; | 1115 | break; |
1118 | } | 1116 | } |
1119 | } | 1117 | } |
1120 | if (hasseen) | 1118 | if (hasseen) |
1121 | { | 1119 | { |
1122 | mystyle.setStrikethru(); | 1120 | mystyle.setStrikethru(); |
1123 | } | 1121 | } |
1124 | else | 1122 | else |
1125 | { | 1123 | { |
1126 | mystyle.setUnderline(); | 1124 | mystyle.setUnderline(); |
1127 | } | 1125 | } |
1128 | mystyle.setOffset(m_offset); | 1126 | mystyle.setOffset(m_offset); |
1129 | m_offset = 0; | 1127 | m_offset = 0; |
1130 | ch = bgetch(); | 1128 | ch = bgetch(); |
1131 | } | 1129 | } |
1132 | break; | 1130 | break; |
1133 | case 0x08: | 1131 | case 0x08: |
1134 | ch = bgetch(); | 1132 | ch = bgetch(); |
1135 | // mystyle.setColour(0, 0, 0); | 1133 | // mystyle.setColour(0, 0, 0); |
1136 | mystyle.unsetUnderline(); | 1134 | mystyle.unsetUnderline(); |
1137 | mystyle.unsetStrikethru(); | 1135 | mystyle.unsetStrikethru(); |
1138 | mystyle.setLink(false); | 1136 | mystyle.setLink(false); |
1139 | mystyle.setData(0); | 1137 | mystyle.setData(0); |
1140 | break; | 1138 | break; |
1141 | case 0x40: | 1139 | case 0x40: |
1142 | mystyle.setItalic(); | 1140 | mystyle.setItalic(); |
1143 | ch = bgetch(); | 1141 | ch = bgetch(); |
1144 | break; | 1142 | break; |
1145 | case 0x48: | 1143 | case 0x48: |
1146 | mystyle.unsetItalic(); | 1144 | mystyle.unsetItalic(); |
1147 | ch = bgetch(); | 1145 | ch = bgetch(); |
1148 | break; | 1146 | break; |
1149 | case 0x11: | 1147 | case 0x11: |
1150 | { | 1148 | { |
1151 | ch = bgetch(); | 1149 | ch = bgetch(); |
1152 | // //qDebug("Font:%d",ch); | 1150 | // //qDebug("Font:%d",ch); |
1153 | mystyle.setVOffset(0); | 1151 | mystyle.setVOffset(0); |
1154 | mystyle.unsetMono(); | 1152 | mystyle.unsetMono(); |
1155 | mystyle.unsetBold(); | 1153 | mystyle.unsetBold(); |
1156 | switch (ch) | 1154 | switch (ch) |
1157 | { | 1155 | { |
1158 | case 0: | 1156 | case 0: |
1159 | mystyle.setFontSize(0); | 1157 | mystyle.setFontSize(0); |
1160 | break; | 1158 | break; |
1161 | case 1: | 1159 | case 1: |
1162 | mystyle.setFontSize(3); | 1160 | mystyle.setFontSize(3); |
1163 | mystyle.setBold(); | 1161 | mystyle.setBold(); |
1164 | break; | 1162 | break; |
1165 | case 2: | 1163 | case 2: |
1166 | mystyle.setFontSize(2); | 1164 | mystyle.setFontSize(2); |
1167 | mystyle.setBold(); | 1165 | mystyle.setBold(); |
1168 | break; | 1166 | break; |
1169 | case 3: | 1167 | case 3: |
1170 | mystyle.setFontSize(1); | 1168 | mystyle.setFontSize(1); |
1171 | mystyle.setBold(); | 1169 | mystyle.setBold(); |
1172 | break; | 1170 | break; |
1173 | case 4: | 1171 | case 4: |
1174 | mystyle.setFontSize(0); | 1172 | mystyle.setFontSize(0); |
1175 | mystyle.setBold(); | 1173 | mystyle.setBold(); |
1176 | break; | 1174 | break; |
1177 | case 5: | 1175 | case 5: |
1178 | mystyle.setFontSize(0); | 1176 | mystyle.setFontSize(0); |
1179 | mystyle.setBold(); | 1177 | mystyle.setBold(); |
1180 | break; | 1178 | break; |
1181 | case 6: | 1179 | case 6: |
1182 | mystyle.setFontSize(0); | 1180 | mystyle.setFontSize(0); |
1183 | mystyle.setBold(); | 1181 | mystyle.setBold(); |
1184 | break; | 1182 | break; |
1185 | case 7: | 1183 | case 7: |
1186 | mystyle.setFontSize(0); | 1184 | mystyle.setFontSize(0); |
1187 | mystyle.setBold(); | 1185 | mystyle.setBold(); |
1188 | break; | 1186 | break; |
1189 | case 8: // should be fixed width | 1187 | case 8: // should be fixed width |
1190 | //qDebug("Trying fixed width"); | 1188 | //qDebug("Trying fixed width"); |
1191 | mystyle.setFontSize(0); | 1189 | mystyle.setFontSize(0); |
1192 | mystyle.setMono(); | 1190 | mystyle.setMono(); |
1193 | break; | 1191 | break; |
1194 | case 9: | 1192 | case 9: |
1195 | // mystyle.setFontSize(mystyle.getFontSize()); | 1193 | // mystyle.setFontSize(mystyle.getFontSize()); |
1196 | mystyle.setFontSize(-1); | 1194 | mystyle.setFontSize(-1); |
1197 | break; | 1195 | break; |
1198 | case 10: | 1196 | case 10: |
1199 | mystyle.setFontSize(-2); | 1197 | mystyle.setFontSize(-2); |
1200 | mystyle.setVOffset(1); | 1198 | mystyle.setVOffset(1); |
1201 | break; | 1199 | break; |
1202 | case 11: | 1200 | case 11: |
1203 | mystyle.setFontSize(-2); | 1201 | mystyle.setFontSize(-2); |
1204 | mystyle.setVOffset(-1); | 1202 | mystyle.setVOffset(-1); |
1205 | break; | 1203 | break; |
1206 | default: | 1204 | default: |
1207 | qDebug("Unrecognised font"); | 1205 | qDebug("Unrecognised font"); |
1208 | break; | 1206 | break; |
1209 | } | 1207 | } |
1210 | ch = bgetch(); | 1208 | ch = bgetch(); |
1211 | } | 1209 | } |
1212 | break; | 1210 | break; |
1213 | case 0x29: | 1211 | case 0x29: |
1214 | ch = bgetch(); | 1212 | ch = bgetch(); |
1215 | switch (ch) | 1213 | switch (ch) |
1216 | { | 1214 | { |
1217 | case 0: | 1215 | case 0: |
1218 | mystyle.setLeftJustify(); | 1216 | mystyle.setLeftJustify(); |
1219 | // //qDebug("left"); | 1217 | // //qDebug("left"); |
1220 | break; | 1218 | break; |
1221 | case 1: | 1219 | case 1: |
1222 | mystyle.setRightJustify(); | 1220 | mystyle.setRightJustify(); |
1223 | // //qDebug("right"); | 1221 | // //qDebug("right"); |
1224 | break; | 1222 | break; |
1225 | case 2: | 1223 | case 2: |
1226 | mystyle.setCentreJustify(); | 1224 | mystyle.setCentreJustify(); |
1227 | // //qDebug("centre"); | 1225 | // //qDebug("centre"); |
1228 | break; | 1226 | break; |
1229 | case 3: | 1227 | case 3: |
1230 | mystyle.setFullJustify(); | 1228 | mystyle.setFullJustify(); |
1231 | // //qDebug("full"); | 1229 | // //qDebug("full"); |
1232 | break; | 1230 | break; |
1233 | 1231 | ||
1234 | } | 1232 | } |
1235 | ch = bgetch(); | 1233 | ch = bgetch(); |
1236 | break; | 1234 | break; |
1237 | case 0x53: | 1235 | case 0x53: |
1238 | { | 1236 | { |
1239 | int r = bgetch(); | 1237 | int r = bgetch(); |
1240 | int g = bgetch(); | 1238 | int g = bgetch(); |
1241 | int b = bgetch(); | 1239 | int b = bgetch(); |
1242 | mystyle.setColour(r,g,b); | 1240 | mystyle.setColour(r,g,b); |
1243 | ch = bgetch(); | 1241 | ch = bgetch(); |
1244 | } | 1242 | } |
1245 | break; | 1243 | break; |
1246 | case 0x1a: | 1244 | case 0x1a: |
1247 | case 0x5c: | 1245 | case 0x5c: |
1248 | { | 1246 | { |
1249 | bool hasalternate = (ch == 0x5c); | 1247 | bool hasalternate = (ch == 0x5c); |
1250 | UInt16 ir = bgetch(); | 1248 | UInt16 ir = bgetch(); |
1251 | ir = (ir << 8) + bgetch(); | 1249 | ir = (ir << 8) + bgetch(); |
1252 | if (hasalternate) | 1250 | if (hasalternate) |
1253 | { | 1251 | { |
1254 | //qDebug("Alternate image:%x", ir); | 1252 | //qDebug("Alternate image:%x", ir); |
1255 | UInt16 ir2 = bgetch(); | 1253 | UInt16 ir2 = bgetch(); |
1256 | ir2 = (ir2 << 8) + bgetch(); | 1254 | ir2 = (ir2 << 8) + bgetch(); |
1257 | if (!fast) mystyle.setPicture(true, expandimg(ir2, true), true, ir << 16); | 1255 | if (!fast) mystyle.setPicture(true, expandimg(ir2, true), true, ir << 16); |
1258 | #ifdef LOCALPICTURES | 1256 | #ifdef LOCALPICTURES |
1259 | UInt32 ln = ir; | 1257 | UInt32 ln = ir; |
1260 | ln <<= 16; | 1258 | ln <<= 16; |
1261 | mystyle.setLink(true); | 1259 | mystyle.setLink(true); |
1262 | mystyle.setData(ln); | 1260 | mystyle.setData(ln); |
1263 | #endif | 1261 | #endif |
1264 | } | 1262 | } |
1265 | else | 1263 | else |
1266 | { | 1264 | { |
1267 | if (!fast) mystyle.setPicture(true, expandimg(ir)); | 1265 | if (!fast) mystyle.setPicture(true, expandimg(ir)); |
1268 | } | 1266 | } |
1269 | // if (mystyle.getLink()) qDebug("Picture link!"); | 1267 | // if (mystyle.getLink()) qDebug("Picture link!"); |
1270 | ch = '#'; | 1268 | ch = '#'; |
1271 | } | 1269 | } |
1272 | // ch = bgetch(); | 1270 | // ch = bgetch(); |
1273 | break; | 1271 | break; |
1274 | case 0x33: | 1272 | case 0x33: |
1275 | { | 1273 | { |
1276 | UInt8 h = bgetch(); | 1274 | UInt8 h = bgetch(); |
1277 | UInt8 wc = bgetch(); | 1275 | UInt8 wc = bgetch(); |
1278 | UInt8 pc = bgetch(); | 1276 | UInt8 pc = bgetch(); |
1279 | UInt16 w = wc; | 1277 | UInt16 w = wc; |
1280 | // //qDebug("h,w,pc [%u, %u, %u]", h, w, pc); | 1278 | // //qDebug("h,w,pc [%u, %u, %u]", h, w, pc); |
1281 | if (w == 0) | 1279 | if (w == 0) |
1282 | { | 1280 | { |
1283 | w = (m_scrWidth*(unsigned long)pc)/100; | 1281 | w = (m_scrWidth*(unsigned long)pc)/100; |
1284 | } | 1282 | } |
1285 | if (w == 0) w = m_scrWidth; | 1283 | if (w == 0) w = m_scrWidth; |
1286 | mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); | 1284 | mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); |
1287 | // if (mystyle.getLink()) //qDebug("hRule link!"); | 1285 | // if (mystyle.getLink()) //qDebug("hRule link!"); |
1288 | ch = '#'; | 1286 | ch = '#'; |
1289 | } | 1287 | } |
1290 | break; | 1288 | break; |
1291 | case 0x60: | 1289 | case 0x60: |
1292 | mystyle.setUnderline(); | 1290 | mystyle.setUnderline(); |
1293 | ch = bgetch(); | 1291 | ch = bgetch(); |
1294 | break; | 1292 | break; |
1295 | case 0x68: | 1293 | case 0x68: |
1296 | mystyle.unsetUnderline(); | 1294 | mystyle.unsetUnderline(); |
1297 | ch = bgetch(); | 1295 | ch = bgetch(); |
1298 | break; | 1296 | break; |
1299 | case 0x22: | 1297 | case 0x22: |
1300 | ch = bgetch(); | 1298 | ch = bgetch(); |
1301 | mystyle.setLeftMargin(ch); | 1299 | mystyle.setLeftMargin(ch); |
1302 | // //qDebug("Left margin:%d", ch); | 1300 | // //qDebug("Left margin:%d", ch); |
1303 | ch = bgetch(); | 1301 | ch = bgetch(); |
1304 | mystyle.setRightMargin(ch); | 1302 | mystyle.setRightMargin(ch); |
1305 | // //qDebug("Right margin:%d", ch); | 1303 | // //qDebug("Right margin:%d", ch); |
1306 | ch = bgetch(); | 1304 | ch = bgetch(); |
1307 | break; | 1305 | break; |
1308 | case 0x70: | 1306 | case 0x70: |
1309 | mystyle.setStrikethru(); | 1307 | mystyle.setStrikethru(); |
1310 | ch = bgetch(); | 1308 | ch = bgetch(); |
1311 | break; | 1309 | break; |
1312 | case 0x78: | 1310 | case 0x78: |
1313 | mystyle.unsetStrikethru(); | 1311 | mystyle.unsetStrikethru(); |
1314 | ch = bgetch(); | 1312 | ch = bgetch(); |
1315 | break; | 1313 | break; |
1316 | case 0x83: | 1314 | case 0x83: |
1317 | { | 1315 | { |
1318 | int tlen = bgetch(); | 1316 | int tlen = bgetch(); |
1319 | ch = bgetch(); | 1317 | ch = bgetch(); |
1320 | ch <<= 8; | 1318 | ch <<= 8; |
1321 | ch |= (tchar)bgetch(); | 1319 | ch |= (tchar)bgetch(); |
1322 | for (int i = 0; i < tlen; i++) bgetch(); | 1320 | for (int i = 0; i < tlen; i++) bgetch(); |
1323 | //qDebug("Function 83"); | 1321 | //qDebug("Function 83"); |
1324 | } | 1322 | } |
1325 | break; | 1323 | break; |
1326 | case 0x9a: | 1324 | case 0x9a: |
1327 | { | 1325 | { |
1328 | m_offset = 255*bgetch(); | 1326 | m_offset = 255*bgetch(); |
1329 | m_offset += bgetch(); | 1327 | m_offset += bgetch(); |
1330 | qDebug("Found offset:%u", m_offset); | 1328 | qDebug("Found offset:%u", m_offset); |
1331 | ch = bgetch(); | 1329 | ch = bgetch(); |
1332 | } | 1330 | } |
1333 | break; | 1331 | break; |
1334 | case 0x85: | 1332 | case 0x85: |
1335 | default: | 1333 | default: |
1336 | qDebug("Function:%x NOT IMPLEMENTED", ch); | 1334 | qDebug("Function:%x NOT IMPLEMENTED", ch); |
1337 | { | 1335 | { |
1338 | int skip = ch & 7; | 1336 | int skip = ch & 7; |
1339 | for (int i = 0; i < skip; i++) | 1337 | for (int i = 0; i < skip; i++) |
1340 | { | 1338 | { |
1341 | ch = bgetch(); | 1339 | ch = bgetch(); |
1342 | //qDebug("Arg %d, %d", i, ch); | 1340 | //qDebug("Arg %d, %d", i, ch); |
1343 | } | 1341 | } |
1344 | ch = bgetch(); | 1342 | ch = bgetch(); |
1345 | } | 1343 | } |
1346 | } | 1344 | } |
1347 | } | 1345 | } |
1348 | 1346 | ||
1349 | if (m_lastIsBreak && !mystyle.isMono()) | 1347 | if (m_lastIsBreak && !mystyle.isMono()) |
1350 | { | 1348 | { |
1351 | while (ch == ' ') | 1349 | while (ch == ' ') |
1352 | { | 1350 | { |
1353 | ch = getch(false); | 1351 | ch = getch(false); |
1354 | } | 1352 | } |
1355 | } | 1353 | } |
1356 | 1354 | ||
1357 | m_lastIsBreak = (ch == 10); | 1355 | m_lastIsBreak = (ch == 10); |
1358 | 1356 | ||
1359 | return (ch == EOF) ? UEOF : ch; | 1357 | return (ch == EOF) ? UEOF : ch; |
1360 | } | 1358 | } |
1361 | 1359 | ||
1362 | #include "static.h" | ||
1363 | #if defined(__STATIC) && defined(USENEF) | 1360 | #if defined(__STATIC) && defined(USENEF) |
1364 | #include "Model.h" | 1361 | #include "Model.h" |
1365 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) | 1362 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) |
1366 | { | 1363 | { |
1367 | if (_s == "PluckerDecompress3") | 1364 | if (_s == "PluckerDecompress3") |
1368 | { | 1365 | { |
1369 | return PluckerDecompress3; | 1366 | return PluckerDecompress3; |
1370 | } | 1367 | } |
1371 | if (_s == "PluckerDecompress4") | 1368 | if (_s == "PluckerDecompress4") |
1372 | { | 1369 | { |
1373 | return PluckerDecompress4; | 1370 | return PluckerDecompress4; |
1374 | } | 1371 | } |
1375 | return NULL; | 1372 | return NULL; |
1376 | } | 1373 | } |
1377 | #else | 1374 | #else |
1378 | 1375 | ||
1379 | #include "qfileinfo.h" | 1376 | #include "qfileinfo.h" |
1380 | 1377 | ||
1381 | #include <dlfcn.h> | 1378 | #include <dlfcn.h> |
1382 | 1379 | ||
1383 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) | 1380 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) |
1384 | { | 1381 | { |
1385 | QString codecpath(QTReaderUtil::getPluginPath("support")); | 1382 | QString codecpath(QTReaderUtil::getPluginPath("support")); |
1386 | codecpath += "/libpluckerdecompress.so"; | 1383 | codecpath += "/libpluckerdecompress.so"; |
1387 | qDebug("Codec:%s", (const char*)codecpath); | 1384 | qDebug("Codec:%s", (const char*)codecpath); |
1388 | if (QFile::exists(codecpath)) | 1385 | if (QFile::exists(codecpath)) |
1389 | { | 1386 | { |
1390 | qDebug("Codec:%s", (const char*)codecpath); | 1387 | qDebug("Codec:%s", (const char*)codecpath); |
1391 | void* handle = dlopen(codecpath, RTLD_LAZY); | 1388 | void* handle = dlopen(codecpath, RTLD_LAZY); |
1392 | if (handle == 0) | 1389 | if (handle == 0) |
1393 | { | 1390 | { |
1394 | qDebug("Can't find codec:%s", dlerror()); | 1391 | qDebug("Can't find codec:%s", dlerror()); |
1395 | return NULL; | 1392 | return NULL; |
1396 | } | 1393 | } |
1397 | return (void (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s); | 1394 | return (void (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s); |
1398 | } | 1395 | } |
1399 | return NULL; | 1396 | return NULL; |
1400 | } | 1397 | } |
1401 | #endif | 1398 | #endif |
1402 | 1399 | ||
1403 | QString CPlucker_base::about() | 1400 | QString CPlucker_base::about() |
1404 | { | 1401 | { |
1405 | QString abt = "Plucker base codec (c) Tim Wentford"; | 1402 | QString abt = "Plucker base codec (c) Tim Wentford"; |
1406 | if (m_decompress != UnDoc && m_decompress != UnZip) | 1403 | if (m_decompress != UnDoc && m_decompress != UnZip) |
1407 | { | 1404 | { |
1408 | abt += "\nSpecial decompression (c) Tim Wentford"; | 1405 | abt += "\nSpecial decompression (c) Tim Wentford"; |
1409 | } | 1406 | } |
1410 | return abt; | 1407 | return abt; |
1411 | } | 1408 | } |
diff --git a/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro b/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro index bee1a2d..7c2f31e 100644 --- a/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro +++ b/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro | |||
@@ -1,18 +1,18 @@ | |||
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 | 9 | ||
10 | INTERFACES= | 10 | INTERFACES= |
11 | DESTDIR = $(OPIEDIR)/lib | 11 | DESTDIR = $(OPIEDIR)/lib |
12 | TARGET = reader_pluckerbase | 12 | TARGET = reader_pluckerbase |
13 | LIBS += -ldl | 13 | LIBS += -ldl |
14 | 14 | ||
15 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 15 | INCLUDEPATH+= $(OPIEDIR)/include |
16 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 16 | DEPENDPATH+= $(OPIEDIR)/include |
17 | 17 | ||
18 | include ( $(OPIEDIR)/include.pro ) | 18 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/ppm_expander.cpp b/noncore/apps/opie-reader/ppm_expander.cpp index ea5b955..2a4318b 100644 --- a/noncore/apps/opie-reader/ppm_expander.cpp +++ b/noncore/apps/opie-reader/ppm_expander.cpp | |||
@@ -1,116 +1,115 @@ | |||
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 | #include "static.h" | ||
12 | 11 | ||
13 | /*************************************************************************** | 12 | /*************************************************************************** |
14 | * Interface avec les routines de compression | 13 | * Interface avec les routines de compression |
15 | */ | 14 | */ |
16 | 15 | ||
17 | #define METHOD_NB 2 /* nombre total de méthodes de compression */ | 16 | #define METHOD_NB 2 /* nombre total de méthodes de compression */ |
18 | 17 | ||
19 | #define METHOD_STORE 0 | 18 | #define METHOD_STORE 0 |
20 | #define METHOD_PPM 1 | 19 | #define METHOD_PPM 1 |
21 | 20 | ||
22 | 21 | ||
23 | #define DEFAULT_SUFFIX ".st" /* extension par défault */ | 22 | #define DEFAULT_SUFFIX ".st" /* extension par défault */ |
24 | /* signature en début de fichier */ | 23 | /* signature en début de fichier */ |
25 | #define STAT_MAGIC_SIZE 4 | 24 | #define STAT_MAGIC_SIZE 4 |
26 | char stat_magic[STAT_MAGIC_SIZE]={'P','P','M','S'}; | 25 | char stat_magic[STAT_MAGIC_SIZE]={'P','P','M','S'}; |
27 | 26 | ||
28 | #include "ppm_expander.h" | 27 | #include "ppm_expander.h" |
29 | 28 | ||
30 | ppm_expander::~ppm_expander() { | 29 | ppm_expander::~ppm_expander() { |
31 | if (needppmend) ppm.PPM_End(); | 30 | if (needppmend) ppm.PPM_End(); |
32 | ppm.arith.Arith_DecodeEnd(); | 31 | ppm.arith.Arith_DecodeEnd(); |
33 | if (buf_in!=NULL) delete [] buf_in; | 32 | if (buf_in!=NULL) delete [] buf_in; |
34 | if (buf_out!=NULL) delete [] buf_out; | 33 | if (buf_out!=NULL) delete [] buf_out; |
35 | if (my_read_buf != NULL) delete my_read_buf; | 34 | if (my_read_buf != NULL) delete my_read_buf; |
36 | if (my_file_in != NULL) fclose(my_file_in); | 35 | if (my_file_in != NULL) fclose(my_file_in); |
37 | } | 36 | } |
38 | 37 | ||
39 | int ppm_expander::OpenFile(const char* infile) | 38 | int ppm_expander::OpenFile(const char* infile) |
40 | { | 39 | { |
41 | my_file_in=fopen(infile,"rb"); | 40 | my_file_in=fopen(infile,"rb"); |
42 | my_read_buf = new PPM_ReadBuf(my_file_in); | 41 | my_read_buf = new PPM_ReadBuf(my_file_in); |
43 | return home(); | 42 | return home(); |
44 | } | 43 | } |
45 | 44 | ||
46 | void ppm_expander::sizes(unsigned long& file, unsigned long& text) | 45 | void ppm_expander::sizes(unsigned long& file, unsigned long& text) |
47 | { | 46 | { |
48 | struct stat _stat; | 47 | struct stat _stat; |
49 | fstat(fileno(my_file_in),&_stat); | 48 | fstat(fileno(my_file_in),&_stat); |
50 | file = _stat.st_size; | 49 | file = _stat.st_size; |
51 | text = numblocks*blocksize; | 50 | text = numblocks*blocksize; |
52 | } | 51 | } |
53 | 52 | ||
54 | int ppm_expander::home() | 53 | int ppm_expander::home() |
55 | { | 54 | { |
56 | fseek(my_file_in,0, SEEK_SET); | 55 | fseek(my_file_in,0, SEEK_SET); |
57 | unsigned char header[STAT_MAGIC_SIZE]; | 56 | unsigned char header[STAT_MAGIC_SIZE]; |
58 | 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); |
59 | if (strncmp((char*)header,stat_magic,STAT_MAGIC_SIZE)!=0) { | 58 | if (strncmp((char*)header,stat_magic,STAT_MAGIC_SIZE)!=0) { |
60 | return 1; | 59 | return 1; |
61 | } | 60 | } |
62 | if (len!=(STAT_MAGIC_SIZE)) { | 61 | if (len!=(STAT_MAGIC_SIZE)) { |
63 | return 1; | 62 | return 1; |
64 | } | 63 | } |
65 | 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; |
66 | 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; |
67 | 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; |
68 | //fprintf(stderr,"<%u,%u,%u>\n",maxnode,blocksize,numblocks); | 67 | //fprintf(stderr,"<%u,%u,%u>\n",maxnode,blocksize,numblocks); |
69 | locate(0,0); | 68 | locate(0,0); |
70 | outbytes = 0; | 69 | outbytes = 0; |
71 | return 0; | 70 | return 0; |
72 | } | 71 | } |
73 | 72 | ||
74 | void ppm_expander::locate(unsigned int n) { | 73 | void ppm_expander::locate(unsigned int n) { |
75 | locate(n/blocksize, n%blocksize); | 74 | locate(n/blocksize, n%blocksize); |
76 | outbytes = n; | 75 | outbytes = n; |
77 | } | 76 | } |
78 | 77 | ||
79 | void ppm_expander::locate(unsigned short block, unsigned int n) | 78 | void ppm_expander::locate(unsigned short block, unsigned int n) |
80 | { | 79 | { |
81 | if (needppmend) | 80 | if (needppmend) |
82 | { | 81 | { |
83 | ppm.PPM_End(); | 82 | ppm.PPM_End(); |
84 | needppmend = false; | 83 | needppmend = false; |
85 | } | 84 | } |
86 | size_t fpos; | 85 | size_t fpos; |
87 | 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); |
88 | fread(&fpos,sizeof(fpos),1,my_file_in); | 87 | fread(&fpos,sizeof(fpos),1,my_file_in); |
89 | fseek(my_file_in,fpos,SEEK_SET); | 88 | fseek(my_file_in,fpos,SEEK_SET); |
90 | 89 | ||
91 | ppm.arith.Arith_DecodeInit(my_read_buf,buf_in,bufsize); | 90 | ppm.arith.Arith_DecodeInit(my_read_buf,buf_in,bufsize); |
92 | int err=ppm.PPM_Init(maxnode); | 91 | int err=ppm.PPM_Init(maxnode); |
93 | needppmend = true; | 92 | needppmend = true; |
94 | curblock = block; | 93 | curblock = block; |
95 | for (int i = 0; i < n; i++) getch(); | 94 | for (int i = 0; i < n; i++) getch(); |
96 | } | 95 | } |
97 | 96 | ||
98 | int ppm_expander::getch() { | 97 | int ppm_expander::getch() { |
99 | if (curblock >= numblocks) return EOF; | 98 | if (curblock >= numblocks) return EOF; |
100 | int c=ppm.PPM_Decode(); | 99 | int c=ppm.PPM_Decode(); |
101 | if (c == SYM_EOF) | 100 | if (c == SYM_EOF) |
102 | { | 101 | { |
103 | if (++curblock >= numblocks) return EOF; | 102 | if (++curblock >= numblocks) return EOF; |
104 | locate(curblock,0); | 103 | locate(curblock,0); |
105 | c = ppm.PPM_Decode(); | 104 | c = ppm.PPM_Decode(); |
106 | } | 105 | } |
107 | outbytes++; | 106 | outbytes++; |
108 | return (c==SYM_EOF) ? EOF : c; | 107 | return (c==SYM_EOF) ? EOF : c; |
109 | } | 108 | } |
110 | 109 | ||
111 | #ifndef __STATIC | 110 | #ifndef __STATIC |
112 | extern "C" | 111 | extern "C" |
113 | { | 112 | { |
114 | CExpander* newcodec() { return new ppm_expander; } | 113 | CExpander* newcodec() { return new ppm_expander; } |
115 | } | 114 | } |
116 | #endif | 115 | #endif |
diff --git a/noncore/apps/opie-reader/ppm_expander.h b/noncore/apps/opie-reader/ppm_expander.h index a1a3b60..ccc89c2 100644 --- a/noncore/apps/opie-reader/ppm_expander.h +++ b/noncore/apps/opie-reader/ppm_expander.h | |||
@@ -1,62 +1,61 @@ | |||
1 | #ifndef __ppm_expander_h | 1 | #ifndef __ppm_expander_h |
2 | #define __ppm_expander_h | 2 | #define __ppm_expander_h |
3 | 3 | ||
4 | #include "useqpe.h" | ||
5 | #include "CExpander.h" | 4 | #include "CExpander.h" |
6 | #include <sys/stat.h> | 5 | #include <sys/stat.h> |
7 | 6 | ||
8 | 7 | ||
9 | #include "utypes.h" | 8 | #include "utypes.h" |
10 | #include "ppm.h" | 9 | #include "ppm.h" |
11 | #include "arith.h" | 10 | #include "arith.h" |
12 | 11 | ||
13 | 12 | ||
14 | #define SYM_EOF 256 | 13 | #define SYM_EOF 256 |
15 | 14 | ||
16 | class ppm_expander : public CExpander { | 15 | class ppm_expander : public CExpander { |
17 | UCHAR *buf_in,*buf_out; | 16 | UCHAR *buf_in,*buf_out; |
18 | unsigned int bufsize; | 17 | unsigned int bufsize; |
19 | unsigned int outbytes; | 18 | unsigned int outbytes; |
20 | unsigned long blocksize; | 19 | unsigned long blocksize; |
21 | unsigned short numblocks; | 20 | unsigned short numblocks; |
22 | unsigned short curblock; | 21 | unsigned short curblock; |
23 | unsigned short maxnode; | 22 | unsigned short maxnode; |
24 | bool needppmend; | 23 | bool needppmend; |
25 | int home(); | 24 | int home(); |
26 | FILE* my_file_in; | 25 | FILE* my_file_in; |
27 | PPM_ReadBuf* my_read_buf; | 26 | PPM_ReadBuf* my_read_buf; |
28 | ppm_worker ppm; | 27 | ppm_worker ppm; |
29 | public: | 28 | public: |
30 | 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"); } |
31 | #ifdef USEQPE | 30 | #ifdef USEQPE |
32 | void suspend() | 31 | void suspend() |
33 | { | 32 | { |
34 | CExpander::suspend(my_file_in); | 33 | CExpander::suspend(my_file_in); |
35 | } | 34 | } |
36 | void unsuspend() | 35 | void unsuspend() |
37 | { | 36 | { |
38 | CExpander::unsuspend(my_file_in); | 37 | CExpander::unsuspend(my_file_in); |
39 | } | 38 | } |
40 | #endif | 39 | #endif |
41 | ppm_expander() : needppmend(false), my_file_in(NULL), my_read_buf(NULL) | 40 | ppm_expander() : needppmend(false), my_file_in(NULL), my_read_buf(NULL) |
42 | { | 41 | { |
43 | bufsize = 1024; | 42 | bufsize = 1024; |
44 | buf_in = new UCHAR[bufsize]; | 43 | buf_in = new UCHAR[bufsize]; |
45 | buf_out = new UCHAR[bufsize]; | 44 | buf_out = new UCHAR[bufsize]; |
46 | outbytes = 0; | 45 | outbytes = 0; |
47 | } | 46 | } |
48 | int OpenFile(const char* infile); | 47 | int OpenFile(const char* infile); |
49 | int getch(); | 48 | int getch(); |
50 | void locate(unsigned short block, unsigned int n); | 49 | void locate(unsigned short block, unsigned int n); |
51 | virtual ~ppm_expander(); | 50 | virtual ~ppm_expander(); |
52 | unsigned int locate() { return outbytes; } | 51 | unsigned int locate() { return outbytes; } |
53 | void locate(unsigned int n); | 52 | void locate(unsigned int n); |
54 | bool hasrandomaccess() { return (numblocks > 1); } | 53 | bool hasrandomaccess() { return (numblocks > 1); } |
55 | void sizes(unsigned long& file, unsigned long& text); | 54 | void sizes(unsigned long& file, unsigned long& text); |
56 | MarkupType PreferredMarkup() | 55 | MarkupType PreferredMarkup() |
57 | { | 56 | { |
58 | return cTEXT; | 57 | return cTEXT; |
59 | } | 58 | } |
60 | }; | 59 | }; |
61 | 60 | ||
62 | #endif | 61 | #endif |
diff --git a/noncore/apps/opie-reader/ppmsCodec/ppmsCodec.pro b/noncore/apps/opie-reader/ppmsCodec/ppmsCodec.pro index 8699d3b..d6ec97b 100644 --- a/noncore/apps/opie-reader/ppmsCodec/ppmsCodec.pro +++ b/noncore/apps/opie-reader/ppmsCodec/ppmsCodec.pro | |||
@@ -1,19 +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 = Aportis.h | 5 | HEADERS = Aportis.h |
6 | 6 | ||
7 | SOURCES = ppm_expander.cpp \ | 7 | SOURCES = ppm_expander.cpp \ |
8 | ppm.cpp \ | 8 | ppm.cpp \ |
9 | arith_d.cpp | 9 | arith_d.cpp |
10 | 10 | ||
11 | INTERFACES= | 11 | INTERFACES= |
12 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | 12 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs |
13 | TARGET = ppms | 13 | TARGET = ppms |
14 | LIBS += -lreader_codec | 14 | LIBS += -lreader_codec |
15 | 15 | ||
16 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 16 | INCLUDEPATH+= $(OPIEDIR)/include |
17 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 17 | DEPENDPATH+= $(OPIEDIR)/include |
18 | 18 | ||
19 | include ( $(OPIEDIR)/include.pro ) | 19 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/preferences.cpp b/noncore/apps/opie-reader/preferences.cpp index b9397cf..0f59a22 100755 --- a/noncore/apps/opie-reader/preferences.cpp +++ b/noncore/apps/opie-reader/preferences.cpp | |||
@@ -1,105 +1,104 @@ | |||
1 | #include "useqpe.h" | ||
2 | #ifndef USEQPE | 1 | #ifndef USEQPE |
3 | 2 | ||
4 | #include "preferences.h" | 3 | #include "preferences.h" |
5 | 4 | ||
6 | #include <qfile.h> | 5 | #include <qfile.h> |
7 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
8 | 7 | ||
9 | Config::Config(const QString& _fn) : fname(_fn) | 8 | Config::Config(const QString& _fn) : fname(_fn) |
10 | { | 9 | { |
11 | // qDebug("Config::Config:%s", (const char*)fname); | 10 | // qDebug("Config::Config:%s", (const char*)fname); |
12 | QFile fl(fname); | 11 | QFile fl(fname); |
13 | if (fl.open(IO_ReadOnly)) | 12 | if (fl.open(IO_ReadOnly)) |
14 | { | 13 | { |
15 | QTextStream t(&fl); | 14 | QTextStream t(&fl); |
16 | QString key, value; | 15 | QString key, value; |
17 | while (!t.eof()) | 16 | while (!t.eof()) |
18 | { | 17 | { |
19 | QString data = t.readLine(); | 18 | QString data = t.readLine(); |
20 | int colon = data.find(':'); | 19 | int colon = data.find(':'); |
21 | if (colon > 0) | 20 | if (colon > 0) |
22 | { | 21 | { |
23 | QString key = data.left(colon); | 22 | QString key = data.left(colon); |
24 | QString value = data.right(data.length()-colon-1); | 23 | QString value = data.right(data.length()-colon-1); |
25 | values[key] = value; | 24 | values[key] = value; |
26 | } | 25 | } |
27 | } | 26 | } |
28 | fl.close(); | 27 | fl.close(); |
29 | } | 28 | } |
30 | // read entries into values | 29 | // read entries into values |
31 | } | 30 | } |
32 | Config::~Config() | 31 | Config::~Config() |
33 | { | 32 | { |
34 | // qDebug("Config::~Config:%s", (const char*)fname); | 33 | // qDebug("Config::~Config:%s", (const char*)fname); |
35 | QFile fl(fname); | 34 | QFile fl(fname); |
36 | if (fl.open(IO_WriteOnly)) | 35 | if (fl.open(IO_WriteOnly)) |
37 | { | 36 | { |
38 | QTextStream t(&fl); | 37 | QTextStream t(&fl); |
39 | for (QMap<QString,QString>::Iterator iter = values.begin(); | 38 | for (QMap<QString,QString>::Iterator iter = values.begin(); |
40 | iter != values.end(); | 39 | iter != values.end(); |
41 | iter++) | 40 | iter++) |
42 | { | 41 | { |
43 | t << iter.key() << ':' << iter.data() << '\n'; | 42 | t << iter.key() << ':' << iter.data() << '\n'; |
44 | } | 43 | } |
45 | fl.close(); | 44 | fl.close(); |
46 | } | 45 | } |
47 | } | 46 | } |
48 | QString Config::readEntry(const QString& key, const QString& deflt) | 47 | QString Config::readEntry(const QString& key, const QString& deflt) |
49 | { | 48 | { |
50 | QMap<QString,QString>::Iterator iter = values.find(key); | 49 | QMap<QString,QString>::Iterator iter = values.find(key); |
51 | if (iter != values.end()) | 50 | if (iter != values.end()) |
52 | { | 51 | { |
53 | return iter.data(); | 52 | return iter.data(); |
54 | } | 53 | } |
55 | else | 54 | else |
56 | { | 55 | { |
57 | return deflt; | 56 | return deflt; |
58 | } | 57 | } |
59 | } | 58 | } |
60 | bool Config::readBoolEntry(const QString& key, const bool deflt) | 59 | bool Config::readBoolEntry(const QString& key, const bool deflt) |
61 | { | 60 | { |
62 | bool ok; | 61 | bool ok; |
63 | QMap<QString,QString>::Iterator iter = values.find(key); | 62 | QMap<QString,QString>::Iterator iter = values.find(key); |
64 | if (iter != values.end()) | 63 | if (iter != values.end()) |
65 | { | 64 | { |
66 | int ret = iter.data().toInt(&ok); | 65 | int ret = iter.data().toInt(&ok); |
67 | return ((ok) ? !!ret : deflt); | 66 | return ((ok) ? !!ret : deflt); |
68 | } | 67 | } |
69 | else | 68 | else |
70 | { | 69 | { |
71 | return deflt; | 70 | return deflt; |
72 | } | 71 | } |
73 | } | 72 | } |
74 | int Config::readNumEntry(const QString& key, const int deflt) | 73 | int Config::readNumEntry(const QString& key, const int deflt) |
75 | { | 74 | { |
76 | bool ok; | 75 | bool ok; |
77 | QMap<QString,QString>::Iterator iter = values.find(key); | 76 | QMap<QString,QString>::Iterator iter = values.find(key); |
78 | if (iter != values.end()) | 77 | if (iter != values.end()) |
79 | { | 78 | { |
80 | int ret = iter.data().toInt(&ok); | 79 | int ret = iter.data().toInt(&ok); |
81 | return ((ok) ? ret : deflt); | 80 | return ((ok) ? ret : deflt); |
82 | } | 81 | } |
83 | else | 82 | else |
84 | { | 83 | { |
85 | return deflt; | 84 | return deflt; |
86 | } | 85 | } |
87 | } | 86 | } |
88 | void Config::writeEntry(const QString& key, const QString& value) | 87 | void Config::writeEntry(const QString& key, const QString& value) |
89 | { | 88 | { |
90 | values[key] = value; | 89 | values[key] = value; |
91 | } | 90 | } |
92 | 91 | ||
93 | void Config::writeEntry(const QString& key, const bool value) | 92 | void Config::writeEntry(const QString& key, const bool value) |
94 | { | 93 | { |
95 | values[key] = (value) ? "1" : "0"; | 94 | values[key] = (value) ? "1" : "0"; |
96 | } | 95 | } |
97 | 96 | ||
98 | void Config::writeEntry(const QString& key, const int value) | 97 | void Config::writeEntry(const QString& key, const int value) |
99 | { | 98 | { |
100 | QString rhs; | 99 | QString rhs; |
101 | rhs.setNum(value); | 100 | rhs.setNum(value); |
102 | values[key] = rhs; | 101 | values[key] = rhs; |
103 | } | 102 | } |
104 | 103 | ||
105 | #endif | 104 | #endif |
diff --git a/noncore/apps/opie-reader/preferences.h b/noncore/apps/opie-reader/preferences.h index 69d1774..aeb2a84 100644 --- a/noncore/apps/opie-reader/preferences.h +++ b/noncore/apps/opie-reader/preferences.h | |||
@@ -1,27 +1,26 @@ | |||
1 | #include "useqpe.h" | ||
2 | #ifndef USEQPE | 1 | #ifndef USEQPE |
3 | #ifndef __PREFERENCES_H | 2 | #ifndef __PREFERENCES_H |
4 | #define __PREFERENCES_H | 3 | #define __PREFERENCES_H |
5 | 4 | ||
6 | #include <qstring.h> | 5 | #include <qstring.h> |
7 | #include <qmap.h> | 6 | #include <qmap.h> |
8 | 7 | ||
9 | class Config | 8 | class Config |
10 | { | 9 | { |
11 | QMap<QString, QString> values; | 10 | QMap<QString, QString> values; |
12 | QString fname; | 11 | QString fname; |
13 | public: | 12 | public: |
14 | Config(const QString& fname); | 13 | Config(const QString& fname); |
15 | ~Config(); | 14 | ~Config(); |
16 | void setGroup(const QString& s) { } | 15 | void setGroup(const QString& s) { } |
17 | QString readEntry(const QString&, const QString&); | 16 | QString readEntry(const QString&, const QString&); |
18 | bool readBoolEntry(const QString&, const bool); | 17 | bool readBoolEntry(const QString&, const bool); |
19 | int readNumEntry(const QString&, const int); | 18 | int readNumEntry(const QString&, const int); |
20 | 19 | ||
21 | void writeEntry(const QString&, const QString&); | 20 | void writeEntry(const QString&, const QString&); |
22 | void writeEntry(const QString&, const bool); | 21 | void writeEntry(const QString&, const bool); |
23 | void writeEntry(const QString&, const int); | 22 | void writeEntry(const QString&, const int); |
24 | }; | 23 | }; |
25 | 24 | ||
26 | #endif // PREFERENCES | 25 | #endif // PREFERENCES |
27 | #endif | 26 | #endif |
diff --git a/noncore/apps/opie-reader/static.h b/noncore/apps/opie-reader/static.h deleted file mode 100644 index e69de29..0000000 --- a/noncore/apps/opie-reader/static.h +++ b/dev/null | |||
diff --git a/noncore/apps/opie-reader/striphtml.cpp b/noncore/apps/opie-reader/striphtml.cpp index 9cd6a0d..e86402b 100644 --- a/noncore/apps/opie-reader/striphtml.cpp +++ b/noncore/apps/opie-reader/striphtml.cpp | |||
@@ -1,1249 +1,1248 @@ | |||
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 | #include "useqpe.h" | ||
6 | #ifdef USEQPE | 5 | #ifdef USEQPE |
7 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
8 | #endif | 7 | #endif |
9 | #include "CDrawBuffer.h" | 8 | #include "CDrawBuffer.h" |
10 | #include "striphtml.h" | 9 | #include "striphtml.h" |
11 | #include "hrule.h" | 10 | #include "hrule.h" |
12 | #include "util.h" | 11 | #include "util.h" |
13 | 12 | ||
14 | #include <qregexp.h> | 13 | #include <qregexp.h> |
15 | #include <qimage.h> | 14 | #include <qimage.h> |
16 | #include <qpixmap.h> | 15 | #include <qpixmap.h> |
17 | //#include <qprogressdialog.h> | 16 | //#include <qprogressdialog.h> |
18 | //#include <qapplication.h> | 17 | //#include <qapplication.h> |
19 | 18 | ||
20 | static unsigned char h2i(unsigned char c) | 19 | static unsigned char h2i(unsigned char c) |
21 | { | 20 | { |
22 | unsigned char ret = 0; | 21 | unsigned char ret = 0; |
23 | if ('0' <= c && c <= '9') | 22 | if ('0' <= c && c <= '9') |
24 | { | 23 | { |
25 | ret = c - '0'; | 24 | ret = c - '0'; |
26 | } | 25 | } |
27 | else if ('a' <= c && c <= 'f') | 26 | else if ('a' <= c && c <= 'f') |
28 | { | 27 | { |
29 | ret = c - 'a' + 10; | 28 | ret = c - 'a' + 10; |
30 | } | 29 | } |
31 | return ret; | 30 | return ret; |
32 | } | 31 | } |
33 | 32 | ||
34 | static void parse_color(const QString& attr, unsigned char& r, unsigned char& g, unsigned char& b) | 33 | static void parse_color(const QString& attr, unsigned char& r, unsigned char& g, unsigned char& b) |
35 | { | 34 | { |
36 | r = g = b = 0; | 35 | r = g = b = 0; |
37 | if (attr.length() >= 7 && attr[0] == '#') | 36 | if (attr.length() >= 7 && attr[0] == '#') |
38 | { | 37 | { |
39 | r = h2i(attr[1].unicode()); | 38 | r = h2i(attr[1].unicode()); |
40 | r = 16*r + h2i(attr[2].unicode()); | 39 | r = 16*r + h2i(attr[2].unicode()); |
41 | g = h2i(attr[3].unicode()); | 40 | g = h2i(attr[3].unicode()); |
42 | g = 16*g + h2i(attr[4].unicode()); | 41 | g = 16*g + h2i(attr[4].unicode()); |
43 | b = h2i(attr[5].unicode()); | 42 | b = h2i(attr[5].unicode()); |
44 | b = 16*b + h2i(attr[6].unicode()); | 43 | b = 16*b + h2i(attr[6].unicode()); |
45 | } | 44 | } |
46 | else if (attr == "red") | 45 | else if (attr == "red") |
47 | { | 46 | { |
48 | r = 255; | 47 | r = 255; |
49 | } | 48 | } |
50 | else if (attr == "green") | 49 | else if (attr == "green") |
51 | { | 50 | { |
52 | g = 255; | 51 | g = 255; |
53 | } | 52 | } |
54 | else if (attr == "blue") | 53 | else if (attr == "blue") |
55 | { | 54 | { |
56 | b = 255; | 55 | b = 255; |
57 | } | 56 | } |
58 | else if (attr == "white") | 57 | else if (attr == "white") |
59 | { | 58 | { |
60 | r = g = b = 255; | 59 | r = g = b = 255; |
61 | } | 60 | } |
62 | else if (attr == "black") | 61 | else if (attr == "black") |
63 | { | 62 | { |
64 | r = g = b = 0; | 63 | r = g = b = 0; |
65 | } | 64 | } |
66 | else | 65 | else |
67 | { | 66 | { |
68 | qDebug("Don't understand colour \"%s\"", (const char*)attr); | 67 | qDebug("Don't understand colour \"%s\"", (const char*)attr); |
69 | } | 68 | } |
70 | } | 69 | } |
71 | 70 | ||
72 | CNavigation_base<htmlmark> striphtml::m_nav; | 71 | CNavigation_base<htmlmark> striphtml::m_nav; |
73 | 72 | ||
74 | void striphtml::skipblock(const QString& _ent) | 73 | void striphtml::skipblock(const QString& _ent) |
75 | { | 74 | { |
76 | tchar ch = '>'; | 75 | tchar ch = '>'; |
77 | CStyle dummy; | 76 | CStyle dummy; |
78 | QString ent; | 77 | QString ent; |
79 | unsigned long pos; | 78 | unsigned long pos; |
80 | do | 79 | do |
81 | { | 80 | { |
82 | while (ch != '<' && ch != UEOF) | 81 | while (ch != '<' && ch != UEOF) |
83 | { | 82 | { |
84 | mygetch(ch, dummy, pos); | 83 | mygetch(ch, dummy, pos); |
85 | } | 84 | } |
86 | 85 | ||
87 | ch = skip_ws(); | 86 | ch = skip_ws(); |
88 | 87 | ||
89 | ent = getname(ch, " >").lower(); | 88 | ent = getname(ch, " >").lower(); |
90 | qDebug("Skipblock:%s", (const char*)ent); | 89 | qDebug("Skipblock:%s", (const char*)ent); |
91 | } while (ent != _ent && ch != UEOF); | 90 | } while (ent != _ent && ch != UEOF); |
92 | } | 91 | } |
93 | 92 | ||
94 | void striphtml::locate(unsigned int n) | 93 | void striphtml::locate(unsigned int n) |
95 | { | 94 | { |
96 | m_inblock = false; | 95 | m_inblock = false; |
97 | text_q = ""; | 96 | text_q = ""; |
98 | forcecentre = false; | 97 | forcecentre = false; |
99 | ignorespace = false; | 98 | ignorespace = false; |
100 | while (!stylestack.isEmpty()) stylestack.pop(); | 99 | while (!stylestack.isEmpty()) stylestack.pop(); |
101 | currentstyle.unset(); | 100 | currentstyle.unset(); |
102 | qDebug("striphtml:locating:%u", n); | 101 | qDebug("striphtml:locating:%u", n); |
103 | parent->locate(n); | 102 | parent->locate(n); |
104 | } | 103 | } |
105 | 104 | ||
106 | int striphtml::getpara(CBuffer& buff, unsigned long& startpos) | 105 | int striphtml::getpara(CBuffer& buff, unsigned long& startpos) |
107 | { | 106 | { |
108 | tchar ch; | 107 | tchar ch; |
109 | CStyle sty; | 108 | CStyle sty; |
110 | unsigned long pos; | 109 | unsigned long pos; |
111 | int i = 0; | 110 | int i = 0; |
112 | parent->getch(ch, sty, startpos); | 111 | parent->getch(ch, sty, startpos); |
113 | pos = startpos; | 112 | pos = startpos; |
114 | while (1) | 113 | while (1) |
115 | { | 114 | { |
116 | if (ch == 10 && !isPre) | 115 | if (ch == 10 && !isPre) |
117 | { | 116 | { |
118 | ch = ' '; | 117 | ch = ' '; |
119 | } | 118 | } |
120 | if (ch == UEOF) | 119 | if (ch == UEOF) |
121 | { | 120 | { |
122 | // qDebug("EOF:%d:%u", i, pos); | 121 | // qDebug("EOF:%d:%u", i, pos); |
123 | buff[i] = 0; | 122 | buff[i] = 0; |
124 | if (i == 0) | 123 | if (i == 0) |
125 | { | 124 | { |
126 | i = -1; | 125 | i = -1; |
127 | } | 126 | } |
128 | return i; | 127 | return i; |
129 | } | 128 | } |
130 | else if (ch == '<') | 129 | else if (ch == '<') |
131 | { | 130 | { |
132 | tchar ch2 = skip_ws(); | 131 | tchar ch2 = skip_ws(); |
133 | QString ent = getname(ch2, " >"); | 132 | QString ent = getname(ch2, " >"); |
134 | ent = ent.lower(); | 133 | ent = ent.lower(); |
135 | // qDebug("ent:%s", (const char*)ent); | 134 | // qDebug("ent:%s", (const char*)ent); |
136 | if (ent == "a") | 135 | if (ent == "a") |
137 | { | 136 | { |
138 | buff[i++] = '<'; | 137 | buff[i++] = '<'; |
139 | buff[i++] = 'a'; | 138 | buff[i++] = 'a'; |
140 | buff[i++] = ch2; | 139 | buff[i++] = ch2; |
141 | // buff[i] = 0; qDebug("ANCHOR:%s", (const char*)toQString(buff.data())); | 140 | // buff[i] = 0; qDebug("ANCHOR:%s", (const char*)toQString(buff.data())); |
142 | } | 141 | } |
143 | else if (ent == "/a") | 142 | else if (ent == "/a") |
144 | { | 143 | { |
145 | buff[i++] = '<'; | 144 | buff[i++] = '<'; |
146 | buff[i++] = '/'; | 145 | buff[i++] = '/'; |
147 | buff[i++] = 'a'; | 146 | buff[i++] = 'a'; |
148 | buff[i++] = ch2; | 147 | buff[i++] = ch2; |
149 | // buff[i] = 0; qDebug("/ANCHOR:%s", (const char*)toQString(buff.data())); | 148 | // buff[i] = 0; qDebug("/ANCHOR:%s", (const char*)toQString(buff.data())); |
150 | } | 149 | } |
151 | else if (ent == "div") | 150 | else if (ent == "div") |
152 | { | 151 | { |
153 | // buff[i] = 0; qDebug("DIV:%s", (const char*)toQString(buff.data())); | 152 | // buff[i] = 0; qDebug("DIV:%s", (const char*)toQString(buff.data())); |
154 | if (i == 0) | 153 | if (i == 0) |
155 | { | 154 | { |
156 | buff[i++] = '<'; | 155 | buff[i++] = '<'; |
157 | buff[i++] = 'd'; | 156 | buff[i++] = 'd'; |
158 | buff[i++] = 'i'; | 157 | buff[i++] = 'i'; |
159 | buff[i++] = 'v'; | 158 | buff[i++] = 'v'; |
160 | buff[i++] = ' '; | 159 | buff[i++] = ' '; |
161 | buff[i++] = ch2; | 160 | buff[i++] = ch2; |
162 | while (ch2 != '>' && ch2 != UEOF && i < 2048) | 161 | while (ch2 != '>' && ch2 != UEOF && i < 2048) |
163 | { | 162 | { |
164 | parent->getch(ch2, sty, pos); | 163 | parent->getch(ch2, sty, pos); |
165 | buff[i++] = ch2; | 164 | buff[i++] = ch2; |
166 | } | 165 | } |
167 | } | 166 | } |
168 | else | 167 | else |
169 | { | 168 | { |
170 | locate(pos); | 169 | locate(pos); |
171 | } | 170 | } |
172 | buff[i++] = 0; | 171 | buff[i++] = 0; |
173 | // qDebug("DIV:%s", (const char*)toQString(buff.data())); | 172 | // qDebug("DIV:%s", (const char*)toQString(buff.data())); |
174 | return i; | 173 | return i; |
175 | } | 174 | } |
176 | else if (ent == "p" || (ent[0] == 'h' && ent.length() == 2 && QString("123456789").find(ent[1]) != -1)) | 175 | else if (ent == "p" || (ent[0] == 'h' && ent.length() == 2 && QString("123456789").find(ent[1]) != -1)) |
177 | { | 176 | { |
178 | buff[i++] = 0; | 177 | buff[i++] = 0; |
179 | while (ch2 != '>' && ch2 != UEOF) | 178 | while (ch2 != '>' && ch2 != UEOF) |
180 | { | 179 | { |
181 | parent->getch(ch2, sty, pos); | 180 | parent->getch(ch2, sty, pos); |
182 | } | 181 | } |
183 | return i; | 182 | return i; |
184 | } | 183 | } |
185 | else | 184 | else |
186 | { | 185 | { |
187 | while (ch2 != '>' && ch2 != UEOF) | 186 | while (ch2 != '>' && ch2 != UEOF) |
188 | { | 187 | { |
189 | parent->getch(ch2, sty, pos); | 188 | parent->getch(ch2, sty, pos); |
190 | } | 189 | } |
191 | } | 190 | } |
192 | } | 191 | } |
193 | else | 192 | else |
194 | { | 193 | { |
195 | buff[i++] = ch; | 194 | buff[i++] = ch; |
196 | } | 195 | } |
197 | parent->getch(ch, sty, pos); | 196 | parent->getch(ch, sty, pos); |
198 | } | 197 | } |
199 | } | 198 | } |
200 | 199 | ||
201 | QString striphtml::dehtml(const QString& _info) | 200 | QString striphtml::dehtml(const QString& _info) |
202 | { | 201 | { |
203 | QString info; | 202 | QString info; |
204 | for (int i = 0; i < _info.length(); i++) | 203 | for (int i = 0; i < _info.length(); i++) |
205 | { | 204 | { |
206 | tchar ch = _info[i]; | 205 | tchar ch = _info[i]; |
207 | if (ch == '%') | 206 | if (ch == '%') |
208 | { | 207 | { |
209 | ch = 0; | 208 | ch = 0; |
210 | for (int j = 0; j < 2; j++) | 209 | for (int j = 0; j < 2; j++) |
211 | { | 210 | { |
212 | ch <<= 4; | 211 | ch <<= 4; |
213 | tchar ch1 = _info[++i]; | 212 | tchar ch1 = _info[++i]; |
214 | if ('0' <= ch1 && ch1 <= '9') | 213 | if ('0' <= ch1 && ch1 <= '9') |
215 | { | 214 | { |
216 | ch += ch1 - '0'; | 215 | ch += ch1 - '0'; |
217 | } | 216 | } |
218 | else if ('a' <= ch1 && ch1 <= 'f') | 217 | else if ('a' <= ch1 && ch1 <= 'f') |
219 | { | 218 | { |
220 | ch += ch1 - 'a' + 10; | 219 | ch += ch1 - 'a' + 10; |
221 | } | 220 | } |
222 | else if ('A' <= ch1 && ch1 <= 'F') | 221 | else if ('A' <= ch1 && ch1 <= 'F') |
223 | { | 222 | { |
224 | ch += ch1 - 'A' + 10; | 223 | ch += ch1 - 'A' + 10; |
225 | } | 224 | } |
226 | } | 225 | } |
227 | } | 226 | } |
228 | info += ch; | 227 | info += ch; |
229 | } | 228 | } |
230 | return info; | 229 | return info; |
231 | } | 230 | } |
232 | 231 | ||
233 | bool striphtml::findanchor(const QString& _info) | 232 | bool striphtml::findanchor(const QString& _info) |
234 | { | 233 | { |
235 | // QProgressDialog dlg("Finding link...", QString::null, 0, NULL, "progress", true); | 234 | // QProgressDialog dlg("Finding link...", QString::null, 0, NULL, "progress", true); |
236 | // QProgressBar dlg(0); | 235 | // QProgressBar dlg(0); |
237 | #if defined(USEQPE) || defined(_WINDOWS) | 236 | #if defined(USEQPE) || defined(_WINDOWS) |
238 | QString info; | 237 | QString info; |
239 | for (int i = 0; i < _info.length(); i++) | 238 | for (int i = 0; i < _info.length(); i++) |
240 | { | 239 | { |
241 | tchar ch = _info[i]; | 240 | tchar ch = _info[i]; |
242 | if (QString(".^$[]*+?").find(ch) != -1) | 241 | if (QString(".^$[]*+?").find(ch) != -1) |
243 | { | 242 | { |
244 | info += '\\'; | 243 | info += '\\'; |
245 | } | 244 | } |
246 | info += ch; | 245 | info += ch; |
247 | } | 246 | } |
248 | #else | 247 | #else |
249 | QString info = QRegExp::escape(_info); | 248 | QString info = QRegExp::escape(_info); |
250 | #endif | 249 | #endif |
251 | qDebug("Adjusted searchstring:%s", (const char*)info); | 250 | qDebug("Adjusted searchstring:%s", (const char*)info); |
252 | QString sname("<[Aa][^>]*[ \t]+[Nn][Aa][Mm][Ee][ \t]*=[ \t]*\"?"); | 251 | QString sname("<[Aa][^>]*[ \t]+[Nn][Aa][Mm][Ee][ \t]*=[ \t]*\"?"); |
253 | sname += info + "\"?[ \t>]"; | 252 | sname += info + "\"?[ \t>]"; |
254 | QString sid("<[A-Za-z][^>]*[ \t]+[Ii][Dd][ \t]*=[ \t]*\"?"); | 253 | QString sid("<[A-Za-z][^>]*[ \t]+[Ii][Dd][ \t]*=[ \t]*\"?"); |
255 | sid += info+"\"?[ \t>]"; | 254 | sid += info+"\"?[ \t>]"; |
256 | #ifdef USEQPE | 255 | #ifdef USEQPE |
257 | QRegExp name(sname); | 256 | QRegExp name(sname); |
258 | QRegExp id(sid); | 257 | QRegExp id(sid); |
259 | #else | 258 | #else |
260 | QRegExp name(sname+"|"+sid); | 259 | QRegExp name(sname+"|"+sid); |
261 | #endif | 260 | #endif |
262 | bool ret = true; | 261 | bool ret = true; |
263 | locate(0); | 262 | locate(0); |
264 | unsigned long pos = 0; | 263 | unsigned long pos = 0; |
265 | unsigned long startpos = 0; | 264 | unsigned long startpos = 0; |
266 | int offset; | 265 | int offset; |
267 | CBuffer test; | 266 | CBuffer test; |
268 | qDebug("striphtml::findanchor"); | 267 | qDebug("striphtml::findanchor"); |
269 | // dlg.show(); | 268 | // dlg.show(); |
270 | if (getpara(test, pos) >= 0) | 269 | if (getpara(test, pos) >= 0) |
271 | { | 270 | { |
272 | while (1) | 271 | while (1) |
273 | { | 272 | { |
274 | // qApp->processEvents(); | 273 | // qApp->processEvents(); |
275 | if ((offset = name.match(toQString(test.data()))) != -1) break; | 274 | if ((offset = name.match(toQString(test.data()))) != -1) break; |
276 | #ifdef USEQPE | 275 | #ifdef USEQPE |
277 | if ((offset = id.match(toQString(test.data()))) != -1) break; | 276 | if ((offset = id.match(toQString(test.data()))) != -1) break; |
278 | #endif | 277 | #endif |
279 | if (getpara(test, pos) < 0) | 278 | if (getpara(test, pos) < 0) |
280 | { | 279 | { |
281 | locate(startpos); | 280 | locate(startpos); |
282 | qDebug("Not found"); | 281 | qDebug("Not found"); |
283 | return false; | 282 | return false; |
284 | } | 283 | } |
285 | } | 284 | } |
286 | locate(pos); | 285 | locate(pos); |
287 | qDebug("Found"); | 286 | qDebug("Found"); |
288 | ret = true; | 287 | ret = true; |
289 | } | 288 | } |
290 | else | 289 | else |
291 | { | 290 | { |
292 | locate(startpos); | 291 | locate(startpos); |
293 | qDebug("Not found"); | 292 | qDebug("Not found"); |
294 | ret = false; | 293 | ret = false; |
295 | } | 294 | } |
296 | return ret; | 295 | return ret; |
297 | } | 296 | } |
298 | 297 | ||
299 | 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) | 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) |
300 | { | 299 | { |
301 | href2filepos = new QMap<QString, unsigned long>; | 300 | href2filepos = new QMap<QString, unsigned long>; |
302 | id2href = new QMap<unsigned long, QString>; | 301 | id2href = new QMap<unsigned long, QString>; |
303 | } | 302 | } |
304 | 303 | ||
305 | striphtml::~striphtml() | 304 | striphtml::~striphtml() |
306 | { | 305 | { |
307 | if (entmap != NULL) delete entmap; | 306 | if (entmap != NULL) delete entmap; |
308 | delete href2filepos; | 307 | delete href2filepos; |
309 | delete id2href; | 308 | delete id2href; |
310 | } | 309 | } |
311 | 310 | ||
312 | void striphtml::initentmap() | 311 | void striphtml::initentmap() |
313 | { | 312 | { |
314 | entmap = new QMap<QString, tchar>; | 313 | entmap = new QMap<QString, tchar>; |
315 | QString fname(QTReaderUtil::getPluginPath("data")); | 314 | QString fname(QTReaderUtil::getPluginPath("data")); |
316 | QFileInfo fi; | 315 | QFileInfo fi; |
317 | fi.setFile(fname, "HTMLentities"); | 316 | fi.setFile(fname, "HTMLentities"); |
318 | if (fi.exists()) | 317 | if (fi.exists()) |
319 | { | 318 | { |
320 | fname = fi.absFilePath(); | 319 | fname = fi.absFilePath(); |
321 | 320 | ||
322 | QFile fl(fname); | 321 | QFile fl(fname); |
323 | if (fl.open(IO_ReadOnly)) | 322 | if (fl.open(IO_ReadOnly)) |
324 | { | 323 | { |
325 | QTextStream t(&fl); | 324 | QTextStream t(&fl); |
326 | QString key, value; | 325 | QString key, value; |
327 | while (!t.eof()) | 326 | while (!t.eof()) |
328 | { | 327 | { |
329 | QString data = t.readLine(); | 328 | QString data = t.readLine(); |
330 | int colon = data.find(':'); | 329 | int colon = data.find(':'); |
331 | if (colon > 0) | 330 | if (colon > 0) |
332 | { | 331 | { |
333 | QString key = data.left(colon); | 332 | QString key = data.left(colon); |
334 | QString value = data.right(data.length()-colon-1); | 333 | QString value = data.right(data.length()-colon-1); |
335 | bool ok; | 334 | bool ok; |
336 | int ret = value.toInt(&ok); | 335 | int ret = value.toInt(&ok); |
337 | if (ok) | 336 | if (ok) |
338 | { | 337 | { |
339 | (*entmap)[key] = ret; | 338 | (*entmap)[key] = ret; |
340 | } | 339 | } |
341 | } | 340 | } |
342 | } | 341 | } |
343 | fl.close(); | 342 | fl.close(); |
344 | } | 343 | } |
345 | } | 344 | } |
346 | } | 345 | } |
347 | 346 | ||
348 | unsigned short striphtml::skip_ws() | 347 | unsigned short striphtml::skip_ws() |
349 | { | 348 | { |
350 | tchar ch; | 349 | tchar ch; |
351 | CStyle sty; | 350 | CStyle sty; |
352 | unsigned long dummy; | 351 | unsigned long dummy; |
353 | do | 352 | do |
354 | { | 353 | { |
355 | mygetch(ch, sty, dummy); | 354 | mygetch(ch, sty, dummy); |
356 | } | 355 | } |
357 | while (ch < 33 && ch != UEOF); | 356 | while (ch < 33 && ch != UEOF); |
358 | return ch; | 357 | return ch; |
359 | } | 358 | } |
360 | 359 | ||
361 | unsigned short striphtml::skip_ws_end() | 360 | unsigned short striphtml::skip_ws_end() |
362 | { | 361 | { |
363 | unsigned long dummy; | 362 | unsigned long dummy; |
364 | return skip_ws_end(dummy); | 363 | return skip_ws_end(dummy); |
365 | } | 364 | } |
366 | 365 | ||
367 | unsigned short striphtml::skip_ws_end(unsigned long& pos) | 366 | unsigned short striphtml::skip_ws_end(unsigned long& pos) |
368 | { | 367 | { |
369 | tchar ch; | 368 | tchar ch; |
370 | CStyle sty; | 369 | CStyle sty; |
371 | do | 370 | do |
372 | { | 371 | { |
373 | mygetch(ch, sty, pos); | 372 | mygetch(ch, sty, pos); |
374 | } | 373 | } |
375 | while (ch != '>' && ch != UEOF); | 374 | while (ch != '>' && ch != UEOF); |
376 | return ch; | 375 | return ch; |
377 | } | 376 | } |
378 | 377 | ||
379 | QString striphtml::getname(tchar& ch, const QString& nd) | 378 | QString striphtml::getname(tchar& ch, const QString& nd) |
380 | { | 379 | { |
381 | QString nm = ""; | 380 | QString nm = ""; |
382 | // nm += ch; | 381 | // nm += ch; |
383 | CStyle sty; | 382 | CStyle sty; |
384 | unsigned long dummy; | 383 | unsigned long dummy; |
385 | while (1) | 384 | while (1) |
386 | { | 385 | { |
387 | // if ( QChar(ch).isLetterOrNumber() ) | 386 | // if ( QChar(ch).isLetterOrNumber() ) |
388 | if (ch != UEOF && nd.find(ch, 0, false) == -1 && nm.length() < 2048) | 387 | if (ch != UEOF && nd.find(ch, 0, false) == -1 && nm.length() < 2048) |
389 | { | 388 | { |
390 | nm += ch; | 389 | nm += ch; |
391 | } | 390 | } |
392 | else | 391 | else |
393 | { | 392 | { |
394 | break; | 393 | break; |
395 | } | 394 | } |
396 | mygetch(ch, sty, dummy); | 395 | mygetch(ch, sty, dummy); |
397 | } | 396 | } |
398 | return nm; | 397 | return nm; |
399 | } | 398 | } |
400 | 399 | ||
401 | QString striphtml::getattr(tchar& ch) | 400 | QString striphtml::getattr(tchar& ch) |
402 | { | 401 | { |
403 | QString ref; | 402 | QString ref; |
404 | CStyle sty; | 403 | CStyle sty; |
405 | unsigned long pos; | 404 | unsigned long pos; |
406 | if (ch == ' ') ch = skip_ws(); | 405 | if (ch == ' ') ch = skip_ws(); |
407 | if (ch == '=') | 406 | if (ch == '=') |
408 | { | 407 | { |
409 | ch = skip_ws(); | 408 | ch = skip_ws(); |
410 | if (ch == '"') | 409 | if (ch == '"') |
411 | { | 410 | { |
412 | mygetch(ch, sty, pos); | 411 | mygetch(ch, sty, pos); |
413 | ref = getname(ch, "\""); | 412 | ref = getname(ch, "\""); |
414 | ch = skip_ws(); | 413 | ch = skip_ws(); |
415 | } | 414 | } |
416 | else | 415 | else |
417 | { | 416 | { |
418 | ref = getname(ch, " >"); | 417 | ref = getname(ch, " >"); |
419 | if (ch == ' ') ch = skip_ws(); | 418 | if (ch == ' ') ch = skip_ws(); |
420 | } | 419 | } |
421 | } | 420 | } |
422 | return ref; | 421 | return ref; |
423 | } | 422 | } |
424 | 423 | ||
425 | linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString& nm) | 424 | linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString& nm) |
426 | { | 425 | { |
427 | #if defined(USEQPE) || defined(_WINDOWS) | 426 | #if defined(USEQPE) || defined(_WINDOWS) |
428 | QMap<unsigned long, QString>::Iterator hrefit = id2href->find(n); | 427 | QMap<unsigned long, QString>::Iterator hrefit = id2href->find(n); |
429 | #else | 428 | #else |
430 | QMap<unsigned long, QString>::iterator hrefit = id2href->find(n); | 429 | QMap<unsigned long, QString>::iterator hrefit = id2href->find(n); |
431 | #endif | 430 | #endif |
432 | if (hrefit == id2href->end()) | 431 | if (hrefit == id2href->end()) |
433 | { | 432 | { |
434 | return eNone; | 433 | return eNone; |
435 | } | 434 | } |
436 | QString href = *hrefit; | 435 | QString href = *hrefit; |
437 | #if defined(USEQPE) || defined(_WINDOWS) | 436 | #if defined(USEQPE) || defined(_WINDOWS) |
438 | QMap<QString, unsigned long>::Iterator fpit = href2filepos->find(href); | 437 | QMap<QString, unsigned long>::Iterator fpit = href2filepos->find(href); |
439 | #else | 438 | #else |
440 | QMap<QString, unsigned long>::iterator fpit = href2filepos->find(href); | 439 | QMap<QString, unsigned long>::iterator fpit = href2filepos->find(href); |
441 | #endif | 440 | #endif |
442 | if (fpit == href2filepos->end()) | 441 | if (fpit == href2filepos->end()) |
443 | { | 442 | { |
444 | if (href == "history.back()") | 443 | if (href == "history.back()") |
445 | { | 444 | { |
446 | QString fc = currentfile; | 445 | QString fc = currentfile; |
447 | unsigned long loc; | 446 | unsigned long loc; |
448 | htmlmark m(fc, loc); | 447 | htmlmark m(fc, loc); |
449 | linkType ret = (m_nav.back(m)) ? eFile : eNone; | 448 | linkType ret = (m_nav.back(m)) ? eFile : eNone; |
450 | if (fc == m.filename()) | 449 | if (fc == m.filename()) |
451 | { | 450 | { |
452 | if ((ret & eFile) != 0) | 451 | if ((ret & eFile) != 0) |
453 | { | 452 | { |
454 | locate(m.posn()); | 453 | locate(m.posn()); |
455 | return eLink; | 454 | return eLink; |
456 | } | 455 | } |
457 | } | 456 | } |
458 | return eNone; | 457 | return eNone; |
459 | } | 458 | } |
460 | qDebug("Searching for %s", (const char*)href); | 459 | qDebug("Searching for %s", (const char*)href); |
461 | 460 | ||
462 | 461 | ||
463 | QString file, name; | 462 | QString file, name; |
464 | 463 | ||
465 | int colon = href.find('#'); | 464 | int colon = href.find('#'); |
466 | if (colon >= 0) | 465 | if (colon >= 0) |
467 | { | 466 | { |
468 | file = dehtml(href.left(colon)); | 467 | file = dehtml(href.left(colon)); |
469 | name = dehtml(href.right(href.length()-colon-1)); | 468 | name = dehtml(href.right(href.length()-colon-1)); |
470 | } | 469 | } |
471 | else | 470 | else |
472 | { | 471 | { |
473 | file = dehtml(href); | 472 | file = dehtml(href); |
474 | } | 473 | } |
475 | 474 | ||
476 | qDebug("File:%s", (const char*)file); | 475 | qDebug("File:%s", (const char*)file); |
477 | qDebug("Name:%s", (const char*)name); | 476 | qDebug("Name:%s", (const char*)name); |
478 | 477 | ||
479 | 478 | ||
480 | if (file.isEmpty()) | 479 | if (file.isEmpty()) |
481 | { | 480 | { |
482 | fpit = href2filepos->find(name); | 481 | fpit = href2filepos->find(name); |
483 | if (fpit != href2filepos->end()) | 482 | if (fpit != href2filepos->end()) |
484 | { | 483 | { |
485 | locate(*fpit); | 484 | locate(*fpit); |
486 | return eLink; | 485 | return eLink; |
487 | } | 486 | } |
488 | else | 487 | else |
489 | { | 488 | { |
490 | // nm = QString("<a[^>]*name[ \t]*=[ \t]*\"") + name + "\""; | 489 | // nm = QString("<a[^>]*name[ \t]*=[ \t]*\"") + name + "\""; |
491 | qDebug("Do a search for:%s", (const char*)name); | 490 | qDebug("Do a search for:%s", (const char*)name); |
492 | parent->locate(0); | 491 | parent->locate(0); |
493 | findanchor(name); | 492 | findanchor(name); |
494 | return eLink; | 493 | return eLink; |
495 | } | 494 | } |
496 | } | 495 | } |
497 | else | 496 | else |
498 | // if (href.find('#') == -1) | 497 | // if (href.find('#') == -1) |
499 | { | 498 | { |
500 | if (m_bchm) | 499 | if (m_bchm) |
501 | { | 500 | { |
502 | w = "/"+file; | 501 | w = "/"+file; |
503 | nm = name; | 502 | nm = name; |
504 | return eFile; | 503 | return eFile; |
505 | } | 504 | } |
506 | else | 505 | else |
507 | { | 506 | { |
508 | QFileInfo f(currentfile); | 507 | QFileInfo f(currentfile); |
509 | QFileInfo f1(f.dir(true), file); | 508 | QFileInfo f1(f.dir(true), file); |
510 | if (f1.exists()) | 509 | if (f1.exists()) |
511 | { | 510 | { |
512 | w = f1.absFilePath(); | 511 | w = f1.absFilePath(); |
513 | nm = name; | 512 | nm = name; |
514 | } | 513 | } |
515 | else | 514 | else |
516 | { | 515 | { |
517 | w = file; | 516 | w = file; |
518 | } | 517 | } |
519 | return (f1.exists() ? eFile : eNone); | 518 | return (f1.exists() ? eFile : eNone); |
520 | } | 519 | } |
521 | } | 520 | } |
522 | return eNone; | 521 | return eNone; |
523 | } | 522 | } |
524 | locate(*fpit); | 523 | locate(*fpit); |
525 | // parent->locate((*href2filepos)[(*id2href)[n]]); | 524 | // parent->locate((*href2filepos)[(*id2href)[n]]); |
526 | return eLink; | 525 | return eLink; |
527 | } | 526 | } |
528 | /* | 527 | /* |
529 | unsigned short striphtml::parse_m() | 528 | unsigned short striphtml::parse_m() |
530 | { | 529 | { |
531 | tchar ch; | 530 | tchar ch; |
532 | CStyle sty; | 531 | CStyle sty; |
533 | unsigned long dummy; | 532 | unsigned long dummy; |
534 | mygetch(ch, sty, dummy); | 533 | mygetch(ch, sty, dummy); |
535 | if (ch == 'm' || ch == 'M') | 534 | if (ch == 'm' || ch == 'M') |
536 | { | 535 | { |
537 | ch = skip_ws_end(); | 536 | ch = skip_ws_end(); |
538 | if (ch == '>') | 537 | if (ch == '>') |
539 | { | 538 | { |
540 | return 0; | 539 | return 0; |
541 | } | 540 | } |
542 | } | 541 | } |
543 | return ch; | 542 | return ch; |
544 | } | 543 | } |
545 | */ | 544 | */ |
546 | 545 | ||
547 | void striphtml::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) | 546 | void striphtml::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) |
548 | { | 547 | { |
549 | if (!text_q.isEmpty() && !m_inblock) | 548 | if (!text_q.isEmpty() && !m_inblock) |
550 | { | 549 | { |
551 | ch = text_q[0].unicode(); | 550 | ch = text_q[0].unicode(); |
552 | text_q = text_q.right(text_q.length()-1); | 551 | text_q = text_q.right(text_q.length()-1); |
553 | } | 552 | } |
554 | else | 553 | else |
555 | { | 554 | { |
556 | parent->getch(ch, sty, pos); | 555 | parent->getch(ch, sty, pos); |
557 | if (ch == '<') | 556 | if (ch == '<') |
558 | { | 557 | { |
559 | m_inblock = true; | 558 | m_inblock = true; |
560 | } | 559 | } |
561 | if (ch == '>') | 560 | if (ch == '>') |
562 | { | 561 | { |
563 | m_inblock = false; | 562 | m_inblock = false; |
564 | } | 563 | } |
565 | } | 564 | } |
566 | if (ch == 10 && !isPre) | 565 | if (ch == 10 && !isPre) |
567 | { | 566 | { |
568 | ch = ' '; | 567 | ch = ' '; |
569 | } | 568 | } |
570 | } | 569 | } |
571 | 570 | ||
572 | void striphtml::parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long pos) | 571 | void striphtml::parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long pos) |
573 | { | 572 | { |
574 | /* | 573 | /* |
575 | int count = 0; | 574 | int count = 0; |
576 | for (CList<CStyle>::iterator iter = stylestack.begin(); iter != stylestack.end(); ++iter) | 575 | for (CList<CStyle>::iterator iter = stylestack.begin(); iter != stylestack.end(); ++iter) |
577 | { | 576 | { |
578 | count++; | 577 | count++; |
579 | } | 578 | } |
580 | qDebug("Currently have %u styles", count); | 579 | qDebug("Currently have %u styles", count); |
581 | */ | 580 | */ |
582 | if (stylestack.isEmpty()) | 581 | if (stylestack.isEmpty()) |
583 | { | 582 | { |
584 | currentstyle.unset(); | 583 | currentstyle.unset(); |
585 | } | 584 | } |
586 | else | 585 | else |
587 | { | 586 | { |
588 | qDebug("Using stack style"); | 587 | qDebug("Using stack style"); |
589 | currentstyle = stylestack.first(); | 588 | currentstyle = stylestack.first(); |
590 | } | 589 | } |
591 | if (forcecentre) | 590 | if (forcecentre) |
592 | { | 591 | { |
593 | currentstyle.setCentreJustify(); | 592 | currentstyle.setCentreJustify(); |
594 | } | 593 | } |
595 | if (ch == ' ') ch = skip_ws(); | 594 | if (ch == ' ') ch = skip_ws(); |
596 | while (ch != '>' && ch != UEOF) | 595 | while (ch != '>' && ch != UEOF) |
597 | { | 596 | { |
598 | QString ent = getname(ch, " =>").lower(); | 597 | QString ent = getname(ch, " =>").lower(); |
599 | QString attr = getattr(ch).lower(); | 598 | QString attr = getattr(ch).lower(); |
600 | //qDebug("(Paragraph)Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 599 | //qDebug("(Paragraph)Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
601 | if (ent == "align") | 600 | if (ent == "align") |
602 | { | 601 | { |
603 | if (attr == "center") | 602 | if (attr == "center") |
604 | { | 603 | { |
605 | currentstyle.setCentreJustify(); | 604 | currentstyle.setCentreJustify(); |
606 | } | 605 | } |
607 | if (attr == "right") | 606 | if (attr == "right") |
608 | { | 607 | { |
609 | currentstyle.setRightJustify(); | 608 | currentstyle.setRightJustify(); |
610 | } | 609 | } |
611 | } | 610 | } |
612 | if (ent == "id") | 611 | if (ent == "id") |
613 | { | 612 | { |
614 | (*href2filepos)[attr] = pos; | 613 | (*href2filepos)[attr] = pos; |
615 | } | 614 | } |
616 | if (ent == "bgcolor") | 615 | if (ent == "bgcolor") |
617 | { | 616 | { |
618 | qDebug("Got paper colour:%s", (const char*)attr); | 617 | qDebug("Got paper colour:%s", (const char*)attr); |
619 | unsigned char r,g,b; | 618 | unsigned char r,g,b; |
620 | parse_color(attr, r, g, b); | 619 | parse_color(attr, r, g, b); |
621 | currentstyle.setPaper(r, g, b); | 620 | currentstyle.setPaper(r, g, b); |
622 | } | 621 | } |
623 | if (ent == "color") | 622 | if (ent == "color") |
624 | { | 623 | { |
625 | qDebug("Got foreground colour:%s", (const char*)attr); | 624 | qDebug("Got foreground colour:%s", (const char*)attr); |
626 | unsigned char r,g,b; | 625 | unsigned char r,g,b; |
627 | parse_color(attr, r, g, b); | 626 | parse_color(attr, r, g, b); |
628 | currentstyle.setColour(r, g, b); | 627 | currentstyle.setColour(r, g, b); |
629 | } | 628 | } |
630 | if (ch == ' ') ch = skip_ws(); | 629 | if (ch == ' ') ch = skip_ws(); |
631 | } | 630 | } |
632 | ch = 10; | 631 | ch = 10; |
633 | } | 632 | } |
634 | 633 | ||
635 | void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 634 | void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
636 | { | 635 | { |
637 | currentstyle.clearPicture(); | 636 | currentstyle.clearPicture(); |
638 | if (!q.isEmpty()) | 637 | if (!q.isEmpty()) |
639 | { | 638 | { |
640 | ch = q[0].unicode(); | 639 | ch = q[0].unicode(); |
641 | if (ch == '-') | 640 | if (ch == '-') |
642 | { | 641 | { |
643 | tchar w = q[1].unicode(); | 642 | tchar w = q[1].unicode(); |
644 | tchar h = q[2].unicode(); | 643 | tchar h = q[2].unicode(); |
645 | unsigned char r = q[3].unicode(); | 644 | unsigned char r = q[3].unicode(); |
646 | unsigned char g = q[4].unicode(); | 645 | unsigned char g = q[4].unicode(); |
647 | unsigned char b = q[5].unicode(); | 646 | unsigned char b = q[5].unicode(); |
648 | ch = '#'; | 647 | ch = '#'; |
649 | //qDebug("html:hrule<%u, %u>", w, h); | 648 | //qDebug("html:hrule<%u, %u>", w, h); |
650 | currentstyle.setPicture(false, hRule(w,h,r,g,b)); | 649 | currentstyle.setPicture(false, hRule(w,h,r,g,b)); |
651 | q = q.right(q.length()-6); | 650 | q = q.right(q.length()-6); |
652 | } | 651 | } |
653 | else | 652 | else |
654 | { | 653 | { |
655 | q = q.right(q.length()-1); | 654 | q = q.right(q.length()-1); |
656 | } | 655 | } |
657 | sty = currentstyle; | 656 | sty = currentstyle; |
658 | return; | 657 | return; |
659 | } | 658 | } |
660 | do | 659 | do |
661 | { | 660 | { |
662 | unsigned long npos; | 661 | unsigned long npos; |
663 | CStyle dummy; | 662 | CStyle dummy; |
664 | mygetch(ch, dummy, pos); | 663 | mygetch(ch, dummy, pos); |
665 | // if (ch == 10 && !isPre) ch = ' '; | 664 | // if (ch == 10 && !isPre) ch = ' '; |
666 | while (ch == '<' && ch != UEOF) | 665 | while (ch == '<' && ch != UEOF) |
667 | { | 666 | { |
668 | ch = skip_ws(); | 667 | ch = skip_ws(); |
669 | 668 | ||
670 | QString ent = getname(ch, " >").lower(); | 669 | QString ent = getname(ch, " >").lower(); |
671 | 670 | ||
672 | // qDebug("Entity:%s", (const char*)ent); | 671 | // qDebug("Entity:%s", (const char*)ent); |
673 | 672 | ||
674 | if (ent == "a"/* || ent == "reference"*/) | 673 | if (ent == "a"/* || ent == "reference"*/) |
675 | { | 674 | { |
676 | if (ch == ' ') ch = skip_ws(); | 675 | if (ch == ' ') ch = skip_ws(); |
677 | bool fileposfound = false; | 676 | bool fileposfound = false; |
678 | bool ishref = false; | 677 | bool ishref = false; |
679 | unsigned int filepos = 0; | 678 | unsigned int filepos = 0; |
680 | QString ref, name; | 679 | QString ref, name; |
681 | while (ch != '>' && ch != UEOF) | 680 | while (ch != '>' && ch != UEOF) |
682 | { | 681 | { |
683 | QString ent = getname(ch, " =>").lower(); | 682 | QString ent = getname(ch, " =>").lower(); |
684 | QString attr = getattr(ch); | 683 | QString attr = getattr(ch); |
685 | qDebug("<A>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 684 | qDebug("<A>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
686 | if (ent == "name") | 685 | if (ent == "name") |
687 | { | 686 | { |
688 | name = attr; | 687 | name = attr; |
689 | } | 688 | } |
690 | if (ent == "onclick") | 689 | if (ent == "onclick") |
691 | { | 690 | { |
692 | int st = attr.find('\''); | 691 | int st = attr.find('\''); |
693 | int nd = attr.findRev('\''); | 692 | int nd = attr.findRev('\''); |
694 | ref = attr.mid(st+1, nd-st-1); | 693 | ref = attr.mid(st+1, nd-st-1); |
695 | ishref = true; | 694 | ishref = true; |
696 | qDebug("Onclick:%s", (const char*)ref); | 695 | qDebug("Onclick:%s", (const char*)ref); |
697 | } | 696 | } |
698 | if (ent == "href") | 697 | if (ent == "href") |
699 | { | 698 | { |
700 | ishref = true; | 699 | ishref = true; |
701 | ref = attr; | 700 | ref = attr; |
702 | } | 701 | } |
703 | if (ent == "filepos") | 702 | if (ent == "filepos") |
704 | { | 703 | { |
705 | filepos = attr.toUInt(&fileposfound); | 704 | filepos = attr.toUInt(&fileposfound); |
706 | if (ref.isEmpty()) | 705 | if (ref.isEmpty()) |
707 | { | 706 | { |
708 | ishref = true; | 707 | ishref = true; |
709 | ref = attr; | 708 | ref = attr; |
710 | } | 709 | } |
711 | } | 710 | } |
712 | if (ent == "title") | 711 | if (ent == "title") |
713 | { | 712 | { |
714 | text_q = attr + "</a><p>"; | 713 | text_q = attr + "</a><p>"; |
715 | } | 714 | } |
716 | qDebug("<a %s=%s>", (const char*)ent, (const char*)ref); | 715 | qDebug("<a %s=%s>", (const char*)ent, (const char*)ref); |
717 | } | 716 | } |
718 | if (ishref) | 717 | if (ishref) |
719 | { | 718 | { |
720 | currentstyle.setColour(0,0,255); | 719 | currentstyle.setColour(0,0,255); |
721 | currentstyle.setLink(true); | 720 | currentstyle.setLink(true); |
722 | currentstyle.setData(currentid); | 721 | currentstyle.setData(currentid); |
723 | if (!text_q.isEmpty()) | 722 | if (!text_q.isEmpty()) |
724 | { | 723 | { |
725 | currentstyle.setBold(); | 724 | currentstyle.setBold(); |
726 | currentstyle.setCentreJustify(); | 725 | currentstyle.setCentreJustify(); |
727 | } | 726 | } |
728 | (*id2href)[currentid] = ref; | 727 | (*id2href)[currentid] = ref; |
729 | currentid++; | 728 | currentid++; |
730 | 729 | ||
731 | 730 | ||
732 | if (fileposfound) | 731 | if (fileposfound) |
733 | { | 732 | { |
734 | (*href2filepos)[ref] = filepos; | 733 | (*href2filepos)[ref] = filepos; |
735 | } | 734 | } |
736 | } | 735 | } |
737 | if (!name.isEmpty()) | 736 | if (!name.isEmpty()) |
738 | { | 737 | { |
739 | (*href2filepos)[name] = pos; | 738 | (*href2filepos)[name] = pos; |
740 | } | 739 | } |
741 | } | 740 | } |
742 | else if (ent == "p") | 741 | else if (ent == "p") |
743 | { | 742 | { |
744 | parse_paragraph(currentstyle, ch, pos); | 743 | parse_paragraph(currentstyle, ch, pos); |
745 | currentstyle.setExtraSpace(3); | 744 | currentstyle.setExtraSpace(3); |
746 | continue; | 745 | continue; |
747 | } | 746 | } |
748 | else if (ent == "div") | 747 | else if (ent == "div") |
749 | { | 748 | { |
750 | parse_paragraph(currentstyle, ch, pos); | 749 | parse_paragraph(currentstyle, ch, pos); |
751 | stylestack.push_front(currentstyle); | 750 | stylestack.push_front(currentstyle); |
752 | //indent = 0; | 751 | //indent = 0; |
753 | continue; | 752 | continue; |
754 | } | 753 | } |
755 | else if (ent == "sup") | 754 | else if (ent == "sup") |
756 | { | 755 | { |
757 | currentstyle.setVOffset(-1); | 756 | currentstyle.setVOffset(-1); |
758 | } | 757 | } |
759 | else if (ent == "sup") | 758 | else if (ent == "sup") |
760 | { | 759 | { |
761 | currentstyle.setVOffset(1); | 760 | currentstyle.setVOffset(1); |
762 | } | 761 | } |
763 | else if (ent == "/sup" || ent == "/sub") | 762 | else if (ent == "/sup" || ent == "/sub") |
764 | { | 763 | { |
765 | currentstyle.setVOffset(0); | 764 | currentstyle.setVOffset(0); |
766 | } | 765 | } |
767 | else if (ent == "span") | 766 | else if (ent == "span") |
768 | { | 767 | { |
769 | if (ch == ' ') ch = skip_ws(); | 768 | if (ch == ' ') ch = skip_ws(); |
770 | while (ch != '>' && ch != UEOF) | 769 | while (ch != '>' && ch != UEOF) |
771 | { | 770 | { |
772 | QString ent = getname(ch, " =>").lower(); | 771 | QString ent = getname(ch, " =>").lower(); |
773 | QString attr = getattr(ch).lower(); | 772 | QString attr = getattr(ch).lower(); |
774 | if (ent == "bgcolor") | 773 | if (ent == "bgcolor") |
775 | { | 774 | { |
776 | qDebug("Got background colour:%s", (const char*)attr); | 775 | qDebug("Got background colour:%s", (const char*)attr); |
777 | unsigned char r,g,b; | 776 | unsigned char r,g,b; |
778 | parse_color(attr, r, g, b); | 777 | parse_color(attr, r, g, b); |
779 | currentstyle.setBackground(r, g, b); | 778 | currentstyle.setBackground(r, g, b); |
780 | } | 779 | } |
781 | if (ent == "color") | 780 | if (ent == "color") |
782 | { | 781 | { |
783 | qDebug("Got foreground colour:%s", (const char*)attr); | 782 | qDebug("Got foreground colour:%s", (const char*)attr); |
784 | unsigned char r,g,b; | 783 | unsigned char r,g,b; |
785 | parse_color(attr, r, g, b); | 784 | parse_color(attr, r, g, b); |
786 | currentstyle.setColour(r, g, b); | 785 | currentstyle.setColour(r, g, b); |
787 | } | 786 | } |
788 | } | 787 | } |
789 | stylestack.push_front(currentstyle); | 788 | stylestack.push_front(currentstyle); |
790 | } | 789 | } |
791 | else if (ent == "/span") | 790 | else if (ent == "/span") |
792 | { | 791 | { |
793 | if (ch != '>') ch = skip_ws_end(); | 792 | if (ch != '>') ch = skip_ws_end(); |
794 | currentstyle.setBackground(255, 255, 255); | 793 | currentstyle.setBackground(255, 255, 255); |
795 | currentstyle.setColour(0, 0, 0); | 794 | currentstyle.setColour(0, 0, 0); |
796 | if (!stylestack.isEmpty()) | 795 | if (!stylestack.isEmpty()) |
797 | { | 796 | { |
798 | stylestack.pop(); | 797 | stylestack.pop(); |
799 | } | 798 | } |
800 | } | 799 | } |
801 | else if (ent == "pre") | 800 | else if (ent == "pre") |
802 | { | 801 | { |
803 | isPre = true; | 802 | isPre = true; |
804 | currentstyle.setMono(); | 803 | currentstyle.setMono(); |
805 | } | 804 | } |
806 | else if (ent == "tt") | 805 | else if (ent == "tt") |
807 | { | 806 | { |
808 | currentstyle.setMono(); | 807 | currentstyle.setMono(); |
809 | } | 808 | } |
810 | else if (ent == "b" || ent == "strong") | 809 | else if (ent == "b" || ent == "strong") |
811 | { | 810 | { |
812 | currentstyle.setBold(); | 811 | currentstyle.setBold(); |
813 | } | 812 | } |
814 | else if (ent == "u") | 813 | else if (ent == "u") |
815 | { | 814 | { |
816 | currentstyle.setUnderline(); | 815 | currentstyle.setUnderline(); |
817 | } | 816 | } |
818 | else if (ent == "/u") | 817 | else if (ent == "/u") |
819 | { | 818 | { |
820 | currentstyle.unsetUnderline(); | 819 | currentstyle.unsetUnderline(); |
821 | } | 820 | } |
822 | else if (ent == "blockquote") | 821 | else if (ent == "blockquote") |
823 | { | 822 | { |
824 | if (ch != '>') ch = skip_ws_end(); | 823 | if (ch != '>') ch = skip_ws_end(); |
825 | ch = 10; | 824 | ch = 10; |
826 | currentstyle.setLeftMargin(30); | 825 | currentstyle.setLeftMargin(30); |
827 | currentstyle.setRightMargin(30); | 826 | currentstyle.setRightMargin(30); |
828 | continue; | 827 | continue; |
829 | } | 828 | } |
830 | else if (ent == "br" || ent == "br/") | 829 | else if (ent == "br" || ent == "br/") |
831 | { | 830 | { |
832 | if (ch != '>') ch = skip_ws_end(); | 831 | if (ch != '>') ch = skip_ws_end(); |
833 | ch = 10; | 832 | ch = 10; |
834 | continue; | 833 | continue; |
835 | } | 834 | } |
836 | else if (ent == "mbp:pagebreak") | 835 | else if (ent == "mbp:pagebreak") |
837 | { | 836 | { |
838 | /* | 837 | /* |
839 | if (ch != '>') ch = skip_ws_end(pos); | 838 | if (ch != '>') ch = skip_ws_end(pos); |
840 | q += 10; | 839 | q += 10; |
841 | q += QChar(UEOF); | 840 | q += QChar(UEOF); |
842 | ch = 10; | 841 | ch = 10; |
843 | continue; | 842 | continue; |
844 | */ | 843 | */ |
845 | ch = 6; | 844 | ch = 6; |
846 | // currentstyle.setTop(); | 845 | // currentstyle.setTop(); |
847 | continue; | 846 | continue; |
848 | } | 847 | } |
849 | else if (ent == "center") | 848 | else if (ent == "center") |
850 | { | 849 | { |
851 | //forcecentre = true; | 850 | //forcecentre = true; |
852 | qDebug("setting centre"); | 851 | qDebug("setting centre"); |
853 | currentstyle.setCentreJustify(); | 852 | currentstyle.setCentreJustify(); |
854 | ch = 10; | 853 | ch = 10; |
855 | continue; | 854 | continue; |
856 | } | 855 | } |
857 | else if (ent == "/center") | 856 | else if (ent == "/center") |
858 | { | 857 | { |
859 | qDebug("unsetting centre"); | 858 | qDebug("unsetting centre"); |
860 | forcecentre = false; | 859 | forcecentre = false; |
861 | } | 860 | } |
862 | else if (ent == "li") | 861 | else if (ent == "li") |
863 | { | 862 | { |
864 | if (ch != '>') ch = skip_ws_end(); | 863 | if (ch != '>') ch = skip_ws_end(); |
865 | ch = 10; | 864 | ch = 10; |
866 | if (m_listtype[indent % m_cmaxdepth] == 1) | 865 | if (m_listtype[indent % m_cmaxdepth] == 1) |
867 | { | 866 | { |
868 | q.setNum(m_ctr[indent % m_cmaxdepth]++); | 867 | q.setNum(m_ctr[indent % m_cmaxdepth]++); |
869 | } | 868 | } |
870 | else | 869 | else |
871 | { | 870 | { |
872 | q += QChar(8226); | 871 | q += QChar(8226); |
873 | } | 872 | } |
874 | q += ' '; | 873 | q += ' '; |
875 | currentstyle.setLeftMargin(6*indent); | 874 | currentstyle.setLeftMargin(6*indent); |
876 | qDebug("Setting indent:%d", indent); | 875 | qDebug("Setting indent:%d", indent); |
877 | continue; | 876 | continue; |
878 | } | 877 | } |
879 | else if (ent == "ul") | 878 | else if (ent == "ul") |
880 | { | 879 | { |
881 | indent++; | 880 | indent++; |
882 | m_listtype[indent % m_cmaxdepth] = 0; | 881 | m_listtype[indent % m_cmaxdepth] = 0; |
883 | } | 882 | } |
884 | else if (ent == "/ul") | 883 | else if (ent == "/ul") |
885 | { | 884 | { |
886 | indent--; | 885 | indent--; |
887 | } | 886 | } |
888 | else if (ent == "ol") | 887 | else if (ent == "ol") |
889 | { | 888 | { |
890 | indent++; | 889 | indent++; |
891 | m_listtype[indent % m_cmaxdepth] = 1; | 890 | m_listtype[indent % m_cmaxdepth] = 1; |
892 | m_ctr[indent % m_cmaxdepth] = 1; | 891 | m_ctr[indent % m_cmaxdepth] = 1; |
893 | } | 892 | } |
894 | else if (ent == "/ol") | 893 | else if (ent == "/ol") |
895 | { | 894 | { |
896 | indent--; | 895 | indent--; |
897 | } | 896 | } |
898 | else if (ent == "i") | 897 | else if (ent == "i") |
899 | { | 898 | { |
900 | currentstyle.setItalic(); | 899 | currentstyle.setItalic(); |
901 | } | 900 | } |
902 | else if (ent == "em") | 901 | else if (ent == "em") |
903 | { | 902 | { |
904 | currentstyle.setItalic(); | 903 | currentstyle.setItalic(); |
905 | } | 904 | } |
906 | else if (ent == "small") | 905 | else if (ent == "small") |
907 | { | 906 | { |
908 | currentstyle.setFontSize(-2); | 907 | currentstyle.setFontSize(-2); |
909 | } | 908 | } |
910 | else if (ent == "/small") | 909 | else if (ent == "/small") |
911 | { | 910 | { |
912 | currentstyle.setFontSize(0); | 911 | currentstyle.setFontSize(0); |
913 | } | 912 | } |
914 | else if (ent == "big") | 913 | else if (ent == "big") |
915 | { | 914 | { |
916 | currentstyle.setFontSize(2); | 915 | currentstyle.setFontSize(2); |
917 | } | 916 | } |
918 | else if (ent == "/big") | 917 | else if (ent == "/big") |
919 | { | 918 | { |
920 | currentstyle.setFontSize(0); | 919 | currentstyle.setFontSize(0); |
921 | } | 920 | } |
922 | else if (ent[0] == 'h' && ent.length() == 2 && QString("123456789").find(ent[1]) != -1) | 921 | else if (ent[0] == 'h' && ent.length() == 2 && QString("123456789").find(ent[1]) != -1) |
923 | { | 922 | { |
924 | indent = 0; | 923 | indent = 0; |
925 | if (ent[1] == '1') | 924 | if (ent[1] == '1') |
926 | { | 925 | { |
927 | parse_paragraph(currentstyle, ch, pos); | 926 | parse_paragraph(currentstyle, ch, pos); |
928 | currentstyle.setFontSize(3); | 927 | currentstyle.setFontSize(3); |
929 | currentstyle.setExtraSpace(8); | 928 | currentstyle.setExtraSpace(8); |
930 | currentstyle.setBold(); | 929 | currentstyle.setBold(); |
931 | // currentstyle.setExtraSpace(10); | 930 | // currentstyle.setExtraSpace(10); |
932 | continue; | 931 | continue; |
933 | } | 932 | } |
934 | else if (ent[1] == '2') | 933 | else if (ent[1] == '2') |
935 | { | 934 | { |
936 | parse_paragraph(currentstyle, ch, pos); | 935 | parse_paragraph(currentstyle, ch, pos); |
937 | currentstyle.setFontSize(2); | 936 | currentstyle.setFontSize(2); |
938 | currentstyle.setExtraSpace(6); | 937 | currentstyle.setExtraSpace(6); |
939 | currentstyle.setBold(); | 938 | currentstyle.setBold(); |
940 | // currentstyle.setExtraSpace(10); | 939 | // currentstyle.setExtraSpace(10); |
941 | continue; | 940 | continue; |
942 | } | 941 | } |
943 | else if (ent[1] == '3') | 942 | else if (ent[1] == '3') |
944 | { | 943 | { |
945 | parse_paragraph(currentstyle, ch, pos); | 944 | parse_paragraph(currentstyle, ch, pos); |
946 | currentstyle.setFontSize(1); | 945 | currentstyle.setFontSize(1); |
947 | currentstyle.setExtraSpace(4); | 946 | currentstyle.setExtraSpace(4); |
948 | currentstyle.setBold(); | 947 | currentstyle.setBold(); |
949 | // currentstyle.setExtraSpace(10); | 948 | // currentstyle.setExtraSpace(10); |
950 | continue; | 949 | continue; |
951 | } | 950 | } |
952 | else | 951 | else |
953 | { | 952 | { |
954 | parse_paragraph(currentstyle, ch, pos); | 953 | parse_paragraph(currentstyle, ch, pos); |
955 | currentstyle.setExtraSpace(4); | 954 | currentstyle.setExtraSpace(4); |
956 | currentstyle.setBold(); | 955 | currentstyle.setBold(); |
957 | // currentstyle.setExtraSpace(10); | 956 | // currentstyle.setExtraSpace(10); |
958 | continue; | 957 | continue; |
959 | } | 958 | } |
960 | } | 959 | } |
961 | 960 | ||
962 | 961 | ||
963 | else if (ent == "/a") | 962 | else if (ent == "/a") |
964 | { | 963 | { |
965 | currentstyle.setColour(0,0,0); | 964 | currentstyle.setColour(0,0,0); |
966 | currentstyle.setLink(false); | 965 | currentstyle.setLink(false); |
967 | } | 966 | } |
968 | else if (ent == "/pre") | 967 | else if (ent == "/pre") |
969 | { | 968 | { |
970 | currentstyle.unsetMono(); | 969 | currentstyle.unsetMono(); |
971 | isPre = false; | 970 | isPre = false; |
972 | } | 971 | } |
973 | else if (ent == "/tt") | 972 | else if (ent == "/tt") |
974 | { | 973 | { |
975 | currentstyle.unsetMono(); | 974 | currentstyle.unsetMono(); |
976 | } | 975 | } |
977 | else if (ent == "/b" || ent == "/strong") | 976 | else if (ent == "/b" || ent == "/strong") |
978 | { | 977 | { |
979 | currentstyle.unsetBold(); | 978 | currentstyle.unsetBold(); |
980 | } | 979 | } |
981 | else if (ent == "/i") | 980 | else if (ent == "/i") |
982 | { | 981 | { |
983 | currentstyle.unsetItalic(); | 982 | currentstyle.unsetItalic(); |
984 | } | 983 | } |
985 | else if (ent == "/em") | 984 | else if (ent == "/em") |
986 | { | 985 | { |
987 | currentstyle.unsetItalic(); | 986 | currentstyle.unsetItalic(); |
988 | } | 987 | } |
989 | else if (ent == "/div") | 988 | else if (ent == "/div") |
990 | { | 989 | { |
991 | currentstyle.unset(); | 990 | currentstyle.unset(); |
992 | if (ch != '>') ch = skip_ws_end(); | 991 | if (ch != '>') ch = skip_ws_end(); |
993 | ch = 10; | 992 | ch = 10; |
994 | if (!stylestack.isEmpty()) | 993 | if (!stylestack.isEmpty()) |
995 | { | 994 | { |
996 | stylestack.pop(); | 995 | stylestack.pop(); |
997 | } | 996 | } |
998 | continue; | 997 | continue; |
999 | } | 998 | } |
1000 | else if (ent == "tr") | 999 | else if (ent == "tr") |
1001 | { | 1000 | { |
1002 | if (ch != '>') ch = skip_ws_end(); | 1001 | if (ch != '>') ch = skip_ws_end(); |
1003 | ch = 10; | 1002 | ch = 10; |
1004 | q += '-'; | 1003 | q += '-'; |
1005 | q += QChar(parent->getwidth()); | 1004 | q += QChar(parent->getwidth()); |
1006 | q += 2; | 1005 | q += 2; |
1007 | q += '\0'; | 1006 | q += '\0'; |
1008 | q += '\0'; | 1007 | q += '\0'; |
1009 | q += '\0'; | 1008 | q += '\0'; |
1010 | continue; | 1009 | continue; |
1011 | } | 1010 | } |
1012 | else if (ent == "td") | 1011 | else if (ent == "td") |
1013 | { | 1012 | { |
1014 | if (ch != '>') ch = skip_ws_end(); | 1013 | if (ch != '>') ch = skip_ws_end(); |
1015 | ignorespace = false; | 1014 | ignorespace = false; |
1016 | } | 1015 | } |
1017 | else if (ent == "/td") | 1016 | else if (ent == "/td") |
1018 | { | 1017 | { |
1019 | ignorespace = true; | 1018 | ignorespace = true; |
1020 | // parse_paragraph(currentstyle, ch, pos); | 1019 | // parse_paragraph(currentstyle, ch, pos); |
1021 | //stylestack.push_front(currentstyle); | 1020 | //stylestack.push_front(currentstyle); |
1022 | if (ch != '>') ch = skip_ws_end(); | 1021 | if (ch != '>') ch = skip_ws_end(); |
1023 | // ch = '|'; | 1022 | // ch = '|'; |
1024 | //continue; | 1023 | //continue; |
1025 | ch = 10; | 1024 | ch = 10; |
1026 | q += '-'; | 1025 | q += '-'; |
1027 | q += QChar(parent->getwidth()); | 1026 | q += QChar(parent->getwidth()); |
1028 | q += 1; | 1027 | q += 1; |
1029 | q += '\0'; | 1028 | q += '\0'; |
1030 | q += '\0'; | 1029 | q += '\0'; |
1031 | q += '\0'; | 1030 | q += '\0'; |
1032 | continue; | 1031 | continue; |
1033 | } | 1032 | } |
1034 | /* | 1033 | /* |
1035 | else if (ent == "/td") | 1034 | else if (ent == "/td") |
1036 | { | 1035 | { |
1037 | currentstyle.unset(); | 1036 | currentstyle.unset(); |
1038 | if (ch != '>') ch = skip_ws_end(); | 1037 | if (ch != '>') ch = skip_ws_end(); |
1039 | if (!stylestack.isEmpty()) | 1038 | if (!stylestack.isEmpty()) |
1040 | { | 1039 | { |
1041 | stylestack.pop(); | 1040 | stylestack.pop(); |
1042 | } | 1041 | } |
1043 | // ch = 10; | 1042 | // ch = 10; |
1044 | continue; | 1043 | continue; |
1045 | } | 1044 | } |
1046 | */ | 1045 | */ |
1047 | else if (ent[0] == '/' && ent.length() == 3 && ent[1] == 'h' && QString("123456789").find(ent[2]) != -1) | 1046 | else if (ent[0] == '/' && ent.length() == 3 && ent[1] == 'h' && QString("123456789").find(ent[2]) != -1) |
1048 | { | 1047 | { |
1049 | currentstyle.unset(); | 1048 | currentstyle.unset(); |
1050 | if (ch != '>') ch = skip_ws_end(); | 1049 | if (ch != '>') ch = skip_ws_end(); |
1051 | ch = 10; | 1050 | ch = 10; |
1052 | continue; | 1051 | continue; |
1053 | } | 1052 | } |
1054 | 1053 | ||
1055 | 1054 | ||
1056 | 1055 | ||
1057 | else if (ent == "table" || ent == "/table") | 1056 | else if (ent == "table" || ent == "/table") |
1058 | { | 1057 | { |
1059 | currentstyle.unset(); | 1058 | currentstyle.unset(); |
1060 | ignorespace = (ent == "table"); | 1059 | ignorespace = (ent == "table"); |
1061 | if (ch == ' ') ch = skip_ws(); | 1060 | if (ch == ' ') ch = skip_ws(); |
1062 | while (ch != '>' && ch != UEOF) | 1061 | while (ch != '>' && ch != UEOF) |
1063 | { | 1062 | { |
1064 | QString ent = getname(ch, " =>").lower(); | 1063 | QString ent = getname(ch, " =>").lower(); |
1065 | QString attr = getattr(ch); | 1064 | QString attr = getattr(ch); |
1066 | qDebug("<table>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 1065 | qDebug("<table>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
1067 | } | 1066 | } |
1068 | if (ch != '>') ch = skip_ws_end(); | 1067 | if (ch != '>') ch = skip_ws_end(); |
1069 | 1068 | ||
1070 | ch = 10; | 1069 | ch = 10; |
1071 | q += '-'; | 1070 | q += '-'; |
1072 | q += QChar(parent->getwidth()); | 1071 | q += QChar(parent->getwidth()); |
1073 | q += 2; | 1072 | q += 2; |
1074 | q += '\0'; | 1073 | q += '\0'; |
1075 | q += '\0'; | 1074 | q += '\0'; |
1076 | q += '\0'; | 1075 | q += '\0'; |
1077 | continue; | 1076 | continue; |
1078 | } | 1077 | } |
1079 | else if (ent == "hr") | 1078 | else if (ent == "hr") |
1080 | { | 1079 | { |
1081 | if (ch == ' ') ch = skip_ws(); | 1080 | if (ch == ' ') ch = skip_ws(); |
1082 | // if (stylestack.isEmpty()) | 1081 | // if (stylestack.isEmpty()) |
1083 | // { | 1082 | // { |
1084 | currentstyle.unset(); | 1083 | currentstyle.unset(); |
1085 | // } | 1084 | // } |
1086 | /* | 1085 | /* |
1087 | else | 1086 | else |
1088 | { | 1087 | { |
1089 | qDebug("Using stack style"); | 1088 | qDebug("Using stack style"); |
1090 | currentstyle = stylestack.first(); | 1089 | currentstyle = stylestack.first(); |
1091 | } | 1090 | } |
1092 | */ | 1091 | */ |
1093 | unsigned char red = 0, green = 0, blue = 0; | 1092 | unsigned char red = 0, green = 0, blue = 0; |
1094 | while (ch != '>' && ch != UEOF) | 1093 | while (ch != '>' && ch != UEOF) |
1095 | { | 1094 | { |
1096 | QString ent = getname(ch, " =>").lower(); | 1095 | QString ent = getname(ch, " =>").lower(); |
1097 | QString attr = getattr(ch); | 1096 | QString attr = getattr(ch); |
1098 | if (ent == "color") | 1097 | if (ent == "color") |
1099 | { | 1098 | { |
1100 | parse_color(attr, red, green, blue); | 1099 | parse_color(attr, red, green, blue); |
1101 | } | 1100 | } |
1102 | qDebug("<hr>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 1101 | qDebug("<hr>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
1103 | } | 1102 | } |
1104 | if (ch != '>') ch = skip_ws_end(); | 1103 | if (ch != '>') ch = skip_ws_end(); |
1105 | ch = 10; | 1104 | ch = 10; |
1106 | q += '-'; | 1105 | q += '-'; |
1107 | q += QChar(parent->getwidth()); | 1106 | q += QChar(parent->getwidth()); |
1108 | q += 3; | 1107 | q += 3; |
1109 | q += red; | 1108 | q += red; |
1110 | q += green; | 1109 | q += green; |
1111 | q += blue; | 1110 | q += blue; |
1112 | continue; | 1111 | continue; |
1113 | } | 1112 | } |
1114 | 1113 | ||
1115 | 1114 | ||
1116 | 1115 | ||
1117 | else if (ent == "img") | 1116 | else if (ent == "img") |
1118 | { | 1117 | { |
1119 | if (ch == ' ') ch = skip_ws(); | 1118 | if (ch == ' ') ch = skip_ws(); |
1120 | while (ch != '>' && ch != UEOF) | 1119 | while (ch != '>' && ch != UEOF) |
1121 | { | 1120 | { |
1122 | QString ent = getname(ch, " =>").lower(); | 1121 | QString ent = getname(ch, " =>").lower(); |
1123 | QString attr = getattr(ch); | 1122 | QString attr = getattr(ch); |
1124 | qDebug("<img>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 1123 | qDebug("<img>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
1125 | if (ent == "src") | 1124 | if (ent == "src") |
1126 | { | 1125 | { |
1127 | if (m_bchm) | 1126 | if (m_bchm) |
1128 | { | 1127 | { |
1129 | QImage* img = parent->getPicture(attr); | 1128 | QImage* img = parent->getPicture(attr); |
1130 | if (img != NULL) | 1129 | if (img != NULL) |
1131 | { | 1130 | { |
1132 | currentstyle.setPicture(true, img); | 1131 | currentstyle.setPicture(true, img); |
1133 | } | 1132 | } |
1134 | } | 1133 | } |
1135 | else | 1134 | else |
1136 | { | 1135 | { |
1137 | QFileInfo f(currentfile); | 1136 | QFileInfo f(currentfile); |
1138 | QFileInfo f1(f.dir(true), attr); | 1137 | QFileInfo f1(f.dir(true), attr); |
1139 | QPixmap pm; | 1138 | QPixmap pm; |
1140 | if (pm.load(f1.absFilePath())) | 1139 | if (pm.load(f1.absFilePath())) |
1141 | { | 1140 | { |
1142 | QImage* img = new QImage(pm.convertToImage()); | 1141 | QImage* img = new QImage(pm.convertToImage()); |
1143 | currentstyle.setPicture(true, img); | 1142 | currentstyle.setPicture(true, img); |
1144 | } | 1143 | } |
1145 | } | 1144 | } |
1146 | } | 1145 | } |
1147 | if (ent == "recindex") | 1146 | if (ent == "recindex") |
1148 | { | 1147 | { |
1149 | bool ok; | 1148 | bool ok; |
1150 | unsigned int picindex = attr.toUInt(&ok); | 1149 | unsigned int picindex = attr.toUInt(&ok); |
1151 | qDebug("Looking for image at %u", picindex); | 1150 | qDebug("Looking for image at %u", picindex); |
1152 | QImage* img = parent->getPicture(picindex); | 1151 | QImage* img = parent->getPicture(picindex); |
1153 | if (img != NULL) | 1152 | if (img != NULL) |
1154 | { | 1153 | { |
1155 | currentstyle.setPicture(true, img); | 1154 | currentstyle.setPicture(true, img); |
1156 | } | 1155 | } |
1157 | else | 1156 | else |
1158 | { | 1157 | { |
1159 | qDebug("No image found"); | 1158 | qDebug("No image found"); |
1160 | } | 1159 | } |
1161 | } | 1160 | } |
1162 | } | 1161 | } |
1163 | if (ch != '>') ch = skip_ws_end(); | 1162 | if (ch != '>') ch = skip_ws_end(); |
1164 | ch = '#'; | 1163 | ch = '#'; |
1165 | break; | 1164 | break; |
1166 | } | 1165 | } |
1167 | else if (ent.left(2) == "dc") | 1166 | else if (ent.left(2) == "dc") |
1168 | { | 1167 | { |
1169 | QString nd("/"); | 1168 | QString nd("/"); |
1170 | skipblock(nd+ent); | 1169 | skipblock(nd+ent); |
1171 | } | 1170 | } |
1172 | else if (ent == "metadata") | 1171 | else if (ent == "metadata") |
1173 | { | 1172 | { |
1174 | // skipblock("/metadata"); | 1173 | // skipblock("/metadata"); |
1175 | } | 1174 | } |
1176 | /* | 1175 | /* |
1177 | else if (ent == "metadata") | 1176 | else if (ent == "metadata") |
1178 | { | 1177 | { |
1179 | currentstyle.setFontSize(-2); | 1178 | currentstyle.setFontSize(-2); |
1180 | } | 1179 | } |
1181 | else if (ent == "/metadata") | 1180 | else if (ent == "/metadata") |
1182 | { | 1181 | { |
1183 | currentstyle.unset(); | 1182 | currentstyle.unset(); |
1184 | ch = 10; | 1183 | ch = 10; |
1185 | continue; | 1184 | continue; |
1186 | } | 1185 | } |
1187 | */ | 1186 | */ |
1188 | else | 1187 | else |
1189 | { | 1188 | { |
1190 | if (ent[0] != '/') | 1189 | if (ent[0] != '/') |
1191 | qDebug("Not handling:%s", (const char*)ent); | 1190 | qDebug("Not handling:%s", (const char*)ent); |
1192 | } | 1191 | } |
1193 | 1192 | ||
1194 | if (ch != '>') ch = skip_ws_end(); | 1193 | if (ch != '>') ch = skip_ws_end(); |
1195 | mygetch(ch, dummy, npos); | 1194 | mygetch(ch, dummy, npos); |
1196 | } | 1195 | } |
1197 | if (ch == '&') | 1196 | if (ch == '&') |
1198 | { | 1197 | { |
1199 | mygetch(ch, dummy, npos); | 1198 | mygetch(ch, dummy, npos); |
1200 | if (ch == '#') | 1199 | if (ch == '#') |
1201 | { | 1200 | { |
1202 | int id = 0; | 1201 | int id = 0; |
1203 | mygetch(ch, dummy, npos); | 1202 | mygetch(ch, dummy, npos); |
1204 | while (ch != ';' && ch != UEOF) | 1203 | while (ch != ';' && ch != UEOF) |
1205 | { | 1204 | { |
1206 | id = 10*id+ch-'0'; | 1205 | id = 10*id+ch-'0'; |
1207 | mygetch(ch, dummy, npos); | 1206 | mygetch(ch, dummy, npos); |
1208 | } | 1207 | } |
1209 | ch = id; | 1208 | ch = id; |
1210 | } | 1209 | } |
1211 | else | 1210 | else |
1212 | { | 1211 | { |
1213 | QString en; | 1212 | QString en; |
1214 | en += ch; | 1213 | en += ch; |
1215 | mygetch(ch, dummy, npos); | 1214 | mygetch(ch, dummy, npos); |
1216 | while (ch != ';' && ch != UEOF) | 1215 | while (ch != ';' && ch != UEOF) |
1217 | { | 1216 | { |
1218 | en += ch; | 1217 | en += ch; |
1219 | mygetch(ch, dummy, npos); | 1218 | mygetch(ch, dummy, npos); |
1220 | } | 1219 | } |
1221 | if (entmap == NULL) initentmap(); | 1220 | if (entmap == NULL) initentmap(); |
1222 | #if defined(USEQPE) || defined(_WINDOWS) | 1221 | #if defined(USEQPE) || defined(_WINDOWS) |
1223 | QMap<QString, tchar>::Iterator it = entmap->find(en); | 1222 | QMap<QString, tchar>::Iterator it = entmap->find(en); |
1224 | #else | 1223 | #else |
1225 | QMap<QString, tchar>::iterator it = entmap->find(en); | 1224 | QMap<QString, tchar>::iterator it = entmap->find(en); |
1226 | #endif | 1225 | #endif |
1227 | if (it != entmap->end()) | 1226 | if (it != entmap->end()) |
1228 | { | 1227 | { |
1229 | ch = *it; | 1228 | ch = *it; |
1230 | } | 1229 | } |
1231 | else | 1230 | else |
1232 | { | 1231 | { |
1233 | ch = '.'; | 1232 | ch = '.'; |
1234 | } | 1233 | } |
1235 | } | 1234 | } |
1236 | } | 1235 | } |
1237 | // sty = (dummy == ucFontBase) ? currentstyle : dummy; | 1236 | // sty = (dummy == ucFontBase) ? currentstyle : dummy; |
1238 | sty = currentstyle; | 1237 | sty = currentstyle; |
1239 | } | 1238 | } |
1240 | while (!isPre && (lastch == ' ' || lastch == 10 || ignorespace) && ch == ' '); | 1239 | while (!isPre && (lastch == ' ' || lastch == 10 || ignorespace) && ch == ' '); |
1241 | // lastch = ch; | 1240 | // lastch = ch; |
1242 | lastch = ch; | 1241 | lastch = ch; |
1243 | return; | 1242 | return; |
1244 | } | 1243 | } |
1245 | 1244 | ||
1246 | extern "C" | 1245 | extern "C" |
1247 | { | 1246 | { |
1248 | CFilter* newfilter(const QString& s) { return new striphtml(s); } | 1247 | CFilter* newfilter(const QString& s) { return new striphtml(s); } |
1249 | } | 1248 | } |
diff --git a/noncore/apps/opie-reader/useqpe.h b/noncore/apps/opie-reader/useqpe.h deleted file mode 100644 index e69de29..0000000 --- a/noncore/apps/opie-reader/useqpe.h +++ b/dev/null | |||
diff --git a/noncore/apps/opie-reader/ztxt.cpp b/noncore/apps/opie-reader/ztxt.cpp index 79c5fa4..35db05e 100644 --- a/noncore/apps/opie-reader/ztxt.cpp +++ b/noncore/apps/opie-reader/ztxt.cpp | |||
@@ -1,174 +1,173 @@ | |||
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 | #include "static.h" | ||
7 | 6 | ||
8 | 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);*/ } |
9 | 8 | ||
10 | 9 | ||
11 | int ztxt::OpenFile(const char *src) | 10 | int ztxt::OpenFile(const char *src) |
12 | { | 11 | { |
13 | if (!Cpdb::openpdbfile(src)) | 12 | if (!Cpdb::openpdbfile(src)) |
14 | { | 13 | { |
15 | return -1; | 14 | return -1; |
16 | } | 15 | } |
17 | 16 | ||
18 | //printf("Okay %u\n", 4); | 17 | //printf("Okay %u\n", 4); |
19 | 18 | ||
20 | if (head.type != ZTXT_ID) return -1; | 19 | if (head.type != ZTXT_ID) return -1; |
21 | 20 | ||
22 | gotorecordnumber(0); | 21 | gotorecordnumber(0); |
23 | fread(&hdr0, 1, sizeof(hdr0), fin); | 22 | fread(&hdr0, 1, sizeof(hdr0), fin); |
24 | //printf("Okay %u\n", 5); | 23 | //printf("Okay %u\n", 5); |
25 | buffersize = ntohl(hdr0.size); | 24 | buffersize = ntohl(hdr0.size); |
26 | compressedtextbuffer = new UInt8[buffersize]; | 25 | compressedtextbuffer = new UInt8[buffersize]; |
27 | expandedtextbuffer = new UInt8[buffersize]; | 26 | expandedtextbuffer = new UInt8[buffersize]; |
28 | //printf("Okay %u\n", 6); | 27 | //printf("Okay %u\n", 6); |
29 | 28 | ||
30 | home(); | 29 | home(); |
31 | //printf("Okay %u\n", 7); | 30 | //printf("Okay %u\n", 7); |
32 | 31 | ||
33 | // printf("Returning 0\n"); | 32 | // printf("Returning 0\n"); |
34 | 33 | ||
35 | return 0; | 34 | return 0; |
36 | } | 35 | } |
37 | 36 | ||
38 | int ztxt::getch() | 37 | int ztxt::getch() |
39 | { | 38 | { |
40 | if (bufferpos >= buffercontent) | 39 | if (bufferpos >= buffercontent) |
41 | { | 40 | { |
42 | size_t reclen = recordlength(++bufferrec); | 41 | size_t reclen = recordlength(++bufferrec); |
43 | if (reclen == 0) return -1; | 42 | if (reclen == 0) return -1; |
44 | gotorecordnumber(bufferrec); | 43 | gotorecordnumber(bufferrec); |
45 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | 44 | fread(compressedtextbuffer, reclen, sizeof(char), fin); |
46 | 45 | ||
47 | zstream.next_in = compressedtextbuffer; | 46 | zstream.next_in = compressedtextbuffer; |
48 | zstream.next_out = expandedtextbuffer; | 47 | zstream.next_out = expandedtextbuffer; |
49 | zstream.avail_out = buffersize; | 48 | zstream.avail_out = buffersize; |
50 | zstream.avail_in = reclen; | 49 | zstream.avail_in = reclen; |
51 | 50 | ||
52 | int ret = inflate(&zstream, Z_SYNC_FLUSH); | 51 | int ret = inflate(&zstream, Z_SYNC_FLUSH); |
53 | buffercontent = buffersize - zstream.avail_out; | 52 | buffercontent = buffersize - zstream.avail_out; |
54 | bufferpos = 0; | 53 | bufferpos = 0; |
55 | 54 | ||
56 | } | 55 | } |
57 | currentpos++; | 56 | currentpos++; |
58 | return expandedtextbuffer[bufferpos++]; | 57 | return expandedtextbuffer[bufferpos++]; |
59 | } | 58 | } |
60 | 59 | ||
61 | unsigned int ztxt::locate() | 60 | unsigned int ztxt::locate() |
62 | { | 61 | { |
63 | return currentpos; | 62 | return currentpos; |
64 | } | 63 | } |
65 | 64 | ||
66 | void ztxt::locate(unsigned int n) | 65 | void ztxt::locate(unsigned int n) |
67 | { | 66 | { |
68 | 67 | ||
69 | if (hasrandomaccess()) | 68 | if (hasrandomaccess()) |
70 | { | 69 | { |
71 | bufferrec = n / ntohs(hdr0.recordSize) + 1; | 70 | bufferrec = n / ntohs(hdr0.recordSize) + 1; |
72 | if (bufferrec == 1) | 71 | if (bufferrec == 1) |
73 | { | 72 | { |
74 | inflateEnd(&zstream); | 73 | inflateEnd(&zstream); |
75 | } | 74 | } |
76 | size_t reclen = recordlength(bufferrec); | 75 | size_t reclen = recordlength(bufferrec); |
77 | if (reclen == 0) return; | 76 | if (reclen == 0) return; |
78 | gotorecordnumber(bufferrec); | 77 | gotorecordnumber(bufferrec); |
79 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | 78 | fread(compressedtextbuffer, reclen, sizeof(char), fin); |
80 | 79 | ||
81 | zstream.next_in = compressedtextbuffer; | 80 | zstream.next_in = compressedtextbuffer; |
82 | zstream.next_out = expandedtextbuffer; | 81 | zstream.next_out = expandedtextbuffer; |
83 | zstream.avail_out = buffersize; | 82 | zstream.avail_out = buffersize; |
84 | zstream.avail_in = reclen; | 83 | zstream.avail_in = reclen; |
85 | 84 | ||
86 | if (bufferrec == 1) | 85 | if (bufferrec == 1) |
87 | { | 86 | { |
88 | zstream.zalloc = Z_NULL; | 87 | zstream.zalloc = Z_NULL; |
89 | zstream.zfree = Z_NULL; | 88 | zstream.zfree = Z_NULL; |
90 | zstream.opaque = Z_NULL; | 89 | zstream.opaque = Z_NULL; |
91 | 90 | ||
92 | inflateInit(&zstream); | 91 | inflateInit(&zstream); |
93 | } | 92 | } |
94 | 93 | ||
95 | 94 | ||
96 | int ret = inflate(&zstream, Z_SYNC_FLUSH); | 95 | int ret = inflate(&zstream, Z_SYNC_FLUSH); |
97 | buffercontent = buffersize - zstream.avail_out; | 96 | buffercontent = buffersize - zstream.avail_out; |
98 | bufferpos = 0; | 97 | bufferpos = 0; |
99 | currentpos = n - n % ntohs(hdr0.recordSize); | 98 | currentpos = n - n % ntohs(hdr0.recordSize); |
100 | while (currentpos < n) getch(); | 99 | while (currentpos < n) getch(); |
101 | } | 100 | } |
102 | else | 101 | else |
103 | { | 102 | { |
104 | home(); | 103 | home(); |
105 | while (currentpos < n && getch() != EOF); | 104 | while (currentpos < n && getch() != EOF); |
106 | } | 105 | } |
107 | } | 106 | } |
108 | 107 | ||
109 | void ztxt::home() | 108 | void ztxt::home() |
110 | { | 109 | { |
111 | if (bInit) | 110 | if (bInit) |
112 | { | 111 | { |
113 | inflateEnd(&zstream); | 112 | inflateEnd(&zstream); |
114 | } | 113 | } |
115 | bInit = true; | 114 | bInit = true; |
116 | size_t reclen = recordlength(1); | 115 | size_t reclen = recordlength(1); |
117 | gotorecordnumber(1); | 116 | gotorecordnumber(1); |
118 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | 117 | fread(compressedtextbuffer, reclen, sizeof(char), fin); |
119 | 118 | ||
120 | zstream.next_in = compressedtextbuffer; | 119 | zstream.next_in = compressedtextbuffer; |
121 | zstream.next_out = expandedtextbuffer; | 120 | zstream.next_out = expandedtextbuffer; |
122 | zstream.avail_out = buffersize; | 121 | zstream.avail_out = buffersize; |
123 | zstream.avail_in = reclen; | 122 | zstream.avail_in = reclen; |
124 | 123 | ||
125 | zstream.zalloc = Z_NULL; | 124 | zstream.zalloc = Z_NULL; |
126 | zstream.zfree = Z_NULL; | 125 | zstream.zfree = Z_NULL; |
127 | zstream.opaque = Z_NULL; | 126 | zstream.opaque = Z_NULL; |
128 | 127 | ||
129 | // printf("Initialising\n"); | 128 | // printf("Initialising\n"); |
130 | 129 | ||
131 | inflateInit(&zstream); | 130 | inflateInit(&zstream); |
132 | 131 | ||
133 | int ret = inflate(&zstream, Z_SYNC_FLUSH); | 132 | int ret = inflate(&zstream, Z_SYNC_FLUSH); |
134 | // printf("Inflate : %d\n", ret); | 133 | // printf("Inflate : %d\n", ret); |
135 | bufferpos = 0; | 134 | bufferpos = 0; |
136 | bufferrec = 1; | 135 | bufferrec = 1; |
137 | currentpos = 0; | 136 | currentpos = 0; |
138 | buffercontent = buffersize - zstream.avail_out; | 137 | buffercontent = buffersize - zstream.avail_out; |
139 | //printf("buffercontent:%u\n", buffercontent); | 138 | //printf("buffercontent:%u\n", buffercontent); |
140 | } | 139 | } |
141 | 140 | ||
142 | CList<Bkmk>* ztxt::getbkmklist() | 141 | CList<Bkmk>* ztxt::getbkmklist() |
143 | { | 142 | { |
144 | UInt16 recno = ntohs(hdr0.bookmarkRecord); | 143 | UInt16 recno = ntohs(hdr0.bookmarkRecord); |
145 | 144 | ||
146 | // printf("Bookmarks - record %d contains %d\n", recno, ntohs(hdr0.numBookmarks)); | 145 | // printf("Bookmarks - record %d contains %d\n", recno, ntohs(hdr0.numBookmarks)); |
147 | 146 | ||
148 | if (recno == 0) return NULL; | 147 | if (recno == 0) return NULL; |
149 | 148 | ||
150 | CList<Bkmk>* t = new CList<Bkmk>; | 149 | CList<Bkmk>* t = new CList<Bkmk>; |
151 | size_t cur = ftell(fin); | 150 | size_t cur = ftell(fin); |
152 | gotorecordnumber(recno); | 151 | gotorecordnumber(recno); |
153 | for (int i = 0; i < ntohs(hdr0.numBookmarks); i++) | 152 | for (int i = 0; i < ntohs(hdr0.numBookmarks); i++) |
154 | { | 153 | { |
155 | zTXTbkmk bkmk; | 154 | zTXTbkmk bkmk; |
156 | if (fread(&bkmk, sizeof(bkmk), 1, fin) != 1) break; | 155 | if (fread(&bkmk, sizeof(bkmk), 1, fin) != 1) break; |
157 | // printf("Bookmark number:%d:%.20s\n", i, bkmk.title); | 156 | // printf("Bookmark number:%d:%.20s\n", i, bkmk.title); |
158 | tchar title[MAX_BMRK_LENGTH]; | 157 | tchar title[MAX_BMRK_LENGTH]; |
159 | for (int j = 0; j < MAX_BMRK_LENGTH; j++) | 158 | for (int j = 0; j < MAX_BMRK_LENGTH; j++) |
160 | { | 159 | { |
161 | title[j] = bkmk.title[j]; | 160 | title[j] = bkmk.title[j]; |
162 | } | 161 | } |
163 | t->push_back(Bkmk(title, NULL, ntohl(bkmk.offset))); | 162 | t->push_back(Bkmk(title, NULL, ntohl(bkmk.offset))); |
164 | } | 163 | } |
165 | fseek(fin, cur, SEEK_SET); | 164 | fseek(fin, cur, SEEK_SET); |
166 | return t; | 165 | return t; |
167 | } | 166 | } |
168 | 167 | ||
169 | #ifndef __STATIC | 168 | #ifndef __STATIC |
170 | extern "C" | 169 | extern "C" |
171 | { | 170 | { |
172 | CExpander* newcodec() { return new ztxt; } | 171 | CExpander* newcodec() { return new ztxt; } |
173 | } | 172 | } |
174 | #endif | 173 | #endif |