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,1109 +1,1109 @@
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 }
551*/ 551*/
552 if (numlines > 0) 552 if (numlines > 0)
553 { 553 {
554 int ypos = textarray[0]->ascent(); 554 int ypos = textarray[0]->ascent();
555 textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); 555 textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width());
556 for (int i = 1; i < numlines; i++) 556 for (int i = 1; i < numlines; i++)
557 { 557 {
558 ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; 558 ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2;
559 textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); 559 textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width());
560 560
561 } 561 }
562// mylastpos = locate(); 562// mylastpos = locate();
563 } 563 }
564 } 564 }
565 m_scrolldy1 = m_scrolldy2 = 0; 565 m_scrolldy1 = m_scrolldy2 = 0;
566 emit OnRedraw(); 566 emit OnRedraw();
567} 567}
568 568
569QString QTReader::firstword() 569QString QTReader::firstword()
570{ 570{
571 if (m_bMonoSpaced) 571 if (m_bMonoSpaced)
572 { 572 {
573 return toQString(textarray[0]->data()); 573 return toQString(textarray[0]->data());
574 } 574 }
575 else 575 else
576 { 576 {
577 int start, end, len, j; 577 int start, end, len, j;
578 for (j = 0; j < numlines; j++) 578 for (j = 0; j < numlines; j++)
579 { 579 {
580 len = textarray[j]->length(); 580 len = textarray[j]->length();
581 for (start = 0; start < len && !isalpha((*textarray[j])[start]); start++); 581 for (start = 0; start < len && !isalpha((*textarray[j])[start]); start++);
582 if (start < len) break; 582 if (start < len) break;
583 } 583 }
584 if (j < numlines) 584 if (j < numlines)
585 { 585 {
586 QString ret = ""; 586 QString ret = "";
587 for (end = start; end < len && isalpha((*textarray[j])[end]); end++) 587 for (end = start; end < len && isalpha((*textarray[j])[end]); end++)
588 ret += (*textarray[j])[end]; 588 ret += (*textarray[j])[end];
589 if (ret.isEmpty()) ret = "Current position"; 589 if (ret.isEmpty()) ret = "Current position";
590 return ret; 590 return ret;
591 } 591 }
592 else 592 else
593 return "Current position"; 593 return "Current position";
594 } 594 }
595} 595}
596 596
597// 597//
598// Construct the QTReader with buttons. 598// Construct the QTReader with buttons.
599// 599//
600 600
601bool QTReader::ChangeFont(int tgt) 601bool QTReader::ChangeFont(int tgt)
602{ 602{
603 return m_fontControl.ChangeFont(m_fontname, tgt); 603 return m_fontControl.ChangeFont(m_fontname, tgt);
604} 604}
605 605
606void QTReader::init() 606void QTReader::init()
607{ 607{
608 // setCaption( "Qt Draw Demo Application" ); 608 // setCaption( "Qt Draw Demo Application" );
609 609
610 setBackgroundColor( white ); 610 setBackgroundColor( white );
611// QPainter p(this); 611// QPainter p(this);
612// p.setBackgroundMode( Qt::OpaqueMode ); 612// p.setBackgroundMode( Qt::OpaqueMode );
613 buffdoc.setfilter(getfilter()); 613 buffdoc.setfilter(getfilter());
614 ChangeFont(m_textsize); 614 ChangeFont(m_textsize);
615 setFocusPolicy(QWidget::StrongFocus); 615 setFocusPolicy(QWidget::StrongFocus);
616 // resize( 240, 320 ); 616 // resize( 240, 320 );
617 //setFocus(); 617 //setFocus();
618 timer = new QTimer(this); 618 timer = new QTimer(this);
619 connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); 619 connect(timer, SIGNAL(timeout()), this, SLOT(doscroll()));
620// QMessageBox::information(this, "init", m_lastfile, 1); 620// QMessageBox::information(this, "init", m_lastfile, 1);
621 m_lastwidth = width(); 621 m_lastwidth = width();
622 m_lastheight = height(); 622 m_lastheight = height();
623 setfont(); 623 setfont();
624 if (!m_lastfile.isEmpty()) 624 if (!m_lastfile.isEmpty())
625 { 625 {
626 m_string = DocLnk(m_lastfile).name(); 626 m_string = DocLnk(m_lastfile).name();
627 load_file(m_lastfile); 627 load_file(m_lastfile);
628 } 628 }
629} 629}
630 630
631// 631//
632// Clean up 632// Clean up
633// 633//
634QTReader::~QTReader() 634QTReader::~QTReader()
635{ 635{
636} 636}
637 637
638// 638//
639// Calls the drawing function as specified by the radio buttons. 639// Calls the drawing function as specified by the radio buttons.
640// 640//
641 641
642void QTReader::drawIt( QPainter *p ) 642void QTReader::drawIt( QPainter *p )
643{ 643{
644 drawFonts(p); 644 drawFonts(p);
645} 645}
646 646
647// 647//
648// Called when the print button is clicked. 648// Called when the print button is clicked.
649// 649//
650/* 650/*
651void QTReader::printIt() 651void QTReader::printIt()
652{ 652{
653#ifndef QT_NO_PRINTER 653#ifndef QT_NO_PRINTER
654 if ( printer->setup( this ) ) { 654 if ( printer->setup( this ) ) {
655 QPainter paint; 655 QPainter paint;
656 if ( !paint.begin( printer ) ) 656 if ( !paint.begin( printer ) )
657 return; 657 return;
658 drawIt( &paint ); 658 drawIt( &paint );
659 } 659 }
660#endif 660#endif
661} 661}
662*/ 662*/
663// 663//
664// Called when the widget needs to be updated. 664// Called when the widget needs to be updated.
665// 665//
666 666
667void QTReader::paintEvent( QPaintEvent * ) 667void QTReader::paintEvent( QPaintEvent * )
668{ 668{
669 QPainter paint( this ); 669 QPainter paint( this );
670 drawIt( &paint ); 670 drawIt( &paint );
671} 671}
672 672
673// 673//
674// Called when the widget has been resized. 674// Called when the widget has been resized.
675// Moves the button group to the upper right corner 675// Moves the button group to the upper right corner
676// of the widget. 676// of the widget.
677 677
678/* 678/*
679void QTReader::resizeEvent( QResizeEvent * ) 679void QTReader::resizeEvent( QResizeEvent * )
680{ 680{
681 // qDebug("resize:(%u,%u)", width(), height()); 681 // qDebug("resize:(%u,%u)", width(), height());
682 // bgroup->move( width()-bgroup->width(), 0 ); 682 // bgroup->move( width()-bgroup->width(), 0 );
683} 683}
684*/ 684*/
685 685
686// 686//
687// Create and display our widget. 687// Create and display our widget.
688// 688//
689/* 689/*
690int main( int argc, tchar **argv ) 690int main( int argc, tchar **argv )
691{ 691{
692 QApplication app( argc, argv ); 692 QApplication app( argc, argv );
693 QTReader draw; 693 QTReader draw;
694 app.setMainWidget( &draw ); 694 app.setMainWidget( &draw );
695 draw.setCaption("Qt Example - Drawdemo"); 695 draw.setCaption("Qt Example - Drawdemo");
696 draw.show(); 696 draw.show();
697 return app.exec(); 697 return app.exec();
698} 698}
699*/ 699*/
700 700
701 701
702bool QTReader::locate(unsigned long n) { 702bool QTReader::locate(unsigned long n) {
703 //printf("Locate\n"); 703 //printf("Locate\n");
704 buffdoc.locate(n); 704 buffdoc.locate(n);
705 // qDebug("&buffdoc.located"); 705 // qDebug("&buffdoc.located");
706 fillbuffer(); 706 fillbuffer();
707 // qDebug("&Buffer filled"); 707 // qDebug("&Buffer filled");
708 update(); 708 update();
709 // qDebug("&Located"); 709 // qDebug("&Located");
710 return true; 710 return true;
711} 711}
712 712
713unsigned int QTReader::screenlines() 713unsigned int QTReader::screenlines()
714{ 714{
715 // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; 715 // int linespacing = (tight) ? m_ascent : m_ascent+m_descent;
716 // return (height()-m_descent)/(m_linespacing); 716 // return (height()-m_descent)/(m_linespacing);
717 return (height()-2)/(m_linespacing); 717 return (height()-2)/(m_linespacing);
718}; 718};
719 719
720bool QTReader::fillbuffer(int reuse, int ht) 720bool QTReader::fillbuffer(int reuse, int ht)
721{ 721{
722 if (buffdoc.empty()) return false; 722 if (buffdoc.empty()) return false;
723 m_scrolldy1 = m_scrolldy2 = 0; 723 m_scrolldy1 = m_scrolldy2 = 0;
724 int ch; 724 int ch;
725 bool ret = false; 725 bool ret = false;
726 unsigned int oldpagepos = locnarray[reuse]; 726 unsigned int oldpagepos = locnarray[reuse];
727 int ypos = ht; 727 int ypos = ht;
728 numlines = reuse; 728 numlines = reuse;
729 while (ypos < height()) 729 while (ypos < height())
730 { 730 {
731 if (textarray[numlines] == NULL) 731 if (textarray[numlines] == NULL)
732 { 732 {
733 textarray[numlines] = new CDrawBuffer(&m_fontControl); 733 textarray[numlines] = new CDrawBuffer(&m_fontControl);
734 } 734 }
735 locnarray[numlines] = locate(); 735 locnarray[numlines] = locate();
736 int ch = getline(textarray[numlines]); 736 int ch = getline(textarray[numlines]);
737 ypos += textarray[numlines]->lineSpacing(); 737 ypos += textarray[numlines]->lineSpacing();
738 numlines++; 738 numlines++;
739 if (!ch) 739 if (!ch)
740 { 740 {
741 if (numlines - reuse == 1/* && locnarray[0] == buffdoc.locate()*/) 741 if (numlines - reuse == 1/* && locnarray[0] == buffdoc.locate()*/)
742 { 742 {
743 locate(oldpagepos); 743 locate(oldpagepos);
744 return false; 744 return false;
745 } 745 }
746 else 746 else
747 { 747 {
748 --numlines; 748 --numlines;
749 mylastpos = locate(); 749 mylastpos = locate();
750 return true; 750 return true;
751 } 751 }
752 } 752 }
753 } 753 }
754 754
755 --numlines; 755 --numlines;
756 mylastpos = locate(); 756 mylastpos = locate();
757 757
758 return true; 758 return true;
759} 759}
760 760
761 761
762void QTReader::dopagedn() 762void QTReader::dopagedn()
763{ 763{
764 int skip = 0, ypos = 0; 764 int skip = 0, ypos = 0;
765 if (locate() != mylastpos) 765 if (locate() != mylastpos)
766 { 766 {
767 //qDebug("Jumping to %u", mylastpos); 767 //qDebug("Jumping to %u", mylastpos);
768 jumpto(mylastpos); 768 jumpto(mylastpos);
769 } 769 }
770 CDrawBuffer* reusebuffer = textarray[numlines]; 770 CDrawBuffer* reusebuffer = textarray[numlines];
771 if (reusebuffer != NULL) 771 if (reusebuffer != NULL)
772 { 772 {
773 for (int i = 0; i <= m_overlap; i++) 773 for (int i = 0; i <= m_overlap; i++)
774 { 774 {
775 int offset = numlines - m_overlap + i; 775 int offset = numlines - m_overlap + i;
776 reusebuffer = textarray[offset]; 776 reusebuffer = textarray[offset];
777 size_t reuselocn = locnarray[offset]; 777 size_t reuselocn = locnarray[offset];
778 textarray[offset] = textarray[i]; 778 textarray[offset] = textarray[i];
779 textarray[i] = reusebuffer; 779 textarray[i] = reusebuffer;
780 locnarray[offset] = locnarray[i]; 780 locnarray[offset] = locnarray[i];
781 locnarray[i] = reuselocn; 781 locnarray[i] = reuselocn;
782 ypos += textarray[i]->lineSpacing(); 782 ypos += textarray[i]->lineSpacing();
783 skip++; 783 skip++;
784 } 784 }
785 } 785 }
786 if (fillbuffer(skip, ypos)) 786 if (fillbuffer(skip, ypos))
787 { 787 {
788 update(); 788 update();
789 } 789 }
790} 790}
791 791
792void QTReader::dopageup() 792void QTReader::dopageup()
793{ 793{
794 CBufferFace<CDrawBuffer*> buff; 794 CBufferFace<CDrawBuffer*> buff;
795 CBufferFace<size_t> loc; 795 CBufferFace<size_t> loc;
796 unsigned int target = locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]; 796 unsigned int target = locnarray[(m_overlap < numlines) ? m_overlap : numlines/2];
797 797
798 size_t delta; 798 size_t delta;
799 if (target < 2048) 799 if (target < 2048)
800 { 800 {
801 delta = target; 801 delta = target;
802 jumpto(0); 802 jumpto(0);
803 } 803 }
804 else 804 else
805 { 805 {
806 delta = 2048; 806 delta = 2048;
807 807
808 jumpto(target - delta); 808 jumpto(target - delta);
809 809
810 buff[0] = new CDrawBuffer(&m_fontControl); 810 buff[0] = new CDrawBuffer(&m_fontControl);
811 811
812 do 812 do
813 { 813 {
814 814
815 if (!getline(buff[0])) break; 815 if (!getline(buff[0])) break;
816 816
817 if (locate() > target) continue; 817 if (locate() > target) continue;
818 } 818 }
819 while (!buffdoc.iseol()); 819 while (!buffdoc.iseol());
820 } 820 }
821 int nbfl = 0; 821 int nbfl = 0;
822 822
823 bool ch = true; 823 bool ch = true;
824 int ypos = 0; 824 int ypos = 0;
825 while (locate() < target) 825 while (locate() < target)
826 { 826 {
827 if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); 827 if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl);
828 loc[nbfl] = locate(); 828 loc[nbfl] = locate();
829 ch = getline(buff[nbfl]); 829 ch = getline(buff[nbfl]);
830 ypos += buff[nbfl]->lineSpacing(); 830 ypos += buff[nbfl]->lineSpacing();
831 nbfl++; 831 nbfl++;
832 if (!ch) break; 832 if (!ch) break;
833 } 833 }
834 if (ypos < height()) 834 if (ypos < height())
835 { 835 {
836 locate(0); 836 locate(0);
837 return; 837 return;
838 } 838 }
839 if (ch) 839 if (ch)
840 { 840 {
841 if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); 841 if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl);
842 loc[nbfl] = locate(); 842 loc[nbfl] = locate();
843 int ch = getline(buff[nbfl]); 843 int ch = getline(buff[nbfl]);
844 nbfl++; 844 nbfl++;
845 } 845 }
846 ypos = 0; 846 ypos = 0;
847 numlines = 0; 847 numlines = 0;
848 while (ypos < height() && numlines <= nbfl-2) 848 while (ypos < height() && numlines <= nbfl-2)
849 { 849 {
850 ypos += buff[nbfl - numlines - 2]->lineSpacing(); 850 ypos += buff[nbfl - numlines - 2]->lineSpacing();
851 numlines++; 851 numlines++;
852 } 852 }
853 --numlines; 853 --numlines;
854 int offset = nbfl; 854 int offset = nbfl;
855 offset -= numlines+1; 855 offset -= numlines+1;
856 for (int i = 0; i <= numlines; i++) 856 for (int i = 0; i <= numlines; i++)
857 { 857 {
858 delete textarray[i]; 858 delete textarray[i];
859 textarray[i] = buff[offset+i]; 859 textarray[i] = buff[offset+i];
860 locnarray[i] = loc[offset + i]; 860 locnarray[i] = loc[offset + i];
861 } 861 }
862 for (int i = 0; i < nbfl - numlines - 1; i++) 862 for (int i = 0; i < nbfl - numlines - 1; i++)
863 { 863 {
864 delete buff[i]; 864 delete buff[i];
865 } 865 }
866 866
867// --numlines; 867// --numlines;
868 mylastpos = locate(); 868 mylastpos = locate();
869 869
870 update(); 870 update();
871} 871}
872 872
873bool QTReader::load_file(const char *newfile, unsigned int _lcn) 873bool QTReader::load_file(const char *newfile, unsigned int _lcn)
874{ 874{
875// QMessageBox::information(this, "Name", name, 1); 875// QMessageBox::information(this, "Name", name, 1);
876// QMessageBox::information(this, "load_file", newfile, 1); 876// QMessageBox::information(this, "load_file", newfile, 1);
877 877
878 bool bRC = false; 878 bool bRC = false;
879 unsigned int lcn = _lcn; 879 unsigned int lcn = _lcn;
880 if (m_lastfile == newfile) 880 if (m_lastfile == newfile)
881 { 881 {
882 lcn = m_lastposn; 882 lcn = m_lastposn;
883 } 883 }
884 m_lastfile = newfile; 884 m_lastfile = newfile;
885 // QMessageBox::information(0, "Opening...", newfile); 885 // QMessageBox::information(0, "Opening...", newfile);
886 if (buffdoc.openfile(this,newfile) == 0) 886 if (buffdoc.openfile(this,newfile) == 0)
887 { 887 {
888 bRC = true; 888 bRC = true;
889 // qDebug("buffdoc.openfile done"); 889 // qDebug("buffdoc.openfile done");
890 locate(lcn); 890 locate(lcn);
891 // qDebug("buffdoc.locate done"); 891 // qDebug("buffdoc.locate done");
892 } 892 }
893 setfilter(getfilter()); 893 setfilter(getfilter());
894 update(); 894 update();
895 // qDebug("Updated"); 895 // qDebug("Updated");
896 return bRC; 896 return bRC;
897} 897}
898 898
899void QTReader::lineDown() 899void QTReader::lineDown()
900{ 900{
901 int ypos = 0; 901 int ypos = 0;
902 int offset = numlines; 902 int offset = numlines;
903 903
904 for (int i = 0; i <= numlines; i++) 904 for (int i = 0; i <= numlines; i++)
905 { 905 {
906 if ((ypos += textarray[numlines-i]->lineSpacing()) > height()) 906 if ((ypos += textarray[numlines-i]->lineSpacing()) > height())
907 { 907 {
908 offset = i-1; 908 offset = i-1;
909 break; 909 break;
910 } 910 }
911 } 911 }
912 offset = numlines - offset; 912 offset = numlines - offset;
913 for (int i = offset; i <= numlines; i++) 913 for (int i = offset; i <= numlines; i++)
914 { 914 {
915 CDrawBuffer* buff = textarray[i-offset]; 915 CDrawBuffer* buff = textarray[i-offset];
916 textarray[i-offset] = textarray[i]; 916 textarray[i-offset] = textarray[i];
917 locnarray[i-offset] = locnarray[i]; 917 locnarray[i-offset] = locnarray[i];
918 textarray[i] = buff; 918 textarray[i] = buff;
919 } 919 }
920 numlines = numlines - offset + 1; 920 numlines = numlines - offset + 1;
921 locnarray[numlines] = locate(); 921 locnarray[numlines] = locate();
922 if (textarray[numlines] == NULL) 922 if (textarray[numlines] == NULL)
923 { 923 {
924 textarray[numlines] = new CDrawBuffer(&m_fontControl); 924 textarray[numlines] = new CDrawBuffer(&m_fontControl);
925 } 925 }
926 getline(textarray[numlines]); 926 getline(textarray[numlines]);
927 mylastpos = locate(); 927 mylastpos = locate();
928 update(); 928 update();
929} 929}
930/* 930/*
931void QTReader::lineUp() 931void QTReader::lineUp()
932{ 932{
933 CBuffer** buff = textarray; 933 CBuffer** buff = textarray;
934 unsigned int *loc = new unsigned int[numlines]; 934 unsigned int *loc = new unsigned int[numlines];
935 int cbptr = 0; 935 int cbptr = 0;
936 if (locate() != mylastpos) jumpto(mylastpos); 936 if (locate() != mylastpos) jumpto(mylastpos);
937 unsigned int target = locnarray[numlines-1]; 937 unsigned int target = locnarray[numlines-1];
938 if (buffdoc.hasrandomaccess()) 938 if (buffdoc.hasrandomaccess())
939 { 939 {
940 unsigned int delta = locate()-pagelocate(); 940 unsigned int delta = locate()-pagelocate();
941 if (delta < 64) delta = 64; 941 if (delta < 64) delta = 64;
942 do 942 do
943 { 943 {
944 delta <<= 1; 944 delta <<= 1;
945 if (delta >= target) 945 if (delta >= target)
946 { 946 {
947 delta = target; 947 delta = target;
948 jumpto(0); 948 jumpto(0);
949 for (int i = 0; i < numlines; i++) 949 for (int i = 0; i < numlines; i++)
950 { 950 {
951 loc[i] = locate(); 951 loc[i] = locate();
952 getline(buff[i]); 952 getline(buff[i]);
953 } 953 }
954 break; 954 break;
955 } 955 }
956 jumpto(target-delta); 956 jumpto(target-delta);
957 do 957 do
958 { 958 {
959 buffdoc.getline(buff[0],width()); 959 buffdoc.getline(buff[0],width());
960#ifdef WS 960#ifdef WS
961 //printf("Trying:%s\n",buff[0]); 961 //printf("Trying:%s\n",buff[0]);
962#endif 962#endif
963 if (locate() > target) continue; 963 if (locate() > target) continue;
964 } 964 }
965 while (!buffdoc.iseol()); 965 while (!buffdoc.iseol());
966 for (int i = 0; i < numlines; i++) 966 for (int i = 0; i < numlines; i++)
967 { 967 {
968 loc[i] = locate(); 968 loc[i] = locate();
969 buffdoc.getline(buff[i],width()); 969 buffdoc.getline(buff[i],width());
970#ifdef WS 970#ifdef WS
971 //printf("Filling:%s\n",buff[i]); 971 //printf("Filling:%s\n",buff[i]);
972#endif 972#endif
973 } 973 }
974 } 974 }
975 while (locate() >= target && delta < 4096); 975 while (locate() >= target && delta < 4096);
976#ifdef WS 976#ifdef WS
977 //printf("Delta:%u\n",delta); 977 //printf("Delta:%u\n",delta);
978#endif 978#endif
979 } 979 }
980 else 980 else
981 { 981 {
982 jumpto(0); 982 jumpto(0);
983 for (int i = 0; i < numlines; i++) 983 for (int i = 0; i < numlines; i++)
984 { 984 {
985 loc[i] = locate(); 985 loc[i] = locate();
986 buffdoc.getline(buff[i],width()); 986 buffdoc.getline(buff[i],width());
987 } 987 }
988 } 988 }
989 cbptr = 0; 989 cbptr = 0;
990 while (locate() < target) 990 while (locate() < target)
991 { 991 {
992 loc[cbptr] = locate(); 992 loc[cbptr] = locate();
993 buffdoc.getline(buff[cbptr], width()); 993 buffdoc.getline(buff[cbptr], width());
994#ifdef WS 994#ifdef WS
995 //printf("Adding:%s\n",buff[cbptr]->data()); 995 //printf("Adding:%s\n",buff[cbptr]->data());
996#endif 996#endif
997 cbptr = (cbptr+1) % numlines; 997 cbptr = (cbptr+1) % numlines;
998 } 998 }
999 pagepos = loc[cbptr]; 999 pagepos = loc[cbptr];
1000 textarray = new CBuffer*[numlines]; 1000 textarray = new CBuffer*[numlines];
1001 for (int i = 0; i < numlines; i++) 1001 for (int i = 0; i < numlines; i++)
1002 { 1002 {
1003 int j = (cbptr+i)%numlines; 1003 int j = (cbptr+i)%numlines;
1004 textarray[i] = buff[j]; 1004 textarray[i] = buff[j];
1005 locnarray[i] = loc[j]; 1005 locnarray[i] = loc[j];
1006 } 1006 }
1007 delete [] buff; 1007 delete [] buff;
1008 delete [] loc; 1008 delete [] loc;
1009 mylastpos = locate(); 1009 mylastpos = locate();
1010 update(); 1010 update();
1011} 1011}
1012*/ 1012*/
1013void QTReader::lineUp() 1013void QTReader::lineUp()
1014{ 1014{
1015 CDrawBuffer* buff = textarray[numlines]; 1015 CDrawBuffer* buff = textarray[numlines];
1016 unsigned int loc; 1016 unsigned int loc;
1017 unsigned int end = locnarray[numlines]; 1017 unsigned int end = locnarray[numlines];
1018 int cbptr = 0; 1018 int cbptr = 0;
1019 if (locate() != mylastpos) jumpto(mylastpos); 1019 if (locate() != mylastpos) jumpto(mylastpos);
1020 unsigned int target = locnarray[0]; 1020 unsigned int target = locnarray[0];
1021 if (target == 0) return; 1021 if (target == 0) return;
1022 if (buffdoc.hasrandomaccess()) 1022 if (buffdoc.hasrandomaccess())
1023 { 1023 {
1024 unsigned int delta = locate()-pagelocate(); 1024 unsigned int delta = locate()-pagelocate();
1025 if (delta < 64) delta = 64; 1025 if (delta < 64) delta = 64;
1026 do 1026 do
1027 { 1027 {
1028 delta <<= 1; 1028 delta <<= 1;
1029 if (delta >= target) 1029 if (delta >= target)
1030 { 1030 {
1031 delta = target; 1031 delta = target;
1032 jumpto(0); 1032 jumpto(0);
1033 loc = locate(); 1033 loc = locate();
1034 getline(buff); 1034 getline(buff);
1035 break; 1035 break;
1036 } 1036 }
1037 jumpto(target-delta); 1037 jumpto(target-delta);
1038 do 1038 do
1039 { 1039 {
1040 getline(buff); 1040 getline(buff);
1041#ifdef WS 1041#ifdef WS
1042 //printf("Trying:%s\n",buff[0]); 1042 //printf("Trying:%s\n",buff[0]);
1043#endif 1043#endif
1044 if (locate() > target) continue; 1044 if (locate() > target) continue;
1045 } 1045 }
1046 while (!buffdoc.iseol()); 1046 while (!buffdoc.iseol());
1047 loc = locate(); 1047 loc = locate();
1048 getline(buff); 1048 getline(buff);
1049 } 1049 }
1050 while (locate() >= target && delta < 4096); 1050 while (locate() >= target && delta < 4096);
1051 } 1051 }
1052 else 1052 else
1053 { 1053 {
1054 jumpto(0); 1054 jumpto(0);
1055 loc = locate(); 1055 loc = locate();
1056 getline(buff); 1056 getline(buff);
1057 } 1057 }
1058 cbptr = 0; 1058 cbptr = 0;
1059 while (locate() < target) 1059 while (locate() < target)
1060 { 1060 {
1061 loc = locate(); 1061 loc = locate();
1062 getline(buff); 1062 getline(buff);
1063 } 1063 }
1064 for (int i = numlines; i > 0; i--) 1064 for (int i = numlines; i > 0; i--)
1065 { 1065 {
1066 textarray[i] = textarray[i-1]; 1066 textarray[i] = textarray[i-1];
1067 locnarray[i] = locnarray[i-1]; 1067 locnarray[i] = locnarray[i-1];
1068 } 1068 }
1069 textarray[0] = buff; 1069 textarray[0] = buff;
1070 locnarray[0] = loc; 1070 locnarray[0] = loc;
1071 int start = numlines; 1071 int start = numlines;
1072 int ypos = 0; 1072 int ypos = 0;
1073 for (int i = 0; i <= numlines; i++) 1073 for (int i = 0; i <= numlines; i++)
1074 { 1074 {
1075 ypos += textarray[i]->lineSpacing(); 1075 ypos += textarray[i]->lineSpacing();
1076 if (ypos > height()) 1076 if (ypos > height())
1077 { 1077 {
1078 start = i; 1078 start = i;
1079 ypos -= textarray[i]->lineSpacing(); 1079 ypos -= textarray[i]->lineSpacing();
1080 break; 1080 break;
1081 } 1081 }
1082 } 1082 }
1083 jumpto(locnarray[start]); 1083 jumpto(locnarray[start]);
1084 fillbuffer(start, ypos); 1084 fillbuffer(start, ypos);
1085 update(); 1085 update();
1086} 1086}
1087 1087
1088bool QTReader::empty() 1088bool QTReader::empty()
1089{ 1089{
1090 return buffdoc.empty(); 1090 return buffdoc.empty();
1091} 1091}
1092 1092
1093MarkupType QTReader::PreferredMarkup() 1093MarkupType QTReader::PreferredMarkup()
1094{ 1094{
1095 MarkupType m = buffdoc.PreferredMarkup(); 1095 MarkupType m = buffdoc.PreferredMarkup();
1096 if (m == cTEXT) 1096 if (m == cTEXT)
1097 { 1097 {
1098 int ext = m_lastfile.findRev('.'); 1098 int ext = m_lastfile.findRev('.');
1099 if (ext >= 0) 1099 if (ext >= 0)
1100 { 1100 {
1101 QString ft = m_lastfile.right(m_lastfile.length()-ext-1).upper(); 1101 QString ft = m_lastfile.right(m_lastfile.length()-ext-1).upper();
1102 if (ft.left(3) == "HTM") 1102 if (ft.left(3) == "HTM")
1103 { 1103 {
1104 m = cHTML; 1104 m = cHTML;
1105 } 1105 }
1106 } 1106 }
1107 } 1107 }
1108 return m; 1108 return m;
1109} 1109}
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
@@ -1,2029 +1,2029 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <qclipboard.h> 21#include <qclipboard.h>
22#include <qwidgetstack.h> 22#include <qwidgetstack.h>
23#include <qpe/qpemenubar.h> 23#include <qpe/qpemenubar.h>
24#include <qpe/qpetoolbar.h> 24#include <qpe/qpetoolbar.h>
25#include <qpe/fontdatabase.h> 25#include <qpe/fontdatabase.h>
26#include <qcombobox.h> 26#include <qcombobox.h>
27#include <qpopupmenu.h> 27#include <qpopupmenu.h>
28#include <qaction.h> 28#include <qaction.h>
29#include <qapplication.h> 29#include <qapplication.h>
30#include <qlineedit.h> 30#include <qlineedit.h>
31#include <qtoolbutton.h> 31#include <qtoolbutton.h>
32#include <qspinbox.h> 32#include <qspinbox.h>
33#include <qobjectlist.h> 33#include <qobjectlist.h>
34#include <qpe/global.h> 34#include <qpe/global.h>
35#include <qpe/applnk.h> 35#include <qpe/applnk.h>
36#include <qfileinfo.h> 36#include <qfileinfo.h>
37#include <stdlib.h> //getenv 37#include <stdlib.h> //getenv
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qbuttongroup.h> 40#include <qbuttongroup.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44#include "QTReader.h" 44#include "QTReader.h"
45#include "Bkmks.h" 45#include "Bkmks.h"
46#include "cbkmkselector.h" 46#include "cbkmkselector.h"
47#include "infowin.h" 47#include "infowin.h"
48#include "CAnnoEdit.h" 48#include "CAnnoEdit.h"
49#include "QFloatBar.h" 49#include "QFloatBar.h"
50//#include <qpe/fontdatabase.h> 50//#include <qpe/fontdatabase.h>
51 51
52#include <qpe/resource.h> 52#include <qpe/resource.h>
53#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
54 54
55#include "QTReaderApp.h" 55#include "QTReaderApp.h"
56#include "fileBrowser.h" 56#include "fileBrowser.h"
57#include "CDrawBuffer.h" 57#include "CDrawBuffer.h"
58 58
59 59
60unsigned long QTReaderApp::m_uid = 0; 60unsigned long QTReaderApp::m_uid = 0;
61 61
62void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } 62void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); }
63 63
64#include <unistd.h> 64#include <unistd.h>
65#include <stddef.h> 65#include <stddef.h>
66#include <dirent.h> 66#include <dirent.h>
67 67
68void QTReaderApp::listBkmkFiles() 68void QTReaderApp::listBkmkFiles()
69{ 69{
70 bkmkselector->clear(); 70 bkmkselector->clear();
71 int cnt = 0; 71 int cnt = 0;
72 DIR *d; 72 DIR *d;
73 d = opendir((const char *)Global::applicationFileName("uqtreader","")); 73 d = opendir((const char *)Global::applicationFileName("uqtreader",""));
74 74
75 while(1) 75 while(1)
76 { 76 {
77 struct dirent* de; 77 struct dirent* de;
78 struct stat buf; 78 struct stat buf;
79 de = readdir(d); 79 de = readdir(d);
80 if (de == NULL) break; 80 if (de == NULL) break;
81 81
82 if (lstat((const char *)Global::applicationFileName("uqtreader",de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) 82 if (lstat((const char *)Global::applicationFileName("uqtreader",de->d_name),&buf) == 0 && S_ISREG(buf.st_mode))
83 { 83 {
84 bkmkselector->insertItem(de->d_name); 84 bkmkselector->insertItem(de->d_name);
85 cnt++; 85 cnt++;
86 } 86 }
87 } 87 }
88 88
89 closedir(d); 89 closedir(d);
90 90
91 if (cnt > 0) 91 if (cnt > 0)
92 { 92 {
93//tjw menu->hide(); 93//tjw menu->hide();
94 editBar->hide(); 94 editBar->hide();
95 if (m_fontVisible) m_fontBar->hide(); 95 if (m_fontVisible) m_fontBar->hide();
96 if (regVisible) regBar->hide(); 96 if (regVisible) regBar->hide();
97 if (searchVisible) searchBar->hide(); 97 if (searchVisible) searchBar->hide();
98 m_nRegAction = cRmBkmkFile; 98 m_nRegAction = cRmBkmkFile;
99 editorStack->raiseWidget( bkmkselector ); 99 editorStack->raiseWidget( bkmkselector );
100 } 100 }
101 else 101 else
102 QMessageBox::information(this, "OpieReader", "No bookmark files"); 102 QMessageBox::information(this, "OpieReader", "No bookmark files");
103} 103}
104 104
105QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) 105QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
106 : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false) 106 : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false)
107{ 107{
108// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); 108// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir());
109// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); 109// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml"));
110 110
111 pBkmklist = NULL; 111 pBkmklist = NULL;
112 doc = 0; 112 doc = 0;
113 113
114 m_fBkmksChanged = false; 114 m_fBkmksChanged = false;
115 115
116 QString lang = getenv( "LANG" ); 116 QString lang = getenv( "LANG" );
117 117
118 m_autogenstr = "^ *[A-Z].*[a-z] *$"; 118 m_autogenstr = "^ *[A-Z].*[a-z] *$";
119 setToolBarsMovable( FALSE ); 119 setToolBarsMovable( FALSE );
120 120
121 setIcon( Resource::loadPixmap( "opie-reader/uqtreader" ) ); 121 setIcon( Resource::loadPixmap( "opie-reader/uqtreader" ) );
122 122
123 QPEToolBar *bar = new QPEToolBar( this ); 123 QPEToolBar *bar = new QPEToolBar( this );
124 bar->setHorizontalStretchable( TRUE ); 124 bar->setHorizontalStretchable( TRUE );
125 addToolBar(bar, "tool",QMainWindow::Top, true); 125 addToolBar(bar, "tool",QMainWindow::Top, true);
126//tjw menu = bar; 126//tjw menu = bar;
127 127
128 QPEMenuBar *mb = new QPEMenuBar( bar ); 128 QPEMenuBar *mb = new QPEMenuBar( bar );
129 QPopupMenu *file = new QPopupMenu( this ); 129 QPopupMenu *file = new QPopupMenu( this );
130 QPopupMenu *format = new QPopupMenu( this ); 130 QPopupMenu *format = new QPopupMenu( this );
131 // QPopupMenu *edit = new QPopupMenu( this ); 131 // QPopupMenu *edit = new QPopupMenu( this );
132 132
133// bar = new QToolBar( this ); 133// bar = new QToolBar( this );
134 editBar = bar; 134 editBar = bar;
135 135
136 /* 136 /*
137 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 137 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
138 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 138 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
139 a->addTo( bar ); 139 a->addTo( bar );
140 a->addTo( file ); 140 a->addTo( file );
141 */ 141 */
142 142
143 editorStack = new QWidgetStack( this ); 143 editorStack = new QWidgetStack( this );
144 setCentralWidget( editorStack ); 144 setCentralWidget( editorStack );
145 145
146 searchVisible = FALSE; 146 searchVisible = FALSE;
147 regVisible = FALSE; 147 regVisible = FALSE;
148 m_fontVisible = false; 148 m_fontVisible = false;
149 149
150 pbar = new QProgressBar(this); 150 pbar = new QProgressBar(this);
151 pbar->hide(); 151 pbar->hide();
152 152
153 m_annoWin = new CAnnoEdit(editorStack); 153 m_annoWin = new CAnnoEdit(editorStack);
154 editorStack->addWidget(m_annoWin, get_unique_id()); 154 editorStack->addWidget(m_annoWin, get_unique_id());
155 connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); 155 connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) );
156 connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); 156 connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) );
157 157
158 m_infoWin = new infowin(editorStack); 158 m_infoWin = new infowin(editorStack);
159 editorStack->addWidget(m_infoWin, get_unique_id()); 159 editorStack->addWidget(m_infoWin, get_unique_id());
160 connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); 160 connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) );
161 161
162// bkmkselector = new QListBox(editorStack, "Bookmarks"); 162// bkmkselector = new QListBox(editorStack, "Bookmarks");
163 bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); 163 bkmkselector = new CBkmkSelector(editorStack, "Bookmarks");
164 // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); 164 // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) );
165 connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); 165 connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) );
166 connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); 166 connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) );
167 editorStack->addWidget( bkmkselector, get_unique_id() ); 167 editorStack->addWidget( bkmkselector, get_unique_id() );
168 168
169/* 169/*
170 importSelector = new FileSelector( "*", editorStack, "importselector", false ); 170 importSelector = new FileSelector( "*", editorStack, "importselector", false );
171 connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); 171 connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) );
172 172
173 editorStack->addWidget( importSelector, get_unique_id() ); 173 editorStack->addWidget( importSelector, get_unique_id() );
174 174
175 // don't need the close visible, it is redundant... 175 // don't need the close visible, it is redundant...
176 importSelector->setCloseVisible( FALSE ); 176 importSelector->setCloseVisible( FALSE );
177*/ 177*/
178 178
179 reader = new QTReader( editorStack ); 179 reader = new QTReader( editorStack );
180 180
181 ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); 181 ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold);
182 182
183 Config config( "uqtreader" ); 183 Config config( "uqtreader" );
184 config.setGroup( "View" ); 184 config.setGroup( "View" );
185 185
186 reader->bstripcr = config.readBoolEntry( "StripCr", true ); 186 reader->bstripcr = config.readBoolEntry( "StripCr", true );
187 reader->btextfmt = config.readBoolEntry( "TextFmt", false ); 187 reader->btextfmt = config.readBoolEntry( "TextFmt", false );
188 reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); 188 reader->bautofmt = config.readBoolEntry( "AutoFmt", true );
189 reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); 189 reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
190 reader->bpeanut = config.readBoolEntry( "Peanut", false ); 190 reader->bpeanut = config.readBoolEntry( "Peanut", false );
191 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); 191 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false );
192 reader->bunindent = config.readBoolEntry( "Unindent", false ); 192 reader->bunindent = config.readBoolEntry( "Unindent", false );
193 reader->brepara = config.readBoolEntry( "Repara", false ); 193 reader->brepara = config.readBoolEntry( "Repara", false );
194 reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); 194 reader->bdblspce = config.readBoolEntry( "DoubleSpace", false );
195 reader->bindenter = config.readNumEntry( "Indent", 0 ); 195 reader->bindenter = config.readNumEntry( "Indent", 0 );
196 reader->m_textsize = config.readNumEntry( "FontSize", 12 ); 196 reader->m_textsize = config.readNumEntry( "FontSize", 12 );
197 reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); 197 reader->m_delay = config.readNumEntry( "ScrollDelay", 5184);
198 reader->m_lastfile = config.readEntry( "LastFile", QString::null ); 198 reader->m_lastfile = config.readEntry( "LastFile", QString::null );
199 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); 199 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 );
200 reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); 200 reader->m_bpagemode = config.readBoolEntry( "PageMode", true );
201 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); 201 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false);
202 reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); 202 reader->m_fontname = config.readEntry( "Fontname", "helvetica" );
203 reader->m_encd = config.readNumEntry( "Encoding", 0 ); 203 reader->m_encd = config.readNumEntry( "Encoding", 0 );
204 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); 204 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 );
205 reader->m_overlap = config.readNumEntry( "Overlap", 0 ); 205 reader->m_overlap = config.readNumEntry( "Overlap", 0 );
206 reader->bremap = config.readBoolEntry( "Remap", true ); 206 reader->bremap = config.readBoolEntry( "Remap", true );
207 reader->bmakebold = config.readBoolEntry( "MakeBold", false ); 207 reader->bmakebold = config.readBoolEntry( "MakeBold", false );
208 m_targetapp = config.readEntry( "TargetApp", QString::null ); 208 m_targetapp = config.readEntry( "TargetApp", QString::null );
209 m_targetmsg = config.readEntry( "TargetMsg", QString::null ); 209 m_targetmsg = config.readEntry( "TargetMsg", QString::null );
210 m_twoTouch = config.readBoolEntry( "TwoTouch", false); 210 m_twoTouch = config.readBoolEntry( "TwoTouch", false);
211 m_doAnnotation = config.readBoolEntry( "Annotation", false); 211 m_doAnnotation = config.readBoolEntry( "Annotation", false);
212 m_doDictionary = config.readBoolEntry( "Dictionary", false); 212 m_doDictionary = config.readBoolEntry( "Dictionary", false);
213 m_doClipboard = config.readBoolEntry( "Clipboard", false); 213 m_doClipboard = config.readBoolEntry( "Clipboard", false);
214 m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); 214 m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll);
215 setTwoTouch(m_twoTouch); 215 setTwoTouch(m_twoTouch);
216 216
217 217
218 connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); 218 connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) );
219 connect( reader, SIGNAL( OnActionPressed() ), this, SLOT( OnActionPressed() ) ); 219 connect( reader, SIGNAL( OnActionPressed() ), this, SLOT( OnActionPressed() ) );
220 connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) ); 220 connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) );
221 editorStack->addWidget( reader, get_unique_id() ); 221 editorStack->addWidget( reader, get_unique_id() );
222 222
223 QAction *a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 223 QAction *a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
224 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 224 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
225 a->addTo( bar ); 225 a->addTo( bar );
226 a->addTo( file ); 226 a->addTo( file );
227 227
228 /* 228 /*
229 a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 229 a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
230 connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); 230 connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) );
231 a->addTo( file ); 231 a->addTo( file );
232 232
233 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 233 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
234 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 234 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
235 a->addTo( editBar ); 235 a->addTo( editBar );
236 a->addTo( edit ); 236 a->addTo( edit );
237 */ 237 */
238 238
239 a = new QAction( tr( "Info" ), QString::null, 0, this, NULL); 239 a = new QAction( tr( "Info" ), QString::null, 0, this, NULL);
240 connect( a, SIGNAL( activated() ), this, SLOT( showinfo() ) ); 240 connect( a, SIGNAL( activated() ), this, SLOT( showinfo() ) );
241 a->addTo( file ); 241 a->addTo( file );
242 242
243 QActionGroup* ag = new QActionGroup(this); 243 QActionGroup* ag = new QActionGroup(this);
244 QPopupMenu *spacemenu = new QPopupMenu(this); 244 QPopupMenu *spacemenu = new QPopupMenu(this);
245 file->insertItem( tr( "On Action..." ), spacemenu ); 245 file->insertItem( tr( "On Action..." ), spacemenu );
246 246
247 m_buttonAction[0] = new QAction( tr( "Open File" ), QString::null, 0, ag, NULL, true ); 247 m_buttonAction[0] = new QAction( tr( "Open File" ), QString::null, 0, ag, NULL, true );
248 248
249 m_buttonAction[1] = new QAction( tr( "Autoscroll" ), QString::null, 0, ag, NULL, true ); 249 m_buttonAction[1] = new QAction( tr( "Autoscroll" ), QString::null, 0, ag, NULL, true );
250 250
251 m_buttonAction[2] = new QAction( tr( "Mark" ), QString::null, 0, ag, NULL, true ); 251 m_buttonAction[2] = new QAction( tr( "Mark" ), QString::null, 0, ag, NULL, true );
252 252
253 ag->addTo(spacemenu); 253 ag->addTo(spacemenu);
254 254
255 connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) ); 255 connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) );
256 256
257 257
258 a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( "opie-reader/panel-arrow-down" ), QString::null, 0, this, 0, true ); 258 a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( "opie-reader/panel-arrow-down" ), QString::null, 0, this, 0, true );
259// connect( a, SIGNAL( activated() ), this, SLOT( autoScroll() ) ); 259// connect( a, SIGNAL( activated() ), this, SLOT( autoScroll() ) );
260 a->setOn(false); 260 a->setOn(false);
261 connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); 261 connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) );
262 file->insertSeparator(); 262 file->insertSeparator();
263 a->addTo( bar ); 263 a->addTo( bar );
264 a->addTo( file ); 264 a->addTo( file );
265 265
266 /* 266 /*
267 a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); 267 a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true );
268 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 268 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
269 a->addTo( file ); 269 a->addTo( file );
270 270
271 a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); 271 a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true );
272 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 272 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
273 a->addTo( file ); 273 a->addTo( file );
274 */ 274 */
275 a = new QAction( tr( "Jump" ), QString::null, 0, this, NULL); 275 a = new QAction( tr( "Jump" ), QString::null, 0, this, NULL);
276 connect( a, SIGNAL( activated() ), this, SLOT( jump() ) ); 276 connect( a, SIGNAL( activated() ), this, SLOT( jump() ) );
277 a->addTo( file ); 277 a->addTo( file );
278 278
279 a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, this, NULL, true ); 279 a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, this, NULL, true );
280 connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); 280 connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) );
281 a->setOn(reader->m_bpagemode); 281 a->setOn(reader->m_bpagemode);
282 a->addTo( file ); 282 a->addTo( file );
283 283
284 a = new QAction( tr( "Set Overlap" ), QString::null, 0, this, NULL); 284 a = new QAction( tr( "Set Overlap" ), QString::null, 0, this, NULL);
285 connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) ); 285 connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) );
286 a->addTo( file ); 286 a->addTo( file );
287 287
288 file->insertSeparator(); 288 file->insertSeparator();
289 289
290 a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL); 290 a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL);
291 connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) ); 291 connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) );
292 a->addTo( file ); 292 a->addTo( file );
293 293
294 a = new QAction( tr( "Two/One Touch" ), QString::null, 0, this, NULL, true ); 294 a = new QAction( tr( "Two/One Touch" ), QString::null, 0, this, NULL, true );
295 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); 295 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) );
296 a->setOn(m_twoTouch); 296 a->setOn(m_twoTouch);
297 a->addTo( file ); 297 a->addTo( file );
298 298
299 ag = new QActionGroup(this); 299 ag = new QActionGroup(this);
300 ag->setExclusive(false); 300 ag->setExclusive(false);
301 QPopupMenu *encoding = new QPopupMenu(this); 301 QPopupMenu *encoding = new QPopupMenu(this);
302 file->insertItem( tr( "Target" ), encoding ); 302 file->insertItem( tr( "Target" ), encoding );
303 303
304 a = new QAction( tr( "Annotation" ), QString::null, 0, ag, NULL, true ); 304 a = new QAction( tr( "Annotation" ), QString::null, 0, ag, NULL, true );
305 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnAnnotation(bool) ) ); 305 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnAnnotation(bool) ) );
306 a->setOn(m_doAnnotation); 306 a->setOn(m_doAnnotation);
307 307
308 a = new QAction( tr( "Dictionary" ), QString::null, 0, ag, NULL, true ); 308 a = new QAction( tr( "Dictionary" ), QString::null, 0, ag, NULL, true );
309 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnDictionary(bool) ) ); 309 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnDictionary(bool) ) );
310 a->setOn(m_doDictionary); 310 a->setOn(m_doDictionary);
311 311
312 a = new QAction( tr( "Clipboard" ), QString::null, 0, ag, NULL, true ); 312 a = new QAction( tr( "Clipboard" ), QString::null, 0, ag, NULL, true );
313 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnClipboard(bool) ) ); 313 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnClipboard(bool) ) );
314 a->setOn(m_doClipboard); 314 a->setOn(m_doClipboard);
315 315
316 ag->addTo(encoding); 316 ag->addTo(encoding);
317 317
318 318
319/* 319/*
320 a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); 320 a = new QAction( tr( "Import" ), QString::null, 0, this, NULL );
321 connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); 321 connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) );
322 a->addTo( file ); 322 a->addTo( file );
323*/ 323*/
324 324
325 a = new QAction( tr( "Up" ), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); 325 a = new QAction( tr( "Up" ), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 );
326 connect( a, SIGNAL( activated() ), this, SLOT( pageup() ) ); 326 connect( a, SIGNAL( activated() ), this, SLOT( pageup() ) );
327 a->addTo( editBar ); 327 a->addTo( editBar );
328 328
329 a = new QAction( tr( "Down" ), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); 329 a = new QAction( tr( "Down" ), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 );
330 connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 330 connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
331 a->addTo( editBar ); 331 a->addTo( editBar );
332 332
333 /* 333 /*
334 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 334 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
335 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 335 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
336 a->addTo( editBar ); 336 a->addTo( editBar );
337 a->addTo( edit ); 337 a->addTo( edit );
338 */ 338 */
339 339
340// a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 340// a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
341 a = new QAction( tr( "Find..." ), QString::null, 0, this, NULL); 341 a = new QAction( tr( "Find..." ), QString::null, 0, this, NULL);
342 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 342 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
343 file->insertSeparator(); 343 file->insertSeparator();
344// a->addTo( bar ); 344// a->addTo( bar );
345 a->addTo( file ); 345 a->addTo( file );
346 346
347 347
348 a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 348 a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
349 connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); 349 connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) );
350 a->addTo( bar ); 350 a->addTo( bar );
351 351
352 m_bkmkAvail->setEnabled(false); 352 m_bkmkAvail->setEnabled(false);
353 353
354 354
355 ag = new QActionGroup(this); 355 ag = new QActionGroup(this);
356// ag->setExclusive(false); 356// ag->setExclusive(false);
357 encoding = new QPopupMenu(this); 357 encoding = new QPopupMenu(this);
358 format->insertItem( tr( "Markup" ), encoding ); 358 format->insertItem( tr( "Markup" ), encoding );
359 359
360 a = new QAction( tr( "Auto" ), QString::null, 0, ag, NULL, true ); 360 a = new QAction( tr( "Auto" ), QString::null, 0, ag, NULL, true );
361 a->setOn(reader->bautofmt); 361 a->setOn(reader->bautofmt);
362 connect( a, SIGNAL( toggled(bool) ), this, SLOT( autofmt(bool) ) ); 362 connect( a, SIGNAL( toggled(bool) ), this, SLOT( autofmt(bool) ) );
363 363
364 a = new QAction( tr( "None" ), QString::null, 0, ag, NULL, true ); 364 a = new QAction( tr( "None" ), QString::null, 0, ag, NULL, true );
365 a->setOn(!reader->bautofmt && !(reader->btextfmt || reader->bstriphtml || reader->bpeanut)); 365 a->setOn(!reader->bautofmt && !(reader->btextfmt || reader->bstriphtml || reader->bpeanut));
366// connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) ); 366// connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) );
367 367
368 a = new QAction( tr( "Text" ), QString::null, 0, ag, NULL, true ); 368 a = new QAction( tr( "Text" ), QString::null, 0, ag, NULL, true );
369 a->setOn(reader->btextfmt); 369 a->setOn(reader->btextfmt);
370 connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) ); 370 connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) );
371 371
372 a = new QAction( tr( "HTML" ), QString::null, 0, ag, NULL, true ); 372 a = new QAction( tr( "HTML" ), QString::null, 0, ag, NULL, true );
373 a->setOn(reader->bstriphtml); 373 a->setOn(reader->bstriphtml);
374 connect( a, SIGNAL( toggled(bool) ), this, SLOT( striphtml(bool) ) ); 374 connect( a, SIGNAL( toggled(bool) ), this, SLOT( striphtml(bool) ) );
375 375
376 a = new QAction( tr( "Peanut/PML" ), QString::null, 0, ag, NULL, true ); 376 a = new QAction( tr( "Peanut/PML" ), QString::null, 0, ag, NULL, true );
377 a->setOn(reader->bpeanut); 377 a->setOn(reader->bpeanut);
378 connect( a, SIGNAL( toggled(bool) ), this, SLOT( peanut(bool) ) ); 378 connect( a, SIGNAL( toggled(bool) ), this, SLOT( peanut(bool) ) );
379 379
380 ag->addTo(encoding); 380 ag->addTo(encoding);
381 381
382 382
383 383
384 ag = new QActionGroup(this); 384 ag = new QActionGroup(this);
385 ag->setExclusive(false); 385 ag->setExclusive(false);
386 encoding = new QPopupMenu(this); 386 encoding = new QPopupMenu(this);
387 format->insertItem( tr( "Layout" ), encoding ); 387 format->insertItem( tr( "Layout" ), encoding );
388 388
389 a = new QAction( tr( "Strip CR" ), QString::null, 0, ag, NULL, true ); 389 a = new QAction( tr( "Strip CR" ), QString::null, 0, ag, NULL, true );
390 a->setOn(reader->bstripcr); 390 a->setOn(reader->bstripcr);
391 connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) ); 391 connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) );
392 392
393 a = new QAction( tr( "Dehyphen" ), QString::null, 0, ag, NULL, true ); 393 a = new QAction( tr( "Dehyphen" ), QString::null, 0, ag, NULL, true );
394 a->setOn(reader->bdehyphen); 394 a->setOn(reader->bdehyphen);
395 connect( a, SIGNAL( toggled(bool) ), this, SLOT( dehyphen(bool) ) ); 395 connect( a, SIGNAL( toggled(bool) ), this, SLOT( dehyphen(bool) ) );
396// a->addTo( format ); 396// a->addTo( format );
397 397
398 a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true ); 398 a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true );
399 connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) ); 399 connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) );
400 a->setOn(reader->bunindent); 400 a->setOn(reader->bunindent);
401// a->addTo( format ); 401// a->addTo( format );
402 402
403 a = new QAction( tr( "Re-paragraph" ), QString::null, 0, ag, NULL, true ); 403 a = new QAction( tr( "Re-paragraph" ), QString::null, 0, ag, NULL, true );
404 connect( a, SIGNAL( toggled(bool) ), this, SLOT( repara(bool) ) ); 404 connect( a, SIGNAL( toggled(bool) ), this, SLOT( repara(bool) ) );
405 a->setOn(reader->brepara); 405 a->setOn(reader->brepara);
406// a->addTo( format ); 406// a->addTo( format );
407 407
408 a = new QAction( tr( "Double Space" ), QString::null, 0, ag, NULL, true ); 408 a = new QAction( tr( "Double Space" ), QString::null, 0, ag, NULL, true );
409 connect( a, SIGNAL( toggled(bool) ), this, SLOT( dblspce(bool) ) ); 409 connect( a, SIGNAL( toggled(bool) ), this, SLOT( dblspce(bool) ) );
410 a->setOn(reader->bdblspce); 410 a->setOn(reader->bdblspce);
411// a->addTo( format ); 411// a->addTo( format );
412 412
413 a = new QAction( tr( "Indent+" ), QString::null, 0, ag, NULL ); 413 a = new QAction( tr( "Indent+" ), QString::null, 0, ag, NULL );
414 connect( a, SIGNAL( activated() ), this, SLOT( indentplus() ) ); 414 connect( a, SIGNAL( activated() ), this, SLOT( indentplus() ) );
415// a->addTo( format ); 415// a->addTo( format );
416 416
417 a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL ); 417 a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL );
418 connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) ); 418 connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) );
419 419
420 a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true ); 420 a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true );
421 connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) ); 421 connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) );
422 a->setOn(reader->bremap); 422 a->setOn(reader->bremap);
423 423
424 a = new QAction( tr( "Embolden" ), QString::null, 0, ag, NULL, true ); 424 a = new QAction( tr( "Embolden" ), QString::null, 0, ag, NULL, true );
425 connect( a, SIGNAL( toggled(bool) ), this, SLOT( embolden(bool) ) ); 425 connect( a, SIGNAL( toggled(bool) ), this, SLOT( embolden(bool) ) );
426 a->setOn(reader->bmakebold); 426 a->setOn(reader->bmakebold);
427 427
428 ag->addTo(encoding); 428 ag->addTo(encoding);
429 429
430 // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); 430 // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true );
431 // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); 431 // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
432 a = new QAction( tr( "Zoom" ), QString::null, 0, this); 432 a = new QAction( tr( "Zoom" ), QString::null, 0, this);
433 connect( a, SIGNAL( activated() ), this, SLOT( TBDzoom() ) ); 433 connect( a, SIGNAL( activated() ), this, SLOT( TBDzoom() ) );
434 format->insertSeparator(); 434 format->insertSeparator();
435 a->addTo( format ); 435 a->addTo( format );
436 // a->addTo( editBar ); 436 // a->addTo( editBar );
437 437
438 438
439 a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); 439 a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true );
440 connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); 440 connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
441 a->setOn(reader->m_bMonoSpaced); 441 a->setOn(reader->m_bMonoSpaced);
442 format->insertSeparator(); 442 format->insertSeparator();
443 a->addTo( format ); 443 a->addTo( format );
444 444
445 a = new QAction( tr( "Set width" ), QString::null, 0, this, NULL); 445 a = new QAction( tr( "Set width" ), QString::null, 0, this, NULL);
446 connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); 446 connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) );
447 a->addTo( format ); 447 a->addTo( format );
448 448
449 encoding = new QPopupMenu(this); 449 encoding = new QPopupMenu(this);
450// format->insertSeparator(); 450// format->insertSeparator();
451 format->insertItem( tr( "Encoding" ), encoding ); 451 format->insertItem( tr( "Encoding" ), encoding );
452 452
453 ag = new QActionGroup(this); 453 ag = new QActionGroup(this);
454 454
455 m_EncodingAction[0] = new QAction( tr( "Ascii" ), QString::null, 0, ag, NULL, true ); 455 m_EncodingAction[0] = new QAction( tr( "Ascii" ), QString::null, 0, ag, NULL, true );
456 456
457 m_EncodingAction[1] = new QAction( tr( "UTF-8" ), QString::null, 0, ag, NULL, true ); 457 m_EncodingAction[1] = new QAction( tr( "UTF-8" ), QString::null, 0, ag, NULL, true );
458 458
459 m_EncodingAction[2] = new QAction( tr( "UCS-2(BE)" ), QString::null, 0, ag, NULL, true ); 459 m_EncodingAction[2] = new QAction( tr( "UCS-2(BE)" ), QString::null, 0, ag, NULL, true );
460 460
461 m_EncodingAction[3] = new QAction( tr( "USC-2(LE)" ), QString::null, 0, ag, NULL, true ); 461 m_EncodingAction[3] = new QAction( tr( "USC-2(LE)" ), QString::null, 0, ag, NULL, true );
462 462
463 m_EncodingAction[4] = new QAction( tr( "Palm" ), QString::null, 0, ag, NULL, true ); 463 m_EncodingAction[4] = new QAction( tr( "Palm" ), QString::null, 0, ag, NULL, true );
464 464
465 m_EncodingAction[5] = new QAction( tr( "Windows(1252)" ), QString::null, 0, ag, NULL, true ); 465 m_EncodingAction[5] = new QAction( tr( "Windows(1252)" ), QString::null, 0, ag, NULL, true );
466 466
467 ag->addTo(encoding); 467 ag->addTo(encoding);
468 468
469 connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( encodingSelected(QAction*) ) ); 469 connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( encodingSelected(QAction*) ) );
470 470
471 a = new QAction( tr( "Set Font" ), QString::null, 0, this); 471 a = new QAction( tr( "Set Font" ), QString::null, 0, this);
472 connect( a, SIGNAL( activated() ), this, SLOT( setfont() ) ); 472 connect( a, SIGNAL( activated() ), this, SLOT( setfont() ) );
473 format->insertSeparator(); 473 format->insertSeparator();
474 a->addTo( format ); 474 a->addTo( format );
475 475
476 QPopupMenu *marks = new QPopupMenu( this ); 476 QPopupMenu *marks = new QPopupMenu( this );
477 477
478 a = new QAction( tr( "Mark" ), QString::null, 0, this, NULL); 478 a = new QAction( tr( "Mark" ), QString::null, 0, this, NULL);
479 connect( a, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); 479 connect( a, SIGNAL( activated() ), this, SLOT( addbkmk() ) );
480 a->addTo( marks ); 480 a->addTo( marks );
481 481
482 a = new QAction( tr( "Annotate" ), QString::null, 0, this, NULL); 482 a = new QAction( tr( "Annotate" ), QString::null, 0, this, NULL);
483 connect( a, SIGNAL( activated() ), this, SLOT( addanno() ) ); 483 connect( a, SIGNAL( activated() ), this, SLOT( addanno() ) );
484 a->addTo( marks ); 484 a->addTo( marks );
485 485
486 a = new QAction( tr( "Goto" ), QString::null, 0, this, NULL, false ); 486 a = new QAction( tr( "Goto" ), QString::null, 0, this, NULL, false );
487 connect( a, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); 487 connect( a, SIGNAL( activated() ), this, SLOT( do_gotomark() ) );
488 a->addTo( marks ); 488 a->addTo( marks );
489 489
490 a = new QAction( tr( "Delete" ), QString::null, 0, this, NULL); 490 a = new QAction( tr( "Delete" ), QString::null, 0, this, NULL);
491 connect( a, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); 491 connect( a, SIGNAL( activated() ), this, SLOT( do_delmark() ) );
492 a->addTo( marks ); 492 a->addTo( marks );
493 493
494 a = new QAction( tr( "Autogen" ), QString::null, 0, this, NULL, false ); 494 a = new QAction( tr( "Autogen" ), QString::null, 0, this, NULL, false );
495 connect( a, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); 495 connect( a, SIGNAL( activated() ), this, SLOT( do_autogen() ) );
496 marks->insertSeparator(); 496 marks->insertSeparator();
497 a->addTo( marks ); 497 a->addTo( marks );
498 498
499 a = new QAction( tr( "Clear" ), QString::null, 0, this, NULL); 499 a = new QAction( tr( "Clear" ), QString::null, 0, this, NULL);
500 connect( a, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); 500 connect( a, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) );
501 a->addTo( marks ); 501 a->addTo( marks );
502 502
503 a = new QAction( tr( "Save" ), QString::null, 0, this, NULL ); 503 a = new QAction( tr( "Save" ), QString::null, 0, this, NULL );
504 connect( a, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); 504 connect( a, SIGNAL( activated() ), this, SLOT( savebkmks() ) );
505 a->addTo( marks ); 505 a->addTo( marks );
506 506
507 a = new QAction( tr( "Tidy" ), QString::null, 0, this, NULL); 507 a = new QAction( tr( "Tidy" ), QString::null, 0, this, NULL);
508 connect( a, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); 508 connect( a, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) );
509 marks->insertSeparator(); 509 marks->insertSeparator();
510 a->addTo( marks ); 510 a->addTo( marks );
511 511
512 a = new QAction( tr( "Start Block" ), QString::null, 0, this, NULL); 512 a = new QAction( tr( "Start Block" ), QString::null, 0, this, NULL);
513 connect( a, SIGNAL( activated() ), this, SLOT( editMark() ) ); 513 connect( a, SIGNAL( activated() ), this, SLOT( editMark() ) );
514 marks->insertSeparator(); 514 marks->insertSeparator();
515 a->addTo( marks ); 515 a->addTo( marks );
516 516
517 a = new QAction( tr( "Copy Block" ), QString::null, 0, this, NULL); 517 a = new QAction( tr( "Copy Block" ), QString::null, 0, this, NULL);
518 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 518 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
519 a->addTo( marks ); 519 a->addTo( marks );
520 520
521 521
522 mb->insertItem( tr( "File" ), file ); 522 mb->insertItem( tr( "File" ), file );
523 // mb->insertItem( tr( "Edit" ), edit ); 523 // mb->insertItem( tr( "Edit" ), edit );
524 mb->insertItem( tr( "Format" ), format ); 524 mb->insertItem( tr( "Format" ), format );
525 mb->insertItem( tr( "Marks" ), marks ); 525 mb->insertItem( tr( "Marks" ), marks );
526 526
527 searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); 527 searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE );
528 528
529 searchBar->setHorizontalStretchable( TRUE ); 529 searchBar->setHorizontalStretchable( TRUE );
530 530
531 connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); 531 connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() ));
532 532
533 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 533 searchEdit = new QLineEdit( searchBar, "searchEdit" );
534// QFont f("unifont", 16 /*, QFont::Bold*/); 534// QFont f("unifont", 16 /*, QFont::Bold*/);
535// searchEdit->setFont( f ); 535// searchEdit->setFont( f );
536 searchBar->setStretchableWidget( searchEdit ); 536 searchBar->setStretchableWidget( searchEdit );
537 537
538#ifdef __ISEARCH 538#ifdef __ISEARCH
539 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 539 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
540 this, SLOT( search( const QString& ) ) ); 540 this, SLOT( search( const QString& ) ) );
541#else 541#else
542 connect( searchEdit, SIGNAL( returnPressed( ) ), 542 connect( searchEdit, SIGNAL( returnPressed( ) ),
543 this, SLOT( search( ) ) ); 543 this, SLOT( search( ) ) );
544#endif 544#endif
545 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 545 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
546 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 546 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
547 a->addTo( searchBar ); 547 a->addTo( searchBar );
548 548
549 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 549 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
550 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 550 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
551 a->addTo( searchBar ); 551 a->addTo( searchBar );
552 552
553 searchBar->hide(); 553 searchBar->hide();
554 554
555 regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); 555 regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE );
556 connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); 556 connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() ));
557 557
558 regBar->setHorizontalStretchable( TRUE ); 558 regBar->setHorizontalStretchable( TRUE );
559 559
560 regEdit = new QLineEdit( regBar, "regEdit" ); 560 regEdit = new QLineEdit( regBar, "regEdit" );
561// regEdit->setFont( f ); 561// regEdit->setFont( f );
562 562
563 regBar->setStretchableWidget( regEdit ); 563 regBar->setStretchableWidget( regEdit );
564 564
565 connect( regEdit, SIGNAL( returnPressed( ) ), 565 connect( regEdit, SIGNAL( returnPressed( ) ),
566 this, SLOT( do_regaction() ) ); 566 this, SLOT( do_regaction() ) );
567 567
568 a = new QAction( tr( "Do Reg" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); 568 a = new QAction( tr( "Do Reg" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
569 connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); 569 connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) );
570 a->addTo( regBar ); 570 a->addTo( regBar );
571 571
572 a = new QAction( tr( "Close Edit" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 572 a = new QAction( tr( "Close Edit" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
573 connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); 573 connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) );
574 a->addTo( regBar ); 574 a->addTo( regBar );
575 575
576 regBar->hide(); 576 regBar->hide();
577 577
578 m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); 578 m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE );
579 579
580 m_fontBar->setHorizontalStretchable( TRUE ); 580 m_fontBar->setHorizontalStretchable( TRUE );
581 581
582 m_fontSelector = new QComboBox(false, m_fontBar); 582 m_fontSelector = new QComboBox(false, m_fontBar);
583 m_fontBar->setStretchableWidget( m_fontSelector ); 583 m_fontBar->setStretchableWidget( m_fontSelector );
584 { 584 {
585 FontDatabase f; 585 FontDatabase f;
586 QStringList flist = f.families(); 586 QStringList flist = f.families();
587 m_fontSelector->insertStringList(flist); 587 m_fontSelector->insertStringList(flist);
588 588
589 bool realfont = false; 589 bool realfont = false;
590 for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) 590 for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++)
591 { 591 {
592 if (reader->m_fontname == *nm) 592 if (reader->m_fontname == *nm)
593 { 593 {
594 realfont = true; 594 realfont = true;
595 break; 595 break;
596 } 596 }
597 } 597 }
598 if (!realfont) reader->m_fontname = flist[0]; 598 if (!realfont) reader->m_fontname = flist[0];
599 } // delete the FontDatabase!!! 599 } // delete the FontDatabase!!!
600 600
601 connect( m_fontSelector, SIGNAL( activated(const QString& ) ), 601 connect( m_fontSelector, SIGNAL( activated(const QString& ) ),
602 this, SLOT( do_setfont(const QString&) ) ); 602 this, SLOT( do_setfont(const QString&) ) );
603 603
604 m_fontBar->hide(); 604 m_fontBar->hide();
605 m_fontVisible = false; 605 m_fontVisible = false;
606 606
607 connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), 607 connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ),
608 this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); 608 this, SLOT( msgHandler(const QCString&, const QByteArray&) ) );
609 609
610 610
611 reader->init(); 611 reader->init();
612 if (!reader->m_lastfile.isEmpty()) 612 if (!reader->m_lastfile.isEmpty())
613 { 613 {
614 openFile( reader->m_lastfile ); 614 openFile( reader->m_lastfile );
615 doc = new DocLnk(reader->m_lastfile); 615 doc = new DocLnk(reader->m_lastfile);
616 } 616 }
617 m_EncodingAction[reader->m_encd]->setOn(true); 617 m_EncodingAction[reader->m_encd]->setOn(true);
618 m_buttonAction[m_spaceTarget]->setOn(true); 618 m_buttonAction[m_spaceTarget]->setOn(true);
619 do_setfont(reader->m_fontname); 619 do_setfont(reader->m_fontname);
620} 620}
621 621
622void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) 622void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
623{ 623{
624 QString msg = QString::fromUtf8(_msg); 624 QString msg = QString::fromUtf8(_msg);
625 625
626// qDebug("Received:%s", (const char*)msg); 626// qDebug("Received:%s", (const char*)msg);
627 627
628 QDataStream stream( _data, IO_ReadOnly ); 628 QDataStream stream( _data, IO_ReadOnly );
629 if ( msg == "info(QString)" ) 629 if ( msg == "info(QString)" )
630 { 630 {
631 QString info; 631 QString info;
632 stream >> info; 632 stream >> info;
633 QMessageBox::information(this, "OpieReader", info); 633 QMessageBox::information(this, "OpieReader", info);
634 } 634 }
635 else if ( msg == "warn(QString)" ) 635 else if ( msg == "warn(QString)" )
636 { 636 {
637 QString info; 637 QString info;
638 stream >> info; 638 stream >> info;
639 QMessageBox::warning(this, "OpieReader", info); 639 QMessageBox::warning(this, "OpieReader", info);
640 } 640 }
641 641
642 642
643 else if ( msg == "exit()" ) 643 else if ( msg == "exit()" )
644 { 644 {
645 m_dontSave = true; 645 m_dontSave = true;
646 close(); 646 close();
647 } 647 }
648 else if ( msg == "pageDown()" ) 648 else if ( msg == "pageDown()" )
649 { 649 {
650 reader->dopagedn(); 650 reader->dopagedn();
651 } 651 }
652 else if ( msg == "pageUp()" ) 652 else if ( msg == "pageUp()" )
653 { 653 {
654 reader->dopageup(); 654 reader->dopageup();
655 } 655 }
656 else if ( msg == "lineDown()" ) 656 else if ( msg == "lineDown()" )
657 { 657 {
658 reader->lineDown(); 658 reader->lineDown();
659 } 659 }
660 else if ( msg == "lineUp()" ) 660 else if ( msg == "lineUp()" )
661 { 661 {
662 reader->lineUp(); 662 reader->lineUp();
663 } 663 }
664 else if ( msg == "showText()" ) 664 else if ( msg == "showText()" )
665 { 665 {
666 showEditTools(); 666 showEditTools();
667 } 667 }
668 else if ( msg == "File/Open(QString)" ) 668 else if ( msg == "File/Open(QString)" )
669 { 669 {
670 QString info; 670 QString info;
671 stream >> info; 671 stream >> info;
672 openFile( info ); 672 openFile( info );
673 } 673 }
674 else if ( msg == "File/Info()" ) 674 else if ( msg == "File/Info()" )
675 { 675 {
676 showinfo(); 676 showinfo();
677 } 677 }
678 else if ( msg == "File/Start Block()" ) 678 else if ( msg == "File/Start Block()" )
679 { 679 {
680 editMark(); 680 editMark();
681 } 681 }
682 else if ( msg == "File/Copy Block()" ) 682 else if ( msg == "File/Copy Block()" )
683 { 683 {
684 editCopy(); 684 editCopy();
685 } 685 }
686 else if ( msg == "File/Scroll(int)" ) 686 else if ( msg == "File/Scroll(int)" )
687 { 687 {
688 int info; 688 int info;
689 stream >> info; 689 stream >> info;
690 autoScroll(info); 690 autoScroll(info);
691 } 691 }
692 else if ( msg == "File/Jump(int)" ) 692 else if ( msg == "File/Jump(int)" )
693 { 693 {
694 int info; 694 int info;
695 stream >> info; 695 stream >> info;
696 reader->locate(info); 696 reader->locate(info);
697 } 697 }
698 else if ( msg == "File/Page/Line Scroll(int)" ) 698 else if ( msg == "File/Page/Line Scroll(int)" )
699 { 699 {
700 int info; 700 int info;
701 stream >> info; 701 stream >> info;
702 pagemode(info); 702 pagemode(info);
703 } 703 }
704 else if ( msg == "File/Set Overlap(int)" ) 704 else if ( msg == "File/Set Overlap(int)" )
705 { 705 {
706 int info; 706 int info;
707 stream >> info; 707 stream >> info;
708 reader->m_overlap = info; 708 reader->m_overlap = info;
709 } 709 }
710 else if ( msg == "File/Set Dictionary(QString)" ) 710 else if ( msg == "File/Set Dictionary(QString)" )
711 { 711 {
712 QString info; 712 QString info;
713 stream >> info; 713 stream >> info;
714 do_settarget(info); 714 do_settarget(info);
715 } 715 }
716 else if ( msg == "File/Two/One Touch(int)" ) 716 else if ( msg == "File/Two/One Touch(int)" )
717 { 717 {
718 int info; 718 int info;
719 stream >> info; 719 stream >> info;
720 setTwoTouch(info); 720 setTwoTouch(info);
721 } 721 }
722 else if ( msg == "Target/Annotation(int)" ) 722 else if ( msg == "Target/Annotation(int)" )
723 { 723 {
724 int info; 724 int info;
725 stream >> info; 725 stream >> info;
726 OnAnnotation(info); 726 OnAnnotation(info);
727 } 727 }
728 else if ( msg == "Target/Dictionary(int)" ) 728 else if ( msg == "Target/Dictionary(int)" )
729 { 729 {
730 int info; 730 int info;
731 stream >> info; 731 stream >> info;
732 OnDictionary(info); 732 OnDictionary(info);
733 } 733 }
734 else if ( msg == "Target/Clipboard(int)" ) 734 else if ( msg == "Target/Clipboard(int)" )
735 { 735 {
736 int info; 736 int info;
737 stream >> info; 737 stream >> info;
738 OnClipboard(info); 738 OnClipboard(info);
739 } 739 }
740 else if ( msg == "File/Find(QString)" ) 740 else if ( msg == "File/Find(QString)" )
741 { 741 {
742 QString info; 742 QString info;
743 stream >> info; 743 stream >> info;
744 QRegExp arg(info); 744 QRegExp arg(info);
745 size_t pos = reader->pagelocate(); 745 size_t pos = reader->pagelocate();
746 size_t start = pos; 746 size_t start = pos;
747 CDrawBuffer test(&(reader->m_fontControl)); 747 CDrawBuffer test(&(reader->m_fontControl));
748 reader->buffdoc.getline(&test,reader->width()); 748 reader->buffdoc.getline(&test,reader->width());
749 while (arg.match(toQString(test.data())) == -1) 749 while (arg.match(toQString(test.data())) == -1)
750 { 750 {
751 pos = reader->locate(); 751 pos = reader->locate();
752 if (!reader->buffdoc.getline(&test,reader->width())) 752 if (!reader->buffdoc.getline(&test,reader->width()))
753 { 753 {
754 QMessageBox::information(this, "OpieReader", QString("Can't find\n")+info); 754 QMessageBox::information(this, "OpieReader", QString("Can't find\n")+info);
755 pos = start; 755 pos = start;
756 break; 756 break;
757 } 757 }
758 } 758 }
759 reader->locate(pos); 759 reader->locate(pos);
760 } 760 }
761 else if ( msg == "Layout/Strip CR(int)" ) 761 else if ( msg == "Layout/Strip CR(int)" )
762 { 762 {
763 int info; 763 int info;
764 stream >> info; 764 stream >> info;
765 stripcr(info); 765 stripcr(info);
766 } 766 }
767 else if ( msg == "Markup/Auto(int)" ) 767 else if ( msg == "Markup/Auto(int)" )
768 { 768 {
769 int info; 769 int info;
770 stream >> info; 770 stream >> info;
771 autofmt(info); 771 autofmt(info);
772 } 772 }
773 else if ( msg == "Markup/Text(int)" ) 773 else if ( msg == "Markup/Text(int)" )
774 { 774 {
775 int info; 775 int info;
776 stream >> info; 776 stream >> info;
777 textfmt(info); 777 textfmt(info);
778 } 778 }
779 else if ( msg == "Markup/HTML(int)" ) 779 else if ( msg == "Markup/HTML(int)" )
780 { 780 {
781 int info; 781 int info;
782 stream >> info; 782 stream >> info;
783 striphtml(info); 783 striphtml(info);
784 } 784 }
785 else if ( msg == "Markup/Peanut(int)" ) 785 else if ( msg == "Markup/Peanut(int)" )
786 { 786 {
787 int info; 787 int info;
788 stream >> info; 788 stream >> info;
789 peanut(info); 789 peanut(info);
790 } 790 }
791 else if ( msg == "Layout/Dehyphen(int)" ) 791 else if ( msg == "Layout/Dehyphen(int)" )
792 { 792 {
793 int info; 793 int info;
794 stream >> info; 794 stream >> info;
795 dehyphen(info); 795 dehyphen(info);
796 } 796 }
797 else if ( msg == "Layout/Unindent(int)" ) 797 else if ( msg == "Layout/Unindent(int)" )
798 { 798 {
799 int info; 799 int info;
800 stream >> info; 800 stream >> info;
801 unindent(info); 801 unindent(info);
802 } 802 }
803 else if ( msg == "Layout/Re-paragraph(int)" ) 803 else if ( msg == "Layout/Re-paragraph(int)" )
804 { 804 {
805 int info; 805 int info;
806 stream >> info; 806 stream >> info;
807 repara(info); 807 repara(info);
808 } 808 }
809 else if ( msg == "Layout/Double Space(int)" ) 809 else if ( msg == "Layout/Double Space(int)" )
810 { 810 {
811 int info; 811 int info;
812 stream >> info; 812 stream >> info;
813 dblspce(info); 813 dblspce(info);
814 } 814 }
815 else if ( msg == "Layout/Indent(int)" ) 815 else if ( msg == "Layout/Indent(int)" )
816 { 816 {
817 int info; 817 int info;
818 stream >> info; 818 stream >> info;
819 reader->bindenter = info; 819 reader->bindenter = info;
820 reader->setfilter(reader->getfilter()); 820 reader->setfilter(reader->getfilter());
821 } 821 }
822 else if ( msg == "Layout/Remap(int)" ) 822 else if ( msg == "Layout/Remap(int)" )
823 { 823 {
824 int info; 824 int info;
825 stream >> info; 825 stream >> info;
826 remap(info); 826 remap(info);
827 } 827 }
828 else if ( msg == "Layout/Embolden(int)" ) 828 else if ( msg == "Layout/Embolden(int)" )
829 { 829 {
830 int info; 830 int info;
831 stream >> info; 831 stream >> info;
832 embolden(info); 832 embolden(info);
833 } 833 }
834 else if ( msg == "Format/Ideogram/Word(int)" ) 834 else if ( msg == "Format/Ideogram/Word(int)" )
835 { 835 {
836 int info; 836 int info;
837 stream >> info; 837 stream >> info;
838 monospace(info); 838 monospace(info);
839 } 839 }
840 else if ( msg == "Format/Set width(int)" ) 840 else if ( msg == "Format/Set width(int)" )
841 { 841 {
842 int info; 842 int info;
843 stream >> info; 843 stream >> info;
844 reader->m_charpc = info; 844 reader->m_charpc = info;
845 reader->setfont(); 845 reader->setfont();
846 reader->refresh(); 846 reader->refresh();
847 } 847 }
848 else if ( msg == "Format/Encoding(QString)" ) 848 else if ( msg == "Format/Encoding(QString)" )
849 { 849 {
850 QString info; 850 QString info;
851 stream >> info; 851 stream >> info;
852 reader->setencoding(EncNameToInt(info)); 852 reader->setencoding(EncNameToInt(info));
853 } 853 }
854 else if ( msg == "Format/Set Font(QString,int)" ) 854 else if ( msg == "Format/Set Font(QString,int)" )
855 { 855 {
856 QString fontname; 856 QString fontname;
857 int size; 857 int size;
858 stream >> fontname; 858 stream >> fontname;
859 stream >> size; 859 stream >> size;
860 setfontHelper(fontname, size); 860 setfontHelper(fontname, size);
861 } 861 }
862 else if ( msg == "Marks/Autogen(QString)" ) 862 else if ( msg == "Marks/Autogen(QString)" )
863 { 863 {
864 QString info; 864 QString info;
865 stream >> info; 865 stream >> info;
866 do_autogen(info); 866 do_autogen(info);
867 } 867 }
868} 868}
869 869
870ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) 870ActionTypes QTReaderApp::ActNameToInt(const QString& _enc)
871{ 871{
872 for (int i = 0; i < MAX_ACTIONS; i++) 872 for (int i = 0; i < MAX_ACTIONS; i++)
873 { 873 {
874 if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; 874 if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i;
875 } 875 }
876 return cesAutoScroll; 876 return cesAutoScroll;
877} 877}
878 878
879int QTReaderApp::EncNameToInt(const QString& _enc) 879int QTReaderApp::EncNameToInt(const QString& _enc)
880{ 880{
881 for (int i = 0; i < MAX_ENCODING; i++) 881 for (int i = 0; i < MAX_ENCODING; i++)
882 { 882 {
883 if (m_EncodingAction[i]->text() == _enc) return i; 883 if (m_EncodingAction[i]->text() == _enc) return i;
884 } 884 }
885 return 0; 885 return 0;
886/* 886/*
887 if (_enc == "Ascii") return 0; 887 if (_enc == "Ascii") return 0;
888 if (_enc == "UTF-8") return 1; 888 if (_enc == "UTF-8") return 1;
889 if (_enc == "UCS-2(BE)") return 2; 889 if (_enc == "UCS-2(BE)") return 2;
890 if (_enc == "USC-2(LE)") return 3; 890 if (_enc == "USC-2(LE)") return 3;
891*/ 891*/
892} 892}
893 893
894void QTReaderApp::encodingSelected(QAction* _a) 894void QTReaderApp::encodingSelected(QAction* _a)
895{ 895{
896// qDebug("es:%x : %s", _a, (const char *)(_a->text())); 896// qDebug("es:%x : %s", _a, (const char *)(_a->text()));
897 reader->setencoding(EncNameToInt(_a->text())); 897 reader->setencoding(EncNameToInt(_a->text()));
898} 898}
899 899
900void QTReaderApp::buttonActionSelected(QAction* _a) 900void QTReaderApp::buttonActionSelected(QAction* _a)
901{ 901{
902// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); 902// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text()));
903 m_spaceTarget = ActNameToInt(_a->text()); 903 m_spaceTarget = ActNameToInt(_a->text());
904} 904}
905 905
906QTReaderApp::~QTReaderApp() 906QTReaderApp::~QTReaderApp()
907{ 907{
908} 908}
909 909
910void QTReaderApp::autoScroll(bool _b) 910void QTReaderApp::autoScroll(bool _b)
911{ 911{
912 reader->setautoscroll(_b); 912 reader->setautoscroll(_b);
913} 913}
914 914
915void QTReaderApp::TBD() 915void QTReaderApp::TBD()
916{ 916{
917 QMessageBox::information(this, "OpieReader", "Not yet implemented", 1); 917 QMessageBox::information(this, "OpieReader", "Not yet implemented", 1);
918} 918}
919 919
920void QTReaderApp::TBDzoom() 920void QTReaderApp::TBDzoom()
921{ 921{
922 QMessageBox::information(this, "OpieReader", "Zooming is done interactively\nTry left/right cursor keys", 1); 922 QMessageBox::information(this, "OpieReader", "Zooming is done interactively\nTry left/right cursor keys", 1);
923} 923}
924 924
925void QTReaderApp::clearBkmkList() 925void QTReaderApp::clearBkmkList()
926{ 926{
927 delete pBkmklist; 927 delete pBkmklist;
928 pBkmklist = NULL; 928 pBkmklist = NULL;
929 m_fBkmksChanged = false; 929 m_fBkmksChanged = false;
930} 930}
931 931
932void QTReaderApp::fileOpen() 932void QTReaderApp::fileOpen()
933{ 933{
934/* 934/*
935 menu->hide(); 935 menu->hide();
936 editBar->hide(); 936 editBar->hide();
937 if (regVisible) regBar->hide(); 937 if (regVisible) regBar->hide();
938 if (searchVisible) searchBar->hide(); 938 if (searchVisible) searchBar->hide();
939*/ 939*/
940 if (pBkmklist != NULL) 940 if (pBkmklist != NULL)
941 { 941 {
942 if (m_fBkmksChanged) 942 if (m_fBkmksChanged)
943 { 943 {
944 if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0) 944 if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0)
945 savebkmks(); 945 savebkmks();
946 } 946 }
947 delete pBkmklist; 947 delete pBkmklist;
948 pBkmklist = NULL; 948 pBkmklist = NULL;
949 m_fBkmksChanged = false; 949 m_fBkmksChanged = false;
950 } 950 }
951 reader->disableAutoscroll(); 951 reader->disableAutoscroll();
952/* 952/*
953 editorStack->raiseWidget( fileSelector ); 953 editorStack->raiseWidget( fileSelector );
954 fileSelector->reread(); 954 fileSelector->reread();
955*/ 955*/
956 fileBrowser* fb = new fileBrowser(this,"OpieReader",TRUE, 956 fileBrowser* fb = new fileBrowser(this,"OpieReader",TRUE,
957 0, 957 0,
958// WStyle_Customize | WStyle_NoBorderEx, 958// WStyle_Customize | WStyle_NoBorderEx,
959 "*", QFileInfo(reader->m_lastfile).dirPath(true)); 959 "*", QFileInfo(reader->m_lastfile).dirPath(true));
960 960
961 if (fb->exec()) 961 if (fb->exec())
962 { 962 {
963 QString fn(fb->fileList[0]); 963 QString fn(fb->fileList[0]);
964// fb->populateList(); 964// fb->populateList();
965 if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); 965 if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn);
966 } 966 }
967 delete fb; 967 delete fb;
968 reader->setFocus(); 968 reader->setFocus();
969} 969}
970 970
971void QTReaderApp::showinfo() 971void QTReaderApp::showinfo()
972{ 972{
973 unsigned long fs, ts, pl; 973 unsigned long fs, ts, pl;
974 if (reader->empty()) 974 if (reader->empty())
975 { 975 {
976 QMessageBox::information(this, "OpieReader", "No file loaded", 1); 976 QMessageBox::information(this, "OpieReader", "No file loaded", 1);
977 } 977 }
978 else 978 else
979 { 979 {
980 reader->sizes(fs,ts); 980 reader->sizes(fs,ts);
981 pl = reader->pagelocate(); 981 pl = reader->pagelocate();
982 m_infoWin->setFileSize(fs); 982 m_infoWin->setFileSize(fs);
983 m_infoWin->setTextSize(ts); 983 m_infoWin->setTextSize(ts);
984 m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); 984 m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts);
985 m_infoWin->setLocation(pl); 985 m_infoWin->setLocation(pl);
986 m_infoWin->setRead((100*pl + (ts >> 1))/ts); 986 m_infoWin->setRead((100*pl + (ts >> 1))/ts);
987 editorStack->raiseWidget( m_infoWin ); 987 editorStack->raiseWidget( m_infoWin );
988 m_infoWin->setFocus(); 988 m_infoWin->setFocus();
989 } 989 }
990} 990}
991 991
992void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) 992void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn)
993{ 993{
994 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; 994 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>;
995#ifdef _UNICODE 995#ifdef _UNICODE
996 CBuffer buff(name.length()+1); 996 CBuffer buff(name.length()+1);
997 int i; 997 int i;
998 for (i = 0; i < name.length(); i++) 998 for (i = 0; i < name.length(); i++)
999 { 999 {
1000 buff[i] = name[i].unicode(); 1000 buff[i] = name[i].unicode();
1001 } 1001 }
1002 buff[i] = 0; 1002 buff[i] = 0;
1003 CBuffer buff2(text.length()+1); 1003 CBuffer buff2(text.length()+1);
1004 for (i = 0; i < text.length(); i++) 1004 for (i = 0; i < text.length(); i++)
1005 { 1005 {
1006 buff2[i] = text[i].unicode(); 1006 buff2[i] = text[i].unicode();
1007 } 1007 }
1008 buff2[i] = 0; 1008 buff2[i] = 0;
1009 pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn)); 1009 pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn));
1010#else 1010#else
1011 pBkmklist->push_front(Bkmk((const tchar*)text,posn)); 1011 pBkmklist->push_front(Bkmk((const tchar*)text,posn));
1012#endif 1012#endif
1013 m_fBkmksChanged = true; 1013 m_fBkmksChanged = true;
1014 pBkmklist->sort(); 1014 pBkmklist->sort();
1015} 1015}
1016 1016
1017void QTReaderApp::addAnno(const QString& name, const QString& text) 1017void QTReaderApp::addAnno(const QString& name, const QString& text)
1018{ 1018{
1019 if (m_annoIsEditing) 1019 if (m_annoIsEditing)
1020 { 1020 {
1021 if (name.isEmpty()) 1021 if (name.isEmpty())
1022 { 1022 {
1023 QMessageBox::information(this, "OpieReader", "Need a name for the bookmark\nPlease try again", 1); 1023 QMessageBox::information(this, "OpieReader", "Need a name for the bookmark\nPlease try again", 1);
1024 } 1024 }
1025 else 1025 else
1026 { 1026 {
1027 addAnno(name, text, m_annoWin->getPosn()); 1027 addAnno(name, text, m_annoWin->getPosn());
1028 } 1028 }
1029 showEditTools(); 1029 showEditTools();
1030 } 1030 }
1031 else 1031 else
1032 { 1032 {
1033 if (m_annoWin->edited()) 1033 if (m_annoWin->edited())
1034 { 1034 {
1035 CBuffer buff(text.length()+1); 1035 CBuffer buff(text.length()+1);
1036 int i; 1036 int i;
1037 for (i = 0; i < text.length(); i++) 1037 for (i = 0; i < text.length(); i++)
1038 { 1038 {
1039 buff[i] = text[i].unicode(); 1039 buff[i] = text[i].unicode();
1040 } 1040 }
1041 buff[i] = 0; 1041 buff[i] = 0;
1042 m_fBkmksChanged = true; 1042 m_fBkmksChanged = true;
1043 m_anno->setAnno(buff.data()); 1043 m_anno->setAnno(buff.data());
1044 } 1044 }
1045 bool found = findNextBookmark(m_anno->value()+1); 1045 bool found = findNextBookmark(m_anno->value()+1);
1046 if (found) 1046 if (found)
1047 { 1047 {
1048 m_annoWin->setName(toQString(m_anno->name())); 1048 m_annoWin->setName(toQString(m_anno->name()));
1049 m_annoWin->setAnno(toQString(m_anno->anno())); 1049 m_annoWin->setAnno(toQString(m_anno->anno()));
1050 } 1050 }
1051 else 1051 else
1052 { 1052 {
1053 showEditTools(); 1053 showEditTools();
1054 } 1054 }
1055 } 1055 }
1056} 1056}
1057 1057
1058bool QTReaderApp::findNextBookmark(size_t start) 1058bool QTReaderApp::findNextBookmark(size_t start)
1059{ 1059{
1060 bool found = false; 1060 bool found = false;
1061 for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) 1061 for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++)
1062 { 1062 {
1063 if (iter->value() >= start) 1063 if (iter->value() >= start)
1064 { 1064 {
1065 if (iter->value() < reader->locate()) 1065 if (iter->value() < reader->locate())
1066 { 1066 {
1067 found = true; 1067 found = true;
1068 m_anno = iter.pContent(); 1068 m_anno = iter.pContent();
1069 } 1069 }
1070 break; 1070 break;
1071 } 1071 }
1072 } 1072 }
1073 return found; 1073 return found;
1074} 1074}
1075 1075
1076void QTReaderApp::addanno() 1076void QTReaderApp::addanno()
1077{ 1077{
1078 if (reader->empty()) 1078 if (reader->empty())
1079 { 1079 {
1080 QMessageBox::information(this, "OpieReader", "No file loaded", 1); 1080 QMessageBox::information(this, "OpieReader", "No file loaded", 1);
1081 } 1081 }
1082 else 1082 else
1083 { 1083 {
1084 m_annoWin->setName(""); 1084 m_annoWin->setName("");
1085 m_annoWin->setAnno(""); 1085 m_annoWin->setAnno("");
1086 m_annoWin->setPosn(reader->pagelocate()); 1086 m_annoWin->setPosn(reader->pagelocate());
1087 m_annoIsEditing = true; 1087 m_annoIsEditing = true;
1088 editorStack->raiseWidget( m_annoWin ); 1088 editorStack->raiseWidget( m_annoWin );
1089 m_annoWin->setFocus(); 1089 m_annoWin->setFocus();
1090 } 1090 }
1091} 1091}
1092 1092
1093void QTReaderApp::infoClose() 1093void QTReaderApp::infoClose()
1094{ 1094{
1095 showEditTools(); 1095 showEditTools();
1096} 1096}
1097 1097
1098/* 1098/*
1099void QTReaderApp::fileRevert() 1099void QTReaderApp::fileRevert()
1100{ 1100{
1101 clear(); 1101 clear();
1102 fileOpen(); 1102 fileOpen();
1103} 1103}
1104 1104
1105void QTReaderApp::editCut() 1105void QTReaderApp::editCut()
1106{ 1106{
1107#ifndef QT_NO_CLIPBOARD 1107#ifndef QT_NO_CLIPBOARD
1108 editor->cut(); 1108 editor->cut();
1109#endif 1109#endif
1110} 1110}
1111*/ 1111*/
1112void QTReaderApp::editMark() 1112void QTReaderApp::editMark()
1113{ 1113{
1114 m_savedpos = reader->pagelocate(); 1114 m_savedpos = reader->pagelocate();
1115} 1115}
1116 1116
1117void QTReaderApp::editCopy() 1117void QTReaderApp::editCopy()
1118{ 1118{
1119 QClipboard* cb = QApplication::clipboard(); 1119 QClipboard* cb = QApplication::clipboard();
1120 QString text; 1120 QString text;
1121 int ch; 1121 int ch;
1122 unsigned long currentpos = reader->pagelocate(); 1122 unsigned long currentpos = reader->pagelocate();
1123 unsigned long endpos = reader->locate(); 1123 unsigned long endpos = reader->locate();
1124 reader->jumpto(m_savedpos); 1124 reader->jumpto(m_savedpos);
1125 while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) 1125 while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF)
1126 { 1126 {
1127 text += ch; 1127 text += ch;
1128 } 1128 }
1129 cb->setText(text); 1129 cb->setText(text);
1130 reader->locate(currentpos); 1130 reader->locate(currentpos);
1131} 1131}
1132 1132
1133void QTReaderApp::pageup() 1133void QTReaderApp::pageup()
1134{ 1134{
1135 reader->goUp(); 1135 reader->goUp();
1136} 1136}
1137 1137
1138void QTReaderApp::pagedn() 1138void QTReaderApp::pagedn()
1139{ 1139{
1140 reader->goDown(); 1140 reader->goDown();
1141} 1141}
1142 1142
1143void QTReaderApp::stripcr(bool _b) 1143void QTReaderApp::stripcr(bool _b)
1144{ 1144{
1145 reader->setstripcr(_b); 1145 reader->setstripcr(_b);
1146} 1146}
1147void QTReaderApp::remap(bool _b) 1147void QTReaderApp::remap(bool _b)
1148{ 1148{
1149 reader->setremap(_b); 1149 reader->setremap(_b);
1150} 1150}
1151void QTReaderApp::peanut(bool _b) 1151void QTReaderApp::peanut(bool _b)
1152{ 1152{
1153 reader->setpeanut(_b); 1153 reader->setpeanut(_b);
1154} 1154}
1155void QTReaderApp::embolden(bool _b) 1155void QTReaderApp::embolden(bool _b)
1156{ 1156{
1157 reader->setmakebold(_b); 1157 reader->setmakebold(_b);
1158} 1158}
1159void QTReaderApp::autofmt(bool _b) 1159void QTReaderApp::autofmt(bool _b)
1160{ 1160{
1161 reader->setautofmt(_b); 1161 reader->setautofmt(_b);
1162} 1162}
1163void QTReaderApp::textfmt(bool _b) 1163void QTReaderApp::textfmt(bool _b)
1164{ 1164{
1165 reader->settextfmt(_b); 1165 reader->settextfmt(_b);
1166} 1166}
1167void QTReaderApp::striphtml(bool _b) 1167void QTReaderApp::striphtml(bool _b)
1168{ 1168{
1169 reader->setstriphtml(_b); 1169 reader->setstriphtml(_b);
1170} 1170}
1171void QTReaderApp::dehyphen(bool _b) 1171void QTReaderApp::dehyphen(bool _b)
1172{ 1172{
1173 reader->setdehyphen(_b); 1173 reader->setdehyphen(_b);
1174} 1174}
1175void QTReaderApp::unindent(bool _b) 1175void QTReaderApp::unindent(bool _b)
1176{ 1176{
1177 reader->setunindent(_b); 1177 reader->setunindent(_b);
1178} 1178}
1179void QTReaderApp::repara(bool _b) 1179void QTReaderApp::repara(bool _b)
1180{ 1180{
1181 reader->setrepara(_b); 1181 reader->setrepara(_b);
1182} 1182}
1183void QTReaderApp::dblspce(bool _b) 1183void QTReaderApp::dblspce(bool _b)
1184{ 1184{
1185 reader->setdblspce(_b); 1185 reader->setdblspce(_b);
1186} 1186}
1187void QTReaderApp::pagemode(bool _b) 1187void QTReaderApp::pagemode(bool _b)
1188{ 1188{
1189 reader->setpagemode(_b); 1189 reader->setpagemode(_b);
1190} 1190}
1191 1191
1192void QTReaderApp::monospace(bool _b) 1192void QTReaderApp::monospace(bool _b)
1193{ 1193{
1194 reader->setmono(_b); 1194 reader->setmono(_b);
1195} 1195}
1196 1196
1197void QTReaderApp::setspacing() 1197void QTReaderApp::setspacing()
1198{ 1198{
1199 m_nRegAction = cMonoSpace; 1199 m_nRegAction = cMonoSpace;
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}