author | zecke <zecke> | 2002-11-03 11:11:00 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-11-03 11:11:00 (UTC) |
commit | d26f82ea57c70fd0e77eb192f7e133c5f76c2f0f (patch) (unidiff) | |
tree | 16240b40b1be5b581dc2fb7e1a0c18239c3dc4fd | |
parent | eac6c5d3a22147d78866122c2f5b89d3fdf6bfc6 (diff) | |
download | opie-d26f82ea57c70fd0e77eb192f7e133c5f76c2f0f.zip opie-d26f82ea57c70fd0e77eb192f7e133c5f76c2f0f.tar.gz opie-d26f82ea57c70fd0e77eb192f7e133c5f76c2f0f.tar.bz2 |
Gcc3 compiler fixes again
No default arguments in the implementation please
-rw-r--r-- | noncore/apps/opie-reader/Bkmks.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/CBuffer.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-reader/CDrawBuffer.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/QTReader.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/infowin.cpp | 2 |
6 files changed, 7 insertions, 7 deletions
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp index 0cb9ea9..30d2881 100644 --- a/noncore/apps/opie-reader/Bkmks.cpp +++ b/noncore/apps/opie-reader/Bkmks.cpp | |||
@@ -1,240 +1,240 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | 2 | ||
3 | #include "Bkmks.h" | 3 | #include "Bkmks.h" |
4 | 4 | ||
5 | #include "StyleConsts.h" | 5 | #include "StyleConsts.h" |
6 | #include "Markups.h" | 6 | #include "Markups.h" |
7 | #include "my_list.h" | 7 | #include "my_list.h" |
8 | #include "version.h" | 8 | #include "version.h" |
9 | 9 | ||
10 | const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); | 10 | const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); |
11 | 11 | ||
12 | 12 | ||
13 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) | 13 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) |
14 | { | 14 | { |
15 | int len = ustrlen(_nm)+1; | 15 | int len = ustrlen(_nm)+1; |
16 | m_name = new tchar[len]; | 16 | m_name = new tchar[len]; |
17 | for (int i = 0; i < len; i++) m_name[i] = _nm[i]; | 17 | for (int i = 0; i < len; i++) m_name[i] = _nm[i]; |
18 | 18 | ||
19 | if (_anno == NULL) | 19 | if (_anno == NULL) |
20 | { | 20 | { |
21 | m_anno = new tchar[1]; | 21 | m_anno = new tchar[1]; |
22 | m_anno[0] = 0; | 22 | m_anno[0] = 0; |
23 | } | 23 | } |
24 | else | 24 | else |
25 | { | 25 | { |
26 | len = ustrlen(_anno)+1; | 26 | len = ustrlen(_anno)+1; |
27 | m_anno = new tchar[len]; | 27 | m_anno = new tchar[len]; |
28 | for (int i = 0; i < len; i++) m_anno[i] = _anno[i]; | 28 | for (int i = 0; i < len; i++) m_anno[i] = _anno[i]; |
29 | } | 29 | } |
30 | } | 30 | } |
31 | 31 | ||
32 | Bkmk::~Bkmk() | 32 | Bkmk::~Bkmk() |
33 | { | 33 | { |
34 | if (m_name != NULL) delete [] m_name; | 34 | if (m_name != NULL) delete [] m_name; |
35 | m_name = NULL; | 35 | m_name = NULL; |
36 | if (m_anno != NULL) delete [] m_anno; | 36 | if (m_anno != NULL) delete [] m_anno; |
37 | m_anno = NULL; | 37 | m_anno = NULL; |
38 | } | 38 | } |
39 | 39 | ||
40 | Bkmk& Bkmk::operator=(const Bkmk& rhs) | 40 | Bkmk& Bkmk::operator=(const Bkmk& rhs) |
41 | { | 41 | { |
42 | if (m_name != NULL) | 42 | if (m_name != NULL) |
43 | { | 43 | { |
44 | delete [] m_name; | 44 | delete [] m_name; |
45 | m_name = NULL; | 45 | m_name = NULL; |
46 | } | 46 | } |
47 | if (m_anno != NULL) | 47 | if (m_anno != NULL) |
48 | { | 48 | { |
49 | delete [] m_anno; | 49 | delete [] m_anno; |
50 | m_anno = NULL; | 50 | m_anno = NULL; |
51 | } | 51 | } |
52 | if (rhs.m_name != NULL) | 52 | if (rhs.m_name != NULL) |
53 | { | 53 | { |
54 | int len = ustrlen(rhs.m_name)+1; | 54 | int len = ustrlen(rhs.m_name)+1; |
55 | m_name = new tchar[len]; | 55 | m_name = new tchar[len]; |
56 | for (int i = 0; i < len; i++) m_name[i] = rhs.m_name[i]; | 56 | for (int i = 0; i < len; i++) m_name[i] = rhs.m_name[i]; |
57 | } | 57 | } |
58 | else | 58 | else |
59 | m_name = NULL; | 59 | m_name = NULL; |
60 | if (rhs.m_anno != NULL) | 60 | if (rhs.m_anno != NULL) |
61 | { | 61 | { |
62 | int len = ustrlen(rhs.m_anno)+1; | 62 | int len = ustrlen(rhs.m_anno)+1; |
63 | m_anno = new tchar[len]; | 63 | m_anno = new tchar[len]; |
64 | for (int i = 0; i < len; i++) m_anno[i] = rhs.m_anno[i]; | 64 | for (int i = 0; i < len; i++) m_anno[i] = rhs.m_anno[i]; |
65 | } | 65 | } |
66 | else | 66 | else |
67 | m_anno = NULL; | 67 | m_anno = NULL; |
68 | m_position = rhs.m_position; | 68 | m_position = rhs.m_position; |
69 | return *this; | 69 | return *this; |
70 | } | 70 | } |
71 | 71 | ||
72 | bool Bkmk::operator==(const Bkmk& rhs) | 72 | bool Bkmk::operator==(const Bkmk& rhs) |
73 | { | 73 | { |
74 | return (m_position == rhs.m_position && ustrcmp(m_name,rhs.m_name) == 0); | 74 | return (m_position == rhs.m_position && ustrcmp(m_name,rhs.m_name) == 0); |
75 | } | 75 | } |
76 | 76 | ||
77 | void Bkmk::setAnno(tchar* t) | 77 | void Bkmk::setAnno(tchar* t) |
78 | { | 78 | { |
79 | if (m_anno != NULL) | 79 | if (m_anno != NULL) |
80 | { | 80 | { |
81 | delete [] m_anno; | 81 | delete [] m_anno; |
82 | m_anno = NULL; | 82 | m_anno = NULL; |
83 | } | 83 | } |
84 | if (t != NULL) | 84 | if (t != NULL) |
85 | { | 85 | { |
86 | int len = ustrlen(t)+1; | 86 | int len = ustrlen(t)+1; |
87 | m_anno = new tchar[len]; | 87 | m_anno = new tchar[len]; |
88 | for (int i = 0; i < len; i++) m_anno[i] = t[i]; | 88 | for (int i = 0; i < len; i++) m_anno[i] = t[i]; |
89 | } | 89 | } |
90 | else | 90 | else |
91 | m_anno = NULL; | 91 | m_anno = NULL; |
92 | } | 92 | } |
93 | 93 | ||
94 | BkmkFile::BkmkFile(const char *fnm, bool w = false) | 94 | BkmkFile::BkmkFile(const char *fnm, bool w ) |
95 | : | 95 | : |
96 | wt(w), isUpgraded(false) | 96 | wt(w), isUpgraded(false) |
97 | { | 97 | { |
98 | if (w) | 98 | if (w) |
99 | { | 99 | { |
100 | f = fopen(fnm, "wb"); | 100 | f = fopen(fnm, "wb"); |
101 | } | 101 | } |
102 | else | 102 | else |
103 | { | 103 | { |
104 | f = fopen(fnm, "rb"); | 104 | f = fopen(fnm, "rb"); |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | BkmkFile::~BkmkFile() | 108 | BkmkFile::~BkmkFile() |
109 | { | 109 | { |
110 | if (f != NULL) fclose(f); | 110 | if (f != NULL) fclose(f); |
111 | } | 111 | } |
112 | 112 | ||
113 | void BkmkFile::write(tchar* nm, tchar* an, const unsigned int& pos) | 113 | void BkmkFile::write(tchar* nm, tchar* an, const unsigned int& pos) |
114 | { | 114 | { |
115 | if (f != NULL) | 115 | if (f != NULL) |
116 | { | 116 | { |
117 | unsigned short ln = ustrlen(nm); | 117 | unsigned short ln = ustrlen(nm); |
118 | fwrite(&ln,sizeof(ln),1,f); | 118 | fwrite(&ln,sizeof(ln),1,f); |
119 | fwrite(nm,sizeof(tchar),ln,f); | 119 | fwrite(nm,sizeof(tchar),ln,f); |
120 | ln = ustrlen(an); | 120 | ln = ustrlen(an); |
121 | fwrite(&ln,sizeof(ln),1,f); | 121 | fwrite(&ln,sizeof(ln),1,f); |
122 | if (ln > 0) fwrite(an,sizeof(tchar),ln,f); | 122 | if (ln > 0) fwrite(an,sizeof(tchar),ln,f); |
123 | fwrite(&pos,sizeof(pos),1,f); | 123 | fwrite(&pos,sizeof(pos),1,f); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | void BkmkFile::write(const Bkmk& b) { write(b.name(), b.anno(), b.value()); } | 127 | void BkmkFile::write(const Bkmk& b) { write(b.name(), b.anno(), b.value()); } |
128 | 128 | ||
129 | void BkmkFile::write(CList<Bkmk>& bl) | 129 | void BkmkFile::write(CList<Bkmk>& bl) |
130 | { | 130 | { |
131 | if (f != NULL) | 131 | if (f != NULL) |
132 | { | 132 | { |
133 | fwrite(&magic, sizeof(magic), 1, f); | 133 | fwrite(&magic, sizeof(magic), 1, f); |
134 | for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++) | 134 | for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++) |
135 | { | 135 | { |
136 | write(*i); | 136 | write(*i); |
137 | } | 137 | } |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | Bkmk* BkmkFile::read() | 141 | Bkmk* BkmkFile::read() |
142 | { | 142 | { |
143 | Bkmk* b = NULL; | 143 | Bkmk* b = NULL; |
144 | if (f != NULL) | 144 | if (f != NULL) |
145 | { | 145 | { |
146 | unsigned short ln; | 146 | unsigned short ln; |
147 | if (fread(&ln,sizeof(ln),1,f) == 1) | 147 | if (fread(&ln,sizeof(ln),1,f) == 1) |
148 | { | 148 | { |
149 | b = new Bkmk; | 149 | b = new Bkmk; |
150 | b->m_name = new tchar[ln+1]; | 150 | b->m_name = new tchar[ln+1]; |
151 | fread(b->m_name,sizeof(tchar),ln,f); | 151 | fread(b->m_name,sizeof(tchar),ln,f); |
152 | b->m_name[ln] = 0; | 152 | b->m_name[ln] = 0; |
153 | 153 | ||
154 | fread(&ln,sizeof(ln),1,f); | 154 | fread(&ln,sizeof(ln),1,f); |
155 | b->m_anno = new tchar[ln+1]; | 155 | b->m_anno = new tchar[ln+1]; |
156 | if (ln > 0) fread(b->m_anno,sizeof(tchar),ln,f); | 156 | if (ln > 0) fread(b->m_anno,sizeof(tchar),ln,f); |
157 | b->m_anno[ln] = 0; | 157 | b->m_anno[ln] = 0; |
158 | fread(&b->m_position,sizeof(b->m_position),1,f); | 158 | fread(&b->m_position,sizeof(b->m_position),1,f); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | return b; | 161 | return b; |
162 | } | 162 | } |
163 | 163 | ||
164 | CList<Bkmk>* BkmkFile::readall() | 164 | CList<Bkmk>* BkmkFile::readall() |
165 | { | 165 | { |
166 | CList<Bkmk>* bl = NULL; | 166 | CList<Bkmk>* bl = NULL; |
167 | if (f != NULL) | 167 | if (f != NULL) |
168 | { | 168 | { |
169 | unsigned long newmagic; | 169 | unsigned long newmagic; |
170 | fread(&newmagic, sizeof(newmagic), 1, f); | 170 | fread(&newmagic, sizeof(newmagic), 1, f); |
171 | if (newmagic != magic) | 171 | if (newmagic != magic) |
172 | { | 172 | { |
173 | if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of OpieReader\ndid you upgrade from?", "0_4*", "Any other version") == 0) | 173 | if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of OpieReader\ndid you upgrade from?", "0_4*", "Any other version") == 0) |
174 | { | 174 | { |
175 | fseek(f,0,SEEK_SET); | 175 | fseek(f,0,SEEK_SET); |
176 | bl = readall04(); | 176 | bl = readall04(); |
177 | } | 177 | } |
178 | else | 178 | else |
179 | { | 179 | { |
180 | fseek(f,0,SEEK_SET); | 180 | fseek(f,0,SEEK_SET); |
181 | bl = readall03(); | 181 | bl = readall03(); |
182 | } | 182 | } |
183 | isUpgraded = true; | 183 | isUpgraded = true; |
184 | } | 184 | } |
185 | else | 185 | else |
186 | { | 186 | { |
187 | bl = readall04(); | 187 | bl = readall04(); |
188 | } | 188 | } |
189 | } | 189 | } |
190 | return bl; | 190 | return bl; |
191 | } | 191 | } |
192 | 192 | ||
193 | CList<Bkmk>* BkmkFile::readall04() | 193 | CList<Bkmk>* BkmkFile::readall04() |
194 | { | 194 | { |
195 | CList<Bkmk>* bl = new CList<Bkmk>; | 195 | CList<Bkmk>* bl = new CList<Bkmk>; |
196 | while (1) | 196 | while (1) |
197 | { | 197 | { |
198 | Bkmk* b = read(); | 198 | Bkmk* b = read(); |
199 | if (b == NULL) break; | 199 | if (b == NULL) break; |
200 | bl->push_back(*b); | 200 | bl->push_back(*b); |
201 | delete b; | 201 | delete b; |
202 | } | 202 | } |
203 | return bl; | 203 | return bl; |
204 | } | 204 | } |
205 | 205 | ||
206 | CList<Bkmk>* BkmkFile::readall03() | 206 | CList<Bkmk>* BkmkFile::readall03() |
207 | { | 207 | { |
208 | CList<Bkmk>* bl = new CList<Bkmk>; | 208 | CList<Bkmk>* bl = new CList<Bkmk>; |
209 | while (1) | 209 | while (1) |
210 | { | 210 | { |
211 | Bkmk* b = read03(); | 211 | Bkmk* b = read03(); |
212 | if (b == NULL) break; | 212 | if (b == NULL) break; |
213 | bl->push_back(*b); | 213 | bl->push_back(*b); |
214 | delete b; | 214 | delete b; |
215 | } | 215 | } |
216 | return bl; | 216 | return bl; |
217 | } | 217 | } |
218 | 218 | ||
219 | Bkmk* BkmkFile::read03() | 219 | Bkmk* BkmkFile::read03() |
220 | { | 220 | { |
221 | Bkmk* b = NULL; | 221 | Bkmk* b = NULL; |
222 | if (f != NULL) | 222 | if (f != NULL) |
223 | { | 223 | { |
224 | unsigned short ln; | 224 | unsigned short ln; |
225 | if (fread(&ln,sizeof(ln),1,f) == 1) | 225 | if (fread(&ln,sizeof(ln),1,f) == 1) |
226 | { | 226 | { |
227 | b = new Bkmk; | 227 | b = new Bkmk; |
228 | b->m_name = new tchar[ln+1]; | 228 | b->m_name = new tchar[ln+1]; |
229 | fread(b->m_name,sizeof(tchar),ln,f); | 229 | fread(b->m_name,sizeof(tchar),ln,f); |
230 | b->m_name[ln] = 0; | 230 | b->m_name[ln] = 0; |
231 | 231 | ||
232 | ln = 0; | 232 | ln = 0; |
233 | b->m_anno = new tchar[ln+1]; | 233 | b->m_anno = new tchar[ln+1]; |
234 | b->m_anno[ln] = 0; | 234 | b->m_anno[ln] = 0; |
235 | 235 | ||
236 | fread(&b->m_position,sizeof(b->m_position),1,f); | 236 | fread(&b->m_position,sizeof(b->m_position),1,f); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | return b; | 239 | return b; |
240 | } | 240 | } |
diff --git a/noncore/apps/opie-reader/CBuffer.cpp b/noncore/apps/opie-reader/CBuffer.cpp index 526b25f..0780a88 100644 --- a/noncore/apps/opie-reader/CBuffer.cpp +++ b/noncore/apps/opie-reader/CBuffer.cpp | |||
@@ -1,46 +1,46 @@ | |||
1 | #include "CBuffer.h" | 1 | #include "CBuffer.h" |
2 | 2 | ||
3 | CBufferBase& CBufferBase::assign(const void* sztmp, size_t ms) | 3 | CBufferBase& CBufferBase::assign(const void* sztmp, size_t ms) |
4 | { | 4 | { |
5 | if (ms*membersize > len) | 5 | if (ms*membersize > len) |
6 | { | 6 | { |
7 | delete [] buffer; | 7 | delete [] buffer; |
8 | buffer = new unsigned char[len = ms*membersize]; | 8 | buffer = new unsigned char[len = ms*membersize]; |
9 | } | 9 | } |
10 | memcpy(buffer, sztmp, ms*membersize); | 10 | memcpy(buffer, sztmp, ms*membersize); |
11 | return *this; | 11 | return *this; |
12 | } | 12 | } |
13 | 13 | ||
14 | CBufferBase::CBufferBase(size_t ms, size_t n = 16) : len(n), membersize(ms) | 14 | CBufferBase::CBufferBase(size_t ms, size_t n) : len(n), membersize(ms) |
15 | { | 15 | { |
16 | buffer = new unsigned char[len*membersize]; | 16 | buffer = new unsigned char[len*membersize]; |
17 | memset(buffer, 0, len*membersize); | 17 | memset(buffer, 0, len*membersize); |
18 | } | 18 | } |
19 | 19 | ||
20 | void* CBufferBase::operator[](int i) | 20 | void* CBufferBase::operator[](int i) |
21 | { | 21 | { |
22 | if ((i+1)*membersize > len) | 22 | if ((i+1)*membersize > len) |
23 | { | 23 | { |
24 | unsigned char* oldbuffer = buffer; | 24 | unsigned char* oldbuffer = buffer; |
25 | buffer = new unsigned char[(i+1)*membersize]; | 25 | buffer = new unsigned char[(i+1)*membersize]; |
26 | memcpy(buffer, oldbuffer, len); | 26 | memcpy(buffer, oldbuffer, len); |
27 | memset(buffer+len, 0, (i+1)*membersize-len); | 27 | memset(buffer+len, 0, (i+1)*membersize-len); |
28 | len = (i+1)*membersize; | 28 | len = (i+1)*membersize; |
29 | delete [] oldbuffer; | 29 | delete [] oldbuffer; |
30 | } | 30 | } |
31 | return buffer+i*membersize; | 31 | return buffer+i*membersize; |
32 | } | 32 | } |
33 | 33 | ||
34 | size_t CBufferBase::bstrlen(unsigned char* _buffer = NULL) | 34 | size_t CBufferBase::bstrlen(unsigned char* _buffer) |
35 | { | 35 | { |
36 | if (_buffer == NULL) _buffer = buffer; | 36 | if (_buffer == NULL) _buffer = buffer; |
37 | unsigned char* zero = new unsigned char[membersize]; | 37 | unsigned char* zero = new unsigned char[membersize]; |
38 | memset(zero,0,membersize); | 38 | memset(zero,0,membersize); |
39 | unsigned char* element = _buffer; | 39 | unsigned char* element = _buffer; |
40 | while (memcmp(element, zero, membersize) != 0) | 40 | while (memcmp(element, zero, membersize) != 0) |
41 | { | 41 | { |
42 | element += membersize; | 42 | element += membersize; |
43 | } | 43 | } |
44 | delete [] zero; | 44 | delete [] zero; |
45 | return (element - _buffer)/membersize; | 45 | return (element - _buffer)/membersize; |
46 | } | 46 | } |
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp index 2ceb2d5..892456f 100644 --- a/noncore/apps/opie-reader/CDrawBuffer.cpp +++ b/noncore/apps/opie-reader/CDrawBuffer.cpp | |||
@@ -1,211 +1,211 @@ | |||
1 | 1 | ||
2 | #include "CDrawBuffer.h" | 2 | #include "CDrawBuffer.h" |
3 | #include "FontControl.h" | 3 | #include "FontControl.h" |
4 | #include <qfontmetrics.h> | 4 | #include <qfontmetrics.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | 6 | ||
7 | void CDrawBuffer::setright(CDrawBuffer& rhs, int f) | 7 | void CDrawBuffer::setright(CDrawBuffer& rhs, int f) |
8 | { | 8 | { |
9 | int i; | 9 | int i; |
10 | // qDebug("Trying 1:%d:%s", f, (const char*)toQString(rhs.data())); | 10 | // qDebug("Trying 1:%d:%s", f, (const char*)toQString(rhs.data())); |
11 | len = rhs.len; | 11 | len = rhs.len; |
12 | m_maxstyle = rhs.m_maxstyle; | 12 | m_maxstyle = rhs.m_maxstyle; |
13 | m_ascent = rhs.m_ascent; | 13 | m_ascent = rhs.m_ascent; |
14 | m_descent = rhs.m_descent; | 14 | m_descent = rhs.m_descent; |
15 | m_lineSpacing = rhs.m_lineSpacing; | 15 | m_lineSpacing = rhs.m_lineSpacing; |
16 | while (!segs.isEmpty()) segs.erase(0); | 16 | while (!segs.isEmpty()) segs.erase(0); |
17 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); ) | 17 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); ) |
18 | { | 18 | { |
19 | CList<textsegment>::iterator next = iter; | 19 | CList<textsegment>::iterator next = iter; |
20 | iter++; | 20 | iter++; |
21 | if (iter == rhs.segs.end() || iter->start > f) | 21 | if (iter == rhs.segs.end() || iter->start > f) |
22 | { | 22 | { |
23 | int st = next->start-f; | 23 | int st = next->start-f; |
24 | if (st < 0) st = 0; | 24 | if (st < 0) st = 0; |
25 | segs.push_back(textsegment(st,next->style)); | 25 | segs.push_back(textsegment(st,next->style)); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i]; | 28 | for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i]; |
29 | (*this)[i-f] = '\0'; | 29 | (*this)[i-f] = '\0'; |
30 | len = i; | 30 | len = i; |
31 | // qDebug("Tried 1"); | 31 | // qDebug("Tried 1"); |
32 | } | 32 | } |
33 | 33 | ||
34 | CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) | 34 | CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) |
35 | { | 35 | { |
36 | int i; | 36 | int i; |
37 | // qDebug("Trying 2"); | 37 | // qDebug("Trying 2"); |
38 | len = rhs.len; | 38 | len = rhs.len; |
39 | m_maxstyle = rhs.m_maxstyle; | 39 | m_maxstyle = rhs.m_maxstyle; |
40 | m_ascent = rhs.m_ascent; | 40 | m_ascent = rhs.m_ascent; |
41 | m_descent = rhs.m_descent; | 41 | m_descent = rhs.m_descent; |
42 | m_lineSpacing = rhs.m_lineSpacing; | 42 | m_lineSpacing = rhs.m_lineSpacing; |
43 | while (!segs.isEmpty()) segs.erase(0); | 43 | while (!segs.isEmpty()) segs.erase(0); |
44 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) | 44 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) |
45 | { | 45 | { |
46 | segs.push_back(*iter); | 46 | segs.push_back(*iter); |
47 | } | 47 | } |
48 | for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; | 48 | for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; |
49 | (*this)[i] = '\0'; | 49 | (*this)[i] = '\0'; |
50 | len = i; | 50 | len = i; |
51 | // qDebug("Tried 2"); | 51 | // qDebug("Tried 2"); |
52 | return *this; | 52 | return *this; |
53 | } | 53 | } |
54 | 54 | ||
55 | CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) | 55 | CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) |
56 | { | 56 | { |
57 | int i; | 57 | int i; |
58 | while (!segs.isEmpty()) segs.erase(0); | 58 | while (!segs.isEmpty()) segs.erase(0); |
59 | segs.push_back(textsegment(0, CStyle())); | 59 | segs.push_back(textsegment(0, CStyle())); |
60 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; | 60 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; |
61 | (*this)[i] = '\0'; | 61 | (*this)[i] = '\0'; |
62 | len = i; | 62 | len = i; |
63 | return *this; | 63 | return *this; |
64 | } | 64 | } |
65 | 65 | ||
66 | void CDrawBuffer::empty() | 66 | void CDrawBuffer::empty() |
67 | { | 67 | { |
68 | len = 0; | 68 | len = 0; |
69 | (*this)[0] = 0; | 69 | (*this)[0] = 0; |
70 | while (!segs.isEmpty()) segs.erase(0); | 70 | while (!segs.isEmpty()) segs.erase(0); |
71 | segs.push_back(textsegment(0,CStyle())); | 71 | segs.push_back(textsegment(0,CStyle())); |
72 | m_maxstyle = m_ascent = m_descent = m_lineSpacing = 0; | 72 | m_maxstyle = m_ascent = m_descent = m_lineSpacing = 0; |
73 | } | 73 | } |
74 | 74 | ||
75 | void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) | 75 | void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) |
76 | { | 76 | { |
77 | if (len == 0) | 77 | if (len == 0) |
78 | { | 78 | { |
79 | int thissize = fc->getsize(_style); | 79 | int thissize = fc->getsize(_style); |
80 | m_maxstyle = thissize; | 80 | m_maxstyle = thissize; |
81 | m_ascent = fc->ascent(_style); | 81 | m_ascent = fc->ascent(_style); |
82 | m_descent = fc->descent(_style); | 82 | m_descent = fc->descent(_style); |
83 | m_lineSpacing = fc->lineSpacing(_style); | 83 | m_lineSpacing = fc->lineSpacing(_style); |
84 | segs.first().start = 0; | 84 | segs.first().start = 0; |
85 | segs.first().style = _style; | 85 | segs.first().style = _style; |
86 | } | 86 | } |
87 | else if (_style != segs.last().style) | 87 | else if (_style != segs.last().style) |
88 | { | 88 | { |
89 | int thissize = fc->getsize(_style); | 89 | int thissize = fc->getsize(_style); |
90 | if (thissize > m_maxstyle) | 90 | if (thissize > m_maxstyle) |
91 | { | 91 | { |
92 | m_maxstyle = thissize; | 92 | m_maxstyle = thissize; |
93 | m_ascent = fc->ascent(_style); | 93 | m_ascent = fc->ascent(_style); |
94 | m_descent = fc->descent(_style); | 94 | m_descent = fc->descent(_style); |
95 | m_lineSpacing = fc->lineSpacing(_style); | 95 | m_lineSpacing = fc->lineSpacing(_style); |
96 | } | 96 | } |
97 | segs.push_back(textsegment(len, _style)); | 97 | segs.push_back(textsegment(len, _style)); |
98 | } | 98 | } |
99 | (*this)[len++] = ch; | 99 | (*this)[len++] = ch; |
100 | } | 100 | } |
101 | 101 | ||
102 | void CDrawBuffer::truncate(int n) | 102 | void CDrawBuffer::truncate(int n) |
103 | { | 103 | { |
104 | len = n; | 104 | len = n; |
105 | (*this)[n] = 0; | 105 | (*this)[n] = 0; |
106 | } | 106 | } |
107 | 107 | ||
108 | int CDrawBuffer::width(int numchars = -1) | 108 | int CDrawBuffer::width(int numchars) |
109 | { | 109 | { |
110 | int currentx = 0, end = 0; | 110 | int currentx = 0, end = 0; |
111 | QString text = toQString(data()); | 111 | QString text = toQString(data()); |
112 | CList<textsegment>::iterator textstart = segs.begin(); | 112 | CList<textsegment>::iterator textstart = segs.begin(); |
113 | CList<textsegment>::iterator textend = textstart; | 113 | CList<textsegment>::iterator textend = textstart; |
114 | do | 114 | do |
115 | { | 115 | { |
116 | textend++; | 116 | textend++; |
117 | end = (textend != segs.end()) ? textend->start : length(); | 117 | end = (textend != segs.end()) ? textend->start : length(); |
118 | if (numchars >= 0 && end > numchars) | 118 | if (numchars >= 0 && end > numchars) |
119 | { | 119 | { |
120 | end = numchars; | 120 | end = numchars; |
121 | } | 121 | } |
122 | CStyle currentstyle = textstart->style; | 122 | CStyle currentstyle = textstart->style; |
123 | QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 123 | QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
124 | QString str = text.mid(textstart->start, end-textstart->start); | 124 | QString str = text.mid(textstart->start, end-textstart->start); |
125 | QFontMetrics fm(f); | 125 | QFontMetrics fm(f); |
126 | currentx += fm.width(str); | 126 | currentx += fm.width(str); |
127 | textstart = textend; | 127 | textstart = textend; |
128 | } | 128 | } |
129 | while (textend != segs.end() && end != numchars); | 129 | while (textend != segs.end() && end != numchars); |
130 | return currentx; | 130 | return currentx; |
131 | } | 131 | } |
132 | 132 | ||
133 | void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth) | 133 | void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth) |
134 | { | 134 | { |
135 | int currentx = 0; | 135 | int currentx = 0; |
136 | QString text = toQString(data()); | 136 | QString text = toQString(data()); |
137 | CList<textsegment>::iterator textstart = segs.begin(); | 137 | CList<textsegment>::iterator textstart = segs.begin(); |
138 | StyleType align = textstart->style.getJustify(); | 138 | StyleType align = textstart->style.getJustify(); |
139 | switch (align) | 139 | switch (align) |
140 | { | 140 | { |
141 | case CStyle::m_AlignRight: | 141 | case CStyle::m_AlignRight: |
142 | { | 142 | { |
143 | // int linelength = width(); | 143 | // int linelength = width(); |
144 | currentx = scwidth - width(); | 144 | currentx = scwidth - width(); |
145 | } | 145 | } |
146 | break; | 146 | break; |
147 | case CStyle::m_AlignCentre: | 147 | case CStyle::m_AlignCentre: |
148 | { | 148 | { |
149 | // int linelength = width(); | 149 | // int linelength = width(); |
150 | currentx = (scwidth - width())/2; | 150 | currentx = (scwidth - width())/2; |
151 | } | 151 | } |
152 | break; | 152 | break; |
153 | case CStyle::m_AlignJustify: | 153 | case CStyle::m_AlignJustify: |
154 | case CStyle::m_AlignLeft: | 154 | case CStyle::m_AlignLeft: |
155 | break; | 155 | break; |
156 | } | 156 | } |
157 | CList<textsegment>::iterator textend = textstart; | 157 | CList<textsegment>::iterator textend = textstart; |
158 | do | 158 | do |
159 | { | 159 | { |
160 | textend++; | 160 | textend++; |
161 | int end = (textend != segs.end()) ? textend->start : length(); | 161 | int end = (textend != segs.end()) ? textend->start : length(); |
162 | CStyle currentstyle = textstart->style; | 162 | CStyle currentstyle = textstart->style; |
163 | QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 163 | QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
164 | _p->setFont(f); | 164 | _p->setFont(f); |
165 | QString str = text.mid(textstart->start, end-textstart->start); | 165 | QString str = text.mid(textstart->start, end-textstart->start); |
166 | _p->setPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue())); | 166 | _p->setPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue())); |
167 | if (_bMono) | 167 | if (_bMono) |
168 | { | 168 | { |
169 | for (int i = 0; i < str.length(); i++) | 169 | for (int i = 0; i < str.length(); i++) |
170 | { | 170 | { |
171 | _p->drawText( currentx + i*_charWidth, _y, QString(str[i])); | 171 | _p->drawText( currentx + i*_charWidth, _y, QString(str[i])); |
172 | } | 172 | } |
173 | currentx += str.length()*_charWidth; | 173 | currentx += str.length()*_charWidth; |
174 | } | 174 | } |
175 | else | 175 | else |
176 | { | 176 | { |
177 | _p->drawText( currentx, _y, str); | 177 | _p->drawText( currentx, _y, str); |
178 | QFontMetrics fm(f); | 178 | QFontMetrics fm(f); |
179 | currentx += fm.width(str); | 179 | currentx += fm.width(str); |
180 | } | 180 | } |
181 | textstart = textend; | 181 | textstart = textend; |
182 | } | 182 | } |
183 | while (textend != segs.end()); | 183 | while (textend != segs.end()); |
184 | } | 184 | } |
185 | 185 | ||
186 | CStyle CDrawBuffer::laststyle() | 186 | CStyle CDrawBuffer::laststyle() |
187 | { | 187 | { |
188 | return segs.last().style; | 188 | return segs.last().style; |
189 | } | 189 | } |
190 | 190 | ||
191 | bool CDrawBuffer::isLink(int numchars, size_t& tgt) | 191 | bool CDrawBuffer::isLink(int numchars, size_t& tgt) |
192 | { | 192 | { |
193 | int end = 0; | 193 | int end = 0; |
194 | CStyle currentstyle; | 194 | CStyle currentstyle; |
195 | CList<textsegment>::iterator textstart = segs.begin(); | 195 | CList<textsegment>::iterator textstart = segs.begin(); |
196 | CList<textsegment>::iterator textend = textstart; | 196 | CList<textsegment>::iterator textend = textstart; |
197 | do | 197 | do |
198 | { | 198 | { |
199 | textend++; | 199 | textend++; |
200 | end = (textend != segs.end()) ? textend->start : length(); | 200 | end = (textend != segs.end()) ? textend->start : length(); |
201 | if (numchars >= 0 && end > numchars) | 201 | if (numchars >= 0 && end > numchars) |
202 | { | 202 | { |
203 | end = numchars; | 203 | end = numchars; |
204 | } | 204 | } |
205 | currentstyle = textstart->style; | 205 | currentstyle = textstart->style; |
206 | textstart = textend; | 206 | textstart = textend; |
207 | } | 207 | } |
208 | while (textend != segs.end() && end != numchars); | 208 | while (textend != segs.end() && end != numchars); |
209 | tgt = currentstyle.getData(); | 209 | tgt = currentstyle.getData(); |
210 | return currentstyle.getLink(); | 210 | return currentstyle.getLink(); |
211 | } | 211 | } |
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp index e7bfc28..7cf08e5 100644 --- a/noncore/apps/opie-reader/QTReader.cpp +++ b/noncore/apps/opie-reader/QTReader.cpp | |||
@@ -1,230 +1,230 @@ | |||
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 <qpainter.h> | 11 | #include <qpainter.h> |
12 | #include "config.h" | 12 | #include "config.h" |
13 | #include "QTReader.h" | 13 | #include "QTReader.h" |
14 | #include "QTReaderApp.h" | 14 | #include "QTReaderApp.h" |
15 | #include "CDrawBuffer.h" | 15 | #include "CDrawBuffer.h" |
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | #include <math.h> | 17 | #include <math.h> |
18 | #include <ctype.h> | 18 | #include <ctype.h> |
19 | #include <stdio.h> //for sprintf | 19 | #include <stdio.h> //for sprintf |
20 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
21 | #include <qpe/applnk.h> | 21 | #include <qpe/applnk.h> |
22 | #include <qfontdatabase.h> | 22 | #include <qfontdatabase.h> |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | 25 | ||
26 | #ifdef _UNICODE | 26 | #ifdef _UNICODE |
27 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; | 27 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; |
28 | #else | 28 | #else |
29 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; | 29 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; |
30 | #endif | 30 | #endif |
31 | //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 }; |
32 | 32 | ||
33 | //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; | 33 | //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; |
34 | //const int QTReader::fontsizes[] = {10,16,17,22,0}; | 34 | //const int QTReader::fontsizes[] = {10,16,17,22,0}; |
35 | //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; | 35 | //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; |
36 | //const int QTReader::fontsizes[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0}; | 36 | //const int QTReader::fontsizes[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0}; |
37 | 37 | ||
38 | QTReader::QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0) : | 38 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : |
39 | QWidget(parent, name, f), | 39 | QWidget(parent, name, f), |
40 | m_delay(100), | 40 | m_delay(100), |
41 | m_scrolldy1(0), | 41 | m_scrolldy1(0), |
42 | m_scrolldy2(0), | 42 | m_scrolldy2(0), |
43 | m_autoScroll(false), | 43 | m_autoScroll(false), |
44 | //textarray(NULL), | 44 | //textarray(NULL), |
45 | //locnarray(NULL), | 45 | //locnarray(NULL), |
46 | numlines(0), | 46 | numlines(0), |
47 | m_fontname("unifont"), | 47 | m_fontname("unifont"), |
48 | m_fm(NULL), | 48 | m_fm(NULL), |
49 | mouseUpOn(true), | 49 | mouseUpOn(true), |
50 | m_twotouch(true), | 50 | m_twotouch(true), |
51 | m_touchone(true) | 51 | m_touchone(true) |
52 | { | 52 | { |
53 | m_overlap = 1; | 53 | m_overlap = 1; |
54 | // init(); | 54 | // init(); |
55 | } | 55 | } |
56 | /* | 56 | /* |
57 | QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : | 57 | QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : |
58 | QWidget(parent, name, f), | 58 | QWidget(parent, name, f), |
59 | m_textfont(0), | 59 | m_textfont(0), |
60 | m_textsize(1), | 60 | m_textsize(1), |
61 | textarray(NULL), | 61 | textarray(NULL), |
62 | numlines(0), | 62 | numlines(0), |
63 | bstripcr(true), | 63 | bstripcr(true), |
64 | bunindent(false), | 64 | bunindent(false), |
65 | brepara(false), | 65 | brepara(false), |
66 | bdblspce(false), | 66 | bdblspce(false), |
67 | btight(false), | 67 | btight(false), |
68 | bindenter(0), | 68 | bindenter(0), |
69 | m_fm(NULL) | 69 | m_fm(NULL) |
70 | { | 70 | { |
71 | init(); | 71 | init(); |
72 | // qDebug("Load_file(1)"); | 72 | // qDebug("Load_file(1)"); |
73 | load_file((const tchar*)filename); | 73 | load_file((const tchar*)filename); |
74 | } | 74 | } |
75 | */ | 75 | */ |
76 | 76 | ||
77 | long QTReader::real_delay() | 77 | long QTReader::real_delay() |
78 | { | 78 | { |
79 | return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); | 79 | return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); |
80 | } | 80 | } |
81 | 81 | ||
82 | void QTReader::mousePressEvent( QMouseEvent* _e ) | 82 | void QTReader::mousePressEvent( QMouseEvent* _e ) |
83 | { | 83 | { |
84 | if (_e->button() == RightButton) | 84 | if (_e->button() == RightButton) |
85 | { | 85 | { |
86 | mouseUpOn = false; | 86 | mouseUpOn = false; |
87 | if (_e->y() > height()/2) | 87 | if (_e->y() > height()/2) |
88 | { | 88 | { |
89 | goDown(); | 89 | goDown(); |
90 | } | 90 | } |
91 | else | 91 | else |
92 | { | 92 | { |
93 | goUp(); | 93 | goUp(); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | bool QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt) | 98 | bool QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt) |
99 | { | 99 | { |
100 | int lineno = 0; | 100 | int lineno = 0; |
101 | int ht = textarray[0]->lineSpacing(); | 101 | int ht = textarray[0]->lineSpacing(); |
102 | while ((ht < y) && (lineno < numlines)) | 102 | while ((ht < y) && (lineno < numlines)) |
103 | { | 103 | { |
104 | ht += textarray[++lineno]->lineSpacing(); | 104 | ht += textarray[++lineno]->lineSpacing(); |
105 | } | 105 | } |
106 | start = locnarray[lineno]; | 106 | start = locnarray[lineno]; |
107 | if (m_bMonoSpaced) | 107 | if (m_bMonoSpaced) |
108 | { | 108 | { |
109 | offset = x/m_charWidth; | 109 | offset = x/m_charWidth; |
110 | } | 110 | } |
111 | else | 111 | else |
112 | { | 112 | { |
113 | int i; | 113 | int i; |
114 | CDrawBuffer* t = textarray[lineno]; | 114 | CDrawBuffer* t = textarray[lineno]; |
115 | for (i = t->length(); t->width(i) > x; i--); | 115 | for (i = t->length(); t->width(i) > x; i--); |
116 | offset = i; | 116 | offset = i; |
117 | } | 117 | } |
118 | return textarray[lineno]->isLink(offset, tgt); | 118 | return textarray[lineno]->isLink(offset, tgt); |
119 | } | 119 | } |
120 | 120 | ||
121 | void QTReader::setTwoTouch(bool _b) | 121 | void QTReader::setTwoTouch(bool _b) |
122 | { | 122 | { |
123 | setBackgroundColor( white ); | 123 | setBackgroundColor( white ); |
124 | m_twotouch = m_touchone = _b; | 124 | m_twotouch = m_touchone = _b; |
125 | } | 125 | } |
126 | 126 | ||
127 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | 127 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) |
128 | { | 128 | { |
129 | if (_e->button() == LeftButton) | 129 | if (_e->button() == LeftButton) |
130 | { | 130 | { |
131 | if (mouseUpOn) | 131 | if (mouseUpOn) |
132 | { | 132 | { |
133 | if (textarray[0] != NULL) | 133 | if (textarray[0] != NULL) |
134 | { | 134 | { |
135 | QString wrd, line; | 135 | QString wrd, line; |
136 | // int lineno = _e->y()/m_linespacing; | 136 | // int lineno = _e->y()/m_linespacing; |
137 | int lineno = 0; | 137 | int lineno = 0; |
138 | int ht = textarray[0]->lineSpacing(); | 138 | int ht = textarray[0]->lineSpacing(); |
139 | while ((ht < _e->y()) && (lineno < numlines)) | 139 | while ((ht < _e->y()) && (lineno < numlines)) |
140 | { | 140 | { |
141 | ht += textarray[++lineno]->lineSpacing(); | 141 | ht += textarray[++lineno]->lineSpacing(); |
142 | } | 142 | } |
143 | size_t startpos, startoffset, tgt; | 143 | size_t startpos, startoffset, tgt; |
144 | if (getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt)) | 144 | if (getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt)) |
145 | { | 145 | { |
146 | if (buffdoc.hyperlink(tgt)) | 146 | if (buffdoc.hyperlink(tgt)) |
147 | { | 147 | { |
148 | fillbuffer(); | 148 | fillbuffer(); |
149 | update(); | 149 | update(); |
150 | } | 150 | } |
151 | else | 151 | else |
152 | { | 152 | { |
153 | locate(pagelocate()); | 153 | locate(pagelocate()); |
154 | } | 154 | } |
155 | return; | 155 | return; |
156 | } | 156 | } |
157 | if (m_twotouch) | 157 | if (m_twotouch) |
158 | { | 158 | { |
159 | if (m_touchone) | 159 | if (m_touchone) |
160 | { | 160 | { |
161 | m_touchone = false; | 161 | m_touchone = false; |
162 | m_startpos = startpos; | 162 | m_startpos = startpos; |
163 | m_startoffset = startoffset; | 163 | m_startoffset = startoffset; |
164 | setBackgroundColor( lightGray ); | 164 | setBackgroundColor( lightGray ); |
165 | } | 165 | } |
166 | else | 166 | else |
167 | { | 167 | { |
168 | m_touchone = true; | 168 | m_touchone = true; |
169 | setBackgroundColor( white ); | 169 | setBackgroundColor( white ); |
170 | size_t endpos, endoffset; | 170 | size_t endpos, endoffset; |
171 | endpos = startpos; | 171 | endpos = startpos; |
172 | endoffset = startoffset; | 172 | endoffset = startoffset; |
173 | size_t currentpos = locate(); | 173 | size_t currentpos = locate(); |
174 | if (endpos >= m_startpos) | 174 | if (endpos >= m_startpos) |
175 | { | 175 | { |
176 | jumpto(m_startpos); | 176 | jumpto(m_startpos); |
177 | for (int i = 0; i < m_startoffset; i++) | 177 | for (int i = 0; i < m_startoffset; i++) |
178 | { | 178 | { |
179 | getch(); | 179 | getch(); |
180 | } | 180 | } |
181 | if (m_startpos == endpos) | 181 | if (m_startpos == endpos) |
182 | { | 182 | { |
183 | for (int i = m_startoffset; i <= endoffset; i++) | 183 | for (int i = m_startoffset; i <= endoffset; i++) |
184 | { | 184 | { |
185 | wrd += QChar(getch()); | 185 | wrd += QChar(getch()); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | else | 188 | else |
189 | { | 189 | { |
190 | while (buffdoc.explocate() <= endpos) | 190 | while (buffdoc.explocate() <= endpos) |
191 | { | 191 | { |
192 | wrd += QChar(getch()); | 192 | wrd += QChar(getch()); |
193 | } | 193 | } |
194 | for (int i = 0; i < endoffset; i++) | 194 | for (int i = 0; i < endoffset; i++) |
195 | { | 195 | { |
196 | wrd += QChar(getch()); | 196 | wrd += QChar(getch()); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | jumpto(currentpos); | 199 | jumpto(currentpos); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | } | 202 | } |
203 | else if (m_bMonoSpaced) | 203 | else if (m_bMonoSpaced) |
204 | { | 204 | { |
205 | int chno = _e->x()/m_charWidth; | 205 | int chno = _e->x()/m_charWidth; |
206 | if (chno < ustrlen(textarray[lineno]->data())) | 206 | if (chno < ustrlen(textarray[lineno]->data())) |
207 | { | 207 | { |
208 | wrd[0] = textarray[lineno]->data()[chno]; | 208 | wrd[0] = textarray[lineno]->data()[chno]; |
209 | } | 209 | } |
210 | } | 210 | } |
211 | else | 211 | else |
212 | { | 212 | { |
213 | CDrawBuffer* t = textarray[lineno]; | 213 | CDrawBuffer* t = textarray[lineno]; |
214 | int first = 0; | 214 | int first = 0; |
215 | while (1) | 215 | while (1) |
216 | { | 216 | { |
217 | int i = first+1; | 217 | int i = first+1; |
218 | while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; | 218 | while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; |
219 | if (t->width(i) > _e->x()) | 219 | if (t->width(i) > _e->x()) |
220 | { | 220 | { |
221 | wrd = toQString(t->data()+first, i - first); | 221 | wrd = toQString(t->data()+first, i - first); |
222 | break; | 222 | break; |
223 | } | 223 | } |
224 | while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; | 224 | while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; |
225 | if ((*t)[i] == 0) break; | 225 | if ((*t)[i] == 0) break; |
226 | first = i; | 226 | first = i; |
227 | } | 227 | } |
228 | } | 228 | } |
229 | if (!wrd.isEmpty()) | 229 | if (!wrd.isEmpty()) |
230 | { | 230 | { |
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index ef1f4f1..8726df7 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -1520,385 +1520,385 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1520 | } | 1520 | } |
1521 | if (regVisible) | 1521 | if (regVisible) |
1522 | { | 1522 | { |
1523 | regBar->hide(); | 1523 | regBar->hide(); |
1524 | regVisible = false; | 1524 | regVisible = false; |
1525 | return; | 1525 | return; |
1526 | } | 1526 | } |
1527 | if (searchVisible) | 1527 | if (searchVisible) |
1528 | { | 1528 | { |
1529 | searchBar->hide(); | 1529 | searchBar->hide(); |
1530 | searchVisible = false; | 1530 | searchVisible = false; |
1531 | return; | 1531 | return; |
1532 | } | 1532 | } |
1533 | if (m_fBkmksChanged && pBkmklist != NULL) | 1533 | if (m_fBkmksChanged && pBkmklist != NULL) |
1534 | { | 1534 | { |
1535 | if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0) | 1535 | if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0) |
1536 | savebkmks(); | 1536 | savebkmks(); |
1537 | delete pBkmklist; | 1537 | delete pBkmklist; |
1538 | pBkmklist = NULL; | 1538 | pBkmklist = NULL; |
1539 | m_fBkmksChanged = false; | 1539 | m_fBkmksChanged = false; |
1540 | } | 1540 | } |
1541 | bFromDocView = FALSE; | 1541 | bFromDocView = FALSE; |
1542 | saveprefs(); | 1542 | saveprefs(); |
1543 | e->accept(); | 1543 | e->accept(); |
1544 | } | 1544 | } |
1545 | else | 1545 | else |
1546 | { | 1546 | { |
1547 | showEditTools(); | 1547 | showEditTools(); |
1548 | } | 1548 | } |
1549 | } | 1549 | } |
1550 | } | 1550 | } |
1551 | 1551 | ||
1552 | void QTReaderApp::do_gotomark() | 1552 | void QTReaderApp::do_gotomark() |
1553 | { | 1553 | { |
1554 | m_nRegAction = cGotoBkmk; | 1554 | m_nRegAction = cGotoBkmk; |
1555 | listbkmk(); | 1555 | listbkmk(); |
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | void QTReaderApp::do_delmark() | 1558 | void QTReaderApp::do_delmark() |
1559 | { | 1559 | { |
1560 | m_nRegAction = cDelBkmk; | 1560 | m_nRegAction = cDelBkmk; |
1561 | listbkmk(); | 1561 | listbkmk(); |
1562 | } | 1562 | } |
1563 | 1563 | ||
1564 | void QTReaderApp::listbkmk() | 1564 | void QTReaderApp::listbkmk() |
1565 | { | 1565 | { |
1566 | bkmkselector->clear(); | 1566 | bkmkselector->clear(); |
1567 | int cnt = 0; | 1567 | int cnt = 0; |
1568 | if (pBkmklist != NULL) | 1568 | if (pBkmklist != NULL) |
1569 | { | 1569 | { |
1570 | for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++) | 1570 | for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++) |
1571 | { | 1571 | { |
1572 | #ifdef _UNICODE | 1572 | #ifdef _UNICODE |
1573 | bkmkselector->insertItem(toQString(i->name())); | 1573 | bkmkselector->insertItem(toQString(i->name())); |
1574 | #else | 1574 | #else |
1575 | bkmkselector->insertItem(i->name()); | 1575 | bkmkselector->insertItem(i->name()); |
1576 | #endif | 1576 | #endif |
1577 | cnt++; | 1577 | cnt++; |
1578 | } | 1578 | } |
1579 | } | 1579 | } |
1580 | if (cnt > 0) | 1580 | if (cnt > 0) |
1581 | { | 1581 | { |
1582 | //tjw menu->hide(); | 1582 | //tjw menu->hide(); |
1583 | editBar->hide(); | 1583 | editBar->hide(); |
1584 | if (m_fontVisible) m_fontBar->hide(); | 1584 | if (m_fontVisible) m_fontBar->hide(); |
1585 | if (regVisible) regBar->hide(); | 1585 | if (regVisible) regBar->hide(); |
1586 | if (searchVisible) searchBar->hide(); | 1586 | if (searchVisible) searchBar->hide(); |
1587 | editorStack->raiseWidget( bkmkselector ); | 1587 | editorStack->raiseWidget( bkmkselector ); |
1588 | } | 1588 | } |
1589 | else | 1589 | else |
1590 | QMessageBox::information(this, "OpieReader", "No bookmarks in memory"); | 1590 | QMessageBox::information(this, "OpieReader", "No bookmarks in memory"); |
1591 | } | 1591 | } |
1592 | 1592 | ||
1593 | void QTReaderApp::do_autogen() | 1593 | void QTReaderApp::do_autogen() |
1594 | { | 1594 | { |
1595 | m_nRegAction = cAutoGen; | 1595 | m_nRegAction = cAutoGen; |
1596 | regEdit->setText(m_autogenstr); | 1596 | regEdit->setText(m_autogenstr); |
1597 | do_regedit(); | 1597 | do_regedit(); |
1598 | } | 1598 | } |
1599 | 1599 | ||
1600 | void QTReaderApp::do_regedit() | 1600 | void QTReaderApp::do_regedit() |
1601 | { | 1601 | { |
1602 | // editBar->hide(); | 1602 | // editBar->hide(); |
1603 | regBar->show(); | 1603 | regBar->show(); |
1604 | regVisible = true; | 1604 | regVisible = true; |
1605 | regEdit->setFocus(); | 1605 | regEdit->setFocus(); |
1606 | } | 1606 | } |
1607 | 1607 | ||
1608 | void QTReaderApp::gotobkmk(int ind) | 1608 | void QTReaderApp::gotobkmk(int ind) |
1609 | { | 1609 | { |
1610 | switch (m_nRegAction) | 1610 | switch (m_nRegAction) |
1611 | { | 1611 | { |
1612 | case cGotoBkmk: | 1612 | case cGotoBkmk: |
1613 | reader->locate((*pBkmklist)[ind]->value()); | 1613 | reader->locate((*pBkmklist)[ind]->value()); |
1614 | break; | 1614 | break; |
1615 | case cDelBkmk: | 1615 | case cDelBkmk: |
1616 | // qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); | 1616 | // qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); |
1617 | pBkmklist->erase(ind); | 1617 | pBkmklist->erase(ind); |
1618 | m_fBkmksChanged = true; | 1618 | m_fBkmksChanged = true; |
1619 | // pBkmklist->sort(); | 1619 | // pBkmklist->sort(); |
1620 | break; | 1620 | break; |
1621 | case cRmBkmkFile: | 1621 | case cRmBkmkFile: |
1622 | unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind))); | 1622 | unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind))); |
1623 | break; | 1623 | break; |
1624 | } | 1624 | } |
1625 | showEditTools(); | 1625 | showEditTools(); |
1626 | } | 1626 | } |
1627 | 1627 | ||
1628 | void QTReaderApp::cancelbkmk() | 1628 | void QTReaderApp::cancelbkmk() |
1629 | { | 1629 | { |
1630 | showEditTools(); | 1630 | showEditTools(); |
1631 | } | 1631 | } |
1632 | 1632 | ||
1633 | void QTReaderApp::jump() | 1633 | void QTReaderApp::jump() |
1634 | { | 1634 | { |
1635 | m_nRegAction = cJump; | 1635 | m_nRegAction = cJump; |
1636 | char lcn[20]; | 1636 | char lcn[20]; |
1637 | sprintf(lcn, "%lu", reader->pagelocate()); | 1637 | sprintf(lcn, "%lu", reader->pagelocate()); |
1638 | regEdit->setText(lcn); | 1638 | regEdit->setText(lcn); |
1639 | do_regedit(); | 1639 | do_regedit(); |
1640 | } | 1640 | } |
1641 | 1641 | ||
1642 | void QTReaderApp::do_jump(const QString& lcn) | 1642 | void QTReaderApp::do_jump(const QString& lcn) |
1643 | { | 1643 | { |
1644 | bool ok; | 1644 | bool ok; |
1645 | unsigned long ulcn = lcn.toULong(&ok); | 1645 | unsigned long ulcn = lcn.toULong(&ok); |
1646 | if (ok) | 1646 | if (ok) |
1647 | reader->locate(ulcn); | 1647 | reader->locate(ulcn); |
1648 | else | 1648 | else |
1649 | QMessageBox::information(this, "OpieReader", "Must be a number"); | 1649 | QMessageBox::information(this, "OpieReader", "Must be a number"); |
1650 | } | 1650 | } |
1651 | 1651 | ||
1652 | void QTReaderApp::do_regaction() | 1652 | void QTReaderApp::do_regaction() |
1653 | { | 1653 | { |
1654 | regBar->hide(); | 1654 | regBar->hide(); |
1655 | regVisible = false; | 1655 | regVisible = false; |
1656 | switch(m_nRegAction) | 1656 | switch(m_nRegAction) |
1657 | { | 1657 | { |
1658 | case cAutoGen: | 1658 | case cAutoGen: |
1659 | do_autogen(regEdit->text()); | 1659 | do_autogen(regEdit->text()); |
1660 | break; | 1660 | break; |
1661 | case cAddBkmk: | 1661 | case cAddBkmk: |
1662 | do_addbkmk(regEdit->text()); | 1662 | do_addbkmk(regEdit->text()); |
1663 | break; | 1663 | break; |
1664 | case cJump: | 1664 | case cJump: |
1665 | do_jump(regEdit->text()); | 1665 | do_jump(regEdit->text()); |
1666 | break; | 1666 | break; |
1667 | case cMonoSpace: | 1667 | case cMonoSpace: |
1668 | do_mono(regEdit->text()); | 1668 | do_mono(regEdit->text()); |
1669 | break; | 1669 | break; |
1670 | case cOverlap: | 1670 | case cOverlap: |
1671 | do_overlap(regEdit->text()); | 1671 | do_overlap(regEdit->text()); |
1672 | break; | 1672 | break; |
1673 | case cSetTarget: | 1673 | case cSetTarget: |
1674 | do_settarget(regEdit->text()); | 1674 | do_settarget(regEdit->text()); |
1675 | break; | 1675 | break; |
1676 | } | 1676 | } |
1677 | reader->restore(); | 1677 | reader->restore(); |
1678 | // editBar->show(); | 1678 | // editBar->show(); |
1679 | reader->setFocus(); | 1679 | reader->setFocus(); |
1680 | } | 1680 | } |
1681 | 1681 | ||
1682 | void QTReaderApp::do_settarget(const QString& _txt) | 1682 | void QTReaderApp::do_settarget(const QString& _txt) |
1683 | { | 1683 | { |
1684 | int ind = _txt.find('/'); | 1684 | int ind = _txt.find('/'); |
1685 | if (ind == -1) | 1685 | if (ind == -1) |
1686 | { | 1686 | { |
1687 | m_targetapp = ""; | 1687 | m_targetapp = ""; |
1688 | m_targetmsg = ""; | 1688 | m_targetmsg = ""; |
1689 | QMessageBox::information(this, "OpieReader", "Format is\nappname/messagename"); | 1689 | QMessageBox::information(this, "OpieReader", "Format is\nappname/messagename"); |
1690 | } | 1690 | } |
1691 | else | 1691 | else |
1692 | { | 1692 | { |
1693 | m_targetapp = _txt.left(ind); | 1693 | m_targetapp = _txt.left(ind); |
1694 | m_targetmsg = _txt.right(_txt.length()-ind-1); | 1694 | m_targetmsg = _txt.right(_txt.length()-ind-1); |
1695 | } | 1695 | } |
1696 | } | 1696 | } |
1697 | 1697 | ||
1698 | void QTReaderApp::setfont() | 1698 | void QTReaderApp::setfont() |
1699 | { | 1699 | { |
1700 | for (int i = 1; i <= m_fontSelector->count(); i++) | 1700 | for (int i = 1; i <= m_fontSelector->count(); i++) |
1701 | { | 1701 | { |
1702 | if (m_fontSelector->text(i) == reader->m_fontname) | 1702 | if (m_fontSelector->text(i) == reader->m_fontname) |
1703 | { | 1703 | { |
1704 | m_fontSelector->setCurrentItem(i); | 1704 | m_fontSelector->setCurrentItem(i); |
1705 | break; | 1705 | break; |
1706 | } | 1706 | } |
1707 | } | 1707 | } |
1708 | m_fontBar->show(); | 1708 | m_fontBar->show(); |
1709 | m_fontVisible = true; | 1709 | m_fontVisible = true; |
1710 | } | 1710 | } |
1711 | 1711 | ||
1712 | void QTReaderApp::setfontHelper(const QString& lcn, int size = 0) | 1712 | void QTReaderApp::setfontHelper(const QString& lcn, int size) |
1713 | { | 1713 | { |
1714 | if (size == 0) size = reader->m_fontControl.currentsize(); | 1714 | if (size == 0) size = reader->m_fontControl.currentsize(); |
1715 | QFont f(lcn, 10 /*, QFont::Bold*/); | 1715 | QFont f(lcn, 10 /*, QFont::Bold*/); |
1716 | bkmkselector->setFont( f ); | 1716 | bkmkselector->setFont( f ); |
1717 | regEdit->setFont( f ); | 1717 | regEdit->setFont( f ); |
1718 | searchEdit->setFont( f ); | 1718 | searchEdit->setFont( f ); |
1719 | m_annoWin->setFont( f ); | 1719 | m_annoWin->setFont( f ); |
1720 | reader->m_fontname = lcn; | 1720 | reader->m_fontname = lcn; |
1721 | if (!reader->ChangeFont(size)) | 1721 | if (!reader->ChangeFont(size)) |
1722 | { | 1722 | { |
1723 | reader->ChangeFont(size); | 1723 | reader->ChangeFont(size); |
1724 | } | 1724 | } |
1725 | reader->refresh(); | 1725 | reader->refresh(); |
1726 | m_fontBar->hide(); | 1726 | m_fontBar->hide(); |
1727 | m_fontVisible = false; | 1727 | m_fontVisible = false; |
1728 | showEditTools(); | 1728 | showEditTools(); |
1729 | } | 1729 | } |
1730 | 1730 | ||
1731 | void QTReaderApp::do_setfont(const QString& lcn) | 1731 | void QTReaderApp::do_setfont(const QString& lcn) |
1732 | { | 1732 | { |
1733 | setfontHelper(lcn); | 1733 | setfontHelper(lcn); |
1734 | } | 1734 | } |
1735 | 1735 | ||
1736 | void QTReaderApp::do_autogen(const QString& regText) | 1736 | void QTReaderApp::do_autogen(const QString& regText) |
1737 | { | 1737 | { |
1738 | unsigned long fs, ts; | 1738 | unsigned long fs, ts; |
1739 | reader->sizes(fs,ts); | 1739 | reader->sizes(fs,ts); |
1740 | // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); | 1740 | // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); |
1741 | m_autogenstr = regText; | 1741 | m_autogenstr = regText; |
1742 | QRegExp re(regText); | 1742 | QRegExp re(regText); |
1743 | CBuffer buff; | 1743 | CBuffer buff; |
1744 | if (pBkmklist != NULL) delete pBkmklist; | 1744 | if (pBkmklist != NULL) delete pBkmklist; |
1745 | pBkmklist = new CList<Bkmk>; | 1745 | pBkmklist = new CList<Bkmk>; |
1746 | m_fBkmksChanged = true; | 1746 | m_fBkmksChanged = true; |
1747 | pbar->show(); | 1747 | pbar->show(); |
1748 | pbar->resize(width(), editBar->height()); | 1748 | pbar->resize(width(), editBar->height()); |
1749 | pbar->reset(); | 1749 | pbar->reset(); |
1750 | qApp->processEvents(); | 1750 | qApp->processEvents(); |
1751 | reader->setFocus(); | 1751 | reader->setFocus(); |
1752 | reader->jumpto(0); | 1752 | reader->jumpto(0); |
1753 | int lastpc = 0; | 1753 | int lastpc = 0; |
1754 | int i = 0; | 1754 | int i = 0; |
1755 | while (i >= 0) | 1755 | while (i >= 0) |
1756 | { | 1756 | { |
1757 | unsigned int lcn = reader->locate(); | 1757 | unsigned int lcn = reader->locate(); |
1758 | int pc = (100*lcn)/ts; | 1758 | int pc = (100*lcn)/ts; |
1759 | if (pc != lastpc) | 1759 | if (pc != lastpc) |
1760 | { | 1760 | { |
1761 | pbar->setProgress(pc); | 1761 | pbar->setProgress(pc); |
1762 | qApp->processEvents(); | 1762 | qApp->processEvents(); |
1763 | if (reader->locate() != lcn) reader->jumpto(lcn); | 1763 | if (reader->locate() != lcn) reader->jumpto(lcn); |
1764 | reader->setFocus(); | 1764 | reader->setFocus(); |
1765 | lastpc = pc; | 1765 | lastpc = pc; |
1766 | } | 1766 | } |
1767 | i = reader->buffdoc.getpara(buff); | 1767 | i = reader->buffdoc.getpara(buff); |
1768 | #ifdef _UNICODE | 1768 | #ifdef _UNICODE |
1769 | if (re.match(toQString(buff.data())) != -1) | 1769 | if (re.match(toQString(buff.data())) != -1) |
1770 | #else | 1770 | #else |
1771 | if (re.match(buff.data()) != -1) | 1771 | if (re.match(buff.data()) != -1) |
1772 | #endif | 1772 | #endif |
1773 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); | 1773 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); |
1774 | } | 1774 | } |
1775 | pBkmklist->sort(); | 1775 | pBkmklist->sort(); |
1776 | pbar->setProgress(100); | 1776 | pbar->setProgress(100); |
1777 | qApp->processEvents(); | 1777 | qApp->processEvents(); |
1778 | pbar->hide(); | 1778 | pbar->hide(); |
1779 | } | 1779 | } |
1780 | 1780 | ||
1781 | void QTReaderApp::saveprefs() | 1781 | void QTReaderApp::saveprefs() |
1782 | { | 1782 | { |
1783 | // reader->saveprefs("uqtreader"); | 1783 | // reader->saveprefs("uqtreader"); |
1784 | Config config( "uqtreader" ); | 1784 | Config config( "uqtreader" ); |
1785 | config.setGroup( "View" ); | 1785 | config.setGroup( "View" ); |
1786 | 1786 | ||
1787 | reader->m_lastposn = reader->pagelocate(); | 1787 | reader->m_lastposn = reader->pagelocate(); |
1788 | 1788 | ||
1789 | config.writeEntry( "StripCr", reader->bstripcr ); | 1789 | config.writeEntry( "StripCr", reader->bstripcr ); |
1790 | config.writeEntry( "AutoFmt", reader->bautofmt ); | 1790 | config.writeEntry( "AutoFmt", reader->bautofmt ); |
1791 | config.writeEntry( "TextFmt", reader->btextfmt ); | 1791 | config.writeEntry( "TextFmt", reader->btextfmt ); |
1792 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 1792 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
1793 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 1793 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
1794 | config.writeEntry( "Unindent", reader->bunindent ); | 1794 | config.writeEntry( "Unindent", reader->bunindent ); |
1795 | config.writeEntry( "Repara", reader->brepara ); | 1795 | config.writeEntry( "Repara", reader->brepara ); |
1796 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | 1796 | config.writeEntry( "DoubleSpace", reader->bdblspce ); |
1797 | config.writeEntry( "Indent", reader->bindenter ); | 1797 | config.writeEntry( "Indent", reader->bindenter ); |
1798 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | 1798 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); |
1799 | config.writeEntry( "ScrollDelay", reader->m_delay); | 1799 | config.writeEntry( "ScrollDelay", reader->m_delay); |
1800 | config.writeEntry( "LastFile", reader->m_lastfile ); | 1800 | config.writeEntry( "LastFile", reader->m_lastfile ); |
1801 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 1801 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
1802 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 1802 | config.writeEntry( "PageMode", reader->m_bpagemode ); |
1803 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 1803 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); |
1804 | config.writeEntry( "Fontname", reader->m_fontname ); | 1804 | config.writeEntry( "Fontname", reader->m_fontname ); |
1805 | config.writeEntry( "Encoding", reader->m_encd ); | 1805 | config.writeEntry( "Encoding", reader->m_encd ); |
1806 | config.writeEntry( "CharSpacing", reader->m_charpc ); | 1806 | config.writeEntry( "CharSpacing", reader->m_charpc ); |
1807 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | 1807 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); |
1808 | config.writeEntry( "TargetApp", m_targetapp ); | 1808 | config.writeEntry( "TargetApp", m_targetapp ); |
1809 | config.writeEntry( "TargetMsg", m_targetmsg ); | 1809 | config.writeEntry( "TargetMsg", m_targetmsg ); |
1810 | config.writeEntry( "TwoTouch", m_twoTouch ); | 1810 | config.writeEntry( "TwoTouch", m_twoTouch ); |
1811 | config.writeEntry( "Annotation", m_doAnnotation); | 1811 | config.writeEntry( "Annotation", m_doAnnotation); |
1812 | config.writeEntry( "Dictionary", m_doDictionary); | 1812 | config.writeEntry( "Dictionary", m_doDictionary); |
1813 | config.writeEntry( "Clipboard", m_doClipboard); | 1813 | config.writeEntry( "Clipboard", m_doClipboard); |
1814 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 1814 | config.writeEntry( "SpaceTarget", m_spaceTarget); |
1815 | config.writeEntry( "Remap", reader->bremap ); | 1815 | config.writeEntry( "Remap", reader->bremap ); |
1816 | config.writeEntry( "Peanut", reader->bpeanut ); | 1816 | config.writeEntry( "Peanut", reader->bpeanut ); |
1817 | config.writeEntry( "MakeBold", reader->bmakebold ); | 1817 | config.writeEntry( "MakeBold", reader->bmakebold ); |
1818 | } | 1818 | } |
1819 | 1819 | ||
1820 | void QTReaderApp::indentplus() | 1820 | void QTReaderApp::indentplus() |
1821 | { | 1821 | { |
1822 | reader->indentplus(); | 1822 | reader->indentplus(); |
1823 | } | 1823 | } |
1824 | 1824 | ||
1825 | void QTReaderApp::indentminus() | 1825 | void QTReaderApp::indentminus() |
1826 | { | 1826 | { |
1827 | reader->indentminus(); | 1827 | reader->indentminus(); |
1828 | } | 1828 | } |
1829 | 1829 | ||
1830 | /* | 1830 | /* |
1831 | void QTReaderApp::oldFile() | 1831 | void QTReaderApp::oldFile() |
1832 | { | 1832 | { |
1833 | qDebug("oldFile called"); | 1833 | qDebug("oldFile called"); |
1834 | reader->setText(true); | 1834 | reader->setText(true); |
1835 | qDebug("settext called"); | 1835 | qDebug("settext called"); |
1836 | showEditTools(); | 1836 | showEditTools(); |
1837 | qDebug("showedit called"); | 1837 | qDebug("showedit called"); |
1838 | } | 1838 | } |
1839 | */ | 1839 | */ |
1840 | 1840 | ||
1841 | /* | 1841 | /* |
1842 | void info_cb(Fl_Widget* o, void* _data) | 1842 | void info_cb(Fl_Widget* o, void* _data) |
1843 | { | 1843 | { |
1844 | 1844 | ||
1845 | if (infowin == NULL) | 1845 | if (infowin == NULL) |
1846 | { | 1846 | { |
1847 | 1847 | ||
1848 | infowin = new Fl_Window(160,240); | 1848 | infowin = new Fl_Window(160,240); |
1849 | filename = new Fl_Output(45,5,110,14,"Filename"); | 1849 | filename = new Fl_Output(45,5,110,14,"Filename"); |
1850 | filesize = new Fl_Output(45,25,110,14,"Filesize"); | 1850 | filesize = new Fl_Output(45,25,110,14,"Filesize"); |
1851 | textsize = new Fl_Output(45,45,110,14,"Textsize"); | 1851 | textsize = new Fl_Output(45,45,110,14,"Textsize"); |
1852 | comprat = new CBar(45,65,110,14,"Ratio %"); | 1852 | comprat = new CBar(45,65,110,14,"Ratio %"); |
1853 | posn = new Fl_Output(45,85,110,14,"Location"); | 1853 | posn = new Fl_Output(45,85,110,14,"Location"); |
1854 | frcn = new CBar(45,105,110,14,"% Read"); | 1854 | frcn = new CBar(45,105,110,14,"% Read"); |
1855 | about = new Fl_Multiline_Output(5,125,150,90); | 1855 | about = new Fl_Multiline_Output(5,125,150,90); |
1856 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); | 1856 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); |
1857 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); | 1857 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); |
1858 | infowin->set_modal(); | 1858 | infowin->set_modal(); |
1859 | } | 1859 | } |
1860 | if (((reader_ui *)_data)->g_filename[0] != '\0') | 1860 | if (((reader_ui *)_data)->g_filename[0] != '\0') |
1861 | { | 1861 | { |
1862 | unsigned long fs,ts; | 1862 | unsigned long fs,ts; |
1863 | tchar sz[20]; | 1863 | tchar sz[20]; |
1864 | ((reader_ui *)_data)->input->sizes(fs,ts); | 1864 | ((reader_ui *)_data)->input->sizes(fs,ts); |
1865 | unsigned long pl = ((reader_ui *)_data)->input->locate(); | 1865 | unsigned long pl = ((reader_ui *)_data)->input->locate(); |
1866 | 1866 | ||
1867 | filename->value(((reader_ui *)_data)->g_filename); | 1867 | filename->value(((reader_ui *)_data)->g_filename); |
1868 | 1868 | ||
1869 | sprintf(sz,"%u",fs); | 1869 | sprintf(sz,"%u",fs); |
1870 | filesize->value(sz); | 1870 | filesize->value(sz); |
1871 | 1871 | ||
1872 | sprintf(sz,"%u",ts); | 1872 | sprintf(sz,"%u",ts); |
1873 | textsize->value(sz); | 1873 | textsize->value(sz); |
1874 | 1874 | ||
1875 | comprat->value(100-(100*fs + (ts >> 1))/ts); | 1875 | comprat->value(100-(100*fs + (ts >> 1))/ts); |
1876 | 1876 | ||
1877 | sprintf(sz,"%u",pl); | 1877 | sprintf(sz,"%u",pl); |
1878 | posn->value(sz); | 1878 | posn->value(sz); |
1879 | 1879 | ||
1880 | frcn->value((100*pl + (ts >> 1))/ts); | 1880 | frcn->value((100*pl + (ts >> 1))/ts); |
1881 | } | 1881 | } |
1882 | infowin->show(); | 1882 | infowin->show(); |
1883 | } | 1883 | } |
1884 | */ | 1884 | */ |
1885 | 1885 | ||
1886 | void QTReaderApp::savebkmks() | 1886 | void QTReaderApp::savebkmks() |
1887 | { | 1887 | { |
1888 | if (pBkmklist != NULL) | 1888 | if (pBkmklist != NULL) |
1889 | { | 1889 | { |
1890 | BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string), true); | 1890 | BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string), true); |
1891 | bf.write(*pBkmklist); | 1891 | bf.write(*pBkmklist); |
1892 | } | 1892 | } |
1893 | m_fBkmksChanged = false; | 1893 | m_fBkmksChanged = false; |
1894 | } | 1894 | } |
1895 | 1895 | ||
1896 | void QTReaderApp::readbkmks() | 1896 | void QTReaderApp::readbkmks() |
1897 | { | 1897 | { |
1898 | if (pBkmklist != NULL) | 1898 | if (pBkmklist != NULL) |
1899 | { | 1899 | { |
1900 | delete pBkmklist; | 1900 | delete pBkmklist; |
1901 | } | 1901 | } |
1902 | BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string)); | 1902 | BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string)); |
1903 | pBkmklist = bf.readall(); | 1903 | pBkmklist = bf.readall(); |
1904 | m_fBkmksChanged = bf.upgraded(); | 1904 | m_fBkmksChanged = bf.upgraded(); |
diff --git a/noncore/apps/opie-reader/infowin.cpp b/noncore/apps/opie-reader/infowin.cpp index 9637a62..7b8f280 100644 --- a/noncore/apps/opie-reader/infowin.cpp +++ b/noncore/apps/opie-reader/infowin.cpp | |||
@@ -1,42 +1,42 @@ | |||
1 | #include "infowin.h" | 1 | #include "infowin.h" |
2 | #include "version.h" | 2 | #include "version.h" |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | 4 | ||
5 | infowin::infowin( QWidget *parent=0, const char *name=0, WFlags f = 0) : | 5 | infowin::infowin( QWidget *parent, const char *name, WFlags f) : |
6 | QWidget(parent, name, f) | 6 | QWidget(parent, name, f) |
7 | { | 7 | { |
8 | grid = new QGridLayout(this, 6, 2); | 8 | grid = new QGridLayout(this, 6, 2); |
9 | QLabel* l; | 9 | QLabel* l; |
10 | l = new QLabel("Compressed file size", this); | 10 | l = new QLabel("Compressed file size", this); |
11 | grid->addWidget(l, 0, 0); | 11 | grid->addWidget(l, 0, 0); |
12 | fileSize = new QLabel("0", this); | 12 | fileSize = new QLabel("0", this); |
13 | fileSize->setAlignment( AlignVCenter | AlignRight ); | 13 | fileSize->setAlignment( AlignVCenter | AlignRight ); |
14 | grid->addWidget(fileSize, 0, 1); | 14 | grid->addWidget(fileSize, 0, 1); |
15 | l = new QLabel("Original text size", this); | 15 | l = new QLabel("Original text size", this); |
16 | grid->addWidget(l, 1, 0); | 16 | grid->addWidget(l, 1, 0); |
17 | textSize = new QLabel("0", this); | 17 | textSize = new QLabel("0", this); |
18 | textSize->setAlignment( AlignVCenter | AlignRight ); | 18 | textSize->setAlignment( AlignVCenter | AlignRight ); |
19 | grid->addWidget(textSize, 1, 1); | 19 | grid->addWidget(textSize, 1, 1); |
20 | l = new QLabel("Compression Ratio", this); | 20 | l = new QLabel("Compression Ratio", this); |
21 | grid->addWidget(l, 2, 0); | 21 | grid->addWidget(l, 2, 0); |
22 | ratio = new QLabel("0", this); | 22 | ratio = new QLabel("0", this); |
23 | grid->addWidget(ratio, 2, 1); | 23 | grid->addWidget(ratio, 2, 1); |
24 | ratio->setAlignment( AlignVCenter | AlignRight ); | 24 | ratio->setAlignment( AlignVCenter | AlignRight ); |
25 | l = new QLabel("Current location", this); | 25 | l = new QLabel("Current location", this); |
26 | grid->addWidget(l, 3, 0); | 26 | grid->addWidget(l, 3, 0); |
27 | location = new QLabel("0", this); | 27 | location = new QLabel("0", this); |
28 | location->setAlignment( AlignVCenter | AlignRight ); | 28 | location->setAlignment( AlignVCenter | AlignRight ); |
29 | grid->addWidget(location, 3, 1); | 29 | grid->addWidget(location, 3, 1); |
30 | l = new QLabel("Per centage read", this); | 30 | l = new QLabel("Per centage read", this); |
31 | grid->addWidget(l, 4, 0); | 31 | grid->addWidget(l, 4, 0); |
32 | read = new QLabel("0", this); | 32 | read = new QLabel("0", this); |
33 | read->setAlignment( AlignVCenter | AlignRight ); | 33 | read->setAlignment( AlignVCenter | AlignRight ); |
34 | grid->addWidget(read, 4, 1); | 34 | grid->addWidget(read, 4, 1); |
35 | char vstr[128]; | 35 | char vstr[128]; |
36 | sprintf(vstr, "QT Reader v%u.%u%c (%s)\nA small e-text reader", MAJOR, BKMKTYPE, MINOR, RELEASE_TYPE); | 36 | sprintf(vstr, "QT Reader v%u.%u%c (%s)\nA small e-text reader", MAJOR, BKMKTYPE, MINOR, RELEASE_TYPE); |
37 | l = new QLabel(vstr, this); | 37 | l = new QLabel(vstr, this); |
38 | grid->addWidget(l, 5, 0); | 38 | grid->addWidget(l, 5, 0); |
39 | QPushButton* exitbutton = new QPushButton("Cancel", this); | 39 | QPushButton* exitbutton = new QPushButton("Cancel", this); |
40 | connect( exitbutton, SIGNAL( released() ), this, SLOT( infoClose() ) ); | 40 | connect( exitbutton, SIGNAL( released() ), this, SLOT( infoClose() ) ); |
41 | grid->addWidget(exitbutton, 5, 1); | 41 | grid->addWidget(exitbutton, 5, 1); |
42 | } | 42 | } |