summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Bkmks.cpp182
-rw-r--r--noncore/apps/opie-reader/BuffDoc.cpp86
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp942
3 files changed, 605 insertions, 605 deletions
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp
index 92ed69f..0cb9ea9 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 = false)
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 QTReader\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/BuffDoc.cpp b/noncore/apps/opie-reader/BuffDoc.cpp
index e37b136..d4541ea 100644
--- a/noncore/apps/opie-reader/BuffDoc.cpp
+++ b/noncore/apps/opie-reader/BuffDoc.cpp
@@ -1,224 +1,224 @@
1#include "BuffDoc.h" 1#include "BuffDoc.h"
2//#include <FL/fl_draw.h> 2//#include <FL/fl_draw.h>
3#include "config.h" 3#include "config.h"
4#include "CDrawBuffer.h" 4#include "CDrawBuffer.h"
5#include "plucker.h" 5#include "plucker.h"
6 6
7 7
8bool BuffDoc::hyperlink(unsigned int n) 8bool BuffDoc::hyperlink(unsigned int n)
9{ 9{
10 bool bRet = false; 10 bool bRet = false;
11 lastword.empty(); 11 lastword.empty();
12 lastsizes[0] = laststartline = n; 12 lastsizes[0] = laststartline = n;
13 lastispara = false; 13 lastispara = false;
14 if (exp != NULL) 14 if (exp != NULL)
15 { 15 {
16 bRet = exp->hyperlink(n); 16 bRet = exp->hyperlink(n);
17 lastsizes[0] = laststartline = exp->locate(); 17 lastsizes[0] = laststartline = exp->locate();
18 } 18 }
19 return bRet; 19 return bRet;
20} 20}
21 21
22void BuffDoc::locate(unsigned int n) 22void BuffDoc::locate(unsigned int n)
23{ 23{
24 // qDebug("BuffDoc:locating:%u",n); 24 // qDebug("BuffDoc:locating:%u",n);
25 lastword.empty(); 25 lastword.empty();
26 lastsizes[0] = laststartline = n; 26 lastsizes[0] = laststartline = n;
27 lastispara = false; 27 lastispara = false;
28 // tchar linebuf[1024]; 28 // tchar linebuf[1024];
29 if (exp != NULL) exp->locate(n); 29 if (exp != NULL) exp->locate(n);
30 // qDebug("BuffDoc:Located"); 30 // qDebug("BuffDoc:Located");
31} 31}
32 32
33bool BuffDoc::getline(CDrawBuffer* buff, int w) 33bool BuffDoc::getline(CDrawBuffer* buff, int w)
34{ 34{
35 tchar ch = 32; 35 tchar ch = 32;
36 CStyle cs; 36 CStyle cs;
37 buff->empty(); 37 buff->empty();
38 if (exp == NULL) 38 if (exp == NULL)
39 { 39 {
40 //(*buff)[0] = '\0'; 40// (*buff)[0] = '\0';
41 buff->empty(); 41 buff->empty();
42 return false; 42 return false;
43 } 43 }
44 int len = 0, lastcheck = 0; 44 int len = 0, lastcheck = 0;
45 if (lastword.length() > 0) 45 if (lastword.length() > 0)
46 { 46 {
47 *buff = lastword; 47 *buff = lastword;
48 cs = lastword.laststyle(); 48 cs = lastword.laststyle();
49 } 49 }
50 else buff->empty(); 50 else buff->empty();
51// qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); 51// qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data()));
52 lastcheck = len = buff->length(); 52 lastcheck = len = buff->length();
53 unsigned int slen = buff->width(len); 53 unsigned int slen = buff->width(len);
54 if (slen > w) 54 if (slen > w)
55 { 55 {
56 for ( ; len > 0; len--) 56 for ( ; len > 0; len--)
57 { 57 {
58 if (buff->width(len) < w) break; 58 if (buff->width(len) < w) break;
59 } 59 }
60// lastword = buff->data() + len - 1; 60// lastword = buff->data() + len - 1;
61 laststartline = lastsizes[len-1]; 61 laststartline = lastsizes[len-1];
62 lastword.setright(*buff, len - 1); 62 lastword.setright(*buff, len - 1);
63 for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1]; 63 for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1];
64// (*buff)[len-1] = '-'; 64// (*buff)[len-1] = '-';
65 buff->truncate(len-1); 65 buff->truncate(len-1);
66 buff->addch('-', cs); 66 buff->addch('-', cs);
67 (*buff)[len] = '\0'; 67 (*buff)[len] = '\0';
68 return true; 68 return true;
69 } 69 }
70 if (lastispara) 70 if (lastispara)
71 { 71 {
72 lastispara = false; 72 lastispara = false;
73// lastword[0] = '\0'; 73// lastword[0] = '\0';
74 lastword.empty(); 74 lastword.empty();
75 len = buff->length(); 75 len = buff->length();
76 while (buff->width(len) > w) len--; 76 while (buff->width(len) > w) len--;
77// (*buff)[len] = '\0'; 77// (*buff)[len] = '\0';
78 buff->truncate(len); 78 buff->truncate(len);
79 laststartline = exp->locate(); 79 laststartline = exp->locate();
80 return true; 80 return true;
81 } 81 }
82 lastispara = false; 82 lastispara = false;
83 for (int i = 0; i < len; i++) allsizes[i] = lastsizes[i]; 83 for (int i = 0; i < len; i++) allsizes[i] = lastsizes[i];
84 while (slen < w) 84 while (slen < w)
85 { 85 {
86 lastcheck = len; 86 lastcheck = len;
87 allsizes[len] = exp->locate(); 87 allsizes[len] = exp->locate();
88 getch(ch, cs); 88 getch(ch, cs);
89 while (ch != ' ' && ch != '\012' && ch != UEOF && len < 128) 89 while (ch != ' ' && ch != '\012' && ch != UEOF && len < 128)
90 { 90 {
91 len++; 91 len++;
92 buff->addch(ch,cs); 92 buff->addch(ch,cs);
93 allsizes[len] = exp->locate(); 93 allsizes[len] = exp->locate();
94 getch(ch, cs); 94 getch(ch, cs);
95 } 95 }
96 (*buff)[len] = 0; 96 (*buff)[len] = 0;
97 slen = buff->width(len); 97 slen = buff->width(len);
98 len++; 98 len++;
99 buff->addch(' ', cs); 99 buff->addch(' ', cs);
100 allsizes[len] = exp->locate(); 100 allsizes[len] = exp->locate();
101 if (slen < w && ch != ' ') 101 if (slen < w && ch != ' ')
102 { 102 {
103 lastcheck = len; 103 lastcheck = len;
104 break; 104 break;
105 } 105 }
106 lastispara = (ch == '\012'); 106 lastispara = (ch == '\012');
107 } 107 }
108 (*buff)[len] = '\0'; 108 (*buff)[len] = '\0';
109// lastword = buff->data()+lastcheck; 109// lastword = buff->data()+lastcheck;
110 lastword.setright(*buff, lastcheck); 110 lastword.setright(*buff, lastcheck);
111 for (int i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; 111 for (int i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck];
112 if (lastcheck > 0) 112 if (lastcheck > 0)
113 { 113 {
114 laststartline = allsizes[lastcheck]; 114 laststartline = allsizes[lastcheck];
115// (*buff)[lastcheck-1] = '\0'; 115// (*buff)[lastcheck-1] = '\0';
116 buff->truncate(lastcheck-1); 116 buff->truncate(lastcheck-1);
117 } 117 }
118 else 118 else
119 { 119 {
120 laststartline = (lastcheck == len) ? exp->locate() : allsizes[lastcheck+1]; 120 laststartline = (lastcheck == len) ? exp->locate() : allsizes[lastcheck+1];
121// (*buff)[lastcheck] = '\0'; 121// (*buff)[lastcheck] = '\0';
122 buff->truncate(lastcheck); 122 buff->truncate(lastcheck);
123 } 123 }
124// buff->frig(); 124// buff->frig();
125 return (ch != UEOF); 125 return (ch != UEOF);
126} 126}
127 127
128bool BuffDoc::getline(CDrawBuffer* buff, int w, int cw) 128bool BuffDoc::getline(CDrawBuffer* buff, int w, int cw)
129{ 129{
130 buff->empty(); 130 buff->empty();
131 if (exp == NULL) 131 if (exp == NULL)
132 { 132 {
133 return false; 133 return false;
134 } 134 }
135 tchar ch; 135 tchar ch;
136 CStyle cs; 136 CStyle cs;
137 int i = 0; 137 int i = 0;
138 while (i*cw < w) 138 while (i*cw < w)
139 { 139 {
140 getch(ch, cs); 140 getch(ch, cs);
141 if (ch == '\12' || ch == UEOF) break; 141 if (ch == '\12' || ch == UEOF) break;
142 buff->addch(ch,cs); 142 buff->addch(ch,cs);
143 i++; 143 i++;
144 } 144 }
145 buff->truncate(i); 145 buff->truncate(i);
146 laststartline = exp->locate(); 146 laststartline = exp->locate();
147 return (ch != UEOF); 147 return (ch != UEOF);
148} 148}
149 149
150int BuffDoc::openfile(QWidget* _parent, const char *src) 150int BuffDoc::openfile(QWidget* _parent, const char *src)
151{ 151{
152 // qDebug("BuffDoc:Openfile:%s", src); 152 // qDebug("BuffDoc:Openfile:%s", src);
153 // qDebug("Trying aportis %x",exp); 153 // qDebug("Trying aportis %x",exp);
154 if (exp != NULL) delete exp; 154 if (exp != NULL) delete exp;
155 lastword.empty(); 155 lastword.empty();
156 lastsizes[0] = laststartline = 0; 156 lastsizes[0] = laststartline = 0;
157 lastispara = false; 157 lastispara = false;
158 /* 158 /*
159 exp = new Text; 159 exp = new Text;
160 int ret = exp->openfile(src); 160 int ret = exp->openfile(src);
161 */ 161 */
162 162
163 exp = new Aportis; 163 exp = new Aportis;
164 int ret = exp->openfile(src); 164 int ret = exp->openfile(src);
165 if (ret == -1) 165 if (ret == -1)
166 { 166 {
167 delete exp; 167 delete exp;
168 exp = NULL; 168 exp = NULL;
169 return ret; 169 return ret;
170 } 170 }
171 if (ret == -2) 171 if (ret == -2)
172 { 172 {
173 173
174 delete exp; 174 delete exp;
175 exp = new ztxt; 175 exp = new ztxt;
176 ret = exp->openfile(src); 176 ret = exp->openfile(src);
177 } 177 }
178 if (ret != 0) 178 if (ret != 0)
179 { 179 {
180 180
181 delete exp; 181 delete exp;
182 exp = new CPlucker; 182 exp = new CPlucker;
183 ret = exp->openfile(src); 183 ret = exp->openfile(src);
184 } 184 }
185#ifndef SMALL 185#ifndef SMALL
186 if (ret != 0) 186 if (ret != 0)
187 { 187 {
188 delete exp; 188 delete exp;
189 qDebug("Trying ppms"); 189 qDebug("Trying ppms");
190 exp = new ppm_expander; 190 exp = new ppm_expander;
191 ret = exp->openfile(src); 191 ret = exp->openfile(src);
192 } 192 }
193 193
194 if (ret != 0) 194 if (ret != 0)
195 { 195 {
196 delete exp; 196 delete exp;
197 exp = new Text; 197 exp = new Text;
198 // qDebug("Trying text"); 198// qDebug("Trying text");
199 ret = exp->openfile(src); 199 ret = exp->openfile(src);
200 } 200 }
201#else 201#else
202 if (ret != 0) 202 if (ret != 0)
203 { 203 {
204 delete exp; 204 delete exp;
205 exp = new Text; 205 exp = new Text;
206 ret = exp->openfile(src); 206 ret = exp->openfile(src);
207 } 207 }
208#endif 208#endif
209 if (ret != 0) 209 if (ret != 0)
210 { 210 {
211 delete exp; 211 delete exp;
212 QMessageBox::information(_parent, "QTReader", "Unknown file compression type","Try another file"); 212 QMessageBox::information(_parent, "OpieReader", "Unknown file compression type","Try another file");
213 return ret; 213 return ret;
214 } 214 }
215 // qDebug("Doing final open:%x:%x",exp,filt); 215 // qDebug("Doing final open:%x:%x",exp,filt);
216 216
217 lastword.empty(); 217 lastword.empty();
218 lastsizes[0] = laststartline = 0; 218 lastsizes[0] = laststartline = 0;
219 lastispara = false; 219 lastispara = false;
220 exp->locate(0); 220 exp->locate(0);
221 filt->setsource(exp); 221 filt->setsource(exp);
222 // qDebug("BuffDoc:file opened"); 222 // qDebug("BuffDoc:file opened");
223 return 0; 223 return 0;
224} 224}
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index 0608b66..ef1f4f1 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -53,93 +53,93 @@
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, "QTReader", "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( "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
@@ -234,49 +234,49 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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( "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 );
@@ -516,639 +516,639 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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, "QTReader", 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, "QTReader", 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, "QTReader", 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, "QTReader", "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, "QTReader", "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, "QTReader", "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,"QTReader",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, "QTReader", "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, "QTReader", "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, "QTReader", "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}
@@ -1195,79 +1195,79 @@ void QTReaderApp::monospace(bool _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, "QTReader", "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, "QTReader", "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}
@@ -1311,57 +1311,57 @@ void QTReaderApp::regClose()
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 {
@@ -1397,401 +1397,401 @@ void QTReaderApp::openFile( const DocLnk &f )
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, "QTReader", "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("QTReader") ); 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("QTReader") ); 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, "QTReader", "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, "QTReader", "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, "QTReader", "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, "QTReader", "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 = 0)
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 );
@@ -1823,207 +1823,207 @@ void QTReaderApp::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, "QTReader", "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(); }