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,1327 +1,1327 @@
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 )
829{ 829{
830 QApplication app( argc, argv ); 830 QApplication app( argc, argv );
831 QTReader draw; 831 QTReader draw;
832 app.setMainWidget( &draw ); 832 app.setMainWidget( &draw );
833 draw.setCaption("Qt Example - Drawdemo"); 833 draw.setCaption("Qt Example - Drawdemo");
834 draw.show(); 834 draw.show();
835 return app.exec(); 835 return app.exec();
836} 836}
837*/ 837*/
838 838
839 839
840bool QTReader::locate(unsigned long n) { 840bool QTReader::locate(unsigned long n) {
841 //printf("Locate\n"); 841 //printf("Locate\n");
842 buffdoc.unsuspend(); 842 buffdoc.unsuspend();
843 buffdoc.locate(n); 843 buffdoc.locate(n);
844 // qDebug("&buffdoc.located"); 844 // qDebug("&buffdoc.located");
845 fillbuffer(); 845 fillbuffer();
846 // qDebug("&Buffer filled"); 846 // qDebug("&Buffer filled");
847 update(); 847 update();
848 // qDebug("&Located"); 848 // qDebug("&Located");
849 return true; 849 return true;
850} 850}
851 851
852unsigned int QTReader::screenlines() 852unsigned int QTReader::screenlines()
853{ 853{
854 // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; 854 // int linespacing = (tight) ? m_ascent : m_ascent+m_descent;
855 // return (height()-m_descent)/(m_linespacing); 855 // return (height()-m_descent)/(m_linespacing);
856 return (height()-2)/(m_linespacing); 856 return (height()-2)/(m_linespacing);
857}; 857};
858 858
859bool QTReader::fillbuffer(int reuse, int ht) 859bool QTReader::fillbuffer(int reuse, int ht)
860{ 860{
861 buffdoc.unsuspend(); 861 buffdoc.unsuspend();
862 if (buffdoc.empty()) return false; 862 if (buffdoc.empty()) return false;
863 m_scrolldy1 = m_scrolldy2 = 0; 863 m_scrolldy1 = m_scrolldy2 = 0;
864 int ch; 864 int ch;
865 bool ret = false; 865 bool ret = false;
866 unsigned int oldpagepos = locnarray[reuse]; 866 unsigned int oldpagepos = locnarray[reuse];
867 int ypos = ht; 867 int ypos = ht;
868 numlines = reuse; 868 numlines = reuse;
869 while (ypos < height() || numlines < 2) 869 while (ypos < height() || numlines < 2)
870 { 870 {
871 if (textarray[numlines] == NULL) 871 if (textarray[numlines] == NULL)
872 { 872 {
873 textarray[numlines] = new CDrawBuffer(&m_fontControl); 873 textarray[numlines] = new CDrawBuffer(&m_fontControl);
874 } 874 }
875 locnarray[numlines] = locate(); 875 locnarray[numlines] = locate();
876 int ch = getline(textarray[numlines]); 876 int ch = getline(textarray[numlines]);
877 ypos += textarray[numlines]->lineSpacing(); 877 ypos += textarray[numlines]->lineSpacing();
878 numlines++; 878 numlines++;
879 if (!ch) 879 if (!ch)
880 { 880 {
881 if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/) 881 if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/)
882 { 882 {
883 locate(oldpagepos); 883 locate(oldpagepos);
884 return false; 884 return false;
885 } 885 }
886 else 886 else
887 { 887 {
888 --numlines; 888 --numlines;
889 mylastpos = locate(); 889 mylastpos = locate();
890 return true; 890 return true;
891 } 891 }
892 } 892 }
893 } 893 }
894 894
895 --numlines; 895 --numlines;
896 mylastpos = locate(); 896 mylastpos = locate();
897 897
898 return true; 898 return true;
899} 899}
900 900
901 901
902void QTReader::dopagedn() 902void QTReader::dopagedn()
903{ 903{
904 buffdoc.unsuspend(); 904 buffdoc.unsuspend();
905 int skip = 0, ypos = 0; 905 int skip = 0, ypos = 0;
906 if (locate() != mylastpos) 906 if (locate() != mylastpos)
907 { 907 {
908 //qDebug("Jumping to %u", mylastpos); 908 //qDebug("Jumping to %u", mylastpos);
909 jumpto(mylastpos); 909 jumpto(mylastpos);
910 } 910 }
911 CDrawBuffer* reusebuffer = textarray[numlines]; 911 CDrawBuffer* reusebuffer = textarray[numlines];
912 if (reusebuffer != NULL && reusebuffer->eof()) return; 912 if (reusebuffer != NULL && reusebuffer->eof()) return;
913 if (reusebuffer != NULL) 913 if (reusebuffer != NULL)
914 { 914 {
915 for (int i = 0; i <= m_overlap; i++) 915 for (int i = 0; i <= m_overlap; i++)
916 { 916 {
917 int offset = numlines - m_overlap + i; 917 int offset = numlines - m_overlap + i;
918 reusebuffer = textarray[offset]; 918 reusebuffer = textarray[offset];
919 size_t reuselocn = locnarray[offset]; 919 size_t reuselocn = locnarray[offset];
920 textarray[offset] = textarray[i]; 920 textarray[offset] = textarray[i];
921 textarray[i] = reusebuffer; 921 textarray[i] = reusebuffer;
922 // reusebuffer->empty(); 922 // reusebuffer->empty();
923 locnarray[offset] = locnarray[i]; 923 locnarray[offset] = locnarray[i];
924 locnarray[i] = reuselocn; 924 locnarray[i] = reuselocn;
925 ypos += textarray[i]->lineSpacing(); 925 ypos += textarray[i]->lineSpacing();
926 skip++; 926 skip++;
927 } 927 }
928 } 928 }
929 if (fillbuffer(skip, ypos)) 929 if (fillbuffer(skip, ypos))
930 { 930 {
931 update(); 931 update();
932 } 932 }
933} 933}
934 934
935void QTReader::dopageup() 935void QTReader::dopageup()
936{ 936{
937 buffdoc.unsuspend(); 937 buffdoc.unsuspend();
938 dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]); 938 dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]);
939} 939}
940 940
941void QTReader::dopageup(unsigned int target) 941void QTReader::dopageup(unsigned int target)
942{ 942{
943 buffdoc.unsuspend(); 943 buffdoc.unsuspend();
944 CBufferFace<CDrawBuffer*> buff; 944 CBufferFace<CDrawBuffer*> buff;
945 CBufferFace<size_t> loc; 945 CBufferFace<size_t> loc;
946 946
947 size_t delta, guess = 2048; 947 size_t delta, guess = 2048;
948 bool ch = true; 948 bool ch = true;
949 int nbfl, ypos = 0; 949 int nbfl, ypos = 0;
950 950
951 while (1) 951 while (1)
952 { 952 {
953 ch = true; 953 ch = true;
954 nbfl = 0; 954 nbfl = 0;
955 if (target < guess) 955 if (target < guess)
956 { 956 {
957 delta = 0; // 0 is a flag to say don't guess any more 957 delta = 0; // 0 is a flag to say don't guess any more
958 jumpto( (m_continuousDocument) ? 0 : buffdoc.startSection() ); 958 jumpto( (m_continuousDocument) ? 0 : buffdoc.startSection() );
959 } 959 }
960 else if (!m_continuousDocument && (target - guess < buffdoc.startSection())) 960 else if (!m_continuousDocument && (target - guess < buffdoc.startSection()))
961 { 961 {
962 delta = 0; // 0 is a flag to say don't guess any more 962 delta = 0; // 0 is a flag to say don't guess any more
963 jumpto(buffdoc.startSection()); 963 jumpto(buffdoc.startSection());
964 } 964 }
965 else 965 else
966 { 966 {
967 delta = guess; 967 delta = guess;
968 968
969 jumpto(target - delta); 969 jumpto(target - delta);
970 970
971 buff[0] = new CDrawBuffer(&m_fontControl); 971 buff[0] = new CDrawBuffer(&m_fontControl);
972 972
973 do 973 do
974 { 974 {
975 975
976 if (!getline(buff[0])) break; 976 if (!getline(buff[0])) break;
977 977
978 if (locate() > target) break; 978 if (locate() > target) break;
979 } 979 }
980 while (!buffdoc.iseol()); 980 while (!buffdoc.iseol());
981 } 981 }
982 982
983 ypos = 0; 983 ypos = 0;
984 while (locate() < target) 984 while (locate() < target)
985 { 985 {
986 if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); 986 if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl);
987 loc[nbfl] = locate(); 987 loc[nbfl] = locate();
988 ch = getline(buff[nbfl]); 988 ch = getline(buff[nbfl]);
989 ypos += buff[nbfl]->lineSpacing(); 989 ypos += buff[nbfl]->lineSpacing();
990 nbfl++; 990 nbfl++;
991 if (!ch) break; 991 if (!ch) break;
992 } 992 }
993 if (ypos < height() && (delta != 0)) 993 if (ypos < height() && (delta != 0))
994 { 994 {
995 for (int i = 0; i < nbfl; i++) 995 for (int i = 0; i < nbfl; i++)
996 { 996 {
997 delete buff[i]; 997 delete buff[i];
998 buff[i] = NULL; 998 buff[i] = NULL;
999 } 999 }
1000 guess <<= 1; 1000 guess <<= 1;
1001 continue; 1001 continue;
1002 } 1002 }
1003 break; 1003 break;
1004 } 1004 }
1005 if (ch) 1005 if (ch)
1006 { 1006 {
1007 if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); 1007 if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl);
1008 loc[nbfl] = locate(); 1008 loc[nbfl] = locate();
1009 int ch = getline(buff[nbfl]); 1009 int ch = getline(buff[nbfl]);
1010 nbfl++; 1010 nbfl++;
1011 } 1011 }
1012 ypos = 0; 1012 ypos = 0;
1013 numlines = 0; 1013 numlines = 0;
1014 while (ypos < height() && numlines <= nbfl-1) 1014 while (ypos < height() && numlines <= nbfl-1)
1015 { 1015 {
1016 ypos += buff[nbfl - numlines - 1]->lineSpacing(); 1016 ypos += buff[nbfl - numlines - 1]->lineSpacing();
1017 numlines++; 1017 numlines++;
1018 } 1018 }
1019 --numlines; 1019 --numlines;
1020 int offset = nbfl-1; 1020 int offset = nbfl-1;
1021 offset -= numlines; 1021 offset -= numlines;
1022 ypos = 0; 1022 ypos = 0;
1023 for (int i = 0; i <= numlines; i++) 1023 for (int i = 0; i <= numlines; i++)
1024 { 1024 {
1025 delete textarray[i]; 1025 delete textarray[i];
1026 textarray[i] = buff[offset+i]; 1026 textarray[i] = buff[offset+i];
1027 locnarray[i] = loc[offset + i]; 1027 locnarray[i] = loc[offset + i];
1028 ypos += textarray[i]->lineSpacing(); 1028 ypos += textarray[i]->lineSpacing();
1029 } 1029 }
1030 for (int i = 0; i < nbfl - numlines - 1; i++) 1030 for (int i = 0; i < nbfl - numlines - 1; i++)
1031 { 1031 {
1032 delete buff[i]; 1032 delete buff[i];
1033 } 1033 }
1034 1034
1035 while (ypos < height()) 1035 while (ypos < height())
1036 { 1036 {
1037 numlines++; 1037 numlines++;
1038 locnarray[numlines] = locate(); 1038 locnarray[numlines] = locate();
1039 if (textarray[numlines] == NULL) textarray[numlines] = new CDrawBuffer(&m_fontControl); 1039 if (textarray[numlines] == NULL) textarray[numlines] = new CDrawBuffer(&m_fontControl);
1040 if (!getline(textarray[numlines])) break; 1040 if (!getline(textarray[numlines])) break;
1041 ypos += textarray[numlines]->lineSpacing(); 1041 ypos += textarray[numlines]->lineSpacing();
1042 } 1042 }
1043 1043
1044 mylastpos = locate(); 1044 mylastpos = locate();
1045 1045
1046 update(); 1046 update();
1047} 1047}
1048 1048
1049bool QTReader::load_file(const char *newfile, unsigned int _lcn) 1049bool QTReader::load_file(const char *newfile, unsigned int _lcn)
1050{ 1050{
1051// QMessageBox::information(this, "Name", name, 1); 1051// QMessageBox::information(this, "Name", name, 1);
1052// QMessageBox::information(this, "load_file", newfile, 1); 1052// QMessageBox::information(this, "load_file", newfile, 1);
1053 1053
1054 bool bRC = false; 1054 bool bRC = false;
1055 unsigned int lcn = _lcn; 1055 unsigned int lcn = _lcn;
1056 if (m_lastfile == newfile) 1056 if (m_lastfile == newfile)
1057 { 1057 {
1058 lcn = m_lastposn; 1058 lcn = m_lastposn;
1059 } 1059 }
1060 m_lastfile = newfile; 1060 m_lastfile = newfile;
1061 // QMessageBox::information(0, "Opening...", newfile); 1061 // QMessageBox::information(0, "Opening...", newfile);
1062 m_lastwidth = width(); 1062 m_lastwidth = width();
1063 m_lastheight = height(); 1063 m_lastheight = height();
1064 if (buffdoc.openfile(this,newfile) == 0) 1064 if (buffdoc.openfile(this,newfile) == 0)
1065 { 1065 {
1066 bRC = true; 1066 bRC = true;
1067 buffdoc.setContinuous(m_continuousDocument); 1067 buffdoc.setContinuous(m_continuousDocument);
1068 // qDebug("buffdoc.openfile done"); 1068 // qDebug("buffdoc.openfile done");
1069 locate(lcn); 1069 locate(lcn);
1070 // qDebug("buffdoc.locate done"); 1070 // qDebug("buffdoc.locate done");
1071 } 1071 }
1072 setfilter(getfilter()); 1072 setfilter(getfilter());
1073 update(); 1073 update();
1074 // qDebug("Updated"); 1074 // qDebug("Updated");
1075 return bRC; 1075 return bRC;
1076} 1076}
1077 1077
1078void QTReader::lineDown() 1078void QTReader::lineDown()
1079{ 1079{
1080 int ypos = 0; 1080 int ypos = 0;
1081 int offset = numlines; 1081 int offset = numlines;
1082 1082
1083 for (int i = 0; i <= numlines; i++) 1083 for (int i = 0; i <= numlines; i++)
1084 { 1084 {
1085 if ((ypos += textarray[numlines-i]->lineSpacing()) > height()) 1085 if ((ypos += textarray[numlines-i]->lineSpacing()) > height())
1086 { 1086 {
1087 offset = i-1; 1087 offset = i-1;
1088 break; 1088 break;
1089 } 1089 }
1090 } 1090 }
1091 offset = numlines - offset; 1091 offset = numlines - offset;
1092 for (int i = offset; i <= numlines; i++) 1092 for (int i = offset; i <= numlines; i++)
1093 { 1093 {
1094 CDrawBuffer* buff = textarray[i-offset]; 1094 CDrawBuffer* buff = textarray[i-offset];
1095 textarray[i-offset] = textarray[i]; 1095 textarray[i-offset] = textarray[i];
1096 locnarray[i-offset] = locnarray[i]; 1096 locnarray[i-offset] = locnarray[i];
1097 textarray[i] = buff; 1097 textarray[i] = buff;
1098 } 1098 }
1099 numlines = numlines - offset + 1; 1099 numlines = numlines - offset + 1;
1100 locnarray[numlines] = locate(); 1100 locnarray[numlines] = locate();
1101 if (textarray[numlines] == NULL) 1101 if (textarray[numlines] == NULL)
1102 { 1102 {
1103 textarray[numlines] = new CDrawBuffer(&m_fontControl); 1103 textarray[numlines] = new CDrawBuffer(&m_fontControl);
1104 } 1104 }
1105 getline(textarray[numlines]); 1105 getline(textarray[numlines]);
1106 mylastpos = locate(); 1106 mylastpos = locate();
1107 update(); 1107 update();
1108} 1108}
1109/* 1109/*
1110void QTReader::lineUp() 1110void QTReader::lineUp()
1111{ 1111{
1112 CBuffer** buff = textarray; 1112 CBuffer** buff = textarray;
1113 unsigned int *loc = new unsigned int[numlines]; 1113 unsigned int *loc = new unsigned int[numlines];
1114 int cbptr = 0; 1114 int cbptr = 0;
1115 if (locate() != mylastpos) jumpto(mylastpos); 1115 if (locate() != mylastpos) jumpto(mylastpos);
1116 unsigned int target = locnarray[numlines-1]; 1116 unsigned int target = locnarray[numlines-1];
1117 if (buffdoc.hasrandomaccess()) 1117 if (buffdoc.hasrandomaccess())
1118 { 1118 {
1119 unsigned int delta = locate()-pagelocate(); 1119 unsigned int delta = locate()-pagelocate();
1120 if (delta < 64) delta = 64; 1120 if (delta < 64) delta = 64;
1121 do 1121 do
1122 { 1122 {
1123 delta <<= 1; 1123 delta <<= 1;
1124 if (delta >= target) 1124 if (delta >= target)
1125 { 1125 {
1126 delta = target; 1126 delta = target;
1127 jumpto(0); 1127 jumpto(0);
1128 for (int i = 0; i < numlines; i++) 1128 for (int i = 0; i < numlines; i++)
1129 { 1129 {
1130 loc[i] = locate(); 1130 loc[i] = locate();
1131 getline(buff[i]); 1131 getline(buff[i]);
1132 } 1132 }
1133 break; 1133 break;
1134 } 1134 }
1135 jumpto(target-delta); 1135 jumpto(target-delta);
1136 do 1136 do
1137 { 1137 {
1138 buffdoc.getline(buff[0],width()); 1138 buffdoc.getline(buff[0],width());
1139#ifdef WS 1139#ifdef WS
1140 //printf("Trying:%s\n",buff[0]); 1140 //printf("Trying:%s\n",buff[0]);
1141#endif 1141#endif
1142 if (locate() > target) continue; 1142 if (locate() > target) continue;
1143 } 1143 }
1144 while (!buffdoc.iseol()); 1144 while (!buffdoc.iseol());
1145 for (int i = 0; i < numlines; i++) 1145 for (int i = 0; i < numlines; i++)
1146 { 1146 {
1147 loc[i] = locate(); 1147 loc[i] = locate();
1148 buffdoc.getline(buff[i],width()); 1148 buffdoc.getline(buff[i],width());
1149#ifdef WS 1149#ifdef WS
1150 //printf("Filling:%s\n",buff[i]); 1150 //printf("Filling:%s\n",buff[i]);
1151#endif 1151#endif
1152 } 1152 }
1153 } 1153 }
1154 while (locate() >= target && delta < 4096); 1154 while (locate() >= target && delta < 4096);
1155#ifdef WS 1155#ifdef WS
1156 //printf("Delta:%u\n",delta); 1156 //printf("Delta:%u\n",delta);
1157#endif 1157#endif
1158 } 1158 }
1159 else 1159 else
1160 { 1160 {
1161 jumpto(0); 1161 jumpto(0);
1162 for (int i = 0; i < numlines; i++) 1162 for (int i = 0; i < numlines; i++)
1163 { 1163 {
1164 loc[i] = locate(); 1164 loc[i] = locate();
1165 buffdoc.getline(buff[i],width()); 1165 buffdoc.getline(buff[i],width());
1166 } 1166 }
1167 } 1167 }
1168 cbptr = 0; 1168 cbptr = 0;
1169 while (locate() < target) 1169 while (locate() < target)
1170 { 1170 {
1171 loc[cbptr] = locate(); 1171 loc[cbptr] = locate();
1172 buffdoc.getline(buff[cbptr], width()); 1172 buffdoc.getline(buff[cbptr], width());
1173#ifdef WS 1173#ifdef WS
1174 //printf("Adding:%s\n",buff[cbptr]->data()); 1174 //printf("Adding:%s\n",buff[cbptr]->data());
1175#endif 1175#endif
1176 cbptr = (cbptr+1) % numlines; 1176 cbptr = (cbptr+1) % numlines;
1177 } 1177 }
1178 pagepos = loc[cbptr]; 1178 pagepos = loc[cbptr];
1179 textarray = new CBuffer*[numlines]; 1179 textarray = new CBuffer*[numlines];
1180 for (int i = 0; i < numlines; i++) 1180 for (int i = 0; i < numlines; i++)
1181 { 1181 {
1182 int j = (cbptr+i)%numlines; 1182 int j = (cbptr+i)%numlines;
1183 textarray[i] = buff[j]; 1183 textarray[i] = buff[j];
1184 locnarray[i] = loc[j]; 1184 locnarray[i] = loc[j];
1185 } 1185 }
1186 delete [] buff; 1186 delete [] buff;
1187 delete [] loc; 1187 delete [] loc;
1188 mylastpos = locate(); 1188 mylastpos = locate();
1189 update(); 1189 update();
1190} 1190}
1191*/ 1191*/
1192void QTReader::lineUp() 1192void QTReader::lineUp()
1193{ 1193{
1194 buffdoc.unsuspend(); 1194 buffdoc.unsuspend();
1195 CDrawBuffer* buff = textarray[numlines]; 1195 CDrawBuffer* buff = textarray[numlines];
1196 unsigned int loc; 1196 unsigned int loc;
1197 unsigned int end = locnarray[numlines]; 1197 unsigned int end = locnarray[numlines];
1198 int cbptr = 0; 1198 int cbptr = 0;
1199 if (locate() != mylastpos) jumpto(mylastpos); 1199 if (locate() != mylastpos) jumpto(mylastpos);
1200 unsigned int target = locnarray[0]; 1200 unsigned int target = locnarray[0];
1201 if (target == 0) return; 1201 if (target == 0) return;
1202 if (!m_continuousDocument && (target == buffdoc.startSection())) return; 1202 if (!m_continuousDocument && (target == buffdoc.startSection())) return;
1203 if (buffdoc.hasrandomaccess()) 1203 if (buffdoc.hasrandomaccess())
1204 { 1204 {
1205 unsigned int delta = locate()-pagelocate(); 1205 unsigned int delta = locate()-pagelocate();
1206 if (delta < 64) delta = 64; 1206 if (delta < 64) delta = 64;
1207 do 1207 do
1208 { 1208 {
1209 delta <<= 1; 1209 delta <<= 1;
1210 if (delta >= target) 1210 if (delta >= target)
1211 { 1211 {
1212 delta = target; 1212 delta = target;
1213 jumpto(0); 1213 jumpto(0);
1214 loc = locate(); 1214 loc = locate();
1215 getline(buff); 1215 getline(buff);
1216 break; 1216 break;
1217 } 1217 }
1218 else if (!m_continuousDocument && (target - delta < buffdoc.startSection())) 1218 else if (!m_continuousDocument && (target - delta < buffdoc.startSection()))
1219 { 1219 {
1220 delta = target-buffdoc.startSection(); 1220 delta = target-buffdoc.startSection();
1221 jumpto(buffdoc.startSection()); 1221 jumpto(buffdoc.startSection());
1222 loc = locate(); 1222 loc = locate();
1223 getline(buff); 1223 getline(buff);
1224 break; 1224 break;
1225 } 1225 }
1226 jumpto(target-delta); 1226 jumpto(target-delta);
1227 do 1227 do
1228 { 1228 {
1229 getline(buff); 1229 getline(buff);
1230#ifdef WS 1230#ifdef WS
1231 //printf("Trying:%s\n",buff[0]); 1231 //printf("Trying:%s\n",buff[0]);
1232#endif 1232#endif
1233 if (locate() > target) continue; 1233 if (locate() > target) continue;
1234 } 1234 }
1235 while (!buffdoc.iseol()); 1235 while (!buffdoc.iseol());
1236 loc = locate(); 1236 loc = locate();
1237 getline(buff); 1237 getline(buff);
1238 } 1238 }
1239 while (locate() >= target && delta < 4096); 1239 while (locate() >= target && delta < 4096);
1240 } 1240 }
1241 else 1241 else
1242 { 1242 {
1243 jumpto(0); 1243 jumpto(0);
1244 loc = locate(); 1244 loc = locate();
1245 getline(buff); 1245 getline(buff);
1246 } 1246 }
1247 cbptr = 0; 1247 cbptr = 0;
1248 while (locate() < target) 1248 while (locate() < target)
1249 { 1249 {
1250 loc = locate(); 1250 loc = locate();
1251 getline(buff); 1251 getline(buff);
1252 } 1252 }
1253 for (int i = numlines; i > 0; i--) 1253 for (int i = numlines; i > 0; i--)
1254 { 1254 {
1255 textarray[i] = textarray[i-1]; 1255 textarray[i] = textarray[i-1];
1256 locnarray[i] = locnarray[i-1]; 1256 locnarray[i] = locnarray[i-1];
1257 } 1257 }
1258 textarray[0] = buff; 1258 textarray[0] = buff;
1259 locnarray[0] = loc; 1259 locnarray[0] = loc;
1260 int start = numlines; 1260 int start = numlines;
1261 int ypos = 0; 1261 int ypos = 0;
1262 for (int i = 0; i <= numlines; i++) 1262 for (int i = 0; i <= numlines; i++)
1263 { 1263 {
1264 ypos += textarray[i]->lineSpacing(); 1264 ypos += textarray[i]->lineSpacing();
1265 if (ypos > height()) 1265 if (ypos > height())
1266 { 1266 {
1267 start = i; 1267 start = i;
1268 ypos -= textarray[i]->lineSpacing(); 1268 ypos -= textarray[i]->lineSpacing();
1269 break; 1269 break;
1270 } 1270 }
1271 } 1271 }
1272 jumpto(locnarray[start]); 1272 jumpto(locnarray[start]);
1273 fillbuffer(start, ypos); 1273 fillbuffer(start, ypos);
1274 update(); 1274 update();
1275} 1275}
1276 1276
1277bool QTReader::empty() 1277bool QTReader::empty()
1278{ 1278{
1279 return buffdoc.empty(); 1279 return buffdoc.empty();
1280} 1280}
1281 1281
1282MarkupType QTReader::PreferredMarkup() 1282MarkupType QTReader::PreferredMarkup()
1283{ 1283{
1284 MarkupType m = buffdoc.PreferredMarkup(); 1284 MarkupType m = buffdoc.PreferredMarkup();
1285 if (m == cTEXT) 1285 if (m == cTEXT)
1286 { 1286 {
1287 int ext = m_lastfile.findRev('.'); 1287 int ext = m_lastfile.findRev('.');
1288 if (ext >= 0) 1288 if (ext >= 0)
1289 { 1289 {
1290 QString ft = m_lastfile.right(m_lastfile.length()-ext-1).upper(); 1290 QString ft = m_lastfile.right(m_lastfile.length()-ext-1).upper();
1291 if (ft.left(3) == "HTM") 1291 if (ft.left(3) == "HTM")
1292 { 1292 {
1293 m = cHTML; 1293 m = cHTML;
1294 } 1294 }
1295 } 1295 }
1296 } 1296 }
1297 return m; 1297 return m;
1298} 1298}
1299 1299
1300void QTReader::setstate(const statedata& sd) 1300void QTReader::setstate(const statedata& sd)
1301{ 1301{
1302 bstripcr = sd.bstripcr; 1302 bstripcr = sd.bstripcr;
1303 btextfmt = sd.btextfmt; 1303 btextfmt = sd.btextfmt;
1304 bautofmt = sd.bautofmt; 1304 bautofmt = sd.bautofmt;
1305 bstriphtml = sd.bstriphtml; 1305 bstriphtml = sd.bstriphtml;
1306 bpeanut = sd.bpeanut; 1306 bpeanut = sd.bpeanut;
1307 bdehyphen = sd.bdehyphen; 1307 bdehyphen = sd.bdehyphen;
1308 bonespace = sd.bonespace; 1308 bonespace = sd.bonespace;
1309 bunindent = sd.bunindent; 1309 bunindent = sd.bunindent;
1310 brepara = sd.brepara; 1310 brepara = sd.brepara;
1311 bdblspce = sd.bdblspce; 1311 bdblspce = sd.bdblspce;
1312 m_bpagemode = sd.m_bpagemode; 1312 m_bpagemode = sd.m_bpagemode;
1313 m_navkeys = sd.m_navkeys; 1313 m_navkeys = sd.m_navkeys;
1314 m_bMonoSpaced = sd.m_bMonoSpaced; 1314 m_bMonoSpaced = sd.m_bMonoSpaced;
1315 bremap = sd.bremap; 1315 bremap = sd.bremap;
1316 bmakebold = sd.bmakebold; 1316 bmakebold = sd.bmakebold;
1317 m_continuousDocument = sd.Continuous; 1317 m_continuousDocument = sd.Continuous;
1318#ifdef REPALM 1318#ifdef REPALM
1319 brepalm = sd.brepalm; 1319 brepalm = sd.brepalm;
1320#endif 1320#endif
1321 bindenter = sd.bindenter; 1321 bindenter = sd.bindenter;
1322 m_encd = sd.m_charpc; 1322 m_encd = sd.m_charpc;
1323 m_fontname = sd.m_fontname; 1323 m_fontname = sd.m_fontname;
1324 setContinuous(sd.Continuous); 1324 setContinuous(sd.Continuous);
1325 ChangeFont(sd.m_textsize); 1325 ChangeFont(sd.m_textsize);
1326 refresh(); 1326 refresh();
1327} 1327}
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
@@ -124,2483 +124,2483 @@ void QTReaderApp::listBkmkFiles()
124 else 124 else
125 QMessageBox::information(this, PROGNAME, "No bookmark files"); 125 QMessageBox::information(this, PROGNAME, "No bookmark files");
126} 126}
127 127
128QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) 128QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
129 : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false) 129 : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false)
130{ 130{
131// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); 131// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir());
132// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); 132// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml"));
133 133
134 pBkmklist = NULL; 134 pBkmklist = NULL;
135 pOpenlist = NULL; 135 pOpenlist = NULL;
136// doc = 0; 136// doc = 0;
137 137
138 m_fBkmksChanged = false; 138 m_fBkmksChanged = false;
139 139
140 QString lang = getenv( "LANG" ); 140 QString lang = getenv( "LANG" );
141 141
142 m_autogenstr = "^ *[A-Z].*[a-z] *$"; 142 m_autogenstr = "^ *[A-Z].*[a-z] *$";
143 setToolBarsMovable( FALSE ); 143 setToolBarsMovable( FALSE );
144 144
145 setIcon( Resource::loadPixmap( "uqtreader" ) ); 145 setIcon( Resource::loadPixmap( "uqtreader" ) );
146 146
147// QPEToolBar *bar = new QPEToolBar( this ); 147// QPEToolBar *bar = new QPEToolBar( this );
148 QToolBar *bar = new QToolBar( this ); 148 QToolBar *bar = new QToolBar( this );
149 bar->setHorizontalStretchable( TRUE ); 149 bar->setHorizontalStretchable( TRUE );
150 addToolBar(bar, "tool",QMainWindow::Top, true); 150 addToolBar(bar, "tool",QMainWindow::Top, true);
151//tjw menu = bar; 151//tjw menu = bar;
152 152
153 QPEMenuBar *mb = new QPEMenuBar( bar ); 153 QPEMenuBar *mb = new QPEMenuBar( bar );
154// QMenuBar *mb = new QMenuBar( bar ); 154// QMenuBar *mb = new QMenuBar( bar );
155 QPopupMenu *file = new QPopupMenu( this ); 155 QPopupMenu *file = new QPopupMenu( this );
156 QPopupMenu *format = new QPopupMenu( this ); 156 QPopupMenu *format = new QPopupMenu( this );
157 // QPopupMenu *edit = new QPopupMenu( this ); 157 // QPopupMenu *edit = new QPopupMenu( this );
158 158
159// bar = new QToolBar( this ); 159// bar = new QToolBar( this );
160 editBar = bar; 160 editBar = bar;
161 161
162 /* 162 /*
163 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 163 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
164 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 164 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
165 a->addTo( bar ); 165 a->addTo( bar );
166 a->addTo( file ); 166 a->addTo( file );
167 */ 167 */
168 168
169 editorStack = new QWidgetStack( this ); 169 editorStack = new QWidgetStack( this );
170 setCentralWidget( editorStack ); 170 setCentralWidget( editorStack );
171 171
172 searchVisible = FALSE; 172 searchVisible = FALSE;
173 regVisible = FALSE; 173 regVisible = FALSE;
174 m_fontVisible = false; 174 m_fontVisible = false;
175 175
176 pbar = new QProgressBar(this); 176 pbar = new QProgressBar(this);
177 pbar->hide(); 177 pbar->hide();
178 178
179 m_annoWin = new CAnnoEdit(editorStack); 179 m_annoWin = new CAnnoEdit(editorStack);
180 editorStack->addWidget(m_annoWin, get_unique_id()); 180 editorStack->addWidget(m_annoWin, get_unique_id());
181 connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); 181 connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) );
182 connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); 182 connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) );
183 183
184 m_infoWin = new infowin(editorStack); 184 m_infoWin = new infowin(editorStack);
185 editorStack->addWidget(m_infoWin, get_unique_id()); 185 editorStack->addWidget(m_infoWin, get_unique_id());
186 connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); 186 connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) );
187 187
188 m_graphicwin = new GraphicWin(editorStack); 188 m_graphicwin = new GraphicWin(editorStack);
189 editorStack->addWidget(m_graphicwin, get_unique_id()); 189 editorStack->addWidget(m_graphicwin, get_unique_id());
190 connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); 190 connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) );
191 191
192// bkmkselector = new QListBox(editorStack, "Bookmarks"); 192// bkmkselector = new QListBox(editorStack, "Bookmarks");
193 bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); 193 bkmkselector = new CBkmkSelector(editorStack, "Bookmarks");
194 // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); 194 // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) );
195 connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); 195 connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) );
196 connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); 196 connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) );
197 editorStack->addWidget( bkmkselector, get_unique_id() ); 197 editorStack->addWidget( bkmkselector, get_unique_id() );
198 198
199/* 199/*
200 importSelector = new FileSelector( "*", editorStack, "importselector", false ); 200 importSelector = new FileSelector( "*", editorStack, "importselector", false );
201 connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); 201 connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) );
202 202
203 editorStack->addWidget( importSelector, get_unique_id() ); 203 editorStack->addWidget( importSelector, get_unique_id() );
204 204
205 // don't need the close visible, it is redundant... 205 // don't need the close visible, it is redundant...
206 importSelector->setCloseVisible( FALSE ); 206 importSelector->setCloseVisible( FALSE );
207*/ 207*/
208 qDebug("Reading file list"); 208 qDebug("Reading file list");
209 readfilelist(); 209 readfilelist();
210 210
211 reader = new QTReader( editorStack ); 211 reader = new QTReader( editorStack );
212 212
213 reader->bDoUpdates = false; 213 reader->bDoUpdates = false;
214 214
215 ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); 215 ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold);
216 216
217 qDebug("Reading config"); 217 qDebug("Reading config");
218 Config config( APPDIR ); 218 Config config( APPDIR );
219 config.setGroup( "View" ); 219 config.setGroup( "View" );
220 220
221 reader->bstripcr = config.readBoolEntry( "StripCr", true ); 221 reader->bstripcr = config.readBoolEntry( "StripCr", true );
222 reader->btextfmt = config.readBoolEntry( "TextFmt", false ); 222 reader->btextfmt = config.readBoolEntry( "TextFmt", false );
223 reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); 223 reader->bautofmt = config.readBoolEntry( "AutoFmt", true );
224 reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); 224 reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
225 reader->bpeanut = config.readBoolEntry( "Peanut", false ); 225 reader->bpeanut = config.readBoolEntry( "Peanut", false );
226 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); 226 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false );
227 reader->bonespace = config.readBoolEntry( "OneSpace", false ); 227 reader->bonespace = config.readBoolEntry( "OneSpace", false );
228 reader->bunindent = config.readBoolEntry( "Unindent", false ); 228 reader->bunindent = config.readBoolEntry( "Unindent", false );
229 reader->brepara = config.readBoolEntry( "Repara", false ); 229 reader->brepara = config.readBoolEntry( "Repara", false );
230 reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); 230 reader->bdblspce = config.readBoolEntry( "DoubleSpace", false );
231 reader->bindenter = config.readNumEntry( "Indent", 0 ); 231 reader->bindenter = config.readNumEntry( "Indent", 0 );
232 reader->m_textsize = config.readNumEntry( "FontSize", 12 ); 232 reader->m_textsize = config.readNumEntry( "FontSize", 12 );
233 reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); 233 reader->m_delay = config.readNumEntry( "ScrollDelay", 5184);
234 reader->m_lastfile = config.readEntry( "LastFile", QString::null ); 234 reader->m_lastfile = config.readEntry( "LastFile", QString::null );
235 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); 235 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 );
236 reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); 236 reader->m_bpagemode = config.readBoolEntry( "PageMode", true );
237 reader->m_navkeys = config.readBoolEntry( "CursorNavigation", false ); 237 reader->m_navkeys = config.readBoolEntry( "CursorNavigation", false );
238 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); 238 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false);
239 reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); 239 reader->m_fontname = config.readEntry( "Fontname", "helvetica" );
240 reader->m_encd = config.readNumEntry( "Encoding", 0 ); 240 reader->m_encd = config.readNumEntry( "Encoding", 0 );
241 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); 241 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 );
242 reader->m_overlap = config.readNumEntry( "Overlap", 0 ); 242 reader->m_overlap = config.readNumEntry( "Overlap", 0 );
243#ifdef REPALM 243#ifdef REPALM
244 reader->brepalm = config.readBoolEntry( "Repalm", true ); 244 reader->brepalm = config.readBoolEntry( "Repalm", true );
245#endif 245#endif
246 reader->bremap = config.readBoolEntry( "Remap", true ); 246 reader->bremap = config.readBoolEntry( "Remap", true );
247 reader->bmakebold = config.readBoolEntry( "MakeBold", false ); 247 reader->bmakebold = config.readBoolEntry( "MakeBold", false );
248 reader->setContinuous(config.readBoolEntry( "Continuous", true )); 248 reader->setContinuous(config.readBoolEntry( "Continuous", true ));
249 m_targetapp = config.readEntry( "TargetApp", QString::null ); 249 m_targetapp = config.readEntry( "TargetApp", QString::null );
250 m_targetmsg = config.readEntry( "TargetMsg", QString::null ); 250 m_targetmsg = config.readEntry( "TargetMsg", QString::null );
251 m_twoTouch = config.readBoolEntry( "TwoTouch", false); 251 m_twoTouch = config.readBoolEntry( "TwoTouch", false);
252 m_doAnnotation = config.readBoolEntry( "Annotation", false); 252 m_doAnnotation = config.readBoolEntry( "Annotation", false);
253 m_doDictionary = config.readBoolEntry( "Dictionary", false); 253 m_doDictionary = config.readBoolEntry( "Dictionary", false);
254 m_doClipboard = config.readBoolEntry( "Clipboard", false); 254 m_doClipboard = config.readBoolEntry( "Clipboard", false);
255 m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); 255 m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll);
256 setTwoTouch(m_twoTouch); 256 setTwoTouch(m_twoTouch);
257 257
258 258
259 connect( reader, SIGNAL( OnShowPicture(QPixmap&) ), this, SLOT( showgraphic(QPixmap&) ) ); 259 connect( reader, SIGNAL( OnShowPicture(QPixmap&) ), this, SLOT( showgraphic(QPixmap&) ) );
260 260
261 connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); 261 connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) );
262 connect( reader, SIGNAL( OnActionPressed() ), this, SLOT( OnActionPressed() ) ); 262 connect( reader, SIGNAL( OnActionPressed() ), this, SLOT( OnActionPressed() ) );
263 connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) ); 263 connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) );
264 editorStack->addWidget( reader, get_unique_id() ); 264 editorStack->addWidget( reader, get_unique_id() );
265 265
266 QAction *a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 266 QAction *a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
267 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 267 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
268 a->addTo( bar ); 268 a->addTo( bar );
269 a->addTo( file ); 269 a->addTo( file );
270 270
271 a = new QAction( tr( "Close" ), Resource::loadPixmap( "fileclose" ), QString::null, 0, this, 0 ); 271 a = new QAction( tr( "Close" ), Resource::loadPixmap( "fileclose" ), QString::null, 0, this, 0 );
272 connect( a, SIGNAL( activated() ), this, SLOT( fileClose() ) ); 272 connect( a, SIGNAL( activated() ), this, SLOT( fileClose() ) );
273// a->addTo( bar ); 273// a->addTo( bar );
274 a->addTo( file ); 274 a->addTo( file );
275 275
276 /* 276 /*
277 a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 277 a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
278 connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); 278 connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) );
279 a->addTo( file ); 279 a->addTo( file );
280 280
281 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 281 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
282 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 282 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
283 a->addTo( editBar ); 283 a->addTo( editBar );
284 a->addTo( edit ); 284 a->addTo( edit );
285 */ 285 */
286 286
287 a = new QAction( tr( "Info" ), QString::null, 0, this, NULL); 287 a = new QAction( tr( "Info" ), QString::null, 0, this, NULL);
288 connect( a, SIGNAL( activated() ), this, SLOT( showinfo() ) ); 288 connect( a, SIGNAL( activated() ), this, SLOT( showinfo() ) );
289 a->addTo( file ); 289 a->addTo( file );
290 290
291 QActionGroup* ag = new QActionGroup(this); 291 QActionGroup* ag = new QActionGroup(this);
292 QPopupMenu *spacemenu = new QPopupMenu(this); 292 QPopupMenu *spacemenu = new QPopupMenu(this);
293 file->insertItem( tr( "On Action..." ), spacemenu ); 293 file->insertItem( tr( "On Action..." ), spacemenu );
294 294
295 m_buttonAction[0] = new QAction( tr( "Open File" ), QString::null, 0, ag, NULL, true ); 295 m_buttonAction[0] = new QAction( tr( "Open File" ), QString::null, 0, ag, NULL, true );
296 296
297 m_buttonAction[1] = new QAction( tr( "Autoscroll" ), QString::null, 0, ag, NULL, true ); 297 m_buttonAction[1] = new QAction( tr( "Autoscroll" ), QString::null, 0, ag, NULL, true );
298 298
299 m_buttonAction[2] = new QAction( tr( "Mark" ), QString::null, 0, ag, NULL, true ); 299 m_buttonAction[2] = new QAction( tr( "Mark" ), QString::null, 0, ag, NULL, true );
300 300
301 m_buttonAction[3] = new QAction( tr( "Fullscreen" ), QString::null, 0, ag, NULL, true ); 301 m_buttonAction[3] = new QAction( tr( "Fullscreen" ), QString::null, 0, ag, NULL, true );
302 302
303 ag->addTo(spacemenu); 303 ag->addTo(spacemenu);
304 304
305 connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) ); 305 connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) );
306 306
307 file->insertSeparator(); 307 file->insertSeparator();
308 308
309 ag = new QActionGroup(this); 309 ag = new QActionGroup(this);
310 ag->setExclusive(false); 310 ag->setExclusive(false);
311 QPopupMenu *encoding = new QPopupMenu(this); 311 QPopupMenu *encoding = new QPopupMenu(this);
312 file->insertItem( tr( "Navigation" ), encoding ); 312 file->insertItem( tr( "Navigation" ), encoding );
313 313
314 a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( PICDIR "panel-arrow-down" ), QString::null, 0, ag, 0, true ); 314 a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( PICDIR "panel-arrow-down" ), QString::null, 0, ag, 0, true );
315 315
316 a->setOn(false); 316 a->setOn(false);
317 connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); 317 connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) );
318 a->addTo( bar ); 318 a->addTo( bar );
319 319
320 a = new QAction( tr( "Jump" ), QString::null, 0, ag, NULL); 320 a = new QAction( tr( "Jump" ), QString::null, 0, ag, NULL);
321 connect( a, SIGNAL( activated() ), this, SLOT( jump() ) ); 321 connect( a, SIGNAL( activated() ), this, SLOT( jump() ) );
322 322
323 a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, ag, NULL, true ); 323 a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, ag, NULL, true );
324 connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); 324 connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) );
325 a->setOn(reader->m_bpagemode); 325 a->setOn(reader->m_bpagemode);
326 326
327 a = new QAction( tr( "Set Overlap" ), QString::null, 0, ag, NULL); 327 a = new QAction( tr( "Set Overlap" ), QString::null, 0, ag, NULL);
328 connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) ); 328 connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) );
329 329
330 a = new QAction( tr( "Use Cursor" ), QString::null, 0, ag, NULL, true ); 330 a = new QAction( tr( "Use Cursor" ), QString::null, 0, ag, NULL, true );
331 connect( a, SIGNAL( toggled(bool) ), this, SLOT( navkeys(bool) ) ); 331 connect( a, SIGNAL( toggled(bool) ), this, SLOT( navkeys(bool) ) );
332 a->setOn(reader->m_navkeys); 332 a->setOn(reader->m_navkeys);
333 333
334 ag->addTo(encoding); 334 ag->addTo(encoding);
335 335
336 /* 336 /*
337 a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); 337 a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true );
338 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 338 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
339 a->addTo( file ); 339 a->addTo( file );
340 340
341 a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); 341 a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true );
342 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 342 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
343 a->addTo( file ); 343 a->addTo( file );
344 */ 344 */
345 345
346 file->insertSeparator(); 346 file->insertSeparator();
347 347
348 a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL); 348 a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL);
349 connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) ); 349 connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) );
350 a->addTo( file ); 350 a->addTo( file );
351 351
352 a = new QAction( tr( "Two/One Touch" ), QString::null, 0, this, NULL, true ); 352 a = new QAction( tr( "Two/One Touch" ), QString::null, 0, this, NULL, true );
353 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); 353 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) );
354 a->setOn(m_twoTouch); 354 a->setOn(m_twoTouch);
355 a->addTo( file ); 355 a->addTo( file );
356 356
357 ag = new QActionGroup(this); 357 ag = new QActionGroup(this);
358 ag->setExclusive(false); 358 ag->setExclusive(false);
359 encoding = new QPopupMenu(this); 359 encoding = new QPopupMenu(this);
360 file->insertItem( tr( "Target" ), encoding ); 360 file->insertItem( tr( "Target" ), encoding );
361 361
362 a = new QAction( tr( "Annotation" ), QString::null, 0, ag, NULL, true ); 362 a = new QAction( tr( "Annotation" ), QString::null, 0, ag, NULL, true );
363 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnAnnotation(bool) ) ); 363 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnAnnotation(bool) ) );
364 a->setOn(m_doAnnotation); 364 a->setOn(m_doAnnotation);
365 365
366 a = new QAction( tr( "Dictionary" ), QString::null, 0, ag, NULL, true ); 366 a = new QAction( tr( "Dictionary" ), QString::null, 0, ag, NULL, true );
367 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnDictionary(bool) ) ); 367 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnDictionary(bool) ) );
368 a->setOn(m_doDictionary); 368 a->setOn(m_doDictionary);
369 369
370 a = new QAction( tr( "Clipboard" ), QString::null, 0, ag, NULL, true ); 370 a = new QAction( tr( "Clipboard" ), QString::null, 0, ag, NULL, true );
371 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnClipboard(bool) ) ); 371 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnClipboard(bool) ) );
372 a->setOn(m_doClipboard); 372 a->setOn(m_doClipboard);
373 373
374 ag->addTo(encoding); 374 ag->addTo(encoding);
375 375
376 376
377/* 377/*
378 a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); 378 a = new QAction( tr( "Import" ), QString::null, 0, this, NULL );
379 connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); 379 connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) );
380 a->addTo( file ); 380 a->addTo( file );
381*/ 381*/
382 382
383 a = new QAction( tr( "Up" ), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); 383 a = new QAction( tr( "Up" ), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 );
384 connect( a, SIGNAL( activated() ), this, SLOT( pageup() ) ); 384 connect( a, SIGNAL( activated() ), this, SLOT( pageup() ) );
385 a->addTo( editBar ); 385 a->addTo( editBar );
386 386
387 a = new QAction( tr( "Down" ), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); 387 a = new QAction( tr( "Down" ), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 );
388 connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 388 connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
389 a->addTo( editBar ); 389 a->addTo( editBar );
390 390
391 /* 391 /*
392 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 392 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
393 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 393 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
394 a->addTo( editBar ); 394 a->addTo( editBar );
395 a->addTo( edit ); 395 a->addTo( edit );
396 */ 396 */
397 397
398// a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 398// a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
399 a = new QAction( tr( "Find..." ), QString::null, 0, this, NULL); 399 a = new QAction( tr( "Find..." ), QString::null, 0, this, NULL);
400 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 400 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
401 file->insertSeparator(); 401 file->insertSeparator();
402// a->addTo( bar ); 402// a->addTo( bar );
403 a->addTo( file ); 403 a->addTo( file );
404 404
405 405
406 m_fullscreen = false; 406 m_fullscreen = false;
407 a = m_actFullscreen = new QAction( tr( "Fullscreen" ), QString::null, 0, this, NULL, true ); 407 a = m_actFullscreen = new QAction( tr( "Fullscreen" ), QString::null, 0, this, NULL, true );
408 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); 408 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) );
409 a->setOn(m_fullscreen); 409 a->setOn(m_fullscreen);
410 a->addTo( file ); 410 a->addTo( file );
411 411
412 a = new QAction( tr( "Continuous" ), QString::null, 0, ag, NULL, true ); 412 a = new QAction( tr( "Continuous" ), QString::null, 0, ag, NULL, true );
413 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setcontinuous(bool) ) ); 413 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setcontinuous(bool) ) );
414 a->setOn(reader->m_continuousDocument); 414 a->setOn(reader->m_continuousDocument);
415 a->addTo( file ); 415 a->addTo( file );
416 416
417 a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 417 a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
418 connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); 418 connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) );
419 a->addTo( bar ); 419 a->addTo( bar );
420 420
421 m_bkmkAvail->setEnabled(false); 421 m_bkmkAvail->setEnabled(false);
422 422
423 423
424 ag = new QActionGroup(this); 424 ag = new QActionGroup(this);
425// ag->setExclusive(false); 425// ag->setExclusive(false);
426 encoding = new QPopupMenu(this); 426 encoding = new QPopupMenu(this);
427 format->insertItem( tr( "Markup" ), encoding ); 427 format->insertItem( tr( "Markup" ), encoding );
428 428
429 a = new QAction( tr( "Auto" ), QString::null, 0, ag, NULL, true ); 429 a = new QAction( tr( "Auto" ), QString::null, 0, ag, NULL, true );
430 a->setOn(reader->bautofmt); 430 a->setOn(reader->bautofmt);
431 connect( a, SIGNAL( toggled(bool) ), this, SLOT( autofmt(bool) ) ); 431 connect( a, SIGNAL( toggled(bool) ), this, SLOT( autofmt(bool) ) );
432 432
433 a = new QAction( tr( "None" ), QString::null, 0, ag, NULL, true ); 433 a = new QAction( tr( "None" ), QString::null, 0, ag, NULL, true );
434 a->setOn(!reader->bautofmt && !(reader->btextfmt || reader->bstriphtml || reader->bpeanut)); 434 a->setOn(!reader->bautofmt && !(reader->btextfmt || reader->bstriphtml || reader->bpeanut));
435// connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) ); 435// connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) );
436 436
437 a = new QAction( tr( "Text" ), QString::null, 0, ag, NULL, true ); 437 a = new QAction( tr( "Text" ), QString::null, 0, ag, NULL, true );
438 a->setOn(reader->btextfmt); 438 a->setOn(reader->btextfmt);
439 connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) ); 439 connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) );
440 440
441 a = new QAction( tr( "HTML" ), QString::null, 0, ag, NULL, true ); 441 a = new QAction( tr( "HTML" ), QString::null, 0, ag, NULL, true );
442 a->setOn(reader->bstriphtml); 442 a->setOn(reader->bstriphtml);
443 connect( a, SIGNAL( toggled(bool) ), this, SLOT( striphtml(bool) ) ); 443 connect( a, SIGNAL( toggled(bool) ), this, SLOT( striphtml(bool) ) );
444 444
445 a = new QAction( tr( "Peanut/PML" ), QString::null, 0, ag, NULL, true ); 445 a = new QAction( tr( "Peanut/PML" ), QString::null, 0, ag, NULL, true );
446 a->setOn(reader->bpeanut); 446 a->setOn(reader->bpeanut);
447 connect( a, SIGNAL( toggled(bool) ), this, SLOT( peanut(bool) ) ); 447 connect( a, SIGNAL( toggled(bool) ), this, SLOT( peanut(bool) ) );
448 448
449 ag->addTo(encoding); 449 ag->addTo(encoding);
450 450
451 451
452 452
453 ag = new QActionGroup(this); 453 ag = new QActionGroup(this);
454 ag->setExclusive(false); 454 ag->setExclusive(false);
455 encoding = new QPopupMenu(this); 455 encoding = new QPopupMenu(this);
456 format->insertItem( tr( "Layout" ), encoding ); 456 format->insertItem( tr( "Layout" ), encoding );
457 457
458 a = new QAction( tr( "Strip CR" ), QString::null, 0, ag, NULL, true ); 458 a = new QAction( tr( "Strip CR" ), QString::null, 0, ag, NULL, true );
459 a->setOn(reader->bstripcr); 459 a->setOn(reader->bstripcr);
460 connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) ); 460 connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) );
461 461
462 a = new QAction( tr( "Dehyphen" ), QString::null, 0, ag, NULL, true ); 462 a = new QAction( tr( "Dehyphen" ), QString::null, 0, ag, NULL, true );
463 a->setOn(reader->bdehyphen); 463 a->setOn(reader->bdehyphen);
464 connect( a, SIGNAL( toggled(bool) ), this, SLOT( dehyphen(bool) ) ); 464 connect( a, SIGNAL( toggled(bool) ), this, SLOT( dehyphen(bool) ) );
465// a->addTo( format ); 465// a->addTo( format );
466 466
467 a = new QAction( tr( "Single Space" ), QString::null, 0, ag, NULL, true ); 467 a = new QAction( tr( "Single Space" ), QString::null, 0, ag, NULL, true );
468 a->setOn(reader->bonespace); 468 a->setOn(reader->bonespace);
469 connect( a, SIGNAL( toggled(bool) ), this, SLOT( onespace(bool) ) ); 469 connect( a, SIGNAL( toggled(bool) ), this, SLOT( onespace(bool) ) );
470 470
471 a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true ); 471 a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true );
472 connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) ); 472 connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) );
473 a->setOn(reader->bunindent); 473 a->setOn(reader->bunindent);
474// a->addTo( format ); 474// a->addTo( format );
475 475
476 a = new QAction( tr( "Re-paragraph" ), QString::null, 0, ag, NULL, true ); 476 a = new QAction( tr( "Re-paragraph" ), QString::null, 0, ag, NULL, true );
477 connect( a, SIGNAL( toggled(bool) ), this, SLOT( repara(bool) ) ); 477 connect( a, SIGNAL( toggled(bool) ), this, SLOT( repara(bool) ) );
478 a->setOn(reader->brepara); 478 a->setOn(reader->brepara);
479// a->addTo( format ); 479// a->addTo( format );
480 480
481 a = new QAction( tr( "Double Space" ), QString::null, 0, ag, NULL, true ); 481 a = new QAction( tr( "Double Space" ), QString::null, 0, ag, NULL, true );
482 connect( a, SIGNAL( toggled(bool) ), this, SLOT( dblspce(bool) ) ); 482 connect( a, SIGNAL( toggled(bool) ), this, SLOT( dblspce(bool) ) );
483 a->setOn(reader->bdblspce); 483 a->setOn(reader->bdblspce);
484// a->addTo( format ); 484// a->addTo( format );
485 485
486 a = new QAction( tr( "Indent+" ), QString::null, 0, ag, NULL ); 486 a = new QAction( tr( "Indent+" ), QString::null, 0, ag, NULL );
487 connect( a, SIGNAL( activated() ), this, SLOT( indentplus() ) ); 487 connect( a, SIGNAL( activated() ), this, SLOT( indentplus() ) );
488// a->addTo( format ); 488// a->addTo( format );
489 489
490 a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL ); 490 a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL );
491 connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) ); 491 connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) );
492#ifdef REPALM 492#ifdef REPALM
493 a = new QAction( tr( "Repalm" ), QString::null, 0, ag, NULL, true ); 493 a = new QAction( tr( "Repalm" ), QString::null, 0, ag, NULL, true );
494 a->setOn(reader->brepalm); 494 a->setOn(reader->brepalm);
495 connect( a, SIGNAL( toggled(bool) ), this, SLOT( repalm(bool) ) ); 495 connect( a, SIGNAL( toggled(bool) ), this, SLOT( repalm(bool) ) );
496#endif 496#endif
497 a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true ); 497 a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true );
498 connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) ); 498 connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) );
499 a->setOn(reader->bremap); 499 a->setOn(reader->bremap);
500 500
501 a = new QAction( tr( "Embolden" ), QString::null, 0, ag, NULL, true ); 501 a = new QAction( tr( "Embolden" ), QString::null, 0, ag, NULL, true );
502 connect( a, SIGNAL( toggled(bool) ), this, SLOT( embolden(bool) ) ); 502 connect( a, SIGNAL( toggled(bool) ), this, SLOT( embolden(bool) ) );
503 a->setOn(reader->bmakebold); 503 a->setOn(reader->bmakebold);
504 504
505 ag->addTo(encoding); 505 ag->addTo(encoding);
506 506
507 // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); 507 // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true );
508 // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); 508 // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
509 format->insertSeparator(); 509 format->insertSeparator();
510 a = new QAction( tr( "Zoom In" ), QString::null, 0, this); 510 a = new QAction( tr( "Zoom In" ), QString::null, 0, this);
511 connect( a, SIGNAL( activated() ), this, SLOT( zoomin() ) ); 511 connect( a, SIGNAL( activated() ), this, SLOT( zoomin() ) );
512 a->addTo( format ); 512 a->addTo( format );
513 a = new QAction( tr( "Zoom Out" ), QString::null, 0, this); 513 a = new QAction( tr( "Zoom Out" ), QString::null, 0, this);
514 connect( a, SIGNAL( activated() ), this, SLOT( zoomout() ) ); 514 connect( a, SIGNAL( activated() ), this, SLOT( zoomout() ) );
515 a->addTo( format ); 515 a->addTo( format );
516 // a->addTo( editBar ); 516 // a->addTo( editBar );
517 format->insertSeparator(); 517 format->insertSeparator();
518 518
519 519
520 a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); 520 a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true );
521 connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); 521 connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
522 a->setOn(reader->m_bMonoSpaced); 522 a->setOn(reader->m_bMonoSpaced);
523 a->addTo( format ); 523 a->addTo( format );
524 524
525 a = new QAction( tr( "Set width" ), QString::null, 0, this, NULL); 525 a = new QAction( tr( "Set width" ), QString::null, 0, this, NULL);
526 connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); 526 connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) );
527 a->addTo( format ); 527 a->addTo( format );
528 528
529 encoding = new QPopupMenu(this); 529 encoding = new QPopupMenu(this);
530// format->insertSeparator(); 530// format->insertSeparator();
531 format->insertItem( tr( "Encoding" ), encoding ); 531 format->insertItem( tr( "Encoding" ), encoding );
532 532
533 ag = new QActionGroup(this); 533 ag = new QActionGroup(this);
534 534
535 m_EncodingAction[0] = new QAction( tr( "Ascii" ), QString::null, 0, ag, NULL, true ); 535 m_EncodingAction[0] = new QAction( tr( "Ascii" ), QString::null, 0, ag, NULL, true );
536 536
537 m_EncodingAction[1] = new QAction( tr( "UTF-8" ), QString::null, 0, ag, NULL, true ); 537 m_EncodingAction[1] = new QAction( tr( "UTF-8" ), QString::null, 0, ag, NULL, true );
538 538
539 m_EncodingAction[2] = new QAction( tr( "UCS-2(BE)" ), QString::null, 0, ag, NULL, true ); 539 m_EncodingAction[2] = new QAction( tr( "UCS-2(BE)" ), QString::null, 0, ag, NULL, true );
540 540
541 m_EncodingAction[3] = new QAction( tr( "USC-2(LE)" ), QString::null, 0, ag, NULL, true ); 541 m_EncodingAction[3] = new QAction( tr( "USC-2(LE)" ), QString::null, 0, ag, NULL, true );
542 542
543 m_EncodingAction[4] = new QAction( tr( "Palm" ), QString::null, 0, ag, NULL, true ); 543 m_EncodingAction[4] = new QAction( tr( "Palm" ), QString::null, 0, ag, NULL, true );
544 544
545 m_EncodingAction[5] = new QAction( tr( "Windows(1252)" ), QString::null, 0, ag, NULL, true ); 545 m_EncodingAction[5] = new QAction( tr( "Windows(1252)" ), QString::null, 0, ag, NULL, true );
546 546
547 ag->addTo(encoding); 547 ag->addTo(encoding);
548 548
549 connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( encodingSelected(QAction*) ) ); 549 connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( encodingSelected(QAction*) ) );
550 550
551 a = new QAction( tr( "Set Font" ), QString::null, 0, this); 551 a = new QAction( tr( "Set Font" ), QString::null, 0, this);
552 connect( a, SIGNAL( activated() ), this, SLOT( setfont() ) ); 552 connect( a, SIGNAL( activated() ), this, SLOT( setfont() ) );
553 format->insertSeparator(); 553 format->insertSeparator();
554 a->addTo( format ); 554 a->addTo( format );
555 555
556 QPopupMenu *marks = new QPopupMenu( this ); 556 QPopupMenu *marks = new QPopupMenu( this );
557 557
558 a = new QAction( tr( "Mark" ), QString::null, 0, this, NULL); 558 a = new QAction( tr( "Mark" ), QString::null, 0, this, NULL);
559 connect( a, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); 559 connect( a, SIGNAL( activated() ), this, SLOT( addbkmk() ) );
560 a->addTo( marks ); 560 a->addTo( marks );
561 561
562 a = new QAction( tr( "Annotate" ), QString::null, 0, this, NULL); 562 a = new QAction( tr( "Annotate" ), QString::null, 0, this, NULL);
563 connect( a, SIGNAL( activated() ), this, SLOT( addanno() ) ); 563 connect( a, SIGNAL( activated() ), this, SLOT( addanno() ) );
564 a->addTo( marks ); 564 a->addTo( marks );
565 565
566 a = new QAction( tr( "Goto" ), QString::null, 0, this, NULL, false ); 566 a = new QAction( tr( "Goto" ), QString::null, 0, this, NULL, false );
567 connect( a, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); 567 connect( a, SIGNAL( activated() ), this, SLOT( do_gotomark() ) );
568 a->addTo( marks ); 568 a->addTo( marks );
569 569
570 a = new QAction( tr( "Delete" ), QString::null, 0, this, NULL); 570 a = new QAction( tr( "Delete" ), QString::null, 0, this, NULL);
571 connect( a, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); 571 connect( a, SIGNAL( activated() ), this, SLOT( do_delmark() ) );
572 a->addTo( marks ); 572 a->addTo( marks );
573 573
574 a = new QAction( tr( "Autogen" ), QString::null, 0, this, NULL, false ); 574 a = new QAction( tr( "Autogen" ), QString::null, 0, this, NULL, false );
575 connect( a, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); 575 connect( a, SIGNAL( activated() ), this, SLOT( do_autogen() ) );
576 marks->insertSeparator(); 576 marks->insertSeparator();
577 a->addTo( marks ); 577 a->addTo( marks );
578 578
579 a = new QAction( tr( "Clear" ), QString::null, 0, this, NULL); 579 a = new QAction( tr( "Clear" ), QString::null, 0, this, NULL);
580 connect( a, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); 580 connect( a, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) );
581 a->addTo( marks ); 581 a->addTo( marks );
582 582
583 a = new QAction( tr( "Save" ), QString::null, 0, this, NULL ); 583 a = new QAction( tr( "Save" ), QString::null, 0, this, NULL );
584 connect( a, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); 584 connect( a, SIGNAL( activated() ), this, SLOT( savebkmks() ) );
585 a->addTo( marks ); 585 a->addTo( marks );
586 586
587 a = new QAction( tr( "Tidy" ), QString::null, 0, this, NULL); 587 a = new QAction( tr( "Tidy" ), QString::null, 0, this, NULL);
588 connect( a, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); 588 connect( a, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) );
589 marks->insertSeparator(); 589 marks->insertSeparator();
590 a->addTo( marks ); 590 a->addTo( marks );
591 591
592 a = new QAction( tr( "Start Block" ), QString::null, 0, this, NULL); 592 a = new QAction( tr( "Start Block" ), QString::null, 0, this, NULL);
593 connect( a, SIGNAL( activated() ), this, SLOT( editMark() ) ); 593 connect( a, SIGNAL( activated() ), this, SLOT( editMark() ) );
594 marks->insertSeparator(); 594 marks->insertSeparator();
595 a->addTo( marks ); 595 a->addTo( marks );
596 596
597 a = new QAction( tr( "Copy Block" ), QString::null, 0, this, NULL); 597 a = new QAction( tr( "Copy Block" ), QString::null, 0, this, NULL);
598 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 598 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
599 a->addTo( marks ); 599 a->addTo( marks );
600 600
601 601
602 mb->insertItem( tr( "File" ), file ); 602 mb->insertItem( tr( "File" ), file );
603 // mb->insertItem( tr( "Edit" ), edit ); 603 // mb->insertItem( tr( "Edit" ), edit );
604 mb->insertItem( tr( "Format" ), format ); 604 mb->insertItem( tr( "Format" ), format );
605 mb->insertItem( tr( "Marks" ), marks ); 605 mb->insertItem( tr( "Marks" ), marks );
606 606
607 searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); 607 searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE );
608 608
609 searchBar->setHorizontalStretchable( TRUE ); 609 searchBar->setHorizontalStretchable( TRUE );
610 610
611 connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); 611 connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() ));
612 612
613 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 613 searchEdit = new QLineEdit( searchBar, "searchEdit" );
614// QFont f("unifont", 16 /*, QFont::Bold*/); 614// QFont f("unifont", 16 /*, QFont::Bold*/);
615// searchEdit->setFont( f ); 615// searchEdit->setFont( f );
616 searchBar->setStretchableWidget( searchEdit ); 616 searchBar->setStretchableWidget( searchEdit );
617 617
618#ifdef __ISEARCH 618#ifdef __ISEARCH
619 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 619 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
620 this, SLOT( search( const QString& ) ) ); 620 this, SLOT( search( const QString& ) ) );
621#else 621#else
622 connect( searchEdit, SIGNAL( returnPressed( ) ), 622 connect( searchEdit, SIGNAL( returnPressed( ) ),
623 this, SLOT( search( ) ) ); 623 this, SLOT( search( ) ) );
624#endif 624#endif
625 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 625 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
626 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 626 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
627 a->addTo( searchBar ); 627 a->addTo( searchBar );
628 628
629 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 629 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
630 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 630 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
631 a->addTo( searchBar ); 631 a->addTo( searchBar );
632 632
633 searchBar->hide(); 633 searchBar->hide();
634 634
635 regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); 635 regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE );
636 connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); 636 connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() ));
637 637
638 regBar->setHorizontalStretchable( TRUE ); 638 regBar->setHorizontalStretchable( TRUE );
639 639
640 regEdit = new QLineEdit( regBar, "regEdit" ); 640 regEdit = new QLineEdit( regBar, "regEdit" );
641// regEdit->setFont( f ); 641// regEdit->setFont( f );
642 642
643 regBar->setStretchableWidget( regEdit ); 643 regBar->setStretchableWidget( regEdit );
644 644
645 connect( regEdit, SIGNAL( returnPressed( ) ), 645 connect( regEdit, SIGNAL( returnPressed( ) ),
646 this, SLOT( do_regaction() ) ); 646 this, SLOT( do_regaction() ) );
647 647
648 a = new QAction( tr( "Do Reg" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); 648 a = new QAction( tr( "Do Reg" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
649 connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); 649 connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) );
650 a->addTo( regBar ); 650 a->addTo( regBar );
651 651
652 a = new QAction( tr( "Close Edit" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 652 a = new QAction( tr( "Close Edit" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
653 connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); 653 connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) );
654 a->addTo( regBar ); 654 a->addTo( regBar );
655 655
656 regBar->hide(); 656 regBar->hide();
657 657
658 m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); 658 m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE );
659 659
660 m_fontBar->setHorizontalStretchable( TRUE ); 660 m_fontBar->setHorizontalStretchable( TRUE );
661 661
662 qDebug("Font selector"); 662 qDebug("Font selector");
663 m_fontSelector = new QComboBox(false, m_fontBar); 663 m_fontSelector = new QComboBox(false, m_fontBar);
664 m_fontBar->setStretchableWidget( m_fontSelector ); 664 m_fontBar->setStretchableWidget( m_fontSelector );
665 { 665 {
666 FontDatabase f; 666 FontDatabase f;
667 QStringList flist = f.families(); 667 QStringList flist = f.families();
668 m_fontSelector->insertStringList(flist); 668 m_fontSelector->insertStringList(flist);
669 669
670 bool realfont = false; 670 bool realfont = false;
671 for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) 671 for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++)
672 { 672 {
673 if (reader->m_fontname == *nm) 673 if (reader->m_fontname == *nm)
674 { 674 {
675 realfont = true; 675 realfont = true;
676 } 676 }
677 if (*nm == "courier") reader->m_fontControl.hasCourier(true); 677 if (*nm == "courier") reader->m_fontControl.hasCourier(true);
678 } 678 }
679 if (!realfont) reader->m_fontname = flist[0]; 679 if (!realfont) reader->m_fontname = flist[0];
680 } // delete the FontDatabase!!! 680 } // delete the FontDatabase!!!
681 681
682 connect( m_fontSelector, SIGNAL( activated(const QString& ) ), 682 connect( m_fontSelector, SIGNAL( activated(const QString& ) ),
683 this, SLOT( do_setfont(const QString&) ) ); 683 this, SLOT( do_setfont(const QString&) ) );
684 684
685 m_fontBar->hide(); 685 m_fontBar->hide();
686 m_fontVisible = false; 686 m_fontVisible = false;
687 687
688 connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), 688 connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ),
689 this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); 689 this, SLOT( msgHandler(const QCString&, const QByteArray&) ) );
690 690
691 qDebug("Initing"); 691 qDebug("Initing");
692 reader->init(); 692 reader->init();
693 qDebug("Inited"); 693 qDebug("Inited");
694 m_EncodingAction[reader->m_encd]->setOn(true); 694 m_EncodingAction[reader->m_encd]->setOn(true);
695 m_buttonAction[m_spaceTarget]->setOn(true); 695 m_buttonAction[m_spaceTarget]->setOn(true);
696 qDebug("fonting"); 696 qDebug("fonting");
697 do_setfont(reader->m_fontname); 697 do_setfont(reader->m_fontname);
698 if (!reader->m_lastfile.isEmpty()) 698 if (!reader->m_lastfile.isEmpty())
699 { 699 {
700 qDebug("doclnk"); 700 qDebug("doclnk");
701 //doc = new DocLnk(reader->m_lastfile); 701 //doc = new DocLnk(reader->m_lastfile);
702 qDebug("doclnk done"); 702 qDebug("doclnk done");
703 if (pOpenlist != NULL) 703 if (pOpenlist != NULL)
704 { 704 {
705 705
706/* 706/*
707 int ind = 0; 707 int ind = 0;
708 Bkmk* p = (*pOpenlist)[ind]; 708 Bkmk* p = (*pOpenlist)[ind];
709 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) 709 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
710 { 710 {
711 p = (*pOpenlist)[++ind]; 711 p = (*pOpenlist)[++ind];
712 } 712 }
713*/ 713*/
714 Bkmk* p = NULL; 714 Bkmk* p = NULL;
715 for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) 715 for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++)
716 { 716 {
717 p = iter.pContent(); 717 p = iter.pContent();
718 if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) 718 if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile)
719 { 719 {
720 break; 720 break;
721 } 721 }
722 qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); 722 qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name()));
723 p = NULL; 723 p = NULL;
724 } 724 }
725 if (p != NULL) 725 if (p != NULL)
726 { 726 {
727 qDebug("openfrombkmk"); 727 qDebug("openfrombkmk");
728 openfrombkmk(p); 728 openfrombkmk(p);
729 } 729 }
730 else 730 else
731 { 731 {
732 qDebug("openfile"); 732 qDebug("openfile");
733 openFile( reader->m_lastfile ); 733 openFile( reader->m_lastfile );
734 } 734 }
735 } 735 }
736 else 736 else
737 { 737 {
738 qDebug("Openfile 2"); 738 qDebug("Openfile 2");
739 if (!reader->m_lastfile.isNull()) 739 if (!reader->m_lastfile.isNull())
740 openFile( reader->m_lastfile ); 740 openFile( reader->m_lastfile );
741 } 741 }
742 } 742 }
743 qApp->processEvents(); 743 qApp->processEvents();
744 reader->bDoUpdates = true; 744 reader->bDoUpdates = true;
745 reader->update(); 745 reader->update();
746 qDebug("finished update"); 746 qDebug("finished update");
747} 747}
748 748
749void QTReaderApp::suspend() { reader->suspend(); } 749void QTReaderApp::suspend() { reader->suspend(); }
750 750
751void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) 751void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
752{ 752{
753 QString msg = QString::fromUtf8(_msg); 753 QString msg = QString::fromUtf8(_msg);
754 754
755// qDebug("Received:%s", (const char*)msg); 755// qDebug("Received:%s", (const char*)msg);
756 756
757 QDataStream stream( _data, IO_ReadOnly ); 757 QDataStream stream( _data, IO_ReadOnly );
758 if ( msg == "info(QString)" ) 758 if ( msg == "info(QString)" )
759 { 759 {
760 QString info; 760 QString info;
761 stream >> info; 761 stream >> info;
762 QMessageBox::information(this, PROGNAME, info); 762 QMessageBox::information(this, PROGNAME, info);
763 } 763 }
764 else if ( msg == "warn(QString)" ) 764 else if ( msg == "warn(QString)" )
765 { 765 {
766 QString info; 766 QString info;
767 stream >> info; 767 stream >> info;
768 QMessageBox::warning(this, PROGNAME, info); 768 QMessageBox::warning(this, PROGNAME, info);
769 } 769 }
770 770
771 771
772 else if ( msg == "exit()" ) 772 else if ( msg == "exit()" )
773 { 773 {
774 m_dontSave = true; 774 m_dontSave = true;
775 close(); 775 close();
776 } 776 }
777 else if ( msg == "pageDown()" ) 777 else if ( msg == "pageDown()" )
778 { 778 {
779 reader->dopagedn(); 779 reader->dopagedn();
780 } 780 }
781 else if ( msg == "pageUp()" ) 781 else if ( msg == "pageUp()" )
782 { 782 {
783 reader->dopageup(); 783 reader->dopageup();
784 } 784 }
785 else if ( msg == "lineDown()" ) 785 else if ( msg == "lineDown()" )
786 { 786 {
787 reader->lineDown(); 787 reader->lineDown();
788 } 788 }
789 else if ( msg == "lineUp()" ) 789 else if ( msg == "lineUp()" )
790 { 790 {
791 reader->lineUp(); 791 reader->lineUp();
792 } 792 }
793 else if ( msg == "showText()" ) 793 else if ( msg == "showText()" )
794 { 794 {
795 showEditTools(); 795 showEditTools();
796 } 796 }
797 else if ( msg == "File/Open(QString)" ) 797 else if ( msg == "File/Open(QString)" )
798 { 798 {
799 QString info; 799 QString info;
800 stream >> info; 800 stream >> info;
801 openFile( info ); 801 openFile( info );
802 } 802 }
803 else if ( msg == "File/Info()" ) 803 else if ( msg == "File/Info()" )
804 { 804 {
805 showinfo(); 805 showinfo();
806 } 806 }
807 else if ( msg == "File/Start Block()" ) 807 else if ( msg == "File/Start Block()" )
808 { 808 {
809 editMark(); 809 editMark();
810 } 810 }
811 else if ( msg == "File/Copy Block()" ) 811 else if ( msg == "File/Copy Block()" )
812 { 812 {
813 editCopy(); 813 editCopy();
814 } 814 }
815 else if ( msg == "File/Scroll(int)" ) 815 else if ( msg == "File/Scroll(int)" )
816 { 816 {
817 int info; 817 int info;
818 stream >> info; 818 stream >> info;
819 autoScroll(info); 819 autoScroll(info);
820 } 820 }
821 else if ( msg == "File/Jump(int)" ) 821 else if ( msg == "File/Jump(int)" )
822 { 822 {
823 int info; 823 int info;
824 stream >> info; 824 stream >> info;
825 reader->locate(info); 825 reader->locate(info);
826 } 826 }
827 else if ( msg == "File/Page/Line Scroll(int)" ) 827 else if ( msg == "File/Page/Line Scroll(int)" )
828 { 828 {
829 int info; 829 int info;
830 stream >> info; 830 stream >> info;
831 pagemode(info); 831 pagemode(info);
832 } 832 }
833 else if ( msg == "File/Set Overlap(int)" ) 833 else if ( msg == "File/Set Overlap(int)" )
834 { 834 {
835 int info; 835 int info;
836 stream >> info; 836 stream >> info;
837 reader->m_overlap = info; 837 reader->m_overlap = info;
838 } 838 }
839 else if ( msg == "File/Set Dictionary(QString)" ) 839 else if ( msg == "File/Set Dictionary(QString)" )
840 { 840 {
841 QString info; 841 QString info;
842 stream >> info; 842 stream >> info;
843 do_settarget(info); 843 do_settarget(info);
844 } 844 }
845 else if ( msg == "File/Two/One Touch(int)" ) 845 else if ( msg == "File/Two/One Touch(int)" )
846 { 846 {
847 int info; 847 int info;
848 stream >> info; 848 stream >> info;
849 setTwoTouch(info); 849 setTwoTouch(info);
850 } 850 }
851 else if ( msg == "Target/Annotation(int)" ) 851 else if ( msg == "Target/Annotation(int)" )
852 { 852 {
853 int info; 853 int info;
854 stream >> info; 854 stream >> info;
855 OnAnnotation(info); 855 OnAnnotation(info);
856 } 856 }
857 else if ( msg == "Target/Dictionary(int)" ) 857 else if ( msg == "Target/Dictionary(int)" )
858 { 858 {
859 int info; 859 int info;
860 stream >> info; 860 stream >> info;
861 OnDictionary(info); 861 OnDictionary(info);
862 } 862 }
863 else if ( msg == "Target/Clipboard(int)" ) 863 else if ( msg == "Target/Clipboard(int)" )
864 { 864 {
865 int info; 865 int info;
866 stream >> info; 866 stream >> info;
867 OnClipboard(info); 867 OnClipboard(info);
868 } 868 }
869 else if ( msg == "File/Find(QString)" ) 869 else if ( msg == "File/Find(QString)" )
870 { 870 {
871 QString info; 871 QString info;
872 stream >> info; 872 stream >> info;
873 QRegExp arg(info); 873 QRegExp arg(info);
874 size_t pos = reader->pagelocate(); 874 size_t pos = reader->pagelocate();
875 size_t start = pos; 875 size_t start = pos;
876 CDrawBuffer test(&(reader->m_fontControl)); 876 CDrawBuffer test(&(reader->m_fontControl));
877 reader->buffdoc.getline(&test,reader->width()); 877 reader->buffdoc.getline(&test,reader->width());
878 while (arg.match(toQString(test.data())) == -1) 878 while (arg.match(toQString(test.data())) == -1)
879 { 879 {
880 pos = reader->locate(); 880 pos = reader->locate();
881 if (!reader->buffdoc.getline(&test,reader->width())) 881 if (!reader->buffdoc.getline(&test,reader->width()))
882 { 882 {
883 QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); 883 QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info);
884 pos = start; 884 pos = start;
885 break; 885 break;
886 } 886 }
887 } 887 }
888 reader->locate(pos); 888 reader->locate(pos);
889 } 889 }
890 else if ( msg == "Layout/Strip CR(int)" ) 890 else if ( msg == "Layout/Strip CR(int)" )
891 { 891 {
892 int info; 892 int info;
893 stream >> info; 893 stream >> info;
894 stripcr(info); 894 stripcr(info);
895 } 895 }
896 else if ( msg == "Layout/Single Space" ) 896 else if ( msg == "Layout/Single Space" )
897 { 897 {
898 int info; 898 int info;
899 stream >> info; 899 stream >> info;
900 onespace(info); 900 onespace(info);
901 } 901 }
902#ifdef REPALM 902#ifdef REPALM
903 else if ( msg == "Layout/Repalm(int)" ) 903 else if ( msg == "Layout/Repalm(int)" )
904 { 904 {
905 int info; 905 int info;
906 stream >> info; 906 stream >> info;
907 repalm(info); 907 repalm(info);
908 } 908 }
909#endif 909#endif
910 else if ( msg == "Markup/Auto(int)" ) 910 else if ( msg == "Markup/Auto(int)" )
911 { 911 {
912 int info; 912 int info;
913 stream >> info; 913 stream >> info;
914 autofmt(info); 914 autofmt(info);
915 } 915 }
916 else if ( msg == "Markup/Text(int)" ) 916 else if ( msg == "Markup/Text(int)" )
917 { 917 {
918 int info; 918 int info;
919 stream >> info; 919 stream >> info;
920 textfmt(info); 920 textfmt(info);
921 } 921 }
922 else if ( msg == "Markup/HTML(int)" ) 922 else if ( msg == "Markup/HTML(int)" )
923 { 923 {
924 int info; 924 int info;
925 stream >> info; 925 stream >> info;
926 striphtml(info); 926 striphtml(info);
927 } 927 }
928 else if ( msg == "Markup/Peanut(int)" ) 928 else if ( msg == "Markup/Peanut(int)" )
929 { 929 {
930 int info; 930 int info;
931 stream >> info; 931 stream >> info;
932 peanut(info); 932 peanut(info);
933 } 933 }
934 else if ( msg == "Layout/Dehyphen(int)" ) 934 else if ( msg == "Layout/Dehyphen(int)" )
935 { 935 {
936 int info; 936 int info;
937 stream >> info; 937 stream >> info;
938 dehyphen(info); 938 dehyphen(info);
939 } 939 }
940 else if ( msg == "Layout/Unindent(int)" ) 940 else if ( msg == "Layout/Unindent(int)" )
941 { 941 {
942 int info; 942 int info;
943 stream >> info; 943 stream >> info;
944 unindent(info); 944 unindent(info);
945 } 945 }
946 else if ( msg == "Layout/Re-paragraph(int)" ) 946 else if ( msg == "Layout/Re-paragraph(int)" )
947 { 947 {
948 int info; 948 int info;
949 stream >> info; 949 stream >> info;
950 repara(info); 950 repara(info);
951 } 951 }
952 else if ( msg == "Layout/Double Space(int)" ) 952 else if ( msg == "Layout/Double Space(int)" )
953 { 953 {
954 int info; 954 int info;
955 stream >> info; 955 stream >> info;
956 dblspce(info); 956 dblspce(info);
957 } 957 }
958 else if ( msg == "Layout/Indent(int)" ) 958 else if ( msg == "Layout/Indent(int)" )
959 { 959 {
960 int info; 960 int info;
961 stream >> info; 961 stream >> info;
962 reader->bindenter = info; 962 reader->bindenter = info;
963 reader->setfilter(reader->getfilter()); 963 reader->setfilter(reader->getfilter());
964 } 964 }
965 else if ( msg == "Layout/Remap(int)" ) 965 else if ( msg == "Layout/Remap(int)" )
966 { 966 {
967 int info; 967 int info;
968 stream >> info; 968 stream >> info;
969 remap(info); 969 remap(info);
970 } 970 }
971 else if ( msg == "Layout/Embolden(int)" ) 971 else if ( msg == "Layout/Embolden(int)" )
972 { 972 {
973 int info; 973 int info;
974 stream >> info; 974 stream >> info;
975 embolden(info); 975 embolden(info);
976 } 976 }
977 else if ( msg == "Format/Ideogram/Word(int)" ) 977 else if ( msg == "Format/Ideogram/Word(int)" )
978 { 978 {
979 int info; 979 int info;
980 stream >> info; 980 stream >> info;
981 monospace(info); 981 monospace(info);
982 } 982 }
983 else if ( msg == "Format/Set width(int)" ) 983 else if ( msg == "Format/Set width(int)" )
984 { 984 {
985 int info; 985 int info;
986 stream >> info; 986 stream >> info;
987 reader->m_charpc = info; 987 reader->m_charpc = info;
988 reader->setfont(); 988 reader->setfont();
989 reader->refresh(); 989 reader->refresh();
990 } 990 }
991 else if ( msg == "Format/Encoding(QString)" ) 991 else if ( msg == "Format/Encoding(QString)" )
992 { 992 {
993 QString info; 993 QString info;
994 stream >> info; 994 stream >> info;
995 reader->setencoding(EncNameToInt(info)); 995 reader->setencoding(EncNameToInt(info));
996 } 996 }
997 else if ( msg == "Format/Set Font(QString,int)" ) 997 else if ( msg == "Format/Set Font(QString,int)" )
998 { 998 {
999 QString fontname; 999 QString fontname;
1000 int size; 1000 int size;
1001 stream >> fontname; 1001 stream >> fontname;
1002 stream >> size; 1002 stream >> size;
1003 setfontHelper(fontname, size); 1003 setfontHelper(fontname, size);
1004 } 1004 }
1005 else if ( msg == "Marks/Autogen(QString)" ) 1005 else if ( msg == "Marks/Autogen(QString)" )
1006 { 1006 {
1007 QString info; 1007 QString info;
1008 stream >> info; 1008 stream >> info;
1009 do_autogen(info); 1009 do_autogen(info);
1010 } 1010 }
1011} 1011}
1012 1012
1013ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) 1013ActionTypes QTReaderApp::ActNameToInt(const QString& _enc)
1014{ 1014{
1015 for (int i = 0; i < MAX_ACTIONS; i++) 1015 for (int i = 0; i < MAX_ACTIONS; i++)
1016 { 1016 {
1017 if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; 1017 if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i;
1018 } 1018 }
1019 return cesAutoScroll; 1019 return cesAutoScroll;
1020} 1020}
1021 1021
1022void QTReaderApp::setfullscreen(bool sfs) 1022void QTReaderApp::setfullscreen(bool sfs)
1023{ 1023{
1024 reader->bDoUpdates = false; 1024 reader->bDoUpdates = false;
1025 m_fullscreen = sfs; 1025 m_fullscreen = sfs;
1026 showEditTools(); 1026 showEditTools();
1027 qApp->processEvents(); 1027 qApp->processEvents();
1028 reader->bDoUpdates = true; 1028 reader->bDoUpdates = true;
1029 reader->update(); 1029 reader->update();
1030} 1030}
1031 1031
1032void QTReaderApp::setcontinuous(bool sfs) 1032void QTReaderApp::setcontinuous(bool sfs)
1033{ 1033{
1034 reader->setContinuous(sfs); 1034 reader->setContinuous(sfs);
1035 reader->refresh(); 1035 reader->refresh();
1036} 1036}
1037 1037
1038int QTReaderApp::EncNameToInt(const QString& _enc) 1038int QTReaderApp::EncNameToInt(const QString& _enc)
1039{ 1039{
1040 for (int i = 0; i < MAX_ENCODING; i++) 1040 for (int i = 0; i < MAX_ENCODING; i++)
1041 { 1041 {
1042 if (m_EncodingAction[i]->text() == _enc) return i; 1042 if (m_EncodingAction[i]->text() == _enc) return i;
1043 } 1043 }
1044 return 0; 1044 return 0;
1045/* 1045/*
1046 if (_enc == "Ascii") return 0; 1046 if (_enc == "Ascii") return 0;
1047 if (_enc == "UTF-8") return 1; 1047 if (_enc == "UTF-8") return 1;
1048 if (_enc == "UCS-2(BE)") return 2; 1048 if (_enc == "UCS-2(BE)") return 2;
1049 if (_enc == "USC-2(LE)") return 3; 1049 if (_enc == "USC-2(LE)") return 3;
1050*/ 1050*/
1051} 1051}
1052 1052
1053void QTReaderApp::encodingSelected(QAction* _a) 1053void QTReaderApp::encodingSelected(QAction* _a)
1054{ 1054{
1055// qDebug("es:%x : %s", _a, (const char *)(_a->text())); 1055// qDebug("es:%x : %s", _a, (const char *)(_a->text()));
1056 reader->setencoding(EncNameToInt(_a->text())); 1056 reader->setencoding(EncNameToInt(_a->text()));
1057} 1057}
1058 1058
1059void QTReaderApp::buttonActionSelected(QAction* _a) 1059void QTReaderApp::buttonActionSelected(QAction* _a)
1060{ 1060{
1061// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); 1061// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text()));
1062 m_spaceTarget = ActNameToInt(_a->text()); 1062 m_spaceTarget = ActNameToInt(_a->text());
1063} 1063}
1064 1064
1065QTReaderApp::~QTReaderApp() 1065QTReaderApp::~QTReaderApp()
1066{ 1066{
1067} 1067}
1068 1068
1069void QTReaderApp::autoScroll(bool _b) 1069void QTReaderApp::autoScroll(bool _b)
1070{ 1070{
1071 reader->setautoscroll(_b); 1071 reader->setautoscroll(_b);
1072 setScrollState(reader->m_autoScroll); 1072 setScrollState(reader->m_autoScroll);
1073} 1073}
1074 1074
1075void QTReaderApp::zoomin() 1075void QTReaderApp::zoomin()
1076{ 1076{
1077 reader->zoomin(); 1077 reader->zoomin();
1078} 1078}
1079 1079
1080void QTReaderApp::zoomout() 1080void QTReaderApp::zoomout()
1081{ 1081{
1082 reader->zoomout(); 1082 reader->zoomout();
1083} 1083}
1084 1084
1085void QTReaderApp::clearBkmkList() 1085void QTReaderApp::clearBkmkList()
1086{ 1086{
1087 delete pBkmklist; 1087 delete pBkmklist;
1088 pBkmklist = NULL; 1088 pBkmklist = NULL;
1089 m_fBkmksChanged = false; 1089 m_fBkmksChanged = false;
1090} 1090}
1091 1091
1092void QTReaderApp::fileClose() 1092void QTReaderApp::fileClose()
1093{ 1093{
1094 if (pOpenlist != NULL) 1094 if (pOpenlist != NULL)
1095 { 1095 {
1096 int ind = 0; 1096 int ind = 0;
1097 Bkmk* p = (*pOpenlist)[ind]; 1097 Bkmk* p = (*pOpenlist)[ind];
1098 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) 1098 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
1099 { 1099 {
1100 p = (*pOpenlist)[++ind]; 1100 p = (*pOpenlist)[++ind];
1101 } 1101 }
1102 if (p != NULL) pOpenlist->erase(ind); 1102 if (p != NULL) pOpenlist->erase(ind);
1103 switch (QMessageBox::information ( this , PROGNAME, "What do you want to delete?", "Nothing", "Marks", "Marks\nFile", 1, 0 )) 1103 switch (QMessageBox::information ( this , PROGNAME, "What do you want to delete?", "Nothing", "Marks", "Marks\nFile", 1, 0 ))
1104 { 1104 {
1105 case 0: 1105 case 0:
1106 default: 1106 default:
1107 break; 1107 break;
1108 case 2: 1108 case 2:
1109 unlink((const char*)reader->m_lastfile); 1109 unlink((const char*)reader->m_lastfile);
1110 case 1: 1110 case 1:
1111 unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string)); 1111 unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string));
1112 } 1112 }
1113 } 1113 }
1114 1114
1115 fileOpen2(); 1115 fileOpen2();
1116} 1116}
1117 1117
1118void QTReaderApp::updatefileinfo() 1118void QTReaderApp::updatefileinfo()
1119{ 1119{
1120 if (reader->m_string.isNull()) return; 1120 if (reader->m_string.isNull()) return;
1121 if (reader->m_lastfile.isNull()) return; 1121 if (reader->m_lastfile.isNull()) return;
1122 tchar* nm = fromQString(reader->m_string); 1122 tchar* nm = fromQString(reader->m_string);
1123 tchar* fl = fromQString(reader->m_lastfile); 1123 tchar* fl = fromQString(reader->m_lastfile);
1124 qDebug("Lastfile:%x", fl); 1124 qDebug("Lastfile:%x", fl);
1125 bool notadded = true; 1125 bool notadded = true;
1126 if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; 1126 if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>;
1127 else 1127 else
1128 { 1128 {
1129 for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) 1129 for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++)
1130 { 1130 {
1131 if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) 1131 if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0)
1132 { 1132 {
1133 iter->value(reader->pagelocate()); 1133 iter->value(reader->pagelocate());
1134 unsigned short dlen; 1134 unsigned short dlen;
1135 unsigned char* data; 1135 unsigned char* data;
1136 CFiledata fd(iter->anno()); 1136 CFiledata fd(iter->anno());
1137 reader->setSaveData(data, dlen, fd.content(), fd.length()); 1137 reader->setSaveData(data, dlen, fd.content(), fd.length());
1138 qDebug("Filedata(1):%u, %u", fd.length(), dlen); 1138 qDebug("Filedata(1):%u, %u", fd.length(), dlen);
1139 // getstate(data, dlen); 1139 // getstate(data, dlen);
1140 iter->setAnno(data, dlen); 1140 iter->setAnno(data, dlen);
1141 notadded = false; 1141 notadded = false;
1142 delete [] data; 1142 delete [] data;
1143 break; 1143 break;
1144 } 1144 }
1145 } 1145 }
1146 } 1146 }
1147 qDebug("Added?:%x", notadded); 1147 qDebug("Added?:%x", notadded);
1148 if (notadded) 1148 if (notadded)
1149 { 1149 {
1150 struct stat fnstat; 1150 struct stat fnstat;
1151 stat((const char *)reader->m_lastfile, &fnstat); 1151 stat((const char *)reader->m_lastfile, &fnstat);
1152 CFiledata fd(fnstat.st_mtime, fl); 1152 CFiledata fd(fnstat.st_mtime, fl);
1153 unsigned short dlen; 1153 unsigned short dlen;
1154 unsigned char* data; 1154 unsigned char* data;
1155 reader->setSaveData(data, dlen, fd.content(), fd.length()); 1155 reader->setSaveData(data, dlen, fd.content(), fd.length());
1156 pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); 1156 pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate()));
1157 qDebug("Filedata(2):%u, %u", fd.length(), dlen); 1157 qDebug("Filedata(2):%u, %u", fd.length(), dlen);
1158 delete [] data; 1158 delete [] data;
1159 } 1159 }
1160 delete [] nm; 1160 delete [] nm;
1161 delete [] fl; 1161 delete [] fl;
1162} 1162}
1163 1163
1164void QTReaderApp::fileOpen() 1164void QTReaderApp::fileOpen()
1165{ 1165{
1166/* 1166/*
1167 menu->hide(); 1167 menu->hide();
1168 editBar->hide(); 1168 editBar->hide();
1169 if (regVisible) regBar->hide(); 1169 if (regVisible) regBar->hide();
1170 if (searchVisible) searchBar->hide(); 1170 if (searchVisible) searchBar->hide();
1171*/ 1171*/
1172 qDebug("fileOpen"); 1172 qDebug("fileOpen");
1173// if (!reader->m_lastfile.isEmpty()) 1173// if (!reader->m_lastfile.isEmpty())
1174 updatefileinfo(); 1174 updatefileinfo();
1175 fileOpen2(); 1175 fileOpen2();
1176} 1176}
1177 1177
1178void QTReaderApp::fileOpen2() 1178void QTReaderApp::fileOpen2()
1179{ 1179{
1180 if (pBkmklist != NULL) 1180 if (pBkmklist != NULL)
1181 { 1181 {
1182 if (m_fBkmksChanged) 1182 if (m_fBkmksChanged)
1183 { 1183 {
1184 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) 1184 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
1185 savebkmks(); 1185 savebkmks();
1186 } 1186 }
1187 delete pBkmklist; 1187 delete pBkmklist;
1188 pBkmklist = NULL; 1188 pBkmklist = NULL;
1189 m_fBkmksChanged = false; 1189 m_fBkmksChanged = false;
1190 } 1190 }
1191 reader->disableAutoscroll(); 1191 reader->disableAutoscroll();
1192/* 1192/*
1193 editorStack->raiseWidget( fileSelector ); 1193 editorStack->raiseWidget( fileSelector );
1194 fileSelector->reread(); 1194 fileSelector->reread();
1195*/ 1195*/
1196 if (pOpenlist != NULL) 1196 if (pOpenlist != NULL)
1197 { 1197 {
1198 m_nRegAction = cOpenFile; 1198 m_nRegAction = cOpenFile;
1199 listbkmk(pOpenlist, "Browse"); 1199 listbkmk(pOpenlist, "Browse");
1200 } 1200 }
1201 else 1201 else
1202 { 1202 {
1203 QString fn = usefilebrowser(); 1203 QString fn = usefilebrowser();
1204 if (!fn.isEmpty() && QFileInfo(fn).isFile()) 1204 if (!fn.isEmpty() && QFileInfo(fn).isFile())
1205 { 1205 {
1206 openFile(fn); 1206 openFile(fn);
1207 } 1207 }
1208 reader->setFocus(); 1208 reader->setFocus();
1209 } 1209 }
1210} 1210}
1211 1211
1212QString QTReaderApp::usefilebrowser() 1212QString QTReaderApp::usefilebrowser()
1213{ 1213{
1214 fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE, 1214 fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE,
1215 0, 1215 0,
1216 // WStyle_Customize | WStyle_NoBorderEx, 1216 // WStyle_Customize | WStyle_NoBorderEx,
1217 "*", QFileInfo(reader->m_lastfile).dirPath(true)); 1217 "*", QFileInfo(reader->m_lastfile).dirPath(true));
1218 1218
1219 1219
1220 QString fn; 1220 QString fn;
1221 if (fb->exec()) 1221 if (fb->exec())
1222 { 1222 {
1223 fn = fb->fileList[0]; 1223 fn = fb->fileList[0];
1224 } 1224 }
1225 qDebug("Selected %s", (const char*)fn); 1225 qDebug("Selected %s", (const char*)fn);
1226 delete fb; 1226 delete fb;
1227 return fn; 1227 return fn;
1228} 1228}
1229 1229
1230void QTReaderApp::showgraphic(QPixmap& pm) 1230void QTReaderApp::showgraphic(QPixmap& pm)
1231{ 1231{
1232 m_graphicwin->setPixmap(pm); 1232 m_graphicwin->setPixmap(pm);
1233 editorStack->raiseWidget( m_graphicwin ); 1233 editorStack->raiseWidget( m_graphicwin );
1234 m_graphicwin->setFocus(); 1234 m_graphicwin->setFocus();
1235} 1235}
1236 1236
1237void QTReaderApp::showinfo() 1237void QTReaderApp::showinfo()
1238{ 1238{
1239 unsigned long fs, ts, pl; 1239 unsigned long fs, ts, pl;
1240 if (reader->empty()) 1240 if (reader->empty())
1241 { 1241 {
1242 QMessageBox::information(this, PROGNAME, "No file loaded", 1); 1242 QMessageBox::information(this, PROGNAME, "No file loaded", 1);
1243 } 1243 }
1244 else 1244 else
1245 { 1245 {
1246 reader->sizes(fs,ts); 1246 reader->sizes(fs,ts);
1247 pl = reader->pagelocate(); 1247 pl = reader->pagelocate();
1248 m_infoWin->setFileSize(fs); 1248 m_infoWin->setFileSize(fs);
1249 m_infoWin->setTextSize(ts); 1249 m_infoWin->setTextSize(ts);
1250 m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); 1250 m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts);
1251 m_infoWin->setLocation(pl); 1251 m_infoWin->setLocation(pl);
1252 m_infoWin->setRead((100*pl + (ts >> 1))/ts); 1252 m_infoWin->setRead((100*pl + (ts >> 1))/ts);
1253 editorStack->raiseWidget( m_infoWin ); 1253 editorStack->raiseWidget( m_infoWin );
1254 m_infoWin->setFocus(); 1254 m_infoWin->setFocus();
1255 } 1255 }
1256} 1256}
1257 1257
1258void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) 1258void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn)
1259{ 1259{
1260 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; 1260 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>;
1261#ifdef _UNICODE 1261#ifdef _UNICODE
1262 CBuffer buff(name.length()+1); 1262 CBuffer buff(name.length()+1);
1263 int i; 1263 int i;
1264 for (i = 0; i < name.length(); i++) 1264 for (i = 0; i < name.length(); i++)
1265 { 1265 {
1266 buff[i] = name[i].unicode(); 1266 buff[i] = name[i].unicode();
1267 } 1267 }
1268 buff[i] = 0; 1268 buff[i] = 0;
1269 CBuffer buff2(text.length()+1); 1269 CBuffer buff2(text.length()+1);
1270 for (i = 0; i < text.length(); i++) 1270 for (i = 0; i < text.length(); i++)
1271 { 1271 {
1272 buff2[i] = text[i].unicode(); 1272 buff2[i] = text[i].unicode();
1273 } 1273 }
1274 buff2[i] = 0; 1274 buff2[i] = 0;
1275 pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn)); 1275 pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn));
1276#else 1276#else
1277 pBkmklist->push_front(Bkmk((const tchar*)text,posn)); 1277 pBkmklist->push_front(Bkmk((const tchar*)text,posn));
1278#endif 1278#endif
1279 m_fBkmksChanged = true; 1279 m_fBkmksChanged = true;
1280 pBkmklist->sort(); 1280 pBkmklist->sort();
1281} 1281}
1282 1282
1283void QTReaderApp::addAnno(const QString& name, const QString& text) 1283void QTReaderApp::addAnno(const QString& name, const QString& text)
1284{ 1284{
1285 if (m_annoIsEditing) 1285 if (m_annoIsEditing)
1286 { 1286 {
1287 if (name.isEmpty()) 1287 if (name.isEmpty())
1288 { 1288 {
1289 QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); 1289 QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1);
1290 } 1290 }
1291 else 1291 else
1292 { 1292 {
1293 addAnno(name, text, m_annoWin->getPosn()); 1293 addAnno(name, text, m_annoWin->getPosn());
1294 } 1294 }
1295 showEditTools(); 1295 showEditTools();
1296 } 1296 }
1297 else 1297 else
1298 { 1298 {
1299 if (m_annoWin->edited()) 1299 if (m_annoWin->edited())
1300 { 1300 {
1301 CBuffer buff(text.length()+1); 1301 CBuffer buff(text.length()+1);
1302 int i; 1302 int i;
1303 for (i = 0; i < text.length(); i++) 1303 for (i = 0; i < text.length(); i++)
1304 { 1304 {
1305 buff[i] = text[i].unicode(); 1305 buff[i] = text[i].unicode();
1306 } 1306 }
1307 buff[i] = 0; 1307 buff[i] = 0;
1308 m_fBkmksChanged = true; 1308 m_fBkmksChanged = true;
1309 m_anno->setAnno(buff.data()); 1309 m_anno->setAnno(buff.data());
1310 } 1310 }
1311 bool found = findNextBookmark(m_anno->value()+1); 1311 bool found = findNextBookmark(m_anno->value()+1);
1312 if (found) 1312 if (found)
1313 { 1313 {
1314 m_annoWin->setName(toQString(m_anno->name())); 1314 m_annoWin->setName(toQString(m_anno->name()));
1315 m_annoWin->setAnno(toQString(m_anno->anno())); 1315 m_annoWin->setAnno(toQString(m_anno->anno()));
1316 } 1316 }
1317 else 1317 else
1318 { 1318 {
1319 showEditTools(); 1319 showEditTools();
1320 } 1320 }
1321 } 1321 }
1322} 1322}
1323 1323
1324bool QTReaderApp::findNextBookmark(size_t start) 1324bool QTReaderApp::findNextBookmark(size_t start)
1325{ 1325{
1326 bool found = false; 1326 bool found = false;
1327 for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) 1327 for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++)
1328 { 1328 {
1329 if (iter->value() >= start) 1329 if (iter->value() >= start)
1330 { 1330 {
1331 if (iter->value() < reader->locate()) 1331 if (iter->value() < reader->locate())
1332 { 1332 {
1333 found = true; 1333 found = true;
1334 m_anno = iter.pContent(); 1334 m_anno = iter.pContent();
1335 } 1335 }
1336 break; 1336 break;
1337 } 1337 }
1338 } 1338 }
1339 return found; 1339 return found;
1340} 1340}
1341 1341
1342void QTReaderApp::addanno() 1342void QTReaderApp::addanno()
1343{ 1343{
1344 if (reader->empty()) 1344 if (reader->empty())
1345 { 1345 {
1346 QMessageBox::information(this, PROGNAME, "No file loaded", 1); 1346 QMessageBox::information(this, PROGNAME, "No file loaded", 1);
1347 } 1347 }
1348 else 1348 else
1349 { 1349 {
1350 m_annoWin->setName(""); 1350 m_annoWin->setName("");
1351 m_annoWin->setAnno(""); 1351 m_annoWin->setAnno("");
1352 m_annoWin->setPosn(reader->pagelocate()); 1352 m_annoWin->setPosn(reader->pagelocate());
1353 m_annoIsEditing = true; 1353 m_annoIsEditing = true;
1354 editorStack->raiseWidget( m_annoWin ); 1354 editorStack->raiseWidget( m_annoWin );
1355 Global::showInputMethod(); 1355 Global::showInputMethod();
1356 m_annoWin->setFocus(); 1356 m_annoWin->setFocus();
1357 } 1357 }
1358} 1358}
1359 1359
1360void QTReaderApp::infoClose() 1360void QTReaderApp::infoClose()
1361{ 1361{
1362 showEditTools(); 1362 showEditTools();
1363} 1363}
1364 1364
1365/* 1365/*
1366void QTReaderApp::fileRevert() 1366void QTReaderApp::fileRevert()
1367{ 1367{
1368 clear(); 1368 clear();
1369 fileOpen(); 1369 fileOpen();
1370} 1370}
1371 1371
1372void QTReaderApp::editCut() 1372void QTReaderApp::editCut()
1373{ 1373{
1374#ifndef QT_NO_CLIPBOARD 1374#ifndef QT_NO_CLIPBOARD
1375 editor->cut(); 1375 editor->cut();
1376#endif 1376#endif
1377} 1377}
1378*/ 1378*/
1379void QTReaderApp::editMark() 1379void QTReaderApp::editMark()
1380{ 1380{
1381 m_savedpos = reader->pagelocate(); 1381 m_savedpos = reader->pagelocate();
1382} 1382}
1383 1383
1384void QTReaderApp::editCopy() 1384void QTReaderApp::editCopy()
1385{ 1385{
1386 QClipboard* cb = QApplication::clipboard(); 1386 QClipboard* cb = QApplication::clipboard();
1387 QString text; 1387 QString text;
1388 int ch; 1388 int ch;
1389 unsigned long currentpos = reader->pagelocate(); 1389 unsigned long currentpos = reader->pagelocate();
1390 unsigned long endpos = reader->locate(); 1390 unsigned long endpos = reader->locate();
1391 reader->jumpto(m_savedpos); 1391 reader->jumpto(m_savedpos);
1392 while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) 1392 while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF)
1393 { 1393 {
1394 text += ch; 1394 text += ch;
1395 } 1395 }
1396 cb->setText(text); 1396 cb->setText(text);
1397 reader->locate(currentpos); 1397 reader->locate(currentpos);
1398} 1398}
1399 1399
1400void QTReaderApp::pageup() 1400void QTReaderApp::pageup()
1401{ 1401{
1402 reader->NavUp(); 1402 reader->NavUp();
1403} 1403}
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}