summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Bkmks.cpp2
-rw-r--r--noncore/apps/opie-reader/CBuffer.cpp4
-rw-r--r--noncore/apps/opie-reader/QTReader.cpp4
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp2
-rw-r--r--noncore/apps/opie-reader/infowin.cpp2
5 files changed, 7 insertions, 7 deletions
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp
index 998601a..a8bee13 100644
--- a/noncore/apps/opie-reader/Bkmks.cpp
+++ b/noncore/apps/opie-reader/Bkmks.cpp
@@ -1,322 +1,322 @@
1#include "name.h" 1#include "name.h"
2#include <qmessagebox.h> 2#include <qmessagebox.h>
3 3
4#include "Bkmks.h" 4#include "Bkmks.h"
5 5
6#include "StyleConsts.h" 6#include "StyleConsts.h"
7#include "Markups.h" 7#include "Markups.h"
8#include "my_list.h" 8#include "my_list.h"
9#include "version.h" 9#include "version.h"
10 10
11const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); 11const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE);
12 12
13Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) : m_position(_p) 13Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) : m_position(_p)
14{ 14{
15 init(_nm, _nmlen, _anno, _annolen, _p); 15 init(_nm, _nmlen, _anno, _annolen, _p);
16} 16}
17 17
18Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p) 18Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p)
19{ 19{
20 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p); 20 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p);
21} 21}
22 22
23Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) 23Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p)
24{ 24{
25 25
26 if (_anno == NULL) 26 if (_anno == NULL)
27 { 27 {
28 tchar t = 0; 28 tchar t = 0;
29 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); 29 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p);
30 } 30 }
31 else 31 else
32 { 32 {
33 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); 33 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p);
34 } 34 }
35} 35}
36 36
37void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p) 37void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p)
38{ 38{
39 m_namelen = _nmlen; 39 m_namelen = _nmlen;
40 if (m_namelen > 0) 40 if (m_namelen > 0)
41 { 41 {
42 m_name = new unsigned char[m_namelen]; 42 m_name = new unsigned char[m_namelen];
43 memcpy(m_name, _nm, m_namelen); 43 memcpy(m_name, _nm, m_namelen);
44 } 44 }
45 else 45 else
46 { 46 {
47 m_name = NULL; 47 m_name = NULL;
48 } 48 }
49 49
50 m_annolen = _annolen; 50 m_annolen = _annolen;
51 if (m_annolen > 0) 51 if (m_annolen > 0)
52 { 52 {
53 m_anno = new unsigned char[m_annolen]; 53 m_anno = new unsigned char[m_annolen];
54 memcpy(m_anno, _anno, m_annolen); 54 memcpy(m_anno, _anno, m_annolen);
55 } 55 }
56 else 56 else
57 { 57 {
58 m_anno = NULL; 58 m_anno = NULL;
59 } 59 }
60 m_position = _p; 60 m_position = _p;
61} 61}
62 62
63Bkmk::~Bkmk() 63Bkmk::~Bkmk()
64{ 64{
65 if (m_name != NULL) delete [] m_name; 65 if (m_name != NULL) delete [] m_name;
66 m_name = NULL; 66 m_name = NULL;
67 if (m_anno != NULL) delete [] m_anno; 67 if (m_anno != NULL) delete [] m_anno;
68 m_anno = NULL; 68 m_anno = NULL;
69} 69}
70 70
71Bkmk& Bkmk::operator=(const Bkmk& rhs) 71Bkmk& Bkmk::operator=(const Bkmk& rhs)
72{ 72{
73 if (m_name != NULL) 73 if (m_name != NULL)
74 { 74 {
75 delete [] m_name; 75 delete [] m_name;
76 m_name = NULL; 76 m_name = NULL;
77 } 77 }
78 if (m_anno != NULL) 78 if (m_anno != NULL)
79 { 79 {
80 delete [] m_anno; 80 delete [] m_anno;
81 m_anno = NULL; 81 m_anno = NULL;
82 } 82 }
83 if (rhs.m_name != NULL) 83 if (rhs.m_name != NULL)
84 { 84 {
85 m_namelen = rhs.m_namelen; 85 m_namelen = rhs.m_namelen;
86 m_name = new unsigned char[m_namelen]; 86 m_name = new unsigned char[m_namelen];
87 memcpy(m_name, rhs.m_name, m_namelen); 87 memcpy(m_name, rhs.m_name, m_namelen);
88 } 88 }
89 else 89 else
90 m_name = NULL; 90 m_name = NULL;
91 if (rhs.m_anno != NULL) 91 if (rhs.m_anno != NULL)
92 { 92 {
93 m_annolen = rhs.m_annolen; 93 m_annolen = rhs.m_annolen;
94 m_anno = new unsigned char[m_annolen]; 94 m_anno = new unsigned char[m_annolen];
95 memcpy(m_anno, rhs.m_anno, m_annolen); 95 memcpy(m_anno, rhs.m_anno, m_annolen);
96 } 96 }
97 else 97 else
98 m_anno = NULL; 98 m_anno = NULL;
99 m_position = rhs.m_position; 99 m_position = rhs.m_position;
100 return *this; 100 return *this;
101} 101}
102 102
103bool Bkmk::operator==(const Bkmk& rhs) 103bool Bkmk::operator==(const Bkmk& rhs)
104{ 104{
105 return (m_position == rhs.m_position && (rhs.m_namelen == m_namelen) && memcmp(m_name,rhs.m_name,m_namelen) == 0); 105 return (m_position == rhs.m_position && (rhs.m_namelen == m_namelen) && memcmp(m_name,rhs.m_name,m_namelen) == 0);
106} 106}
107 107
108void Bkmk::setAnno(unsigned char* t, unsigned short len) 108void Bkmk::setAnno(unsigned char* t, unsigned short len)
109{ 109{
110 if (m_anno != NULL) 110 if (m_anno != NULL)
111 { 111 {
112 delete [] m_anno; 112 delete [] m_anno;
113 m_anno = NULL; 113 m_anno = NULL;
114 } 114 }
115 if (t != NULL) 115 if (t != NULL)
116 { 116 {
117 m_annolen = len; 117 m_annolen = len;
118 m_anno = new unsigned char[m_annolen]; 118 m_anno = new unsigned char[m_annolen];
119 memcpy(m_anno, t, m_annolen); 119 memcpy(m_anno, t, m_annolen);
120 } 120 }
121 else 121 else
122 { 122 {
123 m_annolen = sizeof(tchar); 123 m_annolen = sizeof(tchar);
124 m_anno = new unsigned char[m_annolen]; 124 m_anno = new unsigned char[m_annolen];
125 *((tchar*)m_anno) = 0; 125 *((tchar*)m_anno) = 0;
126 } 126 }
127} 127}
128 128
129void Bkmk::setAnno(tchar* t) 129void Bkmk::setAnno(tchar* t)
130{ 130{
131 if (m_anno != NULL) 131 if (m_anno != NULL)
132 { 132 {
133 delete [] m_anno; 133 delete [] m_anno;
134 m_anno = NULL; 134 m_anno = NULL;
135 } 135 }
136 if (t != NULL) 136 if (t != NULL)
137 { 137 {
138 unsigned short len = ustrlen(t)+1; 138 unsigned short len = ustrlen(t)+1;
139 m_annolen = sizeof(tchar)*len; 139 m_annolen = sizeof(tchar)*len;
140 m_anno = new unsigned char[m_annolen]; 140 m_anno = new unsigned char[m_annolen];
141 memcpy(m_anno, t, m_annolen); 141 memcpy(m_anno, t, m_annolen);
142 } 142 }
143 else 143 else
144 { 144 {
145 m_annolen = sizeof(tchar); 145 m_annolen = sizeof(tchar);
146 m_anno = new unsigned char[m_annolen]; 146 m_anno = new unsigned char[m_annolen];
147 *((tchar*)m_anno) = 0; 147 *((tchar*)m_anno) = 0;
148 } 148 }
149} 149}
150 150
151BkmkFile::BkmkFile(const char *fnm, bool w = false) 151BkmkFile::BkmkFile(const char *fnm, bool w)
152 : 152 :
153 wt(w), isUpgraded(false) 153 wt(w), isUpgraded(false)
154{ 154{
155 if (w) 155 if (w)
156 { 156 {
157 f = fopen(fnm, "wb"); 157 f = fopen(fnm, "wb");
158 } 158 }
159 else 159 else
160 { 160 {
161 f = fopen(fnm, "rb"); 161 f = fopen(fnm, "rb");
162 } 162 }
163} 163}
164 164
165BkmkFile::~BkmkFile() 165BkmkFile::~BkmkFile()
166{ 166{
167 if (f != NULL) fclose(f); 167 if (f != NULL) fclose(f);
168} 168}
169 169
170void BkmkFile::write(const Bkmk& b) 170void BkmkFile::write(const Bkmk& b)
171{ 171{
172 if (f != NULL) 172 if (f != NULL)
173 { 173 {
174 fwrite(&b.m_namelen, sizeof(b.m_namelen),1,f); 174 fwrite(&b.m_namelen, sizeof(b.m_namelen),1,f);
175 fwrite(b.m_name,1,b.m_namelen,f); 175 fwrite(b.m_name,1,b.m_namelen,f);
176 fwrite(&b.m_annolen, sizeof(b.m_annolen),1,f); 176 fwrite(&b.m_annolen, sizeof(b.m_annolen),1,f);
177 fwrite(b.m_anno,1,b.m_annolen,f); 177 fwrite(b.m_anno,1,b.m_annolen,f);
178 fwrite(&b.m_position,sizeof(b.m_position),1,f); 178 fwrite(&b.m_position,sizeof(b.m_position),1,f);
179 } 179 }
180} 180}
181 181
182void BkmkFile::write(CList<Bkmk>& bl) 182void BkmkFile::write(CList<Bkmk>& bl)
183{ 183{
184 if (f != NULL) 184 if (f != NULL)
185 { 185 {
186 fwrite(&magic, sizeof(magic), 1, f); 186 fwrite(&magic, sizeof(magic), 1, f);
187 for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++) 187 for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++)
188 { 188 {
189 write(*i); 189 write(*i);
190 } 190 }
191 } 191 }
192} 192}
193 193
194CList<Bkmk>* BkmkFile::readall() 194CList<Bkmk>* BkmkFile::readall()
195{ 195{
196 CList<Bkmk>* bl = NULL; 196 CList<Bkmk>* bl = NULL;
197 if (f != NULL) 197 if (f != NULL)
198 { 198 {
199 unsigned long newmagic; 199 unsigned long newmagic;
200 fread(&newmagic, sizeof(newmagic), 1, f); 200 fread(&newmagic, sizeof(newmagic), 1, f);
201 if ((newmagic & 0xffffff00) != (magic & 0xffffff00)) 201 if ((newmagic & 0xffffff00) != (magic & 0xffffff00))
202 { 202 {
203 if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of " PROGNAME "\ndid you upgrade from?", "0_4*", "Any other version") == 0) 203 if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of " PROGNAME "\ndid you upgrade from?", "0_4*", "Any other version") == 0)
204 { 204 {
205 fseek(f,0,SEEK_SET); 205 fseek(f,0,SEEK_SET);
206 bl = readall00(&read05); 206 bl = readall00(&read05);
207 } 207 }
208 else 208 else
209 { 209 {
210 fseek(f,0,SEEK_SET); 210 fseek(f,0,SEEK_SET);
211 bl = readall00(&read03); 211 bl = readall00(&read03);
212 } 212 }
213 isUpgraded = true; 213 isUpgraded = true;
214 } 214 }
215 else 215 else
216 { 216 {
217 switch(newmagic & 0xff) 217 switch(newmagic & 0xff)
218 { 218 {
219 case 6: 219 case 6:
220 isUpgraded = false; 220 isUpgraded = false;
221 bl = readall00(read06); 221 bl = readall00(read06);
222 qDebug("Correct version!"); 222 qDebug("Correct version!");
223 break; 223 break;
224 case 5: 224 case 5:
225 isUpgraded = true; 225 isUpgraded = true;
226 bl = readall00(read05); 226 bl = readall00(read05);
227 qDebug("Known version!"); 227 qDebug("Known version!");
228 break; 228 break;
229 default: 229 default:
230 qDebug("Unknown version!"); 230 qDebug("Unknown version!");
231 isUpgraded = true; 231 isUpgraded = true;
232 bl = readall00(read05); 232 bl = readall00(read05);
233 } 233 }
234 } 234 }
235 } 235 }
236 return bl; 236 return bl;
237} 237}
238 238
239CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(FILE*)) 239CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(FILE*))
240{ 240{
241 CList<Bkmk>* bl = new CList<Bkmk>; 241 CList<Bkmk>* bl = new CList<Bkmk>;
242 while (1) 242 while (1)
243 { 243 {
244 Bkmk* b = (*readfn)(f); 244 Bkmk* b = (*readfn)(f);
245 if (b == NULL) break; 245 if (b == NULL) break;
246 bl->push_back(*b); 246 bl->push_back(*b);
247 delete b; 247 delete b;
248 } 248 }
249 return bl; 249 return bl;
250} 250}
251 251
252Bkmk* BkmkFile::read03(FILE* f) 252Bkmk* BkmkFile::read03(FILE* f)
253{ 253{
254 Bkmk* b = NULL; 254 Bkmk* b = NULL;
255 if (f != NULL) 255 if (f != NULL)
256 { 256 {
257 unsigned short ln; 257 unsigned short ln;
258 if (fread(&ln,sizeof(ln),1,f) == 1) 258 if (fread(&ln,sizeof(ln),1,f) == 1)
259 { 259 {
260 tchar* name = new tchar[ln+1]; 260 tchar* name = new tchar[ln+1];
261 fread(name,sizeof(tchar),ln,f); 261 fread(name,sizeof(tchar),ln,f);
262 name[ln] = 0; 262 name[ln] = 0;
263 263
264 ln = 0; 264 ln = 0;
265 tchar* anno = new tchar[ln+1]; 265 tchar* anno = new tchar[ln+1];
266 anno[ln] = 0; 266 anno[ln] = 0;
267 267
268 unsigned int pos; 268 unsigned int pos;
269 fread(&pos,sizeof(pos),1,f); 269 fread(&pos,sizeof(pos),1,f);
270 b = new Bkmk(name,anno,pos); 270 b = new Bkmk(name,anno,pos);
271 } 271 }
272 } 272 }
273 return b; 273 return b;
274} 274}
275 275
276Bkmk* BkmkFile::read05(FILE* f) 276Bkmk* BkmkFile::read05(FILE* f)
277{ 277{
278 Bkmk* b = NULL; 278 Bkmk* b = NULL;
279 if (f != NULL) 279 if (f != NULL)
280 { 280 {
281 unsigned short ln; 281 unsigned short ln;
282 if (fread(&ln,sizeof(ln),1,f) == 1) 282 if (fread(&ln,sizeof(ln),1,f) == 1)
283 { 283 {
284 tchar* nm = new tchar[ln+1]; 284 tchar* nm = new tchar[ln+1];
285 fread(nm,sizeof(tchar),ln,f); 285 fread(nm,sizeof(tchar),ln,f);
286 nm[ln] = 0; 286 nm[ln] = 0;
287 fread(&ln,sizeof(ln),1,f); 287 fread(&ln,sizeof(ln),1,f);
288 tchar* anno = new tchar[ln+1]; 288 tchar* anno = new tchar[ln+1];
289 if (ln > 0) fread(anno,sizeof(tchar),ln,f); 289 if (ln > 0) fread(anno,sizeof(tchar),ln,f);
290 anno[ln] = 0; 290 anno[ln] = 0;
291 unsigned int pos; 291 unsigned int pos;
292 fread(&pos,sizeof(pos),1,f); 292 fread(&pos,sizeof(pos),1,f);
293 b = new Bkmk(nm,anno,pos); 293 b = new Bkmk(nm,anno,pos);
294 } 294 }
295 } 295 }
296 return b; 296 return b;
297} 297}
298 298
299Bkmk* BkmkFile::read06(FILE* f) 299Bkmk* BkmkFile::read06(FILE* f)
300{ 300{
301 Bkmk* b = NULL; 301 Bkmk* b = NULL;
302 if (f != NULL) 302 if (f != NULL)
303 { 303 {
304 unsigned short ln; 304 unsigned short ln;
305 if (fread(&ln,sizeof(ln),1,f) == 1) 305 if (fread(&ln,sizeof(ln),1,f) == 1)
306 { 306 {
307 b = new Bkmk; 307 b = new Bkmk;
308 b->m_namelen = ln; 308 b->m_namelen = ln;
309 b->m_name = new unsigned char[b->m_namelen]; 309 b->m_name = new unsigned char[b->m_namelen];
310 fread(b->m_name,1,b->m_namelen,f); 310 fread(b->m_name,1,b->m_namelen,f);
311 311
312 fread(&(b->m_annolen),sizeof(b->m_annolen),1,f); 312 fread(&(b->m_annolen),sizeof(b->m_annolen),1,f);
313 if (b->m_annolen > 0) 313 if (b->m_annolen > 0)
314 { 314 {
315 b->m_anno = new unsigned char[b->m_annolen]; 315 b->m_anno = new unsigned char[b->m_annolen];
316 fread(b->m_anno,1,b->m_annolen,f); 316 fread(b->m_anno,1,b->m_annolen,f);
317 } 317 }
318 fread(&(b->m_position),sizeof(b->m_position),1,f); 318 fread(&(b->m_position),sizeof(b->m_position),1,f);
319 } 319 }
320 } 320 }
321 return b; 321 return b;
322} 322}
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
3CBufferBase& CBufferBase::assign(const void* sztmp, size_t ms) 3CBufferBase& 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
14CBufferBase::CBufferBase(size_t ms, size_t n = 16) : len(n), membersize(ms) 14CBufferBase::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
20void* CBufferBase::operator[](int i) 20void* 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
34size_t CBufferBase::bstrlen(unsigned char* _buffer = NULL) 34size_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/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp
index 3995ee7..f2ee027 100644
--- a/noncore/apps/opie-reader/QTReader.cpp
+++ b/noncore/apps/opie-reader/QTReader.cpp
@@ -1,252 +1,252 @@
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#include "StateData.h" 25#include "StateData.h"
26 26
27#ifdef _UNICODE 27#ifdef _UNICODE
28const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; 28const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 };
29#else 29#else
30const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; 30const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 };
31#endif 31#endif
32//const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; 32//const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 };
33 33
34//const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; 34//const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 };
35//const int QTReader::fontsizes[] = {10,16,17,22,0}; 35//const int QTReader::fontsizes[] = {10,16,17,22,0};
36//const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; 36//const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 };
37//const int QTReader::fontsizes[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0}; 37//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};
38 38
39QTReader::QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0) : 39QTReader::QTReader( QWidget *parent, const char *name, WFlags f) :
40 QWidget(parent, name, f), 40 QWidget(parent, name, f),
41 m_delay(100), 41 m_delay(100),
42 m_scrolldy1(0), 42 m_scrolldy1(0),
43 m_scrolldy2(0), 43 m_scrolldy2(0),
44 m_autoScroll(false), 44 m_autoScroll(false),
45 //textarray(NULL), 45 //textarray(NULL),
46 //locnarray(NULL), 46 //locnarray(NULL),
47 numlines(0), 47 numlines(0),
48 m_fontname("unifont"), 48 m_fontname("unifont"),
49 m_fm(NULL), 49 m_fm(NULL),
50 mouseUpOn(true), 50 mouseUpOn(true),
51 m_twotouch(true), 51 m_twotouch(true),
52 m_touchone(true), 52 m_touchone(true),
53 bDoUpdates(false), 53 bDoUpdates(false),
54 m_navkeys(true) 54 m_navkeys(true)
55{ 55{
56 m_overlap = 1; 56 m_overlap = 1;
57// init(); 57// init();
58} 58}
59/* 59/*
60QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : 60QTReader::QTReader( const QString& filename, QWidget *parent, const tchar *name, WFlags f ) :
61 QWidget(parent, name, f), 61 QWidget(parent, name, f),
62 m_textfont(0), 62 m_textfont(0),
63 m_textsize(1), 63 m_textsize(1),
64 textarray(NULL), 64 textarray(NULL),
65 numlines(0), 65 numlines(0),
66 bstripcr(true), 66 bstripcr(true),
67 bunindent(false), 67 bunindent(false),
68 brepara(false), 68 brepara(false),
69 bdblspce(false), 69 bdblspce(false),
70 btight(false), 70 btight(false),
71 bindenter(0), 71 bindenter(0),
72 m_fm(NULL) 72 m_fm(NULL)
73{ 73{
74 init(); 74 init();
75 // qDebug("Load_file(1)"); 75 // qDebug("Load_file(1)");
76 load_file((const tchar*)filename); 76 load_file((const tchar*)filename);
77} 77}
78*/ 78*/
79 79
80long QTReader::real_delay() 80long QTReader::real_delay()
81{ 81{
82 return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); 82 return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing );
83} 83}
84 84
85void QTReader::mousePressEvent( QMouseEvent* _e ) 85void QTReader::mousePressEvent( QMouseEvent* _e )
86{ 86{
87 buffdoc.unsuspend(); 87 buffdoc.unsuspend();
88 if (_e->button() == RightButton) 88 if (_e->button() == RightButton)
89 { 89 {
90 mouseUpOn = false; 90 mouseUpOn = false;
91 if (buffdoc.hasnavigation()) 91 if (buffdoc.hasnavigation())
92 { 92 {
93 if (_e->y() > (2*height())/3) 93 if (_e->y() > (2*height())/3)
94 { 94 {
95 goDown(); 95 goDown();
96 } 96 }
97 else if (_e->y() < height()/3) 97 else if (_e->y() < height()/3)
98 { 98 {
99 goUp(); 99 goUp();
100 } 100 }
101 else 101 else
102 { 102 {
103 if (_e->x() < width()/3) 103 if (_e->x() < width()/3)
104 { 104 {
105 size_t target = pagelocate(); 105 size_t target = pagelocate();
106 if (buffdoc.back(target)) 106 if (buffdoc.back(target))
107 { 107 {
108 locate(target); 108 locate(target);
109 } 109 }
110 } 110 }
111 else if (_e->x() > (2*width())/3) 111 else if (_e->x() > (2*width())/3)
112 { 112 {
113 size_t target = pagelocate(); 113 size_t target = pagelocate();
114 if (buffdoc.forward(target)) 114 if (buffdoc.forward(target))
115 { 115 {
116 locate(target); 116 locate(target);
117 } 117 }
118 } 118 }
119 else 119 else
120 { 120 {
121 buffdoc.saveposn(pagelocate()); 121 buffdoc.saveposn(pagelocate());
122 locate(buffdoc.getHome()); 122 locate(buffdoc.getHome());
123 } 123 }
124 } 124 }
125 } 125 }
126 else 126 else
127 { 127 {
128 if (_e->y() > height()/2) 128 if (_e->y() > height()/2)
129 { 129 {
130 goDown(); 130 goDown();
131 } 131 }
132 else 132 else
133 { 133 {
134 goUp(); 134 goUp();
135 } 135 }
136 } 136 }
137 } 137 }
138} 138}
139 139
140linkType QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt) 140linkType QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt)
141{ 141{
142 int lineno = 0; 142 int lineno = 0;
143 int ht = textarray[0]->lineSpacing(); 143 int ht = textarray[0]->lineSpacing();
144 while ((ht < y) && (lineno < numlines)) 144 while ((ht < y) && (lineno < numlines))
145 { 145 {
146 ht += textarray[++lineno]->lineSpacing(); 146 ht += textarray[++lineno]->lineSpacing();
147 } 147 }
148 start = locnarray[lineno]; 148 start = locnarray[lineno];
149 if (m_bMonoSpaced) 149 if (m_bMonoSpaced)
150 { 150 {
151 offset = x/m_charWidth; 151 offset = x/m_charWidth;
152 } 152 }
153 else 153 else
154 { 154 {
155 int i; 155 int i;
156 CDrawBuffer* t = textarray[lineno]; 156 CDrawBuffer* t = textarray[lineno];
157 x = x - t->offset(width()); 157 x = x - t->offset(width());
158 for (i = t->length(); i >= 0 && t->width(i) > x; i--); 158 for (i = t->length(); i >= 0 && t->width(i) > x; i--);
159 offset = i; 159 offset = i;
160 } 160 }
161 return textarray[lineno]->getLinkType(offset, tgt); 161 return textarray[lineno]->getLinkType(offset, tgt);
162} 162}
163 163
164void QTReader::setTwoTouch(bool _b) 164void QTReader::setTwoTouch(bool _b)
165{ 165{
166 setBackgroundColor( white ); 166 setBackgroundColor( white );
167 m_twotouch = m_touchone = _b; 167 m_twotouch = m_touchone = _b;
168} 168}
169 169
170void QTReader::setContinuous(bool _b) 170void QTReader::setContinuous(bool _b)
171{ 171{
172 buffdoc.unsuspend(); 172 buffdoc.unsuspend();
173 buffdoc.setContinuous(m_continuousDocument = _b); 173 buffdoc.setContinuous(m_continuousDocument = _b);
174} 174}
175 175
176void QTReader::mouseReleaseEvent( QMouseEvent* _e ) 176void QTReader::mouseReleaseEvent( QMouseEvent* _e )
177{ 177{
178 buffdoc.unsuspend(); 178 buffdoc.unsuspend();
179 if (_e->button() == LeftButton) 179 if (_e->button() == LeftButton)
180 { 180 {
181 if (mouseUpOn) 181 if (mouseUpOn)
182 { 182 {
183 if (textarray[0] != NULL) 183 if (textarray[0] != NULL)
184 { 184 {
185 QString wrd, line; 185 QString wrd, line;
186 // int lineno = _e->y()/m_linespacing; 186 // int lineno = _e->y()/m_linespacing;
187 int lineno = 0; 187 int lineno = 0;
188 int ht = textarray[0]->lineSpacing(); 188 int ht = textarray[0]->lineSpacing();
189 while ((ht < _e->y()) && (lineno < numlines)) 189 while ((ht < _e->y()) && (lineno < numlines))
190 { 190 {
191 ht += textarray[++lineno]->lineSpacing(); 191 ht += textarray[++lineno]->lineSpacing();
192 } 192 }
193 size_t startpos, startoffset, tgt; 193 size_t startpos, startoffset, tgt;
194 switch (getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt)) 194 switch (getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt))
195 { 195 {
196 case eLink: 196 case eLink:
197 { 197 {
198 size_t saveposn = pagelocate(); 198 size_t saveposn = pagelocate();
199 if (buffdoc.hyperlink(tgt)) 199 if (buffdoc.hyperlink(tgt))
200 { 200 {
201 buffdoc.saveposn(saveposn); 201 buffdoc.saveposn(saveposn);
202 fillbuffer(); 202 fillbuffer();
203 update(); 203 update();
204 } 204 }
205 else 205 else
206 { 206 {
207 locate(pagelocate()); 207 locate(pagelocate());
208 } 208 }
209 return; 209 return;
210 } 210 }
211 case ePicture: 211 case ePicture:
212 { 212 {
213 qDebug("Picture:%x", tgt); 213 qDebug("Picture:%x", tgt);
214 QPixmap* pm = buffdoc.getPicture(tgt); 214 QPixmap* pm = buffdoc.getPicture(tgt);
215 if (pm != NULL) 215 if (pm != NULL)
216 { 216 {
217 emit OnShowPicture(*pm); 217 emit OnShowPicture(*pm);
218 delete pm; 218 delete pm;
219 } 219 }
220 else 220 else
221 { 221 {
222 locate(pagelocate()); 222 locate(pagelocate());
223 } 223 }
224 return; 224 return;
225 } 225 }
226 case eNone: 226 case eNone:
227 break; 227 break;
228 default: 228 default:
229 qDebug("Unknown linktype"); 229 qDebug("Unknown linktype");
230 return; 230 return;
231 } 231 }
232 if (m_twotouch) 232 if (m_twotouch)
233 { 233 {
234 if (m_touchone) 234 if (m_touchone)
235 { 235 {
236 m_touchone = false; 236 m_touchone = false;
237 m_startpos = startpos; 237 m_startpos = startpos;
238 m_startoffset = startoffset; 238 m_startoffset = startoffset;
239 setBackgroundColor( lightGray ); 239 setBackgroundColor( lightGray );
240 } 240 }
241 else 241 else
242 { 242 {
243 m_touchone = true; 243 m_touchone = true;
244 setBackgroundColor( white ); 244 setBackgroundColor( white );
245 size_t endpos, endoffset; 245 size_t endpos, endoffset;
246 endpos = startpos; 246 endpos = startpos;
247 endoffset = startoffset; 247 endoffset = startoffset;
248 size_t currentpos = locate(); 248 size_t currentpos = locate();
249 if (endpos >= m_startpos) 249 if (endpos >= m_startpos)
250 { 250 {
251 jumpto(m_startpos); 251 jumpto(m_startpos);
252 for (int i = 0; i < m_startoffset; i++) 252 for (int i = 0; i < m_startoffset; i++)
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index 2044b1d..7333a28 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -1980,385 +1980,385 @@ void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
1980 editorStack->raiseWidget( bkmkselector ); 1980 editorStack->raiseWidget( bkmkselector );
1981 } 1981 }
1982 else 1982 else
1983 QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); 1983 QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
1984} 1984}
1985 1985
1986void QTReaderApp::do_autogen() 1986void QTReaderApp::do_autogen()
1987{ 1987{
1988 m_nRegAction = cAutoGen; 1988 m_nRegAction = cAutoGen;
1989 regEdit->setText(m_autogenstr); 1989 regEdit->setText(m_autogenstr);
1990 do_regedit(); 1990 do_regedit();
1991} 1991}
1992 1992
1993void QTReaderApp::do_regedit() 1993void QTReaderApp::do_regedit()
1994{ 1994{
1995// editBar->hide(); 1995// editBar->hide();
1996 reader->bDoUpdates = false; 1996 reader->bDoUpdates = false;
1997 qDebug("Showing regbar"); 1997 qDebug("Showing regbar");
1998 regBar->show(); 1998 regBar->show();
1999 qDebug("Showing kbd"); 1999 qDebug("Showing kbd");
2000 Global::showInputMethod(); 2000 Global::showInputMethod();
2001 regVisible = true; 2001 regVisible = true;
2002 regEdit->setFocus(); 2002 regEdit->setFocus();
2003 qApp->processEvents(); 2003 qApp->processEvents();
2004 reader->bDoUpdates = true; 2004 reader->bDoUpdates = true;
2005 reader->update(); 2005 reader->update();
2006} 2006}
2007 2007
2008bool QTReaderApp::openfrombkmk(Bkmk* bk) 2008bool QTReaderApp::openfrombkmk(Bkmk* bk)
2009{ 2009{
2010 QString fn = toQString( 2010 QString fn = toQString(
2011 CFiledata(bk->anno()).name() 2011 CFiledata(bk->anno()).name()
2012 ); 2012 );
2013 qDebug("fileinfo"); 2013 qDebug("fileinfo");
2014 if (!fn.isEmpty() && QFileInfo(fn).isFile()) 2014 if (!fn.isEmpty() && QFileInfo(fn).isFile())
2015 { 2015 {
2016 qDebug("Opening"); 2016 qDebug("Opening");
2017 openFile(fn); 2017 openFile(fn);
2018 struct stat fnstat; 2018 struct stat fnstat;
2019 stat((const char *)reader->m_lastfile, &fnstat); 2019 stat((const char *)reader->m_lastfile, &fnstat);
2020 2020
2021 if (CFiledata(bk->anno()).date() 2021 if (CFiledata(bk->anno()).date()
2022 != fnstat.st_mtime) 2022 != fnstat.st_mtime)
2023 { 2023 {
2024 CFiledata fd(bk->anno()); 2024 CFiledata fd(bk->anno());
2025 fd.setdate(fnstat.st_mtime); 2025 fd.setdate(fnstat.st_mtime);
2026 bk->value(0); 2026 bk->value(0);
2027 } 2027 }
2028 else 2028 else
2029 { 2029 {
2030 unsigned short svlen = bk->filedatalen(); 2030 unsigned short svlen = bk->filedatalen();
2031 unsigned char* svdata = bk->filedata(); 2031 unsigned char* svdata = bk->filedata();
2032 reader->putSaveData(svdata, svlen); 2032 reader->putSaveData(svdata, svlen);
2033 // setstate(svdata, svlen); 2033 // setstate(svdata, svlen);
2034 if (svlen != 0) 2034 if (svlen != 0)
2035 { 2035 {
2036 QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); 2036 QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?");
2037 } 2037 }
2038 qDebug("updating"); 2038 qDebug("updating");
2039 reader->locate(bk->value()); 2039 reader->locate(bk->value());
2040 } 2040 }
2041 return true; 2041 return true;
2042 } 2042 }
2043 else 2043 else
2044 { 2044 {
2045 return false; 2045 return false;
2046 } 2046 }
2047} 2047}
2048 2048
2049void QTReaderApp::gotobkmk(int ind) 2049void QTReaderApp::gotobkmk(int ind)
2050{ 2050{
2051 switch (m_nRegAction) 2051 switch (m_nRegAction)
2052 { 2052 {
2053 case cOpenFile: 2053 case cOpenFile:
2054 { 2054 {
2055 if (!openfrombkmk((*pOpenlist)[ind])) 2055 if (!openfrombkmk((*pOpenlist)[ind]))
2056 { 2056 {
2057 pOpenlist->erase(ind); 2057 pOpenlist->erase(ind);
2058 QMessageBox::information(this, PROGNAME, "Can't find file"); 2058 QMessageBox::information(this, PROGNAME, "Can't find file");
2059 } 2059 }
2060 } 2060 }
2061 break; 2061 break;
2062 case cGotoBkmk: 2062 case cGotoBkmk:
2063 reader->locate((*pBkmklist)[ind]->value()); 2063 reader->locate((*pBkmklist)[ind]->value());
2064 break; 2064 break;
2065 case cDelBkmk: 2065 case cDelBkmk:
2066 // qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); 2066 // qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name());
2067 pBkmklist->erase(ind); 2067 pBkmklist->erase(ind);
2068 m_fBkmksChanged = true; 2068 m_fBkmksChanged = true;
2069 // pBkmklist->sort(); 2069 // pBkmklist->sort();
2070 break; 2070 break;
2071 case cRmBkmkFile: 2071 case cRmBkmkFile:
2072 unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); 2072 unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind)));
2073 break; 2073 break;
2074 } 2074 }
2075 showEditTools(); 2075 showEditTools();
2076} 2076}
2077 2077
2078void QTReaderApp::cancelbkmk() 2078void QTReaderApp::cancelbkmk()
2079{ 2079{
2080 if (m_nRegAction == cOpenFile) 2080 if (m_nRegAction == cOpenFile)
2081 { 2081 {
2082 QString fn = usefilebrowser(); 2082 QString fn = usefilebrowser();
2083 if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); 2083 if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn);
2084 } 2084 }
2085 showEditTools(); 2085 showEditTools();
2086} 2086}
2087 2087
2088void QTReaderApp::jump() 2088void QTReaderApp::jump()
2089{ 2089{
2090 m_nRegAction = cJump; 2090 m_nRegAction = cJump;
2091 char lcn[20]; 2091 char lcn[20];
2092 sprintf(lcn, "%lu", reader->pagelocate()); 2092 sprintf(lcn, "%lu", reader->pagelocate());
2093 regEdit->setText(lcn); 2093 regEdit->setText(lcn);
2094 do_regedit(); 2094 do_regedit();
2095} 2095}
2096 2096
2097void QTReaderApp::do_jump(const QString& lcn) 2097void QTReaderApp::do_jump(const QString& lcn)
2098{ 2098{
2099 bool ok; 2099 bool ok;
2100 unsigned long ulcn = lcn.toULong(&ok); 2100 unsigned long ulcn = lcn.toULong(&ok);
2101 if (ok) 2101 if (ok)
2102 reader->locate(ulcn); 2102 reader->locate(ulcn);
2103 else 2103 else
2104 QMessageBox::information(this, PROGNAME, "Must be a number"); 2104 QMessageBox::information(this, PROGNAME, "Must be a number");
2105} 2105}
2106 2106
2107void QTReaderApp::do_regaction() 2107void QTReaderApp::do_regaction()
2108{ 2108{
2109 reader->bDoUpdates = false; 2109 reader->bDoUpdates = false;
2110 regBar->hide(); 2110 regBar->hide();
2111 Global::hideInputMethod(); 2111 Global::hideInputMethod();
2112 regVisible = false; 2112 regVisible = false;
2113 switch(m_nRegAction) 2113 switch(m_nRegAction)
2114 { 2114 {
2115 case cAutoGen: 2115 case cAutoGen:
2116 do_autogen(regEdit->text()); 2116 do_autogen(regEdit->text());
2117 break; 2117 break;
2118 case cAddBkmk: 2118 case cAddBkmk:
2119 do_addbkmk(regEdit->text()); 2119 do_addbkmk(regEdit->text());
2120 break; 2120 break;
2121 case cJump: 2121 case cJump:
2122 do_jump(regEdit->text()); 2122 do_jump(regEdit->text());
2123 break; 2123 break;
2124 case cMonoSpace: 2124 case cMonoSpace:
2125 do_mono(regEdit->text()); 2125 do_mono(regEdit->text());
2126 break; 2126 break;
2127 case cOverlap: 2127 case cOverlap:
2128 do_overlap(regEdit->text()); 2128 do_overlap(regEdit->text());
2129 break; 2129 break;
2130 case cSetTarget: 2130 case cSetTarget:
2131 do_settarget(regEdit->text()); 2131 do_settarget(regEdit->text());
2132 break; 2132 break;
2133 } 2133 }
2134 reader->restore(); 2134 reader->restore();
2135// editBar->show(); 2135// editBar->show();
2136 reader->setFocus(); 2136 reader->setFocus();
2137 qApp->processEvents(); 2137 qApp->processEvents();
2138 reader->bDoUpdates = true; 2138 reader->bDoUpdates = true;
2139 reader->update(); 2139 reader->update();
2140} 2140}
2141 2141
2142void QTReaderApp::do_settarget(const QString& _txt) 2142void QTReaderApp::do_settarget(const QString& _txt)
2143{ 2143{
2144 int ind = _txt.find('/'); 2144 int ind = _txt.find('/');
2145 if (ind == -1) 2145 if (ind == -1)
2146 { 2146 {
2147 m_targetapp = ""; 2147 m_targetapp = "";
2148 m_targetmsg = ""; 2148 m_targetmsg = "";
2149 QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); 2149 QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename");
2150 } 2150 }
2151 else 2151 else
2152 { 2152 {
2153 m_targetapp = _txt.left(ind); 2153 m_targetapp = _txt.left(ind);
2154 m_targetmsg = _txt.right(_txt.length()-ind-1); 2154 m_targetmsg = _txt.right(_txt.length()-ind-1);
2155 } 2155 }
2156} 2156}
2157 2157
2158void QTReaderApp::setfont() 2158void QTReaderApp::setfont()
2159{ 2159{
2160 for (int i = 1; i <= m_fontSelector->count(); i++) 2160 for (int i = 1; i <= m_fontSelector->count(); i++)
2161 { 2161 {
2162 if (m_fontSelector->text(i) == reader->m_fontname) 2162 if (m_fontSelector->text(i) == reader->m_fontname)
2163 { 2163 {
2164 m_fontSelector->setCurrentItem(i); 2164 m_fontSelector->setCurrentItem(i);
2165 break; 2165 break;
2166 } 2166 }
2167 } 2167 }
2168 m_fontBar->show(); 2168 m_fontBar->show();
2169 m_fontVisible = true; 2169 m_fontVisible = true;
2170} 2170}
2171 2171
2172void QTReaderApp::setfontHelper(const QString& lcn, int size = 0) 2172void QTReaderApp::setfontHelper(const QString& lcn, int size)
2173{ 2173{
2174 if (size == 0) size = reader->m_fontControl.currentsize(); 2174 if (size == 0) size = reader->m_fontControl.currentsize();
2175 QFont f(lcn, 10 /*, QFont::Bold*/); 2175 QFont f(lcn, 10 /*, QFont::Bold*/);
2176 qDebug("bs"); 2176 qDebug("bs");
2177 bkmkselector->setFont( f ); 2177 bkmkselector->setFont( f );
2178 qDebug("re"); 2178 qDebug("re");
2179 regEdit->setFont( f ); 2179 regEdit->setFont( f );
2180 qDebug("se"); 2180 qDebug("se");
2181 searchEdit->setFont( f ); 2181 searchEdit->setFont( f );
2182 qDebug("aw"); 2182 qDebug("aw");
2183 m_annoWin->setFont( f ); 2183 m_annoWin->setFont( f );
2184 reader->m_fontname = lcn; 2184 reader->m_fontname = lcn;
2185 qDebug("cf1"); 2185 qDebug("cf1");
2186 if (!reader->ChangeFont(size)) 2186 if (!reader->ChangeFont(size))
2187 { 2187 {
2188 qDebug("cf2"); 2188 qDebug("cf2");
2189 reader->ChangeFont(size); 2189 reader->ChangeFont(size);
2190 } 2190 }
2191 qDebug("ref"); 2191 qDebug("ref");
2192 reader->refresh(); 2192 reader->refresh();
2193 m_fontBar->hide(); 2193 m_fontBar->hide();
2194 m_fontVisible = false; 2194 m_fontVisible = false;
2195 qDebug("showedit"); 2195 qDebug("showedit");
2196 if (reader->isVisible()) showEditTools(); 2196 if (reader->isVisible()) showEditTools();
2197 qDebug("showeditdone"); 2197 qDebug("showeditdone");
2198} 2198}
2199 2199
2200void QTReaderApp::do_setfont(const QString& lcn) 2200void QTReaderApp::do_setfont(const QString& lcn)
2201{ 2201{
2202 setfontHelper(lcn); 2202 setfontHelper(lcn);
2203} 2203}
2204 2204
2205void QTReaderApp::do_autogen(const QString& regText) 2205void QTReaderApp::do_autogen(const QString& regText)
2206{ 2206{
2207 unsigned long fs, ts; 2207 unsigned long fs, ts;
2208 reader->sizes(fs,ts); 2208 reader->sizes(fs,ts);
2209 // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); 2209 // qDebug("Reg:%s\n", (const tchar*)(regEdit->text()));
2210 m_autogenstr = regText; 2210 m_autogenstr = regText;
2211 QRegExp re(regText); 2211 QRegExp re(regText);
2212 CBuffer buff; 2212 CBuffer buff;
2213 if (pBkmklist != NULL) delete pBkmklist; 2213 if (pBkmklist != NULL) delete pBkmklist;
2214 pBkmklist = new CList<Bkmk>; 2214 pBkmklist = new CList<Bkmk>;
2215 m_fBkmksChanged = true; 2215 m_fBkmksChanged = true;
2216 pbar->show(); 2216 pbar->show();
2217pbar->resize(width(), editBar->height()); 2217pbar->resize(width(), editBar->height());
2218 pbar->reset(); 2218 pbar->reset();
2219 qApp->processEvents(); 2219 qApp->processEvents();
2220 reader->setFocus(); 2220 reader->setFocus();
2221 reader->jumpto(0); 2221 reader->jumpto(0);
2222 int lastpc = 0; 2222 int lastpc = 0;
2223 int i = 0; 2223 int i = 0;
2224 while (i >= 0) 2224 while (i >= 0)
2225 { 2225 {
2226 unsigned int lcn = reader->locate(); 2226 unsigned int lcn = reader->locate();
2227 int pc = (100*lcn)/ts; 2227 int pc = (100*lcn)/ts;
2228 if (pc != lastpc) 2228 if (pc != lastpc)
2229 { 2229 {
2230 pbar->setProgress(pc); 2230 pbar->setProgress(pc);
2231 qApp->processEvents(); 2231 qApp->processEvents();
2232 if (reader->locate() != lcn) reader->jumpto(lcn); 2232 if (reader->locate() != lcn) reader->jumpto(lcn);
2233 reader->setFocus(); 2233 reader->setFocus();
2234 lastpc = pc; 2234 lastpc = pc;
2235 } 2235 }
2236 i = reader->buffdoc.getpara(buff); 2236 i = reader->buffdoc.getpara(buff);
2237#ifdef _UNICODE 2237#ifdef _UNICODE
2238 if (re.match(toQString(buff.data())) != -1) 2238 if (re.match(toQString(buff.data())) != -1)
2239#else 2239#else
2240 if (re.match(buff.data()) != -1) 2240 if (re.match(buff.data()) != -1)
2241#endif 2241#endif
2242 pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); 2242 pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn));
2243 } 2243 }
2244 pBkmklist->sort(); 2244 pBkmklist->sort();
2245 pbar->setProgress(100); 2245 pbar->setProgress(100);
2246 qApp->processEvents(); 2246 qApp->processEvents();
2247 pbar->hide(); 2247 pbar->hide();
2248} 2248}
2249 2249
2250void QTReaderApp::saveprefs() 2250void QTReaderApp::saveprefs()
2251{ 2251{
2252// reader->saveprefs("uqtreader"); 2252// reader->saveprefs("uqtreader");
2253 Config config( APPDIR ); 2253 Config config( APPDIR );
2254 config.setGroup( "View" ); 2254 config.setGroup( "View" );
2255 2255
2256 reader->m_lastposn = reader->pagelocate(); 2256 reader->m_lastposn = reader->pagelocate();
2257 2257
2258 config.writeEntry( "StripCr", reader->bstripcr ); 2258 config.writeEntry( "StripCr", reader->bstripcr );
2259 config.writeEntry( "AutoFmt", reader->bautofmt ); 2259 config.writeEntry( "AutoFmt", reader->bautofmt );
2260 config.writeEntry( "TextFmt", reader->btextfmt ); 2260 config.writeEntry( "TextFmt", reader->btextfmt );
2261 config.writeEntry( "StripHtml", reader->bstriphtml ); 2261 config.writeEntry( "StripHtml", reader->bstriphtml );
2262 config.writeEntry( "Dehyphen", reader->bdehyphen ); 2262 config.writeEntry( "Dehyphen", reader->bdehyphen );
2263 config.writeEntry( "OneSpace", reader->bonespace ); 2263 config.writeEntry( "OneSpace", reader->bonespace );
2264 config.writeEntry( "Unindent", reader->bunindent ); 2264 config.writeEntry( "Unindent", reader->bunindent );
2265 config.writeEntry( "Repara", reader->brepara ); 2265 config.writeEntry( "Repara", reader->brepara );
2266 config.writeEntry( "DoubleSpace", reader->bdblspce ); 2266 config.writeEntry( "DoubleSpace", reader->bdblspce );
2267 config.writeEntry( "Indent", reader->bindenter ); 2267 config.writeEntry( "Indent", reader->bindenter );
2268 config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); 2268 config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) );
2269 config.writeEntry( "ScrollDelay", reader->m_delay); 2269 config.writeEntry( "ScrollDelay", reader->m_delay);
2270 config.writeEntry( "LastFile", reader->m_lastfile ); 2270 config.writeEntry( "LastFile", reader->m_lastfile );
2271 config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); 2271 config.writeEntry( "LastPosn", (int)(reader->pagelocate()) );
2272 config.writeEntry( "PageMode", reader->m_bpagemode ); 2272 config.writeEntry( "PageMode", reader->m_bpagemode );
2273 config.writeEntry( "CursorNavigation", reader->m_navkeys ); 2273 config.writeEntry( "CursorNavigation", reader->m_navkeys );
2274 config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); 2274 config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced );
2275 config.writeEntry( "Fontname", reader->m_fontname ); 2275 config.writeEntry( "Fontname", reader->m_fontname );
2276 config.writeEntry( "Encoding", reader->m_encd ); 2276 config.writeEntry( "Encoding", reader->m_encd );
2277 config.writeEntry( "CharSpacing", reader->m_charpc ); 2277 config.writeEntry( "CharSpacing", reader->m_charpc );
2278 config.writeEntry( "Overlap", (int)(reader->m_overlap) ); 2278 config.writeEntry( "Overlap", (int)(reader->m_overlap) );
2279 config.writeEntry( "TargetApp", m_targetapp ); 2279 config.writeEntry( "TargetApp", m_targetapp );
2280 config.writeEntry( "TargetMsg", m_targetmsg ); 2280 config.writeEntry( "TargetMsg", m_targetmsg );
2281 config.writeEntry( "TwoTouch", m_twoTouch ); 2281 config.writeEntry( "TwoTouch", m_twoTouch );
2282 config.writeEntry( "Annotation", m_doAnnotation); 2282 config.writeEntry( "Annotation", m_doAnnotation);
2283 config.writeEntry( "Dictionary", m_doDictionary); 2283 config.writeEntry( "Dictionary", m_doDictionary);
2284 config.writeEntry( "Clipboard", m_doClipboard); 2284 config.writeEntry( "Clipboard", m_doClipboard);
2285 config.writeEntry( "SpaceTarget", m_spaceTarget); 2285 config.writeEntry( "SpaceTarget", m_spaceTarget);
2286#ifdef REPALM 2286#ifdef REPALM
2287 config.writeEntry( "Repalm", reader->brepalm ); 2287 config.writeEntry( "Repalm", reader->brepalm );
2288#endif 2288#endif
2289 config.writeEntry( "Remap", reader->bremap ); 2289 config.writeEntry( "Remap", reader->bremap );
2290 config.writeEntry( "Peanut", reader->bpeanut ); 2290 config.writeEntry( "Peanut", reader->bpeanut );
2291 config.writeEntry( "MakeBold", reader->bmakebold ); 2291 config.writeEntry( "MakeBold", reader->bmakebold );
2292 config.writeEntry( "Continuous", reader->m_continuousDocument ); 2292 config.writeEntry( "Continuous", reader->m_continuousDocument );
2293 2293
2294 savefilelist(); 2294 savefilelist();
2295} 2295}
2296 2296
2297void QTReaderApp::indentplus() 2297void QTReaderApp::indentplus()
2298{ 2298{
2299 reader->indentplus(); 2299 reader->indentplus();
2300} 2300}
2301 2301
2302void QTReaderApp::indentminus() 2302void QTReaderApp::indentminus()
2303{ 2303{
2304 reader->indentminus(); 2304 reader->indentminus();
2305} 2305}
2306 2306
2307/* 2307/*
2308void QTReaderApp::oldFile() 2308void QTReaderApp::oldFile()
2309{ 2309{
2310 qDebug("oldFile called"); 2310 qDebug("oldFile called");
2311 reader->setText(true); 2311 reader->setText(true);
2312 qDebug("settext called"); 2312 qDebug("settext called");
2313 showEditTools(); 2313 showEditTools();
2314 qDebug("showedit called"); 2314 qDebug("showedit called");
2315} 2315}
2316*/ 2316*/
2317 2317
2318/* 2318/*
2319void info_cb(Fl_Widget* o, void* _data) 2319void info_cb(Fl_Widget* o, void* _data)
2320{ 2320{
2321 2321
2322 if (infowin == NULL) 2322 if (infowin == NULL)
2323 { 2323 {
2324 2324
2325 infowin = new Fl_Window(160,240); 2325 infowin = new Fl_Window(160,240);
2326 filename = new Fl_Output(45,5,110,14,"Filename"); 2326 filename = new Fl_Output(45,5,110,14,"Filename");
2327 filesize = new Fl_Output(45,25,110,14,"Filesize"); 2327 filesize = new Fl_Output(45,25,110,14,"Filesize");
2328 textsize = new Fl_Output(45,45,110,14,"Textsize"); 2328 textsize = new Fl_Output(45,45,110,14,"Textsize");
2329 comprat = new CBar(45,65,110,14,"Ratio %"); 2329 comprat = new CBar(45,65,110,14,"Ratio %");
2330 posn = new Fl_Output(45,85,110,14,"Location"); 2330 posn = new Fl_Output(45,85,110,14,"Location");
2331 frcn = new CBar(45,105,110,14,"% Read"); 2331 frcn = new CBar(45,105,110,14,"% Read");
2332 about = new Fl_Multiline_Output(5,125,150,90); 2332 about = new Fl_Multiline_Output(5,125,150,90);
2333 about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); 2333 about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files");
2334 Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); 2334 Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay");
2335 infowin->set_modal(); 2335 infowin->set_modal();
2336 } 2336 }
2337 if (((reader_ui *)_data)->g_filename[0] != '\0') 2337 if (((reader_ui *)_data)->g_filename[0] != '\0')
2338 { 2338 {
2339 unsigned long fs,ts; 2339 unsigned long fs,ts;
2340 tchar sz[20]; 2340 tchar sz[20];
2341 ((reader_ui *)_data)->input->sizes(fs,ts); 2341 ((reader_ui *)_data)->input->sizes(fs,ts);
2342 unsigned long pl = ((reader_ui *)_data)->input->locate(); 2342 unsigned long pl = ((reader_ui *)_data)->input->locate();
2343 2343
2344 filename->value(((reader_ui *)_data)->g_filename); 2344 filename->value(((reader_ui *)_data)->g_filename);
2345 2345
2346 sprintf(sz,"%u",fs); 2346 sprintf(sz,"%u",fs);
2347 filesize->value(sz); 2347 filesize->value(sz);
2348 2348
2349 sprintf(sz,"%u",ts); 2349 sprintf(sz,"%u",ts);
2350 textsize->value(sz); 2350 textsize->value(sz);
2351 2351
2352 comprat->value(100-(100*fs + (ts >> 1))/ts); 2352 comprat->value(100-(100*fs + (ts >> 1))/ts);
2353 2353
2354 sprintf(sz,"%u",pl); 2354 sprintf(sz,"%u",pl);
2355 posn->value(sz); 2355 posn->value(sz);
2356 2356
2357 frcn->value((100*pl + (ts >> 1))/ts); 2357 frcn->value((100*pl + (ts >> 1))/ts);
2358 } 2358 }
2359 infowin->show(); 2359 infowin->show();
2360} 2360}
2361*/ 2361*/
2362 2362
2363void QTReaderApp::savebkmks() 2363void QTReaderApp::savebkmks()
2364{ 2364{
diff --git a/noncore/apps/opie-reader/infowin.cpp b/noncore/apps/opie-reader/infowin.cpp
index 30adebf..459b648 100644
--- a/noncore/apps/opie-reader/infowin.cpp
+++ b/noncore/apps/opie-reader/infowin.cpp
@@ -1,43 +1,43 @@
1#include "name.h" 1#include "name.h"
2#include "infowin.h" 2#include "infowin.h"
3#include "version.h" 3#include "version.h"
4#include <stdio.h> 4#include <stdio.h>
5 5
6infowin::infowin( QWidget *parent=0, const char *name=0, WFlags f = 0) : 6infowin::infowin( QWidget *parent, const char *name, WFlags f ) :
7 QWidget(parent, name, f) 7 QWidget(parent, name, f)
8{ 8{
9 grid = new QGridLayout(this, 6, 2); 9 grid = new QGridLayout(this, 6, 2);
10 QLabel* l; 10 QLabel* l;
11 l = new QLabel("Compressed file size", this); 11 l = new QLabel("Compressed file size", this);
12 grid->addWidget(l, 0, 0); 12 grid->addWidget(l, 0, 0);
13 fileSize = new QLabel("0", this); 13 fileSize = new QLabel("0", this);
14 fileSize->setAlignment( AlignVCenter | AlignRight ); 14 fileSize->setAlignment( AlignVCenter | AlignRight );
15 grid->addWidget(fileSize, 0, 1); 15 grid->addWidget(fileSize, 0, 1);
16 l = new QLabel("Original text size", this); 16 l = new QLabel("Original text size", this);
17 grid->addWidget(l, 1, 0); 17 grid->addWidget(l, 1, 0);
18 textSize = new QLabel("0", this); 18 textSize = new QLabel("0", this);
19 textSize->setAlignment( AlignVCenter | AlignRight ); 19 textSize->setAlignment( AlignVCenter | AlignRight );
20 grid->addWidget(textSize, 1, 1); 20 grid->addWidget(textSize, 1, 1);
21 l = new QLabel("Compression Ratio", this); 21 l = new QLabel("Compression Ratio", this);
22 grid->addWidget(l, 2, 0); 22 grid->addWidget(l, 2, 0);
23 ratio = new QLabel("0", this); 23 ratio = new QLabel("0", this);
24 grid->addWidget(ratio, 2, 1); 24 grid->addWidget(ratio, 2, 1);
25 ratio->setAlignment( AlignVCenter | AlignRight ); 25 ratio->setAlignment( AlignVCenter | AlignRight );
26 l = new QLabel("Current location", this); 26 l = new QLabel("Current location", this);
27 grid->addWidget(l, 3, 0); 27 grid->addWidget(l, 3, 0);
28 location = new QLabel("0", this); 28 location = new QLabel("0", this);
29 location->setAlignment( AlignVCenter | AlignRight ); 29 location->setAlignment( AlignVCenter | AlignRight );
30 grid->addWidget(location, 3, 1); 30 grid->addWidget(location, 3, 1);
31 l = new QLabel("Per centage read", this); 31 l = new QLabel("Per centage read", this);
32 grid->addWidget(l, 4, 0); 32 grid->addWidget(l, 4, 0);
33 read = new QLabel("0", this); 33 read = new QLabel("0", this);
34 read->setAlignment( AlignVCenter | AlignRight ); 34 read->setAlignment( AlignVCenter | AlignRight );
35 grid->addWidget(read, 4, 1); 35 grid->addWidget(read, 4, 1);
36 char vstr[128]; 36 char vstr[128];
37 sprintf(vstr, PROGNAME " v%u.%u%c (%s)\nA small e-text reader", MAJOR, BKMKTYPE, MINOR, RELEASE_TYPE); 37 sprintf(vstr, PROGNAME " v%u.%u%c (%s)\nA small e-text reader", MAJOR, BKMKTYPE, MINOR, RELEASE_TYPE);
38 l = new QLabel(vstr, this); 38 l = new QLabel(vstr, this);
39 grid->addWidget(l, 5, 0); 39 grid->addWidget(l, 5, 0);
40 QPushButton* exitbutton = new QPushButton("Cancel", this); 40 QPushButton* exitbutton = new QPushButton("Cancel", this);
41 connect( exitbutton, SIGNAL( released() ), this, SLOT( infoClose() ) ); 41 connect( exitbutton, SIGNAL( released() ), this, SLOT( infoClose() ) );
42 grid->addWidget(exitbutton, 5, 1); 42 grid->addWidget(exitbutton, 5, 1);
43} 43}