author | chicken <chicken> | 2004-03-01 19:23:21 (UTC) |
---|---|---|
committer | chicken <chicken> | 2004-03-01 19:23:21 (UTC) |
commit | e6fcfb9a4c0c744ea7b0ec8b7e200b185a8a309a (patch) (unidiff) | |
tree | 35b7298eb0d91fa038f84814205f415102975f3f | |
parent | ddc3d749af5f7afebf69488b79641771fe246b5b (diff) | |
download | opie-e6fcfb9a4c0c744ea7b0ec8b7e200b185a8a309a.zip opie-e6fcfb9a4c0c744ea7b0ec8b7e200b185a8a309a.tar.gz opie-e6fcfb9a4c0c744ea7b0ec8b7e200b185a8a309a.tar.bz2 |
fix includes
-rw-r--r-- | noncore/apps/opie-reader/Bkmks.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/BuffDoc.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-reader/CDrawBuffer.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-reader/CEncoding_tables.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-reader/CFilter.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-reader/FontControl.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/Palm2QImage.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-reader/Prefs.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/opie-reader/QTReader.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 8443 | ||||
-rw-r--r-- | noncore/apps/opie-reader/ToolbarPrefs.cpp | 10 | ||||
-rw-r--r-- | noncore/apps/opie-reader/fileBrowser.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-reader/main.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/plucker.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/opie-reader/plucker_base.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/opie-reader/ppm.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-reader/version.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/Excel.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/sheet.cpp | 1 |
20 files changed, 4221 insertions, 4291 deletions
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp index 889c6d8..16bc1f1 100644 --- a/noncore/apps/opie-reader/Bkmks.cpp +++ b/noncore/apps/opie-reader/Bkmks.cpp | |||
@@ -1,322 +1,320 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | 2 | ||
3 | #include "Bkmks.h" | 3 | #include "Bkmks.h" |
4 | 4 | ||
5 | #include "StyleConsts.h" | ||
6 | #include "Markups.h" | ||
7 | #include "my_list.h" | 5 | #include "my_list.h" |
8 | #include "version.h" | 6 | #include "version.h" |
9 | #include "names.h" | 7 | #include "names.h" |
10 | 8 | ||
11 | const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); | 9 | const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); |
12 | 10 | ||
13 | Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) : m_position(_p) | 11 | Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) : m_position(_p) |
14 | { | 12 | { |
15 | init(_nm, _nmlen, _anno, _annolen, _p); | 13 | init(_nm, _nmlen, _anno, _annolen, _p); |
16 | } | 14 | } |
17 | 15 | ||
18 | Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p) | 16 | Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p) |
19 | { | 17 | { |
20 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p); | 18 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p); |
21 | } | 19 | } |
22 | 20 | ||
23 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) | 21 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) |
24 | { | 22 | { |
25 | 23 | ||
26 | if (_anno == NULL) | 24 | if (_anno == NULL) |
27 | { | 25 | { |
28 | tchar t = 0; | 26 | tchar t = 0; |
29 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); | 27 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); |
30 | } | 28 | } |
31 | else | 29 | else |
32 | { | 30 | { |
33 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); | 31 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); |
34 | } | 32 | } |
35 | } | 33 | } |
36 | 34 | ||
37 | void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p) | 35 | void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p) |
38 | { | 36 | { |
39 | m_namelen = _nmlen; | 37 | m_namelen = _nmlen; |
40 | if (m_namelen > 0) | 38 | if (m_namelen > 0) |
41 | { | 39 | { |
42 | m_name = new unsigned char[m_namelen]; | 40 | m_name = new unsigned char[m_namelen]; |
43 | memcpy(m_name, _nm, m_namelen); | 41 | memcpy(m_name, _nm, m_namelen); |
44 | } | 42 | } |
45 | else | 43 | else |
46 | { | 44 | { |
47 | m_name = NULL; | 45 | m_name = NULL; |
48 | } | 46 | } |
49 | 47 | ||
50 | m_annolen = _annolen; | 48 | m_annolen = _annolen; |
51 | if (m_annolen > 0) | 49 | if (m_annolen > 0) |
52 | { | 50 | { |
53 | m_anno = new unsigned char[m_annolen]; | 51 | m_anno = new unsigned char[m_annolen]; |
54 | memcpy(m_anno, _anno, m_annolen); | 52 | memcpy(m_anno, _anno, m_annolen); |
55 | } | 53 | } |
56 | else | 54 | else |
57 | { | 55 | { |
58 | m_anno = NULL; | 56 | m_anno = NULL; |
59 | } | 57 | } |
60 | m_position = _p; | 58 | m_position = _p; |
61 | } | 59 | } |
62 | 60 | ||
63 | Bkmk::~Bkmk() | 61 | Bkmk::~Bkmk() |
64 | { | 62 | { |
65 | if (m_name != NULL) delete [] m_name; | 63 | if (m_name != NULL) delete [] m_name; |
66 | m_name = NULL; | 64 | m_name = NULL; |
67 | if (m_anno != NULL) delete [] m_anno; | 65 | if (m_anno != NULL) delete [] m_anno; |
68 | m_anno = NULL; | 66 | m_anno = NULL; |
69 | } | 67 | } |
70 | 68 | ||
71 | Bkmk& Bkmk::operator=(const Bkmk& rhs) | 69 | Bkmk& Bkmk::operator=(const Bkmk& rhs) |
72 | { | 70 | { |
73 | if (m_name != NULL) | 71 | if (m_name != NULL) |
74 | { | 72 | { |
75 | delete [] m_name; | 73 | delete [] m_name; |
76 | m_name = NULL; | 74 | m_name = NULL; |
77 | } | 75 | } |
78 | if (m_anno != NULL) | 76 | if (m_anno != NULL) |
79 | { | 77 | { |
80 | delete [] m_anno; | 78 | delete [] m_anno; |
81 | m_anno = NULL; | 79 | m_anno = NULL; |
82 | } | 80 | } |
83 | if (rhs.m_name != NULL) | 81 | if (rhs.m_name != NULL) |
84 | { | 82 | { |
85 | m_namelen = rhs.m_namelen; | 83 | m_namelen = rhs.m_namelen; |
86 | m_name = new unsigned char[m_namelen]; | 84 | m_name = new unsigned char[m_namelen]; |
87 | memcpy(m_name, rhs.m_name, m_namelen); | 85 | memcpy(m_name, rhs.m_name, m_namelen); |
88 | } | 86 | } |
89 | else | 87 | else |
90 | m_name = NULL; | 88 | m_name = NULL; |
91 | if (rhs.m_anno != NULL) | 89 | if (rhs.m_anno != NULL) |
92 | { | 90 | { |
93 | m_annolen = rhs.m_annolen; | 91 | m_annolen = rhs.m_annolen; |
94 | m_anno = new unsigned char[m_annolen]; | 92 | m_anno = new unsigned char[m_annolen]; |
95 | memcpy(m_anno, rhs.m_anno, m_annolen); | 93 | memcpy(m_anno, rhs.m_anno, m_annolen); |
96 | } | 94 | } |
97 | else | 95 | else |
98 | m_anno = NULL; | 96 | m_anno = NULL; |
99 | m_position = rhs.m_position; | 97 | m_position = rhs.m_position; |
100 | return *this; | 98 | return *this; |
101 | } | 99 | } |
102 | 100 | ||
103 | bool Bkmk::operator==(const Bkmk& rhs) | 101 | bool Bkmk::operator==(const Bkmk& rhs) |
104 | { | 102 | { |
105 | return (m_position == rhs.m_position && (rhs.m_namelen == m_namelen) && memcmp(m_name,rhs.m_name,m_namelen) == 0); | 103 | return (m_position == rhs.m_position && (rhs.m_namelen == m_namelen) && memcmp(m_name,rhs.m_name,m_namelen) == 0); |
106 | } | 104 | } |
107 | 105 | ||
108 | void Bkmk::setAnno(unsigned char* t, unsigned short len) | 106 | void Bkmk::setAnno(unsigned char* t, unsigned short len) |
109 | { | 107 | { |
110 | if (m_anno != NULL) | 108 | if (m_anno != NULL) |
111 | { | 109 | { |
112 | delete [] m_anno; | 110 | delete [] m_anno; |
113 | m_anno = NULL; | 111 | m_anno = NULL; |
114 | } | 112 | } |
115 | if (t != NULL) | 113 | if (t != NULL) |
116 | { | 114 | { |
117 | m_annolen = len; | 115 | m_annolen = len; |
118 | m_anno = new unsigned char[m_annolen]; | 116 | m_anno = new unsigned char[m_annolen]; |
119 | memcpy(m_anno, t, m_annolen); | 117 | memcpy(m_anno, t, m_annolen); |
120 | } | 118 | } |
121 | else | 119 | else |
122 | { | 120 | { |
123 | m_annolen = sizeof(tchar); | 121 | m_annolen = sizeof(tchar); |
124 | m_anno = new unsigned char[m_annolen]; | 122 | m_anno = new unsigned char[m_annolen]; |
125 | *((tchar*)m_anno) = 0; | 123 | *((tchar*)m_anno) = 0; |
126 | } | 124 | } |
127 | } | 125 | } |
128 | 126 | ||
129 | void Bkmk::setAnno(tchar* t) | 127 | void Bkmk::setAnno(tchar* t) |
130 | { | 128 | { |
131 | if (m_anno != NULL) | 129 | if (m_anno != NULL) |
132 | { | 130 | { |
133 | delete [] m_anno; | 131 | delete [] m_anno; |
134 | m_anno = NULL; | 132 | m_anno = NULL; |
135 | } | 133 | } |
136 | if (t != NULL) | 134 | if (t != NULL) |
137 | { | 135 | { |
138 | unsigned short len = ustrlen(t)+1; | 136 | unsigned short len = ustrlen(t)+1; |
139 | m_annolen = sizeof(tchar)*len; | 137 | m_annolen = sizeof(tchar)*len; |
140 | m_anno = new unsigned char[m_annolen]; | 138 | m_anno = new unsigned char[m_annolen]; |
141 | memcpy(m_anno, t, m_annolen); | 139 | memcpy(m_anno, t, m_annolen); |
142 | } | 140 | } |
143 | else | 141 | else |
144 | { | 142 | { |
145 | m_annolen = sizeof(tchar); | 143 | m_annolen = sizeof(tchar); |
146 | m_anno = new unsigned char[m_annolen]; | 144 | m_anno = new unsigned char[m_annolen]; |
147 | *((tchar*)m_anno) = 0; | 145 | *((tchar*)m_anno) = 0; |
148 | } | 146 | } |
149 | } | 147 | } |
150 | 148 | ||
151 | BkmkFile::BkmkFile(const char *fnm, bool w) | 149 | BkmkFile::BkmkFile(const char *fnm, bool w) |
152 | : | 150 | : |
153 | wt(w), isUpgraded(false) | 151 | wt(w), isUpgraded(false) |
154 | { | 152 | { |
155 | if (w) | 153 | if (w) |
156 | { | 154 | { |
157 | f = fopen(fnm, "wb"); | 155 | f = fopen(fnm, "wb"); |
158 | } | 156 | } |
159 | else | 157 | else |
160 | { | 158 | { |
161 | f = fopen(fnm, "rb"); | 159 | f = fopen(fnm, "rb"); |
162 | } | 160 | } |
163 | } | 161 | } |
164 | 162 | ||
165 | BkmkFile::~BkmkFile() | 163 | BkmkFile::~BkmkFile() |
166 | { | 164 | { |
167 | if (f != NULL) fclose(f); | 165 | if (f != NULL) fclose(f); |
168 | } | 166 | } |
169 | 167 | ||
170 | void BkmkFile::write(const Bkmk& b) | 168 | void BkmkFile::write(const Bkmk& b) |
171 | { | 169 | { |
172 | if (f != NULL) | 170 | if (f != NULL) |
173 | { | 171 | { |
174 | fwrite(&b.m_namelen, sizeof(b.m_namelen),1,f); | 172 | fwrite(&b.m_namelen, sizeof(b.m_namelen),1,f); |
175 | fwrite(b.m_name,1,b.m_namelen,f); | 173 | fwrite(b.m_name,1,b.m_namelen,f); |
176 | fwrite(&b.m_annolen, sizeof(b.m_annolen),1,f); | 174 | fwrite(&b.m_annolen, sizeof(b.m_annolen),1,f); |
177 | fwrite(b.m_anno,1,b.m_annolen,f); | 175 | fwrite(b.m_anno,1,b.m_annolen,f); |
178 | fwrite(&b.m_position,sizeof(b.m_position),1,f); | 176 | fwrite(&b.m_position,sizeof(b.m_position),1,f); |
179 | } | 177 | } |
180 | } | 178 | } |
181 | 179 | ||
182 | void BkmkFile::write(CList<Bkmk>& bl) | 180 | void BkmkFile::write(CList<Bkmk>& bl) |
183 | { | 181 | { |
184 | if (f != NULL) | 182 | if (f != NULL) |
185 | { | 183 | { |
186 | fwrite(&magic, sizeof(magic), 1, f); | 184 | fwrite(&magic, sizeof(magic), 1, f); |
187 | for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++) | 185 | for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++) |
188 | { | 186 | { |
189 | write(*i); | 187 | write(*i); |
190 | } | 188 | } |
191 | } | 189 | } |
192 | } | 190 | } |
193 | 191 | ||
194 | CList<Bkmk>* BkmkFile::readall() | 192 | CList<Bkmk>* BkmkFile::readall() |
195 | { | 193 | { |
196 | CList<Bkmk>* bl = NULL; | 194 | CList<Bkmk>* bl = NULL; |
197 | if (f != NULL) | 195 | if (f != NULL) |
198 | { | 196 | { |
199 | unsigned long newmagic; | 197 | unsigned long newmagic; |
200 | fread(&newmagic, sizeof(newmagic), 1, f); | 198 | fread(&newmagic, sizeof(newmagic), 1, f); |
201 | if ((newmagic & 0xffffff00) != (magic & 0xffffff00)) | 199 | if ((newmagic & 0xffffff00) != (magic & 0xffffff00)) |
202 | { | 200 | { |
203 | if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of " PROGNAME "\ndid you upgrade from?", "0_4*", "Any other version") == 0) | 201 | if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of " PROGNAME "\ndid you upgrade from?", "0_4*", "Any other version") == 0) |
204 | { | 202 | { |
205 | fseek(f,0,SEEK_SET); | 203 | fseek(f,0,SEEK_SET); |
206 | bl = readall00(&read05); | 204 | bl = readall00(&read05); |
207 | } | 205 | } |
208 | else | 206 | else |
209 | { | 207 | { |
210 | fseek(f,0,SEEK_SET); | 208 | fseek(f,0,SEEK_SET); |
211 | bl = readall00(&read03); | 209 | bl = readall00(&read03); |
212 | } | 210 | } |
213 | isUpgraded = true; | 211 | isUpgraded = true; |
214 | } | 212 | } |
215 | else | 213 | else |
216 | { | 214 | { |
217 | switch(newmagic & 0xff) | 215 | switch(newmagic & 0xff) |
218 | { | 216 | { |
219 | case 6: | 217 | case 6: |
220 | isUpgraded = false; | 218 | isUpgraded = false; |
221 | bl = readall00(read06); | 219 | bl = readall00(read06); |
222 | // qDebug("Correct version!"); | 220 | // qDebug("Correct version!"); |
223 | break; | 221 | break; |
224 | case 5: | 222 | case 5: |
225 | isUpgraded = true; | 223 | isUpgraded = true; |
226 | bl = readall00(read05); | 224 | bl = readall00(read05); |
227 | // qDebug("Known version!"); | 225 | // qDebug("Known version!"); |
228 | break; | 226 | break; |
229 | default: | 227 | default: |
230 | // qDebug("Unknown version!"); | 228 | // qDebug("Unknown version!"); |
231 | isUpgraded = true; | 229 | isUpgraded = true; |
232 | bl = readall00(read05); | 230 | bl = readall00(read05); |
233 | } | 231 | } |
234 | } | 232 | } |
235 | } | 233 | } |
236 | return bl; | 234 | return bl; |
237 | } | 235 | } |
238 | 236 | ||
239 | CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(FILE*)) | 237 | CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(FILE*)) |
240 | { | 238 | { |
241 | CList<Bkmk>* bl = new CList<Bkmk>; | 239 | CList<Bkmk>* bl = new CList<Bkmk>; |
242 | while (1) | 240 | while (1) |
243 | { | 241 | { |
244 | Bkmk* b = (*readfn)(f); | 242 | Bkmk* b = (*readfn)(f); |
245 | if (b == NULL) break; | 243 | if (b == NULL) break; |
246 | bl->push_back(*b); | 244 | bl->push_back(*b); |
247 | delete b; | 245 | delete b; |
248 | } | 246 | } |
249 | return bl; | 247 | return bl; |
250 | } | 248 | } |
251 | 249 | ||
252 | Bkmk* BkmkFile::read03(FILE* f) | 250 | Bkmk* BkmkFile::read03(FILE* f) |
253 | { | 251 | { |
254 | Bkmk* b = NULL; | 252 | Bkmk* b = NULL; |
255 | if (f != NULL) | 253 | if (f != NULL) |
256 | { | 254 | { |
257 | unsigned short ln; | 255 | unsigned short ln; |
258 | if (fread(&ln,sizeof(ln),1,f) == 1) | 256 | if (fread(&ln,sizeof(ln),1,f) == 1) |
259 | { | 257 | { |
260 | tchar* name = new tchar[ln+1]; | 258 | tchar* name = new tchar[ln+1]; |
261 | fread(name,sizeof(tchar),ln,f); | 259 | fread(name,sizeof(tchar),ln,f); |
262 | name[ln] = 0; | 260 | name[ln] = 0; |
263 | 261 | ||
264 | ln = 0; | 262 | ln = 0; |
265 | tchar* anno = new tchar[ln+1]; | 263 | tchar* anno = new tchar[ln+1]; |
266 | anno[ln] = 0; | 264 | anno[ln] = 0; |
267 | 265 | ||
268 | unsigned int pos; | 266 | unsigned int pos; |
269 | fread(&pos,sizeof(pos),1,f); | 267 | fread(&pos,sizeof(pos),1,f); |
270 | b = new Bkmk(name,anno,pos); | 268 | b = new Bkmk(name,anno,pos); |
271 | } | 269 | } |
272 | } | 270 | } |
273 | return b; | 271 | return b; |
274 | } | 272 | } |
275 | 273 | ||
276 | Bkmk* BkmkFile::read05(FILE* f) | 274 | Bkmk* BkmkFile::read05(FILE* f) |
277 | { | 275 | { |
278 | Bkmk* b = NULL; | 276 | Bkmk* b = NULL; |
279 | if (f != NULL) | 277 | if (f != NULL) |
280 | { | 278 | { |
281 | unsigned short ln; | 279 | unsigned short ln; |
282 | if (fread(&ln,sizeof(ln),1,f) == 1) | 280 | if (fread(&ln,sizeof(ln),1,f) == 1) |
283 | { | 281 | { |
284 | tchar* nm = new tchar[ln+1]; | 282 | tchar* nm = new tchar[ln+1]; |
285 | fread(nm,sizeof(tchar),ln,f); | 283 | fread(nm,sizeof(tchar),ln,f); |
286 | nm[ln] = 0; | 284 | nm[ln] = 0; |
287 | fread(&ln,sizeof(ln),1,f); | 285 | fread(&ln,sizeof(ln),1,f); |
288 | tchar* anno = new tchar[ln+1]; | 286 | tchar* anno = new tchar[ln+1]; |
289 | if (ln > 0) fread(anno,sizeof(tchar),ln,f); | 287 | if (ln > 0) fread(anno,sizeof(tchar),ln,f); |
290 | anno[ln] = 0; | 288 | anno[ln] = 0; |
291 | unsigned int pos; | 289 | unsigned int pos; |
292 | fread(&pos,sizeof(pos),1,f); | 290 | fread(&pos,sizeof(pos),1,f); |
293 | b = new Bkmk(nm,anno,pos); | 291 | b = new Bkmk(nm,anno,pos); |
294 | } | 292 | } |
295 | } | 293 | } |
296 | return b; | 294 | return b; |
297 | } | 295 | } |
298 | 296 | ||
299 | Bkmk* BkmkFile::read06(FILE* f) | 297 | Bkmk* BkmkFile::read06(FILE* f) |
300 | { | 298 | { |
301 | Bkmk* b = NULL; | 299 | Bkmk* b = NULL; |
302 | if (f != NULL) | 300 | if (f != NULL) |
303 | { | 301 | { |
304 | unsigned short ln; | 302 | unsigned short ln; |
305 | if (fread(&ln,sizeof(ln),1,f) == 1) | 303 | if (fread(&ln,sizeof(ln),1,f) == 1) |
306 | { | 304 | { |
307 | b = new Bkmk; | 305 | b = new Bkmk; |
308 | b->m_namelen = ln; | 306 | b->m_namelen = ln; |
309 | b->m_name = new unsigned char[b->m_namelen]; | 307 | b->m_name = new unsigned char[b->m_namelen]; |
310 | fread(b->m_name,1,b->m_namelen,f); | 308 | fread(b->m_name,1,b->m_namelen,f); |
311 | 309 | ||
312 | fread(&(b->m_annolen),sizeof(b->m_annolen),1,f); | 310 | fread(&(b->m_annolen),sizeof(b->m_annolen),1,f); |
313 | if (b->m_annolen > 0) | 311 | if (b->m_annolen > 0) |
314 | { | 312 | { |
315 | b->m_anno = new unsigned char[b->m_annolen]; | 313 | b->m_anno = new unsigned char[b->m_annolen]; |
316 | fread(b->m_anno,1,b->m_annolen,f); | 314 | fread(b->m_anno,1,b->m_annolen,f); |
317 | } | 315 | } |
318 | fread(&(b->m_position),sizeof(b->m_position),1,f); | 316 | fread(&(b->m_position),sizeof(b->m_position),1,f); |
319 | } | 317 | } |
320 | } | 318 | } |
321 | return b; | 319 | return b; |
322 | } | 320 | } |
diff --git a/noncore/apps/opie-reader/BuffDoc.cpp b/noncore/apps/opie-reader/BuffDoc.cpp index 2402904..4fbab93 100644 --- a/noncore/apps/opie-reader/BuffDoc.cpp +++ b/noncore/apps/opie-reader/BuffDoc.cpp | |||
@@ -1,416 +1,412 @@ | |||
1 | #include "names.h" | ||
2 | 1 | ||
3 | #define NEWLINEBREAK | 2 | #define NEWLINEBREAK |
4 | 3 | ||
5 | #include "BuffDoc.h" | 4 | #include "BuffDoc.h" |
6 | //#include <FL/fl_draw.h> | 5 | //#include <FL/fl_draw.h> |
7 | #include "config.h" | ||
8 | #include "CDrawBuffer.h" | ||
9 | #include "plucker.h" | 6 | #include "plucker.h" |
10 | #include "usenef.h" | ||
11 | #ifdef USENEF | 7 | #ifdef USENEF |
12 | #include "nef.h" | 8 | #include "nef.h" |
13 | #include "arrierego.h" | 9 | #include "arrierego.h" |
14 | #endif | 10 | #endif |
15 | 11 | ||
16 | linkType BuffDoc::hyperlink(unsigned int n, QString& wrd) | 12 | linkType BuffDoc::hyperlink(unsigned int n, QString& wrd) |
17 | { | 13 | { |
18 | linkType bRet = eNone; | 14 | linkType bRet = eNone; |
19 | if (exp != NULL) | 15 | if (exp != NULL) |
20 | { | 16 | { |
21 | bRet = exp->hyperlink(n, wrd); | 17 | bRet = exp->hyperlink(n, wrd); |
22 | if (bRet == eLink) | 18 | if (bRet == eLink) |
23 | { | 19 | { |
24 | lastword.empty(); | 20 | lastword.empty(); |
25 | lastsizes[0] = laststartline = n; | 21 | lastsizes[0] = laststartline = n; |
26 | #ifdef NEWLINEBREAK | 22 | #ifdef NEWLINEBREAK |
27 | lastispara = true; | 23 | lastispara = true; |
28 | #else | 24 | #else |
29 | lastispara = false; | 25 | lastispara = false; |
30 | #endif | 26 | #endif |
31 | lastsizes[0] = laststartline = exp->locate(); | 27 | lastsizes[0] = laststartline = exp->locate(); |
32 | } | 28 | } |
33 | } | 29 | } |
34 | return bRet; | 30 | return bRet; |
35 | } | 31 | } |
36 | 32 | ||
37 | void BuffDoc::locate(unsigned int n) | 33 | void BuffDoc::locate(unsigned int n) |
38 | { | 34 | { |
39 | // //qDebug("BuffDoc:locating:%u",n); | 35 | // //qDebug("BuffDoc:locating:%u",n); |
40 | lastword.empty(); | 36 | lastword.empty(); |
41 | lastsizes[0] = laststartline = n; | 37 | lastsizes[0] = laststartline = n; |
42 | #ifdef NEWLINEBREAK | 38 | #ifdef NEWLINEBREAK |
43 | lastispara = true; | 39 | lastispara = true; |
44 | #else | 40 | #else |
45 | lastispara = false; | 41 | lastispara = false; |
46 | #endif | 42 | #endif |
47 | // tchar linebuf[1024]; | 43 | // tchar linebuf[1024]; |
48 | if (exp != NULL) exp->locate(n); | 44 | if (exp != NULL) exp->locate(n); |
49 | // //qDebug("BuffDoc:Located"); | 45 | // //qDebug("BuffDoc:Located"); |
50 | } | 46 | } |
51 | 47 | ||
52 | #ifdef NEWLINEBREAK | 48 | #ifdef NEWLINEBREAK |
53 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border) | 49 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border) |
54 | { | 50 | { |
55 | bool moreleft = true; | 51 | bool moreleft = true; |
56 | bool margindone = false; | 52 | bool margindone = false; |
57 | int w = wth-2*_border; | 53 | int w = wth-2*_border; |
58 | tchar ch = 32; | 54 | tchar ch = 32; |
59 | CStyle cs; | 55 | CStyle cs; |
60 | buff->empty(); | 56 | buff->empty(); |
61 | if (exp == NULL) | 57 | if (exp == NULL) |
62 | { | 58 | { |
63 | buff->empty(); | 59 | buff->empty(); |
64 | buff->setEof(); | 60 | buff->setEof(); |
65 | return false; | 61 | return false; |
66 | } | 62 | } |
67 | int len = 0; | 63 | int len = 0; |
68 | if (lastword.length() > 0) | 64 | if (lastword.length() > 0) |
69 | { | 65 | { |
70 | *buff = lastword; | 66 | *buff = lastword; |
71 | cs = lastword.laststyle(); | 67 | cs = lastword.laststyle(); |
72 | w -= buff->leftMargin() + buff->rightMargin(); | 68 | w -= buff->leftMargin() + buff->rightMargin(); |
73 | margindone = true; | 69 | margindone = true; |
74 | len = lastword.length(); | 70 | len = lastword.length(); |
75 | } | 71 | } |
76 | else buff->empty(); | 72 | else buff->empty(); |
77 | lastword.empty(); | 73 | lastword.empty(); |
78 | unsigned int slen = buff->width(len); | 74 | unsigned int slen = buff->width(len); |
79 | if (lastispara) buff->setstartpara(); | 75 | if (lastispara) buff->setstartpara(); |
80 | while (1) | 76 | while (1) |
81 | { | 77 | { |
82 | lastsizes[len] = exp->locate(); | 78 | lastsizes[len] = exp->locate(); |
83 | getch(ch, cs); | 79 | getch(ch, cs); |
84 | if (ch == 10 && len == 0 && !lastispara) | 80 | if (ch == 10 && len == 0 && !lastispara) |
85 | { | 81 | { |
86 | lastsizes[len] = exp->locate(); | 82 | lastsizes[len] = exp->locate(); |
87 | getch(ch, cs); | 83 | getch(ch, cs); |
88 | } | 84 | } |
89 | if (ch == UEOF) | 85 | if (ch == UEOF) |
90 | { | 86 | { |
91 | if (len == 0) | 87 | if (len == 0) |
92 | { | 88 | { |
93 | buff->setEof(); | 89 | buff->setEof(); |
94 | moreleft = false; | 90 | moreleft = false; |
95 | } | 91 | } |
96 | laststartline = exp->locate(); | 92 | laststartline = exp->locate(); |
97 | break; | 93 | break; |
98 | } | 94 | } |
99 | if (ch == 10) | 95 | if (ch == 10) |
100 | { | 96 | { |
101 | buff->setendpara(); | 97 | buff->setendpara(); |
102 | lastispara = true; | 98 | lastispara = true; |
103 | laststartline = exp->locate(); | 99 | laststartline = exp->locate(); |
104 | break; | 100 | break; |
105 | } | 101 | } |
106 | lastispara = false; | 102 | lastispara = false; |
107 | buff->addch(ch, cs); | 103 | buff->addch(ch, cs); |
108 | len++; | 104 | len++; |
109 | if (!margindone) | 105 | if (!margindone) |
110 | { | 106 | { |
111 | w -= buff->leftMargin() + buff->rightMargin(); | 107 | w -= buff->leftMargin() + buff->rightMargin(); |
112 | margindone = true; | 108 | margindone = true; |
113 | } | 109 | } |
114 | if ((slen = buff->width(len)) > w) | 110 | if ((slen = buff->width(len)) > w) |
115 | { | 111 | { |
116 | if (ch == ' ' || len == 1) | 112 | if (ch == ' ' || len == 1) |
117 | { | 113 | { |
118 | if (ch == ' ') buff->truncate(len-1); | 114 | if (ch == ' ') buff->truncate(len-1); |
119 | laststartline = exp->locate(); | 115 | laststartline = exp->locate(); |
120 | break; | 116 | break; |
121 | } | 117 | } |
122 | else // should do a backward search for spaces, first. | 118 | else // should do a backward search for spaces, first. |
123 | { | 119 | { |
124 | for (int i = len-2; i > 0; i--) | 120 | for (int i = len-2; i > 0; i--) |
125 | { | 121 | { |
126 | if ((*buff)[i] == ' ') | 122 | if ((*buff)[i] == ' ') |
127 | { | 123 | { |
128 | (*buff)[len] = 0; | 124 | (*buff)[len] = 0; |
129 | lastword.setright(*buff, i+1); | 125 | lastword.setright(*buff, i+1); |
130 | buff->truncate(i); | 126 | buff->truncate(i); |
131 | (*buff)[i] = '\0'; | 127 | (*buff)[i] = '\0'; |
132 | laststartline = lastsizes[i+1]; | 128 | laststartline = lastsizes[i+1]; |
133 | buff->resize(); | 129 | buff->resize(); |
134 | for (int j = 0; j < lastword.length(); j++) | 130 | for (int j = 0; j < lastword.length(); j++) |
135 | { | 131 | { |
136 | lastsizes[j] = lastsizes[j+i+1]; | 132 | lastsizes[j] = lastsizes[j+i+1]; |
137 | } | 133 | } |
138 | return true; | 134 | return true; |
139 | } | 135 | } |
140 | if ((*buff)[i] == '-' && !(((*buff)[i-1] == '-') || ((*buff)[i+1] == '-'))) | 136 | if ((*buff)[i] == '-' && !(((*buff)[i-1] == '-') || ((*buff)[i+1] == '-'))) |
141 | { | 137 | { |
142 | (*buff)[len] = 0; | 138 | (*buff)[len] = 0; |
143 | lastword.setright(*buff, i+1); | 139 | lastword.setright(*buff, i+1); |
144 | buff->truncate(i+1); | 140 | buff->truncate(i+1); |
145 | (*buff)[i+1] = '\0'; | 141 | (*buff)[i+1] = '\0'; |
146 | laststartline = lastsizes[i+1]; | 142 | laststartline = lastsizes[i+1]; |
147 | buff->resize(); | 143 | buff->resize(); |
148 | for (int j = 0; j < lastword.length(); j++) | 144 | for (int j = 0; j < lastword.length(); j++) |
149 | { | 145 | { |
150 | lastsizes[j] = lastsizes[j+i+1]; | 146 | lastsizes[j] = lastsizes[j+i+1]; |
151 | } | 147 | } |
152 | return true; | 148 | return true; |
153 | } | 149 | } |
154 | } | 150 | } |
155 | laststartline = lastsizes[len-1]; | 151 | laststartline = lastsizes[len-1]; |
156 | (*buff)[len] = 0; | 152 | (*buff)[len] = 0; |
157 | lastword.setright(*buff, len - 1); | 153 | lastword.setright(*buff, len - 1); |
158 | buff->truncate(len-1); | 154 | buff->truncate(len-1); |
159 | buff->addch('-', cs); | 155 | buff->addch('-', cs); |
160 | for (int j = 0; j < lastword.length(); j++) | 156 | for (int j = 0; j < lastword.length(); j++) |
161 | { | 157 | { |
162 | lastsizes[j] = lastsizes[j+len]; | 158 | lastsizes[j] = lastsizes[j+len]; |
163 | } | 159 | } |
164 | break; | 160 | break; |
165 | } | 161 | } |
166 | } | 162 | } |
167 | } | 163 | } |
168 | (*buff)[len] = '\0'; | 164 | (*buff)[len] = '\0'; |
169 | buff->resize(); | 165 | buff->resize(); |
170 | return moreleft; | 166 | return moreleft; |
171 | } | 167 | } |
172 | #else | 168 | #else |
173 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border) | 169 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border) |
174 | { | 170 | { |
175 | bool margindone = false; | 171 | bool margindone = false; |
176 | int w = wth-2*_border; | 172 | int w = wth-2*_border; |
177 | tchar ch = 32; | 173 | tchar ch = 32; |
178 | CStyle cs; | 174 | CStyle cs; |
179 | buff->empty(); | 175 | buff->empty(); |
180 | if (exp == NULL) | 176 | if (exp == NULL) |
181 | { | 177 | { |
182 | //(*buff)[0] = '\0'; | 178 | //(*buff)[0] = '\0'; |
183 | buff->empty(); | 179 | buff->empty(); |
184 | return false; | 180 | return false; |
185 | } | 181 | } |
186 | int len = 0, lastcheck = 0; | 182 | int len = 0, lastcheck = 0; |
187 | if (lastword.length() > 0) | 183 | if (lastword.length() > 0) |
188 | { | 184 | { |
189 | *buff = lastword; | 185 | *buff = lastword; |
190 | cs = lastword.laststyle(); | 186 | cs = lastword.laststyle(); |
191 | w -= buff->leftMargin() + buff->rightMargin(); | 187 | w -= buff->leftMargin() + buff->rightMargin(); |
192 | margindone = true; | 188 | margindone = true; |
193 | } | 189 | } |
194 | else buff->empty(); | 190 | else buff->empty(); |
195 | // //qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); | 191 | // //qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); |
196 | lastcheck = len = buff->length(); | 192 | lastcheck = len = buff->length(); |
197 | unsigned int slen = buff->width(len); | 193 | unsigned int slen = buff->width(len); |
198 | if (slen > w) | 194 | if (slen > w) |
199 | { | 195 | { |
200 | for ( ; len > 1; len--) | 196 | for ( ; len > 1; len--) |
201 | { | 197 | { |
202 | if (buff->width(len) < w) break; | 198 | if (buff->width(len) < w) break; |
203 | } | 199 | } |
204 | // lastword = buff->data() + len - 1; | 200 | // lastword = buff->data() + len - 1; |
205 | laststartline = lastsizes[len-1]; | 201 | laststartline = lastsizes[len-1]; |
206 | for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1]; | 202 | for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1]; |
207 | // (*buff)[len-1] = '-'; | 203 | // (*buff)[len-1] = '-'; |
208 | if (len > 2) | 204 | if (len > 2) |
209 | { | 205 | { |
210 | lastword.setright(*buff, len - 1); | 206 | lastword.setright(*buff, len - 1); |
211 | buff->truncate(len-1); | 207 | buff->truncate(len-1); |
212 | buff->addch('-', cs); | 208 | buff->addch('-', cs); |
213 | (*buff)[len] = '\0'; | 209 | (*buff)[len] = '\0'; |
214 | } | 210 | } |
215 | 211 | ||
216 | else | 212 | else |
217 | { | 213 | { |
218 | lastword.empty(); | 214 | lastword.empty(); |
219 | (*buff)[len] = '\0'; | 215 | (*buff)[len] = '\0'; |
220 | } | 216 | } |
221 | buff->resize(); | 217 | buff->resize(); |
222 | return true; | 218 | return true; |
223 | } | 219 | } |
224 | if (lastispara) | 220 | if (lastispara) |
225 | { | 221 | { |
226 | lastispara = false; | 222 | lastispara = false; |
227 | // lastword[0] = '\0'; | 223 | // lastword[0] = '\0'; |
228 | lastword.empty(); | 224 | lastword.empty(); |
229 | len = buff->length(); | 225 | len = buff->length(); |
230 | while (buff->width(len) > w) len--; | 226 | while (buff->width(len) > w) len--; |
231 | // (*buff)[len] = '\0'; | 227 | // (*buff)[len] = '\0'; |
232 | buff->truncate(len); | 228 | buff->truncate(len); |
233 | laststartline = exp->locate(); | 229 | laststartline = exp->locate(); |
234 | buff->resize(); | 230 | buff->resize(); |
235 | return true; | 231 | return true; |
236 | } | 232 | } |
237 | lastispara = false; | 233 | lastispara = false; |
238 | for (int i = 0; i < len; i++) allsizes[i] = lastsizes[i]; | 234 | for (int i = 0; i < len; i++) allsizes[i] = lastsizes[i]; |
239 | while (slen < w) | 235 | while (slen < w) |
240 | { | 236 | { |
241 | lastcheck = len; | 237 | lastcheck = len; |
242 | allsizes[len] = exp->locate(); | 238 | allsizes[len] = exp->locate(); |
243 | getch(ch, cs); | 239 | getch(ch, cs); |
244 | while (ch != ' ' && ch != '\012' && ch != UEOF && len < 128) | 240 | while (ch != ' ' && ch != '\012' && ch != UEOF && len < 128) |
245 | { | 241 | { |
246 | len++; | 242 | len++; |
247 | buff->addch(ch,cs); | 243 | buff->addch(ch,cs); |
248 | allsizes[len] = exp->locate(); | 244 | allsizes[len] = exp->locate(); |
249 | getch(ch, cs); | 245 | getch(ch, cs); |
250 | } | 246 | } |
251 | (*buff)[len] = 0; | 247 | (*buff)[len] = 0; |
252 | slen = buff->width(len); | 248 | slen = buff->width(len); |
253 | len++; | 249 | len++; |
254 | buff->addch(' ', cs); | 250 | buff->addch(' ', cs); |
255 | if (!margindone) | 251 | if (!margindone) |
256 | { | 252 | { |
257 | w -= buff->leftMargin() + buff->rightMargin(); | 253 | w -= buff->leftMargin() + buff->rightMargin(); |
258 | margindone = true; | 254 | margindone = true; |
259 | } | 255 | } |
260 | allsizes[len] = exp->locate(); | 256 | allsizes[len] = exp->locate(); |
261 | if (slen < w && ch != ' ') | 257 | if (slen < w && ch != ' ') |
262 | { | 258 | { |
263 | lastcheck = len; | 259 | lastcheck = len; |
264 | break; | 260 | break; |
265 | } | 261 | } |
266 | lastispara = (ch == '\012'); | 262 | lastispara = (ch == '\012'); |
267 | } | 263 | } |
268 | (*buff)[len] = '\0'; | 264 | (*buff)[len] = '\0'; |
269 | // lastword = buff->data()+lastcheck; | 265 | // lastword = buff->data()+lastcheck; |
270 | #ifdef _WINDOWS | 266 | #ifdef _WINDOWS |
271 | lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); | 267 | lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); |
272 | { | 268 | { |
273 | int i; | 269 | int i; |
274 | for (i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; | 270 | for (i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; |
275 | } | 271 | } |
276 | #else | 272 | #else |
277 | lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); | 273 | lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); |
278 | for (int i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; | 274 | for (int i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; |
279 | #endif | 275 | #endif |
280 | if (lastcheck > 0) | 276 | if (lastcheck > 0) |
281 | { | 277 | { |
282 | laststartline = allsizes[lastcheck]; | 278 | laststartline = allsizes[lastcheck]; |
283 | // (*buff)[lastcheck-1] = '\0'; | 279 | // (*buff)[lastcheck-1] = '\0'; |
284 | buff->truncate(lastcheck-1); | 280 | buff->truncate(lastcheck-1); |
285 | } | 281 | } |
286 | else | 282 | else |
287 | { | 283 | { |
288 | laststartline = (lastcheck == len) ? exp->locate() : allsizes[lastcheck+1]; | 284 | laststartline = (lastcheck == len) ? exp->locate() : allsizes[lastcheck+1]; |
289 | // (*buff)[lastcheck] = '\0'; | 285 | // (*buff)[lastcheck] = '\0'; |
290 | buff->truncate(lastcheck); | 286 | buff->truncate(lastcheck); |
291 | } | 287 | } |
292 | // buff->frig(); | 288 | // buff->frig(); |
293 | buff->resize(); | 289 | buff->resize(); |
294 | if (ch == UEOF && buff->length() == 0) | 290 | if (ch == UEOF && buff->length() == 0) |
295 | { | 291 | { |
296 | buff->setEof(); | 292 | buff->setEof(); |
297 | return false; | 293 | return false; |
298 | } | 294 | } |
299 | return true; | 295 | return true; |
300 | } | 296 | } |
301 | #endif | 297 | #endif |
302 | 298 | ||
303 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw, unsigned char _border) | 299 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw, unsigned char _border) |
304 | { | 300 | { |
305 | int w = wth-2*_border; | 301 | int w = wth-2*_border; |
306 | buff->empty(); | 302 | buff->empty(); |
307 | if (exp == NULL) | 303 | if (exp == NULL) |
308 | { | 304 | { |
309 | return false; | 305 | return false; |
310 | } | 306 | } |
311 | tchar ch; | 307 | tchar ch; |
312 | CStyle cs; | 308 | CStyle cs; |
313 | int i = 1; | 309 | int i = 1; |
314 | while (i*cw < w-buff->offset(w,0)) | 310 | while (i*cw < w-buff->offset(w,0)) |
315 | { | 311 | { |
316 | getch(ch, cs); | 312 | getch(ch, cs); |
317 | if (ch == '\12' || ch == UEOF) break; | 313 | if (ch == '\12' || ch == UEOF) break; |
318 | buff->addch(ch,cs); | 314 | buff->addch(ch,cs); |
319 | i++; | 315 | i++; |
320 | } | 316 | } |
321 | buff->truncate(i); | 317 | buff->truncate(i); |
322 | laststartline = exp->locate(); | 318 | laststartline = exp->locate(); |
323 | buff->resize(); | 319 | buff->resize(); |
324 | return (ch != UEOF); | 320 | return (ch != UEOF); |
325 | } | 321 | } |
326 | 322 | ||
327 | int BuffDoc::openfile(QWidget* _parent, const char *src) | 323 | int BuffDoc::openfile(QWidget* _parent, const char *src) |
328 | { | 324 | { |
329 | // //qDebug("BuffDoc:Openfile:%s", src); | 325 | // //qDebug("BuffDoc:Openfile:%s", src); |
330 | // //qDebug("Trying aportis %x",exp); | 326 | // //qDebug("Trying aportis %x",exp); |
331 | if (exp != NULL) delete exp; | 327 | if (exp != NULL) delete exp; |
332 | lastword.empty(); | 328 | lastword.empty(); |
333 | lastsizes[0] = laststartline = 0; | 329 | lastsizes[0] = laststartline = 0; |
334 | #ifdef NEWLINEBREAK | 330 | #ifdef NEWLINEBREAK |
335 | lastispara = true; | 331 | lastispara = true; |
336 | #else | 332 | #else |
337 | lastispara = false; | 333 | lastispara = false; |
338 | #endif | 334 | #endif |
339 | /* | 335 | /* |
340 | exp = new Text; | 336 | exp = new Text; |
341 | int ret = exp->openfile(src); | 337 | int ret = exp->openfile(src); |
342 | */ | 338 | */ |
343 | 339 | ||
344 | exp = new Aportis; | 340 | exp = new Aportis; |
345 | int ret = exp->openfile(src); | 341 | int ret = exp->openfile(src); |
346 | if (ret == -1) | 342 | if (ret == -1) |
347 | { | 343 | { |
348 | delete exp; | 344 | delete exp; |
349 | exp = NULL; | 345 | exp = NULL; |
350 | return ret; | 346 | return ret; |
351 | } | 347 | } |
352 | if (ret == -2) | 348 | if (ret == -2) |
353 | { | 349 | { |
354 | 350 | ||
355 | delete exp; | 351 | delete exp; |
356 | exp = new ztxt; | 352 | exp = new ztxt; |
357 | ret = exp->openfile(src); | 353 | ret = exp->openfile(src); |
358 | } | 354 | } |
359 | #ifdef USENEF | 355 | #ifdef USENEF |
360 | if (ret != 0) | 356 | if (ret != 0) |
361 | { | 357 | { |
362 | 358 | ||
363 | delete exp; | 359 | delete exp; |
364 | exp = new CArriere; | 360 | exp = new CArriere; |
365 | ret = exp->openfile(src); | 361 | ret = exp->openfile(src); |
366 | } | 362 | } |
367 | if (ret != 0) | 363 | if (ret != 0) |
368 | { | 364 | { |
369 | 365 | ||
370 | delete exp; | 366 | delete exp; |
371 | exp = new CNEF; | 367 | exp = new CNEF; |
372 | ret = exp->openfile(src); | 368 | ret = exp->openfile(src); |
373 | } | 369 | } |
374 | #endif | 370 | #endif |
375 | if (ret != 0) | 371 | if (ret != 0) |
376 | { | 372 | { |
377 | 373 | ||
378 | delete exp; | 374 | delete exp; |
379 | exp = new CPlucker; | 375 | exp = new CPlucker; |
380 | ret = exp->openfile(src); | 376 | ret = exp->openfile(src); |
381 | } | 377 | } |
382 | if (ret != 0) | 378 | if (ret != 0) |
383 | { | 379 | { |
384 | delete exp; | 380 | delete exp; |
385 | //qDebug("Trying ppms"); | 381 | //qDebug("Trying ppms"); |
386 | exp = new ppm_expander; | 382 | exp = new ppm_expander; |
387 | ret = exp->openfile(src); | 383 | ret = exp->openfile(src); |
388 | } | 384 | } |
389 | if (ret != 0) | 385 | if (ret != 0) |
390 | { | 386 | { |
391 | delete exp; | 387 | delete exp; |
392 | exp = new Text; | 388 | exp = new Text; |
393 | // //qDebug("Trying text"); | 389 | // //qDebug("Trying text"); |
394 | ret = exp->openfile(src); | 390 | ret = exp->openfile(src); |
395 | } | 391 | } |
396 | 392 | ||
397 | if (ret != 0) | 393 | if (ret != 0) |
398 | { | 394 | { |
399 | delete exp; | 395 | delete exp; |
400 | QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file"); | 396 | QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file"); |
401 | return ret; | 397 | return ret; |
402 | } | 398 | } |
403 | // //qDebug("Doing final open:%x:%x",exp,filt); | 399 | // //qDebug("Doing final open:%x:%x",exp,filt); |
404 | 400 | ||
405 | lastword.empty(); | 401 | lastword.empty(); |
406 | lastsizes[0] = laststartline = 0; | 402 | lastsizes[0] = laststartline = 0; |
407 | #ifdef NEWLINEBREAK | 403 | #ifdef NEWLINEBREAK |
408 | lastispara = true; | 404 | lastispara = true; |
409 | #else | 405 | #else |
410 | lastispara = false; | 406 | lastispara = false; |
411 | #endif | 407 | #endif |
412 | exp->locate(0); | 408 | exp->locate(0); |
413 | filt->setsource(exp); | 409 | filt->setsource(exp); |
414 | // //qDebug("BuffDoc:file opened"); | 410 | // //qDebug("BuffDoc:file opened"); |
415 | return 0; | 411 | return 0; |
416 | } | 412 | } |
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp index 77b76fb..ec36fb2 100644 --- a/noncore/apps/opie-reader/CDrawBuffer.cpp +++ b/noncore/apps/opie-reader/CDrawBuffer.cpp | |||
@@ -1,550 +1,546 @@ | |||
1 | #include "CDrawBuffer.h" | 1 | #include "CDrawBuffer.h" |
2 | #include "FontControl.h" | 2 | #include "FontControl.h" |
3 | #include <qfontmetrics.h> | ||
4 | #include <qpainter.h> | 3 | #include <qpainter.h> |
5 | #include <qpixmap.h> | ||
6 | #include <qimage.h> | 4 | #include <qimage.h> |
7 | #include "useqpe.h" | ||
8 | #include "opie.h" | ||
9 | 5 | ||
10 | CDrawBuffer::~CDrawBuffer() | 6 | CDrawBuffer::~CDrawBuffer() |
11 | { | 7 | { |
12 | while (!segs.isEmpty()) segs.erase(0); | 8 | while (!segs.isEmpty()) segs.erase(0); |
13 | } | 9 | } |
14 | 10 | ||
15 | void CDrawBuffer::setright(CDrawBuffer& rhs, int f) | 11 | void CDrawBuffer::setright(CDrawBuffer& rhs, int f) |
16 | { | 12 | { |
17 | int i; | 13 | int i; |
18 | len = rhs.len; | 14 | len = rhs.len; |
19 | fc = rhs.fc; | 15 | fc = rhs.fc; |
20 | m_maxstyle = m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; | 16 | m_maxstyle = m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
21 | while (!segs.isEmpty()) | 17 | while (!segs.isEmpty()) |
22 | { | 18 | { |
23 | segs.erase(0); | 19 | segs.erase(0); |
24 | } | 20 | } |
25 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); ) | 21 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); ) |
26 | { | 22 | { |
27 | CList<textsegment>::iterator next = iter; | 23 | CList<textsegment>::iterator next = iter; |
28 | iter++; | 24 | iter++; |
29 | if (iter == rhs.segs.end() || iter->start > f) | 25 | if (iter == rhs.segs.end() || iter->start > f) |
30 | { | 26 | { |
31 | int st = next->start-f; | 27 | int st = next->start-f; |
32 | if (st < 0) st = 0; | 28 | if (st < 0) st = 0; |
33 | 29 | ||
34 | CStyle _style = next->style; | 30 | CStyle _style = next->style; |
35 | 31 | ||
36 | segs.push_back(textsegment(st,next->style)); | 32 | segs.push_back(textsegment(st,next->style)); |
37 | } | 33 | } |
38 | } | 34 | } |
39 | for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i]; | 35 | for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i]; |
40 | (*this)[i-f] = '\0'; | 36 | (*this)[i-f] = '\0'; |
41 | len = i; | 37 | len = i; |
42 | } | 38 | } |
43 | 39 | ||
44 | CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) | 40 | CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) |
45 | { | 41 | { |
46 | int i; | 42 | int i; |
47 | // //qDebug("Trying 2"); | 43 | // //qDebug("Trying 2"); |
48 | len = rhs.len; | 44 | len = rhs.len; |
49 | m_maxstyle = rhs.m_maxstyle; | 45 | m_maxstyle = rhs.m_maxstyle; |
50 | m_ascent = rhs.m_ascent; | 46 | m_ascent = rhs.m_ascent; |
51 | m_descent = rhs.m_descent; | 47 | m_descent = rhs.m_descent; |
52 | m_lineSpacing = rhs.m_lineSpacing; | 48 | m_lineSpacing = rhs.m_lineSpacing; |
53 | m_lineExtraSpacing = rhs.m_lineExtraSpacing; | 49 | m_lineExtraSpacing = rhs.m_lineExtraSpacing; |
54 | while (!segs.isEmpty()) | 50 | while (!segs.isEmpty()) |
55 | { | 51 | { |
56 | segs.erase(0); | 52 | segs.erase(0); |
57 | } | 53 | } |
58 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) | 54 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) |
59 | { | 55 | { |
60 | segs.push_back(*iter); | 56 | segs.push_back(*iter); |
61 | } | 57 | } |
62 | for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; | 58 | for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; |
63 | (*this)[i] = '\0'; | 59 | (*this)[i] = '\0'; |
64 | len = i; | 60 | len = i; |
65 | // //qDebug("Tried 2"); | 61 | // //qDebug("Tried 2"); |
66 | return *this; | 62 | return *this; |
67 | } | 63 | } |
68 | 64 | ||
69 | CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) | 65 | CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) |
70 | { | 66 | { |
71 | int i; | 67 | int i; |
72 | while (!segs.isEmpty()) | 68 | while (!segs.isEmpty()) |
73 | { | 69 | { |
74 | segs.erase(0); | 70 | segs.erase(0); |
75 | } | 71 | } |
76 | segs.push_back(textsegment(0, CStyle())); | 72 | segs.push_back(textsegment(0, CStyle())); |
77 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; | 73 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; |
78 | (*this)[i] = '\0'; | 74 | (*this)[i] = '\0'; |
79 | len = i; | 75 | len = i; |
80 | return *this; | 76 | return *this; |
81 | } | 77 | } |
82 | 78 | ||
83 | void CDrawBuffer::empty() | 79 | void CDrawBuffer::empty() |
84 | { | 80 | { |
85 | m_bSop = false; | 81 | m_bSop = false; |
86 | m_bEop = false; | 82 | m_bEop = false; |
87 | len = 0; | 83 | len = 0; |
88 | (*this)[0] = 0; | 84 | (*this)[0] = 0; |
89 | while (!segs.isEmpty()) | 85 | while (!segs.isEmpty()) |
90 | { | 86 | { |
91 | segs.erase(0); | 87 | segs.erase(0); |
92 | } | 88 | } |
93 | segs.push_back(textsegment(0,CStyle())); | 89 | segs.push_back(textsegment(0,CStyle())); |
94 | m_maxstyle = m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; | 90 | m_maxstyle = m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
95 | m_bEof = false; | 91 | m_bEof = false; |
96 | } | 92 | } |
97 | 93 | ||
98 | void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) | 94 | void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) |
99 | { | 95 | { |
100 | if (len == 0) | 96 | if (len == 0) |
101 | { | 97 | { |
102 | segs.first().start = 0; | 98 | segs.first().start = 0; |
103 | segs.first().style = _style; | 99 | segs.first().style = _style; |
104 | } | 100 | } |
105 | else if (_style != segs.last().style) | 101 | else if (_style != segs.last().style) |
106 | { | 102 | { |
107 | segs.push_back(textsegment(len, _style)); | 103 | segs.push_back(textsegment(len, _style)); |
108 | } | 104 | } |
109 | (*this)[len++] = ch; | 105 | (*this)[len++] = ch; |
110 | } | 106 | } |
111 | 107 | ||
112 | void CDrawBuffer::truncate(int n) | 108 | void CDrawBuffer::truncate(int n) |
113 | { | 109 | { |
114 | len = n; | 110 | len = n; |
115 | (*this)[n] = 0; | 111 | (*this)[n] = 0; |
116 | } | 112 | } |
117 | 113 | ||
118 | int CDrawBuffer::width(int numchars, bool onscreen, int scwidth, unsigned char _border) | 114 | int CDrawBuffer::width(int numchars, bool onscreen, int scwidth, unsigned char _border) |
119 | { | 115 | { |
120 | int gzoom = fc->gzoom(); | 116 | int gzoom = fc->gzoom(); |
121 | int currentx = 0, end = 0; | 117 | int currentx = 0, end = 0; |
122 | QString text = (numchars < 0) ? toQString(data()) : toQString(data(), numchars); | 118 | QString text = (numchars < 0) ? toQString(data()) : toQString(data(), numchars); |
123 | CList<textsegment>::iterator textstart = segs.begin(); | 119 | CList<textsegment>::iterator textstart = segs.begin(); |
124 | int extraspace = 0; | 120 | int extraspace = 0; |
125 | bool just = (onscreen && !m_bEop && textstart->style.getJustify() == m_AlignJustify); | 121 | bool just = (onscreen && !m_bEop && textstart->style.getJustify() == m_AlignJustify); |
126 | int spaces = 0; | 122 | int spaces = 0; |
127 | int spacesofar = 0; | 123 | int spacesofar = 0; |
128 | int spacenumber = 0; | 124 | int spacenumber = 0; |
129 | int nonspace = 0; | 125 | int nonspace = 0; |
130 | if (just) | 126 | if (just) |
131 | { | 127 | { |
132 | for (int i = 0; i < len; i++) | 128 | for (int i = 0; i < len; i++) |
133 | { | 129 | { |
134 | if ((*this)[i] != ' ') | 130 | if ((*this)[i] != ' ') |
135 | { | 131 | { |
136 | nonspace = i; | 132 | nonspace = i; |
137 | break; | 133 | break; |
138 | } | 134 | } |
139 | } | 135 | } |
140 | #ifdef _WINDOWS | 136 | #ifdef _WINDOWS |
141 | for (i = nonspace; i < len; i++) | 137 | for (i = nonspace; i < len; i++) |
142 | #else | 138 | #else |
143 | for (int i = nonspace; i < len; i++) | 139 | for (int i = nonspace; i < len; i++) |
144 | #endif | 140 | #endif |
145 | { | 141 | { |
146 | if ((*this)[i] == ' ') | 142 | if ((*this)[i] == ' ') |
147 | { | 143 | { |
148 | spaces++; | 144 | spaces++; |
149 | } | 145 | } |
150 | } | 146 | } |
151 | if (spaces == 0) | 147 | if (spaces == 0) |
152 | { | 148 | { |
153 | just = false; | 149 | just = false; |
154 | } | 150 | } |
155 | else | 151 | else |
156 | { | 152 | { |
157 | extraspace = (scwidth - 2*_border - rightMargin() - leftMargin() - width()); | 153 | extraspace = (scwidth - 2*_border - rightMargin() - leftMargin() - width()); |
158 | if (extraspace == 0) just = false; | 154 | if (extraspace == 0) just = false; |
159 | } | 155 | } |
160 | } | 156 | } |
161 | CList<textsegment>::iterator textend = textstart; | 157 | CList<textsegment>::iterator textend = textstart; |
162 | do | 158 | do |
163 | { | 159 | { |
164 | textend++; | 160 | textend++; |
165 | end = (textend != segs.end()) ? textend->start : len; | 161 | end = (textend != segs.end()) ? textend->start : len; |
166 | if (numchars >= 0 && end > numchars) | 162 | if (numchars >= 0 && end > numchars) |
167 | { | 163 | { |
168 | end = numchars; | 164 | end = numchars; |
169 | } | 165 | } |
170 | CStyle currentstyle = textstart->style; | 166 | CStyle currentstyle = textstart->style; |
171 | if (currentstyle.isPicture()) | 167 | if (currentstyle.isPicture()) |
172 | { | 168 | { |
173 | if (currentstyle.canScale()) | 169 | if (currentstyle.canScale()) |
174 | { | 170 | { |
175 | currentx += (gzoom*currentstyle.getPicture()->width())/100; | 171 | currentx += (gzoom*currentstyle.getPicture()->width())/100; |
176 | } | 172 | } |
177 | else | 173 | else |
178 | { | 174 | { |
179 | currentx += currentstyle.getPicture()->width(); | 175 | currentx += currentstyle.getPicture()->width(); |
180 | } | 176 | } |
181 | } | 177 | } |
182 | else | 178 | else |
183 | { | 179 | { |
184 | if (currentstyle.isMono() && !fc->hasCourier()) | 180 | if (currentstyle.isMono() && !fc->hasCourier()) |
185 | { | 181 | { |
186 | int cw = (7*fc->getsize(currentstyle))/10; | 182 | int cw = (7*fc->getsize(currentstyle))/10; |
187 | currentx += cw*(end-textstart->start); | 183 | currentx += cw*(end-textstart->start); |
188 | } | 184 | } |
189 | else | 185 | else |
190 | { | 186 | { |
191 | QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 187 | QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
192 | // f.setUnderline(currentstyle.isUnderline()); | 188 | // f.setUnderline(currentstyle.isUnderline()); |
193 | QString str = text.mid(textstart->start, end-textstart->start); | 189 | QString str = text.mid(textstart->start, end-textstart->start); |
194 | QFontMetrics fm(f); | 190 | QFontMetrics fm(f); |
195 | if (just) | 191 | if (just) |
196 | { | 192 | { |
197 | int lastspace = -1; | 193 | int lastspace = -1; |
198 | int nsp = 0; | 194 | int nsp = 0; |
199 | int cx = currentx; | 195 | int cx = currentx; |
200 | while ((nsp = str.find(" ", lastspace+1)) >= 0) | 196 | while ((nsp = str.find(" ", lastspace+1)) >= 0) |
201 | { | 197 | { |
202 | if (nsp > nonspace) | 198 | if (nsp > nonspace) |
203 | { | 199 | { |
204 | spacenumber++; | 200 | spacenumber++; |
205 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; | 201 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; |
206 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 202 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
207 | int lw = fm.width(nstr); | 203 | int lw = fm.width(nstr); |
208 | cx += lw+nexttoadd; | 204 | cx += lw+nexttoadd; |
209 | spacesofar += nexttoadd; | 205 | spacesofar += nexttoadd; |
210 | lastspace = nsp; | 206 | lastspace = nsp; |
211 | } | 207 | } |
212 | else | 208 | else |
213 | { | 209 | { |
214 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 210 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
215 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); | 211 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); |
216 | int lw = fm.width(nstr); | 212 | int lw = fm.width(nstr); |
217 | cx += lw; | 213 | cx += lw; |
218 | lastspace = nsp; | 214 | lastspace = nsp; |
219 | } | 215 | } |
220 | } | 216 | } |
221 | QString nstr = str.right(str.length()-1-lastspace); | 217 | QString nstr = str.right(str.length()-1-lastspace); |
222 | cx += fm.width(nstr); | 218 | cx += fm.width(nstr); |
223 | currentx = cx; | 219 | currentx = cx; |
224 | } | 220 | } |
225 | else | 221 | else |
226 | { | 222 | { |
227 | currentx += fm.width(str); | 223 | currentx += fm.width(str); |
228 | } | 224 | } |
229 | } | 225 | } |
230 | } | 226 | } |
231 | textstart = textend; | 227 | textstart = textend; |
232 | } | 228 | } |
233 | while (textend != segs.end() && end != numchars && textstart->start < len); | 229 | while (textend != segs.end() && end != numchars && textstart->start < len); |
234 | return currentx; | 230 | return currentx; |
235 | } | 231 | } |
236 | 232 | ||
237 | int CDrawBuffer::leftMargin() | 233 | int CDrawBuffer::leftMargin() |
238 | { | 234 | { |
239 | return (segs.begin()->style.getLeftMargin()*fc->getsize(segs.begin()->style)+3)/6; | 235 | return (segs.begin()->style.getLeftMargin()*fc->getsize(segs.begin()->style)+3)/6; |
240 | } | 236 | } |
241 | 237 | ||
242 | int CDrawBuffer::rightMargin() | 238 | int CDrawBuffer::rightMargin() |
243 | { | 239 | { |
244 | return (segs.begin()->style.getRightMargin()*fc->getsize(segs.begin()->style)+3)/6; | 240 | return (segs.begin()->style.getRightMargin()*fc->getsize(segs.begin()->style)+3)/6; |
245 | } | 241 | } |
246 | 242 | ||
247 | int CDrawBuffer::offset(int scwidth, unsigned char _border) | 243 | int CDrawBuffer::offset(int scwidth, unsigned char _border) |
248 | { | 244 | { |
249 | int currentx = _border; | 245 | int currentx = _border; |
250 | switch(segs.begin()->style.getJustify()) | 246 | switch(segs.begin()->style.getJustify()) |
251 | { | 247 | { |
252 | case m_AlignRight: | 248 | case m_AlignRight: |
253 | { | 249 | { |
254 | currentx = scwidth - _border - rightMargin() - width(); | 250 | currentx = scwidth - _border - rightMargin() - width(); |
255 | } | 251 | } |
256 | break; | 252 | break; |
257 | case m_AlignCentre: | 253 | case m_AlignCentre: |
258 | { | 254 | { |
259 | currentx = ( | 255 | currentx = ( |
260 | scwidth + | 256 | scwidth + |
261 | leftMargin() - rightMargin() | 257 | leftMargin() - rightMargin() |
262 | - width())/2; | 258 | - width())/2; |
263 | } | 259 | } |
264 | break; | 260 | break; |
265 | case m_AlignJustify: | 261 | case m_AlignJustify: |
266 | case m_AlignLeft: | 262 | case m_AlignLeft: |
267 | currentx = _border + leftMargin(); | 263 | currentx = _border + leftMargin(); |
268 | break; | 264 | break; |
269 | } | 265 | } |
270 | return currentx; | 266 | return currentx; |
271 | } | 267 | } |
272 | 268 | ||
273 | void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth, unsigned char _border) | 269 | void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth, unsigned char _border) |
274 | { | 270 | { |
275 | int gzoom = fc->gzoom(); | 271 | int gzoom = fc->gzoom(); |
276 | int currentx = offset(scwidth, _border); | 272 | int currentx = offset(scwidth, _border); |
277 | QString text = toQString(data()); | 273 | QString text = toQString(data()); |
278 | CList<textsegment>::iterator textstart = segs.begin(); | 274 | CList<textsegment>::iterator textstart = segs.begin(); |
279 | int extraspace = 0; | 275 | int extraspace = 0; |
280 | bool just = (!m_bEop && textstart->style.getJustify() == m_AlignJustify); | 276 | bool just = (!m_bEop && textstart->style.getJustify() == m_AlignJustify); |
281 | int spaces = 0; | 277 | int spaces = 0; |
282 | int spacesofar = 0; | 278 | int spacesofar = 0; |
283 | int spacenumber = 0; | 279 | int spacenumber = 0; |
284 | int nonspace = 0; | 280 | int nonspace = 0; |
285 | if (just) | 281 | if (just) |
286 | { | 282 | { |
287 | for (int i = 0; i < len; i++) | 283 | for (int i = 0; i < len; i++) |
288 | { | 284 | { |
289 | if ((*this)[i] != ' ') | 285 | if ((*this)[i] != ' ') |
290 | { | 286 | { |
291 | nonspace = i; | 287 | nonspace = i; |
292 | break; | 288 | break; |
293 | } | 289 | } |
294 | } | 290 | } |
295 | #ifdef _WINDOWS | 291 | #ifdef _WINDOWS |
296 | for (i = nonspace; i < len; i++) | 292 | for (i = nonspace; i < len; i++) |
297 | #else | 293 | #else |
298 | for (int i = nonspace; i < len; i++) | 294 | for (int i = nonspace; i < len; i++) |
299 | #endif | 295 | #endif |
300 | { | 296 | { |
301 | if ((*this)[i] == ' ') | 297 | if ((*this)[i] == ' ') |
302 | { | 298 | { |
303 | spaces++; | 299 | spaces++; |
304 | } | 300 | } |
305 | } | 301 | } |
306 | if (spaces == 0) | 302 | if (spaces == 0) |
307 | { | 303 | { |
308 | just = false; | 304 | just = false; |
309 | } | 305 | } |
310 | else | 306 | else |
311 | { | 307 | { |
312 | extraspace = (scwidth - 2*_border - rightMargin() - leftMargin() - width()); | 308 | extraspace = (scwidth - 2*_border - rightMargin() - leftMargin() - width()); |
313 | if (extraspace == 0) just = false; | 309 | if (extraspace == 0) just = false; |
314 | } | 310 | } |
315 | } | 311 | } |
316 | CList<textsegment>::iterator textend = textstart; | 312 | CList<textsegment>::iterator textend = textstart; |
317 | do | 313 | do |
318 | { | 314 | { |
319 | textend++; | 315 | textend++; |
320 | int end = (textend != segs.end()) ? textend->start : len; | 316 | int end = (textend != segs.end()) ? textend->start : len; |
321 | CStyle currentstyle = textstart->style; | 317 | CStyle currentstyle = textstart->style; |
322 | QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 318 | QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
323 | //f.setUnderline(currentstyle.isUnderline()); | 319 | //f.setUnderline(currentstyle.isUnderline()); |
324 | //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); | 320 | //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); |
325 | _p->setFont(f); | 321 | _p->setFont(f); |
326 | QString str = text.mid(textstart->start, end-textstart->start); | 322 | QString str = text.mid(textstart->start, end-textstart->start); |
327 | #if defined(OPIE) || !defined(USEQPE) | 323 | #if defined(OPIE) || !defined(USEQPE) |
328 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100)); | 324 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100)); |
329 | #else | 325 | #else |
330 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); | 326 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); |
331 | #endif | 327 | #endif |
332 | int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2; | 328 | int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2; |
333 | if (_bMono) | 329 | if (_bMono) |
334 | { | 330 | { |
335 | if (currentstyle.isUnderline()) | 331 | if (currentstyle.isUnderline()) |
336 | { | 332 | { |
337 | _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset); | 333 | _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset); |
338 | } | 334 | } |
339 | if (currentstyle.isStrikethru()) | 335 | if (currentstyle.isStrikethru()) |
340 | { | 336 | { |
341 | int ascent = fc->ascent(currentstyle)/3; | 337 | int ascent = fc->ascent(currentstyle)/3; |
342 | _p->drawLine( currentx, _y-ascent+voffset, currentx + str.length()*_charWidth, _y-ascent+voffset); | 338 | _p->drawLine( currentx, _y-ascent+voffset, currentx + str.length()*_charWidth, _y-ascent+voffset); |
343 | } | 339 | } |
344 | for (int i = 0; i < str.length(); i++) | 340 | for (int i = 0; i < str.length(); i++) |
345 | { | 341 | { |
346 | _p->drawText( currentx + i*_charWidth, _y+voffset, QString(str[i])); | 342 | _p->drawText( currentx + i*_charWidth, _y+voffset, QString(str[i])); |
347 | } | 343 | } |
348 | currentx += str.length()*_charWidth; | 344 | currentx += str.length()*_charWidth; |
349 | } | 345 | } |
350 | else | 346 | else |
351 | { | 347 | { |
352 | if (currentstyle.isPicture()) | 348 | if (currentstyle.isPicture()) |
353 | { | 349 | { |
354 | int ht = (gzoom*currentstyle.getPicture()->height())/100; | 350 | int ht = (gzoom*currentstyle.getPicture()->height())/100; |
355 | int wt = (gzoom*currentstyle.getPicture()->width())/100; | 351 | int wt = (gzoom*currentstyle.getPicture()->width())/100; |
356 | int ascent = fc->ascent(currentstyle)/2; | 352 | int ascent = fc->ascent(currentstyle)/2; |
357 | int yoffset = ht/2 + ascent; | 353 | int yoffset = ht/2 + ascent; |
358 | 354 | ||
359 | QPixmap pc; | 355 | QPixmap pc; |
360 | if (gzoom != 100 && currentstyle.canScale()) | 356 | if (gzoom != 100 && currentstyle.canScale()) |
361 | { | 357 | { |
362 | QImage im = currentstyle.getPicture()->smoothScale(wt,ht); | 358 | QImage im = currentstyle.getPicture()->smoothScale(wt,ht); |
363 | pc.convertFromImage(im); | 359 | pc.convertFromImage(im); |
364 | } | 360 | } |
365 | else | 361 | else |
366 | { | 362 | { |
367 | pc.convertFromImage(*currentstyle.getPicture()); | 363 | pc.convertFromImage(*currentstyle.getPicture()); |
368 | } | 364 | } |
369 | _p->drawPixmap( currentx, _y-yoffset, pc ); | 365 | _p->drawPixmap( currentx, _y-yoffset, pc ); |
370 | currentx += wt; | 366 | currentx += wt; |
371 | } | 367 | } |
372 | else | 368 | else |
373 | { | 369 | { |
374 | if (currentstyle.isMono() && !fc->hasCourier()) | 370 | if (currentstyle.isMono() && !fc->hasCourier()) |
375 | { | 371 | { |
376 | int cw = (7*fc->getsize(currentstyle))/10; | 372 | int cw = (7*fc->getsize(currentstyle))/10; |
377 | int w = cw*(end-textstart->start); | 373 | int w = cw*(end-textstart->start); |
378 | if (currentstyle.isUnderline()) | 374 | if (currentstyle.isUnderline()) |
379 | { | 375 | { |
380 | _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset); | 376 | _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset); |
381 | } | 377 | } |
382 | if (currentstyle.isStrikethru()) | 378 | if (currentstyle.isStrikethru()) |
383 | { | 379 | { |
384 | int ascent = fc->ascent(currentstyle)/3; | 380 | int ascent = fc->ascent(currentstyle)/3; |
385 | _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset); | 381 | _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset); |
386 | } | 382 | } |
387 | QString str = text.mid(textstart->start, end-textstart->start); | 383 | QString str = text.mid(textstart->start, end-textstart->start); |
388 | 384 | ||
389 | for (unsigned int i = 0; i < str.length(); i++) | 385 | for (unsigned int i = 0; i < str.length(); i++) |
390 | { | 386 | { |
391 | #ifdef _WINDOWS | 387 | #ifdef _WINDOWS |
392 | _p->drawText( currentx, _y+voffset, QString(str.at(i))); | 388 | _p->drawText( currentx, _y+voffset, QString(str.at(i))); |
393 | #else | 389 | #else |
394 | _p->drawText( currentx, _y+voffset, QString(str[i])); | 390 | _p->drawText( currentx, _y+voffset, QString(str[i])); |
395 | #endif | 391 | #endif |
396 | currentx += cw; | 392 | currentx += cw; |
397 | } | 393 | } |
398 | } | 394 | } |
399 | else | 395 | else |
400 | { | 396 | { |
401 | QFontMetrics fm(f); | 397 | QFontMetrics fm(f); |
402 | int w; | 398 | int w; |
403 | if (just) | 399 | if (just) |
404 | { | 400 | { |
405 | int lastspace = -1; | 401 | int lastspace = -1; |
406 | int nsp = 0; | 402 | int nsp = 0; |
407 | int cx = currentx; | 403 | int cx = currentx; |
408 | while ((nsp = str.find(" ", lastspace+1)) >= 0) | 404 | while ((nsp = str.find(" ", lastspace+1)) >= 0) |
409 | { | 405 | { |
410 | if (nsp+textstart->start >= nonspace) | 406 | if (nsp+textstart->start >= nonspace) |
411 | { | 407 | { |
412 | spacenumber++; | 408 | spacenumber++; |
413 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; | 409 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; |
414 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 410 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
415 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); | 411 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); |
416 | int lw = fm.width(nstr); | 412 | int lw = fm.width(nstr); |
417 | _p->drawText( cx, _y+voffset, nstr); | 413 | _p->drawText( cx, _y+voffset, nstr); |
418 | cx += lw+nexttoadd; | 414 | cx += lw+nexttoadd; |
419 | spacesofar += nexttoadd; | 415 | spacesofar += nexttoadd; |
420 | lastspace = nsp; | 416 | lastspace = nsp; |
421 | } | 417 | } |
422 | else | 418 | else |
423 | { | 419 | { |
424 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 420 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
425 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); | 421 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); |
426 | int lw = fm.width(nstr); | 422 | int lw = fm.width(nstr); |
427 | _p->drawText( cx, _y+voffset, nstr); | 423 | _p->drawText( cx, _y+voffset, nstr); |
428 | cx += lw; | 424 | cx += lw; |
429 | lastspace = nsp; | 425 | lastspace = nsp; |
430 | } | 426 | } |
431 | } | 427 | } |
432 | QString nstr = str.right(str.length()-1-lastspace); | 428 | QString nstr = str.right(str.length()-1-lastspace); |
433 | _p->drawText( cx, _y+voffset, nstr); | 429 | _p->drawText( cx, _y+voffset, nstr); |
434 | cx += fm.width(nstr); | 430 | cx += fm.width(nstr); |
435 | w = cx - currentx; | 431 | w = cx - currentx; |
436 | } | 432 | } |
437 | else | 433 | else |
438 | { | 434 | { |
439 | _p->drawText( currentx, _y+voffset, str); | 435 | _p->drawText( currentx, _y+voffset, str); |
440 | w = fm.width(str); | 436 | w = fm.width(str); |
441 | } | 437 | } |
442 | if (currentstyle.isUnderline()) | 438 | if (currentstyle.isUnderline()) |
443 | { | 439 | { |
444 | _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset); | 440 | _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset); |
445 | } | 441 | } |
446 | if (currentstyle.isStrikethru()) | 442 | if (currentstyle.isStrikethru()) |
447 | { | 443 | { |
448 | int ascent = fc->ascent(currentstyle)/3; | 444 | int ascent = fc->ascent(currentstyle)/3; |
449 | _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset); | 445 | _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset); |
450 | } | 446 | } |
451 | currentx += w; | 447 | currentx += w; |
452 | } | 448 | } |
453 | } | 449 | } |
454 | } | 450 | } |
455 | textstart = textend; | 451 | textstart = textend; |
456 | } | 452 | } |
457 | while (textend != segs.end() && textstart->start < len); | 453 | while (textend != segs.end() && textstart->start < len); |
458 | } | 454 | } |
459 | 455 | ||
460 | CStyle CDrawBuffer::laststyle() | 456 | CStyle CDrawBuffer::laststyle() |
461 | { | 457 | { |
462 | return segs.last().style; | 458 | return segs.last().style; |
463 | } | 459 | } |
464 | 460 | ||
465 | linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt) | 461 | linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt) |
466 | { | 462 | { |
467 | int end = 0; | 463 | int end = 0; |
468 | CStyle currentstyle; | 464 | CStyle currentstyle; |
469 | CList<textsegment>::iterator textstart = segs.begin(); | 465 | CList<textsegment>::iterator textstart = segs.begin(); |
470 | CList<textsegment>::iterator textend = textstart; | 466 | CList<textsegment>::iterator textend = textstart; |
471 | do | 467 | do |
472 | { | 468 | { |
473 | textend++; | 469 | textend++; |
474 | end = (textend != segs.end()) ? textend->start : len; | 470 | end = (textend != segs.end()) ? textend->start : len; |
475 | currentstyle = textstart->style; | 471 | currentstyle = textstart->style; |
476 | /* | 472 | /* |
477 | if (currentstyle.isPicture()) qDebug("Passed thru picture"); | 473 | if (currentstyle.isPicture()) qDebug("Passed thru picture"); |
478 | if (currentstyle.getLink()) qDebug("Passed thru link"); | 474 | if (currentstyle.getLink()) qDebug("Passed thru link"); |
479 | //qDebug("islink:%d - %d", numchars, end); | 475 | //qDebug("islink:%d - %d", numchars, end); |
480 | */ | 476 | */ |
481 | textstart = textend; | 477 | textstart = textend; |
482 | } | 478 | } |
483 | while (textend != segs.end() && end <= numchars); | 479 | while (textend != segs.end() && end <= numchars); |
484 | // if (currentstyle.isPicture()) qDebug("Clicked on picture"); | 480 | // if (currentstyle.isPicture()) qDebug("Clicked on picture"); |
485 | if (currentstyle.getPictureLink()) | 481 | if (currentstyle.getPictureLink()) |
486 | { | 482 | { |
487 | tgt = currentstyle.getPictureLinkData(); | 483 | tgt = currentstyle.getPictureLinkData(); |
488 | return ePicture; | 484 | return ePicture; |
489 | } | 485 | } |
490 | if (currentstyle.getLink()) | 486 | if (currentstyle.getLink()) |
491 | { | 487 | { |
492 | tgt = currentstyle.getData(); | 488 | tgt = currentstyle.getData(); |
493 | return eLink; | 489 | return eLink; |
494 | } | 490 | } |
495 | return eNone; | 491 | return eNone; |
496 | } | 492 | } |
497 | 493 | ||
498 | void CDrawBuffer::resize() | 494 | void CDrawBuffer::resize() |
499 | { | 495 | { |
500 | int gzoom = fc->gzoom(); | 496 | int gzoom = fc->gzoom(); |
501 | m_maxstyle = m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; | 497 | m_maxstyle = m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
502 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) | 498 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) |
503 | { | 499 | { |
504 | CList<textsegment>::iterator next = iter; | 500 | CList<textsegment>::iterator next = iter; |
505 | iter++; | 501 | iter++; |
506 | int st = next->start; | 502 | int st = next->start; |
507 | if (st < 0) st = 0; | 503 | if (st < 0) st = 0; |
508 | 504 | ||
509 | CStyle _style = next->style; | 505 | CStyle _style = next->style; |
510 | 506 | ||
511 | int linespacing, ascent, descent, extra; | 507 | int linespacing, ascent, descent, extra; |
512 | 508 | ||
513 | ascent = fc->ascent(_style); | 509 | ascent = fc->ascent(_style); |
514 | descent = fc->descent(_style); | 510 | descent = fc->descent(_style); |
515 | linespacing = fc->lineSpacing(_style); | 511 | linespacing = fc->lineSpacing(_style); |
516 | extra = linespacing - ascent - descent; | 512 | extra = linespacing - ascent - descent; |
517 | if (_style.isPicture() && _style.canScale()) | 513 | if (_style.isPicture() && _style.canScale()) |
518 | { | 514 | { |
519 | descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2; | 515 | descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2; |
520 | ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2; | 516 | ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2; |
521 | } | 517 | } |
522 | /* | 518 | /* |
523 | else if (fc != NULL) | 519 | else if (fc != NULL) |
524 | { | 520 | { |
525 | ascent = fc->ascent(_style); | 521 | ascent = fc->ascent(_style); |
526 | descent = fc->descent(_style); | 522 | descent = fc->descent(_style); |
527 | linespacing = fc->lineSpacing(_style); | 523 | linespacing = fc->lineSpacing(_style); |
528 | extra = linespacing - ascent - descent; | 524 | extra = linespacing - ascent - descent; |
529 | } | 525 | } |
530 | */ | 526 | */ |
531 | if (ascent > m_ascent) m_ascent = ascent; | 527 | if (ascent > m_ascent) m_ascent = ascent; |
532 | if (descent > m_descent) m_descent = descent; | 528 | if (descent > m_descent) m_descent = descent; |
533 | if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; | 529 | if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; |
534 | m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; | 530 | m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; |
535 | } | 531 | } |
536 | int lead = fc->getlead(); | 532 | int lead = fc->getlead(); |
537 | if (lead != 0) | 533 | if (lead != 0) |
538 | { | 534 | { |
539 | int xt = (lead*m_lineSpacing+5)/10; | 535 | int xt = (lead*m_lineSpacing+5)/10; |
540 | m_descent += xt; | 536 | m_descent += xt; |
541 | m_lineSpacing += xt; | 537 | m_lineSpacing += xt; |
542 | } | 538 | } |
543 | if (m_bSop) | 539 | if (m_bSop) |
544 | { | 540 | { |
545 | int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10; | 541 | int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10; |
546 | //qDebug("ExtraSpace:%d", xt); | 542 | //qDebug("ExtraSpace:%d", xt); |
547 | m_ascent += xt; | 543 | m_ascent += xt; |
548 | m_lineSpacing += xt; | 544 | m_lineSpacing += xt; |
549 | } | 545 | } |
550 | } | 546 | } |
diff --git a/noncore/apps/opie-reader/CEncoding_tables.cpp b/noncore/apps/opie-reader/CEncoding_tables.cpp index 667bda0..e335819 100644 --- a/noncore/apps/opie-reader/CEncoding_tables.cpp +++ b/noncore/apps/opie-reader/CEncoding_tables.cpp | |||
@@ -1,534 +1,533 @@ | |||
1 | #include "CEncoding_tables.h" | 1 | #include "CEncoding_tables.h" |
2 | #include "config.h" | ||
3 | 2 | ||
4 | static const unicodetable unicodevalues[] = { | 3 | static const unicodetable unicodevalues[] = { |
5 | // from RFC 1489, ftp://ftp.isi.edu/in-notes/rfc1489.txt | 4 | // from RFC 1489, ftp://ftp.isi.edu/in-notes/rfc1489.txt |
6 | { "KOI8-R", "KOI8-R", 2084, | 5 | { "KOI8-R", "KOI8-R", 2084, |
7 | { 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524, | 6 | { 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524, |
8 | 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590, | 7 | 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590, |
9 | 0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219/**/, 0x221A, 0x2248, | 8 | 0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219/**/, 0x221A, 0x2248, |
10 | 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7, | 9 | 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7, |
11 | 0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556, | 10 | 0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556, |
12 | 0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E, | 11 | 0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E, |
13 | 0x255F, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565, | 12 | 0x255F, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565, |
14 | 0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x00A9, | 13 | 0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x00A9, |
15 | 0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, | 14 | 0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, |
16 | 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, | 15 | 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, |
17 | 0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, | 16 | 0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, |
18 | 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A, | 17 | 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A, |
19 | 0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, | 18 | 0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, |
20 | 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, | 19 | 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, |
21 | 0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, | 20 | 0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, |
22 | 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A } }, | 21 | 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A } }, |
23 | // /**/ - The BULLET OPERATOR is confused. Some people think | 22 | // /**/ - The BULLET OPERATOR is confused. Some people think |
24 | // it should be 0x2022 (BULLET). | 23 | // it should be 0x2022 (BULLET). |
25 | 24 | ||
26 | // from RFC 2319, ftp://ftp.isi.edu/in-notes/rfc2319.txt | 25 | // from RFC 2319, ftp://ftp.isi.edu/in-notes/rfc2319.txt |
27 | { "KOI8-U", "KOI8-U", 2088, | 26 | { "KOI8-U", "KOI8-U", 2088, |
28 | { 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524, | 27 | { 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524, |
29 | 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590, | 28 | 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590, |
30 | 0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248, | 29 | 0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248, |
31 | 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7, | 30 | 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7, |
32 | 0x2550, 0x2551, 0x2552, 0x0451, 0x0454, 0x2554, 0x0456, 0x0457, | 31 | 0x2550, 0x2551, 0x2552, 0x0451, 0x0454, 0x2554, 0x0456, 0x0457, |
33 | 0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x0491, 0x255D, 0x255E, | 32 | 0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x0491, 0x255D, 0x255E, |
34 | 0x255F, 0x2560, 0x2561, 0x0401, 0x0404, 0x2563, 0x0406, 0x0407, | 33 | 0x255F, 0x2560, 0x2561, 0x0401, 0x0404, 0x2563, 0x0406, 0x0407, |
35 | 0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x0490, 0x256C, 0x00A9, | 34 | 0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x0490, 0x256C, 0x00A9, |
36 | 0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, | 35 | 0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, |
37 | 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, | 36 | 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, |
38 | 0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, | 37 | 0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, |
39 | 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A, | 38 | 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A, |
40 | 0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, | 39 | 0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, |
41 | 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, | 40 | 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, |
42 | 0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, | 41 | 0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, |
43 | 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A } }, | 42 | 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A } }, |
44 | 43 | ||
45 | // next bits generated from tables on the Unicode 2.0 CD. we can | 44 | // next bits generated from tables on the Unicode 2.0 CD. we can |
46 | // use these tables since this is part of the transition to using | 45 | // use these tables since this is part of the transition to using |
47 | // unicode everywhere in qt. | 46 | // unicode everywhere in qt. |
48 | 47 | ||
49 | // $ for A in 8 9 A B C D E F ; do for B in 0 1 2 3 4 5 6 7 8 9 A B C D E F ; do echo 0x${A}${B} 0xFFFD ; done ; done > /tmp/digits ; for a in 8859-* ; do ( awk '/^0x[89ABCDEF]/{ print $1, $2 }' < $a ; cat /tmp/digits ) | sort | uniq -w4 | cut -c6- | paste '-d ' - - - - - - - - | sed -e 's/ /, /g' -e 's/$/,/' -e '$ s/,$/} },/' -e '1 s/^/{ /' > ~/tmp/$a ; done | 48 | // $ for A in 8 9 A B C D E F ; do for B in 0 1 2 3 4 5 6 7 8 9 A B C D E F ; do echo 0x${A}${B} 0xFFFD ; done ; done > /tmp/digits ; for a in 8859-* ; do ( awk '/^0x[89ABCDEF]/{ print $1, $2 }' < $a ; cat /tmp/digits ) | sort | uniq -w4 | cut -c6- | paste '-d ' - - - - - - - - | sed -e 's/ /, /g' -e 's/$/,/' -e '$ s/,$/} },/' -e '1 s/^/{ /' > ~/tmp/$a ; done |
50 | 49 | ||
51 | // then I inserted the files manually. | 50 | // then I inserted the files manually. |
52 | { "ISO-8859-2", "ISO 8859-2", 5, | 51 | { "ISO-8859-2", "ISO 8859-2", 5, |
53 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, | 52 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, |
54 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, | 53 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, |
55 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, | 54 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, |
56 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, | 55 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, |
57 | 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7, | 56 | 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7, |
58 | 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B, | 57 | 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B, |
59 | 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7, | 58 | 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7, |
60 | 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C, | 59 | 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C, |
61 | 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, | 60 | 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, |
62 | 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, | 61 | 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, |
63 | 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, | 62 | 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, |
64 | 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, | 63 | 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, |
65 | 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, | 64 | 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, |
66 | 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, | 65 | 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, |
67 | 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, | 66 | 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, |
68 | 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9} }, | 67 | 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9} }, |
69 | { "ISO-8859-3", "ISO 8859-3", 6, | 68 | { "ISO-8859-3", "ISO 8859-3", 6, |
70 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, | 69 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, |
71 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, | 70 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, |
72 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, | 71 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, |
73 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, | 72 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, |
74 | 0x00A0, 0x0126, 0x02D8, 0x00A3, 0x00A4, 0xFFFD, 0x0124, 0x00A7, | 73 | 0x00A0, 0x0126, 0x02D8, 0x00A3, 0x00A4, 0xFFFD, 0x0124, 0x00A7, |
75 | 0x00A8, 0x0130, 0x015E, 0x011E, 0x0134, 0x00AD, 0xFFFD, 0x017B, | 74 | 0x00A8, 0x0130, 0x015E, 0x011E, 0x0134, 0x00AD, 0xFFFD, 0x017B, |
76 | 0x00B0, 0x0127, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0125, 0x00B7, | 75 | 0x00B0, 0x0127, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0125, 0x00B7, |
77 | 0x00B8, 0x0131, 0x015F, 0x011F, 0x0135, 0x00BD, 0xFFFD, 0x017C, | 76 | 0x00B8, 0x0131, 0x015F, 0x011F, 0x0135, 0x00BD, 0xFFFD, 0x017C, |
78 | 0x00C0, 0x00C1, 0x00C2, 0xFFFD, 0x00C4, 0x010A, 0x0108, 0x00C7, | 77 | 0x00C0, 0x00C1, 0x00C2, 0xFFFD, 0x00C4, 0x010A, 0x0108, 0x00C7, |
79 | 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, | 78 | 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, |
80 | 0xFFFD, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x0120, 0x00D6, 0x00D7, | 79 | 0xFFFD, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x0120, 0x00D6, 0x00D7, |
81 | 0x011C, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x016C, 0x015C, 0x00DF, | 80 | 0x011C, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x016C, 0x015C, 0x00DF, |
82 | 0x00E0, 0x00E1, 0x00E2, 0xFFFD, 0x00E4, 0x010B, 0x0109, 0x00E7, | 81 | 0x00E0, 0x00E1, 0x00E2, 0xFFFD, 0x00E4, 0x010B, 0x0109, 0x00E7, |
83 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, | 82 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, |
84 | 0xFFFD, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7, | 83 | 0xFFFD, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7, |
85 | 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9} }, | 84 | 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9} }, |
86 | { "ISO-8859-4", "ISO 8859-4", 7, | 85 | { "ISO-8859-4", "ISO 8859-4", 7, |
87 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, | 86 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, |
88 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, | 87 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, |
89 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, | 88 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, |
90 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, | 89 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, |
91 | 0x00A0, 0x0104, 0x0138, 0x0156, 0x00A4, 0x0128, 0x013B, 0x00A7, | 90 | 0x00A0, 0x0104, 0x0138, 0x0156, 0x00A4, 0x0128, 0x013B, 0x00A7, |
92 | 0x00A8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00AD, 0x017D, 0x00AF, | 91 | 0x00A8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00AD, 0x017D, 0x00AF, |
93 | 0x00B0, 0x0105, 0x02DB, 0x0157, 0x00B4, 0x0129, 0x013C, 0x02C7, | 92 | 0x00B0, 0x0105, 0x02DB, 0x0157, 0x00B4, 0x0129, 0x013C, 0x02C7, |
94 | 0x00B8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014A, 0x017E, 0x014B, | 93 | 0x00B8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014A, 0x017E, 0x014B, |
95 | 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E, | 94 | 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E, |
96 | 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x012A, | 95 | 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x012A, |
97 | 0x0110, 0x0145, 0x014C, 0x0136, 0x00D4, 0x00D5, 0x00D6, 0x00D7, | 96 | 0x0110, 0x0145, 0x014C, 0x0136, 0x00D4, 0x00D5, 0x00D6, 0x00D7, |
98 | 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x0168, 0x016A, 0x00DF, | 97 | 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x0168, 0x016A, 0x00DF, |
99 | 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F, | 98 | 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F, |
100 | 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x012B, | 99 | 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x012B, |
101 | 0x0111, 0x0146, 0x014D, 0x0137, 0x00F4, 0x00F5, 0x00F6, 0x00F7, | 100 | 0x0111, 0x0146, 0x014D, 0x0137, 0x00F4, 0x00F5, 0x00F6, 0x00F7, |
102 | 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x0169, 0x016B, 0x02D9} }, | 101 | 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x0169, 0x016B, 0x02D9} }, |
103 | { "ISO-8859-5", "ISO 8859-5", 8, | 102 | { "ISO-8859-5", "ISO 8859-5", 8, |
104 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, | 103 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, |
105 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, | 104 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, |
106 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, | 105 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, |
107 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, | 106 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, |
108 | 0x00A0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407, | 107 | 0x00A0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407, |
109 | 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00AD, 0x040E, 0x040F, | 108 | 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00AD, 0x040E, 0x040F, |
110 | 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, | 109 | 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, |
111 | 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, | 110 | 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, |
112 | 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, | 111 | 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, |
113 | 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, | 112 | 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, |
114 | 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, | 113 | 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, |
115 | 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, | 114 | 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, |
116 | 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, | 115 | 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, |
117 | 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, | 116 | 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, |
118 | 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457, | 117 | 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457, |
119 | 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00A7, 0x045E, 0x045F} }, | 118 | 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00A7, 0x045E, 0x045F} }, |
120 | { "ISO-8859-6", "ISO 8859-6", 82, | 119 | { "ISO-8859-6", "ISO 8859-6", 82, |
121 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, | 120 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, |
122 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, | 121 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, |
123 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, | 122 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, |
124 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, | 123 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, |
125 | 0x00A0, 0xFFFD, 0xFFFD, 0xFFFD, 0x00A4, 0xFFFD, 0xFFFD, 0xFFFD, | 124 | 0x00A0, 0xFFFD, 0xFFFD, 0xFFFD, 0x00A4, 0xFFFD, 0xFFFD, 0xFFFD, |
126 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x060C, 0x00AD, 0xFFFD, 0xFFFD, | 125 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x060C, 0x00AD, 0xFFFD, 0xFFFD, |
127 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 126 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
128 | 0xFFFD, 0xFFFD, 0xFFFD, 0x061B, 0xFFFD, 0xFFFD, 0xFFFD, 0x061F, | 127 | 0xFFFD, 0xFFFD, 0xFFFD, 0x061B, 0xFFFD, 0xFFFD, 0xFFFD, 0x061F, |
129 | 0xFFFD, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, | 128 | 0xFFFD, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, |
130 | 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, | 129 | 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, |
131 | 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, | 130 | 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, |
132 | 0x0638, 0x0639, 0x063A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 131 | 0x0638, 0x0639, 0x063A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
133 | 0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, | 132 | 0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, |
134 | 0x0648, 0x0649, 0x064A, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, | 133 | 0x0648, 0x0649, 0x064A, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, |
135 | 0x0650, 0x0651, 0x0652, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 134 | 0x0650, 0x0651, 0x0652, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
136 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} }, | 135 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} }, |
137 | { "ISO-8859-7", "ISO 8859-7", 10, | 136 | { "ISO-8859-7", "ISO 8859-7", 10, |
138 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, | 137 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, |
139 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, | 138 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, |
140 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, | 139 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, |
141 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, | 140 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, |
142 | 0x00A0, 0x2018, 0x2019, 0x00A3, 0xFFFD, 0xFFFD, 0x00A6, 0x00A7, | 141 | 0x00A0, 0x2018, 0x2019, 0x00A3, 0xFFFD, 0xFFFD, 0x00A6, 0x00A7, |
143 | 0x00A8, 0x00A9, 0xFFFD, 0x00AB, 0x00AC, 0x00AD, 0xFFFD, 0x2015, | 142 | 0x00A8, 0x00A9, 0xFFFD, 0x00AB, 0x00AC, 0x00AD, 0xFFFD, 0x2015, |
144 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x0385, 0x0386, 0x00B7, | 143 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x0385, 0x0386, 0x00B7, |
145 | 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F, | 144 | 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F, |
146 | 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, | 145 | 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, |
147 | 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, | 146 | 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, |
148 | 0x03A0, 0x03A1, 0xFFFD, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, | 147 | 0x03A0, 0x03A1, 0xFFFD, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, |
149 | 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF, | 148 | 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF, |
150 | 0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, | 149 | 0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, |
151 | 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, | 150 | 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, |
152 | 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, | 151 | 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, |
153 | 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0xFFFD} }, | 152 | 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0xFFFD} }, |
154 | { "ISO-8859-8-I", "ISO 8859-8-I", 85, | 153 | { "ISO-8859-8-I", "ISO 8859-8-I", 85, |
155 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, | 154 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, |
156 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, | 155 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, |
157 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, | 156 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, |
158 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, | 157 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, |
159 | 0x00A0, 0xFFFD, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, | 158 | 0x00A0, 0xFFFD, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, |
160 | 0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x203E, | 159 | 0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x203E, |
161 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, | 160 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, |
162 | 0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0xFFFD, | 161 | 0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0xFFFD, |
163 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 162 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
164 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 163 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
165 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 164 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
166 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x2017, | 165 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x2017, |
167 | 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, | 166 | 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, |
168 | 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, | 167 | 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, |
169 | 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, | 168 | 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, |
170 | 0x05E8, 0x05E9, 0x05EA, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} }, | 169 | 0x05E8, 0x05E9, 0x05EA, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} }, |
171 | { "ISO-8859-9", "ISO 8859-9", 12, | 170 | { "ISO-8859-9", "ISO 8859-9", 12, |
172 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, | 171 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, |
173 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, | 172 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, |
174 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, | 173 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, |
175 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, | 174 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, |
176 | 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, | 175 | 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, |
177 | 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, | 176 | 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, |
178 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, | 177 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, |
179 | 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, | 178 | 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, |
180 | 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, | 179 | 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, |
181 | 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, | 180 | 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, |
182 | 0x011E, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, | 181 | 0x011E, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, |
183 | 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0130, 0x015E, 0x00DF, | 182 | 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0130, 0x015E, 0x00DF, |
184 | 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, | 183 | 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, |
185 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, | 184 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, |
186 | 0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, | 185 | 0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, |
187 | 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF} }, | 186 | 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF} }, |
188 | { "ISO-8859-10", "ISO 8859-10", 13, | 187 | { "ISO-8859-10", "ISO 8859-10", 13, |
189 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, | 188 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, |
190 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, | 189 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, |
191 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, | 190 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, |
192 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, | 191 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, |
193 | 0x00A0, 0x0104, 0x0112, 0x0122, 0x012A, 0x0128, 0x0136, 0x00A7, | 192 | 0x00A0, 0x0104, 0x0112, 0x0122, 0x012A, 0x0128, 0x0136, 0x00A7, |
194 | 0x013B, 0x0110, 0x0160, 0x0166, 0x017D, 0x00AD, 0x016A, 0x014A, | 193 | 0x013B, 0x0110, 0x0160, 0x0166, 0x017D, 0x00AD, 0x016A, 0x014A, |
195 | 0x00B0, 0x0105, 0x0113, 0x0123, 0x012B, 0x0129, 0x0137, 0x00B7, | 194 | 0x00B0, 0x0105, 0x0113, 0x0123, 0x012B, 0x0129, 0x0137, 0x00B7, |
196 | 0x013C, 0x0111, 0x0161, 0x0167, 0x017E, 0x2015, 0x016B, 0x014B, | 195 | 0x013C, 0x0111, 0x0161, 0x0167, 0x017E, 0x2015, 0x016B, 0x014B, |
197 | 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E, | 196 | 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E, |
198 | 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x00CF, | 197 | 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x00CF, |
199 | 0x00D0, 0x0145, 0x014C, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x0168, | 198 | 0x00D0, 0x0145, 0x014C, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x0168, |
200 | 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, | 199 | 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, |
201 | 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F, | 200 | 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F, |
202 | 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x00EF, | 201 | 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x00EF, |
203 | 0x00F0, 0x0146, 0x014D, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x0169, | 202 | 0x00F0, 0x0146, 0x014D, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x0169, |
204 | 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x0138} }, | 203 | 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x0138} }, |
205 | { "ISO-8859-13", "ISO 8859-13", 109, | 204 | { "ISO-8859-13", "ISO 8859-13", 109, |
206 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, | 205 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, |
207 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, | 206 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, |
208 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, | 207 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, |
209 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, | 208 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, |
210 | 0x00A0, 0x201D, 0x00A2, 0x00A3, 0x00A4, 0x201E, 0x00A6, 0x00A7, | 209 | 0x00A0, 0x201D, 0x00A2, 0x00A3, 0x00A4, 0x201E, 0x00A6, 0x00A7, |
211 | 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6, | 210 | 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6, |
212 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x201C, 0x00B5, 0x00B6, 0x00B7, | 211 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x201C, 0x00B5, 0x00B6, 0x00B7, |
213 | 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6, | 212 | 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6, |
214 | 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, | 213 | 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, |
215 | 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B, | 214 | 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B, |
216 | 0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, | 215 | 0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, |
217 | 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF, | 216 | 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF, |
218 | 0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, | 217 | 0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, |
219 | 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C, | 218 | 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C, |
220 | 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, | 219 | 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, |
221 | 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x2019} }, | 220 | 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x2019} }, |
222 | { "ISO-8859-14", "ISO 8859-14", 110, | 221 | { "ISO-8859-14", "ISO 8859-14", 110, |
223 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, | 222 | { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, |
224 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, | 223 | 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, |
225 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, | 224 | 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, |
226 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, | 225 | 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, |
227 | 0x00A0, 0x1E02, 0x1E03, 0x00A3, 0x010A, 0x010B, 0x1E0A, 0x00A7, | 226 | 0x00A0, 0x1E02, 0x1E03, 0x00A3, 0x010A, 0x010B, 0x1E0A, 0x00A7, |
228 | 0x1E80, 0x00A9, 0x1E82, 0x1E0B, 0x1EF2, 0x00AD, 0x00AE, 0x0178, | 227 | 0x1E80, 0x00A9, 0x1E82, 0x1E0B, 0x1EF2, 0x00AD, 0x00AE, 0x0178, |
229 | 0x1E1E, 0x1E1F, 0x0120, 0x0121, 0x1E40, 0x1E41, 0x00B6, 0x1E56, | 228 | 0x1E1E, 0x1E1F, 0x0120, 0x0121, 0x1E40, 0x1E41, 0x00B6, 0x1E56, |
230 | 0x1E81, 0x1E57, 0x1E83, 0x1E60, 0x1EF3, 0x1E84, 0x1E85, 0x1E61, | 229 | 0x1E81, 0x1E57, 0x1E83, 0x1E60, 0x1EF3, 0x1E84, 0x1E85, 0x1E61, |
231 | 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, | 230 | 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, |
232 | 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, | 231 | 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, |
233 | 0x0174, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x1E6A, | 232 | 0x0174, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x1E6A, |
234 | 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x0176, 0x00DF, | 233 | 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x0176, 0x00DF, |
235 | 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, | 234 | 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, |
236 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, | 235 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, |
237 | 0x0175, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x1E6B, | 236 | 0x0175, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x1E6B, |
238 | 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x0177, 0x00FF} }, | 237 | 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x0177, 0x00FF} }, |
239 | 238 | ||
240 | // next bits generated again from tables on the Unicode 3.0 CD. | 239 | // next bits generated again from tables on the Unicode 3.0 CD. |
241 | 240 | ||
242 | // $ for a in CP* ; do ( awk '/^0x[89ABCDEF]/{ print $1, $2 }' < $a ) | sort | sed -e 's/#UNDEF.*$/0xFFFD/' | cut -c6- | paste '-d ' - - - - - - - - | sed -e 's/ /, /g' -e 's/$/,/' -e '$ s/,$/} },/' -e '1 s/^/{ /' > ~/tmp/$a ; done | 241 | // $ for a in CP* ; do ( awk '/^0x[89ABCDEF]/{ print $1, $2 }' < $a ) | sort | sed -e 's/#UNDEF.*$/0xFFFD/' | cut -c6- | paste '-d ' - - - - - - - - | sed -e 's/ /, /g' -e 's/$/,/' -e '$ s/,$/} },/' -e '1 s/^/{ /' > ~/tmp/$a ; done |
243 | 242 | ||
244 | { "CP 850", "IBM 850", 2009, | 243 | { "CP 850", "IBM 850", 2009, |
245 | { 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, | 244 | { 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, |
246 | 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, | 245 | 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, |
247 | 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, | 246 | 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, |
248 | 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, | 247 | 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, |
249 | 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, | 248 | 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, |
250 | 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, | 249 | 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, |
251 | 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, | 250 | 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, |
252 | 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, | 251 | 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, |
253 | 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, | 252 | 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, |
254 | 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, | 253 | 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, |
255 | 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, | 254 | 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, |
256 | 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, | 255 | 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, |
257 | 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, | 256 | 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, |
258 | 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, | 257 | 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, |
259 | 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, | 258 | 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, |
260 | 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0} }, | 259 | 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0} }, |
261 | { "CP 874", "CP 874", 0, //### what is the mib? | 260 | { "CP 874", "CP 874", 0, //### what is the mib? |
262 | { 0x20AC, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x2026, 0xFFFD, 0xFFFD, | 261 | { 0x20AC, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x2026, 0xFFFD, 0xFFFD, |
263 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 262 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
264 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, | 263 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, |
265 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 264 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
266 | 0x00A0, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07, | 265 | 0x00A0, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07, |
267 | 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F, | 266 | 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F, |
268 | 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17, | 267 | 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17, |
269 | 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F, | 268 | 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F, |
270 | 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27, | 269 | 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27, |
271 | 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F, | 270 | 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F, |
272 | 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37, | 271 | 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37, |
273 | 0x0E38, 0x0E39, 0x0E3A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x0E3F, | 272 | 0x0E38, 0x0E39, 0x0E3A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x0E3F, |
274 | 0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47, | 273 | 0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47, |
275 | 0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F, | 274 | 0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F, |
276 | 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57, | 275 | 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57, |
277 | 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} }, | 276 | 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} }, |
278 | { "IBM 866", "IBM 866", 2086, | 277 | { "IBM 866", "IBM 866", 2086, |
279 | { 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, | 278 | { 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, |
280 | 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, | 279 | 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, |
281 | 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, | 280 | 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, |
282 | 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, | 281 | 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, |
283 | 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, | 282 | 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, |
284 | 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, | 283 | 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, |
285 | 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, | 284 | 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, |
286 | 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, | 285 | 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, |
287 | 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, | 286 | 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, |
288 | 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, | 287 | 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, |
289 | 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, | 288 | 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, |
290 | 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, | 289 | 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, |
291 | 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, | 290 | 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, |
292 | 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, | 291 | 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, |
293 | 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, | 292 | 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, |
294 | 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0} }, | 293 | 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0} }, |
295 | 294 | ||
296 | { "windows-1250", "CP 1250", 2250, | 295 | { "windows-1250", "CP 1250", 2250, |
297 | { 0x20AC, 0xFFFD, 0x201A, 0xFFFD, 0x201E, 0x2026, 0x2020, 0x2021, | 296 | { 0x20AC, 0xFFFD, 0x201A, 0xFFFD, 0x201E, 0x2026, 0x2020, 0x2021, |
298 | 0xFFFD, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179, | 297 | 0xFFFD, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179, |
299 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, | 298 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, |
300 | 0xFFFD, 0x2122, 0x0161, 0x203A, 0x015B, 0x0165, 0x017E, 0x017A, | 299 | 0xFFFD, 0x2122, 0x0161, 0x203A, 0x015B, 0x0165, 0x017E, 0x017A, |
301 | 0x00A0, 0x02C7, 0x02D8, 0x0141, 0x00A4, 0x0104, 0x00A6, 0x00A7, | 300 | 0x00A0, 0x02C7, 0x02D8, 0x0141, 0x00A4, 0x0104, 0x00A6, 0x00A7, |
302 | 0x00A8, 0x00A9, 0x015E, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x017B, | 301 | 0x00A8, 0x00A9, 0x015E, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x017B, |
303 | 0x00B0, 0x00B1, 0x02DB, 0x0142, 0x00B4, 0x00B5, 0x00B6, 0x00B7, | 302 | 0x00B0, 0x00B1, 0x02DB, 0x0142, 0x00B4, 0x00B5, 0x00B6, 0x00B7, |
304 | 0x00B8, 0x0105, 0x015F, 0x00BB, 0x013D, 0x02DD, 0x013E, 0x017C, | 303 | 0x00B8, 0x0105, 0x015F, 0x00BB, 0x013D, 0x02DD, 0x013E, 0x017C, |
305 | 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, | 304 | 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, |
306 | 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, | 305 | 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, |
307 | 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, | 306 | 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, |
308 | 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, | 307 | 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, |
309 | 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, | 308 | 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, |
310 | 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, | 309 | 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, |
311 | 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, | 310 | 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, |
312 | 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9} }, | 311 | 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9} }, |
313 | { "windows-1251", "CP 1251", 2251, | 312 | { "windows-1251", "CP 1251", 2251, |
314 | { 0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021, | 313 | { 0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021, |
315 | 0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F, | 314 | 0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F, |
316 | 0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, | 315 | 0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, |
317 | 0xFFFD, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F, | 316 | 0xFFFD, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F, |
318 | 0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7, | 317 | 0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7, |
319 | 0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407, | 318 | 0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407, |
320 | 0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7, | 319 | 0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7, |
321 | 0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457, | 320 | 0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457, |
322 | 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, | 321 | 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, |
323 | 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, | 322 | 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, |
324 | 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, | 323 | 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, |
325 | 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, | 324 | 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, |
326 | 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, | 325 | 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, |
327 | 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, | 326 | 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, |
328 | 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, | 327 | 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, |
329 | 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F} }, | 328 | 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F} }, |
330 | { "windows-1252", "CP 1252", 2252, | 329 | { "windows-1252", "CP 1252", 2252, |
331 | { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, | 330 | { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, |
332 | 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0xFFFD, 0x017D, 0xFFFD, | 331 | 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0xFFFD, 0x017D, 0xFFFD, |
333 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, | 332 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, |
334 | 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0xFFFD, 0x017E, 0x0178, | 333 | 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0xFFFD, 0x017E, 0x0178, |
335 | 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, | 334 | 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, |
336 | 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, | 335 | 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, |
337 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, | 336 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, |
338 | 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, | 337 | 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, |
339 | 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, | 338 | 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, |
340 | 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, | 339 | 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, |
341 | 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, | 340 | 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, |
342 | 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, | 341 | 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, |
343 | 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, | 342 | 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, |
344 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, | 343 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, |
345 | 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, | 344 | 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, |
346 | 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF} }, | 345 | 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF} }, |
347 | { "windows-1253", "CP 1253", 2253, | 346 | { "windows-1253", "CP 1253", 2253, |
348 | { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, | 347 | { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, |
349 | 0xFFFD, 0x2030, 0xFFFD, 0x2039, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 348 | 0xFFFD, 0x2030, 0xFFFD, 0x2039, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
350 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, | 349 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, |
351 | 0xFFFD, 0x2122, 0xFFFD, 0x203A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 350 | 0xFFFD, 0x2122, 0xFFFD, 0x203A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
352 | 0x00A0, 0x0385, 0x0386, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, | 351 | 0x00A0, 0x0385, 0x0386, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, |
353 | 0x00A8, 0x00A9, 0xFFFD, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x2015, | 352 | 0x00A8, 0x00A9, 0xFFFD, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x2015, |
354 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x00B5, 0x00B6, 0x00B7, | 353 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x00B5, 0x00B6, 0x00B7, |
355 | 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F, | 354 | 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F, |
356 | 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, | 355 | 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, |
357 | 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, | 356 | 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, |
358 | 0x03A0, 0x03A1, 0xFFFD, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, | 357 | 0x03A0, 0x03A1, 0xFFFD, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, |
359 | 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF, | 358 | 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF, |
360 | 0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, | 359 | 0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, |
361 | 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, | 360 | 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, |
362 | 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, | 361 | 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, |
363 | 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0xFFFD} }, | 362 | 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0xFFFD} }, |
364 | { "windows-1254", "CP 1254", 2254, | 363 | { "windows-1254", "CP 1254", 2254, |
365 | { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, | 364 | { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, |
366 | 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0xFFFD, 0xFFFD, 0xFFFD, | 365 | 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0xFFFD, 0xFFFD, 0xFFFD, |
367 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, | 366 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, |
368 | 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0xFFFD, 0xFFFD, 0x0178, | 367 | 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0xFFFD, 0xFFFD, 0x0178, |
369 | 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, | 368 | 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, |
370 | 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, | 369 | 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, |
371 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, | 370 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, |
372 | 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, | 371 | 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, |
373 | 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, | 372 | 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, |
374 | 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, | 373 | 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, |
375 | 0x011E, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, | 374 | 0x011E, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, |
376 | 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0130, 0x015E, 0x00DF, | 375 | 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0130, 0x015E, 0x00DF, |
377 | 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, | 376 | 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, |
378 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, | 377 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, |
379 | 0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, | 378 | 0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, |
380 | 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF} }, | 379 | 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF} }, |
381 | { "windows-1255", "CP 1255", 2255, | 380 | { "windows-1255", "CP 1255", 2255, |
382 | { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, | 381 | { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, |
383 | 0x02C6, 0x2030, 0xFFFD, 0x2039, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 382 | 0x02C6, 0x2030, 0xFFFD, 0x2039, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
384 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, | 383 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, |
385 | 0x02DC, 0x2122, 0xFFFD, 0x203A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 384 | 0x02DC, 0x2122, 0xFFFD, 0x203A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
386 | 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x20AA, 0x00A5, 0x00A6, 0x00A7, | 385 | 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x20AA, 0x00A5, 0x00A6, 0x00A7, |
387 | 0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, | 386 | 0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, |
388 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, | 387 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, |
389 | 0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, | 388 | 0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, |
390 | 0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7, | 389 | 0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7, |
391 | 0x05B8, 0x05B9, 0xFFFD, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF, | 390 | 0x05B8, 0x05B9, 0xFFFD, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF, |
392 | 0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05F0, 0x05F1, 0x05F2, 0x05F3, | 391 | 0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05F0, 0x05F1, 0x05F2, 0x05F3, |
393 | 0x05F4, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 392 | 0x05F4, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
394 | 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, | 393 | 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, |
395 | 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, | 394 | 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, |
396 | 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, | 395 | 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, |
397 | 0x05E8, 0x05E9, 0x05EA, 0xFFFD, 0xFFFD, 0x200E, 0x200F, 0xFFFD} }, | 396 | 0x05E8, 0x05E9, 0x05EA, 0xFFFD, 0xFFFD, 0x200E, 0x200F, 0xFFFD} }, |
398 | { "windows-1256", "CP 1256", 2256, | 397 | { "windows-1256", "CP 1256", 2256, |
399 | { 0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, | 398 | { 0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, |
400 | 0x02C6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688, | 399 | 0x02C6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688, |
401 | 0x06AF, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, | 400 | 0x06AF, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, |
402 | 0x06A9, 0x2122, 0x0691, 0x203A, 0x0153, 0x200C, 0x200D, 0x06BA, | 401 | 0x06A9, 0x2122, 0x0691, 0x203A, 0x0153, 0x200C, 0x200D, 0x06BA, |
403 | 0x00A0, 0x060C, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, | 402 | 0x00A0, 0x060C, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, |
404 | 0x00A8, 0x00A9, 0x06BE, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, | 403 | 0x00A8, 0x00A9, 0x06BE, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, |
405 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, | 404 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, |
406 | 0x00B8, 0x00B9, 0x061B, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x061F, | 405 | 0x00B8, 0x00B9, 0x061B, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x061F, |
407 | 0x06C1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, | 406 | 0x06C1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, |
408 | 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, | 407 | 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, |
409 | 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00D7, | 408 | 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00D7, |
410 | 0x0637, 0x0638, 0x0639, 0x063A, 0x0640, 0x0641, 0x0642, 0x0643, | 409 | 0x0637, 0x0638, 0x0639, 0x063A, 0x0640, 0x0641, 0x0642, 0x0643, |
411 | 0x00E0, 0x0644, 0x00E2, 0x0645, 0x0646, 0x0647, 0x0648, 0x00E7, | 410 | 0x00E0, 0x0644, 0x00E2, 0x0645, 0x0646, 0x0647, 0x0648, 0x00E7, |
412 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0649, 0x064A, 0x00EE, 0x00EF, | 411 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0649, 0x064A, 0x00EE, 0x00EF, |
413 | 0x064B, 0x064C, 0x064D, 0x064E, 0x00F4, 0x064F, 0x0650, 0x00F7, | 412 | 0x064B, 0x064C, 0x064D, 0x064E, 0x00F4, 0x064F, 0x0650, 0x00F7, |
414 | 0x0651, 0x00F9, 0x0652, 0x00FB, 0x00FC, 0x200E, 0x200F, 0x06D2} }, | 413 | 0x0651, 0x00F9, 0x0652, 0x00FB, 0x00FC, 0x200E, 0x200F, 0x06D2} }, |
415 | { "windows-1257", "CP 1257", 2257, | 414 | { "windows-1257", "CP 1257", 2257, |
416 | { 0x20AC, 0xFFFD, 0x201A, 0xFFFD, 0x201E, 0x2026, 0x2020, 0x2021, | 415 | { 0x20AC, 0xFFFD, 0x201A, 0xFFFD, 0x201E, 0x2026, 0x2020, 0x2021, |
417 | 0xFFFD, 0x2030, 0xFFFD, 0x2039, 0xFFFD, 0x00A8, 0x02C7, 0x00B8, | 416 | 0xFFFD, 0x2030, 0xFFFD, 0x2039, 0xFFFD, 0x00A8, 0x02C7, 0x00B8, |
418 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, | 417 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, |
419 | 0xFFFD, 0x2122, 0xFFFD, 0x203A, 0xFFFD, 0x00AF, 0x02DB, 0xFFFD, | 418 | 0xFFFD, 0x2122, 0xFFFD, 0x203A, 0xFFFD, 0x00AF, 0x02DB, 0xFFFD, |
420 | 0x00A0, 0xFFFD, 0x00A2, 0x00A3, 0x00A4, 0xFFFD, 0x00A6, 0x00A7, | 419 | 0x00A0, 0xFFFD, 0x00A2, 0x00A3, 0x00A4, 0xFFFD, 0x00A6, 0x00A7, |
421 | 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6, | 420 | 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6, |
422 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, | 421 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, |
423 | 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6, | 422 | 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6, |
424 | 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, | 423 | 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, |
425 | 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B, | 424 | 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B, |
426 | 0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, | 425 | 0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, |
427 | 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF, | 426 | 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF, |
428 | 0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, | 427 | 0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, |
429 | 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C, | 428 | 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C, |
430 | 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, | 429 | 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, |
431 | 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x02D9} }, | 430 | 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x02D9} }, |
432 | { "windows-1258", "CP 1258", 2258, | 431 | { "windows-1258", "CP 1258", 2258, |
433 | { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, | 432 | { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, |
434 | 0x02C6, 0x2030, 0xFFFD, 0x2039, 0x0152, 0xFFFD, 0xFFFD, 0xFFFD, | 433 | 0x02C6, 0x2030, 0xFFFD, 0x2039, 0x0152, 0xFFFD, 0xFFFD, 0xFFFD, |
435 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, | 434 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, |
436 | 0x02DC, 0x2122, 0xFFFD, 0x203A, 0x0153, 0xFFFD, 0xFFFD, 0x0178, | 435 | 0x02DC, 0x2122, 0xFFFD, 0x203A, 0x0153, 0xFFFD, 0xFFFD, 0x0178, |
437 | 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, | 436 | 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, |
438 | 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, | 437 | 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, |
439 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, | 438 | 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, |
440 | 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, | 439 | 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, |
441 | 0x00C0, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x00C5, 0x00C6, 0x00C7, | 440 | 0x00C0, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x00C5, 0x00C6, 0x00C7, |
442 | 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x0300, 0x00CD, 0x00CE, 0x00CF, | 441 | 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x0300, 0x00CD, 0x00CE, 0x00CF, |
443 | 0x0110, 0x00D1, 0x0309, 0x00D3, 0x00D4, 0x01A0, 0x00D6, 0x00D7, | 442 | 0x0110, 0x00D1, 0x0309, 0x00D3, 0x00D4, 0x01A0, 0x00D6, 0x00D7, |
444 | 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x01AF, 0x0303, 0x00DF, | 443 | 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x01AF, 0x0303, 0x00DF, |
445 | 0x00E0, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x00E5, 0x00E6, 0x00E7, | 444 | 0x00E0, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x00E5, 0x00E6, 0x00E7, |
446 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0301, 0x00ED, 0x00EE, 0x00EF, | 445 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0301, 0x00ED, 0x00EE, 0x00EF, |
447 | 0x0111, 0x00F1, 0x0323, 0x00F3, 0x00F4, 0x01A1, 0x00F6, 0x00F7, | 446 | 0x0111, 0x00F1, 0x0323, 0x00F3, 0x00F4, 0x01A1, 0x00F6, 0x00F7, |
448 | 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF} }, | 447 | 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF} }, |
449 | 448 | ||
450 | { "Apple Roman", "Apple Roman", 0, | 449 | { "Apple Roman", "Apple Roman", 0, |
451 | { 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1, | 450 | { 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1, |
452 | 0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8, | 451 | 0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8, |
453 | 0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3, | 452 | 0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3, |
454 | 0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC, | 453 | 0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC, |
455 | 0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF, | 454 | 0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF, |
456 | 0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x00C6, 0x00D8, | 455 | 0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x00C6, 0x00D8, |
457 | 0x221E, 0x00B1, 0x2264, 0x2265, 0x00A5, 0x00B5, 0x2202, 0x2211, | 456 | 0x221E, 0x00B1, 0x2264, 0x2265, 0x00A5, 0x00B5, 0x2202, 0x2211, |
458 | 0x220F, 0x03C0, 0x222B, 0x00AA, 0x00BA, 0x03A9, 0x00E6, 0x00F8, | 457 | 0x220F, 0x03C0, 0x222B, 0x00AA, 0x00BA, 0x03A9, 0x00E6, 0x00F8, |
459 | 0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, 0x2206, 0x00AB, | 458 | 0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, 0x2206, 0x00AB, |
460 | 0x00BB, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153, | 459 | 0x00BB, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153, |
461 | 0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA, | 460 | 0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA, |
462 | 0x00FF, 0x0178, 0x2044, 0x20AC, 0x2039, 0x203A, 0xFB01, 0xFB02, | 461 | 0x00FF, 0x0178, 0x2044, 0x20AC, 0x2039, 0x203A, 0xFB01, 0xFB02, |
463 | 0x2021, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x00CA, 0x00C1, | 462 | 0x2021, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x00CA, 0x00C1, |
464 | 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4, | 463 | 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4, |
465 | 0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC, | 464 | 0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC, |
466 | 0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7} }, | 465 | 0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7} }, |
467 | 466 | ||
468 | 467 | ||
469 | 468 | ||
470 | // This one is based on the charmap file | 469 | // This one is based on the charmap file |
471 | // /usr/share/i18n/charmaps/SAMI-WS2.gz, which is manually adapted | 470 | // /usr/share/i18n/charmaps/SAMI-WS2.gz, which is manually adapted |
472 | // to this format by Børre Gaup <boerre@subdimension.com> | 471 | // to this format by Børre Gaup <boerre@subdimension.com> |
473 | { "WINSAMI2", "WS2", 0, | 472 | { "WINSAMI2", "WS2", 0, |
474 | { 0x20AC, 0xFFFD, 0x010C, 0x0192, 0x010D, 0x01B7, 0x0292, 0x01EE, | 473 | { 0x20AC, 0xFFFD, 0x010C, 0x0192, 0x010D, 0x01B7, 0x0292, 0x01EE, |
475 | 0x01EF, 0x0110, 0x0160, 0x2039, 0x0152, 0xFFFD, 0xFFFD, 0xFFFD, | 474 | 0x01EF, 0x0110, 0x0160, 0x2039, 0x0152, 0xFFFD, 0xFFFD, 0xFFFD, |
476 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, | 475 | 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, |
477 | 0x0111, 0x01E6, 0x0161, 0x203A, 0x0153, 0xFFFD, 0xFFFD, 0x0178, | 476 | 0x0111, 0x01E6, 0x0161, 0x203A, 0x0153, 0xFFFD, 0xFFFD, 0x0178, |
478 | 0x00A0, 0x01E7, 0x01E4, 0x00A3, 0x00A4, 0x01E5, 0x00A6, 0x00A7, | 477 | 0x00A0, 0x01E7, 0x01E4, 0x00A3, 0x00A4, 0x01E5, 0x00A6, 0x00A7, |
479 | 0x00A8, 0x00A9, 0x021E, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x021F, | 478 | 0x00A8, 0x00A9, 0x021E, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x021F, |
480 | 0x00B0, 0x00B1, 0x01E8, 0x01E9, 0x00B4, 0x00B5, 0x00B6, 0x00B7, | 479 | 0x00B0, 0x00B1, 0x01E8, 0x01E9, 0x00B4, 0x00B5, 0x00B6, 0x00B7, |
481 | 0x014A, 0x014B, 0x0166, 0x00BB, 0x0167, 0x00BD, 0x017D, 0x017E, | 480 | 0x014A, 0x014B, 0x0166, 0x00BB, 0x0167, 0x00BD, 0x017D, 0x017E, |
482 | 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, | 481 | 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, |
483 | 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, | 482 | 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, |
484 | 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, | 483 | 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, |
485 | 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, | 484 | 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, |
486 | 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, | 485 | 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, |
487 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, | 486 | 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, |
488 | 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, | 487 | 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, |
489 | 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF} }, | 488 | 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF} }, |
490 | 489 | ||
491 | 490 | ||
492 | // this one is generated from the charmap file located in /usr/share/i18n/charmaps | 491 | // this one is generated from the charmap file located in /usr/share/i18n/charmaps |
493 | // on most Linux distributions. The thai character set tis620 is byte by byte equivalent | 492 | // on most Linux distributions. The thai character set tis620 is byte by byte equivalent |
494 | // to iso8859-11, so we name it 8859-11 here, but recognise the name tis620 too. | 493 | // to iso8859-11, so we name it 8859-11 here, but recognise the name tis620 too. |
495 | 494 | ||
496 | // $ for A in 8 9 A B C D E F ; do for B in 0 1 2 3 4 5 6 7 8 9 A B C D E F ; do echo x${A}${B} 0xFFFD ; done ; done > /tmp/digits ; ( cut -c25- < TIS-620 ; cat /tmp/digits ) | awk '/^x[89ABCDEF]/{ print $1, $2 }' | sed -e 's/<U/0x/' -e 's/>//' | sort | uniq -w4 | cut -c5- | paste '-d ' - - - - - - - - | sed -e 's/ /, /g' -e 's/$/,/' -e '$ s/,$/} },/' -e '1 s/^/{ /' > ~/tmp/tis-620 | 495 | // $ for A in 8 9 A B C D E F ; do for B in 0 1 2 3 4 5 6 7 8 9 A B C D E F ; do echo x${A}${B} 0xFFFD ; done ; done > /tmp/digits ; ( cut -c25- < TIS-620 ; cat /tmp/digits ) | awk '/^x[89ABCDEF]/{ print $1, $2 }' | sed -e 's/<U/0x/' -e 's/>//' | sort | uniq -w4 | cut -c5- | paste '-d ' - - - - - - - - | sed -e 's/ /, /g' -e 's/$/,/' -e '$ s/,$/} },/' -e '1 s/^/{ /' > ~/tmp/tis-620 |
497 | { "TIS-620", "ISO 8859-11", 2259, // Thai character set mib enum taken from tis620 (which is byte by byte equivalent) | 496 | { "TIS-620", "ISO 8859-11", 2259, // Thai character set mib enum taken from tis620 (which is byte by byte equivalent) |
498 | { 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 497 | { 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
499 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 498 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
500 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 499 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
501 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, | 500 | 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, |
502 | 0xFFFD, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07, | 501 | 0xFFFD, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07, |
503 | 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F, | 502 | 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F, |
504 | 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17, | 503 | 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17, |
505 | 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F, | 504 | 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F, |
506 | 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27, | 505 | 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27, |
507 | 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F, | 506 | 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F, |
508 | 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37, | 507 | 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37, |
509 | 0x0E38, 0x0E39, 0x0E3A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x0E3F, | 508 | 0x0E38, 0x0E39, 0x0E3A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x0E3F, |
510 | 0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47, | 509 | 0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47, |
511 | 0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F, | 510 | 0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F, |
512 | 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57, | 511 | 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57, |
513 | 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} }, | 512 | 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} }, |
514 | 513 | ||
515 | // if you add more chacater sets at the end, change LAST_MIB above | 514 | // if you add more chacater sets at the end, change LAST_MIB above |
516 | }; | 515 | }; |
517 | 516 | ||
518 | const unicodetable& unicodetable::iterator::operator*() | 517 | const unicodetable& unicodetable::iterator::operator*() |
519 | { | 518 | { |
520 | return unicodevalues[offset]; | 519 | return unicodevalues[offset]; |
521 | } | 520 | } |
522 | 521 | ||
523 | const unicodetable* unicodetable::iterator::operator->() | 522 | const unicodetable* unicodetable::iterator::operator->() |
524 | { | 523 | { |
525 | return unicodevalues+offset; | 524 | return unicodevalues+offset; |
526 | } | 525 | } |
527 | 526 | ||
528 | unsigned short unicodetable::unicodevalue(int offset, unsigned short c) | 527 | unsigned short unicodetable::unicodevalue(int offset, unsigned short c) |
529 | { | 528 | { |
530 | if (c > 127 && c < 256) | 529 | if (c > 127 && c < 256) |
531 | return unicodevalues[offset].values[c-128]; | 530 | return unicodevalues[offset].values[c-128]; |
532 | else | 531 | else |
533 | return c; | 532 | return c; |
534 | } | 533 | } |
diff --git a/noncore/apps/opie-reader/CFilter.cpp b/noncore/apps/opie-reader/CFilter.cpp index 73a0872..0422ba6 100644 --- a/noncore/apps/opie-reader/CFilter.cpp +++ b/noncore/apps/opie-reader/CFilter.cpp | |||
@@ -1,742 +1,741 @@ | |||
1 | #include "CDrawBuffer.h" | ||
2 | #include "CFilter.h" | 1 | #include "CFilter.h" |
3 | 2 | ||
4 | unsigned short striphtml::skip_ws() | 3 | unsigned short striphtml::skip_ws() |
5 | { | 4 | { |
6 | tchar ch; | 5 | tchar ch; |
7 | CStyle sty; | 6 | CStyle sty; |
8 | do | 7 | do |
9 | { | 8 | { |
10 | parent->getch(ch, sty); | 9 | parent->getch(ch, sty); |
11 | } | 10 | } |
12 | while (ch < 33); | 11 | while (ch < 33); |
13 | return ch; | 12 | return ch; |
14 | } | 13 | } |
15 | 14 | ||
16 | unsigned short striphtml::skip_ws_end() | 15 | unsigned short striphtml::skip_ws_end() |
17 | { | 16 | { |
18 | tchar ch; | 17 | tchar ch; |
19 | CStyle sty; | 18 | CStyle sty; |
20 | parent->getch(ch, sty); | 19 | parent->getch(ch, sty); |
21 | if (ch == ' ') | 20 | if (ch == ' ') |
22 | { | 21 | { |
23 | do | 22 | do |
24 | { | 23 | { |
25 | parent->getch(ch, sty); | 24 | parent->getch(ch, sty); |
26 | } | 25 | } |
27 | while (ch != '>'); | 26 | while (ch != '>'); |
28 | } | 27 | } |
29 | return ch; | 28 | return ch; |
30 | } | 29 | } |
31 | 30 | ||
32 | unsigned short striphtml::parse_m() | 31 | unsigned short striphtml::parse_m() |
33 | { | 32 | { |
34 | tchar ch; | 33 | tchar ch; |
35 | CStyle sty; | 34 | CStyle sty; |
36 | parent->getch(ch, sty); | 35 | parent->getch(ch, sty); |
37 | if (ch == 'm' || ch == 'M') | 36 | if (ch == 'm' || ch == 'M') |
38 | { | 37 | { |
39 | ch = skip_ws_end(); | 38 | ch = skip_ws_end(); |
40 | if (ch == '>') | 39 | if (ch == '>') |
41 | { | 40 | { |
42 | return 0; | 41 | return 0; |
43 | } | 42 | } |
44 | } | 43 | } |
45 | return ch; | 44 | return ch; |
46 | } | 45 | } |
47 | 46 | ||
48 | void striphtml::mygetch(tchar& ch, CStyle& sty) | 47 | void striphtml::mygetch(tchar& ch, CStyle& sty) |
49 | { | 48 | { |
50 | parent->getch(ch, sty); | 49 | parent->getch(ch, sty); |
51 | if (ch == 10) ch = ' '; | 50 | if (ch == 10) ch = ' '; |
52 | } | 51 | } |
53 | 52 | ||
54 | void striphtml::getch(tchar& ch, CStyle& sty) | 53 | void striphtml::getch(tchar& ch, CStyle& sty) |
55 | { | 54 | { |
56 | CStyle dummy; | 55 | CStyle dummy; |
57 | mygetch(ch, dummy); | 56 | mygetch(ch, dummy); |
58 | if (ch == 10) ch = ' '; | 57 | if (ch == 10) ch = ' '; |
59 | while (ch == '<') | 58 | while (ch == '<') |
60 | { | 59 | { |
61 | ch = skip_ws(); | 60 | ch = skip_ws(); |
62 | 61 | ||
63 | switch (ch) | 62 | switch (ch) |
64 | { | 63 | { |
65 | case 'p': | 64 | case 'p': |
66 | case 'P': | 65 | case 'P': |
67 | ch = skip_ws_end(); | 66 | ch = skip_ws_end(); |
68 | if (ch == '>') | 67 | if (ch == '>') |
69 | { | 68 | { |
70 | ch = 10; | 69 | ch = 10; |
71 | continue; | 70 | continue; |
72 | } | 71 | } |
73 | break; | 72 | break; |
74 | case 'b': | 73 | case 'b': |
75 | case 'B': | 74 | case 'B': |
76 | ch = skip_ws_end(); | 75 | ch = skip_ws_end(); |
77 | if (ch == '>') | 76 | if (ch == '>') |
78 | { | 77 | { |
79 | currentstyle.setBold(); | 78 | currentstyle.setBold(); |
80 | mygetch(ch, dummy); | 79 | mygetch(ch, dummy); |
81 | continue; | 80 | continue; |
82 | } | 81 | } |
83 | else if (ch == 'r' || ch == 'R') | 82 | else if (ch == 'r' || ch == 'R') |
84 | { | 83 | { |
85 | ch = skip_ws_end(); | 84 | ch = skip_ws_end(); |
86 | if (ch == '>') | 85 | if (ch == '>') |
87 | { | 86 | { |
88 | ch = 10; | 87 | ch = 10; |
89 | continue; | 88 | continue; |
90 | } | 89 | } |
91 | } | 90 | } |
92 | break; | 91 | break; |
93 | case 'i': | 92 | case 'i': |
94 | case 'I': | 93 | case 'I': |
95 | ch = skip_ws_end(); | 94 | ch = skip_ws_end(); |
96 | if (ch == '>') | 95 | if (ch == '>') |
97 | { | 96 | { |
98 | currentstyle.setItalic(); | 97 | currentstyle.setItalic(); |
99 | mygetch(ch, dummy); | 98 | mygetch(ch, dummy); |
100 | continue; | 99 | continue; |
101 | } | 100 | } |
102 | break; | 101 | break; |
103 | case 'e': | 102 | case 'e': |
104 | case 'E': | 103 | case 'E': |
105 | if ((ch = parse_m()) == 0) | 104 | if ((ch = parse_m()) == 0) |
106 | { | 105 | { |
107 | currentstyle.setItalic(); | 106 | currentstyle.setItalic(); |
108 | mygetch(ch, dummy); | 107 | mygetch(ch, dummy); |
109 | continue; | 108 | continue; |
110 | } | 109 | } |
111 | break; | 110 | break; |
112 | case 'h': | 111 | case 'h': |
113 | case 'H': | 112 | case 'H': |
114 | mygetch(ch, dummy); | 113 | mygetch(ch, dummy); |
115 | if ('0' < ch && ch <= '9') | 114 | if ('0' < ch && ch <= '9') |
116 | { | 115 | { |
117 | tchar hs = ch; | 116 | tchar hs = ch; |
118 | ch = skip_ws_end(); | 117 | ch = skip_ws_end(); |
119 | if (ch == '>') | 118 | if (ch == '>') |
120 | { | 119 | { |
121 | switch (hs) | 120 | switch (hs) |
122 | { | 121 | { |
123 | case '1': | 122 | case '1': |
124 | // currentstyle = ucBold | ucFontBase+2 | (ucAlignCentre << ucAlignShift); | 123 | // currentstyle = ucBold | ucFontBase+2 | (ucAlignCentre << ucAlignShift); |
125 | currentstyle.unset(); | 124 | currentstyle.unset(); |
126 | currentstyle.setFontSize(2); | 125 | currentstyle.setFontSize(2); |
127 | currentstyle.setBold(); | 126 | currentstyle.setBold(); |
128 | currentstyle.setCentreJustify(); | 127 | currentstyle.setCentreJustify(); |
129 | break; | 128 | break; |
130 | case '2': | 129 | case '2': |
131 | // currentstyle = ucBold | ucFontBase+1; | 130 | // currentstyle = ucBold | ucFontBase+1; |
132 | currentstyle.unset(); | 131 | currentstyle.unset(); |
133 | currentstyle.setFontSize(1); | 132 | currentstyle.setFontSize(1); |
134 | currentstyle.setBold(); | 133 | currentstyle.setBold(); |
135 | break; | 134 | break; |
136 | default: | 135 | default: |
137 | // currentstyle = ucBold | ucFontBase; | 136 | // currentstyle = ucBold | ucFontBase; |
138 | currentstyle.unset(); | 137 | currentstyle.unset(); |
139 | currentstyle.setBold(); | 138 | currentstyle.setBold(); |
140 | } | 139 | } |
141 | ch = 10; | 140 | ch = 10; |
142 | // mygetch(ch, dummy); | 141 | // mygetch(ch, dummy); |
143 | continue; | 142 | continue; |
144 | } | 143 | } |
145 | } | 144 | } |
146 | break; | 145 | break; |
147 | case '/': | 146 | case '/': |
148 | mygetch(ch, dummy); | 147 | mygetch(ch, dummy); |
149 | switch (ch) | 148 | switch (ch) |
150 | { | 149 | { |
151 | case 'b': | 150 | case 'b': |
152 | case 'B': | 151 | case 'B': |
153 | ch = skip_ws_end(); | 152 | ch = skip_ws_end(); |
154 | if (ch == '>') | 153 | if (ch == '>') |
155 | { | 154 | { |
156 | currentstyle.unsetBold(); | 155 | currentstyle.unsetBold(); |
157 | mygetch(ch, dummy); | 156 | mygetch(ch, dummy); |
158 | continue; | 157 | continue; |
159 | } | 158 | } |
160 | break; | 159 | break; |
161 | case 'i': | 160 | case 'i': |
162 | case 'I': | 161 | case 'I': |
163 | ch = skip_ws_end(); | 162 | ch = skip_ws_end(); |
164 | if (ch == '>') | 163 | if (ch == '>') |
165 | { | 164 | { |
166 | currentstyle.unsetItalic(); | 165 | currentstyle.unsetItalic(); |
167 | mygetch(ch, dummy); | 166 | mygetch(ch, dummy); |
168 | continue; | 167 | continue; |
169 | } | 168 | } |
170 | break; | 169 | break; |
171 | case 'e': | 170 | case 'e': |
172 | case 'E': | 171 | case 'E': |
173 | if ((ch = parse_m()) == 0) | 172 | if ((ch = parse_m()) == 0) |
174 | { | 173 | { |
175 | currentstyle.unsetItalic(); | 174 | currentstyle.unsetItalic(); |
176 | mygetch(ch, dummy); | 175 | mygetch(ch, dummy); |
177 | continue; | 176 | continue; |
178 | } | 177 | } |
179 | break; | 178 | break; |
180 | case 'h': | 179 | case 'h': |
181 | case 'H': | 180 | case 'H': |
182 | mygetch(ch, dummy); | 181 | mygetch(ch, dummy); |
183 | if ('0' < ch && ch <= '9') | 182 | if ('0' < ch && ch <= '9') |
184 | { | 183 | { |
185 | ch = skip_ws_end(); | 184 | ch = skip_ws_end(); |
186 | if (ch == '>') | 185 | if (ch == '>') |
187 | { | 186 | { |
188 | currentstyle.unset(); | 187 | currentstyle.unset(); |
189 | //mygetch(ch, dummy); | 188 | //mygetch(ch, dummy); |
190 | ch = 10; | 189 | ch = 10; |
191 | continue; | 190 | continue; |
192 | } | 191 | } |
193 | } | 192 | } |
194 | break; | 193 | break; |
195 | default: | 194 | default: |
196 | break; | 195 | break; |
197 | } | 196 | } |
198 | break; | 197 | break; |
199 | default: | 198 | default: |
200 | break; | 199 | break; |
201 | } | 200 | } |
202 | while (ch != '>' && ch != UEOF) | 201 | while (ch != '>' && ch != UEOF) |
203 | { | 202 | { |
204 | mygetch(ch, dummy); | 203 | mygetch(ch, dummy); |
205 | } | 204 | } |
206 | mygetch(ch, dummy); | 205 | mygetch(ch, dummy); |
207 | } | 206 | } |
208 | if (ch == '&') | 207 | if (ch == '&') |
209 | { | 208 | { |
210 | mygetch(ch, dummy); | 209 | mygetch(ch, dummy); |
211 | if (ch == '#') | 210 | if (ch == '#') |
212 | { | 211 | { |
213 | int id = 0; | 212 | int id = 0; |
214 | mygetch(ch, dummy); | 213 | mygetch(ch, dummy); |
215 | while (ch != ';' && ch != UEOF) | 214 | while (ch != ';' && ch != UEOF) |
216 | { | 215 | { |
217 | id = 10*id+ch-'0'; | 216 | id = 10*id+ch-'0'; |
218 | mygetch(ch, dummy); | 217 | mygetch(ch, dummy); |
219 | } | 218 | } |
220 | ch = id; | 219 | ch = id; |
221 | } | 220 | } |
222 | } | 221 | } |
223 | // sty = (dummy == ucFontBase) ? currentstyle : dummy; | 222 | // sty = (dummy == ucFontBase) ? currentstyle : dummy; |
224 | sty = currentstyle; | 223 | sty = currentstyle; |
225 | return; | 224 | return; |
226 | } | 225 | } |
227 | 226 | ||
228 | 227 | ||
229 | void textfmt::mygetch(tchar& ch, CStyle& sty) | 228 | void textfmt::mygetch(tchar& ch, CStyle& sty) |
230 | { | 229 | { |
231 | if (uselast) | 230 | if (uselast) |
232 | { | 231 | { |
233 | ch = lastchar; | 232 | ch = lastchar; |
234 | uselast = false; | 233 | uselast = false; |
235 | } | 234 | } |
236 | else | 235 | else |
237 | { | 236 | { |
238 | parent->getch(ch, sty); | 237 | parent->getch(ch, sty); |
239 | } | 238 | } |
240 | } | 239 | } |
241 | 240 | ||
242 | void textfmt::getch(tchar& ch, CStyle& sty) | 241 | void textfmt::getch(tchar& ch, CStyle& sty) |
243 | { | 242 | { |
244 | mygetch(ch, sty); | 243 | mygetch(ch, sty); |
245 | do | 244 | do |
246 | { | 245 | { |
247 | sty = currentstyle; | 246 | sty = currentstyle; |
248 | switch (ch) | 247 | switch (ch) |
249 | { | 248 | { |
250 | case 10: | 249 | case 10: |
251 | currentstyle.unset(); | 250 | currentstyle.unset(); |
252 | sty = currentstyle; | 251 | sty = currentstyle; |
253 | break; | 252 | break; |
254 | // Use this if you want to replace -- by em-dash | 253 | // Use this if you want to replace -- by em-dash |
255 | case '-': | 254 | case '-': |
256 | // parent->getch(ch, sty); | 255 | // parent->getch(ch, sty); |
257 | mygetch(ch, sty); | 256 | mygetch(ch, sty); |
258 | if (ch == '-') | 257 | if (ch == '-') |
259 | { | 258 | { |
260 | ch = 0x2014; | 259 | ch = 0x2014; |
261 | } | 260 | } |
262 | else | 261 | else |
263 | { | 262 | { |
264 | lastchar = ch; | 263 | lastchar = ch; |
265 | uselast = true; | 264 | uselast = true; |
266 | ch = '-'; | 265 | ch = '-'; |
267 | } | 266 | } |
268 | break; | 267 | break; |
269 | case '*': | 268 | case '*': |
270 | if (currentstyle.isBold()) | 269 | if (currentstyle.isBold()) |
271 | { | 270 | { |
272 | // Already bold - time to turn it off? | 271 | // Already bold - time to turn it off? |
273 | // The next two lines ensure that * follows a character but it works better without | 272 | // The next two lines ensure that * follows a character but it works better without |
274 | // QChar c(lastchar); | 273 | // QChar c(lastchar); |
275 | // if ((lastchar != '*') && (c.isPunct() || c.isLetterOrNumber())) | 274 | // if ((lastchar != '*') && (c.isPunct() || c.isLetterOrNumber())) |
276 | if (lastchar != '*') | 275 | if (lastchar != '*') |
277 | { | 276 | { |
278 | currentstyle.unsetBold(); | 277 | currentstyle.unsetBold(); |
279 | CStyle dummy; | 278 | CStyle dummy; |
280 | // parent->getch(ch, dummy); | 279 | // parent->getch(ch, dummy); |
281 | mygetch(ch, dummy); | 280 | mygetch(ch, dummy); |
282 | } | 281 | } |
283 | } | 282 | } |
284 | else | 283 | else |
285 | { | 284 | { |
286 | // not bold - time to turn it on? | 285 | // not bold - time to turn it on? |
287 | CStyle dummy; | 286 | CStyle dummy; |
288 | // parent->getch(ch, dummy); | 287 | // parent->getch(ch, dummy); |
289 | mygetch(ch, dummy); | 288 | mygetch(ch, dummy); |
290 | QChar c(ch); | 289 | QChar c(ch); |
291 | if ((ch != '*') && (c.isPunct() || c.isLetterOrNumber())) | 290 | if ((ch != '*') && (c.isPunct() || c.isLetterOrNumber())) |
292 | { | 291 | { |
293 | currentstyle.setBold(); | 292 | currentstyle.setBold(); |
294 | } | 293 | } |
295 | else | 294 | else |
296 | { | 295 | { |
297 | lastchar = ch; | 296 | lastchar = ch; |
298 | uselast = true; | 297 | uselast = true; |
299 | ch = '*'; | 298 | ch = '*'; |
300 | } | 299 | } |
301 | 300 | ||
302 | } | 301 | } |
303 | break; | 302 | break; |
304 | case '_': | 303 | case '_': |
305 | if (currentstyle.isItalic()) | 304 | if (currentstyle.isItalic()) |
306 | { | 305 | { |
307 | // Already bold - time to turn it off? | 306 | // Already bold - time to turn it off? |
308 | // The next two lines ensure that * follows a character but it works better without | 307 | // The next two lines ensure that * follows a character but it works better without |
309 | // QChar c(lastchar); | 308 | // QChar c(lastchar); |
310 | // if ((lastchar != '_') && (c.isPunct() || c.isLetterOrNumber())) | 309 | // if ((lastchar != '_') && (c.isPunct() || c.isLetterOrNumber())) |
311 | if (lastchar != '_') | 310 | if (lastchar != '_') |
312 | { | 311 | { |
313 | currentstyle.unsetItalic(); | 312 | currentstyle.unsetItalic(); |
314 | CStyle dummy; | 313 | CStyle dummy; |
315 | // parent->getch(ch, dummy); | 314 | // parent->getch(ch, dummy); |
316 | mygetch(ch, dummy); | 315 | mygetch(ch, dummy); |
317 | } | 316 | } |
318 | } | 317 | } |
319 | else | 318 | else |
320 | { | 319 | { |
321 | // not bold - time to turn it on? | 320 | // not bold - time to turn it on? |
322 | CStyle dummy; | 321 | CStyle dummy; |
323 | // parent->getch(ch, dummy); | 322 | // parent->getch(ch, dummy); |
324 | mygetch(ch, dummy); | 323 | mygetch(ch, dummy); |
325 | QChar c(ch); | 324 | QChar c(ch); |
326 | if ((ch != '_') && (c.isPunct() || c.isLetterOrNumber())) | 325 | if ((ch != '_') && (c.isPunct() || c.isLetterOrNumber())) |
327 | { | 326 | { |
328 | currentstyle.setItalic(); | 327 | currentstyle.setItalic(); |
329 | } | 328 | } |
330 | else | 329 | else |
331 | { | 330 | { |
332 | lastchar = ch; | 331 | lastchar = ch; |
333 | uselast = true; | 332 | uselast = true; |
334 | ch = '_'; | 333 | ch = '_'; |
335 | } | 334 | } |
336 | 335 | ||
337 | } | 336 | } |
338 | break; | 337 | break; |
339 | } | 338 | } |
340 | } | 339 | } |
341 | while (sty != currentstyle); | 340 | while (sty != currentstyle); |
342 | if (!uselast) lastchar = ch; | 341 | if (!uselast) lastchar = ch; |
343 | return; | 342 | return; |
344 | } | 343 | } |
345 | 344 | ||
346 | void remap::getch(tchar& ch, CStyle& sty) | 345 | void remap::getch(tchar& ch, CStyle& sty) |
347 | { | 346 | { |
348 | if (q[offset] != 0) | 347 | if (q[offset] != 0) |
349 | { | 348 | { |
350 | q[offset++]; | 349 | q[offset++]; |
351 | sty = currentstyle; | 350 | sty = currentstyle; |
352 | return; | 351 | return; |
353 | } | 352 | } |
354 | parent->getch(ch, sty); | 353 | parent->getch(ch, sty); |
355 | switch (ch) | 354 | switch (ch) |
356 | { | 355 | { |
357 | case 0x201a: | 356 | case 0x201a: |
358 | ch = '\''; | 357 | ch = '\''; |
359 | break; | 358 | break; |
360 | case 0x0192: | 359 | case 0x0192: |
361 | ch = 'f'; | 360 | ch = 'f'; |
362 | break; | 361 | break; |
363 | case 0x201e: | 362 | case 0x201e: |
364 | ch = '"'; | 363 | ch = '"'; |
365 | break; | 364 | break; |
366 | case 0x2026: | 365 | case 0x2026: |
367 | offset = 0; | 366 | offset = 0; |
368 | q[0] = '.'; | 367 | q[0] = '.'; |
369 | q[1] = '.'; | 368 | q[1] = '.'; |
370 | q[2] = 0; | 369 | q[2] = 0; |
371 | ch = '.'; // should be ... | 370 | ch = '.'; // should be ... |
372 | break; | 371 | break; |
373 | case 0x0160: | 372 | case 0x0160: |
374 | ch = 'S'; | 373 | ch = 'S'; |
375 | break; | 374 | break; |
376 | case 0x2039: | 375 | case 0x2039: |
377 | ch = '<'; | 376 | ch = '<'; |
378 | break; | 377 | break; |
379 | case 0x0152: | 378 | case 0x0152: |
380 | offset = 0; | 379 | offset = 0; |
381 | q[0] = 'E'; | 380 | q[0] = 'E'; |
382 | q[1] = 0; | 381 | q[1] = 0; |
383 | ch = 'O'; | 382 | ch = 'O'; |
384 | break; | 383 | break; |
385 | case 0x017d: | 384 | case 0x017d: |
386 | ch = 'Z'; | 385 | ch = 'Z'; |
387 | break; | 386 | break; |
388 | case 0x2018: | 387 | case 0x2018: |
389 | ch = '\''; | 388 | ch = '\''; |
390 | break; | 389 | break; |
391 | case 0x2019: | 390 | case 0x2019: |
392 | ch = '\''; | 391 | ch = '\''; |
393 | break; | 392 | break; |
394 | case 0x201c: | 393 | case 0x201c: |
395 | ch = '"'; | 394 | ch = '"'; |
396 | break; | 395 | break; |
397 | case 0x201d: | 396 | case 0x201d: |
398 | ch = '"'; | 397 | ch = '"'; |
399 | break; | 398 | break; |
400 | case 0x2022: | 399 | case 0x2022: |
401 | ch = '>'; | 400 | ch = '>'; |
402 | break; | 401 | break; |
403 | case 0x2013: | 402 | case 0x2013: |
404 | ch = '-'; | 403 | ch = '-'; |
405 | break; | 404 | break; |
406 | case 0x2014: | 405 | case 0x2014: |
407 | offset = 0; | 406 | offset = 0; |
408 | q[0] = '-'; | 407 | q[0] = '-'; |
409 | q[1] = 0; | 408 | q[1] = 0; |
410 | ch = '-'; // should be -- | 409 | ch = '-'; // should be -- |
411 | break; | 410 | break; |
412 | case 0x02dc: | 411 | case 0x02dc: |
413 | ch = '~'; | 412 | ch = '~'; |
414 | break; | 413 | break; |
415 | case 0x0161: | 414 | case 0x0161: |
416 | ch = 's'; | 415 | ch = 's'; |
417 | break; | 416 | break; |
418 | case 0x203a: | 417 | case 0x203a: |
419 | ch = '>'; | 418 | ch = '>'; |
420 | break; | 419 | break; |
421 | case 0x0153: | 420 | case 0x0153: |
422 | offset = 0; | 421 | offset = 0; |
423 | q[0] = 'e'; | 422 | q[0] = 'e'; |
424 | q[1] = 0; | 423 | q[1] = 0; |
425 | ch = 'o';// should be oe | 424 | ch = 'o';// should be oe |
426 | break; | 425 | break; |
427 | case 0x017e: | 426 | case 0x017e: |
428 | ch = 'z'; | 427 | ch = 'z'; |
429 | break; | 428 | break; |
430 | case 0x0178: | 429 | case 0x0178: |
431 | ch = 'Y'; | 430 | ch = 'Y'; |
432 | break; | 431 | break; |
433 | } | 432 | } |
434 | currentstyle = sty; | 433 | currentstyle = sty; |
435 | } | 434 | } |
436 | 435 | ||
437 | void PeanutFormatter::getch(tchar& ch, CStyle& sty) | 436 | void PeanutFormatter::getch(tchar& ch, CStyle& sty) |
438 | { | 437 | { |
439 | CStyle dummy; | 438 | CStyle dummy; |
440 | currentstyle.setColour(0,0,0); | 439 | currentstyle.setColour(0,0,0); |
441 | parent->getch(ch, dummy); | 440 | parent->getch(ch, dummy); |
442 | while (ch == '\\') | 441 | while (ch == '\\') |
443 | { | 442 | { |
444 | parent->getch(ch, dummy); | 443 | parent->getch(ch, dummy); |
445 | if (ch == '\\') break; | 444 | if (ch == '\\') break; |
446 | switch(ch) | 445 | switch(ch) |
447 | { | 446 | { |
448 | case 'a': | 447 | case 'a': |
449 | { | 448 | { |
450 | int code = 0; | 449 | int code = 0; |
451 | for (int i = 0; i < 3; i++) | 450 | for (int i = 0; i < 3; i++) |
452 | { | 451 | { |
453 | parent->getch(ch, dummy); | 452 | parent->getch(ch, dummy); |
454 | code = 10*code + ch - '0'; | 453 | code = 10*code + ch - '0'; |
455 | } | 454 | } |
456 | ch = code; | 455 | ch = code; |
457 | } | 456 | } |
458 | break; | 457 | break; |
459 | case 'v': | 458 | case 'v': |
460 | { | 459 | { |
461 | while (1) | 460 | while (1) |
462 | { | 461 | { |
463 | parent->getch(ch, dummy); | 462 | parent->getch(ch, dummy); |
464 | if (ch == '\\') | 463 | if (ch == '\\') |
465 | { | 464 | { |
466 | parent->getch(ch, dummy); | 465 | parent->getch(ch, dummy); |
467 | if (ch == 'v') | 466 | if (ch == 'v') |
468 | { | 467 | { |
469 | parent->getch(ch, dummy); | 468 | parent->getch(ch, dummy); |
470 | break; | 469 | break; |
471 | } | 470 | } |
472 | } | 471 | } |
473 | } | 472 | } |
474 | } | 473 | } |
475 | break; | 474 | break; |
476 | case 's': | 475 | case 's': |
477 | case 'n': | 476 | case 'n': |
478 | currentstyle.setFontSize(0); | 477 | currentstyle.setFontSize(0); |
479 | parent->getch(ch,dummy); | 478 | parent->getch(ch,dummy); |
480 | break; | 479 | break; |
481 | case 'p': | 480 | case 'p': |
482 | currentstyle.unset(); | 481 | currentstyle.unset(); |
483 | // parent->getch(ch,dummy); | 482 | // parent->getch(ch,dummy); |
484 | ch = 10; | 483 | ch = 10; |
485 | break; | 484 | break; |
486 | case 'l': | 485 | case 'l': |
487 | if (currentstyle.getFontSize() == 1) | 486 | if (currentstyle.getFontSize() == 1) |
488 | { | 487 | { |
489 | currentstyle.setFontSize(0); | 488 | currentstyle.setFontSize(0); |
490 | } | 489 | } |
491 | else | 490 | else |
492 | { | 491 | { |
493 | currentstyle.setFontSize(1); | 492 | currentstyle.setFontSize(1); |
494 | } | 493 | } |
495 | parent->getch(ch, dummy); | 494 | parent->getch(ch, dummy); |
496 | break; | 495 | break; |
497 | case 'x': | 496 | case 'x': |
498 | if (currentstyle.getFontSize() == 0) | 497 | if (currentstyle.getFontSize() == 0) |
499 | { | 498 | { |
500 | // currentstyle.unset(); | 499 | // currentstyle.unset(); |
501 | // currentstyle.setBold(); | 500 | // currentstyle.setBold(); |
502 | currentstyle.setFontSize(1); | 501 | currentstyle.setFontSize(1); |
503 | } | 502 | } |
504 | else | 503 | else |
505 | { | 504 | { |
506 | currentstyle.unset(); | 505 | currentstyle.unset(); |
507 | } | 506 | } |
508 | // parent->getch(ch, dummy); | 507 | // parent->getch(ch, dummy); |
509 | ch = 10; | 508 | ch = 10; |
510 | break; | 509 | break; |
511 | case 'i': | 510 | case 'i': |
512 | if (currentstyle.isItalic()) | 511 | if (currentstyle.isItalic()) |
513 | { | 512 | { |
514 | currentstyle.unsetItalic(); | 513 | currentstyle.unsetItalic(); |
515 | } | 514 | } |
516 | else | 515 | else |
517 | { | 516 | { |
518 | currentstyle.setItalic(); | 517 | currentstyle.setItalic(); |
519 | } | 518 | } |
520 | parent->getch(ch, dummy); | 519 | parent->getch(ch, dummy); |
521 | break; | 520 | break; |
522 | case 'b': | 521 | case 'b': |
523 | case 'B': | 522 | case 'B': |
524 | if (currentstyle.isBold()) | 523 | if (currentstyle.isBold()) |
525 | { | 524 | { |
526 | currentstyle.unsetBold(); | 525 | currentstyle.unsetBold(); |
527 | } | 526 | } |
528 | else | 527 | else |
529 | { | 528 | { |
530 | currentstyle.setBold(); | 529 | currentstyle.setBold(); |
531 | } | 530 | } |
532 | parent->getch(ch, dummy); | 531 | parent->getch(ch, dummy); |
533 | break; | 532 | break; |
534 | case 'c': | 533 | case 'c': |
535 | if (currentstyle.getJustify() == m_AlignCentre) | 534 | if (currentstyle.getJustify() == m_AlignCentre) |
536 | { | 535 | { |
537 | currentstyle.setLeftJustify(); | 536 | currentstyle.setLeftJustify(); |
538 | } | 537 | } |
539 | else | 538 | else |
540 | { | 539 | { |
541 | currentstyle.setCentreJustify(); | 540 | currentstyle.setCentreJustify(); |
542 | } | 541 | } |
543 | parent->getch(ch, dummy); | 542 | parent->getch(ch, dummy); |
544 | break; | 543 | break; |
545 | case 'r': | 544 | case 'r': |
546 | if (currentstyle.getJustify() == m_AlignRight) | 545 | if (currentstyle.getJustify() == m_AlignRight) |
547 | { | 546 | { |
548 | currentstyle.setLeftJustify(); | 547 | currentstyle.setLeftJustify(); |
549 | } | 548 | } |
550 | else | 549 | else |
551 | { | 550 | { |
552 | currentstyle.setRightJustify(); | 551 | currentstyle.setRightJustify(); |
553 | } | 552 | } |
554 | parent->getch(ch, dummy); | 553 | parent->getch(ch, dummy); |
555 | break; | 554 | break; |
556 | default: | 555 | default: |
557 | currentstyle.setColour(255,0,0); | 556 | currentstyle.setColour(255,0,0); |
558 | } | 557 | } |
559 | } | 558 | } |
560 | sty = currentstyle; | 559 | sty = currentstyle; |
561 | } | 560 | } |
562 | 561 | ||
563 | void OnePara::getch(tchar& ch, CStyle& sty) | 562 | void OnePara::getch(tchar& ch, CStyle& sty) |
564 | { | 563 | { |
565 | parent->getch(ch, sty); | 564 | parent->getch(ch, sty); |
566 | if (m_lastchar == 10) | 565 | if (m_lastchar == 10) |
567 | { | 566 | { |
568 | while (ch == 10) parent->getch(ch, sty); | 567 | while (ch == 10) parent->getch(ch, sty); |
569 | } | 568 | } |
570 | m_lastchar = ch; | 569 | m_lastchar = ch; |
571 | } | 570 | } |
572 | 571 | ||
573 | #ifdef REPALM | 572 | #ifdef REPALM |
574 | void repalm::getch(tchar& ch, CStyle& sty) | 573 | void repalm::getch(tchar& ch, CStyle& sty) |
575 | { | 574 | { |
576 | parent->getch(ch, sty); | 575 | parent->getch(ch, sty); |
577 | switch (ch) | 576 | switch (ch) |
578 | { | 577 | { |
579 | case 0x80: | 578 | case 0x80: |
580 | ch = 0x20ac; | 579 | ch = 0x20ac; |
581 | break; | 580 | break; |
582 | case 0x82: | 581 | case 0x82: |
583 | ch = 0x201a; | 582 | ch = 0x201a; |
584 | break; | 583 | break; |
585 | case 0x83: | 584 | case 0x83: |
586 | ch = 0x0192; | 585 | ch = 0x0192; |
587 | break; | 586 | break; |
588 | case 0x84: | 587 | case 0x84: |
589 | ch = 0x201e; | 588 | ch = 0x201e; |
590 | break; | 589 | break; |
591 | case 0x85: | 590 | case 0x85: |
592 | ch = 0x2026; | 591 | ch = 0x2026; |
593 | break; | 592 | break; |
594 | case 0x86: | 593 | case 0x86: |
595 | ch = 0x2020; | 594 | ch = 0x2020; |
596 | break; | 595 | break; |
597 | case 0x87: | 596 | case 0x87: |
598 | ch = 0x2021; | 597 | ch = 0x2021; |
599 | break; | 598 | break; |
600 | case 0x88: | 599 | case 0x88: |
601 | ch = 0x02c6; | 600 | ch = 0x02c6; |
602 | break; | 601 | break; |
603 | case 0x89: | 602 | case 0x89: |
604 | ch = 0x2030; | 603 | ch = 0x2030; |
605 | break; | 604 | break; |
606 | case 0x8a: | 605 | case 0x8a: |
607 | ch = 0x0160; | 606 | ch = 0x0160; |
608 | break; | 607 | break; |
609 | case 0x8b: | 608 | case 0x8b: |
610 | ch = 0x2039; | 609 | ch = 0x2039; |
611 | break; | 610 | break; |
612 | case 0x8c: | 611 | case 0x8c: |
613 | ch = 0x0152; | 612 | ch = 0x0152; |
614 | break; | 613 | break; |
615 | /* | 614 | /* |
616 | case 0x8e: | 615 | case 0x8e: |
617 | ch = 0x017d; | 616 | ch = 0x017d; |
618 | break; | 617 | break; |
619 | */ | 618 | */ |
620 | case 0x91: | 619 | case 0x91: |
621 | ch = 0x2018; | 620 | ch = 0x2018; |
622 | break; | 621 | break; |
623 | case 0x92: | 622 | case 0x92: |
624 | ch = 0x2019; | 623 | ch = 0x2019; |
625 | break; | 624 | break; |
626 | case 0x93: | 625 | case 0x93: |
627 | ch = 0x201c; | 626 | ch = 0x201c; |
628 | break; | 627 | break; |
629 | case 0x94: | 628 | case 0x94: |
630 | ch = 0x201d; | 629 | ch = 0x201d; |
631 | break; | 630 | break; |
632 | case 0x95: | 631 | case 0x95: |
633 | ch = 0x2022; | 632 | ch = 0x2022; |
634 | break; | 633 | break; |
635 | case 0x96: | 634 | case 0x96: |
636 | ch = 0x2013; | 635 | ch = 0x2013; |
637 | break; | 636 | break; |
638 | case 0x97: | 637 | case 0x97: |
639 | ch = 0x2014; | 638 | ch = 0x2014; |
640 | break; | 639 | break; |
641 | case 0x98: | 640 | case 0x98: |
642 | ch = 0x02dc; | 641 | ch = 0x02dc; |
643 | break; | 642 | break; |
644 | case 0x99: | 643 | case 0x99: |
645 | ch = 0x2122; | 644 | ch = 0x2122; |
646 | break; | 645 | break; |
647 | case 0x9a: | 646 | case 0x9a: |
648 | ch = 0x0161; | 647 | ch = 0x0161; |
649 | break; | 648 | break; |
650 | case 0x9b: | 649 | case 0x9b: |
651 | ch = 0x203a; | 650 | ch = 0x203a; |
652 | break; | 651 | break; |
653 | case 0x9c: | 652 | case 0x9c: |
654 | ch = 0x0153; | 653 | ch = 0x0153; |
655 | break; | 654 | break; |
656 | case 0x9e: | 655 | case 0x9e: |
657 | ch = 0x017e; | 656 | ch = 0x017e; |
658 | break; | 657 | break; |
659 | case 0x9f: | 658 | case 0x9f: |
660 | ch = 0x0178; | 659 | ch = 0x0178; |
661 | break; | 660 | break; |
662 | case 0x18: | 661 | case 0x18: |
663 | ch = 0x2026; | 662 | ch = 0x2026; |
664 | break; | 663 | break; |
665 | case 0x19: | 664 | case 0x19: |
666 | ch = 0x2007; | 665 | ch = 0x2007; |
667 | break; | 666 | break; |
668 | case 0x8d: | 667 | case 0x8d: |
669 | ch = 0x2662; | 668 | ch = 0x2662; |
670 | break; | 669 | break; |
671 | case 0x8e: | 670 | case 0x8e: |
672 | ch = 0x2663; | 671 | ch = 0x2663; |
673 | break; | 672 | break; |
674 | case 0x8f: | 673 | case 0x8f: |
675 | ch = 0x2661; | 674 | ch = 0x2661; |
676 | break; | 675 | break; |
677 | case 0x90: | 676 | case 0x90: |
678 | ch = 0x2660; | 677 | ch = 0x2660; |
679 | break; | 678 | break; |
680 | default: | 679 | default: |
681 | break; | 680 | break; |
682 | } | 681 | } |
683 | } | 682 | } |
684 | #endif | 683 | #endif |
685 | 684 | ||
686 | //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 }; | 685 | //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 }; |
687 | //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 }; | 686 | //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 }; |
688 | 687 | ||
689 | void DePluck::getch(tchar& ch, CStyle& sty) | 688 | void DePluck::getch(tchar& ch, CStyle& sty) |
690 | { | 689 | { |
691 | if (m_buffed > 0) | 690 | if (m_buffed > 0) |
692 | { | 691 | { |
693 | sty = m_laststyle; | 692 | sty = m_laststyle; |
694 | ch = nextpart[m_current++]; | 693 | ch = nextpart[m_current++]; |
695 | if (m_current == m_buffed) | 694 | if (m_current == m_buffed) |
696 | { | 695 | { |
697 | m_current = m_buffed = 0; | 696 | m_current = m_buffed = 0; |
698 | } | 697 | } |
699 | } | 698 | } |
700 | else | 699 | else |
701 | { | 700 | { |
702 | if (m_buffer != 0) | 701 | if (m_buffer != 0) |
703 | { | 702 | { |
704 | ch = m_buffer; | 703 | ch = m_buffer; |
705 | m_buffer = 0; | 704 | m_buffer = 0; |
706 | return; | 705 | return; |
707 | } | 706 | } |
708 | unsigned long lnk; | 707 | unsigned long lnk; |
709 | do | 708 | do |
710 | { | 709 | { |
711 | if (nextpart[m_buffed] == 0) break; | 710 | if (nextpart[m_buffed] == 0) break; |
712 | parent->getch(ch, sty); | 711 | parent->getch(ch, sty); |
713 | m_laststyle = sty; | 712 | m_laststyle = sty; |
714 | if (sty.getLink()) lnk = sty.getData(); | 713 | if (sty.getLink()) lnk = sty.getData(); |
715 | } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed); | 714 | } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed); |
716 | m_current = 0; | 715 | m_current = 0; |
717 | if (nextpart[m_buffed] == 0) | 716 | if (nextpart[m_buffed] == 0) |
718 | { | 717 | { |
719 | m_buffed = 0; | 718 | m_buffed = 0; |
720 | QString dmy; | 719 | QString dmy; |
721 | parent->hyperlink(lnk, dmy); | 720 | parent->hyperlink(lnk, dmy); |
722 | do | 721 | do |
723 | { | 722 | { |
724 | parent->getch(ch, sty); | 723 | parent->getch(ch, sty); |
725 | } | 724 | } |
726 | while (ch != 10); | 725 | while (ch != 10); |
727 | parent->getch(ch, sty); | 726 | parent->getch(ch, sty); |
728 | } | 727 | } |
729 | else if (m_buffed > 0) | 728 | else if (m_buffed > 0) |
730 | { | 729 | { |
731 | m_buffer = ch; | 730 | m_buffer = ch; |
732 | ch = nextpart[0]; | 731 | ch = nextpart[0]; |
733 | if (m_buffed == 1) | 732 | if (m_buffed == 1) |
734 | { | 733 | { |
735 | m_buffed = 0; | 734 | m_buffed = 0; |
736 | } | 735 | } |
737 | else m_current = 1; | 736 | else m_current = 1; |
738 | } | 737 | } |
739 | } | 738 | } |
740 | 739 | ||
741 | return; | 740 | return; |
742 | } | 741 | } |
diff --git a/noncore/apps/opie-reader/FontControl.cpp b/noncore/apps/opie-reader/FontControl.cpp index e03bf64..cfa8534 100644 --- a/noncore/apps/opie-reader/FontControl.cpp +++ b/noncore/apps/opie-reader/FontControl.cpp | |||
@@ -1,60 +1,58 @@ | |||
1 | #include "opie.h" | ||
2 | #include "useqpe.h" | ||
3 | #include "FontControl.h" | 1 | #include "FontControl.h" |
4 | 2 | ||
5 | int FontControl::gzoom() | 3 | int FontControl::gzoom() |
6 | { | 4 | { |
7 | int ret; | 5 | int ret; |
8 | if (m_size == g_size) | 6 | if (m_size == g_size) |
9 | { | 7 | { |
10 | ret = m_fontsizes[m_size]*m_basesize; | 8 | ret = m_fontsizes[m_size]*m_basesize; |
11 | } | 9 | } |
12 | else if (g_size < 0) | 10 | else if (g_size < 0) |
13 | { | 11 | { |
14 | int f = -g_size; | 12 | int f = -g_size; |
15 | ret = (m_fontsizes[0]*m_basesize) >> (f/2); | 13 | ret = (m_fontsizes[0]*m_basesize) >> (f/2); |
16 | if (f%2) ret = (2*ret/3); | 14 | if (f%2) ret = (2*ret/3); |
17 | } | 15 | } |
18 | else | 16 | else |
19 | { | 17 | { |
20 | int f = g_size - m_maxsize + 1; | 18 | int f = g_size - m_maxsize + 1; |
21 | ret = (m_fontsizes[m_maxsize-1]*m_basesize) << (f/2); | 19 | ret = (m_fontsizes[m_maxsize-1]*m_basesize) << (f/2); |
22 | if (f%2) ret = (3*ret/2); | 20 | if (f%2) ret = (3*ret/2); |
23 | } | 21 | } |
24 | return ret; | 22 | return ret; |
25 | } | 23 | } |
26 | 24 | ||
27 | bool FontControl::ChangeFont(QString& n, int tgt) | 25 | bool FontControl::ChangeFont(QString& n, int tgt) |
28 | { | 26 | { |
29 | QValueList<int>::Iterator it; | 27 | QValueList<int>::Iterator it; |
30 | QFontDatabase fdb; | 28 | QFontDatabase fdb; |
31 | QValueList<int> sizes = fdb.pointSizes(n); | 29 | QValueList<int> sizes = fdb.pointSizes(n); |
32 | if (sizes.count() == 0) | 30 | if (sizes.count() == 0) |
33 | { | 31 | { |
34 | return false; | 32 | return false; |
35 | } | 33 | } |
36 | else | 34 | else |
37 | { | 35 | { |
38 | m_fontname = n; | 36 | m_fontname = n; |
39 | m_maxsize = sizes.count(); | 37 | m_maxsize = sizes.count(); |
40 | if (m_fontsizes != NULL) delete [] m_fontsizes; | 38 | if (m_fontsizes != NULL) delete [] m_fontsizes; |
41 | m_fontsizes = new int[m_maxsize]; | 39 | m_fontsizes = new int[m_maxsize]; |
42 | uint i = 0; | 40 | uint i = 0; |
43 | uint best = 0; | 41 | uint best = 0; |
44 | for (it = sizes.begin(); it != sizes.end(); it++) | 42 | for (it = sizes.begin(); it != sizes.end(); it++) |
45 | { | 43 | { |
46 | #if defined(OPIE) || !defined(USEQPE) | 44 | #if defined(OPIE) || !defined(USEQPE) |
47 | m_fontsizes[i] = (*it); | 45 | m_fontsizes[i] = (*it); |
48 | #else | 46 | #else |
49 | m_fontsizes[i] = (*it)/10; | 47 | m_fontsizes[i] = (*it)/10; |
50 | #endif | 48 | #endif |
51 | if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) | 49 | if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) |
52 | { | 50 | { |
53 | best = i; | 51 | best = i; |
54 | } | 52 | } |
55 | i++; | 53 | i++; |
56 | } | 54 | } |
57 | g_size = m_size = best; | 55 | g_size = m_size = best; |
58 | } | 56 | } |
59 | return true; | 57 | return true; |
60 | } | 58 | } |
diff --git a/noncore/apps/opie-reader/Palm2QImage.cpp b/noncore/apps/opie-reader/Palm2QImage.cpp index bf5ece3..9339595 100644 --- a/noncore/apps/opie-reader/Palm2QImage.cpp +++ b/noncore/apps/opie-reader/Palm2QImage.cpp | |||
@@ -1,309 +1,308 @@ | |||
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 | } |
300 | 299 | ||
301 | QImage* hRule(int w, int h, unsigned char r, unsigned char g, unsigned char b) | 300 | QImage* hRule(int w, int h, unsigned char r, unsigned char g, unsigned char b) |
302 | { | 301 | { |
303 | //// qDebug("hrule [%d, %d]", w, h); | 302 | //// qDebug("hrule [%d, %d]", w, h); |
304 | QPixmap* qimage = new QPixmap(w, h); | 303 | QPixmap* qimage = new QPixmap(w, h); |
305 | qimage->fill(QColor(r,g,b)); | 304 | qimage->fill(QColor(r,g,b)); |
306 | QImage* ret = new QImage(qimage->convertToImage()); | 305 | QImage* ret = new QImage(qimage->convertToImage()); |
307 | delete qimage; | 306 | delete qimage; |
308 | return ret; | 307 | return ret; |
309 | } | 308 | } |
diff --git a/noncore/apps/opie-reader/Prefs.cpp b/noncore/apps/opie-reader/Prefs.cpp index 5150ca5..72eefba 100644 --- a/noncore/apps/opie-reader/Prefs.cpp +++ b/noncore/apps/opie-reader/Prefs.cpp | |||
@@ -1,639 +1,630 @@ | |||
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 "Prefs.h" | 9 | #include "Prefs.h" |
11 | 10 | ||
12 | #include <qcheckbox.h> | ||
13 | #include <qlabel.h> | 11 | #include <qlabel.h> |
14 | #include <qpushbutton.h> | ||
15 | #include <qspinbox.h> | ||
16 | #include <qlayout.h> | 12 | #include <qlayout.h> |
17 | #include <qvariant.h> | ||
18 | #include <qtooltip.h> | ||
19 | #include <qwhatsthis.h> | ||
20 | #include <qcombobox.h> | ||
21 | #include <qbuttongroup.h> | 13 | #include <qbuttongroup.h> |
22 | #include <qlineedit.h> | ||
23 | #ifdef USEQPE | 14 | #ifdef USEQPE |
24 | #include <qpe/menubutton.h> | 15 | #include <qpe/menubutton.h> |
25 | #include <qpe/fontdatabase.h> | 16 | #include <qpe/fontdatabase.h> |
26 | #else | 17 | #else |
27 | #include <qfontdatabase.h> | 18 | #include <qfontdatabase.h> |
28 | #endif | 19 | #endif |
29 | 20 | ||
30 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
31 | 22 | ||
32 | CLayoutPrefs::CLayoutPrefs( QWidget* parent, const char* name, WFlags fl ) | 23 | CLayoutPrefs::CLayoutPrefs( QWidget* parent, const char* name, WFlags fl ) |
33 | : QWidget( parent, name, fl ) | 24 | : QWidget( parent, name, fl ) |
34 | { | 25 | { |
35 | QHBoxLayout* hb = new QHBoxLayout(this); | 26 | QHBoxLayout* hb = new QHBoxLayout(this); |
36 | QButtonGroup* bg = new QButtonGroup(2, Qt::Horizontal, tr("Text"), this); | 27 | QButtonGroup* bg = new QButtonGroup(2, Qt::Horizontal, tr("Text"), this); |
37 | hb->addWidget(bg); | 28 | hb->addWidget(bg); |
38 | 29 | ||
39 | StripCR = new QCheckBox( bg ); | 30 | StripCR = new QCheckBox( bg ); |
40 | StripCR->setText( tr( "Strip CR" ) ); | 31 | StripCR->setText( tr( "Strip CR" ) ); |
41 | 32 | ||
42 | Dehyphen = new QCheckBox( bg ); | 33 | Dehyphen = new QCheckBox( bg ); |
43 | Dehyphen->setText( tr( "Dehyphen" ) ); | 34 | Dehyphen->setText( tr( "Dehyphen" ) ); |
44 | 35 | ||
45 | SingleSpace = new QCheckBox( bg ); | 36 | SingleSpace = new QCheckBox( bg ); |
46 | SingleSpace->setText( tr( "Single Space" ) ); | 37 | SingleSpace->setText( tr( "Single Space" ) ); |
47 | 38 | ||
48 | Unindent = new QCheckBox( bg ); | 39 | Unindent = new QCheckBox( bg ); |
49 | Unindent->setText( tr( "Unindent" ) ); | 40 | Unindent->setText( tr( "Unindent" ) ); |
50 | 41 | ||
51 | Reparagraph = new QCheckBox( bg ); | 42 | Reparagraph = new QCheckBox( bg ); |
52 | Reparagraph->setText( tr( "Reparagraph" ) ); | 43 | Reparagraph->setText( tr( "Reparagraph" ) ); |
53 | 44 | ||
54 | DoubleSpace = new QCheckBox( bg ); | 45 | DoubleSpace = new QCheckBox( bg ); |
55 | DoubleSpace->setText( tr( "Double Space" ) ); | 46 | DoubleSpace->setText( tr( "Double Space" ) ); |
56 | 47 | ||
57 | Remap = new QCheckBox( bg ); | 48 | Remap = new QCheckBox( bg ); |
58 | Remap->setText( tr( "Remap" ) ); | 49 | Remap->setText( tr( "Remap" ) ); |
59 | 50 | ||
60 | Embolden = new QCheckBox( bg ); | 51 | Embolden = new QCheckBox( bg ); |
61 | Embolden->setText( tr( "Embolden" ) ); | 52 | Embolden->setText( tr( "Embolden" ) ); |
62 | 53 | ||
63 | FullJustify = new QCheckBox( bg ); | 54 | FullJustify = new QCheckBox( bg ); |
64 | FullJustify->setText( tr( "Full Justify" ) ); | 55 | FullJustify->setText( tr( "Full Justify" ) ); |
65 | 56 | ||
66 | } | 57 | } |
67 | 58 | ||
68 | /* | 59 | /* |
69 | * Destroys the object and frees any allocated resources | 60 | * Destroys the object and frees any allocated resources |
70 | */ | 61 | */ |
71 | CLayoutPrefs::~CLayoutPrefs() | 62 | CLayoutPrefs::~CLayoutPrefs() |
72 | { | 63 | { |
73 | // no need to delete child widgets, Qt does it all for us | 64 | // no need to delete child widgets, Qt does it all for us |
74 | } | 65 | } |
75 | 66 | ||
76 | 67 | ||
77 | 68 | ||
78 | CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) | 69 | CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) |
79 | : QWidget( parent, name, fl ) | 70 | : QWidget( parent, name, fl ) |
80 | { | 71 | { |
81 | 72 | ||
82 | QVBoxLayout* vb = new QVBoxLayout(this); | 73 | QVBoxLayout* vb = new QVBoxLayout(this); |
83 | QGridLayout* gl = new QGridLayout(vb, 4, 3); | 74 | QGridLayout* gl = new QGridLayout(vb, 4, 3); |
84 | 75 | ||
85 | QLabel *TextLabel; | 76 | QLabel *TextLabel; |
86 | 77 | ||
87 | TextLabel = new QLabel( this, "TextLabel1" ); | 78 | TextLabel = new QLabel( this, "TextLabel1" ); |
88 | TextLabel->setText( tr( "Indent" ) ); | 79 | TextLabel->setText( tr( "Indent" ) ); |
89 | gl->addWidget(TextLabel, 0, 0); | 80 | gl->addWidget(TextLabel, 0, 0); |
90 | 81 | ||
91 | 82 | ||
92 | TextLabel = new QLabel( this ); | 83 | TextLabel = new QLabel( this ); |
93 | TextLabel->setText( tr( "Page\nOverlap" ) ); | 84 | TextLabel->setText( tr( "Page\nOverlap" ) ); |
94 | gl->addWidget(TextLabel, 0, 1); | 85 | gl->addWidget(TextLabel, 0, 1); |
95 | 86 | ||
96 | TextLabel = new QLabel( this ); | 87 | TextLabel = new QLabel( this ); |
97 | TextLabel->setText( tr( "Graphics\nZoom" ) ); | 88 | TextLabel->setText( tr( "Graphics\nZoom" ) ); |
98 | gl->addWidget(TextLabel, 0, 2); | 89 | gl->addWidget(TextLabel, 0, 2); |
99 | 90 | ||
100 | Indent = new QSpinBox( this, "Indent" ); | 91 | Indent = new QSpinBox( this, "Indent" ); |
101 | Indent->setRange(0,20); | 92 | Indent->setRange(0,20); |
102 | gl->addWidget(Indent, 1, 0); | 93 | gl->addWidget(Indent, 1, 0); |
103 | 94 | ||
104 | pageoverlap = new QSpinBox( this ); | 95 | pageoverlap = new QSpinBox( this ); |
105 | pageoverlap->setRange(0,20); | 96 | pageoverlap->setRange(0,20); |
106 | gl->addWidget(pageoverlap, 1, 1); | 97 | gl->addWidget(pageoverlap, 1, 1); |
107 | 98 | ||
108 | gfxzoom = new QSpinBox( this ); | 99 | gfxzoom = new QSpinBox( this ); |
109 | gfxzoom->setRange(0,100); | 100 | gfxzoom->setRange(0,100); |
110 | gl->addWidget(gfxzoom, 1, 2); | 101 | gl->addWidget(gfxzoom, 1, 2); |
111 | 102 | ||
112 | TextLabel = new QLabel( this, "TextLabel4" ); | 103 | TextLabel = new QLabel( this, "TextLabel4" ); |
113 | TextLabel->setText( tr( "Margin" ) ); | 104 | TextLabel->setText( tr( "Margin" ) ); |
114 | gl->addWidget(TextLabel, 2, 0); | 105 | gl->addWidget(TextLabel, 2, 0); |
115 | 106 | ||
116 | TextLabel = new QLabel( this ); | 107 | TextLabel = new QLabel( this ); |
117 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); | 108 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); |
118 | gl->addWidget(TextLabel, 2, 1); | 109 | gl->addWidget(TextLabel, 2, 1); |
119 | 110 | ||
120 | TextLabel = new QLabel( this ); | 111 | TextLabel = new QLabel( this ); |
121 | TextLabel->setText( tr( "Line\nLeading" ) ); | 112 | TextLabel->setText( tr( "Line\nLeading" ) ); |
122 | gl->addWidget(TextLabel, 2, 2); | 113 | gl->addWidget(TextLabel, 2, 2); |
123 | 114 | ||
124 | Margin = new QSpinBox( this, "Margin" ); | 115 | Margin = new QSpinBox( this, "Margin" ); |
125 | Margin->setRange(0, 100); | 116 | Margin->setRange(0, 100); |
126 | gl->addWidget(Margin, 3, 0); | 117 | gl->addWidget(Margin, 3, 0); |
127 | 118 | ||
128 | ParaLead = new QSpinBox( this ); | 119 | ParaLead = new QSpinBox( this ); |
129 | ParaLead->setRange(-5, 50); | 120 | ParaLead->setRange(-5, 50); |
130 | gl->addWidget(ParaLead, 3, 1); | 121 | gl->addWidget(ParaLead, 3, 1); |
131 | 122 | ||
132 | LineLead = new QSpinBox( this ); | 123 | LineLead = new QSpinBox( this ); |
133 | LineLead->setRange(-5, 50); | 124 | LineLead->setRange(-5, 50); |
134 | gl->addWidget(LineLead, 3, 2); | 125 | gl->addWidget(LineLead, 3, 2); |
135 | 126 | ||
136 | gl = new QGridLayout(vb, 2, 2); | 127 | gl = new QGridLayout(vb, 2, 2); |
137 | 128 | ||
138 | TextLabel = new QLabel( this); | 129 | TextLabel = new QLabel( this); |
139 | TextLabel->setText( tr( "Markup" ) ); | 130 | TextLabel->setText( tr( "Markup" ) ); |
140 | gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); | 131 | gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); |
141 | TextLabel = new QLabel( this); | 132 | TextLabel = new QLabel( this); |
142 | TextLabel->setText( tr( "Font" ) ); | 133 | TextLabel->setText( tr( "Font" ) ); |
143 | gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); | 134 | gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); |
144 | 135 | ||
145 | 136 | ||
146 | #ifdef USECOMBO | 137 | #ifdef USECOMBO |
147 | Markup = new QComboBox( this); | 138 | Markup = new QComboBox( this); |
148 | #else | 139 | #else |
149 | Markup = new MenuButton( this); | 140 | Markup = new MenuButton( this); |
150 | #endif | 141 | #endif |
151 | Markup->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 142 | Markup->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
152 | Markup->insertItem("Auto"); | 143 | Markup->insertItem("Auto"); |
153 | Markup->insertItem("None"); | 144 | Markup->insertItem("None"); |
154 | Markup->insertItem("Text"); | 145 | Markup->insertItem("Text"); |
155 | Markup->insertItem("HTML"); | 146 | Markup->insertItem("HTML"); |
156 | Markup->insertItem("PML"); | 147 | Markup->insertItem("PML"); |
157 | gl->addWidget(Markup, 1, 0, Qt::AlignTop); | 148 | gl->addWidget(Markup, 1, 0, Qt::AlignTop); |
158 | 149 | ||
159 | #ifdef USECOMBO | 150 | #ifdef USECOMBO |
160 | fontselector = new QComboBox( this); | 151 | fontselector = new QComboBox( this); |
161 | #else | 152 | #else |
162 | fontselector = new MenuButton( this); | 153 | fontselector = new MenuButton( this); |
163 | #endif | 154 | #endif |
164 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 155 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
165 | { | 156 | { |
166 | #ifdef USEQPE | 157 | #ifdef USEQPE |
167 | FontDatabase f; | 158 | FontDatabase f; |
168 | #else | 159 | #else |
169 | QFontDatabase f; | 160 | QFontDatabase f; |
170 | #endif | 161 | #endif |
171 | QStringList flist = f.families(); | 162 | QStringList flist = f.families(); |
172 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 163 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
173 | { | 164 | { |
174 | fontselector->insertItem(*nm); | 165 | fontselector->insertItem(*nm); |
175 | } | 166 | } |
176 | } // delete the FontDatabase!!! | 167 | } // delete the FontDatabase!!! |
177 | gl->addWidget(fontselector, 1, 1, Qt::AlignTop); | 168 | gl->addWidget(fontselector, 1, 1, Qt::AlignTop); |
178 | } | 169 | } |
179 | /* | 170 | /* |
180 | CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) | 171 | CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) |
181 | : QWidget( parent, name, fl ) | 172 | : QWidget( parent, name, fl ) |
182 | { | 173 | { |
183 | QHBoxLayout* hb = new QHBoxLayout(this); | 174 | QHBoxLayout* hb = new QHBoxLayout(this); |
184 | 175 | ||
185 | QVBoxLayout* vb = new QVBoxLayout; | 176 | QVBoxLayout* vb = new QVBoxLayout; |
186 | hb->addLayout(vb); | 177 | hb->addLayout(vb); |
187 | 178 | ||
188 | QLabel *TextLabel; | 179 | QLabel *TextLabel; |
189 | 180 | ||
190 | TextLabel = new QLabel( this, "TextLabel1" ); | 181 | TextLabel = new QLabel( this, "TextLabel1" ); |
191 | TextLabel->setText( tr( "Indent" ) ); | 182 | TextLabel->setText( tr( "Indent" ) ); |
192 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 183 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
193 | Indent = new QSpinBox( this, "Indent" ); | 184 | Indent = new QSpinBox( this, "Indent" ); |
194 | Indent->setRange(0,20); | 185 | Indent->setRange(0,20); |
195 | vb->addWidget( Indent, 0, Qt::AlignLeft ); | 186 | vb->addWidget( Indent, 0, Qt::AlignLeft ); |
196 | 187 | ||
197 | TextLabel = new QLabel( this ); | 188 | TextLabel = new QLabel( this ); |
198 | TextLabel->setText( tr( "Page\nOverlap" ) ); | 189 | TextLabel->setText( tr( "Page\nOverlap" ) ); |
199 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 190 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
200 | pageoverlap = new QSpinBox( this ); | 191 | pageoverlap = new QSpinBox( this ); |
201 | pageoverlap->setRange(0,20); | 192 | pageoverlap->setRange(0,20); |
202 | vb->addWidget( pageoverlap, 0, Qt::AlignLeft ); | 193 | vb->addWidget( pageoverlap, 0, Qt::AlignLeft ); |
203 | 194 | ||
204 | TextLabel = new QLabel( this ); | 195 | TextLabel = new QLabel( this ); |
205 | TextLabel->setText( tr( "Graphics\nZoom" ) ); | 196 | TextLabel->setText( tr( "Graphics\nZoom" ) ); |
206 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 197 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
207 | gfxzoom = new QSpinBox( this ); | 198 | gfxzoom = new QSpinBox( this ); |
208 | gfxzoom->setRange(0,100); | 199 | gfxzoom->setRange(0,100); |
209 | vb->addWidget( gfxzoom, 0, Qt::AlignLeft ); | 200 | vb->addWidget( gfxzoom, 0, Qt::AlignLeft ); |
210 | 201 | ||
211 | vb->addStretch(); | 202 | vb->addStretch(); |
212 | 203 | ||
213 | vb = new QVBoxLayout; | 204 | vb = new QVBoxLayout; |
214 | hb->addLayout(vb); | 205 | hb->addLayout(vb); |
215 | 206 | ||
216 | TextLabel = new QLabel( this, "TextLabel4" ); | 207 | TextLabel = new QLabel( this, "TextLabel4" ); |
217 | TextLabel->setText( tr( "Margin" ) ); | 208 | TextLabel->setText( tr( "Margin" ) ); |
218 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 209 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
219 | Margin = new QSpinBox( this, "Margin" ); | 210 | Margin = new QSpinBox( this, "Margin" ); |
220 | Margin->setRange(0, 100); | 211 | Margin->setRange(0, 100); |
221 | vb->addWidget( Margin, 0, Qt::AlignLeft ); | 212 | vb->addWidget( Margin, 0, Qt::AlignLeft ); |
222 | 213 | ||
223 | TextLabel = new QLabel( this ); | 214 | TextLabel = new QLabel( this ); |
224 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); | 215 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); |
225 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 216 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
226 | ParaLead = new QSpinBox( this ); | 217 | ParaLead = new QSpinBox( this ); |
227 | ParaLead->setRange(-5, 50); | 218 | ParaLead->setRange(-5, 50); |
228 | vb->addWidget( ParaLead, 0, Qt::AlignLeft ); | 219 | vb->addWidget( ParaLead, 0, Qt::AlignLeft ); |
229 | 220 | ||
230 | TextLabel = new QLabel( this ); | 221 | TextLabel = new QLabel( this ); |
231 | TextLabel->setText( tr( "Line\nLeading" ) ); | 222 | TextLabel->setText( tr( "Line\nLeading" ) ); |
232 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 223 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
233 | LineLead = new QSpinBox( this ); | 224 | LineLead = new QSpinBox( this ); |
234 | LineLead->setRange(-5, 50); | 225 | LineLead->setRange(-5, 50); |
235 | vb->addWidget( LineLead, 0, Qt::AlignLeft ); | 226 | vb->addWidget( LineLead, 0, Qt::AlignLeft ); |
236 | 227 | ||
237 | vb->addStretch(); | 228 | vb->addStretch(); |
238 | 229 | ||
239 | vb = new QVBoxLayout; | 230 | vb = new QVBoxLayout; |
240 | hb->addLayout(vb); | 231 | hb->addLayout(vb); |
241 | 232 | ||
242 | 233 | ||
243 | TextLabel = new QLabel( this); | 234 | TextLabel = new QLabel( this); |
244 | TextLabel->setText( tr( "Markup" ) ); | 235 | TextLabel->setText( tr( "Markup" ) ); |
245 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 236 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
246 | Markup = new MenuButton( this); | 237 | Markup = new MenuButton( this); |
247 | Markup->insertItem("Auto"); | 238 | Markup->insertItem("Auto"); |
248 | Markup->insertItem("None"); | 239 | Markup->insertItem("None"); |
249 | Markup->insertItem("Text"); | 240 | Markup->insertItem("Text"); |
250 | Markup->insertItem("HTML"); | 241 | Markup->insertItem("HTML"); |
251 | Markup->insertItem("PML"); | 242 | Markup->insertItem("PML"); |
252 | vb->addWidget( Markup, 0, Qt::AlignLeft ); | 243 | vb->addWidget( Markup, 0, Qt::AlignLeft ); |
253 | 244 | ||
254 | TextLabel = new QLabel( this); | 245 | TextLabel = new QLabel( this); |
255 | TextLabel->setText( tr( "Font" ) ); | 246 | TextLabel->setText( tr( "Font" ) ); |
256 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 247 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
257 | fontselector = new MenuButton( this); | 248 | fontselector = new MenuButton( this); |
258 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 249 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
259 | { | 250 | { |
260 | FontDatabase f; | 251 | FontDatabase f; |
261 | QStringList flist = f.families(); | 252 | QStringList flist = f.families(); |
262 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 253 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
263 | { | 254 | { |
264 | fontselector->insertItem(*nm); | 255 | fontselector->insertItem(*nm); |
265 | } | 256 | } |
266 | } // delete the FontDatabase!!! | 257 | } // delete the FontDatabase!!! |
267 | vb->addWidget( fontselector, 0, Qt::AlignLeft ); | 258 | vb->addWidget( fontselector, 0, Qt::AlignLeft ); |
268 | 259 | ||
269 | vb->addStretch(); | 260 | vb->addStretch(); |
270 | } | 261 | } |
271 | */ | 262 | */ |
272 | /* | 263 | /* |
273 | * Destroys the object and frees any allocated resources | 264 | * Destroys the object and frees any allocated resources |
274 | */ | 265 | */ |
275 | CLayoutPrefs2::~CLayoutPrefs2() | 266 | CLayoutPrefs2::~CLayoutPrefs2() |
276 | { | 267 | { |
277 | // no need to delete child widgets, Qt does it all for us | 268 | // no need to delete child widgets, Qt does it all for us |
278 | } | 269 | } |
279 | 270 | ||
280 | /* | 271 | /* |
281 | CPluckerPrefs::CPluckerPrefs( QWidget* parent, const char* name, WFlags fl ) | 272 | CPluckerPrefs::CPluckerPrefs( QWidget* parent, const char* name, WFlags fl ) |
282 | : QWidget( parent, name, fl ) | 273 | : QWidget( parent, name, fl ) |
283 | { | 274 | { |
284 | Layout11 = new QVBoxLayout(this); | 275 | Layout11 = new QVBoxLayout(this); |
285 | Layout11->setMargin( 0 ); | 276 | Layout11->setMargin( 0 ); |
286 | 277 | ||
287 | Depluck = new QCheckBox( this, "Depluck" ); | 278 | Depluck = new QCheckBox( this, "Depluck" ); |
288 | Depluck->setText( tr( "Depluck" ) ); | 279 | Depluck->setText( tr( "Depluck" ) ); |
289 | Layout11->addWidget( Depluck ); | 280 | Layout11->addWidget( Depluck ); |
290 | 281 | ||
291 | Dejpluck = new QCheckBox( this, "Dejpluck" ); | 282 | Dejpluck = new QCheckBox( this, "Dejpluck" ); |
292 | Dejpluck->setText( tr( "Dejpluck" ) ); | 283 | Dejpluck->setText( tr( "Dejpluck" ) ); |
293 | Layout11->addWidget( Dejpluck ); | 284 | Layout11->addWidget( Dejpluck ); |
294 | 285 | ||
295 | Continuous = new QCheckBox( this, "Continuous" ); | 286 | Continuous = new QCheckBox( this, "Continuous" ); |
296 | Continuous->setText( tr( "Continuous" ) ); | 287 | Continuous->setText( tr( "Continuous" ) ); |
297 | Layout11->addWidget( Continuous ); | 288 | Layout11->addWidget( Continuous ); |
298 | 289 | ||
299 | } | 290 | } |
300 | 291 | ||
301 | CPluckerPrefs::~CPluckerPrefs() | 292 | CPluckerPrefs::~CPluckerPrefs() |
302 | { | 293 | { |
303 | // no need to delete child widgets, Qt does it all for us | 294 | // no need to delete child widgets, Qt does it all for us |
304 | } | 295 | } |
305 | */ | 296 | */ |
306 | /* | 297 | /* |
307 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) | 298 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) |
308 | : QWidget( parent, name, fl ) | 299 | : QWidget( parent, name, fl ) |
309 | { | 300 | { |
310 | 301 | ||
311 | QVBoxLayout* Layout11 = new QVBoxLayout(this); | 302 | QVBoxLayout* Layout11 = new QVBoxLayout(this); |
312 | Layout11->setMargin( 0 ); | 303 | Layout11->setMargin( 0 ); |
313 | 304 | ||
314 | 305 | ||
315 | QHBoxLayout* hl = new QHBoxLayout; | 306 | QHBoxLayout* hl = new QHBoxLayout; |
316 | 307 | ||
317 | QLabel* TextLabel = new QLabel( this ); | 308 | QLabel* TextLabel = new QLabel( this ); |
318 | TextLabel->setText( tr( "Action for\nSelect Button" ) ); | 309 | TextLabel->setText( tr( "Action for\nSelect Button" ) ); |
319 | hl->addWidget(TextLabel); | 310 | hl->addWidget(TextLabel); |
320 | 311 | ||
321 | action = new QComboBox( this ); | 312 | action = new QComboBox( this ); |
322 | action->insertItem("Open file"); | 313 | action->insertItem("Open file"); |
323 | action->insertItem("Autoscroll"); | 314 | action->insertItem("Autoscroll"); |
324 | action->insertItem("Mark"); | 315 | action->insertItem("Mark"); |
325 | action->insertItem("Annotate"); | 316 | action->insertItem("Annotate"); |
326 | action->insertItem("Fullscreen"); | 317 | action->insertItem("Fullscreen"); |
327 | hl->addWidget( action ); | 318 | hl->addWidget( action ); |
328 | 319 | ||
329 | Layout11->addLayout(hl); | 320 | Layout11->addLayout(hl); |
330 | 321 | ||
331 | hl = new QHBoxLayout; | 322 | hl = new QHBoxLayout; |
332 | 323 | ||
333 | TextLabel = new QLabel( this ); | 324 | TextLabel = new QLabel( this ); |
334 | TextLabel->setText( tr( "Dictionary\nApplication" ) ); | 325 | TextLabel->setText( tr( "Dictionary\nApplication" ) ); |
335 | hl->addWidget(TextLabel); | 326 | hl->addWidget(TextLabel); |
336 | target = new QLineEdit(this); | 327 | target = new QLineEdit(this); |
337 | hl->addWidget( target ); | 328 | hl->addWidget( target ); |
338 | 329 | ||
339 | Layout11->addLayout(hl); | 330 | Layout11->addLayout(hl); |
340 | 331 | ||
341 | 332 | ||
342 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Selection Target", this); | 333 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Selection Target", this); |
343 | Layout11->addWidget( bg ); | 334 | Layout11->addWidget( bg ); |
344 | 335 | ||
345 | annotation = new QCheckBox( bg ); | 336 | annotation = new QCheckBox( bg ); |
346 | annotation->setText( tr( "Annotation" ) ); | 337 | annotation->setText( tr( "Annotation" ) ); |
347 | 338 | ||
348 | dictionary = new QCheckBox( bg ); | 339 | dictionary = new QCheckBox( bg ); |
349 | dictionary->setText( tr( "Dictionary" ) ); | 340 | dictionary->setText( tr( "Dictionary" ) ); |
350 | 341 | ||
351 | clipboard = new QCheckBox( bg ); | 342 | clipboard = new QCheckBox( bg ); |
352 | clipboard->setText( tr( "Clipboard" ) ); | 343 | clipboard->setText( tr( "Clipboard" ) ); |
353 | 344 | ||
354 | } | 345 | } |
355 | 346 | ||
356 | CMiscPrefs::~CMiscPrefs() | 347 | CMiscPrefs::~CMiscPrefs() |
357 | { | 348 | { |
358 | // no need to delete child widgets, Qt does it all for us | 349 | // no need to delete child widgets, Qt does it all for us |
359 | } | 350 | } |
360 | */ | 351 | */ |
361 | 352 | ||
362 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) | 353 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) |
363 | : QWidget( parent, name, fl ) | 354 | : QWidget( parent, name, fl ) |
364 | { | 355 | { |
365 | 356 | ||
366 | QGridLayout* hl = new QGridLayout(this,1,2); | 357 | QGridLayout* hl = new QGridLayout(this,1,2); |
367 | 358 | ||
368 | hl->setMargin( 0 ); | 359 | hl->setMargin( 0 ); |
369 | 360 | ||
370 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("Select Action"), this); | 361 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("Select Action"), this); |
371 | hl->addWidget( gb, 0, 0 ); | 362 | hl->addWidget( gb, 0, 0 ); |
372 | 363 | ||
373 | annotation = new QCheckBox( gb ); | 364 | annotation = new QCheckBox( gb ); |
374 | annotation->setText( tr( "Annotation" ) ); | 365 | annotation->setText( tr( "Annotation" ) ); |
375 | 366 | ||
376 | dictionary = new QCheckBox( gb ); | 367 | dictionary = new QCheckBox( gb ); |
377 | dictionary->setText( tr( "Dictionary" ) ); | 368 | dictionary->setText( tr( "Dictionary" ) ); |
378 | 369 | ||
379 | clipboard = new QCheckBox( gb ); | 370 | clipboard = new QCheckBox( gb ); |
380 | clipboard->setText( tr( "Clipboard" ) ); | 371 | clipboard->setText( tr( "Clipboard" ) ); |
381 | 372 | ||
382 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, tr("Plucker"), this); | 373 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, tr("Plucker"), this); |
383 | hl->addWidget( bg, 0 , 1 ); | 374 | hl->addWidget( bg, 0 , 1 ); |
384 | 375 | ||
385 | Depluck = new QCheckBox( bg ); | 376 | Depluck = new QCheckBox( bg ); |
386 | Depluck->setText( tr( "Depluck" ) ); | 377 | Depluck->setText( tr( "Depluck" ) ); |
387 | 378 | ||
388 | Dejpluck = new QCheckBox( bg ); | 379 | Dejpluck = new QCheckBox( bg ); |
389 | Dejpluck->setText( tr( "Dejpluck" ) ); | 380 | Dejpluck->setText( tr( "Dejpluck" ) ); |
390 | 381 | ||
391 | Continuous = new QCheckBox( bg ); | 382 | Continuous = new QCheckBox( bg ); |
392 | Continuous->setText( tr( "Continuous" ) ); | 383 | Continuous->setText( tr( "Continuous" ) ); |
393 | 384 | ||
394 | 385 | ||
395 | /* | 386 | /* |
396 | 387 | ||
397 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Navigation", this); | 388 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Navigation", this); |
398 | TextLabel = new QLabel( gb ); | 389 | TextLabel = new QLabel( gb ); |
399 | TextLabel->setText( tr( "Overlap" ) ); | 390 | TextLabel->setText( tr( "Overlap" ) ); |
400 | QSpinBox* sb = new QSpinBox( gb ); | 391 | QSpinBox* sb = new QSpinBox( gb ); |
401 | 392 | ||
402 | Internationalisation | 393 | Internationalisation |
403 | Ideogram/Word | 394 | Ideogram/Word |
404 | Set Width | 395 | Set Width |
405 | Set Encoding | 396 | Set Encoding |
406 | Set Font | 397 | Set Font |
407 | */ | 398 | */ |
408 | } | 399 | } |
409 | 400 | ||
410 | CMiscPrefs::~CMiscPrefs() | 401 | CMiscPrefs::~CMiscPrefs() |
411 | { | 402 | { |
412 | // no need to delete child widgets, Qt does it all for us | 403 | // no need to delete child widgets, Qt does it all for us |
413 | } | 404 | } |
414 | 405 | ||
415 | CPrefs::CPrefs(bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) | 406 | CPrefs::CPrefs(bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) |
416 | { | 407 | { |
417 | setCaption(tr( "OpieReader Settings" ) ); | 408 | setCaption(tr( "OpieReader Settings" ) ); |
418 | QTabWidget* td = new QTabWidget(this); | 409 | QTabWidget* td = new QTabWidget(this); |
419 | layout = new CLayoutPrefs(this); | 410 | layout = new CLayoutPrefs(this); |
420 | layout2 = new CLayoutPrefs2(this); | 411 | layout2 = new CLayoutPrefs2(this); |
421 | misc = new CMiscPrefs(this); | 412 | misc = new CMiscPrefs(this); |
422 | button = new CButtonPrefs(this); | 413 | button = new CButtonPrefs(this); |
423 | inter = new CInterPrefs(this); | 414 | inter = new CInterPrefs(this); |
424 | td->addTab(layout, tr("Layout")); | 415 | td->addTab(layout, tr("Layout")); |
425 | td->addTab(layout2, tr("Layout(2)")); | 416 | td->addTab(layout2, tr("Layout(2)")); |
426 | td->addTab(inter, tr("Locale")); | 417 | td->addTab(inter, tr("Locale")); |
427 | td->addTab(misc, tr("Misc")); | 418 | td->addTab(misc, tr("Misc")); |
428 | td->addTab(button, tr("Buttons")); | 419 | td->addTab(button, tr("Buttons")); |
429 | QVBoxLayout* v = new QVBoxLayout(this); | 420 | QVBoxLayout* v = new QVBoxLayout(this); |
430 | v->addWidget(td); | 421 | v->addWidget(td); |
431 | 422 | ||
432 | if (fs) | 423 | if (fs) |
433 | QPEApplication::showDialog( this ); | 424 | QPEApplication::showDialog( this ); |
434 | } | 425 | } |
435 | 426 | ||
436 | 427 | ||
437 | /* | 428 | /* |
438 | 429 | ||
439 | Unicode | 430 | Unicode |
440 | Ideo/Word | 431 | Ideo/Word |
441 | Width | 432 | Width |
442 | Encoding | 433 | Encoding |
443 | 434 | ||
444 | */ | 435 | */ |
445 | 436 | ||
446 | #include "CEncoding_tables.h" | 437 | #include "CEncoding_tables.h" |
447 | 438 | ||
448 | CInterPrefs::CInterPrefs( QWidget* parent, const char* name, WFlags fl ) | 439 | CInterPrefs::CInterPrefs( QWidget* parent, const char* name, WFlags fl ) |
449 | : QWidget( parent, name, fl ) | 440 | : QWidget( parent, name, fl ) |
450 | { | 441 | { |
451 | QHBoxLayout* hb = new QHBoxLayout(this); | 442 | QHBoxLayout* hb = new QHBoxLayout(this); |
452 | 443 | ||
453 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("International"), this); | 444 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("International"), this); |
454 | 445 | ||
455 | hb->addWidget(gb); | 446 | hb->addWidget(gb); |
456 | 447 | ||
457 | QLabel *TextLabel; | 448 | QLabel *TextLabel; |
458 | 449 | ||
459 | ideogram = new QCheckBox( gb ); | 450 | ideogram = new QCheckBox( gb ); |
460 | ideogram->setText( tr( "Ideograms" ) ); | 451 | ideogram->setText( tr( "Ideograms" ) ); |
461 | 452 | ||
462 | TextLabel = new QLabel( gb ); | 453 | TextLabel = new QLabel( gb ); |
463 | TextLabel->setText( tr( "Ideogram Width" ) ); | 454 | TextLabel->setText( tr( "Ideogram Width" ) ); |
464 | ideogramwidth = new QSpinBox( gb ); | 455 | ideogramwidth = new QSpinBox( gb ); |
465 | ideogramwidth->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 456 | ideogramwidth->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
466 | ideogramwidth->setRange(1,200); | 457 | ideogramwidth->setRange(1,200); |
467 | 458 | ||
468 | propfontchange = new QCheckBox( gb ); | 459 | propfontchange = new QCheckBox( gb ); |
469 | propfontchange->setText( tr( "Apply font\nto dialogs" ) ); | 460 | propfontchange->setText( tr( "Apply font\nto dialogs" ) ); |
470 | 461 | ||
471 | TextLabel = new QLabel( gb ); | 462 | TextLabel = new QLabel( gb ); |
472 | TextLabel->setText( tr( "Encoding" ) ); | 463 | TextLabel->setText( tr( "Encoding" ) ); |
473 | #ifdef USECOMBO | 464 | #ifdef USECOMBO |
474 | encoding = new QComboBox(gb); | 465 | encoding = new QComboBox(gb); |
475 | #else | 466 | #else |
476 | encoding = new MenuButton(gb); | 467 | encoding = new MenuButton(gb); |
477 | #endif | 468 | #endif |
478 | encoding->insertItem("Ascii"); | 469 | encoding->insertItem("Ascii"); |
479 | encoding->insertItem("UTF-8"); | 470 | encoding->insertItem("UTF-8"); |
480 | encoding->insertItem("UCS-2(BE)"); | 471 | encoding->insertItem("UCS-2(BE)"); |
481 | encoding->insertItem("USC-2(LE)"); | 472 | encoding->insertItem("USC-2(LE)"); |
482 | encoding->insertItem("Palm"); | 473 | encoding->insertItem("Palm"); |
483 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) | 474 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) |
484 | { | 475 | { |
485 | encoding->insertItem(iter->mime); | 476 | encoding->insertItem(iter->mime); |
486 | } | 477 | } |
487 | 478 | ||
488 | QVBoxLayout* vb = new QVBoxLayout; | 479 | QVBoxLayout* vb = new QVBoxLayout; |
489 | 480 | ||
490 | gb = new QGroupBox(1, Qt::Horizontal, tr("Dictionary"), this); | 481 | gb = new QGroupBox(1, Qt::Horizontal, tr("Dictionary"), this); |
491 | 482 | ||
492 | TextLabel = new QLabel( gb ); | 483 | TextLabel = new QLabel( gb ); |
493 | TextLabel->setText( tr( "Application" ) ); | 484 | TextLabel->setText( tr( "Application" ) ); |
494 | application = new QLineEdit(gb); | 485 | application = new QLineEdit(gb); |
495 | application->setFixedWidth(80); | 486 | application->setFixedWidth(80); |
496 | 487 | ||
497 | TextLabel = new QLabel( gb ); | 488 | TextLabel = new QLabel( gb ); |
498 | TextLabel->setText( tr( "Message" ) ); | 489 | TextLabel->setText( tr( "Message" ) ); |
499 | message = new QLineEdit(gb); | 490 | message = new QLineEdit(gb); |
500 | message->setFixedWidth(80); | 491 | message->setFixedWidth(80); |
501 | // message->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 492 | // message->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
502 | twotouch = new QCheckBox( gb ); | 493 | twotouch = new QCheckBox( gb ); |
503 | twotouch->setText( tr( "Two/One\nTouch" ) ); | 494 | twotouch->setText( tr( "Two/One\nTouch" ) ); |
504 | 495 | ||
505 | SwapMouse = new QCheckBox( gb ); | 496 | SwapMouse = new QCheckBox( gb ); |
506 | SwapMouse->setText(tr("Swap Tap\nActions") ); | 497 | SwapMouse->setText(tr("Swap Tap\nActions") ); |
507 | 498 | ||
508 | 499 | ||
509 | vb->addWidget(gb); | 500 | vb->addWidget(gb); |
510 | 501 | ||
511 | // vb->addStretch(); | 502 | // vb->addStretch(); |
512 | hb->addLayout(vb); | 503 | hb->addLayout(vb); |
513 | } | 504 | } |
514 | 505 | ||
515 | CInterPrefs::~CInterPrefs() | 506 | CInterPrefs::~CInterPrefs() |
516 | { | 507 | { |
517 | // no need to delete child widgets, Qt does it all for us | 508 | // no need to delete child widgets, Qt does it all for us |
518 | } | 509 | } |
519 | 510 | ||
520 | 511 | ||
521 | 512 | ||
522 | #ifdef USECOMBO | 513 | #ifdef USECOMBO |
523 | void CButtonPrefs::populate(QComboBox *mb) | 514 | void CButtonPrefs::populate(QComboBox *mb) |
524 | #else | 515 | #else |
525 | void CButtonPrefs::populate(MenuButton *mb) | 516 | void CButtonPrefs::populate(MenuButton *mb) |
526 | #endif | 517 | #endif |
527 | { | 518 | { |
528 | mb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 519 | mb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
529 | mb->insertItem(tr("<Nothing>") ); | 520 | mb->insertItem(tr("<Nothing>") ); |
530 | mb->insertItem(tr("Open file") ); | 521 | mb->insertItem(tr("Open file") ); |
531 | mb->insertItem(tr("Autoscroll") ); | 522 | mb->insertItem(tr("Autoscroll") ); |
532 | mb->insertItem(tr("Bookmark") ); | 523 | mb->insertItem(tr("Bookmark") ); |
533 | mb->insertItem(tr("Annotate") ); | 524 | mb->insertItem(tr("Annotate") ); |
534 | mb->insertItem(tr("Fullscreen") ); | 525 | mb->insertItem(tr("Fullscreen") ); |
535 | 526 | ||
536 | mb->insertItem(tr("Zoom in") ); | 527 | mb->insertItem(tr("Zoom in") ); |
537 | mb->insertItem(tr("Zoom out") ); | 528 | mb->insertItem(tr("Zoom out") ); |
538 | mb->insertItem(tr("Back") ); | 529 | mb->insertItem(tr("Back") ); |
539 | mb->insertItem(tr("Forward") ); | 530 | mb->insertItem(tr("Forward") ); |
540 | mb->insertItem(tr("Home") ); | 531 | mb->insertItem(tr("Home") ); |
541 | mb->insertItem(tr("Page up") ); | 532 | mb->insertItem(tr("Page up") ); |
542 | mb->insertItem(tr("Page down") ); | 533 | mb->insertItem(tr("Page down") ); |
543 | mb->insertItem(tr("Line up") ); | 534 | mb->insertItem(tr("Line up") ); |
544 | mb->insertItem(tr("Line down") ); | 535 | mb->insertItem(tr("Line down") ); |
545 | mb->insertItem(tr("Beginning") ); | 536 | mb->insertItem(tr("Beginning") ); |
546 | mb->insertItem(tr("End") ); | 537 | mb->insertItem(tr("End") ); |
547 | } | 538 | } |
548 | 539 | ||
549 | CButtonPrefs::CButtonPrefs( QWidget* parent, const char* name, WFlags fl ) | 540 | CButtonPrefs::CButtonPrefs( QWidget* parent, const char* name, WFlags fl ) |
550 | : QWidget( parent, name, fl ) | 541 | : QWidget( parent, name, fl ) |
551 | { | 542 | { |
552 | 543 | ||
553 | QGridLayout* hl = new QGridLayout(this,10,2); | 544 | QGridLayout* hl = new QGridLayout(this,10,2); |
554 | 545 | ||
555 | hl->setMargin( 0 ); | 546 | hl->setMargin( 0 ); |
556 | 547 | ||
557 | QLabel* ql = new QLabel(tr("Escape Button"), this); | 548 | QLabel* ql = new QLabel(tr("Escape Button"), this); |
558 | hl->addWidget(ql, 0, 0, Qt::AlignBottom); | 549 | hl->addWidget(ql, 0, 0, Qt::AlignBottom); |
559 | #ifdef USECOMBO | 550 | #ifdef USECOMBO |
560 | escapeAction = new QComboBox( this ); | 551 | escapeAction = new QComboBox( this ); |
561 | #else | 552 | #else |
562 | escapeAction = new MenuButton( this ); | 553 | escapeAction = new MenuButton( this ); |
563 | #endif | 554 | #endif |
564 | populate(escapeAction); | 555 | populate(escapeAction); |
565 | hl->addWidget(escapeAction, 1, 0, Qt::AlignTop | Qt::AlignLeft); | 556 | hl->addWidget(escapeAction, 1, 0, Qt::AlignTop | Qt::AlignLeft); |
566 | 557 | ||
567 | ql = new QLabel(tr("Space Button"), this); | 558 | ql = new QLabel(tr("Space Button"), this); |
568 | hl->addWidget(ql, 2, 0, Qt::AlignBottom); | 559 | hl->addWidget(ql, 2, 0, Qt::AlignBottom); |
569 | #ifdef USECOMBO | 560 | #ifdef USECOMBO |
570 | spaceAction = new QComboBox( this ); | 561 | spaceAction = new QComboBox( this ); |
571 | #else | 562 | #else |
572 | spaceAction = new MenuButton( this ); | 563 | spaceAction = new MenuButton( this ); |
573 | #endif | 564 | #endif |
574 | populate(spaceAction); | 565 | populate(spaceAction); |
575 | hl->addWidget(spaceAction, 3, 0, Qt::AlignTop | Qt::AlignLeft); | 566 | hl->addWidget(spaceAction, 3, 0, Qt::AlignTop | Qt::AlignLeft); |
576 | 567 | ||
577 | ql = new QLabel(tr("Return Button"), this); | 568 | ql = new QLabel(tr("Return Button"), this); |
578 | hl->addWidget(ql, 2, 1, Qt::AlignBottom); | 569 | hl->addWidget(ql, 2, 1, Qt::AlignBottom); |
579 | #ifdef USECOMBO | 570 | #ifdef USECOMBO |
580 | returnAction = new QComboBox( this ); | 571 | returnAction = new QComboBox( this ); |
581 | #else | 572 | #else |
582 | returnAction = new MenuButton( this ); | 573 | returnAction = new MenuButton( this ); |
583 | #endif | 574 | #endif |
584 | populate(returnAction); | 575 | populate(returnAction); |
585 | hl->addWidget(returnAction, 3, 1, Qt::AlignTop | Qt::AlignLeft); | 576 | hl->addWidget(returnAction, 3, 1, Qt::AlignTop | Qt::AlignLeft); |
586 | 577 | ||
587 | ql = new QLabel(tr("Left Arrow"), this); | 578 | ql = new QLabel(tr("Left Arrow"), this); |
588 | hl->addWidget(ql, 4, 0, Qt::AlignBottom); | 579 | hl->addWidget(ql, 4, 0, Qt::AlignBottom); |
589 | #ifdef USECOMBO | 580 | #ifdef USECOMBO |
590 | leftAction = new QComboBox( this ); | 581 | leftAction = new QComboBox( this ); |
591 | #else | 582 | #else |
592 | leftAction = new MenuButton( this ); | 583 | leftAction = new MenuButton( this ); |
593 | #endif | 584 | #endif |
594 | populate(leftAction); | 585 | populate(leftAction); |
595 | hl->addWidget(leftAction, 5, 0, Qt::AlignTop | Qt::AlignLeft); | 586 | hl->addWidget(leftAction, 5, 0, Qt::AlignTop | Qt::AlignLeft); |
596 | leftScroll = new QCheckBox( tr("Scroll Speed"), this ); | 587 | leftScroll = new QCheckBox( tr("Scroll Speed"), this ); |
597 | hl->addWidget(leftScroll, 6, 0, Qt::AlignTop | Qt::AlignLeft); | 588 | hl->addWidget(leftScroll, 6, 0, Qt::AlignTop | Qt::AlignLeft); |
598 | 589 | ||
599 | ql = new QLabel(tr("Right Arrow"), this); | 590 | ql = new QLabel(tr("Right Arrow"), this); |
600 | hl->addWidget(ql, 4, 1, Qt::AlignBottom); | 591 | hl->addWidget(ql, 4, 1, Qt::AlignBottom); |
601 | #ifdef USECOMBO | 592 | #ifdef USECOMBO |
602 | rightAction = new QComboBox( this ); | 593 | rightAction = new QComboBox( this ); |
603 | #else | 594 | #else |
604 | rightAction = new MenuButton( this ); | 595 | rightAction = new MenuButton( this ); |
605 | #endif | 596 | #endif |
606 | populate(rightAction); | 597 | populate(rightAction); |
607 | hl->addWidget(rightAction, 5, 1, Qt::AlignTop | Qt::AlignLeft); | 598 | hl->addWidget(rightAction, 5, 1, Qt::AlignTop | Qt::AlignLeft); |
608 | rightScroll = new QCheckBox( tr("Scroll Speed"), this ); | 599 | rightScroll = new QCheckBox( tr("Scroll Speed"), this ); |
609 | hl->addWidget(rightScroll, 6, 1, Qt::AlignTop | Qt::AlignLeft); | 600 | hl->addWidget(rightScroll, 6, 1, Qt::AlignTop | Qt::AlignLeft); |
610 | 601 | ||
611 | ql = new QLabel(tr("Down Arrow"), this); | 602 | ql = new QLabel(tr("Down Arrow"), this); |
612 | hl->addWidget(ql, 7, 0, Qt::AlignBottom); | 603 | hl->addWidget(ql, 7, 0, Qt::AlignBottom); |
613 | #ifdef USECOMBO | 604 | #ifdef USECOMBO |
614 | downAction = new QComboBox( this ); | 605 | downAction = new QComboBox( this ); |
615 | #else | 606 | #else |
616 | downAction = new MenuButton( this ); | 607 | downAction = new MenuButton( this ); |
617 | #endif | 608 | #endif |
618 | populate(downAction); | 609 | populate(downAction); |
619 | hl->addWidget(downAction, 8, 0, Qt::AlignTop | Qt::AlignLeft); | 610 | hl->addWidget(downAction, 8, 0, Qt::AlignTop | Qt::AlignLeft); |
620 | downScroll = new QCheckBox( tr("Scroll Speed"), this ); | 611 | downScroll = new QCheckBox( tr("Scroll Speed"), this ); |
621 | hl->addWidget(downScroll, 9, 0, Qt::AlignTop | Qt::AlignLeft); | 612 | hl->addWidget(downScroll, 9, 0, Qt::AlignTop | Qt::AlignLeft); |
622 | 613 | ||
623 | ql = new QLabel(tr("Up Arrow"), this); | 614 | ql = new QLabel(tr("Up Arrow"), this); |
624 | hl->addWidget(ql, 7, 1, Qt::AlignBottom); | 615 | hl->addWidget(ql, 7, 1, Qt::AlignBottom); |
625 | #ifdef USECOMBO | 616 | #ifdef USECOMBO |
626 | upAction = new QComboBox( this ); | 617 | upAction = new QComboBox( this ); |
627 | #else | 618 | #else |
628 | upAction = new MenuButton( this ); | 619 | upAction = new MenuButton( this ); |
629 | #endif | 620 | #endif |
630 | populate(upAction); | 621 | populate(upAction); |
631 | hl->addWidget(upAction, 8, 1, Qt::AlignTop | Qt::AlignLeft); | 622 | hl->addWidget(upAction, 8, 1, Qt::AlignTop | Qt::AlignLeft); |
632 | upScroll = new QCheckBox( tr("Scroll Speed"), this ); | 623 | upScroll = new QCheckBox( tr("Scroll Speed"), this ); |
633 | hl->addWidget(upScroll, 9, 1, Qt::AlignTop | Qt::AlignLeft); | 624 | hl->addWidget(upScroll, 9, 1, Qt::AlignTop | Qt::AlignLeft); |
634 | } | 625 | } |
635 | 626 | ||
636 | CButtonPrefs::~CButtonPrefs() | 627 | CButtonPrefs::~CButtonPrefs() |
637 | { | 628 | { |
638 | // no need to delete child widgets, Qt does it all for us | 629 | // no need to delete child widgets, Qt does it all for us |
639 | } | 630 | } |
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp index 03c8fbe..d64abb4 100644 --- a/noncore/apps/opie-reader/QTReader.cpp +++ b/noncore/apps/opie-reader/QTReader.cpp | |||
@@ -1,1220 +1,1211 @@ | |||
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 | #include "useqpe.h" | ||
12 | #include <qpainter.h> | ||
13 | #include <qimage.h> | ||
14 | #include <qtimer.h> | ||
15 | #include "config.h" | ||
16 | #include "QTReader.h" | 11 | #include "QTReader.h" |
17 | #include "QTReaderApp.h" | 12 | #include "QTReaderApp.h" |
18 | #include "CDrawBuffer.h" | ||
19 | #ifdef USEQPE | 13 | #ifdef USEQPE |
20 | #include <qpe/qpeapplication.h> | 14 | #include <qpe/qpeapplication.h> |
21 | #endif | 15 | #endif |
22 | #include <math.h> | 16 | #include <math.h> |
23 | #include <ctype.h> | 17 | #include <ctype.h> |
24 | #include <stdio.h> //for sprintf | 18 | #include <stdio.h> //for sprintf |
25 | #ifdef USEQPE | 19 | #ifdef USEQPE |
26 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
27 | #include <qpe/applnk.h> | 21 | #include <qpe/applnk.h> |
28 | #include <qpe/global.h> | 22 | #include <qpe/global.h> |
29 | #include <qpe/qcopenvelope_qws.h> | 23 | #include <qpe/qcopenvelope_qws.h> |
30 | #endif | 24 | #endif |
31 | #include <qfontdatabase.h> | ||
32 | 25 | ||
33 | #ifdef _UNICODE | 26 | #ifdef _UNICODE |
34 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; | 27 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; |
35 | #else | 28 | #else |
36 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; | 29 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; |
37 | #endif | 30 | #endif |
38 | //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; | 31 | //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; |
39 | 32 | ||
40 | //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; | 33 | //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; |
41 | //const int QTReader::fontsizes[] = {10,16,17,22,0}; | 34 | //const int QTReader::fontsizes[] = {10,16,17,22,0}; |
42 | //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; | 35 | //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; |
43 | //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}; | 36 | //const int QTReader::fontsizes[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0}; |
44 | 37 | ||
45 | 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 }; | 38 | 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 }; |
46 | tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; | 39 | tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; |
47 | //tchar QTReader::jplucknextpart[] = { 10,'#',10,'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; | 40 | //tchar QTReader::jplucknextpart[] = { 10,'#',10,'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; |
48 | 41 | ||
49 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : | 42 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : |
50 | QWidget(parent, name, f), | 43 | QWidget(parent, name, f), |
51 | m_delay(100), | 44 | m_delay(100), |
52 | m_scrolldy1(0), | 45 | m_scrolldy1(0), |
53 | m_scrolldy2(0), | 46 | m_scrolldy2(0), |
54 | m_autoScroll(false), | 47 | m_autoScroll(false), |
55 | //textarray(NULL), | 48 | //textarray(NULL), |
56 | //locnarray(NULL), | 49 | //locnarray(NULL), |
57 | numlines(0), | 50 | numlines(0), |
58 | m_fontname("unifont"), | 51 | m_fontname("unifont"), |
59 | m_fm(NULL), | 52 | m_fm(NULL), |
60 | mouseUpOn(true), | 53 | mouseUpOn(true), |
61 | m_twotouch(true), | 54 | m_twotouch(true), |
62 | m_touchone(true), | 55 | m_touchone(true), |
63 | bDoUpdates(false), | 56 | bDoUpdates(false), |
64 | #ifdef _SCROLLPIPE | 57 | #ifdef _SCROLLPIPE |
65 | m_pipeout(NULL), | 58 | m_pipeout(NULL), |
66 | #endif | 59 | #endif |
67 | m_border(2) | 60 | m_border(2) |
68 | { | 61 | { |
69 | m_overlap = 1; | 62 | m_overlap = 1; |
70 | setKeyCompression ( true ); | 63 | setKeyCompression ( true ); |
71 | // init(); | 64 | // init(); |
72 | } | 65 | } |
73 | 66 | ||
74 | /* | 67 | /* |
75 | QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : | 68 | QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : |
76 | QWidget(parent, name, f), | 69 | QWidget(parent, name, f), |
77 | m_textfont(0), | 70 | m_textfont(0), |
78 | m_textsize(1), | 71 | m_textsize(1), |
79 | textarray(NULL), | 72 | textarray(NULL), |
80 | numlines(0), | 73 | numlines(0), |
81 | bstripcr(true), | 74 | bstripcr(true), |
82 | bunindent(false), | 75 | bunindent(false), |
83 | brepara(false), | 76 | brepara(false), |
84 | bdblspce(false), | 77 | bdblspce(false), |
85 | btight(false), | 78 | btight(false), |
86 | bindenter(0), | 79 | bindenter(0), |
87 | m_fm(NULL) | 80 | m_fm(NULL) |
88 | { | 81 | { |
89 | init(); | 82 | init(); |
90 | // // qDebug("Load_file(1)"); | 83 | // // qDebug("Load_file(1)"); |
91 | load_file((const tchar*)filename); | 84 | load_file((const tchar*)filename); |
92 | } | 85 | } |
93 | */ | 86 | */ |
94 | 87 | ||
95 | /* | 88 | /* |
96 | void QTReader::mouseMoveEvent(QMouseEvent* _e) | 89 | void QTReader::mouseMoveEvent(QMouseEvent* _e) |
97 | { | 90 | { |
98 | 91 | ||
99 | mouseUpOn = !(_e->pos().x() == -1); | 92 | mouseUpOn = !(_e->pos().x() == -1); |
100 | 93 | ||
101 | qDebug("MouseMove:[%d, %d]", _e->pos().x(), _e->pos().y()); | 94 | qDebug("MouseMove:[%d, %d]", _e->pos().x(), _e->pos().y()); |
102 | } | 95 | } |
103 | */ | 96 | */ |
104 | long QTReader::real_delay() | 97 | long QTReader::real_delay() |
105 | { | 98 | { |
106 | return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); | 99 | return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); |
107 | } | 100 | } |
108 | 101 | ||
109 | void QTReader::mousePressEvent( QMouseEvent* _e ) | 102 | void QTReader::mousePressEvent( QMouseEvent* _e ) |
110 | { | 103 | { |
111 | buffdoc.unsuspend(); | 104 | buffdoc.unsuspend(); |
112 | if (_e->button() == RightButton) | 105 | if (_e->button() == RightButton) |
113 | { | 106 | { |
114 | //qDebug("MousePress"); | 107 | //qDebug("MousePress"); |
115 | mouseUpOn = false; | 108 | mouseUpOn = false; |
116 | if (m_swapmouse) | 109 | if (m_swapmouse) |
117 | { | 110 | { |
118 | int lineno = 0; | 111 | int lineno = 0; |
119 | int ht = textarray[0]->lineSpacing(); | 112 | int ht = textarray[0]->lineSpacing(); |
120 | while ((ht < _e->y()) && (lineno < numlines)) | 113 | while ((ht < _e->y()) && (lineno < numlines)) |
121 | { | 114 | { |
122 | ht += textarray[++lineno]->lineSpacing(); | 115 | ht += textarray[++lineno]->lineSpacing(); |
123 | } | 116 | } |
124 | size_t startpos, startoffset, tgt; | 117 | size_t startpos, startoffset, tgt; |
125 | getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt); | 118 | getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt); |
126 | processmousewordevent(startpos, startoffset, _e, lineno); | 119 | processmousewordevent(startpos, startoffset, _e, lineno); |
127 | } | 120 | } |
128 | else | 121 | else |
129 | processmousepositionevent(_e); | 122 | processmousepositionevent(_e); |
130 | } | 123 | } |
131 | } | 124 | } |
132 | 125 | ||
133 | void QTReader::processmousepositionevent( QMouseEvent* _e ) | 126 | void QTReader::processmousepositionevent( QMouseEvent* _e ) |
134 | { | 127 | { |
135 | if (buffdoc.hasnavigation()) | 128 | if (buffdoc.hasnavigation()) |
136 | { | 129 | { |
137 | if (_e->y() > (2*height())/3) | 130 | if (_e->y() > (2*height())/3) |
138 | { | 131 | { |
139 | goDown(); | 132 | goDown(); |
140 | } | 133 | } |
141 | else if (_e->y() < height()/3) | 134 | else if (_e->y() < height()/3) |
142 | { | 135 | { |
143 | goUp(); | 136 | goUp(); |
144 | } | 137 | } |
145 | else | 138 | else |
146 | { | 139 | { |
147 | if (_e->x() < width()/3) | 140 | if (_e->x() < width()/3) |
148 | { | 141 | { |
149 | goBack(); | 142 | goBack(); |
150 | } | 143 | } |
151 | else if (_e->x() > (2*width())/3) | 144 | else if (_e->x() > (2*width())/3) |
152 | { | 145 | { |
153 | goForward(); | 146 | goForward(); |
154 | } | 147 | } |
155 | else | 148 | else |
156 | { | 149 | { |
157 | goHome(); | 150 | goHome(); |
158 | } | 151 | } |
159 | } | 152 | } |
160 | } | 153 | } |
161 | else | 154 | else |
162 | { | 155 | { |
163 | if (_e->y() > height()/2) | 156 | if (_e->y() > height()/2) |
164 | { | 157 | { |
165 | goDown(); | 158 | goDown(); |
166 | } | 159 | } |
167 | else | 160 | else |
168 | { | 161 | { |
169 | goUp(); | 162 | goUp(); |
170 | } | 163 | } |
171 | } | 164 | } |
172 | } | 165 | } |
173 | 166 | ||
174 | void QTReader::goHome() | 167 | void QTReader::goHome() |
175 | { | 168 | { |
176 | if (buffdoc.hasnavigation()) | 169 | if (buffdoc.hasnavigation()) |
177 | { | 170 | { |
178 | size_t current=pagelocate(); | 171 | size_t current=pagelocate(); |
179 | size_t home=buffdoc.getHome(); | 172 | size_t home=buffdoc.getHome(); |
180 | if (current!=home) | 173 | if (current!=home) |
181 | { | 174 | { |
182 | buffdoc.saveposn(current); | 175 | buffdoc.saveposn(current); |
183 | locate(home); | 176 | locate(home); |
184 | } | 177 | } |
185 | } | 178 | } |
186 | } | 179 | } |
187 | 180 | ||
188 | void QTReader::goBack() | 181 | void QTReader::goBack() |
189 | { | 182 | { |
190 | if (buffdoc.hasnavigation()) | 183 | if (buffdoc.hasnavigation()) |
191 | { | 184 | { |
192 | size_t target = pagelocate(); | 185 | size_t target = pagelocate(); |
193 | buffdoc.writeposn(target); | 186 | buffdoc.writeposn(target); |
194 | if (buffdoc.back(target)) | 187 | if (buffdoc.back(target)) |
195 | { | 188 | { |
196 | locate(target); | 189 | locate(target); |
197 | } | 190 | } |
198 | } | 191 | } |
199 | } | 192 | } |
200 | 193 | ||
201 | void QTReader::goForward() | 194 | void QTReader::goForward() |
202 | { | 195 | { |
203 | if (buffdoc.hasnavigation()) | 196 | if (buffdoc.hasnavigation()) |
204 | { | 197 | { |
205 | size_t target = pagelocate(); | 198 | size_t target = pagelocate(); |
206 | if (buffdoc.forward(target)) | 199 | if (buffdoc.forward(target)) |
207 | { | 200 | { |
208 | locate(target); | 201 | locate(target); |
209 | } | 202 | } |
210 | } | 203 | } |
211 | } | 204 | } |
212 | 205 | ||
213 | linkType QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt) | 206 | linkType QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt) |
214 | { | 207 | { |
215 | int lineno = 0; | 208 | int lineno = 0; |
216 | int ht = textarray[0]->lineSpacing(); | 209 | int ht = textarray[0]->lineSpacing(); |
217 | while ((ht < y) && (lineno < numlines)) | 210 | while ((ht < y) && (lineno < numlines)) |
218 | { | 211 | { |
219 | ht += textarray[++lineno]->lineSpacing(); | 212 | ht += textarray[++lineno]->lineSpacing(); |
220 | } | 213 | } |
221 | start = locnarray[lineno]; | 214 | start = locnarray[lineno]; |
222 | if (m_bMonoSpaced) | 215 | if (m_bMonoSpaced) |
223 | { | 216 | { |
224 | offset = (x - textarray[lineno]->offset(width(), m_border))/m_charWidth; | 217 | offset = (x - textarray[lineno]->offset(width(), m_border))/m_charWidth; |
225 | } | 218 | } |
226 | else | 219 | else |
227 | { | 220 | { |
228 | int i; | 221 | int i; |
229 | CDrawBuffer* t = textarray[lineno]; | 222 | CDrawBuffer* t = textarray[lineno]; |
230 | x = x - t->offset(width(), m_border); | 223 | x = x - t->offset(width(), m_border); |
231 | for (i = t->length(); i >= 0 && t->width(i, true, width(), m_border) > x; i--); | 224 | for (i = t->length(); i >= 0 && t->width(i, true, width(), m_border) > x; i--); |
232 | offset = i; | 225 | offset = i; |
233 | } | 226 | } |
234 | return textarray[lineno]->getLinkType(offset, tgt); | 227 | return textarray[lineno]->getLinkType(offset, tgt); |
235 | } | 228 | } |
236 | 229 | ||
237 | void QTReader::suspend() | 230 | void QTReader::suspend() |
238 | { | 231 | { |
239 | #ifdef OPIE | 232 | #ifdef OPIE |
240 | if (memcmp("/mnt/", m_lastfile.latin1(), 5) == 0) buffdoc.suspend(); | 233 | if (memcmp("/mnt/", m_lastfile.latin1(), 5) == 0) buffdoc.suspend(); |
241 | #else | 234 | #else |
242 | if (memcmp("/usr/mnt.rom/", m_lastfile.latin1(), 13) == 0) buffdoc.suspend(); | 235 | if (memcmp("/usr/mnt.rom/", m_lastfile.latin1(), 13) == 0) buffdoc.suspend(); |
243 | #endif | 236 | #endif |
244 | } | 237 | } |
245 | 238 | ||
246 | void QTReader::setTwoTouch(bool _b) | 239 | void QTReader::setTwoTouch(bool _b) |
247 | { | 240 | { |
248 | setBackgroundColor( white ); | 241 | setBackgroundColor( white ); |
249 | m_twotouch = m_touchone = _b; | 242 | m_twotouch = m_touchone = _b; |
250 | } | 243 | } |
251 | 244 | ||
252 | void QTReader::setContinuous(bool _b) | 245 | void QTReader::setContinuous(bool _b) |
253 | { | 246 | { |
254 | buffdoc.unsuspend(); | 247 | buffdoc.unsuspend(); |
255 | buffdoc.setContinuous(m_continuousDocument = _b); | 248 | buffdoc.setContinuous(m_continuousDocument = _b); |
256 | } | 249 | } |
257 | 250 | ||
258 | void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno) | 251 | void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno) |
259 | { | 252 | { |
260 | QString wrd; | 253 | QString wrd; |
261 | if (m_twotouch) | 254 | if (m_twotouch) |
262 | { | 255 | { |
263 | if (m_touchone) | 256 | if (m_touchone) |
264 | { | 257 | { |
265 | m_touchone = false; | 258 | m_touchone = false; |
266 | m_startpos = startpos; | 259 | m_startpos = startpos; |
267 | m_startoffset = startoffset; | 260 | m_startoffset = startoffset; |
268 | setBackgroundColor( lightGray ); | 261 | setBackgroundColor( lightGray ); |
269 | } | 262 | } |
270 | else | 263 | else |
271 | { | 264 | { |
272 | m_touchone = true; | 265 | m_touchone = true; |
273 | setBackgroundColor( white ); | 266 | setBackgroundColor( white ); |
274 | size_t endpos, endoffset; | 267 | size_t endpos, endoffset; |
275 | endpos = startpos; | 268 | endpos = startpos; |
276 | endoffset = startoffset; | 269 | endoffset = startoffset; |
277 | size_t currentpos = locate(); | 270 | size_t currentpos = locate(); |
278 | if (endpos >= m_startpos) | 271 | if (endpos >= m_startpos) |
279 | { | 272 | { |
280 | jumpto(m_startpos); | 273 | jumpto(m_startpos); |
281 | for (int i = 0; i < m_startoffset; i++) | 274 | for (int i = 0; i < m_startoffset; i++) |
282 | { | 275 | { |
283 | getch(); | 276 | getch(); |
284 | } | 277 | } |
285 | if (m_startpos == endpos) | 278 | if (m_startpos == endpos) |
286 | { | 279 | { |
287 | for (int i = m_startoffset; i <= endoffset; i++) | 280 | for (int i = m_startoffset; i <= endoffset; i++) |
288 | { | 281 | { |
289 | wrd += QChar(getch()); | 282 | wrd += QChar(getch()); |
290 | } | 283 | } |
291 | } | 284 | } |
292 | else | 285 | else |
293 | { | 286 | { |
294 | while (buffdoc.explocate() <= endpos) | 287 | while (buffdoc.explocate() <= endpos) |
295 | { | 288 | { |
296 | wrd += QChar(getch()); | 289 | wrd += QChar(getch()); |
297 | } | 290 | } |
298 | for (int i = 0; i < endoffset; i++) | 291 | for (int i = 0; i < endoffset; i++) |
299 | { | 292 | { |
300 | wrd += QChar(getch()); | 293 | wrd += QChar(getch()); |
301 | } | 294 | } |
302 | } | 295 | } |
303 | jumpto(currentpos); | 296 | jumpto(currentpos); |
304 | } | 297 | } |
305 | } | 298 | } |
306 | } | 299 | } |
307 | else if (m_bMonoSpaced) | 300 | else if (m_bMonoSpaced) |
308 | { | 301 | { |
309 | int chno = (_e->x()-textarray[lineno]->offset(width(), m_border))/m_charWidth; | 302 | int chno = (_e->x()-textarray[lineno]->offset(width(), m_border))/m_charWidth; |
310 | if (chno < ustrlen(textarray[lineno]->data())) | 303 | if (chno < ustrlen(textarray[lineno]->data())) |
311 | { | 304 | { |
312 | wrd[0] = textarray[lineno]->data()[chno]; | 305 | wrd[0] = textarray[lineno]->data()[chno]; |
313 | } | 306 | } |
314 | } | 307 | } |
315 | else | 308 | else |
316 | { | 309 | { |
317 | CDrawBuffer* t = textarray[lineno]; | 310 | CDrawBuffer* t = textarray[lineno]; |
318 | int first = 0; | 311 | int first = 0; |
319 | int tgt = _e->x() - t->offset(width(), m_border); | 312 | int tgt = _e->x() - t->offset(width(), m_border); |
320 | while (1) | 313 | while (1) |
321 | { | 314 | { |
322 | int i = first+1; | 315 | int i = first+1; |
323 | while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; | 316 | while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; |
324 | if (t->width(i, true, width(), m_border) > tgt) | 317 | if (t->width(i, true, width(), m_border) > tgt) |
325 | { | 318 | { |
326 | wrd = toQString(t->data()+first, i - first); | 319 | wrd = toQString(t->data()+first, i - first); |
327 | // qDebug("Got %s", (const char *)wrd); | 320 | // qDebug("Got %s", (const char *)wrd); |
328 | break; | 321 | break; |
329 | } | 322 | } |
330 | while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; | 323 | while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; |
331 | if ((*t)[i] == 0) break; | 324 | if ((*t)[i] == 0) break; |
332 | first = i; | 325 | first = i; |
333 | } | 326 | } |
334 | } | 327 | } |
335 | if (!wrd.isEmpty()) | 328 | if (!wrd.isEmpty()) |
336 | { | 329 | { |
337 | //qDebug("Selected:%s", (const char*)wrd); | 330 | //qDebug("Selected:%s", (const char*)wrd); |
338 | emit OnWordSelected(wrd, locnarray[lineno], (m_twotouch) ? wrd : toQString(textarray[lineno]->data())); | 331 | emit OnWordSelected(wrd, locnarray[lineno], (m_twotouch) ? wrd : toQString(textarray[lineno]->data())); |
339 | } | 332 | } |
340 | } | 333 | } |
341 | 334 | ||
342 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | 335 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) |
343 | { | 336 | { |
344 | buffdoc.unsuspend(); | 337 | buffdoc.unsuspend(); |
345 | if (_e->button() == LeftButton) | 338 | if (_e->button() == LeftButton) |
346 | { | 339 | { |
347 | if (mouseUpOn) | 340 | if (mouseUpOn) |
348 | { | 341 | { |
349 | // qDebug("MouseRelease"); | 342 | // qDebug("MouseRelease"); |
350 | if (_e->x() > width() - m_border) | 343 | if (_e->x() > width() - m_border) |
351 | { | 344 | { |
352 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*_e->y()+height()/2)/height()); | 345 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*_e->y()+height()/2)/height()); |
353 | return; | 346 | return; |
354 | } | 347 | } |
355 | if (textarray[0] != NULL) | 348 | if (textarray[0] != NULL) |
356 | { | 349 | { |
357 | QString line; | 350 | QString line; |
358 | // int lineno = _e->y()/m_linespacing; | 351 | // int lineno = _e->y()/m_linespacing; |
359 | int lineno = 0; | 352 | int lineno = 0; |
360 | int ht = textarray[0]->lineSpacing(); | 353 | int ht = textarray[0]->lineSpacing(); |
361 | while ((ht < _e->y()) && (lineno < numlines)) | 354 | while ((ht < _e->y()) && (lineno < numlines)) |
362 | { | 355 | { |
363 | ht += textarray[++lineno]->lineSpacing(); | 356 | ht += textarray[++lineno]->lineSpacing(); |
364 | } | 357 | } |
365 | size_t startpos, startoffset, tgt; | 358 | size_t startpos, startoffset, tgt; |
366 | switch (getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt)) | 359 | switch (getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt)) |
367 | { | 360 | { |
368 | case eLink: | 361 | case eLink: |
369 | { | 362 | { |
370 | size_t saveposn = pagelocate(); | 363 | size_t saveposn = pagelocate(); |
371 | QString href; | 364 | QString href; |
372 | linkType lt = buffdoc.hyperlink(tgt, href); | 365 | linkType lt = buffdoc.hyperlink(tgt, href); |
373 | if (lt == eLink) | 366 | if (lt == eLink) |
374 | { | 367 | { |
375 | buffdoc.saveposn(saveposn); | 368 | buffdoc.saveposn(saveposn); |
376 | fillbuffer(); | 369 | fillbuffer(); |
377 | update(); | 370 | update(); |
378 | } | 371 | } |
379 | else | 372 | else |
380 | { | 373 | { |
381 | if (lt == ePicture) | 374 | if (lt == ePicture) |
382 | { | 375 | { |
383 | QImage* pm = buffdoc.getPicture(tgt); | 376 | QImage* pm = buffdoc.getPicture(tgt); |
384 | if (pm != NULL) | 377 | if (pm != NULL) |
385 | { | 378 | { |
386 | emit OnShowPicture(*pm); | 379 | emit OnShowPicture(*pm); |
387 | delete pm; | 380 | delete pm; |
388 | } | 381 | } |
389 | } | 382 | } |
390 | else | 383 | else |
391 | { | 384 | { |
392 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); | 385 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); |
393 | if (!href.isEmpty()) | 386 | if (!href.isEmpty()) |
394 | { | 387 | { |
395 | emit OnURLSelected(href); | 388 | emit OnURLSelected(href); |
396 | } | 389 | } |
397 | } | 390 | } |
398 | locate(pagelocate()); | 391 | locate(pagelocate()); |
399 | } | 392 | } |
400 | return; | 393 | return; |
401 | } | 394 | } |
402 | case ePicture: | 395 | case ePicture: |
403 | { | 396 | { |
404 | // qDebug("Picture:%x", tgt); | 397 | // qDebug("Picture:%x", tgt); |
405 | QImage* pm = buffdoc.getPicture(tgt); | 398 | QImage* pm = buffdoc.getPicture(tgt); |
406 | if (pm != NULL) | 399 | if (pm != NULL) |
407 | { | 400 | { |
408 | emit OnShowPicture(*pm); | 401 | emit OnShowPicture(*pm); |
409 | delete pm; | 402 | delete pm; |
410 | } | 403 | } |
411 | else | 404 | else |
412 | { | 405 | { |
413 | locate(pagelocate()); | 406 | locate(pagelocate()); |
414 | } | 407 | } |
415 | return; | 408 | return; |
416 | } | 409 | } |
417 | case eNone: | 410 | case eNone: |
418 | break; | 411 | break; |
419 | default: | 412 | default: |
420 | // qDebug("Unknown linktype"); | 413 | // qDebug("Unknown linktype"); |
421 | return; | 414 | return; |
422 | } | 415 | } |
423 | if (m_swapmouse) | 416 | if (m_swapmouse) |
424 | processmousepositionevent(_e); | 417 | processmousepositionevent(_e); |
425 | else | 418 | else |
426 | processmousewordevent(startpos, startoffset, _e, lineno); | 419 | processmousewordevent(startpos, startoffset, _e, lineno); |
427 | } | 420 | } |
428 | } | 421 | } |
429 | else | 422 | else |
430 | { | 423 | { |
431 | mouseUpOn = true; | 424 | mouseUpOn = true; |
432 | } | 425 | } |
433 | } | 426 | } |
434 | } | 427 | } |
435 | 428 | ||
436 | void QTReader::focusInEvent(QFocusEvent* e) | 429 | void QTReader::focusInEvent(QFocusEvent* e) |
437 | { | 430 | { |
438 | if (m_autoScroll) timer->start(real_delay(), false); | 431 | if (m_autoScroll) timer->start(real_delay(), false); |
439 | update(); | 432 | update(); |
440 | } | 433 | } |
441 | 434 | ||
442 | void QTReader::focusOutEvent(QFocusEvent* e) | 435 | void QTReader::focusOutEvent(QFocusEvent* e) |
443 | { | 436 | { |
444 | if (m_autoScroll) | 437 | if (m_autoScroll) |
445 | { | 438 | { |
446 | timer->stop(); | 439 | timer->stop(); |
447 | //m_scrolldy1 = m_scrolldy2 = 0; | 440 | //m_scrolldy1 = m_scrolldy2 = 0; |
448 | } | 441 | } |
449 | } | 442 | } |
450 | 443 | ||
451 | #include <qapplication.h> | ||
452 | #include <qdrawutil.h> | ||
453 | #ifndef _WINDOWS | 444 | #ifndef _WINDOWS |
454 | #include <unistd.h> | 445 | #include <unistd.h> |
455 | #endif | 446 | #endif |
456 | 447 | ||
457 | void QTReader::goDown() | 448 | void QTReader::goDown() |
458 | { | 449 | { |
459 | if (m_bpagemode) | 450 | if (m_bpagemode) |
460 | { | 451 | { |
461 | dopagedn(); | 452 | dopagedn(); |
462 | } | 453 | } |
463 | else | 454 | else |
464 | { | 455 | { |
465 | lineDown(); | 456 | lineDown(); |
466 | } | 457 | } |
467 | } | 458 | } |
468 | 459 | ||
469 | void QTReader::goUp() | 460 | void QTReader::goUp() |
470 | { | 461 | { |
471 | if (m_bpagemode) | 462 | if (m_bpagemode) |
472 | { | 463 | { |
473 | dopageup(); | 464 | dopageup(); |
474 | } | 465 | } |
475 | else | 466 | else |
476 | { | 467 | { |
477 | lineUp(); | 468 | lineUp(); |
478 | } | 469 | } |
479 | } | 470 | } |
480 | 471 | ||
481 | void QTReader::NavUp() | 472 | void QTReader::NavUp() |
482 | { | 473 | { |
483 | buffdoc.unsuspend(); | 474 | buffdoc.unsuspend(); |
484 | if (buffdoc.hasnavigation()) | 475 | if (buffdoc.hasnavigation()) |
485 | { | 476 | { |
486 | /* | 477 | /* |
487 | size_t target = pagelocate(); | 478 | size_t target = pagelocate(); |
488 | if (buffdoc.back(target)) | 479 | if (buffdoc.back(target)) |
489 | { | 480 | { |
490 | locate(target); | 481 | locate(target); |
491 | } | 482 | } |
492 | */ | 483 | */ |
493 | locate(buffdoc.startSection()); | 484 | locate(buffdoc.startSection()); |
494 | } | 485 | } |
495 | else | 486 | else |
496 | { | 487 | { |
497 | goUp(); | 488 | goUp(); |
498 | } | 489 | } |
499 | } | 490 | } |
500 | 491 | ||
501 | void QTReader::NavDown() | 492 | void QTReader::NavDown() |
502 | { | 493 | { |
503 | buffdoc.unsuspend(); | 494 | buffdoc.unsuspend(); |
504 | if (buffdoc.hasnavigation()) | 495 | if (buffdoc.hasnavigation()) |
505 | { | 496 | { |
506 | /* | 497 | /* |
507 | size_t target = pagelocate(); | 498 | size_t target = pagelocate(); |
508 | if (buffdoc.forward(target)) | 499 | if (buffdoc.forward(target)) |
509 | { | 500 | { |
510 | locate(target); | 501 | locate(target); |
511 | } | 502 | } |
512 | */ | 503 | */ |
513 | dopageup(buffdoc.endSection()); | 504 | dopageup(buffdoc.endSection()); |
514 | } | 505 | } |
515 | else | 506 | else |
516 | { | 507 | { |
517 | goDown(); | 508 | goDown(); |
518 | } | 509 | } |
519 | } | 510 | } |
520 | 511 | ||
521 | void QTReader::zoomin() | 512 | void QTReader::zoomin() |
522 | { | 513 | { |
523 | if (m_fontControl.increasesize()) | 514 | if (m_fontControl.increasesize()) |
524 | { | 515 | { |
525 | bool sc = m_autoScroll; | 516 | bool sc = m_autoScroll; |
526 | setfont(); | 517 | setfont(); |
527 | m_autoScroll = false; | 518 | m_autoScroll = false; |
528 | locate(pagelocate()); | 519 | locate(pagelocate()); |
529 | update(); | 520 | update(); |
530 | m_autoScroll = sc; | 521 | m_autoScroll = sc; |
531 | if (m_autoScroll) autoscroll(); | 522 | if (m_autoScroll) autoscroll(); |
532 | } | 523 | } |
533 | } | 524 | } |
534 | 525 | ||
535 | void QTReader::zoomout() | 526 | void QTReader::zoomout() |
536 | { | 527 | { |
537 | if (m_fontControl.decreasesize()) | 528 | if (m_fontControl.decreasesize()) |
538 | { | 529 | { |
539 | bool sc = m_autoScroll; | 530 | bool sc = m_autoScroll; |
540 | m_autoScroll = false; | 531 | m_autoScroll = false; |
541 | setfont(); | 532 | setfont(); |
542 | locate(pagelocate()); | 533 | locate(pagelocate()); |
543 | update(); | 534 | update(); |
544 | m_autoScroll = sc; | 535 | m_autoScroll = sc; |
545 | if (m_autoScroll) autoscroll(); | 536 | if (m_autoScroll) autoscroll(); |
546 | } | 537 | } |
547 | } | 538 | } |
548 | 539 | ||
549 | void QTReader::reduceScroll() | 540 | void QTReader::reduceScroll() |
550 | { | 541 | { |
551 | if (m_delay < 59049) | 542 | if (m_delay < 59049) |
552 | { | 543 | { |
553 | m_delay = (3*m_delay)/2; | 544 | m_delay = (3*m_delay)/2; |
554 | timer->changeInterval(real_delay()); | 545 | timer->changeInterval(real_delay()); |
555 | } | 546 | } |
556 | else | 547 | else |
557 | { | 548 | { |
558 | m_delay = 59049; | 549 | m_delay = 59049; |
559 | } | 550 | } |
560 | } | 551 | } |
561 | 552 | ||
562 | void QTReader::increaseScroll() | 553 | void QTReader::increaseScroll() |
563 | { | 554 | { |
564 | if (m_delay > 1024) | 555 | if (m_delay > 1024) |
565 | { | 556 | { |
566 | m_delay = (2*m_delay)/3; | 557 | m_delay = (2*m_delay)/3; |
567 | timer->changeInterval(real_delay()); | 558 | timer->changeInterval(real_delay()); |
568 | } | 559 | } |
569 | else | 560 | else |
570 | { | 561 | { |
571 | m_delay = 1024; | 562 | m_delay = 1024; |
572 | } | 563 | } |
573 | } | 564 | } |
574 | 565 | ||
575 | void QTReader::keyPressEvent(QKeyEvent* e) | 566 | void QTReader::keyPressEvent(QKeyEvent* e) |
576 | { | 567 | { |
577 | buffdoc.unsuspend(); | 568 | buffdoc.unsuspend(); |
578 | ((QTReaderApp*)parent()->parent())->handlekey(e); | 569 | ((QTReaderApp*)parent()->parent())->handlekey(e); |
579 | // e->ignore(); | 570 | // e->ignore(); |
580 | return; | 571 | return; |
581 | #ifdef _SCROLLPIPE | 572 | #ifdef _SCROLLPIPE |
582 | if (m_isPaused) | 573 | if (m_isPaused) |
583 | { | 574 | { |
584 | m_isPaused = false; | 575 | m_isPaused = false; |
585 | if (e->key() != Key_Space) | 576 | if (e->key() != Key_Space) |
586 | { | 577 | { |
587 | m_autoScroll = false; | 578 | m_autoScroll = false; |
588 | if (m_pipeout != NULL) | 579 | if (m_pipeout != NULL) |
589 | { | 580 | { |
590 | pclose(m_pipeout); | 581 | pclose(m_pipeout); |
591 | m_pipeout = NULL; | 582 | m_pipeout = NULL; |
592 | } | 583 | } |
593 | ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); | 584 | ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); |
594 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 585 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
595 | } | 586 | } |
596 | else | 587 | else |
597 | { | 588 | { |
598 | timer->start(real_delay(), false); | 589 | timer->start(real_delay(), false); |
599 | } | 590 | } |
600 | e->accept(); | 591 | e->accept(); |
601 | return; | 592 | return; |
602 | } | 593 | } |
603 | #endif | 594 | #endif |
604 | /* | 595 | /* |
605 | switch (e->key()) | 596 | switch (e->key()) |
606 | { | 597 | { |
607 | case Key_Down: | 598 | case Key_Down: |
608 | { | 599 | { |
609 | e->accept(); | 600 | e->accept(); |
610 | if (m_autoScroll) | 601 | if (m_autoScroll) |
611 | { | 602 | { |
612 | if (m_delay < 59049) | 603 | if (m_delay < 59049) |
613 | { | 604 | { |
614 | m_delay = (3*m_delay)/2; | 605 | m_delay = (3*m_delay)/2; |
615 | timer->changeInterval(real_delay()); | 606 | timer->changeInterval(real_delay()); |
616 | } | 607 | } |
617 | else | 608 | else |
618 | { | 609 | { |
619 | m_delay = 59049; | 610 | m_delay = 59049; |
620 | } | 611 | } |
621 | } | 612 | } |
622 | else | 613 | else |
623 | { | 614 | { |
624 | goDown(); | 615 | goDown(); |
625 | } | 616 | } |
626 | } | 617 | } |
627 | break; | 618 | break; |
628 | case Key_Up: | 619 | case Key_Up: |
629 | { | 620 | { |
630 | e->accept(); | 621 | e->accept(); |
631 | if (m_autoScroll) | 622 | if (m_autoScroll) |
632 | { | 623 | { |
633 | if (m_delay > 1024) | 624 | if (m_delay > 1024) |
634 | { | 625 | { |
635 | m_delay = (2*m_delay)/3; | 626 | m_delay = (2*m_delay)/3; |
636 | timer->changeInterval(real_delay()); | 627 | timer->changeInterval(real_delay()); |
637 | } | 628 | } |
638 | else | 629 | else |
639 | { | 630 | { |
640 | m_delay = 1024; | 631 | m_delay = 1024; |
641 | } | 632 | } |
642 | } | 633 | } |
643 | else | 634 | else |
644 | { | 635 | { |
645 | goUp(); | 636 | goUp(); |
646 | } | 637 | } |
647 | } | 638 | } |
648 | break; | 639 | break; |
649 | case Key_Right: | 640 | case Key_Right: |
650 | { | 641 | { |
651 | e->accept(); | 642 | e->accept(); |
652 | if (m_navkeys && buffdoc.hasnavigation()) | 643 | if (m_navkeys && buffdoc.hasnavigation()) |
653 | { | 644 | { |
654 | size_t target = pagelocate(); | 645 | size_t target = pagelocate(); |
655 | if (buffdoc.forward(target)) | 646 | if (buffdoc.forward(target)) |
656 | { | 647 | { |
657 | locate(target); | 648 | locate(target); |
658 | } | 649 | } |
659 | } | 650 | } |
660 | else zoomin(); | 651 | else zoomin(); |
661 | } | 652 | } |
662 | break; | 653 | break; |
663 | case Key_Left: | 654 | case Key_Left: |
664 | { | 655 | { |
665 | e->accept(); | 656 | e->accept(); |
666 | if (m_navkeys && buffdoc.hasnavigation()) | 657 | if (m_navkeys && buffdoc.hasnavigation()) |
667 | { | 658 | { |
668 | size_t target = pagelocate(); | 659 | size_t target = pagelocate(); |
669 | if (buffdoc.back(target)) | 660 | if (buffdoc.back(target)) |
670 | { | 661 | { |
671 | locate(target); | 662 | locate(target); |
672 | } | 663 | } |
673 | } | 664 | } |
674 | else zoomout(); | 665 | else zoomout(); |
675 | } | 666 | } |
676 | break; | 667 | break; |
677 | default: | 668 | default: |
678 | e->ignore(); | 669 | e->ignore(); |
679 | } | 670 | } |
680 | */ | 671 | */ |
681 | } | 672 | } |
682 | 673 | ||
683 | void QTReader::setautoscroll(bool _sc) | 674 | void QTReader::setautoscroll(bool _sc) |
684 | { | 675 | { |
685 | if (_sc == m_autoScroll) return; | 676 | if (_sc == m_autoScroll) return; |
686 | if (m_autoScroll) | 677 | if (m_autoScroll) |
687 | { | 678 | { |
688 | m_autoScroll = false; | 679 | m_autoScroll = false; |
689 | #ifdef USEQPE | 680 | #ifdef USEQPE |
690 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 681 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
691 | #endif | 682 | #endif |
692 | #ifdef _SCROLLPIPE | 683 | #ifdef _SCROLLPIPE |
693 | if (m_pipeout != NULL) | 684 | if (m_pipeout != NULL) |
694 | { | 685 | { |
695 | pclose(m_pipeout); | 686 | pclose(m_pipeout); |
696 | m_pipeout = NULL; | 687 | m_pipeout = NULL; |
697 | } | 688 | } |
698 | #endif | 689 | #endif |
699 | } | 690 | } |
700 | else | 691 | else |
701 | { | 692 | { |
702 | CDrawBuffer* reusebuffer = textarray[numlines]; | 693 | CDrawBuffer* reusebuffer = textarray[numlines]; |
703 | if (reusebuffer == NULL || reusebuffer->eof()) return; | 694 | if (reusebuffer == NULL || reusebuffer->eof()) return; |
704 | m_autoScroll = true; | 695 | m_autoScroll = true; |
705 | #ifdef _SCROLLPIPE | 696 | #ifdef _SCROLLPIPE |
706 | if (!m_pipetarget.isEmpty()) | 697 | if (!m_pipetarget.isEmpty()) |
707 | { | 698 | { |
708 | // qDebug("Opening pipe to %s", (const char*)m_pipetarget); | 699 | // qDebug("Opening pipe to %s", (const char*)m_pipetarget); |
709 | m_pipeout = popen((const char*)m_pipetarget, "w"); | 700 | m_pipeout = popen((const char*)m_pipetarget, "w"); |
710 | m_isPaused = false; | 701 | m_isPaused = false; |
711 | } | 702 | } |
712 | #endif | 703 | #endif |
713 | autoscroll(); | 704 | autoscroll(); |
714 | #ifdef USEQPE | 705 | #ifdef USEQPE |
715 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed | 706 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed |
716 | #endif | 707 | #endif |
717 | } | 708 | } |
718 | } | 709 | } |
719 | 710 | ||
720 | bool QTReader::getline(CDrawBuffer *buff) | 711 | bool QTReader::getline(CDrawBuffer *buff) |
721 | { | 712 | { |
722 | buffdoc.unsuspend(); | 713 | buffdoc.unsuspend(); |
723 | if (m_bMonoSpaced) | 714 | if (m_bMonoSpaced) |
724 | { | 715 | { |
725 | return buffdoc.getline(buff ,width(), m_charWidth, m_border); | 716 | return buffdoc.getline(buff ,width(), m_charWidth, m_border); |
726 | } | 717 | } |
727 | else | 718 | else |
728 | { | 719 | { |
729 | return buffdoc.getline(buff, width(), m_border); | 720 | return buffdoc.getline(buff, width(), m_border); |
730 | } | 721 | } |
731 | } | 722 | } |
732 | 723 | ||
733 | void QTReader::doscroll() | 724 | void QTReader::doscroll() |
734 | { | 725 | { |
735 | if (!m_autoScroll) | 726 | if (!m_autoScroll) |
736 | { | 727 | { |
737 | timer->stop(); | 728 | timer->stop(); |
738 | return; | 729 | return; |
739 | } | 730 | } |
740 | // timer->changeInterval(real_delay()); | 731 | // timer->changeInterval(real_delay()); |
741 | QPainter p( this ); | 732 | QPainter p( this ); |
742 | QBrush b( white); | 733 | QBrush b( white); |
743 | bitBlt(this,0,0,this,0,1,width(),-1); | 734 | bitBlt(this,0,0,this,0,1,width(),-1); |
744 | qDrawPlainRect(&p,0,height() - 2,width(),2,white,1,&b); | 735 | qDrawPlainRect(&p,0,height() - 2,width(),2,white,1,&b); |
745 | 736 | ||
746 | if (++m_scrolldy1 == textarray[0]->lineSpacing()) | 737 | if (++m_scrolldy1 == textarray[0]->lineSpacing()) |
747 | { | 738 | { |
748 | #ifdef _SCROLLPIPE | 739 | #ifdef _SCROLLPIPE |
749 | if (m_pipeout != NULL) | 740 | if (m_pipeout != NULL) |
750 | { | 741 | { |
751 | QString outstr = toQString(textarray[0]->data()); | 742 | QString outstr = toQString(textarray[0]->data()); |
752 | if (!outstr.isEmpty()) | 743 | if (!outstr.isEmpty()) |
753 | { | 744 | { |
754 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 745 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
755 | fflush(m_pipeout); | 746 | fflush(m_pipeout); |
756 | } | 747 | } |
757 | else if (m_pauseAfterEachPara) | 748 | else if (m_pauseAfterEachPara) |
758 | { | 749 | { |
759 | m_isPaused = true; | 750 | m_isPaused = true; |
760 | timer->stop(); | 751 | timer->stop(); |
761 | } | 752 | } |
762 | // write(m_pipeout, (const char*)outstr, outstr.length()); | 753 | // write(m_pipeout, (const char*)outstr, outstr.length()); |
763 | // write(m_pipeout, "\n", 1); | 754 | // write(m_pipeout, "\n", 1); |
764 | // fputc(10, m_pipeout); | 755 | // fputc(10, m_pipeout); |
765 | } | 756 | } |
766 | #endif | 757 | #endif |
767 | CDrawBuffer* buff = textarray[0]; | 758 | CDrawBuffer* buff = textarray[0]; |
768 | for (int i = 1; i <= numlines; i++) | 759 | for (int i = 1; i <= numlines; i++) |
769 | { | 760 | { |
770 | textarray[i-1] = textarray[i]; | 761 | textarray[i-1] = textarray[i]; |
771 | locnarray[i-1] = locnarray[i]; | 762 | locnarray[i-1] = locnarray[i]; |
772 | } | 763 | } |
773 | textarray[numlines] = buff; | 764 | textarray[numlines] = buff; |
774 | --numlines; | 765 | --numlines; |
775 | m_scrolldy1 = 0; | 766 | m_scrolldy1 = 0; |
776 | } | 767 | } |
777 | if (++m_scrolldy2 == textarray[numlines]->lineSpacing()) | 768 | if (++m_scrolldy2 == textarray[numlines]->lineSpacing()) |
778 | { | 769 | { |
779 | m_scrolldy2 = 0; | 770 | m_scrolldy2 = 0; |
780 | numlines++; | 771 | numlines++; |
781 | 772 | ||
782 | if (textarray[numlines] == NULL) | 773 | if (textarray[numlines] == NULL) |
783 | { | 774 | { |
784 | textarray[numlines] = new CDrawBuffer(&m_fontControl); | 775 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
785 | } | 776 | } |
786 | locnarray[numlines] = locate(); | 777 | locnarray[numlines] = locate(); |
787 | int ch = getline(textarray[numlines]); | 778 | int ch = getline(textarray[numlines]); |
788 | textarray[numlines-1]->render(&p, height() - textarray[numlines-1]->descent() - 2, m_bMonoSpaced, m_charWidth, width(), m_border); | 779 | textarray[numlines-1]->render(&p, height() - textarray[numlines-1]->descent() - 2, m_bMonoSpaced, m_charWidth, width(), m_border); |
789 | mylastpos = locate(); | 780 | mylastpos = locate(); |
790 | if (!ch) | 781 | if (!ch) |
791 | { | 782 | { |
792 | m_autoScroll = false; | 783 | m_autoScroll = false; |
793 | #ifdef _SCROLLPIPE | 784 | #ifdef _SCROLLPIPE |
794 | for (int i = 0; i < numlines; i++) | 785 | for (int i = 0; i < numlines; i++) |
795 | { | 786 | { |
796 | if (m_pipeout != NULL) | 787 | if (m_pipeout != NULL) |
797 | { | 788 | { |
798 | QString outstr = toQString(textarray[i]->data()); | 789 | QString outstr = toQString(textarray[i]->data()); |
799 | if (!outstr.isEmpty()) | 790 | if (!outstr.isEmpty()) |
800 | { | 791 | { |
801 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 792 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
802 | fflush(m_pipeout); | 793 | fflush(m_pipeout); |
803 | } | 794 | } |
804 | } | 795 | } |
805 | } | 796 | } |
806 | #endif | 797 | #endif |
807 | ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); | 798 | ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); |
808 | #ifdef USEQPE | 799 | #ifdef USEQPE |
809 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 800 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
810 | #endif | 801 | #endif |
811 | } | 802 | } |
812 | emit OnRedraw(); | 803 | emit OnRedraw(); |
813 | } | 804 | } |
814 | } | 805 | } |
815 | 806 | ||
816 | void QTReader::autoscroll() | 807 | void QTReader::autoscroll() |
817 | { | 808 | { |
818 | timer->start(real_delay(), false); | 809 | timer->start(real_delay(), false); |
819 | } | 810 | } |
820 | 811 | ||
821 | void QTReader::setfont() | 812 | void QTReader::setfont() |
822 | { | 813 | { |
823 | // m_fontControl.Change | 814 | // m_fontControl.Change |
824 | m_charWidth = (m_charpc*m_fontControl.currentsize())/100; | 815 | m_charWidth = (m_charpc*m_fontControl.currentsize())/100; |
825 | if (m_charWidth <= 0) m_charWidth = 1; | 816 | if (m_charWidth <= 0) m_charWidth = 1; |
826 | m_ascent = m_fontControl.ascent(); | 817 | m_ascent = m_fontControl.ascent(); |
827 | m_descent = m_fontControl.descent(); | 818 | m_descent = m_fontControl.descent(); |
828 | m_linespacing = m_fontControl.lineSpacing(); | 819 | m_linespacing = m_fontControl.lineSpacing(); |
829 | } | 820 | } |
830 | 821 | ||
831 | void QTReader::drawFonts( QPainter *p ) | 822 | void QTReader::drawFonts( QPainter *p ) |
832 | { | 823 | { |
833 | if (bDoUpdates) | 824 | if (bDoUpdates) |
834 | { | 825 | { |
835 | //qDebug("How refreshing..."); | 826 | //qDebug("How refreshing..."); |
836 | if (buffdoc.empty()) return; | 827 | if (buffdoc.empty()) return; |
837 | setfont(); | 828 | setfont(); |
838 | if (m_lastwidth != width()) | 829 | if (m_lastwidth != width()) |
839 | { | 830 | { |
840 | // qDebug("Not Optimised %d", m_lastwidth); | 831 | // qDebug("Not Optimised %d", m_lastwidth); |
841 | m_lastwidth = width(); | 832 | m_lastwidth = width(); |
842 | m_lastheight = height(); | 833 | m_lastheight = height(); |
843 | buffdoc.setwidth(m_lastwidth-2*m_border); | 834 | buffdoc.setwidth(m_lastwidth-2*m_border); |
844 | locate(pagelocate()); | 835 | locate(pagelocate()); |
845 | // qDebug("Not Optimised %d", m_lastwidth); | 836 | // qDebug("Not Optimised %d", m_lastwidth); |
846 | } | 837 | } |
847 | else | 838 | else |
848 | { | 839 | { |
849 | int newht = height(); | 840 | int newht = height(); |
850 | if (m_lastheight > newht) | 841 | if (m_lastheight > newht) |
851 | { | 842 | { |
852 | // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht); | 843 | // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht); |
853 | int ypos = 0; | 844 | int ypos = 0; |
854 | for (int i = 0; i < numlines; i++) | 845 | for (int i = 0; i < numlines; i++) |
855 | { | 846 | { |
856 | if ((ypos += textarray[i]->lineSpacing()) > newht) | 847 | if ((ypos += textarray[i]->lineSpacing()) > newht) |
857 | { | 848 | { |
858 | numlines = i; | 849 | numlines = i; |
859 | jumpto(mylastpos = locnarray[i+1]); | 850 | jumpto(mylastpos = locnarray[i+1]); |
860 | break; | 851 | break; |
861 | } | 852 | } |
862 | } | 853 | } |
863 | // qDebug("Optimised < %d", numlines); | 854 | // qDebug("Optimised < %d", numlines); |
864 | m_lastheight = newht; | 855 | m_lastheight = newht; |
865 | } | 856 | } |
866 | else if (m_lastheight < newht) | 857 | else if (m_lastheight < newht) |
867 | { | 858 | { |
868 | // qDebug("Optimised > %d", numlines); | 859 | // qDebug("Optimised > %d", numlines); |
869 | int ypos = 0; | 860 | int ypos = 0; |
870 | for (int i = 0; i <= numlines; i++) | 861 | for (int i = 0; i <= numlines; i++) |
871 | { | 862 | { |
872 | ypos += textarray[i]->lineSpacing(); | 863 | ypos += textarray[i]->lineSpacing(); |
873 | } | 864 | } |
874 | fillbuffer(numlines+1, ypos, newht); | 865 | fillbuffer(numlines+1, ypos, newht); |
875 | // qDebug("Optimised > %d", numlines); | 866 | // qDebug("Optimised > %d", numlines); |
876 | } | 867 | } |
877 | if (numlines > 0) | 868 | if (numlines > 0) |
878 | { | 869 | { |
879 | int ypos = textarray[0]->ascent(); | 870 | int ypos = textarray[0]->ascent(); |
880 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_border); | 871 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_border); |
881 | // int last = (m_showlast) ? numlines : numlines-1; | 872 | // int last = (m_showlast) ? numlines : numlines-1; |
882 | // for (int i = 1; i <= last; i++) | 873 | // for (int i = 1; i <= last; i++) |
883 | for (int i = 1; i < numlines; i++) | 874 | for (int i = 1; i < numlines; i++) |
884 | { | 875 | { |
885 | // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; | 876 | // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; |
886 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ | 877 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ |
887 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; | 878 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; |
888 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_border); | 879 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_border); |
889 | } | 880 | } |
890 | // mylastpos = locate(); | 881 | // mylastpos = locate(); |
891 | } | 882 | } |
892 | } | 883 | } |
893 | 884 | ||
894 | m_scrolldy1 = m_scrolldy2 = m_scrollpart; | 885 | m_scrolldy1 = m_scrolldy2 = m_scrollpart; |
895 | if (m_border > 5 && !buffdoc.empty()) | 886 | if (m_border > 5 && !buffdoc.empty()) |
896 | { | 887 | { |
897 | p->fillRect(width()-2, 0, 2, height(), cyan); | 888 | p->fillRect(width()-2, 0, 2, height(), cyan); |
898 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); | 889 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); |
899 | int mid = (height()*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); | 890 | int mid = (height()*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); |
900 | p->fillRect(width()-2, mid-5, 2, 10, yellow); | 891 | p->fillRect(width()-2, mid-5, 2, 10, yellow); |
901 | p->fillRect(width()-2, (height()*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize, 2, ((locnarray[numlines]-locnarray[0])*height()+sectionsize/2)/sectionsize, magenta); | 892 | p->fillRect(width()-2, (height()*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize, 2, ((locnarray[numlines]-locnarray[0])*height()+sectionsize/2)/sectionsize, magenta); |
902 | } | 893 | } |
903 | 894 | ||
904 | emit OnRedraw(); | 895 | emit OnRedraw(); |
905 | } | 896 | } |
906 | /* | 897 | /* |
907 | else | 898 | else |
908 | { | 899 | { |
909 | qDebug("Not so refreshing..."); | 900 | qDebug("Not so refreshing..."); |
910 | } | 901 | } |
911 | */ | 902 | */ |
912 | } | 903 | } |
913 | 904 | ||
914 | QString QTReader::firstword() | 905 | QString QTReader::firstword() |
915 | { | 906 | { |
916 | if (m_bMonoSpaced) | 907 | if (m_bMonoSpaced) |
917 | { | 908 | { |
918 | return toQString(textarray[0]->data()); | 909 | return toQString(textarray[0]->data()); |
919 | } | 910 | } |
920 | else | 911 | else |
921 | { | 912 | { |
922 | int start, end, len, j; | 913 | int start, end, len, j; |
923 | for (j = 0; j < numlines; j++) | 914 | for (j = 0; j < numlines; j++) |
924 | { | 915 | { |
925 | len = textarray[j]->length(); | 916 | len = textarray[j]->length(); |
926 | for (start = 0; start < len && !isalpha((*textarray[j])[start]); start++); | 917 | for (start = 0; start < len && !isalpha((*textarray[j])[start]); start++); |
927 | if (start < len) break; | 918 | if (start < len) break; |
928 | } | 919 | } |
929 | if (j < numlines) | 920 | if (j < numlines) |
930 | { | 921 | { |
931 | QString ret = ""; | 922 | QString ret = ""; |
932 | for (end = start; end < len && isalpha((*textarray[j])[end]); end++) | 923 | for (end = start; end < len && isalpha((*textarray[j])[end]); end++) |
933 | ret += (*textarray[j])[end]; | 924 | ret += (*textarray[j])[end]; |
934 | if (ret.isEmpty()) ret = "Current position"; | 925 | if (ret.isEmpty()) ret = "Current position"; |
935 | return ret; | 926 | return ret; |
936 | } | 927 | } |
937 | else | 928 | else |
938 | return "Current position"; | 929 | return "Current position"; |
939 | } | 930 | } |
940 | } | 931 | } |
941 | 932 | ||
942 | // | 933 | // |
943 | // Construct the QTReader with buttons. | 934 | // Construct the QTReader with buttons. |
944 | // | 935 | // |
945 | 936 | ||
946 | bool QTReader::ChangeFont(int tgt) | 937 | bool QTReader::ChangeFont(int tgt) |
947 | { | 938 | { |
948 | return m_fontControl.ChangeFont(m_fontname, tgt); | 939 | return m_fontControl.ChangeFont(m_fontname, tgt); |
949 | } | 940 | } |
950 | 941 | ||
951 | void QTReader::init() | 942 | void QTReader::init() |
952 | { | 943 | { |
953 | // m_showlast = true; | 944 | // m_showlast = true; |
954 | // setCaption( "Qt Draw Demo Application" ); | 945 | // setCaption( "Qt Draw Demo Application" ); |
955 | 946 | ||
956 | buffdoc.unsuspend(); | 947 | buffdoc.unsuspend(); |
957 | setBackgroundColor( white ); | 948 | setBackgroundColor( white ); |
958 | // QPainter p(this); | 949 | // QPainter p(this); |
959 | // p.setBackgroundMode( Qt::OpaqueMode ); | 950 | // p.setBackgroundMode( Qt::OpaqueMode ); |
960 | buffdoc.setfilter(getfilter()); | 951 | buffdoc.setfilter(getfilter()); |
961 | ChangeFont(m_textsize); | 952 | ChangeFont(m_textsize); |
962 | setFocusPolicy(QWidget::StrongFocus); | 953 | setFocusPolicy(QWidget::StrongFocus); |
963 | // resize( 240, 320 ); | 954 | // resize( 240, 320 ); |
964 | //setFocus(); | 955 | //setFocus(); |
965 | timer = new QTimer(this); | 956 | timer = new QTimer(this); |
966 | connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); | 957 | connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); |
967 | // QMessageBox::information(this, "init", m_lastfile, 1); | 958 | // QMessageBox::information(this, "init", m_lastfile, 1); |
968 | setfont(); | 959 | setfont(); |
969 | /* | 960 | /* |
970 | if (!m_lastfile.isEmpty()) | 961 | if (!m_lastfile.isEmpty()) |
971 | { | 962 | { |
972 | m_string = DocLnk(m_lastfile).name(); | 963 | m_string = DocLnk(m_lastfile).name(); |
973 | load_file(m_lastfile); | 964 | load_file(m_lastfile); |
974 | } | 965 | } |
975 | */ | 966 | */ |
976 | } | 967 | } |
977 | 968 | ||
978 | // | 969 | // |
979 | // Clean up | 970 | // Clean up |
980 | // | 971 | // |
981 | QTReader::~QTReader() | 972 | QTReader::~QTReader() |
982 | { | 973 | { |
983 | #ifdef USEQPE | 974 | #ifdef USEQPE |
984 | if (m_autoScroll) | 975 | if (m_autoScroll) |
985 | { | 976 | { |
986 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 977 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
987 | } | 978 | } |
988 | #endif | 979 | #endif |
989 | #ifdef _SCROLLPIPE | 980 | #ifdef _SCROLLPIPE |
990 | if (m_pipeout != NULL) | 981 | if (m_pipeout != NULL) |
991 | { | 982 | { |
992 | fclose(m_pipeout); | 983 | fclose(m_pipeout); |
993 | } | 984 | } |
994 | #endif | 985 | #endif |
995 | } | 986 | } |
996 | 987 | ||
997 | // | 988 | // |
998 | // Calls the drawing function as specified by the radio buttons. | 989 | // Calls the drawing function as specified by the radio buttons. |
999 | // | 990 | // |
1000 | 991 | ||
1001 | void QTReader::drawIt( QPainter *p ) | 992 | void QTReader::drawIt( QPainter *p ) |
1002 | { | 993 | { |
1003 | drawFonts(p); | 994 | drawFonts(p); |
1004 | } | 995 | } |
1005 | 996 | ||
1006 | // | 997 | // |
1007 | // Called when the print button is clicked. | 998 | // Called when the print button is clicked. |
1008 | // | 999 | // |
1009 | /* | 1000 | /* |
1010 | void QTReader::printIt() | 1001 | void QTReader::printIt() |
1011 | { | 1002 | { |
1012 | #ifndef QT_NO_PRINTER | 1003 | #ifndef QT_NO_PRINTER |
1013 | if ( printer->setup( this ) ) { | 1004 | if ( printer->setup( this ) ) { |
1014 | QPainter paint; | 1005 | QPainter paint; |
1015 | if ( !paint.begin( printer ) ) | 1006 | if ( !paint.begin( printer ) ) |
1016 | return; | 1007 | return; |
1017 | drawIt( &paint ); | 1008 | drawIt( &paint ); |
1018 | } | 1009 | } |
1019 | #endif | 1010 | #endif |
1020 | } | 1011 | } |
1021 | */ | 1012 | */ |
1022 | // | 1013 | // |
1023 | // Called when the widget needs to be updated. | 1014 | // Called when the widget needs to be updated. |
1024 | // | 1015 | // |
1025 | 1016 | ||
1026 | void QTReader::paintEvent( QPaintEvent * ) | 1017 | void QTReader::paintEvent( QPaintEvent * ) |
1027 | { | 1018 | { |
1028 | QPainter paint( this ); | 1019 | QPainter paint( this ); |
1029 | drawIt( &paint ); | 1020 | drawIt( &paint ); |
1030 | } | 1021 | } |
1031 | 1022 | ||
1032 | // | 1023 | // |
1033 | // Called when the widget has been resized. | 1024 | // Called when the widget has been resized. |
1034 | // Moves the button group to the upper right corner | 1025 | // Moves the button group to the upper right corner |
1035 | // of the widget. | 1026 | // of the widget. |
1036 | 1027 | ||
1037 | /* | 1028 | /* |
1038 | void QTReader::resizeEvent( QResizeEvent * ) | 1029 | void QTReader::resizeEvent( QResizeEvent * ) |
1039 | { | 1030 | { |
1040 | // // qDebug("resize:(%u,%u)", width(), height()); | 1031 | // // qDebug("resize:(%u,%u)", width(), height()); |
1041 | // bgroup->move( width()-bgroup->width(), 0 ); | 1032 | // bgroup->move( width()-bgroup->width(), 0 ); |
1042 | } | 1033 | } |
1043 | */ | 1034 | */ |
1044 | 1035 | ||
1045 | // | 1036 | // |
1046 | // Create and display our widget. | 1037 | // Create and display our widget. |
1047 | // | 1038 | // |
1048 | /* | 1039 | /* |
1049 | int main( int argc, tchar **argv ) | 1040 | int main( int argc, tchar **argv ) |
1050 | { | 1041 | { |
1051 | QApplication app( argc, argv ); | 1042 | QApplication app( argc, argv ); |
1052 | QTReader draw; | 1043 | QTReader draw; |
1053 | app.setMainWidget( &draw ); | 1044 | app.setMainWidget( &draw ); |
1054 | draw.setCaption("Qt Example - Drawdemo"); | 1045 | draw.setCaption("Qt Example - Drawdemo"); |
1055 | draw.show(); | 1046 | draw.show(); |
1056 | return app.exec(); | 1047 | return app.exec(); |
1057 | } | 1048 | } |
1058 | */ | 1049 | */ |
1059 | 1050 | ||
1060 | 1051 | ||
1061 | bool QTReader::locate(unsigned long n) { | 1052 | bool QTReader::locate(unsigned long n) { |
1062 | //printf("Locate\n"); | 1053 | //printf("Locate\n"); |
1063 | buffdoc.unsuspend(); | 1054 | buffdoc.unsuspend(); |
1064 | buffdoc.locate(n); | 1055 | buffdoc.locate(n); |
1065 | // // qDebug("&buffdoc.located"); | 1056 | // // qDebug("&buffdoc.located"); |
1066 | fillbuffer(); | 1057 | fillbuffer(); |
1067 | // // qDebug("&Buffer filled"); | 1058 | // // qDebug("&Buffer filled"); |
1068 | update(); | 1059 | update(); |
1069 | // // qDebug("&Located"); | 1060 | // // qDebug("&Located"); |
1070 | return true; | 1061 | return true; |
1071 | } | 1062 | } |
1072 | 1063 | ||
1073 | unsigned int QTReader::screenlines() | 1064 | unsigned int QTReader::screenlines() |
1074 | { | 1065 | { |
1075 | // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; | 1066 | // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; |
1076 | // return (height()-m_descent)/(m_linespacing); | 1067 | // return (height()-m_descent)/(m_linespacing); |
1077 | return (height()-2)/(m_linespacing); | 1068 | return (height()-2)/(m_linespacing); |
1078 | }; | 1069 | }; |
1079 | 1070 | ||
1080 | bool QTReader::fillbuffer(int reuse, int ht, int newht) | 1071 | bool QTReader::fillbuffer(int reuse, int ht, int newht) |
1081 | { | 1072 | { |
1082 | buffdoc.unsuspend(); | 1073 | buffdoc.unsuspend(); |
1083 | if (buffdoc.empty()) return false; | 1074 | if (buffdoc.empty()) return false; |
1084 | if (newht < 0) | 1075 | if (newht < 0) |
1085 | m_lastheight = height(); | 1076 | m_lastheight = height(); |
1086 | else | 1077 | else |
1087 | m_lastheight = newht; | 1078 | m_lastheight = newht; |
1088 | int ch; | 1079 | int ch; |
1089 | bool ret = false; | 1080 | bool ret = false; |
1090 | unsigned int oldpagepos = locnarray[reuse]; | 1081 | unsigned int oldpagepos = locnarray[reuse]; |
1091 | int lastypos = ht, ypos = ht; | 1082 | int lastypos = ht, ypos = ht; |
1092 | numlines = reuse; | 1083 | numlines = reuse; |
1093 | while (ypos < m_lastheight || numlines < 2) | 1084 | while (ypos < m_lastheight || numlines < 2) |
1094 | { | 1085 | { |
1095 | lastypos = ypos; | 1086 | lastypos = ypos; |
1096 | if (textarray[numlines] == NULL) | 1087 | if (textarray[numlines] == NULL) |
1097 | { | 1088 | { |
1098 | textarray[numlines] = new CDrawBuffer(&m_fontControl); | 1089 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
1099 | } | 1090 | } |
1100 | locnarray[numlines] = locate(); | 1091 | locnarray[numlines] = locate(); |
1101 | int ch = getline(textarray[numlines]); | 1092 | int ch = getline(textarray[numlines]); |
1102 | ypos += textarray[numlines]->lineSpacing(); | 1093 | ypos += textarray[numlines]->lineSpacing(); |
1103 | numlines++; | 1094 | numlines++; |
1104 | if (!ch) | 1095 | if (!ch) |
1105 | { | 1096 | { |
1106 | if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/) | 1097 | if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/) |
1107 | { | 1098 | { |
1108 | locate(oldpagepos); | 1099 | locate(oldpagepos); |
1109 | return false; | 1100 | return false; |
1110 | } | 1101 | } |
1111 | else | 1102 | else |
1112 | { | 1103 | { |
1113 | --numlines; | 1104 | --numlines; |
1114 | mylastpos = locate(); | 1105 | mylastpos = locate(); |
1115 | return true; | 1106 | return true; |
1116 | } | 1107 | } |
1117 | } | 1108 | } |
1118 | } | 1109 | } |
1119 | 1110 | ||
1120 | --numlines; | 1111 | --numlines; |
1121 | mylastpos = locate(); | 1112 | mylastpos = locate(); |
1122 | m_scrolldy1 = m_scrolldy2 = m_scrollpart = m_lastheight - lastypos; | 1113 | m_scrolldy1 = m_scrolldy2 = m_scrollpart = m_lastheight - lastypos; |
1123 | 1114 | ||
1124 | return true; | 1115 | return true; |
1125 | } | 1116 | } |
1126 | 1117 | ||
1127 | void QTReader::dopagedn() | 1118 | void QTReader::dopagedn() |
1128 | { | 1119 | { |
1129 | // qDebug("HEIGHT(2):%d", m_lastheight); | 1120 | // qDebug("HEIGHT(2):%d", m_lastheight); |
1130 | buffdoc.unsuspend(); | 1121 | buffdoc.unsuspend(); |
1131 | int skip = 0, ypos = 0; | 1122 | int skip = 0, ypos = 0; |
1132 | if (locate() != mylastpos) | 1123 | if (locate() != mylastpos) |
1133 | { | 1124 | { |
1134 | ////qDebug("Jumping to %u", mylastpos); | 1125 | ////qDebug("Jumping to %u", mylastpos); |
1135 | jumpto(mylastpos); | 1126 | jumpto(mylastpos); |
1136 | } | 1127 | } |
1137 | CDrawBuffer* reusebuffer = textarray[numlines]; | 1128 | CDrawBuffer* reusebuffer = textarray[numlines]; |
1138 | if (reusebuffer != NULL && reusebuffer->eof()) return; | 1129 | if (reusebuffer != NULL && reusebuffer->eof()) return; |
1139 | if (reusebuffer != NULL) | 1130 | if (reusebuffer != NULL) |
1140 | { | 1131 | { |
1141 | for (int i = 0; i <= m_overlap; i++) | 1132 | for (int i = 0; i <= m_overlap; i++) |
1142 | { | 1133 | { |
1143 | int offset = numlines - m_overlap + i; | 1134 | int offset = numlines - m_overlap + i; |
1144 | reusebuffer = textarray[offset]; | 1135 | reusebuffer = textarray[offset]; |
1145 | size_t reuselocn = locnarray[offset]; | 1136 | size_t reuselocn = locnarray[offset]; |
1146 | textarray[offset] = textarray[i]; | 1137 | textarray[offset] = textarray[i]; |
1147 | textarray[i] = reusebuffer; | 1138 | textarray[i] = reusebuffer; |
1148 | // reusebuffer->empty(); | 1139 | // reusebuffer->empty(); |
1149 | locnarray[offset] = locnarray[i]; | 1140 | locnarray[offset] = locnarray[i]; |
1150 | locnarray[i] = reuselocn; | 1141 | locnarray[i] = reuselocn; |
1151 | ypos += textarray[i]->lineSpacing(); | 1142 | ypos += textarray[i]->lineSpacing(); |
1152 | skip++; | 1143 | skip++; |
1153 | } | 1144 | } |
1154 | } | 1145 | } |
1155 | if (fillbuffer(skip, ypos)) | 1146 | if (fillbuffer(skip, ypos)) |
1156 | { | 1147 | { |
1157 | update(); | 1148 | update(); |
1158 | } | 1149 | } |
1159 | } | 1150 | } |
1160 | 1151 | ||
1161 | void QTReader::dopageup() | 1152 | void QTReader::dopageup() |
1162 | { | 1153 | { |
1163 | buffdoc.unsuspend(); | 1154 | buffdoc.unsuspend(); |
1164 | dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]); | 1155 | dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]); |
1165 | } | 1156 | } |
1166 | 1157 | ||
1167 | bool QTReader::synch(size_t start, size_t end) | 1158 | bool QTReader::synch(size_t start, size_t end) |
1168 | { | 1159 | { |
1169 | jumpto(start); | 1160 | jumpto(start); |
1170 | while (start++ < end) | 1161 | while (start++ < end) |
1171 | { | 1162 | { |
1172 | tchar ch = getch(); | 1163 | tchar ch = getch(); |
1173 | if (ch == 10) return true; | 1164 | if (ch == 10) return true; |
1174 | if (ch == UEOF) return false; | 1165 | if (ch == UEOF) return false; |
1175 | } | 1166 | } |
1176 | return false; | 1167 | return false; |
1177 | } | 1168 | } |
1178 | 1169 | ||
1179 | void QTReader::dopageup(unsigned int target) | 1170 | void QTReader::dopageup(unsigned int target) |
1180 | { | 1171 | { |
1181 | buffdoc.unsuspend(); | 1172 | buffdoc.unsuspend(); |
1182 | CBufferFace<CDrawBuffer*> buff; | 1173 | CBufferFace<CDrawBuffer*> buff; |
1183 | CBufferFace<size_t> loc; | 1174 | CBufferFace<size_t> loc; |
1184 | 1175 | ||
1185 | size_t delta, guess = 2*(locate()-pagelocate()), lastdelta = 0; | 1176 | size_t delta, guess = 2*(locate()-pagelocate()), lastdelta = 0; |
1186 | bool ch = true; | 1177 | bool ch = true; |
1187 | int nbfl, ypos = 0; | 1178 | int nbfl, ypos = 0; |
1188 | if (guess < 128) guess = 128; | 1179 | if (guess < 128) guess = 128; |
1189 | while (1) | 1180 | while (1) |
1190 | { | 1181 | { |
1191 | ch = true; | 1182 | ch = true; |
1192 | if (target < guess) | 1183 | if (target < guess) |
1193 | { | 1184 | { |
1194 | delta = 0; // 0 is a flag to say don't guess any more | 1185 | delta = 0; // 0 is a flag to say don't guess any more |
1195 | jumpto( (m_continuousDocument) ? 0 : buffdoc.startSection() ); | 1186 | jumpto( (m_continuousDocument) ? 0 : buffdoc.startSection() ); |
1196 | } | 1187 | } |
1197 | else if (!m_continuousDocument && (target - guess < buffdoc.startSection())) | 1188 | else if (!m_continuousDocument && (target - guess < buffdoc.startSection())) |
1198 | { | 1189 | { |
1199 | delta = 0; // 0 is a flag to say don't guess any more | 1190 | delta = 0; // 0 is a flag to say don't guess any more |
1200 | jumpto(buffdoc.startSection()); | 1191 | jumpto(buffdoc.startSection()); |
1201 | } | 1192 | } |
1202 | else | 1193 | else |
1203 | { | 1194 | { |
1204 | delta = guess; | 1195 | delta = guess; |
1205 | if (!synch(target-delta, target-lastdelta)) | 1196 | if (!synch(target-delta, target-lastdelta)) |
1206 | { | 1197 | { |
1207 | lastdelta = delta; | 1198 | lastdelta = delta; |
1208 | if (guess < 4000) | 1199 | if (guess < 4000) |
1209 | { | 1200 | { |
1210 | guess <<= 1; | 1201 | guess <<= 1; |
1211 | continue; | 1202 | continue; |
1212 | } | 1203 | } |
1213 | else | 1204 | else |
1214 | { | 1205 | { |
1215 | jumpto(target-delta); | 1206 | jumpto(target-delta); |
1216 | } | 1207 | } |
1217 | } | 1208 | } |
1218 | } | 1209 | } |
1219 | 1210 | ||
1220 | nbfl = 0; | 1211 | nbfl = 0; |
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index 07af597..e759249 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -1,4222 +1,4221 @@ | |||
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" | 20 | #include "useqpe.h" |
21 | #include <qregexp.h> | 21 | #include <qregexp.h> |
22 | #include <qclipboard.h> | 22 | #include <qclipboard.h> |
23 | #include <qwidgetstack.h> | 23 | #include <qwidgetstack.h> |
24 | #ifdef USEQPE | 24 | #ifdef USEQPE |
25 | #include <qmenubar.h> | 25 | #include <qmenubar.h> |
26 | #include <qpe/qpetoolbar.h> | 26 | #include <qpe/qpetoolbar.h> |
27 | #endif | 27 | #endif |
28 | #include <qmenubar.h> | 28 | #include <qmenubar.h> |
29 | #include <qtoolbar.h> | 29 | #include <qtoolbar.h> |
30 | #ifdef USEQPE | 30 | #ifdef USEQPE |
31 | #include <qpe/menubutton.h> | 31 | #include <qpe/menubutton.h> |
32 | #include <qpe/fontdatabase.h> | 32 | #include <qpe/fontdatabase.h> |
33 | #endif | 33 | #endif |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qaction.h> | 36 | #include <qaction.h> |
37 | #include <qapplication.h> | 37 | #include <qapplication.h> |
38 | #include <qlineedit.h> | 38 | #include <qlineedit.h> |
39 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | #include <qobjectlist.h> | 41 | #include <qobjectlist.h> |
42 | #ifdef USEQPE | 42 | #ifdef USEQPE |
43 | #include <qpe/global.h> | 43 | #include <qpe/global.h> |
44 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
45 | #endif | 45 | #endif |
46 | #include <qfileinfo.h> | 46 | #include <qfileinfo.h> |
47 | #include <stdlib.h> //getenv | 47 | #include <stdlib.h> //getenv |
48 | #include <qprogressbar.h> | 48 | #include <qprogressbar.h> |
49 | #ifdef USEQPE | 49 | #ifdef USEQPE |
50 | #include <qpe/config.h> | 50 | #include <qpe/config.h> |
51 | #endif | 51 | #endif |
52 | #include <qbuttongroup.h> | 52 | #include <qbuttongroup.h> |
53 | #include <qradiobutton.h> | 53 | #include <qradiobutton.h> |
54 | #ifdef USEQPE | 54 | #ifdef USEQPE |
55 | #include <qpe/qcopenvelope_qws.h> | 55 | #include <qpe/qcopenvelope_qws.h> |
56 | #endif | 56 | #endif |
57 | #include "QTReader.h" | 57 | #include "QTReader.h" |
58 | #include "GraphicWin.h" | 58 | #include "GraphicWin.h" |
59 | #include "Bkmks.h" | 59 | #include "Bkmks.h" |
60 | #include "cbkmkselector.h" | 60 | #include "cbkmkselector.h" |
61 | #include "infowin.h" | 61 | #include "infowin.h" |
62 | #include "ToolbarPrefs.h" | 62 | #include "ToolbarPrefs.h" |
63 | #include "Prefs.h" | 63 | #include "Prefs.h" |
64 | #include "CAnnoEdit.h" | 64 | #include "CAnnoEdit.h" |
65 | #include "QFloatBar.h" | 65 | #include "QFloatBar.h" |
66 | #include "FixedFont.h" | 66 | #include "FixedFont.h" |
67 | #include "URLDialog.h" | 67 | #include "URLDialog.h" |
68 | //#include <qpe/fontdatabase.h> | 68 | //#include <qpe/fontdatabase.h> |
69 | 69 | ||
70 | #ifdef USEQPE | 70 | #ifdef USEQPE |
71 | #include <qpe/resource.h> | 71 | #include <qpe/resource.h> |
72 | #include <qpe/qpeapplication.h> | 72 | #include <qpe/qpeapplication.h> |
73 | #include "fileBrowser.h" | 73 | #include "fileBrowser.h" |
74 | #else | 74 | #else |
75 | #include "qfiledialog.h" | 75 | #include "qfiledialog.h" |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | #include "QTReaderApp.h" | 78 | #include "QTReaderApp.h" |
79 | #include "CDrawBuffer.h" | 79 | #include "CDrawBuffer.h" |
80 | #include "Filedata.h" | 80 | #include "Filedata.h" |
81 | #include "opie.h" | 81 | #include "opie.h" |
82 | #include "useqpe.h" | 82 | #include "names.h" |
83 | #include "names.h" | 83 | #include "CEncoding_tables.h" |
84 | #include "CEncoding_tables.h" | 84 | #include "CloseDialog.h" |
85 | #include "CloseDialog.h" | 85 | |
86 | 86 | bool CheckVersion(int&, int&, char&); | |
87 | bool CheckVersion(int&, int&, char&); | 87 | |
88 | 88 | #ifdef _WINDOWS | |
89 | #ifdef _WINDOWS | 89 | #define PICDIR "c:\\uqtreader\\pics\\" |
90 | #define PICDIR "c:\\uqtreader\\pics\\" | 90 | #else |
91 | #else | 91 | #ifdef USEQPE |
92 | #ifdef USEQPE | 92 | #define PICDIR "opie-reader/" |
93 | #define PICDIR "opie-reader/" | 93 | #else |
94 | #else | 94 | #define PICDIR "/home/tim/uqtreader/pics/" |
95 | #define PICDIR "/home/tim/uqtreader/pics/" | 95 | #endif |
96 | #endif | 96 | #endif |
97 | #endif | 97 | |
98 | 98 | unsigned long QTReaderApp::m_uid = 0; | |
99 | unsigned long QTReaderApp::m_uid = 0; | 99 | |
100 | 100 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } | |
101 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } | 101 | |
102 | 102 | #ifdef USEQPE | |
103 | #ifdef USEQPE | 103 | #define geticon(iconname) Resource::loadPixmap( iconname ) |
104 | #define geticon(iconname) Resource::loadPixmap( iconname ) | 104 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) |
105 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) | 105 | #else |
106 | #else | 106 | #define geticon(iconname) QPixmap(PICDIR iconname ".png") |
107 | #define geticon(iconname) QPixmap(PICDIR iconname ".png") | 107 | #define getmyicon(iconname) geticon(iconname) |
108 | #define getmyicon(iconname) geticon(iconname) | 108 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) |
109 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) | 109 | #endif |
110 | #endif | 110 | |
111 | 111 | #ifndef _WINDOWS | |
112 | #ifndef _WINDOWS | 112 | #include <unistd.h> |
113 | #include <unistd.h> | 113 | #endif |
114 | #endif | 114 | #include <stddef.h> |
115 | #include <stddef.h> | 115 | #ifndef _WINDOWS |
116 | #ifndef _WINDOWS | 116 | #include <dirent.h> |
117 | #include <dirent.h> | 117 | #endif |
118 | #endif | 118 | |
119 | 119 | void QTReaderApp::listBkmkFiles() | |
120 | void QTReaderApp::listBkmkFiles() | 120 | { |
121 | { | 121 | bkmkselector->clear(); |
122 | bkmkselector->clear(); | 122 | bkmkselector->setText("Cancel"); |
123 | bkmkselector->setText("Cancel"); | 123 | #ifndef USEQPE |
124 | #ifndef USEQPE | 124 | int cnt = 0; |
125 | int cnt = 0; | 125 | |
126 | 126 | QDir d = QDir::home(); // "/" | |
127 | QDir d = QDir::home(); // "/" | 127 | if ( !d.cd(APPDIR) ) { // "/tmp" |
128 | if ( !d.cd(APPDIR) ) { // "/tmp" | 128 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
129 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 129 | d = QDir::home(); |
130 | d = QDir::home(); | 130 | d.mkdir(APPDIR); |
131 | d.mkdir(APPDIR); | 131 | d.cd(APPDIR); |
132 | d.cd(APPDIR); | 132 | } |
133 | } | 133 | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | ||
137 | 137 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | |
138 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 138 | // d.setSorting( QDir::Size | QDir::Reversed ); |
139 | // d.setSorting( QDir::Size | QDir::Reversed ); | 139 | |
140 | 140 | const QFileInfoList *list = d.entryInfoList(); | |
141 | const QFileInfoList *list = d.entryInfoList(); | 141 | QFileInfoListIterator it( *list ); // create list iterator |
142 | QFileInfoListIterator it( *list ); // create list iterator | 142 | QFileInfo *fi; // pointer for traversing |
143 | QFileInfo *fi; // pointer for traversing | 143 | |
144 | 144 | while ( (fi=it.current()) ) { // for each file... | |
145 | while ( (fi=it.current()) ) { // for each file... | 145 | |
146 | 146 | bkmkselector->insertItem(fi->fileName()); | |
147 | bkmkselector->insertItem(fi->fileName()); | 147 | cnt++; |
148 | cnt++; | 148 | |
149 | 149 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | |
150 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | 150 | ++it; // goto next list element |
151 | ++it; // goto next list element | 151 | } |
152 | } | 152 | |
153 | 153 | #else /* USEQPE */ | |
154 | #else /* USEQPE */ | 154 | int cnt = 0; |
155 | int cnt = 0; | 155 | DIR *d; |
156 | DIR *d; | 156 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); |
157 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); | 157 | |
158 | 158 | while(1) | |
159 | while(1) | 159 | { |
160 | { | 160 | struct dirent* de; |
161 | struct dirent* de; | 161 | struct stat buf; |
162 | struct stat buf; | 162 | de = readdir(d); |
163 | de = readdir(d); | 163 | if (de == NULL) break; |
164 | if (de == NULL) break; | 164 | |
165 | 165 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | |
166 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 166 | { |
167 | { | 167 | bkmkselector->insertItem(de->d_name); |
168 | bkmkselector->insertItem(de->d_name); | 168 | cnt++; |
169 | cnt++; | 169 | } |
170 | } | 170 | } |
171 | } | 171 | |
172 | 172 | closedir(d); | |
173 | closedir(d); | 173 | #endif |
174 | #endif | 174 | if (cnt > 0) |
175 | if (cnt > 0) | 175 | { |
176 | { | 176 | //tjw menu->hide(); |
177 | //tjw menu->hide(); | 177 | editorStack->raiseWidget( bkmkselector ); |
178 | editorStack->raiseWidget( bkmkselector ); | 178 | hidetoolbars(); |
179 | hidetoolbars(); | 179 | m_nBkmkAction = cRmBkmkFile; |
180 | m_nBkmkAction = cRmBkmkFile; | 180 | } |
181 | } | 181 | else |
182 | else | 182 | QMessageBox::information(this, PROGNAME, "No bookmark files"); |
183 | QMessageBox::information(this, PROGNAME, "No bookmark files"); | 183 | } |
184 | } | 184 | |
185 | 185 | void QTReaderApp::hidetoolbars() | |
186 | void QTReaderApp::hidetoolbars() | 186 | { |
187 | { | 187 | menubar->hide(); |
188 | menubar->hide(); | 188 | if (fileBar != NULL) fileBar->hide(); |
189 | if (fileBar != NULL) fileBar->hide(); | 189 | if (viewBar != NULL) viewBar->hide(); |
190 | if (viewBar != NULL) viewBar->hide(); | 190 | if (navBar != NULL) navBar->hide(); |
191 | if (navBar != NULL) navBar->hide(); | 191 | if (markBar != NULL) markBar->hide(); |
192 | if (markBar != NULL) markBar->hide(); | 192 | if (m_fontVisible) m_fontBar->hide(); |
193 | if (m_fontVisible) m_fontBar->hide(); | 193 | if (regVisible) |
194 | if (regVisible) | 194 | { |
195 | { | 195 | #ifdef USEQPE |
196 | #ifdef USEQPE | 196 | Global::hideInputMethod(); |
197 | Global::hideInputMethod(); | 197 | #endif |
198 | #endif | 198 | regBar->hide(); |
199 | regBar->hide(); | 199 | } |
200 | } | 200 | if (searchVisible) |
201 | if (searchVisible) | 201 | { |
202 | { | 202 | #ifdef USEQPE |
203 | #ifdef USEQPE | 203 | Global::hideInputMethod(); |
204 | Global::hideInputMethod(); | 204 | #endif |
205 | #endif | 205 | searchBar->hide(); |
206 | searchBar->hide(); | 206 | } |
207 | } | 207 | } |
208 | } | 208 | |
209 | 209 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |
210 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | 210 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false), |
211 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false), | 211 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL) |
212 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL) | 212 | { |
213 | { | 213 | m_url_clipboard = false; |
214 | m_url_clipboard = false; | 214 | m_url_localfile = false; |
215 | m_url_localfile = false; | 215 | m_url_globalfile = false; |
216 | m_url_globalfile = false; | 216 | ftime(&m_lastkeytime); |
217 | ftime(&m_lastkeytime); | 217 | //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); |
218 | //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); | 218 | //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); |
219 | //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); | 219 | |
220 | 220 | m_bcloseDisabled = true; | |
221 | m_bcloseDisabled = true; | 221 | m_disableesckey = false; |
222 | m_disableesckey = false; | 222 | pBkmklist = NULL; |
223 | pBkmklist = NULL; | 223 | pOpenlist = NULL; |
224 | pOpenlist = NULL; | 224 | // doc = 0; |
225 | // doc = 0; | 225 | |
226 | 226 | m_fBkmksChanged = false; | |
227 | m_fBkmksChanged = false; | 227 | |
228 | 228 | QString lang = getenv( "LANG" ); | |
229 | QString lang = getenv( "LANG" ); | 229 | QString rot = getenv( "QWS_DISPLAY" ); |
230 | QString rot = getenv( "QWS_DISPLAY" ); | 230 | |
231 | 231 | /* | |
232 | /* | 232 | int m_rot = 0; |
233 | int m_rot = 0; | 233 | if (rot.contains("Rot90")) |
234 | if (rot.contains("Rot90")) | 234 | { |
235 | { | 235 | m_rot = 90; |
236 | m_rot = 90; | 236 | } |
237 | } | 237 | else if (rot.contains("Rot180")) |
238 | else if (rot.contains("Rot180")) | 238 | { |
239 | { | 239 | m_rot = 180; |
240 | m_rot = 180; | 240 | } |
241 | } | 241 | else if (rot.contains("Rot270")) |
242 | else if (rot.contains("Rot270")) | 242 | { |
243 | { | 243 | m_rot = 270; |
244 | m_rot = 270; | 244 | } |
245 | } | 245 | |
246 | 246 | // qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); | |
247 | // qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); | 247 | */ |
248 | */ | 248 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; |
249 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; | 249 | |
250 | 250 | #ifdef USEQPE | |
251 | #ifdef USEQPE | 251 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); |
252 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); | 252 | #else |
253 | #else | 253 | setIcon( QPixmap (PICDIR "uqtreader.png") ); |
254 | setIcon( QPixmap (PICDIR "uqtreader.png") ); | 254 | #endif /* USEQPE */ |
255 | #endif /* USEQPE */ | 255 | |
256 | 256 | // QToolBar *bar = new QToolBar( this ); | |
257 | // QToolBar *bar = new QToolBar( this ); | 257 | // menubar = new QToolBar( this ); |
258 | // menubar = new QToolBar( this ); | 258 | #ifdef USEQPE |
259 | #ifdef USEQPE | 259 | Config config( APPDIR ); |
260 | Config config( APPDIR ); | 260 | #else |
261 | #else | 261 | QDir d = QDir::home(); // "/" |
262 | QDir d = QDir::home(); // "/" | 262 | if ( !d.cd(APPDIR) ) { // "/tmp" |
263 | if ( !d.cd(APPDIR) ) { // "/tmp" | 263 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
264 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 264 | d = QDir::home(); |
265 | d = QDir::home(); | 265 | d.mkdir(APPDIR); |
266 | d.mkdir(APPDIR); | 266 | d.cd(APPDIR); |
267 | d.cd(APPDIR); | 267 | } |
268 | } | 268 | QFileInfo fi(d, INIFILE); |
269 | QFileInfo fi(d, INIFILE); | 269 | // qDebug("Path:%s", (const char*)fi.absFilePath()); |
270 | // qDebug("Path:%s", (const char*)fi.absFilePath()); | 270 | Config config(fi.absFilePath()); |
271 | Config config(fi.absFilePath()); | 271 | #endif |
272 | #endif | 272 | config.setGroup("Toolbar"); |
273 | config.setGroup("Toolbar"); | 273 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); |
274 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); | 274 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); |
275 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); | 275 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); |
276 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | 276 | menubar = new QToolBar("Menus", this, m_tbposition); |
277 | menubar = new QToolBar("Menus", this, m_tbposition); | 277 | |
278 | 278 | // fileBar = new QToolBar("File", this); | |
279 | // fileBar = new QToolBar("File", this); | 279 | // QToolBar* viewBar = new QToolBar("File", this); |
280 | // QToolBar* viewBar = new QToolBar("File", this); | 280 | // QToolBar* navBar = new QToolBar("File", this); |
281 | // QToolBar* navBar = new QToolBar("File", this); | 281 | // QToolBar* markBar = new QToolBar("File", this); |
282 | // QToolBar* markBar = new QToolBar("File", this); | 282 | |
283 | 283 | #ifdef USEQPE | |
284 | #ifdef USEQPE | 284 | mb = new QMenuBar( menubar ); |
285 | mb = new QMenuBar( menubar ); | 285 | #else |
286 | #else | 286 | mb = new QMenuBar( menubar ); |
287 | mb = new QMenuBar( menubar ); | 287 | #endif |
288 | #endif | 288 | |
289 | 289 | //#ifdef USEQPE | |
290 | //#ifdef USEQPE | 290 | QPopupMenu* tmp = new QPopupMenu(mb); |
291 | QPopupMenu* tmp = new QPopupMenu(mb); | 291 | mb->insertItem( geticon( "AppsIcon" ), tmp ); |
292 | mb->insertItem( geticon( "AppsIcon" ), tmp ); | 292 | //#else |
293 | //#else | 293 | // QMenuBar* tmp = mb; |
294 | // QMenuBar* tmp = mb; | 294 | //#endif |
295 | //#endif | 295 | |
296 | 296 | QPopupMenu *file = new QPopupMenu( mb ); | |
297 | QPopupMenu *file = new QPopupMenu( mb ); | 297 | tmp->insertItem( tr( "File" ), file ); |
298 | tmp->insertItem( tr( "File" ), file ); | 298 | |
299 | 299 | QPopupMenu *navigation = new QPopupMenu(mb); | |
300 | QPopupMenu *navigation = new QPopupMenu(mb); | 300 | tmp->insertItem( tr( "Navigation" ), navigation ); |
301 | tmp->insertItem( tr( "Navigation" ), navigation ); | 301 | |
302 | 302 | QPopupMenu *view = new QPopupMenu( mb ); | |
303 | QPopupMenu *view = new QPopupMenu( mb ); | 303 | tmp->insertItem( tr( "View" ), view ); |
304 | tmp->insertItem( tr( "View" ), view ); | 304 | |
305 | 305 | QPopupMenu *marks = new QPopupMenu( this ); | |
306 | QPopupMenu *marks = new QPopupMenu( this ); | 306 | tmp->insertItem( tr( "Marks" ), marks ); |
307 | tmp->insertItem( tr( "Marks" ), marks ); | 307 | |
308 | 308 | QPopupMenu *settings = new QPopupMenu( this ); | |
309 | QPopupMenu *settings = new QPopupMenu( this ); | 309 | tmp->insertItem( tr( "Settings" ), settings ); |
310 | tmp->insertItem( tr( "Settings" ), settings ); | 310 | |
311 | 311 | // addToolBar(menubar, "Menus",QMainWindow::Top); | |
312 | // addToolBar(menubar, "Menus",QMainWindow::Top); | 312 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); |
313 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); | 313 | |
314 | 314 | // QPopupMenu *edit = new QPopupMenu( this ); | |
315 | // QPopupMenu *edit = new QPopupMenu( this ); | 315 | |
316 | 316 | /* | |
317 | /* | 317 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
318 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 318 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
319 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 319 | a->addTo( bar ); |
320 | a->addTo( bar ); | 320 | a->addTo( file ); |
321 | a->addTo( file ); | 321 | */ |
322 | */ | 322 | |
323 | 323 | editorStack = new QWidgetStack( this ); | |
324 | editorStack = new QWidgetStack( this ); | 324 | setCentralWidget( editorStack ); |
325 | setCentralWidget( editorStack ); | 325 | |
326 | 326 | searchVisible = FALSE; | |
327 | searchVisible = FALSE; | 327 | regVisible = FALSE; |
328 | regVisible = FALSE; | 328 | m_fontVisible = false; |
329 | m_fontVisible = false; | 329 | |
330 | 330 | m_annoWin = new CAnnoEdit(editorStack); | |
331 | m_annoWin = new CAnnoEdit(editorStack); | 331 | editorStack->addWidget(m_annoWin, get_unique_id()); |
332 | editorStack->addWidget(m_annoWin, get_unique_id()); | 332 | connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); |
333 | connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); | 333 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); |
334 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); | 334 | |
335 | 335 | m_infoWin = new infowin(editorStack); | |
336 | m_infoWin = new infowin(editorStack); | 336 | editorStack->addWidget(m_infoWin, get_unique_id()); |
337 | editorStack->addWidget(m_infoWin, get_unique_id()); | 337 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); |
338 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); | 338 | |
339 | 339 | m_graphicwin = new GraphicWin(editorStack); | |
340 | m_graphicwin = new GraphicWin(editorStack); | 340 | editorStack->addWidget(m_graphicwin, get_unique_id()); |
341 | editorStack->addWidget(m_graphicwin, get_unique_id()); | 341 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); |
342 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); | 342 | |
343 | 343 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); | |
344 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); | 344 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); |
345 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); | 345 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); |
346 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); | 346 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); |
347 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); | 347 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); |
348 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); | 348 | editorStack->addWidget( bkmkselector, get_unique_id() ); |
349 | editorStack->addWidget( bkmkselector, get_unique_id() ); | 349 | |
350 | 350 | /* | |
351 | /* | 351 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); |
352 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); | 352 | connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); |
353 | connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); | 353 | |
354 | 354 | editorStack->addWidget( importSelector, get_unique_id() ); | |
355 | editorStack->addWidget( importSelector, get_unique_id() ); | 355 | |
356 | 356 | // don't need the close visible, it is redundant... | |
357 | // don't need the close visible, it is redundant... | 357 | importSelector->setCloseVisible( FALSE ); |
358 | importSelector->setCloseVisible( FALSE ); | 358 | */ |
359 | */ | 359 | // qDebug("Reading file list"); |
360 | // qDebug("Reading file list"); | 360 | readfilelist(); |
361 | readfilelist(); | 361 | |
362 | 362 | reader = new QTReader( editorStack ); | |
363 | reader = new QTReader( editorStack ); | 363 | |
364 | 364 | reader->bDoUpdates = false; | |
365 | reader->bDoUpdates = false; | 365 | |
366 | 366 | #ifdef USEQPE | |
367 | #ifdef USEQPE | 367 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); |
368 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); | 368 | #endif |
369 | #endif | 369 | |
370 | 370 | // qDebug("Reading config"); | |
371 | // qDebug("Reading config"); | 371 | // Config config( APPDIR ); |
372 | // Config config( APPDIR ); | 372 | config.setGroup( "View" ); |
373 | config.setGroup( "View" ); | 373 | m_debounce = config.readNumEntry("Debounce", 0); |
374 | m_debounce = config.readNumEntry("Debounce", 0); | 374 | #ifdef USEQPE |
375 | #ifdef USEQPE | 375 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); |
376 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); | 376 | #else |
377 | #else | 377 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); |
378 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); | 378 | #endif |
379 | #endif | 379 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); |
380 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); | 380 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); |
381 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | 381 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); |
382 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); | 382 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); |
383 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); | 383 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); |
384 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | 384 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); |
385 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | 385 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); |
386 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | 386 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); |
387 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 387 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
388 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 388 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); |
389 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | 389 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); |
390 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); | 390 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); |
391 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | 391 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
392 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 392 | reader->brepara = config.readBoolEntry( "Repara", false ); |
393 | reader->brepara = config.readBoolEntry( "Repara", false ); | 393 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); |
394 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | 394 | reader->bindenter = config.readNumEntry( "Indent", 0 ); |
395 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | 395 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); |
396 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | 396 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); |
397 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | 397 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); |
398 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | 398 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
399 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 399 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
400 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 400 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); |
401 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 401 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); |
402 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); | 402 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
403 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 403 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); |
404 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 404 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
405 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 405 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
406 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 406 | reader->m_border = config.readNumEntry( "Margin", 6 ); |
407 | reader->m_border = config.readNumEntry( "Margin", 6 ); | 407 | #ifdef REPALM |
408 | #ifdef REPALM | 408 | reader->brepalm = config.readBoolEntry( "Repalm", true ); |
409 | reader->brepalm = config.readBoolEntry( "Repalm", true ); | 409 | #endif |
410 | #endif | 410 | reader->bremap = config.readBoolEntry( "Remap", true ); |
411 | reader->bremap = config.readBoolEntry( "Remap", true ); | 411 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); |
412 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | 412 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); |
413 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | 413 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
414 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 414 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
415 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 415 | #ifdef _SCROLLPIPE |
416 | #ifdef _SCROLLPIPE | 416 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); |
417 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); | 417 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); |
418 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); | 418 | #endif |
419 | #endif | 419 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); |
420 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | 420 | m_doAnnotation = config.readBoolEntry( "Annotation", false); |
421 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | 421 | m_doDictionary = config.readBoolEntry( "Dictionary", false); |
422 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | 422 | m_doClipboard = config.readBoolEntry( "Clipboard", false); |
423 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | 423 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); |
424 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | 424 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); |
425 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); | 425 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); |
426 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); | 426 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); |
427 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); | 427 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); |
428 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); | 428 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); |
429 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); | 429 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); |
430 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | 430 | |
431 | 431 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | |
432 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | 432 | m_rightScroll = config.readBoolEntry("RightScroll", false); |
433 | m_rightScroll = config.readBoolEntry("RightScroll", false); | 433 | m_upScroll = config.readBoolEntry("UpScroll", true); |
434 | m_upScroll = config.readBoolEntry("UpScroll", true); | 434 | m_downScroll = config.readBoolEntry("DownScroll", true); |
435 | m_downScroll = config.readBoolEntry("DownScroll", true); | 435 | |
436 | 436 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); | |
437 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); | 437 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); |
438 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); | 438 | |
439 | 439 | #ifndef USEQPE | |
440 | #ifndef USEQPE | 440 | config.setGroup( "Geometry" ); |
441 | config.setGroup( "Geometry" ); | 441 | setGeometry(0,0, |
442 | setGeometry(0,0, | 442 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), |
443 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), | 443 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); |
444 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); | 444 | move( |
445 | move( | 445 | config.readNumEntry( "x", 20 ), |
446 | config.readNumEntry( "x", 20 ), | 446 | config.readNumEntry( "y", 20 )); |
447 | config.readNumEntry( "y", 20 )); | 447 | #endif |
448 | #endif | 448 | |
449 | 449 | ||
450 | 450 | ||
451 | 451 | setTwoTouch(m_twoTouch); | |
452 | setTwoTouch(m_twoTouch); | 452 | |
453 | 453 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); | |
454 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); | 454 | |
455 | 455 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); | |
456 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); | 456 | connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) ); |
457 | connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) ); | 457 | connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) ); |
458 | connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) ); | 458 | editorStack->addWidget( reader, get_unique_id() ); |
459 | editorStack->addWidget( reader, get_unique_id() ); | 459 | |
460 | 460 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); | |
461 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); | 461 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); |
462 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); | 462 | m_preferences_action->addTo( settings ); |
463 | m_preferences_action->addTo( settings ); | 463 | |
464 | 464 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); | |
465 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); | 465 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); |
466 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); | 466 | m_saveconfig_action->addTo( settings ); |
467 | m_saveconfig_action->addTo( settings ); | 467 | |
468 | 468 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); | |
469 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); | 469 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); |
470 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); | 470 | m_loadconfig_action->addTo( settings ); |
471 | m_loadconfig_action->addTo( settings ); | 471 | |
472 | 472 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); | |
473 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); | 473 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); |
474 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); | 474 | m_tidyconfig_action->addTo( settings ); |
475 | m_tidyconfig_action->addTo( settings ); | 475 | |
476 | 476 | settings->insertSeparator(); | |
477 | settings->insertSeparator(); | 477 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); |
478 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); | 478 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); |
479 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); | 479 | m_toolbarprefs_action->addTo( settings ); |
480 | m_toolbarprefs_action->addTo( settings ); | 480 | |
481 | 481 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); | |
482 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); | 482 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
483 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 483 | m_open_action->addTo( file ); |
484 | m_open_action->addTo( file ); | 484 | |
485 | 485 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); | |
486 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); | 486 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); |
487 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); | 487 | m_close_action->addTo( file ); |
488 | m_close_action->addTo( file ); | 488 | |
489 | 489 | #ifdef _SCRIPT | |
490 | #ifdef _SCRIPT | 490 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); |
491 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); | 491 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); |
492 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); | 492 | a->addTo( file ); |
493 | a->addTo( file ); | 493 | #endif |
494 | #endif | 494 | /* |
495 | /* | 495 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); |
496 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); | 496 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); |
497 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); | 497 | a->addTo( file ); |
498 | a->addTo( file ); | 498 | |
499 | 499 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); | |
500 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); | 500 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
501 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 501 | a->addTo( filebar() ); |
502 | a->addTo( filebar() ); | 502 | a->addTo( edit ); |
503 | a->addTo( edit ); | 503 | */ |
504 | */ | 504 | |
505 | 505 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); | |
506 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); | 506 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); |
507 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); | 507 | m_info_action->addTo( file ); |
508 | m_info_action->addTo( file ); | 508 | |
509 | 509 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); | |
510 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); | 510 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); |
511 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); | 511 | m_touch_action->setOn(m_twoTouch); |
512 | m_touch_action->setOn(m_twoTouch); | 512 | m_touch_action->addTo( file ); |
513 | m_touch_action->addTo( file ); | 513 | |
514 | 514 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); | |
515 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); | 515 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
516 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 516 | file->insertSeparator(); |
517 | file->insertSeparator(); | 517 | // a->addTo( bar ); |
518 | // a->addTo( bar ); | 518 | m_find_action->addTo( file ); |
519 | m_find_action->addTo( file ); | 519 | |
520 | 520 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); | |
521 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); | 521 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); |
522 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); | 522 | m_exportlinks_action->addTo( file ); |
523 | m_exportlinks_action->addTo( file ); | 523 | |
524 | 524 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); | |
525 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); | 525 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); |
526 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); | 526 | m_scrollButton->addTo(navigation); |
527 | m_scrollButton->addTo(navigation); | 527 | m_scrollButton->setOn(false); |
528 | m_scrollButton->setOn(false); | 528 | |
529 | 529 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); | |
530 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); | 530 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); |
531 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); | 531 | m_start_action->addTo(navigation); |
532 | m_start_action->addTo(navigation); | 532 | |
533 | 533 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); | |
534 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); | 534 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); |
535 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); | 535 | m_end_action->addTo(navigation); |
536 | m_end_action->addTo(navigation); | 536 | |
537 | 537 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); | |
538 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); | 538 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); |
539 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); | 539 | m_jump_action->addTo(navigation); |
540 | m_jump_action->addTo(navigation); | 540 | |
541 | 541 | m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); | |
542 | m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); | 542 | connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); |
543 | connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); | 543 | m_pageline_action->addTo(navigation); |
544 | m_pageline_action->addTo(navigation); | 544 | m_pageline_action->setOn(reader->m_bpagemode); |
545 | m_pageline_action->setOn(reader->m_bpagemode); | 545 | |
546 | 546 | m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); | |
547 | m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); | 547 | connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); |
548 | connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); | 548 | m_pageup_action->addTo( navigation ); |
549 | m_pageup_action->addTo( navigation ); | 549 | |
550 | 550 | m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); | |
551 | m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); | 551 | connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
552 | connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 552 | m_pagedn_action->addTo( navigation ); |
553 | m_pagedn_action->addTo( navigation ); | 553 | |
554 | 554 | m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 ); | |
555 | m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 ); | 555 | connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) ); |
556 | connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) ); | 556 | m_back_action->addTo( navigation ); |
557 | m_back_action->addTo( navigation ); | 557 | |
558 | 558 | m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 ); | |
559 | m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 ); | 559 | connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) ); |
560 | connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) ); | 560 | m_home_action->addTo( navigation ); |
561 | m_home_action->addTo( navigation ); | 561 | |
562 | 562 | m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 ); | |
563 | m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 ); | 563 | connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) ); |
564 | connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) ); | 564 | m_forward_action->addTo( navigation ); |
565 | m_forward_action->addTo( navigation ); | 565 | |
566 | 566 | /* | |
567 | /* | 567 | a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); |
568 | a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); | 568 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
569 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 569 | a->addTo( file ); |
570 | a->addTo( file ); | 570 | |
571 | 571 | a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); | |
572 | a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); | 572 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
573 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 573 | a->addTo( file ); |
574 | a->addTo( file ); | 574 | */ |
575 | */ | 575 | |
576 | 576 | // file->insertSeparator(); | |
577 | // file->insertSeparator(); | 577 | |
578 | 578 | #ifdef _SCROLLPIPE | |
579 | #ifdef _SCROLLPIPE | 579 | |
580 | 580 | QActionGroup* ag = new QActionGroup(this); | |
581 | QActionGroup* ag = new QActionGroup(this); | 581 | ag->setExclusive(false); |
582 | ag->setExclusive(false); | 582 | spacemenu = new QPopupMenu(this); |
583 | spacemenu = new QPopupMenu(this); | 583 | file->insertItem( tr( "Scrolling" ), spacemenu ); |
584 | file->insertItem( tr( "Scrolling" ), spacemenu ); | 584 | |
585 | 585 | a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL); | |
586 | a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL); | 586 | connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) ); |
587 | connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) ); | 587 | |
588 | 588 | a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true ); | |
589 | a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true ); | 589 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) ); |
590 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) ); | 590 | a->setOn(reader->m_pauseAfterEachPara); |
591 | a->setOn(reader->m_pauseAfterEachPara); | 591 | |
592 | 592 | ag->addTo(spacemenu); | |
593 | ag->addTo(spacemenu); | 593 | // file->insertSeparator(); |
594 | // file->insertSeparator(); | 594 | |
595 | 595 | #endif | |
596 | #endif | 596 | |
597 | 597 | /* | |
598 | /* | 598 | a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); |
599 | a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); | 599 | connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); |
600 | connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); | 600 | a->addTo( file ); |
601 | a->addTo( file ); | 601 | */ |
602 | */ | 602 | |
603 | 603 | /* | |
604 | /* | 604 | a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 ); |
605 | a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 ); | 605 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
606 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 606 | a->addTo( fileBar ); |
607 | a->addTo( fileBar ); | 607 | a->addTo( edit ); |
608 | a->addTo( edit ); | 608 | */ |
609 | */ | 609 | |
610 | 610 | // a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 ); | |
611 | // a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 ); | 611 | |
612 | 612 | m_fullscreen = false; | |
613 | m_fullscreen = false; | 613 | m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true ); |
614 | m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true ); | 614 | connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); |
615 | connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); | 615 | m_actFullscreen->setOn(m_fullscreen); |
616 | m_actFullscreen->setOn(m_fullscreen); | 616 | m_actFullscreen->addTo( view ); |
617 | m_actFullscreen->addTo( view ); | 617 | |
618 | 618 | view->insertSeparator(); | |
619 | view->insertSeparator(); | 619 | |
620 | 620 | m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this); | |
621 | m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this); | 621 | connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) ); |
622 | connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) ); | 622 | m_zoomin_action->addTo( view ); |
623 | m_zoomin_action->addTo( view ); | 623 | |
624 | 624 | m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this); | |
625 | m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this); | 625 | connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) ); |
626 | connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) ); | 626 | m_zoomout_action->addTo( view ); |
627 | m_zoomout_action->addTo( view ); | 627 | |
628 | 628 | view->insertSeparator(); | |
629 | view->insertSeparator(); | 629 | m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this); |
630 | m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this); | 630 | connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) ); |
631 | connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) ); | 631 | m_setfont_action->addTo( view ); |
632 | m_setfont_action->addTo( view ); | 632 | |
633 | 633 | view->insertSeparator(); | |
634 | view->insertSeparator(); | 634 | m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); |
635 | m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); | 635 | connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); |
636 | connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); | 636 | m_setenc_action->addTo( view ); |
637 | m_setenc_action->addTo( view ); | 637 | |
638 | 638 | m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); | |
639 | m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); | 639 | connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
640 | connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 640 | m_setmono_action->addTo( view ); |
641 | m_setmono_action->addTo( view ); | 641 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
642 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 642 | |
643 | 643 | ||
644 | 644 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); | |
645 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); | 645 | // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); |
646 | // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); | 646 | |
647 | 647 | ||
648 | 648 | ||
649 | 649 | // a->addTo( filebar() ); | |
650 | // a->addTo( filebar() ); | 650 | // view->insertSeparator(); |
651 | // view->insertSeparator(); | 651 | |
652 | 652 | /* | |
653 | /* | 653 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); |
654 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); | 654 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
655 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 655 | a->setOn(reader->m_bMonoSpaced); |
656 | a->setOn(reader->m_bMonoSpaced); | 656 | a->addTo( view ); |
657 | a->addTo( view ); | 657 | */ |
658 | */ | 658 | /* |
659 | /* | 659 | a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); |
660 | a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); | 660 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); |
661 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); | 661 | a->addTo( view ); |
662 | a->addTo( view ); | 662 | */ |
663 | */ | 663 | |
664 | 664 | m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); | |
665 | m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); | 665 | connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); |
666 | connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); | 666 | m_mark_action->addTo( marks ); |
667 | m_mark_action->addTo( marks ); | 667 | |
668 | 668 | m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); | |
669 | m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); | 669 | connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); |
670 | connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); | 670 | m_annotate_action->addTo( marks ); |
671 | m_annotate_action->addTo( marks ); | 671 | |
672 | 672 | m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); | |
673 | m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); | 673 | connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); |
674 | connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); | 674 | m_goto_action->addTo( marks ); |
675 | m_goto_action->addTo( marks ); | 675 | |
676 | 676 | m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); | |
677 | m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); | 677 | connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); |
678 | connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); | 678 | m_delete_action->addTo( marks ); |
679 | m_delete_action->addTo( marks ); | 679 | |
680 | 680 | m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); | |
681 | m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); | 681 | connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); |
682 | connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); | 682 | marks->insertSeparator(); |
683 | marks->insertSeparator(); | 683 | m_autogen_action->addTo( marks ); |
684 | m_autogen_action->addTo( marks ); | 684 | |
685 | 685 | m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); | |
686 | m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); | 686 | connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); |
687 | connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); | 687 | m_clear_action->addTo( marks ); |
688 | m_clear_action->addTo( marks ); | 688 | |
689 | 689 | m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); | |
690 | m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); | 690 | connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); |
691 | connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); | 691 | m_save_action->addTo( marks ); |
692 | m_save_action->addTo( marks ); | 692 | |
693 | 693 | m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); | |
694 | m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); | 694 | connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); |
695 | connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); | 695 | marks->insertSeparator(); |
696 | marks->insertSeparator(); | 696 | m_tidy_action->addTo( marks ); |
697 | m_tidy_action->addTo( marks ); | 697 | |
698 | 698 | m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); | |
699 | m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); | 699 | connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); |
700 | connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); | 700 | marks->insertSeparator(); |
701 | marks->insertSeparator(); | 701 | m_startBlock_action->addTo( marks ); |
702 | m_startBlock_action->addTo( marks ); | 702 | |
703 | 703 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); | |
704 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); | 704 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
705 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 705 | m_endBlock_action->addTo( marks ); |
706 | m_endBlock_action->addTo( marks ); | 706 | |
707 | 707 | m_bkmkAvail = NULL; | |
708 | m_bkmkAvail = NULL; | 708 | |
709 | 709 | ||
710 | 710 | setToolBarsMovable(m_tbmove); | |
711 | setToolBarsMovable(m_tbmove); | 711 | addtoolbars(&config); |
712 | addtoolbars(&config); | 712 | |
713 | 713 | pbar = new QProgressBar(this); | |
714 | pbar = new QProgressBar(this); | 714 | pbar->hide(); |
715 | pbar->hide(); | 715 | |
716 | 716 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); | |
717 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 717 | |
718 | 718 | searchBar->setHorizontalStretchable( TRUE ); | |
719 | searchBar->setHorizontalStretchable( TRUE ); | 719 | |
720 | 720 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | |
721 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | 721 | |
722 | 722 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | |
723 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 723 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
724 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 724 | // searchEdit->setFont( f ); |
725 | // searchEdit->setFont( f ); | 725 | searchBar->setStretchableWidget( searchEdit ); |
726 | searchBar->setStretchableWidget( searchEdit ); | 726 | |
727 | 727 | ||
728 | 728 | #ifdef __ISEARCH | |
729 | #ifdef __ISEARCH | 729 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
730 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 730 | this, SLOT( search( const QString& ) ) ); |
731 | this, SLOT( search( const QString& ) ) ); | 731 | #else |
732 | #else | 732 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
733 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 733 | this, SLOT( search( ) ) ); |
734 | this, SLOT( search( ) ) ); | 734 | #endif |
735 | #endif | 735 | QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); |
736 | QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); | 736 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
737 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 737 | a->addTo( searchBar ); |
738 | a->addTo( searchBar ); | 738 | |
739 | 739 | a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); | |
740 | a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); | 740 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
741 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 741 | a->addTo( searchBar ); |
742 | a->addTo( searchBar ); | 742 | |
743 | 743 | searchBar->hide(); | |
744 | searchBar->hide(); | 744 | |
745 | 745 | regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); | |
746 | regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); | 746 | connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); |
747 | connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | 747 | |
748 | 748 | regBar->setHorizontalStretchable( TRUE ); | |
749 | regBar->setHorizontalStretchable( TRUE ); | 749 | |
750 | 750 | regEdit = new QLineEdit( regBar, "regEdit" ); | |
751 | regEdit = new QLineEdit( regBar, "regEdit" ); | 751 | // regEdit->setFont( f ); |
752 | // regEdit->setFont( f ); | 752 | |
753 | 753 | regBar->setStretchableWidget( regEdit ); | |
754 | regBar->setStretchableWidget( regEdit ); | 754 | |
755 | 755 | connect( regEdit, SIGNAL( returnPressed( ) ), | |
756 | connect( regEdit, SIGNAL( returnPressed( ) ), | 756 | this, SLOT( do_regaction() ) ); |
757 | this, SLOT( do_regaction() ) ); | 757 | |
758 | 758 | a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); | |
759 | a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); | 759 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); |
760 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); | 760 | a->addTo( regBar ); |
761 | a->addTo( regBar ); | 761 | |
762 | 762 | a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); | |
763 | a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); | 763 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); |
764 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); | 764 | a->addTo( regBar ); |
765 | a->addTo( regBar ); | 765 | |
766 | 766 | regBar->hide(); | |
767 | regBar->hide(); | 767 | |
768 | 768 | m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); | |
769 | m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); | 769 | |
770 | 770 | m_fontBar->setHorizontalStretchable( TRUE ); | |
771 | m_fontBar->setHorizontalStretchable( TRUE ); | 771 | |
772 | 772 | // qDebug("Font selector"); | |
773 | // qDebug("Font selector"); | 773 | m_fontSelector = new QComboBox(false, m_fontBar); |
774 | m_fontSelector = new QComboBox(false, m_fontBar); | 774 | m_fontBar->setStretchableWidget( m_fontSelector ); |
775 | m_fontBar->setStretchableWidget( m_fontSelector ); | 775 | { |
776 | { | 776 | #ifndef USEQPE |
777 | #ifndef USEQPE | 777 | QFontDatabase f; |
778 | QFontDatabase f; | 778 | #else |
779 | #else | 779 | FontDatabase f; |
780 | FontDatabase f; | 780 | #endif |
781 | #endif | 781 | QStringList flist = f.families(); |
782 | QStringList flist = f.families(); | 782 | bool realfont = false; |
783 | bool realfont = false; | 783 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
784 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 784 | { |
785 | { | 785 | if (reader->m_fontname == *nm) |
786 | if (reader->m_fontname == *nm) | 786 | { |
787 | { | 787 | realfont = true; |
788 | realfont = true; | 788 | } |
789 | } | 789 | if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); |
790 | if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); | 790 | } |
791 | } | 791 | if (!realfont) reader->m_fontname = flist[0]; |
792 | if (!realfont) reader->m_fontname = flist[0]; | 792 | } // delete the FontDatabase!!! |
793 | } // delete the FontDatabase!!! | 793 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), |
794 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), | 794 | this, SLOT( do_setfont(const QString&) ) ); |
795 | this, SLOT( do_setfont(const QString&) ) ); | 795 | connect( m_fontSelector, SIGNAL( activated(int ) ), |
796 | connect( m_fontSelector, SIGNAL( activated(int ) ), | 796 | this, SLOT( do_setencoding(int) ) ); |
797 | this, SLOT( do_setencoding(int) ) ); | 797 | |
798 | 798 | m_fontBar->hide(); | |
799 | m_fontBar->hide(); | 799 | m_fontVisible = false; |
800 | m_fontVisible = false; | 800 | #ifdef USEMSGS |
801 | #ifdef USEMSGS | 801 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), |
802 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), | 802 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); |
803 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); | 803 | #endif |
804 | #endif | 804 | // qDebug("Initing"); |
805 | // qDebug("Initing"); | 805 | reader->init(); |
806 | reader->init(); | 806 | // qDebug("Inited"); |
807 | // qDebug("Inited"); | 807 | // m_buttonAction[m_spaceTarget]->setOn(true); |
808 | // m_buttonAction[m_spaceTarget]->setOn(true); | 808 | // qDebug("fonting"); |
809 | // qDebug("fonting"); | 809 | do_setfont(reader->m_fontname); |
810 | do_setfont(reader->m_fontname); | 810 | if (!reader->m_lastfile.isEmpty()) |
811 | if (!reader->m_lastfile.isEmpty()) | 811 | { |
812 | { | 812 | //qDebug("doclnk"); |
813 | //qDebug("doclnk"); | 813 | //doc = new DocLnk(reader->m_lastfile); |
814 | //doc = new DocLnk(reader->m_lastfile); | 814 | //qDebug("doclnk done"); |
815 | //qDebug("doclnk done"); | 815 | if (pOpenlist != NULL) |
816 | if (pOpenlist != NULL) | 816 | { |
817 | { | 817 | |
818 | 818 | /* | |
819 | /* | 819 | int ind = 0; |
820 | int ind = 0; | 820 | Bkmk* p = (*pOpenlist)[ind]; |
821 | Bkmk* p = (*pOpenlist)[ind]; | 821 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) |
822 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | 822 | { |
823 | { | 823 | p = (*pOpenlist)[++ind]; |
824 | p = (*pOpenlist)[++ind]; | 824 | } |
825 | } | 825 | */ |
826 | */ | 826 | Bkmk* p = NULL; |
827 | Bkmk* p = NULL; | 827 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) |
828 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | 828 | { |
829 | { | 829 | p = iter.pContent(); |
830 | p = iter.pContent(); | 830 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) |
831 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) | 831 | { |
832 | { | 832 | break; |
833 | break; | 833 | } |
834 | } | 834 | // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); |
835 | // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); | 835 | p = NULL; |
836 | p = NULL; | 836 | } |
837 | } | 837 | if (p != NULL) |
838 | if (p != NULL) | 838 | { |
839 | { | 839 | //qDebug("openfrombkmk"); |
840 | //qDebug("openfrombkmk"); | 840 | if (!openfrombkmk(p)) |
841 | if (!openfrombkmk(p)) | 841 | showEditTools(); |
842 | showEditTools(); | 842 | } |
843 | } | 843 | else |
844 | else | 844 | { |
845 | { | 845 | //qDebug("openfile"); |
846 | //qDebug("openfile"); | 846 | openFile( reader->m_lastfile ); |
847 | openFile( reader->m_lastfile ); | 847 | } |
848 | } | 848 | } |
849 | } | 849 | else |
850 | else | 850 | { |
851 | { | 851 | // qDebug("Openfile 2"); |
852 | // qDebug("Openfile 2"); | 852 | if (!reader->m_lastfile.isEmpty()) |
853 | if (!reader->m_lastfile.isEmpty()) | 853 | openFile( reader->m_lastfile ); |
854 | openFile( reader->m_lastfile ); | 854 | } |
855 | } | 855 | } |
856 | } | 856 | else |
857 | else | 857 | { |
858 | { | 858 | showEditTools(); |
859 | showEditTools(); | 859 | } |
860 | } | 860 | // qApp->processEvents(); |
861 | // qApp->processEvents(); | 861 | reader->bDoUpdates = true; |
862 | reader->bDoUpdates = true; | 862 | reader->update(); |
863 | reader->update(); | 863 | config.setGroup("Version"); |
864 | config.setGroup("Version"); | 864 | int major = config.readNumEntry("Major", 0); |
865 | int major = config.readNumEntry("Major", 0); | 865 | int bkmktype = config.readNumEntry("BkmkType", 0); |
866 | int bkmktype = config.readNumEntry("BkmkType", 0); | 866 | char minor = config.readNumEntry("Minor", 0); |
867 | char minor = config.readNumEntry("Minor", 0); | 867 | if (CheckVersion(major, bkmktype, minor)) |
868 | if (CheckVersion(major, bkmktype, minor)) | 868 | { |
869 | { | 869 | config.writeEntry("Major", major); |
870 | config.writeEntry("Major", major); | 870 | config.writeEntry("BkmkType", bkmktype); |
871 | config.writeEntry("BkmkType", bkmktype); | 871 | config.writeEntry("Minor", (int)minor); |
872 | config.writeEntry("Minor", (int)minor); | 872 | } |
873 | } | 873 | // qDebug("finished update"); |
874 | // qDebug("finished update"); | 874 | } |
875 | } | 875 | |
876 | 876 | void QTReaderApp::addtoolbars(Config* config) | |
877 | void QTReaderApp::addtoolbars(Config* config) | 877 | { |
878 | { | 878 | config->setGroup("Toolbar"); |
879 | config->setGroup("Toolbar"); | 879 | |
880 | 880 | if (fileBar != NULL) | |
881 | if (fileBar != NULL) | 881 | { |
882 | { | 882 | if (fileBar != menubar) |
883 | if (fileBar != menubar) | 883 | { |
884 | { | 884 | fileBar->clear(); |
885 | fileBar->clear(); | 885 | } |
886 | } | 886 | else |
887 | else | 887 | { |
888 | { | 888 | m_preferences_action->removeFrom( filebar() ); |
889 | m_preferences_action->removeFrom( filebar() ); | 889 | m_open_action->removeFrom( filebar() ); |
890 | m_open_action->removeFrom( filebar() ); | 890 | m_close_action->removeFrom( filebar() ); |
891 | m_close_action->removeFrom( filebar() ); | 891 | m_info_action->removeFrom( filebar() ); |
892 | m_info_action->removeFrom( filebar() ); | 892 | m_touch_action->removeFrom( filebar() ); |
893 | m_touch_action->removeFrom( filebar() ); | 893 | m_find_action->removeFrom( filebar() ); |
894 | m_find_action->removeFrom( filebar() ); | 894 | } |
895 | } | 895 | } |
896 | } | 896 | |
897 | 897 | m_preferences_action->addTo( filebar() ); | |
898 | m_preferences_action->addTo( filebar() ); | 898 | addfilebar(config, "Open", m_open_action); |
899 | addfilebar(config, "Open", m_open_action); | 899 | addfilebar(config, "Close", m_close_action); |
900 | addfilebar(config, "Close", m_close_action); | 900 | addfilebar(config, "Info", m_info_action); |
901 | addfilebar(config, "Info", m_info_action); | 901 | addfilebar(config, "Two/One Touch", m_touch_action); |
902 | addfilebar(config, "Two/One Touch", m_touch_action); | 902 | addfilebar(config, "Find", m_find_action); |
903 | addfilebar(config, "Find", m_find_action); | 903 | |
904 | 904 | if (navBar != NULL) | |
905 | if (navBar != NULL) | 905 | { |
906 | { | 906 | if ((navBar == fileBar) && (fileBar == menubar)) |
907 | if ((navBar == fileBar) && (fileBar == menubar)) | 907 | { |
908 | { | 908 | m_scrollButton->removeFrom( navbar() ); |
909 | m_scrollButton->removeFrom( navbar() ); | 909 | m_start_action->removeFrom( navbar() ); |
910 | m_start_action->removeFrom( navbar() ); | 910 | m_end_action->removeFrom( navbar() ); |
911 | m_end_action->removeFrom( navbar() ); | 911 | m_jump_action->removeFrom( navbar() ); |
912 | m_jump_action->removeFrom( navbar() ); | 912 | m_pageline_action->removeFrom( navbar() ); |
913 | m_pageline_action->removeFrom( navbar() ); | 913 | m_pageup_action->removeFrom( navbar() ); |
914 | m_pageup_action->removeFrom( navbar() ); | 914 | m_pagedn_action->removeFrom( navbar() ); |
915 | m_pagedn_action->removeFrom( navbar() ); | 915 | m_back_action->removeFrom( navbar() ); |
916 | m_back_action->removeFrom( navbar() ); | 916 | m_home_action->removeFrom( navbar() ); |
917 | m_home_action->removeFrom( navbar() ); | 917 | m_forward_action->removeFrom( navbar() ); |
918 | m_forward_action->removeFrom( navbar() ); | 918 | } |
919 | } | 919 | else if (navBar != fileBar) |
920 | else if (navBar != fileBar) | 920 | { |
921 | { | 921 | navBar->clear(); |
922 | navBar->clear(); | 922 | } |
923 | } | 923 | } |
924 | } | 924 | |
925 | 925 | addnavbar(config, "Scroll", m_scrollButton); | |
926 | addnavbar(config, "Scroll", m_scrollButton); | 926 | addnavbar(config, "Goto Start", m_start_action); |
927 | addnavbar(config, "Goto Start", m_start_action); | 927 | addnavbar(config, "Goto End", m_end_action); |
928 | addnavbar(config, "Goto End", m_end_action); | 928 | |
929 | 929 | addnavbar(config, "Jump", m_jump_action); | |
930 | addnavbar(config, "Jump", m_jump_action); | 930 | addnavbar(config, "Page/Line Scroll", m_pageline_action); |
931 | addnavbar(config, "Page/Line Scroll", m_pageline_action); | 931 | |
932 | 932 | addnavbar(config, "Page Up", m_pageup_action); | |
933 | addnavbar(config, "Page Up", m_pageup_action); | 933 | addnavbar(config, "Page Down", m_pagedn_action); |
934 | addnavbar(config, "Page Down", m_pagedn_action); | 934 | |
935 | 935 | addnavbar(config, "Back", m_back_action); | |
936 | addnavbar(config, "Back", m_back_action); | 936 | addnavbar(config, "Home", m_home_action); |
937 | addnavbar(config, "Home", m_home_action); | 937 | addnavbar(config, "Forward", m_forward_action); |
938 | addnavbar(config, "Forward", m_forward_action); | 938 | |
939 | 939 | if (viewBar != NULL) | |
940 | if (viewBar != NULL) | 940 | { |
941 | { | 941 | if ((viewBar == fileBar) && (fileBar == menubar)) |
942 | if ((viewBar == fileBar) && (fileBar == menubar)) | 942 | { |
943 | { | 943 | m_actFullscreen->removeFrom( filebar() ); |
944 | m_actFullscreen->removeFrom( filebar() ); | 944 | m_zoomin_action->removeFrom( viewbar() ); |
945 | m_zoomin_action->removeFrom( viewbar() ); | 945 | m_zoomout_action->removeFrom( viewbar() ); |
946 | m_zoomout_action->removeFrom( viewbar() ); | 946 | m_setfont_action->removeFrom( viewbar() ); |
947 | m_setfont_action->removeFrom( viewbar() ); | 947 | m_setenc_action->removeFrom( viewbar() ); |
948 | m_setenc_action->removeFrom( viewbar() ); | 948 | m_setmono_action->removeFrom( viewbar() ); |
949 | m_setmono_action->removeFrom( viewbar() ); | 949 | } |
950 | } | 950 | else if (viewBar != fileBar) |
951 | else if (viewBar != fileBar) | 951 | { |
952 | { | 952 | viewBar->clear(); |
953 | viewBar->clear(); | 953 | } |
954 | } | 954 | } |
955 | } | 955 | |
956 | 956 | addviewbar(config, "Fullscreen", m_actFullscreen); | |
957 | addviewbar(config, "Fullscreen", m_actFullscreen); | 957 | addviewbar(config, "Zoom In", m_zoomin_action); |
958 | addviewbar(config, "Zoom In", m_zoomin_action); | 958 | addviewbar(config, "Zoom Out", m_zoomout_action); |
959 | addviewbar(config, "Zoom Out", m_zoomout_action); | 959 | addviewbar(config, "Set Font", m_setfont_action); |
960 | addviewbar(config, "Set Font", m_setfont_action); | 960 | addviewbar(config, "Encoding Select", m_setenc_action); |
961 | addviewbar(config, "Encoding Select", m_setenc_action); | 961 | addviewbar(config, "Ideogram Mode", m_setmono_action); |
962 | addviewbar(config, "Ideogram Mode", m_setmono_action); | 962 | |
963 | 963 | if (markBar != NULL) | |
964 | if (markBar != NULL) | 964 | { |
965 | { | 965 | if ((markBar == fileBar) && (fileBar == menubar)) |
966 | if ((markBar == fileBar) && (fileBar == menubar)) | 966 | { |
967 | { | 967 | m_mark_action->removeFrom( markbar() ); |
968 | m_mark_action->removeFrom( markbar() ); | 968 | m_annotate_action->removeFrom( markbar()); |
969 | m_annotate_action->removeFrom( markbar()); | 969 | m_goto_action->removeFrom( markbar() ); |
970 | m_goto_action->removeFrom( markbar() ); | 970 | m_delete_action->removeFrom( markbar() ); |
971 | m_delete_action->removeFrom( markbar() ); | 971 | m_autogen_action->removeFrom( markbar() ); |
972 | m_autogen_action->removeFrom( markbar() ); | 972 | m_clear_action->removeFrom( markbar() ); |
973 | m_clear_action->removeFrom( markbar() ); | 973 | m_save_action->removeFrom( markbar() ); |
974 | m_save_action->removeFrom( markbar() ); | 974 | m_tidy_action->removeFrom( markbar() ); |
975 | m_tidy_action->removeFrom( markbar() ); | 975 | m_startBlock_action->removeFrom( markbar() ); |
976 | m_startBlock_action->removeFrom( markbar() ); | 976 | m_endBlock_action->removeFrom( markbar() ); |
977 | m_endBlock_action->removeFrom( markbar() ); | 977 | } |
978 | } | 978 | else if (markBar != fileBar) |
979 | else if (markBar != fileBar) | 979 | { |
980 | { | 980 | markBar->clear(); |
981 | markBar->clear(); | 981 | } |
982 | } | 982 | } |
983 | } | 983 | addmarkbar(config, "Mark", m_mark_action); |
984 | addmarkbar(config, "Mark", m_mark_action); | 984 | addmarkbar(config, "Annotate", m_annotate_action); |
985 | addmarkbar(config, "Annotate", m_annotate_action); | 985 | addmarkbar(config, "Goto", m_goto_action); |
986 | addmarkbar(config, "Goto", m_goto_action); | 986 | addmarkbar(config, "Delete", m_delete_action); |
987 | addmarkbar(config, "Delete", m_delete_action); | 987 | addmarkbar(config, "Autogen", m_autogen_action); |
988 | addmarkbar(config, "Autogen", m_autogen_action); | 988 | addmarkbar(config, "Clear", m_clear_action); |
989 | addmarkbar(config, "Clear", m_clear_action); | 989 | addmarkbar(config, "Save", m_save_action); |
990 | addmarkbar(config, "Save", m_save_action); | 990 | addmarkbar(config, "Tidy", m_tidy_action); |
991 | addmarkbar(config, "Tidy", m_tidy_action); | 991 | addmarkbar(config, "Start Block", m_startBlock_action); |
992 | addmarkbar(config, "Start Block", m_startBlock_action); | 992 | addmarkbar(config, "Copy Block", m_endBlock_action); |
993 | addmarkbar(config, "Copy Block", m_endBlock_action); | 993 | if (checkbar(config, "Annotation indicator")) |
994 | if (checkbar(config, "Annotation indicator")) | 994 | { |
995 | { | 995 | if (m_bkmkAvail == NULL) |
996 | if (m_bkmkAvail == NULL) | 996 | { |
997 | { | 997 | m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 ); |
998 | m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 ); | 998 | connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); |
999 | connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); | 999 | |
1000 | 1000 | m_bkmkAvail->setEnabled(false); | |
1001 | m_bkmkAvail->setEnabled(false); | 1001 | } |
1002 | } | 1002 | QLabel *spacer = new QLabel(markBar, ""); |
1003 | QLabel *spacer = new QLabel(markBar, ""); | 1003 | markbar()->setStretchableWidget(spacer); |
1004 | markbar()->setStretchableWidget(spacer); | 1004 | m_bkmkAvail->removeFrom( markbar() ); |
1005 | m_bkmkAvail->removeFrom( markbar() ); | 1005 | m_bkmkAvail->addTo( markbar() ); |
1006 | m_bkmkAvail->addTo( markbar() ); | 1006 | } |
1007 | } | 1007 | else |
1008 | else | 1008 | { |
1009 | { | 1009 | if (m_bkmkAvail != NULL) |
1010 | if (m_bkmkAvail != NULL) | 1010 | { |
1011 | { | 1011 | m_bkmkAvail->removeFrom( markbar() ); |
1012 | m_bkmkAvail->removeFrom( markbar() ); | 1012 | delete m_bkmkAvail; |
1013 | delete m_bkmkAvail; | 1013 | m_bkmkAvail = NULL; |
1014 | m_bkmkAvail = NULL; | 1014 | } |
1015 | } | 1015 | } |
1016 | } | 1016 | } |
1017 | } | 1017 | |
1018 | 1018 | bool QTReaderApp::checkbar(Config* _config, const QString& key) | |
1019 | bool QTReaderApp::checkbar(Config* _config, const QString& key) | 1019 | { |
1020 | { | 1020 | return _config->readBoolEntry(key, false); |
1021 | return _config->readBoolEntry(key, false); | 1021 | } |
1022 | } | 1022 | |
1023 | 1023 | ||
1024 | 1024 | QToolBar* QTReaderApp::filebar() | |
1025 | QToolBar* QTReaderApp::filebar() | 1025 | { |
1026 | { | 1026 | if (fileBar == NULL) |
1027 | if (fileBar == NULL) | 1027 | { |
1028 | { | 1028 | switch (m_tbpol) |
1029 | switch (m_tbpol) | 1029 | { |
1030 | { | 1030 | case cesSingle: |
1031 | case cesSingle: | 1031 | // qDebug("Setting filebar to menubar"); |
1032 | // qDebug("Setting filebar to menubar"); | 1032 | fileBar = menubar; |
1033 | fileBar = menubar; | 1033 | break; |
1034 | break; | 1034 | default: |
1035 | default: | 1035 | qDebug("Incorrect toolbar policy set"); |
1036 | qDebug("Incorrect toolbar policy set"); | 1036 | case cesMenuTool: |
1037 | case cesMenuTool: | 1037 | case cesMultiple: |
1038 | case cesMultiple: | 1038 | // qDebug("Creating new file bar"); |
1039 | // qDebug("Creating new file bar"); | 1039 | fileBar = new QToolBar("File", this, m_tbposition); |
1040 | fileBar = new QToolBar("File", this, m_tbposition); | 1040 | break; |
1041 | break; | 1041 | } |
1042 | } | 1042 | //fileBar->setHorizontalStretchable( true ); |
1043 | //fileBar->setHorizontalStretchable( true ); | 1043 | } |
1044 | } | 1044 | return fileBar; |
1045 | return fileBar; | 1045 | } |
1046 | } | 1046 | QToolBar* QTReaderApp::viewbar() |
1047 | QToolBar* QTReaderApp::viewbar() | 1047 | { |
1048 | { | 1048 | if (viewBar == NULL) |
1049 | if (viewBar == NULL) | 1049 | { |
1050 | { | 1050 | switch (m_tbpol) |
1051 | switch (m_tbpol) | 1051 | { |
1052 | { | 1052 | case cesMultiple: |
1053 | case cesMultiple: | 1053 | viewBar = new QToolBar("View", this, m_tbposition); |
1054 | viewBar = new QToolBar("View", this, m_tbposition); | 1054 | break; |
1055 | break; | 1055 | default: |
1056 | default: | 1056 | qDebug("Incorrect toolbar policy set"); |
1057 | qDebug("Incorrect toolbar policy set"); | 1057 | case cesSingle: |
1058 | case cesSingle: | 1058 | case cesMenuTool: |
1059 | case cesMenuTool: | 1059 | viewBar = fileBar; |
1060 | viewBar = fileBar; | 1060 | break; |
1061 | break; | 1061 | } |
1062 | } | 1062 | } |
1063 | } | 1063 | return viewBar; |
1064 | return viewBar; | 1064 | } |
1065 | } | 1065 | QToolBar* QTReaderApp::navbar() |
1066 | QToolBar* QTReaderApp::navbar() | 1066 | { |
1067 | { | 1067 | if (navBar == NULL) |
1068 | if (navBar == NULL) | 1068 | { |
1069 | { | 1069 | switch (m_tbpol) |
1070 | switch (m_tbpol) | 1070 | { |
1071 | { | 1071 | case cesMultiple: |
1072 | case cesMultiple: | 1072 | // qDebug("Creating new nav bar"); |
1073 | // qDebug("Creating new nav bar"); | 1073 | navBar = new QToolBar("Navigation", this, m_tbposition); |
1074 | navBar = new QToolBar("Navigation", this, m_tbposition); | 1074 | break; |
1075 | break; | 1075 | default: |
1076 | default: | 1076 | qDebug("Incorrect toolbar policy set"); |
1077 | qDebug("Incorrect toolbar policy set"); | 1077 | case cesSingle: |
1078 | case cesSingle: | 1078 | case cesMenuTool: |
1079 | case cesMenuTool: | 1079 | navBar = fileBar; |
1080 | navBar = fileBar; | 1080 | // qDebug("Setting navbar to filebar"); |
1081 | // qDebug("Setting navbar to filebar"); | 1081 | break; |
1082 | break; | 1082 | } |
1083 | } | 1083 | } |
1084 | } | 1084 | return navBar; |
1085 | return navBar; | 1085 | } |
1086 | } | 1086 | QToolBar* QTReaderApp::markbar() |
1087 | QToolBar* QTReaderApp::markbar() | 1087 | { |
1088 | { | 1088 | if (markBar == NULL) |
1089 | if (markBar == NULL) | 1089 | { |
1090 | { | 1090 | switch (m_tbpol) |
1091 | switch (m_tbpol) | 1091 | { |
1092 | { | 1092 | case cesMultiple: |
1093 | case cesMultiple: | 1093 | markBar = new QToolBar("Marks", this, m_tbposition); |
1094 | markBar = new QToolBar("Marks", this, m_tbposition); | 1094 | break; |
1095 | break; | 1095 | default: |
1096 | default: | 1096 | qDebug("Incorrect toolbar policy set"); |
1097 | qDebug("Incorrect toolbar policy set"); | 1097 | case cesSingle: |
1098 | case cesSingle: | 1098 | case cesMenuTool: |
1099 | case cesMenuTool: | 1099 | markBar = fileBar; |
1100 | markBar = fileBar; | 1100 | break; |
1101 | break; | 1101 | } |
1102 | } | 1102 | } |
1103 | } | 1103 | return markBar; |
1104 | return markBar; | 1104 | } |
1105 | } | 1105 | |
1106 | 1106 | void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) | |
1107 | void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) | 1107 | { |
1108 | { | 1108 | if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); |
1109 | if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); | 1109 | } |
1110 | } | 1110 | void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) |
1111 | void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) | 1111 | { |
1112 | { | 1112 | if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); |
1113 | if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); | 1113 | } |
1114 | } | 1114 | void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) |
1115 | void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) | 1115 | { |
1116 | { | 1116 | if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); |
1117 | if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); | 1117 | } |
1118 | } | 1118 | void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) |
1119 | void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) | 1119 | { |
1120 | { | 1120 | if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); |
1121 | if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); | 1121 | } |
1122 | } | 1122 | |
1123 | 1123 | void QTReaderApp::suspend() { reader->suspend(); } | |
1124 | void QTReaderApp::suspend() { reader->suspend(); } | 1124 | |
1125 | 1125 | #ifdef USEMSGS | |
1126 | #ifdef USEMSGS | 1126 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) |
1127 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | 1127 | { |
1128 | { | 1128 | QString msg = QString::fromUtf8(_msg); |
1129 | QString msg = QString::fromUtf8(_msg); | 1129 | |
1130 | 1130 | //// qDebug("Received:%s", (const char*)msg); | |
1131 | //// qDebug("Received:%s", (const char*)msg); | 1131 | |
1132 | 1132 | QDataStream stream( _data, IO_ReadOnly ); | |
1133 | QDataStream stream( _data, IO_ReadOnly ); | 1133 | if ( msg == "info(QString)" ) |
1134 | if ( msg == "info(QString)" ) | 1134 | { |
1135 | { | 1135 | QString info; |
1136 | QString info; | 1136 | stream >> info; |
1137 | stream >> info; | 1137 | QMessageBox::information(this, PROGNAME, info); |
1138 | QMessageBox::information(this, PROGNAME, info); | 1138 | } |
1139 | } | 1139 | else if ( msg == "Update(int)" ) |
1140 | else if ( msg == "Update(int)" ) | 1140 | { |
1141 | { | 1141 | int info; |
1142 | int info; | 1142 | stream >> info; |
1143 | stream >> info; | 1143 | if (info) |
1144 | if (info) | 1144 | { |
1145 | { | 1145 | reader->bDoUpdates = true; |
1146 | reader->bDoUpdates = true; | 1146 | reader->refresh(); |
1147 | reader->refresh(); | 1147 | } |
1148 | } | 1148 | else |
1149 | else | 1149 | { |
1150 | { | 1150 | reader->bDoUpdates = false; |
1151 | reader->bDoUpdates = false; | 1151 | } |
1152 | } | 1152 | } |
1153 | } | 1153 | else if ( msg == "warn(QString)" ) |
1154 | else if ( msg == "warn(QString)" ) | 1154 | { |
1155 | { | 1155 | QString info; |
1156 | QString info; | 1156 | stream >> info; |
1157 | stream >> info; | 1157 | QMessageBox::warning(this, PROGNAME, info); |
1158 | QMessageBox::warning(this, PROGNAME, info); | 1158 | } |
1159 | } | 1159 | else if ( msg == "exit()" ) |
1160 | else if ( msg == "exit()" ) | 1160 | { |
1161 | { | 1161 | m_dontSave = true; |
1162 | m_dontSave = true; | 1162 | close(); |
1163 | close(); | 1163 | } |
1164 | } | 1164 | else if ( msg == "pageDown()" ) |
1165 | else if ( msg == "pageDown()" ) | 1165 | { |
1166 | { | 1166 | reader->dopagedn(); |
1167 | reader->dopagedn(); | 1167 | } |
1168 | } | 1168 | else if ( msg == "pageUp()" ) |
1169 | else if ( msg == "pageUp()" ) | 1169 | { |
1170 | { | 1170 | reader->dopageup(); |
1171 | reader->dopageup(); | 1171 | } |
1172 | } | 1172 | else if ( msg == "lineDown()" ) |
1173 | else if ( msg == "lineDown()" ) | 1173 | { |
1174 | { | 1174 | reader->lineDown(); |
1175 | reader->lineDown(); | 1175 | } |
1176 | } | 1176 | else if ( msg == "lineUp()" ) |
1177 | else if ( msg == "lineUp()" ) | 1177 | { |
1178 | { | 1178 | reader->lineUp(); |
1179 | reader->lineUp(); | 1179 | } |
1180 | } | 1180 | else if ( msg == "showText()" ) |
1181 | else if ( msg == "showText()" ) | 1181 | { |
1182 | { | 1182 | showEditTools(); |
1183 | showEditTools(); | 1183 | } |
1184 | } | 1184 | else if ( msg == "home()" ) |
1185 | else if ( msg == "home()" ) | 1185 | { |
1186 | { | 1186 | reader->goHome(); |
1187 | reader->goHome(); | 1187 | } |
1188 | } | 1188 | else if ( msg == "back()" ) |
1189 | else if ( msg == "back()" ) | 1189 | { |
1190 | { | 1190 | reader->goBack(); |
1191 | reader->goBack(); | 1191 | } |
1192 | } | 1192 | else if ( msg == "forward()" ) |
1193 | else if ( msg == "forward()" ) | 1193 | { |
1194 | { | 1194 | reader->goForward(); |
1195 | reader->goForward(); | 1195 | } |
1196 | } | 1196 | else if ( msg == "File/Open(QString)" ) |
1197 | else if ( msg == "File/Open(QString)" ) | 1197 | { |
1198 | { | 1198 | QString info; |
1199 | QString info; | 1199 | stream >> info; |
1200 | stream >> info; | 1200 | openFile( info ); |
1201 | openFile( info ); | 1201 | } |
1202 | } | 1202 | else if ( msg == "File/Info()" ) |
1203 | else if ( msg == "File/Info()" ) | 1203 | { |
1204 | { | 1204 | showinfo(); |
1205 | showinfo(); | 1205 | } |
1206 | } | 1206 | else if ( msg == "File/Action(QString)" ) |
1207 | else if ( msg == "File/Action(QString)" ) | 1207 | { |
1208 | { | 1208 | QString info; |
1209 | QString info; | 1209 | stream >> info; |
1210 | stream >> info; | 1210 | m_spaceTarget = ActNameToInt(info); |
1211 | m_spaceTarget = ActNameToInt(info); | 1211 | } |
1212 | } | 1212 | else if ( msg == "Navigation/Scroll(int)" ) |
1213 | else if ( msg == "Navigation/Scroll(int)" ) | 1213 | { |
1214 | { | 1214 | int info; |
1215 | int info; | 1215 | stream >> info; |
1216 | stream >> info; | 1216 | autoScroll(info); |
1217 | autoScroll(info); | 1217 | } |
1218 | } | 1218 | |
1219 | 1219 | else if ( msg == "Navigation/GotoStart()" ) | |
1220 | else if ( msg == "Navigation/GotoStart()" ) | 1220 | { |
1221 | { | 1221 | gotoStart(); |
1222 | gotoStart(); | 1222 | } |
1223 | } | 1223 | else if ( msg == "Navigation/GotoEnd()" ) |
1224 | else if ( msg == "Navigation/GotoEnd()" ) | 1224 | { |
1225 | { | 1225 | gotoEnd(); |
1226 | gotoEnd(); | 1226 | } |
1227 | } | 1227 | else if ( msg == "Navigation/Jump(int)" ) |
1228 | else if ( msg == "Navigation/Jump(int)" ) | 1228 | { |
1229 | { | 1229 | int info; |
1230 | int info; | 1230 | stream >> info; |
1231 | stream >> info; | 1231 | reader->locate(info); |
1232 | reader->locate(info); | 1232 | } |
1233 | } | 1233 | else if ( msg == "Navigation/Page/LineScroll(int)" ) |
1234 | else if ( msg == "Navigation/Page/LineScroll(int)" ) | 1234 | { |
1235 | { | 1235 | int info; |
1236 | int info; | 1236 | stream >> info; |
1237 | stream >> info; | 1237 | pagemode(info); |
1238 | pagemode(info); | 1238 | } |
1239 | } | 1239 | else if ( msg == "Navigation/SetOverlap(int)" ) |
1240 | else if ( msg == "Navigation/SetOverlap(int)" ) | 1240 | { |
1241 | { | 1241 | int info; |
1242 | int info; | 1242 | stream >> info; |
1243 | stream >> info; | 1243 | reader->m_overlap = info; |
1244 | reader->m_overlap = info; | 1244 | } |
1245 | } | 1245 | else if ( msg == "Navigation/SetMargin(int)" ) |
1246 | else if ( msg == "Navigation/SetMargin(int)" ) | 1246 | { |
1247 | { | 1247 | int info; |
1248 | int info; | 1248 | stream >> info; |
1249 | stream >> info; | 1249 | do_margin(info); |
1250 | do_margin(info); | 1250 | } |
1251 | } | 1251 | else if ( msg == "File/SetDictionary(QString)" ) |
1252 | else if ( msg == "File/SetDictionary(QString)" ) | 1252 | { |
1253 | { | 1253 | QString info; |
1254 | QString info; | 1254 | stream >> info; |
1255 | stream >> info; | 1255 | do_settarget(info); |
1256 | do_settarget(info); | 1256 | } |
1257 | } | 1257 | #ifdef _SCROLLPIPE |
1258 | #ifdef _SCROLLPIPE | 1258 | else if ( msg == "File/SetScrollTarget(QString)" ) |
1259 | else if ( msg == "File/SetScrollTarget(QString)" ) | 1259 | { |
1260 | { | 1260 | QString info; |
1261 | QString info; | 1261 | stream >> info; |
1262 | stream >> info; | 1262 | reader->m_pipetarget = info; |
1263 | reader->m_pipetarget = info; | 1263 | } |
1264 | } | 1264 | #endif |
1265 | #endif | 1265 | else if ( msg == "File/Two/OneTouch(int)" ) |
1266 | else if ( msg == "File/Two/OneTouch(int)" ) | 1266 | { |
1267 | { | 1267 | int info; |
1268 | int info; | 1268 | stream >> info; |
1269 | stream >> info; | 1269 | setTwoTouch(info); |
1270 | setTwoTouch(info); | 1270 | } |
1271 | } | 1271 | else if ( msg == "Target/Annotation(int)" ) |
1272 | else if ( msg == "Target/Annotation(int)" ) | 1272 | { |
1273 | { | 1273 | int info; |
1274 | int info; | 1274 | stream >> info; |
1275 | stream >> info; | 1275 | OnAnnotation(info); |
1276 | OnAnnotation(info); | 1276 | } |
1277 | } | 1277 | else if ( msg == "Target/Dictionary(int)" ) |
1278 | else if ( msg == "Target/Dictionary(int)" ) | 1278 | { |
1279 | { | 1279 | int info; |
1280 | int info; | 1280 | stream >> info; |
1281 | stream >> info; | 1281 | OnDictionary(info); |
1282 | OnDictionary(info); | 1282 | } |
1283 | } | 1283 | else if ( msg == "Target/Clipboard(int)" ) |
1284 | else if ( msg == "Target/Clipboard(int)" ) | 1284 | { |
1285 | { | 1285 | int info; |
1286 | int info; | 1286 | stream >> info; |
1287 | stream >> info; | 1287 | OnClipboard(info); |
1288 | OnClipboard(info); | 1288 | } |
1289 | } | 1289 | else if ( msg == "File/Find(QString)" ) |
1290 | else if ( msg == "File/Find(QString)" ) | 1290 | { |
1291 | { | 1291 | QString info; |
1292 | QString info; | 1292 | stream >> info; |
1293 | stream >> info; | 1293 | QRegExp arg(info); |
1294 | QRegExp arg(info); | 1294 | size_t pos = reader->pagelocate(); |
1295 | size_t pos = reader->pagelocate(); | 1295 | size_t start = pos; |
1296 | size_t start = pos; | 1296 | CDrawBuffer test(&(reader->m_fontControl)); |
1297 | CDrawBuffer test(&(reader->m_fontControl)); | 1297 | reader->getline(&test); |
1298 | reader->getline(&test); | 1298 | while (arg.match(toQString(test.data())) == -1) |
1299 | while (arg.match(toQString(test.data())) == -1) | 1299 | { |
1300 | { | 1300 | pos = reader->locate(); |
1301 | pos = reader->locate(); | 1301 | if (!reader->getline(&test)) |
1302 | if (!reader->getline(&test)) | 1302 | { |
1303 | { | 1303 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); |
1304 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); | 1304 | pos = start; |
1305 | pos = start; | 1305 | break; |
1306 | break; | 1306 | } |
1307 | } | 1307 | } |
1308 | } | 1308 | reader->locate(pos); |
1309 | reader->locate(pos); | 1309 | } |
1310 | } | 1310 | else if ( msg == "File/Fullscreen(int)" ) |
1311 | else if ( msg == "File/Fullscreen(int)" ) | 1311 | { |
1312 | { | 1312 | int info; |
1313 | int info; | 1313 | stream >> info; |
1314 | stream >> info; | 1314 | setfullscreen(info); |
1315 | setfullscreen(info); | 1315 | } |
1316 | } | 1316 | else if ( msg == "File/Continuous(int)" ) |
1317 | else if ( msg == "File/Continuous(int)" ) | 1317 | { |
1318 | { | 1318 | int info; |
1319 | int info; | 1319 | stream >> info; |
1320 | stream >> info; | 1320 | setcontinuous(info); |
1321 | setcontinuous(info); | 1321 | } |
1322 | } | 1322 | else if ( msg == "Markup(QString)" ) |
1323 | else if ( msg == "Markup(QString)" ) | 1323 | { |
1324 | { | 1324 | QString info; |
1325 | QString info; | 1325 | stream >> info; |
1326 | stream >> info; | 1326 | if (info == "Auto") |
1327 | if (info == "Auto") | 1327 | { |
1328 | { | 1328 | autofmt(true); |
1329 | autofmt(true); | 1329 | } |
1330 | } | 1330 | if (info == "None") |
1331 | if (info == "None") | 1331 | { |
1332 | { | 1332 | autofmt(false); |
1333 | autofmt(false); | 1333 | textfmt(false); |
1334 | textfmt(false); | 1334 | striphtml(false); |
1335 | striphtml(false); | 1335 | peanut(false); |
1336 | peanut(false); | 1336 | } |
1337 | } | 1337 | if (info == "Text") |
1338 | if (info == "Text") | 1338 | { |
1339 | { | 1339 | textfmt(true); |
1340 | textfmt(true); | 1340 | } |
1341 | } | 1341 | if (info == "HTML") |
1342 | if (info == "HTML") | 1342 | { |
1343 | { | 1343 | striphtml(true); |
1344 | striphtml(true); | 1344 | } |
1345 | } | 1345 | if (info == "Peanut/PML") |
1346 | if (info == "Peanut/PML") | 1346 | { |
1347 | { | 1347 | peanut(true); |
1348 | peanut(true); | 1348 | } |
1349 | } | 1349 | } |
1350 | } | 1350 | else if ( msg == "Layout/StripCR(int)" ) |
1351 | else if ( msg == "Layout/StripCR(int)" ) | 1351 | { |
1352 | { | 1352 | int info; |
1353 | int info; | 1353 | stream >> info; |
1354 | stream >> info; | 1354 | stripcr(info); |
1355 | stripcr(info); | 1355 | } |
1356 | } | 1356 | else if ( msg == "Layout/Dehyphen(int)" ) |
1357 | else if ( msg == "Layout/Dehyphen(int)" ) | 1357 | { |
1358 | { | 1358 | int info; |
1359 | int info; | 1359 | stream >> info; |
1360 | stream >> info; | 1360 | dehyphen(info); |
1361 | dehyphen(info); | 1361 | } |
1362 | } | 1362 | else if ( msg == "Layout/Depluck(int)" ) |
1363 | else if ( msg == "Layout/Depluck(int)" ) | 1363 | { |
1364 | { | 1364 | int info; |
1365 | int info; | 1365 | stream >> info; |
1366 | stream >> info; | 1366 | depluck(info); |
1367 | depluck(info); | 1367 | } |
1368 | } | 1368 | else if ( msg == "Layout/Dejpluck(int)" ) |
1369 | else if ( msg == "Layout/Dejpluck(int)" ) | 1369 | { |
1370 | { | 1370 | int info; |
1371 | int info; | 1371 | stream >> info; |
1372 | stream >> info; | 1372 | dejpluck(info); |
1373 | dejpluck(info); | 1373 | } |
1374 | } | 1374 | else if ( msg == "Layout/SingleSpace(int)" ) |
1375 | else if ( msg == "Layout/SingleSpace(int)" ) | 1375 | { |
1376 | { | 1376 | int info; |
1377 | int info; | 1377 | stream >> info; |
1378 | stream >> info; | 1378 | onespace(info); |
1379 | onespace(info); | 1379 | } |
1380 | } | 1380 | #ifdef REPALM |
1381 | #ifdef REPALM | 1381 | else if ( msg == "Layout/Repalm(int)" ) |
1382 | else if ( msg == "Layout/Repalm(int)" ) | 1382 | { |
1383 | { | 1383 | int info; |
1384 | int info; | 1384 | stream >> info; |
1385 | stream >> info; | 1385 | repalm(info); |
1386 | repalm(info); | 1386 | } |
1387 | } | 1387 | #endif |
1388 | #endif | 1388 | else if ( msg == "Layout/Unindent(int)" ) |
1389 | else if ( msg == "Layout/Unindent(int)" ) | 1389 | { |
1390 | { | 1390 | int info; |
1391 | int info; | 1391 | stream >> info; |
1392 | stream >> info; | 1392 | unindent(info); |
1393 | unindent(info); | 1393 | } |
1394 | } | 1394 | else if ( msg == "Layout/Re-paragraph(int)" ) |
1395 | else if ( msg == "Layout/Re-paragraph(int)" ) | 1395 | { |
1396 | { | 1396 | int info; |
1397 | int info; | 1397 | stream >> info; |
1398 | stream >> info; | 1398 | repara(info); |
1399 | repara(info); | 1399 | } |
1400 | } | 1400 | else if ( msg == "Layout/DoubleSpace(int)" ) |
1401 | else if ( msg == "Layout/DoubleSpace(int)" ) | 1401 | { |
1402 | { | 1402 | int info; |
1403 | int info; | 1403 | stream >> info; |
1404 | stream >> info; | 1404 | dblspce(info); |
1405 | dblspce(info); | 1405 | } |
1406 | } | 1406 | else if ( msg == "Layout/Indent(int)" ) |
1407 | else if ( msg == "Layout/Indent(int)" ) | 1407 | { |
1408 | { | 1408 | int info; |
1409 | int info; | 1409 | stream >> info; |
1410 | stream >> info; | 1410 | reader->bindenter = info; |
1411 | reader->bindenter = info; | 1411 | reader->setfilter(reader->getfilter()); |
1412 | reader->setfilter(reader->getfilter()); | 1412 | } |
1413 | } | 1413 | else if ( msg == "Layout/Remap(int)" ) |
1414 | else if ( msg == "Layout/Remap(int)" ) | 1414 | { |
1415 | { | 1415 | int info; |
1416 | int info; | 1416 | stream >> info; |
1417 | stream >> info; | 1417 | remap(info); |
1418 | remap(info); | 1418 | } |
1419 | } | 1419 | else if ( msg == "Layout/Embolden(int)" ) |
1420 | else if ( msg == "Layout/Embolden(int)" ) | 1420 | { |
1421 | { | 1421 | int info; |
1422 | int info; | 1422 | stream >> info; |
1423 | stream >> info; | 1423 | embolden(info); |
1424 | embolden(info); | 1424 | } |
1425 | } | 1425 | else if ( msg == "Format/Ideogram/Word(int)" ) |
1426 | else if ( msg == "Format/Ideogram/Word(int)" ) | 1426 | { |
1427 | { | 1427 | int info; |
1428 | int info; | 1428 | stream >> info; |
1429 | stream >> info; | 1429 | monospace(info); |
1430 | monospace(info); | 1430 | } |
1431 | } | 1431 | else if ( msg == "Format/SetWidth(int)" ) |
1432 | else if ( msg == "Format/SetWidth(int)" ) | 1432 | { |
1433 | { | 1433 | int info; |
1434 | int info; | 1434 | stream >> info; |
1435 | stream >> info; | 1435 | reader->m_charpc = info; |
1436 | reader->m_charpc = info; | 1436 | reader->setfont(); |
1437 | reader->setfont(); | 1437 | reader->refresh(); |
1438 | reader->refresh(); | 1438 | } |
1439 | } | 1439 | else if ( msg == "Format/SetFont(QString,int)" ) |
1440 | else if ( msg == "Format/SetFont(QString,int)" ) | 1440 | { |
1441 | { | 1441 | QString fontname; |
1442 | QString fontname; | 1442 | int size; |
1443 | int size; | 1443 | stream >> fontname; |
1444 | stream >> fontname; | 1444 | stream >> size; |
1445 | stream >> size; | 1445 | setfontHelper(fontname, size); |
1446 | setfontHelper(fontname, size); | 1446 | } |
1447 | } | 1447 | else if ( msg == "Marks/Autogen(QString)" ) |
1448 | else if ( msg == "Marks/Autogen(QString)" ) | 1448 | { |
1449 | { | 1449 | QString info; |
1450 | QString info; | 1450 | stream >> info; |
1451 | stream >> info; | 1451 | do_autogen(info); |
1452 | do_autogen(info); | 1452 | } |
1453 | } | 1453 | else if ( msg == "File/StartBlock()" ) |
1454 | else if ( msg == "File/StartBlock()" ) | 1454 | { |
1455 | { | 1455 | editMark(); |
1456 | editMark(); | 1456 | } |
1457 | } | 1457 | else if ( msg == "File/CopyBlock()" ) |
1458 | else if ( msg == "File/CopyBlock()" ) | 1458 | { |
1459 | { | 1459 | editCopy(); |
1460 | editCopy(); | 1460 | } |
1461 | } | 1461 | } |
1462 | } | 1462 | #endif |
1463 | #endif | 1463 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) |
1464 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) | 1464 | { |
1465 | { | 1465 | for (int i = 0; i < MAX_ACTIONS; i++) |
1466 | for (int i = 0; i < MAX_ACTIONS; i++) | 1466 | { |
1467 | { | 1467 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; |
1468 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; | 1468 | } |
1469 | } | 1469 | return cesAutoScroll; |
1470 | return cesAutoScroll; | 1470 | } |
1471 | } | 1471 | |
1472 | 1472 | void QTReaderApp::setfullscreen(bool sfs) | |
1473 | void QTReaderApp::setfullscreen(bool sfs) | 1473 | { |
1474 | { | 1474 | reader->bDoUpdates = false; |
1475 | reader->bDoUpdates = false; | 1475 | m_fullscreen = sfs; |
1476 | m_fullscreen = sfs; | 1476 | showEditTools(); |
1477 | showEditTools(); | 1477 | // qApp->processEvents(); |
1478 | // qApp->processEvents(); | 1478 | reader->bDoUpdates = true; |
1479 | reader->bDoUpdates = true; | 1479 | reader->update(); |
1480 | reader->update(); | 1480 | } |
1481 | } | 1481 | |
1482 | 1482 | void QTReaderApp::buttonActionSelected(QAction* _a) | |
1483 | void QTReaderApp::buttonActionSelected(QAction* _a) | 1483 | { |
1484 | { | 1484 | //// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); |
1485 | //// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); | 1485 | m_spaceTarget = ActNameToInt(_a->text()); |
1486 | m_spaceTarget = ActNameToInt(_a->text()); | 1486 | } |
1487 | } | 1487 | |
1488 | 1488 | QTReaderApp::~QTReaderApp() | |
1489 | QTReaderApp::~QTReaderApp() | 1489 | { |
1490 | { | 1490 | } |
1491 | } | 1491 | |
1492 | 1492 | void QTReaderApp::autoScroll(bool _b) | |
1493 | void QTReaderApp::autoScroll(bool _b) | 1493 | { |
1494 | { | 1494 | reader->setautoscroll(_b); |
1495 | reader->setautoscroll(_b); | 1495 | setScrollState(reader->m_autoScroll); |
1496 | setScrollState(reader->m_autoScroll); | 1496 | } |
1497 | } | 1497 | |
1498 | 1498 | void QTReaderApp::zoomin() | |
1499 | void QTReaderApp::zoomin() | 1499 | { |
1500 | { | 1500 | reader->zoomin(); |
1501 | reader->zoomin(); | 1501 | } |
1502 | } | 1502 | |
1503 | 1503 | void QTReaderApp::zoomout() | |
1504 | void QTReaderApp::zoomout() | 1504 | { |
1505 | { | 1505 | reader->zoomout(); |
1506 | reader->zoomout(); | 1506 | } |
1507 | } | 1507 | |
1508 | 1508 | void QTReaderApp::clearBkmkList() | |
1509 | void QTReaderApp::clearBkmkList() | 1509 | { |
1510 | { | 1510 | delete pBkmklist; |
1511 | delete pBkmklist; | 1511 | pBkmklist = NULL; |
1512 | pBkmklist = NULL; | 1512 | m_fBkmksChanged = false; |
1513 | m_fBkmksChanged = false; | 1513 | } |
1514 | } | 1514 | |
1515 | 1515 | void QTReaderApp::fileClose() | |
1516 | void QTReaderApp::fileClose() | 1516 | { |
1517 | { | 1517 | CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); |
1518 | CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); | 1518 | if (cd->exec()) |
1519 | if (cd->exec()) | 1519 | { |
1520 | { | 1520 | if (pOpenlist != NULL) |
1521 | if (pOpenlist != NULL) | 1521 | { |
1522 | { | 1522 | int ind = 0; |
1523 | int ind = 0; | 1523 | Bkmk* p = (*pOpenlist)[ind]; |
1524 | Bkmk* p = (*pOpenlist)[ind]; | 1524 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) |
1525 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | 1525 | { |
1526 | { | 1526 | p = (*pOpenlist)[++ind]; |
1527 | p = (*pOpenlist)[++ind]; | 1527 | } |
1528 | } | 1528 | if (p != NULL) pOpenlist->erase(ind); |
1529 | if (p != NULL) pOpenlist->erase(ind); | 1529 | if (cd->delFile()) |
1530 | if (cd->delFile()) | 1530 | { |
1531 | { | 1531 | unlink((const char*)reader->m_lastfile); |
1532 | unlink((const char*)reader->m_lastfile); | 1532 | } |
1533 | } | 1533 | if (cd->delMarks()) |
1534 | if (cd->delMarks()) | 1534 | { |
1535 | { | 1535 | #ifndef USEQPE |
1536 | #ifndef USEQPE | 1536 | QDir d = QDir::home(); // "/" |
1537 | QDir d = QDir::home(); // "/" | 1537 | d.cd(APPDIR); |
1538 | d.cd(APPDIR); | 1538 | d.remove(reader->m_string); |
1539 | d.remove(reader->m_string); | 1539 | #else /* USEQPE */ |
1540 | #else /* USEQPE */ | 1540 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
1541 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 1541 | #endif /* USEQPE */ |
1542 | #endif /* USEQPE */ | 1542 | } |
1543 | } | 1543 | if (cd->delConfig()) |
1544 | if (cd->delConfig()) | 1544 | { |
1545 | { | 1545 | #ifndef USEQPE |
1546 | #ifndef USEQPE | 1546 | QDir d = QDir::home(); // "/" |
1547 | QDir d = QDir::home(); // "/" | 1547 | d.cd(APPDIR "/configs"); |
1548 | d.cd(APPDIR "/configs"); | 1548 | d.remove(reader->m_string); |
1549 | d.remove(reader->m_string); | 1549 | #else /* USEQPE */ |
1550 | #else /* USEQPE */ | 1550 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); |
1551 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); | 1551 | #endif /* USEQPE */ |
1552 | #endif /* USEQPE */ | 1552 | } |
1553 | } | 1553 | } |
1554 | } | 1554 | |
1555 | 1555 | fileOpen2(); | |
1556 | fileOpen2(); | 1556 | } |
1557 | } | 1557 | delete cd; |
1558 | delete cd; | 1558 | } |
1559 | } | 1559 | |
1560 | 1560 | void QTReaderApp::updatefileinfo() | |
1561 | void QTReaderApp::updatefileinfo() | 1561 | { |
1562 | { | 1562 | if (reader->m_string.isEmpty()) return; |
1563 | if (reader->m_string.isEmpty()) return; | 1563 | if (reader->m_lastfile.isEmpty()) return; |
1564 | if (reader->m_lastfile.isEmpty()) return; | 1564 | tchar* nm = fromQString(reader->m_string); |
1565 | tchar* nm = fromQString(reader->m_string); | 1565 | tchar* fl = fromQString(reader->m_lastfile); |
1566 | tchar* fl = fromQString(reader->m_lastfile); | 1566 | // qDebug("Lastfile:%x", fl); |
1567 | // qDebug("Lastfile:%x", fl); | 1567 | bool notadded = true; |
1568 | bool notadded = true; | 1568 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; |
1569 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; | 1569 | else |
1570 | else | 1570 | { |
1571 | { | 1571 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) |
1572 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | 1572 | { |
1573 | { | 1573 | if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) |
1574 | if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) | 1574 | { |
1575 | { | 1575 | iter->value(reader->pagelocate()); |
1576 | iter->value(reader->pagelocate()); | 1576 | unsigned short dlen; |
1577 | unsigned short dlen; | 1577 | unsigned char* data; |
1578 | unsigned char* data; | 1578 | CFiledata fd(iter->anno()); |
1579 | CFiledata fd(iter->anno()); | 1579 | reader->setSaveData(data, dlen, fd.content(), fd.length()); |
1580 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | 1580 | // qDebug("Filedata(1):%u, %u", fd.length(), dlen); |
1581 | // qDebug("Filedata(1):%u, %u", fd.length(), dlen); | 1581 | // getstate(data, dlen); |
1582 | // getstate(data, dlen); | 1582 | iter->setAnno(data, dlen); |
1583 | iter->setAnno(data, dlen); | 1583 | notadded = false; |
1584 | notadded = false; | 1584 | delete [] data; |
1585 | delete [] data; | 1585 | break; |
1586 | break; | 1586 | } |
1587 | } | 1587 | } |
1588 | } | 1588 | } |
1589 | } | 1589 | // qDebug("Added?:%x", notadded); |
1590 | // qDebug("Added?:%x", notadded); | 1590 | if (notadded) |
1591 | if (notadded) | 1591 | { |
1592 | { | 1592 | struct stat fnstat; |
1593 | struct stat fnstat; | 1593 | stat((const char *)reader->m_lastfile, &fnstat); |
1594 | stat((const char *)reader->m_lastfile, &fnstat); | 1594 | CFiledata fd(fnstat.st_mtime, fl); |
1595 | CFiledata fd(fnstat.st_mtime, fl); | 1595 | unsigned short dlen; |
1596 | unsigned short dlen; | 1596 | unsigned char* data; |
1597 | unsigned char* data; | 1597 | reader->setSaveData(data, dlen, fd.content(), fd.length()); |
1598 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | 1598 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); |
1599 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); | 1599 | //qDebug("Filedata(2):%u, %u", fd.length(), dlen); |
1600 | //qDebug("Filedata(2):%u, %u", fd.length(), dlen); | 1600 | delete [] data; |
1601 | delete [] data; | 1601 | } |
1602 | } | 1602 | delete [] nm; |
1603 | delete [] nm; | 1603 | delete [] fl; |
1604 | delete [] fl; | 1604 | } |
1605 | } | 1605 | |
1606 | 1606 | void QTReaderApp::fileOpen() | |
1607 | void QTReaderApp::fileOpen() | 1607 | { |
1608 | { | 1608 | /* |
1609 | /* | 1609 | menu->hide(); |
1610 | menu->hide(); | 1610 | fileBar->hide(); |
1611 | fileBar->hide(); | 1611 | if (regVisible) regBar->hide(); |
1612 | if (regVisible) regBar->hide(); | 1612 | if (searchVisible) searchBar->hide(); |
1613 | if (searchVisible) searchBar->hide(); | 1613 | */ |
1614 | */ | 1614 | // qDebug("fileOpen"); |
1615 | // qDebug("fileOpen"); | 1615 | // if (!reader->m_lastfile.isEmpty()) |
1616 | // if (!reader->m_lastfile.isEmpty()) | 1616 | updatefileinfo(); |
1617 | updatefileinfo(); | 1617 | fileOpen2(); |
1618 | fileOpen2(); | 1618 | } |
1619 | } | 1619 | |
1620 | 1620 | void QTReaderApp::fileOpen2() | |
1621 | void QTReaderApp::fileOpen2() | 1621 | { |
1622 | { | 1622 | if (pBkmklist != NULL) |
1623 | if (pBkmklist != NULL) | 1623 | { |
1624 | { | 1624 | if (m_fBkmksChanged) |
1625 | if (m_fBkmksChanged) | 1625 | { |
1626 | { | 1626 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
1627 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | 1627 | savebkmks(); |
1628 | savebkmks(); | 1628 | } |
1629 | } | 1629 | delete pBkmklist; |
1630 | delete pBkmklist; | 1630 | pBkmklist = NULL; |
1631 | pBkmklist = NULL; | 1631 | m_fBkmksChanged = false; |
1632 | m_fBkmksChanged = false; | 1632 | } |
1633 | } | 1633 | reader->disableAutoscroll(); |
1634 | reader->disableAutoscroll(); | 1634 | /* |
1635 | /* | 1635 | editorStack->raiseWidget( fileSelector ); |
1636 | editorStack->raiseWidget( fileSelector ); | 1636 | fileSelector->reread(); |
1637 | fileSelector->reread(); | 1637 | */ |
1638 | */ | 1638 | bool usebrowser = true; |
1639 | bool usebrowser = true; | 1639 | if (pOpenlist != NULL) |
1640 | if (pOpenlist != NULL) | 1640 | { |
1641 | { | 1641 | m_nBkmkAction = cOpenFile; |
1642 | m_nBkmkAction = cOpenFile; | 1642 | if (listbkmk(pOpenlist, "Browse")) usebrowser = false; |
1643 | if (listbkmk(pOpenlist, "Browse")) usebrowser = false; | 1643 | } |
1644 | } | 1644 | if (usebrowser) |
1645 | if (usebrowser) | 1645 | { |
1646 | { | 1646 | QString fn = usefilebrowser(); |
1647 | QString fn = usefilebrowser(); | 1647 | //qApp->processEvents(); |
1648 | //qApp->processEvents(); | 1648 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
1649 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 1649 | { |
1650 | { | 1650 | openFile(fn); |
1651 | openFile(fn); | 1651 | } |
1652 | } | 1652 | reader->setFocus(); |
1653 | reader->setFocus(); | 1653 | } |
1654 | } | 1654 | // reader->refresh(); |
1655 | // reader->refresh(); | 1655 | // qDebug("HEIGHT:%d", reader->m_lastheight); |
1656 | // qDebug("HEIGHT:%d", reader->m_lastheight); | 1656 | } |
1657 | } | 1657 | |
1658 | 1658 | QString QTReaderApp::usefilebrowser() | |
1659 | QString QTReaderApp::usefilebrowser() | 1659 | { |
1660 | { | 1660 | #ifndef USEQPE |
1661 | #ifndef USEQPE | 1661 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); |
1662 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); | 1662 | return s; |
1663 | return s; | 1663 | #else |
1664 | #else | 1664 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, |
1665 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, | 1665 | 0, |
1666 | 0, | 1666 | // WStyle_Customize | WStyle_NoBorderEx, |
1667 | // WStyle_Customize | WStyle_NoBorderEx, | 1667 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); |
1668 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); | 1668 | |
1669 | 1669 | ||
1670 | 1670 | QString fn; | |
1671 | QString fn; | 1671 | if (fb->exec()) |
1672 | if (fb->exec()) | 1672 | { |
1673 | { | 1673 | fn = fb->getCurrentFile(); |
1674 | fn = fb->getCurrentFile(); | 1674 | } |
1675 | } | 1675 | // qDebug("Selected %s", (const char*)fn); |
1676 | // qDebug("Selected %s", (const char*)fn); | 1676 | delete fb; |
1677 | delete fb; | 1677 | showEditTools(); |
1678 | showEditTools(); | 1678 | return fn; |
1679 | return fn; | 1679 | #endif |
1680 | #endif | 1680 | } |
1681 | } | 1681 | |
1682 | 1682 | void QTReaderApp::showgraphic(QImage& pm) | |
1683 | void QTReaderApp::showgraphic(QImage& pm) | 1683 | { |
1684 | { | 1684 | QPixmap pc; |
1685 | QPixmap pc; | 1685 | pc.convertFromImage(pm); |
1686 | pc.convertFromImage(pm); | 1686 | m_graphicwin->setPixmap(pc); |
1687 | m_graphicwin->setPixmap(pc); | 1687 | editorStack->raiseWidget( m_graphicwin ); |
1688 | editorStack->raiseWidget( m_graphicwin ); | 1688 | m_graphicwin->setFocus(); |
1689 | m_graphicwin->setFocus(); | 1689 | } |
1690 | } | 1690 | |
1691 | 1691 | ||
1692 | 1692 | void QTReaderApp::showprefs() | |
1693 | void QTReaderApp::showprefs() | 1693 | { |
1694 | { | 1694 | CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this); |
1695 | CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this); | 1695 | |
1696 | 1696 | prefwin->twotouch(m_twoTouch); | |
1697 | prefwin->twotouch(m_twoTouch); | 1697 | prefwin->propfontchange(m_propogatefontchange); |
1698 | prefwin->propfontchange(m_propogatefontchange); | 1698 | prefwin->StripCR(reader->bstripcr); |
1699 | prefwin->StripCR(reader->bstripcr); | 1699 | prefwin->Dehyphen(reader->bdehyphen); |
1700 | prefwin->Dehyphen(reader->bdehyphen); | 1700 | prefwin->SingleSpace(reader->bonespace); |
1701 | prefwin->SingleSpace(reader->bonespace); | 1701 | prefwin->Unindent(reader->bunindent); |
1702 | prefwin->Unindent(reader->bunindent); | 1702 | prefwin->Reparagraph(reader->brepara); |
1703 | prefwin->Reparagraph(reader->brepara); | 1703 | prefwin->DoubleSpace(reader->bdblspce); |
1704 | prefwin->DoubleSpace(reader->bdblspce); | 1704 | prefwin->Remap(reader->bremap); |
1705 | prefwin->Remap(reader->bremap); | 1705 | prefwin->Embolden(reader->bmakebold); |
1706 | prefwin->Embolden(reader->bmakebold); | 1706 | prefwin->FullJustify(reader->bfulljust); |
1707 | prefwin->FullJustify(reader->bfulljust); | 1707 | prefwin->ParaLead(reader->getextraspace()); |
1708 | prefwin->ParaLead(reader->getextraspace()); | 1708 | prefwin->LineLead(reader->getlead()); |
1709 | prefwin->LineLead(reader->getlead()); | 1709 | prefwin->Margin(reader->m_border); |
1710 | prefwin->Margin(reader->m_border); | 1710 | prefwin->Indent(reader->bindenter); |
1711 | prefwin->Indent(reader->bindenter); | 1711 | if (reader->bautofmt) |
1712 | if (reader->bautofmt) | 1712 | { |
1713 | { | 1713 | prefwin->Markup(0); |
1714 | prefwin->Markup(0); | 1714 | } |
1715 | } | 1715 | else if (reader->btextfmt) |
1716 | else if (reader->btextfmt) | 1716 | { |
1717 | { | 1717 | prefwin->Markup(2); |
1718 | prefwin->Markup(2); | 1718 | } |
1719 | } | 1719 | else if (reader->bstriphtml) |
1720 | else if (reader->bstriphtml) | 1720 | { |
1721 | { | 1721 | prefwin->Markup(3); |
1722 | prefwin->Markup(3); | 1722 | } |
1723 | } | 1723 | else if (reader->bpeanut) |
1724 | else if (reader->bpeanut) | 1724 | { |
1725 | { | 1725 | prefwin->Markup(4); |
1726 | prefwin->Markup(4); | 1726 | } |
1727 | } | 1727 | else |
1728 | else | 1728 | { |
1729 | { | 1729 | prefwin->Markup(1); |
1730 | prefwin->Markup(1); | 1730 | } |
1731 | } | 1731 | prefwin->Depluck(reader->bdepluck); |
1732 | prefwin->Depluck(reader->bdepluck); | 1732 | prefwin->Dejpluck(reader->bdejpluck); |
1733 | prefwin->Dejpluck(reader->bdejpluck); | 1733 | prefwin->Continuous(reader->m_continuousDocument); |
1734 | prefwin->Continuous(reader->m_continuousDocument); | 1734 | |
1735 | 1735 | prefwin->dictApplication(m_targetapp); | |
1736 | prefwin->dictApplication(m_targetapp); | 1736 | prefwin->dictMessage(m_targetmsg); |
1737 | prefwin->dictMessage(m_targetmsg); | 1737 | |
1738 | 1738 | prefwin->spaceAction(m_spaceTarget); | |
1739 | prefwin->spaceAction(m_spaceTarget); | 1739 | prefwin->escapeAction(m_escapeTarget); |
1740 | prefwin->escapeAction(m_escapeTarget); | 1740 | prefwin->returnAction(m_returnTarget); |
1741 | prefwin->returnAction(m_returnTarget); | 1741 | prefwin->leftAction(m_leftTarget); |
1742 | prefwin->leftAction(m_leftTarget); | 1742 | prefwin->rightAction(m_rightTarget); |
1743 | prefwin->rightAction(m_rightTarget); | 1743 | prefwin->upAction(m_upTarget); |
1744 | prefwin->upAction(m_upTarget); | 1744 | prefwin->downAction(m_downTarget); |
1745 | prefwin->downAction(m_downTarget); | 1745 | |
1746 | 1746 | prefwin->leftScroll(m_leftScroll); | |
1747 | prefwin->leftScroll(m_leftScroll); | 1747 | prefwin->rightScroll(m_rightScroll); |
1748 | prefwin->rightScroll(m_rightScroll); | 1748 | prefwin->upScroll(m_upScroll); |
1749 | prefwin->upScroll(m_upScroll); | 1749 | prefwin->downScroll(m_downScroll); |
1750 | prefwin->downScroll(m_downScroll); | 1750 | |
1751 | 1751 | prefwin->miscannotation(m_doAnnotation); | |
1752 | prefwin->miscannotation(m_doAnnotation); | 1752 | prefwin->miscdictionary(m_doDictionary); |
1753 | prefwin->miscdictionary(m_doDictionary); | 1753 | prefwin->miscclipboard(m_doClipboard); |
1754 | prefwin->miscclipboard(m_doClipboard); | 1754 | |
1755 | 1755 | prefwin->SwapMouse(reader->m_swapmouse); | |
1756 | prefwin->SwapMouse(reader->m_swapmouse); | 1756 | |
1757 | 1757 | prefwin->Font(reader->m_fontname); | |
1758 | prefwin->Font(reader->m_fontname); | 1758 | |
1759 | 1759 | prefwin->gfxsize(reader->getBaseSize()); | |
1760 | prefwin->gfxsize(reader->getBaseSize()); | 1760 | |
1761 | 1761 | prefwin->pageoverlap(reader->m_overlap); | |
1762 | prefwin->pageoverlap(reader->m_overlap); | 1762 | |
1763 | 1763 | prefwin->ideogram(reader->m_bMonoSpaced); | |
1764 | prefwin->ideogram(reader->m_bMonoSpaced); | 1764 | |
1765 | 1765 | prefwin->encoding(reader->m_encd); | |
1766 | prefwin->encoding(reader->m_encd); | 1766 | |
1767 | 1767 | prefwin->ideogramwidth(reader->m_charpc); | |
1768 | prefwin->ideogramwidth(reader->m_charpc); | 1768 | |
1769 | 1769 | if (prefwin->exec()) | |
1770 | if (prefwin->exec()) | 1770 | { |
1771 | { | 1771 | m_twoTouch = prefwin->twotouch(); |
1772 | m_twoTouch = prefwin->twotouch(); | 1772 | reader->setTwoTouch(m_twoTouch); |
1773 | reader->setTwoTouch(m_twoTouch); | 1773 | m_touch_action->setOn(m_twoTouch); |
1774 | m_touch_action->setOn(m_twoTouch); | 1774 | |
1775 | 1775 | reader->bstripcr = prefwin->StripCR(); | |
1776 | reader->bstripcr = prefwin->StripCR(); | 1776 | reader->bdehyphen = prefwin->Dehyphen(); |
1777 | reader->bdehyphen = prefwin->Dehyphen(); | 1777 | reader->bonespace = prefwin->SingleSpace(); |
1778 | reader->bonespace = prefwin->SingleSpace(); | 1778 | reader->bunindent = prefwin->Unindent(); |
1779 | reader->bunindent = prefwin->Unindent(); | 1779 | reader->brepara = prefwin->Reparagraph(); |
1780 | reader->brepara = prefwin->Reparagraph(); | 1780 | reader->bdblspce = prefwin->DoubleSpace(); |
1781 | reader->bdblspce = prefwin->DoubleSpace(); | 1781 | reader->bremap = prefwin->Remap(); |
1782 | reader->bremap = prefwin->Remap(); | 1782 | reader->bmakebold = prefwin->Embolden(); |
1783 | reader->bmakebold = prefwin->Embolden(); | 1783 | reader->bfulljust = prefwin->FullJustify(); |
1784 | reader->bfulljust = prefwin->FullJustify(); | 1784 | reader->setextraspace(prefwin->ParaLead()); |
1785 | reader->setextraspace(prefwin->ParaLead()); | 1785 | reader->setlead(prefwin->LineLead()); |
1786 | reader->setlead(prefwin->LineLead()); | 1786 | reader->m_border = prefwin->Margin(); |
1787 | reader->m_border = prefwin->Margin(); | 1787 | reader->bindenter = prefwin->Indent(); |
1788 | reader->bindenter = prefwin->Indent(); | 1788 | reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; |
1789 | reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; | 1789 | switch (prefwin->Markup()) |
1790 | switch (prefwin->Markup()) | 1790 | { |
1791 | { | 1791 | case 0: |
1792 | case 0: | 1792 | reader->bautofmt = true; |
1793 | reader->bautofmt = true; | 1793 | break; |
1794 | break; | 1794 | case 1: |
1795 | case 1: | 1795 | break; |
1796 | break; | 1796 | case 2: |
1797 | case 2: | 1797 | reader->btextfmt = true; |
1798 | reader->btextfmt = true; | 1798 | break; |
1799 | break; | 1799 | case 3: |
1800 | case 3: | 1800 | reader->bstriphtml = true; |
1801 | reader->bstriphtml = true; | 1801 | break; |
1802 | break; | 1802 | case 4: |
1803 | case 4: | 1803 | reader->bpeanut = true; |
1804 | reader->bpeanut = true; | 1804 | break; |
1805 | break; | 1805 | default: |
1806 | default: | 1806 | qDebug("Format out of range"); |
1807 | qDebug("Format out of range"); | 1807 | } |
1808 | } | 1808 | reader->bdepluck = prefwin->Depluck(); |
1809 | reader->bdepluck = prefwin->Depluck(); | 1809 | reader->bdejpluck = prefwin->Dejpluck(); |
1810 | reader->bdejpluck = prefwin->Dejpluck(); | 1810 | reader->setContinuous(prefwin->Continuous()); |
1811 | reader->setContinuous(prefwin->Continuous()); | 1811 | |
1812 | 1812 | m_spaceTarget = (ActionTypes)prefwin->spaceAction(); | |
1813 | m_spaceTarget = (ActionTypes)prefwin->spaceAction(); | 1813 | m_escapeTarget = (ActionTypes)prefwin->escapeAction(); |
1814 | m_escapeTarget = (ActionTypes)prefwin->escapeAction(); | 1814 | m_returnTarget = (ActionTypes)prefwin->returnAction(); |
1815 | m_returnTarget = (ActionTypes)prefwin->returnAction(); | 1815 | m_leftTarget = (ActionTypes)prefwin->leftAction(); |
1816 | m_leftTarget = (ActionTypes)prefwin->leftAction(); | 1816 | m_rightTarget = (ActionTypes)prefwin->rightAction(); |
1817 | m_rightTarget = (ActionTypes)prefwin->rightAction(); | 1817 | m_upTarget = (ActionTypes)prefwin->upAction(); |
1818 | m_upTarget = (ActionTypes)prefwin->upAction(); | 1818 | m_downTarget = (ActionTypes)prefwin->downAction(); |
1819 | m_downTarget = (ActionTypes)prefwin->downAction(); | 1819 | m_leftScroll = prefwin->leftScroll(); |
1820 | m_leftScroll = prefwin->leftScroll(); | 1820 | m_rightScroll = prefwin->rightScroll(); |
1821 | m_rightScroll = prefwin->rightScroll(); | 1821 | m_upScroll = prefwin->upScroll(); |
1822 | m_upScroll = prefwin->upScroll(); | 1822 | m_downScroll = prefwin->downScroll(); |
1823 | m_downScroll = prefwin->downScroll(); | 1823 | |
1824 | 1824 | m_targetapp = prefwin->dictApplication(); | |
1825 | m_targetapp = prefwin->dictApplication(); | 1825 | m_targetmsg = prefwin->dictMessage(); |
1826 | m_targetmsg = prefwin->dictMessage(); | 1826 | |
1827 | 1827 | m_doAnnotation = prefwin->miscannotation(); | |
1828 | m_doAnnotation = prefwin->miscannotation(); | 1828 | m_doDictionary = prefwin->miscdictionary(); |
1829 | m_doDictionary = prefwin->miscdictionary(); | 1829 | m_doClipboard = prefwin->miscclipboard(); |
1830 | m_doClipboard = prefwin->miscclipboard(); | 1830 | reader->m_swapmouse = prefwin->SwapMouse(); |
1831 | reader->m_swapmouse = prefwin->SwapMouse(); | 1831 | reader->setBaseSize(prefwin->gfxsize()); |
1832 | reader->setBaseSize(prefwin->gfxsize()); | 1832 | reader->m_overlap = prefwin->pageoverlap(); |
1833 | reader->m_overlap = prefwin->pageoverlap(); | 1833 | reader->m_bMonoSpaced = prefwin->ideogram(); |
1834 | reader->m_bMonoSpaced = prefwin->ideogram(); | 1834 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
1835 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 1835 | reader->m_encd = prefwin->encoding(); |
1836 | reader->m_encd = prefwin->encoding(); | 1836 | reader->m_charpc = prefwin->ideogramwidth(); |
1837 | reader->m_charpc = prefwin->ideogramwidth(); | 1837 | |
1838 | 1838 | if ( | |
1839 | if ( | 1839 | reader->m_fontname != prefwin->Font() |
1840 | reader->m_fontname != prefwin->Font() | 1840 | || |
1841 | || | 1841 | m_propogatefontchange != prefwin->propfontchange()) |
1842 | m_propogatefontchange != prefwin->propfontchange()) | 1842 | { |
1843 | { | 1843 | m_propogatefontchange = prefwin->propfontchange(); |
1844 | m_propogatefontchange = prefwin->propfontchange(); | 1844 | setfontHelper(prefwin->Font()); |
1845 | setfontHelper(prefwin->Font()); | 1845 | } |
1846 | } | 1846 | delete prefwin; |
1847 | delete prefwin; | 1847 | reader->setfilter(reader->getfilter()); |
1848 | reader->setfilter(reader->getfilter()); | 1848 | reader->refresh(); |
1849 | reader->refresh(); | 1849 | |
1850 | 1850 | } | |
1851 | } | 1851 | else |
1852 | else | 1852 | { |
1853 | { | 1853 | delete prefwin; |
1854 | delete prefwin; | 1854 | } |
1855 | } | 1855 | } |
1856 | } | 1856 | |
1857 | 1857 | void QTReaderApp::showtoolbarprefs() | |
1858 | void QTReaderApp::showtoolbarprefs() | 1858 | { |
1859 | { | 1859 | #ifdef USEQPE |
1860 | #ifdef USEQPE | 1860 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); |
1861 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); | 1861 | #else |
1862 | #else | 1862 | QFileInfo fi; |
1863 | QFileInfo fi; | 1863 | QDir d = QDir::home(); // "/" |
1864 | QDir d = QDir::home(); // "/" | 1864 | if ( !d.cd(APPDIR) ) |
1865 | if ( !d.cd(APPDIR) ) | 1865 | { // "/tmp" |
1866 | { // "/tmp" | 1866 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
1867 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | 1867 | d = QDir::home(); |
1868 | d = QDir::home(); | 1868 | d.mkdir(APPDIR); |
1869 | d.mkdir(APPDIR); | 1869 | d.cd(APPDIR); |
1870 | d.cd(APPDIR); | 1870 | } |
1871 | } | 1871 | fi.setFile(d, INIFILE); |
1872 | fi.setFile(d, INIFILE); | 1872 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); |
1873 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); | 1873 | #endif |
1874 | #endif | 1874 | prefwin->tbpolicy(m_tbpolsave); |
1875 | prefwin->tbpolicy(m_tbpolsave); | 1875 | prefwin->tbposition(m_tbposition-2); |
1876 | prefwin->tbposition(m_tbposition-2); | 1876 | prefwin->tbmovable(m_tbmovesave); |
1877 | prefwin->tbmovable(m_tbmovesave); | 1877 | prefwin->floating(m_bFloatingDialog); |
1878 | prefwin->floating(m_bFloatingDialog); | 1878 | if (prefwin->exec()) |
1879 | if (prefwin->exec()) | 1879 | { |
1880 | { | 1880 | m_bFloatingDialog = prefwin->floating(); |
1881 | m_bFloatingDialog = prefwin->floating(); | 1881 | if ( |
1882 | if ( | 1882 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() |
1883 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() | 1883 | || |
1884 | || | 1884 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) |
1885 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) | 1885 | || |
1886 | || | 1886 | m_tbmovesave != prefwin->tbmovable() |
1887 | m_tbmovesave != prefwin->tbmovable() | 1887 | ) |
1888 | ) | 1888 | { |
1889 | { | 1889 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); |
1890 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); | 1890 | } |
1891 | } | 1891 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); |
1892 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); | 1892 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); |
1893 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); | 1893 | m_tbmovesave = prefwin->tbmovable(); |
1894 | m_tbmovesave = prefwin->tbmovable(); | 1894 | bool isChanged = prefwin->isChanged(); |
1895 | bool isChanged = prefwin->isChanged(); | 1895 | delete prefwin; |
1896 | delete prefwin; | 1896 | #ifdef USEQPE |
1897 | #ifdef USEQPE | 1897 | Config config( APPDIR ); |
1898 | Config config( APPDIR ); | 1898 | #else |
1899 | #else | 1899 | QFileInfo fi; |
1900 | QFileInfo fi; | 1900 | QDir d = QDir::home(); // "/" |
1901 | QDir d = QDir::home(); // "/" | 1901 | if ( !d.cd(APPDIR) ) |
1902 | if ( !d.cd(APPDIR) ) | 1902 | { // "/tmp" |
1903 | { // "/tmp" | 1903 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
1904 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | 1904 | d = QDir::home(); |
1905 | d = QDir::home(); | 1905 | d.mkdir(APPDIR); |
1906 | d.mkdir(APPDIR); | 1906 | d.cd(APPDIR); |
1907 | d.cd(APPDIR); | 1907 | } |
1908 | } | 1908 | fi.setFile(d, INIFILE); |
1909 | fi.setFile(d, INIFILE); | 1909 | Config config( fi.absFilePath() ); |
1910 | Config config( fi.absFilePath() ); | 1910 | #endif |
1911 | #endif | 1911 | if (isChanged) addtoolbars(&config); |
1912 | if (isChanged) addtoolbars(&config); | 1912 | } |
1913 | } | 1913 | else |
1914 | else | 1914 | { |
1915 | { | 1915 | delete prefwin; |
1916 | delete prefwin; | 1916 | } |
1917 | } | 1917 | } |
1918 | } | 1918 | |
1919 | 1919 | void QTReaderApp::showinfo() | |
1920 | void QTReaderApp::showinfo() | 1920 | { |
1921 | { | 1921 | unsigned long fs, ts, pl; |
1922 | unsigned long fs, ts, pl; | 1922 | if (reader->empty()) |
1923 | if (reader->empty()) | 1923 | { |
1924 | { | 1924 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
1925 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 1925 | } |
1926 | } | 1926 | else |
1927 | else | 1927 | { |
1928 | { | 1928 | reader->sizes(fs,ts); |
1929 | reader->sizes(fs,ts); | 1929 | pl = reader->pagelocate(); |
1930 | pl = reader->pagelocate(); | 1930 | m_infoWin->setFileSize(fs); |
1931 | m_infoWin->setFileSize(fs); | 1931 | m_infoWin->setTextSize(ts); |
1932 | m_infoWin->setTextSize(ts); | 1932 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); |
1933 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); | 1933 | m_infoWin->setLocation(pl); |
1934 | m_infoWin->setLocation(pl); | 1934 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); |
1935 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); | 1935 | editorStack->raiseWidget( m_infoWin ); |
1936 | editorStack->raiseWidget( m_infoWin ); | 1936 | m_infoWin->setFocus(); |
1937 | m_infoWin->setFocus(); | 1937 | } |
1938 | } | 1938 | } |
1939 | } | 1939 | |
1940 | 1940 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) | |
1941 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) | 1941 | { |
1942 | { | 1942 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; |
1943 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; | 1943 | #ifdef _UNICODE |
1944 | #ifdef _UNICODE | 1944 | CBuffer buff(name.length()+1); |
1945 | CBuffer buff(name.length()+1); | 1945 | int i; |
1946 | int i; | 1946 | for (i = 0; i < name.length(); i++) |
1947 | for (i = 0; i < name.length(); i++) | 1947 | { |
1948 | { | 1948 | buff[i] = name[i].unicode(); |
1949 | buff[i] = name[i].unicode(); | 1949 | } |
1950 | } | 1950 | buff[i] = 0; |
1951 | buff[i] = 0; | 1951 | CBuffer buff2(text.length()+1); |
1952 | CBuffer buff2(text.length()+1); | 1952 | for (i = 0; i < text.length(); i++) |
1953 | for (i = 0; i < text.length(); i++) | 1953 | { |
1954 | { | 1954 | buff2[i] = text[i].unicode(); |
1955 | buff2[i] = text[i].unicode(); | 1955 | } |
1956 | } | 1956 | buff2[i] = 0; |
1957 | buff2[i] = 0; | 1957 | pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn)); |
1958 | pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn)); | 1958 | #else |
1959 | #else | 1959 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); |
1960 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); | 1960 | #endif |
1961 | #endif | 1961 | m_fBkmksChanged = true; |
1962 | m_fBkmksChanged = true; | 1962 | pBkmklist->sort(); |
1963 | pBkmklist->sort(); | 1963 | } |
1964 | } | 1964 | |
1965 | 1965 | void QTReaderApp::addAnno(const QString& name, const QString& text) | |
1966 | void QTReaderApp::addAnno(const QString& name, const QString& text) | 1966 | { |
1967 | { | 1967 | if (m_annoIsEditing) |
1968 | if (m_annoIsEditing) | 1968 | { |
1969 | { | 1969 | if (name.isEmpty()) |
1970 | if (name.isEmpty()) | 1970 | { |
1971 | { | 1971 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); |
1972 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); | 1972 | } |
1973 | } | 1973 | else |
1974 | else | 1974 | { |
1975 | { | 1975 | addAnno(name, text, m_annoWin->getPosn()); |
1976 | addAnno(name, text, m_annoWin->getPosn()); | 1976 | } |
1977 | } | 1977 | showEditTools(); |
1978 | showEditTools(); | 1978 | } |
1979 | } | 1979 | else |
1980 | else | 1980 | { |
1981 | { | 1981 | if (m_annoWin->edited()) |
1982 | if (m_annoWin->edited()) | 1982 | { |
1983 | { | 1983 | CBuffer buff(text.length()+1); |
1984 | CBuffer buff(text.length()+1); | 1984 | int i; |
1985 | int i; | 1985 | for (i = 0; i < text.length(); i++) |
1986 | for (i = 0; i < text.length(); i++) | 1986 | { |
1987 | { | 1987 | buff[i] = text[i].unicode(); |
1988 | buff[i] = text[i].unicode(); | 1988 | } |
1989 | } | 1989 | buff[i] = 0; |
1990 | buff[i] = 0; | 1990 | m_fBkmksChanged = true; |
1991 | m_fBkmksChanged = true; | 1991 | m_anno->setAnno(buff.data()); |
1992 | m_anno->setAnno(buff.data()); | 1992 | } |
1993 | } | 1993 | bool found = findNextBookmark(m_anno->value()+1); |
1994 | bool found = findNextBookmark(m_anno->value()+1); | 1994 | if (found) |
1995 | if (found) | 1995 | { |
1996 | { | 1996 | m_annoWin->setName(toQString(m_anno->name())); |
1997 | m_annoWin->setName(toQString(m_anno->name())); | 1997 | m_annoWin->setAnno(toQString(m_anno->anno())); |
1998 | m_annoWin->setAnno(toQString(m_anno->anno())); | 1998 | } |
1999 | } | 1999 | else |
2000 | else | 2000 | { |
2001 | { | 2001 | showEditTools(); |
2002 | showEditTools(); | 2002 | } |
2003 | } | 2003 | } |
2004 | } | 2004 | } |
2005 | } | 2005 | |
2006 | 2006 | bool QTReaderApp::findNextBookmark(size_t start) | |
2007 | bool QTReaderApp::findNextBookmark(size_t start) | 2007 | { |
2008 | { | 2008 | bool found = false; |
2009 | bool found = false; | 2009 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) |
2010 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) | 2010 | { |
2011 | { | 2011 | if (iter->value() >= start) |
2012 | if (iter->value() >= start) | 2012 | { |
2013 | { | 2013 | if (iter->value() < reader->locate()) |
2014 | if (iter->value() < reader->locate()) | 2014 | { |
2015 | { | 2015 | found = true; |
2016 | found = true; | 2016 | m_anno = iter.pContent(); |
2017 | m_anno = iter.pContent(); | 2017 | } |
2018 | } | 2018 | break; |
2019 | break; | 2019 | } |
2020 | } | 2020 | } |
2021 | } | 2021 | return found; |
2022 | return found; | 2022 | } |
2023 | } | 2023 | |
2024 | 2024 | void QTReaderApp::addanno() | |
2025 | void QTReaderApp::addanno() | 2025 | { |
2026 | { | 2026 | if (reader->empty()) |
2027 | if (reader->empty()) | 2027 | { |
2028 | { | 2028 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
2029 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 2029 | } |
2030 | } | 2030 | else |
2031 | else | 2031 | { |
2032 | { | 2032 | m_annoWin->setName(""); |
2033 | m_annoWin->setName(""); | 2033 | m_annoWin->setAnno(""); |
2034 | m_annoWin->setAnno(""); | 2034 | m_annoWin->setPosn(reader->pagelocate()); |
2035 | m_annoWin->setPosn(reader->pagelocate()); | 2035 | m_annoIsEditing = true; |
2036 | m_annoIsEditing = true; | 2036 | editorStack->raiseWidget( m_annoWin ); |
2037 | editorStack->raiseWidget( m_annoWin ); | 2037 | #ifdef USEQPE |
2038 | #ifdef USEQPE | 2038 | Global::showInputMethod(); |
2039 | Global::showInputMethod(); | 2039 | #endif |
2040 | #endif | 2040 | m_annoWin->setFocus(); |
2041 | m_annoWin->setFocus(); | 2041 | } |
2042 | } | 2042 | } |
2043 | } | 2043 | |
2044 | 2044 | void QTReaderApp::infoClose() | |
2045 | void QTReaderApp::infoClose() | 2045 | { |
2046 | { | 2046 | showEditTools(); |
2047 | showEditTools(); | 2047 | } |
2048 | } | 2048 | |
2049 | 2049 | /* | |
2050 | /* | 2050 | void QTReaderApp::fileRevert() |
2051 | void QTReaderApp::fileRevert() | 2051 | { |
2052 | { | 2052 | clear(); |
2053 | clear(); | 2053 | fileOpen(); |
2054 | fileOpen(); | 2054 | } |
2055 | } | 2055 | |
2056 | 2056 | void QTReaderApp::editCut() | |
2057 | void QTReaderApp::editCut() | 2057 | { |
2058 | { | 2058 | #ifndef QT_NO_CLIPBOARD |
2059 | #ifndef QT_NO_CLIPBOARD | 2059 | editor->cut(); |
2060 | editor->cut(); | 2060 | #endif |
2061 | #endif | 2061 | } |
2062 | } | 2062 | */ |
2063 | */ | 2063 | void QTReaderApp::editMark() |
2064 | void QTReaderApp::editMark() | 2064 | { |
2065 | { | 2065 | m_savedpos = reader->pagelocate(); |
2066 | m_savedpos = reader->pagelocate(); | 2066 | } |
2067 | } | 2067 | |
2068 | 2068 | void QTReaderApp::editCopy() | |
2069 | void QTReaderApp::editCopy() | 2069 | { |
2070 | { | 2070 | QClipboard* cb = QApplication::clipboard(); |
2071 | QClipboard* cb = QApplication::clipboard(); | 2071 | QString text; |
2072 | QString text; | 2072 | int ch; |
2073 | int ch; | 2073 | unsigned long currentpos = reader->pagelocate(); |
2074 | unsigned long currentpos = reader->pagelocate(); | 2074 | unsigned long endpos = reader->locate(); |
2075 | unsigned long endpos = reader->locate(); | 2075 | if (m_savedpos == 0xffffffff) |
2076 | if (m_savedpos == 0xffffffff) | 2076 | { |
2077 | { | 2077 | m_savedpos = currentpos; |
2078 | m_savedpos = currentpos; | 2078 | } |
2079 | } | 2079 | reader->jumpto(m_savedpos); |
2080 | reader->jumpto(m_savedpos); | 2080 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) |
2081 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) | 2081 | { |
2082 | { | 2082 | text += ch; |
2083 | text += ch; | 2083 | } |
2084 | } | 2084 | cb->setText(text); |
2085 | cb->setText(text); | 2085 | reader->locate(currentpos); |
2086 | reader->locate(currentpos); | 2086 | m_savedpos = 0xffffffff; |
2087 | m_savedpos = 0xffffffff; | 2087 | } |
2088 | } | 2088 | |
2089 | 2089 | void QTReaderApp::gotoStart() | |
2090 | void QTReaderApp::gotoStart() | 2090 | { |
2091 | { | 2091 | reader->locate(reader->buffdoc.startSection()); |
2092 | reader->locate(reader->buffdoc.startSection()); | 2092 | } |
2093 | } | 2093 | |
2094 | 2094 | void QTReaderApp::gotoEnd() | |
2095 | void QTReaderApp::gotoEnd() | 2095 | { |
2096 | { | 2096 | reader->dopageup(reader->buffdoc.endSection()); |
2097 | reader->dopageup(reader->buffdoc.endSection()); | 2097 | } |
2098 | } | 2098 | |
2099 | 2099 | void QTReaderApp::pageup() | |
2100 | void QTReaderApp::pageup() | 2100 | { |
2101 | { | 2101 | reader->NavUp(); |
2102 | reader->NavUp(); | 2102 | } |
2103 | } | 2103 | |
2104 | 2104 | void QTReaderApp::pagedn() | |
2105 | void QTReaderApp::pagedn() | 2105 | { |
2106 | { | 2106 | reader->NavDown(); |
2107 | reader->NavDown(); | 2107 | } |
2108 | } | 2108 | |
2109 | 2109 | void QTReaderApp::pagemode(bool _b) | |
2110 | void QTReaderApp::pagemode(bool _b) | 2110 | { |
2111 | { | 2111 | reader->setpagemode(_b); |
2112 | reader->setpagemode(_b); | 2112 | } |
2113 | } | 2113 | |
2114 | 2114 | /* | |
2115 | /* | 2115 | void QTReaderApp::setspacing() |
2116 | void QTReaderApp::setspacing() | 2116 | { |
2117 | { | 2117 | m_nRegAction = cMonoSpace; |
2118 | m_nRegAction = cMonoSpace; | 2118 | char lcn[20]; |
2119 | char lcn[20]; | 2119 | sprintf(lcn, "%lu", reader->m_charpc); |
2120 | sprintf(lcn, "%lu", reader->m_charpc); | 2120 | regEdit->setText(lcn); |
2121 | regEdit->setText(lcn); | 2121 | do_regedit(); |
2122 | do_regedit(); | 2122 | } |
2123 | } | 2123 | */ |
2124 | */ | 2124 | void QTReaderApp::settarget() |
2125 | void QTReaderApp::settarget() | 2125 | { |
2126 | { | 2126 | m_nRegAction = cSetTarget; |
2127 | m_nRegAction = cSetTarget; | 2127 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) |
2128 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) | 2128 | + "/" |
2129 | + "/" | 2129 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); |
2130 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); | 2130 | regEdit->setText(text); |
2131 | regEdit->setText(text); | 2131 | do_regedit(); |
2132 | do_regedit(); | 2132 | } |
2133 | } | 2133 | |
2134 | 2134 | /* | |
2135 | /* | 2135 | void QTReaderApp::do_mono(const QString& lcn) |
2136 | void QTReaderApp::do_mono(const QString& lcn) | 2136 | { |
2137 | { | 2137 | bool ok; |
2138 | bool ok; | 2138 | unsigned long ulcn = lcn.toULong(&ok); |
2139 | unsigned long ulcn = lcn.toULong(&ok); | 2139 | if (ok) |
2140 | if (ok) | 2140 | { |
2141 | { | 2141 | reader->m_charpc = ulcn; |
2142 | reader->m_charpc = ulcn; | 2142 | reader->setfont(); |
2143 | reader->setfont(); | 2143 | reader->refresh(); |
2144 | reader->refresh(); | 2144 | //reader->setmono(true); |
2145 | //reader->setmono(true); | 2145 | } |
2146 | } | 2146 | else |
2147 | else | 2147 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
2148 | QMessageBox::information(this, PROGNAME, "Must be a number"); | 2148 | } |
2149 | } | 2149 | */ |
2150 | */ | 2150 | /* |
2151 | /* | 2151 | void QTReaderApp::editPaste() |
2152 | void QTReaderApp::editPaste() | 2152 | { |
2153 | { | 2153 | #ifndef QT_NO_CLIPBOARD |
2154 | #ifndef QT_NO_CLIPBOARD | 2154 | editor->paste(); |
2155 | editor->paste(); | 2155 | #endif |
2156 | #endif | 2156 | } |
2157 | } | 2157 | */ |
2158 | */ | 2158 | |
2159 | 2159 | void QTReaderApp::editFind() | |
2160 | void QTReaderApp::editFind() | 2160 | { |
2161 | { | 2161 | searchStart = reader->pagelocate(); |
2162 | searchStart = reader->pagelocate(); | 2162 | #ifdef __ISEARCH |
2163 | #ifdef __ISEARCH | 2163 | searchStack = new QStack<searchrecord>; |
2164 | searchStack = new QStack<searchrecord>; | 2164 | #endif |
2165 | #endif | 2165 | #ifdef USEQPE |
2166 | #ifdef USEQPE | 2166 | Global::showInputMethod(); |
2167 | Global::showInputMethod(); | 2167 | #endif |
2168 | #endif | 2168 | searchBar->show(); |
2169 | searchBar->show(); | 2169 | searchVisible = TRUE; |
2170 | searchVisible = TRUE; | 2170 | searchEdit->setFocus(); |
2171 | searchEdit->setFocus(); | 2171 | #ifdef __ISEARCH |
2172 | #ifdef __ISEARCH | 2172 | searchStack->push(new searchrecord("",reader->pagelocate())); |
2173 | searchStack->push(new searchrecord("",reader->pagelocate())); | 2173 | #endif |
2174 | #endif | 2174 | } |
2175 | } | 2175 | |
2176 | 2176 | void QTReaderApp::findNext() | |
2177 | void QTReaderApp::findNext() | 2177 | { |
2178 | { | 2178 | // // qDebug("findNext called\n"); |
2179 | // // qDebug("findNext called\n"); | 2179 | #ifdef __ISEARCH |
2180 | #ifdef __ISEARCH | 2180 | QString arg = searchEdit->text(); |
2181 | QString arg = searchEdit->text(); | 2181 | #else |
2182 | #else | 2182 | QRegExp arg = searchEdit->text(); |
2183 | QRegExp arg = searchEdit->text(); | 2183 | #endif |
2184 | #endif | 2184 | CDrawBuffer test(&(reader->m_fontControl)); |
2185 | CDrawBuffer test(&(reader->m_fontControl)); | 2185 | size_t start = reader->pagelocate(); |
2186 | size_t start = reader->pagelocate(); | 2186 | reader->jumpto(start); |
2187 | reader->jumpto(start); | 2187 | reader->getline(&test); |
2188 | reader->getline(&test); | 2188 | dosearch(start, test, arg); |
2189 | dosearch(start, test, arg); | 2189 | } |
2190 | } | 2190 | |
2191 | 2191 | void QTReaderApp::findClose() | |
2192 | void QTReaderApp::findClose() | 2192 | { |
2193 | { | 2193 | searchVisible = FALSE; |
2194 | searchVisible = FALSE; | 2194 | searchEdit->setText(""); |
2195 | searchEdit->setText(""); | 2195 | #ifdef USEQPE |
2196 | #ifdef USEQPE | 2196 | Global::hideInputMethod(); |
2197 | Global::hideInputMethod(); | 2197 | #endif |
2198 | #endif | 2198 | searchBar->hide(); |
2199 | searchBar->hide(); | 2199 | #ifdef __ISEARCH |
2200 | #ifdef __ISEARCH | 2200 | // searchStack = new QStack<searchrecord>; |
2201 | // searchStack = new QStack<searchrecord>; | 2201 | while (!searchStack->isEmpty()) |
2202 | while (!searchStack->isEmpty()) | 2202 | { |
2203 | { | 2203 | delete searchStack->pop(); |
2204 | delete searchStack->pop(); | 2204 | } |
2205 | } | 2205 | delete searchStack; |
2206 | delete searchStack; | 2206 | #endif |
2207 | #endif | 2207 | reader->setFocus(); |
2208 | reader->setFocus(); | 2208 | } |
2209 | } | 2209 | |
2210 | 2210 | void QTReaderApp::regClose() | |
2211 | void QTReaderApp::regClose() | 2211 | { |
2212 | { | 2212 | regVisible = FALSE; |
2213 | regVisible = FALSE; | 2213 | regEdit->setText(""); |
2214 | regEdit->setText(""); | 2214 | regBar->hide(); |
2215 | regBar->hide(); | 2215 | #ifdef USEQPE |
2216 | #ifdef USEQPE | 2216 | Global::hideInputMethod(); |
2217 | Global::hideInputMethod(); | 2217 | #endif |
2218 | #endif | 2218 | reader->setFocus(); |
2219 | reader->setFocus(); | 2219 | } |
2220 | } | 2220 | |
2221 | 2221 | #ifdef __ISEARCH | |
2222 | #ifdef __ISEARCH | 2222 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) |
2223 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) | 2223 | #else |
2224 | #else | 2224 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) |
2225 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | 2225 | #endif |
2226 | #endif | 2226 | { |
2227 | { | 2227 | bool ret = true; |
2228 | bool ret = true; | 2228 | unsigned long fs, ts; |
2229 | unsigned long fs, ts; | 2229 | reader->sizes(fs,ts); |
2230 | reader->sizes(fs,ts); | 2230 | size_t pos = reader->locate(); |
2231 | size_t pos = reader->locate(); | 2231 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); |
2232 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); | 2232 | pbar->show(); |
2233 | pbar->show(); | 2233 | pbar->raise(); |
2234 | pbar->raise(); | 2234 | pbar->reset(); |
2235 | pbar->reset(); | 2235 | int offset; |
2236 | int offset; | 2236 | int lastpc = (100*pos)/ts; |
2237 | int lastpc = (100*pos)/ts; | 2237 | pbar->setProgress(lastpc); |
2238 | pbar->setProgress(lastpc); | 2238 | // qApp->processEvents(); |
2239 | // qApp->processEvents(); | 2239 | if (reader->buffdoc.getpara(test) >= 0) |
2240 | if (reader->buffdoc.getpara(test) >= 0) | 2240 | { |
2241 | { | 2241 | reader->setFocus(); |
2242 | reader->setFocus(); | 2242 | #ifdef __ISEARCH |
2243 | #ifdef __ISEARCH | 2243 | while (strstr(test.data(),(const tchar*)arg) == NULL) |
2244 | while (strstr(test.data(),(const tchar*)arg) == NULL) | 2244 | #else |
2245 | #else | 2245 | #ifdef _UNICODE |
2246 | #ifdef _UNICODE | 2246 | while ((offset = arg.match(toQString(test.data()))) == -1) |
2247 | while ((offset = arg.match(toQString(test.data()))) == -1) | 2247 | #else |
2248 | #else | 2248 | while (arg.match(test.data()) == -1) |
2249 | while (arg.match(test.data()) == -1) | 2249 | #endif |
2250 | #endif | 2250 | #endif |
2251 | #endif | 2251 | { |
2252 | { | 2252 | pos = reader->locate(); |
2253 | pos = reader->locate(); | 2253 | int pc = (100*pos)/ts; |
2254 | int pc = (100*pos)/ts; | 2254 | if (pc != lastpc) |
2255 | if (pc != lastpc) | 2255 | { |
2256 | { | 2256 | pbar->setProgress(pc); |
2257 | pbar->setProgress(pc); | 2257 | qApp->processEvents(); |
2258 | qApp->processEvents(); | 2258 | reader->setFocus(); |
2259 | reader->setFocus(); | 2259 | lastpc = pc; |
2260 | lastpc = pc; | 2260 | } |
2261 | } | 2261 | |
2262 | 2262 | if (reader->buffdoc.getpara(test) < 0) | |
2263 | if (reader->buffdoc.getpara(test) < 0) | 2263 | { |
2264 | { | 2264 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2265 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2265 | pos = searchStart; |
2266 | pos = searchStart; | 2266 | else |
2267 | else | 2267 | pos = start; |
2268 | pos = start; | 2268 | findClose(); |
2269 | findClose(); | 2269 | pbar->hide(); |
2270 | pbar->hide(); | 2270 | reader->locate(pos); |
2271 | reader->locate(pos); | 2271 | return false; |
2272 | return false; | 2272 | } |
2273 | } | 2273 | } |
2274 | } | 2274 | // qDebug("Found it at %u:%u", pos, offset); |
2275 | // qDebug("Found it at %u:%u", pos, offset); | 2275 | pbar->hide(); |
2276 | pbar->hide(); | 2276 | // qDebug("Hid"); |
2277 | // qDebug("Hid"); | 2277 | reader->locate(pos+offset); |
2278 | reader->locate(pos+offset); | 2278 | // qDebug("Loacted"); |
2279 | // qDebug("Loacted"); | 2279 | // qDebug("page up"); |
2280 | // qDebug("page up"); | 2280 | ret = true; |
2281 | ret = true; | 2281 | } |
2282 | } | 2282 | else |
2283 | else | 2283 | { |
2284 | { | 2284 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2285 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2285 | pos = searchStart; |
2286 | pos = searchStart; | 2286 | else |
2287 | else | 2287 | pos = start; |
2288 | pos = start; | 2288 | ret = false; |
2289 | ret = false; | 2289 | findClose(); |
2290 | findClose(); | 2290 | } |
2291 | } | 2291 | return ret; |
2292 | return ret; | 2292 | } |
2293 | } | 2293 | |
2294 | 2294 | #ifdef __ISEARCH | |
2295 | #ifdef __ISEARCH | 2295 | void QTReaderApp::search(const QString & arg) |
2296 | void QTReaderApp::search(const QString & arg) | 2296 | { |
2297 | { | 2297 | searchrecord* ss = searchStack->top(); |
2298 | searchrecord* ss = searchStack->top(); | 2298 | CBuffer test; |
2299 | CBuffer test; | 2299 | size_t start = reader->pagelocate(); |
2300 | size_t start = reader->pagelocate(); | 2300 | bool haspopped = false; |
2301 | bool haspopped = false; | 2301 | while (arg.left(ss->s.length()) != ss->s) |
2302 | while (arg.left(ss->s.length()) != ss->s) | 2302 | { |
2303 | { | 2303 | haspopped = true; |
2304 | haspopped = true; | 2304 | start = ss->pos; |
2305 | start = ss->pos; | 2305 | // reader->locate(start); |
2306 | // reader->locate(start); | 2306 | searchStack->pop(); |
2307 | searchStack->pop(); | 2307 | delete ss; |
2308 | delete ss; | 2308 | } |
2309 | } | 2309 | if (haspopped) reader->locate(start); |
2310 | if (haspopped) reader->locate(start); | 2310 | /* |
2311 | /* | 2311 | if (arg.length() < ss->len) |
2312 | if (arg.length() < ss->len) | 2312 | { |
2313 | { | 2313 | start = ss->pos; |
2314 | start = ss->pos; | 2314 | reader->locate(start); |
2315 | reader->locate(start); | 2315 | searchStack->pop(); |
2316 | searchStack->pop(); | 2316 | delete ss; |
2317 | delete ss; | 2317 | } |
2318 | } | 2318 | */ |
2319 | */ | 2319 | else |
2320 | else | 2320 | { |
2321 | { | 2321 | start = reader->pagelocate(); |
2322 | start = reader->pagelocate(); | 2322 | reader->jumpto(start); |
2323 | reader->jumpto(start); | 2323 | searchStack->push(new searchrecord(arg,start)); |
2324 | searchStack->push(new searchrecord(arg,start)); | 2324 | } |
2325 | } | 2325 | dosearch(start, test, arg); |
2326 | dosearch(start, test, arg); | 2326 | } |
2327 | } | 2327 | #else |
2328 | #else | 2328 | void QTReaderApp::search() |
2329 | void QTReaderApp::search() | 2329 | { |
2330 | { | 2330 | findNext(); |
2331 | findNext(); | 2331 | } |
2332 | } | 2332 | #endif |
2333 | #endif | 2333 | |
2334 | 2334 | void QTReaderApp::openFile( const QString &f ) | |
2335 | void QTReaderApp::openFile( const QString &f ) | 2335 | { |
2336 | { | 2336 | // qDebug("File:%s", (const char*)f); |
2337 | // qDebug("File:%s", (const char*)f); | 2337 | // openFile(DocLnk(f)); |
2338 | // openFile(DocLnk(f)); | 2338 | //} |
2339 | //} | 2339 | // |
2340 | // | 2340 | //void QTReaderApp::openFile( const DocLnk &f ) |
2341 | //void QTReaderApp::openFile( const DocLnk &f ) | 2341 | //{ |
2342 | //{ | 2342 | clear(); |
2343 | clear(); | 2343 | QFileInfo fm(f); |
2344 | QFileInfo fm(f); | 2344 | if ( fm.exists() ) |
2345 | if ( fm.exists() ) | 2345 | { |
2346 | { | 2346 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); |
2347 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); | 2347 | #ifdef USEQPE |
2348 | #ifdef USEQPE | 2348 | if (fm.extension( FALSE ) == "desktop") |
2349 | if (fm.extension( FALSE ) == "desktop") | 2349 | { |
2350 | { | 2350 | DocLnk d(f); |
2351 | DocLnk d(f); | 2351 | QFileInfo fnew(d.file()); |
2352 | QFileInfo fnew(d.file()); | 2352 | fm = fnew; |
2353 | fm = fnew; | 2353 | if (!fm.exists()) return; |
2354 | if (!fm.exists()) return; | 2354 | } |
2355 | } | 2355 | #endif |
2356 | #endif | 2356 | clear(); |
2357 | clear(); | 2357 | |
2358 | 2358 | reader->setText(fm.baseName(), fm.absFilePath()); | |
2359 | reader->setText(fm.baseName(), fm.absFilePath()); | 2359 | m_loadedconfig = readconfig(reader->m_string, false); |
2360 | m_loadedconfig = readconfig(reader->m_string, false); | 2360 | showEditTools(); |
2361 | showEditTools(); | 2361 | readbkmks(); |
2362 | readbkmks(); | 2362 | m_savedpos = 0xffffffff; |
2363 | m_savedpos = 0xffffffff; | 2363 | } |
2364 | } | 2364 | else |
2365 | else | 2365 | { |
2366 | { | 2366 | QMessageBox::information(this, PROGNAME, "File does not exist"); |
2367 | QMessageBox::information(this, PROGNAME, "File does not exist"); | 2367 | reader->m_lastfile = QString::null; |
2368 | reader->m_lastfile = QString::null; | 2368 | } |
2369 | } | 2369 | |
2370 | 2370 | } | |
2371 | } | 2371 | /* |
2372 | /* | 2372 | void QTReaderApp::resizeEvent(QResizeEvent* e) |
2373 | void QTReaderApp::resizeEvent(QResizeEvent* e) | 2373 | { |
2374 | { | 2374 | if (m_fullscreen) |
2375 | if (m_fullscreen) | 2375 | { |
2376 | { | 2376 | showNormal(); |
2377 | showNormal(); | 2377 | showFullScreen(); |
2378 | showFullScreen(); | 2378 | } |
2379 | } | 2379 | } |
2380 | } | 2380 | */ |
2381 | */ | 2381 | void QTReaderApp::handlekey(QKeyEvent* e) |
2382 | void QTReaderApp::handlekey(QKeyEvent* e) | 2382 | { |
2383 | { | 2383 | // qDebug("Keypress event"); |
2384 | // qDebug("Keypress event"); | 2384 | timeb now; |
2385 | timeb now; | 2385 | ftime(&now); |
2386 | ftime(&now); | 2386 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; |
2387 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; | 2387 | if (etime < m_debounce) |
2388 | if (etime < m_debounce) | 2388 | { |
2389 | { | 2389 | return; |
2390 | return; | 2390 | } |
2391 | } | 2391 | m_lastkeytime = now; |
2392 | m_lastkeytime = now; | 2392 | switch(e->key()) |
2393 | switch(e->key()) | 2393 | { |
2394 | { | 2394 | case Key_Escape: |
2395 | case Key_Escape: | 2395 | // qDebug("escape event"); |
2396 | // qDebug("escape event"); | 2396 | if (m_disableesckey) |
2397 | if (m_disableesckey) | 2397 | { |
2398 | { | 2398 | m_disableesckey = false; |
2399 | m_disableesckey = false; | 2399 | } |
2400 | } | 2400 | else |
2401 | else | 2401 | { |
2402 | { | 2402 | m_bcloseDisabled = true; |
2403 | m_bcloseDisabled = true; | 2403 | if (m_fullscreen) |
2404 | if (m_fullscreen) | 2404 | { |
2405 | { | 2405 | m_actFullscreen->setOn(false); |
2406 | m_actFullscreen->setOn(false); | 2406 | e->accept(); |
2407 | e->accept(); | 2407 | } |
2408 | } | 2408 | else |
2409 | else | 2409 | { |
2410 | { | 2410 | // qDebug("escape action"); |
2411 | // qDebug("escape action"); | 2411 | doAction(m_escapeTarget, e); |
2412 | doAction(m_escapeTarget, e); | 2412 | } |
2413 | } | 2413 | } |
2414 | } | 2414 | break; |
2415 | break; | 2415 | case Key_Space: |
2416 | case Key_Space: | 2416 | { |
2417 | { | 2417 | doAction(m_spaceTarget, e); |
2418 | doAction(m_spaceTarget, e); | 2418 | } |
2419 | } | 2419 | break; |
2420 | break; | 2420 | case Key_Return: |
2421 | case Key_Return: | 2421 | { |
2422 | { | 2422 | doAction(m_returnTarget, e); |
2423 | doAction(m_returnTarget, e); | 2423 | } |
2424 | } | 2424 | break; |
2425 | break; | 2425 | case Key_Left: |
2426 | case Key_Left: | 2426 | { |
2427 | { | 2427 | if (reader->m_autoScroll && m_leftScroll) |
2428 | if (reader->m_autoScroll && m_leftScroll) | 2428 | { |
2429 | { | 2429 | reader->reduceScroll(); |
2430 | reader->reduceScroll(); | 2430 | } |
2431 | } | 2431 | else |
2432 | else | 2432 | { |
2433 | { | 2433 | doAction(m_leftTarget, e); |
2434 | doAction(m_leftTarget, e); | 2434 | } |
2435 | } | 2435 | } |
2436 | } | 2436 | break; |
2437 | break; | 2437 | case Key_Right: |
2438 | case Key_Right: | 2438 | { |
2439 | { | 2439 | if (reader->m_autoScroll && m_rightScroll) |
2440 | if (reader->m_autoScroll && m_rightScroll) | 2440 | { |
2441 | { | 2441 | reader->increaseScroll(); |
2442 | reader->increaseScroll(); | 2442 | } |
2443 | } | 2443 | else |
2444 | else | 2444 | { |
2445 | { | 2445 | doAction(m_rightTarget, e); |
2446 | doAction(m_rightTarget, e); | 2446 | } |
2447 | } | 2447 | } |
2448 | } | 2448 | break; |
2449 | break; | 2449 | case Key_Up: |
2450 | case Key_Up: | 2450 | { |
2451 | { | 2451 | if (reader->m_autoScroll && m_upScroll) |
2452 | if (reader->m_autoScroll && m_upScroll) | 2452 | { |
2453 | { | 2453 | reader->increaseScroll(); |
2454 | reader->increaseScroll(); | 2454 | } |
2455 | } | 2455 | else |
2456 | else | 2456 | { |
2457 | { | 2457 | doAction(m_upTarget, e); |
2458 | doAction(m_upTarget, e); | 2458 | } |
2459 | } | 2459 | } |
2460 | } | 2460 | break; |
2461 | break; | 2461 | case Key_Down: |
2462 | case Key_Down: | 2462 | { |
2463 | { | 2463 | if (reader->m_autoScroll && m_downScroll) |
2464 | if (reader->m_autoScroll && m_downScroll) | 2464 | { |
2465 | { | 2465 | reader->reduceScroll(); |
2466 | reader->reduceScroll(); | 2466 | } |
2467 | } | 2467 | else |
2468 | else | 2468 | { |
2469 | { | 2469 | doAction(m_downTarget, e); |
2470 | doAction(m_downTarget, e); | 2470 | } |
2471 | } | 2471 | } |
2472 | } | 2472 | break; |
2473 | break; | 2473 | default: |
2474 | default: | 2474 | { |
2475 | { | 2475 | e->ignore(); |
2476 | e->ignore(); | 2476 | } |
2477 | } | 2477 | |
2478 | 2478 | /* | |
2479 | /* | 2479 | QString msg("Key press was:"); |
2480 | QString msg("Key press was:"); | 2480 | QString key; |
2481 | QString key; | 2481 | msg += key.setNum(e->key()); |
2482 | msg += key.setNum(e->key()); | 2482 | QMessageBox::information(this, PROGNAME, msg); |
2483 | QMessageBox::information(this, PROGNAME, msg); | 2483 | */ |
2484 | */ | 2484 | } |
2485 | } | 2485 | } |
2486 | } | 2486 | |
2487 | 2487 | void QTReaderApp::showEditTools() | |
2488 | void QTReaderApp::showEditTools() | 2488 | { |
2489 | { | 2489 | // if ( !doc ) |
2490 | // if ( !doc ) | 2490 | //close(); |
2491 | //close(); | 2491 | if (m_fullscreen) |
2492 | if (m_fullscreen) | 2492 | { |
2493 | { | 2493 | if (menubar != NULL) menubar->hide(); |
2494 | if (menubar != NULL) menubar->hide(); | 2494 | if (fileBar != NULL) fileBar->hide(); |
2495 | if (fileBar != NULL) fileBar->hide(); | 2495 | if (viewBar != NULL) viewBar->hide(); |
2496 | if (viewBar != NULL) viewBar->hide(); | 2496 | if (navBar != NULL) navBar->hide(); |
2497 | if (navBar != NULL) navBar->hide(); | 2497 | if (markBar != NULL) markBar->hide(); |
2498 | if (markBar != NULL) markBar->hide(); | 2498 | searchBar->hide(); |
2499 | searchBar->hide(); | 2499 | regBar->hide(); |
2500 | regBar->hide(); | 2500 | #ifdef USEQPE |
2501 | #ifdef USEQPE | 2501 | Global::hideInputMethod(); |
2502 | Global::hideInputMethod(); | 2502 | #endif |
2503 | #endif | 2503 | m_fontBar->hide(); |
2504 | m_fontBar->hide(); | 2504 | //showNormal(); |
2505 | //showNormal(); | 2505 | showFullScreen(); |
2506 | showFullScreen(); | 2506 | } |
2507 | } | 2507 | else |
2508 | else | 2508 | { |
2509 | { | 2509 | //qDebug("him"); |
2510 | //qDebug("him"); | 2510 | #ifdef USEQPE |
2511 | #ifdef USEQPE | 2511 | Global::hideInputMethod(); |
2512 | Global::hideInputMethod(); | 2512 | #endif |
2513 | #endif | 2513 | //qDebug("eb"); |
2514 | //qDebug("eb"); | 2514 | menubar->show(); |
2515 | menubar->show(); | 2515 | if (fileBar != NULL) fileBar->show(); |
2516 | if (fileBar != NULL) fileBar->show(); | 2516 | if (viewBar != NULL) viewBar->show(); |
2517 | if (viewBar != NULL) viewBar->show(); | 2517 | if (navBar != NULL) navBar->show(); |
2518 | if (navBar != NULL) navBar->show(); | 2518 | if (markBar != NULL) markBar->show(); |
2519 | if (markBar != NULL) markBar->show(); | 2519 | mb->show(); |
2520 | mb->show(); | 2520 | if ( searchVisible ) |
2521 | if ( searchVisible ) | 2521 | { |
2522 | { | 2522 | #ifdef USEQPE |
2523 | #ifdef USEQPE | 2523 | Global::showInputMethod(); |
2524 | Global::showInputMethod(); | 2524 | #endif |
2525 | #endif | 2525 | searchBar->show(); |
2526 | searchBar->show(); | 2526 | } |
2527 | } | 2527 | if ( regVisible ) |
2528 | if ( regVisible ) | 2528 | { |
2529 | { | 2529 | #ifdef USEQPE |
2530 | #ifdef USEQPE | 2530 | Global::showInputMethod(); |
2531 | Global::showInputMethod(); | 2531 | #endif |
2532 | #endif | 2532 | regBar->show(); |
2533 | regBar->show(); | 2533 | } |
2534 | } | 2534 | if (m_fontVisible) m_fontBar->show(); |
2535 | if (m_fontVisible) m_fontBar->show(); | 2535 | //qDebug("sn"); |
2536 | //qDebug("sn"); | 2536 | showNormal(); |
2537 | showNormal(); | 2537 | //qDebug("sm"); |
2538 | //qDebug("sm"); | 2538 | #ifdef USEQPE |
2539 | #ifdef USEQPE | 2539 | showMaximized(); |
2540 | showMaximized(); | 2540 | #endif |
2541 | #endif | 2541 | //setCentralWidget(reader); |
2542 | //setCentralWidget(reader); | 2542 | } |
2543 | } | 2543 | |
2544 | 2544 | // qDebug("uc"); | |
2545 | // qDebug("uc"); | 2545 | updateCaption(); |
2546 | updateCaption(); | 2546 | // qDebug("rw"); |
2547 | // qDebug("rw"); | 2547 | editorStack->raiseWidget( reader ); |
2548 | editorStack->raiseWidget( reader ); | 2548 | // qDebug("sf"); |
2549 | // qDebug("sf"); | 2549 | reader->setFocus(); |
2550 | reader->setFocus(); | 2550 | reader->refresh(); |
2551 | reader->refresh(); | 2551 | } |
2552 | } | 2552 | /* |
2553 | /* | 2553 | void QTReaderApp::save() |
2554 | void QTReaderApp::save() | 2554 | { |
2555 | { | 2555 | if ( !doc ) |
2556 | if ( !doc ) | 2556 | return; |
2557 | return; | 2557 | if ( !editor->edited() ) |
2558 | if ( !editor->edited() ) | 2558 | return; |
2559 | return; | 2559 | |
2560 | 2560 | QString rt = editor->text(); | |
2561 | QString rt = editor->text(); | 2561 | QString pt = rt; |
2562 | QString pt = rt; | 2562 | |
2563 | 2563 | if ( doc->name().isEmpty() ) { | |
2564 | if ( doc->name().isEmpty() ) { | 2564 | unsigned ispace = pt.find( ' ' ); |
2565 | unsigned ispace = pt.find( ' ' ); | 2565 | unsigned ienter = pt.find( '\n' ); |
2566 | unsigned ienter = pt.find( '\n' ); | 2566 | int i = (ispace < ienter) ? ispace : ienter; |
2567 | int i = (ispace < ienter) ? ispace : ienter; | 2567 | QString docname; |
2568 | QString docname; | 2568 | if ( i == -1 ) { |
2569 | if ( i == -1 ) { | 2569 | if ( pt.isEmpty() ) |
2570 | if ( pt.isEmpty() ) | 2570 | docname = "Empty Text"; |
2571 | docname = "Empty Text"; | 2571 | else |
2572 | else | 2572 | docname = pt; |
2573 | docname = pt; | 2573 | } else { |
2574 | } else { | 2574 | docname = pt.left( i ); |
2575 | docname = pt.left( i ); | 2575 | } |
2576 | } | 2576 | doc->setName(docname); |
2577 | doc->setName(docname); | 2577 | } |
2578 | } | 2578 | FileManager fm; |
2579 | FileManager fm; | 2579 | fm.saveFile( *doc, rt ); |
2580 | fm.saveFile( *doc, rt ); | 2580 | } |
2581 | } | 2581 | */ |
2582 | */ | 2582 | |
2583 | 2583 | void QTReaderApp::clear() | |
2584 | void QTReaderApp::clear() | 2584 | { |
2585 | { | 2585 | // if (doc != 0) |
2586 | // if (doc != 0) | 2586 | // { |
2587 | // { | 2587 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); |
2588 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); | 2588 | //delete doc; |
2589 | //delete doc; | 2589 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); |
2590 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); | 2590 | //doc = 0; |
2591 | //doc = 0; | 2591 | // } |
2592 | // } | 2592 | reader->clear(); |
2593 | reader->clear(); | 2593 | } |
2594 | } | 2594 | |
2595 | 2595 | void QTReaderApp::updateCaption() | |
2596 | void QTReaderApp::updateCaption() | 2596 | { |
2597 | { | 2597 | // if ( !doc ) |
2598 | // if ( !doc ) | 2598 | //setCaption( tr("QTReader") ); |
2599 | //setCaption( tr("QTReader") ); | 2599 | // else { |
2600 | // else { | 2600 | //QString s = doc->name(); |
2601 | //QString s = doc->name(); | 2601 | //if ( s.isEmpty() ) |
2602 | //if ( s.isEmpty() ) | 2602 | // s = tr( "Unnamed" ); |
2603 | // s = tr( "Unnamed" ); | 2603 | setCaption( reader->m_string + " - " + tr("Reader") ); |
2604 | setCaption( reader->m_string + " - " + tr("Reader") ); | 2604 | // } |
2605 | // } | 2605 | } |
2606 | } | 2606 | |
2607 | 2607 | void QTReaderApp::setDocument(const QString& fileref) | |
2608 | void QTReaderApp::setDocument(const QString& fileref) | 2608 | { |
2609 | { | 2609 | bFromDocView = TRUE; |
2610 | bFromDocView = TRUE; | 2610 | //QMessageBox::information(0, "setDocument", fileref); |
2611 | //QMessageBox::information(0, "setDocument", fileref); | 2611 | openFile(fileref); |
2612 | openFile(fileref); | 2612 | // showEditTools(); |
2613 | // showEditTools(); | 2613 | } |
2614 | } | 2614 | |
2615 | 2615 | void QTReaderApp::closeEvent( QCloseEvent *e ) | |
2616 | void QTReaderApp::closeEvent( QCloseEvent *e ) | 2616 | { |
2617 | { | 2617 | // qDebug("Close event"); |
2618 | // qDebug("Close event"); | 2618 | if (m_fullscreen) |
2619 | if (m_fullscreen) | 2619 | { |
2620 | { | 2620 | m_fullscreen = false; |
2621 | m_fullscreen = false; | 2621 | showEditTools(); |
2622 | showEditTools(); | 2622 | e->accept(); |
2623 | e->accept(); | 2623 | } |
2624 | } | 2624 | else if (m_dontSave) |
2625 | else if (m_dontSave) | 2625 | { |
2626 | { | 2626 | e->accept(); |
2627 | e->accept(); | 2627 | } |
2628 | } | 2628 | else |
2629 | else | 2629 | { |
2630 | { | 2630 | if (editorStack->visibleWidget() == reader) |
2631 | if (editorStack->visibleWidget() == reader) | 2631 | { |
2632 | { | 2632 | if ((m_escapeTarget != cesNone) && m_bcloseDisabled) |
2633 | if ((m_escapeTarget != cesNone) && m_bcloseDisabled) | 2633 | { |
2634 | { | 2634 | //qDebug("Close disabled"); |
2635 | //qDebug("Close disabled"); | 2635 | m_bcloseDisabled = false; |
2636 | m_bcloseDisabled = false; | 2636 | e->ignore(); |
2637 | e->ignore(); | 2637 | } |
2638 | } | 2638 | else |
2639 | else | 2639 | { |
2640 | { | 2640 | if (m_fontVisible) |
2641 | if (m_fontVisible) | 2641 | { |
2642 | { | 2642 | m_fontBar->hide(); |
2643 | m_fontBar->hide(); | 2643 | m_fontVisible = false; |
2644 | m_fontVisible = false; | 2644 | } |
2645 | } | 2645 | if (regVisible) |
2646 | if (regVisible) | 2646 | { |
2647 | { | 2647 | regBar->hide(); |
2648 | regBar->hide(); | 2648 | #ifdef USEQPE |
2649 | #ifdef USEQPE | 2649 | Global::hideInputMethod(); |
2650 | Global::hideInputMethod(); | 2650 | #endif |
2651 | #endif | 2651 | regVisible = false; |
2652 | regVisible = false; | 2652 | return; |
2653 | return; | 2653 | } |
2654 | } | 2654 | if (searchVisible) |
2655 | if (searchVisible) | 2655 | { |
2656 | { | 2656 | searchBar->hide(); |
2657 | searchBar->hide(); | 2657 | #ifdef USEQPE |
2658 | #ifdef USEQPE | 2658 | Global::hideInputMethod(); |
2659 | Global::hideInputMethod(); | 2659 | #endif |
2660 | #endif | 2660 | searchVisible = false; |
2661 | searchVisible = false; | 2661 | return; |
2662 | return; | 2662 | } |
2663 | } | 2663 | if (m_fBkmksChanged && pBkmklist != NULL) |
2664 | if (m_fBkmksChanged && pBkmklist != NULL) | 2664 | { |
2665 | { | 2665 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
2666 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | 2666 | savebkmks(); |
2667 | savebkmks(); | 2667 | delete pBkmklist; |
2668 | delete pBkmklist; | 2668 | pBkmklist = NULL; |
2669 | pBkmklist = NULL; | 2669 | m_fBkmksChanged = false; |
2670 | m_fBkmksChanged = false; | 2670 | } |
2671 | } | 2671 | bFromDocView = FALSE; |
2672 | bFromDocView = FALSE; | 2672 | updatefileinfo(); |
2673 | updatefileinfo(); | 2673 | saveprefs(); |
2674 | saveprefs(); | 2674 | e->accept(); |
2675 | e->accept(); | 2675 | } |
2676 | } | 2676 | } |
2677 | } | 2677 | else |
2678 | else | 2678 | { |
2679 | { | 2679 | showEditTools(); |
2680 | showEditTools(); | 2680 | m_disableesckey = true; |
2681 | m_disableesckey = true; | 2681 | } |
2682 | } | 2682 | } |
2683 | } | 2683 | } |
2684 | } | 2684 | |
2685 | 2685 | void QTReaderApp::do_gotomark() | |
2686 | void QTReaderApp::do_gotomark() | 2686 | { |
2687 | { | 2687 | m_nBkmkAction = cGotoBkmk; |
2688 | m_nBkmkAction = cGotoBkmk; | 2688 | if (!listbkmk(pBkmklist)) |
2689 | if (!listbkmk(pBkmklist)) | 2689 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
2690 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 2690 | } |
2691 | } | 2691 | |
2692 | 2692 | void QTReaderApp::do_delmark() | |
2693 | void QTReaderApp::do_delmark() | 2693 | { |
2694 | { | 2694 | m_nBkmkAction = cDelBkmk; |
2695 | m_nBkmkAction = cDelBkmk; | 2695 | if (!listbkmk(pBkmklist)) |
2696 | if (!listbkmk(pBkmklist)) | 2696 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
2697 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 2697 | } |
2698 | } | 2698 | |
2699 | 2699 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) | |
2700 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) | 2700 | { |
2701 | { | 2701 | bkmkselector->clear(); |
2702 | bkmkselector->clear(); | 2702 | if (_lab.isEmpty()) |
2703 | if (_lab.isEmpty()) | 2703 | bkmkselector->setText("Cancel"); |
2704 | bkmkselector->setText("Cancel"); | 2704 | else |
2705 | else | 2705 | bkmkselector->setText(_lab); |
2706 | bkmkselector->setText(_lab); | 2706 | int cnt = 0; |
2707 | int cnt = 0; | 2707 | if (plist != NULL) |
2708 | if (plist != NULL) | 2708 | { |
2709 | { | 2709 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) |
2710 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) | 2710 | { |
2711 | { | 2711 | #ifdef _UNICODE |
2712 | #ifdef _UNICODE | 2712 | // qDebug("Item:%s", (const char*)toQString(i->name())); |
2713 | // qDebug("Item:%s", (const char*)toQString(i->name())); | 2713 | bkmkselector->insertItem(toQString(i->name())); |
2714 | bkmkselector->insertItem(toQString(i->name())); | 2714 | #else |
2715 | #else | 2715 | bkmkselector->insertItem(i->name()); |
2716 | bkmkselector->insertItem(i->name()); | 2716 | #endif |
2717 | #endif | 2717 | cnt++; |
2718 | cnt++; | 2718 | } |
2719 | } | 2719 | } |
2720 | } | 2720 | if (cnt > 0) |
2721 | if (cnt > 0) | 2721 | { |
2722 | { | 2722 | hidetoolbars(); |
2723 | hidetoolbars(); | 2723 | editorStack->raiseWidget( bkmkselector ); |
2724 | editorStack->raiseWidget( bkmkselector ); | 2724 | return true; |
2725 | return true; | 2725 | } |
2726 | } | 2726 | else |
2727 | else | 2727 | return false; |
2728 | return false; | 2728 | } |
2729 | } | 2729 | |
2730 | 2730 | void QTReaderApp::do_autogen() | |
2731 | void QTReaderApp::do_autogen() | 2731 | { |
2732 | { | 2732 | m_nRegAction = cAutoGen; |
2733 | m_nRegAction = cAutoGen; | 2733 | regEdit->setText(m_autogenstr); |
2734 | regEdit->setText(m_autogenstr); | 2734 | do_regedit(); |
2735 | do_regedit(); | 2735 | } |
2736 | } | 2736 | |
2737 | 2737 | void QTReaderApp::do_regedit() | |
2738 | void QTReaderApp::do_regedit() | 2738 | { |
2739 | { | 2739 | // fileBar->hide(); |
2740 | // fileBar->hide(); | 2740 | reader->bDoUpdates = false; |
2741 | reader->bDoUpdates = false; | 2741 | // qDebug("Showing regbar"); |
2742 | // qDebug("Showing regbar"); | 2742 | regBar->show(); |
2743 | regBar->show(); | 2743 | // qDebug("Showing kbd"); |
2744 | // qDebug("Showing kbd"); | 2744 | #ifdef USEQPE |
2745 | #ifdef USEQPE | 2745 | Global::showInputMethod(); |
2746 | Global::showInputMethod(); | 2746 | #endif |
2747 | #endif | 2747 | regVisible = true; |
2748 | regVisible = true; | 2748 | regEdit->setFocus(); |
2749 | regEdit->setFocus(); | 2749 | // qApp->processEvents(); |
2750 | // qApp->processEvents(); | 2750 | reader->bDoUpdates = true; |
2751 | reader->bDoUpdates = true; | 2751 | reader->update(); |
2752 | reader->update(); | 2752 | } |
2753 | } | 2753 | |
2754 | 2754 | bool QTReaderApp::openfrombkmk(Bkmk* bk) | |
2755 | bool QTReaderApp::openfrombkmk(Bkmk* bk) | 2755 | { |
2756 | { | 2756 | QString fn = toQString( |
2757 | QString fn = toQString( | 2757 | CFiledata(bk->anno()).name() |
2758 | CFiledata(bk->anno()).name() | 2758 | ); |
2759 | ); | 2759 | //qDebug("fileinfo"); |
2760 | //qDebug("fileinfo"); | 2760 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
2761 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 2761 | { |
2762 | { | 2762 | //qDebug("Opening"); |
2763 | //qDebug("Opening"); | 2763 | openFile(fn); |
2764 | openFile(fn); | 2764 | struct stat fnstat; |
2765 | struct stat fnstat; | 2765 | stat((const char *)reader->m_lastfile, &fnstat); |
2766 | stat((const char *)reader->m_lastfile, &fnstat); | 2766 | |
2767 | 2767 | if (CFiledata(bk->anno()).date() | |
2768 | if (CFiledata(bk->anno()).date() | 2768 | != fnstat.st_mtime) |
2769 | != fnstat.st_mtime) | 2769 | { |
2770 | { | 2770 | CFiledata fd(bk->anno()); |
2771 | CFiledata fd(bk->anno()); | 2771 | fd.setdate(fnstat.st_mtime); |
2772 | fd.setdate(fnstat.st_mtime); | 2772 | bk->value(0); |
2773 | bk->value(0); | 2773 | } |
2774 | } | 2774 | else |
2775 | else | 2775 | { |
2776 | { | 2776 | unsigned short svlen = bk->filedatalen(); |
2777 | unsigned short svlen = bk->filedatalen(); | 2777 | unsigned char* svdata = bk->filedata(); |
2778 | unsigned char* svdata = bk->filedata(); | 2778 | reader->putSaveData(svdata, svlen); |
2779 | reader->putSaveData(svdata, svlen); | 2779 | // setstate(svdata, svlen); |
2780 | // setstate(svdata, svlen); | 2780 | if (svlen != 0) |
2781 | if (svlen != 0) | 2781 | { |
2782 | { | 2782 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); |
2783 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); | 2783 | } |
2784 | } | 2784 | // qDebug("updating"); |
2785 | // qDebug("updating"); | 2785 | // showEditTools(); |
2786 | // showEditTools(); | 2786 | reader->locate(bk->value()); |
2787 | reader->locate(bk->value()); | 2787 | } |
2788 | } | 2788 | return true; |
2789 | return true; | 2789 | } |
2790 | } | 2790 | else |
2791 | else | 2791 | { |
2792 | { | 2792 | return false; |
2793 | return false; | 2793 | } |
2794 | } | 2794 | } |
2795 | } | 2795 | |
2796 | 2796 | void QTReaderApp::gotobkmk(int ind) | |
2797 | void QTReaderApp::gotobkmk(int ind) | 2797 | { |
2798 | { | 2798 | showEditTools(); |
2799 | showEditTools(); | 2799 | switch (m_nBkmkAction) |
2800 | switch (m_nBkmkAction) | 2800 | { |
2801 | { | 2801 | case cOpenFile: |
2802 | case cOpenFile: | 2802 | { |
2803 | { | 2803 | // qApp->processEvents(); |
2804 | // qApp->processEvents(); | 2804 | if (!openfrombkmk((*pOpenlist)[ind])) |
2805 | if (!openfrombkmk((*pOpenlist)[ind])) | 2805 | { |
2806 | { | 2806 | pOpenlist->erase(ind); |
2807 | pOpenlist->erase(ind); | 2807 | QMessageBox::information(this, PROGNAME, "Can't find file"); |
2808 | QMessageBox::information(this, PROGNAME, "Can't find file"); | 2808 | } |
2809 | } | 2809 | } |
2810 | } | 2810 | break; |
2811 | break; | 2811 | case cGotoBkmk: |
2812 | case cGotoBkmk: | 2812 | reader->locate((*pBkmklist)[ind]->value()); |
2813 | reader->locate((*pBkmklist)[ind]->value()); | 2813 | break; |
2814 | break; | 2814 | case cDelBkmk: |
2815 | case cDelBkmk: | 2815 | //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); |
2816 | //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); | 2816 | pBkmklist->erase(ind); |
2817 | pBkmklist->erase(ind); | 2817 | m_fBkmksChanged = true; |
2818 | m_fBkmksChanged = true; | 2818 | // pBkmklist->sort(); |
2819 | // pBkmklist->sort(); | 2819 | break; |
2820 | break; | 2820 | case cRmBkmkFile: |
2821 | case cRmBkmkFile: | 2821 | { |
2822 | { | 2822 | #ifndef USEQPE |
2823 | #ifndef USEQPE | 2823 | QDir d = QDir::home(); // "/" |
2824 | QDir d = QDir::home(); // "/" | 2824 | d.cd(APPDIR); |
2825 | d.cd(APPDIR); | 2825 | d.remove(bkmkselector->text(ind)); |
2826 | d.remove(bkmkselector->text(ind)); | 2826 | #else /* USEQPE */ |
2827 | #else /* USEQPE */ | 2827 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); |
2828 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); | 2828 | #endif /* USEQPE */ |
2829 | #endif /* USEQPE */ | 2829 | } |
2830 | } | 2830 | break; |
2831 | break; | 2831 | case cLdConfig: |
2832 | case cLdConfig: | 2832 | readconfig(bkmkselector->text(ind), false); |
2833 | readconfig(bkmkselector->text(ind), false); | 2833 | break; |
2834 | break; | 2834 | case cRmConfig: |
2835 | case cRmConfig: | 2835 | { |
2836 | { | 2836 | #ifndef USEQPE |
2837 | #ifndef USEQPE | 2837 | QDir d = QDir::home(); // "/" |
2838 | QDir d = QDir::home(); // "/" | 2838 | d.cd(APPDIR "/configs"); |
2839 | d.cd(APPDIR "/configs"); | 2839 | d.remove(bkmkselector->text(ind)); |
2840 | d.remove(bkmkselector->text(ind)); | 2840 | #else /* USEQPE */ |
2841 | #else /* USEQPE */ | 2841 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); |
2842 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); | 2842 | #endif /* USEQPE */ |
2843 | #endif /* USEQPE */ | 2843 | } |
2844 | } | 2844 | break; |
2845 | break; | 2845 | case cExportLinks: |
2846 | case cExportLinks: | 2846 | { |
2847 | { | 2847 | #ifndef USEQPE |
2848 | #ifndef USEQPE | 2848 | QDir d = QDir::home(); // "/" |
2849 | QDir d = QDir::home(); // "/" | 2849 | d.cd(APPDIR "/urls"); |
2850 | d.cd(APPDIR "/urls"); | 2850 | QFileInfo fi(d, bkmkselector->text(ind)); |
2851 | QFileInfo fi(d, bkmkselector->text(ind)); | 2851 | if (fi.exists()) |
2852 | if (fi.exists()) | 2852 | { |
2853 | { | 2853 | QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); |
2854 | QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); | 2854 | if (!outfile.isEmpty()) |
2855 | if (!outfile.isEmpty()) | 2855 | { |
2856 | { | 2856 | FILE* fout = fopen((const char *)outfile, "w"); |
2857 | FILE* fout = fopen((const char *)outfile, "w"); | 2857 | if (fout != NULL) |
2858 | if (fout != NULL) | 2858 | { |
2859 | { | 2859 | FILE* fin = fopen((const char *)fi.absFilePath(), "r"); |
2860 | FILE* fin = fopen((const char *)fi.absFilePath(), "r"); | 2860 | if (fin != NULL) |
2861 | if (fin != NULL) | 2861 | { |
2862 | { | 2862 | fprintf(fout, "<html><body>\n"); |
2863 | fprintf(fout, "<html><body>\n"); | 2863 | int ch = 0; |
2864 | int ch = 0; | 2864 | while ((ch = fgetc(fin)) != EOF) |
2865 | while ((ch = fgetc(fin)) != EOF) | 2865 | { |
2866 | { | 2866 | fputc(ch, fout); |
2867 | fputc(ch, fout); | 2867 | } |
2868 | } | 2868 | fclose(fin); |
2869 | fclose(fin); | 2869 | fprintf(fout, "</html></body>\n"); |
2870 | fprintf(fout, "</html></body>\n"); | 2870 | d.remove(bkmkselector->text(ind)); |
2871 | d.remove(bkmkselector->text(ind)); | 2871 | } |
2872 | } | 2872 | fclose(fout); |
2873 | fclose(fout); | 2873 | } |
2874 | } | 2874 | else |
2875 | else | 2875 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
2876 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 2876 | } |
2877 | } | 2877 | } |
2878 | } | 2878 | #else /* USEQPE */ |
2879 | #else /* USEQPE */ | 2879 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); |
2880 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | 2880 | if (fin != NULL) |
2881 | if (fin != NULL) | 2881 | { |
2882 | { | 2882 | bool allok = false; |
2883 | bool allok = false; | 2883 | fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); |
2884 | fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); | 2884 | if (fb->exec()) |
2885 | if (fb->exec()) | 2885 | { |
2886 | { | 2886 | QString outfile = fb->getCurrentFile(); |
2887 | QString outfile = fb->getCurrentFile(); | 2887 | FILE* fout = fopen((const char *)outfile, "w"); |
2888 | FILE* fout = fopen((const char *)outfile, "w"); | 2888 | if (fout != NULL) |
2889 | if (fout != NULL) | 2889 | { |
2890 | { | 2890 | fprintf(fout, "<html><body>\n"); |
2891 | fprintf(fout, "<html><body>\n"); | 2891 | int ch = 0; |
2892 | int ch = 0; | 2892 | while ((ch = fgetc(fin)) != EOF) |
2893 | while ((ch = fgetc(fin)) != EOF) | 2893 | { |
2894 | { | 2894 | fputc(ch, fout); |
2895 | fputc(ch, fout); | 2895 | } |
2896 | } | 2896 | fprintf(fout, "</html></body>\n"); |
2897 | fprintf(fout, "</html></body>\n"); | 2897 | fclose(fout); |
2898 | fclose(fout); | 2898 | allok = true; |
2899 | allok = true; | 2899 | } |
2900 | } | 2900 | else |
2901 | else | 2901 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
2902 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 2902 | } |
2903 | } | 2903 | delete fb; |
2904 | delete fb; | 2904 | fclose(fin); |
2905 | fclose(fin); | 2905 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); |
2906 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); | 2906 | } |
2907 | } | 2907 | else |
2908 | else | 2908 | { |
2909 | { | 2909 | QMessageBox::information(this, PROGNAME, "Couldn't open input"); |
2910 | QMessageBox::information(this, PROGNAME, "Couldn't open input"); | 2910 | } |
2911 | } | 2911 | |
2912 | 2912 | /* | |
2913 | /* | 2913 | CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); |
2914 | CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); | 2914 | int ret = f->exec(); |
2915 | int ret = f->exec(); | 2915 | qDebug("Return:%d", ret); |
2916 | qDebug("Return:%d", ret); | 2916 | DocLnk* doc = f->getDoc(); |
2917 | DocLnk* doc = f->getDoc(); | 2917 | if (doc != NULL) |
2918 | if (doc != NULL) | 2918 | { |
2919 | { | 2919 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); |
2920 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | 2920 | QString rt; |
2921 | QString rt; | 2921 | rt = "<html><body>\n"; |
2922 | rt = "<html><body>\n"; | 2922 | int ch = 0; |
2923 | int ch = 0; | 2923 | while ((ch = fgetc(fin)) != EOF) |
2924 | while ((ch = fgetc(fin)) != EOF) | 2924 | { |
2925 | { | 2925 | rt += (char)ch; |
2926 | rt += (char)ch; | 2926 | } |
2927 | } | 2927 | fclose(fin); |
2928 | fclose(fin); | 2928 | rt += "</html></body>\n"; |
2929 | rt += "</html></body>\n"; | 2929 | if ( doc->name().isEmpty() ) |
2930 | if ( doc->name().isEmpty() ) | 2930 | { |
2931 | { | 2931 | doc->setName(bkmkselector->text(ind)); |
2932 | doc->setName(bkmkselector->text(ind)); | 2932 | } |
2933 | } | 2933 | FileManager fm; |
2934 | FileManager fm; | 2934 | fm.saveFile( *doc, rt ); |
2935 | fm.saveFile( *doc, rt ); | 2935 | qDebug("YES"); |
2936 | qDebug("YES"); | 2936 | } |
2937 | } | 2937 | else |
2938 | else | 2938 | { |
2939 | { | 2939 | qDebug("NO"); |
2940 | qDebug("NO"); | 2940 | } |
2941 | } | 2941 | delete f; |
2942 | delete f; | 2942 | */ |
2943 | */ | 2943 | |
2944 | 2944 | #endif /* USEQPE */ | |
2945 | #endif /* USEQPE */ | 2945 | } |
2946 | } | 2946 | break; |
2947 | break; | 2947 | } |
2948 | } | 2948 | } |
2949 | } | 2949 | |
2950 | 2950 | void QTReaderApp::cancelbkmk() | |
2951 | void QTReaderApp::cancelbkmk() | 2951 | { |
2952 | { | 2952 | if (m_nBkmkAction == cOpenFile) |
2953 | if (m_nBkmkAction == cOpenFile) | 2953 | { |
2954 | { | 2954 | QString fn = usefilebrowser(); |
2955 | QString fn = usefilebrowser(); | 2955 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); |
2956 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); | 2956 | } |
2957 | } | 2957 | showEditTools(); |
2958 | showEditTools(); | 2958 | } |
2959 | } | 2959 | |
2960 | 2960 | void QTReaderApp::jump() | |
2961 | void QTReaderApp::jump() | 2961 | { |
2962 | { | 2962 | m_nRegAction = cJump; |
2963 | m_nRegAction = cJump; | 2963 | char lcn[20]; |
2964 | char lcn[20]; | 2964 | sprintf(lcn, "%lu", reader->pagelocate()); |
2965 | sprintf(lcn, "%lu", reader->pagelocate()); | 2965 | regEdit->setText(lcn); |
2966 | regEdit->setText(lcn); | 2966 | do_regedit(); |
2967 | do_regedit(); | 2967 | } |
2968 | } | 2968 | |
2969 | 2969 | void QTReaderApp::do_jump(const QString& lcn) | |
2970 | void QTReaderApp::do_jump(const QString& lcn) | 2970 | { |
2971 | { | 2971 | bool ok; |
2972 | bool ok; | 2972 | unsigned long ulcn = lcn.toULong(&ok); |
2973 | unsigned long ulcn = lcn.toULong(&ok); | 2973 | if (ok) |
2974 | if (ok) | 2974 | reader->locate(ulcn); |
2975 | reader->locate(ulcn); | 2975 | else |
2976 | else | 2976 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
2977 | QMessageBox::information(this, PROGNAME, "Must be a number"); | 2977 | } |
2978 | } | 2978 | |
2979 | 2979 | void QTReaderApp::do_regaction() | |
2980 | void QTReaderApp::do_regaction() | 2980 | { |
2981 | { | 2981 | reader->bDoUpdates = false; |
2982 | reader->bDoUpdates = false; | 2982 | regBar->hide(); |
2983 | regBar->hide(); | 2983 | #ifdef USEQPE |
2984 | #ifdef USEQPE | 2984 | Global::hideInputMethod(); |
2985 | Global::hideInputMethod(); | 2985 | #endif |
2986 | #endif | 2986 | regVisible = false; |
2987 | regVisible = false; | 2987 | switch(m_nRegAction) |
2988 | switch(m_nRegAction) | 2988 | { |
2989 | { | 2989 | case cAutoGen: |
2990 | case cAutoGen: | 2990 | do_autogen(regEdit->text()); |
2991 | do_autogen(regEdit->text()); | 2991 | break; |
2992 | break; | 2992 | case cAddBkmk: |
2993 | case cAddBkmk: | 2993 | do_addbkmk(regEdit->text()); |
2994 | do_addbkmk(regEdit->text()); | 2994 | break; |
2995 | break; | 2995 | case cJump: |
2996 | case cJump: | 2996 | do_jump(regEdit->text()); |
2997 | do_jump(regEdit->text()); | 2997 | break; |
2998 | break; | 2998 | /* |
2999 | /* | 2999 | case cMonoSpace: |
3000 | case cMonoSpace: | 3000 | do_mono(regEdit->text()); |
3001 | do_mono(regEdit->text()); | 3001 | break; |
3002 | break; | 3002 | */ |
3003 | */ | 3003 | case cSetTarget: |
3004 | case cSetTarget: | 3004 | do_settarget(regEdit->text()); |
3005 | do_settarget(regEdit->text()); | 3005 | break; |
3006 | break; | 3006 | #ifdef _SCROLLPIPE |
3007 | #ifdef _SCROLLPIPE | 3007 | case cSetPipeTarget: |
3008 | case cSetPipeTarget: | 3008 | do_setpipetarget(regEdit->text()); |
3009 | do_setpipetarget(regEdit->text()); | 3009 | break; |
3010 | break; | 3010 | #endif |
3011 | #endif | 3011 | case cSetConfigName: |
3012 | case cSetConfigName: | 3012 | // qDebug("Saving config"); |
3013 | // qDebug("Saving config"); | 3013 | do_saveconfig(regEdit->text(), false); |
3014 | do_saveconfig(regEdit->text(), false); | 3014 | break; |
3015 | break; | 3015 | } |
3016 | } | 3016 | // reader->restore(); |
3017 | // reader->restore(); | 3017 | // fileBar->show(); |
3018 | // fileBar->show(); | 3018 | reader->setFocus(); |
3019 | reader->setFocus(); | 3019 | // qApp->processEvents(); |
3020 | // qApp->processEvents(); | 3020 | reader->bDoUpdates = true; |
3021 | reader->bDoUpdates = true; | 3021 | reader->update(); |
3022 | reader->update(); | 3022 | } |
3023 | } | 3023 | |
3024 | 3024 | void QTReaderApp::do_settarget(const QString& _txt) | |
3025 | void QTReaderApp::do_settarget(const QString& _txt) | 3025 | { |
3026 | { | 3026 | int ind = _txt.find('/'); |
3027 | int ind = _txt.find('/'); | 3027 | if (ind == -1) |
3028 | if (ind == -1) | 3028 | { |
3029 | { | 3029 | m_targetapp = ""; |
3030 | m_targetapp = ""; | 3030 | m_targetmsg = ""; |
3031 | m_targetmsg = ""; | 3031 | QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); |
3032 | QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); | 3032 | } |
3033 | } | 3033 | else |
3034 | else | 3034 | { |
3035 | { | 3035 | m_targetapp = _txt.left(ind); |
3036 | m_targetapp = _txt.left(ind); | 3036 | m_targetmsg = _txt.right(_txt.length()-ind-1); |
3037 | m_targetmsg = _txt.right(_txt.length()-ind-1); | 3037 | } |
3038 | } | 3038 | } |
3039 | } | 3039 | |
3040 | 3040 | void QTReaderApp::chooseencoding() | |
3041 | void QTReaderApp::chooseencoding() | 3041 | { |
3042 | { | 3042 | m_fontSelector->clear(); |
3043 | m_fontSelector->clear(); | 3043 | m_fontSelector->insertItem("Ascii"); |
3044 | m_fontSelector->insertItem("Ascii"); | 3044 | m_fontSelector->insertItem("UTF-8"); |
3045 | m_fontSelector->insertItem("UTF-8"); | 3045 | m_fontSelector->insertItem("UCS-2(BE)"); |
3046 | m_fontSelector->insertItem("UCS-2(BE)"); | 3046 | m_fontSelector->insertItem("USC-2(LE)"); |
3047 | m_fontSelector->insertItem("USC-2(LE)"); | 3047 | m_fontSelector->insertItem("Palm"); |
3048 | m_fontSelector->insertItem("Palm"); | 3048 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) |
3049 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) | 3049 | { |
3050 | { | 3050 | m_fontSelector->insertItem(iter->mime); |
3051 | m_fontSelector->insertItem(iter->mime); | 3051 | } // delete the FontDatabase!!! |
3052 | } // delete the FontDatabase!!! | 3052 | m_fontSelector->setCurrentItem (reader->m_encd); |
3053 | m_fontSelector->setCurrentItem (reader->m_encd); | 3053 | m_fontAction = cChooseEncoding; |
3054 | m_fontAction = cChooseEncoding; | 3054 | m_fontBar->show(); |
3055 | m_fontBar->show(); | 3055 | m_fontVisible = true; |
3056 | m_fontVisible = true; | 3056 | } |
3057 | } | 3057 | |
3058 | 3058 | void QTReaderApp::setfont() | |
3059 | void QTReaderApp::setfont() | 3059 | { |
3060 | { | 3060 | m_fontSelector->clear(); |
3061 | m_fontSelector->clear(); | 3061 | { |
3062 | { | 3062 | #ifdef USEQPE |
3063 | #ifdef USEQPE | 3063 | FontDatabase f; |
3064 | FontDatabase f; | 3064 | #else |
3065 | #else | 3065 | QFontDatabase f; |
3066 | QFontDatabase f; | 3066 | #endif |
3067 | #endif | 3067 | QStringList flist = f.families(); |
3068 | QStringList flist = f.families(); | 3068 | m_fontSelector->insertStringList(flist); |
3069 | m_fontSelector->insertStringList(flist); | 3069 | } // delete the FontDatabase!!! |
3070 | } // delete the FontDatabase!!! | 3070 | |
3071 | 3071 | for (int i = 1; i <= m_fontSelector->count(); i++) | |
3072 | for (int i = 1; i <= m_fontSelector->count(); i++) | 3072 | { |
3073 | { | 3073 | if (m_fontSelector->text(i) == reader->m_fontname) |
3074 | if (m_fontSelector->text(i) == reader->m_fontname) | 3074 | { |
3075 | { | 3075 | m_fontSelector->setCurrentItem(i); |
3076 | m_fontSelector->setCurrentItem(i); | 3076 | break; |
3077 | break; | 3077 | } |
3078 | } | 3078 | } |
3079 | } | 3079 | m_fontAction = cChooseFont; |
3080 | m_fontAction = cChooseFont; | 3080 | m_fontBar->show(); |
3081 | m_fontBar->show(); | 3081 | m_fontVisible = true; |
3082 | m_fontVisible = true; | 3082 | } |
3083 | } | 3083 | |
3084 | 3084 | void QTReaderApp::setfontHelper(const QString& lcn, int size) | |
3085 | void QTReaderApp::setfontHelper(const QString& lcn, int size) | 3085 | { |
3086 | { | 3086 | if (size == 0) size = reader->m_fontControl.currentsize(); |
3087 | if (size == 0) size = reader->m_fontControl.currentsize(); | 3087 | if (m_propogatefontchange) |
3088 | if (m_propogatefontchange) | 3088 | { |
3089 | { | 3089 | QFont f(lcn, 10); |
3090 | QFont f(lcn, 10); | 3090 | bkmkselector->setFont( f ); |
3091 | bkmkselector->setFont( f ); | 3091 | regEdit->setFont( f ); |
3092 | regEdit->setFont( f ); | 3092 | searchEdit->setFont( f ); |
3093 | searchEdit->setFont( f ); | 3093 | m_annoWin->setFont( f ); |
3094 | m_annoWin->setFont( f ); | 3094 | } |
3095 | } | 3095 | reader->m_fontname = lcn; |
3096 | reader->m_fontname = lcn; | 3096 | if (!reader->ChangeFont(size)) |
3097 | if (!reader->ChangeFont(size)) | 3097 | { |
3098 | { | 3098 | reader->ChangeFont(size); |
3099 | reader->ChangeFont(size); | 3099 | } |
3100 | } | 3100 | } |
3101 | } | 3101 | |
3102 | 3102 | void QTReaderApp::do_setencoding(int i) | |
3103 | void QTReaderApp::do_setencoding(int i) | 3103 | { |
3104 | { | 3104 | // qDebug("setencoding:%d", i); |
3105 | // qDebug("setencoding:%d", i); | 3105 | if (m_fontAction == cChooseEncoding) |
3106 | if (m_fontAction == cChooseEncoding) | 3106 | { |
3107 | { | 3107 | reader->setencoding(i); |
3108 | reader->setencoding(i); | 3108 | } |
3109 | } | 3109 | reader->refresh(); |
3110 | reader->refresh(); | 3110 | m_fontBar->hide(); |
3111 | m_fontBar->hide(); | 3111 | m_fontVisible = false; |
3112 | m_fontVisible = false; | 3112 | // qDebug("showedit"); |
3113 | // qDebug("showedit"); | 3113 | if (reader->isVisible()) showEditTools(); |
3114 | if (reader->isVisible()) showEditTools(); | 3114 | // qDebug("showeditdone"); |
3115 | // qDebug("showeditdone"); | 3115 | } |
3116 | } | 3116 | |
3117 | 3117 | void QTReaderApp::do_setfont(const QString& lcn) | |
3118 | void QTReaderApp::do_setfont(const QString& lcn) | 3118 | { |
3119 | { | 3119 | if (m_fontAction == cChooseFont) |
3120 | if (m_fontAction == cChooseFont) | 3120 | { |
3121 | { | 3121 | setfontHelper(lcn); |
3122 | setfontHelper(lcn); | 3122 | } |
3123 | } | 3123 | reader->refresh(); |
3124 | reader->refresh(); | 3124 | m_fontBar->hide(); |
3125 | m_fontBar->hide(); | 3125 | m_fontVisible = false; |
3126 | m_fontVisible = false; | 3126 | // qDebug("showedit"); |
3127 | // qDebug("showedit"); | 3127 | //if (reader->isVisible()) |
3128 | //if (reader->isVisible()) | 3128 | showEditTools(); |
3129 | showEditTools(); | 3129 | // qDebug("showeditdone"); |
3130 | // qDebug("showeditdone"); | 3130 | } |
3131 | } | 3131 | |
3132 | 3132 | void QTReaderApp::do_autogen(const QString& regText) | |
3133 | void QTReaderApp::do_autogen(const QString& regText) | 3133 | { |
3134 | { | 3134 | unsigned long fs, ts; |
3135 | unsigned long fs, ts; | 3135 | reader->sizes(fs,ts); |
3136 | reader->sizes(fs,ts); | 3136 | // // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); |
3137 | // // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); | 3137 | m_autogenstr = regText; |
3138 | m_autogenstr = regText; | 3138 | QRegExp re(regText); |
3139 | QRegExp re(regText); | 3139 | CBuffer buff; |
3140 | CBuffer buff; | 3140 | if (pBkmklist != NULL) delete pBkmklist; |
3141 | if (pBkmklist != NULL) delete pBkmklist; | 3141 | pBkmklist = new CList<Bkmk>; |
3142 | pBkmklist = new CList<Bkmk>; | 3142 | m_fBkmksChanged = true; |
3143 | m_fBkmksChanged = true; | 3143 | |
3144 | 3144 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); | |
3145 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); | 3145 | pbar->show(); |
3146 | pbar->show(); | 3146 | pbar->raise(); |
3147 | pbar->raise(); | 3147 | pbar->reset(); |
3148 | pbar->reset(); | 3148 | reader->update(); |
3149 | reader->update(); | 3149 | qApp->processEvents(); |
3150 | qApp->processEvents(); | 3150 | reader->setFocus(); |
3151 | reader->setFocus(); | 3151 | reader->jumpto(0); |
3152 | reader->jumpto(0); | 3152 | int lastpc = 0; |
3153 | int lastpc = 0; | 3153 | int i = 0; |
3154 | int i = 0; | 3154 | while (i >= 0) |
3155 | while (i >= 0) | 3155 | { |
3156 | { | 3156 | unsigned int lcn = reader->locate(); |
3157 | unsigned int lcn = reader->locate(); | 3157 | int pc = (100*lcn)/ts; |
3158 | int pc = (100*lcn)/ts; | 3158 | if (pc != lastpc) |
3159 | if (pc != lastpc) | 3159 | { |
3160 | { | 3160 | pbar->setProgress(pc); |
3161 | pbar->setProgress(pc); | 3161 | qApp->processEvents(); |
3162 | qApp->processEvents(); | 3162 | if (reader->locate() != lcn) reader->jumpto(lcn); |
3163 | if (reader->locate() != lcn) reader->jumpto(lcn); | 3163 | reader->setFocus(); |
3164 | reader->setFocus(); | 3164 | lastpc = pc; |
3165 | lastpc = pc; | 3165 | } |
3166 | } | 3166 | i = reader->buffdoc.getpara(buff); |
3167 | i = reader->buffdoc.getpara(buff); | 3167 | #ifdef _UNICODE |
3168 | #ifdef _UNICODE | 3168 | if (re.match(toQString(buff.data())) != -1) |
3169 | if (re.match(toQString(buff.data())) != -1) | 3169 | #else |
3170 | #else | 3170 | if (re.match(buff.data()) != -1) |
3171 | if (re.match(buff.data()) != -1) | 3171 | #endif |
3172 | #endif | 3172 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); |
3173 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); | 3173 | } |
3174 | } | 3174 | pBkmklist->sort(); |
3175 | pBkmklist->sort(); | 3175 | pbar->setProgress(100); |
3176 | pbar->setProgress(100); | 3176 | qApp->processEvents(); |
3177 | qApp->processEvents(); | 3177 | pbar->hide(); |
3178 | pbar->hide(); | 3178 | reader->refresh(); |
3179 | reader->refresh(); | 3179 | } |
3180 | } | 3180 | |
3181 | 3181 | void QTReaderApp::saveprefs() | |
3182 | void QTReaderApp::saveprefs() | 3182 | { |
3183 | { | 3183 | // qDebug("saveprefs"); |
3184 | // qDebug("saveprefs"); | 3184 | // reader->saveprefs("uqtreader"); |
3185 | // reader->saveprefs("uqtreader"); | 3185 | // if (!m_loadedconfig) |
3186 | // if (!m_loadedconfig) | 3186 | do_saveconfig( APPDIR, true ); |
3187 | do_saveconfig( APPDIR, true ); | 3187 | |
3188 | 3188 | /* | |
3189 | /* | 3189 | Config config( APPDIR ); |
3190 | Config config( APPDIR ); | 3190 | config.setGroup( "View" ); |
3191 | config.setGroup( "View" ); | 3191 | |
3192 | 3192 | reader->m_lastposn = reader->pagelocate(); | |
3193 | reader->m_lastposn = reader->pagelocate(); | 3193 | |
3194 | 3194 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | |
3195 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | 3195 | config.writeEntry( "StripCr", reader->bstripcr ); |
3196 | config.writeEntry( "StripCr", reader->bstripcr ); | 3196 | config.writeEntry( "AutoFmt", reader->bautofmt ); |
3197 | config.writeEntry( "AutoFmt", reader->bautofmt ); | 3197 | config.writeEntry( "TextFmt", reader->btextfmt ); |
3198 | config.writeEntry( "TextFmt", reader->btextfmt ); | 3198 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
3199 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 3199 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
3200 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 3200 | config.writeEntry( "Depluck", reader->bdepluck ); |
3201 | config.writeEntry( "Depluck", reader->bdepluck ); | 3201 | config.writeEntry( "Dejpluck", reader->bdejpluck ); |
3202 | config.writeEntry( "Dejpluck", reader->bdejpluck ); | 3202 | config.writeEntry( "OneSpace", reader->bonespace ); |
3203 | config.writeEntry( "OneSpace", reader->bonespace ); | 3203 | config.writeEntry( "Unindent", reader->bunindent ); |
3204 | config.writeEntry( "Unindent", reader->bunindent ); | 3204 | config.writeEntry( "Repara", reader->brepara ); |
3205 | config.writeEntry( "Repara", reader->brepara ); | 3205 | config.writeEntry( "DoubleSpace", reader->bdblspce ); |
3206 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | 3206 | config.writeEntry( "Indent", reader->bindenter ); |
3207 | config.writeEntry( "Indent", reader->bindenter ); | 3207 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); |
3208 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | 3208 | config.writeEntry( "ScrollDelay", reader->m_delay); |
3209 | config.writeEntry( "ScrollDelay", reader->m_delay); | 3209 | config.writeEntry( "LastFile", reader->m_lastfile ); |
3210 | config.writeEntry( "LastFile", reader->m_lastfile ); | 3210 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
3211 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 3211 | config.writeEntry( "PageMode", reader->m_bpagemode ); |
3212 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 3212 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); |
3213 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 3213 | config.writeEntry( "SwapMouse", reader->m_swapmouse); |
3214 | config.writeEntry( "SwapMouse", reader->m_swapmouse); | 3214 | config.writeEntry( "Fontname", reader->m_fontname ); |
3215 | config.writeEntry( "Fontname", reader->m_fontname ); | 3215 | config.writeEntry( "Encoding", reader->m_encd ); |
3216 | config.writeEntry( "Encoding", reader->m_encd ); | 3216 | config.writeEntry( "CharSpacing", reader->m_charpc ); |
3217 | config.writeEntry( "CharSpacing", reader->m_charpc ); | 3217 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); |
3218 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | 3218 | config.writeEntry( "Margin", (int)reader->m_border ); |
3219 | config.writeEntry( "Margin", (int)reader->m_border ); | 3219 | config.writeEntry( "TargetApp", m_targetapp ); |
3220 | config.writeEntry( "TargetApp", m_targetapp ); | 3220 | config.writeEntry( "TargetMsg", m_targetmsg ); |
3221 | config.writeEntry( "TargetMsg", m_targetmsg ); | 3221 | #ifdef _SCROLLPIPE |
3222 | #ifdef _SCROLLPIPE | 3222 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); |
3223 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); | 3223 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); |
3224 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | 3224 | #endif |
3225 | #endif | 3225 | config.writeEntry( "TwoTouch", m_twoTouch ); |
3226 | config.writeEntry( "TwoTouch", m_twoTouch ); | 3226 | config.writeEntry( "Annotation", m_doAnnotation); |
3227 | config.writeEntry( "Annotation", m_doAnnotation); | 3227 | config.writeEntry( "Dictionary", m_doDictionary); |
3228 | config.writeEntry( "Dictionary", m_doDictionary); | 3228 | config.writeEntry( "Clipboard", m_doClipboard); |
3229 | config.writeEntry( "Clipboard", m_doClipboard); | 3229 | config.writeEntry( "SpaceTarget", m_spaceTarget); |
3230 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 3230 | config.writeEntry( "EscapeTarget", m_escapeTarget); |
3231 | config.writeEntry( "EscapeTarget", m_escapeTarget); | 3231 | config.writeEntry( "ReturnTarget", m_returnTarget); |
3232 | config.writeEntry( "ReturnTarget", m_returnTarget); | 3232 | config.writeEntry( "LeftTarget", m_leftTarget); |
3233 | config.writeEntry( "LeftTarget", m_leftTarget); | 3233 | config.writeEntry( "RightTarget", m_rightTarget); |
3234 | config.writeEntry( "RightTarget", m_rightTarget); | 3234 | config.writeEntry( "UpTarget", m_upTarget); |
3235 | config.writeEntry( "UpTarget", m_upTarget); | 3235 | config.writeEntry( "DownTarget", m_downTarget); |
3236 | config.writeEntry( "DownTarget", m_downTarget); | 3236 | config.writeEntry("LeftScroll", m_leftScroll); |
3237 | config.writeEntry("LeftScroll", m_leftScroll); | 3237 | config.writeEntry("RightScroll", m_rightScroll); |
3238 | config.writeEntry("RightScroll", m_rightScroll); | 3238 | config.writeEntry("UpScroll", m_upScroll); |
3239 | config.writeEntry("UpScroll", m_upScroll); | 3239 | config.writeEntry("DownScroll", m_downScroll); |
3240 | config.writeEntry("DownScroll", m_downScroll); | 3240 | #ifdef REPALM |
3241 | #ifdef REPALM | 3241 | config.writeEntry( "Repalm", reader->brepalm ); |
3242 | config.writeEntry( "Repalm", reader->brepalm ); | 3242 | #endif |
3243 | #endif | 3243 | config.writeEntry( "Remap", reader->bremap ); |
3244 | config.writeEntry( "Remap", reader->bremap ); | 3244 | config.writeEntry( "Peanut", reader->bpeanut ); |
3245 | config.writeEntry( "Peanut", reader->bpeanut ); | 3245 | config.writeEntry( "MakeBold", reader->bmakebold ); |
3246 | config.writeEntry( "MakeBold", reader->bmakebold ); | 3246 | config.writeEntry( "Continuous", reader->m_continuousDocument ); |
3247 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | 3247 | config.writeEntry( "FullJust", reader->bfulljust ); |
3248 | config.writeEntry( "FullJust", reader->bfulljust ); | 3248 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); |
3249 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); | 3249 | config.writeEntry( "ExtraLead", reader->getlead() ); |
3250 | config.writeEntry( "ExtraLead", reader->getlead() ); | 3250 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); |
3251 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); | 3251 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); |
3252 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); | 3252 | |
3253 | 3253 | config.setGroup( "Toolbar" ); | |
3254 | config.setGroup( "Toolbar" ); | 3254 | config.writeEntry("Movable", m_tbmovesave); |
3255 | config.writeEntry("Movable", m_tbmovesave); | 3255 | config.writeEntry("Policy", m_tbpolsave); |
3256 | config.writeEntry("Policy", m_tbpolsave); | 3256 | config.writeEntry("Position", m_tbposition); |
3257 | config.writeEntry("Position", m_tbposition); | 3257 | */ |
3258 | */ | 3258 | savefilelist(); |
3259 | savefilelist(); | 3259 | } |
3260 | } | 3260 | |
3261 | 3261 | /* | |
3262 | /* | 3262 | void QTReaderApp::oldFile() |
3263 | void QTReaderApp::oldFile() | 3263 | { |
3264 | { | 3264 | // qDebug("oldFile called"); |
3265 | // qDebug("oldFile called"); | 3265 | reader->setText(true); |
3266 | reader->setText(true); | 3266 | // qDebug("settext called"); |
3267 | // qDebug("settext called"); | 3267 | showEditTools(); |
3268 | showEditTools(); | 3268 | // qDebug("showedit called"); |
3269 | // qDebug("showedit called"); | 3269 | } |
3270 | } | 3270 | */ |
3271 | */ | 3271 | |
3272 | 3272 | /* | |
3273 | /* | 3273 | void info_cb(Fl_Widget* o, void* _data) |
3274 | void info_cb(Fl_Widget* o, void* _data) | 3274 | { |
3275 | { | 3275 | |
3276 | 3276 | if (infowin == NULL) | |
3277 | if (infowin == NULL) | 3277 | { |
3278 | { | 3278 | |
3279 | 3279 | infowin = new Fl_Window(160,240); | |
3280 | infowin = new Fl_Window(160,240); | 3280 | filename = new Fl_Output(45,5,110,14,"Filename"); |
3281 | filename = new Fl_Output(45,5,110,14,"Filename"); | 3281 | filesize = new Fl_Output(45,25,110,14,"Filesize"); |
3282 | filesize = new Fl_Output(45,25,110,14,"Filesize"); | 3282 | textsize = new Fl_Output(45,45,110,14,"Textsize"); |
3283 | textsize = new Fl_Output(45,45,110,14,"Textsize"); | 3283 | comprat = new CBar(45,65,110,14,"Ratio %"); |
3284 | comprat = new CBar(45,65,110,14,"Ratio %"); | 3284 | posn = new Fl_Output(45,85,110,14,"Location"); |
3285 | posn = new Fl_Output(45,85,110,14,"Location"); | 3285 | frcn = new CBar(45,105,110,14,"% Read"); |
3286 | frcn = new CBar(45,105,110,14,"% Read"); | 3286 | about = new Fl_Multiline_Output(5,125,150,90); |
3287 | about = new Fl_Multiline_Output(5,125,150,90); | 3287 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); |
3288 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); | 3288 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); |
3289 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); | 3289 | infowin->set_modal(); |
3290 | infowin->set_modal(); | 3290 | } |
3291 | } | 3291 | if (((reader_ui *)_data)->g_filename[0] != '\0') |
3292 | if (((reader_ui *)_data)->g_filename[0] != '\0') | 3292 | { |
3293 | { | 3293 | unsigned long fs,ts; |
3294 | unsigned long fs,ts; | 3294 | tchar sz[20]; |
3295 | tchar sz[20]; | 3295 | ((reader_ui *)_data)->input->sizes(fs,ts); |
3296 | ((reader_ui *)_data)->input->sizes(fs,ts); | 3296 | unsigned long pl = ((reader_ui *)_data)->input->locate(); |
3297 | unsigned long pl = ((reader_ui *)_data)->input->locate(); | 3297 | |
3298 | 3298 | filename->value(((reader_ui *)_data)->g_filename); | |
3299 | filename->value(((reader_ui *)_data)->g_filename); | 3299 | |
3300 | 3300 | sprintf(sz,"%u",fs); | |
3301 | sprintf(sz,"%u",fs); | 3301 | filesize->value(sz); |
3302 | filesize->value(sz); | 3302 | |
3303 | 3303 | sprintf(sz,"%u",ts); | |
3304 | sprintf(sz,"%u",ts); | 3304 | textsize->value(sz); |
3305 | textsize->value(sz); | 3305 | |
3306 | 3306 | comprat->value(100-(100*fs + (ts >> 1))/ts); | |
3307 | comprat->value(100-(100*fs + (ts >> 1))/ts); | 3307 | |
3308 | 3308 | sprintf(sz,"%u",pl); | |
3309 | sprintf(sz,"%u",pl); | 3309 | posn->value(sz); |
3310 | posn->value(sz); | 3310 | |
3311 | 3311 | frcn->value((100*pl + (ts >> 1))/ts); | |
3312 | frcn->value((100*pl + (ts >> 1))/ts); | 3312 | } |
3313 | } | 3313 | infowin->show(); |
3314 | infowin->show(); | 3314 | } |
3315 | } | 3315 | */ |
3316 | */ | 3316 | |
3317 | 3317 | void QTReaderApp::savebkmks() | |
3318 | void QTReaderApp::savebkmks() | 3318 | { |
3319 | { | 3319 | if (pBkmklist != NULL) |
3320 | if (pBkmklist != NULL) | 3320 | { |
3321 | { | 3321 | #ifndef USEQPE |
3322 | #ifndef USEQPE | 3322 | QDir d = QDir::home(); // "/" |
3323 | QDir d = QDir::home(); // "/" | 3323 | d.cd(APPDIR); |
3324 | d.cd(APPDIR); | 3324 | QFileInfo fi(d, reader->m_string); |
3325 | QFileInfo fi(d, reader->m_string); | 3325 | BkmkFile bf((const char *)fi.absFilePath(), true); |
3326 | BkmkFile bf((const char *)fi.absFilePath(), true); | 3326 | #else /* USEQPE */ |
3327 | #else /* USEQPE */ | 3327 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true); |
3328 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true); | 3328 | #endif /* USEQPE */ |
3329 | #endif /* USEQPE */ | 3329 | bf.write(*pBkmklist); |
3330 | bf.write(*pBkmklist); | 3330 | } |
3331 | } | 3331 | m_fBkmksChanged = false; |
3332 | m_fBkmksChanged = false; | 3332 | } |
3333 | } | 3333 | |
3334 | 3334 | void QTReaderApp::readfilelist() | |
3335 | void QTReaderApp::readfilelist() | 3335 | { |
3336 | { | 3336 | #ifndef USEQPE |
3337 | #ifndef USEQPE | 3337 | QDir d = QDir::home(); // "/" |
3338 | QDir d = QDir::home(); // "/" | 3338 | d.cd(APPDIR); |
3339 | d.cd(APPDIR); | 3339 | QFileInfo fi(d, ".openfiles"); |
3340 | QFileInfo fi(d, ".openfiles"); | 3340 | BkmkFile bf((const char *)fi.absFilePath()); |
3341 | BkmkFile bf((const char *)fi.absFilePath()); | 3341 | #else /* USEQPE */ |
3342 | #else /* USEQPE */ | 3342 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles")); |
3343 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles")); | 3343 | #endif /* USEQPE */ |
3344 | #endif /* USEQPE */ | 3344 | // qDebug("Reading open files"); |
3345 | // qDebug("Reading open files"); | 3345 | pOpenlist = bf.readall(); |
3346 | pOpenlist = bf.readall(); | 3346 | // if (pOpenlist != NULL) qDebug("...with success"); |
3347 | // if (pOpenlist != NULL) qDebug("...with success"); | 3347 | // else qDebug("...without success!"); |
3348 | // else qDebug("...without success!"); | 3348 | } |
3349 | } | 3349 | |
3350 | 3350 | void QTReaderApp::savefilelist() | |
3351 | void QTReaderApp::savefilelist() | 3351 | { |
3352 | { | 3352 | if (pOpenlist != NULL) |
3353 | if (pOpenlist != NULL) | 3353 | { |
3354 | { | 3354 | #ifndef USEQPE |
3355 | #ifndef USEQPE | 3355 | QDir d = QDir::home(); // "/" |
3356 | QDir d = QDir::home(); // "/" | 3356 | d.cd(APPDIR); |
3357 | d.cd(APPDIR); | 3357 | QFileInfo fi(d, ".openfiles"); |
3358 | QFileInfo fi(d, ".openfiles"); | 3358 | BkmkFile bf((const char *)fi.absFilePath(), true); |
3359 | BkmkFile bf((const char *)fi.absFilePath(), true); | 3359 | #else /* USEQPE */ |
3360 | #else /* USEQPE */ | 3360 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true); |
3361 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true); | 3361 | #endif /* USEQPE */ |
3362 | #endif /* USEQPE */ | 3362 | //qDebug("Writing open files"); |
3363 | //qDebug("Writing open files"); | 3363 | bf.write(*pOpenlist); |
3364 | bf.write(*pOpenlist); | 3364 | } |
3365 | } | 3365 | } |
3366 | } | 3366 | |
3367 | 3367 | void QTReaderApp::readbkmks() | |
3368 | void QTReaderApp::readbkmks() | 3368 | { |
3369 | { | 3369 | if (pBkmklist != NULL) |
3370 | if (pBkmklist != NULL) | 3370 | { |
3371 | { | 3371 | delete pBkmklist; |
3372 | delete pBkmklist; | 3372 | } |
3373 | } | 3373 | struct stat fnstat; |
3374 | struct stat fnstat; | 3374 | struct stat bkstat; |
3375 | struct stat bkstat; | 3375 | #ifndef USEQPE |
3376 | #ifndef USEQPE | 3376 | QDir d = QDir::home(); // "/" |
3377 | QDir d = QDir::home(); // "/" | 3377 | d.cd(APPDIR); |
3378 | d.cd(APPDIR); | 3378 | QFileInfo fi(d, reader->m_string); |
3379 | QFileInfo fi(d, reader->m_string); | 3379 | #endif /* ! USEQPE */ |
3380 | #endif /* ! USEQPE */ | 3380 | if ( |
3381 | if ( | 3381 | stat((const char *)reader->m_lastfile, &fnstat) == 0 |
3382 | stat((const char *)reader->m_lastfile, &fnstat) == 0 | 3382 | && |
3383 | && | 3383 | #ifndef USEQPE |
3384 | #ifndef USEQPE | 3384 | stat((const char *)fi.absFilePath(), &bkstat) == 0 |
3385 | stat((const char *)fi.absFilePath(), &bkstat) == 0 | 3385 | #else /* USEQPE */ |
3386 | #else /* USEQPE */ | 3386 | stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 |
3387 | stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 | 3387 | #endif /* USEQPE */ |
3388 | #endif /* USEQPE */ | 3388 | ) |
3389 | ) | 3389 | { |
3390 | { | 3390 | if (bkstat.st_mtime < fnstat.st_mtime) |
3391 | if (bkstat.st_mtime < fnstat.st_mtime) | 3391 | { |
3392 | { | 3392 | #ifndef USEQPE |
3393 | #ifndef USEQPE | 3393 | unlink((const char *)fi.absFilePath()); |
3394 | unlink((const char *)fi.absFilePath()); | 3394 | #else /* USEQPE */ |
3395 | #else /* USEQPE */ | 3395 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
3396 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 3396 | #endif /* USEQPE */ |
3397 | #endif /* USEQPE */ | 3397 | } |
3398 | } | 3398 | } |
3399 | } | 3399 | |
3400 | 3400 | #ifndef USEQPE | |
3401 | #ifndef USEQPE | 3401 | BkmkFile bf((const char *)fi.absFilePath()); |
3402 | BkmkFile bf((const char *)fi.absFilePath()); | 3402 | #else /* USEQPE */ |
3403 | #else /* USEQPE */ | 3403 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
3404 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 3404 | #endif /* USEQPE */ |
3405 | #endif /* USEQPE */ | 3405 | |
3406 | 3406 | pBkmklist = bf.readall(); | |
3407 | pBkmklist = bf.readall(); | 3407 | m_fBkmksChanged = bf.upgraded(); |
3408 | m_fBkmksChanged = bf.upgraded(); | 3408 | if (pBkmklist == NULL) |
3409 | if (pBkmklist == NULL) | 3409 | { |
3410 | { | 3410 | pBkmklist = reader->getbkmklist(); |
3411 | pBkmklist = reader->getbkmklist(); | 3411 | } |
3412 | } | 3412 | if (pBkmklist != NULL) |
3413 | if (pBkmklist != NULL) | 3413 | pBkmklist->sort(); |
3414 | pBkmklist->sort(); | 3414 | } |
3415 | } | 3415 | |
3416 | 3416 | void QTReaderApp::addbkmk() | |
3417 | void QTReaderApp::addbkmk() | 3417 | { |
3418 | { | 3418 | m_nRegAction = cAddBkmk; |
3419 | m_nRegAction = cAddBkmk; | 3419 | regEdit->setText(reader->firstword()); |
3420 | regEdit->setText(reader->firstword()); | 3420 | do_regedit(); |
3421 | do_regedit(); | 3421 | } |
3422 | } | 3422 | |
3423 | 3423 | void QTReaderApp::do_addbkmk(const QString& text) | |
3424 | void QTReaderApp::do_addbkmk(const QString& text) | 3424 | { |
3425 | { | 3425 | if (text.isEmpty()) |
3426 | if (text.isEmpty()) | 3426 | { |
3427 | { | 3427 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); |
3428 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); | 3428 | } |
3429 | } | 3429 | else |
3430 | else | 3430 | { |
3431 | { | 3431 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; |
3432 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; | 3432 | #ifdef _UNICODE |
3433 | #ifdef _UNICODE | 3433 | CBuffer buff; |
3434 | CBuffer buff; | 3434 | int i = 0; |
3435 | int i = 0; | 3435 | for (i = 0; i < text.length(); i++) |
3436 | for (i = 0; i < text.length(); i++) | 3436 | { |
3437 | { | 3437 | buff[i] = text[i].unicode(); |
3438 | buff[i] = text[i].unicode(); | 3438 | } |
3439 | } | 3439 | buff[i] = 0; |
3440 | buff[i] = 0; | 3440 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); |
3441 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); | 3441 | #else |
3442 | #else | 3442 | pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); |
3443 | pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); | 3443 | #endif |
3444 | #endif | 3444 | m_fBkmksChanged = true; |
3445 | m_fBkmksChanged = true; | 3445 | pBkmklist->sort(); |
3446 | pBkmklist->sort(); | 3446 | } |
3447 | } | 3447 | } |
3448 | } | 3448 | |
3449 | 3449 | void QTReaderApp::OnRedraw() | |
3450 | void QTReaderApp::OnRedraw() | 3450 | { |
3451 | { | 3451 | if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) |
3452 | if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) | 3452 | { |
3453 | { | 3453 | bool found = findNextBookmark(reader->pagelocate()); |
3454 | bool found = findNextBookmark(reader->pagelocate()); | 3454 | m_bkmkAvail->setEnabled(found); |
3455 | m_bkmkAvail->setEnabled(found); | 3455 | } |
3456 | } | 3456 | } |
3457 | } | 3457 | |
3458 | 3458 | void QTReaderApp::showAnnotation() | |
3459 | void QTReaderApp::showAnnotation() | 3459 | { |
3460 | { | 3460 | m_annoWin->setName(toQString(m_anno->name())); |
3461 | m_annoWin->setName(toQString(m_anno->name())); | 3461 | m_annoWin->setAnno(toQString(m_anno->anno())); |
3462 | m_annoWin->setAnno(toQString(m_anno->anno())); | 3462 | m_annoIsEditing = false; |
3463 | m_annoIsEditing = false; | 3463 | #ifdef USEQPE |
3464 | #ifdef USEQPE | 3464 | Global::showInputMethod(); |
3465 | Global::showInputMethod(); | 3465 | #endif |
3466 | #endif | 3466 | editorStack->raiseWidget( m_annoWin ); |
3467 | editorStack->raiseWidget( m_annoWin ); | 3467 | m_annoWin->setFocus(); |
3468 | m_annoWin->setFocus(); | 3468 | } |
3469 | } | 3469 | |
3470 | 3470 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) | |
3471 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) | 3471 | { |
3472 | { | 3472 | //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); |
3473 | //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); | 3473 | |
3474 | 3474 | if (m_doClipboard) | |
3475 | if (m_doClipboard) | 3475 | { |
3476 | { | 3476 | QClipboard* cb = QApplication::clipboard(); |
3477 | QClipboard* cb = QApplication::clipboard(); | 3477 | cb->setText(wrd); |
3478 | cb->setText(wrd); | 3478 | #ifdef USEQPE |
3479 | #ifdef USEQPE | 3479 | if (wrd.length() > 10) |
3480 | if (wrd.length() > 10) | 3480 | { |
3481 | { | 3481 | Global::statusMessage(wrd.left(8) + ".."); |
3482 | Global::statusMessage(wrd.left(8) + ".."); | 3482 | } |
3483 | } | 3483 | else |
3484 | else | 3484 | { |
3485 | { | 3485 | Global::statusMessage(wrd); |
3486 | Global::statusMessage(wrd); | 3486 | } |
3487 | } | 3487 | #endif |
3488 | #endif | 3488 | } |
3489 | } | 3489 | if (m_doAnnotation) |
3490 | if (m_doAnnotation) | 3490 | { |
3491 | { | 3491 | //addAnno(wrd, "Need to be able to edit this", posn); |
3492 | //addAnno(wrd, "Need to be able to edit this", posn); | 3492 | m_annoWin->setName(line); |
3493 | m_annoWin->setName(line); | 3493 | m_annoWin->setAnno(""); |
3494 | m_annoWin->setAnno(""); | 3494 | m_annoWin->setPosn(posn); |
3495 | m_annoWin->setPosn(posn); | 3495 | m_annoIsEditing = true; |
3496 | m_annoIsEditing = true; | 3496 | #ifdef USEQPE |
3497 | #ifdef USEQPE | 3497 | Global::showInputMethod(); |
3498 | Global::showInputMethod(); | 3498 | #endif |
3499 | #endif | 3499 | editorStack->raiseWidget( m_annoWin ); |
3500 | editorStack->raiseWidget( m_annoWin ); | 3500 | } |
3501 | } | 3501 | #ifdef USEQPE |
3502 | #ifdef USEQPE | 3502 | if (m_doDictionary) |
3503 | if (m_doDictionary) | 3503 | { |
3504 | { | 3504 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) |
3505 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) | 3505 | { |
3506 | { | 3506 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); |
3507 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); | 3507 | e << wrd; |
3508 | e << wrd; | 3508 | } |
3509 | } | 3509 | } |
3510 | } | 3510 | #endif |
3511 | #endif | 3511 | } |
3512 | } | 3512 | |
3513 | 3513 | void QTReaderApp::doAction(ActionTypes a, QKeyEvent* e) | |
3514 | void QTReaderApp::doAction(ActionTypes a, QKeyEvent* e) | 3514 | { |
3515 | { | 3515 | if (a == 0) |
3516 | if (a == 0) | 3516 | { |
3517 | { | 3517 | e->ignore(); |
3518 | e->ignore(); | 3518 | } |
3519 | } | 3519 | else |
3520 | else | 3520 | { |
3521 | { | 3521 | e->accept(); |
3522 | e->accept(); | 3522 | //qDebug("Accepted"); |
3523 | //qDebug("Accepted"); | 3523 | switch (a) |
3524 | switch (a) | 3524 | { |
3525 | { | 3525 | case cesOpenFile: |
3526 | case cesOpenFile: | 3526 | { |
3527 | { | 3527 | fileOpen(); |
3528 | fileOpen(); | 3528 | } |
3529 | } | 3529 | break; |
3530 | break; | 3530 | case cesAutoScroll: |
3531 | case cesAutoScroll: | 3531 | { |
3532 | { | 3532 | reader->setautoscroll(!reader->m_autoScroll); |
3533 | reader->setautoscroll(!reader->m_autoScroll); | 3533 | setScrollState(reader->m_autoScroll); |
3534 | setScrollState(reader->m_autoScroll); | 3534 | } |
3535 | } | 3535 | break; |
3536 | break; | 3536 | case cesActionMark: |
3537 | case cesActionMark: | 3537 | { |
3538 | { | 3538 | addbkmk(); |
3539 | addbkmk(); | 3539 | } |
3540 | } | 3540 | break; |
3541 | break; | 3541 | case cesFullScreen: |
3542 | case cesFullScreen: | 3542 | { |
3543 | { | 3543 | m_actFullscreen->setOn(!m_fullscreen); |
3544 | m_actFullscreen->setOn(!m_fullscreen); | 3544 | } |
3545 | } | 3545 | break; |
3546 | break; | 3546 | case cesActionAnno: |
3547 | case cesActionAnno: | 3547 | { |
3548 | { | 3548 | addanno(); |
3549 | addanno(); | 3549 | } |
3550 | } | 3550 | break; |
3551 | break; | 3551 | case cesZoomIn: |
3552 | case cesZoomIn: | 3552 | zoomin(); |
3553 | zoomin(); | 3553 | break; |
3554 | break; | 3554 | case cesZoomOut: |
3555 | case cesZoomOut: | 3555 | zoomout(); |
3556 | zoomout(); | 3556 | break; |
3557 | break; | 3557 | case cesBack: |
3558 | case cesBack: | 3558 | reader->goBack(); |
3559 | reader->goBack(); | 3559 | break; |
3560 | break; | 3560 | case cesForward: |
3561 | case cesForward: | 3561 | reader->goForward(); |
3562 | reader->goForward(); | 3562 | break; |
3563 | break; | 3563 | case cesHome: |
3564 | case cesHome: | 3564 | reader->goHome(); |
3565 | reader->goHome(); | 3565 | break; |
3566 | break; | 3566 | case cesPageUp: |
3567 | case cesPageUp: | 3567 | reader->dopageup(); |
3568 | reader->dopageup(); | 3568 | break; |
3569 | break; | 3569 | case cesPageDown: |
3570 | case cesPageDown: | 3570 | reader->dopagedn(); |
3571 | reader->dopagedn(); | 3571 | break; |
3572 | break; | 3572 | case cesLineUp: |
3573 | case cesLineUp: | 3573 | reader->lineUp(); |
3574 | reader->lineUp(); | 3574 | break; |
3575 | break; | 3575 | case cesLineDown: |
3576 | case cesLineDown: | 3576 | reader->lineDown(); |
3577 | reader->lineDown(); | 3577 | break; |
3578 | break; | 3578 | case cesStartDoc: |
3579 | case cesStartDoc: | 3579 | gotoStart(); |
3580 | gotoStart(); | 3580 | break; |
3581 | break; | 3581 | case cesEndDoc: |
3582 | case cesEndDoc: | 3582 | gotoEnd(); |
3583 | gotoEnd(); | 3583 | break; |
3584 | break; | 3584 | default: |
3585 | default: | 3585 | qDebug("Unknown ActionType:%u", a); |
3586 | qDebug("Unknown ActionType:%u", a); | 3586 | break; |
3587 | break; | 3587 | } |
3588 | } | 3588 | } |
3589 | } | 3589 | } |
3590 | } | 3590 | |
3591 | 3591 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } | |
3592 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } | 3592 | void QTReaderApp::restoreFocus() { reader->setFocus(); } |
3593 | void QTReaderApp::restoreFocus() { reader->setFocus(); } | 3593 | |
3594 | 3594 | void QTReaderApp::SaveConfig() | |
3595 | void QTReaderApp::SaveConfig() | 3595 | { |
3596 | { | 3596 | m_nRegAction = cSetConfigName; |
3597 | m_nRegAction = cSetConfigName; | 3597 | regEdit->setText(reader->m_string); |
3598 | regEdit->setText(reader->m_string); | 3598 | do_regedit(); |
3599 | do_regedit(); | 3599 | } |
3600 | } | 3600 | |
3601 | 3601 | void QTReaderApp::do_saveconfig(const QString& _txt, bool full) | |
3602 | void QTReaderApp::do_saveconfig(const QString& _txt, bool full) | 3602 | { |
3603 | { | 3603 | // qDebug("do_saveconfig:%s", (const char*)_txt); |
3604 | // qDebug("do_saveconfig:%s", (const char*)_txt); | 3604 | #ifdef USEQPE |
3605 | #ifdef USEQPE | 3605 | QString configname; |
3606 | QString configname; | 3606 | Config::Domain dom; |
3607 | Config::Domain dom; | 3607 | |
3608 | 3608 | if (full) | |
3609 | if (full) | 3609 | { |
3610 | { | 3610 | configname = _txt; |
3611 | configname = _txt; | 3611 | dom = Config::User; |
3612 | dom = Config::User; | 3612 | } |
3613 | } | 3613 | else |
3614 | else | 3614 | { |
3615 | { | 3615 | configname = Global::applicationFileName(APPDIR "/configs", _txt); |
3616 | configname = Global::applicationFileName(APPDIR "/configs", _txt); | 3616 | dom = Config::File; |
3617 | dom = Config::File; | 3617 | } |
3618 | } | 3618 | |
3619 | 3619 | Config config(configname, dom); | |
3620 | Config config(configname, dom); | 3620 | config.setGroup( "View" ); |
3621 | config.setGroup( "View" ); | 3621 | |
3622 | 3622 | #else | |
3623 | #else | 3623 | QFileInfo fi; |
3624 | QFileInfo fi; | 3624 | if (full) |
3625 | if (full) | 3625 | { |
3626 | { | 3626 | // qDebug("full:%s", (const char*)_txt); |
3627 | // qDebug("full:%s", (const char*)_txt); | 3627 | QDir d = QDir::home(); // "/" |
3628 | QDir d = QDir::home(); // "/" | 3628 | if ( !d.cd(_txt) ) |
3629 | if ( !d.cd(_txt) ) | 3629 | { // "/tmp" |
3630 | { // "/tmp" | 3630 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); |
3631 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); | 3631 | d = QDir::home(); |
3632 | d = QDir::home(); | 3632 | d.mkdir(_txt); |
3633 | d.mkdir(_txt); | 3633 | d.cd(_txt); |
3634 | d.cd(_txt); | 3634 | } |
3635 | } | 3635 | fi.setFile(d, INIFILE); |
3636 | fi.setFile(d, INIFILE); | 3636 | } |
3637 | } | 3637 | else |
3638 | else | 3638 | { |
3639 | { | 3639 | QDir d = QDir::home(); // "/" |
3640 | QDir d = QDir::home(); // "/" | 3640 | if ( !d.cd(APPDIR) ) |
3641 | if ( !d.cd(APPDIR) ) | 3641 | { // "/tmp" |
3642 | { // "/tmp" | 3642 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
3643 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 3643 | d = QDir::home(); |
3644 | d = QDir::home(); | 3644 | d.mkdir(APPDIR); |
3645 | d.mkdir(APPDIR); | 3645 | d.cd(APPDIR); |
3646 | d.cd(APPDIR); | 3646 | } |
3647 | } | 3647 | if ( !d.cd("configs") ) |
3648 | if ( !d.cd("configs") ) | 3648 | { // "/tmp" |
3649 | { // "/tmp" | 3649 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); |
3650 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); | 3650 | d = QDir::home(); |
3651 | d = QDir::home(); | 3651 | d.cd(APPDIR); |
3652 | d.cd(APPDIR); | 3652 | d.mkdir("configs"); |
3653 | d.mkdir("configs"); | 3653 | d.cd("configs"); |
3654 | d.cd("configs"); | 3654 | } |
3655 | } | 3655 | fi.setFile(d, _txt); |
3656 | fi.setFile(d, _txt); | 3656 | } |
3657 | } | 3657 | //qDebug("Path:%s", (const char*)fi.absFilePath()); |
3658 | //qDebug("Path:%s", (const char*)fi.absFilePath()); | 3658 | Config config(fi.absFilePath()); |
3659 | Config config(fi.absFilePath()); | 3659 | #endif |
3660 | #endif | 3660 | |
3661 | 3661 | ||
3662 | 3662 | config.writeEntry( "StripCr", reader->bstripcr ); | |
3663 | config.writeEntry( "StripCr", reader->bstripcr ); | 3663 | config.writeEntry( "AutoFmt", reader->bautofmt ); |
3664 | config.writeEntry( "AutoFmt", reader->bautofmt ); | 3664 | config.writeEntry( "TextFmt", reader->btextfmt ); |
3665 | config.writeEntry( "TextFmt", reader->btextfmt ); | 3665 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
3666 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 3666 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
3667 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 3667 | config.writeEntry( "Depluck", reader->bdepluck ); |
3668 | config.writeEntry( "Depluck", reader->bdepluck ); | 3668 | config.writeEntry( "Dejpluck", reader->bdejpluck ); |
3669 | config.writeEntry( "Dejpluck", reader->bdejpluck ); | 3669 | config.writeEntry( "OneSpace", reader->bonespace ); |
3670 | config.writeEntry( "OneSpace", reader->bonespace ); | 3670 | config.writeEntry( "Unindent", reader->bunindent ); |
3671 | config.writeEntry( "Unindent", reader->bunindent ); | 3671 | config.writeEntry( "Repara", reader->brepara ); |
3672 | config.writeEntry( "Repara", reader->brepara ); | 3672 | config.writeEntry( "DoubleSpace", reader->bdblspce ); |
3673 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | 3673 | config.writeEntry( "Indent", reader->bindenter ); |
3674 | config.writeEntry( "Indent", reader->bindenter ); | 3674 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); |
3675 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | 3675 | config.writeEntry( "ScrollDelay", reader->m_delay); |
3676 | config.writeEntry( "ScrollDelay", reader->m_delay); | 3676 | if (full) |
3677 | if (full) | 3677 | { |
3678 | { | 3678 | config.writeEntry("Debounce", m_debounce); |
3679 | config.writeEntry("Debounce", m_debounce); | 3679 | config.writeEntry("FloatDialogs", m_bFloatingDialog); |
3680 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | 3680 | reader->m_lastposn = reader->pagelocate(); |
3681 | reader->m_lastposn = reader->pagelocate(); | 3681 | config.writeEntry( "LastFile", reader->m_lastfile ); |
3682 | config.writeEntry( "LastFile", reader->m_lastfile ); | 3682 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
3683 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 3683 | } |
3684 | } | 3684 | config.writeEntry( "PageMode", reader->m_bpagemode ); |
3685 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 3685 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); |
3686 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 3686 | config.writeEntry( "SwapMouse", reader->m_swapmouse); |
3687 | config.writeEntry( "SwapMouse", reader->m_swapmouse); | 3687 | config.writeEntry( "Fontname", reader->m_fontname ); |
3688 | config.writeEntry( "Fontname", reader->m_fontname ); | 3688 | config.writeEntry( "Encoding", reader->m_encd ); |
3689 | config.writeEntry( "Encoding", reader->m_encd ); | 3689 | config.writeEntry( "CharSpacing", reader->m_charpc ); |
3690 | config.writeEntry( "CharSpacing", reader->m_charpc ); | 3690 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); |
3691 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | 3691 | config.writeEntry( "Margin", (int)reader->m_border ); |
3692 | config.writeEntry( "Margin", (int)reader->m_border ); | 3692 | config.writeEntry( "TargetApp", m_targetapp ); |
3693 | config.writeEntry( "TargetApp", m_targetapp ); | 3693 | config.writeEntry( "TargetMsg", m_targetmsg ); |
3694 | config.writeEntry( "TargetMsg", m_targetmsg ); | 3694 | #ifdef _SCROLLPIPE |
3695 | #ifdef _SCROLLPIPE | 3695 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); |
3696 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); | 3696 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); |
3697 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | 3697 | #endif |
3698 | #endif | 3698 | config.writeEntry( "TwoTouch", m_twoTouch ); |
3699 | config.writeEntry( "TwoTouch", m_twoTouch ); | 3699 | config.writeEntry( "Annotation", m_doAnnotation); |
3700 | config.writeEntry( "Annotation", m_doAnnotation); | 3700 | config.writeEntry( "Dictionary", m_doDictionary); |
3701 | config.writeEntry( "Dictionary", m_doDictionary); | 3701 | config.writeEntry( "Clipboard", m_doClipboard); |
3702 | config.writeEntry( "Clipboard", m_doClipboard); | 3702 | config.writeEntry( "SpaceTarget", m_spaceTarget); |
3703 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 3703 | config.writeEntry( "EscapeTarget", m_escapeTarget); |
3704 | config.writeEntry( "EscapeTarget", m_escapeTarget); | 3704 | config.writeEntry( "ReturnTarget", m_returnTarget); |
3705 | config.writeEntry( "ReturnTarget", m_returnTarget); | 3705 | config.writeEntry( "LeftTarget", m_leftTarget); |
3706 | config.writeEntry( "LeftTarget", m_leftTarget); | 3706 | config.writeEntry( "RightTarget", m_rightTarget); |
3707 | config.writeEntry( "RightTarget", m_rightTarget); | 3707 | config.writeEntry( "UpTarget", m_upTarget); |
3708 | config.writeEntry( "UpTarget", m_upTarget); | 3708 | config.writeEntry( "DownTarget", m_downTarget); |
3709 | config.writeEntry( "DownTarget", m_downTarget); | 3709 | config.writeEntry("LeftScroll", m_leftScroll); |
3710 | config.writeEntry("LeftScroll", m_leftScroll); | 3710 | config.writeEntry("RightScroll", m_rightScroll); |
3711 | config.writeEntry("RightScroll", m_rightScroll); | 3711 | config.writeEntry("UpScroll", m_upScroll); |
3712 | config.writeEntry("UpScroll", m_upScroll); | 3712 | config.writeEntry("DownScroll", m_downScroll); |
3713 | config.writeEntry("DownScroll", m_downScroll); | 3713 | #ifdef REPALM |
3714 | #ifdef REPALM | 3714 | config.writeEntry( "Repalm", reader->brepalm ); |
3715 | config.writeEntry( "Repalm", reader->brepalm ); | 3715 | #endif |
3716 | #endif | 3716 | config.writeEntry( "Remap", reader->bremap ); |
3717 | config.writeEntry( "Remap", reader->bremap ); | 3717 | config.writeEntry( "Peanut", reader->bpeanut ); |
3718 | config.writeEntry( "Peanut", reader->bpeanut ); | 3718 | config.writeEntry( "MakeBold", reader->bmakebold ); |
3719 | config.writeEntry( "MakeBold", reader->bmakebold ); | 3719 | config.writeEntry( "Continuous", reader->m_continuousDocument ); |
3720 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | 3720 | config.writeEntry( "FullJust", reader->bfulljust ); |
3721 | config.writeEntry( "FullJust", reader->bfulljust ); | 3721 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); |
3722 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); | 3722 | config.writeEntry( "ExtraLead", reader->getlead() ); |
3723 | config.writeEntry( "ExtraLead", reader->getlead() ); | 3723 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); |
3724 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); | 3724 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); |
3725 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); | 3725 | if (full) |
3726 | if (full) | 3726 | { |
3727 | { | 3727 | config.setGroup( "Toolbar" ); |
3728 | config.setGroup( "Toolbar" ); | 3728 | config.writeEntry("Movable", m_tbmovesave); |
3729 | config.writeEntry("Movable", m_tbmovesave); | 3729 | config.writeEntry("Policy", m_tbpolsave); |
3730 | config.writeEntry("Policy", m_tbpolsave); | 3730 | config.writeEntry("Position", m_tbposition); |
3731 | config.writeEntry("Position", m_tbposition); | 3731 | #ifndef USEQPE |
3732 | #ifndef USEQPE | 3732 | config.setGroup( "Geometry" ); |
3733 | config.setGroup( "Geometry" ); | 3733 | config.writeEntry( "x", x() ); |
3734 | config.writeEntry( "x", x() ); | 3734 | config.writeEntry( "y", y() ); |
3735 | config.writeEntry( "y", y() ); | 3735 | config.writeEntry( "width", width() ); |
3736 | config.writeEntry( "width", width() ); | 3736 | config.writeEntry( "height", height() ); |
3737 | config.writeEntry( "height", height() ); | 3737 | #endif |
3738 | #endif | 3738 | } |
3739 | } | 3739 | } |
3740 | } | 3740 | |
3741 | 3741 | /* | |
3742 | /* | 3742 | void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen) |
3743 | void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen) | 3743 | { |
3744 | { | 3744 | unsigned short sdlen; |
3745 | unsigned short sdlen; | 3745 | memcpy(&sdlen, _sd, sizeof(sdlen)); |
3746 | memcpy(&sdlen, _sd, sizeof(sdlen)); | 3746 | sdlen -= sizeof(sdlen); |
3747 | sdlen -= sizeof(sdlen); | 3747 | _sd += sizeof(sdlen); |
3748 | _sd += sizeof(sdlen); | 3748 | statedata* sd; |
3749 | statedata* sd; | 3749 | char* data; |
3750 | char* data; | 3750 | if (sdlen < sizeof(statedata)+1) |
3751 | if (sdlen < sizeof(statedata)+1) | 3751 | { |
3752 | { | 3752 | sdlen = sizeof(statedata)+1; |
3753 | sdlen = sizeof(statedata)+1; | 3753 | } |
3754 | } | 3754 | data = new char[sdlen]; |
3755 | data = new char[sdlen]; | 3755 | sd = (statedata*)data; |
3756 | sd = (statedata*)data; | 3756 | memcpy(sd, _sd, sdlen); |
3757 | memcpy(sd, _sd, sdlen); | 3757 | data[sdlen] = 0; |
3758 | data[sdlen] = 0; | 3758 | reader->setstate(*sd); |
3759 | reader->setstate(*sd); | 3759 | delete [] data; |
3760 | delete [] data; | 3760 | } |
3761 | } | 3761 | |
3762 | 3762 | void QTReaderApp::getstate(unsigned char*& data, unsigned short& len) | |
3763 | void QTReaderApp::getstate(unsigned char*& data, unsigned short& len) | 3763 | { |
3764 | { | 3764 | unsigned char* olddata = data; |
3765 | unsigned char* olddata = data; | 3765 | unsigned short oldlen = len; |
3766 | unsigned short oldlen = len; | 3766 | len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length(); |
3767 | len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length(); | 3767 | data = new unsigned char[len]; |
3768 | data = new unsigned char[len]; | 3768 | memcpy(data, olddata, oldlen); |
3769 | memcpy(data, olddata, oldlen); | 3769 | delete [] olddata; |
3770 | delete [] olddata; | 3770 | memcpy(data+oldlen, &len, sizeof(len)); |
3771 | memcpy(data+oldlen, &len, sizeof(len)); | 3771 | statedata* sd = (statedata*)(data+oldlen+sizeof(unsigned short)); |
3772 | statedata* sd = (statedata*)(data+oldlen+sizeof(unsigned short)); | 3772 | |
3773 | 3773 | sd->bstripcr = reader->bstripcr; | |
3774 | sd->bstripcr = reader->bstripcr; | 3774 | sd->btextfmt = reader->btextfmt; |
3775 | sd->btextfmt = reader->btextfmt; | 3775 | sd->bautofmt = reader->bautofmt; |
3776 | sd->bautofmt = reader->bautofmt; | 3776 | sd->bstriphtml = reader->bstriphtml; |
3777 | sd->bstriphtml = reader->bstriphtml; | 3777 | sd->bpeanut = reader->bpeanut; |
3778 | sd->bpeanut = reader->bpeanut; | 3778 | sd->bdehyphen = reader->bdehyphen; |
3779 | sd->bdehyphen = reader->bdehyphen; | 3779 | sd->bdepluck = reader->bdepluck; |
3780 | sd->bdepluck = reader->bdepluck; | 3780 | sd->bdejpluck = reader->bdejpluck; |
3781 | sd->bdejpluck = reader->bdejpluck; | 3781 | sd->bonespace = reader->bonespace; |
3782 | sd->bonespace = reader->bonespace; | 3782 | sd->bunindent = reader->bunindent; |
3783 | sd->bunindent = reader->bunindent; | 3783 | sd->brepara = reader->brepara; |
3784 | sd->brepara = reader->brepara; | 3784 | sd->bdblspce = reader->bdblspce; |
3785 | sd->bdblspce = reader->bdblspce; | 3785 | sd->m_bpagemode = reader->m_bpagemode; |
3786 | sd->m_bpagemode = reader->m_bpagemode; | 3786 | sd->m_bMonoSpaced = reader->m_bMonoSpaced; |
3787 | sd->m_bMonoSpaced = reader->m_bMonoSpaced; | 3787 | sd->bremap = reader->bremap; |
3788 | sd->bremap = reader->bremap; | 3788 | sd->bmakebold = reader->bmakebold; |
3789 | sd->bmakebold = reader->bmakebold; | 3789 | sd->Continuous = reader->m_continuousDocument; |
3790 | sd->Continuous = reader->m_continuousDocument; | 3790 | #ifdef REPALM |
3791 | #ifdef REPALM | 3791 | sd->brepalm = reader->brepalm; |
3792 | sd->brepalm = reader->brepalm; | 3792 | #endif |
3793 | #endif | 3793 | sd->bindenter = reader->bindenter; |
3794 | sd->bindenter = reader->bindenter; | 3794 | sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize() |
3795 | sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize() | 3795 | sd->m_encd = reader->m_encd; |
3796 | sd->m_encd = reader->m_encd; | 3796 | sd->m_charpc = reader->m_charpc; |
3797 | sd->m_charpc = reader->m_charpc; | 3797 | strcpy(sd->m_fontname, reader->m_fontname.latin1()); |
3798 | strcpy(sd->m_fontname, reader->m_fontname.latin1()); | 3798 | } |
3799 | } | 3799 | */ |
3800 | */ | 3800 | #ifdef _SCRIPT |
3801 | #ifdef _SCRIPT | 3801 | void QTReaderApp::RunScript() |
3802 | void QTReaderApp::RunScript() | 3802 | { |
3803 | { | 3803 | fileBrowser* fb = new fileBrowser(this,"OpieReader",!m_bFloatingDialog, |
3804 | fileBrowser* fb = new fileBrowser(this,"OpieReader",!m_bFloatingDialog, | 3804 | 0, |
3805 | 0, | 3805 | // WStyle_Customize | WStyle_NoBorderEx, |
3806 | // WStyle_Customize | WStyle_NoBorderEx, | 3806 | "*", Global::applicationFileName(APPDIR "/scripts", "")); |
3807 | "*", Global::applicationFileName(APPDIR "/scripts", "")); | 3807 | |
3808 | 3808 | QString fn; | |
3809 | QString fn; | 3809 | if (fb->exec()) |
3810 | if (fb->exec()) | 3810 | { |
3811 | { | 3811 | fn = fb->fileList[0]; |
3812 | fn = fb->fileList[0]; | 3812 | } |
3813 | } | 3813 | delete fb; |
3814 | delete fb; | 3814 | if ( !fn.isEmpty() && fork() == 0 ) |
3815 | if ( !fn.isEmpty() && fork() == 0 ) | 3815 | { |
3816 | { | 3816 | execlp((const char *)fn,(const char *)fn,NULL); |
3817 | execlp((const char *)fn,(const char *)fn,NULL); | 3817 | } |
3818 | } | 3818 | } |
3819 | } | 3819 | |
3820 | 3820 | void QTReaderApp::SaveScript(const char* sname) | |
3821 | void QTReaderApp::SaveScript(const char* sname) | 3821 | { |
3822 | { | 3822 | FILE* f = fopen(sname,"w"); |
3823 | FILE* f = fopen(sname,"w"); | 3823 | if (f != NULL) |
3824 | if (f != NULL) | 3824 | { |
3825 | { | 3825 | #ifdef OPIE |
3826 | #ifdef OPIE | 3826 | fprintf(f, "#!/bin/sh\nmsg() {\n\tqcop QPE/Application/reader \"$1\" \"$2\" \"$3\"\n}\n"); |
3827 | fprintf(f, "#!/bin/sh\nmsg() {\n\tqcop QPE/Application/reader \"$1\" \"$2\" \"$3\"\n}\n"); | 3827 | #else |
3828 | #else | 3828 | fprintf(f, "#!/bin/bash\nmsg() {\n\tqcop QPE/Application/uqtreader \"$1\" \"$2\" \"$3\"\n}\n"); |
3829 | fprintf(f, "#!/bin/bash\nmsg() {\n\tqcop QPE/Application/uqtreader \"$1\" \"$2\" \"$3\"\n}\n"); | 3829 | #endif |
3830 | #endif | 3830 | fprintf(f, "msg \"Update(int)\" 0\n"); |
3831 | fprintf(f, "msg \"Update(int)\" 0\n"); | 3831 | fprintf(f, "msg \"Layout/StripCR(int)\" %d\n", (reader->bstripcr) ? 1:0); |
3832 | fprintf(f, "msg \"Layout/StripCR(int)\" %d\n", (reader->bstripcr) ? 1:0); | 3832 | if (reader->btextfmt) fprintf(f, "msg \"Markup(QString)\" \"Text\"\n"); |
3833 | if (reader->btextfmt) fprintf(f, "msg \"Markup(QString)\" \"Text\"\n"); | 3833 | else if (reader->bautofmt) fprintf(f, "msg \"Markup(QString)\" \"Auto\"\n"); |
3834 | else if (reader->bautofmt) fprintf(f, "msg \"Markup(QString)\" \"Auto\"\n"); | 3834 | else if (reader->bstriphtml) fprintf(f, "msg \"Markup(QString)\" \"HTML\"\n"); |
3835 | else if (reader->bstriphtml) fprintf(f, "msg \"Markup(QString)\" \"HTML\"\n"); | 3835 | else if (reader->bpeanut) fprintf(f, "msg \"Markup(QString)\" \"Peanut/PML\"\n"); |
3836 | else if (reader->bpeanut) fprintf(f, "msg \"Markup(QString)\" \"Peanut/PML\"\n"); | 3836 | else fprintf(f, "msg \"Markup(QString)\" \"None\"\n"); |
3837 | else fprintf(f, "msg \"Markup(QString)\" \"None\"\n"); | 3837 | fprintf(f, "msg \"Layout/Dehyphen(int)\" %d\n", (reader->bdehyphen) ? 1:0); |
3838 | fprintf(f, "msg \"Layout/Dehyphen(int)\" %d\n", (reader->bdehyphen) ? 1:0); | 3838 | fprintf(f, "msg \"Layout/Depluck(int)\" %d\n", (reader->bdepluck) ? 1:0); |
3839 | fprintf(f, "msg \"Layout/Depluck(int)\" %d\n", (reader->bdepluck) ? 1:0); | 3839 | fprintf(f, "msg \"Layout/Dejpluck(int)\" %d\n", (reader->bdejpluck) ? 1:0); |
3840 | fprintf(f, "msg \"Layout/Dejpluck(int)\" %d\n", (reader->bdejpluck) ? 1:0); | 3840 | fprintf(f, "msg \"Layout/SingleSpace(int)\" %d\n", (reader->bonespace) ? 1:0); |
3841 | fprintf(f, "msg \"Layout/SingleSpace(int)\" %d\n", (reader->bonespace) ? 1:0); | 3841 | fprintf(f, "msg \"Layout/Unindent(int)\" %d\n", (reader->bunindent) ? 1:0); |
3842 | fprintf(f, "msg \"Layout/Unindent(int)\" %d\n", (reader->bunindent) ? 1:0); | 3842 | fprintf(f, "msg \"Layout/Re-paragraph(int)\" %d\n", (reader->brepara) ? 1:0); |
3843 | fprintf(f, "msg \"Layout/Re-paragraph(int)\" %d\n", (reader->brepara) ? 1:0); | 3843 | fprintf(f, "msg \"Layout/DoubleSpace(int)\" %d\n", (reader->bdblspce) ? 1:0); |
3844 | fprintf(f, "msg \"Layout/DoubleSpace(int)\" %d\n", (reader->bdblspce) ? 1:0); | 3844 | fprintf(f, "msg \"Layout/Indent(int)\" %d\n", reader->bindenter); |
3845 | fprintf(f, "msg \"Layout/Indent(int)\" %d\n", reader->bindenter); | 3845 | fprintf(f, "msg \"Format/SetFont(QString,int)\" \"%s\" %d\n", (const char*)reader->m_fontname, reader->m_textsize); |
3846 | fprintf(f, "msg \"Format/SetFont(QString,int)\" \"%s\" %d\n", (const char*)reader->m_fontname, reader->m_textsize); | 3846 | fprintf(f, "msg \"Navigation/Page/LineScroll(int)\" %d\n", (reader->m_bpagemode) ? 1:0); |
3847 | fprintf(f, "msg \"Navigation/Page/LineScroll(int)\" %d\n", (reader->m_bpagemode) ? 1:0); | 3847 | fprintf(f, "msg \"Format/Ideogram/Word(int)\" %d\n", (reader->m_bMonoSpaced) ? 1:0); |
3848 | fprintf(f, "msg \"Format/Ideogram/Word(int)\" %d\n", (reader->m_bMonoSpaced) ? 1:0); | 3848 | fprintf(f, "msg \"Format/Encoding(QString)\" \"%s\"\n", (const char*)m_EncodingAction[reader->m_encd]->text()); |
3849 | fprintf(f, "msg \"Format/Encoding(QString)\" \"%s\"\n", (const char*)m_EncodingAction[reader->m_encd]->text()); | 3849 | fprintf(f, "msg \"Format/SetWidth(int)\" %d\n", reader->m_charpc); |
3850 | fprintf(f, "msg \"Format/SetWidth(int)\" %d\n", reader->m_charpc); | 3850 | fprintf(f, "msg \"Navigation/SetOverlap(int)\" %d\n", reader->m_overlap); |
3851 | fprintf(f, "msg \"Navigation/SetOverlap(int)\" %d\n", reader->m_overlap); | 3851 | fprintf(f, "msg \"Layout/Remap(int)\" %d\n", (reader->bremap) ? 1:0); |
3852 | fprintf(f, "msg \"Layout/Remap(int)\" %d\n", (reader->bremap) ? 1:0); | 3852 | fprintf(f, "msg \"Layout/Embolden(int)\" %d\n", (reader->bmakebold) ? 1:0); |
3853 | fprintf(f, "msg \"Layout/Embolden(int)\" %d\n", (reader->bmakebold) ? 1:0); | 3853 | fprintf(f, "msg \"File/Continuous(int)\" %d\n", (reader->m_continuousDocument) ? 1:0); |
3854 | fprintf(f, "msg \"File/Continuous(int)\" %d\n", (reader->m_continuousDocument) ? 1:0); | 3854 | fprintf(f, "msg \"File/SetDictionary(QString)\" \"%s/%s\"\n", (const char *)m_targetapp, (const char *)m_targetmsg); |
3855 | fprintf(f, "msg \"File/SetDictionary(QString)\" \"%s/%s\"\n", (const char *)m_targetapp, (const char *)m_targetmsg); | 3855 | #ifdef _SCROLLPIPE |
3856 | #ifdef _SCROLLPIPE | 3856 | fprintf(f, "msg \"File/SetScrollTarget(QString)\" \"%s\"\n", (const char *)reader->m_pipetarget); |
3857 | fprintf(f, "msg \"File/SetScrollTarget(QString)\" \"%s\"\n", (const char *)reader->m_pipetarget); | 3857 | #endif |
3858 | #endif | 3858 | fprintf(f, "msg \"File/Two/OneTouch(int)\" %d\n", (m_twoTouch) ? 1:0); |
3859 | fprintf(f, "msg \"File/Two/OneTouch(int)\" %d\n", (m_twoTouch) ? 1:0); | 3859 | fprintf(f, "msg \"Target/Annotation(int)\" %d\n", (m_doAnnotation) ? 1:0); |
3860 | fprintf(f, "msg \"Target/Annotation(int)\" %d\n", (m_doAnnotation) ? 1:0); | 3860 | fprintf(f, "msg \"Target/Dictionary(int)\" %d\n", (m_doDictionary) ? 1:0); |
3861 | fprintf(f, "msg \"Target/Dictionary(int)\" %d\n", (m_doDictionary) ? 1:0); | 3861 | fprintf(f, "msg \"Target/Clipboard(int)\" %d\n", (m_doClipboard) ? 1:0); |
3862 | fprintf(f, "msg \"Target/Clipboard(int)\" %d\n", (m_doClipboard) ? 1:0); | 3862 | fprintf(f, "msg \"File/Action(QString)\" \"%s\"\n", (const char *)m_buttonAction[m_spaceTarget]->text()); |
3863 | fprintf(f, "msg \"File/Action(QString)\" \"%s\"\n", (const char *)m_buttonAction[m_spaceTarget]->text()); | 3863 | fprintf(f, "msg \"Update(int)\" 1\n"); |
3864 | fprintf(f, "msg \"Update(int)\" 1\n"); | 3864 | fprintf(f, "msg \"info(QString)\" \"All Done\"\n"); |
3865 | fprintf(f, "msg \"info(QString)\" \"All Done\"\n"); | 3865 | fclose(f); |
3866 | fclose(f); | 3866 | chmod(sname, S_IXUSR | S_IXGRP | S_IXOTH); |
3867 | chmod(sname, S_IXUSR | S_IXGRP | S_IXOTH); | 3867 | } |
3868 | } | 3868 | } |
3869 | } | 3869 | |
3870 | 3870 | void QTReaderApp::SaveConfig() | |
3871 | void QTReaderApp::SaveConfig() | 3871 | { |
3872 | { | 3872 | m_nRegAction = cSetConfigName; |
3873 | m_nRegAction = cSetConfigName; | 3873 | regEdit->setText(""); |
3874 | regEdit->setText(""); | 3874 | do_regedit(); |
3875 | do_regedit(); | 3875 | } |
3876 | } | 3876 | |
3877 | 3877 | void QTReaderApp::do_saveconfig(const QString& _txt) | |
3878 | void QTReaderApp::do_saveconfig(const QString& _txt) | 3878 | { |
3879 | { | 3879 | SaveScript(Global::applicationFileName(APPDIR "/scripts", _txt)); |
3880 | SaveScript(Global::applicationFileName(APPDIR "/scripts", _txt)); | 3880 | } |
3881 | } | 3881 | #endif |
3882 | #endif | 3882 | |
3883 | 3883 | #ifdef _SCROLLPIPE | |
3884 | #ifdef _SCROLLPIPE | 3884 | void QTReaderApp::setpipetarget() |
3885 | void QTReaderApp::setpipetarget() | 3885 | { |
3886 | { | 3886 | m_nRegAction = cSetPipeTarget; |
3887 | m_nRegAction = cSetPipeTarget; | 3887 | QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget; |
3888 | QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget; | 3888 | regEdit->setText(text); |
3889 | regEdit->setText(text); | 3889 | do_regedit(); |
3890 | do_regedit(); | 3890 | } |
3891 | } | 3891 | |
3892 | 3892 | void QTReaderApp::do_setpipetarget(const QString& _txt) | |
3893 | void QTReaderApp::do_setpipetarget(const QString& _txt) | 3893 | { |
3894 | { | 3894 | reader->m_pipetarget = _txt; |
3895 | reader->m_pipetarget = _txt; | 3895 | } |
3896 | } | 3896 | |
3897 | 3897 | void QTReaderApp::setpause(bool sfs) | |
3898 | void QTReaderApp::setpause(bool sfs) | 3898 | { |
3899 | { | 3899 | reader->m_pauseAfterEachPara = sfs; |
3900 | reader->m_pauseAfterEachPara = sfs; | 3900 | } |
3901 | } | 3901 | #endif |
3902 | #endif | 3902 | |
3903 | 3903 | void QTReaderApp::monospace(bool _b) | |
3904 | void QTReaderApp::monospace(bool _b) | 3904 | { |
3905 | { | 3905 | reader->setmono(_b); |
3906 | reader->setmono(_b); | 3906 | } |
3907 | } | 3907 | |
3908 | 3908 | bool QTReaderApp::readconfig(const QString& _txt, bool full=false) | |
3909 | bool QTReaderApp::readconfig(const QString& _txt, bool full=false) | 3909 | { |
3910 | { | 3910 | #ifdef USEQPE |
3911 | #ifdef USEQPE | 3911 | QString configname; |
3912 | QString configname; | 3912 | Config::Domain dom; |
3913 | Config::Domain dom; | 3913 | |
3914 | 3914 | if (full) | |
3915 | if (full) | 3915 | { |
3916 | { | 3916 | configname = _txt; |
3917 | configname = _txt; | 3917 | dom = Config::User; |
3918 | dom = Config::User; | 3918 | } |
3919 | } | 3919 | else |
3920 | else | 3920 | { |
3921 | { | 3921 | configname = Global::applicationFileName(APPDIR "/configs", _txt); |
3922 | configname = Global::applicationFileName(APPDIR "/configs", _txt); | 3922 | QFileInfo fm(configname); |
3923 | QFileInfo fm(configname); | 3923 | if ( !fm.exists() ) return false; |
3924 | if ( !fm.exists() ) return false; | 3924 | dom = Config::File; |
3925 | dom = Config::File; | 3925 | } |
3926 | } | 3926 | |
3927 | 3927 | Config config(configname, dom); | |
3928 | Config config(configname, dom); | 3928 | config.setGroup( "View" ); |
3929 | config.setGroup( "View" ); | 3929 | |
3930 | 3930 | #else | |
3931 | #else | 3931 | QFileInfo fi; |
3932 | QFileInfo fi; | 3932 | if (full) |
3933 | if (full) | 3933 | { |
3934 | { | 3934 | QDir d = QDir::home(); // "/" |
3935 | QDir d = QDir::home(); // "/" | 3935 | if ( !d.cd(_txt) ) |
3936 | if ( !d.cd(_txt) ) | 3936 | { // "/tmp" |
3937 | { // "/tmp" | 3937 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); |
3938 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); | 3938 | d = QDir::home(); |
3939 | d = QDir::home(); | 3939 | d.mkdir(_txt); |
3940 | d.mkdir(_txt); | 3940 | d.cd(_txt); |
3941 | d.cd(_txt); | 3941 | } |
3942 | } | 3942 | fi.setFile(d, INIFILE); |
3943 | fi.setFile(d, INIFILE); | 3943 | } |
3944 | } | 3944 | else |
3945 | else | 3945 | { |
3946 | { | 3946 | QDir d = QDir::home(); // "/" |
3947 | QDir d = QDir::home(); // "/" | 3947 | if ( !d.cd(APPDIR) ) |
3948 | if ( !d.cd(APPDIR) ) | 3948 | { // "/tmp" |
3949 | { // "/tmp" | 3949 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
3950 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 3950 | d = QDir::home(); |
3951 | d = QDir::home(); | 3951 | d.mkdir(APPDIR); |
3952 | d.mkdir(APPDIR); | 3952 | d.cd(APPDIR); |
3953 | d.cd(APPDIR); | 3953 | } |
3954 | } | 3954 | if ( !d.cd("configs") ) |
3955 | if ( !d.cd("configs") ) | 3955 | { // "/tmp" |
3956 | { // "/tmp" | 3956 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); |
3957 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); | 3957 | d = QDir::home(); |
3958 | d = QDir::home(); | 3958 | d.mkdir("configs"); |
3959 | d.mkdir("configs"); | 3959 | d.cd("configs"); |
3960 | d.cd("configs"); | 3960 | } |
3961 | } | 3961 | fi.setFile(d, _txt); |
3962 | fi.setFile(d, _txt); | 3962 | } |
3963 | } | 3963 | #ifdef _WINDOWS |
3964 | #ifdef _WINDOWS | 3964 | struct stat fnstat; |
3965 | struct stat fnstat; | 3965 | if (stat((const char *)reader->m_lastfile, &fnstat) == 0) return false; // get round fileinfo bug on windows |
3966 | if (stat((const char *)reader->m_lastfile, &fnstat) == 0) return false; // get round fileinfo bug on windows | 3966 | #else |
3967 | #else | 3967 | if (!fi.exists()) return false; |
3968 | if (!fi.exists()) return false; | 3968 | #endif |
3969 | #endif | 3969 | Config config(fi.absFilePath()); |
3970 | Config config(fi.absFilePath()); | 3970 | #endif |
3971 | #endif | 3971 | if (full) |
3972 | if (full) | 3972 | { |
3973 | { | 3973 | config.setGroup("Toolbar"); |
3974 | config.setGroup("Toolbar"); | 3974 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); |
3975 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); | 3975 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); |
3976 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); | 3976 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); |
3977 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | 3977 | } |
3978 | } | 3978 | config.setGroup( "View" ); |
3979 | config.setGroup( "View" ); | 3979 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); |
3980 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); | 3980 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); |
3981 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); | 3981 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); |
3982 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | 3982 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); |
3983 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); | 3983 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); |
3984 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); | 3984 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); |
3985 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | 3985 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); |
3986 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | 3986 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); |
3987 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | 3987 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); |
3988 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 3988 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
3989 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 3989 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); |
3990 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | 3990 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); |
3991 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); | 3991 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); |
3992 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | 3992 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
3993 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 3993 | reader->brepara = config.readBoolEntry( "Repara", false ); |
3994 | reader->brepara = config.readBoolEntry( "Repara", false ); | 3994 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); |
3995 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | 3995 | reader->bindenter = config.readNumEntry( "Indent", 0 ); |
3996 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | 3996 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); |
3997 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | 3997 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); |
3998 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | 3998 | if (full) |
3999 | if (full) | 3999 | { |
4000 | { | 4000 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); |
4001 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | 4001 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
4002 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 4002 | } |
4003 | } | 4003 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
4004 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 4004 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); |
4005 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 4005 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); |
4006 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); | 4006 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
4007 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 4007 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); |
4008 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 4008 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
4009 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 4009 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
4010 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 4010 | reader->m_border = config.readNumEntry( "Margin", 6 ); |
4011 | reader->m_border = config.readNumEntry( "Margin", 6 ); | 4011 | #ifdef REPALM |
4012 | #ifdef REPALM | 4012 | reader->brepalm = config.readBoolEntry( "Repalm", true ); |
4013 | reader->brepalm = config.readBoolEntry( "Repalm", true ); | 4013 | #endif |
4014 | #endif | 4014 | reader->bremap = config.readBoolEntry( "Remap", true ); |
4015 | reader->bremap = config.readBoolEntry( "Remap", true ); | 4015 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); |
4016 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | 4016 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); |
4017 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | 4017 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
4018 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 4018 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
4019 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 4019 | #ifdef _SCROLLPIPE |
4020 | #ifdef _SCROLLPIPE | 4020 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); |
4021 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); | 4021 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); |
4022 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); | 4022 | #endif |
4023 | #endif | 4023 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); |
4024 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | 4024 | m_doAnnotation = config.readBoolEntry( "Annotation", false); |
4025 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | 4025 | m_doDictionary = config.readBoolEntry( "Dictionary", false); |
4026 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | 4026 | m_doClipboard = config.readBoolEntry( "Clipboard", false); |
4027 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | 4027 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); |
4028 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | 4028 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); |
4029 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); | 4029 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); |
4030 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); | 4030 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); |
4031 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); | 4031 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); |
4032 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); | 4032 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); |
4033 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); | 4033 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); |
4034 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | 4034 | |
4035 | 4035 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | |
4036 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | 4036 | m_rightScroll = config.readBoolEntry("RightScroll", false); |
4037 | m_rightScroll = config.readBoolEntry("RightScroll", false); | 4037 | m_upScroll = config.readBoolEntry("UpScroll", true); |
4038 | m_upScroll = config.readBoolEntry("UpScroll", true); | 4038 | m_downScroll = config.readBoolEntry("DownScroll", true); |
4039 | m_downScroll = config.readBoolEntry("DownScroll", true); | 4039 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); |
4040 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); | 4040 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); |
4041 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); | 4041 | reader->setTwoTouch(m_twoTouch); |
4042 | reader->setTwoTouch(m_twoTouch); | 4042 | |
4043 | 4043 | m_touch_action->setOn(m_twoTouch); | |
4044 | m_touch_action->setOn(m_twoTouch); | 4044 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
4045 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 4045 | setfontHelper(reader->m_fontname); |
4046 | setfontHelper(reader->m_fontname); | 4046 | if (full) |
4047 | if (full) | 4047 | { |
4048 | { | 4048 | addtoolbars(&config); |
4049 | addtoolbars(&config); | 4049 | } |
4050 | } | 4050 | reader->setfilter(reader->getfilter()); |
4051 | reader->setfilter(reader->getfilter()); | 4051 | reader->refresh(); |
4052 | reader->refresh(); | 4052 | return true; |
4053 | return true; | 4053 | } |
4054 | } | 4054 | |
4055 | 4055 | bool QTReaderApp::PopulateConfig(const char* tgtdir) | |
4056 | bool QTReaderApp::PopulateConfig(const char* tgtdir) | 4056 | { |
4057 | { | 4057 | bkmkselector->clear(); |
4058 | bkmkselector->clear(); | 4058 | bkmkselector->setText("Cancel"); |
4059 | bkmkselector->setText("Cancel"); | 4059 | #ifndef USEQPE |
4060 | #ifndef USEQPE | 4060 | int cnt = 0; |
4061 | int cnt = 0; | 4061 | |
4062 | 4062 | QDir d = QDir::home(); // "/" | |
4063 | QDir d = QDir::home(); // "/" | 4063 | if ( !d.cd(APPDIR) ) { // "/tmp" |
4064 | if ( !d.cd(APPDIR) ) { // "/tmp" | 4064 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
4065 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 4065 | d = QDir::home(); |
4066 | d = QDir::home(); | 4066 | d.mkdir(APPDIR); |
4067 | d.mkdir(APPDIR); | 4067 | d.cd(APPDIR); |
4068 | d.cd(APPDIR); | 4068 | } |
4069 | } | 4069 | if ( !d.cd(tgtdir) ) { // "/tmp" |
4070 | if ( !d.cd(tgtdir) ) { // "/tmp" | 4070 | qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir ); |
4071 | qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir ); | 4071 | d = QDir::home(); |
4072 | d = QDir::home(); | 4072 | d.mkdir(tgtdir); |
4073 | d.mkdir(tgtdir); | 4073 | d.cd(tgtdir); |
4074 | d.cd(tgtdir); | 4074 | } |
4075 | } | 4075 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
4076 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 4076 | // d.setSorting( QDir::Size | QDir::Reversed ); |
4077 | // d.setSorting( QDir::Size | QDir::Reversed ); | 4077 | |
4078 | 4078 | const QFileInfoList *list = d.entryInfoList(); | |
4079 | const QFileInfoList *list = d.entryInfoList(); | 4079 | QFileInfoListIterator it( *list ); // create list iterator |
4080 | QFileInfoListIterator it( *list ); // create list iterator | 4080 | QFileInfo *fi; // pointer for traversing |
4081 | QFileInfo *fi; // pointer for traversing | 4081 | |
4082 | 4082 | while ( (fi=it.current()) ) { // for each file... | |
4083 | while ( (fi=it.current()) ) { // for each file... | 4083 | |
4084 | 4084 | bkmkselector->insertItem(fi->fileName()); | |
4085 | bkmkselector->insertItem(fi->fileName()); | 4085 | cnt++; |
4086 | cnt++; | 4086 | |
4087 | 4087 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | |
4088 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | 4088 | ++it; // goto next list element |
4089 | ++it; // goto next list element | 4089 | } |
4090 | } | 4090 | |
4091 | 4091 | #else /* USEQPE */ | |
4092 | #else /* USEQPE */ | 4092 | int cnt = 0; |
4093 | int cnt = 0; | 4093 | DIR *d; |
4094 | DIR *d; | 4094 | char* finaldir; |
4095 | char* finaldir; | 4095 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; |
4096 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; | 4096 | strcpy(finaldir, APPDIR); |
4097 | strcpy(finaldir, APPDIR); | 4097 | strcat(finaldir, "/"); |
4098 | strcat(finaldir, "/"); | 4098 | strcat(finaldir, tgtdir); |
4099 | strcat(finaldir, tgtdir); | 4099 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); |
4100 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); | 4100 | |
4101 | 4101 | while(1) | |
4102 | while(1) | 4102 | { |
4103 | { | 4103 | struct dirent* de; |
4104 | struct dirent* de; | 4104 | struct stat buf; |
4105 | struct stat buf; | 4105 | de = readdir(d); |
4106 | de = readdir(d); | 4106 | if (de == NULL) break; |
4107 | if (de == NULL) break; | 4107 | |
4108 | 4108 | if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | |
4109 | if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 4109 | { |
4110 | { | 4110 | bkmkselector->insertItem(de->d_name); |
4111 | bkmkselector->insertItem(de->d_name); | 4111 | cnt++; |
4112 | cnt++; | 4112 | } |
4113 | } | 4113 | } |
4114 | } | 4114 | delete [] finaldir; |
4115 | delete [] finaldir; | 4115 | closedir(d); |
4116 | closedir(d); | 4116 | #endif |
4117 | #endif | 4117 | return (cnt > 0); |
4118 | return (cnt > 0); | 4118 | } |
4119 | } | 4119 | |
4120 | 4120 | void QTReaderApp::LoadConfig() | |
4121 | void QTReaderApp::LoadConfig() | 4121 | { |
4122 | { | 4122 | if (PopulateConfig("configs")) |
4123 | if (PopulateConfig("configs")) | 4123 | { |
4124 | { | 4124 | editorStack->raiseWidget( bkmkselector ); |
4125 | editorStack->raiseWidget( bkmkselector ); | 4125 | hidetoolbars(); |
4126 | hidetoolbars(); | 4126 | m_nBkmkAction = cLdConfig; |
4127 | m_nBkmkAction = cLdConfig; | 4127 | } |
4128 | } | 4128 | else |
4129 | else | 4129 | QMessageBox::information(this, PROGNAME, "No config files"); |
4130 | QMessageBox::information(this, PROGNAME, "No config files"); | 4130 | } |
4131 | } | 4131 | |
4132 | 4132 | void QTReaderApp::TidyConfig() | |
4133 | void QTReaderApp::TidyConfig() | 4133 | { |
4134 | { | 4134 | if (PopulateConfig("configs")) |
4135 | if (PopulateConfig("configs")) | 4135 | { |
4136 | { | 4136 | editorStack->raiseWidget( bkmkselector ); |
4137 | editorStack->raiseWidget( bkmkselector ); | 4137 | hidetoolbars(); |
4138 | hidetoolbars(); | 4138 | m_nBkmkAction = cRmConfig; |
4139 | m_nBkmkAction = cRmConfig; | 4139 | } |
4140 | } | 4140 | else |
4141 | else | 4141 | QMessageBox::information(this, PROGNAME, "No config files"); |
4142 | QMessageBox::information(this, PROGNAME, "No config files"); | 4142 | } |
4143 | } | 4143 | |
4144 | 4144 | void QTReaderApp::ExportLinks() | |
4145 | void QTReaderApp::ExportLinks() | 4145 | { |
4146 | { | 4146 | if (PopulateConfig("urls")) |
4147 | if (PopulateConfig("urls")) | 4147 | { |
4148 | { | 4148 | editorStack->raiseWidget( bkmkselector ); |
4149 | editorStack->raiseWidget( bkmkselector ); | 4149 | hidetoolbars(); |
4150 | hidetoolbars(); | 4150 | m_nBkmkAction = cExportLinks; |
4151 | m_nBkmkAction = cExportLinks; | 4151 | } |
4152 | } | 4152 | else |
4153 | else | 4153 | QMessageBox::information(this, PROGNAME, "No url files"); |
4154 | QMessageBox::information(this, PROGNAME, "No url files"); | 4154 | } |
4155 | } | 4155 | |
4156 | 4156 | void QTReaderApp::OnURLSelected(const QString& href) | |
4157 | void QTReaderApp::OnURLSelected(const QString& href) | 4157 | { |
4158 | { | 4158 | CURLDialog* urld = new CURLDialog(href, false, this); |
4159 | CURLDialog* urld = new CURLDialog(href, false, this); | 4159 | urld->clipboard(m_url_clipboard); |
4160 | urld->clipboard(m_url_clipboard); | 4160 | urld->localfile(m_url_localfile); |
4161 | urld->localfile(m_url_localfile); | 4161 | urld->globalfile(m_url_globalfile); |
4162 | urld->globalfile(m_url_globalfile); | 4162 | if (urld->exec()) |
4163 | if (urld->exec()) | 4163 | { |
4164 | { | 4164 | m_url_clipboard = urld->clipboard(); |
4165 | m_url_clipboard = urld->clipboard(); | 4165 | m_url_localfile = urld->localfile(); |
4166 | m_url_localfile = urld->localfile(); | 4166 | m_url_globalfile = urld->globalfile(); |
4167 | m_url_globalfile = urld->globalfile(); | 4167 | if (m_url_clipboard) |
4168 | if (m_url_clipboard) | 4168 | { |
4169 | { | 4169 | QClipboard* cb = QApplication::clipboard(); |
4170 | QClipboard* cb = QApplication::clipboard(); | 4170 | cb->setText(href); |
4171 | cb->setText(href); | 4171 | qDebug("<a href=\"%s\">%s</a>", (const char*)href, (const char*)href); |
4172 | qDebug("<a href=\"%s\">%s</a>", (const char*)href, (const char*)href); | 4172 | } |
4173 | } | 4173 | if (m_url_localfile) |
4174 | if (m_url_localfile) | 4174 | { |
4175 | { | 4175 | writeUrl(reader->m_string, href); |
4176 | writeUrl(reader->m_string, href); | 4176 | } |
4177 | } | 4177 | if (m_url_globalfile) |
4178 | if (m_url_globalfile) | 4178 | { |
4179 | { | 4179 | writeUrl("GlobalURLFile", href); |
4180 | writeUrl("GlobalURLFile", href); | 4180 | } |
4181 | } | 4181 | } |
4182 | } | 4182 | delete urld; |
4183 | delete urld; | 4183 | } |
4184 | } | 4184 | |
4185 | 4185 | void QTReaderApp::writeUrl(const QString& file, const QString& href) | |
4186 | void QTReaderApp::writeUrl(const QString& file, const QString& href) | 4186 | { |
4187 | { | 4187 | QString filename; |
4188 | QString filename; | 4188 | #ifdef USEQPE |
4189 | #ifdef USEQPE | 4189 | filename = Global::applicationFileName(APPDIR "/urls", file); |
4190 | filename = Global::applicationFileName(APPDIR "/urls", file); | 4190 | #else |
4191 | #else | 4191 | QFileInfo fi; |
4192 | QFileInfo fi; | 4192 | QDir d = QDir::home(); // "/" |
4193 | QDir d = QDir::home(); // "/" | 4193 | if ( !d.cd(APPDIR) ) |
4194 | if ( !d.cd(APPDIR) ) | 4194 | { // "/tmp" |
4195 | { // "/tmp" | 4195 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
4196 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 4196 | d = QDir::home(); |
4197 | d = QDir::home(); | 4197 | d.mkdir(APPDIR); |
4198 | d.mkdir(APPDIR); | 4198 | d.cd(APPDIR); |
4199 | d.cd(APPDIR); | 4199 | } |
4200 | } | 4200 | if ( !d.cd("urls") ) |
4201 | if ( !d.cd("urls") ) | 4201 | { // "/tmp" |
4202 | { // "/tmp" | 4202 | qWarning( "Cannot find the \"~/" APPDIR "/urls\" directory" ); |
4203 | qWarning( "Cannot find the \"~/" APPDIR "/urls\" directory" ); | 4203 | d = QDir::home(); |
4204 | d = QDir::home(); | 4204 | d.cd(APPDIR); |
4205 | d.cd(APPDIR); | 4205 | d.mkdir("urls"); |
4206 | d.mkdir("urls"); | 4206 | d.cd("urls"); |
4207 | d.cd("urls"); | 4207 | } |
4208 | } | 4208 | fi.setFile(d, file); |
4209 | fi.setFile(d, file); | 4209 | filename = fi.absFilePath(); |
4210 | filename = fi.absFilePath(); | 4210 | #endif |
4211 | #endif | 4211 | FILE* fout = fopen(filename, "a"); |
4212 | FILE* fout = fopen(filename, "a"); | 4212 | if (fout != NULL) |
4213 | if (fout != NULL) | 4213 | { |
4214 | { | 4214 | fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href); |
4215 | fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href); | 4215 | fclose(fout); |
4216 | fclose(fout); | 4216 | } |
4217 | } | 4217 | else |
4218 | else | 4218 | { |
4219 | { | 4219 | QMessageBox::warning(this, PROGNAME, "Problem with writing URL"); |
4220 | QMessageBox::warning(this, PROGNAME, "Problem with writing URL"); | 4220 | } |
4221 | } | 4221 | } |
4222 | } | ||
diff --git a/noncore/apps/opie-reader/ToolbarPrefs.cpp b/noncore/apps/opie-reader/ToolbarPrefs.cpp index d878829..0347736 100644 --- a/noncore/apps/opie-reader/ToolbarPrefs.cpp +++ b/noncore/apps/opie-reader/ToolbarPrefs.cpp | |||
@@ -1,501 +1,491 @@ | |||
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> | ||
13 | #include <qlabel.h> | ||
14 | #include <qpushbutton.h> | ||
15 | #include <qspinbox.h> | ||
16 | #include <qlayout.h> | 11 | #include <qlayout.h> |
17 | #include <qvariant.h> | ||
18 | #include <qtooltip.h> | ||
19 | #include <qwhatsthis.h> | ||
20 | #include <qcombobox.h> | ||
21 | #include <qbuttongroup.h> | 12 | #include <qbuttongroup.h> |
22 | #include <qlineedit.h> | ||
23 | #ifdef USEQPE | 13 | #ifdef USEQPE |
24 | #include <qpe/menubutton.h> | 14 | #include <qpe/menubutton.h> |
25 | #endif | 15 | #endif |
26 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
27 | 17 | ||
28 | CBarPrefs::CBarPrefs(const QString& appdir, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true), config( appdir ) | 18 | CBarPrefs::CBarPrefs(const QString& appdir, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true), config( appdir ) |
29 | { | 19 | { |
30 | setCaption(tr( "Toolbar Settings" ) ); | 20 | setCaption(tr( "Toolbar Settings" ) ); |
31 | QTabWidget* td = new QTabWidget(this); | 21 | QTabWidget* td = new QTabWidget(this); |
32 | misc = new CMiscBarPrefs(this); | 22 | misc = new CMiscBarPrefs(this); |
33 | filebar = new CFileBarPrefs(config, this); | 23 | filebar = new CFileBarPrefs(config, this); |
34 | navbar = new CNavBarPrefs(config, this); | 24 | navbar = new CNavBarPrefs(config, this); |
35 | viewbar = new CViewBarPrefs(config, this); | 25 | viewbar = new CViewBarPrefs(config, this); |
36 | markbar = new CMarkBarPrefs(config, this); | 26 | markbar = new CMarkBarPrefs(config, this); |
37 | indbar = new CIndBarPrefs(config, this); | 27 | indbar = new CIndBarPrefs(config, this); |
38 | td->addTab(filebar, tr("File")); | 28 | td->addTab(filebar, tr("File")); |
39 | td->addTab(navbar, tr("Navigation")); | 29 | td->addTab(navbar, tr("Navigation")); |
40 | td->addTab(viewbar, tr("View")); | 30 | td->addTab(viewbar, tr("View")); |
41 | td->addTab(markbar, tr("Marks")); | 31 | td->addTab(markbar, tr("Marks")); |
42 | td->addTab(indbar, tr("Indicators")); | 32 | td->addTab(indbar, tr("Indicators")); |
43 | td->addTab(misc, tr("Policy")); | 33 | td->addTab(misc, tr("Policy")); |
44 | QVBoxLayout* v = new QVBoxLayout(this); | 34 | QVBoxLayout* v = new QVBoxLayout(this); |
45 | v->addWidget(td); | 35 | v->addWidget(td); |
46 | 36 | ||
47 | if (fs) | 37 | if (fs) |
48 | QPEApplication::showDialog( this ); | 38 | QPEApplication::showDialog( this ); |
49 | } | 39 | } |
50 | 40 | ||
51 | /* | 41 | /* |
52 | CBarPrefs1::CBarPrefs1( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 42 | CBarPrefs1::CBarPrefs1( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
53 | : QWidget( parent, name, fl ), config(_config) | 43 | : QWidget( parent, name, fl ), config(_config) |
54 | { | 44 | { |
55 | config.setGroup( "Toolbar" ); | 45 | config.setGroup( "Toolbar" ); |
56 | QVBoxLayout* vb = new QVBoxLayout(this); | 46 | QVBoxLayout* vb = new QVBoxLayout(this); |
57 | 47 | ||
58 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "File", this); | 48 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "File", this); |
59 | vb->addWidget(bg); | 49 | vb->addWidget(bg); |
60 | 50 | ||
61 | open = new QCheckBox( tr("Open"), bg ); | 51 | open = new QCheckBox( tr("Open"), bg ); |
62 | open->setChecked(config.readBoolEntry( "Open", false )); | 52 | open->setChecked(config.readBoolEntry( "Open", false )); |
63 | connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 53 | connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
64 | close = new QCheckBox( tr("Close"), bg ); | 54 | close = new QCheckBox( tr("Close"), bg ); |
65 | close->setChecked(config.readBoolEntry( "Close", false )); | 55 | close->setChecked(config.readBoolEntry( "Close", false )); |
66 | connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 56 | connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
67 | info = new QCheckBox( tr("Info"), bg ); | 57 | info = new QCheckBox( tr("Info"), bg ); |
68 | info->setChecked(config.readBoolEntry( "Info", false )); | 58 | info->setChecked(config.readBoolEntry( "Info", false )); |
69 | connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 59 | connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
70 | twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); | 60 | twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); |
71 | twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); | 61 | twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); |
72 | connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 62 | connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
73 | find = new QCheckBox( tr("Find"), bg ); | 63 | find = new QCheckBox( tr("Find"), bg ); |
74 | find->setChecked(config.readBoolEntry( "Find", false )); | 64 | find->setChecked(config.readBoolEntry( "Find", false )); |
75 | connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 65 | connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
76 | 66 | ||
77 | bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); | 67 | bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); |
78 | vb->addWidget(bg); | 68 | vb->addWidget(bg); |
79 | scroll = new QCheckBox( tr("Scroll"), bg ); | 69 | scroll = new QCheckBox( tr("Scroll"), bg ); |
80 | scroll->setChecked(config.readBoolEntry( "Scroll", false )); | 70 | scroll->setChecked(config.readBoolEntry( "Scroll", false )); |
81 | connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 71 | connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
82 | navigation = new QCheckBox( tr("Back/Home/Forward"), bg ); | 72 | navigation = new QCheckBox( tr("Back/Home/Forward"), bg ); |
83 | navigation->setChecked(config.readBoolEntry( "Back/Home/Forward", false )); | 73 | navigation->setChecked(config.readBoolEntry( "Back/Home/Forward", false )); |
84 | connect(navigation, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 74 | connect(navigation, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
85 | page = new QCheckBox( tr("Page\nUp/Down"), bg ); | 75 | page = new QCheckBox( tr("Page\nUp/Down"), bg ); |
86 | page->setChecked(config.readBoolEntry( "Page Up/Down", false )); | 76 | page->setChecked(config.readBoolEntry( "Page Up/Down", false )); |
87 | connect(page, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 77 | connect(page, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
88 | startend = new QCheckBox( tr("Goto Start/End"), bg ); | 78 | startend = new QCheckBox( tr("Goto Start/End"), bg ); |
89 | startend->setChecked(config.readBoolEntry( "Goto Start/End", false )); | 79 | startend->setChecked(config.readBoolEntry( "Goto Start/End", false )); |
90 | connect(startend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 80 | connect(startend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
91 | jump = new QCheckBox( tr("Jump"), bg ); | 81 | jump = new QCheckBox( tr("Jump"), bg ); |
92 | jump->setChecked(config.readBoolEntry( "Jump", false )); | 82 | jump->setChecked(config.readBoolEntry( "Jump", false )); |
93 | connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 83 | connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
94 | pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); | 84 | pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); |
95 | pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); | 85 | pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); |
96 | connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 86 | connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
97 | m_isChanged = false; | 87 | m_isChanged = false; |
98 | } | 88 | } |
99 | 89 | ||
100 | void CBarPrefs1::saveall() | 90 | void CBarPrefs1::saveall() |
101 | { | 91 | { |
102 | config.setGroup( "Toolbar" ); | 92 | config.setGroup( "Toolbar" ); |
103 | config.writeEntry( "Open", open->isChecked()); | 93 | config.writeEntry( "Open", open->isChecked()); |
104 | config.writeEntry( "Close", close->isChecked()); | 94 | config.writeEntry( "Close", close->isChecked()); |
105 | config.writeEntry( "Info", info->isChecked()); | 95 | config.writeEntry( "Info", info->isChecked()); |
106 | config.writeEntry( "Two/One Touch", twotouch->isChecked()); | 96 | config.writeEntry( "Two/One Touch", twotouch->isChecked()); |
107 | config.writeEntry( "Find", find->isChecked()); | 97 | config.writeEntry( "Find", find->isChecked()); |
108 | config.writeEntry( "Scroll", scroll->isChecked()); | 98 | config.writeEntry( "Scroll", scroll->isChecked()); |
109 | config.writeEntry( "Back/Home/Forward", navigation->isChecked()); | 99 | config.writeEntry( "Back/Home/Forward", navigation->isChecked()); |
110 | config.writeEntry( "Page Up/Down", page->isChecked()); | 100 | config.writeEntry( "Page Up/Down", page->isChecked()); |
111 | config.writeEntry( "Goto Start/End", startend->isChecked()); | 101 | config.writeEntry( "Goto Start/End", startend->isChecked()); |
112 | config.writeEntry( "Jump", jump->isChecked()); | 102 | config.writeEntry( "Jump", jump->isChecked()); |
113 | config.writeEntry( "Page/Line Scroll", pageline->isChecked()); | 103 | config.writeEntry( "Page/Line Scroll", pageline->isChecked()); |
114 | } | 104 | } |
115 | 105 | ||
116 | CBarPrefs1::~CBarPrefs1() | 106 | CBarPrefs1::~CBarPrefs1() |
117 | { | 107 | { |
118 | } | 108 | } |
119 | */ | 109 | */ |
120 | /* | 110 | /* |
121 | CBarPrefs2::CBarPrefs2( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 111 | CBarPrefs2::CBarPrefs2( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
122 | : QWidget( parent, name, fl ), config(_config) | 112 | : QWidget( parent, name, fl ), config(_config) |
123 | { | 113 | { |
124 | QVBoxLayout* vb = new QVBoxLayout(this); | 114 | QVBoxLayout* vb = new QVBoxLayout(this); |
125 | 115 | ||
126 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "View", this); | 116 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "View", this); |
127 | vb->addWidget(bg); | 117 | vb->addWidget(bg); |
128 | 118 | ||
129 | config.setGroup( "Toolbar" ); | 119 | config.setGroup( "Toolbar" ); |
130 | 120 | ||
131 | fullscreen = new QCheckBox( tr("Fullscreen"), bg ); | 121 | fullscreen = new QCheckBox( tr("Fullscreen"), bg ); |
132 | fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); | 122 | fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); |
133 | connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 123 | connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
134 | zoom = new QCheckBox( tr("Zoom"), bg ); | 124 | zoom = new QCheckBox( tr("Zoom"), bg ); |
135 | zoom->setChecked(config.readBoolEntry( "Zoom In/Out", false )); | 125 | zoom->setChecked(config.readBoolEntry( "Zoom In/Out", false )); |
136 | connect(zoom, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 126 | connect(zoom, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
137 | setfont = new QCheckBox( tr("Set Font"), bg ); | 127 | setfont = new QCheckBox( tr("Set Font"), bg ); |
138 | setfont->setChecked(config.readBoolEntry( "Set Font", false )); | 128 | setfont->setChecked(config.readBoolEntry( "Set Font", false )); |
139 | connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 129 | connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
140 | 130 | ||
141 | encoding = new QCheckBox( tr("Encoding"), bg ); | 131 | encoding = new QCheckBox( tr("Encoding"), bg ); |
142 | encoding->setChecked(config.readBoolEntry("Encoding Select", false)); | 132 | encoding->setChecked(config.readBoolEntry("Encoding Select", false)); |
143 | connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 133 | connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
144 | ideogram = new QCheckBox( tr("Ideogram"), bg ); | 134 | ideogram = new QCheckBox( tr("Ideogram"), bg ); |
145 | ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); | 135 | ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); |
146 | connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 136 | connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
147 | 137 | ||
148 | bg = new QGroupBox(3, Qt::Horizontal, "Marks", this); | 138 | bg = new QGroupBox(3, Qt::Horizontal, "Marks", this); |
149 | vb->addWidget(bg); | 139 | vb->addWidget(bg); |
150 | mark = new QCheckBox( tr("Bookmark"), bg ); | 140 | mark = new QCheckBox( tr("Bookmark"), bg ); |
151 | mark->setChecked(config.readBoolEntry( "Mark", false )); | 141 | mark->setChecked(config.readBoolEntry( "Mark", false )); |
152 | connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 142 | connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
153 | annotate = new QCheckBox( tr("Annotate"), bg ); | 143 | annotate = new QCheckBox( tr("Annotate"), bg ); |
154 | annotate->setChecked(config.readBoolEntry( "Annotate", false )); | 144 | annotate->setChecked(config.readBoolEntry( "Annotate", false )); |
155 | connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 145 | connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
156 | go_to = new QCheckBox( tr("Goto"), bg ); | 146 | go_to = new QCheckBox( tr("Goto"), bg ); |
157 | go_to->setChecked(config.readBoolEntry( "Goto", false )); | 147 | go_to->setChecked(config.readBoolEntry( "Goto", false )); |
158 | connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 148 | connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
159 | Delete = new QCheckBox( tr("Delete"), bg ); | 149 | Delete = new QCheckBox( tr("Delete"), bg ); |
160 | Delete->setChecked(config.readBoolEntry( "Delete", false )); | 150 | Delete->setChecked(config.readBoolEntry( "Delete", false )); |
161 | connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 151 | connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
162 | autogen = new QCheckBox( tr("Autogen"), bg ); | 152 | autogen = new QCheckBox( tr("Autogen"), bg ); |
163 | autogen->setChecked(config.readBoolEntry( "Autogen", false )); | 153 | autogen->setChecked(config.readBoolEntry( "Autogen", false )); |
164 | connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 154 | connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
165 | clear = new QCheckBox( tr("Clear"), bg ); | 155 | clear = new QCheckBox( tr("Clear"), bg ); |
166 | clear->setChecked(config.readBoolEntry( "Clear", false )); | 156 | clear->setChecked(config.readBoolEntry( "Clear", false )); |
167 | connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 157 | connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
168 | save = new QCheckBox( tr("Save"), bg ); | 158 | save = new QCheckBox( tr("Save"), bg ); |
169 | save->setChecked(config.readBoolEntry( "Save", false )); | 159 | save->setChecked(config.readBoolEntry( "Save", false )); |
170 | connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 160 | connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
171 | tidy = new QCheckBox( tr("Tidy"), bg ); | 161 | tidy = new QCheckBox( tr("Tidy"), bg ); |
172 | tidy->setChecked(config.readBoolEntry( "Tidy", false )); | 162 | tidy->setChecked(config.readBoolEntry( "Tidy", false )); |
173 | connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 163 | connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
174 | block = new QCheckBox( tr("Mark/Copy"), bg ); | 164 | block = new QCheckBox( tr("Mark/Copy"), bg ); |
175 | block->setChecked(config.readBoolEntry( "Start/Copy Block", false )); | 165 | block->setChecked(config.readBoolEntry( "Start/Copy Block", false )); |
176 | connect(block, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 166 | connect(block, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
177 | 167 | ||
178 | bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); | 168 | bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); |
179 | vb->addWidget(bg); | 169 | vb->addWidget(bg); |
180 | indannotate = new QCheckBox( tr("Annotation"), bg ); | 170 | indannotate = new QCheckBox( tr("Annotation"), bg ); |
181 | indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); | 171 | indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); |
182 | connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 172 | connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
183 | m_isChanged = false; | 173 | m_isChanged = false; |
184 | } | 174 | } |
185 | 175 | ||
186 | void CBarPrefs2::saveall() | 176 | void CBarPrefs2::saveall() |
187 | { | 177 | { |
188 | config.setGroup( "Toolbar" ); | 178 | config.setGroup( "Toolbar" ); |
189 | config.writeEntry( "Fullscreen", fullscreen->isChecked()); | 179 | config.writeEntry( "Fullscreen", fullscreen->isChecked()); |
190 | config.writeEntry( "Zoom In/Out", zoom->isChecked()); | 180 | config.writeEntry( "Zoom In/Out", zoom->isChecked()); |
191 | config.writeEntry( "Set Font", setfont->isChecked()); | 181 | config.writeEntry( "Set Font", setfont->isChecked()); |
192 | config.writeEntry("Encoding Select", encoding->isChecked()); | 182 | config.writeEntry("Encoding Select", encoding->isChecked()); |
193 | config.writeEntry("Ideogram Mode", ideogram->isChecked()); | 183 | config.writeEntry("Ideogram Mode", ideogram->isChecked()); |
194 | 184 | ||
195 | config.writeEntry( "Mark", mark->isChecked()); | 185 | config.writeEntry( "Mark", mark->isChecked()); |
196 | config.writeEntry( "Annotate", annotate->isChecked()); | 186 | config.writeEntry( "Annotate", annotate->isChecked()); |
197 | config.writeEntry( "Goto", go_to->isChecked()); | 187 | config.writeEntry( "Goto", go_to->isChecked()); |
198 | config.writeEntry( "Delete", Delete->isChecked()); | 188 | config.writeEntry( "Delete", Delete->isChecked()); |
199 | config.writeEntry( "Autogen", autogen->isChecked()); | 189 | config.writeEntry( "Autogen", autogen->isChecked()); |
200 | config.writeEntry( "Clear", clear->isChecked()); | 190 | config.writeEntry( "Clear", clear->isChecked()); |
201 | config.writeEntry( "Save", save->isChecked()); | 191 | config.writeEntry( "Save", save->isChecked()); |
202 | config.writeEntry( "Tidy", tidy->isChecked()); | 192 | config.writeEntry( "Tidy", tidy->isChecked()); |
203 | config.writeEntry( "Start/Copy Block", block->isChecked()); | 193 | config.writeEntry( "Start/Copy Block", block->isChecked()); |
204 | config.writeEntry( "Annotation indicator", indannotate->isChecked()); | 194 | config.writeEntry( "Annotation indicator", indannotate->isChecked()); |
205 | } | 195 | } |
206 | 196 | ||
207 | CBarPrefs2::~CBarPrefs2() | 197 | CBarPrefs2::~CBarPrefs2() |
208 | { | 198 | { |
209 | } | 199 | } |
210 | */ | 200 | */ |
211 | 201 | ||
212 | CFileBarPrefs::CFileBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 202 | CFileBarPrefs::CFileBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
213 | : QWidget( parent, name, fl ), config(_config) | 203 | : QWidget( parent, name, fl ), config(_config) |
214 | { | 204 | { |
215 | config.setGroup( "Toolbar" ); | 205 | config.setGroup( "Toolbar" ); |
216 | QVBoxLayout* vb = new QVBoxLayout(this); | 206 | QVBoxLayout* vb = new QVBoxLayout(this); |
217 | 207 | ||
218 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "File", this); | 208 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "File", this); |
219 | vb->addWidget(bg); | 209 | vb->addWidget(bg); |
220 | 210 | ||
221 | open = new QCheckBox( tr("Open"), bg ); | 211 | open = new QCheckBox( tr("Open"), bg ); |
222 | open->setChecked(config.readBoolEntry( "Open", false )); | 212 | open->setChecked(config.readBoolEntry( "Open", false )); |
223 | connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 213 | connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
224 | close = new QCheckBox( tr("Close"), bg ); | 214 | close = new QCheckBox( tr("Close"), bg ); |
225 | close->setChecked(config.readBoolEntry( "Close", false )); | 215 | close->setChecked(config.readBoolEntry( "Close", false )); |
226 | connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 216 | connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
227 | info = new QCheckBox( tr("Info"), bg ); | 217 | info = new QCheckBox( tr("Info"), bg ); |
228 | info->setChecked(config.readBoolEntry( "Info", false )); | 218 | info->setChecked(config.readBoolEntry( "Info", false )); |
229 | connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 219 | connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
230 | twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); | 220 | twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); |
231 | twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); | 221 | twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); |
232 | connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 222 | connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
233 | find = new QCheckBox( tr("Find"), bg ); | 223 | find = new QCheckBox( tr("Find"), bg ); |
234 | find->setChecked(config.readBoolEntry( "Find", false )); | 224 | find->setChecked(config.readBoolEntry( "Find", false )); |
235 | connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 225 | connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
236 | m_isChanged = false; | 226 | m_isChanged = false; |
237 | } | 227 | } |
238 | 228 | ||
239 | void CFileBarPrefs::saveall() | 229 | void CFileBarPrefs::saveall() |
240 | { | 230 | { |
241 | config.setGroup( "Toolbar" ); | 231 | config.setGroup( "Toolbar" ); |
242 | config.writeEntry( "Open", open->isChecked()); | 232 | config.writeEntry( "Open", open->isChecked()); |
243 | config.writeEntry( "Close", close->isChecked()); | 233 | config.writeEntry( "Close", close->isChecked()); |
244 | config.writeEntry( "Info", info->isChecked()); | 234 | config.writeEntry( "Info", info->isChecked()); |
245 | config.writeEntry( "Two/One Touch", twotouch->isChecked()); | 235 | config.writeEntry( "Two/One Touch", twotouch->isChecked()); |
246 | config.writeEntry( "Find", find->isChecked()); | 236 | config.writeEntry( "Find", find->isChecked()); |
247 | } | 237 | } |
248 | 238 | ||
249 | CFileBarPrefs::~CFileBarPrefs() | 239 | CFileBarPrefs::~CFileBarPrefs() |
250 | { | 240 | { |
251 | } | 241 | } |
252 | 242 | ||
253 | CNavBarPrefs::CNavBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 243 | CNavBarPrefs::CNavBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
254 | : QWidget( parent, name, fl ), config(_config) | 244 | : QWidget( parent, name, fl ), config(_config) |
255 | { | 245 | { |
256 | config.setGroup( "Toolbar" ); | 246 | config.setGroup( "Toolbar" ); |
257 | QVBoxLayout* vb = new QVBoxLayout(this); | 247 | QVBoxLayout* vb = new QVBoxLayout(this); |
258 | 248 | ||
259 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); | 249 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); |
260 | vb->addWidget(bg); | 250 | vb->addWidget(bg); |
261 | scroll = new QCheckBox( tr("Scroll"), bg ); | 251 | scroll = new QCheckBox( tr("Scroll"), bg ); |
262 | scroll->setChecked(config.readBoolEntry( "Scroll", false )); | 252 | scroll->setChecked(config.readBoolEntry( "Scroll", false )); |
263 | connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 253 | connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
264 | 254 | ||
265 | navback = new QCheckBox( tr("Back"), bg ); | 255 | navback = new QCheckBox( tr("Back"), bg ); |
266 | navback->setChecked(config.readBoolEntry( "Back", false )); | 256 | navback->setChecked(config.readBoolEntry( "Back", false )); |
267 | connect(navback, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 257 | connect(navback, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
268 | navhome = new QCheckBox( tr("Home"), bg ); | 258 | navhome = new QCheckBox( tr("Home"), bg ); |
269 | navhome->setChecked(config.readBoolEntry( "Home", false )); | 259 | navhome->setChecked(config.readBoolEntry( "Home", false )); |
270 | connect(navhome, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 260 | connect(navhome, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
271 | navforward = new QCheckBox( tr("Forward"), bg ); | 261 | navforward = new QCheckBox( tr("Forward"), bg ); |
272 | navforward->setChecked(config.readBoolEntry( "Forward", false )); | 262 | navforward->setChecked(config.readBoolEntry( "Forward", false )); |
273 | connect(navforward, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 263 | connect(navforward, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
274 | 264 | ||
275 | pageup = new QCheckBox( tr("Page Up"), bg ); | 265 | pageup = new QCheckBox( tr("Page Up"), bg ); |
276 | pageup->setChecked(config.readBoolEntry( "Page Up", false )); | 266 | pageup->setChecked(config.readBoolEntry( "Page Up", false )); |
277 | connect(pageup, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 267 | connect(pageup, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
278 | pagedown = new QCheckBox( tr("Page Down"), bg ); | 268 | pagedown = new QCheckBox( tr("Page Down"), bg ); |
279 | pagedown->setChecked(config.readBoolEntry( "Page Down", false )); | 269 | pagedown->setChecked(config.readBoolEntry( "Page Down", false )); |
280 | connect(pagedown, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 270 | connect(pagedown, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
281 | gotostart = new QCheckBox( tr("Goto Start"), bg ); | 271 | gotostart = new QCheckBox( tr("Goto Start"), bg ); |
282 | gotostart->setChecked(config.readBoolEntry( "Goto Start", false )); | 272 | gotostart->setChecked(config.readBoolEntry( "Goto Start", false )); |
283 | connect(gotostart, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 273 | connect(gotostart, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
284 | gotoend = new QCheckBox( tr("Goto End"), bg ); | 274 | gotoend = new QCheckBox( tr("Goto End"), bg ); |
285 | gotoend->setChecked(config.readBoolEntry( "Goto End", false )); | 275 | gotoend->setChecked(config.readBoolEntry( "Goto End", false )); |
286 | connect(gotoend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 276 | connect(gotoend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
287 | jump = new QCheckBox( tr("Jump"), bg ); | 277 | jump = new QCheckBox( tr("Jump"), bg ); |
288 | jump->setChecked(config.readBoolEntry( "Jump", false )); | 278 | jump->setChecked(config.readBoolEntry( "Jump", false )); |
289 | connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 279 | connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
290 | pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); | 280 | pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); |
291 | pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); | 281 | pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); |
292 | connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 282 | connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
293 | m_isChanged = false; | 283 | m_isChanged = false; |
294 | } | 284 | } |
295 | 285 | ||
296 | void CNavBarPrefs::saveall() | 286 | void CNavBarPrefs::saveall() |
297 | { | 287 | { |
298 | config.setGroup( "Toolbar" ); | 288 | config.setGroup( "Toolbar" ); |
299 | config.writeEntry( "Scroll", scroll->isChecked()); | 289 | config.writeEntry( "Scroll", scroll->isChecked()); |
300 | config.writeEntry( "Back", navback->isChecked()); | 290 | config.writeEntry( "Back", navback->isChecked()); |
301 | config.writeEntry( "Home", navhome->isChecked()); | 291 | config.writeEntry( "Home", navhome->isChecked()); |
302 | config.writeEntry( "Forward", navforward->isChecked()); | 292 | config.writeEntry( "Forward", navforward->isChecked()); |
303 | config.writeEntry( "Page Up", pageup->isChecked()); | 293 | config.writeEntry( "Page Up", pageup->isChecked()); |
304 | config.writeEntry( "Page Down", pagedown->isChecked()); | 294 | config.writeEntry( "Page Down", pagedown->isChecked()); |
305 | config.writeEntry( "Goto Start", gotostart->isChecked()); | 295 | config.writeEntry( "Goto Start", gotostart->isChecked()); |
306 | config.writeEntry( "Goto End", gotoend->isChecked()); | 296 | config.writeEntry( "Goto End", gotoend->isChecked()); |
307 | config.writeEntry( "Jump", jump->isChecked()); | 297 | config.writeEntry( "Jump", jump->isChecked()); |
308 | config.writeEntry( "Page/Line Scroll", pageline->isChecked()); | 298 | config.writeEntry( "Page/Line Scroll", pageline->isChecked()); |
309 | } | 299 | } |
310 | 300 | ||
311 | CNavBarPrefs::~CNavBarPrefs() | 301 | CNavBarPrefs::~CNavBarPrefs() |
312 | { | 302 | { |
313 | } | 303 | } |
314 | 304 | ||
315 | CViewBarPrefs::CViewBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 305 | CViewBarPrefs::CViewBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
316 | : QWidget( parent, name, fl ), config(_config) | 306 | : QWidget( parent, name, fl ), config(_config) |
317 | { | 307 | { |
318 | QVBoxLayout* vb = new QVBoxLayout(this); | 308 | QVBoxLayout* vb = new QVBoxLayout(this); |
319 | 309 | ||
320 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "View", this); | 310 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "View", this); |
321 | vb->addWidget(bg); | 311 | vb->addWidget(bg); |
322 | 312 | ||
323 | config.setGroup( "Toolbar" ); | 313 | config.setGroup( "Toolbar" ); |
324 | 314 | ||
325 | fullscreen = new QCheckBox( tr("Fullscreen"), bg ); | 315 | fullscreen = new QCheckBox( tr("Fullscreen"), bg ); |
326 | fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); | 316 | fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); |
327 | connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 317 | connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
328 | zoomin = new QCheckBox( tr("Zoom In"), bg ); | 318 | zoomin = new QCheckBox( tr("Zoom In"), bg ); |
329 | zoomin->setChecked(config.readBoolEntry( "Zoom In", false )); | 319 | zoomin->setChecked(config.readBoolEntry( "Zoom In", false )); |
330 | connect(zoomin, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 320 | connect(zoomin, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
331 | zoomout = new QCheckBox( tr("Zoom Out"), bg ); | 321 | zoomout = new QCheckBox( tr("Zoom Out"), bg ); |
332 | zoomout->setChecked(config.readBoolEntry( "Zoom Out", false )); | 322 | zoomout->setChecked(config.readBoolEntry( "Zoom Out", false )); |
333 | connect(zoomout, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 323 | connect(zoomout, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
334 | setfont = new QCheckBox( tr("Set Font"), bg ); | 324 | setfont = new QCheckBox( tr("Set Font"), bg ); |
335 | setfont->setChecked(config.readBoolEntry( "Set Font", false )); | 325 | setfont->setChecked(config.readBoolEntry( "Set Font", false )); |
336 | connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 326 | connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
337 | 327 | ||
338 | encoding = new QCheckBox( tr("Encoding"), bg ); | 328 | encoding = new QCheckBox( tr("Encoding"), bg ); |
339 | encoding->setChecked(config.readBoolEntry("Encoding Select", false)); | 329 | encoding->setChecked(config.readBoolEntry("Encoding Select", false)); |
340 | connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 330 | connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
341 | ideogram = new QCheckBox( tr("Ideogram"), bg ); | 331 | ideogram = new QCheckBox( tr("Ideogram"), bg ); |
342 | ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); | 332 | ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); |
343 | connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 333 | connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
344 | m_isChanged = false; | 334 | m_isChanged = false; |
345 | } | 335 | } |
346 | 336 | ||
347 | void CViewBarPrefs::saveall() | 337 | void CViewBarPrefs::saveall() |
348 | { | 338 | { |
349 | config.setGroup( "Toolbar" ); | 339 | config.setGroup( "Toolbar" ); |
350 | config.writeEntry( "Fullscreen", fullscreen->isChecked()); | 340 | config.writeEntry( "Fullscreen", fullscreen->isChecked()); |
351 | config.writeEntry( "Zoom In", zoomin->isChecked()); | 341 | config.writeEntry( "Zoom In", zoomin->isChecked()); |
352 | config.writeEntry( "Zoom Out", zoomout->isChecked()); | 342 | config.writeEntry( "Zoom Out", zoomout->isChecked()); |
353 | config.writeEntry( "Set Font", setfont->isChecked()); | 343 | config.writeEntry( "Set Font", setfont->isChecked()); |
354 | config.writeEntry("Encoding Select", encoding->isChecked()); | 344 | config.writeEntry("Encoding Select", encoding->isChecked()); |
355 | config.writeEntry("Ideogram Mode", ideogram->isChecked()); | 345 | config.writeEntry("Ideogram Mode", ideogram->isChecked()); |
356 | } | 346 | } |
357 | 347 | ||
358 | CViewBarPrefs::~CViewBarPrefs() | 348 | CViewBarPrefs::~CViewBarPrefs() |
359 | { | 349 | { |
360 | } | 350 | } |
361 | 351 | ||
362 | CMarkBarPrefs::CMarkBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 352 | CMarkBarPrefs::CMarkBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
363 | : QWidget( parent, name, fl ), config(_config) | 353 | : QWidget( parent, name, fl ), config(_config) |
364 | { | 354 | { |
365 | QVBoxLayout* vb = new QVBoxLayout(this); | 355 | QVBoxLayout* vb = new QVBoxLayout(this); |
366 | 356 | ||
367 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Marks", this); | 357 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Marks", this); |
368 | vb->addWidget(bg); | 358 | vb->addWidget(bg); |
369 | mark = new QCheckBox( tr("Bookmark"), bg ); | 359 | mark = new QCheckBox( tr("Bookmark"), bg ); |
370 | mark->setChecked(config.readBoolEntry( "Mark", false )); | 360 | mark->setChecked(config.readBoolEntry( "Mark", false )); |
371 | connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 361 | connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
372 | annotate = new QCheckBox( tr("Annotate"), bg ); | 362 | annotate = new QCheckBox( tr("Annotate"), bg ); |
373 | annotate->setChecked(config.readBoolEntry( "Annotate", false )); | 363 | annotate->setChecked(config.readBoolEntry( "Annotate", false )); |
374 | connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 364 | connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
375 | go_to = new QCheckBox( tr("Goto"), bg ); | 365 | go_to = new QCheckBox( tr("Goto"), bg ); |
376 | go_to->setChecked(config.readBoolEntry( "Goto", false )); | 366 | go_to->setChecked(config.readBoolEntry( "Goto", false )); |
377 | connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 367 | connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
378 | Delete = new QCheckBox( tr("Delete"), bg ); | 368 | Delete = new QCheckBox( tr("Delete"), bg ); |
379 | Delete->setChecked(config.readBoolEntry( "Delete", false )); | 369 | Delete->setChecked(config.readBoolEntry( "Delete", false )); |
380 | connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 370 | connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
381 | autogen = new QCheckBox( tr("Autogen"), bg ); | 371 | autogen = new QCheckBox( tr("Autogen"), bg ); |
382 | autogen->setChecked(config.readBoolEntry( "Autogen", false )); | 372 | autogen->setChecked(config.readBoolEntry( "Autogen", false )); |
383 | connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 373 | connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
384 | clear = new QCheckBox( tr("Clear"), bg ); | 374 | clear = new QCheckBox( tr("Clear"), bg ); |
385 | clear->setChecked(config.readBoolEntry( "Clear", false )); | 375 | clear->setChecked(config.readBoolEntry( "Clear", false )); |
386 | connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 376 | connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
387 | save = new QCheckBox( tr("Save"), bg ); | 377 | save = new QCheckBox( tr("Save"), bg ); |
388 | save->setChecked(config.readBoolEntry( "Save", false )); | 378 | save->setChecked(config.readBoolEntry( "Save", false )); |
389 | connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 379 | connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
390 | tidy = new QCheckBox( tr("Tidy"), bg ); | 380 | tidy = new QCheckBox( tr("Tidy"), bg ); |
391 | tidy->setChecked(config.readBoolEntry( "Tidy", false )); | 381 | tidy->setChecked(config.readBoolEntry( "Tidy", false )); |
392 | connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 382 | connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
393 | startblock = new QCheckBox( tr("Mark Block"), bg ); | 383 | startblock = new QCheckBox( tr("Mark Block"), bg ); |
394 | startblock->setChecked(config.readBoolEntry( "Start Block", false )); | 384 | startblock->setChecked(config.readBoolEntry( "Start Block", false )); |
395 | connect(startblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 385 | connect(startblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
396 | copyblock = new QCheckBox( tr("Copy Block"), bg ); | 386 | copyblock = new QCheckBox( tr("Copy Block"), bg ); |
397 | copyblock->setChecked(config.readBoolEntry( "Copy Block", false )); | 387 | copyblock->setChecked(config.readBoolEntry( "Copy Block", false )); |
398 | connect(copyblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 388 | connect(copyblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
399 | m_isChanged = false; | 389 | m_isChanged = false; |
400 | } | 390 | } |
401 | 391 | ||
402 | void CMarkBarPrefs::saveall() | 392 | void CMarkBarPrefs::saveall() |
403 | { | 393 | { |
404 | config.setGroup( "Toolbar" ); | 394 | config.setGroup( "Toolbar" ); |
405 | config.writeEntry( "Mark", mark->isChecked()); | 395 | config.writeEntry( "Mark", mark->isChecked()); |
406 | config.writeEntry( "Annotate", annotate->isChecked()); | 396 | config.writeEntry( "Annotate", annotate->isChecked()); |
407 | config.writeEntry( "Goto", go_to->isChecked()); | 397 | config.writeEntry( "Goto", go_to->isChecked()); |
408 | config.writeEntry( "Delete", Delete->isChecked()); | 398 | config.writeEntry( "Delete", Delete->isChecked()); |
409 | config.writeEntry( "Autogen", autogen->isChecked()); | 399 | config.writeEntry( "Autogen", autogen->isChecked()); |
410 | config.writeEntry( "Clear", clear->isChecked()); | 400 | config.writeEntry( "Clear", clear->isChecked()); |
411 | config.writeEntry( "Save", save->isChecked()); | 401 | config.writeEntry( "Save", save->isChecked()); |
412 | config.writeEntry( "Tidy", tidy->isChecked()); | 402 | config.writeEntry( "Tidy", tidy->isChecked()); |
413 | config.writeEntry( "Start Block", startblock->isChecked()); | 403 | config.writeEntry( "Start Block", startblock->isChecked()); |
414 | config.writeEntry( "Copy Block", copyblock->isChecked()); | 404 | config.writeEntry( "Copy Block", copyblock->isChecked()); |
415 | } | 405 | } |
416 | 406 | ||
417 | CMarkBarPrefs::~CMarkBarPrefs() | 407 | CMarkBarPrefs::~CMarkBarPrefs() |
418 | { | 408 | { |
419 | } | 409 | } |
420 | 410 | ||
421 | CMiscBarPrefs::CMiscBarPrefs( QWidget* parent, const char* name, WFlags fl ) | 411 | CMiscBarPrefs::CMiscBarPrefs( QWidget* parent, const char* name, WFlags fl ) |
422 | : QWidget( parent, name, fl ) | 412 | : QWidget( parent, name, fl ) |
423 | { | 413 | { |
424 | 414 | ||
425 | QGridLayout* hl = new QGridLayout(this,1,2); | 415 | QGridLayout* hl = new QGridLayout(this,1,2); |
426 | 416 | ||
427 | hl->setMargin( 0 ); | 417 | hl->setMargin( 0 ); |
428 | 418 | ||
429 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Dialogs", this); | 419 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Dialogs", this); |
430 | floating = new QCheckBox(gb); | 420 | floating = new QCheckBox(gb); |
431 | floating->setText(tr("Floating")); | 421 | floating->setText(tr("Floating")); |
432 | 422 | ||
433 | // QLabel* TextLabel = new QLabel( gb ); | 423 | // QLabel* TextLabel = new QLabel( gb ); |
434 | // TextLabel->setText( tr( "Select Button" ) ); | 424 | // TextLabel->setText( tr( "Select Button" ) ); |
435 | 425 | ||
436 | 426 | ||
437 | hl->addWidget( gb, 0, 0 ); | 427 | hl->addWidget( gb, 0, 0 ); |
438 | 428 | ||
439 | 429 | ||
440 | gb = new QGroupBox(1, Qt::Horizontal, "Bars (Restart)", this); | 430 | gb = new QGroupBox(1, Qt::Horizontal, "Bars (Restart)", this); |
441 | 431 | ||
442 | // QLabel* ql = new QLabel("Restart to apply changes", gb); | 432 | // QLabel* ql = new QLabel("Restart to apply changes", gb); |
443 | // TextLabel = new QLabel( gb ); | 433 | // TextLabel = new QLabel( gb ); |
444 | // TextLabel->setText( tr( "Policy" ) ); | 434 | // TextLabel->setText( tr( "Policy" ) ); |
445 | 435 | ||
446 | #ifdef USECOMBO | 436 | #ifdef USECOMBO |
447 | tbpolicy = new QComboBox(gb); | 437 | tbpolicy = new QComboBox(gb); |
448 | #else | 438 | #else |
449 | tbpolicy = new MenuButton(gb); | 439 | tbpolicy = new MenuButton(gb); |
450 | #endif | 440 | #endif |
451 | tbpolicy->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 441 | tbpolicy->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
452 | tbpolicy->insertItem(tr("Single bar")); | 442 | tbpolicy->insertItem(tr("Single bar")); |
453 | tbpolicy->insertItem(tr("Menu/tool bar")); | 443 | tbpolicy->insertItem(tr("Menu/tool bar")); |
454 | tbpolicy->insertItem(tr("Multiple bars")); | 444 | tbpolicy->insertItem(tr("Multiple bars")); |
455 | 445 | ||
456 | #ifdef USECOMBO | 446 | #ifdef USECOMBO |
457 | tbposition = new QComboBox(gb); | 447 | tbposition = new QComboBox(gb); |
458 | #else | 448 | #else |
459 | tbposition = new MenuButton(gb); | 449 | tbposition = new MenuButton(gb); |
460 | #endif | 450 | #endif |
461 | tbposition->insertItem(tr("Top")); | 451 | tbposition->insertItem(tr("Top")); |
462 | tbposition->insertItem(tr("Bottom")); | 452 | tbposition->insertItem(tr("Bottom")); |
463 | tbposition->insertItem(tr("Right")); | 453 | tbposition->insertItem(tr("Right")); |
464 | tbposition->insertItem(tr("Left")); | 454 | tbposition->insertItem(tr("Left")); |
465 | tbposition->insertItem(tr("Minimised")); | 455 | tbposition->insertItem(tr("Minimised")); |
466 | 456 | ||
467 | tbmovable = new QCheckBox( tr("Movable"), gb ); | 457 | tbmovable = new QCheckBox( tr("Movable"), gb ); |
468 | // ch->setChecked(config.readBoolEntry( "Movable", false )); | 458 | // ch->setChecked(config.readBoolEntry( "Movable", false )); |
469 | 459 | ||
470 | hl->addWidget(gb, 0, 1); | 460 | hl->addWidget(gb, 0, 1); |
471 | 461 | ||
472 | } | 462 | } |
473 | 463 | ||
474 | CMiscBarPrefs::~CMiscBarPrefs() | 464 | CMiscBarPrefs::~CMiscBarPrefs() |
475 | { | 465 | { |
476 | // no need to delete child widgets, Qt does it all for us | 466 | // no need to delete child widgets, Qt does it all for us |
477 | } | 467 | } |
478 | 468 | ||
479 | 469 | ||
480 | CIndBarPrefs::CIndBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 470 | CIndBarPrefs::CIndBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
481 | : QWidget( parent, name, fl ), config(_config) | 471 | : QWidget( parent, name, fl ), config(_config) |
482 | { | 472 | { |
483 | QVBoxLayout* vb = new QVBoxLayout(this); | 473 | QVBoxLayout* vb = new QVBoxLayout(this); |
484 | 474 | ||
485 | QGroupBox* bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); | 475 | QGroupBox* bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); |
486 | vb->addWidget(bg); | 476 | vb->addWidget(bg); |
487 | indannotate = new QCheckBox( tr("Annotation"), bg ); | 477 | indannotate = new QCheckBox( tr("Annotation"), bg ); |
488 | indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); | 478 | indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); |
489 | connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 479 | connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
490 | m_isChanged = false; | 480 | m_isChanged = false; |
491 | } | 481 | } |
492 | 482 | ||
493 | void CIndBarPrefs::saveall() | 483 | void CIndBarPrefs::saveall() |
494 | { | 484 | { |
495 | config.setGroup( "Toolbar" ); | 485 | config.setGroup( "Toolbar" ); |
496 | config.writeEntry( "Annotation indicator", indannotate->isChecked()); | 486 | config.writeEntry( "Annotation indicator", indannotate->isChecked()); |
497 | } | 487 | } |
498 | 488 | ||
499 | CIndBarPrefs::~CIndBarPrefs() | 489 | CIndBarPrefs::~CIndBarPrefs() |
500 | { | 490 | { |
501 | } | 491 | } |
diff --git a/noncore/apps/opie-reader/fileBrowser.cpp b/noncore/apps/opie-reader/fileBrowser.cpp index 05f2c31..ebd14f3 100644 --- a/noncore/apps/opie-reader/fileBrowser.cpp +++ b/noncore/apps/opie-reader/fileBrowser.cpp | |||
@@ -1,269 +1,266 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | 2 | ||
3 | Derived from a file browser which was | 3 | Derived from a file browser which was |
4 | 4 | ||
5 | ** copyright 2001 ljp ljp@llornkcor.com | 5 | ** copyright 2001 ljp ljp@llornkcor.com |
6 | 6 | ||
7 | Extensive modification by Tim Wentford to allow it to work in rotated mode | 7 | Extensive modification by Tim Wentford to allow it to work in rotated mode |
8 | 8 | ||
9 | ****************************************************************************/ | 9 | ****************************************************************************/ |
10 | #include "fileBrowser.h" | 10 | #include "fileBrowser.h" |
11 | 11 | ||
12 | #include "QtrListView.h" | 12 | #include "QtrListView.h" |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
15 | #include <qfile.h> | ||
16 | #include <qmessagebox.h> | ||
17 | #ifndef _WINDOWS | 15 | #ifndef _WINDOWS |
18 | #include <unistd.h> | 16 | #include <unistd.h> |
19 | #endif | 17 | #endif |
20 | #include <qlayout.h> | 18 | #include <qlayout.h> |
21 | #ifdef _WINDOWS | 19 | #ifdef _WINDOWS |
22 | #include <direct.h> | 20 | #include <direct.h> |
23 | #endif | 21 | #endif |
24 | 22 | ||
25 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
26 | 24 | ||
27 | #include "opie.h" | ||
28 | 25 | ||
29 | fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) | 26 | fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) |
30 | : QDialog( parent, name, true, | 27 | : QDialog( parent, name, true, |
31 | fl/* | WStyle_Customize | WStyle_Tool*/), | 28 | fl/* | WStyle_Customize | WStyle_Tool*/), |
32 | filterspec(QDir::All) | 29 | filterspec(QDir::All) |
33 | { | 30 | { |
34 | // showMaximized(); | 31 | // showMaximized(); |
35 | if ( !name ) | 32 | if ( !name ) |
36 | setName( "fileBrowser" ); | 33 | setName( "fileBrowser" ); |
37 | /* | 34 | /* |
38 | if (parent != NULL) | 35 | if (parent != NULL) |
39 | { | 36 | { |
40 | #ifdef OPIE | 37 | #ifdef OPIE |
41 | move(0,0); | 38 | move(0,0); |
42 | resize( parent->width(), parent->height() ); | 39 | resize( parent->width(), parent->height() ); |
43 | #else | 40 | #else |
44 | setGeometry(parent->x(), parent->y(), parent->width(), parent->height() ); | 41 | setGeometry(parent->x(), parent->y(), parent->width(), parent->height() ); |
45 | #endif | 42 | #endif |
46 | } | 43 | } |
47 | */ | 44 | */ |
48 | // showFullScreen(); | 45 | // showFullScreen(); |
49 | setCaption(tr( "Browse for file" ) ); | 46 | setCaption(tr( "Browse for file" ) ); |
50 | filterStr=filter; | 47 | filterStr=filter; |
51 | 48 | ||
52 | buttonOk = new QPushButton( this, "buttonOk" ); | 49 | buttonOk = new QPushButton( this, "buttonOk" ); |
53 | buttonOk->setFixedSize( 25, 25 ); | 50 | buttonOk->setFixedSize( 25, 25 ); |
54 | buttonOk->setAutoDefault( false ); | 51 | buttonOk->setAutoDefault( false ); |
55 | buttonOk->setText( tr( "/" ) ); | 52 | buttonOk->setText( tr( "/" ) ); |
56 | 53 | ||
57 | buttonShowHidden = new QPushButton( this, "buttonShowHidden" ); | 54 | buttonShowHidden = new QPushButton( this, "buttonShowHidden" ); |
58 | // buttonShowHidden->setFixedSize( 50, 25 ); | 55 | // buttonShowHidden->setFixedSize( 50, 25 ); |
59 | buttonShowHidden->setText( tr( "Hidden" ) ); | 56 | buttonShowHidden->setText( tr( "Hidden" ) ); |
60 | buttonShowHidden->setAutoDefault( false ); | 57 | buttonShowHidden->setAutoDefault( false ); |
61 | buttonShowHidden->setToggleButton( true ); | 58 | buttonShowHidden->setToggleButton( true ); |
62 | buttonShowHidden->setOn( false ); | 59 | buttonShowHidden->setOn( false ); |
63 | 60 | ||
64 | dirLabel = new QLabel(this, "DirLabel"); | 61 | dirLabel = new QLabel(this, "DirLabel"); |
65 | dirLabel->setAlignment(AlignLeft | AlignVCenter | ExpandTabs | WordBreak); | 62 | dirLabel->setAlignment(AlignLeft | AlignVCenter | ExpandTabs | WordBreak); |
66 | dirLabel->setText(currentDir.canonicalPath()); | 63 | dirLabel->setText(currentDir.canonicalPath()); |
67 | 64 | ||
68 | ListView = new QtrListView( this, "ListView" ); | 65 | ListView = new QtrListView( this, "ListView" ); |
69 | ListView->addColumn( tr( "Name" ) ); | 66 | ListView->addColumn( tr( "Name" ) ); |
70 | ListView->setSorting( 2, FALSE); | 67 | ListView->setSorting( 2, FALSE); |
71 | ListView->addColumn( tr( "Size" ) ); | 68 | ListView->addColumn( tr( "Size" ) ); |
72 | ListView->setSelectionMode(QListView::Single); | 69 | ListView->setSelectionMode(QListView::Single); |
73 | ListView->setAllColumnsShowFocus( TRUE ); | 70 | ListView->setAllColumnsShowFocus( TRUE ); |
74 | ListView->setColumnWidthMode(0, QListView::Manual); | 71 | ListView->setColumnWidthMode(0, QListView::Manual); |
75 | ListView->setColumnWidthMode(1, QListView::Manual); | 72 | ListView->setColumnWidthMode(1, QListView::Manual); |
76 | 73 | ||
77 | // signals and slots connections | 74 | // signals and slots connections |
78 | connect( buttonShowHidden, SIGNAL( toggled(bool) ), this, SLOT( setHidden(bool) ) ); | 75 | connect( buttonShowHidden, SIGNAL( toggled(bool) ), this, SLOT( setHidden(bool) ) ); |
79 | connect( buttonOk, SIGNAL( clicked() ), this, SLOT( OnRoot() ) ); | 76 | connect( buttonOk, SIGNAL( clicked() ), this, SLOT( OnRoot() ) ); |
80 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); | 77 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); |
81 | connect( ListView, SIGNAL(clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 78 | connect( ListView, SIGNAL(clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
82 | connect( ListView, SIGNAL(OnOKButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 79 | connect( ListView, SIGNAL(OnOKButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
83 | connect( ListView, SIGNAL(OnCentreButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 80 | connect( ListView, SIGNAL(OnCentreButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
84 | connect( ListView, SIGNAL(OnCancelButton()), SLOT(OnCancel()) ); | 81 | connect( ListView, SIGNAL(OnCancelButton()), SLOT(OnCancel()) ); |
85 | 82 | ||
86 | QVBoxLayout* grid = new QVBoxLayout(this); | 83 | QVBoxLayout* grid = new QVBoxLayout(this); |
87 | QHBoxLayout* hgrid = new QHBoxLayout(grid); | 84 | QHBoxLayout* hgrid = new QHBoxLayout(grid); |
88 | hgrid->addWidget(dirLabel,1); | 85 | hgrid->addWidget(dirLabel,1); |
89 | hgrid->addWidget(buttonShowHidden); | 86 | hgrid->addWidget(buttonShowHidden); |
90 | hgrid->addWidget(buttonOk); | 87 | hgrid->addWidget(buttonOk); |
91 | grid->addWidget(ListView,1); | 88 | grid->addWidget(ListView,1); |
92 | if (allownew) | 89 | if (allownew) |
93 | { | 90 | { |
94 | m_filename = new QLineEdit(this); | 91 | m_filename = new QLineEdit(this); |
95 | grid->addWidget(m_filename); | 92 | grid->addWidget(m_filename); |
96 | connect( m_filename, SIGNAL( returnPressed() ), this, SLOT( onReturn() )); | 93 | connect( m_filename, SIGNAL( returnPressed() ), this, SLOT( onReturn() )); |
97 | } | 94 | } |
98 | else | 95 | else |
99 | { | 96 | { |
100 | m_filename = NULL; | 97 | m_filename = NULL; |
101 | } | 98 | } |
102 | 99 | ||
103 | if (QFileInfo(iPath).exists()) | 100 | if (QFileInfo(iPath).exists()) |
104 | { | 101 | { |
105 | currentDir.setPath(iPath); | 102 | currentDir.setPath(iPath); |
106 | #ifdef _WINDOWS | 103 | #ifdef _WINDOWS |
107 | _chdir(iPath.latin1()); | 104 | _chdir(iPath.latin1()); |
108 | #else | 105 | #else |
109 | chdir(iPath.latin1()); | 106 | chdir(iPath.latin1()); |
110 | #endif | 107 | #endif |
111 | } | 108 | } |
112 | else | 109 | else |
113 | { | 110 | { |
114 | currentDir.setPath(QDir::currentDirPath()); | 111 | currentDir.setPath(QDir::currentDirPath()); |
115 | chdir(QDir::currentDirPath().latin1()); | 112 | chdir(QDir::currentDirPath().latin1()); |
116 | } | 113 | } |
117 | 114 | ||
118 | populateList(); | 115 | populateList(); |
119 | 116 | ||
120 | if (modal) | 117 | if (modal) |
121 | QPEApplication::showDialog( this ); | 118 | QPEApplication::showDialog( this ); |
122 | } | 119 | } |
123 | 120 | ||
124 | void fileBrowser::resizeEvent(QResizeEvent* e) | 121 | void fileBrowser::resizeEvent(QResizeEvent* e) |
125 | { | 122 | { |
126 | ListView->setColumnWidth(1,(ListView->width())/4); | 123 | ListView->setColumnWidth(1,(ListView->width())/4); |
127 | ListView->setColumnWidth(0,ListView->width()-20-ListView->columnWidth(1)); | 124 | ListView->setColumnWidth(0,ListView->width()-20-ListView->columnWidth(1)); |
128 | } | 125 | } |
129 | 126 | ||
130 | fileBrowser::~fileBrowser() | 127 | fileBrowser::~fileBrowser() |
131 | { | 128 | { |
132 | } | 129 | } |
133 | 130 | ||
134 | 131 | ||
135 | void fileBrowser::populateList() | 132 | void fileBrowser::populateList() |
136 | { | 133 | { |
137 | ListView->clear(); | 134 | ListView->clear(); |
138 | ////qDebug(currentDir.canonicalPath()); | 135 | ////qDebug(currentDir.canonicalPath()); |
139 | // currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); | 136 | // currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); |
140 | currentDir.setFilter( filterspec ); | 137 | currentDir.setFilter( filterspec ); |
141 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 138 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
142 | currentDir.setMatchAllDirs(TRUE); | 139 | currentDir.setMatchAllDirs(TRUE); |
143 | 140 | ||
144 | currentDir.setNameFilter(filterStr); | 141 | currentDir.setNameFilter(filterStr); |
145 | // currentDir.setNameFilter("*.txt;*.etx"); | 142 | // currentDir.setNameFilter("*.txt;*.etx"); |
146 | QString fileL, fileS; | 143 | QString fileL, fileS; |
147 | const QFileInfoList *list = currentDir.entryInfoList(); | 144 | const QFileInfoList *list = currentDir.entryInfoList(); |
148 | QFileInfoListIterator it(*list); | 145 | QFileInfoListIterator it(*list); |
149 | QFileInfo *fi; | 146 | QFileInfo *fi; |
150 | while ( (fi=it.current()) ) | 147 | while ( (fi=it.current()) ) |
151 | { | 148 | { |
152 | if (fi->fileName() != ".") | 149 | if (fi->fileName() != ".") |
153 | { | 150 | { |
154 | fileS.sprintf( "%10li", fi->size() ); | 151 | fileS.sprintf( "%10li", fi->size() ); |
155 | fileL.sprintf( "%s",fi->fileName().data() ); | 152 | fileL.sprintf( "%s",fi->fileName().data() ); |
156 | if( fi->isDir() ) | 153 | if( fi->isDir() ) |
157 | { | 154 | { |
158 | fileL+="/"; | 155 | fileL+="/"; |
159 | } | 156 | } |
160 | else | 157 | else |
161 | { | 158 | { |
162 | //// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 159 | //// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
163 | } | 160 | } |
164 | new QListViewItem( ListView,fileL,fileS ); | 161 | new QListViewItem( ListView,fileL,fileS ); |
165 | } | 162 | } |
166 | ++it; | 163 | ++it; |
167 | } | 164 | } |
168 | ListView->setSorting( 2, FALSE); | 165 | ListView->setSorting( 2, FALSE); |
169 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); | 166 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); |
170 | ListView->setFocus(); | 167 | ListView->setFocus(); |
171 | } | 168 | } |
172 | 169 | ||
173 | void fileBrowser::upDir() | 170 | void fileBrowser::upDir() |
174 | { | 171 | { |
175 | //// qDebug(currentDir.canonicalPath()); | 172 | //// qDebug(currentDir.canonicalPath()); |
176 | } | 173 | } |
177 | 174 | ||
178 | void fileBrowser::listClicked(QListViewItem *selectedItem) | 175 | void fileBrowser::listClicked(QListViewItem *selectedItem) |
179 | { | 176 | { |
180 | if (selectedItem == NULL) return; | 177 | if (selectedItem == NULL) return; |
181 | QString strItem=selectedItem->text(0); | 178 | QString strItem=selectedItem->text(0); |
182 | 179 | ||
183 | //// qDebug("%s", (const char*)strItem); | 180 | //// qDebug("%s", (const char*)strItem); |
184 | 181 | ||
185 | 182 | ||
186 | QString strSize=selectedItem->text(1); | 183 | QString strSize=selectedItem->text(1); |
187 | 184 | ||
188 | strSize.stripWhiteSpace(); | 185 | strSize.stripWhiteSpace(); |
189 | 186 | ||
190 | bool ok; | 187 | bool ok; |
191 | 188 | ||
192 | QFileInfo fi(strItem); | 189 | QFileInfo fi(strItem); |
193 | while (fi.isSymLink()) fi.setFile(fi.readLink()); | 190 | while (fi.isSymLink()) fi.setFile(fi.readLink()); |
194 | if (fi.isDir()) | 191 | if (fi.isDir()) |
195 | { | 192 | { |
196 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 193 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
197 | 194 | ||
198 | if(QDir(strItem).exists()) | 195 | if(QDir(strItem).exists()) |
199 | { | 196 | { |
200 | currentDir.cd(strItem, TRUE); | 197 | currentDir.cd(strItem, TRUE); |
201 | populateList(); | 198 | populateList(); |
202 | } | 199 | } |
203 | } else | 200 | } else |
204 | { | 201 | { |
205 | QListViewItem *selectedItem = ListView->selectedItem(); | 202 | QListViewItem *selectedItem = ListView->selectedItem(); |
206 | if (selectedItem == NULL) | 203 | if (selectedItem == NULL) |
207 | { | 204 | { |
208 | filename = ""; | 205 | filename = ""; |
209 | } | 206 | } |
210 | else | 207 | else |
211 | { | 208 | { |
212 | filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+selectedItem->text(0)); | 209 | filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+selectedItem->text(0)); |
213 | } | 210 | } |
214 | OnOK(); | 211 | OnOK(); |
215 | } | 212 | } |
216 | chdir(strItem.latin1()); | 213 | chdir(strItem.latin1()); |
217 | // | 214 | // |
218 | 215 | ||
219 | } | 216 | } |
220 | 217 | ||
221 | // you may want to switch these 2 functions. I like single clicks | 218 | // you may want to switch these 2 functions. I like single clicks |
222 | void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) | 219 | void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) |
223 | { | 220 | { |
224 | } | 221 | } |
225 | 222 | ||
226 | QString fileBrowser::getCurrentFile() | 223 | QString fileBrowser::getCurrentFile() |
227 | { | 224 | { |
228 | return filename; | 225 | return filename; |
229 | } | 226 | } |
230 | 227 | ||
231 | void fileBrowser::OnOK() | 228 | void fileBrowser::OnOK() |
232 | { | 229 | { |
233 | accept(); | 230 | accept(); |
234 | } | 231 | } |
235 | 232 | ||
236 | void fileBrowser::OnRoot() | 233 | void fileBrowser::OnRoot() |
237 | { | 234 | { |
238 | currentDir.cd("/", TRUE); | 235 | currentDir.cd("/", TRUE); |
239 | populateList(); | 236 | populateList(); |
240 | chdir("/"); | 237 | chdir("/"); |
241 | } | 238 | } |
242 | 239 | ||
243 | void fileBrowser::OnCancel() | 240 | void fileBrowser::OnCancel() |
244 | { | 241 | { |
245 | reject(); | 242 | reject(); |
246 | } | 243 | } |
247 | 244 | ||
248 | void fileBrowser::setHidden(bool _hidden) | 245 | void fileBrowser::setHidden(bool _hidden) |
249 | { | 246 | { |
250 | if (_hidden) | 247 | if (_hidden) |
251 | filterspec = QDir::All | QDir::Hidden; | 248 | filterspec = QDir::All | QDir::Hidden; |
252 | else | 249 | else |
253 | filterspec = QDir::All; | 250 | filterspec = QDir::All; |
254 | populateList(); | 251 | populateList(); |
255 | } | 252 | } |
256 | 253 | ||
257 | void fileBrowser::onReturn() | 254 | void fileBrowser::onReturn() |
258 | { | 255 | { |
259 | QListViewItem *selectedItem = ListView->selectedItem(); | 256 | QListViewItem *selectedItem = ListView->selectedItem(); |
260 | if (selectedItem == NULL) | 257 | if (selectedItem == NULL) |
261 | { | 258 | { |
262 | filename = m_filename->text(); | 259 | filename = m_filename->text(); |
263 | } | 260 | } |
264 | else | 261 | else |
265 | { | 262 | { |
266 | filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+m_filename->text()); | 263 | filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+m_filename->text()); |
267 | } | 264 | } |
268 | OnOK(); | 265 | OnOK(); |
269 | } | 266 | } |
diff --git a/noncore/apps/opie-reader/main.cpp b/noncore/apps/opie-reader/main.cpp index 3e1f5e7..6d706c4 100644 --- a/noncore/apps/opie-reader/main.cpp +++ b/noncore/apps/opie-reader/main.cpp | |||
@@ -1,50 +1,48 @@ | |||
1 | #include "useqpe.h" | 1 | #include "useqpe.h" |
2 | #ifdef USEQPE | 2 | #ifdef USEQPE |
3 | #include <qpe/qpeapplication.h> | 3 | #include <qpe/qpeapplication.h> |
4 | #else | 4 | #else |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #endif | 6 | #endif |
7 | #include "QTReaderApp.h" | 7 | #include "QTReaderApp.h" |
8 | 8 | ||
9 | #include "signal.h" | 9 | #include "signal.h" |
10 | #include "stdio.h" | ||
11 | #include "time.h" | ||
12 | 10 | ||
13 | 11 | ||
14 | #ifdef USEQPE | 12 | #ifdef USEQPE |
15 | QTReaderApp* app = NULL; | 13 | QTReaderApp* app = NULL; |
16 | 14 | ||
17 | void handler(int signum) | 15 | void handler(int signum) |
18 | { | 16 | { |
19 | if (app != NULL) | 17 | if (app != NULL) |
20 | { | 18 | { |
21 | app->suspend(); | 19 | app->suspend(); |
22 | app->saveprefs(); | 20 | app->saveprefs(); |
23 | } | 21 | } |
24 | signal(signum, handler); | 22 | signal(signum, handler); |
25 | } | 23 | } |
26 | #endif | 24 | #endif |
27 | 25 | ||
28 | int main( int argc, char ** argv ) | 26 | int main( int argc, char ** argv ) |
29 | { | 27 | { |
30 | 28 | ||
31 | #ifdef USEQPE | 29 | #ifdef USEQPE |
32 | signal(SIGCONT, handler); | 30 | signal(SIGCONT, handler); |
33 | QPEApplication a( argc, argv ); | 31 | QPEApplication a( argc, argv ); |
34 | QTReaderApp m; | 32 | QTReaderApp m; |
35 | a.showMainDocumentWidget( &m ); | 33 | a.showMainDocumentWidget( &m ); |
36 | app = &m; | 34 | app = &m; |
37 | #else | 35 | #else |
38 | QApplication a( argc, argv ); | 36 | QApplication a( argc, argv ); |
39 | QTReaderApp m; | 37 | QTReaderApp m; |
40 | a.setMainWidget( &m ); | 38 | a.setMainWidget( &m ); |
41 | if (argc > 1) | 39 | if (argc > 1) |
42 | { | 40 | { |
43 | m.setDocument(argv[1]); | 41 | m.setDocument(argv[1]); |
44 | } | 42 | } |
45 | #endif | 43 | #endif |
46 | 44 | ||
47 | 45 | ||
48 | return a.exec(); | 46 | return a.exec(); |
49 | } | 47 | } |
50 | 48 | ||
diff --git a/noncore/apps/opie-reader/plucker.cpp b/noncore/apps/opie-reader/plucker.cpp index e49e35f..e52fd6a 100644 --- a/noncore/apps/opie-reader/plucker.cpp +++ b/noncore/apps/opie-reader/plucker.cpp | |||
@@ -1,156 +1,151 @@ | |||
1 | #include "useqpe.h" | ||
2 | #include <stdio.h> | 1 | #include <stdio.h> |
3 | #include <string.h> | 2 | #include <string.h> |
4 | #include <qmessagebox.h> | ||
5 | #include <qpixmap.h> | ||
6 | #ifdef USEQPE | 3 | #ifdef USEQPE |
7 | #include <qpe/qcopenvelope_qws.h> | 4 | #include <qpe/qcopenvelope_qws.h> |
8 | #endif | 5 | #endif |
9 | #ifdef LOCALPICTURES | 6 | #ifdef LOCALPICTURES |
10 | #include <qscrollview.h> | 7 | #include <qscrollview.h> |
11 | #endif | 8 | #endif |
12 | #ifdef USEQPE | 9 | #ifdef USEQPE |
13 | #include <qpe/global.h> | 10 | #include <qpe/global.h> |
14 | #include <qpe/qpeapplication.h> | 11 | #include <qpe/qpeapplication.h> |
15 | #else | 12 | #else |
16 | #include <qapplication.h> | 13 | #include <qapplication.h> |
17 | #endif | 14 | #endif |
18 | #include <qclipboard.h> | ||
19 | 15 | ||
20 | #include "plucker.h" | 16 | #include "plucker.h" |
21 | #include "Aportis.h" | ||
22 | #include "Palm2QImage.h" | 17 | #include "Palm2QImage.h" |
23 | 18 | ||
24 | 19 | ||
25 | struct CPlucker_dataRecord | 20 | struct CPlucker_dataRecord |
26 | { | 21 | { |
27 | UInt16 uid; | 22 | UInt16 uid; |
28 | UInt16 nParagraphs; | 23 | UInt16 nParagraphs; |
29 | UInt16 size; | 24 | UInt16 size; |
30 | UInt8 type; | 25 | UInt8 type; |
31 | UInt8 reserved; | 26 | UInt8 reserved; |
32 | }; | 27 | }; |
33 | 28 | ||
34 | int CPlucker::HeaderSize() | 29 | int CPlucker::HeaderSize() |
35 | { | 30 | { |
36 | return sizeof(CPlucker_dataRecord); | 31 | return sizeof(CPlucker_dataRecord); |
37 | } | 32 | } |
38 | 33 | ||
39 | void CPlucker::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved) | 34 | void CPlucker::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved) |
40 | { | 35 | { |
41 | CPlucker_dataRecord thishdr; | 36 | CPlucker_dataRecord thishdr; |
42 | fread(&thishdr, 1, HeaderSize(), fin); | 37 | fread(&thishdr, 1, HeaderSize(), fin); |
43 | uid = ntohs(thishdr.uid); | 38 | uid = ntohs(thishdr.uid); |
44 | nParagraphs = ntohs(thishdr.nParagraphs); | 39 | nParagraphs = ntohs(thishdr.nParagraphs); |
45 | size = ntohs(thishdr.size); | 40 | size = ntohs(thishdr.size); |
46 | type = thishdr.type; | 41 | type = thishdr.type; |
47 | reserved = thishdr.reserved; | 42 | reserved = thishdr.reserved; |
48 | } | 43 | } |
49 | 44 | ||
50 | CPlucker::CPlucker() | 45 | CPlucker::CPlucker() |
51 | { /*printf("constructing:%x\n",fin);*/ } | 46 | { /*printf("constructing:%x\n",fin);*/ } |
52 | 47 | ||
53 | bool CPlucker::CorrectDecoder() | 48 | bool CPlucker::CorrectDecoder() |
54 | { | 49 | { |
55 | return (memcmp(&head.type, "DataPlkr", 8) == 0); | 50 | return (memcmp(&head.type, "DataPlkr", 8) == 0); |
56 | } | 51 | } |
57 | 52 | ||
58 | int CPlucker::bgetch() | 53 | int CPlucker::bgetch() |
59 | { | 54 | { |
60 | int ch = EOF; | 55 | int ch = EOF; |
61 | if (bufferpos >= buffercontent) | 56 | if (bufferpos >= buffercontent) |
62 | { | 57 | { |
63 | if (!m_continuous) return EOF; | 58 | if (!m_continuous) return EOF; |
64 | if (bufferrec >= ntohs(head.recordList.numRecords) - 1) return EOF; | 59 | if (bufferrec >= ntohs(head.recordList.numRecords) - 1) return EOF; |
65 | ////qDebug("Passing through %u", currentpos); | 60 | ////qDebug("Passing through %u", currentpos); |
66 | if (!expand(bufferrec+1)) return EOF; | 61 | if (!expand(bufferrec+1)) return EOF; |
67 | mystyle.unset(); | 62 | mystyle.unset(); |
68 | if (m_ParaOffsets[m_nextParaIndex] == 0) | 63 | if (m_ParaOffsets[m_nextParaIndex] == 0) |
69 | { | 64 | { |
70 | while (m_ParaOffsets[m_nextParaIndex+1] == 0) | 65 | while (m_ParaOffsets[m_nextParaIndex+1] == 0) |
71 | { | 66 | { |
72 | // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); | 67 | // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
73 | m_nextParaIndex++; | 68 | m_nextParaIndex++; |
74 | } | 69 | } |
75 | } | 70 | } |
76 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); | 71 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); |
77 | //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); | 72 | //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
78 | ch = 10; | 73 | ch = 10; |
79 | EOPPhase = 4; | 74 | EOPPhase = 4; |
80 | } | 75 | } |
81 | else if (bufferpos == m_nextPara) | 76 | else if (bufferpos == m_nextPara) |
82 | { | 77 | { |
83 | while (bufferpos == m_nextPara) | 78 | while (bufferpos == m_nextPara) |
84 | { | 79 | { |
85 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; | 80 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; |
86 | m_nextParaIndex++; | 81 | m_nextParaIndex++; |
87 | // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); | 82 | // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
88 | if (m_nextParaIndex == m_nParas) | 83 | if (m_nextParaIndex == m_nParas) |
89 | { | 84 | { |
90 | m_nextPara = -1; | 85 | m_nextPara = -1; |
91 | } | 86 | } |
92 | else | 87 | else |
93 | { | 88 | { |
94 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | 89 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; |
95 | } | 90 | } |
96 | } | 91 | } |
97 | mystyle.unset(); | 92 | mystyle.unset(); |
98 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); | 93 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); |
99 | //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); | 94 | //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
100 | if (m_lastBreak == locate()) | 95 | if (m_lastBreak == locate()) |
101 | { | 96 | { |
102 | currentpos++; | 97 | currentpos++; |
103 | ch = expandedtextbuffer[bufferpos++]; | 98 | ch = expandedtextbuffer[bufferpos++]; |
104 | } | 99 | } |
105 | else | 100 | else |
106 | { | 101 | { |
107 | ch = 10; | 102 | ch = 10; |
108 | } | 103 | } |
109 | } | 104 | } |
110 | else | 105 | else |
111 | { | 106 | { |
112 | currentpos++; | 107 | currentpos++; |
113 | ch = expandedtextbuffer[bufferpos++]; | 108 | ch = expandedtextbuffer[bufferpos++]; |
114 | } | 109 | } |
115 | return ch; | 110 | return ch; |
116 | } | 111 | } |
117 | 112 | ||
118 | tchar CPlucker::getch(bool fast) | 113 | tchar CPlucker::getch(bool fast) |
119 | { | 114 | { |
120 | mystyle.clearPicture(); | 115 | mystyle.clearPicture(); |
121 | 116 | ||
122 | if (EOPPhase > 0) | 117 | if (EOPPhase > 0) |
123 | { | 118 | { |
124 | int ch = 10; | 119 | int ch = 10; |
125 | switch (EOPPhase) | 120 | switch (EOPPhase) |
126 | { | 121 | { |
127 | case 4: | 122 | case 4: |
128 | if (!fast) mystyle.setPicture(false, hRule(100,5)); | 123 | if (!fast) mystyle.setPicture(false, hRule(100,5)); |
129 | mystyle.setCentreJustify(); | 124 | mystyle.setCentreJustify(); |
130 | ch = '#'; | 125 | ch = '#'; |
131 | break; | 126 | break; |
132 | case 3: | 127 | case 3: |
133 | mystyle.setFontSize(3); | 128 | mystyle.setFontSize(3); |
134 | ch = 10; | 129 | ch = 10; |
135 | break; | 130 | break; |
136 | case 2: | 131 | case 2: |
137 | ch = 10; | 132 | ch = 10; |
138 | break; | 133 | break; |
139 | case 1: | 134 | case 1: |
140 | mystyle.unset(); | 135 | mystyle.unset(); |
141 | default: | 136 | default: |
142 | ch = 10; | 137 | ch = 10; |
143 | } | 138 | } |
144 | EOPPhase--; | 139 | EOPPhase--; |
145 | return ch; | 140 | return ch; |
146 | } | 141 | } |
147 | 142 | ||
148 | return getch_base(fast); | 143 | return getch_base(fast); |
149 | } | 144 | } |
150 | 145 | ||
151 | QImage* CPlucker::imagefromdata(UInt8* imgbuffer, UInt32 imgsize) | 146 | QImage* CPlucker::imagefromdata(UInt8* imgbuffer, UInt32 imgsize) |
152 | { | 147 | { |
153 | QImage* qimage = Palm2QImage(imgbuffer, imgsize); | 148 | QImage* qimage = Palm2QImage(imgbuffer, imgsize); |
154 | delete [] imgbuffer; | 149 | delete [] imgbuffer; |
155 | return qimage; | 150 | return qimage; |
156 | } | 151 | } |
diff --git a/noncore/apps/opie-reader/plucker_base.cpp b/noncore/apps/opie-reader/plucker_base.cpp index 9047a45..caa945d 100644 --- a/noncore/apps/opie-reader/plucker_base.cpp +++ b/noncore/apps/opie-reader/plucker_base.cpp | |||
@@ -1,1240 +1,1235 @@ | |||
1 | #include "useqpe.h" | 1 | #include "useqpe.h" |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include <qmessagebox.h> | ||
5 | #include <qpixmap.h> | ||
6 | #ifdef USEQPE | 4 | #ifdef USEQPE |
7 | #include <qpe/qcopenvelope_qws.h> | 5 | #include <qpe/qcopenvelope_qws.h> |
8 | #endif /* USEQPE */ | 6 | #endif /* USEQPE */ |
9 | #ifdef LOCALPICTURES | 7 | #ifdef LOCALPICTURES |
10 | #include <qscrollview.h> | 8 | #include <qscrollview.h> |
11 | #endif | 9 | #endif |
12 | #ifdef USEQPE | 10 | #ifdef USEQPE |
13 | #include <qpe/global.h> | 11 | #include <qpe/global.h> |
14 | #endif /* USEQPE */ | 12 | #endif /* USEQPE */ |
15 | #include <qclipboard.h> | ||
16 | #ifndef USEQPE | 13 | #ifndef USEQPE |
17 | #include <qapplication.h> | 14 | #include <qapplication.h> |
18 | #else /* USEQPE */ | 15 | #else /* USEQPE */ |
19 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
20 | #endif /* USEQPE */ | 17 | #endif /* USEQPE */ |
21 | 18 | ||
22 | #include "plucker_base.h" | 19 | #include "plucker_base.h" |
23 | #include "Aportis.h" | 20 | #include "Aportis.h" |
24 | #include "Palm2QImage.h" | 21 | #include "Palm2QImage.h" |
25 | 22 | ||
26 | CPlucker_base::CPlucker_base() : | 23 | CPlucker_base::CPlucker_base() : |
27 | #ifdef LOCALPICTURES | 24 | #ifdef LOCALPICTURES |
28 | m_viewer(NULL), | 25 | m_viewer(NULL), |
29 | m_picture(NULL), | 26 | m_picture(NULL), |
30 | #endif | 27 | #endif |
31 | expandedtextbuffer(NULL), | 28 | expandedtextbuffer(NULL), |
32 | compressedtextbuffer(NULL) | 29 | compressedtextbuffer(NULL) |
33 | //, urls(NULL) | 30 | //, urls(NULL) |
34 | { /*printf("constructing:%x\n",fin);*/ } | 31 | { /*printf("constructing:%x\n",fin);*/ } |
35 | 32 | ||
36 | 33 | ||
37 | void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buffersize) | 34 | void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buffersize) |
38 | { | 35 | { |
39 | if (type%2 == 0) | 36 | if (type%2 == 0) |
40 | { | 37 | { |
41 | fread(buffer, reclen, sizeof(char), fin); | 38 | fread(buffer, reclen, sizeof(char), fin); |
42 | } | 39 | } |
43 | else | 40 | else |
44 | { | 41 | { |
45 | UInt8* readbuffer = NULL; | 42 | UInt8* readbuffer = NULL; |
46 | if (reclen > compressedbuffersize) | 43 | if (reclen > compressedbuffersize) |
47 | { | 44 | { |
48 | readbuffer = new UInt8[reclen]; | 45 | readbuffer = new UInt8[reclen]; |
49 | } | 46 | } |
50 | else | 47 | else |
51 | { | 48 | { |
52 | readbuffer = compressedtextbuffer; | 49 | readbuffer = compressedtextbuffer; |
53 | } | 50 | } |
54 | if (readbuffer != NULL) | 51 | if (readbuffer != NULL) |
55 | { | 52 | { |
56 | fread(readbuffer, reclen, sizeof(char), fin); | 53 | fread(readbuffer, reclen, sizeof(char), fin); |
57 | switch (ntohs(hdr0.version)) | 54 | switch (ntohs(hdr0.version)) |
58 | { | 55 | { |
59 | case 2: | 56 | case 2: |
60 | UnZip(readbuffer, reclen, buffer, buffersize); | 57 | UnZip(readbuffer, reclen, buffer, buffersize); |
61 | break; | 58 | break; |
62 | case 1: | 59 | case 1: |
63 | UnDoc(readbuffer, reclen, buffer, buffersize); | 60 | UnDoc(readbuffer, reclen, buffer, buffersize); |
64 | break; | 61 | break; |
65 | } | 62 | } |
66 | if (reclen > compressedbuffersize) | 63 | if (reclen > compressedbuffersize) |
67 | { | 64 | { |
68 | delete [] readbuffer; | 65 | delete [] readbuffer; |
69 | } | 66 | } |
70 | } | 67 | } |
71 | } | 68 | } |
72 | } | 69 | } |
73 | 70 | ||
74 | void CPlucker_base::sizes(unsigned long& _file, unsigned long& _text) | 71 | void CPlucker_base::sizes(unsigned long& _file, unsigned long& _text) |
75 | { | 72 | { |
76 | _file = file_length; | 73 | _file = file_length; |
77 | if (textlength == 0) | 74 | if (textlength == 0) |
78 | { | 75 | { |
79 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 76 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
80 | { | 77 | { |
81 | gotorecordnumber(recptr); | 78 | gotorecordnumber(recptr); |
82 | UInt16 thishdr_uid, thishdr_nParagraphs; | 79 | UInt16 thishdr_uid, thishdr_nParagraphs; |
83 | UInt32 thishdr_size; | 80 | UInt32 thishdr_size; |
84 | UInt8 thishdr_type, thishdr_reserved; | 81 | UInt8 thishdr_type, thishdr_reserved; |
85 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 82 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
86 | if (thishdr_type < 2) textlength += thishdr_size; | 83 | if (thishdr_type < 2) textlength += thishdr_size; |
87 | } | 84 | } |
88 | } | 85 | } |
89 | _text = textlength; | 86 | _text = textlength; |
90 | //ntohl(hdr0.size); | 87 | //ntohl(hdr0.size); |
91 | } | 88 | } |
92 | 89 | ||
93 | char* CPlucker_base::geturl(UInt16 tgt) | 90 | char* CPlucker_base::geturl(UInt16 tgt) |
94 | { | 91 | { |
95 | char * pRet = NULL; | 92 | char * pRet = NULL; |
96 | gotorecordnumber(0); | 93 | gotorecordnumber(0); |
97 | fread(&hdr0, 1, 6, fin); | 94 | fread(&hdr0, 1, 6, fin); |
98 | unsigned int nrecs = ntohs(hdr0.nRecords); | 95 | unsigned int nrecs = ntohs(hdr0.nRecords); |
99 | //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); | 96 | //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); |
100 | UInt16 urlid = 0; | 97 | UInt16 urlid = 0; |
101 | bool urlsfound = false; | 98 | bool urlsfound = false; |
102 | char* urls = NULL; | 99 | char* urls = NULL; |
103 | size_t urlsize = 0; | 100 | size_t urlsize = 0; |
104 | for (unsigned int i = 0; i < nrecs; i++) | 101 | for (unsigned int i = 0; i < nrecs; i++) |
105 | { | 102 | { |
106 | UInt16 id, name; | 103 | UInt16 id, name; |
107 | fread(&name, 1, sizeof(name), fin); | 104 | fread(&name, 1, sizeof(name), fin); |
108 | fread(&id, 1, sizeof(id), fin); | 105 | fread(&id, 1, sizeof(id), fin); |
109 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); | 106 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); |
110 | if (ntohs(name) == 2) | 107 | if (ntohs(name) == 2) |
111 | { | 108 | { |
112 | urlsfound = true; | 109 | urlsfound = true; |
113 | urlid = id; | 110 | urlid = id; |
114 | //qDebug("Found url index:%d", ntohs(urlid)); | 111 | //qDebug("Found url index:%d", ntohs(urlid)); |
115 | } | 112 | } |
116 | ////qDebug("%x", id); | 113 | ////qDebug("%x", id); |
117 | } | 114 | } |
118 | if (urlsfound) | 115 | if (urlsfound) |
119 | { | 116 | { |
120 | unsigned short recptr = finduid(ntohs(urlid)); | 117 | unsigned short recptr = finduid(ntohs(urlid)); |
121 | if (recptr != 0) | 118 | if (recptr != 0) |
122 | { | 119 | { |
123 | gotorecordnumber(recptr); | 120 | gotorecordnumber(recptr); |
124 | UInt16 thishdr_uid, thishdr_nParagraphs; | 121 | UInt16 thishdr_uid, thishdr_nParagraphs; |
125 | UInt32 thishdr_size; | 122 | UInt32 thishdr_size; |
126 | UInt8 thishdr_type, thishdr_reserved; | 123 | UInt8 thishdr_type, thishdr_reserved; |
127 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 124 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
128 | UInt16 urlctr = 0; | 125 | UInt16 urlctr = 0; |
129 | while (1) | 126 | while (1) |
130 | { | 127 | { |
131 | UInt16 tctr; | 128 | UInt16 tctr; |
132 | fread(&tctr, 1, sizeof(tctr), fin); | 129 | fread(&tctr, 1, sizeof(tctr), fin); |
133 | fread(&urlid, 1, sizeof(urlid), fin); | 130 | fread(&urlid, 1, sizeof(urlid), fin); |
134 | tctr = ntohs(tctr); | 131 | tctr = ntohs(tctr); |
135 | //qDebug("tgt:%u urlctr:%u tctr:%u", tgt, urlctr, tctr); | 132 | //qDebug("tgt:%u urlctr:%u tctr:%u", tgt, urlctr, tctr); |
136 | if (tctr >= tgt) | 133 | if (tctr >= tgt) |
137 | { | 134 | { |
138 | break; | 135 | break; |
139 | } | 136 | } |
140 | urlctr = tctr; | 137 | urlctr = tctr; |
141 | } | 138 | } |
142 | //qDebug("urls are in %d", ntohs(urlid)); | 139 | //qDebug("urls are in %d", ntohs(urlid)); |
143 | recptr = finduid(ntohs(urlid)); | 140 | recptr = finduid(ntohs(urlid)); |
144 | if (recptr != 0) | 141 | if (recptr != 0) |
145 | { | 142 | { |
146 | UInt32 reclen = recordlength(recptr) - HeaderSize(); | 143 | UInt32 reclen = recordlength(recptr) - HeaderSize(); |
147 | gotorecordnumber(recptr); | 144 | gotorecordnumber(recptr); |
148 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 145 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
149 | //qDebug("Found urls:%x",thishdr_type); | 146 | //qDebug("Found urls:%x",thishdr_type); |
150 | urlsize = thishdr_size; | 147 | urlsize = thishdr_size; |
151 | urls = new char[urlsize]; | 148 | urls = new char[urlsize]; |
152 | Expand(reclen, thishdr_type, (UInt8*)urls, urlsize); | 149 | Expand(reclen, thishdr_type, (UInt8*)urls, urlsize); |
153 | char* ptr = urls; | 150 | char* ptr = urls; |
154 | int rn = urlctr+1; | 151 | int rn = urlctr+1; |
155 | while (ptr - urls < urlsize) | 152 | while (ptr - urls < urlsize) |
156 | { | 153 | { |
157 | if (rn == tgt) | 154 | if (rn == tgt) |
158 | { | 155 | { |
159 | //qDebug("URL:%s", ptr); | 156 | //qDebug("URL:%s", ptr); |
160 | int len = strlen(ptr)+1; | 157 | int len = strlen(ptr)+1; |
161 | pRet = new char[len]; | 158 | pRet = new char[len]; |
162 | memcpy(pRet, ptr, len); | 159 | memcpy(pRet, ptr, len); |
163 | break; | 160 | break; |
164 | } | 161 | } |
165 | ptr += strlen(ptr)+1; | 162 | ptr += strlen(ptr)+1; |
166 | rn++; | 163 | rn++; |
167 | } | 164 | } |
168 | delete [] urls; | 165 | delete [] urls; |
169 | } | 166 | } |
170 | } | 167 | } |
171 | } | 168 | } |
172 | else | 169 | else |
173 | { | 170 | { |
174 | QMessageBox::information(NULL, | 171 | QMessageBox::information(NULL, |
175 | QString(PROGNAME), | 172 | QString(PROGNAME), |
176 | QString("No external links\nin this pluck") | 173 | QString("No external links\nin this pluck") |
177 | ); | 174 | ); |
178 | } | 175 | } |
179 | return pRet; | 176 | return pRet; |
180 | } | 177 | } |
181 | 178 | ||
182 | CPlucker_base::~CPlucker_base() | 179 | CPlucker_base::~CPlucker_base() |
183 | { | 180 | { |
184 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; | 181 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; |
185 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; | 182 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; |
186 | #ifdef LOCALPICTURES | 183 | #ifdef LOCALPICTURES |
187 | if (m_viewer != NULL) delete m_viewer; | 184 | if (m_viewer != NULL) delete m_viewer; |
188 | #endif | 185 | #endif |
189 | } | 186 | } |
190 | 187 | ||
191 | int CPlucker_base::getch() { return getch(false); } | 188 | int CPlucker_base::getch() { return getch(false); } |
192 | 189 | ||
193 | void CPlucker_base::getch(tchar& ch, CStyle& sty) | 190 | void CPlucker_base::getch(tchar& ch, CStyle& sty) |
194 | { | 191 | { |
195 | ch = getch(false); | 192 | ch = getch(false); |
196 | sty = mystyle; | 193 | sty = mystyle; |
197 | } | 194 | } |
198 | 195 | ||
199 | unsigned int CPlucker_base::locate() | 196 | unsigned int CPlucker_base::locate() |
200 | { | 197 | { |
201 | return currentpos; | 198 | return currentpos; |
202 | /* | 199 | /* |
203 | UInt16 thisrec = 1; | 200 | UInt16 thisrec = 1; |
204 | unsigned long locpos = 0; | 201 | unsigned long locpos = 0; |
205 | gotorecordnumber(thisrec); | 202 | gotorecordnumber(thisrec); |
206 | UInt16 thishdr_uid, thishdr_nParagraphs; | 203 | UInt16 thishdr_uid, thishdr_nParagraphs; |
207 | UInt32 thishdr_size; | 204 | UInt32 thishdr_size; |
208 | UInt8 thishdr_type, thishdr_reserved; | 205 | UInt8 thishdr_type, thishdr_reserved; |
209 | while (thisrec < bufferrec) | 206 | while (thisrec < bufferrec) |
210 | { | 207 | { |
211 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 208 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
212 | if (thishdr_type < 2) locpos += thishdr_size; | 209 | if (thishdr_type < 2) locpos += thishdr_size; |
213 | thisrec++; | 210 | thisrec++; |
214 | gotorecordnumber(thisrec); | 211 | gotorecordnumber(thisrec); |
215 | } | 212 | } |
216 | return locpos+bufferpos; | 213 | return locpos+bufferpos; |
217 | */ | 214 | */ |
218 | } | 215 | } |
219 | 216 | ||
220 | void CPlucker_base::locate(unsigned int n) | 217 | void CPlucker_base::locate(unsigned int n) |
221 | { | 218 | { |
222 | 219 | ||
223 | // clock_t start = clock(); | 220 | // clock_t start = clock(); |
224 | UInt32 textlength = currentpos - bufferpos; | 221 | UInt32 textlength = currentpos - bufferpos; |
225 | UInt16 recptr = bufferrec; | 222 | UInt16 recptr = bufferrec; |
226 | if (n < textlength/2) | 223 | if (n < textlength/2) |
227 | { | 224 | { |
228 | textlength = 0; | 225 | textlength = 0; |
229 | UInt16 thishdr_uid, thishdr_nParagraphs; | 226 | UInt16 thishdr_uid, thishdr_nParagraphs; |
230 | UInt32 thishdr_size = buffercontent; | 227 | UInt32 thishdr_size = buffercontent; |
231 | UInt8 thishdr_type, thishdr_reserved; | 228 | UInt8 thishdr_type, thishdr_reserved; |
232 | for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 229 | for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
233 | { | 230 | { |
234 | gotorecordnumber(recptr); | 231 | gotorecordnumber(recptr); |
235 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 232 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
236 | if (thishdr_type < 2) | 233 | if (thishdr_type < 2) |
237 | { | 234 | { |
238 | textlength += thishdr_size; | 235 | textlength += thishdr_size; |
239 | if (textlength > n) | 236 | if (textlength > n) |
240 | { | 237 | { |
241 | textlength -= thishdr_size; | 238 | textlength -= thishdr_size; |
242 | break; | 239 | break; |
243 | } | 240 | } |
244 | } | 241 | } |
245 | } | 242 | } |
246 | } | 243 | } |
247 | else if (n < textlength) | 244 | else if (n < textlength) |
248 | { | 245 | { |
249 | UInt16 thishdr_uid, thishdr_nParagraphs; | 246 | UInt16 thishdr_uid, thishdr_nParagraphs; |
250 | UInt32 thishdr_size; | 247 | UInt32 thishdr_size; |
251 | UInt8 thishdr_type, thishdr_reserved; | 248 | UInt8 thishdr_type, thishdr_reserved; |
252 | while (n < textlength && recptr > 1) | 249 | while (n < textlength && recptr > 1) |
253 | { | 250 | { |
254 | recptr--; | 251 | recptr--; |
255 | gotorecordnumber(recptr); | 252 | gotorecordnumber(recptr); |
256 | //qDebug("recptr:%u", recptr); | 253 | //qDebug("recptr:%u", recptr); |
257 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 254 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
258 | if (thishdr_type < 2) | 255 | if (thishdr_type < 2) |
259 | { | 256 | { |
260 | textlength -= thishdr_size; | 257 | textlength -= thishdr_size; |
261 | } | 258 | } |
262 | } | 259 | } |
263 | } | 260 | } |
264 | else | 261 | else |
265 | { | 262 | { |
266 | UInt16 thishdr_uid, thishdr_nParagraphs; | 263 | UInt16 thishdr_uid, thishdr_nParagraphs; |
267 | UInt32 thishdr_size = buffercontent; | 264 | UInt32 thishdr_size = buffercontent; |
268 | UInt8 thishdr_type, thishdr_reserved; | 265 | UInt8 thishdr_type, thishdr_reserved; |
269 | while (n > textlength + thishdr_size && recptr < ntohs(head.recordList.numRecords)-1) | 266 | while (n > textlength + thishdr_size && recptr < ntohs(head.recordList.numRecords)-1) |
270 | { | 267 | { |
271 | textlength += thishdr_size; | 268 | textlength += thishdr_size; |
272 | recptr++; | 269 | recptr++; |
273 | gotorecordnumber(recptr); | 270 | gotorecordnumber(recptr); |
274 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 271 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
275 | if (!(thishdr_type < 2)) | 272 | if (!(thishdr_type < 2)) |
276 | { | 273 | { |
277 | thishdr_size = 0; | 274 | thishdr_size = 0; |
278 | } | 275 | } |
279 | } | 276 | } |
280 | } | 277 | } |
281 | // qDebug("Time(1): %u", clock()-start); | 278 | // qDebug("Time(1): %u", clock()-start); |
282 | /* | 279 | /* |
283 | expand(recptr); | 280 | expand(recptr); |
284 | mystyle.unset(); | 281 | mystyle.unset(); |
285 | bufferpos = n-textlength; | 282 | bufferpos = n-textlength; |
286 | currentpos = n; | 283 | currentpos = n; |
287 | while (bufferpos >= m_nextPara && m_nextPara >= 0) | 284 | while (bufferpos >= m_nextPara && m_nextPara >= 0) |
288 | { | 285 | { |
289 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; | 286 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; |
290 | m_nextParaIndex++; | 287 | m_nextParaIndex++; |
291 | if (m_nextParaIndex == m_nParas) | 288 | if (m_nextParaIndex == m_nParas) |
292 | { | 289 | { |
293 | m_nextPara = -1; | 290 | m_nextPara = -1; |
294 | } | 291 | } |
295 | else | 292 | else |
296 | { | 293 | { |
297 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | 294 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; |
298 | } | 295 | } |
299 | } | 296 | } |
300 | 297 | ||
301 | return; | 298 | return; |
302 | */ | 299 | */ |
303 | // start = clock(); | 300 | // start = clock(); |
304 | 301 | ||
305 | UInt16 thisrec = 0; | 302 | UInt16 thisrec = 0; |
306 | unsigned long locpos = 0; | 303 | unsigned long locpos = 0; |
307 | unsigned long bs = 0; | 304 | unsigned long bs = 0; |
308 | UInt16 thishdr_uid, thishdr_nParagraphs; | 305 | UInt16 thishdr_uid, thishdr_nParagraphs; |
309 | UInt32 thishdr_size; | 306 | UInt32 thishdr_size; |
310 | UInt8 thishdr_type, thishdr_reserved; | 307 | UInt8 thishdr_type, thishdr_reserved; |
311 | do | 308 | do |
312 | { | 309 | { |
313 | thisrec++; | 310 | thisrec++; |
314 | locpos += bs; | 311 | locpos += bs; |
315 | gotorecordnumber(thisrec); | 312 | gotorecordnumber(thisrec); |
316 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 313 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
317 | if (thishdr_type < 2) | 314 | if (thishdr_type < 2) |
318 | { | 315 | { |
319 | bs = thishdr_size; | 316 | bs = thishdr_size; |
320 | } | 317 | } |
321 | else | 318 | else |
322 | { | 319 | { |
323 | bs = 0; | 320 | bs = 0; |
324 | } | 321 | } |
325 | } while (locpos + bs <= n); | 322 | } while (locpos + bs <= n); |
326 | 323 | ||
327 | // qDebug("Time(2): %u", clock()-start); | 324 | // qDebug("Time(2): %u", clock()-start); |
328 | if (recptr != thisrec) | 325 | if (recptr != thisrec) |
329 | { | 326 | { |
330 | qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec); | 327 | qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec); |
331 | UInt16 thishdr_uid, thishdr_nParagraphs; | 328 | UInt16 thishdr_uid, thishdr_nParagraphs; |
332 | UInt32 thishdr_size = buffercontent; | 329 | UInt32 thishdr_size = buffercontent; |
333 | UInt8 thishdr_type, thishdr_reserved; | 330 | UInt8 thishdr_type, thishdr_reserved; |
334 | for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 331 | for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
335 | { | 332 | { |
336 | gotorecordnumber(recptr); | 333 | gotorecordnumber(recptr); |
337 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 334 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
338 | // 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); | 335 | // 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); |
339 | } | 336 | } |
340 | //QApplication::exit ( 100 ); | 337 | //QApplication::exit ( 100 ); |
341 | } | 338 | } |
342 | 339 | ||
343 | currentpos = locpos; | 340 | currentpos = locpos; |
344 | expand(thisrec); | 341 | expand(thisrec); |
345 | while (currentpos < n && bufferpos < buffercontent) getch_base(true); | 342 | while (currentpos < n && bufferpos < buffercontent) getch_base(true); |
346 | 343 | ||
347 | /* // This is faster but the alignment attribute doesn't get set 8^( | 344 | /* // This is faster but the alignment attribute doesn't get set 8^( |
348 | bufferpos = n-locpos; | 345 | bufferpos = n-locpos; |
349 | currentpos = n; | 346 | currentpos = n; |
350 | while (bufferpos >= m_nextPara && m_nextPara >= 0) | 347 | while (bufferpos >= m_nextPara && m_nextPara >= 0) |
351 | { | 348 | { |
352 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; | 349 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; |
353 | m_nextParaIndex++; | 350 | m_nextParaIndex++; |
354 | if (m_nextParaIndex == m_nParas) | 351 | if (m_nextParaIndex == m_nParas) |
355 | { | 352 | { |
356 | m_nextPara = -1; | 353 | m_nextPara = -1; |
357 | } | 354 | } |
358 | else | 355 | else |
359 | { | 356 | { |
360 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | 357 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; |
361 | } | 358 | } |
362 | } | 359 | } |
363 | */ | 360 | */ |
364 | } | 361 | } |
365 | 362 | ||
366 | bool CPlucker_base::expand(int thisrec) | 363 | bool CPlucker_base::expand(int thisrec) |
367 | { | 364 | { |
368 | mystyle.unset(); | 365 | mystyle.unset(); |
369 | size_t reclen = recordlength(thisrec); | 366 | size_t reclen = recordlength(thisrec); |
370 | gotorecordnumber(thisrec); | 367 | gotorecordnumber(thisrec); |
371 | UInt16 thishdr_uid, thishdr_nParagraphs; | 368 | UInt16 thishdr_uid, thishdr_nParagraphs; |
372 | UInt32 thishdr_size; | 369 | UInt32 thishdr_size; |
373 | UInt8 thishdr_type, thishdr_reserved; | 370 | UInt8 thishdr_type, thishdr_reserved; |
374 | while (1) | 371 | while (1) |
375 | { | 372 | { |
376 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 373 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
377 | //qDebug("This (%d) type is %d, uid is %u", thisrec, thishdr_type, thishdr_uid); | 374 | //qDebug("This (%d) type is %d, uid is %u", thisrec, thishdr_type, thishdr_uid); |
378 | if (thishdr_type < 2) break; | 375 | if (thishdr_type < 2) break; |
379 | //qDebug("Skipping paragraph of type %d", thishdr_type); | 376 | //qDebug("Skipping paragraph of type %d", thishdr_type); |
380 | if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; | 377 | if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; |
381 | reclen = recordlength(thisrec); | 378 | reclen = recordlength(thisrec); |
382 | gotorecordnumber(thisrec); | 379 | gotorecordnumber(thisrec); |
383 | } | 380 | } |
384 | m_nParas = thishdr_nParagraphs; | 381 | m_nParas = thishdr_nParagraphs; |
385 | m_bufferisreserved = (thishdr_reserved != 0); | 382 | m_bufferisreserved = (thishdr_reserved != 0); |
386 | //qDebug("It has %u paragraphs and is %u bytes", thishdr_nParagraphs, thishdr_size); | 383 | //qDebug("It has %u paragraphs and is %u bytes", thishdr_nParagraphs, thishdr_size); |
387 | uid = thishdr_uid; | 384 | uid = thishdr_uid; |
388 | // gotorecordnumber(thisrec); | 385 | // gotorecordnumber(thisrec); |
389 | // fread(expandedtextbuffer,1,10,fin); | 386 | // fread(expandedtextbuffer,1,10,fin); |
390 | for (int i = 0; i < m_nParas; i++) | 387 | for (int i = 0; i < m_nParas; i++) |
391 | { | 388 | { |
392 | UInt16 ubytes, attrs; | 389 | UInt16 ubytes, attrs; |
393 | fread(&ubytes, 1, sizeof(ubytes), fin); | 390 | fread(&ubytes, 1, sizeof(ubytes), fin); |
394 | fread(&attrs, 1, sizeof(attrs), fin); | 391 | fread(&attrs, 1, sizeof(attrs), fin); |
395 | m_ParaOffsets[i] = ntohs(ubytes); | 392 | m_ParaOffsets[i] = ntohs(ubytes); |
396 | m_ParaAttrs[i] = ntohs(attrs); | 393 | m_ParaAttrs[i] = ntohs(attrs); |
397 | ////qDebug("Bytes %u, Attr %x", ntohs(ubytes), ntohs(attrs)); | 394 | ////qDebug("Bytes %u, Attr %x", ntohs(ubytes), ntohs(attrs)); |
398 | } | 395 | } |
399 | if (m_nParas > 0) | 396 | if (m_nParas > 0) |
400 | { | 397 | { |
401 | m_nextPara = m_ParaOffsets[0]; | 398 | m_nextPara = m_ParaOffsets[0]; |
402 | //qDebug("First offset = %u", m_nextPara); | 399 | //qDebug("First offset = %u", m_nextPara); |
403 | m_nextParaIndex = 0; | 400 | m_nextParaIndex = 0; |
404 | } | 401 | } |
405 | else | 402 | else |
406 | { | 403 | { |
407 | m_nextPara = -1; | 404 | m_nextPara = -1; |
408 | } | 405 | } |
409 | 406 | ||
410 | reclen -= HeaderSize()+4*m_nParas; | 407 | reclen -= HeaderSize()+4*m_nParas; |
411 | 408 | ||
412 | buffercontent = thishdr_size; | 409 | buffercontent = thishdr_size; |
413 | 410 | ||
414 | if (thishdr_size > buffersize) | 411 | if (thishdr_size > buffersize) |
415 | { | 412 | { |
416 | delete [] expandedtextbuffer; | 413 | delete [] expandedtextbuffer; |
417 | buffersize = thishdr_size; | 414 | buffersize = thishdr_size; |
418 | expandedtextbuffer = new UInt8[buffersize]; | 415 | expandedtextbuffer = new UInt8[buffersize]; |
419 | } | 416 | } |
420 | 417 | ||
421 | Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent); | 418 | Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent); |
422 | bufferpos = 0; | 419 | bufferpos = 0; |
423 | bufferrec = thisrec; | 420 | bufferrec = thisrec; |
424 | //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size); | 421 | //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size); |
425 | return true; | 422 | return true; |
426 | } | 423 | } |
427 | 424 | ||
428 | void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) | 425 | void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) |
429 | { | 426 | { |
430 | z_stream zstream; | 427 | z_stream zstream; |
431 | memset(&zstream,sizeof(zstream),0); | 428 | memset(&zstream,sizeof(zstream),0); |
432 | zstream.next_in = compressedbuffer; | 429 | zstream.next_in = compressedbuffer; |
433 | zstream.next_out = tgtbuffer; | 430 | zstream.next_out = tgtbuffer; |
434 | zstream.avail_out = bsize; | 431 | zstream.avail_out = bsize; |
435 | zstream.avail_in = reclen; | 432 | zstream.avail_in = reclen; |
436 | 433 | ||
437 | int keylen = 0; | 434 | int keylen = 0; |
438 | 435 | ||
439 | zstream.zalloc = Z_NULL; | 436 | zstream.zalloc = Z_NULL; |
440 | zstream.zfree = Z_NULL; | 437 | zstream.zfree = Z_NULL; |
441 | zstream.opaque = Z_NULL; | 438 | zstream.opaque = Z_NULL; |
442 | 439 | ||
443 | // printf("Initialising\n"); | 440 | // printf("Initialising\n"); |
444 | 441 | ||
445 | inflateInit(&zstream); | 442 | inflateInit(&zstream); |
446 | int err = 0; | 443 | int err = 0; |
447 | do { | 444 | do { |
448 | if ( zstream.avail_in == 0 && 0 < keylen ) { | 445 | if ( zstream.avail_in == 0 && 0 < keylen ) { |
449 | zstream.next_in = compressedbuffer + keylen; | 446 | zstream.next_in = compressedbuffer + keylen; |
450 | zstream.avail_in = reclen - keylen; | 447 | zstream.avail_in = reclen - keylen; |
451 | keylen = 0; | 448 | keylen = 0; |
452 | } | 449 | } |
453 | zstream.next_out = tgtbuffer; | 450 | zstream.next_out = tgtbuffer; |
454 | zstream.avail_out = bsize; | 451 | zstream.avail_out = bsize; |
455 | 452 | ||
456 | err = inflate( &zstream, Z_SYNC_FLUSH ); | 453 | err = inflate( &zstream, Z_SYNC_FLUSH ); |
457 | 454 | ||
458 | ////qDebug("err:%d - %u", err, zstream.avail_in); | 455 | ////qDebug("err:%d - %u", err, zstream.avail_in); |
459 | 456 | ||
460 | } while ( err == Z_OK ); | 457 | } while ( err == Z_OK ); |
461 | 458 | ||
462 | inflateEnd(&zstream); | 459 | inflateEnd(&zstream); |
463 | } | 460 | } |
464 | 461 | ||
465 | void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) | 462 | void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) |
466 | { | 463 | { |
467 | // UInt16 headerSize; | 464 | // UInt16 headerSize; |
468 | UInt16 docSize; | 465 | UInt16 docSize; |
469 | UInt16 i; | 466 | UInt16 i; |
470 | UInt16 j; | 467 | UInt16 j; |
471 | UInt16 k; | 468 | UInt16 k; |
472 | 469 | ||
473 | UInt8 *inBuf = compressedbuffer; | 470 | UInt8 *inBuf = compressedbuffer; |
474 | UInt8 *outBuf = tgtbuffer; | 471 | UInt8 *outBuf = tgtbuffer; |
475 | 472 | ||
476 | // headerSize = sizeof( Header ) + record->paragraphs * sizeof( Paragraph ); | 473 | // headerSize = sizeof( Header ) + record->paragraphs * sizeof( Paragraph ); |
477 | docSize = reclen; | 474 | docSize = reclen; |
478 | 475 | ||
479 | j = 0; | 476 | j = 0; |
480 | k = 0; | 477 | k = 0; |
481 | while ( j < docSize ) { | 478 | while ( j < docSize ) { |
482 | i = 0; | 479 | i = 0; |
483 | while ( i < bsize && j < docSize ) { | 480 | while ( i < bsize && j < docSize ) { |
484 | UInt16 c; | 481 | UInt16 c; |
485 | 482 | ||
486 | c = (UInt16) inBuf[ j++ ]; | 483 | c = (UInt16) inBuf[ j++ ]; |
487 | if ( 0 < c && c < 9 ) { | 484 | if ( 0 < c && c < 9 ) { |
488 | while ( 0 < c-- ) | 485 | while ( 0 < c-- ) |
489 | outBuf[ i++ ] = inBuf[ j++ ]; | 486 | outBuf[ i++ ] = inBuf[ j++ ]; |
490 | } | 487 | } |
491 | else if ( c < 0x80 ) | 488 | else if ( c < 0x80 ) |
492 | outBuf[ i++ ] = c; | 489 | outBuf[ i++ ] = c; |
493 | else if ( 0xc0 <= c ) { | 490 | else if ( 0xc0 <= c ) { |
494 | outBuf[ i++ ] = ' '; | 491 | outBuf[ i++ ] = ' '; |
495 | outBuf[ i++ ] = c ^ 0x80; | 492 | outBuf[ i++ ] = c ^ 0x80; |
496 | } | 493 | } |
497 | else { | 494 | else { |
498 | Int16 m; | 495 | Int16 m; |
499 | Int16 n; | 496 | Int16 n; |
500 | 497 | ||
501 | c <<= 8; | 498 | c <<= 8; |
502 | c += inBuf[ j++ ]; | 499 | c += inBuf[ j++ ]; |
503 | 500 | ||
504 | m = ( c & 0x3fff ) >> COUNT_BITS; | 501 | m = ( c & 0x3fff ) >> COUNT_BITS; |
505 | n = c & ( ( 1 << COUNT_BITS ) - 1 ); | 502 | n = c & ( ( 1 << COUNT_BITS ) - 1 ); |
506 | n += 2; | 503 | n += 2; |
507 | 504 | ||
508 | do { | 505 | do { |
509 | outBuf[ i ] = outBuf[ i - m ]; | 506 | outBuf[ i ] = outBuf[ i - m ]; |
510 | i++; | 507 | i++; |
511 | } while ( 0 < n-- ); | 508 | } while ( 0 < n-- ); |
512 | } | 509 | } |
513 | } | 510 | } |
514 | k += bsize; | 511 | k += bsize; |
515 | } | 512 | } |
516 | } | 513 | } |
517 | 514 | ||
518 | void CPlucker_base::home() | 515 | void CPlucker_base::home() |
519 | { | 516 | { |
520 | currentpos = 0; | 517 | currentpos = 0; |
521 | expand(1); | 518 | expand(1); |
522 | } | 519 | } |
523 | 520 | ||
524 | CList<Bkmk>* CPlucker_base::getbkmklist() | 521 | CList<Bkmk>* CPlucker_base::getbkmklist() |
525 | { | 522 | { |
526 | /* | 523 | /* |
527 | UInt16 thishdr_uid, thishdr_nParagraphs; | 524 | UInt16 thishdr_uid, thishdr_nParagraphs; |
528 | UInt32 thishdr_size; | 525 | UInt32 thishdr_size; |
529 | UInt8 thishdr_type, thishdr_reserved; | 526 | UInt8 thishdr_type, thishdr_reserved; |
530 | 527 | ||
531 | for (int i = 1; i < ntohs(head.recordList.numRecords); i++) | 528 | for (int i = 1; i < ntohs(head.recordList.numRecords); i++) |
532 | { | 529 | { |
533 | gotorecordnumber(i); | 530 | gotorecordnumber(i); |
534 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 531 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
535 | if (thishdr_type == 8) | 532 | if (thishdr_type == 8) |
536 | { | 533 | { |
537 | UInt16 n; | 534 | UInt16 n; |
538 | fread(&n, 1, sizeof(n), fin); | 535 | fread(&n, 1, sizeof(n), fin); |
539 | n = ntohs(n); | 536 | n = ntohs(n); |
540 | //qDebug("Found %u bookmarks", n); | 537 | //qDebug("Found %u bookmarks", n); |
541 | } | 538 | } |
542 | //qDebug("Found:%d, %u", i , thishdr_type); | 539 | //qDebug("Found:%d, %u", i , thishdr_type); |
543 | } | 540 | } |
544 | */ | 541 | */ |
545 | return NULL; | 542 | return NULL; |
546 | } | 543 | } |
547 | 544 | ||
548 | #include <qnamespace.h> | ||
549 | 545 | ||
550 | QImage* CPlucker_base::expandimg(UInt16 tgt, bool border) | 546 | QImage* CPlucker_base::expandimg(UInt16 tgt, bool border) |
551 | { | 547 | { |
552 | QImage* qimage = getimg(tgt); | 548 | QImage* qimage = getimg(tgt); |
553 | QImage* ret; | 549 | QImage* ret; |
554 | if (qimage == NULL) return NULL; | 550 | if (qimage == NULL) return NULL; |
555 | if (border) | 551 | if (border) |
556 | { | 552 | { |
557 | QPixmap* image = new QPixmap(0,0); | 553 | QPixmap* image = new QPixmap(0,0); |
558 | image->convertFromImage(*qimage); | 554 | image->convertFromImage(*qimage); |
559 | delete qimage; | 555 | delete qimage; |
560 | QPixmap* pret = new QPixmap(image->width()+4, image->height()+4); | 556 | QPixmap* pret = new QPixmap(image->width()+4, image->height()+4); |
561 | pret->fill(Qt::red); | 557 | pret->fill(Qt::red); |
562 | bitBlt(pret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP); | 558 | bitBlt(pret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP); |
563 | delete image; | 559 | delete image; |
564 | ret = new QImage(pret->convertToImage()); | 560 | ret = new QImage(pret->convertToImage()); |
565 | } | 561 | } |
566 | else | 562 | else |
567 | { | 563 | { |
568 | ret = qimage; | 564 | ret = qimage; |
569 | } | 565 | } |
570 | return ret; | 566 | return ret; |
571 | } | 567 | } |
572 | 568 | ||
573 | #ifdef _BUFFERPICS | 569 | #ifdef _BUFFERPICS |
574 | #include <qmap.h> | 570 | #include <qmap.h> |
575 | #endif | 571 | #endif |
576 | 572 | ||
577 | QImage* CPlucker_base::getPicture(unsigned long tgt) | 573 | QImage* CPlucker_base::getPicture(unsigned long tgt) |
578 | { | 574 | { |
579 | #ifdef _BUFFERPICS | 575 | #ifdef _BUFFERPICS |
580 | static QMap<unsigned long, QPixmap> pix; | 576 | static QMap<unsigned long, QPixmap> pix; |
581 | QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt); | 577 | QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt); |
582 | if (t == pix.end()) | 578 | if (t == pix.end()) |
583 | { | 579 | { |
584 | pix[tgt] = *expandimg(tgt); | 580 | pix[tgt] = *expandimg(tgt); |
585 | return &pix[tgt]; | 581 | return &pix[tgt]; |
586 | } | 582 | } |
587 | else | 583 | else |
588 | return &(t.data()); | 584 | return &(t.data()); |
589 | #else | 585 | #else |
590 | return expandimg(tgt >> 16); | 586 | return expandimg(tgt >> 16); |
591 | #endif | 587 | #endif |
592 | } | 588 | } |
593 | 589 | ||
594 | #ifdef LOCALPICTURES | 590 | #ifdef LOCALPICTURES |
595 | #include <unistd.h> | 591 | #include <unistd.h> |
596 | #include <qpe/global.h> | 592 | #include <qpe/global.h> |
597 | void CPlucker_base::showimg(UInt16 tgt) | 593 | void CPlucker_base::showimg(UInt16 tgt) |
598 | { | 594 | { |
599 | //qDebug("Crassssssh!"); | 595 | //qDebug("Crassssssh!"); |
600 | QPixmap* qimage = expandimg(tgt); | 596 | QPixmap* qimage = expandimg(tgt); |
601 | m_picture->setFixedSize(qimage->size()); | 597 | m_picture->setFixedSize(qimage->size()); |
602 | m_picture->setBackgroundPixmap(*qimage); | 598 | m_picture->setBackgroundPixmap(*qimage); |
603 | delete qimage; | 599 | delete qimage; |
604 | m_viewer->show(); | 600 | m_viewer->show(); |
605 | 601 | ||
606 | /* | 602 | /* |
607 | char tmp[] = "uqtreader.XXXXXX"; | 603 | char tmp[] = "uqtreader.XXXXXX"; |
608 | QImage* qimage = getimg(tgt); | 604 | QImage* qimage = getimg(tgt); |
609 | QPixmap* image = new QPixmap(0,0); | 605 | QPixmap* image = new QPixmap(0,0); |
610 | // //qDebug("New image"); | 606 | // //qDebug("New image"); |
611 | image->convertFromImage(*qimage); | 607 | image->convertFromImage(*qimage); |
612 | delete qimage; | 608 | delete qimage; |
613 | char tmpfile[sizeof(tmp)+1]; | 609 | char tmpfile[sizeof(tmp)+1]; |
614 | strcpy(tmpfile,tmp); | 610 | strcpy(tmpfile,tmp); |
615 | int f = mkstemp(tmpfile); | 611 | int f = mkstemp(tmpfile); |
616 | close(f); | 612 | close(f); |
617 | //qDebug("TMPFILE:%s", tmpfile); | 613 | //qDebug("TMPFILE:%s", tmpfile); |
618 | if (image->save(tmpfile,"PNG")) | 614 | if (image->save(tmpfile,"PNG")) |
619 | { | 615 | { |
620 | QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)"); | 616 | QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)"); |
621 | e << QString(tmpfile); | 617 | e << QString(tmpfile); |
622 | } | 618 | } |
623 | Global::statusMessage("Opening image"); | 619 | Global::statusMessage("Opening image"); |
624 | sleep(5); | 620 | sleep(5); |
625 | delete image; | 621 | delete image; |
626 | unlink(tmpfile); | 622 | unlink(tmpfile); |
627 | */ | 623 | */ |
628 | } | 624 | } |
629 | 625 | ||
630 | #endif | 626 | #endif |
631 | 627 | ||
632 | unsigned short CPlucker_base::finduid(unsigned short urlid) | 628 | unsigned short CPlucker_base::finduid(unsigned short urlid) |
633 | { | 629 | { |
634 | // //qDebug("Finding %u", urlid); | 630 | // //qDebug("Finding %u", urlid); |
635 | unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); | 631 | unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); |
636 | unsigned short jmid = (jmin+jmax) >> 1; | 632 | unsigned short jmid = (jmin+jmax) >> 1; |
637 | while (jmax - jmin > 1) | 633 | while (jmax - jmin > 1) |
638 | { | 634 | { |
639 | gotorecordnumber(jmid); | 635 | gotorecordnumber(jmid); |
640 | UInt16 thishdr_uid, thishdr_nParagraphs; | 636 | UInt16 thishdr_uid, thishdr_nParagraphs; |
641 | UInt32 thishdr_size; | 637 | UInt32 thishdr_size; |
642 | UInt8 thishdr_type, thishdr_reserved; | 638 | UInt8 thishdr_type, thishdr_reserved; |
643 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 639 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
644 | unsigned short luid = thishdr_uid; | 640 | unsigned short luid = thishdr_uid; |
645 | ////qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); | 641 | ////qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); |
646 | if (luid == urlid) | 642 | if (luid == urlid) |
647 | { | 643 | { |
648 | return jmid; | 644 | return jmid; |
649 | } | 645 | } |
650 | if (luid < urlid) | 646 | if (luid < urlid) |
651 | { | 647 | { |
652 | jmin = jmid; | 648 | jmin = jmid; |
653 | } | 649 | } |
654 | else | 650 | else |
655 | { | 651 | { |
656 | jmax = jmid; | 652 | jmax = jmid; |
657 | } | 653 | } |
658 | jmid = (jmin+jmax) >> 1; | 654 | jmid = (jmin+jmax) >> 1; |
659 | } | 655 | } |
660 | gotorecordnumber(jmin); | 656 | gotorecordnumber(jmin); |
661 | UInt16 thishdr_uid, thishdr_nParagraphs; | 657 | UInt16 thishdr_uid, thishdr_nParagraphs; |
662 | UInt32 thishdr_size; | 658 | UInt32 thishdr_size; |
663 | UInt8 thishdr_type, thishdr_reserved; | 659 | UInt8 thishdr_type, thishdr_reserved; |
664 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 660 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
665 | unsigned short luid = thishdr_uid; | 661 | unsigned short luid = thishdr_uid; |
666 | //qDebug("jmin at end:%u,%u", jmin, luid); | 662 | //qDebug("jmin at end:%u,%u", jmin, luid); |
667 | if (luid == urlid) | 663 | if (luid == urlid) |
668 | { | 664 | { |
669 | return jmin; | 665 | return jmin; |
670 | } | 666 | } |
671 | gotorecordnumber(jmax); | 667 | gotorecordnumber(jmax); |
672 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 668 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
673 | luid = thishdr_uid; | 669 | luid = thishdr_uid; |
674 | //qDebug("jmax at end:%u,%u", jmax, luid); | 670 | //qDebug("jmax at end:%u,%u", jmax, luid); |
675 | if (luid == urlid) | 671 | if (luid == urlid) |
676 | { | 672 | { |
677 | return jmax; | 673 | return jmax; |
678 | } | 674 | } |
679 | //qDebug("Couldn't find %u", urlid); | 675 | //qDebug("Couldn't find %u", urlid); |
680 | return 0; // Not found! | 676 | return 0; // Not found! |
681 | } | 677 | } |
682 | 678 | ||
683 | #include <qnamespace.h> | ||
684 | 679 | ||
685 | void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | 680 | void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) |
686 | { | 681 | { |
687 | unsigned short sz = 0; | 682 | unsigned short sz = 0; |
688 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | 683 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) |
689 | { | 684 | { |
690 | sz++; | 685 | sz++; |
691 | } | 686 | } |
692 | size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long); | 687 | size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long); |
693 | unsigned char* newdata = new unsigned char[newlen]; | 688 | unsigned char* newdata = new unsigned char[newlen]; |
694 | unsigned char* pdata = newdata; | 689 | unsigned char* pdata = newdata; |
695 | memcpy(newdata, src, srclen); | 690 | memcpy(newdata, src, srclen); |
696 | newdata += srclen; | 691 | newdata += srclen; |
697 | memcpy(newdata, &sz, sizeof(sz)); | 692 | memcpy(newdata, &sz, sizeof(sz)); |
698 | newdata += sizeof(sz); | 693 | newdata += sizeof(sz); |
699 | #ifdef _WINDOWS | 694 | #ifdef _WINDOWS |
700 | for (it = visited.begin(); it != visited.end(); it++) | 695 | for (it = visited.begin(); it != visited.end(); it++) |
701 | #else | 696 | #else |
702 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | 697 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) |
703 | #endif | 698 | #endif |
704 | { | 699 | { |
705 | unsigned long t = *it; | 700 | unsigned long t = *it; |
706 | //qDebug("[%u]", t); | 701 | //qDebug("[%u]", t); |
707 | memcpy(newdata, &t, sizeof(t)); | 702 | memcpy(newdata, &t, sizeof(t)); |
708 | newdata += sizeof(t); | 703 | newdata += sizeof(t); |
709 | } | 704 | } |
710 | m_nav.setSaveData(data, len, pdata, newlen); | 705 | m_nav.setSaveData(data, len, pdata, newlen); |
711 | delete [] pdata; | 706 | delete [] pdata; |
712 | } | 707 | } |
713 | 708 | ||
714 | void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen) | 709 | void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen) |
715 | { | 710 | { |
716 | unsigned short sz; | 711 | unsigned short sz; |
717 | if (srclen >= sizeof(sz)) | 712 | if (srclen >= sizeof(sz)) |
718 | { | 713 | { |
719 | memcpy(&sz, src, sizeof(sz)); | 714 | memcpy(&sz, src, sizeof(sz)); |
720 | src += sizeof(sz); | 715 | src += sizeof(sz); |
721 | srclen -= sizeof(sz); | 716 | srclen -= sizeof(sz); |
722 | } | 717 | } |
723 | for (int i = 0; i < sz; i++) | 718 | for (int i = 0; i < sz; i++) |
724 | { | 719 | { |
725 | unsigned long t; | 720 | unsigned long t; |
726 | if (srclen >= sizeof(t)) | 721 | if (srclen >= sizeof(t)) |
727 | { | 722 | { |
728 | memcpy(&t, src, sizeof(t)); | 723 | memcpy(&t, src, sizeof(t)); |
729 | // qDebug("[%u]", t); | 724 | // qDebug("[%u]", t); |
730 | visited.push_front(t); | 725 | visited.push_front(t); |
731 | src += sizeof(t); | 726 | src += sizeof(t); |
732 | srclen -= sizeof(t); | 727 | srclen -= sizeof(t); |
733 | } | 728 | } |
734 | else | 729 | else |
735 | { | 730 | { |
736 | QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself"); | 731 | QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself"); |
737 | break; | 732 | break; |
738 | } | 733 | } |
739 | } | 734 | } |
740 | m_nav.putSaveData(src, srclen); | 735 | m_nav.putSaveData(src, srclen); |
741 | } | 736 | } |
742 | 737 | ||
743 | int CPlucker_base::OpenFile(const char *src) | 738 | int CPlucker_base::OpenFile(const char *src) |
744 | { | 739 | { |
745 | m_lastBreak = 0; | 740 | m_lastBreak = 0; |
746 | if (!Cpdb::openfile(src)) | 741 | if (!Cpdb::openfile(src)) |
747 | { | 742 | { |
748 | return -1; | 743 | return -1; |
749 | } | 744 | } |
750 | 745 | ||
751 | if (!CorrectDecoder()) return -1; | 746 | if (!CorrectDecoder()) return -1; |
752 | 747 | ||
753 | gotorecordnumber(0); | 748 | gotorecordnumber(0); |
754 | fread(&hdr0, 1, 6, fin); | 749 | fread(&hdr0, 1, 6, fin); |
755 | setbuffersize(); | 750 | setbuffersize(); |
756 | compressedtextbuffer = new UInt8[compressedbuffersize]; | 751 | compressedtextbuffer = new UInt8[compressedbuffersize]; |
757 | expandedtextbuffer = new UInt8[buffersize]; | 752 | expandedtextbuffer = new UInt8[buffersize]; |
758 | 753 | ||
759 | //qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); | 754 | //qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); |
760 | 755 | ||
761 | unsigned int nrecs = ntohs(hdr0.nRecords); | 756 | unsigned int nrecs = ntohs(hdr0.nRecords); |
762 | //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); | 757 | //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); |
763 | UInt16 homerecid = 1; | 758 | UInt16 homerecid = 1; |
764 | for (unsigned int i = 0; i < nrecs; i++) | 759 | for (unsigned int i = 0; i < nrecs; i++) |
765 | { | 760 | { |
766 | UInt16 id, name; | 761 | UInt16 id, name; |
767 | fread(&name, 1, sizeof(name), fin); | 762 | fread(&name, 1, sizeof(name), fin); |
768 | fread(&id, 1, sizeof(id), fin); | 763 | fread(&id, 1, sizeof(id), fin); |
769 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); | 764 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); |
770 | if (ntohs(name) == 0) homerecid = ntohs(id); | 765 | if (ntohs(name) == 0) homerecid = ntohs(id); |
771 | } | 766 | } |
772 | 767 | ||
773 | textlength = 0; | 768 | textlength = 0; |
774 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 769 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
775 | { | 770 | { |
776 | gotorecordnumber(recptr); | 771 | gotorecordnumber(recptr); |
777 | UInt16 thishdr_uid, thishdr_nParagraphs; | 772 | UInt16 thishdr_uid, thishdr_nParagraphs; |
778 | UInt32 thishdr_size; | 773 | UInt32 thishdr_size; |
779 | UInt8 thishdr_type, thishdr_reserved; | 774 | UInt8 thishdr_type, thishdr_reserved; |
780 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 775 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
781 | if (thishdr_uid == homerecid) | 776 | if (thishdr_uid == homerecid) |
782 | { | 777 | { |
783 | m_homepos = textlength; | 778 | m_homepos = textlength; |
784 | break; | 779 | break; |
785 | } | 780 | } |
786 | if (thishdr_type < 2) textlength += thishdr_size; | 781 | if (thishdr_type < 2) textlength += thishdr_size; |
787 | } | 782 | } |
788 | textlength = 0; | 783 | textlength = 0; |
789 | home(); | 784 | home(); |
790 | #ifdef LOCALPICTURES | 785 | #ifdef LOCALPICTURES |
791 | if (m_viewer == NULL) | 786 | if (m_viewer == NULL) |
792 | { | 787 | { |
793 | m_viewer = new QScrollView(NULL); | 788 | m_viewer = new QScrollView(NULL); |
794 | m_picture = new QWidget(m_viewer->viewport()); | 789 | m_picture = new QWidget(m_viewer->viewport()); |
795 | m_viewer->addChild(m_picture); | 790 | m_viewer->addChild(m_picture); |
796 | } | 791 | } |
797 | #endif | 792 | #endif |
798 | return 0; | 793 | return 0; |
799 | 794 | ||
800 | } | 795 | } |
801 | 796 | ||
802 | QImage* CPlucker_base::getimg(UInt16 tgt) | 797 | QImage* CPlucker_base::getimg(UInt16 tgt) |
803 | { | 798 | { |
804 | size_t reclen; | 799 | size_t reclen; |
805 | UInt16 thisrec = finduid(tgt); | 800 | UInt16 thisrec = finduid(tgt); |
806 | reclen = recordlength(thisrec); | 801 | reclen = recordlength(thisrec); |
807 | gotorecordnumber(thisrec); | 802 | gotorecordnumber(thisrec); |
808 | UInt16 thishdr_uid, thishdr_nParagraphs; | 803 | UInt16 thishdr_uid, thishdr_nParagraphs; |
809 | UInt32 thishdr_size; | 804 | UInt32 thishdr_size; |
810 | UInt8 thishdr_type, thishdr_reserved; | 805 | UInt8 thishdr_type, thishdr_reserved; |
811 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 806 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
812 | reclen -= HeaderSize(); | 807 | reclen -= HeaderSize(); |
813 | 808 | ||
814 | UInt32 imgsize = thishdr_size; | 809 | UInt32 imgsize = thishdr_size; |
815 | UInt8* imgbuffer = new UInt8[imgsize]; | 810 | UInt8* imgbuffer = new UInt8[imgsize]; |
816 | 811 | ||
817 | Expand(reclen, thishdr_type, imgbuffer, imgsize); | 812 | Expand(reclen, thishdr_type, imgbuffer, imgsize); |
818 | 813 | ||
819 | return imagefromdata(imgbuffer, imgsize); | 814 | return imagefromdata(imgbuffer, imgsize); |
820 | } | 815 | } |
821 | 816 | ||
822 | linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) | 817 | linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) |
823 | { | 818 | { |
824 | visited.push_front(n); | 819 | visited.push_front(n); |
825 | UInt16 tuid = (n >> 16); | 820 | UInt16 tuid = (n >> 16); |
826 | n &= 0xffff; | 821 | n &= 0xffff; |
827 | // //qDebug("Hyper:<%u,%u>", tuid, n); | 822 | // //qDebug("Hyper:<%u,%u>", tuid, n); |
828 | UInt16 thisrec = 1; | 823 | UInt16 thisrec = 1; |
829 | currentpos = 0; | 824 | currentpos = 0; |
830 | gotorecordnumber(thisrec); | 825 | gotorecordnumber(thisrec); |
831 | UInt16 thishdr_uid, thishdr_nParagraphs; | 826 | UInt16 thishdr_uid, thishdr_nParagraphs; |
832 | UInt32 thishdr_size; | 827 | UInt32 thishdr_size; |
833 | UInt8 thishdr_type, thishdr_reserved; | 828 | UInt8 thishdr_type, thishdr_reserved; |
834 | while (1) | 829 | while (1) |
835 | { | 830 | { |
836 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 831 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
837 | if (tuid == thishdr_uid) break; | 832 | if (tuid == thishdr_uid) break; |
838 | if (thishdr_type < 2) currentpos += thishdr_size; | 833 | if (thishdr_type < 2) currentpos += thishdr_size; |
839 | ////qDebug("hyper-cp:%u", currentpos); | 834 | ////qDebug("hyper-cp:%u", currentpos); |
840 | thisrec++; | 835 | thisrec++; |
841 | if (thisrec >= ntohs(head.recordList.numRecords)) | 836 | if (thisrec >= ntohs(head.recordList.numRecords)) |
842 | { | 837 | { |
843 | char *turl = geturl(tuid); | 838 | char *turl = geturl(tuid); |
844 | if (turl == NULL) | 839 | if (turl == NULL) |
845 | { | 840 | { |
846 | QMessageBox::information(NULL, | 841 | QMessageBox::information(NULL, |
847 | QString(PROGNAME), | 842 | QString(PROGNAME), |
848 | QString("Couldn't find link") | 843 | QString("Couldn't find link") |
849 | ); | 844 | ); |
850 | } | 845 | } |
851 | else | 846 | else |
852 | { | 847 | { |
853 | wrd = turl; | 848 | wrd = turl; |
854 | #ifdef USEQPE | 849 | #ifdef USEQPE |
855 | if (wrd.length() > 10) | 850 | if (wrd.length() > 10) |
856 | { | 851 | { |
857 | Global::statusMessage(wrd.left(8) + ".."); | 852 | Global::statusMessage(wrd.left(8) + ".."); |
858 | } | 853 | } |
859 | else | 854 | else |
860 | { | 855 | { |
861 | Global::statusMessage(wrd); | 856 | Global::statusMessage(wrd); |
862 | } | 857 | } |
863 | #else | 858 | #else |
864 | #endif /* USEQPE */ | 859 | #endif /* USEQPE */ |
865 | //qDebug("Link:%s", (const char*)wrd); | 860 | //qDebug("Link:%s", (const char*)wrd); |
866 | // setlink(fn, wrd); | 861 | // setlink(fn, wrd); |
867 | delete [] turl; | 862 | delete [] turl; |
868 | } | 863 | } |
869 | return eNone; | 864 | return eNone; |
870 | } | 865 | } |
871 | gotorecordnumber(thisrec); | 866 | gotorecordnumber(thisrec); |
872 | } | 867 | } |
873 | if (thishdr_type > 1) | 868 | if (thishdr_type > 1) |
874 | { | 869 | { |
875 | if (thishdr_type == 4) | 870 | if (thishdr_type == 4) |
876 | { | 871 | { |
877 | QMessageBox::information(NULL, | 872 | QMessageBox::information(NULL, |
878 | QString(PROGNAME), | 873 | QString(PROGNAME), |
879 | QString("Mailto links\nnot yet supported (2)")); | 874 | QString("Mailto links\nnot yet supported (2)")); |
880 | } | 875 | } |
881 | else | 876 | else |
882 | { | 877 | { |
883 | if (thishdr_type > 3) | 878 | if (thishdr_type > 3) |
884 | { | 879 | { |
885 | QMessageBox::information(NULL, | 880 | QMessageBox::information(NULL, |
886 | QString(PROGNAME), | 881 | QString(PROGNAME), |
887 | QString("External links\nnot yet supported (2)") | 882 | QString("External links\nnot yet supported (2)") |
888 | ); | 883 | ); |
889 | return eNone; | 884 | return eNone; |
890 | } | 885 | } |
891 | else | 886 | else |
892 | { | 887 | { |
893 | #ifdef LOCALPICTURES | 888 | #ifdef LOCALPICTURES |
894 | showimg(tuid); | 889 | showimg(tuid); |
895 | #else | 890 | #else |
896 | return ePicture; | 891 | return ePicture; |
897 | #endif | 892 | #endif |
898 | } | 893 | } |
899 | } | 894 | } |
900 | return eNone; | 895 | return eNone; |
901 | } | 896 | } |
902 | /* | 897 | /* |
903 | if (thishdr_type == 2 || thishdr_type == 3) | 898 | if (thishdr_type == 2 || thishdr_type == 3) |
904 | { | 899 | { |
905 | expandimg(thisrec); | 900 | expandimg(thisrec); |
906 | 901 | ||
907 | } | 902 | } |
908 | */ | 903 | */ |
909 | else | 904 | else |
910 | { | 905 | { |
911 | expand(thisrec); | 906 | expand(thisrec); |
912 | if (n != 0) | 907 | if (n != 0) |
913 | { | 908 | { |
914 | if (n >= m_nParas) | 909 | if (n >= m_nParas) |
915 | { | 910 | { |
916 | QMessageBox::information(NULL, | 911 | QMessageBox::information(NULL, |
917 | QString(PROGNAME), | 912 | QString(PROGNAME), |
918 | QString("Error in link\nPara # too big") | 913 | QString("Error in link\nPara # too big") |
919 | ); | 914 | ); |
920 | return eNone; | 915 | return eNone; |
921 | } | 916 | } |
922 | unsigned int noff = 0; | 917 | unsigned int noff = 0; |
923 | for (unsigned int i = 0; i < n; i++) noff += m_ParaOffsets[i]; | 918 | for (unsigned int i = 0; i < n; i++) noff += m_ParaOffsets[i]; |
924 | n = noff; | 919 | n = noff; |
925 | } | 920 | } |
926 | if (n > thishdr_size) | 921 | if (n > thishdr_size) |
927 | { | 922 | { |
928 | QMessageBox::information(NULL, | 923 | QMessageBox::information(NULL, |
929 | QString(PROGNAME), | 924 | QString(PROGNAME), |
930 | QString("Error in link\nOffset too big") | 925 | QString("Error in link\nOffset too big") |
931 | ); | 926 | ); |
932 | return eNone; | 927 | return eNone; |
933 | } | 928 | } |
934 | //qDebug("Hyper:<%u,%u>", tuid, n); | 929 | //qDebug("Hyper:<%u,%u>", tuid, n); |
935 | while (bufferpos < n && bufferpos < buffercontent) getch_base(true); | 930 | while (bufferpos < n && bufferpos < buffercontent) getch_base(true); |
936 | /* // This is faster but the alignment doesn't get set | 931 | /* // This is faster but the alignment doesn't get set |
937 | mystyle.unset(); | 932 | mystyle.unset(); |
938 | bufferpos = n; | 933 | bufferpos = n; |
939 | currentpos += n; | 934 | currentpos += n; |
940 | while (bufferpos >= m_nextPara && m_nextPara >= 0) | 935 | while (bufferpos >= m_nextPara && m_nextPara >= 0) |
941 | { | 936 | { |
942 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; | 937 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; |
943 | m_nextParaIndex++; | 938 | m_nextParaIndex++; |
944 | if (m_nextParaIndex == m_nParas) | 939 | if (m_nextParaIndex == m_nParas) |
945 | { | 940 | { |
946 | m_nextPara = -1; | 941 | m_nextPara = -1; |
947 | } | 942 | } |
948 | else | 943 | else |
949 | { | 944 | { |
950 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | 945 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; |
951 | } | 946 | } |
952 | } | 947 | } |
953 | */ | 948 | */ |
954 | } | 949 | } |
955 | return eLink; | 950 | return eLink; |
956 | } | 951 | } |
957 | 952 | ||
958 | tchar CPlucker_base::getch_base(bool fast) | 953 | tchar CPlucker_base::getch_base(bool fast) |
959 | { | 954 | { |
960 | int ch = bgetch(); | 955 | int ch = bgetch(); |
961 | while (ch == 0) | 956 | while (ch == 0) |
962 | { | 957 | { |
963 | ch = bgetch(); | 958 | ch = bgetch(); |
964 | ////qDebug("Function:%x", ch); | 959 | ////qDebug("Function:%x", ch); |
965 | switch (ch) | 960 | switch (ch) |
966 | { | 961 | { |
967 | case 0x38: | 962 | case 0x38: |
968 | // //qDebug("Break:%u", locate()); | 963 | // //qDebug("Break:%u", locate()); |
969 | if (m_lastBreak == locate()) | 964 | if (m_lastBreak == locate()) |
970 | { | 965 | { |
971 | ch = bgetch(); | 966 | ch = bgetch(); |
972 | } | 967 | } |
973 | else | 968 | else |
974 | { | 969 | { |
975 | ch = 10; | 970 | ch = 10; |
976 | } | 971 | } |
977 | m_lastBreak = locate(); | 972 | m_lastBreak = locate(); |
978 | break; | 973 | break; |
979 | case 0x0a: | 974 | case 0x0a: |
980 | case 0x0c: | 975 | case 0x0c: |
981 | { | 976 | { |
982 | unsigned long ln = 0; | 977 | unsigned long ln = 0; |
983 | int skip = ch & 7; | 978 | int skip = ch & 7; |
984 | for (int i = 0; i < 2; i++) | 979 | for (int i = 0; i < 2; i++) |
985 | { | 980 | { |
986 | int ch = bgetch(); | 981 | int ch = bgetch(); |
987 | ln = (ln << 8) + ch; | 982 | ln = (ln << 8) + ch; |
988 | // //qDebug("ch:%d, ln:%u", ch, ln); | 983 | // //qDebug("ch:%d, ln:%u", ch, ln); |
989 | } | 984 | } |
990 | if (skip == 2) | 985 | if (skip == 2) |
991 | { | 986 | { |
992 | ln <<= 16; | 987 | ln <<= 16; |
993 | } | 988 | } |
994 | else | 989 | else |
995 | { | 990 | { |
996 | for (int i = 0; i < 2; i++) | 991 | for (int i = 0; i < 2; i++) |
997 | { | 992 | { |
998 | int ch = bgetch(); | 993 | int ch = bgetch(); |
999 | ln = (ln << 8) + ch; | 994 | ln = (ln << 8) + ch; |
1000 | // //qDebug("ch:%d, ln:%u", ch, ln); | 995 | // //qDebug("ch:%d, ln:%u", ch, ln); |
1001 | } | 996 | } |
1002 | } | 997 | } |
1003 | // //qDebug("ln:%u", ln); | 998 | // //qDebug("ln:%u", ln); |
1004 | mystyle.setLink(true); | 999 | mystyle.setLink(true); |
1005 | mystyle.setData(ln); | 1000 | mystyle.setData(ln); |
1006 | // mystyle.setColour(255, 0, 0); | 1001 | // mystyle.setColour(255, 0, 0); |
1007 | bool hasseen = false; | 1002 | bool hasseen = false; |
1008 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | 1003 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) |
1009 | { | 1004 | { |
1010 | if (*it == ln) | 1005 | if (*it == ln) |
1011 | { | 1006 | { |
1012 | hasseen = true; | 1007 | hasseen = true; |
1013 | break; | 1008 | break; |
1014 | } | 1009 | } |
1015 | } | 1010 | } |
1016 | if (hasseen) | 1011 | if (hasseen) |
1017 | { | 1012 | { |
1018 | mystyle.setStrikethru(); | 1013 | mystyle.setStrikethru(); |
1019 | } | 1014 | } |
1020 | else | 1015 | else |
1021 | { | 1016 | { |
1022 | mystyle.setUnderline(); | 1017 | mystyle.setUnderline(); |
1023 | } | 1018 | } |
1024 | ch = bgetch(); | 1019 | ch = bgetch(); |
1025 | } | 1020 | } |
1026 | break; | 1021 | break; |
1027 | case 0x08: | 1022 | case 0x08: |
1028 | ch = bgetch(); | 1023 | ch = bgetch(); |
1029 | // mystyle.setColour(0, 0, 0); | 1024 | // mystyle.setColour(0, 0, 0); |
1030 | mystyle.unsetUnderline(); | 1025 | mystyle.unsetUnderline(); |
1031 | mystyle.unsetStrikethru(); | 1026 | mystyle.unsetStrikethru(); |
1032 | mystyle.setLink(false); | 1027 | mystyle.setLink(false); |
1033 | mystyle.setData(0); | 1028 | mystyle.setData(0); |
1034 | break; | 1029 | break; |
1035 | case 0x40: | 1030 | case 0x40: |
1036 | mystyle.setItalic(); | 1031 | mystyle.setItalic(); |
1037 | ch = bgetch(); | 1032 | ch = bgetch(); |
1038 | break; | 1033 | break; |
1039 | case 0x48: | 1034 | case 0x48: |
1040 | mystyle.unsetItalic(); | 1035 | mystyle.unsetItalic(); |
1041 | ch = bgetch(); | 1036 | ch = bgetch(); |
1042 | break; | 1037 | break; |
1043 | case 0x11: | 1038 | case 0x11: |
1044 | { | 1039 | { |
1045 | ch = bgetch(); | 1040 | ch = bgetch(); |
1046 | // //qDebug("Font:%d",ch); | 1041 | // //qDebug("Font:%d",ch); |
1047 | mystyle.setVOffset(0); | 1042 | mystyle.setVOffset(0); |
1048 | mystyle.unsetMono(); | 1043 | mystyle.unsetMono(); |
1049 | mystyle.unsetBold(); | 1044 | mystyle.unsetBold(); |
1050 | mystyle.setFontSize(0); | 1045 | mystyle.setFontSize(0); |
1051 | switch (ch) | 1046 | switch (ch) |
1052 | { | 1047 | { |
1053 | case 0: | 1048 | case 0: |
1054 | break; | 1049 | break; |
1055 | case 1: | 1050 | case 1: |
1056 | mystyle.setBold(); | 1051 | mystyle.setBold(); |
1057 | mystyle.setFontSize(3); | 1052 | mystyle.setFontSize(3); |
1058 | break; | 1053 | break; |
1059 | case 2: | 1054 | case 2: |
1060 | mystyle.setBold(); | 1055 | mystyle.setBold(); |
1061 | mystyle.setFontSize(2); | 1056 | mystyle.setFontSize(2); |
1062 | break; | 1057 | break; |
1063 | case 3: | 1058 | case 3: |
1064 | mystyle.setBold(); | 1059 | mystyle.setBold(); |
1065 | mystyle.setFontSize(1); | 1060 | mystyle.setFontSize(1); |
1066 | break; | 1061 | break; |
1067 | case 4: | 1062 | case 4: |
1068 | mystyle.setBold(); | 1063 | mystyle.setBold(); |
1069 | break; | 1064 | break; |
1070 | case 5: | 1065 | case 5: |
1071 | mystyle.setBold(); | 1066 | mystyle.setBold(); |
1072 | break; | 1067 | break; |
1073 | case 6: | 1068 | case 6: |
1074 | mystyle.setBold(); | 1069 | mystyle.setBold(); |
1075 | break; | 1070 | break; |
1076 | case 7: | 1071 | case 7: |
1077 | mystyle.setBold(); | 1072 | mystyle.setBold(); |
1078 | break; | 1073 | break; |
1079 | case 8: // should be fixed width | 1074 | case 8: // should be fixed width |
1080 | //qDebug("Trying fixed width"); | 1075 | //qDebug("Trying fixed width"); |
1081 | mystyle.setMono(); | 1076 | mystyle.setMono(); |
1082 | break; | 1077 | break; |
1083 | case 9: | 1078 | case 9: |
1084 | mystyle.setFontSize(-1); | 1079 | mystyle.setFontSize(-1); |
1085 | break; | 1080 | break; |
1086 | case 10: | 1081 | case 10: |
1087 | mystyle.setFontSize(-2); | 1082 | mystyle.setFontSize(-2); |
1088 | mystyle.setVOffset(1); | 1083 | mystyle.setVOffset(1); |
1089 | break; | 1084 | break; |
1090 | case 11: | 1085 | case 11: |
1091 | mystyle.setFontSize(-2); | 1086 | mystyle.setFontSize(-2); |
1092 | mystyle.setVOffset(-1); | 1087 | mystyle.setVOffset(-1); |
1093 | break; | 1088 | break; |
1094 | default: | 1089 | default: |
1095 | qDebug("Unrecognised font"); | 1090 | qDebug("Unrecognised font"); |
1096 | break; | 1091 | break; |
1097 | } | 1092 | } |
1098 | ch = bgetch(); | 1093 | ch = bgetch(); |
1099 | } | 1094 | } |
1100 | break; | 1095 | break; |
1101 | case 0x29: | 1096 | case 0x29: |
1102 | ch = bgetch(); | 1097 | ch = bgetch(); |
1103 | switch (ch) | 1098 | switch (ch) |
1104 | { | 1099 | { |
1105 | case 0: | 1100 | case 0: |
1106 | mystyle.setLeftJustify(); | 1101 | mystyle.setLeftJustify(); |
1107 | // //qDebug("left"); | 1102 | // //qDebug("left"); |
1108 | break; | 1103 | break; |
1109 | case 1: | 1104 | case 1: |
1110 | mystyle.setRightJustify(); | 1105 | mystyle.setRightJustify(); |
1111 | // //qDebug("right"); | 1106 | // //qDebug("right"); |
1112 | break; | 1107 | break; |
1113 | case 2: | 1108 | case 2: |
1114 | mystyle.setCentreJustify(); | 1109 | mystyle.setCentreJustify(); |
1115 | // //qDebug("centre"); | 1110 | // //qDebug("centre"); |
1116 | break; | 1111 | break; |
1117 | case 3: | 1112 | case 3: |
1118 | mystyle.setFullJustify(); | 1113 | mystyle.setFullJustify(); |
1119 | // //qDebug("full"); | 1114 | // //qDebug("full"); |
1120 | break; | 1115 | break; |
1121 | 1116 | ||
1122 | } | 1117 | } |
1123 | ch = bgetch(); | 1118 | ch = bgetch(); |
1124 | break; | 1119 | break; |
1125 | case 0x53: | 1120 | case 0x53: |
1126 | { | 1121 | { |
1127 | int r = bgetch(); | 1122 | int r = bgetch(); |
1128 | int g = bgetch(); | 1123 | int g = bgetch(); |
1129 | int b = bgetch(); | 1124 | int b = bgetch(); |
1130 | mystyle.setColour(r,g,b); | 1125 | mystyle.setColour(r,g,b); |
1131 | ch = bgetch(); | 1126 | ch = bgetch(); |
1132 | } | 1127 | } |
1133 | break; | 1128 | break; |
1134 | case 0x1a: | 1129 | case 0x1a: |
1135 | case 0x5c: | 1130 | case 0x5c: |
1136 | { | 1131 | { |
1137 | bool hasalternate = (ch == 0x5c); | 1132 | bool hasalternate = (ch == 0x5c); |
1138 | UInt16 ir = bgetch(); | 1133 | UInt16 ir = bgetch(); |
1139 | ir = (ir << 8) + bgetch(); | 1134 | ir = (ir << 8) + bgetch(); |
1140 | if (hasalternate) | 1135 | if (hasalternate) |
1141 | { | 1136 | { |
1142 | //qDebug("Alternate image:%x", ir); | 1137 | //qDebug("Alternate image:%x", ir); |
1143 | UInt16 ir2 = bgetch(); | 1138 | UInt16 ir2 = bgetch(); |
1144 | ir2 = (ir2 << 8) + bgetch(); | 1139 | ir2 = (ir2 << 8) + bgetch(); |
1145 | if (!fast) mystyle.setPicture(true, expandimg(ir2, true), true, ir << 16); | 1140 | if (!fast) mystyle.setPicture(true, expandimg(ir2, true), true, ir << 16); |
1146 | #ifdef LOCALPICTURES | 1141 | #ifdef LOCALPICTURES |
1147 | UInt32 ln = ir; | 1142 | UInt32 ln = ir; |
1148 | ln <<= 16; | 1143 | ln <<= 16; |
1149 | mystyle.setLink(true); | 1144 | mystyle.setLink(true); |
1150 | mystyle.setData(ln); | 1145 | mystyle.setData(ln); |
1151 | #endif | 1146 | #endif |
1152 | } | 1147 | } |
1153 | else | 1148 | else |
1154 | { | 1149 | { |
1155 | if (!fast) mystyle.setPicture(true, expandimg(ir)); | 1150 | if (!fast) mystyle.setPicture(true, expandimg(ir)); |
1156 | } | 1151 | } |
1157 | // if (mystyle.getLink()) qDebug("Picture link!"); | 1152 | // if (mystyle.getLink()) qDebug("Picture link!"); |
1158 | ch = '#'; | 1153 | ch = '#'; |
1159 | } | 1154 | } |
1160 | // ch = bgetch(); | 1155 | // ch = bgetch(); |
1161 | break; | 1156 | break; |
1162 | case 0x33: | 1157 | case 0x33: |
1163 | { | 1158 | { |
1164 | UInt8 h = bgetch(); | 1159 | UInt8 h = bgetch(); |
1165 | UInt8 wc = bgetch(); | 1160 | UInt8 wc = bgetch(); |
1166 | UInt8 pc = bgetch(); | 1161 | UInt8 pc = bgetch(); |
1167 | UInt16 w = wc; | 1162 | UInt16 w = wc; |
1168 | // //qDebug("h,w,pc [%u, %u, %u]", h, w, pc); | 1163 | // //qDebug("h,w,pc [%u, %u, %u]", h, w, pc); |
1169 | if (w == 0) | 1164 | if (w == 0) |
1170 | { | 1165 | { |
1171 | w = (m_scrWidth*(unsigned long)pc)/100; | 1166 | w = (m_scrWidth*(unsigned long)pc)/100; |
1172 | } | 1167 | } |
1173 | if (w == 0) w = m_scrWidth; | 1168 | if (w == 0) w = m_scrWidth; |
1174 | mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); | 1169 | mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); |
1175 | // if (mystyle.getLink()) //qDebug("hRule link!"); | 1170 | // if (mystyle.getLink()) //qDebug("hRule link!"); |
1176 | ch = '#'; | 1171 | ch = '#'; |
1177 | } | 1172 | } |
1178 | break; | 1173 | break; |
1179 | case 0x60: | 1174 | case 0x60: |
1180 | mystyle.setUnderline(); | 1175 | mystyle.setUnderline(); |
1181 | ch = bgetch(); | 1176 | ch = bgetch(); |
1182 | break; | 1177 | break; |
1183 | case 0x68: | 1178 | case 0x68: |
1184 | mystyle.unsetUnderline(); | 1179 | mystyle.unsetUnderline(); |
1185 | ch = bgetch(); | 1180 | ch = bgetch(); |
1186 | break; | 1181 | break; |
1187 | case 0x22: | 1182 | case 0x22: |
1188 | ch = bgetch(); | 1183 | ch = bgetch(); |
1189 | mystyle.setLeftMargin(ch); | 1184 | mystyle.setLeftMargin(ch); |
1190 | // //qDebug("Left margin:%d", ch); | 1185 | // //qDebug("Left margin:%d", ch); |
1191 | ch = bgetch(); | 1186 | ch = bgetch(); |
1192 | mystyle.setRightMargin(ch); | 1187 | mystyle.setRightMargin(ch); |
1193 | // //qDebug("Right margin:%d", ch); | 1188 | // //qDebug("Right margin:%d", ch); |
1194 | ch = bgetch(); | 1189 | ch = bgetch(); |
1195 | break; | 1190 | break; |
1196 | case 0x70: | 1191 | case 0x70: |
1197 | mystyle.setStrikethru(); | 1192 | mystyle.setStrikethru(); |
1198 | ch = bgetch(); | 1193 | ch = bgetch(); |
1199 | break; | 1194 | break; |
1200 | case 0x78: | 1195 | case 0x78: |
1201 | mystyle.unsetStrikethru(); | 1196 | mystyle.unsetStrikethru(); |
1202 | ch = bgetch(); | 1197 | ch = bgetch(); |
1203 | break; | 1198 | break; |
1204 | case 0x83: | 1199 | case 0x83: |
1205 | { | 1200 | { |
1206 | int tlen = bgetch(); | 1201 | int tlen = bgetch(); |
1207 | ch = bgetch(); | 1202 | ch = bgetch(); |
1208 | ch <<= 8; | 1203 | ch <<= 8; |
1209 | ch |= (tchar)bgetch(); | 1204 | ch |= (tchar)bgetch(); |
1210 | for (int i = 0; i < tlen; i++) bgetch(); | 1205 | for (int i = 0; i < tlen; i++) bgetch(); |
1211 | //qDebug("Function 83"); | 1206 | //qDebug("Function 83"); |
1212 | } | 1207 | } |
1213 | break; | 1208 | break; |
1214 | case 0x85: | 1209 | case 0x85: |
1215 | default: | 1210 | default: |
1216 | qDebug("Function:%x NOT IMPLEMENTED", ch); | 1211 | qDebug("Function:%x NOT IMPLEMENTED", ch); |
1217 | { | 1212 | { |
1218 | int skip = ch & 7; | 1213 | int skip = ch & 7; |
1219 | for (int i = 0; i < skip; i++) | 1214 | for (int i = 0; i < skip; i++) |
1220 | { | 1215 | { |
1221 | ch = bgetch(); | 1216 | ch = bgetch(); |
1222 | //qDebug("Arg %d, %d", i, ch); | 1217 | //qDebug("Arg %d, %d", i, ch); |
1223 | } | 1218 | } |
1224 | ch = bgetch(); | 1219 | ch = bgetch(); |
1225 | } | 1220 | } |
1226 | } | 1221 | } |
1227 | } | 1222 | } |
1228 | 1223 | ||
1229 | if (m_lastIsBreak && !mystyle.isMono()) | 1224 | if (m_lastIsBreak && !mystyle.isMono()) |
1230 | { | 1225 | { |
1231 | while (ch == ' ') | 1226 | while (ch == ' ') |
1232 | { | 1227 | { |
1233 | ch = getch(false); | 1228 | ch = getch(false); |
1234 | } | 1229 | } |
1235 | } | 1230 | } |
1236 | 1231 | ||
1237 | m_lastIsBreak = (ch == 10); | 1232 | m_lastIsBreak = (ch == 10); |
1238 | 1233 | ||
1239 | return (ch == EOF) ? UEOF : ch; | 1234 | return (ch == EOF) ? UEOF : ch; |
1240 | } | 1235 | } |
diff --git a/noncore/apps/opie-reader/ppm.cpp b/noncore/apps/opie-reader/ppm.cpp index e8bf110..1face46 100644 --- a/noncore/apps/opie-reader/ppm.cpp +++ b/noncore/apps/opie-reader/ppm.cpp | |||
@@ -1,756 +1,755 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include "arith.h" | ||
4 | #include "ppm.h" | 3 | #include "ppm.h" |
5 | 4 | ||
6 | /**************************************************************************** | 5 | /**************************************************************************** |
7 | * Gestion des noeuds | 6 | * Gestion des noeuds |
8 | ****************************************************************************/ | 7 | ****************************************************************************/ |
9 | 8 | ||
10 | /* | 9 | /* |
11 | * Désallocation du noeud p | 10 | * Désallocation du noeud p |
12 | */ | 11 | */ |
13 | 12 | ||
14 | void ppm_worker::Node_Free(UINT p) { | 13 | void ppm_worker::Node_Free(UINT p) { |
15 | node_heap[node_free_last].free_next=p; | 14 | node_heap[node_free_last].free_next=p; |
16 | node_heap[p].free_next=NIL; | 15 | node_heap[p].free_next=NIL; |
17 | node_free_last=p; | 16 | node_free_last=p; |
18 | node_free_nb++; | 17 | node_free_nb++; |
19 | } | 18 | } |
20 | 19 | ||
21 | /* | 20 | /* |
22 | * Allocation d'un noeud | 21 | * Allocation d'un noeud |
23 | * s'il ne reste plus de place, on désalloue le contexte le moins utilisé. | 22 | * s'il ne reste plus de place, on désalloue le contexte le moins utilisé. |
24 | */ | 23 | */ |
25 | 24 | ||
26 | UINT ppm_worker::Node_Alloc(void) { | 25 | UINT ppm_worker::Node_Alloc(void) { |
27 | UINT p; | 26 | UINT p; |
28 | if (node_free_nb<=2) Context_DeleteLast(); | 27 | if (node_free_nb<=2) Context_DeleteLast(); |
29 | p=node_free_first; | 28 | p=node_free_first; |
30 | node_free_first=node_heap[node_free_first].free_next; | 29 | node_free_first=node_heap[node_free_first].free_next; |
31 | node_free_nb--; | 30 | node_free_nb--; |
32 | #ifdef DEBUG | 31 | #ifdef DEBUG |
33 | printf("Node_Alloc: p=%d\n",p); | 32 | printf("Node_Alloc: p=%d\n",p); |
34 | #endif | 33 | #endif |
35 | return p; | 34 | return p; |
36 | } | 35 | } |
37 | 36 | ||
38 | /**************************************************************************** | 37 | /**************************************************************************** |
39 | * Gestion des contextes | 38 | * Gestion des contextes |
40 | ****************************************************************************/ | 39 | ****************************************************************************/ |
41 | 40 | ||
42 | 41 | ||
43 | /* | 42 | /* |
44 | * Mise au début de la liste des contextes du contexte c | 43 | * Mise au début de la liste des contextes du contexte c |
45 | */ | 44 | */ |
46 | void ppm_worker::Context_MoveFirst(UINT c) { | 45 | void ppm_worker::Context_MoveFirst(UINT c) { |
47 | NODE *ctx; | 46 | NODE *ctx; |
48 | 47 | ||
49 | if (c!=ctx_first) { | 48 | if (c!=ctx_first) { |
50 | ctx=&node_heap[c]; | 49 | ctx=&node_heap[c]; |
51 | /* suppression du contexte dans la liste */ | 50 | /* suppression du contexte dans la liste */ |
52 | if (c==ctx_last) { | 51 | if (c==ctx_last) { |
53 | ctx_last=ctx->hdr.ctx_prev; | 52 | ctx_last=ctx->hdr.ctx_prev; |
54 | } else { | 53 | } else { |
55 | node_heap[ctx->hdr.ctx_prev].hdr.ctx_next=ctx->hdr.ctx_next; | 54 | node_heap[ctx->hdr.ctx_prev].hdr.ctx_next=ctx->hdr.ctx_next; |
56 | node_heap[ctx->hdr.ctx_next].hdr.ctx_prev=ctx->hdr.ctx_prev; | 55 | node_heap[ctx->hdr.ctx_next].hdr.ctx_prev=ctx->hdr.ctx_prev; |
57 | } | 56 | } |
58 | /* insertion au début de la liste */ | 57 | /* insertion au début de la liste */ |
59 | node_heap[ctx_first].hdr.ctx_prev=c; | 58 | node_heap[ctx_first].hdr.ctx_prev=c; |
60 | ctx->hdr.ctx_next=ctx_first; | 59 | ctx->hdr.ctx_next=ctx_first; |
61 | ctx_first=c; | 60 | ctx_first=c; |
62 | } | 61 | } |
63 | } | 62 | } |
64 | 63 | ||
65 | /* | 64 | /* |
66 | * Destruction du contexte le moins utilisé (ctx_last) | 65 | * Destruction du contexte le moins utilisé (ctx_last) |
67 | */ | 66 | */ |
68 | void ppm_worker::Context_DeleteLast(void) { | 67 | void ppm_worker::Context_DeleteLast(void) { |
69 | NODE *n; | 68 | NODE *n; |
70 | UINT h,h_next,node,node_next; | 69 | UINT h,h_next,node,node_next; |
71 | USHORT *p; | 70 | USHORT *p; |
72 | 71 | ||
73 | n=&node_heap[ctx_last]; | 72 | n=&node_heap[ctx_last]; |
74 | 73 | ||
75 | /* libération dans la table de hachage. Comme on ne dispose pas de | 74 | /* libération dans la table de hachage. Comme on ne dispose pas de |
76 | * pointeur hash_prev dans les contextes, il faut parcourir toute | 75 | * pointeur hash_prev dans les contextes, il faut parcourir toute |
77 | * la liste. Heureusement, celle-ci est de longueur faible en moyenne | 76 | * la liste. Heureusement, celle-ci est de longueur faible en moyenne |
78 | */ | 77 | */ |
79 | h_next=n->hdr.hash_next; | 78 | h_next=n->hdr.hash_next; |
80 | h=h_next; | 79 | h=h_next; |
81 | while (h<HASH_ADDRESS) h=node_heap[h].hdr.hash_next; | 80 | while (h<HASH_ADDRESS) h=node_heap[h].hdr.hash_next; |
82 | p=&hash_table[h-HASH_ADDRESS]; | 81 | p=&hash_table[h-HASH_ADDRESS]; |
83 | while (*p!=ctx_last) p=&node_heap[*p].hdr.hash_next; | 82 | while (*p!=ctx_last) p=&node_heap[*p].hdr.hash_next; |
84 | *p=h_next; | 83 | *p=h_next; |
85 | 84 | ||
86 | /* libération des noeuds & modification de ctx_last */ | 85 | /* libération des noeuds & modification de ctx_last */ |
87 | 86 | ||
88 | if (n->hdr.sf_max>=2) { | 87 | if (n->hdr.sf_max>=2) { |
89 | node=n->hdr.sf.l.sf_next; | 88 | node=n->hdr.sf.l.sf_next; |
90 | while (1) { | 89 | while (1) { |
91 | node_next=node_heap[node].sf.sf_next; | 90 | node_next=node_heap[node].sf.sf_next; |
92 | Node_Free(node); | 91 | Node_Free(node); |
93 | if (node_next==NIL) break; | 92 | if (node_next==NIL) break; |
94 | node=node_next; | 93 | node=node_next; |
95 | } | 94 | } |
96 | } | 95 | } |
97 | 96 | ||
98 | node=ctx_last; | 97 | node=ctx_last; |
99 | ctx_last=n->hdr.ctx_prev; | 98 | ctx_last=n->hdr.ctx_prev; |
100 | Node_Free(node); | 99 | Node_Free(node); |
101 | ctx_nb--; | 100 | ctx_nb--; |
102 | } | 101 | } |
103 | 102 | ||
104 | /* | 103 | /* |
105 | * Création d'un nouveau contexte avec un seul symbole sym de fréquence 1 | 104 | * Création d'un nouveau contexte avec un seul symbole sym de fréquence 1 |
106 | * Utilisation implicite de sym_context et sym_hash. | 105 | * Utilisation implicite de sym_context et sym_hash. |
107 | * Libération de mémoire si nécessaire, et mise en premier dans la liste | 106 | * Libération de mémoire si nécessaire, et mise en premier dans la liste |
108 | */ | 107 | */ |
109 | void ppm_worker::Context_New(int sym,int order) { | 108 | void ppm_worker::Context_New(int sym,int order) { |
110 | NODE *ctx; | 109 | NODE *ctx; |
111 | UINT i,c; | 110 | UINT i,c; |
112 | 111 | ||
113 | #ifdef DEBUG | 112 | #ifdef DEBUG |
114 | printf("Context_New: sym=%d o=%d\n",sym,order); | 113 | printf("Context_New: sym=%d o=%d\n",sym,order); |
115 | #endif | 114 | #endif |
116 | 115 | ||
117 | c=Node_Alloc(); | 116 | c=Node_Alloc(); |
118 | ctx=&node_heap[c]; | 117 | ctx=&node_heap[c]; |
119 | 118 | ||
120 | /* mise du contexte en tête de la liste */ | 119 | /* mise du contexte en tête de la liste */ |
121 | ctx->hdr.ctx_next=ctx_first; | 120 | ctx->hdr.ctx_next=ctx_first; |
122 | node_heap[ctx_first].hdr.ctx_prev=c; | 121 | node_heap[ctx_first].hdr.ctx_prev=c; |
123 | ctx_first=c; | 122 | ctx_first=c; |
124 | ctx_nb++; | 123 | ctx_nb++; |
125 | 124 | ||
126 | /* insertion dans la table de hachage */ | 125 | /* insertion dans la table de hachage */ |
127 | ctx->hdr.hash_next=hash_table[sym_hash[order]]; | 126 | ctx->hdr.hash_next=hash_table[sym_hash[order]]; |
128 | hash_table[sym_hash[order]]=ctx_first; | 127 | hash_table[sym_hash[order]]=ctx_first; |
129 | 128 | ||
130 | /* initialisation du contexte */ | 129 | /* initialisation du contexte */ |
131 | ctx->hdr.order=order; | 130 | ctx->hdr.order=order; |
132 | for(i=0;i<order;i++) ctx->hdr.sym[i]=sym_context[i+1]; | 131 | for(i=0;i<order;i++) ctx->hdr.sym[i]=sym_context[i+1]; |
133 | 132 | ||
134 | ctx->hdr.sf_max=0; | 133 | ctx->hdr.sf_max=0; |
135 | ctx->hdr.sf.sf[0].sym=sym; | 134 | ctx->hdr.sf.sf[0].sym=sym; |
136 | ctx->hdr.sf.sf[0].freq=1; | 135 | ctx->hdr.sf.sf[0].freq=1; |
137 | #ifdef DEBUG | 136 | #ifdef DEBUG |
138 | Context_Print(ctx_first); | 137 | Context_Print(ctx_first); |
139 | #endif | 138 | #endif |
140 | } | 139 | } |
141 | 140 | ||
142 | /* | 141 | /* |
143 | * Ajout d'un nouveau symbole au contexte c | 142 | * Ajout d'un nouveau symbole au contexte c |
144 | */ | 143 | */ |
145 | 144 | ||
146 | void ppm_worker::Context_NewSym(int sym,UINT c) { | 145 | void ppm_worker::Context_NewSym(int sym,UINT c) { |
147 | NODE *n,*m; | 146 | NODE *n,*m; |
148 | UINT p,sf_max; | 147 | UINT p,sf_max; |
149 | 148 | ||
150 | #ifdef DEBUG | 149 | #ifdef DEBUG |
151 | printf("Context_NewSym: sym=%d c=%d\n",sym,c); | 150 | printf("Context_NewSym: sym=%d c=%d\n",sym,c); |
152 | Context_Print(c); | 151 | Context_Print(c); |
153 | #endif | 152 | #endif |
154 | 153 | ||
155 | n=&node_heap[c]; | 154 | n=&node_heap[c]; |
156 | sf_max=n->hdr.sf_max; | 155 | sf_max=n->hdr.sf_max; |
157 | n->hdr.sf_max++; | 156 | n->hdr.sf_max++; |
158 | if (sf_max==0) { | 157 | if (sf_max==0) { |
159 | n->hdr.sf.sf[1].sym=sym; | 158 | n->hdr.sf.sf[1].sym=sym; |
160 | n->hdr.sf.sf[1].freq=1; | 159 | n->hdr.sf.sf[1].freq=1; |
161 | } else if (sf_max==1) { | 160 | } else if (sf_max==1) { |
162 | p=Node_Alloc(); | 161 | p=Node_Alloc(); |
163 | m=&node_heap[p]; | 162 | m=&node_heap[p]; |
164 | m->sf.sf[0]=n->hdr.sf.sf[0]; | 163 | m->sf.sf[0]=n->hdr.sf.sf[0]; |
165 | m->sf.sf[1]=n->hdr.sf.sf[1]; | 164 | m->sf.sf[1]=n->hdr.sf.sf[1]; |
166 | m->sf.sf[2].sym=sym; | 165 | m->sf.sf[2].sym=sym; |
167 | m->sf.sf[2].freq=1; | 166 | m->sf.sf[2].freq=1; |
168 | m->sf.sf_next=NIL; | 167 | m->sf.sf_next=NIL; |
169 | n->hdr.sf.l.sf_next=p; | 168 | n->hdr.sf.l.sf_next=p; |
170 | n->hdr.sf.l.freq_tot=((UINT)m->sf.sf[0].freq+(UINT)m->sf.sf[1].freq+1); | 169 | n->hdr.sf.l.freq_tot=((UINT)m->sf.sf[0].freq+(UINT)m->sf.sf[1].freq+1); |
171 | } else { | 170 | } else { |
172 | n->hdr.sf.l.freq_tot++; | 171 | n->hdr.sf.l.freq_tot++; |
173 | m=&node_heap[n->hdr.sf.l.sf_next]; | 172 | m=&node_heap[n->hdr.sf.l.sf_next]; |
174 | while (sf_max>=NODE_SFNB) { | 173 | while (sf_max>=NODE_SFNB) { |
175 | sf_max-=NODE_SFNB; | 174 | sf_max-=NODE_SFNB; |
176 | m=&node_heap[m->sf.sf_next]; | 175 | m=&node_heap[m->sf.sf_next]; |
177 | } | 176 | } |
178 | sf_max++; | 177 | sf_max++; |
179 | if (sf_max==NODE_SFNB) { | 178 | if (sf_max==NODE_SFNB) { |
180 | p=Node_Alloc(); | 179 | p=Node_Alloc(); |
181 | m->sf.sf_next=p; | 180 | m->sf.sf_next=p; |
182 | m=&node_heap[p]; | 181 | m=&node_heap[p]; |
183 | m->sf.sf_next=NIL; | 182 | m->sf.sf_next=NIL; |
184 | sf_max=0; | 183 | sf_max=0; |
185 | } | 184 | } |
186 | m->sf.sf[sf_max].sym=sym; | 185 | m->sf.sf[sf_max].sym=sym; |
187 | m->sf.sf[sf_max].freq=1; | 186 | m->sf.sf[sf_max].freq=1; |
188 | } | 187 | } |
189 | #ifdef DEBUG | 188 | #ifdef DEBUG |
190 | Context_Print(c); | 189 | Context_Print(c); |
191 | #endif | 190 | #endif |
192 | } | 191 | } |
193 | 192 | ||
194 | 193 | ||
195 | #ifdef STAT | 194 | #ifdef STAT |
196 | int hash_nb=1; | 195 | int hash_nb=1; |
197 | int hash_cnt=0; | 196 | int hash_cnt=0; |
198 | #endif | 197 | #endif |
199 | 198 | ||
200 | /* | 199 | /* |
201 | * Recherche d'un contexte, utilisation de façon implicite de sym_context | 200 | * Recherche d'un contexte, utilisation de façon implicite de sym_context |
202 | * et de sym_hash. | 201 | * et de sym_hash. |
203 | * C'est une procédure très critique qui doit être particulièrement optimisée | 202 | * C'est une procédure très critique qui doit être particulièrement optimisée |
204 | */ | 203 | */ |
205 | 204 | ||
206 | UINT ppm_worker::Context_Search(int order) { | 205 | UINT ppm_worker::Context_Search(int order) { |
207 | UCHAR *sym; | 206 | UCHAR *sym; |
208 | UINT i,p; | 207 | UINT i,p; |
209 | NODE *n; | 208 | NODE *n; |
210 | #ifdef DEBUG | 209 | #ifdef DEBUG |
211 | printf("Context_Search: o=%d\n",order); | 210 | printf("Context_Search: o=%d\n",order); |
212 | #endif | 211 | #endif |
213 | 212 | ||
214 | p=hash_table[sym_hash[order]]; | 213 | p=hash_table[sym_hash[order]]; |
215 | sym=&sym_context[1]; | 214 | sym=&sym_context[1]; |
216 | #ifdef STAT | 215 | #ifdef STAT |
217 | hash_nb++; | 216 | hash_nb++; |
218 | #endif | 217 | #endif |
219 | while (p<HASH_ADDRESS) { | 218 | while (p<HASH_ADDRESS) { |
220 | #ifdef STAT | 219 | #ifdef STAT |
221 | hash_cnt++; | 220 | hash_cnt++; |
222 | #endif | 221 | #endif |
223 | n=&node_heap[p]; | 222 | n=&node_heap[p]; |
224 | if (n->hdr.order==order) { | 223 | if (n->hdr.order==order) { |
225 | if (order==0) return p; | 224 | if (order==0) return p; |
226 | i=0; | 225 | i=0; |
227 | while (sym[i]==n->hdr.sym[i]) { | 226 | while (sym[i]==n->hdr.sym[i]) { |
228 | i++; | 227 | i++; |
229 | if (i==order) return p; | 228 | if (i==order) return p; |
230 | } | 229 | } |
231 | } | 230 | } |
232 | p=n->hdr.hash_next; | 231 | p=n->hdr.hash_next; |
233 | } | 232 | } |
234 | return HASH_ADDRESS; | 233 | return HASH_ADDRESS; |
235 | } | 234 | } |
236 | 235 | ||
237 | /* | 236 | /* |
238 | * Cette macro est HORRIBLE mais permet de simplifier beaucoup le parcours | 237 | * Cette macro est HORRIBLE mais permet de simplifier beaucoup le parcours |
239 | * des listes de couples symbole,fréquence tout en ayant un code rapide. | 238 | * des listes de couples symbole,fréquence tout en ayant un code rapide. |
240 | * Une alternative élégante mais lente aurait été de passer une fonction | 239 | * Une alternative élégante mais lente aurait été de passer une fonction |
241 | * en paramètre contenant le code à exécuter | 240 | * en paramètre contenant le code à exécuter |
242 | */ | 241 | */ |
243 | 242 | ||
244 | #define SF_Read(n,p,code_to_execute) \ | 243 | #define SF_Read(n,p,code_to_execute) \ |
245 | {\ | 244 | {\ |
246 | UINT nb,i;\ | 245 | UINT nb,i;\ |
247 | nb=(UINT)n->hdr.sf_max+1;\ | 246 | nb=(UINT)n->hdr.sf_max+1;\ |
248 | if (nb<=HDR_SFNB) {\ | 247 | if (nb<=HDR_SFNB) {\ |
249 | p=&n->hdr.sf.sf[0];\ | 248 | p=&n->hdr.sf.sf[0];\ |
250 | } else {\ | 249 | } else {\ |
251 | p=&node_heap[n->hdr.sf.l.sf_next].sf.sf[0];\ | 250 | p=&node_heap[n->hdr.sf.l.sf_next].sf.sf[0];\ |
252 | while (nb>NODE_SFNB) {\ | 251 | while (nb>NODE_SFNB) {\ |
253 | for(i=0;i<NODE_SFNB;i++) {\ | 252 | for(i=0;i<NODE_SFNB;i++) {\ |
254 | code_to_execute;\ | 253 | code_to_execute;\ |
255 | p++;\ | 254 | p++;\ |
256 | }\ | 255 | }\ |
257 | p=&node_heap[ *((USHORT *)p) ].sf.sf[0];\ | 256 | p=&node_heap[ *((USHORT *)p) ].sf.sf[0];\ |
258 | nb-=NODE_SFNB;\ | 257 | nb-=NODE_SFNB;\ |
259 | }\ | 258 | }\ |
260 | }\ | 259 | }\ |
261 | for(i=0;i<nb;i++) {\ | 260 | for(i=0;i<nb;i++) {\ |
262 | code_to_execute;\ | 261 | code_to_execute;\ |
263 | p++;\ | 262 | p++;\ |
264 | }\ | 263 | }\ |
265 | } | 264 | } |
266 | 265 | ||
267 | 266 | ||
268 | /* | 267 | /* |
269 | * Renormalisation d'un contexte, ie, division de toutes les fréquences | 268 | * Renormalisation d'un contexte, ie, division de toutes les fréquences |
270 | * par 2 et élimination des symboles de fréquence nulle | 269 | * par 2 et élimination des symboles de fréquence nulle |
271 | * Note: le contexte obtenu n'est jamais vide. | 270 | * Note: le contexte obtenu n'est jamais vide. |
272 | * Une amélioration prévue mais non implémentée serait de trier le contexte | 271 | * Une amélioration prévue mais non implémentée serait de trier le contexte |
273 | * dans l'ordre des fréquences décroissantes pour accélérer la recherche. | 272 | * dans l'ordre des fréquences décroissantes pour accélérer la recherche. |
274 | * Les gains en vitesse seraient de toute façon assez faibles car les | 273 | * Les gains en vitesse seraient de toute façon assez faibles car les |
275 | * contextes sont de toute façon à peu près triés vu leur méthode de | 274 | * contextes sont de toute façon à peu près triés vu leur méthode de |
276 | * construction: les caractères sont ajoutés à la fin de la liste | 275 | * construction: les caractères sont ajoutés à la fin de la liste |
277 | */ | 276 | */ |
278 | void ppm_worker::Context_Renorm(UINT ctx) { | 277 | void ppm_worker::Context_Renorm(UINT ctx) { |
279 | NODE *n,*m; | 278 | NODE *n,*m; |
280 | UINT a,b,c,i,freq_tot,sf_nb; | 279 | UINT a,b,c,i,freq_tot,sf_nb; |
281 | SYMFREQ s,*p,tab_sf[SYM_NB]; | 280 | SYMFREQ s,*p,tab_sf[SYM_NB]; |
282 | 281 | ||
283 | #ifdef DEBUG | 282 | #ifdef DEBUG |
284 | printf("Context_Renorm: c=%d\n",ctx); | 283 | printf("Context_Renorm: c=%d\n",ctx); |
285 | Context_Print(ctx); | 284 | Context_Print(ctx); |
286 | #endif | 285 | #endif |
287 | 286 | ||
288 | n=&node_heap[ctx]; | 287 | n=&node_heap[ctx]; |
289 | freq_tot=0; | 288 | freq_tot=0; |
290 | sf_nb=0; | 289 | sf_nb=0; |
291 | 290 | ||
292 | SF_Read(n,p, { | 291 | SF_Read(n,p, { |
293 | s=*p; | 292 | s=*p; |
294 | s.freq=s.freq/2; | 293 | s.freq=s.freq/2; |
295 | if (s.freq!=0) { | 294 | if (s.freq!=0) { |
296 | freq_tot+=s.freq; | 295 | freq_tot+=s.freq; |
297 | tab_sf[sf_nb]=s; | 296 | tab_sf[sf_nb]=s; |
298 | sf_nb++; | 297 | sf_nb++; |
299 | } | 298 | } |
300 | } ); | 299 | } ); |
301 | 300 | ||
302 | 301 | ||
303 | /* libération des noeuds utilisés pour stocker les symboles */ | 302 | /* libération des noeuds utilisés pour stocker les symboles */ |
304 | if (n->hdr.sf_max>=HDR_SFNB) { | 303 | if (n->hdr.sf_max>=HDR_SFNB) { |
305 | a=n->hdr.sf.l.sf_next; | 304 | a=n->hdr.sf.l.sf_next; |
306 | do { | 305 | do { |
307 | b=node_heap[a].sf.sf_next; | 306 | b=node_heap[a].sf.sf_next; |
308 | Node_Free(a); | 307 | Node_Free(a); |
309 | a=b; | 308 | a=b; |
310 | } while (a!=NIL); | 309 | } while (a!=NIL); |
311 | } | 310 | } |
312 | 311 | ||
313 | /* reconstruction de la liste des "sf_nb" symboles d'apres le tableau | 312 | /* reconstruction de la liste des "sf_nb" symboles d'apres le tableau |
314 | * "tab_sf" | 313 | * "tab_sf" |
315 | */ | 314 | */ |
316 | 315 | ||
317 | n->hdr.sf_max=sf_nb-1; | 316 | n->hdr.sf_max=sf_nb-1; |
318 | if (sf_nb<=HDR_SFNB) { | 317 | if (sf_nb<=HDR_SFNB) { |
319 | for(i=0;i<sf_nb;i++) n->hdr.sf.sf[i]=tab_sf[i]; | 318 | for(i=0;i<sf_nb;i++) n->hdr.sf.sf[i]=tab_sf[i]; |
320 | } else { | 319 | } else { |
321 | a=Node_Alloc(); | 320 | a=Node_Alloc(); |
322 | n->hdr.sf.l.sf_next=a; | 321 | n->hdr.sf.l.sf_next=a; |
323 | n->hdr.sf.l.freq_tot=freq_tot; | 322 | n->hdr.sf.l.freq_tot=freq_tot; |
324 | m=&node_heap[a]; | 323 | m=&node_heap[a]; |
325 | i=0; | 324 | i=0; |
326 | c=0; | 325 | c=0; |
327 | while (1) { | 326 | while (1) { |
328 | m->sf.sf[c]=tab_sf[i]; | 327 | m->sf.sf[c]=tab_sf[i]; |
329 | i++; | 328 | i++; |
330 | if (i==sf_nb) break; | 329 | if (i==sf_nb) break; |
331 | c++; | 330 | c++; |
332 | if (c==NODE_SFNB) { | 331 | if (c==NODE_SFNB) { |
333 | c=0; | 332 | c=0; |
334 | a=Node_Alloc(); | 333 | a=Node_Alloc(); |
335 | m->sf.sf_next=a; | 334 | m->sf.sf_next=a; |
336 | m=&node_heap[a]; | 335 | m=&node_heap[a]; |
337 | } | 336 | } |
338 | } | 337 | } |
339 | m->sf.sf_next=NIL; | 338 | m->sf.sf_next=NIL; |
340 | } | 339 | } |
341 | 340 | ||
342 | #ifdef DEBUG | 341 | #ifdef DEBUG |
343 | Context_Print(ctx); | 342 | Context_Print(ctx); |
344 | #endif | 343 | #endif |
345 | } | 344 | } |
346 | 345 | ||
347 | 346 | ||
348 | /* | 347 | /* |
349 | * Mise à jour des index dans la table de hachage et des caractères du | 348 | * Mise à jour des index dans la table de hachage et des caractères du |
350 | * contexte courant. | 349 | * contexte courant. |
351 | * La fonction de hachage a été choisie de façon empirique en controlant | 350 | * La fonction de hachage a été choisie de façon empirique en controlant |
352 | * qu'elle donne en moyenne de bons résultats. | 351 | * qu'elle donne en moyenne de bons résultats. |
353 | */ | 352 | */ |
354 | void ppm_worker::Hash_Update(int sym) { | 353 | void ppm_worker::Hash_Update(int sym) { |
355 | UINT i,k; | 354 | UINT i,k; |
356 | 355 | ||
357 | for(i=ORDER_MAX;i>=2;i--) | 356 | for(i=ORDER_MAX;i>=2;i--) |
358 | sym_context[i]=sym_context[i-1]; | 357 | sym_context[i]=sym_context[i-1]; |
359 | sym_context[1]=sym; | 358 | sym_context[1]=sym; |
360 | 359 | ||
361 | for(i=ORDER_MAX;i>=2;i--) { | 360 | for(i=ORDER_MAX;i>=2;i--) { |
362 | k=sym_hash[i-1]; | 361 | k=sym_hash[i-1]; |
363 | sym_hash[i]=( (k<<6)-k+sym ) & (HASH_SIZE-1); | 362 | sym_hash[i]=( (k<<6)-k+sym ) & (HASH_SIZE-1); |
364 | } | 363 | } |
365 | sym_hash[1]=sym+1; | 364 | sym_hash[1]=sym+1; |
366 | } | 365 | } |
367 | 366 | ||
368 | 367 | ||
369 | /**************************************************************************** | 368 | /**************************************************************************** |
370 | * Système d'exclusion des symboles | 369 | * Système d'exclusion des symboles |
371 | ****************************************************************************/ | 370 | ****************************************************************************/ |
372 | 371 | ||
373 | 372 | ||
374 | /* | 373 | /* |
375 | * Remise à zéro du tableau d'exclusion des symboles | 374 | * Remise à zéro du tableau d'exclusion des symboles |
376 | */ | 375 | */ |
377 | void ppm_worker::Sym_ExcludeReset(void) { | 376 | void ppm_worker::Sym_ExcludeReset(void) { |
378 | UINT i; | 377 | UINT i; |
379 | 378 | ||
380 | sym_excl_code++; | 379 | sym_excl_code++; |
381 | if (sym_excl_code==0) { | 380 | if (sym_excl_code==0) { |
382 | for(i=0;i<SYM_NB;i++) sym_excl[i]=0; | 381 | for(i=0;i<SYM_NB;i++) sym_excl[i]=0; |
383 | sym_excl_code=1; | 382 | sym_excl_code=1; |
384 | } | 383 | } |
385 | } | 384 | } |
386 | 385 | ||
387 | 386 | ||
388 | /**************************************************************************** | 387 | /**************************************************************************** |
389 | * Initialisation et Libération mémoire | 388 | * Initialisation et Libération mémoire |
390 | ****************************************************************************/ | 389 | ****************************************************************************/ |
391 | 390 | ||
392 | /* | 391 | /* |
393 | * Initialisation des structures de données du compresseur/décompresseur | 392 | * Initialisation des structures de données du compresseur/décompresseur |
394 | * retourne 0 si tout va bien | 393 | * retourne 0 si tout va bien |
395 | */ | 394 | */ |
396 | int ppm_worker::PPM_Init(unsigned short NODE_NBMAX) { | 395 | int ppm_worker::PPM_Init(unsigned short NODE_NBMAX) { |
397 | UINT i; | 396 | UINT i; |
398 | node_heap= new NODE[NODE_NBMAX]; | 397 | node_heap= new NODE[NODE_NBMAX]; |
399 | hash_table= new USHORT[HASH_SIZE]; | 398 | hash_table= new USHORT[HASH_SIZE]; |
400 | if (node_heap==NULL || hash_table==NULL) { | 399 | if (node_heap==NULL || hash_table==NULL) { |
401 | if (node_heap!=NULL) delete [] node_heap; | 400 | if (node_heap!=NULL) delete [] node_heap; |
402 | if (hash_table!=NULL) delete [] hash_table; | 401 | if (hash_table!=NULL) delete [] hash_table; |
403 | return 1; | 402 | return 1; |
404 | } | 403 | } |
405 | /* noeuds: tous vides */ | 404 | /* noeuds: tous vides */ |
406 | for(i=0;i<=(NODE_NBMAX-2);i++) node_heap[i].free_next=i+1; | 405 | for(i=0;i<=(NODE_NBMAX-2);i++) node_heap[i].free_next=i+1; |
407 | node_heap[NODE_NBMAX-1].free_next=NIL; | 406 | node_heap[NODE_NBMAX-1].free_next=NIL; |
408 | node_free_first=0; | 407 | node_free_first=0; |
409 | node_free_last=NODE_NBMAX-1; | 408 | node_free_last=NODE_NBMAX-1; |
410 | node_free_nb=NODE_NBMAX; | 409 | node_free_nb=NODE_NBMAX; |
411 | 410 | ||
412 | /* contextes */ | 411 | /* contextes */ |
413 | for(i=0;i<HASH_SIZE;i++) hash_table[i]=HASH_ADDRESS+i; | 412 | for(i=0;i<HASH_SIZE;i++) hash_table[i]=HASH_ADDRESS+i; |
414 | 413 | ||
415 | /* cette initialisation n'est pas sûre mais simplifie beaucoup le code: | 414 | /* cette initialisation n'est pas sûre mais simplifie beaucoup le code: |
416 | * on suppose que le premier contexte sera alloué dans le noeud 0 | 415 | * on suppose que le premier contexte sera alloué dans le noeud 0 |
417 | */ | 416 | */ |
418 | ctx_first=0; | 417 | ctx_first=0; |
419 | ctx_last=0; | 418 | ctx_last=0; |
420 | ctx_nb=0; | 419 | ctx_nb=0; |
421 | 420 | ||
422 | /* contexte courant */ | 421 | /* contexte courant */ |
423 | for(i=0;i<=ORDER_MAX;i++) sym_context[i]=0; | 422 | for(i=0;i<=ORDER_MAX;i++) sym_context[i]=0; |
424 | for(i=0;i<=ORDER_MAX;i++) sym_hash[i]=0; | 423 | for(i=0;i<=ORDER_MAX;i++) sym_hash[i]=0; |
425 | 424 | ||
426 | /* système d'exclusion des caractères */ | 425 | /* système d'exclusion des caractères */ |
427 | sym_excl_code=0xFF; | 426 | sym_excl_code=0xFF; |
428 | 427 | ||
429 | return 0; | 428 | return 0; |
430 | } | 429 | } |
431 | 430 | ||
432 | /* | 431 | /* |
433 | * Fin de la compression/décompression: on libère la mémoire | 432 | * Fin de la compression/décompression: on libère la mémoire |
434 | */ | 433 | */ |
435 | void ppm_worker::PPM_End(void) { | 434 | void ppm_worker::PPM_End(void) { |
436 | free(hash_table); | 435 | free(hash_table); |
437 | free(node_heap); | 436 | free(node_heap); |
438 | } | 437 | } |
439 | 438 | ||
440 | /**************************************************************************** | 439 | /**************************************************************************** |
441 | * Décodage et décompression | 440 | * Décodage et décompression |
442 | ****************************************************************************/ | 441 | ****************************************************************************/ |
443 | 442 | ||
444 | /* | 443 | /* |
445 | * Décodage: cf Encode_NewSym | 444 | * Décodage: cf Encode_NewSym |
446 | */ | 445 | */ |
447 | int ppm_worker::Decode_NewSym(void) { | 446 | int ppm_worker::Decode_NewSym(void) { |
448 | UINT i,freq_tot,freq_cum,f; | 447 | UINT i,freq_tot,freq_cum,f; |
449 | UCHAR code; | 448 | UCHAR code; |
450 | 449 | ||
451 | code=sym_excl_code; | 450 | code=sym_excl_code; |
452 | freq_tot=0; | 451 | freq_tot=0; |
453 | for(i=0;i<SYM_NB;i++) if (sym_excl[i]!=code) freq_tot++; | 452 | for(i=0;i<SYM_NB;i++) if (sym_excl[i]!=code) freq_tot++; |
454 | f=arith.Arith_DecodeVal(freq_tot+SYM_SPECIAL_NB); | 453 | f=arith.Arith_DecodeVal(freq_tot+SYM_SPECIAL_NB); |
455 | if (f>=freq_tot) { | 454 | if (f>=freq_tot) { |
456 | /* cas d'un symbole spécial */ | 455 | /* cas d'un symbole spécial */ |
457 | arith.Arith_Decode(f,f+1,freq_tot+SYM_SPECIAL_NB); | 456 | arith.Arith_Decode(f,f+1,freq_tot+SYM_SPECIAL_NB); |
458 | return SYM_NB+f-freq_tot; | 457 | return SYM_NB+f-freq_tot; |
459 | } else { | 458 | } else { |
460 | i=0; | 459 | i=0; |
461 | freq_cum=0; | 460 | freq_cum=0; |
462 | while (1) { | 461 | while (1) { |
463 | if (sym_excl[i]!=code) { | 462 | if (sym_excl[i]!=code) { |
464 | freq_cum++; | 463 | freq_cum++; |
465 | if (freq_cum>f) break; | 464 | if (freq_cum>f) break; |
466 | } | 465 | } |
467 | i++; | 466 | i++; |
468 | } | 467 | } |
469 | arith.Arith_Decode(freq_cum-1,freq_cum,freq_tot+SYM_SPECIAL_NB); | 468 | arith.Arith_Decode(freq_cum-1,freq_cum,freq_tot+SYM_SPECIAL_NB); |
470 | return i; | 469 | return i; |
471 | } | 470 | } |
472 | } | 471 | } |
473 | 472 | ||
474 | /* | 473 | /* |
475 | * Décodage: cf Decode_NoExclude | 474 | * Décodage: cf Decode_NoExclude |
476 | */ | 475 | */ |
477 | int ppm_worker::Decode_NoExclude(UINT ctx) { | 476 | int ppm_worker::Decode_NoExclude(UINT ctx) { |
478 | NODE *n; | 477 | NODE *n; |
479 | UCHAR code; | 478 | UCHAR code; |
480 | UINT i,f,freq_tot,freq_cum,freq_sym,sf_nb; | 479 | UINT i,f,freq_tot,freq_cum,freq_sym,sf_nb; |
481 | SYMFREQ *p,s; | 480 | SYMFREQ *p,s; |
482 | 481 | ||
483 | 482 | ||
484 | n=&node_heap[ctx]; | 483 | n=&node_heap[ctx]; |
485 | code=sym_excl_code; | 484 | code=sym_excl_code; |
486 | 485 | ||
487 | /* Calcul de la somme des fréquences des caractères */ | 486 | /* Calcul de la somme des fréquences des caractères */ |
488 | if (n->hdr.sf_max<HDR_SFNB) { | 487 | if (n->hdr.sf_max<HDR_SFNB) { |
489 | freq_tot=0; | 488 | freq_tot=0; |
490 | for(i=0;i<=n->hdr.sf_max;i++) freq_tot+=n->hdr.sf.sf[i].freq; | 489 | for(i=0;i<=n->hdr.sf_max;i++) freq_tot+=n->hdr.sf.sf[i].freq; |
491 | } else { | 490 | } else { |
492 | freq_tot=n->hdr.sf.l.freq_tot; | 491 | freq_tot=n->hdr.sf.l.freq_tot; |
493 | } | 492 | } |
494 | 493 | ||
495 | /* décodage */ | 494 | /* décodage */ |
496 | sf_nb=(UINT) n->hdr.sf_max+1; | 495 | sf_nb=(UINT) n->hdr.sf_max+1; |
497 | f=arith.Arith_DecodeVal(freq_tot+sf_nb); | 496 | f=arith.Arith_DecodeVal(freq_tot+sf_nb); |
498 | if (f>=freq_tot) { | 497 | if (f>=freq_tot) { |
499 | /* gestion du code ESCAPE */ | 498 | /* gestion du code ESCAPE */ |
500 | 499 | ||
501 | /* marquage des caractères utilisés */ | 500 | /* marquage des caractères utilisés */ |
502 | SF_Read(n,p, { sym_excl[p->sym]=code; }); | 501 | SF_Read(n,p, { sym_excl[p->sym]=code; }); |
503 | 502 | ||
504 | /* décodage ESCAPE */ | 503 | /* décodage ESCAPE */ |
505 | arith.Arith_Decode(freq_tot,freq_tot+sf_nb,freq_tot+sf_nb); | 504 | arith.Arith_Decode(freq_tot,freq_tot+sf_nb,freq_tot+sf_nb); |
506 | return SYM_ESCAPE; | 505 | return SYM_ESCAPE; |
507 | } | 506 | } |
508 | 507 | ||
509 | /* recherche du caractère en calculant la fréquence */ | 508 | /* recherche du caractère en calculant la fréquence */ |
510 | freq_cum=0; | 509 | freq_cum=0; |
511 | SF_Read(n,p, { | 510 | SF_Read(n,p, { |
512 | s=*p; | 511 | s=*p; |
513 | freq_cum+=s.freq; | 512 | freq_cum+=s.freq; |
514 | if (freq_cum>f) goto decode_sym; | 513 | if (freq_cum>f) goto decode_sym; |
515 | } ); | 514 | } ); |
516 | 515 | ||
517 | decode_sym: | 516 | decode_sym: |
518 | 517 | ||
519 | freq_sym=s.freq; | 518 | freq_sym=s.freq; |
520 | p->freq=freq_sym+1; | 519 | p->freq=freq_sym+1; |
521 | if (n->hdr.sf_max>=HDR_SFNB) n->hdr.sf.l.freq_tot=freq_tot+1; | 520 | if (n->hdr.sf_max>=HDR_SFNB) n->hdr.sf.l.freq_tot=freq_tot+1; |
522 | 521 | ||
523 | arith.Arith_Decode(freq_cum-freq_sym,freq_cum,freq_tot+sf_nb); | 522 | arith.Arith_Decode(freq_cum-freq_sym,freq_cum,freq_tot+sf_nb); |
524 | 523 | ||
525 | /* test de la renormalisation */ | 524 | /* test de la renormalisation */ |
526 | if (freq_sym==(RENORM_FREQSYM-1) || freq_tot>=RENORM_FREQTOT) { | 525 | if (freq_sym==(RENORM_FREQSYM-1) || freq_tot>=RENORM_FREQTOT) { |
527 | Context_Renorm(ctx); | 526 | Context_Renorm(ctx); |
528 | } | 527 | } |
529 | return s.sym; | 528 | return s.sym; |
530 | } | 529 | } |
531 | 530 | ||
532 | 531 | ||
533 | /* | 532 | /* |
534 | * Décodage: cf Encode_Exclude | 533 | * Décodage: cf Encode_Exclude |
535 | */ | 534 | */ |
536 | 535 | ||
537 | int ppm_worker::Decode_Exclude(UINT ctx) { | 536 | int ppm_worker::Decode_Exclude(UINT ctx) { |
538 | UINT sf_nb,freq_sym,freq_cum,freq_tot,f; | 537 | UINT sf_nb,freq_sym,freq_cum,freq_tot,f; |
539 | NODE *n; | 538 | NODE *n; |
540 | SYMFREQ s,*p; | 539 | SYMFREQ s,*p; |
541 | UCHAR code; | 540 | UCHAR code; |
542 | 541 | ||
543 | n=&node_heap[ctx]; | 542 | n=&node_heap[ctx]; |
544 | code=sym_excl_code; | 543 | code=sym_excl_code; |
545 | 544 | ||
546 | freq_tot=0; | 545 | freq_tot=0; |
547 | sf_nb=0; | 546 | sf_nb=0; |
548 | 547 | ||
549 | SF_Read( n,p, { | 548 | SF_Read( n,p, { |
550 | s=*p; | 549 | s=*p; |
551 | if (sym_excl[s.sym]!=code) | 550 | if (sym_excl[s.sym]!=code) |
552 | { | 551 | { |
553 | freq_tot+=s.freq; | 552 | freq_tot+=s.freq; |
554 | sf_nb++; | 553 | sf_nb++; |
555 | } | 554 | } |
556 | } ); | 555 | } ); |
557 | 556 | ||
558 | 557 | ||
559 | f=arith.Arith_DecodeVal(freq_tot+sf_nb); | 558 | f=arith.Arith_DecodeVal(freq_tot+sf_nb); |
560 | 559 | ||
561 | if (f>=freq_tot) { | 560 | if (f>=freq_tot) { |
562 | 561 | ||
563 | /* ESCAPE */ | 562 | /* ESCAPE */ |
564 | 563 | ||
565 | SF_Read(n,p, { sym_excl[p->sym]=code; } ); | 564 | SF_Read(n,p, { sym_excl[p->sym]=code; } ); |
566 | 565 | ||
567 | arith.Arith_Decode(freq_tot,freq_tot+sf_nb,freq_tot+sf_nb); | 566 | arith.Arith_Decode(freq_tot,freq_tot+sf_nb,freq_tot+sf_nb); |
568 | 567 | ||
569 | return SYM_ESCAPE; | 568 | return SYM_ESCAPE; |
570 | } else { | 569 | } else { |
571 | 570 | ||
572 | /* recherche du caractère */ | 571 | /* recherche du caractère */ |
573 | 572 | ||
574 | freq_cum=0; | 573 | freq_cum=0; |
575 | SF_Read(n,p, { | 574 | SF_Read(n,p, { |
576 | s=*p; | 575 | s=*p; |
577 | if (sym_excl[s.sym]!=code) { | 576 | if (sym_excl[s.sym]!=code) { |
578 | freq_cum+=s.freq; | 577 | freq_cum+=s.freq; |
579 | if (freq_cum>f) goto decode_sym; | 578 | if (freq_cum>f) goto decode_sym; |
580 | } | 579 | } |
581 | } ); | 580 | } ); |
582 | 581 | ||
583 | decode_sym: | 582 | decode_sym: |
584 | 583 | ||
585 | /* incrémentation de la fréquence */ | 584 | /* incrémentation de la fréquence */ |
586 | 585 | ||
587 | freq_sym=p->freq; | 586 | freq_sym=p->freq; |
588 | p->freq=freq_sym+1; | 587 | p->freq=freq_sym+1; |
589 | if (n->hdr.sf_max>=HDR_SFNB) n->hdr.sf.l.freq_tot++; | 588 | if (n->hdr.sf_max>=HDR_SFNB) n->hdr.sf.l.freq_tot++; |
590 | 589 | ||
591 | /* décodage du caractère */ | 590 | /* décodage du caractère */ |
592 | 591 | ||
593 | arith.Arith_Decode(freq_cum-freq_sym,freq_cum,freq_tot+sf_nb); | 592 | arith.Arith_Decode(freq_cum-freq_sym,freq_cum,freq_tot+sf_nb); |
594 | 593 | ||
595 | if (freq_sym==(RENORM_FREQSYM-1) || freq_tot>=RENORM_FREQTOT) { | 594 | if (freq_sym==(RENORM_FREQSYM-1) || freq_tot>=RENORM_FREQTOT) { |
596 | Context_Renorm(ctx); | 595 | Context_Renorm(ctx); |
597 | } | 596 | } |
598 | 597 | ||
599 | return s.sym; | 598 | return s.sym; |
600 | } | 599 | } |
601 | } | 600 | } |
602 | 601 | ||
603 | 602 | ||
604 | /* | 603 | /* |
605 | * Décodage d'un symbole | 604 | * Décodage d'un symbole |
606 | */ | 605 | */ |
607 | int ppm_worker::PPM_Decode(void) { | 606 | int ppm_worker::PPM_Decode(void) { |
608 | int i,order,sym; | 607 | int i,order,sym; |
609 | UINT ctx,ctx_tab[ORDER_MAX+1],ctx_last; | 608 | UINT ctx,ctx_tab[ORDER_MAX+1],ctx_last; |
610 | 609 | ||
611 | 610 | ||
612 | /* recherche de l'ordre maximum */ | 611 | /* recherche de l'ordre maximum */ |
613 | 612 | ||
614 | Sym_ExcludeReset(); | 613 | Sym_ExcludeReset(); |
615 | order=ORDER_MAX; | 614 | order=ORDER_MAX; |
616 | ctx_last=NIL; | 615 | ctx_last=NIL; |
617 | while (1) { | 616 | while (1) { |
618 | ctx=Context_Search(order); | 617 | ctx=Context_Search(order); |
619 | ctx_tab[order]=ctx; | 618 | ctx_tab[order]=ctx; |
620 | if (ctx<HASH_ADDRESS) { | 619 | if (ctx<HASH_ADDRESS) { |
621 | Context_MoveFirst(ctx); | 620 | Context_MoveFirst(ctx); |
622 | if (ctx_last==NIL) | 621 | if (ctx_last==NIL) |
623 | sym=Decode_NoExclude(ctx); | 622 | sym=Decode_NoExclude(ctx); |
624 | else | 623 | else |
625 | sym=Decode_Exclude(ctx); | 624 | sym=Decode_Exclude(ctx); |
626 | if (sym!=SYM_ESCAPE) break; | 625 | if (sym!=SYM_ESCAPE) break; |
627 | ctx_last=ctx; | 626 | ctx_last=ctx; |
628 | } | 627 | } |
629 | order--; | 628 | order--; |
630 | if (order==-1) { | 629 | if (order==-1) { |
631 | sym=Decode_NewSym(); | 630 | sym=Decode_NewSym(); |
632 | if (sym>=SYM_NB) return sym; | 631 | if (sym>=SYM_NB) return sym; |
633 | break; | 632 | break; |
634 | } | 633 | } |
635 | } | 634 | } |
636 | 635 | ||
637 | for(i=order+1;i<=ORDER_MAX;i++) { | 636 | for(i=order+1;i<=ORDER_MAX;i++) { |
638 | if (ctx_tab[i]>=HASH_ADDRESS) | 637 | if (ctx_tab[i]>=HASH_ADDRESS) |
639 | Context_New(sym,i); | 638 | Context_New(sym,i); |
640 | else | 639 | else |
641 | Context_NewSym(sym,ctx_tab[i]); | 640 | Context_NewSym(sym,ctx_tab[i]); |
642 | } | 641 | } |
643 | 642 | ||
644 | Hash_Update(sym); | 643 | Hash_Update(sym); |
645 | 644 | ||
646 | return sym; | 645 | return sym; |
647 | } | 646 | } |
648 | 647 | ||
649 | /* | 648 | /* |
650 | * Décompression: idem | 649 | * Décompression: idem |
651 | */ | 650 | */ |
652 | 651 | ||
653 | #ifdef STAT | 652 | #ifdef STAT |
654 | 653 | ||
655 | /**************************************************************************** | 654 | /**************************************************************************** |
656 | * Statistiques | 655 | * Statistiques |
657 | ****************************************************************************/ | 656 | ****************************************************************************/ |
658 | 657 | ||
659 | 658 | ||
660 | void ppm_worker::PrintStat(void) { | 659 | void ppm_worker::PrintStat(void) { |
661 | fprintf(stderr,"free=%d ctx_nb=%d hash_moy=%0.2f\n", | 660 | fprintf(stderr,"free=%d ctx_nb=%d hash_moy=%0.2f\n", |
662 | node_free_nb,ctx_nb, | 661 | node_free_nb,ctx_nb, |
663 | (float)hash_cnt/(float)hash_nb); | 662 | (float)hash_cnt/(float)hash_nb); |
664 | 663 | ||
665 | } | 664 | } |
666 | 665 | ||
667 | /* | 666 | /* |
668 | * Impression d'un caractère | 667 | * Impression d'un caractère |
669 | */ | 668 | */ |
670 | void ppm_worker::Sym_Print(int c) { | 669 | void ppm_worker::Sym_Print(int c) { |
671 | if (c>=32 && c<=126) printf("%c",c); else printf("\\%2X",c); | 670 | if (c>=32 && c<=126) printf("%c",c); else printf("\\%2X",c); |
672 | } | 671 | } |
673 | 672 | ||
674 | /* | 673 | /* |
675 | * Impression couple SYMFREQ | 674 | * Impression couple SYMFREQ |
676 | */ | 675 | */ |
677 | 676 | ||
678 | void ppm_worker::SF_Print(SYMFREQ s) { | 677 | void ppm_worker::SF_Print(SYMFREQ s) { |
679 | Sym_Print(s.sym); | 678 | Sym_Print(s.sym); |
680 | printf(":%d ",s.freq); | 679 | printf(":%d ",s.freq); |
681 | } | 680 | } |
682 | 681 | ||
683 | /* | 682 | /* |
684 | * Impression du contenu d'un contexte | 683 | * Impression du contenu d'un contexte |
685 | * utilisé pour les tests | 684 | * utilisé pour les tests |
686 | */ | 685 | */ |
687 | 686 | ||
688 | void ppm_worker::Context_Print(UINT c) { | 687 | void ppm_worker::Context_Print(UINT c) { |
689 | NODE *n; | 688 | NODE *n; |
690 | int i,sf_max,sf_nb,sf_freq; | 689 | int i,sf_max,sf_nb,sf_freq; |
691 | 690 | ||
692 | n=&node_heap[c]; | 691 | n=&node_heap[c]; |
693 | 692 | ||
694 | sf_max=n->hdr.sf_max; | 693 | sf_max=n->hdr.sf_max; |
695 | sf_nb=sf_max+1; | 694 | sf_nb=sf_max+1; |
696 | if (sf_max>=2) sf_freq=n->hdr.sf.l.freq_tot; | 695 | if (sf_max>=2) sf_freq=n->hdr.sf.l.freq_tot; |
697 | else { | 696 | else { |
698 | sf_freq=0; | 697 | sf_freq=0; |
699 | for(i=0;i<=sf_max;i++) sf_freq+=n->hdr.sf.sf[i].freq; | 698 | for(i=0;i<=sf_max;i++) sf_freq+=n->hdr.sf.sf[i].freq; |
700 | } | 699 | } |
701 | 700 | ||
702 | printf("Ctx=%d: hash_n=%d ctx_p=%d ctx_n=%d o=%d sf_nb=%d sf_freq=%d\n", | 701 | printf("Ctx=%d: hash_n=%d ctx_p=%d ctx_n=%d o=%d sf_nb=%d sf_freq=%d\n", |
703 | c,n->hdr.hash_next,n->hdr.ctx_prev,n->hdr.ctx_next, | 702 | c,n->hdr.hash_next,n->hdr.ctx_prev,n->hdr.ctx_next, |
704 | n->hdr.order,sf_nb,sf_freq); | 703 | n->hdr.order,sf_nb,sf_freq); |
705 | for(i=0;i<n->hdr.order;i++) Sym_Print(n->hdr.sym[i]); | 704 | for(i=0;i<n->hdr.order;i++) Sym_Print(n->hdr.sym[i]); |
706 | printf(": "); | 705 | printf(": "); |
707 | if (sf_max<=1) { | 706 | if (sf_max<=1) { |
708 | for(i=0;i<=sf_max;i++) SF_Print(n->hdr.sf.sf[i]); | 707 | for(i=0;i<=sf_max;i++) SF_Print(n->hdr.sf.sf[i]); |
709 | } else { | 708 | } else { |
710 | n=&node_heap[n->hdr.sf.l.sf_next]; | 709 | n=&node_heap[n->hdr.sf.l.sf_next]; |
711 | i=0; | 710 | i=0; |
712 | while (1) { | 711 | while (1) { |
713 | SF_Print(n->sf.sf[i]); | 712 | SF_Print(n->sf.sf[i]); |
714 | if (sf_max==0) break; | 713 | if (sf_max==0) break; |
715 | i++; | 714 | i++; |
716 | sf_max--; | 715 | sf_max--; |
717 | if (i==NODE_SFNB) { | 716 | if (i==NODE_SFNB) { |
718 | i=0; | 717 | i=0; |
719 | n=&node_heap[n->sf.sf_next]; | 718 | n=&node_heap[n->sf.sf_next]; |
720 | } | 719 | } |
721 | } | 720 | } |
722 | } | 721 | } |
723 | printf("\n"); | 722 | printf("\n"); |
724 | } | 723 | } |
725 | 724 | ||
726 | 725 | ||
727 | /* | 726 | /* |
728 | * Nombre total de contextes et nombre de contextes de longueur données. | 727 | * Nombre total de contextes et nombre de contextes de longueur données. |
729 | * Utilisé pour les statistiques | 728 | * Utilisé pour les statistiques |
730 | */ | 729 | */ |
731 | 730 | ||
732 | void ppm_worker::Context_Statistic(void) { | 731 | void ppm_worker::Context_Statistic(void) { |
733 | UINT i,p; | 732 | UINT i,p; |
734 | int tab[SYM_NB+1],tot,cnt; | 733 | int tab[SYM_NB+1],tot,cnt; |
735 | 734 | ||
736 | for(i=0;i<=SYM_NB;i++) tab[i]=0; | 735 | for(i=0;i<=SYM_NB;i++) tab[i]=0; |
737 | tot=0; | 736 | tot=0; |
738 | 737 | ||
739 | p=ctx_first; | 738 | p=ctx_first; |
740 | do { | 739 | do { |
741 | cnt=node_heap[p].hdr.sf_max+1; | 740 | cnt=node_heap[p].hdr.sf_max+1; |
742 | tab[cnt]++; | 741 | tab[cnt]++; |
743 | tot++; | 742 | tot++; |
744 | p=node_heap[p].hdr.ctx_next; | 743 | p=node_heap[p].hdr.ctx_next; |
745 | } while (p!=ctx_last); | 744 | } while (p!=ctx_last); |
746 | 745 | ||
747 | 746 | ||
748 | printf("Context_Statistic: "); | 747 | printf("Context_Statistic: "); |
749 | for(i=1;i<=SYM_NB;i++) { | 748 | for(i=1;i<=SYM_NB;i++) { |
750 | printf("%d:%d (%0.2f%%),",i,tab[i],(float)tab[i]/(float)tot*100.0); | 749 | printf("%d:%d (%0.2f%%),",i,tab[i],(float)tab[i]/(float)tot*100.0); |
751 | } | 750 | } |
752 | printf("\n"); | 751 | printf("\n"); |
753 | } | 752 | } |
754 | 753 | ||
755 | #endif | 754 | #endif |
756 | 755 | ||
diff --git a/noncore/apps/opie-reader/version.cpp b/noncore/apps/opie-reader/version.cpp index 3796b67..864e4c1 100644 --- a/noncore/apps/opie-reader/version.cpp +++ b/noncore/apps/opie-reader/version.cpp | |||
@@ -1,39 +1,37 @@ | |||
1 | #include "version.h" | 1 | #include "version.h" |
2 | #include "names.h" | ||
3 | #include <qmessagebox.h> | ||
4 | 2 | ||
5 | bool CheckVersion(int& major, int& bkmktype, char& minor) | 3 | bool CheckVersion(int& major, int& bkmktype, char& minor) |
6 | { | 4 | { |
7 | if ( | 5 | if ( |
8 | (major != MAJOR) | 6 | (major != MAJOR) |
9 | || | 7 | || |
10 | (bkmktype != BKMKTYPE) | 8 | (bkmktype != BKMKTYPE) |
11 | || | 9 | || |
12 | (minor != MINOR) | 10 | (minor != MINOR) |
13 | ) | 11 | ) |
14 | { | 12 | { |
15 | major = MAJOR; | 13 | major = MAJOR; |
16 | bkmktype = BKMKTYPE; | 14 | bkmktype = BKMKTYPE; |
17 | minor = MINOR; | 15 | minor = MINOR; |
18 | /* | 16 | /* |
19 | QMessageBox::warning(NULL, PROGNAME, | 17 | QMessageBox::warning(NULL, PROGNAME, |
20 | "This is the first time that you have\n" | 18 | "This is the first time that you have\n" |
21 | "run this version of OpieReader.\n\n" | 19 | "run this version of OpieReader.\n\n" |
22 | "There are two new icons visible at\n" | 20 | "There are two new icons visible at\n" |
23 | "the left end of the toolbar. The left\n" | 21 | "the left end of the toolbar. The left\n" |
24 | "one brings up the menus, the next\n" | 22 | "one brings up the menus, the next\n" |
25 | "one brings up the settings dialog.\n\n" | 23 | "one brings up the settings dialog.\n\n" |
26 | "Start by tapping the settings icon\n" | 24 | "Start by tapping the settings icon\n" |
27 | "and selecting the Buttons tab to\n" | 25 | "and selecting the Buttons tab to\n" |
28 | "make sure that the buttons are\n" | 26 | "make sure that the buttons are\n" |
29 | "mapped as you expect\n\n" | 27 | "mapped as you expect\n\n" |
30 | "Next go to Settings/Toolbars via the\n" | 28 | "Next go to Settings/Toolbars via the\n" |
31 | "menu icon to set up your toolbars."); | 29 | "menu icon to set up your toolbars."); |
32 | */ | 30 | */ |
33 | return true; | 31 | return true; |
34 | } | 32 | } |
35 | else | 33 | else |
36 | { | 34 | { |
37 | return false; | 35 | return false; |
38 | } | 36 | } |
39 | } | 37 | } |
diff --git a/noncore/apps/opie-sheet/Excel.cpp b/noncore/apps/opie-sheet/Excel.cpp index 225c3e1..fc49d56 100644 --- a/noncore/apps/opie-sheet/Excel.cpp +++ b/noncore/apps/opie-sheet/Excel.cpp | |||
@@ -1,779 +1,776 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #include <math.h> | 5 | #include <math.h> |
6 | #include <time.h> | 6 | #include <time.h> |
7 | #include <sys/types.h> | 7 | #include <sys/types.h> |
8 | #include <strings.h> | 8 | #include <strings.h> |
9 | #include <qstring.h> | ||
10 | #include <qlist.h> | ||
11 | #include <qarray.h> | ||
12 | #include "Excel.h" | 9 | #include "Excel.h" |
13 | 10 | ||
14 | static xfrecord formatter[] = { | 11 | static xfrecord formatter[] = { |
15 | { 0xe , DATEFORMAT, "%m/%d/%y"}, | 12 | { 0xe , DATEFORMAT, "%m/%d/%y"}, |
16 | { 0xf , DATEFORMAT, "%d-%b-%y"}, | 13 | { 0xf , DATEFORMAT, "%d-%b-%y"}, |
17 | { 0x10, DATEFORMAT, "%d-%b"}, | 14 | { 0x10, DATEFORMAT, "%d-%b"}, |
18 | { 0x11, DATEFORMAT, "%b-%y"}, | 15 | { 0x11, DATEFORMAT, "%b-%y"}, |
19 | { 0x12, DATEFORMAT, "%I:%M %p"}, | 16 | { 0x12, DATEFORMAT, "%I:%M %p"}, |
20 | { 0x13, DATEFORMAT, "%I:%M:%S %p"}, | 17 | { 0x13, DATEFORMAT, "%I:%M:%S %p"}, |
21 | { 0x14, DATEFORMAT, "%H:%M"}, | 18 | { 0x14, DATEFORMAT, "%H:%M"}, |
22 | { 0x15, DATEFORMAT, "%H:%M:%S"}, | 19 | { 0x15, DATEFORMAT, "%H:%M:%S"}, |
23 | { 0x16, DATEFORMAT, "%m/%d/%y %H:%M"}, | 20 | { 0x16, DATEFORMAT, "%m/%d/%y %H:%M"}, |
24 | { 0x2d, DATEFORMAT, "%M:%S"}, | 21 | { 0x2d, DATEFORMAT, "%M:%S"}, |
25 | { 0x2e, DATEFORMAT, "%H:%M:%S"}, | 22 | { 0x2e, DATEFORMAT, "%H:%M:%S"}, |
26 | { 0x2f, DATEFORMAT, "%M:%S"}, | 23 | { 0x2f, DATEFORMAT, "%M:%S"}, |
27 | { 0xa5, DATEFORMAT, "%m/%d/%y %I:%M %p"}, | 24 | { 0xa5, DATEFORMAT, "%m/%d/%y %I:%M %p"}, |
28 | { 0x1 , NUMBERFORMAT, "%.0f"}, | 25 | { 0x1 , NUMBERFORMAT, "%.0f"}, |
29 | { 0x2 , NUMBERFORMAT, "%.2f"}, | 26 | { 0x2 , NUMBERFORMAT, "%.2f"}, |
30 | { 0x3 , NUMBERFORMAT, "#,##%.0f"}, | 27 | { 0x3 , NUMBERFORMAT, "#,##%.0f"}, |
31 | { 0x4 , NUMBERFORMAT, "#,##%.2f"}, | 28 | { 0x4 , NUMBERFORMAT, "#,##%.2f"}, |
32 | { 0x5 , NUMBERFORMAT, "$#,##%.0f"}, | 29 | { 0x5 , NUMBERFORMAT, "$#,##%.0f"}, |
33 | { 0x6 , NUMBERFORMAT, "$#,##%.0f"}, | 30 | { 0x6 , NUMBERFORMAT, "$#,##%.0f"}, |
34 | { 0x7 , NUMBERFORMAT, "$#,##%.2f"}, | 31 | { 0x7 , NUMBERFORMAT, "$#,##%.2f"}, |
35 | { 0x8 , NUMBERFORMAT, "$#,##%.2f"}, | 32 | { 0x8 , NUMBERFORMAT, "$#,##%.2f"}, |
36 | { 0x9 , NUMBERFORMAT, "%.0f%%"}, | 33 | { 0x9 , NUMBERFORMAT, "%.0f%%"}, |
37 | { 0xa , NUMBERFORMAT, "%.2f%%"}, | 34 | { 0xa , NUMBERFORMAT, "%.2f%%"}, |
38 | { 0xb , NUMBERFORMAT, "%e"}, | 35 | { 0xb , NUMBERFORMAT, "%e"}, |
39 | { 0x25, NUMBERFORMAT, "#,##%.0f;(#,##0)"}, | 36 | { 0x25, NUMBERFORMAT, "#,##%.0f;(#,##0)"}, |
40 | { 0x26, NUMBERFORMAT, "#,##%.0f;(#,##0)"}, | 37 | { 0x26, NUMBERFORMAT, "#,##%.0f;(#,##0)"}, |
41 | { 0x27, NUMBERFORMAT, "#,##%.2f;(#,##0.00)"}, | 38 | { 0x27, NUMBERFORMAT, "#,##%.2f;(#,##0.00)"}, |
42 | { 0x28, NUMBERFORMAT, "#,##%.2f;(#,##0.00)"}, | 39 | { 0x28, NUMBERFORMAT, "#,##%.2f;(#,##0.00)"}, |
43 | { 0x29, NUMBERFORMAT, "#,##%.0f;(#,##0)"}, | 40 | { 0x29, NUMBERFORMAT, "#,##%.0f;(#,##0)"}, |
44 | { 0x2a, NUMBERFORMAT, "$#,##%.0f;($#,##0)"}, | 41 | { 0x2a, NUMBERFORMAT, "$#,##%.0f;($#,##0)"}, |
45 | { 0x2b, NUMBERFORMAT, "#,##%.2f;(#,##0.00)"}, | 42 | { 0x2b, NUMBERFORMAT, "#,##%.2f;(#,##0.00)"}, |
46 | { 0x2c, NUMBERFORMAT, "$#,##%.2f;($#,##0.00)"}, | 43 | { 0x2c, NUMBERFORMAT, "$#,##%.2f;($#,##0.00)"}, |
47 | { 0x30, NUMBERFORMAT, "##0.0E0"}, | 44 | { 0x30, NUMBERFORMAT, "##0.0E0"}, |
48 | { 0, 0, ""} | 45 | { 0, 0, ""} |
49 | }; | 46 | }; |
50 | 47 | ||
51 | 48 | ||
52 | 49 | ||
53 | int ExcelBook::Integer2Byte(int b1, int b2) | 50 | int ExcelBook::Integer2Byte(int b1, int b2) |
54 | { | 51 | { |
55 | int i1 = b1 & 0xff; | 52 | int i1 = b1 & 0xff; |
56 | int i2 = b2 & 0xff; | 53 | int i2 = b2 & 0xff; |
57 | int val = i2 << 8 | i1; | 54 | int val = i2 << 8 | i1; |
58 | return val; | 55 | return val; |
59 | }; | 56 | }; |
60 | 57 | ||
61 | int ExcelBook::Integer4Byte(int b1,int b2,int b3,int b4) | 58 | int ExcelBook::Integer4Byte(int b1,int b2,int b3,int b4) |
62 | { | 59 | { |
63 | int i1 = Integer2Byte(b1, b2); | 60 | int i1 = Integer2Byte(b1, b2); |
64 | int i2 = Integer2Byte(b3, b4); | 61 | int i2 = Integer2Byte(b3, b4); |
65 | int val = i2 << 16 | i1; | 62 | int val = i2 << 16 | i1; |
66 | return val; | 63 | return val; |
67 | }; | 64 | }; |
68 | 65 | ||
69 | int ExcelBook::Integer2ByteFile(FILE *f) { | 66 | int ExcelBook::Integer2ByteFile(FILE *f) { |
70 | int i1, i2; | 67 | int i1, i2; |
71 | i1 = fgetc(f); | 68 | i1 = fgetc(f); |
72 | i2 = fgetc(f); | 69 | i2 = fgetc(f); |
73 | return Integer2Byte(i1,i2); | 70 | return Integer2Byte(i1,i2); |
74 | }; | 71 | }; |
75 | 72 | ||
76 | float ExcelBook::Float4Byte(int b1, int b2, int b3, int b4) | 73 | float ExcelBook::Float4Byte(int b1, int b2, int b3, int b4) |
77 | { | 74 | { |
78 | int i; | 75 | int i; |
79 | float f; | 76 | float f; |
80 | unsigned char *ieee; | 77 | unsigned char *ieee; |
81 | ieee = (unsigned char *) &f; | 78 | ieee = (unsigned char *) &f; |
82 | for (i = 0; i < 4; i++) ieee[i] = 0; | 79 | for (i = 0; i < 4; i++) ieee[i] = 0; |
83 | ieee[0] = ((int)b4) & 0xff; | 80 | ieee[0] = ((int)b4) & 0xff; |
84 | ieee[1] = ((int)b3) & 0xff; | 81 | ieee[1] = ((int)b3) & 0xff; |
85 | ieee[2] = ((int)b2) & 0xff; | 82 | ieee[2] = ((int)b2) & 0xff; |
86 | ieee[3] = ((int)b1) & 0xff; | 83 | ieee[3] = ((int)b1) & 0xff; |
87 | return f; | 84 | return f; |
88 | }; | 85 | }; |
89 | 86 | ||
90 | double ExcelBook::Double4Byte(int b1, int b2, int b3, int b4) | 87 | double ExcelBook::Double4Byte(int b1, int b2, int b3, int b4) |
91 | { | 88 | { |
92 | long int rk; | 89 | long int rk; |
93 | double value; | 90 | double value; |
94 | 91 | ||
95 | rk=Integer4Byte(b1,b2,b3,b4); | 92 | rk=Integer4Byte(b1,b2,b3,b4); |
96 | //printf("Double4Bytes:%d,%d,%d,%d\r\n",b1,b2,b3,b4); | 93 | //printf("Double4Bytes:%d,%d,%d,%d\r\n",b1,b2,b3,b4); |
97 | if ( (rk & 0x02) != 0) | 94 | if ( (rk & 0x02) != 0) |
98 | { | 95 | { |
99 | long int intval = rk >> 2; //drops the 2 bits | 96 | long int intval = rk >> 2; //drops the 2 bits |
100 | printf("Double4Byte:intval=%d, rk=%d, rk>>2=%d\r\n",intval,rk,rk>>2); | 97 | printf("Double4Byte:intval=%d, rk=%d, rk>>2=%d\r\n",intval,rk,rk>>2); |
101 | value = (double) intval; | 98 | value = (double) intval; |
102 | printf("Double4Byte: VALUEINT=%f\r\n",value); | 99 | printf("Double4Byte: VALUEINT=%f\r\n",value); |
103 | if ( (rk & 0x01) != 0) | 100 | if ( (rk & 0x01) != 0) |
104 | { | 101 | { |
105 | value /= 100.0; | 102 | value /= 100.0; |
106 | }; | 103 | }; |
107 | return value; | 104 | return value; |
108 | }else | 105 | }else |
109 | { | 106 | { |
110 | 107 | ||
111 | union { double d; unsigned long int b[2]; } dbl_byte; | 108 | union { double d; unsigned long int b[2]; } dbl_byte; |
112 | unsigned long int valbits = (rk & 0xfffffffc); | 109 | unsigned long int valbits = (rk & 0xfffffffc); |
113 | #if defined(__arm__) && !defined(__vfp__) | 110 | #if defined(__arm__) && !defined(__vfp__) |
114 | dbl_byte.b[0]=valbits; | 111 | dbl_byte.b[0]=valbits; |
115 | dbl_byte.b[1]=0; | 112 | dbl_byte.b[1]=0; |
116 | #else | 113 | #else |
117 | dbl_byte.b[0]=0; | 114 | dbl_byte.b[0]=0; |
118 | dbl_byte.b[1]=valbits; | 115 | dbl_byte.b[1]=valbits; |
119 | #endif | 116 | #endif |
120 | printf("dbl_byte.b[0]=%d,dbl_byte.b[1]=%d\r\n",dbl_byte.b[0],dbl_byte.b[1]); | 117 | printf("dbl_byte.b[0]=%d,dbl_byte.b[1]=%d\r\n",dbl_byte.b[0],dbl_byte.b[1]); |
121 | value=dbl_byte.d; | 118 | value=dbl_byte.d; |
122 | printf("Double4Byte: VALUE=%f\r\n",value); | 119 | printf("Double4Byte: VALUE=%f\r\n",value); |
123 | 120 | ||
124 | if ( (rk & 0x01) != 0) | 121 | if ( (rk & 0x01) != 0) |
125 | { | 122 | { |
126 | value /= 100.0; | 123 | value /= 100.0; |
127 | }; | 124 | }; |
128 | return value; | 125 | return value; |
129 | }; | 126 | }; |
130 | }; | 127 | }; |
131 | 128 | ||
132 | void ExcelBook::DetectEndian(void) | 129 | void ExcelBook::DetectEndian(void) |
133 | { | 130 | { |
134 | int end; | 131 | int end; |
135 | long i = 0x44332211; | 132 | long i = 0x44332211; |
136 | unsigned char* a = (unsigned char*) &i; | 133 | unsigned char* a = (unsigned char*) &i; |
137 | end = (*a != 0x11); | 134 | end = (*a != 0x11); |
138 | if (end == 1) { | 135 | if (end == 1) { |
139 | endian = BIG_ENDIAN; | 136 | endian = BIG_ENDIAN; |
140 | printf("BIGENDIAN!\r\n"); | 137 | printf("BIGENDIAN!\r\n"); |
141 | } else { | 138 | } else { |
142 | endian = LITTLE_ENDIAN; | 139 | endian = LITTLE_ENDIAN; |
143 | printf("LITTLEENDIAN!\r\n"); | 140 | printf("LITTLEENDIAN!\r\n"); |
144 | } | 141 | } |
145 | }; | 142 | }; |
146 | 143 | ||
147 | double ExcelBook::Double8Byte(int b1, int b2, int b3, int b4, int b5, int b6, int b7, int b8) | 144 | double ExcelBook::Double8Byte(int b1, int b2, int b3, int b4, int b5, int b6, int b7, int b8) |
148 | { | 145 | { |
149 | int i; | 146 | int i; |
150 | double d; | 147 | double d; |
151 | unsigned char *ieee; | 148 | unsigned char *ieee; |
152 | ieee = (unsigned char *)&d; | 149 | ieee = (unsigned char *)&d; |
153 | for (i = 0; i < 8; i++) ieee[i] = 0; | 150 | for (i = 0; i < 8; i++) ieee[i] = 0; |
154 | if (endian == BIG_ENDIAN) { | 151 | if (endian == BIG_ENDIAN) { |
155 | ieee[0] = ((int)b8) & 0xff;ieee[1] = ((int)b7) & 0xff; | 152 | ieee[0] = ((int)b8) & 0xff;ieee[1] = ((int)b7) & 0xff; |
156 | ieee[2] = ((int)b6) & 0xff;ieee[3] = ((int)b5) & 0xff; | 153 | ieee[2] = ((int)b6) & 0xff;ieee[3] = ((int)b5) & 0xff; |
157 | ieee[4] = ((int)b4) & 0xff;ieee[5] = ((int)b3) & 0xff; | 154 | ieee[4] = ((int)b4) & 0xff;ieee[5] = ((int)b3) & 0xff; |
158 | ieee[6] = ((int)b2) & 0xff;ieee[7] = ((int)b1) & 0xff; | 155 | ieee[6] = ((int)b2) & 0xff;ieee[7] = ((int)b1) & 0xff; |
159 | } else { | 156 | } else { |
160 | ieee[0] = ((int)b1) & 0xff;ieee[1] = ((int)b2) & 0xff; | 157 | ieee[0] = ((int)b1) & 0xff;ieee[1] = ((int)b2) & 0xff; |
161 | ieee[2] = ((int)b3) & 0xff;ieee[3] = ((int)b4) & 0xff; | 158 | ieee[2] = ((int)b3) & 0xff;ieee[3] = ((int)b4) & 0xff; |
162 | ieee[4] = ((int)b5) & 0xff;ieee[5] = ((int)b6) & 0xff; | 159 | ieee[4] = ((int)b5) & 0xff;ieee[5] = ((int)b6) & 0xff; |
163 | ieee[6] = ((int)b7) & 0xff;ieee[7] = ((int)b8) & 0xff; | 160 | ieee[6] = ((int)b7) & 0xff;ieee[7] = ((int)b8) & 0xff; |
164 | } | 161 | } |
165 | return d; | 162 | return d; |
166 | }; | 163 | }; |
167 | 164 | ||
168 | bool ExcelBook::OpenFile(char *Filename) | 165 | bool ExcelBook::OpenFile(char *Filename) |
169 | { | 166 | { |
170 | printf("Opening excel file!\r\n"); | 167 | printf("Opening excel file!\r\n"); |
171 | File= fopen(Filename, "r"); | 168 | File= fopen(Filename, "r"); |
172 | Position=0; // first byte index in file | 169 | Position=0; // first byte index in file |
173 | XFRecords.resize(0); | 170 | XFRecords.resize(0); |
174 | SharedStrings.resize(0); | 171 | SharedStrings.resize(0); |
175 | Names.resize(0); | 172 | Names.resize(0); |
176 | Sheets.resize(0); | 173 | Sheets.resize(0); |
177 | if(File==NULL) return false; | 174 | if(File==NULL) return false; |
178 | printf("Opened excel file!\r\n"); | 175 | printf("Opened excel file!\r\n"); |
179 | return true; | 176 | return true; |
180 | }; | 177 | }; |
181 | 178 | ||
182 | bool ExcelBook::CloseFile(void) | 179 | bool ExcelBook::CloseFile(void) |
183 | { | 180 | { |
184 | int w1; | 181 | int w1; |
185 | for(w1=0;w1<(int)XFRecords.count();w1++) | 182 | for(w1=0;w1<(int)XFRecords.count();w1++) |
186 | { | 183 | { |
187 | if(XFRecords[w1]!=NULL) {delete XFRecords[w1];XFRecords[w1]=NULL;}; | 184 | if(XFRecords[w1]!=NULL) {delete XFRecords[w1];XFRecords[w1]=NULL;}; |
188 | }; | 185 | }; |
189 | for(w1=0;w1<(int)SharedStrings.count();w1++) | 186 | for(w1=0;w1<(int)SharedStrings.count();w1++) |
190 | { | 187 | { |
191 | if(SharedStrings[w1]!=NULL) {delete SharedStrings[w1];SharedStrings[w1]=NULL;}; | 188 | if(SharedStrings[w1]!=NULL) {delete SharedStrings[w1];SharedStrings[w1]=NULL;}; |
192 | }; | 189 | }; |
193 | for(w1=0;w1<(int)Names.count();w1++) | 190 | for(w1=0;w1<(int)Names.count();w1++) |
194 | { | 191 | { |
195 | if(Names[w1]!=NULL) {delete Names[w1];Names[w1]=NULL;}; | 192 | if(Names[w1]!=NULL) {delete Names[w1];Names[w1]=NULL;}; |
196 | }; | 193 | }; |
197 | for(w1=0;w1<(int)Sheets.count();w1++) | 194 | for(w1=0;w1<(int)Sheets.count();w1++) |
198 | { | 195 | { |
199 | if(Sheets[w1]!=NULL) {delete Sheets[w1];Sheets[w1]=NULL;}; | 196 | if(Sheets[w1]!=NULL) {delete Sheets[w1];Sheets[w1]=NULL;}; |
200 | }; | 197 | }; |
201 | XFRecords.resize(0); | 198 | XFRecords.resize(0); |
202 | SharedStrings.resize(0); | 199 | SharedStrings.resize(0); |
203 | Names.resize(0); | 200 | Names.resize(0); |
204 | Sheets.resize(0); | 201 | Sheets.resize(0); |
205 | fclose(File); | 202 | fclose(File); |
206 | printf("closed excel file!\r\n"); | 203 | printf("closed excel file!\r\n"); |
207 | if(File==NULL) return true; | 204 | if(File==NULL) return true; |
208 | return false; | 205 | return false; |
209 | }; | 206 | }; |
210 | 207 | ||
211 | void ExcelBook::SeekPosition(int pos) | 208 | void ExcelBook::SeekPosition(int pos) |
212 | { | 209 | { |
213 | if(!feof(File)) | 210 | if(!feof(File)) |
214 | { | 211 | { |
215 | Position=pos; | 212 | Position=pos; |
216 | //printf("SeekPosition:Pos:%d\r\n",Position); | 213 | //printf("SeekPosition:Pos:%d\r\n",Position); |
217 | fseek(File,pos,SEEK_SET); | 214 | fseek(File,pos,SEEK_SET); |
218 | }; | 215 | }; |
219 | }; | 216 | }; |
220 | 217 | ||
221 | void ExcelBook::SeekSkip(int pos) | 218 | void ExcelBook::SeekSkip(int pos) |
222 | { | 219 | { |
223 | if(!feof(File)) | 220 | if(!feof(File)) |
224 | { | 221 | { |
225 | Position=Position+pos; | 222 | Position=Position+pos; |
226 | //printf("SeekSkip:Pos:%d\r\n",Position); | 223 | //printf("SeekSkip:Pos:%d\r\n",Position); |
227 | fseek(File, Position, SEEK_SET); | 224 | fseek(File, Position, SEEK_SET); |
228 | }; | 225 | }; |
229 | }; | 226 | }; |
230 | 227 | ||
231 | int ExcelBook::FileEOF(void) | 228 | int ExcelBook::FileEOF(void) |
232 | { | 229 | { |
233 | if(File!=NULL) return(feof(File)); else return 0; | 230 | if(File!=NULL) return(feof(File)); else return 0; |
234 | //EOF is defined in stdlib as -1 | 231 | //EOF is defined in stdlib as -1 |
235 | }; | 232 | }; |
236 | 233 | ||
237 | int ExcelBook::Get2Bytes(void) | 234 | int ExcelBook::Get2Bytes(void) |
238 | { | 235 | { |
239 | int i1,i2; | 236 | int i1,i2; |
240 | i1=0; i2=0; | 237 | i1=0; i2=0; |
241 | if (!feof(File)) | 238 | if (!feof(File)) |
242 | { | 239 | { |
243 | i1=fgetc(File); | 240 | i1=fgetc(File); |
244 | Position++; | 241 | Position++; |
245 | }; | 242 | }; |
246 | if (!feof(File)) | 243 | if (!feof(File)) |
247 | { | 244 | { |
248 | i2=fgetc(File); | 245 | i2=fgetc(File); |
249 | Position++; | 246 | Position++; |
250 | }; | 247 | }; |
251 | return Integer2Byte(i1,i2); | 248 | return Integer2Byte(i1,i2); |
252 | }; | 249 | }; |
253 | 250 | ||
254 | char* ExcelBook::Read(int pos, int length) | 251 | char* ExcelBook::Read(int pos, int length) |
255 | { | 252 | { |
256 | int i; | 253 | int i; |
257 | char *data; | 254 | char *data; |
258 | data= new char[length]; | 255 | data= new char[length]; |
259 | SeekPosition(pos); | 256 | SeekPosition(pos); |
260 | for(i=0; i<length; i++) | 257 | for(i=0; i<length; i++) |
261 | { | 258 | { |
262 | if(!feof(File)) data[i]=fgetc(File); | 259 | if(!feof(File)) data[i]=fgetc(File); |
263 | }; | 260 | }; |
264 | Position= Position+length; | 261 | Position= Position+length; |
265 | return data; | 262 | return data; |
266 | }; | 263 | }; |
267 | 264 | ||
268 | QString ExcelBook::ReadUnicodeChar(int pos, int length) | 265 | QString ExcelBook::ReadUnicodeChar(int pos, int length) |
269 | { | 266 | { |
270 | int i; | 267 | int i; |
271 | QString data; | 268 | QString data; |
272 | int i1=' ',i2=' ',ii; | 269 | int i1=' ',i2=' ',ii; |
273 | SeekPosition(pos); | 270 | SeekPosition(pos); |
274 | for(i=0; i<length; i++) | 271 | for(i=0; i<length; i++) |
275 | { | 272 | { |
276 | if(!feof(File)) i1=fgetc(File); | 273 | if(!feof(File)) i1=fgetc(File); |
277 | if(!feof(File)) i2=fgetc(File); | 274 | if(!feof(File)) i2=fgetc(File); |
278 | ii=Integer2Byte(i1,i2); | 275 | ii=Integer2Byte(i1,i2); |
279 | data.append(ii); | 276 | data.append(ii); |
280 | Position+=2; | 277 | Position+=2; |
281 | }; | 278 | }; |
282 | return data; | 279 | return data; |
283 | }; | 280 | }; |
284 | 281 | ||
285 | QString* ExcelBook::GetString(int num) | 282 | QString* ExcelBook::GetString(int num) |
286 | { | 283 | { |
287 | if(num>=0 && num<(int)SharedStrings.count()) | 284 | if(num>=0 && num<(int)SharedStrings.count()) |
288 | { | 285 | { |
289 | return SharedStrings[num]; | 286 | return SharedStrings[num]; |
290 | }; | 287 | }; |
291 | return new QString(""); | 288 | return new QString(""); |
292 | }; | 289 | }; |
293 | 290 | ||
294 | int ExcelBook::SeekBOF(void) | 291 | int ExcelBook::SeekBOF(void) |
295 | { | 292 | { |
296 | int opcode,version,streamtype,length,ret=0; | 293 | int opcode,version,streamtype,length,ret=0; |
297 | char *data; | 294 | char *data; |
298 | while(!feof(File)) | 295 | while(!feof(File)) |
299 | { | 296 | { |
300 | opcode=Get2Bytes(); | 297 | opcode=Get2Bytes(); |
301 | if(opcode==XL_BOF) | 298 | if(opcode==XL_BOF) |
302 | { | 299 | { |
303 | length=Get2Bytes(); | 300 | length=Get2Bytes(); |
304 | data=Read(Position,length); | 301 | data=Read(Position,length); |
305 | version=Integer2Byte(data[0], data[1]); | 302 | version=Integer2Byte(data[0], data[1]); |
306 | streamtype=Integer2Byte(data[2], data[3]); | 303 | streamtype=Integer2Byte(data[2], data[3]); |
307 | printf("SEEKBOF:opcode=XLBOF, %d ,version %d\r\n",Position,version); | 304 | printf("SEEKBOF:opcode=XLBOF, %d ,version %d\r\n",Position,version); |
308 | delete data; data=NULL; | 305 | delete data; data=NULL; |
309 | if (version==BIFF8) ret=8; | 306 | if (version==BIFF8) ret=8; |
310 | else if(version==BIFF7) ret=7; | 307 | else if(version==BIFF7) ret=7; |
311 | printf("SEEKBOF:versionBIFF%d\r\n",ret); | 308 | printf("SEEKBOF:versionBIFF%d\r\n",ret); |
312 | if(streamtype==WBKGLOBAL) return ret *2; | 309 | if(streamtype==WBKGLOBAL) return ret *2; |
313 | else if(streamtype==WRKSHEET) return ret *1; | 310 | else if(streamtype==WRKSHEET) return ret *1; |
314 | return 1; | 311 | return 1; |
315 | }; | 312 | }; |
316 | }; | 313 | }; |
317 | return 0; | 314 | return 0; |
318 | }; | 315 | }; |
319 | 316 | ||
320 | ExcelBREC* ExcelBook::GetBREC(void) | 317 | ExcelBREC* ExcelBook::GetBREC(void) |
321 | { | 318 | { |
322 | ExcelBREC* rec; | 319 | ExcelBREC* rec; |
323 | rec= new ExcelBREC; | 320 | rec= new ExcelBREC; |
324 | if(FileEOF()) return NULL; | 321 | if(FileEOF()) return NULL; |
325 | rec->data=NULL; | 322 | rec->data=NULL; |
326 | rec->code=Get2Bytes(); | 323 | rec->code=Get2Bytes(); |
327 | rec->length=Get2Bytes(); | 324 | rec->length=Get2Bytes(); |
328 | rec->position=Position; | 325 | rec->position=Position; |
329 | SeekSkip(rec->length); | 326 | SeekSkip(rec->length); |
330 | return rec; | 327 | return rec; |
331 | }; | 328 | }; |
332 | 329 | ||
333 | ExcelBREC* ExcelBook::PeekBREC(void) | 330 | ExcelBREC* ExcelBook::PeekBREC(void) |
334 | { | 331 | { |
335 | int oldpos; | 332 | int oldpos; |
336 | ExcelBREC* NextRec; | 333 | ExcelBREC* NextRec; |
337 | oldpos=Position; | 334 | oldpos=Position; |
338 | NextRec=GetBREC(); | 335 | NextRec=GetBREC(); |
339 | SeekPosition(oldpos); | 336 | SeekPosition(oldpos); |
340 | return NextRec; | 337 | return NextRec; |
341 | }; | 338 | }; |
342 | 339 | ||
343 | char* ExcelBook::GetDataOfBREC(ExcelBREC* record) | 340 | char* ExcelBook::GetDataOfBREC(ExcelBREC* record) |
344 | { | 341 | { |
345 | if(record->data==NULL) | 342 | if(record->data==NULL) |
346 | { | 343 | { |
347 | ConvertCharToArray(record,Read(record->position,record->length),record->length); | 344 | ConvertCharToArray(record,Read(record->position,record->length),record->length); |
348 | }; | 345 | }; |
349 | return record->data;//new? | 346 | return record->data;//new? |
350 | }; | 347 | }; |
351 | 348 | ||
352 | void ExcelBook::ConvertCharToArray(ExcelBREC* record, char* chars, int length) | 349 | void ExcelBook::ConvertCharToArray(ExcelBREC* record, char* chars, int length) |
353 | { | 350 | { |
354 | record->data=new char[length]; | 351 | record->data=new char[length]; |
355 | for(int w1=0;w1<=length-1;w1++) | 352 | for(int w1=0;w1<=length-1;w1++) |
356 | record->data[w1]=chars[w1]; | 353 | record->data[w1]=chars[w1]; |
357 | }; | 354 | }; |
358 | 355 | ||
359 | 356 | ||
360 | bool ExcelSheet::InitCells() | 357 | bool ExcelSheet::InitCells() |
361 | { | 358 | { |
362 | int r; | 359 | int r; |
363 | Cells.resize(rows * cols + cols+1); | 360 | Cells.resize(rows * cols + cols+1); |
364 | if(Cells.count()==0) return false; | 361 | if(Cells.count()==0) return false; |
365 | for(r=0;r < Cells.count();r++) | 362 | for(r=0;r < Cells.count();r++) |
366 | { | 363 | { |
367 | Cells[r]=NULL; | 364 | Cells[r]=NULL; |
368 | }; | 365 | }; |
369 | return true; | 366 | return true; |
370 | }; | 367 | }; |
371 | 368 | ||
372 | void ExcelSheet::Set(int row, int col, ExcelCell* cell) | 369 | void ExcelSheet::Set(int row, int col, ExcelCell* cell) |
373 | { | 370 | { |
374 | if(cell!=NULL&&(row*cols+col)<Cells.count()) | 371 | if(cell!=NULL&&(row*cols+col)<Cells.count()) |
375 | { | 372 | { |
376 | Cells[row*cols+col]=cell; | 373 | Cells[row*cols+col]=cell; |
377 | }; | 374 | }; |
378 | }; | 375 | }; |
379 | 376 | ||
380 | ExcelCell* ExcelSheet::Get(int row, int col) | 377 | ExcelCell* ExcelSheet::Get(int row, int col) |
381 | { | 378 | { |
382 | ExcelCell* cell; | 379 | ExcelCell* cell; |
383 | cell=Cells[row*cols+col]; | 380 | cell=Cells[row*cols+col]; |
384 | if(cell==NULL) return NULL; | 381 | if(cell==NULL) return NULL; |
385 | return cell; | 382 | return cell; |
386 | }; | 383 | }; |
387 | 384 | ||
388 | int ExcelBook::SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record) | 385 | int ExcelBook::SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record) |
389 | { | 386 | { |
390 | char* data=NULL; | 387 | char* data=NULL; |
391 | switch (record->code) | 388 | switch (record->code) |
392 | { | 389 | { |
393 | case XL_DIMENSION: | 390 | case XL_DIMENSION: |
394 | data = GetDataOfBREC(record); | 391 | data = GetDataOfBREC(record); |
395 | if (record->length == 10) | 392 | if (record->length == 10) |
396 | { | 393 | { |
397 | sheet->rows = Integer2Byte(data[2], data[3]); | 394 | sheet->rows = Integer2Byte(data[2], data[3]); |
398 | sheet->cols = Integer2Byte(data[6], data[7]); | 395 | sheet->cols = Integer2Byte(data[6], data[7]); |
399 | } else | 396 | } else |
400 | { | 397 | { |
401 | sheet->rows = Integer4Byte(data[4], data[5], data[6], data[7]); | 398 | sheet->rows = Integer4Byte(data[4], data[5], data[6], data[7]); |
402 | sheet->cols = Integer2Byte(data[10], data[11]); | 399 | sheet->cols = Integer2Byte(data[10], data[11]); |
403 | } | 400 | } |
404 | sheet->InitCells(); | 401 | sheet->InitCells(); |
405 | break; | 402 | break; |
406 | 403 | ||
407 | case XL_LABELSST: | 404 | case XL_LABELSST: |
408 | HandleLabelSST(sheet, record); | 405 | HandleLabelSST(sheet, record); |
409 | break; | 406 | break; |
410 | 407 | ||
411 | case XL_RK: | 408 | case XL_RK: |
412 | case XL_RK2: | 409 | case XL_RK2: |
413 | HandleRK(sheet, record); | 410 | HandleRK(sheet, record); |
414 | break; | 411 | break; |
415 | 412 | ||
416 | case XL_MULRK: | 413 | case XL_MULRK: |
417 | HandleMulrk(sheet, record); | 414 | HandleMulrk(sheet, record); |
418 | break; | 415 | break; |
419 | 416 | ||
420 | case XL_ROW: | 417 | case XL_ROW: |
421 | break; | 418 | break; |
422 | 419 | ||
423 | case XL_NUMBER: | 420 | case XL_NUMBER: |
424 | HandleNumber(sheet, record); | 421 | HandleNumber(sheet, record); |
425 | break; | 422 | break; |
426 | 423 | ||
427 | case XL_BOOLERR: | 424 | case XL_BOOLERR: |
428 | break; | 425 | break; |
429 | 426 | ||
430 | case XL_CONTINUE: | 427 | case XL_CONTINUE: |
431 | break; | 428 | break; |
432 | 429 | ||
433 | case XL_FORMULA: | 430 | case XL_FORMULA: |
434 | case XL_FORMULA2: | 431 | case XL_FORMULA2: |
435 | HandleFormula(sheet, record); | 432 | HandleFormula(sheet, record); |
436 | break; | 433 | break; |
437 | 434 | ||
438 | case XL_LABEL: | 435 | case XL_LABEL: |
439 | break; | 436 | break; |
440 | 437 | ||
441 | case XL_NAME: | 438 | case XL_NAME: |
442 | HandleName(sheet, record); | 439 | HandleName(sheet, record); |
443 | break; | 440 | break; |
444 | 441 | ||
445 | case XL_BOF: | 442 | case XL_BOF: |
446 | break; | 443 | break; |
447 | case XL_EOF: | 444 | case XL_EOF: |
448 | return 0; | 445 | return 0; |
449 | default: | 446 | default: |
450 | break; | 447 | break; |
451 | }; | 448 | }; |
452 | return 1; | 449 | return 1; |
453 | }; | 450 | }; |
454 | 451 | ||
455 | int ExcelBook::ReadSheet(ExcelSheet* sheet) | 452 | int ExcelBook::ReadSheet(ExcelSheet* sheet) |
456 | { | 453 | { |
457 | ExcelBREC* record; | 454 | ExcelBREC* record; |
458 | int oldpos; | 455 | int oldpos; |
459 | oldpos = Position; | 456 | oldpos = Position; |
460 | SeekPosition(sheet->position); | 457 | SeekPosition(sheet->position); |
461 | record = GetBREC(); | 458 | record = GetBREC(); |
462 | while (record!=NULL) | 459 | while (record!=NULL) |
463 | { | 460 | { |
464 | if (!SheetHandleRecord(sheet, record)) break; | 461 | if (!SheetHandleRecord(sheet, record)) break; |
465 | record=GetBREC(); | 462 | record=GetBREC(); |
466 | }; | 463 | }; |
467 | SeekPosition(oldpos); | 464 | SeekPosition(oldpos); |
468 | return 1; | 465 | return 1; |
469 | }; | 466 | }; |
470 | 467 | ||
471 | ExcelSheet* ExcelBook::GetSheet(void) | 468 | ExcelSheet* ExcelBook::GetSheet(void) |
472 | { | 469 | { |
473 | ExcelSheet* sh=NULL; | 470 | ExcelSheet* sh=NULL; |
474 | int type; | 471 | int type; |
475 | type=SeekBOF(); | 472 | type=SeekBOF(); |
476 | Version=type; | 473 | Version=type; |
477 | sh=new ExcelSheet; | 474 | sh=new ExcelSheet; |
478 | if(type) | 475 | if(type) |
479 | { | 476 | { |
480 | sh->type=type; | 477 | sh->type=type; |
481 | sh->position=Position; | 478 | sh->position=Position; |
482 | sh->name=QString(""); | 479 | sh->name=QString(""); |
483 | }; | 480 | }; |
484 | if(type==8||type==7) | 481 | if(type==8||type==7) |
485 | { | 482 | { |
486 | ReadSheet(sh); | 483 | ReadSheet(sh); |
487 | }; | 484 | }; |
488 | return sh; | 485 | return sh; |
489 | }; | 486 | }; |
490 | 487 | ||
491 | void ExcelBook::ParseSheets(void) | 488 | void ExcelBook::ParseSheets(void) |
492 | { | 489 | { |
493 | int BOFs; | 490 | int BOFs; |
494 | ExcelBREC* r; | 491 | ExcelBREC* r; |
495 | BOFs=1; | 492 | BOFs=1; |
496 | r=GetBREC(); | 493 | r=GetBREC(); |
497 | while(BOFs) | 494 | while(BOFs) |
498 | { | 495 | { |
499 | r=GetBREC(); | 496 | r=GetBREC(); |
500 | switch(r->code) | 497 | switch(r->code) |
501 | { | 498 | { |
502 | case XL_SST: | 499 | case XL_SST: |
503 | HandleSST(r); | 500 | HandleSST(r); |
504 | break; | 501 | break; |
505 | 502 | ||
506 | case XL_TXO: | 503 | case XL_TXO: |
507 | break; | 504 | break; |
508 | case XL_NAME: | 505 | case XL_NAME: |
509 | break; | 506 | break; |
510 | case XL_ROW: | 507 | case XL_ROW: |
511 | break; | 508 | break; |
512 | 509 | ||
513 | case XL_FORMAT: | 510 | case XL_FORMAT: |
514 | HandleFormat(r); | 511 | HandleFormat(r); |
515 | break; | 512 | break; |
516 | 513 | ||
517 | case XL_XF: | 514 | case XL_XF: |
518 | HandleXF(r); | 515 | HandleXF(r); |
519 | break; | 516 | break; |
520 | 517 | ||
521 | case XL_BOUNDSHEET: | 518 | case XL_BOUNDSHEET: |
522 | HandleBoundSheet(r); | 519 | HandleBoundSheet(r); |
523 | break; | 520 | break; |
524 | 521 | ||
525 | case XL_EXTSST: | 522 | case XL_EXTSST: |
526 | break; | 523 | break; |
527 | case XL_CONTINUE: | 524 | case XL_CONTINUE: |
528 | break; | 525 | break; |
529 | 526 | ||
530 | case XL_EOF: | 527 | case XL_EOF: |
531 | BOFs--; | 528 | BOFs--; |
532 | break; | 529 | break; |
533 | 530 | ||
534 | default: | 531 | default: |
535 | break; | 532 | break; |
536 | }; | 533 | }; |
537 | }; | 534 | }; |
538 | }; | 535 | }; |
539 | 536 | ||
540 | void ExcelBook::GetSheets(void) | 537 | void ExcelBook::GetSheets(void) |
541 | { | 538 | { |
542 | ExcelSheet* sheet; | 539 | ExcelSheet* sheet; |
543 | Sheets.resize(0); | 540 | Sheets.resize(0); |
544 | sheet=GetSheet(); | 541 | sheet=GetSheet(); |
545 | while (sheet->Cells.count()!= 0 ) | 542 | while (sheet->Cells.count()!= 0 ) |
546 | { | 543 | { |
547 | Sheets.resize(Sheets.count()+1); | 544 | Sheets.resize(Sheets.count()+1); |
548 | Sheets[Sheets.count()-1]=sheet; | 545 | Sheets[Sheets.count()-1]=sheet; |
549 | sheet->name=*Names[Sheets.count()-1]; | 546 | sheet->name=*Names[Sheets.count()-1]; |
550 | sheet=GetSheet(); | 547 | sheet=GetSheet(); |
551 | }; | 548 | }; |
552 | }; | 549 | }; |
553 | 550 | ||
554 | bool ExcelBook::ParseBook(char *file) | 551 | bool ExcelBook::ParseBook(char *file) |
555 | { | 552 | { |
556 | dateformat=QString(""); | 553 | dateformat=QString(""); |
557 | DetectEndian(); | 554 | DetectEndian(); |
558 | OpenFile(file); | 555 | OpenFile(file); |
559 | SeekBOF(); | 556 | SeekBOF(); |
560 | ParseSheets(); | 557 | ParseSheets(); |
561 | GetSheets(); | 558 | GetSheets(); |
562 | return true; | 559 | return true; |
563 | }; | 560 | }; |
564 | 561 | ||
565 | QString ExcelBook::GetASCII(char* inbytes, int pos, int chars) | 562 | QString ExcelBook::GetASCII(char* inbytes, int pos, int chars) |
566 | { | 563 | { |
567 | int i; | 564 | int i; |
568 | QString outstr=""; | 565 | QString outstr=""; |
569 | for (i = 0; i < chars; i++) | 566 | for (i = 0; i < chars; i++) |
570 | { | 567 | { |
571 | outstr.append(inbytes[i+pos]); | 568 | outstr.append(inbytes[i+pos]); |
572 | }; | 569 | }; |
573 | return outstr; | 570 | return outstr; |
574 | }; | 571 | }; |
575 | 572 | ||
576 | QString ExcelBook::GetUnicode(char * inbytes, int pos, int chars) | 573 | QString ExcelBook::GetUnicode(char * inbytes, int pos, int chars) |
577 | { | 574 | { |
578 | QString outstr=""; | 575 | QString outstr=""; |
579 | int i; | 576 | int i; |
580 | int rc; | 577 | int rc; |
581 | for (i=0; i<chars*2; i++) | 578 | for (i=0; i<chars*2; i++) |
582 | { | 579 | { |
583 | rc=Integer2Byte(inbytes[i+pos],inbytes[i+pos+1]); | 580 | rc=Integer2Byte(inbytes[i+pos],inbytes[i+pos+1]); |
584 | outstr.append(QChar(rc)); | 581 | outstr.append(QChar(rc)); |
585 | i++; | 582 | i++; |
586 | }; | 583 | }; |
587 | return outstr; | 584 | return outstr; |
588 | }; | 585 | }; |
589 | 586 | ||
590 | 587 | ||
591 | void ExcelBook::HandleBoundSheet(ExcelBREC* rec) | 588 | void ExcelBook::HandleBoundSheet(ExcelBREC* rec) |
592 | { | 589 | { |
593 | char* data; | 590 | char* data; |
594 | int type; | 591 | int type; |
595 | int visibility; | 592 | int visibility; |
596 | int length; | 593 | int length; |
597 | int pos; | 594 | int pos; |
598 | QString name; | 595 | QString name; |
599 | pos = 8; | 596 | pos = 8; |
600 | data = GetDataOfBREC(rec); | 597 | data = GetDataOfBREC(rec); |
601 | type = data[4]; | 598 | type = data[4]; |
602 | visibility = data[5]; | 599 | visibility = data[5]; |
603 | length = data[6]; | 600 | length = data[6]; |
604 | if(data[7]==0) | 601 | if(data[7]==0) |
605 | { | 602 | { |
606 | //ascii | 603 | //ascii |
607 | name=GetASCII(data,pos,length); | 604 | name=GetASCII(data,pos,length); |
608 | }else | 605 | }else |
609 | { | 606 | { |
610 | name=GetUnicode(data,pos,length); | 607 | name=GetUnicode(data,pos,length); |
611 | }; | 608 | }; |
612 | Names.resize(Names.count()+1); | 609 | Names.resize(Names.count()+1); |
613 | Names[Names.count()-1]=new QString(name); | 610 | Names[Names.count()-1]=new QString(name); |
614 | }; | 611 | }; |
615 | 612 | ||
616 | void ExcelBook::HandleName(ExcelSheet* sheet, ExcelBREC* rec) | 613 | void ExcelBook::HandleName(ExcelSheet* sheet, ExcelBREC* rec) |
617 | { | 614 | { |
618 | char* data; | 615 | char* data; |
619 | QString name; | 616 | QString name; |
620 | int length; | 617 | int length; |
621 | int pos; | 618 | int pos; |
622 | pos = 15; | 619 | pos = 15; |
623 | data = GetDataOfBREC(rec); | 620 | data = GetDataOfBREC(rec); |
624 | length = data[3]; | 621 | length = data[3]; |
625 | name = GetASCII(data,pos,length); | 622 | name = GetASCII(data,pos,length); |
626 | 623 | ||
627 | 624 | ||
628 | }; | 625 | }; |
629 | 626 | ||
630 | ExcelFormat* ExcelBook::GetFormatting(int xf) | 627 | ExcelFormat* ExcelBook::GetFormatting(int xf) |
631 | { | 628 | { |
632 | int i; | 629 | int i; |
633 | ExcelFormat* rec; | 630 | ExcelFormat* rec; |
634 | rec=new ExcelFormat(); | 631 | rec=new ExcelFormat(); |
635 | for (i = 0; formatter[i].code != 0; i++) | 632 | for (i = 0; formatter[i].code != 0; i++) |
636 | { | 633 | { |
637 | if (xf == formatter[i].code) break; | 634 | if (xf == formatter[i].code) break; |
638 | }; | 635 | }; |
639 | if (formatter[i].format ==NULL) return NULL; | 636 | if (formatter[i].format ==NULL) return NULL; |
640 | rec->code = xf; | 637 | rec->code = xf; |
641 | rec->type = formatter[i].type; | 638 | rec->type = formatter[i].type; |
642 | rec->format = formatter[i].format; | 639 | rec->format = formatter[i].format; |
643 | return rec; | 640 | return rec; |
644 | }; | 641 | }; |
645 | 642 | ||
646 | void ExcelBook::HandleSetOfSST(ExcelBREC* rec/*, SSTList* cont*/, char* bytes) | 643 | void ExcelBook::HandleSetOfSST(ExcelBREC* rec/*, SSTList* cont*/, char* bytes) |
647 | { | 644 | { |
648 | QString str=QString(""); | 645 | QString str=QString(""); |
649 | char* data; | 646 | char* data; |
650 | int chars, pos, options, i; | 647 | int chars, pos, options, i; |
651 | int richstring, fareaststring, runlength=0; | 648 | int richstring, fareaststring, runlength=0; |
652 | int richruns=0,fareastsize=0; | 649 | int richruns=0,fareastsize=0; |
653 | int totalstrings; | 650 | int totalstrings; |
654 | int uniquestrings; | 651 | int uniquestrings; |
655 | data = GetDataOfBREC(rec); | 652 | data = GetDataOfBREC(rec); |
656 | totalstrings = Integer4Byte(data[0], data[1], data[2], data[3]); | 653 | totalstrings = Integer4Byte(data[0], data[1], data[2], data[3]); |
657 | uniquestrings = Integer4Byte(data[4], data[5], data[6], data[7]); | 654 | uniquestrings = Integer4Byte(data[4], data[5], data[6], data[7]); |
658 | pos = 8; | 655 | pos = 8; |
659 | for (i = 0; i < uniquestrings; i++) | 656 | for (i = 0; i < uniquestrings; i++) |
660 | { | 657 | { |
661 | richruns=0; fareastsize=0; | 658 | richruns=0; fareastsize=0; |
662 | chars = Integer2Byte(data[pos], data[pos+1]); | 659 | chars = Integer2Byte(data[pos], data[pos+1]); |
663 | pos += 2; | 660 | pos += 2; |
664 | options = data[pos]; | 661 | options = data[pos]; |
665 | pos++; | 662 | pos++; |
666 | fareaststring = ((options & 0x04) != 0); | 663 | fareaststring = ((options & 0x04) != 0); |
667 | richstring = ((options & 0x08) != 0); | 664 | richstring = ((options & 0x08) != 0); |
668 | if(richstring) | 665 | if(richstring) |
669 | { | 666 | { |
670 | richruns= Integer2Byte(data[pos],data[pos+1]); | 667 | richruns= Integer2Byte(data[pos],data[pos+1]); |
671 | pos+=2; | 668 | pos+=2; |
672 | }; | 669 | }; |
673 | if(fareaststring) | 670 | if(fareaststring) |
674 | { | 671 | { |
675 | fareastsize=Integer4Byte(data[pos], data[pos+1], data[pos+2], data[pos+3]); | 672 | fareastsize=Integer4Byte(data[pos], data[pos+1], data[pos+2], data[pos+3]); |
676 | pos+=4; | 673 | pos+=4; |
677 | }; | 674 | }; |
678 | 675 | ||
679 | if ((options & 0x01) == 0) //8 bit chars | 676 | if ((options & 0x01) == 0) //8 bit chars |
680 | { | 677 | { |
681 | /* ascii */ | 678 | /* ascii */ |
682 | str = GetASCII(bytes,pos,chars); | 679 | str = GetASCII(bytes,pos,chars); |
683 | pos=pos+chars; | 680 | pos=pos+chars; |
684 | if(str[0]=='=') str[0]=' '; | 681 | if(str[0]=='=') str[0]=' '; |
685 | }else //16 bit chars | 682 | }else //16 bit chars |
686 | { | 683 | { |
687 | /* unicode */ | 684 | /* unicode */ |
688 | str = GetUnicode(bytes,pos,chars); | 685 | str = GetUnicode(bytes,pos,chars); |
689 | pos=pos+chars*2; | 686 | pos=pos+chars*2; |
690 | }; | 687 | }; |
691 | // HERE TO PUT richformat handling | 688 | // HERE TO PUT richformat handling |
692 | if (richstring) | 689 | if (richstring) |
693 | { | 690 | { |
694 | pos += 4 * richruns; | 691 | pos += 4 * richruns; |
695 | }; | 692 | }; |
696 | if (fareaststring) | 693 | if (fareaststring) |
697 | { | 694 | { |
698 | pos += fareastsize; | 695 | pos += fareastsize; |
699 | }; | 696 | }; |
700 | //printf("String=%s, length=%d first=0x%x\r\n",str.ascii(),str.length(),str[0].unicode()); | 697 | //printf("String=%s, length=%d first=0x%x\r\n",str.ascii(),str.length(),str[0].unicode()); |
701 | SharedStrings.resize(SharedStrings.count()+1); | 698 | SharedStrings.resize(SharedStrings.count()+1); |
702 | SharedStrings[SharedStrings.count()-1]=new QString(str); | 699 | SharedStrings[SharedStrings.count()-1]=new QString(str); |
703 | } | 700 | } |
704 | }; | 701 | }; |
705 | 702 | ||
706 | 703 | ||
707 | char* ExcelBook::MergeBytesFromSSTs(ExcelBREC* rec,SSTList* cont) | 704 | char* ExcelBook::MergeBytesFromSSTs(ExcelBREC* rec,SSTList* cont) |
708 | { | 705 | { |
709 | int i, pos; | 706 | int i, pos; |
710 | int length; | 707 | int length; |
711 | 708 | ||
712 | char* data; | 709 | char* data; |
713 | char* bytes; | 710 | char* bytes; |
714 | length = rec->length; | 711 | length = rec->length; |
715 | for (i = 0; i < (int) cont->rec.count(); i++) | 712 | for (i = 0; i < (int) cont->rec.count(); i++) |
716 | { | 713 | { |
717 | length += cont->rec[i]->length; | 714 | length += cont->rec[i]->length; |
718 | } | 715 | } |
719 | bytes = GetDataOfBREC(rec); | 716 | bytes = GetDataOfBREC(rec); |
720 | pos = rec->length; | 717 | pos = rec->length; |
721 | for (i = 0; i < (int) cont->rec.count(); i++) | 718 | for (i = 0; i < (int) cont->rec.count(); i++) |
722 | { | 719 | { |
723 | data = GetDataOfBREC(cont->rec[i]); | 720 | data = GetDataOfBREC(cont->rec[i]); |
724 | *bytes += pos; | 721 | *bytes += pos; |
725 | bytes = data; | 722 | bytes = data; |
726 | pos += cont->rec[i]->length; | 723 | pos += cont->rec[i]->length; |
727 | } | 724 | } |
728 | return bytes; | 725 | return bytes; |
729 | }; | 726 | }; |
730 | 727 | ||
731 | 728 | ||
732 | void ExcelBook::HandleSST(ExcelBREC* rec) | 729 | void ExcelBook::HandleSST(ExcelBREC* rec) |
733 | { | 730 | { |
734 | char* bytes; | 731 | char* bytes; |
735 | SSTList* cont; | 732 | SSTList* cont; |
736 | cont= new SSTList; | 733 | cont= new SSTList; |
737 | ExcelBREC* nr; | 734 | ExcelBREC* nr; |
738 | nr = PeekBREC(); | 735 | nr = PeekBREC(); |
739 | while (nr->code == XL_CONTINUE) | 736 | while (nr->code == XL_CONTINUE) |
740 | { | 737 | { |
741 | cont->rec.resize(cont->rec.count()+1); | 738 | cont->rec.resize(cont->rec.count()+1); |
742 | cont->rec[cont->rec.count()-1]=GetBREC(); | 739 | cont->rec[cont->rec.count()-1]=GetBREC(); |
743 | nr = PeekBREC(); | 740 | nr = PeekBREC(); |
744 | } | 741 | } |
745 | bytes = MergeBytesFromSSTs(rec,cont); | 742 | bytes = MergeBytesFromSSTs(rec,cont); |
746 | HandleSetOfSST(rec, bytes); | 743 | HandleSetOfSST(rec, bytes); |
747 | for(int w1=0;w1<(int)cont->rec.count();w1++) | 744 | for(int w1=0;w1<(int)cont->rec.count();w1++) |
748 | { | 745 | { |
749 | if(cont->rec[w1]!=NULL) {delete cont->rec[w1];cont->rec[w1]=NULL;}; | 746 | if(cont->rec[w1]!=NULL) {delete cont->rec[w1];cont->rec[w1]=NULL;}; |
750 | }; | 747 | }; |
751 | cont->rec.resize(0); | 748 | cont->rec.resize(0); |
752 | }; | 749 | }; |
753 | 750 | ||
754 | void ExcelBook::HandleLabelSST(ExcelSheet* sheet, ExcelBREC* rec) | 751 | void ExcelBook::HandleLabelSST(ExcelSheet* sheet, ExcelBREC* rec) |
755 | { | 752 | { |
756 | int index, row, col; | 753 | int index, row, col; |
757 | char* data; | 754 | char* data; |
758 | data = GetDataOfBREC(rec); | 755 | data = GetDataOfBREC(rec); |
759 | index = Integer4Byte(data[6], data[7], data[8], data[9]); | 756 | index = Integer4Byte(data[6], data[7], data[8], data[9]); |
760 | row = Integer2Byte(data[0], data[1]); | 757 | row = Integer2Byte(data[0], data[1]); |
761 | col = Integer2Byte(data[2], data[3]); | 758 | col = Integer2Byte(data[2], data[3]); |
762 | sheet->Set(row,col, CellLabel(row, col, *GetString(index))); | 759 | sheet->Set(row,col, CellLabel(row, col, *GetString(index))); |
763 | }; | 760 | }; |
764 | 761 | ||
765 | ExcelCell* ExcelBook::CellLabel(int row, int col, QString str) | 762 | ExcelCell* ExcelBook::CellLabel(int row, int col, QString str) |
766 | { | 763 | { |
767 | ExcelCell* c; | 764 | ExcelCell* c; |
768 | c= new ExcelCell; | 765 | c= new ExcelCell; |
769 | c->row = row; | 766 | c->row = row; |
770 | c->col = col; | 767 | c->col = col; |
771 | c->type = CELL_LABEL; | 768 | c->type = CELL_LABEL; |
772 | c->valuec = str; | 769 | c->valuec = str; |
773 | return c; | 770 | return c; |
774 | }; | 771 | }; |
775 | 772 | ||
776 | ExcelCell* ExcelBook::CellNumber(int row, int col, int index, double d) | 773 | ExcelCell* ExcelBook::CellNumber(int row, int col, int index, double d) |
777 | { | 774 | { |
778 | ExcelCell* c; | 775 | ExcelCell* c; |
779 | c=new ExcelCell; | 776 | c=new ExcelCell; |
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index 3d3c688..1fb2a3d 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp | |||
@@ -1,792 +1,788 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 11 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 12 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include "mainwindow.h" | 15 | #include "mainwindow.h" |
16 | 16 | ||
17 | #include <qpe/filemanager.h> | ||
18 | #include <qpe/qcopenvelope_qws.h> | ||
19 | #include <qpe/resource.h> | 17 | #include <qpe/resource.h> |
20 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
21 | 19 | ||
22 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
23 | #include <qfile.h> | ||
24 | #include <qtranslator.h> | ||
25 | #include <qradiobutton.h> | 21 | #include <qradiobutton.h> |
26 | 22 | ||
27 | #include "cellformat.h" | 23 | #include "cellformat.h" |
28 | #include "numberdlg.h" | 24 | #include "numberdlg.h" |
29 | #include "textdlg.h" | 25 | #include "textdlg.h" |
30 | #include "sortdlg.h" | 26 | #include "sortdlg.h" |
31 | #include "finddlg.h" | 27 | #include "finddlg.h" |
32 | 28 | ||
33 | #define DEFAULT_NUM_ROWS 300 | 29 | #define DEFAULT_NUM_ROWS 300 |
34 | #define DEFAULT_NUM_COLS (26*3) | 30 | #define DEFAULT_NUM_COLS (26*3) |
35 | #define DEFAULT_NUM_SHEETS 3 | 31 | #define DEFAULT_NUM_SHEETS 3 |
36 | 32 | ||
37 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) | 33 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) |
38 | :QMainWindow(parent, n, fl) | 34 | :QMainWindow(parent, n, fl) |
39 | { | 35 | { |
40 | // initialize variables | 36 | // initialize variables |
41 | documentModified=FALSE; | 37 | documentModified=FALSE; |
42 | 38 | ||
43 | // construct objects | 39 | // construct objects |
44 | currentDoc=0; | 40 | currentDoc=0; |
45 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); | 41 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); |
46 | ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); | 42 | ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); |
47 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); | 43 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); |
48 | connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); | 44 | connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); |
49 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); | 45 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); |
50 | connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk &)),this,SLOT(slotImportExcel(const DocLnk &))); | 46 | connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk &)),this,SLOT(slotImportExcel(const DocLnk &))); |
51 | connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); | 47 | connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); |
52 | 48 | ||
53 | 49 | ||
54 | listSheets.setAutoDelete(TRUE); | 50 | listSheets.setAutoDelete(TRUE); |
55 | 51 | ||
56 | initActions(); | 52 | initActions(); |
57 | initMenu(); | 53 | initMenu(); |
58 | initEditToolbar(); | 54 | initEditToolbar(); |
59 | initFunctionsToolbar(); | 55 | initFunctionsToolbar(); |
60 | initStandardToolbar(); | 56 | initStandardToolbar(); |
61 | initSheet(); | 57 | initSheet(); |
62 | 58 | ||
63 | // set window title | 59 | // set window title |
64 | setCaption(tr("Opie Sheet")); | 60 | setCaption(tr("Opie Sheet")); |
65 | 61 | ||
66 | // create sheets | 62 | // create sheets |
67 | selectorFileNew(DocLnk()); | 63 | selectorFileNew(DocLnk()); |
68 | } | 64 | } |
69 | 65 | ||
70 | MainWindow::~MainWindow() | 66 | MainWindow::~MainWindow() |
71 | { | 67 | { |
72 | if (currentDoc) delete currentDoc; | 68 | if (currentDoc) delete currentDoc; |
73 | } | 69 | } |
74 | 70 | ||
75 | void MainWindow::documentSave(DocLnk *lnkDoc) | 71 | void MainWindow::documentSave(DocLnk *lnkDoc) |
76 | { | 72 | { |
77 | FileManager fm; | 73 | FileManager fm; |
78 | QByteArray streamBuffer; | 74 | QByteArray streamBuffer; |
79 | QDataStream stream(streamBuffer, IO_WriteOnly); | 75 | QDataStream stream(streamBuffer, IO_WriteOnly); |
80 | 76 | ||
81 | typeSheet *currentSheet=findSheet(sheet->getName()); | 77 | typeSheet *currentSheet=findSheet(sheet->getName()); |
82 | if (!currentSheet) | 78 | if (!currentSheet) |
83 | { | 79 | { |
84 | QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); | 80 | QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); |
85 | return; | 81 | return; |
86 | } | 82 | } |
87 | sheet->copySheetData(¤tSheet->data); | 83 | sheet->copySheetData(¤tSheet->data); |
88 | stream.writeRawBytes("SQT100", 6); | 84 | stream.writeRawBytes("SQT100", 6); |
89 | stream << (Q_UINT32)listSheets.count(); | 85 | stream << (Q_UINT32)listSheets.count(); |
90 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 86 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
91 | { | 87 | { |
92 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); | 88 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); |
93 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) | 89 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) |
94 | stream << (Q_UINT32)tempCell->col << (Q_UINT32)tempCell->row << tempCell->borders.right << tempCell->borders.bottom << tempCell->background << (Q_UINT32)tempCell->alignment << tempCell->fontColor << tempCell->font << tempCell->data; | 90 | stream << (Q_UINT32)tempCell->col << (Q_UINT32)tempCell->row << tempCell->borders.right << tempCell->borders.bottom << tempCell->background << (Q_UINT32)tempCell->alignment << tempCell->fontColor << tempCell->font << tempCell->data; |
95 | } | 91 | } |
96 | 92 | ||
97 | lnkDoc->setType("application/sheet-qt"); | 93 | lnkDoc->setType("application/sheet-qt"); |
98 | if (!fm.saveFile(*lnkDoc, streamBuffer)) | 94 | if (!fm.saveFile(*lnkDoc, streamBuffer)) |
99 | { | 95 | { |
100 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); | 96 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); |
101 | return; | 97 | return; |
102 | } | 98 | } |
103 | documentModified=FALSE; | 99 | documentModified=FALSE; |
104 | } | 100 | } |
105 | 101 | ||
106 | void MainWindow::documentOpen(const DocLnk &lnkDoc) | 102 | void MainWindow::documentOpen(const DocLnk &lnkDoc) |
107 | { | 103 | { |
108 | FileManager fm; | 104 | FileManager fm; |
109 | QByteArray streamBuffer; | 105 | QByteArray streamBuffer; |
110 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) | 106 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) |
111 | { | 107 | { |
112 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); | 108 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); |
113 | documentModified=FALSE; | 109 | documentModified=FALSE; |
114 | selectorFileNew(DocLnk()); | 110 | selectorFileNew(DocLnk()); |
115 | return; | 111 | return; |
116 | } | 112 | } |
117 | QDataStream stream(streamBuffer, IO_ReadOnly); | 113 | QDataStream stream(streamBuffer, IO_ReadOnly); |
118 | 114 | ||
119 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; | 115 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; |
120 | typeSheet *newSheet; | 116 | typeSheet *newSheet; |
121 | typeCellData *newCell; | 117 | typeCellData *newCell; |
122 | 118 | ||
123 | char fileFormat[7]; | 119 | char fileFormat[7]; |
124 | stream.readRawBytes(fileFormat, 6); | 120 | stream.readRawBytes(fileFormat, 6); |
125 | fileFormat[6]=0; | 121 | fileFormat[6]=0; |
126 | if ((QString)fileFormat!="SQT100") | 122 | if ((QString)fileFormat!="SQT100") |
127 | { | 123 | { |
128 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); | 124 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); |
129 | documentModified=FALSE; | 125 | documentModified=FALSE; |
130 | selectorFileNew(DocLnk()); | 126 | selectorFileNew(DocLnk()); |
131 | return; | 127 | return; |
132 | } | 128 | } |
133 | 129 | ||
134 | stream >> countSheet; | 130 | stream >> countSheet; |
135 | for (i=0; i<countSheet; ++i) | 131 | for (i=0; i<countSheet; ++i) |
136 | { | 132 | { |
137 | newSheet=new typeSheet; | 133 | newSheet=new typeSheet; |
138 | newSheet->data.setAutoDelete(TRUE); | 134 | newSheet->data.setAutoDelete(TRUE); |
139 | stream >> newSheet->name >> countCell; | 135 | stream >> newSheet->name >> countCell; |
140 | comboSheets->insertItem(newSheet->name); | 136 | comboSheets->insertItem(newSheet->name); |
141 | 137 | ||
142 | for (j=0; j<countCell; ++j) | 138 | for (j=0; j<countCell; ++j) |
143 | { | 139 | { |
144 | newCell=new typeCellData; | 140 | newCell=new typeCellData; |
145 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; | 141 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; |
146 | newCell->col=col; | 142 | newCell->col=col; |
147 | newCell->row=row; | 143 | newCell->row=row; |
148 | newCell->alignment=(Qt::AlignmentFlags)alignment; | 144 | newCell->alignment=(Qt::AlignmentFlags)alignment; |
149 | newSheet->data.append(newCell); | 145 | newSheet->data.append(newCell); |
150 | } | 146 | } |
151 | listSheets.append(newSheet); | 147 | listSheets.append(newSheet); |
152 | 148 | ||
153 | if (i==0) | 149 | if (i==0) |
154 | { | 150 | { |
155 | sheet->setName(newSheet->name); | 151 | sheet->setName(newSheet->name); |
156 | sheet->setSheetData(&newSheet->data); | 152 | sheet->setSheetData(&newSheet->data); |
157 | } | 153 | } |
158 | } | 154 | } |
159 | } | 155 | } |
160 | 156 | ||
161 | int MainWindow::saveCurrentFile(bool ask) | 157 | int MainWindow::saveCurrentFile(bool ask) |
162 | { | 158 | { |
163 | if (ask) | 159 | if (ask) |
164 | { | 160 | { |
165 | int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); | 161 | int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); |
166 | if (result!=QMessageBox::Yes) return result; | 162 | if (result!=QMessageBox::Yes) return result; |
167 | } | 163 | } |
168 | 164 | ||
169 | if (!currentDoc->isValid()) | 165 | if (!currentDoc->isValid()) |
170 | { | 166 | { |
171 | TextDialog dialogText(this); | 167 | TextDialog dialogText(this); |
172 | if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; | 168 | if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; |
173 | 169 | ||
174 | currentDoc->setName(dialogText.getValue()); | 170 | currentDoc->setName(dialogText.getValue()); |
175 | currentDoc->setFile(QString::null); | 171 | currentDoc->setFile(QString::null); |
176 | currentDoc->setLinkFile(QString::null); | 172 | currentDoc->setLinkFile(QString::null); |
177 | } | 173 | } |
178 | 174 | ||
179 | documentSave(currentDoc); | 175 | documentSave(currentDoc); |
180 | return QMessageBox::Yes; | 176 | return QMessageBox::Yes; |
181 | } | 177 | } |
182 | 178 | ||
183 | void MainWindow::selectorFileNew(const DocLnk &lnkDoc) | 179 | void MainWindow::selectorFileNew(const DocLnk &lnkDoc) |
184 | { | 180 | { |
185 | selectorHide(); | 181 | selectorHide(); |
186 | 182 | ||
187 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 183 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
188 | if (currentDoc) delete currentDoc; | 184 | if (currentDoc) delete currentDoc; |
189 | currentDoc = new DocLnk(lnkDoc); | 185 | currentDoc = new DocLnk(lnkDoc); |
190 | editData->clear(); | 186 | editData->clear(); |
191 | listSheets.clear(); | 187 | listSheets.clear(); |
192 | comboSheets->clear(); | 188 | comboSheets->clear(); |
193 | 189 | ||
194 | typeSheet *newSheet=createNewSheet(); | 190 | typeSheet *newSheet=createNewSheet(); |
195 | newSheet->data.setAutoDelete(TRUE); | 191 | newSheet->data.setAutoDelete(TRUE); |
196 | sheet->setName(newSheet->name); | 192 | sheet->setName(newSheet->name); |
197 | sheet->setSheetData(&newSheet->data); | 193 | sheet->setSheetData(&newSheet->data); |
198 | for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) | 194 | for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) |
199 | createNewSheet(); | 195 | createNewSheet(); |
200 | documentModified=FALSE; | 196 | documentModified=FALSE; |
201 | } | 197 | } |
202 | 198 | ||
203 | void MainWindow::closeEvent(QCloseEvent *e) | 199 | void MainWindow::closeEvent(QCloseEvent *e) |
204 | { | 200 | { |
205 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); | 201 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); |
206 | else e->accept(); | 202 | else e->accept(); |
207 | } | 203 | } |
208 | 204 | ||
209 | void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) | 205 | void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) |
210 | { | 206 | { |
211 | selectorHide(); | 207 | selectorHide(); |
212 | 208 | ||
213 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 209 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
214 | if (currentDoc) delete currentDoc; | 210 | if (currentDoc) delete currentDoc; |
215 | currentDoc = new DocLnk(); | 211 | currentDoc = new DocLnk(); |
216 | listSheets.clear(); | 212 | listSheets.clear(); |
217 | comboSheets->clear(); | 213 | comboSheets->clear(); |
218 | 214 | ||
219 | documentOpen(lnkDoc); | 215 | documentOpen(lnkDoc); |
220 | documentModified=FALSE; | 216 | documentModified=FALSE; |
221 | } | 217 | } |
222 | 218 | ||
223 | void MainWindow::selectorShow() | 219 | void MainWindow::selectorShow() |
224 | { | 220 | { |
225 | sheet->hide(); | 221 | sheet->hide(); |
226 | setCentralWidget(fileSelector); | 222 | setCentralWidget(fileSelector); |
227 | fileSelector->show(); | 223 | fileSelector->show(); |
228 | fileSelector->reread(); | 224 | fileSelector->reread(); |
229 | } | 225 | } |
230 | 226 | ||
231 | void MainWindow::selectorHide() | 227 | void MainWindow::selectorHide() |
232 | { | 228 | { |
233 | fileSelector->hide(); | 229 | fileSelector->hide(); |
234 | setCentralWidget(sheet); | 230 | setCentralWidget(sheet); |
235 | sheet->show(); | 231 | sheet->show(); |
236 | } | 232 | } |
237 | 233 | ||
238 | void MainWindow::slotFileNew() | 234 | void MainWindow::slotFileNew() |
239 | { | 235 | { |
240 | selectorFileNew(DocLnk()); | 236 | selectorFileNew(DocLnk()); |
241 | } | 237 | } |
242 | 238 | ||
243 | void MainWindow::slotFileOpen() | 239 | void MainWindow::slotFileOpen() |
244 | { | 240 | { |
245 | selectorShow(); | 241 | selectorShow(); |
246 | } | 242 | } |
247 | 243 | ||
248 | void MainWindow::slotImportExcelOpen() | 244 | void MainWindow::slotImportExcelOpen() |
249 | { | 245 | { |
250 | sheet->hide(); | 246 | sheet->hide(); |
251 | setCentralWidget(ExcelSelector); | 247 | setCentralWidget(ExcelSelector); |
252 | ExcelSelector->show(); | 248 | ExcelSelector->show(); |
253 | ExcelSelector->reread(); | 249 | ExcelSelector->reread(); |
254 | } | 250 | } |
255 | 251 | ||
256 | void MainWindow::ExcelSelectorHide() | 252 | void MainWindow::ExcelSelectorHide() |
257 | { | 253 | { |
258 | ExcelSelector->hide(); | 254 | ExcelSelector->hide(); |
259 | setCentralWidget(sheet); | 255 | setCentralWidget(sheet); |
260 | sheet->show(); | 256 | sheet->show(); |
261 | } | 257 | } |
262 | 258 | ||
263 | void MainWindow::slotFileSave() | 259 | void MainWindow::slotFileSave() |
264 | { | 260 | { |
265 | saveCurrentFile(FALSE); | 261 | saveCurrentFile(FALSE); |
266 | } | 262 | } |
267 | 263 | ||
268 | void MainWindow::setDocument(const QString &applnk_filename) | 264 | void MainWindow::setDocument(const QString &applnk_filename) |
269 | { | 265 | { |
270 | selectorFileOpen(DocLnk(applnk_filename)); | 266 | selectorFileOpen(DocLnk(applnk_filename)); |
271 | } | 267 | } |
272 | 268 | ||
273 | void MainWindow::initActions() | 269 | void MainWindow::initActions() |
274 | { | 270 | { |
275 | fileNew=new QAction(tr("New File"), Resource::loadPixmap( "new" ), tr("&New"), 0, this); | 271 | fileNew=new QAction(tr("New File"), Resource::loadPixmap( "new" ), tr("&New"), 0, this); |
276 | connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew())); | 272 | connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew())); |
277 | fileOpen=new QAction(tr("Open File"), Resource::loadPixmap( "fileopen" ), tr("&Open"), 0, this); | 273 | fileOpen=new QAction(tr("Open File"), Resource::loadPixmap( "fileopen" ), tr("&Open"), 0, this); |
278 | connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); | 274 | connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); |
279 | fileSave=new QAction(tr("Save File"),Resource::loadPixmap( "save" ), tr("&Save"), 0, this); | 275 | fileSave=new QAction(tr("Save File"),Resource::loadPixmap( "save" ), tr("&Save"), 0, this); |
280 | connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); | 276 | connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); |
281 | fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this); | 277 | fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this); |
282 | connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); | 278 | connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); |
283 | 279 | ||
284 | //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); | 280 | //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); |
285 | //connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); | 281 | //connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); |
286 | fileExcelImport=new QAction(tr("Import Excel file"),Resource::loadPixmap( "opie-sheet/excel16" ),tr("Import E&xcel file"),0,this); | 282 | fileExcelImport=new QAction(tr("Import Excel file"),Resource::loadPixmap( "opie-sheet/excel16" ),tr("Import E&xcel file"),0,this); |
287 | connect(fileExcelImport, SIGNAL(activated()), this, SLOT(slotImportExcelOpen())); | 283 | connect(fileExcelImport, SIGNAL(activated()), this, SLOT(slotImportExcelOpen())); |
288 | 284 | ||
289 | // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); | 285 | // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); |
290 | //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); | 286 | //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); |
291 | //helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this); | 287 | //helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this); |
292 | //connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout())); | 288 | //connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout())); |
293 | 289 | ||
294 | editAccept=new QAction(tr("Accept"),Resource::loadPixmap( "enter" ) , tr("&Accept"), 0, this); | 290 | editAccept=new QAction(tr("Accept"),Resource::loadPixmap( "enter" ) , tr("&Accept"), 0, this); |
295 | connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept())); | 291 | connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept())); |
296 | editCancel=new QAction(tr("Cancel"), Resource::loadPixmap( "close" ), tr("&Cancel"), 0, this); | 292 | editCancel=new QAction(tr("Cancel"), Resource::loadPixmap( "close" ), tr("&Cancel"), 0, this); |
297 | connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel())); | 293 | connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel())); |
298 | editCellSelect=new QAction(tr("Cell Selector"), Resource::loadPixmap( "opie-sheet/cell-select" ), tr("Cell &Selector"), 0, this); | 294 | editCellSelect=new QAction(tr("Cell Selector"), Resource::loadPixmap( "opie-sheet/cell-select" ), tr("Cell &Selector"), 0, this); |
299 | editCellSelect->setToggleAction(TRUE); | 295 | editCellSelect->setToggleAction(TRUE); |
300 | connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool))); | 296 | connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool))); |
301 | editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this); | 297 | editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this); |
302 | editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this); | 298 | editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this); |
303 | editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this); | 299 | editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this); |
304 | connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); | 300 | connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); |
305 | editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this); | 301 | editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this); |
306 | connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents())); | 302 | connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents())); |
307 | editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this); | 303 | editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this); |
308 | 304 | ||
309 | insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this); | 305 | insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this); |
310 | connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells())); | 306 | connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells())); |
311 | insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this); | 307 | insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this); |
312 | connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows())); | 308 | connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows())); |
313 | insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this); | 309 | insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this); |
314 | connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols())); | 310 | connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols())); |
315 | insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this); | 311 | insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this); |
316 | connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets())); | 312 | connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets())); |
317 | 313 | ||
318 | formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this); | 314 | formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this); |
319 | connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells())); | 315 | connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells())); |
320 | 316 | ||
321 | rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this); | 317 | rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this); |
322 | connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight())); | 318 | connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight())); |
323 | rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this); | 319 | rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this); |
324 | connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust())); | 320 | connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust())); |
325 | rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this); | 321 | rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this); |
326 | connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow())); | 322 | connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow())); |
327 | rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this); | 323 | rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this); |
328 | connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide())); | 324 | connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide())); |
329 | 325 | ||
330 | colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this); | 326 | colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this); |
331 | connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth())); | 327 | connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth())); |
332 | colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this); | 328 | colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this); |
333 | connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust())); | 329 | connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust())); |
334 | colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this); | 330 | colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this); |
335 | connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow())); | 331 | connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow())); |
336 | colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this); | 332 | colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this); |
337 | connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide())); | 333 | connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide())); |
338 | 334 | ||
339 | sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this); | 335 | sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this); |
340 | connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename())); | 336 | connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename())); |
341 | sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this); | 337 | sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this); |
342 | connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove())); | 338 | connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove())); |
343 | 339 | ||
344 | dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this); | 340 | dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this); |
345 | connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort())); | 341 | connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort())); |
346 | dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this); | 342 | dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this); |
347 | connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace())); | 343 | connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace())); |
348 | 344 | ||
349 | funcEqual=new QAction(tr("Equal To"), Resource::loadPixmap( "opie-sheet/func-equal" ), tr("&Equal To"), 0, this); | 345 | funcEqual=new QAction(tr("Equal To"), Resource::loadPixmap( "opie-sheet/func-equal" ), tr("&Equal To"), 0, this); |
350 | funcEqual->setToolTip("="); | 346 | funcEqual->setToolTip("="); |
351 | connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 347 | connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
352 | funcPlus=new QAction(tr("Addition"), Resource::loadPixmap( "opie-sheet/func-plus" ), tr("&Addition"), 0, this); | 348 | funcPlus=new QAction(tr("Addition"), Resource::loadPixmap( "opie-sheet/func-plus" ), tr("&Addition"), 0, this); |
353 | funcPlus->setToolTip("+"); | 349 | funcPlus->setToolTip("+"); |
354 | connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 350 | connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
355 | funcMinus=new QAction(tr("Subtraction"), Resource::loadPixmap( "opie-sheet/func-minus" ), tr("&Subtraction"), 0, this); | 351 | funcMinus=new QAction(tr("Subtraction"), Resource::loadPixmap( "opie-sheet/func-minus" ), tr("&Subtraction"), 0, this); |
356 | funcMinus->setToolTip("-"); | 352 | funcMinus->setToolTip("-"); |
357 | connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 353 | connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
358 | funcCross=new QAction(tr("Multiplication"), Resource::loadPixmap ("opie-sheet/func-cross" ), tr("&Multiplication"), 0, this); | 354 | funcCross=new QAction(tr("Multiplication"), Resource::loadPixmap ("opie-sheet/func-cross" ), tr("&Multiplication"), 0, this); |
359 | funcCross->setToolTip("*"); | 355 | funcCross->setToolTip("*"); |
360 | connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 356 | connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
361 | funcDivide=new QAction(tr("Division"), Resource::loadPixmap( "opie-sheet/func-divide" ), tr("&Division"), 0, this); | 357 | funcDivide=new QAction(tr("Division"), Resource::loadPixmap( "opie-sheet/func-divide" ), tr("&Division"), 0, this); |
362 | funcDivide->setToolTip("/"); | 358 | funcDivide->setToolTip("/"); |
363 | connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 359 | connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
364 | funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), Resource::loadPixmap( "opie-sheet/func-paran-open" ), tr("&Open Paranthesis"), 0, this); | 360 | funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), Resource::loadPixmap( "opie-sheet/func-paran-open" ), tr("&Open Paranthesis"), 0, this); |
365 | funcParanOpen->setToolTip("("); | 361 | funcParanOpen->setToolTip("("); |
366 | connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 362 | connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
367 | funcParanClose=new QAction(tr("Close Paranthesis"), Resource::loadPixmap( "opie-sheet/func-paran-close" ), tr("&Close Paranthesis"), 0, this); | 363 | funcParanClose=new QAction(tr("Close Paranthesis"), Resource::loadPixmap( "opie-sheet/func-paran-close" ), tr("&Close Paranthesis"), 0, this); |
368 | funcParanClose->setToolTip(")"); | 364 | funcParanClose->setToolTip(")"); |
369 | connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 365 | connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
370 | funcComma=new QAction(tr("Comma"), Resource::loadPixmap( "opie-sheet/func-comma" ), tr("&Comma"), 0, this); | 366 | funcComma=new QAction(tr("Comma"), Resource::loadPixmap( "opie-sheet/func-comma" ), tr("&Comma"), 0, this); |
371 | funcComma->setToolTip(","); | 367 | funcComma->setToolTip(","); |
372 | connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 368 | connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
373 | } | 369 | } |
374 | 370 | ||
375 | void MainWindow::initMenu() | 371 | void MainWindow::initMenu() |
376 | { | 372 | { |
377 | menu=new QMenuBar(this); | 373 | menu=new QMenuBar(this); |
378 | 374 | ||
379 | menuFile=new QPopupMenu; | 375 | menuFile=new QPopupMenu; |
380 | fileNew->addTo(menuFile); | 376 | fileNew->addTo(menuFile); |
381 | fileOpen->addTo(menuFile); | 377 | fileOpen->addTo(menuFile); |
382 | fileSave->addTo(menuFile); | 378 | fileSave->addTo(menuFile); |
383 | fileSaveAs->addTo(menuFile); | 379 | fileSaveAs->addTo(menuFile); |
384 | // menuFile->insertSeparator(); | 380 | // menuFile->insertSeparator(); |
385 | // fileQuit->addTo(menuFile); | 381 | // fileQuit->addTo(menuFile); |
386 | menuFile->insertSeparator(); | 382 | menuFile->insertSeparator(); |
387 | fileExcelImport->addTo(menuFile); | 383 | fileExcelImport->addTo(menuFile); |
388 | menu->insertItem(tr("&File"), menuFile); | 384 | menu->insertItem(tr("&File"), menuFile); |
389 | 385 | ||
390 | menuEdit=new QPopupMenu; | 386 | menuEdit=new QPopupMenu; |
391 | editAccept->addTo(menuEdit); | 387 | editAccept->addTo(menuEdit); |
392 | editCancel->addTo(menuEdit); | 388 | editCancel->addTo(menuEdit); |
393 | editCellSelect->addTo(menuEdit); | 389 | editCellSelect->addTo(menuEdit); |
394 | menuEdit->insertSeparator(); | 390 | menuEdit->insertSeparator(); |
395 | editCut->addTo(menuEdit); | 391 | editCut->addTo(menuEdit); |
396 | editCopy->addTo(menuEdit); | 392 | editCopy->addTo(menuEdit); |
397 | editPaste->addTo(menuEdit); | 393 | editPaste->addTo(menuEdit); |
398 | editPasteContents->addTo(menuEdit); | 394 | editPasteContents->addTo(menuEdit); |
399 | editClear->addTo(menuEdit); | 395 | editClear->addTo(menuEdit); |
400 | menu->insertItem(tr("&Edit"), menuEdit); | 396 | menu->insertItem(tr("&Edit"), menuEdit); |
401 | 397 | ||
402 | menuInsert=new QPopupMenu; | 398 | menuInsert=new QPopupMenu; |
403 | menu->insertItem(tr("&Insert"), menuInsert); | 399 | menu->insertItem(tr("&Insert"), menuInsert); |
404 | 400 | ||
405 | menuFormat=new QPopupMenu; | 401 | menuFormat=new QPopupMenu; |
406 | formatCells->addTo(menuFormat); | 402 | formatCells->addTo(menuFormat); |
407 | menu->insertItem(tr("&Format"), menuFormat); | 403 | menu->insertItem(tr("&Format"), menuFormat); |
408 | 404 | ||
409 | menuData=new QPopupMenu; | 405 | menuData=new QPopupMenu; |
410 | dataSort->addTo(menuData); | 406 | dataSort->addTo(menuData); |
411 | dataFindReplace->addTo(menuData); | 407 | dataFindReplace->addTo(menuData); |
412 | menu->insertItem(tr("&Data"), menuData); | 408 | menu->insertItem(tr("&Data"), menuData); |
413 | 409 | ||
414 | // menuHelp=new QPopupMenu; | 410 | // menuHelp=new QPopupMenu; |
415 | // helpGeneral->addTo(menuHelp); | 411 | // helpGeneral->addTo(menuHelp); |
416 | // helpAbout->addTo(menuHelp); | 412 | // helpAbout->addTo(menuHelp); |
417 | // menu->insertItem(tr("&Help"), menuHelp); | 413 | // menu->insertItem(tr("&Help"), menuHelp); |
418 | 414 | ||
419 | submenuRow=new QPopupMenu; | 415 | submenuRow=new QPopupMenu; |
420 | rowHeight->addTo(submenuRow); | 416 | rowHeight->addTo(submenuRow); |
421 | rowAdjust->addTo(submenuRow); | 417 | rowAdjust->addTo(submenuRow); |
422 | rowShow->addTo(submenuRow); | 418 | rowShow->addTo(submenuRow); |
423 | rowHide->addTo(submenuRow); | 419 | rowHide->addTo(submenuRow); |
424 | menuFormat->insertItem(tr("&Row"), submenuRow); | 420 | menuFormat->insertItem(tr("&Row"), submenuRow); |
425 | 421 | ||
426 | submenuCol=new QPopupMenu; | 422 | submenuCol=new QPopupMenu; |
427 | colWidth->addTo(submenuCol); | 423 | colWidth->addTo(submenuCol); |
428 | colAdjust->addTo(submenuCol); | 424 | colAdjust->addTo(submenuCol); |
429 | colShow->addTo(submenuCol); | 425 | colShow->addTo(submenuCol); |
430 | colHide->addTo(submenuCol); | 426 | colHide->addTo(submenuCol); |
431 | menuFormat->insertItem(tr("Colum&n"), submenuCol); | 427 | menuFormat->insertItem(tr("Colum&n"), submenuCol); |
432 | 428 | ||
433 | submenuSheet=new QPopupMenu; | 429 | submenuSheet=new QPopupMenu; |
434 | sheetRename->addTo(submenuSheet); | 430 | sheetRename->addTo(submenuSheet); |
435 | sheetRemove->addTo(submenuSheet); | 431 | sheetRemove->addTo(submenuSheet); |
436 | menuFormat->insertItem(tr("&Sheet"), submenuSheet); | 432 | menuFormat->insertItem(tr("&Sheet"), submenuSheet); |
437 | 433 | ||
438 | submenuFunc=new QPopupMenu; | 434 | submenuFunc=new QPopupMenu; |
439 | menuInsert->insertItem(tr("&Function"), submenuFunc); | 435 | menuInsert->insertItem(tr("&Function"), submenuFunc); |
440 | 436 | ||
441 | submenuFuncStd=new QPopupMenu; | 437 | submenuFuncStd=new QPopupMenu; |
442 | funcPlus->addTo(submenuFuncStd); | 438 | funcPlus->addTo(submenuFuncStd); |
443 | funcMinus->addTo(submenuFuncStd); | 439 | funcMinus->addTo(submenuFuncStd); |
444 | funcCross->addTo(submenuFuncStd); | 440 | funcCross->addTo(submenuFuncStd); |
445 | funcDivide->addTo(submenuFuncStd); | 441 | funcDivide->addTo(submenuFuncStd); |
446 | submenuFunc->insertItem(tr("&Simple"), submenuFuncStd); | 442 | submenuFunc->insertItem(tr("&Simple"), submenuFuncStd); |
447 | 443 | ||
448 | 444 | ||
449 | 445 | ||
450 | submenuFuncStandard=new QPopupMenu; | 446 | submenuFuncStandard=new QPopupMenu; |
451 | addFlyAction(tr("ABS(x)"), tr("ABS(x)"), "ABS(", submenuFuncStandard); | 447 | addFlyAction(tr("ABS(x)"), tr("ABS(x)"), "ABS(", submenuFuncStandard); |
452 | addFlyAction(tr("CEILING(x,acc)"), tr("CEILING(x,acc)"), "CEILING(", submenuFuncStandard); | 448 | addFlyAction(tr("CEILING(x,acc)"), tr("CEILING(x,acc)"), "CEILING(", submenuFuncStandard); |
453 | addFlyAction(tr("FACT(x)"), tr("FACT(x)"), "FACT(", submenuFuncStandard); | 449 | addFlyAction(tr("FACT(x)"), tr("FACT(x)"), "FACT(", submenuFuncStandard); |
454 | addFlyAction(tr("FLOOR(x,acc)"), tr("FLOOR(x,acc)"), "FLOOR(", submenuFuncStandard); | 450 | addFlyAction(tr("FLOOR(x,acc)"), tr("FLOOR(x,acc)"), "FLOOR(", submenuFuncStandard); |
455 | addFlyAction(tr("INT(x)"), tr("INT(x)"), "INT(", submenuFuncStandard); | 451 | addFlyAction(tr("INT(x)"), tr("INT(x)"), "INT(", submenuFuncStandard); |
456 | addFlyAction(tr("MOD(x,y)"), tr("MOD(x,y)"), "MOD(", submenuFuncStandard); | 452 | addFlyAction(tr("MOD(x,y)"), tr("MOD(x,y)"), "MOD(", submenuFuncStandard); |
457 | addFlyAction(tr("ROUND(x,digits)"), tr("ROUND(x,digits)"), "ROUND(", submenuFuncStandard); | 453 | addFlyAction(tr("ROUND(x,digits)"), tr("ROUND(x,digits)"), "ROUND(", submenuFuncStandard); |
458 | addFlyAction(tr("SIGN(x)"), tr("SIGN(x)"), "SIGN(", submenuFuncStandard); | 454 | addFlyAction(tr("SIGN(x)"), tr("SIGN(x)"), "SIGN(", submenuFuncStandard); |
459 | submenuFuncStandard->insertSeparator(); | 455 | submenuFuncStandard->insertSeparator(); |
460 | addFlyAction(tr("EXP(x)"), tr("EXP(x)"), "EXP(", submenuFuncStandard); | 456 | addFlyAction(tr("EXP(x)"), tr("EXP(x)"), "EXP(", submenuFuncStandard); |
461 | addFlyAction(tr("LN(x)"), tr("LN(x)"), "LN(", submenuFuncStandard); | 457 | addFlyAction(tr("LN(x)"), tr("LN(x)"), "LN(", submenuFuncStandard); |
462 | addFlyAction(tr("LOG(x,b)"), tr("LOG(x,b)"), "LOG(", submenuFuncStandard); | 458 | addFlyAction(tr("LOG(x,b)"), tr("LOG(x,b)"), "LOG(", submenuFuncStandard); |
463 | addFlyAction(tr("LOG10(x)"), tr("LOG10(x)"), "LOG10(", submenuFuncStandard); | 459 | addFlyAction(tr("LOG10(x)"), tr("LOG10(x)"), "LOG10(", submenuFuncStandard); |
464 | addFlyAction(tr("POWER(x,y)"), tr("POWER(x,y)"), "POWER(", submenuFuncStandard); | 460 | addFlyAction(tr("POWER(x,y)"), tr("POWER(x,y)"), "POWER(", submenuFuncStandard); |
465 | addFlyAction(tr("SQRT(x)"), tr("SQRT(x)"), "SQRT(", submenuFuncStandard); | 461 | addFlyAction(tr("SQRT(x)"), tr("SQRT(x)"), "SQRT(", submenuFuncStandard); |
466 | submenuFuncStandard->insertSeparator(); | 462 | submenuFuncStandard->insertSeparator(); |
467 | addFlyAction(tr("DEGREES(x)"), tr("DEGREES(x)"), "DEGREES(", submenuFuncStandard); | 463 | addFlyAction(tr("DEGREES(x)"), tr("DEGREES(x)"), "DEGREES(", submenuFuncStandard); |
468 | addFlyAction(tr("RADIANS(x)"), tr("RADIANS(x)"), "RADIANS(", submenuFuncStandard); | 464 | addFlyAction(tr("RADIANS(x)"), tr("RADIANS(x)"), "RADIANS(", submenuFuncStandard); |
469 | addFlyAction(tr("PI()"), tr("PI()"), "PI()", submenuFuncStandard); | 465 | addFlyAction(tr("PI()"), tr("PI()"), "PI()", submenuFuncStandard); |
470 | addFlyAction(tr("RAND()"), tr("RAND()"), "RAND(", submenuFuncStandard); | 466 | addFlyAction(tr("RAND()"), tr("RAND()"), "RAND(", submenuFuncStandard); |
471 | addFlyAction(tr("RANDBETWEEN(a,b)"), tr("RANDBETWEEN(a,b)"), "RANDBETWEEN(", submenuFuncStandard); | 467 | addFlyAction(tr("RANDBETWEEN(a,b)"), tr("RANDBETWEEN(a,b)"), "RANDBETWEEN(", submenuFuncStandard); |
472 | submenuFunc->insertItem(tr("S&tandard"), submenuFuncStandard); | 468 | submenuFunc->insertItem(tr("S&tandard"), submenuFuncStandard); |
473 | 469 | ||
474 | submenuFuncLogic=new QPopupMenu; | 470 | submenuFuncLogic=new QPopupMenu; |
475 | addFlyAction(tr("AND(x1,x2)"), tr("AND(x1,x2)"), "AND(", submenuFuncLogic); | 471 | addFlyAction(tr("AND(x1,x2)"), tr("AND(x1,x2)"), "AND(", submenuFuncLogic); |
476 | addFlyAction(tr("NOT(x)"), tr("NOT(x)"), "NOT(", submenuFuncLogic); | 472 | addFlyAction(tr("NOT(x)"), tr("NOT(x)"), "NOT(", submenuFuncLogic); |
477 | addFlyAction(tr("OR(x1,x2)"), tr("OR(x1,x2)"), "OR(", submenuFuncLogic); | 473 | addFlyAction(tr("OR(x1,x2)"), tr("OR(x1,x2)"), "OR(", submenuFuncLogic); |
478 | submenuFuncLogic->insertSeparator(); | 474 | submenuFuncLogic->insertSeparator(); |
479 | addFlyAction(tr("IF(compare,val1,val2)"), tr("IF(compare,val1,val2)"), "IF(", submenuFuncLogic); | 475 | addFlyAction(tr("IF(compare,val1,val2)"), tr("IF(compare,val1,val2)"), "IF(", submenuFuncLogic); |
480 | addFlyAction(tr("INDEX(range,index)"),tr("INDEX(range,index)"), "INDEX(", submenuFuncLogic); | 476 | addFlyAction(tr("INDEX(range,index)"),tr("INDEX(range,index)"), "INDEX(", submenuFuncLogic); |
481 | addFlyAction(tr("ISBLANK(x)"), tr("ISBLANK(x)"), "ISBLANK(", submenuFuncLogic); | 477 | addFlyAction(tr("ISBLANK(x)"), tr("ISBLANK(x)"), "ISBLANK(", submenuFuncLogic); |
482 | addFlyAction(tr("ISNUMBER(x)"), tr("ISNUMBER(x)"), "ISNUMBER(", submenuFuncLogic); | 478 | addFlyAction(tr("ISNUMBER(x)"), tr("ISNUMBER(x)"), "ISNUMBER(", submenuFuncLogic); |
483 | addFlyAction(tr("EVEN(x)"), tr("EVEN(x)"), "EVEN(", submenuFuncLogic); | 479 | addFlyAction(tr("EVEN(x)"), tr("EVEN(x)"), "EVEN(", submenuFuncLogic); |
484 | addFlyAction(tr("ISEVEN(x)"), tr("ISEVEN(x)"), "ISEVEN(", submenuFuncLogic); | 480 | addFlyAction(tr("ISEVEN(x)"), tr("ISEVEN(x)"), "ISEVEN(", submenuFuncLogic); |
485 | addFlyAction(tr("ODD(x)"), tr("ODD(x)"), "ODD(", submenuFuncLogic); | 481 | addFlyAction(tr("ODD(x)"), tr("ODD(x)"), "ODD(", submenuFuncLogic); |
486 | addFlyAction(tr("ISODD(x)"), tr("ISODD(x)"), "ISODD(", submenuFuncLogic); | 482 | addFlyAction(tr("ISODD(x)"), tr("ISODD(x)"), "ISODD(", submenuFuncLogic); |
487 | submenuFunc->insertItem(tr("Logical-&Information"), submenuFuncLogic); | 483 | submenuFunc->insertItem(tr("Logical-&Information"), submenuFuncLogic); |
488 | 484 | ||
489 | submenuFuncTrig=new QPopupMenu; | 485 | submenuFuncTrig=new QPopupMenu; |
490 | addFlyAction(tr("SIN(x)"), tr("SIN(x)"), "SIN(", submenuFuncTrig); | 486 | addFlyAction(tr("SIN(x)"), tr("SIN(x)"), "SIN(", submenuFuncTrig); |
491 | addFlyAction(tr("COS(x)"), tr("COS(x)"), "COS(", submenuFuncTrig); | 487 | addFlyAction(tr("COS(x)"), tr("COS(x)"), "COS(", submenuFuncTrig); |
492 | addFlyAction(tr("TAN(x)"), tr("TAN(x)"), "TAN(", submenuFuncTrig); | 488 | addFlyAction(tr("TAN(x)"), tr("TAN(x)"), "TAN(", submenuFuncTrig); |
493 | addFlyAction(tr("ASIN(x)"), tr("ASIN(x)"), "ASIN(", submenuFuncTrig); | 489 | addFlyAction(tr("ASIN(x)"), tr("ASIN(x)"), "ASIN(", submenuFuncTrig); |
494 | addFlyAction(tr("ACOS(x)"), tr("ACOS(x)"), "ACOS(", submenuFuncTrig); | 490 | addFlyAction(tr("ACOS(x)"), tr("ACOS(x)"), "ACOS(", submenuFuncTrig); |
495 | addFlyAction(tr("ATAN(x)"), tr("ATAN(x)"), "ATAN(", submenuFuncTrig); | 491 | addFlyAction(tr("ATAN(x)"), tr("ATAN(x)"), "ATAN(", submenuFuncTrig); |
496 | addFlyAction(tr("ATAN2(x,y)"), tr("ATAN2(x,y)"), "ATAN2(", submenuFuncTrig); | 492 | addFlyAction(tr("ATAN2(x,y)"), tr("ATAN2(x,y)"), "ATAN2(", submenuFuncTrig); |
497 | submenuFuncTrig->insertSeparator(); | 493 | submenuFuncTrig->insertSeparator(); |
498 | addFlyAction(tr("SINH(x)"), tr("SINH(x)"), "SINH(", submenuFuncTrig); | 494 | addFlyAction(tr("SINH(x)"), tr("SINH(x)"), "SINH(", submenuFuncTrig); |
499 | addFlyAction(tr("COSH(x)"), tr("COSH(x)"), "COSH(", submenuFuncTrig); | 495 | addFlyAction(tr("COSH(x)"), tr("COSH(x)"), "COSH(", submenuFuncTrig); |
500 | addFlyAction(tr("TANH(x)"), tr("TANH(x)"), "TANH(", submenuFuncTrig); | 496 | addFlyAction(tr("TANH(x)"), tr("TANH(x)"), "TANH(", submenuFuncTrig); |
501 | addFlyAction(tr("ACOSH(x)"), tr("ACOSH(x)"), "ACOSH(", submenuFuncTrig); | 497 | addFlyAction(tr("ACOSH(x)"), tr("ACOSH(x)"), "ACOSH(", submenuFuncTrig); |
502 | addFlyAction(tr("ASINH(x)"), tr("ASINH(x)"), "ASINH(", submenuFuncTrig); | 498 | addFlyAction(tr("ASINH(x)"), tr("ASINH(x)"), "ASINH(", submenuFuncTrig); |
503 | addFlyAction(tr("ATANH(x)"), tr("ATANH(x)"), "ATANH(", submenuFuncTrig); | 499 | addFlyAction(tr("ATANH(x)"), tr("ATANH(x)"), "ATANH(", submenuFuncTrig); |
504 | submenuFunc->insertItem(tr("&Trigonometric"), submenuFuncTrig); | 500 | submenuFunc->insertItem(tr("&Trigonometric"), submenuFuncTrig); |
505 | 501 | ||
506 | submenuFuncString=new QPopupMenu; | 502 | submenuFuncString=new QPopupMenu; |
507 | addFlyAction(tr("LEN(s)"), tr("LEN(s)"), "LEN(",submenuFuncString); | 503 | addFlyAction(tr("LEN(s)"), tr("LEN(s)"), "LEN(",submenuFuncString); |
508 | addFlyAction(tr("LEFT(s,num)"), tr("LEFT(s,num)"), "LEFT(",submenuFuncString); | 504 | addFlyAction(tr("LEFT(s,num)"), tr("LEFT(s,num)"), "LEFT(",submenuFuncString); |
509 | addFlyAction(tr("RIGHT(s,num)"), tr("RIGHT(s,num)"), "RIGHT(",submenuFuncString); | 505 | addFlyAction(tr("RIGHT(s,num)"), tr("RIGHT(s,num)"), "RIGHT(",submenuFuncString); |
510 | addFlyAction(tr("MID(s,pos,len)"), tr("MID(s,pos,len)"), "MID(",submenuFuncString); | 506 | addFlyAction(tr("MID(s,pos,len)"), tr("MID(s,pos,len)"), "MID(",submenuFuncString); |
511 | submenuFuncString->insertSeparator(); | 507 | submenuFuncString->insertSeparator(); |
512 | addFlyAction(tr("CONCATENATE(s1,s2..)"), tr("CONCATENATE(s1,s2..)"), "CONCATENATE(",submenuFuncString); | 508 | addFlyAction(tr("CONCATENATE(s1,s2..)"), tr("CONCATENATE(s1,s2..)"), "CONCATENATE(",submenuFuncString); |
513 | addFlyAction(tr("EXACT(s1,s2)"), tr("EXACT(s1,s2)"), "EXACT(",submenuFuncString); | 509 | addFlyAction(tr("EXACT(s1,s2)"), tr("EXACT(s1,s2)"), "EXACT(",submenuFuncString); |
514 | addFlyAction(tr("FIND(what,where,pos)"), | 510 | addFlyAction(tr("FIND(what,where,pos)"), |
515 | tr("FIND(what,where,pos)"), "FIND(",submenuFuncString); | 511 | tr("FIND(what,where,pos)"), "FIND(",submenuFuncString); |
516 | addFlyAction(tr("REPLACE(s,pos,len,ns)"), tr("REPLACE(s,pos,len,ns)"), "REPLACE(",submenuFuncString); | 512 | addFlyAction(tr("REPLACE(s,pos,len,ns)"), tr("REPLACE(s,pos,len,ns)"), "REPLACE(",submenuFuncString); |
517 | addFlyAction(tr("REPT(s,n)"), tr("REPT(s,n)"), "REPT(",submenuFuncString); | 513 | addFlyAction(tr("REPT(s,n)"), tr("REPT(s,n)"), "REPT(",submenuFuncString); |
518 | submenuFuncString->insertSeparator(); | 514 | submenuFuncString->insertSeparator(); |
519 | addFlyAction(tr("UPPER(s)"), tr("UPPER(s)"), "UPPER(",submenuFuncString); | 515 | addFlyAction(tr("UPPER(s)"), tr("UPPER(s)"), "UPPER(",submenuFuncString); |
520 | addFlyAction(tr("LOWER(s)"), tr("LOWER(s)"), "LOWER(",submenuFuncString); | 516 | addFlyAction(tr("LOWER(s)"), tr("LOWER(s)"), "LOWER(",submenuFuncString); |
521 | submenuFunc->insertItem(tr("&Strings"), submenuFuncString); | 517 | submenuFunc->insertItem(tr("&Strings"), submenuFuncString); |
522 | 518 | ||
523 | submenuFuncStat=new QPopupMenu; | 519 | submenuFuncStat=new QPopupMenu; |
524 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); | 520 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); |
525 | addFlyAction(tr("COUNT(range)"), tr("COUNT(range)"), "COUNT(",submenuFuncStat); | 521 | addFlyAction(tr("COUNT(range)"), tr("COUNT(range)"), "COUNT(",submenuFuncStat); |
526 | addFlyAction(tr("COUNTIF(range,eqls)"), tr("COUNTIF(range,eqls)"), "COUNTIF(",submenuFuncStat); | 522 | addFlyAction(tr("COUNTIF(range,eqls)"), tr("COUNTIF(range,eqls)"), "COUNTIF(",submenuFuncStat); |
527 | addFlyAction(tr("MAX(range)"), tr("MAX(range)"), "MAX(",submenuFuncStat); | 523 | addFlyAction(tr("MAX(range)"), tr("MAX(range)"), "MAX(",submenuFuncStat); |
528 | addFlyAction(tr("MIN(range)"), tr("MIN(range)"), "MIN(",submenuFuncStat); | 524 | addFlyAction(tr("MIN(range)"), tr("MIN(range)"), "MIN(",submenuFuncStat); |
529 | addFlyAction(tr("SUM(range)"), tr("SUM(range)"), "SUM(",submenuFuncStat); | 525 | addFlyAction(tr("SUM(range)"), tr("SUM(range)"), "SUM(",submenuFuncStat); |
530 | addFlyAction(tr("SUMSQ(range)"), tr("SUMSQ(range)"), "SUMSQ(",submenuFuncStat); | 526 | addFlyAction(tr("SUMSQ(range)"), tr("SUMSQ(range)"), "SUMSQ(",submenuFuncStat); |
531 | submenuFuncStat->insertSeparator(); | 527 | submenuFuncStat->insertSeparator(); |
532 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); | 528 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); |
533 | addFlyAction(tr("VAR(range)"), tr("VAR(range)"), "VAR(",submenuFuncStat); | 529 | addFlyAction(tr("VAR(range)"), tr("VAR(range)"), "VAR(",submenuFuncStat); |
534 | addFlyAction(tr("VARP(range)"), tr("VARP(range)"), "VARP(",submenuFuncStat); | 530 | addFlyAction(tr("VARP(range)"), tr("VARP(range)"), "VARP(",submenuFuncStat); |
535 | addFlyAction(tr("STDEV(range)"), tr("STDEV(range)"), "STDEV(",submenuFuncStat); | 531 | addFlyAction(tr("STDEV(range)"), tr("STDEV(range)"), "STDEV(",submenuFuncStat); |
536 | addFlyAction(tr("STDEVP(range)"), tr("STDEVP(range)"), "STDEVP(",submenuFuncStat); | 532 | addFlyAction(tr("STDEVP(range)"), tr("STDEVP(range)"), "STDEVP(",submenuFuncStat); |
537 | addFlyAction(tr("SKEW(range)"), tr("SKEW(range)"), "SKEW(",submenuFuncStat); | 533 | addFlyAction(tr("SKEW(range)"), tr("SKEW(range)"), "SKEW(",submenuFuncStat); |
538 | addFlyAction(tr("KURT(range)"), tr("KURT(range)"), "KURT(",submenuFuncStat); | 534 | addFlyAction(tr("KURT(range)"), tr("KURT(range)"), "KURT(",submenuFuncStat); |
539 | submenuFunc->insertItem(tr("Sta&tistical"), submenuFuncStat); | 535 | submenuFunc->insertItem(tr("Sta&tistical"), submenuFuncStat); |
540 | 536 | ||
541 | submenuFuncScientific=new QPopupMenu; | 537 | submenuFuncScientific=new QPopupMenu; |
542 | addFlyAction(tr("BESSELI(x,n)"), tr("BESSELI(x,n)"), "BESSELI(",submenuFuncScientific); | 538 | addFlyAction(tr("BESSELI(x,n)"), tr("BESSELI(x,n)"), "BESSELI(",submenuFuncScientific); |
543 | addFlyAction(tr("BESSELJ(x,n)"), tr("BESSELJ(x,n)"), "BESSELJ(",submenuFuncScientific); | 539 | addFlyAction(tr("BESSELJ(x,n)"), tr("BESSELJ(x,n)"), "BESSELJ(",submenuFuncScientific); |
544 | addFlyAction(tr("BESSELK(x,n)"), tr("BESSELK(x,n)"), "BESSELK(",submenuFuncScientific); | 540 | addFlyAction(tr("BESSELK(x,n)"), tr("BESSELK(x,n)"), "BESSELK(",submenuFuncScientific); |
545 | addFlyAction(tr("BESSELY(x,n)"), tr("BESSELY(x,n)"), "BESSELY(",submenuFuncScientific); | 541 | addFlyAction(tr("BESSELY(x,n)"), tr("BESSELY(x,n)"), "BESSELY(",submenuFuncScientific); |
546 | submenuFuncScientific->insertSeparator(); | 542 | submenuFuncScientific->insertSeparator(); |
547 | addFlyAction(tr("BETAI(x,a,b)"), tr("BETAI(x,a,b)"), "BETAI(",submenuFuncScientific); | 543 | addFlyAction(tr("BETAI(x,a,b)"), tr("BETAI(x,a,b)"), "BETAI(",submenuFuncScientific); |
548 | addFlyAction(tr("ERF(a,b)"), tr("ERF(a,b)"), "ERF(",submenuFuncScientific); | 544 | addFlyAction(tr("ERF(a,b)"), tr("ERF(a,b)"), "ERF(",submenuFuncScientific); |
549 | addFlyAction(tr("ERFC(a,b)"), tr("ERFC(a,b)"), "ERFC(",submenuFuncScientific); | 545 | addFlyAction(tr("ERFC(a,b)"), tr("ERFC(a,b)"), "ERFC(",submenuFuncScientific); |
550 | addFlyAction(tr("GAMMALN(x)"), tr("GAMMALN(x)"), "GAMMALN(",submenuFuncScientific); | 546 | addFlyAction(tr("GAMMALN(x)"), tr("GAMMALN(x)"), "GAMMALN(",submenuFuncScientific); |
551 | addFlyAction(tr("GAMMAP(x,a)"), tr("GAMMAP(x,a)"), "GAMMAP(",submenuFuncScientific); | 547 | addFlyAction(tr("GAMMAP(x,a)"), tr("GAMMAP(x,a)"), "GAMMAP(",submenuFuncScientific); |
552 | addFlyAction(tr("GAMMAQ(x,a)"), tr("GAMMAQ(x,a)"), "GAMMAQ(",submenuFuncScientific); | 548 | addFlyAction(tr("GAMMAQ(x,a)"), tr("GAMMAQ(x,a)"), "GAMMAQ(",submenuFuncScientific); |
553 | submenuFunc->insertItem(tr("Scienti&fic"), submenuFuncScientific); | 549 | submenuFunc->insertItem(tr("Scienti&fic"), submenuFuncScientific); |
554 | 550 | ||
555 | submenuFuncDistr=new QPopupMenu; | 551 | submenuFuncDistr=new QPopupMenu; |
556 | addFlyAction(tr("BETADIST(z,a,b,Q?)"), tr("BETADIST(z,a,b,Q?)"), "BETADIST(",submenuFuncDistr); | 552 | addFlyAction(tr("BETADIST(z,a,b,Q?)"), tr("BETADIST(z,a,b,Q?)"), "BETADIST(",submenuFuncDistr); |
557 | addFlyAction(tr("CHI2DIST(x,n,Q?)"), tr("CHI2DIST(x,n,Q?)"), "CHI2DIST(",submenuFuncDistr); | 553 | addFlyAction(tr("CHI2DIST(x,n,Q?)"), tr("CHI2DIST(x,n,Q?)"), "CHI2DIST(",submenuFuncDistr); |
558 | addFlyAction(tr("CHIDIST(x,n,Q?)"), tr("CHIDIST(x,n,Q?)"), "CHIDIST(",submenuFuncDistr); | 554 | addFlyAction(tr("CHIDIST(x,n,Q?)"), tr("CHIDIST(x,n,Q?)"), "CHIDIST(",submenuFuncDistr); |
559 | addFlyAction(tr("FDIST(z,deg1,deg2,Q?)"), tr("FDIST(z,deg1,deg2,Q?)"), "FDIST(",submenuFuncDistr); | 555 | addFlyAction(tr("FDIST(z,deg1,deg2,Q?)"), tr("FDIST(z,deg1,deg2,Q?)"), "FDIST(",submenuFuncDistr); |
560 | addFlyAction(tr("GAMMADIST(x,a,b,Q?)"), tr("GAMMADIST(x,a,b,Q?)"), "GAMMADIST(",submenuFuncDistr); | 556 | addFlyAction(tr("GAMMADIST(x,a,b,Q?)"), tr("GAMMADIST(x,a,b,Q?)"), "GAMMADIST(",submenuFuncDistr); |
561 | addFlyAction(tr("NORMALDIST(x,m,s,Q?)"), tr("NORMALDIST(x,m,s,Q?)"), "NORMALDIST(",submenuFuncDistr); | 557 | addFlyAction(tr("NORMALDIST(x,m,s,Q?)"), tr("NORMALDIST(x,m,s,Q?)"), "NORMALDIST(",submenuFuncDistr); |
562 | addFlyAction(tr("PHI(x,Q?)"), tr("PHI(x,Q?)"), "PHI(",submenuFuncDistr); | 558 | addFlyAction(tr("PHI(x,Q?)"), tr("PHI(x,Q?)"), "PHI(",submenuFuncDistr); |
563 | addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr); | 559 | addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr); |
564 | submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr); | 560 | submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr); |
565 | 561 | ||
566 | 562 | ||
567 | 563 | ||
568 | menuInsert->insertSeparator(); | 564 | menuInsert->insertSeparator(); |
569 | insertCells->addTo(menuInsert); | 565 | insertCells->addTo(menuInsert); |
570 | insertRows->addTo(menuInsert); | 566 | insertRows->addTo(menuInsert); |
571 | insertCols->addTo(menuInsert); | 567 | insertCols->addTo(menuInsert); |
572 | insertSheets->addTo(menuInsert); | 568 | insertSheets->addTo(menuInsert); |
573 | } | 569 | } |
574 | 570 | ||
575 | void MainWindow::initStandardToolbar() | 571 | void MainWindow::initStandardToolbar() |
576 | { | 572 | { |
577 | toolbarStandard=new QToolBar(this); | 573 | toolbarStandard=new QToolBar(this); |
578 | toolbarStandard->setHorizontalStretchable(TRUE); | 574 | toolbarStandard->setHorizontalStretchable(TRUE); |
579 | moveToolBar(toolbarStandard, Top); | 575 | moveToolBar(toolbarStandard, Top); |
580 | 576 | ||
581 | fileNew->addTo(toolbarStandard); | 577 | fileNew->addTo(toolbarStandard); |
582 | fileOpen->addTo(toolbarStandard); | 578 | fileOpen->addTo(toolbarStandard); |
583 | fileSave->addTo(toolbarStandard); | 579 | fileSave->addTo(toolbarStandard); |
584 | 580 | ||
585 | comboSheets=new QComboBox(toolbarStandard); | 581 | comboSheets=new QComboBox(toolbarStandard); |
586 | toolbarStandard->setStretchableWidget(comboSheets); | 582 | toolbarStandard->setStretchableWidget(comboSheets); |
587 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); | 583 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); |
588 | } | 584 | } |
589 | 585 | ||
590 | void MainWindow::initFunctionsToolbar() | 586 | void MainWindow::initFunctionsToolbar() |
591 | { | 587 | { |
592 | toolbarFunctions=new QToolBar(this); | 588 | toolbarFunctions=new QToolBar(this); |
593 | toolbarFunctions->setHorizontalStretchable(TRUE); | 589 | toolbarFunctions->setHorizontalStretchable(TRUE); |
594 | moveToolBar(toolbarFunctions, Bottom); | 590 | moveToolBar(toolbarFunctions, Bottom); |
595 | 591 | ||
596 | funcEqual->addTo(toolbarFunctions); | 592 | funcEqual->addTo(toolbarFunctions); |
597 | funcPlus->addTo(toolbarFunctions); | 593 | funcPlus->addTo(toolbarFunctions); |
598 | funcMinus->addTo(toolbarFunctions); | 594 | funcMinus->addTo(toolbarFunctions); |
599 | funcCross->addTo(toolbarFunctions); | 595 | funcCross->addTo(toolbarFunctions); |
600 | funcDivide->addTo(toolbarFunctions); | 596 | funcDivide->addTo(toolbarFunctions); |
601 | funcParanOpen->addTo(toolbarFunctions); | 597 | funcParanOpen->addTo(toolbarFunctions); |
602 | funcParanClose->addTo(toolbarFunctions); | 598 | funcParanClose->addTo(toolbarFunctions); |
603 | funcComma->addTo(toolbarFunctions); | 599 | funcComma->addTo(toolbarFunctions); |
604 | 600 | ||
605 | toolFunction=new QToolButton(toolbarFunctions); | 601 | toolFunction=new QToolButton(toolbarFunctions); |
606 | toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func-func" )); | 602 | toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func-func" )); |
607 | toolFunction->setTextLabel(tr("Functions")); | 603 | toolFunction->setTextLabel(tr("Functions")); |
608 | toolFunction->setPopup(submenuFunc); | 604 | toolFunction->setPopup(submenuFunc); |
609 | toolFunction->setPopupDelay(0); | 605 | toolFunction->setPopupDelay(0); |
610 | } | 606 | } |
611 | 607 | ||
612 | void MainWindow::initEditToolbar() | 608 | void MainWindow::initEditToolbar() |
613 | { | 609 | { |
614 | toolbarEdit=new QToolBar(this); | 610 | toolbarEdit=new QToolBar(this); |
615 | toolbarEdit->setHorizontalStretchable(TRUE); | 611 | toolbarEdit->setHorizontalStretchable(TRUE); |
616 | moveToolBar(toolbarEdit, Bottom); | 612 | moveToolBar(toolbarEdit, Bottom); |
617 | 613 | ||
618 | editAccept->addTo(toolbarEdit); | 614 | editAccept->addTo(toolbarEdit); |
619 | editCancel->addTo(toolbarEdit); | 615 | editCancel->addTo(toolbarEdit); |
620 | 616 | ||
621 | editData=new QLineEdit(toolbarEdit); | 617 | editData=new QLineEdit(toolbarEdit); |
622 | toolbarEdit->setStretchableWidget(editData); | 618 | toolbarEdit->setStretchableWidget(editData); |
623 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); | 619 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); |
624 | 620 | ||
625 | editCellSelect->addTo(toolbarEdit); | 621 | editCellSelect->addTo(toolbarEdit); |
626 | } | 622 | } |
627 | 623 | ||
628 | void MainWindow::slotHelpAbout() | 624 | void MainWindow::slotHelpAbout() |
629 | { | 625 | { |
630 | QDialog dialogAbout(this, 0, TRUE); | 626 | QDialog dialogAbout(this, 0, TRUE); |
631 | dialogAbout.resize(width()-40, height()-80); | 627 | dialogAbout.resize(width()-40, height()-80); |
632 | dialogAbout.setCaption(tr("About Opie Sheet")); | 628 | dialogAbout.setCaption(tr("About Opie Sheet")); |
633 | 629 | ||
634 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); | 630 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); |
635 | label.setGeometry(dialogAbout.rect()); | 631 | label.setGeometry(dialogAbout.rect()); |
636 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); | 632 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); |
637 | 633 | ||
638 | dialogAbout.exec(); | 634 | dialogAbout.exec(); |
639 | } | 635 | } |
640 | 636 | ||
641 | void MainWindow::initSheet() | 637 | void MainWindow::initSheet() |
642 | { | 638 | { |
643 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); | 639 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); |
644 | setCentralWidget(sheet); | 640 | setCentralWidget(sheet); |
645 | 641 | ||
646 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); | 642 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); |
647 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); | 643 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); |
648 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); | 644 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); |
649 | 645 | ||
650 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); | 646 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); |
651 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); | 647 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); |
652 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); | 648 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); |
653 | } | 649 | } |
654 | 650 | ||
655 | void MainWindow::slotEditAccept() | 651 | void MainWindow::slotEditAccept() |
656 | { | 652 | { |
657 | sheet->setData(editData->text()); | 653 | sheet->setData(editData->text()); |
658 | } | 654 | } |
659 | 655 | ||
660 | void MainWindow::slotEditCancel() | 656 | void MainWindow::slotEditCancel() |
661 | { | 657 | { |
662 | editData->setText(sheet->getData()); | 658 | editData->setText(sheet->getData()); |
663 | } | 659 | } |
664 | 660 | ||
665 | void MainWindow::slotCellSelect(bool lock) | 661 | void MainWindow::slotCellSelect(bool lock) |
666 | { | 662 | { |
667 | sheet->lockClicks(lock); | 663 | sheet->lockClicks(lock); |
668 | } | 664 | } |
669 | 665 | ||
670 | void MainWindow::addToData(const QString &data) | 666 | void MainWindow::addToData(const QString &data) |
671 | { | 667 | { |
672 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); | 668 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); |
673 | } | 669 | } |
674 | 670 | ||
675 | void MainWindow::slotFuncOutput() | 671 | void MainWindow::slotFuncOutput() |
676 | { | 672 | { |
677 | if (sender()->isA("QAction")) | 673 | if (sender()->isA("QAction")) |
678 | addToData(((QAction *)sender())->toolTip()); | 674 | addToData(((QAction *)sender())->toolTip()); |
679 | } | 675 | } |
680 | 676 | ||
681 | void MainWindow::slotInsertRows() | 677 | void MainWindow::slotInsertRows() |
682 | { | 678 | { |
683 | NumberDialog dialogNumber(this); | 679 | NumberDialog dialogNumber(this); |
684 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) | 680 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) |
685 | sheet->insertRows(dialogNumber.getValue()); | 681 | sheet->insertRows(dialogNumber.getValue()); |
686 | } | 682 | } |
687 | 683 | ||
688 | void MainWindow::slotInsertCols() | 684 | void MainWindow::slotInsertCols() |
689 | { | 685 | { |
690 | NumberDialog dialogNumber(this); | 686 | NumberDialog dialogNumber(this); |
691 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) | 687 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) |
692 | sheet->insertColumns(dialogNumber.getValue()); | 688 | sheet->insertColumns(dialogNumber.getValue()); |
693 | } | 689 | } |
694 | 690 | ||
695 | void MainWindow::slotInsertSheets() | 691 | void MainWindow::slotInsertSheets() |
696 | { | 692 | { |
697 | NumberDialog dialogNumber(this); | 693 | NumberDialog dialogNumber(this); |
698 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) | 694 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) |
699 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); | 695 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); |
700 | } | 696 | } |
701 | 697 | ||
702 | void MainWindow::slotCellClicked(const QString &cell) | 698 | void MainWindow::slotCellClicked(const QString &cell) |
703 | { | 699 | { |
704 | editCellSelect->setOn(FALSE); | 700 | editCellSelect->setOn(FALSE); |
705 | addToData(cell); | 701 | addToData(cell); |
706 | } | 702 | } |
707 | 703 | ||
708 | typeSheet *MainWindow::createNewSheet() | 704 | typeSheet *MainWindow::createNewSheet() |
709 | { | 705 | { |
710 | typeSheet *newSheet=new typeSheet; | 706 | typeSheet *newSheet=new typeSheet; |
711 | int currentNo=1, tempNo=0; | 707 | int currentNo=1, tempNo=0; |
712 | bool ok; | 708 | bool ok; |
713 | 709 | ||
714 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 710 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
715 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) | 711 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) |
716 | currentNo=tempNo+1; | 712 | currentNo=tempNo+1; |
717 | 713 | ||
718 | newSheet->name=tr("Sheet")+QString::number(currentNo); | 714 | newSheet->name=tr("Sheet")+QString::number(currentNo); |
719 | newSheet->data.setAutoDelete(TRUE); | 715 | newSheet->data.setAutoDelete(TRUE); |
720 | 716 | ||
721 | comboSheets->insertItem(newSheet->name); | 717 | comboSheets->insertItem(newSheet->name); |
722 | listSheets.append(newSheet); | 718 | listSheets.append(newSheet); |
723 | return newSheet; | 719 | return newSheet; |
724 | } | 720 | } |
725 | 721 | ||
726 | typeSheet *MainWindow::findSheet(const QString &name) | 722 | typeSheet *MainWindow::findSheet(const QString &name) |
727 | { | 723 | { |
728 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 724 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
729 | if (tempSheet->name==name) | 725 | if (tempSheet->name==name) |
730 | return tempSheet; | 726 | return tempSheet; |
731 | return NULL; | 727 | return NULL; |
732 | } | 728 | } |
733 | 729 | ||
734 | void MainWindow::slotSheetChanged(const QString &name) | 730 | void MainWindow::slotSheetChanged(const QString &name) |
735 | { | 731 | { |
736 | sheet->copySheetData(&findSheet(sheet->getName())->data); | 732 | sheet->copySheetData(&findSheet(sheet->getName())->data); |
737 | sheet->setName(name); | 733 | sheet->setName(name); |
738 | sheet->setSheetData(&findSheet(name)->data); | 734 | sheet->setSheetData(&findSheet(name)->data); |
739 | sheet->ReCalc(); | 735 | sheet->ReCalc(); |
740 | } | 736 | } |
741 | 737 | ||
742 | void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) | 738 | void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) |
743 | { | 739 | { |
744 | QAction *action=new QAction(text, menuText, 0, this); | 740 | QAction *action=new QAction(text, menuText, 0, this); |
745 | action->setToolTip(tip); | 741 | action->setToolTip(tip); |
746 | connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 742 | connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
747 | action->addTo(w); | 743 | action->addTo(w); |
748 | } | 744 | } |
749 | 745 | ||
750 | void MainWindow::slotFormatCells() | 746 | void MainWindow::slotFormatCells() |
751 | { | 747 | { |
752 | CellFormat dialogCellFormat(this); | 748 | CellFormat dialogCellFormat(this); |
753 | QPEApplication::showDialog( &dialogCellFormat ); | 749 | QPEApplication::showDialog( &dialogCellFormat ); |
754 | dialogCellFormat.exec(sheet); | 750 | dialogCellFormat.exec(sheet); |
755 | } | 751 | } |
756 | 752 | ||
757 | void MainWindow::slotEditPaste() | 753 | void MainWindow::slotEditPaste() |
758 | { | 754 | { |
759 | sheet->editPaste(); | 755 | sheet->editPaste(); |
760 | } | 756 | } |
761 | 757 | ||
762 | void MainWindow::slotEditPasteContents() | 758 | void MainWindow::slotEditPasteContents() |
763 | { | 759 | { |
764 | sheet->editPaste(TRUE); | 760 | sheet->editPaste(TRUE); |
765 | } | 761 | } |
766 | 762 | ||
767 | void MainWindow::slotRowHeight() | 763 | void MainWindow::slotRowHeight() |
768 | { | 764 | { |
769 | int row1, row2, col1, col2; | 765 | int row1, row2, col1, col2; |
770 | sheet->getSelection(&row1, &col1, &row2, &col2); | 766 | sheet->getSelection(&row1, &col1, &row2, &col2); |
771 | 767 | ||
772 | NumberDialog dialogNumber(this); | 768 | NumberDialog dialogNumber(this); |
773 | if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted) | 769 | if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted) |
774 | { | 770 | { |
775 | int newHeight=dialogNumber.getValue(), row; | 771 | int newHeight=dialogNumber.getValue(), row; |
776 | for (row=row1; row<=row2; ++row) | 772 | for (row=row1; row<=row2; ++row) |
777 | sheet->setRowHeight(row, newHeight); | 773 | sheet->setRowHeight(row, newHeight); |
778 | } | 774 | } |
779 | } | 775 | } |
780 | 776 | ||
781 | void MainWindow::slotRowAdjust() | 777 | void MainWindow::slotRowAdjust() |
782 | { | 778 | { |
783 | int row1, row2, col1, col2; | 779 | int row1, row2, col1, col2; |
784 | sheet->getSelection(&row1, &col1, &row2, &col2); | 780 | sheet->getSelection(&row1, &col1, &row2, &col2); |
785 | 781 | ||
786 | for (int row=row1; row<=row2; ++row) | 782 | for (int row=row1; row<=row2; ++row) |
787 | sheet->adjustRow(row); | 783 | sheet->adjustRow(row); |
788 | } | 784 | } |
789 | 785 | ||
790 | void MainWindow::slotRowShow() | 786 | void MainWindow::slotRowShow() |
791 | { | 787 | { |
792 | int row1, row2, col1, col2; | 788 | int row1, row2, col1, col2; |
diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp index e1e4744..f303d33 100644 --- a/noncore/apps/opie-sheet/sheet.cpp +++ b/noncore/apps/opie-sheet/sheet.cpp | |||
@@ -1,785 +1,784 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 11 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 12 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include "sheet.h" | 15 | #include "sheet.h" |
16 | 16 | ||
17 | #include <qmainwindow.h> | ||
18 | #include <qmessagebox.h> | 17 | #include <qmessagebox.h> |
19 | #include <math.h> | 18 | #include <math.h> |
20 | #include <stdlib.h> | 19 | #include <stdlib.h> |
21 | #include <stdio.h> | 20 | #include <stdio.h> |
22 | #include <time.h> | 21 | #include <time.h> |
23 | 22 | ||
24 | #define DEFAULT_COL_WIDTH 50 | 23 | #define DEFAULT_COL_WIDTH 50 |
25 | 24 | ||
26 | Sheet::Sheet(int numRows, int numCols, QWidget *parent) | 25 | Sheet::Sheet(int numRows, int numCols, QWidget *parent) |
27 | :QTable(numRows, numCols, parent) | 26 | :QTable(numRows, numCols, parent) |
28 | { | 27 | { |
29 | defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); | 28 | defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); |
30 | defaultCellData.data=""; | 29 | defaultCellData.data=""; |
31 | defaultCellData.background=QBrush(Qt::white, Qt::SolidPattern); | 30 | defaultCellData.background=QBrush(Qt::white, Qt::SolidPattern); |
32 | defaultCellData.alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); | 31 | defaultCellData.alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); |
33 | defaultCellData.fontColor=Qt::black; | 32 | defaultCellData.fontColor=Qt::black; |
34 | defaultCellData.font=font(); | 33 | defaultCellData.font=font(); |
35 | defaultCellData.borders=defaultBorders; | 34 | defaultCellData.borders=defaultBorders; |
36 | 35 | ||
37 | clicksLocked=FALSE; | 36 | clicksLocked=FALSE; |
38 | selectionNo=-1; | 37 | selectionNo=-1; |
39 | setSelectionMode(QTable::Single); | 38 | setSelectionMode(QTable::Single); |
40 | 39 | ||
41 | sheetData.setAutoDelete(TRUE); | 40 | sheetData.setAutoDelete(TRUE); |
42 | clipboardData.setAutoDelete(TRUE); | 41 | clipboardData.setAutoDelete(TRUE); |
43 | for (int i=0; i<numCols; ++i) | 42 | for (int i=0; i<numCols; ++i) |
44 | horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); | 43 | horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); |
45 | 44 | ||
46 | 45 | ||
47 | connect(this, SIGNAL(currentChanged(int, int)), this, SLOT(slotCellSelected(int, int))); | 46 | connect(this, SIGNAL(currentChanged(int, int)), this, SLOT(slotCellSelected(int, int))); |
48 | connect(this, SIGNAL(valueChanged(int, int)), this, SLOT(slotCellChanged(int, int))); | 47 | connect(this, SIGNAL(valueChanged(int, int)), this, SLOT(slotCellChanged(int, int))); |
49 | } | 48 | } |
50 | 49 | ||
51 | Sheet::~Sheet() | 50 | Sheet::~Sheet() |
52 | { | 51 | { |
53 | } | 52 | } |
54 | 53 | ||
55 | typeCellData *Sheet::findCellData(int row, int col) | 54 | typeCellData *Sheet::findCellData(int row, int col) |
56 | { | 55 | { |
57 | typeCellData *tempCellData; | 56 | typeCellData *tempCellData; |
58 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 57 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
59 | { | 58 | { |
60 | if (tempCellData->row==row && tempCellData->col==col) return tempCellData; | 59 | if (tempCellData->row==row && tempCellData->col==col) return tempCellData; |
61 | } | 60 | } |
62 | return NULL; | 61 | return NULL; |
63 | } | 62 | } |
64 | 63 | ||
65 | void Sheet::slotCellSelected(int row, int col) | 64 | void Sheet::slotCellSelected(int row, int col) |
66 | { | 65 | { |
67 | typeCellData *cellData=findCellData(row, col); | 66 | typeCellData *cellData=findCellData(row, col); |
68 | if (cellData) | 67 | if (cellData) |
69 | { | 68 | { |
70 | emit currentDataChanged(cellData->data); | 69 | emit currentDataChanged(cellData->data); |
71 | }else | 70 | }else |
72 | emit currentDataChanged(""); | 71 | emit currentDataChanged(""); |
73 | } | 72 | } |
74 | 73 | ||
75 | typeCellData *Sheet::createCellData(int row, int col) | 74 | typeCellData *Sheet::createCellData(int row, int col) |
76 | { | 75 | { |
77 | if (row<0 || col<0) return NULL; | 76 | if (row<0 || col<0) return NULL; |
78 | typeCellData *cellData=new typeCellData; | 77 | typeCellData *cellData=new typeCellData; |
79 | cellData->row=row; | 78 | cellData->row=row; |
80 | cellData->col=col; | 79 | cellData->col=col; |
81 | cellData->data=defaultCellData.data; | 80 | cellData->data=defaultCellData.data; |
82 | cellData->borders=defaultCellData.borders; | 81 | cellData->borders=defaultCellData.borders; |
83 | cellData->alignment=defaultCellData.alignment; | 82 | cellData->alignment=defaultCellData.alignment; |
84 | cellData->font=defaultCellData.font; | 83 | cellData->font=defaultCellData.font; |
85 | cellData->fontColor=defaultCellData.fontColor; | 84 | cellData->fontColor=defaultCellData.fontColor; |
86 | cellData->background=defaultCellData.background; | 85 | cellData->background=defaultCellData.background; |
87 | sheetData.append(cellData); | 86 | sheetData.append(cellData); |
88 | return cellData; | 87 | return cellData; |
89 | } | 88 | } |
90 | 89 | ||
91 | void Sheet::slotCellChanged(int row, int col) | 90 | void Sheet::slotCellChanged(int row, int col) |
92 | { | 91 | { |
93 | typeCellData *cellData=findCellData(row, col); | 92 | typeCellData *cellData=findCellData(row, col); |
94 | if (!cellData) cellData=createCellData(row, col); | 93 | if (!cellData) cellData=createCellData(row, col); |
95 | if (cellData) cellData->data=text(row, col); | 94 | if (cellData) cellData->data=text(row, col); |
96 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) | 95 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) |
97 | { | 96 | { |
98 | // modified by Toussis Manolis koppermind@panafonet.gr | 97 | // modified by Toussis Manolis koppermind@panafonet.gr |
99 | // the parser was crashing if there were no closed parenthesis. | 98 | // the parser was crashing if there were no closed parenthesis. |
100 | int w1,ii=0; | 99 | int w1,ii=0; |
101 | for(w1=0;w1<=(int)text(row, col).length();w1++) | 100 | for(w1=0;w1<=(int)text(row, col).length();w1++) |
102 | { | 101 | { |
103 | if(text(row,col)[w1]=='(') ii++; | 102 | if(text(row,col)[w1]=='(') ii++; |
104 | if(text(row,col)[w1]==')') ii--; | 103 | if(text(row,col)[w1]==')') ii--; |
105 | }; | 104 | }; |
106 | if(ii==0) setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); | 105 | if(ii==0) setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); |
107 | //end of modification | 106 | //end of modification |
108 | // old was plain: | 107 | // old was plain: |
109 | //setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); | 108 | //setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); |
110 | }; | 109 | }; |
111 | emit sheetModified(); | 110 | emit sheetModified(); |
112 | } | 111 | } |
113 | 112 | ||
114 | 113 | ||
115 | void Sheet::ReCalc(void) | 114 | void Sheet::ReCalc(void) |
116 | { | 115 | { |
117 | typeCellData* cellData; | 116 | typeCellData* cellData; |
118 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) | 117 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) |
119 | { | 118 | { |
120 | //printf("cellchanged:%d, %d\r\n",cellData->row,cellData->col); | 119 | //printf("cellchanged:%d, %d\r\n",cellData->row,cellData->col); |
121 | 120 | ||
122 | slotCellChanged(cellData->row,cellData->col); | 121 | slotCellChanged(cellData->row,cellData->col); |
123 | }; | 122 | }; |
124 | }; | 123 | }; |
125 | 124 | ||
126 | 125 | ||
127 | 126 | ||
128 | 127 | ||
129 | void Sheet::swapCells(int row1, int col1, int row2, int col2) | 128 | void Sheet::swapCells(int row1, int col1, int row2, int col2) |
130 | { | 129 | { |
131 | typeCellData *cellData1=findCellData(row1, col1), *cellData2=findCellData(row2, col2); | 130 | typeCellData *cellData1=findCellData(row1, col1), *cellData2=findCellData(row2, col2); |
132 | if (!cellData1) cellData1=createCellData(row1, col1); | 131 | if (!cellData1) cellData1=createCellData(row1, col1); |
133 | if (!cellData2) cellData2=createCellData(row2, col2); | 132 | if (!cellData2) cellData2=createCellData(row2, col2); |
134 | if (cellData1 && cellData2) | 133 | if (cellData1 && cellData2) |
135 | { | 134 | { |
136 | QString tempData(cellData1->data); | 135 | QString tempData(cellData1->data); |
137 | cellData1->data=cellData2->data; | 136 | cellData1->data=cellData2->data; |
138 | cellData2->data=tempData; | 137 | cellData2->data=tempData; |
139 | setText(cellData1->row, cellData1->col, dataParser(findCellName(cellData1->row, cellData1->col), cellData1->data)); | 138 | setText(cellData1->row, cellData1->col, dataParser(findCellName(cellData1->row, cellData1->col), cellData1->data)); |
140 | setText(cellData2->row, cellData2->col, dataParser(findCellName(cellData2->row, cellData2->col), cellData2->data)); | 139 | setText(cellData2->row, cellData2->col, dataParser(findCellName(cellData2->row, cellData2->col), cellData2->data)); |
141 | emit sheetModified(); | 140 | emit sheetModified(); |
142 | } | 141 | } |
143 | } | 142 | } |
144 | 143 | ||
145 | QString Sheet::getParameter(const QString ¶meters, int paramNo, bool giveError, const QString funcName) | 144 | QString Sheet::getParameter(const QString ¶meters, int paramNo, bool giveError, const QString funcName) |
146 | { | 145 | { |
147 | QString params(parameters); | 146 | QString params(parameters); |
148 | int position; | 147 | int position; |
149 | for (int i=0; i<paramNo; ++i) | 148 | for (int i=0; i<paramNo; ++i) |
150 | { | 149 | { |
151 | position=params.find(','); | 150 | position=params.find(','); |
152 | if (position<0) | 151 | if (position<0) |
153 | { | 152 | { |
154 | if (giveError) QMessageBox::critical(this, tr("Error"), tr("Too few arguments to function '"+funcName+'\'')); | 153 | if (giveError) QMessageBox::critical(this, tr("Error"), tr("Too few arguments to function '"+funcName+'\'')); |
155 | //printf("params:%s\r\n",parameters.ascii()); | 154 | //printf("params:%s\r\n",parameters.ascii()); |
156 | return QString(NULL); | 155 | return QString(NULL); |
157 | } | 156 | } |
158 | params=params.mid(position+1); | 157 | params=params.mid(position+1); |
159 | } | 158 | } |
160 | position=params.find(','); | 159 | position=params.find(','); |
161 | if (position<0) return params; | 160 | if (position<0) return params; |
162 | return params.left(position); | 161 | return params.left(position); |
163 | } | 162 | } |
164 | 163 | ||
165 | bool Sheet::findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2) | 164 | bool Sheet::findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2) |
166 | { | 165 | { |
167 | int row, col; | 166 | int row, col; |
168 | if (!findRowColumn(variable1, row1, col1, FALSE) || !findRowColumn(variable2, row2, col2, FALSE)) return FALSE; | 167 | if (!findRowColumn(variable1, row1, col1, FALSE) || !findRowColumn(variable2, row2, col2, FALSE)) return FALSE; |
169 | if (*row1>*row2) | 168 | if (*row1>*row2) |
170 | { | 169 | { |
171 | row=*row1; | 170 | row=*row1; |
172 | *row1=*row2; | 171 | *row1=*row2; |
173 | *row2=row; | 172 | *row2=row; |
174 | } | 173 | } |
175 | if (*col1>*col2) | 174 | if (*col1>*col2) |
176 | { | 175 | { |
177 | col=*col1; | 176 | col=*col1; |
178 | *col1=*col2; | 177 | *col1=*col2; |
179 | *col2=col; | 178 | *col2=col; |
180 | } | 179 | } |
181 | return TRUE; | 180 | return TRUE; |
182 | } | 181 | } |
183 | 182 | ||
184 | bool Sheet::findRowColumn(const QString &variable, int *row, int *col, bool giveError) | 183 | bool Sheet::findRowColumn(const QString &variable, int *row, int *col, bool giveError) |
185 | { | 184 | { |
186 | int position=variable.find(QRegExp("\\d")); | 185 | int position=variable.find(QRegExp("\\d")); |
187 | if (position<1) | 186 | if (position<1) |
188 | { | 187 | { |
189 | if (giveError) QMessageBox::critical(this, tr("Error"), tr("Invalid variable: '"+variable+'\'')); | 188 | if (giveError) QMessageBox::critical(this, tr("Error"), tr("Invalid variable: '"+variable+'\'')); |
190 | return FALSE; | 189 | return FALSE; |
191 | } | 190 | } |
192 | *row=variable.mid(position).toInt()-1; | 191 | *row=variable.mid(position).toInt()-1; |
193 | *col=getHeaderColumn(variable.left(position))-1; | 192 | *col=getHeaderColumn(variable.left(position))-1; |
194 | return TRUE; | 193 | return TRUE; |
195 | } | 194 | } |
196 | 195 | ||
197 | QString Sheet::calculateVariable(const QString &variable) | 196 | QString Sheet::calculateVariable(const QString &variable) |
198 | { | 197 | { |
199 | bool ok; | 198 | bool ok; |
200 | printf("calculateVariable=%s,len=%d\r\n",variable.ascii(),variable.length()); | 199 | printf("calculateVariable=%s,len=%d\r\n",variable.ascii(),variable.length()); |
201 | if(variable.left(1)=="\"") return QString(variable.mid(1,variable.length()-2)); | 200 | if(variable.left(1)=="\"") return QString(variable.mid(1,variable.length()-2)); |
202 | double tempResult=variable.toDouble(&ok); | 201 | double tempResult=variable.toDouble(&ok); |
203 | if (ok) | 202 | if (ok) |
204 | { | 203 | { |
205 | if(tempResult!=0.0) | 204 | if(tempResult!=0.0) |
206 | { | 205 | { |
207 | return QString::number(tempResult); | 206 | return QString::number(tempResult); |
208 | } | 207 | } |
209 | else | 208 | else |
210 | { | 209 | { |
211 | if(variable!="0" || variable!="0.0") return QString(variable); // hereis a string variable | 210 | if(variable!="0" || variable!="0.0") return QString(variable); // hereis a string variable |
212 | return QString::number(tempResult); | 211 | return QString::number(tempResult); |
213 | }; | 212 | }; |
214 | }; | 213 | }; |
215 | 214 | ||
216 | int row, col; | 215 | int row, col; |
217 | if(findRowColumn(variable, &row, &col, FALSE)) return dataParser(variable, text(row,col)); | 216 | if(findRowColumn(variable, &row, &col, FALSE)) return dataParser(variable, text(row,col)); |
218 | //return (findRowColumn(variable, &row, &col, TRUE) ? dataParser(variable, text(row, col)) : 0); | 217 | //return (findRowColumn(variable, &row, &col, TRUE) ? dataParser(variable, text(row, col)) : 0); |
219 | return QString(variable); | 218 | return QString(variable); |
220 | } | 219 | } |
221 | 220 | ||
222 | double Sheet::BesselI0(double x) | 221 | double Sheet::BesselI0(double x) |
223 | { | 222 | { |
224 | //Returns the modi ed Bessel function I0(x) for any real x. | 223 | //Returns the modi ed Bessel function I0(x) for any real x. |
225 | double ax,ans; | 224 | double ax,ans; |
226 | double y; | 225 | double y; |
227 | if ((ax=fabs(x)) < 3.75) | 226 | if ((ax=fabs(x)) < 3.75) |
228 | { | 227 | { |
229 | y=x/3.75; | 228 | y=x/3.75; |
230 | y*=y; | 229 | y*=y; |
231 | ans=1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492 +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2))))); | 230 | ans=1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492 +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2))))); |
232 | }else | 231 | }else |
233 | { | 232 | { |
234 | y=3.75/ax; | 233 | y=3.75/ax; |
235 | ans=(exp(ax)/sqrt(ax))*(0.39894228+y*(0.1328592e-1 +y*(0.225319e-2+y*(-0.157565e-2+y*(0.916281e-2 +y*(-0.2057706e-1+y*(0.2635537e-1+y*(-0.1647633e-1 +y*0.392377e-2)))))))); | 234 | ans=(exp(ax)/sqrt(ax))*(0.39894228+y*(0.1328592e-1 +y*(0.225319e-2+y*(-0.157565e-2+y*(0.916281e-2 +y*(-0.2057706e-1+y*(0.2635537e-1+y*(-0.1647633e-1 +y*0.392377e-2)))))))); |
236 | } | 235 | } |
237 | return ans; | 236 | return ans; |
238 | }; | 237 | }; |
239 | 238 | ||
240 | double Sheet::BesselI1(double x) | 239 | double Sheet::BesselI1(double x) |
241 | { | 240 | { |
242 | double ax,ans; | 241 | double ax,ans; |
243 | double y; | 242 | double y; |
244 | if ((ax=fabs(x)) < 3.75) | 243 | if ((ax=fabs(x)) < 3.75) |
245 | { | 244 | { |
246 | y=x/3.75; | 245 | y=x/3.75; |
247 | y*=y; | 246 | y*=y; |
248 | ans=ax*(0.5+y*(0.87890594+y*(0.51498869+y*(0.15084934 +y*(0.2658733e-1+y*(0.301532e-2+y*0.32411e-3)))))); | 247 | ans=ax*(0.5+y*(0.87890594+y*(0.51498869+y*(0.15084934 +y*(0.2658733e-1+y*(0.301532e-2+y*0.32411e-3)))))); |
249 | } else | 248 | } else |
250 | { | 249 | { |
251 | y=3.75/ax; | 250 | y=3.75/ax; |
252 | ans=0.2282967e-1+y*(-0.2895312e-1+y*(0.1787654e-1 -y*0.420059e-2)); ans=0.39894228+y*(-0.3988024e-1+y*(-0.362018e-2 +y*(0.163801e-2+y*(-0.1031555e-1+y*ans)))); | 251 | ans=0.2282967e-1+y*(-0.2895312e-1+y*(0.1787654e-1 -y*0.420059e-2)); ans=0.39894228+y*(-0.3988024e-1+y*(-0.362018e-2 +y*(0.163801e-2+y*(-0.1031555e-1+y*ans)))); |
253 | ans *= (exp(ax)/sqrt(ax)); | 252 | ans *= (exp(ax)/sqrt(ax)); |
254 | } | 253 | } |
255 | return x < 0.0 ? -ans : ans; | 254 | return x < 0.0 ? -ans : ans; |
256 | }; | 255 | }; |
257 | 256 | ||
258 | double Sheet::BesselI(int n, double x) | 257 | double Sheet::BesselI(int n, double x) |
259 | { | 258 | { |
260 | double ACC=40.0; | 259 | double ACC=40.0; |
261 | double BIGNO=1.0e10; | 260 | double BIGNO=1.0e10; |
262 | double BIGNI=1.0e-10; | 261 | double BIGNI=1.0e-10; |
263 | int j; | 262 | int j; |
264 | double bi,bim,bip,tox,ans; | 263 | double bi,bim,bip,tox,ans; |
265 | if (n < 2) return 0.0; | 264 | if (n < 2) return 0.0; |
266 | if (x == 0.0) return 0.0; else | 265 | if (x == 0.0) return 0.0; else |
267 | { | 266 | { |
268 | tox=2.0/fabs(x); | 267 | tox=2.0/fabs(x); |
269 | bip=ans=0.0; | 268 | bip=ans=0.0; |
270 | bi=1.0; | 269 | bi=1.0; |
271 | for (j=2*(n+(int) sqrt(ACC*n));j>0;j--) | 270 | for (j=2*(n+(int) sqrt(ACC*n));j>0;j--) |
272 | { | 271 | { |
273 | bim=bip+j*tox*bi; | 272 | bim=bip+j*tox*bi; |
274 | bip=bi; | 273 | bip=bi; |
275 | bi=bim; | 274 | bi=bim; |
276 | if (fabs(bi) > BIGNO) | 275 | if (fabs(bi) > BIGNO) |
277 | { | 276 | { |
278 | ans *= BIGNI; | 277 | ans *= BIGNI; |
279 | bi *= BIGNI; | 278 | bi *= BIGNI; |
280 | bip *= BIGNI; | 279 | bip *= BIGNI; |
281 | } | 280 | } |
282 | if (j == n) ans=bip; | 281 | if (j == n) ans=bip; |
283 | } | 282 | } |
284 | ans *= BesselI0(x)/bi; | 283 | ans *= BesselI0(x)/bi; |
285 | return x < 0.0 && (n & 1) ? -ans : ans; | 284 | return x < 0.0 && (n & 1) ? -ans : ans; |
286 | } | 285 | } |
287 | }; | 286 | }; |
288 | 287 | ||
289 | double Sheet::BesselK0(double x) | 288 | double Sheet::BesselK0(double x) |
290 | { | 289 | { |
291 | double y,ans; | 290 | double y,ans; |
292 | if (x <= 2.0) | 291 | if (x <= 2.0) |
293 | { | 292 | { |
294 | y=x*x/4.0; | 293 | y=x*x/4.0; |
295 | ans=(-log(x/2.0)*BesselI0(x))+(-0.57721566+y*(0.42278420 +y*(0.23069756+y*(0.3488590e-1+y*(0.262698e-2 +y*(0.10750e-3+y*0.74e-5)))))); | 294 | ans=(-log(x/2.0)*BesselI0(x))+(-0.57721566+y*(0.42278420 +y*(0.23069756+y*(0.3488590e-1+y*(0.262698e-2 +y*(0.10750e-3+y*0.74e-5)))))); |
296 | } else | 295 | } else |
297 | { | 296 | { |
298 | y=2.0/x; | 297 | y=2.0/x; |
299 | ans=(exp(-x)/sqrt(x))*(1.25331414+y*(-0.7832358e-1 +y*(0.2189568e-1+y*(-0.1062446e-1+y*(0.587872e-2 +y*(-0.251540e-2+y*0.53208e-3)))))); | 298 | ans=(exp(-x)/sqrt(x))*(1.25331414+y*(-0.7832358e-1 +y*(0.2189568e-1+y*(-0.1062446e-1+y*(0.587872e-2 +y*(-0.251540e-2+y*0.53208e-3)))))); |
300 | } | 299 | } |
301 | return ans; | 300 | return ans; |
302 | }; | 301 | }; |
303 | 302 | ||
304 | double Sheet::BesselK1(double x) | 303 | double Sheet::BesselK1(double x) |
305 | { | 304 | { |
306 | double y,ans; | 305 | double y,ans; |
307 | if (x <= 2.0) | 306 | if (x <= 2.0) |
308 | { | 307 | { |
309 | y=x*x/4.0; | 308 | y=x*x/4.0; |
310 | ans=(log(x/2.0)*BesselI1(x))+(1.0/x)*(1.0+y*(0.15443144 +y*(-0.67278579+y*(-0.18156897+y*(-0.1919402e-1 +y*(-0.110404e-2+y*(-0.4686e-4))))))); | 309 | ans=(log(x/2.0)*BesselI1(x))+(1.0/x)*(1.0+y*(0.15443144 +y*(-0.67278579+y*(-0.18156897+y*(-0.1919402e-1 +y*(-0.110404e-2+y*(-0.4686e-4))))))); |
311 | } else | 310 | } else |
312 | { | 311 | { |
313 | y=2.0/x; | 312 | y=2.0/x; |
314 | ans=(exp(-x)/sqrt(x))*(1.25331414+y*(0.23498619 +y*(-0.3655620e-1+y*(0.1504268e-1+y*(-0.780353e-2 +y*(0.325614e-2+y*(-0.68245e-3))))))); | 313 | ans=(exp(-x)/sqrt(x))*(1.25331414+y*(0.23498619 +y*(-0.3655620e-1+y*(0.1504268e-1+y*(-0.780353e-2 +y*(0.325614e-2+y*(-0.68245e-3))))))); |
315 | } | 314 | } |
316 | return ans; | 315 | return ans; |
317 | }; | 316 | }; |
318 | 317 | ||
319 | double Sheet::BesselK(int n, double x) | 318 | double Sheet::BesselK(int n, double x) |
320 | { | 319 | { |
321 | int j; | 320 | int j; |
322 | double bk,bkm,bkp,tox; | 321 | double bk,bkm,bkp,tox; |
323 | if (n < 2) return 0.0; | 322 | if (n < 2) return 0.0; |
324 | tox=2.0/x; | 323 | tox=2.0/x; |
325 | bkm=BesselK0(x); | 324 | bkm=BesselK0(x); |
326 | bk=BesselK1(x); | 325 | bk=BesselK1(x); |
327 | for (j=1;j<n;j++) | 326 | for (j=1;j<n;j++) |
328 | { | 327 | { |
329 | bkp=bkm+j*tox*bk; | 328 | bkp=bkm+j*tox*bk; |
330 | bkm=bk; | 329 | bkm=bk; |
331 | bk=bkp; | 330 | bk=bkp; |
332 | } | 331 | } |
333 | return bk; | 332 | return bk; |
334 | }; | 333 | }; |
335 | 334 | ||
336 | double Sheet::BesselJ0(double x) | 335 | double Sheet::BesselJ0(double x) |
337 | { | 336 | { |
338 | double ax,z; | 337 | double ax,z; |
339 | double xx,y,ans,ans1,ans2; | 338 | double xx,y,ans,ans1,ans2; |
340 | if ((ax=fabs(x)) < 8.0) | 339 | if ((ax=fabs(x)) < 8.0) |
341 | { | 340 | { |
342 | y=x*x; | 341 | y=x*x; |
343 | ans1=57568490574.0+y*(-13362590354.0+y*(651619640.7 +y*(-11214424.18+y*(77392.33017+y*(-184.9052456))))); | 342 | ans1=57568490574.0+y*(-13362590354.0+y*(651619640.7 +y*(-11214424.18+y*(77392.33017+y*(-184.9052456))))); |
344 | ans2=57568490411.0+y*(1029532985.0+y*(9494680.718 +y*(59272.64853+y*(267.8532712+y*1.0)))); | 343 | ans2=57568490411.0+y*(1029532985.0+y*(9494680.718 +y*(59272.64853+y*(267.8532712+y*1.0)))); |
345 | ans=ans1/ans2; | 344 | ans=ans1/ans2; |
346 | } else | 345 | } else |
347 | { | 346 | { |
348 | z=8.0/ax; | 347 | z=8.0/ax; |
349 | y=z*z; | 348 | y=z*z; |
350 | xx=ax-0.785398164; | 349 | xx=ax-0.785398164; |
351 | ans1=1.0+y*(-0.1098628627e-2+y*(0.2734510407e-4 +y*(-0.2073370639e-5+y*0.2093887211e-6))); | 350 | ans1=1.0+y*(-0.1098628627e-2+y*(0.2734510407e-4 +y*(-0.2073370639e-5+y*0.2093887211e-6))); |
352 | ans2 = -0.1562499995e-1+y*(0.1430488765e-3 +y*(-0.6911147651e-5+y*(0.7621095161e-6 -y*0.934935152e-7))); | 351 | ans2 = -0.1562499995e-1+y*(0.1430488765e-3 +y*(-0.6911147651e-5+y*(0.7621095161e-6 -y*0.934935152e-7))); |
353 | ans=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2); | 352 | ans=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2); |
354 | } | 353 | } |
355 | return ans; | 354 | return ans; |
356 | }; | 355 | }; |
357 | 356 | ||
358 | double Sheet::BesselY0(double x) | 357 | double Sheet::BesselY0(double x) |
359 | { | 358 | { |
360 | double z; | 359 | double z; |
361 | double xx,y,ans,ans1,ans2; | 360 | double xx,y,ans,ans1,ans2; |
362 | if (x < 8.0) | 361 | if (x < 8.0) |
363 | { | 362 | { |
364 | y=x*x; | 363 | y=x*x; |
365 | ans1 = -2957821389.0+y*(7062834065.0+y*(-512359803.6 +y*(10879881.29+y*(-86327.92757+y*228.4622733)))); | 364 | ans1 = -2957821389.0+y*(7062834065.0+y*(-512359803.6 +y*(10879881.29+y*(-86327.92757+y*228.4622733)))); |
366 | ans2=40076544269.0+y*(745249964.8+y*(7189466.438 +y*(47447.26470+y*(226.1030244+y*1.0)))); | 365 | ans2=40076544269.0+y*(745249964.8+y*(7189466.438 +y*(47447.26470+y*(226.1030244+y*1.0)))); |
367 | ans=(ans1/ans2)+0.636619772*BesselJ0(x)*log(x); | 366 | ans=(ans1/ans2)+0.636619772*BesselJ0(x)*log(x); |
368 | } else | 367 | } else |
369 | { | 368 | { |
370 | z=8.0/x; | 369 | z=8.0/x; |
371 | y=z*z; | 370 | y=z*z; |
372 | xx=x-0.785398164; | 371 | xx=x-0.785398164; |
373 | ans1=1.0+y*(-0.1098628627e-2+y*(0.2734510407e-4 +y*(-0.2073370639e-5+y*0.2093887211e-6))); | 372 | ans1=1.0+y*(-0.1098628627e-2+y*(0.2734510407e-4 +y*(-0.2073370639e-5+y*0.2093887211e-6))); |
374 | ans2 = -0.1562499995e-1+y*(0.1430488765e-3 +y*(-0.6911147651e-5+y*(0.7621095161e-6 +y*(-0.934945152e-7)))); | 373 | ans2 = -0.1562499995e-1+y*(0.1430488765e-3 +y*(-0.6911147651e-5+y*(0.7621095161e-6 +y*(-0.934945152e-7)))); |
375 | ans=sqrt(0.636619772/x)*(sin(xx)*ans1+z*cos(xx)*ans2); | 374 | ans=sqrt(0.636619772/x)*(sin(xx)*ans1+z*cos(xx)*ans2); |
376 | } | 375 | } |
377 | return ans; | 376 | return ans; |
378 | }; | 377 | }; |
379 | 378 | ||
380 | double Sheet::BesselJ1(double x) | 379 | double Sheet::BesselJ1(double x) |
381 | { | 380 | { |
382 | double ax,z; | 381 | double ax,z; |
383 | double xx,y,ans,ans1,ans2; | 382 | double xx,y,ans,ans1,ans2; |
384 | if ((ax=fabs(x)) < 8.0) | 383 | if ((ax=fabs(x)) < 8.0) |
385 | { | 384 | { |
386 | y=x*x; | 385 | y=x*x; |
387 | ans1=x*(72362614232.0+y*(-7895059235.0+y*(242396853.1 +y*(-2972611.439+y*(15704.48260+y*(-30.16036606)))))); | 386 | ans1=x*(72362614232.0+y*(-7895059235.0+y*(242396853.1 +y*(-2972611.439+y*(15704.48260+y*(-30.16036606)))))); |
388 | ans2=144725228442.0+y*(2300535178.0+y*(18583304.74 +y*(99447.43394+y*(376.9991397+y*1.0)))); | 387 | ans2=144725228442.0+y*(2300535178.0+y*(18583304.74 +y*(99447.43394+y*(376.9991397+y*1.0)))); |
389 | ans=ans1/ans2; | 388 | ans=ans1/ans2; |
390 | } else | 389 | } else |
391 | { | 390 | { |
392 | z=8.0/ax; y=z*z; xx=ax-2.356194491; | 391 | z=8.0/ax; y=z*z; xx=ax-2.356194491; |
393 | ans1=1.0+y*(0.183105e-2+y*(-0.3516396496e-4 +y*(0.2457520174e-5+y*(-0.240337019e-6)))); | 392 | ans1=1.0+y*(0.183105e-2+y*(-0.3516396496e-4 +y*(0.2457520174e-5+y*(-0.240337019e-6)))); |
394 | ans2=0.04687499995+y*(-0.2002690873e-3 +y*(0.8449199096e-5+y*(-0.88228987e-6 +y*0.105787412e-6))); | 393 | ans2=0.04687499995+y*(-0.2002690873e-3 +y*(0.8449199096e-5+y*(-0.88228987e-6 +y*0.105787412e-6))); |
395 | ans=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2); | 394 | ans=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2); |
396 | if (x < 0.0) ans = -ans; | 395 | if (x < 0.0) ans = -ans; |
397 | } | 396 | } |
398 | return ans; | 397 | return ans; |
399 | }; | 398 | }; |
400 | 399 | ||
401 | double Sheet::BesselY1(double x) | 400 | double Sheet::BesselY1(double x) |
402 | { | 401 | { |
403 | double z; | 402 | double z; |
404 | double xx,y,ans,ans1,ans2; | 403 | double xx,y,ans,ans1,ans2; |
405 | if (x < 8.0) | 404 | if (x < 8.0) |
406 | { | 405 | { |
407 | y=x*x; | 406 | y=x*x; |
408 | ans1=x*(-0.4900604943e13+y*(0.1275274390e13 +y*(-0.5153438139e11+y*(0.7349264551e9 +y*(-0.4237922726e7+y*0.8511937935e4))))); | 407 | ans1=x*(-0.4900604943e13+y*(0.1275274390e13 +y*(-0.5153438139e11+y*(0.7349264551e9 +y*(-0.4237922726e7+y*0.8511937935e4))))); |
409 | ans2=0.2499580570e14+y*(0.4244419664e12 +y*(0.3733650367e10+y*(0.2245904002e8 +y*(0.1020426050e6+y*(0.3549632885e3+y))))); | 408 | ans2=0.2499580570e14+y*(0.4244419664e12 +y*(0.3733650367e10+y*(0.2245904002e8 +y*(0.1020426050e6+y*(0.3549632885e3+y))))); |
410 | ans=(ans1/ans2)+0.636619772*(BesselJ1(x)*log(x)-1.0/x); | 409 | ans=(ans1/ans2)+0.636619772*(BesselJ1(x)*log(x)-1.0/x); |
411 | } else | 410 | } else |
412 | { | 411 | { |
413 | z=8.0/x; | 412 | z=8.0/x; |
414 | y=z*z; | 413 | y=z*z; |
415 | xx=x-2.356194491; | 414 | xx=x-2.356194491; |
416 | ans1=1.0+y*(0.183105e-2+y*(-0.3516396496e-4 +y*(0.2457520174e-5+y*(-0.240337019e-6)))); | 415 | ans1=1.0+y*(0.183105e-2+y*(-0.3516396496e-4 +y*(0.2457520174e-5+y*(-0.240337019e-6)))); |
417 | ans2=0.04687499995+y*(-0.2002690873e-3 +y*(0.8449199096e-5+y*(-0.88228987e-6 +y*0.105787412e-6))); | 416 | ans2=0.04687499995+y*(-0.2002690873e-3 +y*(0.8449199096e-5+y*(-0.88228987e-6 +y*0.105787412e-6))); |
418 | ans=sqrt(0.636619772/x)*(sin(xx)*ans1+z*cos(xx)*ans2); | 417 | ans=sqrt(0.636619772/x)*(sin(xx)*ans1+z*cos(xx)*ans2); |
419 | } | 418 | } |
420 | return ans; | 419 | return ans; |
421 | }; | 420 | }; |
422 | 421 | ||
423 | double Sheet::BesselY(int n, double x) | 422 | double Sheet::BesselY(int n, double x) |
424 | { | 423 | { |
425 | int j; | 424 | int j; |
426 | double by,bym,byp,tox; | 425 | double by,bym,byp,tox; |
427 | if (n < 2) return 0.0; | 426 | if (n < 2) return 0.0; |
428 | tox=2.0/x; | 427 | tox=2.0/x; |
429 | by=BesselY1(x); | 428 | by=BesselY1(x); |
430 | bym=BesselY0(x); | 429 | bym=BesselY0(x); |
431 | for (j=1;j<n;j++) | 430 | for (j=1;j<n;j++) |
432 | { | 431 | { |
433 | byp=j*tox*by-bym; | 432 | byp=j*tox*by-bym; |
434 | bym=by; | 433 | bym=by; |
435 | by=byp; | 434 | by=byp; |
436 | } | 435 | } |
437 | return by; | 436 | return by; |
438 | }; | 437 | }; |
439 | 438 | ||
440 | double Sheet::BesselJ(int n, double x) | 439 | double Sheet::BesselJ(int n, double x) |
441 | { | 440 | { |
442 | double ACC=40.0; | 441 | double ACC=40.0; |
443 | double BIGNO=1.0e10; | 442 | double BIGNO=1.0e10; |
444 | double BIGNI=1.0e-10; | 443 | double BIGNI=1.0e-10; |
445 | int j,jsum,m; | 444 | int j,jsum,m; |
446 | double ax,bj,bjm,bjp,sum,tox,ans; | 445 | double ax,bj,bjm,bjp,sum,tox,ans; |
447 | if (n < 2) return 0.0; | 446 | if (n < 2) return 0.0; |
448 | ax=fabs(x); | 447 | ax=fabs(x); |
449 | if (ax == 0.0) return 0.0; | 448 | if (ax == 0.0) return 0.0; |
450 | else if (ax > (double) n) | 449 | else if (ax > (double) n) |
451 | { | 450 | { |
452 | tox=2.0/ax; | 451 | tox=2.0/ax; |
453 | bjm=BesselJ0(ax); | 452 | bjm=BesselJ0(ax); |
454 | bj=BesselJ1(ax); | 453 | bj=BesselJ1(ax); |
455 | for (j=1;j<n;j++) | 454 | for (j=1;j<n;j++) |
456 | { | 455 | { |
457 | bjp=j*tox*bj-bjm; | 456 | bjp=j*tox*bj-bjm; |
458 | bjm=bj; | 457 | bjm=bj; |
459 | bj=bjp; | 458 | bj=bjp; |
460 | } | 459 | } |
461 | ans=bj; | 460 | ans=bj; |
462 | } else | 461 | } else |
463 | { | 462 | { |
464 | tox=2.0/ax; | 463 | tox=2.0/ax; |
465 | m=2*((n+(int) sqrt(ACC*n))/2); | 464 | m=2*((n+(int) sqrt(ACC*n))/2); |
466 | jsum=0; | 465 | jsum=0; |
467 | bjp=ans=sum=0.0; | 466 | bjp=ans=sum=0.0; |
468 | bj=1.0; | 467 | bj=1.0; |
469 | for (j=m;j>0;j--) | 468 | for (j=m;j>0;j--) |
470 | { | 469 | { |
471 | bjm=j*tox*bj-bjp; | 470 | bjm=j*tox*bj-bjp; |
472 | bjp=bj; | 471 | bjp=bj; |
473 | bj=bjm; | 472 | bj=bjm; |
474 | if (fabs(bj) > BIGNO) | 473 | if (fabs(bj) > BIGNO) |
475 | { | 474 | { |
476 | bj *= BIGNI; | 475 | bj *= BIGNI; |
477 | bjp *= BIGNI; | 476 | bjp *= BIGNI; |
478 | ans *= BIGNI; | 477 | ans *= BIGNI; |
479 | sum *= BIGNI; | 478 | sum *= BIGNI; |
480 | } | 479 | } |
481 | if (jsum) sum += bj; | 480 | if (jsum) sum += bj; |
482 | jsum=!jsum; | 481 | jsum=!jsum; |
483 | if (j == n) ans=bjp; | 482 | if (j == n) ans=bjp; |
484 | } | 483 | } |
485 | sum=2.0*sum-bj; | 484 | sum=2.0*sum-bj; |
486 | ans /= sum; | 485 | ans /= sum; |
487 | } | 486 | } |
488 | return x < 0.0 && (n & 1) ? -ans : ans; | 487 | return x < 0.0 && (n & 1) ? -ans : ans; |
489 | }; | 488 | }; |
490 | 489 | ||
491 | double Sheet::GammaLn(double xx) | 490 | double Sheet::GammaLn(double xx) |
492 | { | 491 | { |
493 | double x,y,tmp,ser; | 492 | double x,y,tmp,ser; |
494 | static double cof[6]={76.18009172947146,-86.50532032941677, 24.01409824083091,-1.231739572450155, 0.1208650973866179e-2,-0.5395239384953e-5}; | 493 | static double cof[6]={76.18009172947146,-86.50532032941677, 24.01409824083091,-1.231739572450155, 0.1208650973866179e-2,-0.5395239384953e-5}; |
495 | int j; | 494 | int j; |
496 | y=x=xx; | 495 | y=x=xx; |
497 | tmp=x+5.5; | 496 | tmp=x+5.5; |
498 | tmp -= (x+0.5)*log(tmp); | 497 | tmp -= (x+0.5)*log(tmp); |
499 | ser=1.000000000190015; | 498 | ser=1.000000000190015; |
500 | for (j=0;j<=5;j++) ser += cof[j]/++y; | 499 | for (j=0;j<=5;j++) ser += cof[j]/++y; |
501 | return -tmp+log(2.5066282746310005*ser/x); | 500 | return -tmp+log(2.5066282746310005*ser/x); |
502 | }; | 501 | }; |
503 | 502 | ||
504 | double Sheet::Factorial(double n) | 503 | double Sheet::Factorial(double n) |
505 | { | 504 | { |
506 | if (n < 0) return 0.0; | 505 | if (n < 0) return 0.0; |
507 | if (n > 100) return 0.0; | 506 | if (n > 100) return 0.0; |
508 | return exp(GammaLn(n+1.0)); | 507 | return exp(GammaLn(n+1.0)); |
509 | }; | 508 | }; |
510 | 509 | ||
511 | double Sheet::GammaP(double a, double x) | 510 | double Sheet::GammaP(double a, double x) |
512 | { | 511 | { |
513 | // returns GammaP(a,x) | 512 | // returns GammaP(a,x) |
514 | //void gcf(float *gammcf, float a, float x, float *gln); | 513 | //void gcf(float *gammcf, float a, float x, float *gln); |
515 | //void gser(float *gamser, float a, float x, float *gln); | 514 | //void gser(float *gamser, float a, float x, float *gln); |
516 | double gamser,gammcf,gln; | 515 | double gamser,gammcf,gln; |
517 | if (x < 0.0 || a <= 0.0) return 0.0;//error | 516 | if (x < 0.0 || a <= 0.0) return 0.0;//error |
518 | if (x < (a+1.0)) | 517 | if (x < (a+1.0)) |
519 | { | 518 | { |
520 | GammaSeries(&gamser,a,x,&gln); | 519 | GammaSeries(&gamser,a,x,&gln); |
521 | return gamser; | 520 | return gamser; |
522 | }else | 521 | }else |
523 | { | 522 | { |
524 | GammaContinuedFraction(&gammcf,a,x,&gln); | 523 | GammaContinuedFraction(&gammcf,a,x,&gln); |
525 | return 1.0-gammcf; | 524 | return 1.0-gammcf; |
526 | } | 525 | } |
527 | }; | 526 | }; |
528 | 527 | ||
529 | double Sheet::GammaQ(double a,double x) | 528 | double Sheet::GammaQ(double a,double x) |
530 | { | 529 | { |
531 | //returns GammaQ(a,x)=1.0 - GammaP(a,x); | 530 | //returns GammaQ(a,x)=1.0 - GammaP(a,x); |
532 | return (1.0-GammaP(a,x)); | 531 | return (1.0-GammaP(a,x)); |
533 | }; | 532 | }; |
534 | 533 | ||
535 | 534 | ||
536 | void Sheet::GammaSeries(double *gamser, double a, double x, double *gln) | 535 | void Sheet::GammaSeries(double *gamser, double a, double x, double *gln) |
537 | { | 536 | { |
538 | double EPS=3.0e-7; | 537 | double EPS=3.0e-7; |
539 | int ITMAX=100; | 538 | int ITMAX=100; |
540 | int n; | 539 | int n; |
541 | double sum,del,ap; | 540 | double sum,del,ap; |
542 | *gln=GammaLn(a); | 541 | *gln=GammaLn(a); |
543 | if (x <= 0.0) | 542 | if (x <= 0.0) |
544 | { | 543 | { |
545 | if (x < 0.0) return;//error | 544 | if (x < 0.0) return;//error |
546 | *gamser=0.0; | 545 | *gamser=0.0; |
547 | return; | 546 | return; |
548 | } else | 547 | } else |
549 | { | 548 | { |
550 | ap=a; | 549 | ap=a; |
551 | del=sum=1.0/a; | 550 | del=sum=1.0/a; |
552 | for (n=1;n<=ITMAX;n++) | 551 | for (n=1;n<=ITMAX;n++) |
553 | { | 552 | { |
554 | ++ap; | 553 | ++ap; |
555 | del *= x/ap; | 554 | del *= x/ap; |
556 | sum += del; | 555 | sum += del; |
557 | if (fabs(del) < fabs(sum)*EPS) | 556 | if (fabs(del) < fabs(sum)*EPS) |
558 | { | 557 | { |
559 | *gamser=sum*exp(-x+a*log(x)-(*gln)); | 558 | *gamser=sum*exp(-x+a*log(x)-(*gln)); |
560 | return; | 559 | return; |
561 | } | 560 | } |
562 | } return; | 561 | } return; |
563 | return; | 562 | return; |
564 | } | 563 | } |
565 | }; | 564 | }; |
566 | 565 | ||
567 | 566 | ||
568 | void Sheet::GammaContinuedFraction(double *gammcf, double a, double x, double *gln) | 567 | void Sheet::GammaContinuedFraction(double *gammcf, double a, double x, double *gln) |
569 | { | 568 | { |
570 | double EPS=3.0e-7; | 569 | double EPS=3.0e-7; |
571 | double FPMIN=1.0e-30; | 570 | double FPMIN=1.0e-30; |
572 | int ITMAX=100; | 571 | int ITMAX=100; |
573 | int i; | 572 | int i; |
574 | double an,b,c,d,del,h; | 573 | double an,b,c,d,del,h; |
575 | *gln=GammaLn(a); | 574 | *gln=GammaLn(a); |
576 | b=x+1.0-a; | 575 | b=x+1.0-a; |
577 | c=1.0/FPMIN; | 576 | c=1.0/FPMIN; |
578 | d=1.0/b; h=d; | 577 | d=1.0/b; h=d; |
579 | for (i=1;i<=ITMAX;i++) | 578 | for (i=1;i<=ITMAX;i++) |
580 | { | 579 | { |
581 | an = -i*(i-a); | 580 | an = -i*(i-a); |
582 | b += 2.0; d=an*d+b; | 581 | b += 2.0; d=an*d+b; |
583 | if (fabs(d) < FPMIN) d=FPMIN; | 582 | if (fabs(d) < FPMIN) d=FPMIN; |
584 | c=b+an/c; | 583 | c=b+an/c; |
585 | if (fabs(c) < FPMIN) c=FPMIN; | 584 | if (fabs(c) < FPMIN) c=FPMIN; |
586 | d=1.0/d; del=d*c; h *= del; | 585 | d=1.0/d; del=d*c; h *= del; |
587 | if (fabs(del-1.0) < EPS) break; | 586 | if (fabs(del-1.0) < EPS) break; |
588 | } | 587 | } |
589 | if (i > ITMAX) return; | 588 | if (i > ITMAX) return; |
590 | *gammcf=exp(-x+a*log(x)-(*gln))*h; | 589 | *gammcf=exp(-x+a*log(x)-(*gln))*h; |
591 | }; | 590 | }; |
592 | 591 | ||
593 | double Sheet::ErrorFunction(double x) | 592 | double Sheet::ErrorFunction(double x) |
594 | { | 593 | { |
595 | return x < 0.0 ? -GammaP(0.5,x*x) : GammaP(0.5,x*x); | 594 | return x < 0.0 ? -GammaP(0.5,x*x) : GammaP(0.5,x*x); |
596 | }; | 595 | }; |
597 | 596 | ||
598 | double Sheet::ErrorFunctionComplementary(double x) | 597 | double Sheet::ErrorFunctionComplementary(double x) |
599 | { | 598 | { |
600 | return x < 0.0 ? 1.0+GammaP(0.5,x*x) : GammaQ(0.5,x*x); | 599 | return x < 0.0 ? 1.0+GammaP(0.5,x*x) : GammaQ(0.5,x*x); |
601 | }; | 600 | }; |
602 | 601 | ||
603 | double Sheet::Beta(double z, double w) | 602 | double Sheet::Beta(double z, double w) |
604 | { | 603 | { |
605 | return exp(GammaLn(z)+GammaLn(w)-GammaLn(z+w)); | 604 | return exp(GammaLn(z)+GammaLn(w)-GammaLn(z+w)); |
606 | }; | 605 | }; |
607 | 606 | ||
608 | 607 | ||
609 | double Sheet::BetaContinuedFraction(double a, double b, double x) | 608 | double Sheet::BetaContinuedFraction(double a, double b, double x) |
610 | { | 609 | { |
611 | int MAXIT=100; | 610 | int MAXIT=100; |
612 | double EPS=3.0e-7; | 611 | double EPS=3.0e-7; |
613 | double FPMIN=1.0e-30; | 612 | double FPMIN=1.0e-30; |
614 | int m,m2; | 613 | int m,m2; |
615 | double aa,c,d,del,h,qab,qam,qap; | 614 | double aa,c,d,del,h,qab,qam,qap; |
616 | qab=a+b; | 615 | qab=a+b; |
617 | qap=a+1.0; qam=a-1.0; c=1.0; | 616 | qap=a+1.0; qam=a-1.0; c=1.0; |
618 | d=1.0-qab*x/qap; | 617 | d=1.0-qab*x/qap; |
619 | if (fabs(d) < FPMIN) d=FPMIN; | 618 | if (fabs(d) < FPMIN) d=FPMIN; |
620 | d=1.0/d; h=d; | 619 | d=1.0/d; h=d; |
621 | for (m=1;m<=MAXIT;m++) | 620 | for (m=1;m<=MAXIT;m++) |
622 | { | 621 | { |
623 | m2=2*m; aa=m*(b-m)*x/((qam+m2)*(a+m2)); | 622 | m2=2*m; aa=m*(b-m)*x/((qam+m2)*(a+m2)); |
624 | d=1.0+aa*d; | 623 | d=1.0+aa*d; |
625 | if (fabs(d) < FPMIN) d=FPMIN; | 624 | if (fabs(d) < FPMIN) d=FPMIN; |
626 | c=1.0+aa/c; | 625 | c=1.0+aa/c; |
627 | if (fabs(c) < FPMIN) c=FPMIN; | 626 | if (fabs(c) < FPMIN) c=FPMIN; |
628 | d=1.0/d; h *= d*c; | 627 | d=1.0/d; h *= d*c; |
629 | aa = -(a+m)*(qab+m)*x/((a+m2)*(qap+m2)); d=1.0+aa*d; | 628 | aa = -(a+m)*(qab+m)*x/((a+m2)*(qap+m2)); d=1.0+aa*d; |
630 | if (fabs(d) < FPMIN) d=FPMIN; | 629 | if (fabs(d) < FPMIN) d=FPMIN; |
631 | c=1.0+aa/c; | 630 | c=1.0+aa/c; |
632 | if (fabs(c) < FPMIN) c=FPMIN; d=1.0/d; | 631 | if (fabs(c) < FPMIN) c=FPMIN; d=1.0/d; |
633 | del=d*c; h *= del; | 632 | del=d*c; h *= del; |
634 | if (fabs(del-1.0) < EPS) break; | 633 | if (fabs(del-1.0) < EPS) break; |
635 | } | 634 | } |
636 | if (m > MAXIT) return 0.0; | 635 | if (m > MAXIT) return 0.0; |
637 | return h; | 636 | return h; |
638 | }; | 637 | }; |
639 | 638 | ||
640 | double Sheet::BetaIncomplete(double a, double b, double x) | 639 | double Sheet::BetaIncomplete(double a, double b, double x) |
641 | { | 640 | { |
642 | double bt; | 641 | double bt; |
643 | if (x < 0.0 || x > 1.0) return 0.0; | 642 | if (x < 0.0 || x > 1.0) return 0.0; |
644 | if (x == 0.0 || x == 1.0) bt=0.0; else | 643 | if (x == 0.0 || x == 1.0) bt=0.0; else |
645 | bt=exp(GammaLn(a+b)-GammaLn(a)-GammaLn(b)+a*log(x)+b*log(1.0-x)); | 644 | bt=exp(GammaLn(a+b)-GammaLn(a)-GammaLn(b)+a*log(x)+b*log(1.0-x)); |
646 | if (x < (a+1.0)/(a+b+2.0)) return bt*BetaContinuedFraction(a,b,x)/a; else | 645 | if (x < (a+1.0)/(a+b+2.0)) return bt*BetaContinuedFraction(a,b,x)/a; else |
647 | return 1.0-bt*BetaContinuedFraction(b,a,1.0-x)/b; | 646 | return 1.0-bt*BetaContinuedFraction(b,a,1.0-x)/b; |
648 | }; | 647 | }; |
649 | 648 | ||
650 | 649 | ||
651 | 650 | ||
652 | double Sheet::functionSum(const QString ¶m1, const QString ¶m2) | 651 | double Sheet::functionSum(const QString ¶m1, const QString ¶m2) |
653 | { | 652 | { |
654 | int row1, col1, row2, col2, row, col; | 653 | int row1, col1, row2, col2, row, col; |
655 | double result=0, tempResult; | 654 | double result=0, tempResult; |
656 | bool ok; | 655 | bool ok; |
657 | if (findRange(param1, param2, &row1, &col1, &row2, &col2)) | 656 | if (findRange(param1, param2, &row1, &col1, &row2, &col2)) |
658 | { | 657 | { |
659 | for (row=row1; row<=row2; ++row) | 658 | for (row=row1; row<=row2; ++row) |
660 | for (col=col1; col<=col2; ++col) | 659 | for (col=col1; col<=col2; ++col) |
661 | { | 660 | { |
662 | tempResult=text(row, col).toDouble(&ok); | 661 | tempResult=text(row, col).toDouble(&ok); |
663 | if (ok) result+=tempResult; | 662 | if (ok) result+=tempResult; |
664 | } | 663 | } |
665 | return result; | 664 | return result; |
666 | }else | 665 | }else |
667 | { | 666 | { |
668 | double d1=0,d2=0; | 667 | double d1=0,d2=0; |
669 | d1=calculateVariable(param1).toDouble(&ok); | 668 | d1=calculateVariable(param1).toDouble(&ok); |
670 | d2=calculateVariable(param2).toDouble(&ok); | 669 | d2=calculateVariable(param2).toDouble(&ok); |
671 | return(d1+d2); | 670 | return(d1+d2); |
672 | }; | 671 | }; |
673 | return 0; | 672 | return 0; |
674 | } | 673 | } |
675 | 674 | ||
676 | QString Sheet::functionIndex(const QString ¶m1, const QString ¶m2, int indx) | 675 | QString Sheet::functionIndex(const QString ¶m1, const QString ¶m2, int indx) |
677 | { | 676 | { |
678 | int row1, col1, row2, col2, row, col; | 677 | int row1, col1, row2, col2, row, col; |
679 | if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; | 678 | if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; |
680 | int ii=1; | 679 | int ii=1; |
681 | for (col=col1; col<=col2; ++col) | 680 | for (col=col1; col<=col2; ++col) |
682 | for (row=row1; row<=row2; ++row) | 681 | for (row=row1; row<=row2; ++row) |
683 | { | 682 | { |
684 | if(ii==indx) return text(row,col); | 683 | if(ii==indx) return text(row,col); |
685 | ii++; | 684 | ii++; |
686 | } | 685 | } |
687 | return QString(""); | 686 | return QString(""); |
688 | } | 687 | } |
689 | 688 | ||
690 | 689 | ||
691 | 690 | ||
692 | double Sheet::functionVariancePopulation(const QString ¶m1, const QString ¶m2) | 691 | double Sheet::functionVariancePopulation(const QString ¶m1, const QString ¶m2) |
693 | { | 692 | { |
694 | int row1, col1, row2, col2, row, col; | 693 | int row1, col1, row2, col2, row, col; |
695 | if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; | 694 | if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; |
696 | double avg1=functionAvg(param1,param2); | 695 | double avg1=functionAvg(param1,param2); |
697 | double result=0, tempResult; | 696 | double result=0, tempResult; |
698 | int count1=0; | 697 | int count1=0; |
699 | bool ok; | 698 | bool ok; |
700 | for (row=row1; row<=row2; ++row) | 699 | for (row=row1; row<=row2; ++row) |
701 | for (col=col1; col<=col2; ++col) | 700 | for (col=col1; col<=col2; ++col) |
702 | { | 701 | { |
703 | tempResult=text(row, col).toDouble(&ok); | 702 | tempResult=text(row, col).toDouble(&ok); |
704 | if (ok) { result=result + (tempResult - avg1)*(tempResult - avg1); count1++;}; | 703 | if (ok) { result=result + (tempResult - avg1)*(tempResult - avg1); count1++;}; |
705 | } | 704 | } |
706 | if(count1>0) result=result/double(count1); else result=0.0; | 705 | if(count1>0) result=result/double(count1); else result=0.0; |
707 | return result; | 706 | return result; |
708 | }; | 707 | }; |
709 | 708 | ||
710 | double Sheet::functionVariance(const QString ¶m1, const QString ¶m2) | 709 | double Sheet::functionVariance(const QString ¶m1, const QString ¶m2) |
711 | { | 710 | { |
712 | int row1, col1, row2, col2, row, col; | 711 | int row1, col1, row2, col2, row, col; |
713 | if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; | 712 | if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; |
714 | double avg1=functionAvg(param1,param2); | 713 | double avg1=functionAvg(param1,param2); |
715 | double result=0, tempResult; | 714 | double result=0, tempResult; |
716 | int count1=0; | 715 | int count1=0; |
717 | bool ok; | 716 | bool ok; |
718 | for (row=row1; row<=row2; ++row) | 717 | for (row=row1; row<=row2; ++row) |
719 | for (col=col1; col<=col2; ++col) | 718 | for (col=col1; col<=col2; ++col) |
720 | { | 719 | { |
721 | tempResult=text(row, col).toDouble(&ok); | 720 | tempResult=text(row, col).toDouble(&ok); |
722 | if (ok) { result=result + (tempResult - avg1)*(tempResult - avg1); count1++;}; | 721 | if (ok) { result=result + (tempResult - avg1)*(tempResult - avg1); count1++;}; |
723 | } | 722 | } |
724 | if(count1>1) result=result/double(count1-1); else result=0.0; | 723 | if(count1>1) result=result/double(count1-1); else result=0.0; |
725 | return result; | 724 | return result; |
726 | }; | 725 | }; |
727 | 726 | ||
728 | double Sheet::functionSkew(const QString ¶m1, const QString ¶m2) | 727 | double Sheet::functionSkew(const QString ¶m1, const QString ¶m2) |
729 | { | 728 | { |
730 | int row1, col1, row2, col2, row, col; | 729 | int row1, col1, row2, col2, row, col; |
731 | if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; | 730 | if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; |
732 | double avg1=functionAvg(param1,param2); | 731 | double avg1=functionAvg(param1,param2); |
733 | double var1=sqrt(functionVariancePopulation(param1,param2)); | 732 | double var1=sqrt(functionVariancePopulation(param1,param2)); |
734 | if(var1==0.0) return 0.0; | 733 | if(var1==0.0) return 0.0; |
735 | double result=0, tempResult; | 734 | double result=0, tempResult; |
736 | int count1=0; | 735 | int count1=0; |
737 | bool ok; | 736 | bool ok; |
738 | for (row=row1; row<=row2; ++row) | 737 | for (row=row1; row<=row2; ++row) |
739 | for (col=col1; col<=col2; ++col) | 738 | for (col=col1; col<=col2; ++col) |
740 | { | 739 | { |
741 | tempResult=text(row, col).toDouble(&ok); | 740 | tempResult=text(row, col).toDouble(&ok); |
742 | if (ok) | 741 | if (ok) |
743 | { | 742 | { |
744 | result=result + (tempResult - avg1)*(tempResult - avg1)*(tempResult - avg1)/(var1*var1*var1); | 743 | result=result + (tempResult - avg1)*(tempResult - avg1)*(tempResult - avg1)/(var1*var1*var1); |
745 | count1++; | 744 | count1++; |
746 | }; | 745 | }; |
747 | } | 746 | } |
748 | if(count1>0) result=result/double(count1); else result=0.0; | 747 | if(count1>0) result=result/double(count1); else result=0.0; |
749 | return result; | 748 | return result; |
750 | }; | 749 | }; |
751 | 750 | ||
752 | double Sheet::functionKurt(const QString ¶m1, const QString ¶m2) | 751 | double Sheet::functionKurt(const QString ¶m1, const QString ¶m2) |
753 | { | 752 | { |
754 | int row1, col1, row2, col2, row, col; | 753 | int row1, col1, row2, col2, row, col; |
755 | if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; | 754 | if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; |
756 | double avg1=functionAvg(param1,param2); | 755 | double avg1=functionAvg(param1,param2); |
757 | double var1=sqrt(functionVariancePopulation(param1,param2)); | 756 | double var1=sqrt(functionVariancePopulation(param1,param2)); |
758 | if(var1==0.0) return 0.0; | 757 | if(var1==0.0) return 0.0; |
759 | double result=0, tempResult; | 758 | double result=0, tempResult; |
760 | int count1=0; | 759 | int count1=0; |
761 | bool ok; | 760 | bool ok; |
762 | for (row=row1; row<=row2; ++row) | 761 | for (row=row1; row<=row2; ++row) |
763 | for (col=col1; col<=col2; ++col) | 762 | for (col=col1; col<=col2; ++col) |
764 | { | 763 | { |
765 | tempResult=text(row, col).toDouble(&ok); | 764 | tempResult=text(row, col).toDouble(&ok); |
766 | if (ok) | 765 | if (ok) |
767 | { | 766 | { |
768 | result=result + (tempResult - avg1)*(tempResult - avg1)* | 767 | result=result + (tempResult - avg1)*(tempResult - avg1)* |
769 | (tempResult - avg1)*(tempResult - avg1)/(var1*var1*var1*var1); | 768 | (tempResult - avg1)*(tempResult - avg1)/(var1*var1*var1*var1); |
770 | count1++; | 769 | count1++; |
771 | }; | 770 | }; |
772 | } | 771 | } |
773 | if(count1>0) result=result/double(count1)-3.0; else result=0.0; | 772 | if(count1>0) result=result/double(count1)-3.0; else result=0.0; |
774 | return result; | 773 | return result; |
775 | }; | 774 | }; |
776 | 775 | ||
777 | 776 | ||
778 | 777 | ||
779 | double Sheet::functionSumSQ(const QString ¶m1, const QString ¶m2) | 778 | double Sheet::functionSumSQ(const QString ¶m1, const QString ¶m2) |
780 | { | 779 | { |
781 | int row1, col1, row2, col2, row, col; | 780 | int row1, col1, row2, col2, row, col; |
782 | double result=0, tempResult; | 781 | double result=0, tempResult; |
783 | bool ok; | 782 | bool ok; |
784 | if (findRange(param1, param2, &row1, &col1, &row2, &col2)) | 783 | if (findRange(param1, param2, &row1, &col1, &row2, &col2)) |
785 | { | 784 | { |