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,828 +1,828 @@
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++)
253 { 253 {
254 getch(); 254 getch();
255 } 255 }
256 if (m_startpos == endpos) 256 if (m_startpos == endpos)
257 { 257 {
258 for (int i = m_startoffset; i <= endoffset; i++) 258 for (int i = m_startoffset; i <= endoffset; i++)
259 { 259 {
260 wrd += QChar(getch()); 260 wrd += QChar(getch());
261 } 261 }
262 } 262 }
263 else 263 else
264 { 264 {
265 while (buffdoc.explocate() <= endpos) 265 while (buffdoc.explocate() <= endpos)
266 { 266 {
267 wrd += QChar(getch()); 267 wrd += QChar(getch());
268 } 268 }
269 for (int i = 0; i < endoffset; i++) 269 for (int i = 0; i < endoffset; i++)
270 { 270 {
271 wrd += QChar(getch()); 271 wrd += QChar(getch());
272 } 272 }
273 } 273 }
274 jumpto(currentpos); 274 jumpto(currentpos);
275 } 275 }
276 } 276 }
277 } 277 }
278 else if (m_bMonoSpaced) 278 else if (m_bMonoSpaced)
279 { 279 {
280 int chno = _e->x()/m_charWidth; 280 int chno = _e->x()/m_charWidth;
281 if (chno < ustrlen(textarray[lineno]->data())) 281 if (chno < ustrlen(textarray[lineno]->data()))
282 { 282 {
283 wrd[0] = textarray[lineno]->data()[chno]; 283 wrd[0] = textarray[lineno]->data()[chno];
284 } 284 }
285 } 285 }
286 else 286 else
287 { 287 {
288 CDrawBuffer* t = textarray[lineno]; 288 CDrawBuffer* t = textarray[lineno];
289 int first = 0; 289 int first = 0;
290 int tgt = _e->x() - t->offset(width()); 290 int tgt = _e->x() - t->offset(width());
291 while (1) 291 while (1)
292 { 292 {
293 int i = first+1; 293 int i = first+1;
294 while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; 294 while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
295 if (t->width(i) > tgt) 295 if (t->width(i) > tgt)
296 { 296 {
297 wrd = toQString(t->data()+first, i - first); 297 wrd = toQString(t->data()+first, i - first);
298 break; 298 break;
299 } 299 }
300 while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; 300 while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
301 if ((*t)[i] == 0) break; 301 if ((*t)[i] == 0) break;
302 first = i; 302 first = i;
303 } 303 }
304 } 304 }
305 if (!wrd.isEmpty()) 305 if (!wrd.isEmpty())
306 { 306 {
307 emit OnWordSelected(wrd, locnarray[lineno], (m_twotouch) ? wrd : toQString(textarray[lineno]->data())); 307 emit OnWordSelected(wrd, locnarray[lineno], (m_twotouch) ? wrd : toQString(textarray[lineno]->data()));
308 } 308 }
309 } 309 }
310 } 310 }
311 else 311 else
312 { 312 {
313 mouseUpOn = true; 313 mouseUpOn = true;
314 } 314 }
315 } 315 }
316} 316}
317 317
318void QTReader::focusInEvent(QFocusEvent* e) 318void QTReader::focusInEvent(QFocusEvent* e)
319{ 319{
320 if (m_autoScroll) timer->start(real_delay(), false); 320 if (m_autoScroll) timer->start(real_delay(), false);
321 update(); 321 update();
322} 322}
323 323
324void QTReader::focusOutEvent(QFocusEvent* e) 324void QTReader::focusOutEvent(QFocusEvent* e)
325{ 325{
326 if (m_autoScroll) 326 if (m_autoScroll)
327 { 327 {
328 timer->stop(); 328 timer->stop();
329 m_scrolldy1 = m_scrolldy2 = 0; 329 m_scrolldy1 = m_scrolldy2 = 0;
330 } 330 }
331} 331}
332 332
333#include <qapplication.h> 333#include <qapplication.h>
334#include <qdrawutil.h> 334#include <qdrawutil.h>
335#include <unistd.h> 335#include <unistd.h>
336 336
337void QTReader::goDown() 337void QTReader::goDown()
338{ 338{
339 if (m_bpagemode) 339 if (m_bpagemode)
340 { 340 {
341 dopagedn(); 341 dopagedn();
342 } 342 }
343 else 343 else
344 { 344 {
345 lineDown(); 345 lineDown();
346 } 346 }
347} 347}
348 348
349void QTReader::goUp() 349void QTReader::goUp()
350{ 350{
351 if (m_bpagemode) 351 if (m_bpagemode)
352 { 352 {
353 dopageup(); 353 dopageup();
354 } 354 }
355 else 355 else
356 { 356 {
357 lineUp(); 357 lineUp();
358 } 358 }
359} 359}
360 360
361void QTReader::NavUp() 361void QTReader::NavUp()
362{ 362{
363 buffdoc.unsuspend(); 363 buffdoc.unsuspend();
364 if (buffdoc.hasnavigation()) 364 if (buffdoc.hasnavigation())
365 { 365 {
366/* 366/*
367 size_t target = pagelocate(); 367 size_t target = pagelocate();
368 if (buffdoc.back(target)) 368 if (buffdoc.back(target))
369 { 369 {
370 locate(target); 370 locate(target);
371 } 371 }
372*/ 372*/
373 locate(buffdoc.startSection()); 373 locate(buffdoc.startSection());
374 } 374 }
375 else 375 else
376 { 376 {
377 goUp(); 377 goUp();
378 } 378 }
379} 379}
380 380
381void QTReader::NavDown() 381void QTReader::NavDown()
382{ 382{
383 buffdoc.unsuspend(); 383 buffdoc.unsuspend();
384 if (buffdoc.hasnavigation()) 384 if (buffdoc.hasnavigation())
385 { 385 {
386/* 386/*
387 size_t target = pagelocate(); 387 size_t target = pagelocate();
388 if (buffdoc.forward(target)) 388 if (buffdoc.forward(target))
389 { 389 {
390 locate(target); 390 locate(target);
391 } 391 }
392*/ 392*/
393 dopageup(buffdoc.endSection()); 393 dopageup(buffdoc.endSection());
394 } 394 }
395 else 395 else
396 { 396 {
397 goDown(); 397 goDown();
398 } 398 }
399} 399}
400 400
401void QTReader::zoomin() 401void QTReader::zoomin()
402{ 402{
403 if (m_fontControl.increasesize()) 403 if (m_fontControl.increasesize())
404 { 404 {
405 bool sc = m_autoScroll; 405 bool sc = m_autoScroll;
406 setfont(); 406 setfont();
407 m_autoScroll = false; 407 m_autoScroll = false;
408 locate(pagelocate()); 408 locate(pagelocate());
409 update(); 409 update();
410 m_autoScroll = sc; 410 m_autoScroll = sc;
411 if (m_autoScroll) autoscroll(); 411 if (m_autoScroll) autoscroll();
412 } 412 }
413} 413}
414 414
415void QTReader::zoomout() 415void QTReader::zoomout()
416{ 416{
417 if (m_fontControl.decreasesize()) 417 if (m_fontControl.decreasesize())
418 { 418 {
419 bool sc = m_autoScroll; 419 bool sc = m_autoScroll;
420 m_autoScroll = false; 420 m_autoScroll = false;
421 setfont(); 421 setfont();
422 locate(pagelocate()); 422 locate(pagelocate());
423 update(); 423 update();
424 m_autoScroll = sc; 424 m_autoScroll = sc;
425 if (m_autoScroll) autoscroll(); 425 if (m_autoScroll) autoscroll();
426 } 426 }
427} 427}
428 428
429void QTReader::keyPressEvent(QKeyEvent* e) 429void QTReader::keyPressEvent(QKeyEvent* e)
430{ 430{
431 buffdoc.unsuspend(); 431 buffdoc.unsuspend();
432 switch (e->key()) 432 switch (e->key())
433 { 433 {
434 case Key_Down: 434 case Key_Down:
435 { 435 {
436 e->accept(); 436 e->accept();
437 if (m_autoScroll) 437 if (m_autoScroll)
438 { 438 {
439 if (m_delay < 59049) 439 if (m_delay < 59049)
440 { 440 {
441 m_delay = (3*m_delay)/2; 441 m_delay = (3*m_delay)/2;
442 timer->changeInterval(real_delay()); 442 timer->changeInterval(real_delay());
443 } 443 }
444 else 444 else
445 { 445 {
446 m_delay = 59049; 446 m_delay = 59049;
447 } 447 }
448 } 448 }
449 else 449 else
450 { 450 {
451 goDown(); 451 goDown();
452 } 452 }
453 } 453 }
454 break; 454 break;
455 case Key_Up: 455 case Key_Up:
456 { 456 {
457 e->accept(); 457 e->accept();
458 if (m_autoScroll) 458 if (m_autoScroll)
459 { 459 {
460 if (m_delay > 1024) 460 if (m_delay > 1024)
461 { 461 {
462 m_delay = (2*m_delay)/3; 462 m_delay = (2*m_delay)/3;
463 timer->changeInterval(real_delay()); 463 timer->changeInterval(real_delay());
464 } 464 }
465 else 465 else
466 { 466 {
467 m_delay = 1024; 467 m_delay = 1024;
468 } 468 }
469 } 469 }
470 else 470 else
471 { 471 {
472 goUp(); 472 goUp();
473 } 473 }
474 } 474 }
475 break; 475 break;
476 /* 476 /*
477 case Key_Left: 477 case Key_Left:
478 { 478 {
479 e->accept(); 479 e->accept();
480 if (m_textfont > 0) 480 if (m_textfont > 0)
481 { 481 {
482 m_textfont--; 482 m_textfont--;
483 setfont(NULL); 483 setfont(NULL);
484 locate(pagelocate()); 484 locate(pagelocate());
485 update(); 485 update();
486 } 486 }
487 } 487 }
488 break; 488 break;
489 case Key_Right: 489 case Key_Right:
490 { 490 {
491 e->accept(); 491 e->accept();
492 if (fonts[++m_textfont] == 0) 492 if (fonts[++m_textfont] == 0)
493 { 493 {
494 m_textfont--; 494 m_textfont--;
495 } 495 }
496 else 496 else
497 { 497 {
498 setfont(NULL); 498 setfont(NULL);
499 locate(pagelocate()); 499 locate(pagelocate());
500 update(); 500 update();
501 } 501 }
502 } 502 }
503 break; 503 break;
504 */ 504 */
505 case Key_Right: 505 case Key_Right:
506 { 506 {
507 e->accept(); 507 e->accept();
508 if (m_navkeys && buffdoc.hasnavigation()) 508 if (m_navkeys && buffdoc.hasnavigation())
509 { 509 {
510 size_t target = pagelocate(); 510 size_t target = pagelocate();
511 if (buffdoc.forward(target)) 511 if (buffdoc.forward(target))
512 { 512 {
513 locate(target); 513 locate(target);
514 } 514 }
515 } 515 }
516 else zoomin(); 516 else zoomin();
517 } 517 }
518 break; 518 break;
519 case Key_Left: 519 case Key_Left:
520 { 520 {
521 e->accept(); 521 e->accept();
522 if (m_navkeys && buffdoc.hasnavigation()) 522 if (m_navkeys && buffdoc.hasnavigation())
523 { 523 {
524 size_t target = pagelocate(); 524 size_t target = pagelocate();
525 if (buffdoc.back(target)) 525 if (buffdoc.back(target))
526 { 526 {
527 locate(target); 527 locate(target);
528 } 528 }
529 } 529 }
530 else zoomout(); 530 else zoomout();
531 } 531 }
532 break; 532 break;
533 case Key_Space: 533 case Key_Space:
534 case Key_Return: 534 case Key_Return:
535 { 535 {
536 e->accept(); 536 e->accept();
537 emit OnActionPressed(); 537 emit OnActionPressed();
538 } 538 }
539 break; 539 break;
540 default: 540 default:
541 e->ignore(); 541 e->ignore();
542 } 542 }
543} 543}
544 544
545void QTReader::setautoscroll(bool _sc) 545void QTReader::setautoscroll(bool _sc)
546{ 546{
547 if (_sc == m_autoScroll) return; 547 if (_sc == m_autoScroll) return;
548 if (m_autoScroll) 548 if (m_autoScroll)
549 { 549 {
550 m_autoScroll = false; 550 m_autoScroll = false;
551 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 551 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
552 } 552 }
553 else 553 else
554 { 554 {
555 CDrawBuffer* reusebuffer = textarray[numlines]; 555 CDrawBuffer* reusebuffer = textarray[numlines];
556 if (reusebuffer == NULL || reusebuffer->eof()) return; 556 if (reusebuffer == NULL || reusebuffer->eof()) return;
557 m_autoScroll = true; 557 m_autoScroll = true;
558 autoscroll(); 558 autoscroll();
559 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed 559 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed
560 } 560 }
561} 561}
562 562
563bool QTReader::getline(CDrawBuffer *buff) 563bool QTReader::getline(CDrawBuffer *buff)
564{ 564{
565 buffdoc.unsuspend(); 565 buffdoc.unsuspend();
566 if (m_bMonoSpaced) 566 if (m_bMonoSpaced)
567 { 567 {
568 return buffdoc.getline(buff ,width(), m_charWidth); 568 return buffdoc.getline(buff ,width(), m_charWidth);
569 } 569 }
570 else 570 else
571 { 571 {
572 return buffdoc.getline(buff, width()); 572 return buffdoc.getline(buff, width());
573 } 573 }
574} 574}
575 575
576void QTReader::doscroll() 576void QTReader::doscroll()
577{ 577{
578 if (!m_autoScroll) 578 if (!m_autoScroll)
579 { 579 {
580 timer->stop(); 580 timer->stop();
581 return; 581 return;
582 } 582 }
583// timer->changeInterval(real_delay()); 583// timer->changeInterval(real_delay());
584 QPainter p( this ); 584 QPainter p( this );
585 QBrush b( white); 585 QBrush b( white);
586 bitBlt(this,0,0,this,0,1,width(),-1); 586 bitBlt(this,0,0,this,0,1,width(),-1);
587 qDrawPlainRect(&p,0,height() - 2,width(),2,white,1,&b); 587 qDrawPlainRect(&p,0,height() - 2,width(),2,white,1,&b);
588 588
589 if (++m_scrolldy1 == textarray[0]->lineSpacing()) 589 if (++m_scrolldy1 == textarray[0]->lineSpacing())
590 { 590 {
591 CDrawBuffer* buff = textarray[0]; 591 CDrawBuffer* buff = textarray[0];
592 for (int i = 1; i <= numlines; i++) 592 for (int i = 1; i <= numlines; i++)
593 { 593 {
594 textarray[i-1] = textarray[i]; 594 textarray[i-1] = textarray[i];
595 locnarray[i-1] = locnarray[i]; 595 locnarray[i-1] = locnarray[i];
596 } 596 }
597 textarray[numlines] = buff; 597 textarray[numlines] = buff;
598 --numlines; 598 --numlines;
599 m_scrolldy1 = 0; 599 m_scrolldy1 = 0;
600 } 600 }
601 if (++m_scrolldy2 == textarray[numlines]->lineSpacing()) 601 if (++m_scrolldy2 == textarray[numlines]->lineSpacing())
602 { 602 {
603 m_scrolldy2 = 0; 603 m_scrolldy2 = 0;
604 numlines++; 604 numlines++;
605 605
606 if (textarray[numlines] == NULL) 606 if (textarray[numlines] == NULL)
607 { 607 {
608 textarray[numlines] = new CDrawBuffer(&m_fontControl); 608 textarray[numlines] = new CDrawBuffer(&m_fontControl);
609 } 609 }
610 locnarray[numlines] = locate(); 610 locnarray[numlines] = locate();
611 int ch = getline(textarray[numlines]); 611 int ch = getline(textarray[numlines]);
612 textarray[numlines-1]->render(&p, height() - textarray[numlines-1]->descent() - 2, m_bMonoSpaced, m_charWidth, width()); 612 textarray[numlines-1]->render(&p, height() - textarray[numlines-1]->descent() - 2, m_bMonoSpaced, m_charWidth, width());
613 mylastpos = locate(); 613 mylastpos = locate();
614 if (!ch) 614 if (!ch)
615 { 615 {
616 m_autoScroll = false; 616 m_autoScroll = false;
617 ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); 617 ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll);
618 } 618 }
619 emit OnRedraw(); 619 emit OnRedraw();
620 } 620 }
621} 621}
622 622
623void QTReader::autoscroll() 623void QTReader::autoscroll()
624{ 624{
625 timer->start(real_delay(), false); 625 timer->start(real_delay(), false);
626} 626}
627 627
628void QTReader::setfont() 628void QTReader::setfont()
629{ 629{
630// m_fontControl.Change 630// m_fontControl.Change
631 m_charWidth = (m_charpc*m_fontControl.currentsize())/100; 631 m_charWidth = (m_charpc*m_fontControl.currentsize())/100;
632 if (m_charWidth <= 0) m_charWidth = 1; 632 if (m_charWidth <= 0) m_charWidth = 1;
633 m_ascent = m_fontControl.ascent(); 633 m_ascent = m_fontControl.ascent();
634 m_descent = m_fontControl.descent(); 634 m_descent = m_fontControl.descent();
635 m_linespacing = m_fontControl.lineSpacing(); 635 m_linespacing = m_fontControl.lineSpacing();
636} 636}
637 637
638void QTReader::drawFonts( QPainter *p ) 638void QTReader::drawFonts( QPainter *p )
639{ 639{
640 if (bDoUpdates) 640 if (bDoUpdates)
641 { 641 {
642 qDebug("How refreshing..."); 642 qDebug("How refreshing...");
643 if (buffdoc.empty()) return; 643 if (buffdoc.empty()) return;
644 setfont(); 644 setfont();
645 if (m_lastwidth != width()) 645 if (m_lastwidth != width())
646 { 646 {
647 qDebug("Not Optimised %d", m_lastwidth); 647 qDebug("Not Optimised %d", m_lastwidth);
648 m_lastwidth = width(); 648 m_lastwidth = width();
649 m_lastheight = height(); 649 m_lastheight = height();
650 locate(pagelocate()); 650 locate(pagelocate());
651 qDebug("Not Optimised %d", m_lastwidth); 651 qDebug("Not Optimised %d", m_lastwidth);
652 } 652 }
653 else 653 else
654 { 654 {
655 if (m_lastheight > height()) 655 if (m_lastheight > height())
656 { 656 {
657 qDebug("Optimised < %d", numlines); 657 qDebug("Optimised < %d", numlines);
658 int ypos = 0; 658 int ypos = 0;
659 for (int i = 0; i < numlines; i++) 659 for (int i = 0; i < numlines; i++)
660 { 660 {
661 if ((ypos += textarray[i]->lineSpacing()) > height()) 661 if ((ypos += textarray[i]->lineSpacing()) > height())
662 { 662 {
663 numlines = i; 663 numlines = i;
664 jumpto(locnarray[i+1]); 664 jumpto(locnarray[i+1]);
665 break; 665 break;
666 } 666 }
667 } 667 }
668 qDebug("Optimised < %d", numlines); 668 qDebug("Optimised < %d", numlines);
669 m_lastheight = height(); 669 m_lastheight = height();
670 } 670 }
671 else if (m_lastheight < height()) 671 else if (m_lastheight < height())
672 { 672 {
673 qDebug("Optimised > %d", numlines); 673 qDebug("Optimised > %d", numlines);
674 int ypos = 0; 674 int ypos = 0;
675 for (int i = 0; i <= numlines; i++) 675 for (int i = 0; i <= numlines; i++)
676 { 676 {
677 ypos += textarray[i]->lineSpacing(); 677 ypos += textarray[i]->lineSpacing();
678 } 678 }
679 fillbuffer(numlines+1, ypos); 679 fillbuffer(numlines+1, ypos);
680 qDebug("Optimised > %d", numlines); 680 qDebug("Optimised > %d", numlines);
681 m_lastheight = height(); 681 m_lastheight = height();
682 } 682 }
683 if (numlines > 0) 683 if (numlines > 0)
684 { 684 {
685 int ypos = textarray[0]->ascent(); 685 int ypos = textarray[0]->ascent();
686 textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); 686 textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width());
687 for (int i = 1; i < numlines; i++) 687 for (int i = 1; i < numlines; i++)
688 { 688 {
689 // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; 689 // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2;
690 ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ 690 ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+
691 (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; 691 (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2;
692 textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); 692 textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width());
693 } 693 }
694// mylastpos = locate(); 694// mylastpos = locate();
695 } 695 }
696 } 696 }
697 m_scrolldy1 = m_scrolldy2 = 0; 697 m_scrolldy1 = m_scrolldy2 = 0;
698 emit OnRedraw(); 698 emit OnRedraw();
699 } 699 }
700 else 700 else
701 { 701 {
702 qDebug("Not so refreshing..."); 702 qDebug("Not so refreshing...");
703 } 703 }
704} 704}
705 705
706QString QTReader::firstword() 706QString QTReader::firstword()
707{ 707{
708 if (m_bMonoSpaced) 708 if (m_bMonoSpaced)
709 { 709 {
710 return toQString(textarray[0]->data()); 710 return toQString(textarray[0]->data());
711 } 711 }
712 else 712 else
713 { 713 {
714 int start, end, len, j; 714 int start, end, len, j;
715 for (j = 0; j < numlines; j++) 715 for (j = 0; j < numlines; j++)
716 { 716 {
717 len = textarray[j]->length(); 717 len = textarray[j]->length();
718 for (start = 0; start < len && !isalpha((*textarray[j])[start]); start++); 718 for (start = 0; start < len && !isalpha((*textarray[j])[start]); start++);
719 if (start < len) break; 719 if (start < len) break;
720 } 720 }
721 if (j < numlines) 721 if (j < numlines)
722 { 722 {
723 QString ret = ""; 723 QString ret = "";
724 for (end = start; end < len && isalpha((*textarray[j])[end]); end++) 724 for (end = start; end < len && isalpha((*textarray[j])[end]); end++)
725 ret += (*textarray[j])[end]; 725 ret += (*textarray[j])[end];
726 if (ret.isEmpty()) ret = "Current position"; 726 if (ret.isEmpty()) ret = "Current position";
727 return ret; 727 return ret;
728 } 728 }
729 else 729 else
730 return "Current position"; 730 return "Current position";
731 } 731 }
732} 732}
733 733
734// 734//
735// Construct the QTReader with buttons. 735// Construct the QTReader with buttons.
736// 736//
737 737
738bool QTReader::ChangeFont(int tgt) 738bool QTReader::ChangeFont(int tgt)
739{ 739{
740 return m_fontControl.ChangeFont(m_fontname, tgt); 740 return m_fontControl.ChangeFont(m_fontname, tgt);
741} 741}
742 742
743void QTReader::init() 743void QTReader::init()
744{ 744{
745 // setCaption( "Qt Draw Demo Application" ); 745 // setCaption( "Qt Draw Demo Application" );
746 746
747 buffdoc.unsuspend(); 747 buffdoc.unsuspend();
748 setBackgroundColor( white ); 748 setBackgroundColor( white );
749// QPainter p(this); 749// QPainter p(this);
750// p.setBackgroundMode( Qt::OpaqueMode ); 750// p.setBackgroundMode( Qt::OpaqueMode );
751 buffdoc.setfilter(getfilter()); 751 buffdoc.setfilter(getfilter());
752 ChangeFont(m_textsize); 752 ChangeFont(m_textsize);
753 setFocusPolicy(QWidget::StrongFocus); 753 setFocusPolicy(QWidget::StrongFocus);
754 // resize( 240, 320 ); 754 // resize( 240, 320 );
755 //setFocus(); 755 //setFocus();
756 timer = new QTimer(this); 756 timer = new QTimer(this);
757 connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); 757 connect(timer, SIGNAL(timeout()), this, SLOT(doscroll()));
758// QMessageBox::information(this, "init", m_lastfile, 1); 758// QMessageBox::information(this, "init", m_lastfile, 1);
759 setfont(); 759 setfont();
760/* 760/*
761 if (!m_lastfile.isEmpty()) 761 if (!m_lastfile.isEmpty())
762 { 762 {
763 m_string = DocLnk(m_lastfile).name(); 763 m_string = DocLnk(m_lastfile).name();
764 load_file(m_lastfile); 764 load_file(m_lastfile);
765 } 765 }
766*/ 766*/
767} 767}
768 768
769// 769//
770// Clean up 770// Clean up
771// 771//
772QTReader::~QTReader() 772QTReader::~QTReader()
773{ 773{
774} 774}
775 775
776// 776//
777// Calls the drawing function as specified by the radio buttons. 777// Calls the drawing function as specified by the radio buttons.
778// 778//
779 779
780void QTReader::drawIt( QPainter *p ) 780void QTReader::drawIt( QPainter *p )
781{ 781{
782 drawFonts(p); 782 drawFonts(p);
783} 783}
784 784
785// 785//
786// Called when the print button is clicked. 786// Called when the print button is clicked.
787// 787//
788/* 788/*
789void QTReader::printIt() 789void QTReader::printIt()
790{ 790{
791#ifndef QT_NO_PRINTER 791#ifndef QT_NO_PRINTER
792 if ( printer->setup( this ) ) { 792 if ( printer->setup( this ) ) {
793 QPainter paint; 793 QPainter paint;
794 if ( !paint.begin( printer ) ) 794 if ( !paint.begin( printer ) )
795 return; 795 return;
796 drawIt( &paint ); 796 drawIt( &paint );
797 } 797 }
798#endif 798#endif
799} 799}
800*/ 800*/
801// 801//
802// Called when the widget needs to be updated. 802// Called when the widget needs to be updated.
803// 803//
804 804
805void QTReader::paintEvent( QPaintEvent * ) 805void QTReader::paintEvent( QPaintEvent * )
806{ 806{
807 QPainter paint( this ); 807 QPainter paint( this );
808 drawIt( &paint ); 808 drawIt( &paint );
809} 809}
810 810
811// 811//
812// Called when the widget has been resized. 812// Called when the widget has been resized.
813// Moves the button group to the upper right corner 813// Moves the button group to the upper right corner
814// of the widget. 814// of the widget.
815 815
816/* 816/*
817void QTReader::resizeEvent( QResizeEvent * ) 817void QTReader::resizeEvent( QResizeEvent * )
818{ 818{
819 // qDebug("resize:(%u,%u)", width(), height()); 819 // qDebug("resize:(%u,%u)", width(), height());
820 // bgroup->move( width()-bgroup->width(), 0 ); 820 // bgroup->move( width()-bgroup->width(), 0 );
821} 821}
822*/ 822*/
823 823
824// 824//
825// Create and display our widget. 825// Create and display our widget.
826// 826//
827/* 827/*
828int main( int argc, tchar **argv ) 828int main( int argc, tchar **argv )
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
@@ -1404,1203 +1404,1203 @@ void QTReaderApp::pageup()
1404 1404
1405void QTReaderApp::pagedn() 1405void QTReaderApp::pagedn()
1406{ 1406{
1407 reader->NavDown(); 1407 reader->NavDown();
1408} 1408}
1409 1409
1410void QTReaderApp::stripcr(bool _b) 1410void QTReaderApp::stripcr(bool _b)
1411{ 1411{
1412 reader->setstripcr(_b); 1412 reader->setstripcr(_b);
1413} 1413}
1414void QTReaderApp::onespace(bool _b) 1414void QTReaderApp::onespace(bool _b)
1415{ 1415{
1416 reader->setonespace(_b); 1416 reader->setonespace(_b);
1417} 1417}
1418#ifdef REPALM 1418#ifdef REPALM
1419void QTReaderApp::repalm(bool _b) 1419void QTReaderApp::repalm(bool _b)
1420{ 1420{
1421 reader->setrepalm(_b); 1421 reader->setrepalm(_b);
1422} 1422}
1423#endif 1423#endif
1424void QTReaderApp::remap(bool _b) 1424void QTReaderApp::remap(bool _b)
1425{ 1425{
1426 reader->setremap(_b); 1426 reader->setremap(_b);
1427} 1427}
1428void QTReaderApp::peanut(bool _b) 1428void QTReaderApp::peanut(bool _b)
1429{ 1429{
1430 reader->setpeanut(_b); 1430 reader->setpeanut(_b);
1431} 1431}
1432void QTReaderApp::embolden(bool _b) 1432void QTReaderApp::embolden(bool _b)
1433{ 1433{
1434 reader->setmakebold(_b); 1434 reader->setmakebold(_b);
1435} 1435}
1436void QTReaderApp::autofmt(bool _b) 1436void QTReaderApp::autofmt(bool _b)
1437{ 1437{
1438 reader->setautofmt(_b); 1438 reader->setautofmt(_b);
1439} 1439}
1440void QTReaderApp::textfmt(bool _b) 1440void QTReaderApp::textfmt(bool _b)
1441{ 1441{
1442 reader->settextfmt(_b); 1442 reader->settextfmt(_b);
1443} 1443}
1444void QTReaderApp::striphtml(bool _b) 1444void QTReaderApp::striphtml(bool _b)
1445{ 1445{
1446 reader->setstriphtml(_b); 1446 reader->setstriphtml(_b);
1447} 1447}
1448void QTReaderApp::dehyphen(bool _b) 1448void QTReaderApp::dehyphen(bool _b)
1449{ 1449{
1450 reader->setdehyphen(_b); 1450 reader->setdehyphen(_b);
1451} 1451}
1452void QTReaderApp::unindent(bool _b) 1452void QTReaderApp::unindent(bool _b)
1453{ 1453{
1454 reader->setunindent(_b); 1454 reader->setunindent(_b);
1455} 1455}
1456void QTReaderApp::repara(bool _b) 1456void QTReaderApp::repara(bool _b)
1457{ 1457{
1458 reader->setrepara(_b); 1458 reader->setrepara(_b);
1459} 1459}
1460void QTReaderApp::dblspce(bool _b) 1460void QTReaderApp::dblspce(bool _b)
1461{ 1461{
1462 reader->setdblspce(_b); 1462 reader->setdblspce(_b);
1463} 1463}
1464void QTReaderApp::pagemode(bool _b) 1464void QTReaderApp::pagemode(bool _b)
1465{ 1465{
1466 reader->setpagemode(_b); 1466 reader->setpagemode(_b);
1467} 1467}
1468void QTReaderApp::navkeys(bool _b) 1468void QTReaderApp::navkeys(bool _b)
1469{ 1469{
1470 reader->m_navkeys = _b; 1470 reader->m_navkeys = _b;
1471} 1471}
1472void QTReaderApp::monospace(bool _b) 1472void QTReaderApp::monospace(bool _b)
1473{ 1473{
1474 reader->setmono(_b); 1474 reader->setmono(_b);
1475} 1475}
1476 1476
1477void QTReaderApp::setspacing() 1477void QTReaderApp::setspacing()
1478{ 1478{
1479 m_nRegAction = cMonoSpace; 1479 m_nRegAction = cMonoSpace;
1480 char lcn[20]; 1480 char lcn[20];
1481 sprintf(lcn, "%lu", reader->m_charpc); 1481 sprintf(lcn, "%lu", reader->m_charpc);
1482 regEdit->setText(lcn); 1482 regEdit->setText(lcn);
1483 do_regedit(); 1483 do_regedit();
1484} 1484}
1485 1485
1486void QTReaderApp::setoverlap() 1486void QTReaderApp::setoverlap()
1487{ 1487{
1488 m_nRegAction = cOverlap; 1488 m_nRegAction = cOverlap;
1489 char lcn[20]; 1489 char lcn[20];
1490 sprintf(lcn, "%lu", reader->m_overlap); 1490 sprintf(lcn, "%lu", reader->m_overlap);
1491 regEdit->setText(lcn); 1491 regEdit->setText(lcn);
1492 do_regedit(); 1492 do_regedit();
1493} 1493}
1494 1494
1495void QTReaderApp::settarget() 1495void QTReaderApp::settarget()
1496{ 1496{
1497 m_nRegAction = cSetTarget; 1497 m_nRegAction = cSetTarget;
1498 QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) 1498 QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp)
1499 + "/" 1499 + "/"
1500 + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); 1500 + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg);
1501 regEdit->setText(text); 1501 regEdit->setText(text);
1502 do_regedit(); 1502 do_regedit();
1503} 1503}
1504 1504
1505void QTReaderApp::do_overlap(const QString& lcn) 1505void QTReaderApp::do_overlap(const QString& lcn)
1506{ 1506{
1507 bool ok; 1507 bool ok;
1508 unsigned long ulcn = lcn.toULong(&ok); 1508 unsigned long ulcn = lcn.toULong(&ok);
1509 if (ok) 1509 if (ok)
1510 { 1510 {
1511 reader->m_overlap = ulcn; 1511 reader->m_overlap = ulcn;
1512 } 1512 }
1513 else 1513 else
1514 QMessageBox::information(this, PROGNAME, "Must be a number"); 1514 QMessageBox::information(this, PROGNAME, "Must be a number");
1515} 1515}
1516 1516
1517void QTReaderApp::do_mono(const QString& lcn) 1517void QTReaderApp::do_mono(const QString& lcn)
1518{ 1518{
1519 bool ok; 1519 bool ok;
1520 unsigned long ulcn = lcn.toULong(&ok); 1520 unsigned long ulcn = lcn.toULong(&ok);
1521 if (ok) 1521 if (ok)
1522 { 1522 {
1523 reader->m_charpc = ulcn; 1523 reader->m_charpc = ulcn;
1524 reader->setfont(); 1524 reader->setfont();
1525 reader->refresh(); 1525 reader->refresh();
1526 //reader->setmono(true); 1526 //reader->setmono(true);
1527 } 1527 }
1528 else 1528 else
1529 QMessageBox::information(this, PROGNAME, "Must be a number"); 1529 QMessageBox::information(this, PROGNAME, "Must be a number");
1530} 1530}
1531 1531
1532/* 1532/*
1533void QTReaderApp::editPaste() 1533void QTReaderApp::editPaste()
1534{ 1534{
1535#ifndef QT_NO_CLIPBOARD 1535#ifndef QT_NO_CLIPBOARD
1536 editor->paste(); 1536 editor->paste();
1537#endif 1537#endif
1538} 1538}
1539*/ 1539*/
1540 1540
1541void QTReaderApp::editFind() 1541void QTReaderApp::editFind()
1542{ 1542{
1543 searchStart = reader->pagelocate(); 1543 searchStart = reader->pagelocate();
1544#ifdef __ISEARCH 1544#ifdef __ISEARCH
1545 searchStack = new QStack<searchrecord>; 1545 searchStack = new QStack<searchrecord>;
1546#endif 1546#endif
1547 Global::showInputMethod(); 1547 Global::showInputMethod();
1548 searchBar->show(); 1548 searchBar->show();
1549 searchVisible = TRUE; 1549 searchVisible = TRUE;
1550 searchEdit->setFocus(); 1550 searchEdit->setFocus();
1551#ifdef __ISEARCH 1551#ifdef __ISEARCH
1552 searchStack->push(new searchrecord("",reader->pagelocate())); 1552 searchStack->push(new searchrecord("",reader->pagelocate()));
1553#endif 1553#endif
1554} 1554}
1555 1555
1556void QTReaderApp::findNext() 1556void QTReaderApp::findNext()
1557{ 1557{
1558 // qDebug("findNext called\n"); 1558 // qDebug("findNext called\n");
1559#ifdef __ISEARCH 1559#ifdef __ISEARCH
1560 QString arg = searchEdit->text(); 1560 QString arg = searchEdit->text();
1561#else 1561#else
1562 QRegExp arg = searchEdit->text(); 1562 QRegExp arg = searchEdit->text();
1563#endif 1563#endif
1564 CDrawBuffer test(&(reader->m_fontControl)); 1564 CDrawBuffer test(&(reader->m_fontControl));
1565 size_t start = reader->pagelocate(); 1565 size_t start = reader->pagelocate();
1566 reader->jumpto(start); 1566 reader->jumpto(start);
1567 reader->buffdoc.getline(&test,reader->width()); 1567 reader->buffdoc.getline(&test,reader->width());
1568 dosearch(start, test, arg); 1568 dosearch(start, test, arg);
1569} 1569}
1570 1570
1571void QTReaderApp::findClose() 1571void QTReaderApp::findClose()
1572{ 1572{
1573 searchVisible = FALSE; 1573 searchVisible = FALSE;
1574 searchEdit->setText(""); 1574 searchEdit->setText("");
1575 Global::hideInputMethod(); 1575 Global::hideInputMethod();
1576 searchBar->hide(); 1576 searchBar->hide();
1577#ifdef __ISEARCH 1577#ifdef __ISEARCH
1578// searchStack = new QStack<searchrecord>; 1578// searchStack = new QStack<searchrecord>;
1579 while (!searchStack->isEmpty()) 1579 while (!searchStack->isEmpty())
1580 { 1580 {
1581 delete searchStack->pop(); 1581 delete searchStack->pop();
1582 } 1582 }
1583 delete searchStack; 1583 delete searchStack;
1584#endif 1584#endif
1585 reader->setFocus(); 1585 reader->setFocus();
1586} 1586}
1587 1587
1588void QTReaderApp::regClose() 1588void QTReaderApp::regClose()
1589{ 1589{
1590 regVisible = FALSE; 1590 regVisible = FALSE;
1591 regEdit->setText(""); 1591 regEdit->setText("");
1592 regBar->hide(); 1592 regBar->hide();
1593 Global::hideInputMethod(); 1593 Global::hideInputMethod();
1594 reader->setFocus(); 1594 reader->setFocus();
1595} 1595}
1596 1596
1597#ifdef __ISEARCH 1597#ifdef __ISEARCH
1598bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) 1598bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg)
1599#else 1599#else
1600bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) 1600bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
1601#endif 1601#endif
1602{ 1602{
1603 bool ret = true; 1603 bool ret = true;
1604 unsigned long fs, ts; 1604 unsigned long fs, ts;
1605 reader->sizes(fs,ts); 1605 reader->sizes(fs,ts);
1606 size_t pos = reader->locate(); 1606 size_t pos = reader->locate();
1607 reader->buffdoc.getline(&test,reader->width()); 1607 reader->buffdoc.getline(&test,reader->width());
1608 pbar->show(); 1608 pbar->show();
1609 pbar->resize(width(), editBar->height()); 1609 pbar->resize(width(), editBar->height());
1610 pbar->reset(); 1610 pbar->reset();
1611 int lastpc = (100*pos)/ts; 1611 int lastpc = (100*pos)/ts;
1612 pbar->setProgress(lastpc); 1612 pbar->setProgress(lastpc);
1613 qApp->processEvents(); 1613 qApp->processEvents();
1614 reader->setFocus(); 1614 reader->setFocus();
1615#ifdef __ISEARCH 1615#ifdef __ISEARCH
1616 while (strstr(test.data(),(const tchar*)arg) == NULL) 1616 while (strstr(test.data(),(const tchar*)arg) == NULL)
1617#else 1617#else
1618#ifdef _UNICODE 1618#ifdef _UNICODE
1619 while (arg.match(toQString(test.data())) == -1) 1619 while (arg.match(toQString(test.data())) == -1)
1620#else 1620#else
1621 while (arg.match(test.data()) == -1) 1621 while (arg.match(test.data()) == -1)
1622#endif 1622#endif
1623#endif 1623#endif
1624 { 1624 {
1625 pos = reader->locate(); 1625 pos = reader->locate();
1626 unsigned int lcn = reader->locate(); 1626 unsigned int lcn = reader->locate();
1627 int pc = (100*pos)/ts; 1627 int pc = (100*pos)/ts;
1628 if (pc != lastpc) 1628 if (pc != lastpc)
1629 { 1629 {
1630 pbar->setProgress(pc); 1630 pbar->setProgress(pc);
1631 qApp->processEvents(); 1631 qApp->processEvents();
1632 reader->setFocus(); 1632 reader->setFocus();
1633 lastpc = pc; 1633 lastpc = pc;
1634 } 1634 }
1635 1635
1636 if (!reader->buffdoc.getline(&test,reader->width())) 1636 if (!reader->buffdoc.getline(&test,reader->width()))
1637 { 1637 {
1638 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) 1638 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
1639 pos = searchStart; 1639 pos = searchStart;
1640 else 1640 else
1641 pos = start; 1641 pos = start;
1642 ret = false; 1642 ret = false;
1643 findClose(); 1643 findClose();
1644 break; 1644 break;
1645 } 1645 }
1646 } 1646 }
1647 pbar->hide(); 1647 pbar->hide();
1648 reader->locate(pos); 1648 reader->locate(pos);
1649 return ret; 1649 return ret;
1650} 1650}
1651 1651
1652#ifdef __ISEARCH 1652#ifdef __ISEARCH
1653void QTReaderApp::search(const QString & arg) 1653void QTReaderApp::search(const QString & arg)
1654{ 1654{
1655 searchrecord* ss = searchStack->top(); 1655 searchrecord* ss = searchStack->top();
1656 CBuffer test; 1656 CBuffer test;
1657 size_t start = reader->pagelocate(); 1657 size_t start = reader->pagelocate();
1658 bool haspopped = false; 1658 bool haspopped = false;
1659 while (arg.left(ss->s.length()) != ss->s) 1659 while (arg.left(ss->s.length()) != ss->s)
1660 { 1660 {
1661 haspopped = true; 1661 haspopped = true;
1662 start = ss->pos; 1662 start = ss->pos;
1663// reader->locate(start); 1663// reader->locate(start);
1664 searchStack->pop(); 1664 searchStack->pop();
1665 delete ss; 1665 delete ss;
1666 } 1666 }
1667 if (haspopped) reader->locate(start); 1667 if (haspopped) reader->locate(start);
1668/* 1668/*
1669 if (arg.length() < ss->len) 1669 if (arg.length() < ss->len)
1670 { 1670 {
1671 start = ss->pos; 1671 start = ss->pos;
1672 reader->locate(start); 1672 reader->locate(start);
1673 searchStack->pop(); 1673 searchStack->pop();
1674 delete ss; 1674 delete ss;
1675 } 1675 }
1676*/ 1676*/
1677 else 1677 else
1678 { 1678 {
1679 start = reader->pagelocate(); 1679 start = reader->pagelocate();
1680 reader->jumpto(start); 1680 reader->jumpto(start);
1681 searchStack->push(new searchrecord(arg,start)); 1681 searchStack->push(new searchrecord(arg,start));
1682 } 1682 }
1683 dosearch(start, test, arg); 1683 dosearch(start, test, arg);
1684} 1684}
1685#else 1685#else
1686void QTReaderApp::search() 1686void QTReaderApp::search()
1687{ 1687{
1688 findNext(); 1688 findNext();
1689} 1689}
1690#endif 1690#endif
1691 1691
1692void QTReaderApp::openFile( const QString &f ) 1692void QTReaderApp::openFile( const QString &f )
1693{ 1693{
1694 qDebug("File:%s", (const char*)f); 1694 qDebug("File:%s", (const char*)f);
1695// openFile(DocLnk(f)); 1695// openFile(DocLnk(f));
1696//} 1696//}
1697// 1697//
1698//void QTReaderApp::openFile( const DocLnk &f ) 1698//void QTReaderApp::openFile( const DocLnk &f )
1699//{ 1699//{
1700 clear(); 1700 clear();
1701 QFileInfo fm(f); 1701 QFileInfo fm(f);
1702 if ( fm.exists() ) 1702 if ( fm.exists() )
1703 { 1703 {
1704// QMessageBox::information(0, "Progress", "Calling fileNew()"); 1704// QMessageBox::information(0, "Progress", "Calling fileNew()");
1705 1705
1706 if (fm.extension( FALSE ) == "desktop") 1706 if (fm.extension( FALSE ) == "desktop")
1707 { 1707 {
1708 DocLnk d(f); 1708 DocLnk d(f);
1709 QFileInfo fnew(d.file()); 1709 QFileInfo fnew(d.file());
1710 fm = fnew; 1710 fm = fnew;
1711 if (!fm.exists()) return; 1711 if (!fm.exists()) return;
1712 } 1712 }
1713 1713
1714 clear(); 1714 clear();
1715 1715
1716 reader->setText(fm.baseName(), fm.absFilePath()); 1716 reader->setText(fm.baseName(), fm.absFilePath());
1717 showEditTools(); 1717 showEditTools();
1718 readbkmks(); 1718 readbkmks();
1719 } 1719 }
1720 else 1720 else
1721 { 1721 {
1722 QMessageBox::information(this, PROGNAME, "File does not exist"); 1722 QMessageBox::information(this, PROGNAME, "File does not exist");
1723 } 1723 }
1724 1724
1725} 1725}
1726/* 1726/*
1727void QTReaderApp::resizeEvent(QResizeEvent* e) 1727void QTReaderApp::resizeEvent(QResizeEvent* e)
1728{ 1728{
1729 if (m_fullscreen) 1729 if (m_fullscreen)
1730 { 1730 {
1731 showNormal(); 1731 showNormal();
1732 showFullScreen(); 1732 showFullScreen();
1733 } 1733 }
1734} 1734}
1735*/ 1735*/
1736void QTReaderApp::keyPressEvent(QKeyEvent* e) 1736void QTReaderApp::keyPressEvent(QKeyEvent* e)
1737{ 1737{
1738 if (m_fullscreen) 1738 if (m_fullscreen)
1739 { 1739 {
1740 switch(e->key()) 1740 switch(e->key())
1741 { 1741 {
1742 case Key_Escape: 1742 case Key_Escape:
1743 m_actFullscreen->setOn(false); 1743 m_actFullscreen->setOn(false);
1744 if (m_fullscreen) 1744 if (m_fullscreen)
1745 { 1745 {
1746 qDebug("Fullscreen already set - remove this!"); 1746 qDebug("Fullscreen already set - remove this!");
1747 } 1747 }
1748 else 1748 else
1749 { 1749 {
1750 m_fullscreen = false; 1750 m_fullscreen = false;
1751 reader->bDoUpdates = false; 1751 reader->bDoUpdates = false;
1752 showEditTools(); 1752 showEditTools();
1753 qApp->processEvents(); 1753 qApp->processEvents();
1754 reader->bDoUpdates = true; 1754 reader->bDoUpdates = true;
1755 reader->update(); 1755 reader->update();
1756 } 1756 }
1757 e->accept(); 1757 e->accept();
1758 break; 1758 break;
1759 default: 1759 default:
1760 e->ignore(); 1760 e->ignore();
1761 } 1761 }
1762 } 1762 }
1763 else 1763 else
1764 { 1764 {
1765 e->ignore(); 1765 e->ignore();
1766 } 1766 }
1767} 1767}
1768 1768
1769void QTReaderApp::showEditTools() 1769void QTReaderApp::showEditTools()
1770{ 1770{
1771// if ( !doc ) 1771// if ( !doc )
1772 //close(); 1772 //close();
1773 if (m_fullscreen) 1773 if (m_fullscreen)
1774 { 1774 {
1775 editBar->hide(); 1775 editBar->hide();
1776 searchBar->hide(); 1776 searchBar->hide();
1777 regBar->hide(); 1777 regBar->hide();
1778 Global::hideInputMethod(); 1778 Global::hideInputMethod();
1779 m_fontBar->hide(); 1779 m_fontBar->hide();
1780 //showNormal(); 1780 //showNormal();
1781 showFullScreen(); 1781 showFullScreen();
1782 } 1782 }
1783 else 1783 else
1784 { 1784 {
1785 qDebug("him"); 1785 qDebug("him");
1786 Global::hideInputMethod(); 1786 Global::hideInputMethod();
1787 qDebug("eb"); 1787 qDebug("eb");
1788 editBar->show(); 1788 editBar->show();
1789 if ( searchVisible ) 1789 if ( searchVisible )
1790 { 1790 {
1791 Global::showInputMethod(); 1791 Global::showInputMethod();
1792 searchBar->show(); 1792 searchBar->show();
1793 } 1793 }
1794 if ( regVisible ) 1794 if ( regVisible )
1795 { 1795 {
1796 Global::showInputMethod(); 1796 Global::showInputMethod();
1797 regBar->show(); 1797 regBar->show();
1798 } 1798 }
1799 if (m_fontVisible) m_fontBar->show(); 1799 if (m_fontVisible) m_fontBar->show();
1800 qDebug("sn"); 1800 qDebug("sn");
1801 showNormal(); 1801 showNormal();
1802 qDebug("sm"); 1802 qDebug("sm");
1803 showMaximized(); 1803 showMaximized();
1804 //setCentralWidget(reader); 1804 //setCentralWidget(reader);
1805 } 1805 }
1806 1806
1807 qDebug("uc"); 1807 qDebug("uc");
1808 updateCaption(); 1808 updateCaption();
1809 qDebug("rw"); 1809 qDebug("rw");
1810 editorStack->raiseWidget( reader ); 1810 editorStack->raiseWidget( reader );
1811 qDebug("sf"); 1811 qDebug("sf");
1812 reader->setFocus(); 1812 reader->setFocus();
1813} 1813}
1814/* 1814/*
1815void QTReaderApp::save() 1815void QTReaderApp::save()
1816{ 1816{
1817 if ( !doc ) 1817 if ( !doc )
1818 return; 1818 return;
1819 if ( !editor->edited() ) 1819 if ( !editor->edited() )
1820 return; 1820 return;
1821 1821
1822 QString rt = editor->text(); 1822 QString rt = editor->text();
1823 QString pt = rt; 1823 QString pt = rt;
1824 1824
1825 if ( doc->name().isEmpty() ) { 1825 if ( doc->name().isEmpty() ) {
1826 unsigned ispace = pt.find( ' ' ); 1826 unsigned ispace = pt.find( ' ' );
1827 unsigned ienter = pt.find( '\n' ); 1827 unsigned ienter = pt.find( '\n' );
1828 int i = (ispace < ienter) ? ispace : ienter; 1828 int i = (ispace < ienter) ? ispace : ienter;
1829 QString docname; 1829 QString docname;
1830 if ( i == -1 ) { 1830 if ( i == -1 ) {
1831 if ( pt.isEmpty() ) 1831 if ( pt.isEmpty() )
1832 docname = "Empty Text"; 1832 docname = "Empty Text";
1833 else 1833 else
1834 docname = pt; 1834 docname = pt;
1835 } else { 1835 } else {
1836 docname = pt.left( i ); 1836 docname = pt.left( i );
1837 } 1837 }
1838 doc->setName(docname); 1838 doc->setName(docname);
1839 } 1839 }
1840 FileManager fm; 1840 FileManager fm;
1841 fm.saveFile( *doc, rt ); 1841 fm.saveFile( *doc, rt );
1842} 1842}
1843*/ 1843*/
1844 1844
1845void QTReaderApp::clear() 1845void QTReaderApp::clear()
1846{ 1846{
1847// if (doc != 0) 1847// if (doc != 0)
1848// { 1848// {
1849// QMessageBox::information(this, PROGNAME, "Deleting doc", 1); 1849// QMessageBox::information(this, PROGNAME, "Deleting doc", 1);
1850 //delete doc; 1850 //delete doc;
1851// QMessageBox::information(this, PROGNAME, "Deleted doc", 1); 1851// QMessageBox::information(this, PROGNAME, "Deleted doc", 1);
1852 //doc = 0; 1852 //doc = 0;
1853 // } 1853 // }
1854 reader->clear(); 1854 reader->clear();
1855} 1855}
1856 1856
1857void QTReaderApp::updateCaption() 1857void QTReaderApp::updateCaption()
1858{ 1858{
1859// if ( !doc ) 1859// if ( !doc )
1860 //setCaption( tr("QTReader") ); 1860 //setCaption( tr("QTReader") );
1861// else { 1861// else {
1862 //QString s = doc->name(); 1862 //QString s = doc->name();
1863 //if ( s.isEmpty() ) 1863 //if ( s.isEmpty() )
1864 // s = tr( "Unnamed" ); 1864 // s = tr( "Unnamed" );
1865 setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) ); 1865 setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) );
1866// } 1866// }
1867} 1867}
1868 1868
1869void QTReaderApp::setDocument(const QString& fileref) 1869void QTReaderApp::setDocument(const QString& fileref)
1870{ 1870{
1871 bFromDocView = TRUE; 1871 bFromDocView = TRUE;
1872//QMessageBox::information(0, "setDocument", fileref); 1872//QMessageBox::information(0, "setDocument", fileref);
1873 openFile(fileref); 1873 openFile(fileref);
1874// showEditTools(); 1874// showEditTools();
1875} 1875}
1876 1876
1877void QTReaderApp::closeEvent( QCloseEvent *e ) 1877void QTReaderApp::closeEvent( QCloseEvent *e )
1878{ 1878{
1879 if (m_fullscreen) 1879 if (m_fullscreen)
1880 { 1880 {
1881 m_fullscreen = false; 1881 m_fullscreen = false;
1882 showEditTools(); 1882 showEditTools();
1883 e->accept(); 1883 e->accept();
1884 } 1884 }
1885 else if (m_dontSave) 1885 else if (m_dontSave)
1886 { 1886 {
1887 e->accept(); 1887 e->accept();
1888 } 1888 }
1889 else 1889 else
1890 { 1890 {
1891 if (editorStack->visibleWidget() == reader) 1891 if (editorStack->visibleWidget() == reader)
1892 { 1892 {
1893 if (m_fontVisible) 1893 if (m_fontVisible)
1894 { 1894 {
1895 m_fontBar->hide(); 1895 m_fontBar->hide();
1896 m_fontVisible = false; 1896 m_fontVisible = false;
1897 } 1897 }
1898 if (regVisible) 1898 if (regVisible)
1899 { 1899 {
1900 regBar->hide(); 1900 regBar->hide();
1901 Global::hideInputMethod(); 1901 Global::hideInputMethod();
1902 regVisible = false; 1902 regVisible = false;
1903 return; 1903 return;
1904 } 1904 }
1905 if (searchVisible) 1905 if (searchVisible)
1906 { 1906 {
1907 searchBar->hide(); 1907 searchBar->hide();
1908 Global::hideInputMethod(); 1908 Global::hideInputMethod();
1909 searchVisible = false; 1909 searchVisible = false;
1910 return; 1910 return;
1911 } 1911 }
1912 if (m_fBkmksChanged && pBkmklist != NULL) 1912 if (m_fBkmksChanged && pBkmklist != NULL)
1913 { 1913 {
1914 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) 1914 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
1915 savebkmks(); 1915 savebkmks();
1916 delete pBkmklist; 1916 delete pBkmklist;
1917 pBkmklist = NULL; 1917 pBkmklist = NULL;
1918 m_fBkmksChanged = false; 1918 m_fBkmksChanged = false;
1919 } 1919 }
1920 bFromDocView = FALSE; 1920 bFromDocView = FALSE;
1921 updatefileinfo(); 1921 updatefileinfo();
1922 saveprefs(); 1922 saveprefs();
1923 e->accept(); 1923 e->accept();
1924 } 1924 }
1925 else 1925 else
1926 { 1926 {
1927 showEditTools(); 1927 showEditTools();
1928 } 1928 }
1929 } 1929 }
1930} 1930}
1931 1931
1932void QTReaderApp::do_gotomark() 1932void QTReaderApp::do_gotomark()
1933{ 1933{
1934 m_nRegAction = cGotoBkmk; 1934 m_nRegAction = cGotoBkmk;
1935 listbkmk(pBkmklist); 1935 listbkmk(pBkmklist);
1936} 1936}
1937 1937
1938void QTReaderApp::do_delmark() 1938void QTReaderApp::do_delmark()
1939{ 1939{
1940 m_nRegAction = cDelBkmk; 1940 m_nRegAction = cDelBkmk;
1941 listbkmk(pBkmklist); 1941 listbkmk(pBkmklist);
1942} 1942}
1943 1943
1944void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) 1944void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
1945{ 1945{
1946 bkmkselector->clear(); 1946 bkmkselector->clear();
1947 if (_lab.isNull()) 1947 if (_lab.isNull())
1948 bkmkselector->setText("Cancel"); 1948 bkmkselector->setText("Cancel");
1949 else 1949 else
1950 bkmkselector->setText(_lab); 1950 bkmkselector->setText(_lab);
1951 int cnt = 0; 1951 int cnt = 0;
1952 if (plist != NULL) 1952 if (plist != NULL)
1953 { 1953 {
1954 for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) 1954 for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++)
1955 { 1955 {
1956#ifdef _UNICODE 1956#ifdef _UNICODE
1957 qDebug("Item:%s", (const char*)toQString(i->name())); 1957 qDebug("Item:%s", (const char*)toQString(i->name()));
1958 bkmkselector->insertItem(toQString(i->name())); 1958 bkmkselector->insertItem(toQString(i->name()));
1959#else 1959#else
1960 bkmkselector->insertItem(i->name()); 1960 bkmkselector->insertItem(i->name());
1961#endif 1961#endif
1962 cnt++; 1962 cnt++;
1963 } 1963 }
1964 } 1964 }
1965 if (cnt > 0) 1965 if (cnt > 0)
1966 { 1966 {
1967//tjw menu->hide(); 1967//tjw menu->hide();
1968 editBar->hide(); 1968 editBar->hide();
1969 if (m_fontVisible) m_fontBar->hide(); 1969 if (m_fontVisible) m_fontBar->hide();
1970 if (regVisible) 1970 if (regVisible)
1971 { 1971 {
1972 Global::hideInputMethod(); 1972 Global::hideInputMethod();
1973 regBar->hide(); 1973 regBar->hide();
1974 } 1974 }
1975 if (searchVisible) 1975 if (searchVisible)
1976 { 1976 {
1977 Global::hideInputMethod(); 1977 Global::hideInputMethod();
1978 searchBar->hide(); 1978 searchBar->hide();
1979 } 1979 }
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{
2365 if (pBkmklist != NULL) 2365 if (pBkmklist != NULL)
2366 { 2366 {
2367 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string), true); 2367 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string), true);
2368 bf.write(*pBkmklist); 2368 bf.write(*pBkmklist);
2369 } 2369 }
2370 m_fBkmksChanged = false; 2370 m_fBkmksChanged = false;
2371} 2371}
2372 2372
2373void QTReaderApp::readfilelist() 2373void QTReaderApp::readfilelist()
2374{ 2374{
2375 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles")); 2375 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"));
2376 qDebug("Reading open files"); 2376 qDebug("Reading open files");
2377 pOpenlist = bf.readall(); 2377 pOpenlist = bf.readall();
2378 if (pOpenlist != NULL) qDebug("...with success"); 2378 if (pOpenlist != NULL) qDebug("...with success");
2379 else qDebug("...without success!"); 2379 else qDebug("...without success!");
2380} 2380}
2381 2381
2382void QTReaderApp::savefilelist() 2382void QTReaderApp::savefilelist()
2383{ 2383{
2384 if (pOpenlist != NULL) 2384 if (pOpenlist != NULL)
2385 { 2385 {
2386 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"), true); 2386 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"), true);
2387 qDebug("Writing open files"); 2387 qDebug("Writing open files");
2388 bf.write(*pOpenlist); 2388 bf.write(*pOpenlist);
2389 } 2389 }
2390} 2390}
2391 2391
2392void QTReaderApp::readbkmks() 2392void QTReaderApp::readbkmks()
2393{ 2393{
2394 if (pBkmklist != NULL) 2394 if (pBkmklist != NULL)
2395 { 2395 {
2396 delete pBkmklist; 2396 delete pBkmklist;
2397 } 2397 }
2398 struct stat fnstat; 2398 struct stat fnstat;
2399 struct stat bkstat; 2399 struct stat bkstat;
2400 if ( 2400 if (
2401 stat((const char *)reader->m_lastfile, &fnstat) == 0 2401 stat((const char *)reader->m_lastfile, &fnstat) == 0
2402 && 2402 &&
2403 stat((const char *)Global::applicationFileName(APPDIR, reader->m_string), &bkstat) == 0 2403 stat((const char *)Global::applicationFileName(APPDIR, reader->m_string), &bkstat) == 0
2404 ) 2404 )
2405 { 2405 {
2406 if (bkstat.st_mtime < fnstat.st_mtime) 2406 if (bkstat.st_mtime < fnstat.st_mtime)
2407 { 2407 {
2408 unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string)); 2408 unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string));
2409 } 2409 }
2410 } 2410 }
2411 2411
2412 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string)); 2412 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string));
2413 2413
2414 pBkmklist = bf.readall(); 2414 pBkmklist = bf.readall();
2415 m_fBkmksChanged = bf.upgraded(); 2415 m_fBkmksChanged = bf.upgraded();
2416 if (pBkmklist == NULL) 2416 if (pBkmklist == NULL)
2417 { 2417 {
2418 pBkmklist = reader->getbkmklist(); 2418 pBkmklist = reader->getbkmklist();
2419 } 2419 }
2420 if (pBkmklist != NULL) 2420 if (pBkmklist != NULL)
2421 pBkmklist->sort(); 2421 pBkmklist->sort();
2422} 2422}
2423 2423
2424void QTReaderApp::addbkmk() 2424void QTReaderApp::addbkmk()
2425{ 2425{
2426 m_nRegAction = cAddBkmk; 2426 m_nRegAction = cAddBkmk;
2427 regEdit->setText(reader->firstword()); 2427 regEdit->setText(reader->firstword());
2428 do_regedit(); 2428 do_regedit();
2429} 2429}
2430 2430
2431void QTReaderApp::do_addbkmk(const QString& text) 2431void QTReaderApp::do_addbkmk(const QString& text)
2432{ 2432{
2433 if (text.isEmpty()) 2433 if (text.isEmpty())
2434 { 2434 {
2435 QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); 2435 QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1);
2436 } 2436 }
2437 else 2437 else
2438 { 2438 {
2439 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; 2439 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>;
2440#ifdef _UNICODE 2440#ifdef _UNICODE
2441 CBuffer buff; 2441 CBuffer buff;
2442 int i = 0; 2442 int i = 0;
2443 for (i = 0; i < text.length(); i++) 2443 for (i = 0; i < text.length(); i++)
2444 { 2444 {
2445 buff[i] = text[i].unicode(); 2445 buff[i] = text[i].unicode();
2446 } 2446 }
2447 buff[i] = 0; 2447 buff[i] = 0;
2448 pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); 2448 pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate()));
2449#else 2449#else
2450 pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); 2450 pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate()));
2451#endif 2451#endif
2452 m_fBkmksChanged = true; 2452 m_fBkmksChanged = true;
2453 pBkmklist->sort(); 2453 pBkmklist->sort();
2454 } 2454 }
2455} 2455}
2456 2456
2457void QTReaderApp::OnRedraw() 2457void QTReaderApp::OnRedraw()
2458{ 2458{
2459 if (pBkmklist != NULL) 2459 if (pBkmklist != NULL)
2460 { 2460 {
2461 bool found = findNextBookmark(reader->pagelocate()); 2461 bool found = findNextBookmark(reader->pagelocate());
2462 m_bkmkAvail->setEnabled(found); 2462 m_bkmkAvail->setEnabled(found);
2463 } 2463 }
2464} 2464}
2465 2465
2466void QTReaderApp::showAnnotation() 2466void QTReaderApp::showAnnotation()
2467{ 2467{
2468 m_annoWin->setName(toQString(m_anno->name())); 2468 m_annoWin->setName(toQString(m_anno->name()));
2469 m_annoWin->setAnno(toQString(m_anno->anno())); 2469 m_annoWin->setAnno(toQString(m_anno->anno()));
2470 m_annoIsEditing = false; 2470 m_annoIsEditing = false;
2471 Global::showInputMethod(); 2471 Global::showInputMethod();
2472 editorStack->raiseWidget( m_annoWin ); 2472 editorStack->raiseWidget( m_annoWin );
2473 m_annoWin->setFocus(); 2473 m_annoWin->setFocus();
2474} 2474}
2475 2475
2476void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) 2476void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line)
2477{ 2477{
2478// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); 2478// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd);
2479 2479
2480 if (m_doClipboard) 2480 if (m_doClipboard)
2481 { 2481 {
2482 QClipboard* cb = QApplication::clipboard(); 2482 QClipboard* cb = QApplication::clipboard();
2483 cb->setText(wrd); 2483 cb->setText(wrd);
2484 if (wrd.length() > 10) 2484 if (wrd.length() > 10)
2485 { 2485 {
2486 Global::statusMessage(wrd.left(8) + ".."); 2486 Global::statusMessage(wrd.left(8) + "..");
2487 } 2487 }
2488 else 2488 else
2489 { 2489 {
2490 Global::statusMessage(wrd); 2490 Global::statusMessage(wrd);
2491 } 2491 }
2492 } 2492 }
2493 if (m_doAnnotation) 2493 if (m_doAnnotation)
2494 { 2494 {
2495 //addAnno(wrd, "Need to be able to edit this", posn); 2495 //addAnno(wrd, "Need to be able to edit this", posn);
2496 m_annoWin->setName(line); 2496 m_annoWin->setName(line);
2497 m_annoWin->setAnno(""); 2497 m_annoWin->setAnno("");
2498 m_annoWin->setPosn(posn); 2498 m_annoWin->setPosn(posn);
2499 m_annoIsEditing = true; 2499 m_annoIsEditing = true;
2500 Global::showInputMethod(); 2500 Global::showInputMethod();
2501 editorStack->raiseWidget( m_annoWin ); 2501 editorStack->raiseWidget( m_annoWin );
2502 } 2502 }
2503 if (m_doDictionary) 2503 if (m_doDictionary)
2504 { 2504 {
2505 if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) 2505 if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty())
2506 { 2506 {
2507 QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); 2507 QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8());
2508 e << wrd; 2508 e << wrd;
2509 } 2509 }
2510 } 2510 }
2511} 2511}
2512 2512
2513void QTReaderApp::OnActionPressed() 2513void QTReaderApp::OnActionPressed()
2514{ 2514{
2515 switch (m_spaceTarget) 2515 switch (m_spaceTarget)
2516 { 2516 {
2517 case cesOpenFile: 2517 case cesOpenFile:
2518 { 2518 {
2519 fileOpen(); 2519 fileOpen();
2520 } 2520 }
2521 break; 2521 break;
2522 case cesAutoScroll: 2522 case cesAutoScroll:
2523 { 2523 {
2524 reader->setautoscroll(!reader->m_autoScroll); 2524 reader->setautoscroll(!reader->m_autoScroll);
2525 setScrollState(reader->m_autoScroll); 2525 setScrollState(reader->m_autoScroll);
2526 } 2526 }
2527 break; 2527 break;
2528 case cesActionMark: 2528 case cesActionMark:
2529 { 2529 {
2530 addbkmk(); 2530 addbkmk();
2531 } 2531 }
2532 break; 2532 break;
2533 case cesFullScreen: 2533 case cesFullScreen:
2534 { 2534 {
2535 m_actFullscreen->setOn(true); 2535 m_actFullscreen->setOn(true);
2536 } 2536 }
2537 break; 2537 break;
2538 default: 2538 default:
2539 { 2539 {
2540 qDebug("Unknown ActionType:%u", m_spaceTarget); 2540 qDebug("Unknown ActionType:%u", m_spaceTarget);
2541 } 2541 }
2542 break; 2542 break;
2543 } 2543 }
2544} 2544}
2545 2545
2546void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } 2546void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); }
2547void QTReaderApp::restoreFocus() { reader->setFocus(); } 2547void QTReaderApp::restoreFocus() { reader->setFocus(); }
2548 2548
2549/* 2549/*
2550void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen) 2550void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen)
2551{ 2551{
2552 unsigned short sdlen; 2552 unsigned short sdlen;
2553 memcpy(&sdlen, _sd, sizeof(sdlen)); 2553 memcpy(&sdlen, _sd, sizeof(sdlen));
2554 sdlen -= sizeof(sdlen); 2554 sdlen -= sizeof(sdlen);
2555 _sd += sizeof(sdlen); 2555 _sd += sizeof(sdlen);
2556 statedata* sd; 2556 statedata* sd;
2557 char* data; 2557 char* data;
2558 if (sdlen < sizeof(statedata)+1) 2558 if (sdlen < sizeof(statedata)+1)
2559 { 2559 {
2560 sdlen = sizeof(statedata)+1; 2560 sdlen = sizeof(statedata)+1;
2561 } 2561 }
2562 data = new char[sdlen]; 2562 data = new char[sdlen];
2563 sd = (statedata*)data; 2563 sd = (statedata*)data;
2564 memcpy(sd, _sd, sdlen); 2564 memcpy(sd, _sd, sdlen);
2565 data[sdlen] = 0; 2565 data[sdlen] = 0;
2566 reader->setstate(*sd); 2566 reader->setstate(*sd);
2567 delete [] data; 2567 delete [] data;
2568} 2568}
2569 2569
2570void QTReaderApp::getstate(unsigned char*& data, unsigned short& len) 2570void QTReaderApp::getstate(unsigned char*& data, unsigned short& len)
2571{ 2571{
2572 unsigned char* olddata = data; 2572 unsigned char* olddata = data;
2573 unsigned short oldlen = len; 2573 unsigned short oldlen = len;
2574 len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length(); 2574 len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length();
2575 data = new unsigned char[len]; 2575 data = new unsigned char[len];
2576 memcpy(data, olddata, oldlen); 2576 memcpy(data, olddata, oldlen);
2577 delete [] olddata; 2577 delete [] olddata;
2578 memcpy(data+oldlen, &len, sizeof(len)); 2578 memcpy(data+oldlen, &len, sizeof(len));
2579 statedata* sd = (statedata*)(data+oldlen+sizeof(unsigned short)); 2579 statedata* sd = (statedata*)(data+oldlen+sizeof(unsigned short));
2580 2580
2581 sd->bstripcr = reader->bstripcr; 2581 sd->bstripcr = reader->bstripcr;
2582 sd->btextfmt = reader->btextfmt; 2582 sd->btextfmt = reader->btextfmt;
2583 sd->bautofmt = reader->bautofmt; 2583 sd->bautofmt = reader->bautofmt;
2584 sd->bstriphtml = reader->bstriphtml; 2584 sd->bstriphtml = reader->bstriphtml;
2585 sd->bpeanut = reader->bpeanut; 2585 sd->bpeanut = reader->bpeanut;
2586 sd->bdehyphen = reader->bdehyphen; 2586 sd->bdehyphen = reader->bdehyphen;
2587 sd->bonespace = reader->bonespace; 2587 sd->bonespace = reader->bonespace;
2588 sd->bunindent = reader->bunindent; 2588 sd->bunindent = reader->bunindent;
2589 sd->brepara = reader->brepara; 2589 sd->brepara = reader->brepara;
2590 sd->bdblspce = reader->bdblspce; 2590 sd->bdblspce = reader->bdblspce;
2591 sd->m_bpagemode = reader->m_bpagemode; 2591 sd->m_bpagemode = reader->m_bpagemode;
2592 sd->m_navkeys = reader->m_navkeys; 2592 sd->m_navkeys = reader->m_navkeys;
2593 sd->m_bMonoSpaced = reader->m_bMonoSpaced; 2593 sd->m_bMonoSpaced = reader->m_bMonoSpaced;
2594 sd->bremap = reader->bremap; 2594 sd->bremap = reader->bremap;
2595 sd->bmakebold = reader->bmakebold; 2595 sd->bmakebold = reader->bmakebold;
2596 sd->Continuous = reader->m_continuousDocument; 2596 sd->Continuous = reader->m_continuousDocument;
2597#ifdef REPALM 2597#ifdef REPALM
2598 sd->brepalm = reader->brepalm; 2598 sd->brepalm = reader->brepalm;
2599#endif 2599#endif
2600 sd->bindenter = reader->bindenter; 2600 sd->bindenter = reader->bindenter;
2601 sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize() 2601 sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize()
2602 sd->m_encd = reader->m_encd; 2602 sd->m_encd = reader->m_encd;
2603 sd->m_charpc = reader->m_charpc; 2603 sd->m_charpc = reader->m_charpc;
2604 strcpy(sd->m_fontname, reader->m_fontname.latin1()); 2604 strcpy(sd->m_fontname, reader->m_fontname.latin1());
2605} 2605}
2606*/ 2606*/
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}