summaryrefslogtreecommitdiff
authorzecke <zecke>2002-11-03 11:11:00 (UTC)
committer zecke <zecke>2002-11-03 11:11:00 (UTC)
commitd26f82ea57c70fd0e77eb192f7e133c5f76c2f0f (patch) (unidiff)
tree16240b40b1be5b581dc2fb7e1a0c18239c3dc4fd
parenteac6c5d3a22147d78866122c2f5b89d3fdf6bfc6 (diff)
downloadopie-d26f82ea57c70fd0e77eb192f7e133c5f76c2f0f.zip
opie-d26f82ea57c70fd0e77eb192f7e133c5f76c2f0f.tar.gz
opie-d26f82ea57c70fd0e77eb192f7e133c5f76c2f0f.tar.bz2
Gcc3 compiler fixes again
No default arguments in the implementation please
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/CDrawBuffer.cpp2
-rw-r--r--noncore/apps/opie-reader/QTReader.cpp2
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp2
-rw-r--r--noncore/apps/opie-reader/infowin.cpp2
6 files changed, 7 insertions, 7 deletions
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp
index 0cb9ea9..30d2881 100644
--- a/noncore/apps/opie-reader/Bkmks.cpp
+++ b/noncore/apps/opie-reader/Bkmks.cpp
@@ -1,240 +1,240 @@
1#include <qmessagebox.h> 1#include <qmessagebox.h>
2 2
3#include "Bkmks.h" 3#include "Bkmks.h"
4 4
5#include "StyleConsts.h" 5#include "StyleConsts.h"
6#include "Markups.h" 6#include "Markups.h"
7#include "my_list.h" 7#include "my_list.h"
8#include "version.h" 8#include "version.h"
9 9
10const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); 10const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE);
11 11
12 12
13Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) 13Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p)
14{ 14{
15 int len = ustrlen(_nm)+1; 15 int len = ustrlen(_nm)+1;
16 m_name = new tchar[len]; 16 m_name = new tchar[len];
17 for (int i = 0; i < len; i++) m_name[i] = _nm[i]; 17 for (int i = 0; i < len; i++) m_name[i] = _nm[i];
18 18
19 if (_anno == NULL) 19 if (_anno == NULL)
20 { 20 {
21 m_anno = new tchar[1]; 21 m_anno = new tchar[1];
22 m_anno[0] = 0; 22 m_anno[0] = 0;
23 } 23 }
24 else 24 else
25 { 25 {
26 len = ustrlen(_anno)+1; 26 len = ustrlen(_anno)+1;
27 m_anno = new tchar[len]; 27 m_anno = new tchar[len];
28 for (int i = 0; i < len; i++) m_anno[i] = _anno[i]; 28 for (int i = 0; i < len; i++) m_anno[i] = _anno[i];
29 } 29 }
30} 30}
31 31
32Bkmk::~Bkmk() 32Bkmk::~Bkmk()
33{ 33{
34 if (m_name != NULL) delete [] m_name; 34 if (m_name != NULL) delete [] m_name;
35 m_name = NULL; 35 m_name = NULL;
36 if (m_anno != NULL) delete [] m_anno; 36 if (m_anno != NULL) delete [] m_anno;
37 m_anno = NULL; 37 m_anno = NULL;
38} 38}
39 39
40Bkmk& Bkmk::operator=(const Bkmk& rhs) 40Bkmk& Bkmk::operator=(const Bkmk& rhs)
41{ 41{
42 if (m_name != NULL) 42 if (m_name != NULL)
43 { 43 {
44 delete [] m_name; 44 delete [] m_name;
45 m_name = NULL; 45 m_name = NULL;
46 } 46 }
47 if (m_anno != NULL) 47 if (m_anno != NULL)
48 { 48 {
49 delete [] m_anno; 49 delete [] m_anno;
50 m_anno = NULL; 50 m_anno = NULL;
51 } 51 }
52 if (rhs.m_name != NULL) 52 if (rhs.m_name != NULL)
53 { 53 {
54 int len = ustrlen(rhs.m_name)+1; 54 int len = ustrlen(rhs.m_name)+1;
55 m_name = new tchar[len]; 55 m_name = new tchar[len];
56 for (int i = 0; i < len; i++) m_name[i] = rhs.m_name[i]; 56 for (int i = 0; i < len; i++) m_name[i] = rhs.m_name[i];
57 } 57 }
58 else 58 else
59 m_name = NULL; 59 m_name = NULL;
60 if (rhs.m_anno != NULL) 60 if (rhs.m_anno != NULL)
61 { 61 {
62 int len = ustrlen(rhs.m_anno)+1; 62 int len = ustrlen(rhs.m_anno)+1;
63 m_anno = new tchar[len]; 63 m_anno = new tchar[len];
64 for (int i = 0; i < len; i++) m_anno[i] = rhs.m_anno[i]; 64 for (int i = 0; i < len; i++) m_anno[i] = rhs.m_anno[i];
65 } 65 }
66 else 66 else
67 m_anno = NULL; 67 m_anno = NULL;
68 m_position = rhs.m_position; 68 m_position = rhs.m_position;
69 return *this; 69 return *this;
70} 70}
71 71
72bool Bkmk::operator==(const Bkmk& rhs) 72bool Bkmk::operator==(const Bkmk& rhs)
73{ 73{
74 return (m_position == rhs.m_position && ustrcmp(m_name,rhs.m_name) == 0); 74 return (m_position == rhs.m_position && ustrcmp(m_name,rhs.m_name) == 0);
75} 75}
76 76
77void Bkmk::setAnno(tchar* t) 77void Bkmk::setAnno(tchar* t)
78{ 78{
79 if (m_anno != NULL) 79 if (m_anno != NULL)
80 { 80 {
81 delete [] m_anno; 81 delete [] m_anno;
82 m_anno = NULL; 82 m_anno = NULL;
83 } 83 }
84 if (t != NULL) 84 if (t != NULL)
85 { 85 {
86 int len = ustrlen(t)+1; 86 int len = ustrlen(t)+1;
87 m_anno = new tchar[len]; 87 m_anno = new tchar[len];
88 for (int i = 0; i < len; i++) m_anno[i] = t[i]; 88 for (int i = 0; i < len; i++) m_anno[i] = t[i];
89 } 89 }
90 else 90 else
91 m_anno = NULL; 91 m_anno = NULL;
92} 92}
93 93
94BkmkFile::BkmkFile(const char *fnm, bool w = false) 94BkmkFile::BkmkFile(const char *fnm, bool w )
95 : 95 :
96 wt(w), isUpgraded(false) 96 wt(w), isUpgraded(false)
97{ 97{
98 if (w) 98 if (w)
99 { 99 {
100 f = fopen(fnm, "wb"); 100 f = fopen(fnm, "wb");
101 } 101 }
102 else 102 else
103 { 103 {
104 f = fopen(fnm, "rb"); 104 f = fopen(fnm, "rb");
105 } 105 }
106} 106}
107 107
108BkmkFile::~BkmkFile() 108BkmkFile::~BkmkFile()
109{ 109{
110 if (f != NULL) fclose(f); 110 if (f != NULL) fclose(f);
111} 111}
112 112
113void BkmkFile::write(tchar* nm, tchar* an, const unsigned int& pos) 113void BkmkFile::write(tchar* nm, tchar* an, const unsigned int& pos)
114{ 114{
115 if (f != NULL) 115 if (f != NULL)
116 { 116 {
117 unsigned short ln = ustrlen(nm); 117 unsigned short ln = ustrlen(nm);
118 fwrite(&ln,sizeof(ln),1,f); 118 fwrite(&ln,sizeof(ln),1,f);
119 fwrite(nm,sizeof(tchar),ln,f); 119 fwrite(nm,sizeof(tchar),ln,f);
120 ln = ustrlen(an); 120 ln = ustrlen(an);
121 fwrite(&ln,sizeof(ln),1,f); 121 fwrite(&ln,sizeof(ln),1,f);
122 if (ln > 0) fwrite(an,sizeof(tchar),ln,f); 122 if (ln > 0) fwrite(an,sizeof(tchar),ln,f);
123 fwrite(&pos,sizeof(pos),1,f); 123 fwrite(&pos,sizeof(pos),1,f);
124 } 124 }
125} 125}
126 126
127void BkmkFile::write(const Bkmk& b) { write(b.name(), b.anno(), b.value()); } 127void BkmkFile::write(const Bkmk& b) { write(b.name(), b.anno(), b.value()); }
128 128
129void BkmkFile::write(CList<Bkmk>& bl) 129void BkmkFile::write(CList<Bkmk>& bl)
130{ 130{
131 if (f != NULL) 131 if (f != NULL)
132 { 132 {
133 fwrite(&magic, sizeof(magic), 1, f); 133 fwrite(&magic, sizeof(magic), 1, f);
134 for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++) 134 for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++)
135 { 135 {
136 write(*i); 136 write(*i);
137 } 137 }
138 } 138 }
139} 139}
140 140
141Bkmk* BkmkFile::read() 141Bkmk* BkmkFile::read()
142{ 142{
143 Bkmk* b = NULL; 143 Bkmk* b = NULL;
144 if (f != NULL) 144 if (f != NULL)
145 { 145 {
146 unsigned short ln; 146 unsigned short ln;
147 if (fread(&ln,sizeof(ln),1,f) == 1) 147 if (fread(&ln,sizeof(ln),1,f) == 1)
148 { 148 {
149 b = new Bkmk; 149 b = new Bkmk;
150 b->m_name = new tchar[ln+1]; 150 b->m_name = new tchar[ln+1];
151 fread(b->m_name,sizeof(tchar),ln,f); 151 fread(b->m_name,sizeof(tchar),ln,f);
152 b->m_name[ln] = 0; 152 b->m_name[ln] = 0;
153 153
154 fread(&ln,sizeof(ln),1,f); 154 fread(&ln,sizeof(ln),1,f);
155 b->m_anno = new tchar[ln+1]; 155 b->m_anno = new tchar[ln+1];
156 if (ln > 0) fread(b->m_anno,sizeof(tchar),ln,f); 156 if (ln > 0) fread(b->m_anno,sizeof(tchar),ln,f);
157 b->m_anno[ln] = 0; 157 b->m_anno[ln] = 0;
158 fread(&b->m_position,sizeof(b->m_position),1,f); 158 fread(&b->m_position,sizeof(b->m_position),1,f);
159 } 159 }
160 } 160 }
161 return b; 161 return b;
162} 162}
163 163
164CList<Bkmk>* BkmkFile::readall() 164CList<Bkmk>* BkmkFile::readall()
165{ 165{
166 CList<Bkmk>* bl = NULL; 166 CList<Bkmk>* bl = NULL;
167 if (f != NULL) 167 if (f != NULL)
168 { 168 {
169 unsigned long newmagic; 169 unsigned long newmagic;
170 fread(&newmagic, sizeof(newmagic), 1, f); 170 fread(&newmagic, sizeof(newmagic), 1, f);
171 if (newmagic != magic) 171 if (newmagic != magic)
172 { 172 {
173 if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of OpieReader\ndid you upgrade from?", "0_4*", "Any other version") == 0) 173 if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of OpieReader\ndid you upgrade from?", "0_4*", "Any other version") == 0)
174 { 174 {
175 fseek(f,0,SEEK_SET); 175 fseek(f,0,SEEK_SET);
176 bl = readall04(); 176 bl = readall04();
177 } 177 }
178 else 178 else
179 { 179 {
180 fseek(f,0,SEEK_SET); 180 fseek(f,0,SEEK_SET);
181 bl = readall03(); 181 bl = readall03();
182 } 182 }
183 isUpgraded = true; 183 isUpgraded = true;
184 } 184 }
185 else 185 else
186 { 186 {
187 bl = readall04(); 187 bl = readall04();
188 } 188 }
189 } 189 }
190 return bl; 190 return bl;
191} 191}
192 192
193CList<Bkmk>* BkmkFile::readall04() 193CList<Bkmk>* BkmkFile::readall04()
194{ 194{
195 CList<Bkmk>* bl = new CList<Bkmk>; 195 CList<Bkmk>* bl = new CList<Bkmk>;
196 while (1) 196 while (1)
197 { 197 {
198 Bkmk* b = read(); 198 Bkmk* b = read();
199 if (b == NULL) break; 199 if (b == NULL) break;
200 bl->push_back(*b); 200 bl->push_back(*b);
201 delete b; 201 delete b;
202 } 202 }
203 return bl; 203 return bl;
204} 204}
205 205
206CList<Bkmk>* BkmkFile::readall03() 206CList<Bkmk>* BkmkFile::readall03()
207{ 207{
208 CList<Bkmk>* bl = new CList<Bkmk>; 208 CList<Bkmk>* bl = new CList<Bkmk>;
209 while (1) 209 while (1)
210 { 210 {
211 Bkmk* b = read03(); 211 Bkmk* b = read03();
212 if (b == NULL) break; 212 if (b == NULL) break;
213 bl->push_back(*b); 213 bl->push_back(*b);
214 delete b; 214 delete b;
215 } 215 }
216 return bl; 216 return bl;
217} 217}
218 218
219Bkmk* BkmkFile::read03() 219Bkmk* BkmkFile::read03()
220{ 220{
221 Bkmk* b = NULL; 221 Bkmk* b = NULL;
222 if (f != NULL) 222 if (f != NULL)
223 { 223 {
224 unsigned short ln; 224 unsigned short ln;
225 if (fread(&ln,sizeof(ln),1,f) == 1) 225 if (fread(&ln,sizeof(ln),1,f) == 1)
226 { 226 {
227 b = new Bkmk; 227 b = new Bkmk;
228 b->m_name = new tchar[ln+1]; 228 b->m_name = new tchar[ln+1];
229 fread(b->m_name,sizeof(tchar),ln,f); 229 fread(b->m_name,sizeof(tchar),ln,f);
230 b->m_name[ln] = 0; 230 b->m_name[ln] = 0;
231 231
232 ln = 0; 232 ln = 0;
233 b->m_anno = new tchar[ln+1]; 233 b->m_anno = new tchar[ln+1];
234 b->m_anno[ln] = 0; 234 b->m_anno[ln] = 0;
235 235
236 fread(&b->m_position,sizeof(b->m_position),1,f); 236 fread(&b->m_position,sizeof(b->m_position),1,f);
237 } 237 }
238 } 238 }
239 return b; 239 return b;
240} 240}
diff --git a/noncore/apps/opie-reader/CBuffer.cpp b/noncore/apps/opie-reader/CBuffer.cpp
index 526b25f..0780a88 100644
--- a/noncore/apps/opie-reader/CBuffer.cpp
+++ b/noncore/apps/opie-reader/CBuffer.cpp
@@ -1,46 +1,46 @@
1#include "CBuffer.h" 1#include "CBuffer.h"
2 2
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/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp
index 2ceb2d5..892456f 100644
--- a/noncore/apps/opie-reader/CDrawBuffer.cpp
+++ b/noncore/apps/opie-reader/CDrawBuffer.cpp
@@ -1,211 +1,211 @@
1 1
2#include "CDrawBuffer.h" 2#include "CDrawBuffer.h"
3#include "FontControl.h" 3#include "FontControl.h"
4#include <qfontmetrics.h> 4#include <qfontmetrics.h>
5#include <qpainter.h> 5#include <qpainter.h>
6 6
7void CDrawBuffer::setright(CDrawBuffer& rhs, int f) 7void CDrawBuffer::setright(CDrawBuffer& rhs, int f)
8{ 8{
9 int i; 9 int i;
10// qDebug("Trying 1:%d:%s", f, (const char*)toQString(rhs.data())); 10// qDebug("Trying 1:%d:%s", f, (const char*)toQString(rhs.data()));
11 len = rhs.len; 11 len = rhs.len;
12 m_maxstyle = rhs.m_maxstyle; 12 m_maxstyle = rhs.m_maxstyle;
13 m_ascent = rhs.m_ascent; 13 m_ascent = rhs.m_ascent;
14 m_descent = rhs.m_descent; 14 m_descent = rhs.m_descent;
15 m_lineSpacing = rhs.m_lineSpacing; 15 m_lineSpacing = rhs.m_lineSpacing;
16 while (!segs.isEmpty()) segs.erase(0); 16 while (!segs.isEmpty()) segs.erase(0);
17 for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); ) 17 for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); )
18 { 18 {
19 CList<textsegment>::iterator next = iter; 19 CList<textsegment>::iterator next = iter;
20 iter++; 20 iter++;
21 if (iter == rhs.segs.end() || iter->start > f) 21 if (iter == rhs.segs.end() || iter->start > f)
22 { 22 {
23 int st = next->start-f; 23 int st = next->start-f;
24 if (st < 0) st = 0; 24 if (st < 0) st = 0;
25 segs.push_back(textsegment(st,next->style)); 25 segs.push_back(textsegment(st,next->style));
26 } 26 }
27 } 27 }
28 for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i]; 28 for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i];
29 (*this)[i-f] = '\0'; 29 (*this)[i-f] = '\0';
30 len = i; 30 len = i;
31// qDebug("Tried 1"); 31// qDebug("Tried 1");
32} 32}
33 33
34CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) 34CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs)
35{ 35{
36 int i; 36 int i;
37// qDebug("Trying 2"); 37// qDebug("Trying 2");
38 len = rhs.len; 38 len = rhs.len;
39 m_maxstyle = rhs.m_maxstyle; 39 m_maxstyle = rhs.m_maxstyle;
40 m_ascent = rhs.m_ascent; 40 m_ascent = rhs.m_ascent;
41 m_descent = rhs.m_descent; 41 m_descent = rhs.m_descent;
42 m_lineSpacing = rhs.m_lineSpacing; 42 m_lineSpacing = rhs.m_lineSpacing;
43 while (!segs.isEmpty()) segs.erase(0); 43 while (!segs.isEmpty()) segs.erase(0);
44 for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) 44 for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++)
45 { 45 {
46 segs.push_back(*iter); 46 segs.push_back(*iter);
47 } 47 }
48 for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; 48 for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i];
49 (*this)[i] = '\0'; 49 (*this)[i] = '\0';
50 len = i; 50 len = i;
51// qDebug("Tried 2"); 51// qDebug("Tried 2");
52 return *this; 52 return *this;
53} 53}
54 54
55CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) 55CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp)
56{ 56{
57 int i; 57 int i;
58 while (!segs.isEmpty()) segs.erase(0); 58 while (!segs.isEmpty()) segs.erase(0);
59 segs.push_back(textsegment(0, CStyle())); 59 segs.push_back(textsegment(0, CStyle()));
60 for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; 60 for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i];
61 (*this)[i] = '\0'; 61 (*this)[i] = '\0';
62 len = i; 62 len = i;
63 return *this; 63 return *this;
64} 64}
65 65
66void CDrawBuffer::empty() 66void CDrawBuffer::empty()
67{ 67{
68 len = 0; 68 len = 0;
69 (*this)[0] = 0; 69 (*this)[0] = 0;
70 while (!segs.isEmpty()) segs.erase(0); 70 while (!segs.isEmpty()) segs.erase(0);
71 segs.push_back(textsegment(0,CStyle())); 71 segs.push_back(textsegment(0,CStyle()));
72 m_maxstyle = m_ascent = m_descent = m_lineSpacing = 0; 72 m_maxstyle = m_ascent = m_descent = m_lineSpacing = 0;
73} 73}
74 74
75void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) 75void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/)
76{ 76{
77 if (len == 0) 77 if (len == 0)
78 { 78 {
79 int thissize = fc->getsize(_style); 79 int thissize = fc->getsize(_style);
80 m_maxstyle = thissize; 80 m_maxstyle = thissize;
81 m_ascent = fc->ascent(_style); 81 m_ascent = fc->ascent(_style);
82 m_descent = fc->descent(_style); 82 m_descent = fc->descent(_style);
83 m_lineSpacing = fc->lineSpacing(_style); 83 m_lineSpacing = fc->lineSpacing(_style);
84 segs.first().start = 0; 84 segs.first().start = 0;
85 segs.first().style = _style; 85 segs.first().style = _style;
86 } 86 }
87 else if (_style != segs.last().style) 87 else if (_style != segs.last().style)
88 { 88 {
89 int thissize = fc->getsize(_style); 89 int thissize = fc->getsize(_style);
90 if (thissize > m_maxstyle) 90 if (thissize > m_maxstyle)
91 { 91 {
92 m_maxstyle = thissize; 92 m_maxstyle = thissize;
93 m_ascent = fc->ascent(_style); 93 m_ascent = fc->ascent(_style);
94 m_descent = fc->descent(_style); 94 m_descent = fc->descent(_style);
95 m_lineSpacing = fc->lineSpacing(_style); 95 m_lineSpacing = fc->lineSpacing(_style);
96 } 96 }
97 segs.push_back(textsegment(len, _style)); 97 segs.push_back(textsegment(len, _style));
98 } 98 }
99 (*this)[len++] = ch; 99 (*this)[len++] = ch;
100} 100}
101 101
102void CDrawBuffer::truncate(int n) 102void CDrawBuffer::truncate(int n)
103{ 103{
104 len = n; 104 len = n;
105 (*this)[n] = 0; 105 (*this)[n] = 0;
106} 106}
107 107
108int CDrawBuffer::width(int numchars = -1) 108int CDrawBuffer::width(int numchars)
109{ 109{
110 int currentx = 0, end = 0; 110 int currentx = 0, end = 0;
111 QString text = toQString(data()); 111 QString text = toQString(data());
112 CList<textsegment>::iterator textstart = segs.begin(); 112 CList<textsegment>::iterator textstart = segs.begin();
113 CList<textsegment>::iterator textend = textstart; 113 CList<textsegment>::iterator textend = textstart;
114 do 114 do
115 { 115 {
116 textend++; 116 textend++;
117 end = (textend != segs.end()) ? textend->start : length(); 117 end = (textend != segs.end()) ? textend->start : length();
118 if (numchars >= 0 && end > numchars) 118 if (numchars >= 0 && end > numchars)
119 { 119 {
120 end = numchars; 120 end = numchars;
121 } 121 }
122 CStyle currentstyle = textstart->style; 122 CStyle currentstyle = textstart->style;
123 QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); 123 QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
124 QString str = text.mid(textstart->start, end-textstart->start); 124 QString str = text.mid(textstart->start, end-textstart->start);
125 QFontMetrics fm(f); 125 QFontMetrics fm(f);
126 currentx += fm.width(str); 126 currentx += fm.width(str);
127 textstart = textend; 127 textstart = textend;
128 } 128 }
129 while (textend != segs.end() && end != numchars); 129 while (textend != segs.end() && end != numchars);
130 return currentx; 130 return currentx;
131} 131}
132 132
133void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth) 133void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth)
134{ 134{
135 int currentx = 0; 135 int currentx = 0;
136 QString text = toQString(data()); 136 QString text = toQString(data());
137 CList<textsegment>::iterator textstart = segs.begin(); 137 CList<textsegment>::iterator textstart = segs.begin();
138 StyleType align = textstart->style.getJustify(); 138 StyleType align = textstart->style.getJustify();
139 switch (align) 139 switch (align)
140 { 140 {
141 case CStyle::m_AlignRight: 141 case CStyle::m_AlignRight:
142 { 142 {
143 // int linelength = width(); 143 // int linelength = width();
144 currentx = scwidth - width(); 144 currentx = scwidth - width();
145 } 145 }
146 break; 146 break;
147 case CStyle::m_AlignCentre: 147 case CStyle::m_AlignCentre:
148 { 148 {
149 // int linelength = width(); 149 // int linelength = width();
150 currentx = (scwidth - width())/2; 150 currentx = (scwidth - width())/2;
151 } 151 }
152 break; 152 break;
153 case CStyle::m_AlignJustify: 153 case CStyle::m_AlignJustify:
154 case CStyle::m_AlignLeft: 154 case CStyle::m_AlignLeft:
155 break; 155 break;
156 } 156 }
157 CList<textsegment>::iterator textend = textstart; 157 CList<textsegment>::iterator textend = textstart;
158 do 158 do
159 { 159 {
160 textend++; 160 textend++;
161 int end = (textend != segs.end()) ? textend->start : length(); 161 int end = (textend != segs.end()) ? textend->start : length();
162 CStyle currentstyle = textstart->style; 162 CStyle currentstyle = textstart->style;
163 QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); 163 QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
164 _p->setFont(f); 164 _p->setFont(f);
165 QString str = text.mid(textstart->start, end-textstart->start); 165 QString str = text.mid(textstart->start, end-textstart->start);
166 _p->setPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue())); 166 _p->setPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()));
167 if (_bMono) 167 if (_bMono)
168 { 168 {
169 for (int i = 0; i < str.length(); i++) 169 for (int i = 0; i < str.length(); i++)
170 { 170 {
171 _p->drawText( currentx + i*_charWidth, _y, QString(str[i])); 171 _p->drawText( currentx + i*_charWidth, _y, QString(str[i]));
172 } 172 }
173 currentx += str.length()*_charWidth; 173 currentx += str.length()*_charWidth;
174 } 174 }
175 else 175 else
176 { 176 {
177 _p->drawText( currentx, _y, str); 177 _p->drawText( currentx, _y, str);
178 QFontMetrics fm(f); 178 QFontMetrics fm(f);
179 currentx += fm.width(str); 179 currentx += fm.width(str);
180 } 180 }
181 textstart = textend; 181 textstart = textend;
182 } 182 }
183 while (textend != segs.end()); 183 while (textend != segs.end());
184} 184}
185 185
186CStyle CDrawBuffer::laststyle() 186CStyle CDrawBuffer::laststyle()
187{ 187{
188 return segs.last().style; 188 return segs.last().style;
189} 189}
190 190
191bool CDrawBuffer::isLink(int numchars, size_t& tgt) 191bool CDrawBuffer::isLink(int numchars, size_t& tgt)
192{ 192{
193 int end = 0; 193 int end = 0;
194 CStyle currentstyle; 194 CStyle currentstyle;
195 CList<textsegment>::iterator textstart = segs.begin(); 195 CList<textsegment>::iterator textstart = segs.begin();
196 CList<textsegment>::iterator textend = textstart; 196 CList<textsegment>::iterator textend = textstart;
197 do 197 do
198 { 198 {
199 textend++; 199 textend++;
200 end = (textend != segs.end()) ? textend->start : length(); 200 end = (textend != segs.end()) ? textend->start : length();
201 if (numchars >= 0 && end > numchars) 201 if (numchars >= 0 && end > numchars)
202 { 202 {
203 end = numchars; 203 end = numchars;
204 } 204 }
205 currentstyle = textstart->style; 205 currentstyle = textstart->style;
206 textstart = textend; 206 textstart = textend;
207 } 207 }
208 while (textend != segs.end() && end != numchars); 208 while (textend != segs.end() && end != numchars);
209 tgt = currentstyle.getData(); 209 tgt = currentstyle.getData();
210 return currentstyle.getLink(); 210 return currentstyle.getLink();
211} 211}
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp
index e7bfc28..7cf08e5 100644
--- a/noncore/apps/opie-reader/QTReader.cpp
+++ b/noncore/apps/opie-reader/QTReader.cpp
@@ -1,550 +1,550 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 4** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
5** 5**
6** This file is part of an example program for Qt. This example 6** This file is part of an example program for Qt. This example
7** program may be used, distributed and modified without limitation. 7** program may be used, distributed and modified without limitation.
8** 8**
9*****************************************************************************/ 9*****************************************************************************/
10 10
11#include <qpainter.h> 11#include <qpainter.h>
12#include "config.h" 12#include "config.h"
13#include "QTReader.h" 13#include "QTReader.h"
14#include "QTReaderApp.h" 14#include "QTReaderApp.h"
15#include "CDrawBuffer.h" 15#include "CDrawBuffer.h"
16#include <qpe/qpeapplication.h> 16#include <qpe/qpeapplication.h>
17#include <math.h> 17#include <math.h>
18#include <ctype.h> 18#include <ctype.h>
19#include <stdio.h> //for sprintf 19#include <stdio.h> //for sprintf
20#include <qpe/config.h> 20#include <qpe/config.h>
21#include <qpe/applnk.h> 21#include <qpe/applnk.h>
22#include <qfontdatabase.h> 22#include <qfontdatabase.h>
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25 25
26#ifdef _UNICODE 26#ifdef _UNICODE
27const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; 27const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 };
28#else 28#else
29const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; 29const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 };
30#endif 30#endif
31//const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; 31//const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 };
32 32
33//const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; 33//const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 };
34//const int QTReader::fontsizes[] = {10,16,17,22,0}; 34//const int QTReader::fontsizes[] = {10,16,17,22,0};
35//const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; 35//const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 };
36//const int QTReader::fontsizes[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0}; 36//const int QTReader::fontsizes[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0};
37 37
38QTReader::QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0) : 38QTReader::QTReader( QWidget *parent, const char *name, WFlags f) :
39 QWidget(parent, name, f), 39 QWidget(parent, name, f),
40 m_delay(100), 40 m_delay(100),
41 m_scrolldy1(0), 41 m_scrolldy1(0),
42 m_scrolldy2(0), 42 m_scrolldy2(0),
43 m_autoScroll(false), 43 m_autoScroll(false),
44 //textarray(NULL), 44 //textarray(NULL),
45 //locnarray(NULL), 45 //locnarray(NULL),
46 numlines(0), 46 numlines(0),
47 m_fontname("unifont"), 47 m_fontname("unifont"),
48 m_fm(NULL), 48 m_fm(NULL),
49 mouseUpOn(true), 49 mouseUpOn(true),
50 m_twotouch(true), 50 m_twotouch(true),
51 m_touchone(true) 51 m_touchone(true)
52{ 52{
53 m_overlap = 1; 53 m_overlap = 1;
54// init(); 54// init();
55} 55}
56/* 56/*
57QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : 57QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) :
58 QWidget(parent, name, f), 58 QWidget(parent, name, f),
59 m_textfont(0), 59 m_textfont(0),
60 m_textsize(1), 60 m_textsize(1),
61 textarray(NULL), 61 textarray(NULL),
62 numlines(0), 62 numlines(0),
63 bstripcr(true), 63 bstripcr(true),
64 bunindent(false), 64 bunindent(false),
65 brepara(false), 65 brepara(false),
66 bdblspce(false), 66 bdblspce(false),
67 btight(false), 67 btight(false),
68 bindenter(0), 68 bindenter(0),
69 m_fm(NULL) 69 m_fm(NULL)
70{ 70{
71 init(); 71 init();
72 // qDebug("Load_file(1)"); 72 // qDebug("Load_file(1)");
73 load_file((const tchar*)filename); 73 load_file((const tchar*)filename);
74} 74}
75*/ 75*/
76 76
77long QTReader::real_delay() 77long QTReader::real_delay()
78{ 78{
79 return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); 79 return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing );
80} 80}
81 81
82void QTReader::mousePressEvent( QMouseEvent* _e ) 82void QTReader::mousePressEvent( QMouseEvent* _e )
83{ 83{
84 if (_e->button() == RightButton) 84 if (_e->button() == RightButton)
85 { 85 {
86 mouseUpOn = false; 86 mouseUpOn = false;
87 if (_e->y() > height()/2) 87 if (_e->y() > height()/2)
88 { 88 {
89 goDown(); 89 goDown();
90 } 90 }
91 else 91 else
92 { 92 {
93 goUp(); 93 goUp();
94 } 94 }
95 } 95 }
96} 96}
97 97
98bool QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt) 98bool QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt)
99{ 99{
100 int lineno = 0; 100 int lineno = 0;
101 int ht = textarray[0]->lineSpacing(); 101 int ht = textarray[0]->lineSpacing();
102 while ((ht < y) && (lineno < numlines)) 102 while ((ht < y) && (lineno < numlines))
103 { 103 {
104 ht += textarray[++lineno]->lineSpacing(); 104 ht += textarray[++lineno]->lineSpacing();
105 } 105 }
106 start = locnarray[lineno]; 106 start = locnarray[lineno];
107 if (m_bMonoSpaced) 107 if (m_bMonoSpaced)
108 { 108 {
109 offset = x/m_charWidth; 109 offset = x/m_charWidth;
110 } 110 }
111 else 111 else
112 { 112 {
113 int i; 113 int i;
114 CDrawBuffer* t = textarray[lineno]; 114 CDrawBuffer* t = textarray[lineno];
115 for (i = t->length(); t->width(i) > x; i--); 115 for (i = t->length(); t->width(i) > x; i--);
116 offset = i; 116 offset = i;
117 } 117 }
118 return textarray[lineno]->isLink(offset, tgt); 118 return textarray[lineno]->isLink(offset, tgt);
119} 119}
120 120
121void QTReader::setTwoTouch(bool _b) 121void QTReader::setTwoTouch(bool _b)
122{ 122{
123 setBackgroundColor( white ); 123 setBackgroundColor( white );
124 m_twotouch = m_touchone = _b; 124 m_twotouch = m_touchone = _b;
125} 125}
126 126
127void QTReader::mouseReleaseEvent( QMouseEvent* _e ) 127void QTReader::mouseReleaseEvent( QMouseEvent* _e )
128{ 128{
129 if (_e->button() == LeftButton) 129 if (_e->button() == LeftButton)
130 { 130 {
131 if (mouseUpOn) 131 if (mouseUpOn)
132 { 132 {
133 if (textarray[0] != NULL) 133 if (textarray[0] != NULL)
134 { 134 {
135 QString wrd, line; 135 QString wrd, line;
136 // int lineno = _e->y()/m_linespacing; 136 // int lineno = _e->y()/m_linespacing;
137 int lineno = 0; 137 int lineno = 0;
138 int ht = textarray[0]->lineSpacing(); 138 int ht = textarray[0]->lineSpacing();
139 while ((ht < _e->y()) && (lineno < numlines)) 139 while ((ht < _e->y()) && (lineno < numlines))
140 { 140 {
141 ht += textarray[++lineno]->lineSpacing(); 141 ht += textarray[++lineno]->lineSpacing();
142 } 142 }
143 size_t startpos, startoffset, tgt; 143 size_t startpos, startoffset, tgt;
144 if (getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt)) 144 if (getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt))
145 { 145 {
146 if (buffdoc.hyperlink(tgt)) 146 if (buffdoc.hyperlink(tgt))
147 { 147 {
148 fillbuffer(); 148 fillbuffer();
149 update(); 149 update();
150 } 150 }
151 else 151 else
152 { 152 {
153 locate(pagelocate()); 153 locate(pagelocate());
154 } 154 }
155 return; 155 return;
156 } 156 }
157 if (m_twotouch) 157 if (m_twotouch)
158 { 158 {
159 if (m_touchone) 159 if (m_touchone)
160 { 160 {
161 m_touchone = false; 161 m_touchone = false;
162 m_startpos = startpos; 162 m_startpos = startpos;
163 m_startoffset = startoffset; 163 m_startoffset = startoffset;
164 setBackgroundColor( lightGray ); 164 setBackgroundColor( lightGray );
165 } 165 }
166 else 166 else
167 { 167 {
168 m_touchone = true; 168 m_touchone = true;
169 setBackgroundColor( white ); 169 setBackgroundColor( white );
170 size_t endpos, endoffset; 170 size_t endpos, endoffset;
171 endpos = startpos; 171 endpos = startpos;
172 endoffset = startoffset; 172 endoffset = startoffset;
173 size_t currentpos = locate(); 173 size_t currentpos = locate();
174 if (endpos >= m_startpos) 174 if (endpos >= m_startpos)
175 { 175 {
176 jumpto(m_startpos); 176 jumpto(m_startpos);
177 for (int i = 0; i < m_startoffset; i++) 177 for (int i = 0; i < m_startoffset; i++)
178 { 178 {
179 getch(); 179 getch();
180 } 180 }
181 if (m_startpos == endpos) 181 if (m_startpos == endpos)
182 { 182 {
183 for (int i = m_startoffset; i <= endoffset; i++) 183 for (int i = m_startoffset; i <= endoffset; i++)
184 { 184 {
185 wrd += QChar(getch()); 185 wrd += QChar(getch());
186 } 186 }
187 } 187 }
188 else 188 else
189 { 189 {
190 while (buffdoc.explocate() <= endpos) 190 while (buffdoc.explocate() <= endpos)
191 { 191 {
192 wrd += QChar(getch()); 192 wrd += QChar(getch());
193 } 193 }
194 for (int i = 0; i < endoffset; i++) 194 for (int i = 0; i < endoffset; i++)
195 { 195 {
196 wrd += QChar(getch()); 196 wrd += QChar(getch());
197 } 197 }
198 } 198 }
199 jumpto(currentpos); 199 jumpto(currentpos);
200 } 200 }
201 } 201 }
202 } 202 }
203 else if (m_bMonoSpaced) 203 else if (m_bMonoSpaced)
204 { 204 {
205 int chno = _e->x()/m_charWidth; 205 int chno = _e->x()/m_charWidth;
206 if (chno < ustrlen(textarray[lineno]->data())) 206 if (chno < ustrlen(textarray[lineno]->data()))
207 { 207 {
208 wrd[0] = textarray[lineno]->data()[chno]; 208 wrd[0] = textarray[lineno]->data()[chno];
209 } 209 }
210 } 210 }
211 else 211 else
212 { 212 {
213 CDrawBuffer* t = textarray[lineno]; 213 CDrawBuffer* t = textarray[lineno];
214 int first = 0; 214 int first = 0;
215 while (1) 215 while (1)
216 { 216 {
217 int i = first+1; 217 int i = first+1;
218 while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; 218 while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
219 if (t->width(i) > _e->x()) 219 if (t->width(i) > _e->x())
220 { 220 {
221 wrd = toQString(t->data()+first, i - first); 221 wrd = toQString(t->data()+first, i - first);
222 break; 222 break;
223 } 223 }
224 while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; 224 while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
225 if ((*t)[i] == 0) break; 225 if ((*t)[i] == 0) break;
226 first = i; 226 first = i;
227 } 227 }
228 } 228 }
229 if (!wrd.isEmpty()) 229 if (!wrd.isEmpty())
230 { 230 {
231 emit OnWordSelected(wrd, locnarray[lineno], (m_twotouch) ? wrd : toQString(textarray[lineno]->data())); 231 emit OnWordSelected(wrd, locnarray[lineno], (m_twotouch) ? wrd : toQString(textarray[lineno]->data()));
232 } 232 }
233 } 233 }
234 } 234 }
235 else 235 else
236 { 236 {
237 mouseUpOn = true; 237 mouseUpOn = true;
238 } 238 }
239 } 239 }
240} 240}
241 241
242void QTReader::focusInEvent(QFocusEvent* e) 242void QTReader::focusInEvent(QFocusEvent* e)
243{ 243{
244 if (m_autoScroll) timer->start(real_delay(), false); 244 if (m_autoScroll) timer->start(real_delay(), false);
245 update(); 245 update();
246} 246}
247 247
248void QTReader::focusOutEvent(QFocusEvent* e) 248void QTReader::focusOutEvent(QFocusEvent* e)
249{ 249{
250 if (m_autoScroll) 250 if (m_autoScroll)
251 { 251 {
252 timer->stop(); 252 timer->stop();
253 m_scrolldy1 = m_scrolldy2 = 0; 253 m_scrolldy1 = m_scrolldy2 = 0;
254 } 254 }
255} 255}
256 256
257#include <qapplication.h> 257#include <qapplication.h>
258#include <qdrawutil.h> 258#include <qdrawutil.h>
259#include <unistd.h> 259#include <unistd.h>
260 260
261void QTReader::goDown() 261void QTReader::goDown()
262{ 262{
263 if (m_bpagemode) 263 if (m_bpagemode)
264 { 264 {
265 dopagedn(); 265 dopagedn();
266 } 266 }
267 else 267 else
268 { 268 {
269 lineDown(); 269 lineDown();
270 } 270 }
271} 271}
272 272
273void QTReader::goUp() 273void QTReader::goUp()
274{ 274{
275 if (m_bpagemode) 275 if (m_bpagemode)
276 { 276 {
277 dopageup(); 277 dopageup();
278 } 278 }
279 else 279 else
280 { 280 {
281 lineUp(); 281 lineUp();
282 } 282 }
283} 283}
284 284
285void QTReader::keyPressEvent(QKeyEvent* e) 285void QTReader::keyPressEvent(QKeyEvent* e)
286{ 286{
287 switch (e->key()) 287 switch (e->key())
288 { 288 {
289 case Key_Down: 289 case Key_Down:
290 { 290 {
291 e->accept(); 291 e->accept();
292 if (m_autoScroll) 292 if (m_autoScroll)
293 { 293 {
294 if (m_delay < 59049) 294 if (m_delay < 59049)
295 { 295 {
296 m_delay = (3*m_delay)/2; 296 m_delay = (3*m_delay)/2;
297 timer->changeInterval(real_delay()); 297 timer->changeInterval(real_delay());
298 } 298 }
299 else 299 else
300 { 300 {
301 m_delay = 59049; 301 m_delay = 59049;
302 } 302 }
303 } 303 }
304 else 304 else
305 { 305 {
306 goDown(); 306 goDown();
307 } 307 }
308 } 308 }
309 break; 309 break;
310 case Key_Up: 310 case Key_Up:
311 { 311 {
312 e->accept(); 312 e->accept();
313 if (m_autoScroll) 313 if (m_autoScroll)
314 { 314 {
315 if (m_delay > 1024) 315 if (m_delay > 1024)
316 { 316 {
317 m_delay = (2*m_delay)/3; 317 m_delay = (2*m_delay)/3;
318 timer->changeInterval(real_delay()); 318 timer->changeInterval(real_delay());
319 } 319 }
320 else 320 else
321 { 321 {
322 m_delay = 1024; 322 m_delay = 1024;
323 } 323 }
324 } 324 }
325 else 325 else
326 { 326 {
327 goUp(); 327 goUp();
328 } 328 }
329 } 329 }
330 break; 330 break;
331 /* 331 /*
332 case Key_Left: 332 case Key_Left:
333 { 333 {
334 e->accept(); 334 e->accept();
335 if (m_textfont > 0) 335 if (m_textfont > 0)
336 { 336 {
337 m_textfont--; 337 m_textfont--;
338 setfont(NULL); 338 setfont(NULL);
339 locate(pagelocate()); 339 locate(pagelocate());
340 update(); 340 update();
341 } 341 }
342 } 342 }
343 break; 343 break;
344 case Key_Right: 344 case Key_Right:
345 { 345 {
346 e->accept(); 346 e->accept();
347 if (fonts[++m_textfont] == 0) 347 if (fonts[++m_textfont] == 0)
348 { 348 {
349 m_textfont--; 349 m_textfont--;
350 } 350 }
351 else 351 else
352 { 352 {
353 setfont(NULL); 353 setfont(NULL);
354 locate(pagelocate()); 354 locate(pagelocate());
355 update(); 355 update();
356 } 356 }
357 } 357 }
358 break; 358 break;
359 */ 359 */
360 case Key_Right: 360 case Key_Right:
361 { 361 {
362 e->accept(); 362 e->accept();
363 if (m_fontControl.increasesize()) 363 if (m_fontControl.increasesize())
364 { 364 {
365 bool sc = m_autoScroll; 365 bool sc = m_autoScroll;
366 setfont(); 366 setfont();
367 m_autoScroll = false; 367 m_autoScroll = false;
368 locate(pagelocate()); 368 locate(pagelocate());
369 update(); 369 update();
370 m_autoScroll = sc; 370 m_autoScroll = sc;
371 if (m_autoScroll) autoscroll(); 371 if (m_autoScroll) autoscroll();
372 } 372 }
373 } 373 }
374 break; 374 break;
375 case Key_Left: 375 case Key_Left:
376 { 376 {
377 e->accept(); 377 e->accept();
378 if (m_fontControl.decreasesize()) 378 if (m_fontControl.decreasesize())
379 { 379 {
380 bool sc = m_autoScroll; 380 bool sc = m_autoScroll;
381 m_autoScroll = false; 381 m_autoScroll = false;
382 setfont(); 382 setfont();
383 locate(pagelocate()); 383 locate(pagelocate());
384 update(); 384 update();
385 m_autoScroll = sc; 385 m_autoScroll = sc;
386 if (m_autoScroll) autoscroll(); 386 if (m_autoScroll) autoscroll();
387 } 387 }
388 } 388 }
389 break; 389 break;
390 case Key_Space: 390 case Key_Space:
391 case Key_Return: 391 case Key_Return:
392 { 392 {
393 e->accept(); 393 e->accept();
394 emit OnActionPressed(); 394 emit OnActionPressed();
395 } 395 }
396 break; 396 break;
397 default: 397 default:
398 e->ignore(); 398 e->ignore();
399 } 399 }
400} 400}
401 401
402void QTReader::setautoscroll(bool _sc) 402void QTReader::setautoscroll(bool _sc)
403{ 403{
404 if (_sc == m_autoScroll) return; 404 if (_sc == m_autoScroll) return;
405 if (m_autoScroll) 405 if (m_autoScroll)
406 { 406 {
407 m_autoScroll = false; 407 m_autoScroll = false;
408 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 408 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
409 } 409 }
410 else 410 else
411 { 411 {
412 m_autoScroll = true; 412 m_autoScroll = true;
413 autoscroll(); 413 autoscroll();
414 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed 414 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed
415 } 415 }
416} 416}
417 417
418bool QTReader::getline(CDrawBuffer *buff) 418bool QTReader::getline(CDrawBuffer *buff)
419{ 419{
420 if (m_bMonoSpaced) 420 if (m_bMonoSpaced)
421 { 421 {
422 return buffdoc.getline(buff ,width(), m_charWidth); 422 return buffdoc.getline(buff ,width(), m_charWidth);
423 } 423 }
424 else 424 else
425 { 425 {
426 return buffdoc.getline(buff, width()); 426 return buffdoc.getline(buff, width());
427 } 427 }
428} 428}
429 429
430void QTReader::doscroll() 430void QTReader::doscroll()
431{ 431{
432 if (!m_autoScroll) 432 if (!m_autoScroll)
433 { 433 {
434 timer->stop(); 434 timer->stop();
435 return; 435 return;
436 } 436 }
437// timer->changeInterval(real_delay()); 437// timer->changeInterval(real_delay());
438 QPainter p( this ); 438 QPainter p( this );
439 QBrush b( white); 439 QBrush b( white);
440 bitBlt(this,0,0,this,0,1,width(),-1); 440 bitBlt(this,0,0,this,0,1,width(),-1);
441 qDrawPlainRect(&p,0,height() - 2,width(),2,white,1,&b); 441 qDrawPlainRect(&p,0,height() - 2,width(),2,white,1,&b);
442 442
443 if (++m_scrolldy1 == textarray[0]->lineSpacing()) 443 if (++m_scrolldy1 == textarray[0]->lineSpacing())
444 { 444 {
445 CDrawBuffer* buff = textarray[0]; 445 CDrawBuffer* buff = textarray[0];
446 for (int i = 1; i <= numlines; i++) 446 for (int i = 1; i <= numlines; i++)
447 { 447 {
448 textarray[i-1] = textarray[i]; 448 textarray[i-1] = textarray[i];
449 locnarray[i-1] = locnarray[i]; 449 locnarray[i-1] = locnarray[i];
450 } 450 }
451 textarray[numlines] = buff; 451 textarray[numlines] = buff;
452 --numlines; 452 --numlines;
453 m_scrolldy1 = 0; 453 m_scrolldy1 = 0;
454 } 454 }
455 if (++m_scrolldy2 == textarray[numlines]->lineSpacing()) 455 if (++m_scrolldy2 == textarray[numlines]->lineSpacing())
456 { 456 {
457 m_scrolldy2 = 0; 457 m_scrolldy2 = 0;
458 numlines++; 458 numlines++;
459 459
460 if (textarray[numlines] == NULL) 460 if (textarray[numlines] == NULL)
461 { 461 {
462 textarray[numlines] = new CDrawBuffer; 462 textarray[numlines] = new CDrawBuffer;
463 } 463 }
464 locnarray[numlines] = locate(); 464 locnarray[numlines] = locate();
465 int ch = getline(textarray[numlines]); 465 int ch = getline(textarray[numlines]);
466 textarray[numlines-1]->render(&p, height() - textarray[numlines]->descent() - 2, m_bMonoSpaced, m_charWidth, width()); 466 textarray[numlines-1]->render(&p, height() - textarray[numlines]->descent() - 2, m_bMonoSpaced, m_charWidth, width());
467 mylastpos = locate(); 467 mylastpos = locate();
468 if (!ch) 468 if (!ch)
469 { 469 {
470 m_autoScroll = false; 470 m_autoScroll = false;
471 ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); 471 ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll);
472 emit OnRedraw(); 472 emit OnRedraw();
473 } 473 }
474 emit OnRedraw(); 474 emit OnRedraw();
475 } 475 }
476} 476}
477 477
478void QTReader::autoscroll() 478void QTReader::autoscroll()
479{ 479{
480 timer->start(real_delay(), false); 480 timer->start(real_delay(), false);
481} 481}
482 482
483void QTReader::setfont() 483void QTReader::setfont()
484{ 484{
485// m_fontControl.Change 485// m_fontControl.Change
486 m_charWidth = (m_charpc*m_fontControl.currentsize())/100; 486 m_charWidth = (m_charpc*m_fontControl.currentsize())/100;
487 if (m_charWidth <= 0) m_charWidth = 1; 487 if (m_charWidth <= 0) m_charWidth = 1;
488 m_ascent = m_fontControl.ascent(); 488 m_ascent = m_fontControl.ascent();
489 m_descent = m_fontControl.descent(); 489 m_descent = m_fontControl.descent();
490 m_linespacing = m_fontControl.lineSpacing(); 490 m_linespacing = m_fontControl.lineSpacing();
491} 491}
492 492
493void QTReader::drawFonts( QPainter *p ) 493void QTReader::drawFonts( QPainter *p )
494{ 494{
495 setfont(); 495 setfont();
496 if (m_lastwidth != width() || m_lastheight != height()) 496 if (m_lastwidth != width() || m_lastheight != height())
497 { 497 {
498 m_lastwidth = width(); 498 m_lastwidth = width();
499 m_lastheight = height(); 499 m_lastheight = height();
500 locate(pagelocate()); 500 locate(pagelocate());
501 } 501 }
502 else 502 else
503 { 503 {
504 504
505/* 505/*
506 int sl = screenlines(); 506 int sl = screenlines();
507 if (sl < numlines) 507 if (sl < numlines)
508 { 508 {
509 //qDebug("df:<%u,%u>",sl,numlines); 509 //qDebug("df:<%u,%u>",sl,numlines);
510 510
511 size_t newpos = locnarray[sl]; 511 size_t newpos = locnarray[sl];
512 CDrawBuffer** nta = new CDrawBuffer*[sl]; 512 CDrawBuffer** nta = new CDrawBuffer*[sl];
513 size_t* nla = new size_t[sl]; 513 size_t* nla = new size_t[sl];
514 for (int i = 0; i < sl; i++) 514 for (int i = 0; i < sl; i++)
515 { 515 {
516 nta[i] = textarray[i]; 516 nta[i] = textarray[i];
517 nla[i] = locnarray[i]; 517 nla[i] = locnarray[i];
518 } 518 }
519 for (int i = sl; i < numlines; i++) delete textarray[i]; 519 for (int i = sl; i < numlines; i++) delete textarray[i];
520 delete [] locnarray; 520 delete [] locnarray;
521 delete [] textarray; 521 delete [] textarray;
522 textarray = nta; 522 textarray = nta;
523 locnarray = nla; 523 locnarray = nla;
524 numlines = sl; 524 numlines = sl;
525 jumpto(mylastpos = newpos); 525 jumpto(mylastpos = newpos);
526 } 526 }
527 if (sl > numlines) 527 if (sl > numlines)
528 { 528 {
529 //qDebug("df:<%u,%u>",sl,numlines); 529 //qDebug("df:<%u,%u>",sl,numlines);
530 CDrawBuffer** nta = new CDrawBuffer*[sl]; 530 CDrawBuffer** nta = new CDrawBuffer*[sl];
531 size_t* nla = new size_t[sl]; 531 size_t* nla = new size_t[sl];
532 for (int i = 0; i < numlines; i++) 532 for (int i = 0; i < numlines; i++)
533 { 533 {
534 nta[i] = textarray[i]; 534 nta[i] = textarray[i];
535 nla[i] = locnarray[i]; 535 nla[i] = locnarray[i];
536 } 536 }
537 if (locate() != mylastpos) jumpto(mylastpos); 537 if (locate() != mylastpos) jumpto(mylastpos);
538 for (int i = numlines; i < sl; i++) 538 for (int i = numlines; i < sl; i++)
539 { 539 {
540 nta[i] = new CDrawBuffer(&m_fontControl); 540 nta[i] = new CDrawBuffer(&m_fontControl);
541 nla[i] = locate(); 541 nla[i] = locate();
542 getline(nta[i]); 542 getline(nta[i]);
543 } 543 }
544 mylastpos = locate(); 544 mylastpos = locate();
545 delete [] locnarray; 545 delete [] locnarray;
546 delete [] textarray; 546 delete [] textarray;
547 textarray = nta; 547 textarray = nta;
548 locnarray = nla; 548 locnarray = nla;
549 numlines = sl; 549 numlines = sl;
550 } 550 }
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index ef1f4f1..8726df7 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -1200,830 +1200,830 @@ void QTReaderApp::setspacing()
1200 char lcn[20]; 1200 char lcn[20];
1201 sprintf(lcn, "%lu", reader->m_charpc); 1201 sprintf(lcn, "%lu", reader->m_charpc);
1202 regEdit->setText(lcn); 1202 regEdit->setText(lcn);
1203 do_regedit(); 1203 do_regedit();
1204} 1204}
1205 1205
1206void QTReaderApp::setoverlap() 1206void QTReaderApp::setoverlap()
1207{ 1207{
1208 m_nRegAction = cOverlap; 1208 m_nRegAction = cOverlap;
1209 char lcn[20]; 1209 char lcn[20];
1210 sprintf(lcn, "%lu", reader->m_overlap); 1210 sprintf(lcn, "%lu", reader->m_overlap);
1211 regEdit->setText(lcn); 1211 regEdit->setText(lcn);
1212 do_regedit(); 1212 do_regedit();
1213} 1213}
1214 1214
1215void QTReaderApp::settarget() 1215void QTReaderApp::settarget()
1216{ 1216{
1217 m_nRegAction = cSetTarget; 1217 m_nRegAction = cSetTarget;
1218 QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) 1218 QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp)
1219 + "/" 1219 + "/"
1220 + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); 1220 + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg);
1221 regEdit->setText(text); 1221 regEdit->setText(text);
1222 do_regedit(); 1222 do_regedit();
1223} 1223}
1224 1224
1225void QTReaderApp::do_overlap(const QString& lcn) 1225void QTReaderApp::do_overlap(const QString& lcn)
1226{ 1226{
1227 bool ok; 1227 bool ok;
1228 unsigned long ulcn = lcn.toULong(&ok); 1228 unsigned long ulcn = lcn.toULong(&ok);
1229 if (ok) 1229 if (ok)
1230 { 1230 {
1231 reader->m_overlap = ulcn; 1231 reader->m_overlap = ulcn;
1232 } 1232 }
1233 else 1233 else
1234 QMessageBox::information(this, "OpieReader", "Must be a number"); 1234 QMessageBox::information(this, "OpieReader", "Must be a number");
1235} 1235}
1236 1236
1237void QTReaderApp::do_mono(const QString& lcn) 1237void QTReaderApp::do_mono(const QString& lcn)
1238{ 1238{
1239 bool ok; 1239 bool ok;
1240 unsigned long ulcn = lcn.toULong(&ok); 1240 unsigned long ulcn = lcn.toULong(&ok);
1241 if (ok) 1241 if (ok)
1242 { 1242 {
1243 reader->m_charpc = ulcn; 1243 reader->m_charpc = ulcn;
1244 reader->setfont(); 1244 reader->setfont();
1245 reader->refresh(); 1245 reader->refresh();
1246// reader->setmono(true); 1246// reader->setmono(true);
1247 } 1247 }
1248 else 1248 else
1249 QMessageBox::information(this, "OpieReader", "Must be a number"); 1249 QMessageBox::information(this, "OpieReader", "Must be a number");
1250} 1250}
1251 1251
1252/* 1252/*
1253void QTReaderApp::editPaste() 1253void QTReaderApp::editPaste()
1254{ 1254{
1255#ifndef QT_NO_CLIPBOARD 1255#ifndef QT_NO_CLIPBOARD
1256 editor->paste(); 1256 editor->paste();
1257#endif 1257#endif
1258} 1258}
1259*/ 1259*/
1260 1260
1261void QTReaderApp::editFind() 1261void QTReaderApp::editFind()
1262{ 1262{
1263 searchStart = reader->pagelocate(); 1263 searchStart = reader->pagelocate();
1264#ifdef __ISEARCH 1264#ifdef __ISEARCH
1265 searchStack = new QStack<searchrecord>; 1265 searchStack = new QStack<searchrecord>;
1266#endif 1266#endif
1267 searchBar->show(); 1267 searchBar->show();
1268 searchVisible = TRUE; 1268 searchVisible = TRUE;
1269 searchEdit->setFocus(); 1269 searchEdit->setFocus();
1270#ifdef __ISEARCH 1270#ifdef __ISEARCH
1271 searchStack->push(new searchrecord("",reader->pagelocate())); 1271 searchStack->push(new searchrecord("",reader->pagelocate()));
1272#endif 1272#endif
1273} 1273}
1274 1274
1275void QTReaderApp::findNext() 1275void QTReaderApp::findNext()
1276{ 1276{
1277 // qDebug("findNext called\n"); 1277 // qDebug("findNext called\n");
1278#ifdef __ISEARCH 1278#ifdef __ISEARCH
1279 QString arg = searchEdit->text(); 1279 QString arg = searchEdit->text();
1280#else 1280#else
1281 QRegExp arg = searchEdit->text(); 1281 QRegExp arg = searchEdit->text();
1282#endif 1282#endif
1283 CDrawBuffer test(&(reader->m_fontControl)); 1283 CDrawBuffer test(&(reader->m_fontControl));
1284 size_t start = reader->pagelocate(); 1284 size_t start = reader->pagelocate();
1285 reader->jumpto(start); 1285 reader->jumpto(start);
1286 reader->buffdoc.getline(&test,reader->width()); 1286 reader->buffdoc.getline(&test,reader->width());
1287 dosearch(start, test, arg); 1287 dosearch(start, test, arg);
1288} 1288}
1289 1289
1290void QTReaderApp::findClose() 1290void QTReaderApp::findClose()
1291{ 1291{
1292 searchVisible = FALSE; 1292 searchVisible = FALSE;
1293 searchEdit->setText(""); 1293 searchEdit->setText("");
1294 searchBar->hide(); 1294 searchBar->hide();
1295#ifdef __ISEARCH 1295#ifdef __ISEARCH
1296// searchStack = new QStack<searchrecord>; 1296// searchStack = new QStack<searchrecord>;
1297 while (!searchStack->isEmpty()) 1297 while (!searchStack->isEmpty())
1298 { 1298 {
1299 delete searchStack->pop(); 1299 delete searchStack->pop();
1300 } 1300 }
1301 delete searchStack; 1301 delete searchStack;
1302#endif 1302#endif
1303 reader->setFocus(); 1303 reader->setFocus();
1304} 1304}
1305 1305
1306void QTReaderApp::regClose() 1306void QTReaderApp::regClose()
1307{ 1307{
1308 regVisible = FALSE; 1308 regVisible = FALSE;
1309 regEdit->setText(""); 1309 regEdit->setText("");
1310 regBar->hide(); 1310 regBar->hide();
1311 reader->setFocus(); 1311 reader->setFocus();
1312} 1312}
1313 1313
1314#ifdef __ISEARCH 1314#ifdef __ISEARCH
1315bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) 1315bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg)
1316#else 1316#else
1317bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) 1317bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
1318#endif 1318#endif
1319{ 1319{
1320 bool ret = true; 1320 bool ret = true;
1321 size_t pos = reader->locate(); 1321 size_t pos = reader->locate();
1322 reader->buffdoc.getline(&test,reader->width()); 1322 reader->buffdoc.getline(&test,reader->width());
1323#ifdef __ISEARCH 1323#ifdef __ISEARCH
1324 while (strstr(test.data(),(const tchar*)arg) == NULL) 1324 while (strstr(test.data(),(const tchar*)arg) == NULL)
1325#else 1325#else
1326#ifdef _UNICODE 1326#ifdef _UNICODE
1327 while (arg.match(toQString(test.data())) == -1) 1327 while (arg.match(toQString(test.data())) == -1)
1328#else 1328#else
1329 while (arg.match(test.data()) == -1) 1329 while (arg.match(test.data()) == -1)
1330#endif 1330#endif
1331#endif 1331#endif
1332 { 1332 {
1333 pos = reader->locate(); 1333 pos = reader->locate();
1334 if (!reader->buffdoc.getline(&test,reader->width())) 1334 if (!reader->buffdoc.getline(&test,reader->width()))
1335 { 1335 {
1336 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) 1336 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
1337 pos = searchStart; 1337 pos = searchStart;
1338 else 1338 else
1339 pos = start; 1339 pos = start;
1340 ret = false; 1340 ret = false;
1341 findClose(); 1341 findClose();
1342 break; 1342 break;
1343 } 1343 }
1344 } 1344 }
1345 reader->locate(pos); 1345 reader->locate(pos);
1346 return ret; 1346 return ret;
1347} 1347}
1348 1348
1349#ifdef __ISEARCH 1349#ifdef __ISEARCH
1350void QTReaderApp::search(const QString & arg) 1350void QTReaderApp::search(const QString & arg)
1351{ 1351{
1352 searchrecord* ss = searchStack->top(); 1352 searchrecord* ss = searchStack->top();
1353 CBuffer test; 1353 CBuffer test;
1354 size_t start = reader->pagelocate(); 1354 size_t start = reader->pagelocate();
1355 bool haspopped = false; 1355 bool haspopped = false;
1356 while (arg.left(ss->s.length()) != ss->s) 1356 while (arg.left(ss->s.length()) != ss->s)
1357 { 1357 {
1358 haspopped = true; 1358 haspopped = true;
1359 start = ss->pos; 1359 start = ss->pos;
1360// reader->locate(start); 1360// reader->locate(start);
1361 searchStack->pop(); 1361 searchStack->pop();
1362 delete ss; 1362 delete ss;
1363 } 1363 }
1364 if (haspopped) reader->locate(start); 1364 if (haspopped) reader->locate(start);
1365/* 1365/*
1366 if (arg.length() < ss->len) 1366 if (arg.length() < ss->len)
1367 { 1367 {
1368 start = ss->pos; 1368 start = ss->pos;
1369 reader->locate(start); 1369 reader->locate(start);
1370 searchStack->pop(); 1370 searchStack->pop();
1371 delete ss; 1371 delete ss;
1372 } 1372 }
1373*/ 1373*/
1374 else 1374 else
1375 { 1375 {
1376 start = reader->pagelocate(); 1376 start = reader->pagelocate();
1377 reader->jumpto(start); 1377 reader->jumpto(start);
1378 searchStack->push(new searchrecord(arg,start)); 1378 searchStack->push(new searchrecord(arg,start));
1379 } 1379 }
1380 dosearch(start, test, arg); 1380 dosearch(start, test, arg);
1381} 1381}
1382#else 1382#else
1383void QTReaderApp::search() 1383void QTReaderApp::search()
1384{ 1384{
1385 findNext(); 1385 findNext();
1386} 1386}
1387#endif 1387#endif
1388 1388
1389void QTReaderApp::openFile( const QString &f ) 1389void QTReaderApp::openFile( const QString &f )
1390{ 1390{
1391 openFile(DocLnk(f)); 1391 openFile(DocLnk(f));
1392} 1392}
1393 1393
1394void QTReaderApp::openFile( const DocLnk &f ) 1394void QTReaderApp::openFile( const DocLnk &f )
1395{ 1395{
1396 clear(); 1396 clear();
1397 FileManager fm; 1397 FileManager fm;
1398 if ( fm.exists( f ) ) 1398 if ( fm.exists( f ) )
1399 { 1399 {
1400// QMessageBox::information(0, "Progress", "Calling fileNew()"); 1400// QMessageBox::information(0, "Progress", "Calling fileNew()");
1401 1401
1402 clear(); 1402 clear();
1403 1403
1404 // editorStack->raiseWidget( reader ); 1404 // editorStack->raiseWidget( reader );
1405 1405
1406 // reader->setFocus(); 1406 // reader->setFocus();
1407 1407
1408 // QMessageBox::information(0, "DocLnk", "Begin"); 1408 // QMessageBox::information(0, "DocLnk", "Begin");
1409 doc = new DocLnk(f); 1409 doc = new DocLnk(f);
1410 // QMessageBox::information(0, "DocLnk done", doc->file()); 1410 // QMessageBox::information(0, "DocLnk done", doc->file());
1411 // QMessageBox::information(0, "Progress", "Calling setText()"); 1411 // QMessageBox::information(0, "Progress", "Calling setText()");
1412 // QMessageBox::information(0, "Progress", "Textset"); 1412 // QMessageBox::information(0, "Progress", "Textset");
1413 1413
1414 // updateCaption(); 1414 // updateCaption();
1415 showEditTools(); 1415 showEditTools();
1416 reader->setText(doc->name(), doc->file()); 1416 reader->setText(doc->name(), doc->file());
1417 readbkmks(); 1417 readbkmks();
1418 } 1418 }
1419 else 1419 else
1420 { 1420 {
1421 QMessageBox::information(this, "OpieReader", "File does not exist"); 1421 QMessageBox::information(this, "OpieReader", "File does not exist");
1422 } 1422 }
1423 1423
1424} 1424}
1425 1425
1426void QTReaderApp::showEditTools() 1426void QTReaderApp::showEditTools()
1427{ 1427{
1428 if ( !doc ) 1428 if ( !doc )
1429 close(); 1429 close();
1430// fileSelector->hide(); 1430// fileSelector->hide();
1431//tjw menu->show(); 1431//tjw menu->show();
1432 editBar->show(); 1432 editBar->show();
1433 if ( searchVisible ) 1433 if ( searchVisible )
1434 searchBar->show(); 1434 searchBar->show();
1435 if ( regVisible ) 1435 if ( regVisible )
1436 regBar->show(); 1436 regBar->show();
1437 if (m_fontVisible) m_fontBar->show(); 1437 if (m_fontVisible) m_fontBar->show();
1438 1438
1439 updateCaption(); 1439 updateCaption();
1440 editorStack->raiseWidget( reader ); 1440 editorStack->raiseWidget( reader );
1441 reader->setFocus(); 1441 reader->setFocus();
1442} 1442}
1443/* 1443/*
1444void QTReaderApp::save() 1444void QTReaderApp::save()
1445{ 1445{
1446 if ( !doc ) 1446 if ( !doc )
1447 return; 1447 return;
1448 if ( !editor->edited() ) 1448 if ( !editor->edited() )
1449 return; 1449 return;
1450 1450
1451 QString rt = editor->text(); 1451 QString rt = editor->text();
1452 QString pt = rt; 1452 QString pt = rt;
1453 1453
1454 if ( doc->name().isEmpty() ) { 1454 if ( doc->name().isEmpty() ) {
1455 unsigned ispace = pt.find( ' ' ); 1455 unsigned ispace = pt.find( ' ' );
1456 unsigned ienter = pt.find( '\n' ); 1456 unsigned ienter = pt.find( '\n' );
1457 int i = (ispace < ienter) ? ispace : ienter; 1457 int i = (ispace < ienter) ? ispace : ienter;
1458 QString docname; 1458 QString docname;
1459 if ( i == -1 ) { 1459 if ( i == -1 ) {
1460 if ( pt.isEmpty() ) 1460 if ( pt.isEmpty() )
1461 docname = "Empty Text"; 1461 docname = "Empty Text";
1462 else 1462 else
1463 docname = pt; 1463 docname = pt;
1464 } else { 1464 } else {
1465 docname = pt.left( i ); 1465 docname = pt.left( i );
1466 } 1466 }
1467 doc->setName(docname); 1467 doc->setName(docname);
1468 } 1468 }
1469 FileManager fm; 1469 FileManager fm;
1470 fm.saveFile( *doc, rt ); 1470 fm.saveFile( *doc, rt );
1471} 1471}
1472*/ 1472*/
1473 1473
1474void QTReaderApp::clear() 1474void QTReaderApp::clear()
1475{ 1475{
1476 if (doc != 0) 1476 if (doc != 0)
1477 { 1477 {
1478// QMessageBox::information(this, "QTReader", "Deleting doc", 1); 1478// QMessageBox::information(this, "QTReader", "Deleting doc", 1);
1479 delete doc; 1479 delete doc;
1480// QMessageBox::information(this, "QTReader", "Deleted doc", 1); 1480// QMessageBox::information(this, "QTReader", "Deleted doc", 1);
1481 doc = 0; 1481 doc = 0;
1482 } 1482 }
1483 reader->clear(); 1483 reader->clear();
1484} 1484}
1485 1485
1486void QTReaderApp::updateCaption() 1486void QTReaderApp::updateCaption()
1487{ 1487{
1488 if ( !doc ) 1488 if ( !doc )
1489 setCaption( tr("OpieReader") ); 1489 setCaption( tr("OpieReader") );
1490 else { 1490 else {
1491 QString s = doc->name(); 1491 QString s = doc->name();
1492 if ( s.isEmpty() ) 1492 if ( s.isEmpty() )
1493 s = tr( "Unnamed" ); 1493 s = tr( "Unnamed" );
1494 setCaption( s + " - " + tr("OpieReader") ); 1494 setCaption( s + " - " + tr("OpieReader") );
1495 } 1495 }
1496} 1496}
1497 1497
1498void QTReaderApp::setDocument(const QString& fileref) 1498void QTReaderApp::setDocument(const QString& fileref)
1499{ 1499{
1500 bFromDocView = TRUE; 1500 bFromDocView = TRUE;
1501//QMessageBox::information(0, "setDocument", fileref); 1501//QMessageBox::information(0, "setDocument", fileref);
1502 openFile(DocLnk(fileref)); 1502 openFile(DocLnk(fileref));
1503// showEditTools(); 1503// showEditTools();
1504} 1504}
1505 1505
1506void QTReaderApp::closeEvent( QCloseEvent *e ) 1506void QTReaderApp::closeEvent( QCloseEvent *e )
1507{ 1507{
1508 if (m_dontSave) 1508 if (m_dontSave)
1509 { 1509 {
1510 e->accept(); 1510 e->accept();
1511 } 1511 }
1512 else 1512 else
1513 { 1513 {
1514 if (editorStack->visibleWidget() == reader) 1514 if (editorStack->visibleWidget() == reader)
1515 { 1515 {
1516 if (m_fontVisible) 1516 if (m_fontVisible)
1517 { 1517 {
1518 m_fontBar->hide(); 1518 m_fontBar->hide();
1519 m_fontVisible = false; 1519 m_fontVisible = false;
1520 } 1520 }
1521 if (regVisible) 1521 if (regVisible)
1522 { 1522 {
1523 regBar->hide(); 1523 regBar->hide();
1524 regVisible = false; 1524 regVisible = false;
1525 return; 1525 return;
1526 } 1526 }
1527 if (searchVisible) 1527 if (searchVisible)
1528 { 1528 {
1529 searchBar->hide(); 1529 searchBar->hide();
1530 searchVisible = false; 1530 searchVisible = false;
1531 return; 1531 return;
1532 } 1532 }
1533 if (m_fBkmksChanged && pBkmklist != NULL) 1533 if (m_fBkmksChanged && pBkmklist != NULL)
1534 { 1534 {
1535 if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0) 1535 if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0)
1536 savebkmks(); 1536 savebkmks();
1537 delete pBkmklist; 1537 delete pBkmklist;
1538 pBkmklist = NULL; 1538 pBkmklist = NULL;
1539 m_fBkmksChanged = false; 1539 m_fBkmksChanged = false;
1540 } 1540 }
1541 bFromDocView = FALSE; 1541 bFromDocView = FALSE;
1542 saveprefs(); 1542 saveprefs();
1543 e->accept(); 1543 e->accept();
1544 } 1544 }
1545 else 1545 else
1546 { 1546 {
1547 showEditTools(); 1547 showEditTools();
1548 } 1548 }
1549 } 1549 }
1550} 1550}
1551 1551
1552void QTReaderApp::do_gotomark() 1552void QTReaderApp::do_gotomark()
1553{ 1553{
1554 m_nRegAction = cGotoBkmk; 1554 m_nRegAction = cGotoBkmk;
1555 listbkmk(); 1555 listbkmk();
1556} 1556}
1557 1557
1558void QTReaderApp::do_delmark() 1558void QTReaderApp::do_delmark()
1559{ 1559{
1560 m_nRegAction = cDelBkmk; 1560 m_nRegAction = cDelBkmk;
1561 listbkmk(); 1561 listbkmk();
1562} 1562}
1563 1563
1564void QTReaderApp::listbkmk() 1564void QTReaderApp::listbkmk()
1565{ 1565{
1566 bkmkselector->clear(); 1566 bkmkselector->clear();
1567 int cnt = 0; 1567 int cnt = 0;
1568 if (pBkmklist != NULL) 1568 if (pBkmklist != NULL)
1569 { 1569 {
1570 for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++) 1570 for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++)
1571 { 1571 {
1572#ifdef _UNICODE 1572#ifdef _UNICODE
1573 bkmkselector->insertItem(toQString(i->name())); 1573 bkmkselector->insertItem(toQString(i->name()));
1574#else 1574#else
1575 bkmkselector->insertItem(i->name()); 1575 bkmkselector->insertItem(i->name());
1576#endif 1576#endif
1577 cnt++; 1577 cnt++;
1578 } 1578 }
1579 } 1579 }
1580 if (cnt > 0) 1580 if (cnt > 0)
1581 { 1581 {
1582//tjw menu->hide(); 1582//tjw menu->hide();
1583 editBar->hide(); 1583 editBar->hide();
1584 if (m_fontVisible) m_fontBar->hide(); 1584 if (m_fontVisible) m_fontBar->hide();
1585 if (regVisible) regBar->hide(); 1585 if (regVisible) regBar->hide();
1586 if (searchVisible) searchBar->hide(); 1586 if (searchVisible) searchBar->hide();
1587 editorStack->raiseWidget( bkmkselector ); 1587 editorStack->raiseWidget( bkmkselector );
1588 } 1588 }
1589 else 1589 else
1590 QMessageBox::information(this, "OpieReader", "No bookmarks in memory"); 1590 QMessageBox::information(this, "OpieReader", "No bookmarks in memory");
1591} 1591}
1592 1592
1593void QTReaderApp::do_autogen() 1593void QTReaderApp::do_autogen()
1594{ 1594{
1595 m_nRegAction = cAutoGen; 1595 m_nRegAction = cAutoGen;
1596 regEdit->setText(m_autogenstr); 1596 regEdit->setText(m_autogenstr);
1597 do_regedit(); 1597 do_regedit();
1598} 1598}
1599 1599
1600void QTReaderApp::do_regedit() 1600void QTReaderApp::do_regedit()
1601{ 1601{
1602// editBar->hide(); 1602// editBar->hide();
1603 regBar->show(); 1603 regBar->show();
1604 regVisible = true; 1604 regVisible = true;
1605 regEdit->setFocus(); 1605 regEdit->setFocus();
1606} 1606}
1607 1607
1608void QTReaderApp::gotobkmk(int ind) 1608void QTReaderApp::gotobkmk(int ind)
1609{ 1609{
1610 switch (m_nRegAction) 1610 switch (m_nRegAction)
1611 { 1611 {
1612 case cGotoBkmk: 1612 case cGotoBkmk:
1613 reader->locate((*pBkmklist)[ind]->value()); 1613 reader->locate((*pBkmklist)[ind]->value());
1614 break; 1614 break;
1615 case cDelBkmk: 1615 case cDelBkmk:
1616// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); 1616// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name());
1617 pBkmklist->erase(ind); 1617 pBkmklist->erase(ind);
1618 m_fBkmksChanged = true; 1618 m_fBkmksChanged = true;
1619// pBkmklist->sort(); 1619// pBkmklist->sort();
1620 break; 1620 break;
1621 case cRmBkmkFile: 1621 case cRmBkmkFile:
1622 unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind))); 1622 unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind)));
1623 break; 1623 break;
1624 } 1624 }
1625 showEditTools(); 1625 showEditTools();
1626} 1626}
1627 1627
1628void QTReaderApp::cancelbkmk() 1628void QTReaderApp::cancelbkmk()
1629{ 1629{
1630 showEditTools(); 1630 showEditTools();
1631} 1631}
1632 1632
1633void QTReaderApp::jump() 1633void QTReaderApp::jump()
1634{ 1634{
1635 m_nRegAction = cJump; 1635 m_nRegAction = cJump;
1636 char lcn[20]; 1636 char lcn[20];
1637 sprintf(lcn, "%lu", reader->pagelocate()); 1637 sprintf(lcn, "%lu", reader->pagelocate());
1638 regEdit->setText(lcn); 1638 regEdit->setText(lcn);
1639 do_regedit(); 1639 do_regedit();
1640} 1640}
1641 1641
1642void QTReaderApp::do_jump(const QString& lcn) 1642void QTReaderApp::do_jump(const QString& lcn)
1643{ 1643{
1644 bool ok; 1644 bool ok;
1645 unsigned long ulcn = lcn.toULong(&ok); 1645 unsigned long ulcn = lcn.toULong(&ok);
1646 if (ok) 1646 if (ok)
1647 reader->locate(ulcn); 1647 reader->locate(ulcn);
1648 else 1648 else
1649 QMessageBox::information(this, "OpieReader", "Must be a number"); 1649 QMessageBox::information(this, "OpieReader", "Must be a number");
1650} 1650}
1651 1651
1652void QTReaderApp::do_regaction() 1652void QTReaderApp::do_regaction()
1653{ 1653{
1654 regBar->hide(); 1654 regBar->hide();
1655 regVisible = false; 1655 regVisible = false;
1656 switch(m_nRegAction) 1656 switch(m_nRegAction)
1657 { 1657 {
1658 case cAutoGen: 1658 case cAutoGen:
1659 do_autogen(regEdit->text()); 1659 do_autogen(regEdit->text());
1660 break; 1660 break;
1661 case cAddBkmk: 1661 case cAddBkmk:
1662 do_addbkmk(regEdit->text()); 1662 do_addbkmk(regEdit->text());
1663 break; 1663 break;
1664 case cJump: 1664 case cJump:
1665 do_jump(regEdit->text()); 1665 do_jump(regEdit->text());
1666 break; 1666 break;
1667 case cMonoSpace: 1667 case cMonoSpace:
1668 do_mono(regEdit->text()); 1668 do_mono(regEdit->text());
1669 break; 1669 break;
1670 case cOverlap: 1670 case cOverlap:
1671 do_overlap(regEdit->text()); 1671 do_overlap(regEdit->text());
1672 break; 1672 break;
1673 case cSetTarget: 1673 case cSetTarget:
1674 do_settarget(regEdit->text()); 1674 do_settarget(regEdit->text());
1675 break; 1675 break;
1676 } 1676 }
1677 reader->restore(); 1677 reader->restore();
1678// editBar->show(); 1678// editBar->show();
1679 reader->setFocus(); 1679 reader->setFocus();
1680} 1680}
1681 1681
1682void QTReaderApp::do_settarget(const QString& _txt) 1682void QTReaderApp::do_settarget(const QString& _txt)
1683{ 1683{
1684 int ind = _txt.find('/'); 1684 int ind = _txt.find('/');
1685 if (ind == -1) 1685 if (ind == -1)
1686 { 1686 {
1687 m_targetapp = ""; 1687 m_targetapp = "";
1688 m_targetmsg = ""; 1688 m_targetmsg = "";
1689 QMessageBox::information(this, "OpieReader", "Format is\nappname/messagename"); 1689 QMessageBox::information(this, "OpieReader", "Format is\nappname/messagename");
1690 } 1690 }
1691 else 1691 else
1692 { 1692 {
1693 m_targetapp = _txt.left(ind); 1693 m_targetapp = _txt.left(ind);
1694 m_targetmsg = _txt.right(_txt.length()-ind-1); 1694 m_targetmsg = _txt.right(_txt.length()-ind-1);
1695 } 1695 }
1696} 1696}
1697 1697
1698void QTReaderApp::setfont() 1698void QTReaderApp::setfont()
1699{ 1699{
1700 for (int i = 1; i <= m_fontSelector->count(); i++) 1700 for (int i = 1; i <= m_fontSelector->count(); i++)
1701 { 1701 {
1702 if (m_fontSelector->text(i) == reader->m_fontname) 1702 if (m_fontSelector->text(i) == reader->m_fontname)
1703 { 1703 {
1704 m_fontSelector->setCurrentItem(i); 1704 m_fontSelector->setCurrentItem(i);
1705 break; 1705 break;
1706 } 1706 }
1707 } 1707 }
1708 m_fontBar->show(); 1708 m_fontBar->show();
1709 m_fontVisible = true; 1709 m_fontVisible = true;
1710} 1710}
1711 1711
1712void QTReaderApp::setfontHelper(const QString& lcn, int size = 0) 1712void QTReaderApp::setfontHelper(const QString& lcn, int size)
1713{ 1713{
1714 if (size == 0) size = reader->m_fontControl.currentsize(); 1714 if (size == 0) size = reader->m_fontControl.currentsize();
1715 QFont f(lcn, 10 /*, QFont::Bold*/); 1715 QFont f(lcn, 10 /*, QFont::Bold*/);
1716 bkmkselector->setFont( f ); 1716 bkmkselector->setFont( f );
1717 regEdit->setFont( f ); 1717 regEdit->setFont( f );
1718 searchEdit->setFont( f ); 1718 searchEdit->setFont( f );
1719 m_annoWin->setFont( f ); 1719 m_annoWin->setFont( f );
1720 reader->m_fontname = lcn; 1720 reader->m_fontname = lcn;
1721 if (!reader->ChangeFont(size)) 1721 if (!reader->ChangeFont(size))
1722 { 1722 {
1723 reader->ChangeFont(size); 1723 reader->ChangeFont(size);
1724 } 1724 }
1725 reader->refresh(); 1725 reader->refresh();
1726 m_fontBar->hide(); 1726 m_fontBar->hide();
1727 m_fontVisible = false; 1727 m_fontVisible = false;
1728 showEditTools(); 1728 showEditTools();
1729} 1729}
1730 1730
1731void QTReaderApp::do_setfont(const QString& lcn) 1731void QTReaderApp::do_setfont(const QString& lcn)
1732{ 1732{
1733 setfontHelper(lcn); 1733 setfontHelper(lcn);
1734} 1734}
1735 1735
1736void QTReaderApp::do_autogen(const QString& regText) 1736void QTReaderApp::do_autogen(const QString& regText)
1737{ 1737{
1738 unsigned long fs, ts; 1738 unsigned long fs, ts;
1739 reader->sizes(fs,ts); 1739 reader->sizes(fs,ts);
1740 // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); 1740 // qDebug("Reg:%s\n", (const tchar*)(regEdit->text()));
1741 m_autogenstr = regText; 1741 m_autogenstr = regText;
1742 QRegExp re(regText); 1742 QRegExp re(regText);
1743 CBuffer buff; 1743 CBuffer buff;
1744 if (pBkmklist != NULL) delete pBkmklist; 1744 if (pBkmklist != NULL) delete pBkmklist;
1745 pBkmklist = new CList<Bkmk>; 1745 pBkmklist = new CList<Bkmk>;
1746 m_fBkmksChanged = true; 1746 m_fBkmksChanged = true;
1747 pbar->show(); 1747 pbar->show();
1748pbar->resize(width(), editBar->height()); 1748pbar->resize(width(), editBar->height());
1749 pbar->reset(); 1749 pbar->reset();
1750 qApp->processEvents(); 1750 qApp->processEvents();
1751 reader->setFocus(); 1751 reader->setFocus();
1752 reader->jumpto(0); 1752 reader->jumpto(0);
1753 int lastpc = 0; 1753 int lastpc = 0;
1754 int i = 0; 1754 int i = 0;
1755 while (i >= 0) 1755 while (i >= 0)
1756 { 1756 {
1757 unsigned int lcn = reader->locate(); 1757 unsigned int lcn = reader->locate();
1758 int pc = (100*lcn)/ts; 1758 int pc = (100*lcn)/ts;
1759 if (pc != lastpc) 1759 if (pc != lastpc)
1760 { 1760 {
1761 pbar->setProgress(pc); 1761 pbar->setProgress(pc);
1762 qApp->processEvents(); 1762 qApp->processEvents();
1763 if (reader->locate() != lcn) reader->jumpto(lcn); 1763 if (reader->locate() != lcn) reader->jumpto(lcn);
1764 reader->setFocus(); 1764 reader->setFocus();
1765 lastpc = pc; 1765 lastpc = pc;
1766 } 1766 }
1767 i = reader->buffdoc.getpara(buff); 1767 i = reader->buffdoc.getpara(buff);
1768#ifdef _UNICODE 1768#ifdef _UNICODE
1769 if (re.match(toQString(buff.data())) != -1) 1769 if (re.match(toQString(buff.data())) != -1)
1770#else 1770#else
1771 if (re.match(buff.data()) != -1) 1771 if (re.match(buff.data()) != -1)
1772#endif 1772#endif
1773 pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); 1773 pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn));
1774 } 1774 }
1775 pBkmklist->sort(); 1775 pBkmklist->sort();
1776 pbar->setProgress(100); 1776 pbar->setProgress(100);
1777 qApp->processEvents(); 1777 qApp->processEvents();
1778 pbar->hide(); 1778 pbar->hide();
1779} 1779}
1780 1780
1781void QTReaderApp::saveprefs() 1781void QTReaderApp::saveprefs()
1782{ 1782{
1783// reader->saveprefs("uqtreader"); 1783// reader->saveprefs("uqtreader");
1784 Config config( "uqtreader" ); 1784 Config config( "uqtreader" );
1785 config.setGroup( "View" ); 1785 config.setGroup( "View" );
1786 1786
1787 reader->m_lastposn = reader->pagelocate(); 1787 reader->m_lastposn = reader->pagelocate();
1788 1788
1789 config.writeEntry( "StripCr", reader->bstripcr ); 1789 config.writeEntry( "StripCr", reader->bstripcr );
1790 config.writeEntry( "AutoFmt", reader->bautofmt ); 1790 config.writeEntry( "AutoFmt", reader->bautofmt );
1791 config.writeEntry( "TextFmt", reader->btextfmt ); 1791 config.writeEntry( "TextFmt", reader->btextfmt );
1792 config.writeEntry( "StripHtml", reader->bstriphtml ); 1792 config.writeEntry( "StripHtml", reader->bstriphtml );
1793 config.writeEntry( "Dehyphen", reader->bdehyphen ); 1793 config.writeEntry( "Dehyphen", reader->bdehyphen );
1794 config.writeEntry( "Unindent", reader->bunindent ); 1794 config.writeEntry( "Unindent", reader->bunindent );
1795 config.writeEntry( "Repara", reader->brepara ); 1795 config.writeEntry( "Repara", reader->brepara );
1796 config.writeEntry( "DoubleSpace", reader->bdblspce ); 1796 config.writeEntry( "DoubleSpace", reader->bdblspce );
1797 config.writeEntry( "Indent", reader->bindenter ); 1797 config.writeEntry( "Indent", reader->bindenter );
1798 config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); 1798 config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) );
1799 config.writeEntry( "ScrollDelay", reader->m_delay); 1799 config.writeEntry( "ScrollDelay", reader->m_delay);
1800 config.writeEntry( "LastFile", reader->m_lastfile ); 1800 config.writeEntry( "LastFile", reader->m_lastfile );
1801 config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); 1801 config.writeEntry( "LastPosn", (int)(reader->pagelocate()) );
1802 config.writeEntry( "PageMode", reader->m_bpagemode ); 1802 config.writeEntry( "PageMode", reader->m_bpagemode );
1803 config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); 1803 config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced );
1804 config.writeEntry( "Fontname", reader->m_fontname ); 1804 config.writeEntry( "Fontname", reader->m_fontname );
1805 config.writeEntry( "Encoding", reader->m_encd ); 1805 config.writeEntry( "Encoding", reader->m_encd );
1806 config.writeEntry( "CharSpacing", reader->m_charpc ); 1806 config.writeEntry( "CharSpacing", reader->m_charpc );
1807 config.writeEntry( "Overlap", (int)(reader->m_overlap) ); 1807 config.writeEntry( "Overlap", (int)(reader->m_overlap) );
1808 config.writeEntry( "TargetApp", m_targetapp ); 1808 config.writeEntry( "TargetApp", m_targetapp );
1809 config.writeEntry( "TargetMsg", m_targetmsg ); 1809 config.writeEntry( "TargetMsg", m_targetmsg );
1810 config.writeEntry( "TwoTouch", m_twoTouch ); 1810 config.writeEntry( "TwoTouch", m_twoTouch );
1811 config.writeEntry( "Annotation", m_doAnnotation); 1811 config.writeEntry( "Annotation", m_doAnnotation);
1812 config.writeEntry( "Dictionary", m_doDictionary); 1812 config.writeEntry( "Dictionary", m_doDictionary);
1813 config.writeEntry( "Clipboard", m_doClipboard); 1813 config.writeEntry( "Clipboard", m_doClipboard);
1814 config.writeEntry( "SpaceTarget", m_spaceTarget); 1814 config.writeEntry( "SpaceTarget", m_spaceTarget);
1815 config.writeEntry( "Remap", reader->bremap ); 1815 config.writeEntry( "Remap", reader->bremap );
1816 config.writeEntry( "Peanut", reader->bpeanut ); 1816 config.writeEntry( "Peanut", reader->bpeanut );
1817 config.writeEntry( "MakeBold", reader->bmakebold ); 1817 config.writeEntry( "MakeBold", reader->bmakebold );
1818} 1818}
1819 1819
1820void QTReaderApp::indentplus() 1820void QTReaderApp::indentplus()
1821{ 1821{
1822 reader->indentplus(); 1822 reader->indentplus();
1823} 1823}
1824 1824
1825void QTReaderApp::indentminus() 1825void QTReaderApp::indentminus()
1826{ 1826{
1827 reader->indentminus(); 1827 reader->indentminus();
1828} 1828}
1829 1829
1830/* 1830/*
1831void QTReaderApp::oldFile() 1831void QTReaderApp::oldFile()
1832{ 1832{
1833 qDebug("oldFile called"); 1833 qDebug("oldFile called");
1834 reader->setText(true); 1834 reader->setText(true);
1835 qDebug("settext called"); 1835 qDebug("settext called");
1836 showEditTools(); 1836 showEditTools();
1837 qDebug("showedit called"); 1837 qDebug("showedit called");
1838} 1838}
1839*/ 1839*/
1840 1840
1841/* 1841/*
1842void info_cb(Fl_Widget* o, void* _data) 1842void info_cb(Fl_Widget* o, void* _data)
1843{ 1843{
1844 1844
1845 if (infowin == NULL) 1845 if (infowin == NULL)
1846 { 1846 {
1847 1847
1848 infowin = new Fl_Window(160,240); 1848 infowin = new Fl_Window(160,240);
1849 filename = new Fl_Output(45,5,110,14,"Filename"); 1849 filename = new Fl_Output(45,5,110,14,"Filename");
1850 filesize = new Fl_Output(45,25,110,14,"Filesize"); 1850 filesize = new Fl_Output(45,25,110,14,"Filesize");
1851 textsize = new Fl_Output(45,45,110,14,"Textsize"); 1851 textsize = new Fl_Output(45,45,110,14,"Textsize");
1852 comprat = new CBar(45,65,110,14,"Ratio %"); 1852 comprat = new CBar(45,65,110,14,"Ratio %");
1853 posn = new Fl_Output(45,85,110,14,"Location"); 1853 posn = new Fl_Output(45,85,110,14,"Location");
1854 frcn = new CBar(45,105,110,14,"% Read"); 1854 frcn = new CBar(45,105,110,14,"% Read");
1855 about = new Fl_Multiline_Output(5,125,150,90); 1855 about = new Fl_Multiline_Output(5,125,150,90);
1856 about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); 1856 about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files");
1857 Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); 1857 Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay");
1858 infowin->set_modal(); 1858 infowin->set_modal();
1859 } 1859 }
1860 if (((reader_ui *)_data)->g_filename[0] != '\0') 1860 if (((reader_ui *)_data)->g_filename[0] != '\0')
1861 { 1861 {
1862 unsigned long fs,ts; 1862 unsigned long fs,ts;
1863 tchar sz[20]; 1863 tchar sz[20];
1864 ((reader_ui *)_data)->input->sizes(fs,ts); 1864 ((reader_ui *)_data)->input->sizes(fs,ts);
1865 unsigned long pl = ((reader_ui *)_data)->input->locate(); 1865 unsigned long pl = ((reader_ui *)_data)->input->locate();
1866 1866
1867 filename->value(((reader_ui *)_data)->g_filename); 1867 filename->value(((reader_ui *)_data)->g_filename);
1868 1868
1869 sprintf(sz,"%u",fs); 1869 sprintf(sz,"%u",fs);
1870 filesize->value(sz); 1870 filesize->value(sz);
1871 1871
1872 sprintf(sz,"%u",ts); 1872 sprintf(sz,"%u",ts);
1873 textsize->value(sz); 1873 textsize->value(sz);
1874 1874
1875 comprat->value(100-(100*fs + (ts >> 1))/ts); 1875 comprat->value(100-(100*fs + (ts >> 1))/ts);
1876 1876
1877 sprintf(sz,"%u",pl); 1877 sprintf(sz,"%u",pl);
1878 posn->value(sz); 1878 posn->value(sz);
1879 1879
1880 frcn->value((100*pl + (ts >> 1))/ts); 1880 frcn->value((100*pl + (ts >> 1))/ts);
1881 } 1881 }
1882 infowin->show(); 1882 infowin->show();
1883} 1883}
1884*/ 1884*/
1885 1885
1886void QTReaderApp::savebkmks() 1886void QTReaderApp::savebkmks()
1887{ 1887{
1888 if (pBkmklist != NULL) 1888 if (pBkmklist != NULL)
1889 { 1889 {
1890 BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string), true); 1890 BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string), true);
1891 bf.write(*pBkmklist); 1891 bf.write(*pBkmklist);
1892 } 1892 }
1893 m_fBkmksChanged = false; 1893 m_fBkmksChanged = false;
1894} 1894}
1895 1895
1896void QTReaderApp::readbkmks() 1896void QTReaderApp::readbkmks()
1897{ 1897{
1898 if (pBkmklist != NULL) 1898 if (pBkmklist != NULL)
1899 { 1899 {
1900 delete pBkmklist; 1900 delete pBkmklist;
1901 } 1901 }
1902 BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string)); 1902 BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string));
1903 pBkmklist = bf.readall(); 1903 pBkmklist = bf.readall();
1904 m_fBkmksChanged = bf.upgraded(); 1904 m_fBkmksChanged = bf.upgraded();
1905 if (pBkmklist == NULL) 1905 if (pBkmklist == NULL)
1906 { 1906 {
1907 pBkmklist = reader->getbkmklist(); 1907 pBkmklist = reader->getbkmklist();
1908 } 1908 }
1909 if (pBkmklist != NULL) 1909 if (pBkmklist != NULL)
1910 pBkmklist->sort(); 1910 pBkmklist->sort();
1911} 1911}
1912 1912
1913void QTReaderApp::addbkmk() 1913void QTReaderApp::addbkmk()
1914{ 1914{
1915 m_nRegAction = cAddBkmk; 1915 m_nRegAction = cAddBkmk;
1916 regEdit->setText(reader->firstword()); 1916 regEdit->setText(reader->firstword());
1917 do_regedit(); 1917 do_regedit();
1918} 1918}
1919 1919
1920void QTReaderApp::do_addbkmk(const QString& text) 1920void QTReaderApp::do_addbkmk(const QString& text)
1921{ 1921{
1922 if (text.isEmpty()) 1922 if (text.isEmpty())
1923 { 1923 {
1924 QMessageBox::information(this, "OpieReader", "Need a name for the bookmark\nSelect add again", 1); 1924 QMessageBox::information(this, "OpieReader", "Need a name for the bookmark\nSelect add again", 1);
1925 } 1925 }
1926 else 1926 else
1927 { 1927 {
1928 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; 1928 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>;
1929#ifdef _UNICODE 1929#ifdef _UNICODE
1930 CBuffer buff; 1930 CBuffer buff;
1931 int i = 0; 1931 int i = 0;
1932 for (i = 0; i < text.length(); i++) 1932 for (i = 0; i < text.length(); i++)
1933 { 1933 {
1934 buff[i] = text[i].unicode(); 1934 buff[i] = text[i].unicode();
1935 } 1935 }
1936 buff[i] = 0; 1936 buff[i] = 0;
1937 pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); 1937 pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate()));
1938#else 1938#else
1939 pBkmklist->push_front(Bkmk((const tchar*)text,reader->pagelocate())); 1939 pBkmklist->push_front(Bkmk((const tchar*)text,reader->pagelocate()));
1940#endif 1940#endif
1941 m_fBkmksChanged = true; 1941 m_fBkmksChanged = true;
1942 pBkmklist->sort(); 1942 pBkmklist->sort();
1943 } 1943 }
1944} 1944}
1945 1945
1946void QTReaderApp::OnRedraw() 1946void QTReaderApp::OnRedraw()
1947{ 1947{
1948 if (pBkmklist != NULL) 1948 if (pBkmklist != NULL)
1949 { 1949 {
1950 bool found = findNextBookmark(reader->pagelocate()); 1950 bool found = findNextBookmark(reader->pagelocate());
1951 m_bkmkAvail->setEnabled(found); 1951 m_bkmkAvail->setEnabled(found);
1952 } 1952 }
1953} 1953}
1954 1954
1955void QTReaderApp::showAnnotation() 1955void QTReaderApp::showAnnotation()
1956{ 1956{
1957 m_annoWin->setName(toQString(m_anno->name())); 1957 m_annoWin->setName(toQString(m_anno->name()));
1958 m_annoWin->setAnno(toQString(m_anno->anno())); 1958 m_annoWin->setAnno(toQString(m_anno->anno()));
1959 m_annoIsEditing = false; 1959 m_annoIsEditing = false;
1960 editorStack->raiseWidget( m_annoWin ); 1960 editorStack->raiseWidget( m_annoWin );
1961 m_annoWin->setFocus(); 1961 m_annoWin->setFocus();
1962} 1962}
1963 1963
1964void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) 1964void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line)
1965{ 1965{
1966// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); 1966// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd);
1967 1967
1968 if (m_doClipboard) 1968 if (m_doClipboard)
1969 { 1969 {
1970 QClipboard* cb = QApplication::clipboard(); 1970 QClipboard* cb = QApplication::clipboard();
1971 cb->setText(wrd); 1971 cb->setText(wrd);
1972 if (wrd.length() > 10) 1972 if (wrd.length() > 10)
1973 { 1973 {
1974 Global::statusMessage(wrd.left(8) + ".."); 1974 Global::statusMessage(wrd.left(8) + "..");
1975 } 1975 }
1976 else 1976 else
1977 { 1977 {
1978 Global::statusMessage(wrd); 1978 Global::statusMessage(wrd);
1979 } 1979 }
1980 } 1980 }
1981 if (m_doAnnotation) 1981 if (m_doAnnotation)
1982 { 1982 {
1983// addAnno(wrd, "Need to be able to edit this", posn); 1983// addAnno(wrd, "Need to be able to edit this", posn);
1984 m_annoWin->setName(line); 1984 m_annoWin->setName(line);
1985 m_annoWin->setAnno(""); 1985 m_annoWin->setAnno("");
1986 m_annoWin->setPosn(posn); 1986 m_annoWin->setPosn(posn);
1987 m_annoIsEditing = true; 1987 m_annoIsEditing = true;
1988 editorStack->raiseWidget( m_annoWin ); 1988 editorStack->raiseWidget( m_annoWin );
1989 } 1989 }
1990 if (m_doDictionary) 1990 if (m_doDictionary)
1991 { 1991 {
1992 if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) 1992 if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty())
1993 { 1993 {
1994 QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); 1994 QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8());
1995 e << wrd; 1995 e << wrd;
1996 } 1996 }
1997 } 1997 }
1998} 1998}
1999 1999
2000void QTReaderApp::OnActionPressed() 2000void QTReaderApp::OnActionPressed()
2001{ 2001{
2002 switch (m_spaceTarget) 2002 switch (m_spaceTarget)
2003 { 2003 {
2004 case cesOpenFile: 2004 case cesOpenFile:
2005 { 2005 {
2006 fileOpen(); 2006 fileOpen();
2007 } 2007 }
2008 break; 2008 break;
2009 case cesAutoScroll: 2009 case cesAutoScroll:
2010 { 2010 {
2011 reader->setautoscroll(!reader->m_autoScroll); 2011 reader->setautoscroll(!reader->m_autoScroll);
2012 setScrollState(reader->m_autoScroll); 2012 setScrollState(reader->m_autoScroll);
2013 } 2013 }
2014 break; 2014 break;
2015 case cesActionMark: 2015 case cesActionMark:
2016 { 2016 {
2017 addbkmk(); 2017 addbkmk();
2018 } 2018 }
2019 break; 2019 break;
2020 default: 2020 default:
2021 { 2021 {
2022 qDebug("Unknown ActionType:%u", m_spaceTarget); 2022 qDebug("Unknown ActionType:%u", m_spaceTarget);
2023 } 2023 }
2024 break; 2024 break;
2025 } 2025 }
2026} 2026}
2027 2027
2028void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } 2028void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); }
2029void QTReaderApp::restoreFocus() { reader->setFocus(); } 2029void QTReaderApp::restoreFocus() { reader->setFocus(); }
diff --git a/noncore/apps/opie-reader/infowin.cpp b/noncore/apps/opie-reader/infowin.cpp
index 9637a62..7b8f280 100644
--- a/noncore/apps/opie-reader/infowin.cpp
+++ b/noncore/apps/opie-reader/infowin.cpp
@@ -1,42 +1,42 @@
1#include "infowin.h" 1#include "infowin.h"
2#include "version.h" 2#include "version.h"
3#include <stdio.h> 3#include <stdio.h>
4 4
5infowin::infowin( QWidget *parent=0, const char *name=0, WFlags f = 0) : 5infowin::infowin( QWidget *parent, const char *name, WFlags f) :
6 QWidget(parent, name, f) 6 QWidget(parent, name, f)
7{ 7{
8 grid = new QGridLayout(this, 6, 2); 8 grid = new QGridLayout(this, 6, 2);
9 QLabel* l; 9 QLabel* l;
10 l = new QLabel("Compressed file size", this); 10 l = new QLabel("Compressed file size", this);
11 grid->addWidget(l, 0, 0); 11 grid->addWidget(l, 0, 0);
12 fileSize = new QLabel("0", this); 12 fileSize = new QLabel("0", this);
13 fileSize->setAlignment( AlignVCenter | AlignRight ); 13 fileSize->setAlignment( AlignVCenter | AlignRight );
14 grid->addWidget(fileSize, 0, 1); 14 grid->addWidget(fileSize, 0, 1);
15 l = new QLabel("Original text size", this); 15 l = new QLabel("Original text size", this);
16 grid->addWidget(l, 1, 0); 16 grid->addWidget(l, 1, 0);
17 textSize = new QLabel("0", this); 17 textSize = new QLabel("0", this);
18 textSize->setAlignment( AlignVCenter | AlignRight ); 18 textSize->setAlignment( AlignVCenter | AlignRight );
19 grid->addWidget(textSize, 1, 1); 19 grid->addWidget(textSize, 1, 1);
20 l = new QLabel("Compression Ratio", this); 20 l = new QLabel("Compression Ratio", this);
21 grid->addWidget(l, 2, 0); 21 grid->addWidget(l, 2, 0);
22 ratio = new QLabel("0", this); 22 ratio = new QLabel("0", this);
23 grid->addWidget(ratio, 2, 1); 23 grid->addWidget(ratio, 2, 1);
24 ratio->setAlignment( AlignVCenter | AlignRight ); 24 ratio->setAlignment( AlignVCenter | AlignRight );
25 l = new QLabel("Current location", this); 25 l = new QLabel("Current location", this);
26 grid->addWidget(l, 3, 0); 26 grid->addWidget(l, 3, 0);
27 location = new QLabel("0", this); 27 location = new QLabel("0", this);
28 location->setAlignment( AlignVCenter | AlignRight ); 28 location->setAlignment( AlignVCenter | AlignRight );
29 grid->addWidget(location, 3, 1); 29 grid->addWidget(location, 3, 1);
30 l = new QLabel("Per centage read", this); 30 l = new QLabel("Per centage read", this);
31 grid->addWidget(l, 4, 0); 31 grid->addWidget(l, 4, 0);
32 read = new QLabel("0", this); 32 read = new QLabel("0", this);
33 read->setAlignment( AlignVCenter | AlignRight ); 33 read->setAlignment( AlignVCenter | AlignRight );
34 grid->addWidget(read, 4, 1); 34 grid->addWidget(read, 4, 1);
35 char vstr[128]; 35 char vstr[128];
36 sprintf(vstr, "QT Reader v%u.%u%c (%s)\nA small e-text reader", MAJOR, BKMKTYPE, MINOR, RELEASE_TYPE); 36 sprintf(vstr, "QT Reader v%u.%u%c (%s)\nA small e-text reader", MAJOR, BKMKTYPE, MINOR, RELEASE_TYPE);
37 l = new QLabel(vstr, this); 37 l = new QLabel(vstr, this);
38 grid->addWidget(l, 5, 0); 38 grid->addWidget(l, 5, 0);
39 QPushButton* exitbutton = new QPushButton("Cancel", this); 39 QPushButton* exitbutton = new QPushButton("Cancel", this);
40 connect( exitbutton, SIGNAL( released() ), this, SLOT( infoClose() ) ); 40 connect( exitbutton, SIGNAL( released() ), this, SLOT( infoClose() ) );
41 grid->addWidget(exitbutton, 5, 1); 41 grid->addWidget(exitbutton, 5, 1);
42} 42}