summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Aportis.cpp8
-rw-r--r--noncore/apps/opie-reader/Aportis.h26
-rw-r--r--noncore/apps/opie-reader/Bkmks.cpp8
-rw-r--r--noncore/apps/opie-reader/BuffDoc.cpp128
-rw-r--r--noncore/apps/opie-reader/BuffDoc.h18
-rw-r--r--noncore/apps/opie-reader/CAnnoEdit.h1
-rw-r--r--noncore/apps/opie-reader/CBuffer.cpp8
-rw-r--r--noncore/apps/opie-reader/CDrawBuffer.cpp281
-rw-r--r--noncore/apps/opie-reader/CDrawBuffer.h17
-rw-r--r--noncore/apps/opie-reader/CEncoding.cpp24
-rw-r--r--noncore/apps/opie-reader/CEncoding.h21
-rw-r--r--noncore/apps/opie-reader/CExpander.h63
-rw-r--r--noncore/apps/opie-reader/CFilter.cpp58
-rw-r--r--noncore/apps/opie-reader/CFilter.h93
-rw-r--r--noncore/apps/opie-reader/Filedata.h4
-rw-r--r--noncore/apps/opie-reader/FontControl.cpp27
-rw-r--r--noncore/apps/opie-reader/FontControl.h63
-rw-r--r--noncore/apps/opie-reader/Navigation.cpp112
-rw-r--r--noncore/apps/opie-reader/Navigation.h2
-rw-r--r--noncore/apps/opie-reader/Palm2QImage.cpp15
-rw-r--r--noncore/apps/opie-reader/Palm2QImage.h2
-rw-r--r--noncore/apps/opie-reader/QFloatBar.h1
-rw-r--r--noncore/apps/opie-reader/QTReader.cpp716
-rw-r--r--noncore/apps/opie-reader/QTReader.h150
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp3074
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.h259
-rw-r--r--noncore/apps/opie-reader/StateData.h1
-rw-r--r--noncore/apps/opie-reader/StyleConsts.cpp13
-rw-r--r--noncore/apps/opie-reader/StyleConsts.h32
-rw-r--r--noncore/apps/opie-reader/ZText.h45
-rw-r--r--noncore/apps/opie-reader/fileBrowser.cpp91
-rw-r--r--noncore/apps/opie-reader/fileBrowser.h9
-rw-r--r--noncore/apps/opie-reader/infowin.cpp4
-rw-r--r--noncore/apps/opie-reader/main.cpp24
-rw-r--r--noncore/apps/opie-reader/opie-reader.pro18
-rw-r--r--noncore/apps/opie-reader/pdb.cpp15
-rw-r--r--noncore/apps/opie-reader/pdb.h2
-rw-r--r--noncore/apps/opie-reader/plucker.cpp1179
-rw-r--r--noncore/apps/opie-reader/plucker.h125
-rw-r--r--noncore/apps/opie-reader/ppm_expander.h25
-rw-r--r--noncore/apps/opie-reader/ustring.h10
-rw-r--r--noncore/apps/opie-reader/version.h6
-rw-r--r--noncore/apps/opie-reader/ztxt.h31
43 files changed, 4114 insertions, 2695 deletions
diff --git a/noncore/apps/opie-reader/Aportis.cpp b/noncore/apps/opie-reader/Aportis.cpp
index b4988da..2f8cdc3 100644
--- a/noncore/apps/opie-reader/Aportis.cpp
+++ b/noncore/apps/opie-reader/Aportis.cpp
@@ -28,14 +28,14 @@ CList<Bkmk>* Aportis::getbkmklist()
28 { 28 {
29 char name[17]; 29 char name[17];
30 name[16] = '\0'; 30 name[16] = '\0';
31 qDebug("Record:%d, Length:%u",i,recordlength(i)); 31 // qDebug("Record:%d, Length:%u",i,recordlength(i));
32 gotorecordnumber(i); 32 gotorecordnumber(i);
33 fread(name,1,16,fin); 33 fread(name,1,16,fin);
34 unsigned long lcn; 34 unsigned long lcn;
35 fread(&lcn,sizeof(lcn),1,fin); 35 fread(&lcn,sizeof(lcn),1,fin);
36 lcn ^= 0xa5a5a5a5; 36 lcn ^= 0xa5a5a5a5;
37 lcn = SwapLong(lcn); 37 lcn = SwapLong(lcn);
38 qDebug("Bookmark:%s:%u", name,lcn); 38 // qDebug("Bookmark:%s:%u", name,lcn);
39 tchar tname[17]; 39 tchar tname[17];
40 memset(tname, 0, sizeof(tname)); 40 memset(tname, 0, sizeof(tname));
41 for (int i = 0; name[i] != 0; i++) 41 for (int i = 0; name[i] != 0; i++)
@@ -121,7 +121,7 @@ int Aportis::OpenFile(const char *src)
121 PeanutHeader hdr0; 121 PeanutHeader hdr0;
122 gotorecordnumber(0); 122 gotorecordnumber(0);
123 fread(&hdr0, sizeof(hdr0), 1, fin); 123 fread(&hdr0, sizeof(hdr0), 1, fin);
124 qDebug("Version:%x", ntohs(hdr0.Version)); 124// qDebug("Version:%x", ntohs(hdr0.Version));
125 if (hdr0.Version && 0x0200) 125 if (hdr0.Version && 0x0200)
126 { 126 {
127 bCompressed = 2; 127 bCompressed = 2;
@@ -182,7 +182,7 @@ int Aportis::OpenFile(const char *src)
182 cbptr = 0; 182 cbptr = 0;
183 outptr = 0; 183 outptr = 0;
184 refreshbuffer(); 184 refreshbuffer();
185 qDebug("Number of records:[%u,%u]", nRecs, nRecs2); 185// qDebug("Number of records:[%u,%u]", nRecs, nRecs2);
186 return ret; 186 return ret;
187} 187}
188 188
diff --git a/noncore/apps/opie-reader/Aportis.h b/noncore/apps/opie-reader/Aportis.h
index af1fd3b..202a36f 100644
--- a/noncore/apps/opie-reader/Aportis.h
+++ b/noncore/apps/opie-reader/Aportis.h
@@ -4,7 +4,7 @@
4 4
5#ifndef __Aportis_h 5#ifndef __Aportis_h
6#define __Aportis_h 6#define __Aportis_h
7 7#include "useqpe.h"
8#include "CExpander.h" 8#include "CExpander.h"
9#include "pdb.h" 9#include "pdb.h"
10 10
@@ -75,28 +75,30 @@ class Aportis : public CExpander, Cpdb {
75 unsigned char circbuf[2048]; 75 unsigned char circbuf[2048];
76 char bCompressed; 76 char bCompressed;
77public: 77public:
78 virtual void suspend() 78#ifdef USEQPE
79 void suspend()
79 { 80 {
80 CExpander::suspend(fin); 81 CExpander::suspend(fin);
81 } 82 }
82 virtual void unsuspend() 83 void unsuspend()
83 { 84 {
84 CExpander::unsuspend(fin); 85 CExpander::unsuspend(fin);
85 } 86 }
86 virtual void sizes(unsigned long& _file, unsigned long& _text) 87#endif
88 void sizes(unsigned long& _file, unsigned long& _text)
87 { 89 {
88 _file = dwLen; 90 _file = dwLen;
89 _text = dwTLen; 91 _text = dwTLen;
90 } 92 }
91 virtual bool hasrandomaccess() { return true; } 93 bool hasrandomaccess() { return true; }
92 virtual ~Aportis() {} 94 virtual ~Aportis() {}
93 Aportis(); 95 Aportis();
94 virtual int OpenFile(const char *src); 96 int OpenFile(const char *src);
95 virtual int getch(); 97 int getch();
96 virtual unsigned int locate(); 98 unsigned int locate();
97 virtual void locate(unsigned int n); 99 void locate(unsigned int n);
98 virtual CList<Bkmk>* getbkmklist(); 100 CList<Bkmk>* getbkmklist();
99 virtual MarkupType PreferredMarkup() 101 MarkupType PreferredMarkup()
100 { 102 {
101 return (peanutfile) ? cPML : cTEXT; 103 return (peanutfile) ? cPML : cTEXT;
102 } 104 }
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp
index a8bee13..889c6d8 100644
--- a/noncore/apps/opie-reader/Bkmks.cpp
+++ b/noncore/apps/opie-reader/Bkmks.cpp
@@ -1,4 +1,3 @@
1#include "name.h"
2#include <qmessagebox.h> 1#include <qmessagebox.h>
3 2
4#include "Bkmks.h" 3#include "Bkmks.h"
@@ -7,6 +6,7 @@
7#include "Markups.h" 6#include "Markups.h"
8#include "my_list.h" 7#include "my_list.h"
9#include "version.h" 8#include "version.h"
9#include "names.h"
10 10
11const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); 11const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE);
12 12
@@ -219,15 +219,15 @@ CList<Bkmk>* BkmkFile::readall()
219 case 6: 219 case 6:
220 isUpgraded = false; 220 isUpgraded = false;
221 bl = readall00(read06); 221 bl = readall00(read06);
222 qDebug("Correct version!"); 222 // qDebug("Correct version!");
223 break; 223 break;
224 case 5: 224 case 5:
225 isUpgraded = true; 225 isUpgraded = true;
226 bl = readall00(read05); 226 bl = readall00(read05);
227 qDebug("Known version!"); 227 // qDebug("Known version!");
228 break; 228 break;
229 default: 229 default:
230 qDebug("Unknown version!"); 230 // qDebug("Unknown version!");
231 isUpgraded = true; 231 isUpgraded = true;
232 bl = readall00(read05); 232 bl = readall00(read05);
233 } 233 }
diff --git a/noncore/apps/opie-reader/BuffDoc.cpp b/noncore/apps/opie-reader/BuffDoc.cpp
index 1123960..2402904 100644
--- a/noncore/apps/opie-reader/BuffDoc.cpp
+++ b/noncore/apps/opie-reader/BuffDoc.cpp
@@ -1,44 +1,60 @@
1#include "name.h" 1#include "names.h"
2
3#define NEWLINEBREAK
2 4
3#include "BuffDoc.h" 5#include "BuffDoc.h"
4//#include <FL/fl_draw.h> 6//#include <FL/fl_draw.h>
5#include "config.h" 7#include "config.h"
6#include "CDrawBuffer.h" 8#include "CDrawBuffer.h"
7#include "plucker.h" 9#include "plucker.h"
10#include "usenef.h"
11#ifdef USENEF
12#include "nef.h"
13#include "arrierego.h"
14#endif
8 15
9 16linkType BuffDoc::hyperlink(unsigned int n, QString& wrd)
10bool BuffDoc::hyperlink(unsigned int n)
11{ 17{
12 bool bRet = false; 18 linkType bRet = eNone;
13 lastword.empty();
14 lastsizes[0] = laststartline = n;
15 lastispara = false;
16 if (exp != NULL) 19 if (exp != NULL)
17 { 20 {
18 bRet = exp->hyperlink(n); 21 bRet = exp->hyperlink(n, wrd);
19 lastsizes[0] = laststartline = exp->locate(); 22 if (bRet == eLink)
23 {
24 lastword.empty();
25 lastsizes[0] = laststartline = n;
26#ifdef NEWLINEBREAK
27 lastispara = true;
28#else
29 lastispara = false;
30#endif
31 lastsizes[0] = laststartline = exp->locate();
32 }
20 } 33 }
21 return bRet; 34 return bRet;
22} 35}
23 36
24void BuffDoc::locate(unsigned int n) 37void BuffDoc::locate(unsigned int n)
25{ 38{
26 // qDebug("BuffDoc:locating:%u",n); 39 // //qDebug("BuffDoc:locating:%u",n);
27 lastword.empty(); 40 lastword.empty();
28 lastsizes[0] = laststartline = n; 41 lastsizes[0] = laststartline = n;
29 lastispara = false; 42#ifdef NEWLINEBREAK
43 lastispara = true;
44#else
45 lastispara = false;
46#endif
30 // tchar linebuf[1024]; 47 // tchar linebuf[1024];
31 if (exp != NULL) exp->locate(n); 48 if (exp != NULL) exp->locate(n);
32 // qDebug("BuffDoc:Located"); 49 // //qDebug("BuffDoc:Located");
33} 50}
34 51
35#define NEWLINEBREAK
36#ifdef NEWLINEBREAK 52#ifdef NEWLINEBREAK
37bool BuffDoc::getline(CDrawBuffer* buff, int wth) 53bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border)
38{ 54{
39 bool moreleft = true; 55 bool moreleft = true;
40 bool margindone = false; 56 bool margindone = false;
41 int w = wth-2*BORDER; 57 int w = wth-2*_border;
42 tchar ch = 32; 58 tchar ch = 32;
43 CStyle cs; 59 CStyle cs;
44 buff->empty(); 60 buff->empty();
@@ -60,14 +76,18 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
60 else buff->empty(); 76 else buff->empty();
61 lastword.empty(); 77 lastword.empty();
62 unsigned int slen = buff->width(len); 78 unsigned int slen = buff->width(len);
63 lastispara = false; 79 if (lastispara) buff->setstartpara();
64 while (1) 80 while (1)
65 { 81 {
66 lastsizes[len] = exp->locate(); 82 lastsizes[len] = exp->locate();
67 getch(ch, cs); 83 getch(ch, cs);
84 if (ch == 10 && len == 0 && !lastispara)
85 {
86 lastsizes[len] = exp->locate();
87 getch(ch, cs);
88 }
68 if (ch == UEOF) 89 if (ch == UEOF)
69 { 90 {
70 lastword.empty();
71 if (len == 0) 91 if (len == 0)
72 { 92 {
73 buff->setEof(); 93 buff->setEof();
@@ -78,11 +98,12 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
78 } 98 }
79 if (ch == 10) 99 if (ch == 10)
80 { 100 {
81 lastword.empty(); 101 buff->setendpara();
82 lastispara = true; 102 lastispara = true;
83 laststartline = exp->locate(); 103 laststartline = exp->locate();
84 break; 104 break;
85 } 105 }
106 lastispara = false;
86 buff->addch(ch, cs); 107 buff->addch(ch, cs);
87 len++; 108 len++;
88 if (!margindone) 109 if (!margindone)
@@ -94,13 +115,13 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
94 { 115 {
95 if (ch == ' ' || len == 1) 116 if (ch == ' ' || len == 1)
96 { 117 {
97 lastword.empty(); 118 if (ch == ' ') buff->truncate(len-1);
98 laststartline = exp->locate(); 119 laststartline = exp->locate();
99 break; 120 break;
100 } 121 }
101 else // should do a backward search for spaces, first. 122 else // should do a backward search for spaces, first.
102 { 123 {
103 for (int i = len-1; i > 0; i--) 124 for (int i = len-2; i > 0; i--)
104 { 125 {
105 if ((*buff)[i] == ' ') 126 if ((*buff)[i] == ' ')
106 { 127 {
@@ -116,8 +137,23 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
116 } 137 }
117 return true; 138 return true;
118 } 139 }
140 if ((*buff)[i] == '-' && !(((*buff)[i-1] == '-') || ((*buff)[i+1] == '-')))
141 {
142 (*buff)[len] = 0;
143 lastword.setright(*buff, i+1);
144 buff->truncate(i+1);
145 (*buff)[i+1] = '\0';
146 laststartline = lastsizes[i+1];
147 buff->resize();
148 for (int j = 0; j < lastword.length(); j++)
149 {
150 lastsizes[j] = lastsizes[j+i+1];
151 }
152 return true;
153 }
119 } 154 }
120 laststartline = lastsizes[len-1]; 155 laststartline = lastsizes[len-1];
156 (*buff)[len] = 0;
121 lastword.setright(*buff, len - 1); 157 lastword.setright(*buff, len - 1);
122 buff->truncate(len-1); 158 buff->truncate(len-1);
123 buff->addch('-', cs); 159 buff->addch('-', cs);
@@ -134,10 +170,10 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
134 return moreleft; 170 return moreleft;
135} 171}
136#else 172#else
137bool BuffDoc::getline(CDrawBuffer* buff, int wth) 173bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border)
138{ 174{
139 bool margindone = false; 175 bool margindone = false;
140 int w = wth-2*BORDER; 176 int w = wth-2*_border;
141 tchar ch = 32; 177 tchar ch = 32;
142 CStyle cs; 178 CStyle cs;
143 buff->empty(); 179 buff->empty();
@@ -156,7 +192,7 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
156 margindone = true; 192 margindone = true;
157 } 193 }
158 else buff->empty(); 194 else buff->empty();
159// qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); 195// //qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data()));
160 lastcheck = len = buff->length(); 196 lastcheck = len = buff->length();
161 unsigned int slen = buff->width(len); 197 unsigned int slen = buff->width(len);
162 if (slen > w) 198 if (slen > w)
@@ -231,7 +267,7 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
231 } 267 }
232 (*buff)[len] = '\0'; 268 (*buff)[len] = '\0';
233// lastword = buff->data()+lastcheck; 269// lastword = buff->data()+lastcheck;
234#ifdef WINDOWS 270#ifdef _WINDOWS
235 lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); 271 lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1);
236 { 272 {
237 int i; 273 int i;
@@ -264,9 +300,9 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
264} 300}
265#endif 301#endif
266 302
267bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw) 303bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw, unsigned char _border)
268{ 304{
269 int w = wth-2*BORDER; 305 int w = wth-2*_border;
270 buff->empty(); 306 buff->empty();
271 if (exp == NULL) 307 if (exp == NULL)
272 { 308 {
@@ -274,8 +310,8 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw)
274 } 310 }
275 tchar ch; 311 tchar ch;
276 CStyle cs; 312 CStyle cs;
277 int i = 0; 313 int i = 1;
278 while (i*cw < w) 314 while (i*cw < w-buff->offset(w,0))
279 { 315 {
280 getch(ch, cs); 316 getch(ch, cs);
281 if (ch == '\12' || ch == UEOF) break; 317 if (ch == '\12' || ch == UEOF) break;
@@ -290,12 +326,16 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw)
290 326
291int BuffDoc::openfile(QWidget* _parent, const char *src) 327int BuffDoc::openfile(QWidget* _parent, const char *src)
292{ 328{
293 // qDebug("BuffDoc:Openfile:%s", src); 329 // //qDebug("BuffDoc:Openfile:%s", src);
294 // qDebug("Trying aportis %x",exp); 330 // //qDebug("Trying aportis %x",exp);
295 if (exp != NULL) delete exp; 331 if (exp != NULL) delete exp;
296 lastword.empty(); 332 lastword.empty();
297 lastsizes[0] = laststartline = 0; 333 lastsizes[0] = laststartline = 0;
334#ifdef NEWLINEBREAK
335 lastispara = true;
336#else
298 lastispara = false; 337 lastispara = false;
338#endif
299 /* 339 /*
300 exp = new Text; 340 exp = new Text;
301 int ret = exp->openfile(src); 341 int ret = exp->openfile(src);
@@ -316,6 +356,22 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
316 exp = new ztxt; 356 exp = new ztxt;
317 ret = exp->openfile(src); 357 ret = exp->openfile(src);
318 } 358 }
359#ifdef USENEF
360 if (ret != 0)
361 {
362
363 delete exp;
364 exp = new CArriere;
365 ret = exp->openfile(src);
366 }
367 if (ret != 0)
368 {
369
370 delete exp;
371 exp = new CNEF;
372 ret = exp->openfile(src);
373 }
374#endif
319 if (ret != 0) 375 if (ret != 0)
320 { 376 {
321 377
@@ -326,7 +382,7 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
326 if (ret != 0) 382 if (ret != 0)
327 { 383 {
328 delete exp; 384 delete exp;
329 qDebug("Trying ppms"); 385 //qDebug("Trying ppms");
330 exp = new ppm_expander; 386 exp = new ppm_expander;
331 ret = exp->openfile(src); 387 ret = exp->openfile(src);
332 } 388 }
@@ -334,7 +390,7 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
334 { 390 {
335 delete exp; 391 delete exp;
336 exp = new Text; 392 exp = new Text;
337 // qDebug("Trying text"); 393 // //qDebug("Trying text");
338 ret = exp->openfile(src); 394 ret = exp->openfile(src);
339 } 395 }
340 396
@@ -344,13 +400,17 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
344 QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file"); 400 QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file");
345 return ret; 401 return ret;
346 } 402 }
347 // qDebug("Doing final open:%x:%x",exp,filt); 403 // //qDebug("Doing final open:%x:%x",exp,filt);
348 404
349 lastword.empty(); 405 lastword.empty();
350 lastsizes[0] = laststartline = 0; 406 lastsizes[0] = laststartline = 0;
407#ifdef NEWLINEBREAK
408 lastispara = true;
409#else
351 lastispara = false; 410 lastispara = false;
411#endif
352 exp->locate(0); 412 exp->locate(0);
353 filt->setsource(exp); 413 filt->setsource(exp);
354 // qDebug("BuffDoc:file opened"); 414 // //qDebug("BuffDoc:file opened");
355 return 0; 415 return 0;
356} 416}
diff --git a/noncore/apps/opie-reader/BuffDoc.h b/noncore/apps/opie-reader/BuffDoc.h
index 78d8457..29d0329 100644
--- a/noncore/apps/opie-reader/BuffDoc.h
+++ b/noncore/apps/opie-reader/BuffDoc.h
@@ -1,6 +1,7 @@
1#ifndef __BuffDoc_h 1#ifndef __BuffDoc_h
2#define __BuffDoc_h 2#define __BuffDoc_h
3 3
4#include "useqpe.h"
4#include "ZText.h" 5#include "ZText.h"
5#include "Aportis.h" 6#include "Aportis.h"
6#include "ztxt.h" 7#include "ztxt.h"
@@ -38,8 +39,13 @@ class BuffDoc
38 exp->putSaveData(src, srclen); 39 exp->putSaveData(src, srclen);
39 } 40 }
40 } 41 }
42#ifdef USEQPE
41 void suspend() { if (exp != NULL) exp->suspend(); } 43 void suspend() { if (exp != NULL) exp->suspend(); }
42 void unsuspend() { if (exp != NULL) exp->unsuspend(); } 44 void unsuspend() { if (exp != NULL) exp->unsuspend(); }
45#else
46 void suspend() {}
47 void unsuspend() {}
48#endif
43 ~BuffDoc() 49 ~BuffDoc()
44 { 50 {
45 delete filt; 51 delete filt;
@@ -50,7 +56,7 @@ class BuffDoc
50 exp = NULL; 56 exp = NULL;
51 filt = NULL; 57 filt = NULL;
52 lastword.empty(); 58 lastword.empty();
53 // qDebug("Buffdoc created"); 59 // // qDebug("Buffdoc created");
54 } 60 }
55 bool empty() { return (exp == NULL); } 61 bool empty() { return (exp == NULL); }
56 void setfilter(CFilterChain* _f) 62 void setfilter(CFilterChain* _f)
@@ -82,18 +88,19 @@ class BuffDoc
82 else 88 else
83 ch = UEOF; 89 ch = UEOF;
84 } 90 }
85 QPixmap* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); } 91 void setwidth(int w) { if (exp != NULL) exp->setwidth(w); }
92 QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); }
86 unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); } 93 unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); }
87 unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); } 94 unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); }
88 unsigned int locate() { return (exp == NULL) ? 0 : laststartline; } 95 unsigned int locate() { return (exp == NULL) ? 0 : laststartline; }
89 unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); } 96 unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); }
90 void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); } 97 void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); }
91 MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); } 98 MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); }
92 bool hyperlink(unsigned int n); 99 linkType hyperlink(unsigned int n, QString& wrd);
93 size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); } 100 size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); }
94 void locate(unsigned int n); 101 void locate(unsigned int n);
95 bool getline(CDrawBuffer* buff, int w); 102 bool getline(CDrawBuffer* buff, int w, unsigned char _border);
96 bool getline(CDrawBuffer* buff, int w, int cw); 103 bool getline(CDrawBuffer* buff, int w, int cw, unsigned char _border);
97 void sizes(unsigned long& fs, unsigned long& ts) { exp->sizes(fs,ts); } 104 void sizes(unsigned long& fs, unsigned long& ts) { exp->sizes(fs,ts); }
98 int getpara(CBuffer& buff) 105 int getpara(CBuffer& buff)
99 { 106 {
@@ -106,6 +113,7 @@ class BuffDoc
106 return i; 113 return i;
107 } 114 }
108 void saveposn(size_t posn) { exp->saveposn(posn); } 115 void saveposn(size_t posn) { exp->saveposn(posn); }
116 void writeposn(size_t posn) { exp->writeposn(posn); }
109 bool forward(size_t& loc) { return exp->forward(loc); } 117 bool forward(size_t& loc) { return exp->forward(loc); }
110 bool back(size_t& loc) { return exp->back(loc); } 118 bool back(size_t& loc) { return exp->back(loc); }
111 bool hasnavigation() { return exp->hasnavigation(); } 119 bool hasnavigation() { return exp->hasnavigation(); }
diff --git a/noncore/apps/opie-reader/CAnnoEdit.h b/noncore/apps/opie-reader/CAnnoEdit.h
index 3cc9f78..f320061 100644
--- a/noncore/apps/opie-reader/CAnnoEdit.h
+++ b/noncore/apps/opie-reader/CAnnoEdit.h
@@ -32,6 +32,7 @@ class CAnnoEdit : public QWidget
32 QVBoxLayout* grid = new QVBoxLayout(this); 32 QVBoxLayout* grid = new QVBoxLayout(this);
33 m_name = new QLineEdit(this, "Name"); 33 m_name = new QLineEdit(this, "Name");
34 m_anno = new QMultiLineEdit(this, "Annotation"); 34 m_anno = new QMultiLineEdit(this, "Annotation");
35 m_anno->setWordWrap(QMultiLineEdit::WidgetWidth);
35 QPushButton* exitButton = new QPushButton("Okay", this); 36 QPushButton* exitButton = new QPushButton("Okay", this);
36 connect(exitButton, SIGNAL( released() ), this, SLOT( slotOkay() ) ); 37 connect(exitButton, SIGNAL( released() ), this, SLOT( slotOkay() ) );
37 QPushButton* cancelButton = new QPushButton("Cancel", this); 38 QPushButton* cancelButton = new QPushButton("Cancel", this);
diff --git a/noncore/apps/opie-reader/CBuffer.cpp b/noncore/apps/opie-reader/CBuffer.cpp
index 0780a88..03d7733 100644
--- a/noncore/apps/opie-reader/CBuffer.cpp
+++ b/noncore/apps/opie-reader/CBuffer.cpp
@@ -7,14 +7,14 @@ CBufferBase& CBufferBase::assign(const void* sztmp, size_t ms)
7 delete [] buffer; 7 delete [] buffer;
8 buffer = new unsigned char[len = ms*membersize]; 8 buffer = new unsigned char[len = ms*membersize];
9 } 9 }
10 memcpy(buffer, sztmp, ms*membersize); 10 memcpy(buffer, sztmp, len);
11 return *this; 11 return *this;
12} 12}
13 13
14CBufferBase::CBufferBase(size_t ms, size_t n) : len(n), membersize(ms) 14CBufferBase::CBufferBase(size_t ms, size_t n) : len(n*ms), membersize(ms)
15{ 15{
16 buffer = new unsigned char[len*membersize]; 16 buffer = new unsigned char[len];
17 memset(buffer, 0, len*membersize); 17 memset(buffer, 0, len);
18} 18}
19 19
20void* CBufferBase::operator[](int i) 20void* CBufferBase::operator[](int i)
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp
index ca220e6..77b76fb 100644
--- a/noncore/apps/opie-reader/CDrawBuffer.cpp
+++ b/noncore/apps/opie-reader/CDrawBuffer.cpp
@@ -3,6 +3,8 @@
3#include <qfontmetrics.h> 3#include <qfontmetrics.h>
4#include <qpainter.h> 4#include <qpainter.h>
5#include <qpixmap.h> 5#include <qpixmap.h>
6#include <qimage.h>
7#include "useqpe.h"
6#include "opie.h" 8#include "opie.h"
7 9
8CDrawBuffer::~CDrawBuffer() 10CDrawBuffer::~CDrawBuffer()
@@ -42,7 +44,7 @@ void CDrawBuffer::setright(CDrawBuffer& rhs, int f)
42CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) 44CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs)
43{ 45{
44 int i; 46 int i;
45// qDebug("Trying 2"); 47// //qDebug("Trying 2");
46 len = rhs.len; 48 len = rhs.len;
47 m_maxstyle = rhs.m_maxstyle; 49 m_maxstyle = rhs.m_maxstyle;
48 m_ascent = rhs.m_ascent; 50 m_ascent = rhs.m_ascent;
@@ -60,7 +62,7 @@ CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs)
60 for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; 62 for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i];
61 (*this)[i] = '\0'; 63 (*this)[i] = '\0';
62 len = i; 64 len = i;
63// qDebug("Tried 2"); 65// //qDebug("Tried 2");
64 return *this; 66 return *this;
65} 67}
66 68
@@ -80,6 +82,8 @@ CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp)
80 82
81void CDrawBuffer::empty() 83void CDrawBuffer::empty()
82{ 84{
85 m_bSop = false;
86 m_bEop = false;
83 len = 0; 87 len = 0;
84 (*this)[0] = 0; 88 (*this)[0] = 0;
85 while (!segs.isEmpty()) 89 while (!segs.isEmpty())
@@ -111,16 +115,54 @@ void CDrawBuffer::truncate(int n)
111 (*this)[n] = 0; 115 (*this)[n] = 0;
112} 116}
113 117
114int CDrawBuffer::width(int numchars) 118int CDrawBuffer::width(int numchars, bool onscreen, int scwidth, unsigned char _border)
115{ 119{
120 int gzoom = fc->gzoom();
116 int currentx = 0, end = 0; 121 int currentx = 0, end = 0;
117 QString text = toQString(data()); 122 QString text = (numchars < 0) ? toQString(data()) : toQString(data(), numchars);
118 CList<textsegment>::iterator textstart = segs.begin(); 123 CList<textsegment>::iterator textstart = segs.begin();
124 int extraspace = 0;
125 bool just = (onscreen && !m_bEop && textstart->style.getJustify() == m_AlignJustify);
126 int spaces = 0;
127 int spacesofar = 0;
128 int spacenumber = 0;
129 int nonspace = 0;
130 if (just)
131 {
132 for (int i = 0; i < len; i++)
133 {
134 if ((*this)[i] != ' ')
135 {
136 nonspace = i;
137 break;
138 }
139 }
140#ifdef _WINDOWS
141 for (i = nonspace; i < len; i++)
142#else
143 for (int i = nonspace; i < len; i++)
144#endif
145 {
146 if ((*this)[i] == ' ')
147 {
148 spaces++;
149 }
150 }
151 if (spaces == 0)
152 {
153 just = false;
154 }
155 else
156 {
157 extraspace = (scwidth - 2*_border - rightMargin() - leftMargin() - width());
158 if (extraspace == 0) just = false;
159 }
160 }
119 CList<textsegment>::iterator textend = textstart; 161 CList<textsegment>::iterator textend = textstart;
120 do 162 do
121 { 163 {
122 textend++; 164 textend++;
123 end = (textend != segs.end()) ? textend->start : length(); 165 end = (textend != segs.end()) ? textend->start : len;
124 if (numchars >= 0 && end > numchars) 166 if (numchars >= 0 && end > numchars)
125 { 167 {
126 end = numchars; 168 end = numchars;
@@ -128,7 +170,14 @@ int CDrawBuffer::width(int numchars)
128 CStyle currentstyle = textstart->style; 170 CStyle currentstyle = textstart->style;
129 if (currentstyle.isPicture()) 171 if (currentstyle.isPicture())
130 { 172 {
131 currentx += currentstyle.getPicture()->width(); 173 if (currentstyle.canScale())
174 {
175 currentx += (gzoom*currentstyle.getPicture()->width())/100;
176 }
177 else
178 {
179 currentx += currentstyle.getPicture()->width();
180 }
132 } 181 }
133 else 182 else
134 { 183 {
@@ -139,37 +188,70 @@ int CDrawBuffer::width(int numchars)
139 } 188 }
140 else 189 else
141 { 190 {
142 QFont f(currentstyle.isMono() ? QString("courier") : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); 191 QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
143 // f.setUnderline(currentstyle.isUnderline()); 192 // f.setUnderline(currentstyle.isUnderline());
144 QString str = text.mid(textstart->start, end-textstart->start); 193 QString str = text.mid(textstart->start, end-textstart->start);
145 QFontMetrics fm(f); 194 QFontMetrics fm(f);
146 currentx += fm.width(str); 195 if (just)
196 {
197 int lastspace = -1;
198 int nsp = 0;
199 int cx = currentx;
200 while ((nsp = str.find(" ", lastspace+1)) >= 0)
201 {
202 if (nsp > nonspace)
203 {
204 spacenumber++;
205 int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar;
206 QString nstr = str.mid(lastspace+1, nsp-lastspace);
207 int lw = fm.width(nstr);
208 cx += lw+nexttoadd;
209 spacesofar += nexttoadd;
210 lastspace = nsp;
211 }
212 else
213 {
214 QString nstr = str.mid(lastspace+1, nsp-lastspace);
215 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr);
216 int lw = fm.width(nstr);
217 cx += lw;
218 lastspace = nsp;
219 }
220 }
221 QString nstr = str.right(str.length()-1-lastspace);
222 cx += fm.width(nstr);
223 currentx = cx;
224 }
225 else
226 {
227 currentx += fm.width(str);
228 }
147 } 229 }
148 } 230 }
149 textstart = textend; 231 textstart = textend;
150 } 232 }
151 while (textend != segs.end() && end != numchars); 233 while (textend != segs.end() && end != numchars && textstart->start < len);
152 return currentx; 234 return currentx;
153} 235}
154 236
155int CDrawBuffer::leftMargin() 237int CDrawBuffer::leftMargin()
156{ 238{
157 return (segs.begin()->style.getLeftMargin()*fc->getsize(segs.begin()->style))/6; 239 return (segs.begin()->style.getLeftMargin()*fc->getsize(segs.begin()->style)+3)/6;
158} 240}
159 241
160int CDrawBuffer::rightMargin() 242int CDrawBuffer::rightMargin()
161{ 243{
162 return (segs.begin()->style.getRightMargin()*fc->getsize(segs.begin()->style))/6; 244 return (segs.begin()->style.getRightMargin()*fc->getsize(segs.begin()->style)+3)/6;
163} 245}
164 246
165int CDrawBuffer::offset(int scwidth) 247int CDrawBuffer::offset(int scwidth, unsigned char _border)
166{ 248{
167 int currentx = BORDER; 249 int currentx = _border;
168 switch(segs.begin()->style.getJustify()) 250 switch(segs.begin()->style.getJustify())
169 { 251 {
170 case m_AlignRight: 252 case m_AlignRight:
171 { 253 {
172 currentx = scwidth - BORDER - rightMargin() - width(); 254 currentx = scwidth - _border - rightMargin() - width();
173 } 255 }
174 break; 256 break;
175 case m_AlignCentre: 257 case m_AlignCentre:
@@ -182,66 +264,86 @@ int CDrawBuffer::offset(int scwidth)
182 break; 264 break;
183 case m_AlignJustify: 265 case m_AlignJustify:
184 case m_AlignLeft: 266 case m_AlignLeft:
185 currentx = BORDER + leftMargin(); 267 currentx = _border + leftMargin();
186 break; 268 break;
187 } 269 }
188 return currentx; 270 return currentx;
189} 271}
190 272
191void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth) 273void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth, unsigned char _border)
192{ 274{
193 int currentx = offset(scwidth); 275 int gzoom = fc->gzoom();
276 int currentx = offset(scwidth, _border);
194 QString text = toQString(data()); 277 QString text = toQString(data());
195 CList<textsegment>::iterator textstart = segs.begin(); 278 CList<textsegment>::iterator textstart = segs.begin();
196/* 279 int extraspace = 0;
197 StyleType align = textstart->style.getJustify(); 280 bool just = (!m_bEop && textstart->style.getJustify() == m_AlignJustify);
198 switch (align) 281 int spaces = 0;
282 int spacesofar = 0;
283 int spacenumber = 0;
284 int nonspace = 0;
285 if (just)
199 { 286 {
200 case CStyle::m_AlignRight: 287 for (int i = 0; i < len; i++)
201 { 288 {
202 currentx = scwidth - width() - 2*BORDER; 289 if ((*this)[i] != ' ')
290 {
291 nonspace = i;
292 break;
293 }
203 } 294 }
204 break; 295#ifdef _WINDOWS
205 case CStyle::m_AlignCentre: 296 for (i = nonspace; i < len; i++)
297#else
298 for (int i = nonspace; i < len; i++)
299#endif
206 { 300 {
207 currentx = (scwidth - width())/2 - BORDER; 301 if ((*this)[i] == ' ')
302 {
303 spaces++;
304 }
305 }
306 if (spaces == 0)
307 {
308 just = false;
309 }
310 else
311 {
312 extraspace = (scwidth - 2*_border - rightMargin() - leftMargin() - width());
313 if (extraspace == 0) just = false;
208 } 314 }
209 break;
210 case CStyle::m_AlignJustify:
211 case CStyle::m_AlignLeft:
212 break;
213 } 315 }
214*/
215 CList<textsegment>::iterator textend = textstart; 316 CList<textsegment>::iterator textend = textstart;
216 do 317 do
217 { 318 {
218 textend++; 319 textend++;
219 int end = (textend != segs.end()) ? textend->start : length(); 320 int end = (textend != segs.end()) ? textend->start : len;
220 CStyle currentstyle = textstart->style; 321 CStyle currentstyle = textstart->style;
221 QFont f((currentstyle.isMono() && fc->hasCourier()) ? QString("courier") : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); 322 QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
222 //f.setUnderline(currentstyle.isUnderline()); 323 //f.setUnderline(currentstyle.isUnderline());
223 //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); 324 //if (currentstyle.isUnderline()) qDebug("UNDERLINE");
224 _p->setFont(f); 325 _p->setFont(f);
225 QString str = text.mid(textstart->start, end-textstart->start); 326 QString str = text.mid(textstart->start, end-textstart->start);
226#ifdef OPIE 327#if defined(OPIE) || !defined(USEQPE)
227 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100)); 328 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100));
228#else 329#else
229 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); 330 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10));
230#endif 331#endif
332 int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2;
231 if (_bMono) 333 if (_bMono)
232 { 334 {
233 if (currentstyle.isUnderline()) 335 if (currentstyle.isUnderline())
234 { 336 {
235 _p->drawLine( currentx, _y, currentx + str.length()*_charWidth, _y); 337 _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset);
236 } 338 }
237 if (currentstyle.isStrikethru()) 339 if (currentstyle.isStrikethru())
238 { 340 {
239 int ascent = fc->ascent(currentstyle)/3; 341 int ascent = fc->ascent(currentstyle)/3;
240 _p->drawLine( currentx, _y-ascent, currentx + str.length()*_charWidth, _y-ascent); 342 _p->drawLine( currentx, _y-ascent+voffset, currentx + str.length()*_charWidth, _y-ascent+voffset);
241 } 343 }
242 for (int i = 0; i < str.length(); i++) 344 for (int i = 0; i < str.length(); i++)
243 { 345 {
244 _p->drawText( currentx + i*_charWidth, _y, QString(str[i])); 346 _p->drawText( currentx + i*_charWidth, _y+voffset, QString(str[i]));
245 } 347 }
246 currentx += str.length()*_charWidth; 348 currentx += str.length()*_charWidth;
247 } 349 }
@@ -249,10 +351,23 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
249 { 351 {
250 if (currentstyle.isPicture()) 352 if (currentstyle.isPicture())
251 { 353 {
354 int ht = (gzoom*currentstyle.getPicture()->height())/100;
355 int wt = (gzoom*currentstyle.getPicture()->width())/100;
252 int ascent = fc->ascent(currentstyle)/2; 356 int ascent = fc->ascent(currentstyle)/2;
253 int yoffset = currentstyle.getPicture()->height()/2 + ascent; 357 int yoffset = ht/2 + ascent;
254 _p->drawPixmap( currentx, _y-yoffset, *(currentstyle.getPicture())); 358
255 currentx += currentstyle.getPicture()->width(); 359 QPixmap pc;
360 if (gzoom != 100 && currentstyle.canScale())
361 {
362 QImage im = currentstyle.getPicture()->smoothScale(wt,ht);
363 pc.convertFromImage(im);
364 }
365 else
366 {
367 pc.convertFromImage(*currentstyle.getPicture());
368 }
369 _p->drawPixmap( currentx, _y-yoffset, pc );
370 currentx += wt;
256 } 371 }
257 else 372 else
258 { 373 {
@@ -262,42 +377,84 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
262 int w = cw*(end-textstart->start); 377 int w = cw*(end-textstart->start);
263 if (currentstyle.isUnderline()) 378 if (currentstyle.isUnderline())
264 { 379 {
265 _p->drawLine( currentx, _y, currentx + w, _y); 380 _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset);
266 } 381 }
267 if (currentstyle.isStrikethru()) 382 if (currentstyle.isStrikethru())
268 { 383 {
269 int ascent = fc->ascent(currentstyle)/3; 384 int ascent = fc->ascent(currentstyle)/3;
270 _p->drawLine( currentx, _y-ascent, currentx + w, _y-ascent); 385 _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset);
271 } 386 }
272 QString str = text.mid(textstart->start, end-textstart->start); 387 QString str = text.mid(textstart->start, end-textstart->start);
273 388
274 for (int i = 0; i < str.length(); i++) 389 for (unsigned int i = 0; i < str.length(); i++)
275 { 390 {
276 _p->drawText( currentx, _y, QString(str[i])); 391#ifdef _WINDOWS
392 _p->drawText( currentx, _y+voffset, QString(str.at(i)));
393#else
394 _p->drawText( currentx, _y+voffset, QString(str[i]));
395#endif
277 currentx += cw; 396 currentx += cw;
278 } 397 }
279 } 398 }
280 else 399 else
281 { 400 {
282 QFontMetrics fm(f); 401 QFontMetrics fm(f);
283 int w = fm.width(str); 402 int w;
403 if (just)
404 {
405 int lastspace = -1;
406 int nsp = 0;
407 int cx = currentx;
408 while ((nsp = str.find(" ", lastspace+1)) >= 0)
409 {
410 if (nsp+textstart->start >= nonspace)
411 {
412 spacenumber++;
413 int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar;
414 QString nstr = str.mid(lastspace+1, nsp-lastspace);
415 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr);
416 int lw = fm.width(nstr);
417 _p->drawText( cx, _y+voffset, nstr);
418 cx += lw+nexttoadd;
419 spacesofar += nexttoadd;
420 lastspace = nsp;
421 }
422 else
423 {
424 QString nstr = str.mid(lastspace+1, nsp-lastspace);
425 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr);
426 int lw = fm.width(nstr);
427 _p->drawText( cx, _y+voffset, nstr);
428 cx += lw;
429 lastspace = nsp;
430 }
431 }
432 QString nstr = str.right(str.length()-1-lastspace);
433 _p->drawText( cx, _y+voffset, nstr);
434 cx += fm.width(nstr);
435 w = cx - currentx;
436 }
437 else
438 {
439 _p->drawText( currentx, _y+voffset, str);
440 w = fm.width(str);
441 }
284 if (currentstyle.isUnderline()) 442 if (currentstyle.isUnderline())
285 { 443 {
286 _p->drawLine( currentx, _y, currentx + w, _y); 444 _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset);
287 } 445 }
288 if (currentstyle.isStrikethru()) 446 if (currentstyle.isStrikethru())
289 { 447 {
290 int ascent = fc->ascent(currentstyle)/3; 448 int ascent = fc->ascent(currentstyle)/3;
291 _p->drawLine( currentx, _y-ascent, currentx + w, _y-ascent); 449 _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset);
292 } 450 }
293 _p->drawText( currentx, _y, str);
294 currentx += w; 451 currentx += w;
295 } 452 }
296 } 453 }
297 } 454 }
298 textstart = textend; 455 textstart = textend;
299 } 456 }
300 while (textend != segs.end() && textstart->start < length()-1); 457 while (textend != segs.end() && textstart->start < len);
301} 458}
302 459
303CStyle CDrawBuffer::laststyle() 460CStyle CDrawBuffer::laststyle()
@@ -314,12 +471,12 @@ linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt)
314 do 471 do
315 { 472 {
316 textend++; 473 textend++;
317 end = (textend != segs.end()) ? textend->start : length(); 474 end = (textend != segs.end()) ? textend->start : len;
318 currentstyle = textstart->style; 475 currentstyle = textstart->style;
319/* 476/*
320 if (currentstyle.isPicture()) qDebug("Passed thru picture"); 477 if (currentstyle.isPicture()) qDebug("Passed thru picture");
321 if (currentstyle.getLink()) qDebug("Passed thru link"); 478 if (currentstyle.getLink()) qDebug("Passed thru link");
322 qDebug("islink:%d - %d", numchars, end); 479 //qDebug("islink:%d - %d", numchars, end);
323*/ 480*/
324 textstart = textend; 481 textstart = textend;
325 } 482 }
@@ -340,9 +497,9 @@ linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt)
340 497
341void CDrawBuffer::resize() 498void CDrawBuffer::resize()
342{ 499{
343 int i; 500 int gzoom = fc->gzoom();
344 m_maxstyle = m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; 501 m_maxstyle = m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0;
345 for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= length(); ) 502 for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; )
346 { 503 {
347 CList<textsegment>::iterator next = iter; 504 CList<textsegment>::iterator next = iter;
348 iter++; 505 iter++;
@@ -357,10 +514,10 @@ void CDrawBuffer::resize()
357 descent = fc->descent(_style); 514 descent = fc->descent(_style);
358 linespacing = fc->lineSpacing(_style); 515 linespacing = fc->lineSpacing(_style);
359 extra = linespacing - ascent - descent; 516 extra = linespacing - ascent - descent;
360 if (_style.isPicture()) 517 if (_style.isPicture() && _style.canScale())
361 { 518 {
362 descent = (_style.getPicture()->height()-ascent)/2; 519 descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2;
363 ascent = (_style.getPicture()->height()+ascent)/2; 520 ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2;
364 } 521 }
365/* 522/*
366 else if (fc != NULL) 523 else if (fc != NULL)
@@ -376,4 +533,18 @@ void CDrawBuffer::resize()
376 if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; 533 if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra;
377 m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; 534 m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing;
378 } 535 }
536 int lead = fc->getlead();
537 if (lead != 0)
538 {
539 int xt = (lead*m_lineSpacing+5)/10;
540 m_descent += xt;
541 m_lineSpacing += xt;
542 }
543 if (m_bSop)
544 {
545 int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10;
546 //qDebug("ExtraSpace:%d", xt);
547 m_ascent += xt;
548 m_lineSpacing += xt;
549 }
379} 550}
diff --git a/noncore/apps/opie-reader/CDrawBuffer.h b/noncore/apps/opie-reader/CDrawBuffer.h
index 0d8968c..9ec0ed9 100644
--- a/noncore/apps/opie-reader/CDrawBuffer.h
+++ b/noncore/apps/opie-reader/CDrawBuffer.h
@@ -4,16 +4,10 @@
4#include "StyleConsts.h" 4#include "StyleConsts.h"
5#include "CBuffer.h" 5#include "CBuffer.h"
6#include "my_list.h" 6#include "my_list.h"
7#include "linktype.h"
7 8
8class QPainter; 9class QPainter;
9 10
10enum linkType
11{
12 eNone,
13 eLink,
14 ePicture
15};
16
17struct textsegment 11struct textsegment
18{ 12{
19 int start; 13 int start;
@@ -33,9 +27,12 @@ class CDrawBuffer : public CBuffer
33 FontControl* fc; 27 FontControl* fc;
34 int m_maxstyle, m_ascent, m_descent, m_lineSpacing, m_lineExtraSpacing; 28 int m_maxstyle, m_ascent, m_descent, m_lineSpacing, m_lineExtraSpacing;
35 bool m_bEof; 29 bool m_bEof;
30 bool m_bSop, m_bEop;
36 CDrawBuffer(const CDrawBuffer&); 31 CDrawBuffer(const CDrawBuffer&);
37 CDrawBuffer& operator=(const tchar*sztmp); 32 CDrawBuffer& operator=(const tchar*sztmp);
38 public: 33 public:
34 void setstartpara() { m_bSop = true; }
35 void setendpara() { m_bEop = true; }
39 int leftMargin(); 36 int leftMargin();
40 int rightMargin(); 37 int rightMargin();
41 void setEof() { m_bEof = true; } 38 void setEof() { m_bEof = true; }
@@ -56,9 +53,9 @@ class CDrawBuffer : public CBuffer
56 empty(); 53 empty();
57 } 54 }
58*/ 55*/
59 int width(int numchars = -1); 56 int width(int numchars = -1, bool onscreen = false, int scwidth = 0, unsigned char _border = 0);
60 int offset(int); 57 int offset(int, unsigned char);
61 void render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scw); 58 void render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scw, unsigned char);
62 void empty(); 59 void empty();
63 void addch(tchar ch, CStyle _style); 60 void addch(tchar ch, CStyle _style);
64 void truncate(int); 61 void truncate(int);
diff --git a/noncore/apps/opie-reader/CEncoding.cpp b/noncore/apps/opie-reader/CEncoding.cpp
index c1dcfe8..60a1057 100644
--- a/noncore/apps/opie-reader/CEncoding.cpp
+++ b/noncore/apps/opie-reader/CEncoding.cpp
@@ -3,14 +3,13 @@
3 3
4void CUtf8::getch(tchar& ch, CStyle& sty) 4void CUtf8::getch(tchar& ch, CStyle& sty)
5{ 5{
6 int iret; 6 tchar ret;
7 parent->getch(iret, sty); 7 parent->getch(ret, sty);
8 if (iret == EOF) 8 if (ret == UEOF)
9 { 9 {
10 ch = UEOF; 10 ch = UEOF;
11 return; 11 return;
12 } 12 }
13 tchar ret = iret;
14 int count = 0; 13 int count = 0;
15 if (ret & (1 << 7)) 14 if (ret & (1 << 7))
16 { 15 {
@@ -18,6 +17,7 @@ void CUtf8::getch(tchar& ch, CStyle& sty)
18 while ((flags & (1 << 7)) != 0) 17 while ((flags & (1 << 7)) != 0)
19 { 18 {
20 ret <<= 6; 19 ret <<= 6;
20 tchar iret;
21 parent->getch(iret, sty); 21 parent->getch(iret, sty);
22 ret += iret & 0x3f; 22 ret += iret & 0x3f;
23 flags <<= 1; 23 flags <<= 1;
@@ -45,9 +45,9 @@ void CUtf8::getch(tchar& ch, CStyle& sty)
45 45
46void CUcs16be::getch(tchar& ch, CStyle& sty) 46void CUcs16be::getch(tchar& ch, CStyle& sty)
47{ 47{
48 int iret; 48 tchar iret;
49 parent->getch(iret, sty); 49 parent->getch(iret, sty);
50 if (iret == EOF) 50 if (iret == UEOF)
51 { 51 {
52 ch = UEOF; 52 ch = UEOF;
53 return; 53 return;
@@ -59,9 +59,9 @@ void CUcs16be::getch(tchar& ch, CStyle& sty)
59 59
60void CUcs16le::getch(tchar& ch, CStyle& sty) 60void CUcs16le::getch(tchar& ch, CStyle& sty)
61{ 61{
62 int iret; 62 tchar iret;
63 parent->getch(iret, sty); 63 parent->getch(iret, sty);
64 if (iret == EOF) 64 if (iret == UEOF)
65 { 65 {
66 ch = UEOF; 66 ch = UEOF;
67 return; 67 return;
@@ -73,12 +73,12 @@ void CUcs16le::getch(tchar& ch, CStyle& sty)
73 73
74void Ccp1252::getch(tchar& ch, CStyle& sty) 74void Ccp1252::getch(tchar& ch, CStyle& sty)
75{ 75{
76 int iret; 76 tchar iret;
77 parent->getch(iret, sty); 77 parent->getch(iret, sty);
78 ch = iret; 78 ch = iret;
79 switch (ch) 79 switch (ch)
80 { 80 {
81 case EOF: 81 case UEOF:
82 ch = UEOF; 82 ch = UEOF;
83 break; 83 break;
84 case 0x80: 84 case 0x80:
@@ -197,9 +197,9 @@ void CPalm::getch(tchar& ch, CStyle& sty)
197 197
198void CAscii::getch(tchar& ch, CStyle& sty) 198void CAscii::getch(tchar& ch, CStyle& sty)
199{ 199{
200 int iret; 200 tchar iret;
201 parent->getch(iret, sty); 201 parent->getch(iret, sty);
202 if (iret == EOF) 202 if (iret == UEOF)
203 { 203 {
204 ch = UEOF; 204 ch = UEOF;
205 } 205 }
diff --git a/noncore/apps/opie-reader/CEncoding.h b/noncore/apps/opie-reader/CEncoding.h
index 86562e7..463fba9 100644
--- a/noncore/apps/opie-reader/CEncoding.h
+++ b/noncore/apps/opie-reader/CEncoding.h
@@ -3,11 +3,14 @@
3 3
4#include "CExpander.h" 4#include "CExpander.h"
5 5
6#define MAX_ENCODING 6
7
6class CEncoding : public CCharacterSource 8class CEncoding : public CCharacterSource
7{ 9{
8 friend class CFilterChain; 10 friend class CFilterChain;
9 protected: 11 protected:
10 CExpander* parent; 12 CExpander* parent;
13 linkType hyperlink(unsigned int n, QString& t) { return parent->hyperlink(n,t); }
11public: 14public:
12 CEncoding() : parent(NULL) {} 15 CEncoding() : parent(NULL) {}
13 void setparent(CExpander* p) { parent = p; } 16 void setparent(CExpander* p) { parent = p; }
@@ -50,4 +53,22 @@ public:
50 void getch(tchar& ch, CStyle& sty); 53 void getch(tchar& ch, CStyle& sty);
51}; 54};
52 55
56#include "CEncoding_tables.h"
57
58class CGeneral8Bit : public CEncoding
59{
60 int m_index;
61 public:
62 CGeneral8Bit(int _i) : m_index(_i)
63 {
64 // qDebug("8Bit:%d", _i);
65 // qDebug("%s", unicodetable::iterator(_i)->mime);
66 }
67 void getch(tchar& ch, CStyle& sty)
68 {
69 parent->getch(ch, sty);
70 ch = unicodetable::unicodevalue(m_index, ch);
71 }
72};
73
53#endif 74#endif
diff --git a/noncore/apps/opie-reader/CExpander.h b/noncore/apps/opie-reader/CExpander.h
index c281398..7b21d3e 100644
--- a/noncore/apps/opie-reader/CExpander.h
+++ b/noncore/apps/opie-reader/CExpander.h
@@ -1,16 +1,20 @@
1#ifndef __CExpander_h 1#ifndef __CExpander_h
2#define __CExpander_h 2#define __CExpander_h
3 3
4#ifndef _WINDOWS
4#include <unistd.h> 5#include <unistd.h>
6#endif
5#include <stdio.h> 7#include <stdio.h>
6#include <time.h> 8#include <time.h>
7#include <qmessagebox.h> 9#include <qmessagebox.h>
10#include "useqpe.h"
8#include "config.h" 11#include "config.h"
9#include "StyleConsts.h" 12#include "StyleConsts.h"
10#include "Markups.h" 13#include "Markups.h"
11#include "name.h" 14#include "names.h"
15#include "linktype.h"
12 16
13class QPixmap; 17class QImage;
14class Bkmk; 18class Bkmk;
15 19
16template<class T> 20template<class T>
@@ -20,6 +24,7 @@ class CCharacterSource
20{ 24{
21 public: 25 public:
22 virtual void getch(tchar&, CStyle&) = 0; 26 virtual void getch(tchar&, CStyle&) = 0;
27 virtual linkType hyperlink(unsigned int n, QString&) = 0;
23}; 28};
24 29
25class CExpander 30class CExpander
@@ -31,11 +36,15 @@ class CExpander
31 bool bSuspended; 36 bool bSuspended;
32 size_t suspos; 37 size_t suspos;
33 time_t sustime; 38 time_t sustime;
39 int m_scrWidth;
40 unsigned long m_currentstart, m_currentend;
34 public: 41 public:
35 virtual void suspend() = 0; 42#ifdef USEQPE
43 virtual void suspend() = 0;
36 virtual void unsuspend() = 0; 44 virtual void unsuspend() = 0;
45#endif
37 size_t getHome() { return m_homepos; } 46 size_t getHome() { return m_homepos; }
38 CExpander() : m_homepos(0), fname(NULL) {}; 47 CExpander() : m_homepos(0), fname(NULL), m_scrWidth(240), m_currentstart(1), m_currentend(0) {};
39 virtual ~CExpander() { if (fname != NULL) delete [] fname; }; 48 virtual ~CExpander() { if (fname != NULL) delete [] fname; };
40 int openfile(const char *src) 49 int openfile(const char *src)
41 { 50 {
@@ -49,35 +58,51 @@ class CExpander
49 virtual bool hasrandomaccess() = 0; 58 virtual bool hasrandomaccess() = 0;
50 virtual void sizes(unsigned long& file, unsigned long& text) = 0; 59 virtual void sizes(unsigned long& file, unsigned long& text) = 0;
51 virtual CList<Bkmk>* getbkmklist() { return NULL; } 60 virtual CList<Bkmk>* getbkmklist() { return NULL; }
52 virtual void getch(int& ch, CStyle& sty) 61 virtual void getch(tchar& ch, CStyle& sty)
53 { 62 {
54 ch = getch(); 63 int ich = getch();
64 ch = (ich == EOF) ? UEOF : ich;
55 sty.unset(); 65 sty.unset();
56 } 66 }
57 virtual int getch() = 0; 67 virtual int getch() = 0;
58 virtual bool hyperlink(unsigned int n) 68 virtual linkType hyperlink(unsigned int n, QString& wrd)
59 { 69 {
60 locate(n); 70 locate(n);
61 return true; 71 return eLink;
62 } 72 }
63 virtual MarkupType PreferredMarkup() = 0; 73 virtual MarkupType PreferredMarkup() = 0;
64 virtual void saveposn(size_t posn) {} 74 virtual void saveposn(size_t posn) {}
65 virtual bool forward(size_t& loc) {} 75 virtual void writeposn(size_t posn) {}
66 virtual bool back(size_t& loc) {} 76 virtual bool forward(size_t& loc) { return false; }
77 virtual bool back(size_t& loc) { return false; }
67 virtual bool hasnavigation() { return false; } 78 virtual bool hasnavigation() { return false; }
68 virtual unsigned long startSection() 79 unsigned long startSection()
80 {
81 unsigned long current = locate();
82 if (m_currentstart > current || current > m_currentend)
83 {
84 start2endSection();
85 }
86 return m_currentstart;
87 }
88 unsigned long endSection()
69 { 89 {
70 return 0; 90 unsigned long current = locate();
91 if (m_currentstart > current || current > m_currentend)
92 {
93 start2endSection();
94 }
95 return m_currentend;
71 } 96 }
72 virtual unsigned long endSection() 97 virtual void start2endSection()
73 { 98 {
74 unsigned long file, text; 99 m_currentstart = 0;
75 sizes(file, text); 100 unsigned long file;
76 return text; 101 sizes(file, m_currentend);
77 } 102 }
78 virtual QPixmap* getPicture(unsigned long tgt) { return NULL; } 103 virtual QImage* getPicture(unsigned long tgt) { return NULL; }
79 void setContinuous(bool _b) { m_continuous = _b; } 104 void setContinuous(bool _b) { m_continuous = _b; }
80 105#ifdef USEQPE
81 virtual void suspend(FILE*& fin) 106 virtual void suspend(FILE*& fin)
82 { 107 {
83 bSuspended = true; 108 bSuspended = true;
@@ -107,6 +132,7 @@ class CExpander
107 suspos = fseek(fin, suspos, SEEK_SET); 132 suspos = fseek(fin, suspos, SEEK_SET);
108 } 133 }
109 } 134 }
135#endif
110 virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) 136 virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
111 { 137 {
112 len = srclen; 138 len = srclen;
@@ -120,5 +146,6 @@ class CExpander
120 qDebug("Don't know what to do with non-zero save data"); 146 qDebug("Don't know what to do with non-zero save data");
121 } 147 }
122 } 148 }
149 void setwidth(int w) { m_scrWidth = w; }
123}; 150};
124#endif 151#endif
diff --git a/noncore/apps/opie-reader/CFilter.cpp b/noncore/apps/opie-reader/CFilter.cpp
index d5e3116..73a0872 100644
--- a/noncore/apps/opie-reader/CFilter.cpp
+++ b/noncore/apps/opie-reader/CFilter.cpp
@@ -682,3 +682,61 @@ void repalm::getch(tchar& ch, CStyle& sty)
682 } 682 }
683} 683}
684#endif 684#endif
685
686//static tchar nextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 };
687//static tchar prevpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','p','r','e','v','i','o','u','s',' ','p','a','r','t',0 };
688
689void DePluck::getch(tchar& ch, CStyle& sty)
690{
691 if (m_buffed > 0)
692 {
693 sty = m_laststyle;
694 ch = nextpart[m_current++];
695 if (m_current == m_buffed)
696 {
697 m_current = m_buffed = 0;
698 }
699 }
700 else
701 {
702 if (m_buffer != 0)
703 {
704 ch = m_buffer;
705 m_buffer = 0;
706 return;
707 }
708 unsigned long lnk;
709 do
710 {
711 if (nextpart[m_buffed] == 0) break;
712 parent->getch(ch, sty);
713 m_laststyle = sty;
714 if (sty.getLink()) lnk = sty.getData();
715 } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed);
716 m_current = 0;
717 if (nextpart[m_buffed] == 0)
718 {
719 m_buffed = 0;
720 QString dmy;
721 parent->hyperlink(lnk, dmy);
722 do
723 {
724 parent->getch(ch, sty);
725 }
726 while (ch != 10);
727 parent->getch(ch, sty);
728 }
729 else if (m_buffed > 0)
730 {
731 m_buffer = ch;
732 ch = nextpart[0];
733 if (m_buffed == 1)
734 {
735 m_buffed = 0;
736 }
737 else m_current = 1;
738 }
739 }
740
741 return;
742}
diff --git a/noncore/apps/opie-reader/CFilter.h b/noncore/apps/opie-reader/CFilter.h
index 2d0c30f..0a03b3e 100644
--- a/noncore/apps/opie-reader/CFilter.h
+++ b/noncore/apps/opie-reader/CFilter.h
@@ -9,6 +9,10 @@ class CFilter : public CCharacterSource
9 friend class CFilterChain; 9 friend class CFilterChain;
10 protected: 10 protected:
11 CCharacterSource* parent; 11 CCharacterSource* parent;
12 linkType hyperlink(unsigned int n, QString& w)
13 {
14 return parent->hyperlink(n,w);
15 }
12 public: 16 public:
13 CFilter() : parent(NULL) {} 17 CFilter() : parent(NULL) {}
14 void setparent(CCharacterSource* p) { parent = p; } 18 void setparent(CCharacterSource* p) { parent = p; }
@@ -69,8 +73,8 @@ class stripcr : public CFilter
69{ 73{
70 public: 74 public:
71 stripcr() {} 75 stripcr() {}
72 virtual ~stripcr() {} 76 ~stripcr() {}
73 virtual void getch(tchar& ch, CStyle& sty) 77 void getch(tchar& ch, CStyle& sty)
74 { 78 {
75 do 79 do
76 { 80 {
@@ -87,8 +91,8 @@ class dehyphen : public CFilter
87 CStyle m_nextSty; 91 CStyle m_nextSty;
88 public: 92 public:
89 dehyphen() : m_bCharWaiting(false) {} 93 dehyphen() : m_bCharWaiting(false) {}
90 virtual ~dehyphen() {} 94 ~dehyphen() {}
91 virtual void getch(tchar& ch, CStyle& sty) 95 void getch(tchar& ch, CStyle& sty)
92 { 96 {
93 if (m_bCharWaiting) 97 if (m_bCharWaiting)
94 { 98 {
@@ -119,8 +123,8 @@ class striphtml : public CFilter
119 void mygetch(tchar& ch, CStyle& sty); 123 void mygetch(tchar& ch, CStyle& sty);
120 public: 124 public:
121 striphtml() {} 125 striphtml() {}
122 virtual ~striphtml() {} 126 ~striphtml() {}
123 virtual void getch(tchar& ch, CStyle& sty); 127 void getch(tchar& ch, CStyle& sty);
124}; 128};
125 129
126class unindent : public CFilter 130class unindent : public CFilter
@@ -128,8 +132,8 @@ class unindent : public CFilter
128 tchar lc; 132 tchar lc;
129 public: 133 public:
130 unindent() : lc(0) {} 134 unindent() : lc(0) {}
131 virtual ~unindent() {} 135 ~unindent() {}
132 virtual void getch(tchar& ch, CStyle& sty) 136 void getch(tchar& ch, CStyle& sty)
133 { 137 {
134 if (lc == 10) 138 if (lc == 10)
135 { 139 {
@@ -150,8 +154,8 @@ class repara : public CFilter
150 tchar tch; 154 tchar tch;
151 public: 155 public:
152 repara() : tch(0) {} 156 repara() : tch(0) {}
153 virtual ~repara() {} 157 ~repara() {}
154 virtual void getch(tchar& ch, CStyle& sty) 158 void getch(tchar& ch, CStyle& sty)
155 { 159 {
156 parent->getch(ch, sty); 160 parent->getch(ch, sty);
157 if (ch == 10) 161 if (ch == 10)
@@ -179,8 +183,8 @@ class indenter : public CFilter
179 CStyle lsty; 183 CStyle lsty;
180 public: 184 public:
181 indenter(int _a=5) : amnt(_a), indent(0) {} 185 indenter(int _a=5) : amnt(_a), indent(0) {}
182 virtual ~indenter() {} 186 ~indenter() {}
183 virtual void getch(tchar& ch, CStyle& sty) 187 void getch(tchar& ch, CStyle& sty)
184 { 188 {
185 if (indent > 0) 189 if (indent > 0)
186 { 190 {
@@ -205,8 +209,8 @@ class dblspce : public CFilter
205 CStyle lsty; 209 CStyle lsty;
206 public: 210 public:
207 dblspce() : lastlf(false) {} 211 dblspce() : lastlf(false) {}
208 virtual ~dblspce() {} 212 ~dblspce() {}
209 virtual void getch(tchar& ch, CStyle& sty) 213 void getch(tchar& ch, CStyle& sty)
210 { 214 {
211 if (lastlf) 215 if (lastlf)
212 { 216 {
@@ -232,16 +236,16 @@ class textfmt : public CFilter
232 void mygetch(tchar&, CStyle&); 236 void mygetch(tchar&, CStyle&);
233 public: 237 public:
234 textfmt() : lastchar(0), uselast(false) {} 238 textfmt() : lastchar(0), uselast(false) {}
235 virtual ~textfmt() {} 239 ~textfmt() {}
236 virtual void getch(tchar& ch, CStyle& sty); 240 void getch(tchar& ch, CStyle& sty);
237}; 241};
238 242
239class embolden : public CFilter 243class embolden : public CFilter
240{ 244{
241 public: 245 public:
242 embolden() {} 246 embolden() {}
243 virtual ~embolden() {} 247 ~embolden() {}
244 virtual void getch(tchar& ch, CStyle& sty) 248 void getch(tchar& ch, CStyle& sty)
245 { 249 {
246 parent->getch(ch, sty); 250 parent->getch(ch, sty);
247 sty.setBold(); 251 sty.setBold();
@@ -255,16 +259,16 @@ class remap : public CFilter
255 CStyle currentstyle; 259 CStyle currentstyle;
256 public: 260 public:
257 remap() : offset(0) { q[0] = 0; } 261 remap() : offset(0) { q[0] = 0; }
258 virtual ~remap() {} 262 ~remap() {}
259 virtual void getch(tchar& ch, CStyle& sty); 263 void getch(tchar& ch, CStyle& sty);
260}; 264};
261 265
262class PeanutFormatter : public CFilter 266class PeanutFormatter : public CFilter
263{ 267{
264 CStyle currentstyle; 268 CStyle currentstyle;
265 public: 269 public:
266 virtual ~PeanutFormatter() {} 270 ~PeanutFormatter() {}
267 virtual void getch(tchar& ch, CStyle& sty); 271 void getch(tchar& ch, CStyle& sty);
268}; 272};
269 273
270class OnePara : public CFilter 274class OnePara : public CFilter
@@ -272,16 +276,53 @@ class OnePara : public CFilter
272 tchar m_lastchar; 276 tchar m_lastchar;
273 public: 277 public:
274 OnePara() : m_lastchar(0) {} 278 OnePara() : m_lastchar(0) {}
275 virtual ~OnePara() {} 279 ~OnePara() {}
276 virtual void getch(tchar& ch, CStyle& sty); 280 void getch(tchar& ch, CStyle& sty);
281};
282
283class DePluck : public CFilter
284{
285 tchar* nextpart;
286 tchar m_buffer;
287 int m_buffed;
288 int m_current;
289 bool m_debuff;
290 CStyle m_laststyle;
291 public:
292 DePluck(tchar* t) : nextpart(t), m_buffer(0), m_buffed(0), m_current(0), m_debuff(false) {}
293 ~DePluck() {}
294 void getch(tchar& ch, CStyle& sty);
277}; 295};
278 296
279#ifdef REPALM 297#ifdef REPALM
280class repalm : public CFilter 298class repalm : public CFilter
281{ 299{
282 public: 300 public:
283 virtual ~repalm() {} 301 ~repalm() {}
284 virtual void getch(tchar& ch, CStyle& sty); 302 void getch(tchar& ch, CStyle& sty);
285}; 303};
286#endif 304#endif
305
306class FullJust : public CFilter
307{
308 public:
309 void getch(tchar& ch, CStyle& sty)
310 {
311 parent->getch(ch, sty);
312 if (sty.getJustify() == m_AlignLeft) sty.setFullJustify();
313 }
314};
315/*
316class AddSpace : public CFilter
317{
318 unsigned char m_espc;
319 public:
320 AddSpace(unsigned char s) : m_espc(s) {}
321 void getch(tchar& ch, CStyle& sty)
322 {
323 parent->getch(ch, sty);
324 sty.setExtraSpace(m_espc);
325 }
326};
327*/
287#endif 328#endif
diff --git a/noncore/apps/opie-reader/Filedata.h b/noncore/apps/opie-reader/Filedata.h
index f920238..096dd31 100644
--- a/noncore/apps/opie-reader/Filedata.h
+++ b/noncore/apps/opie-reader/Filedata.h
@@ -26,11 +26,11 @@ class CFiledata
26 if (m_own && data != NULL) 26 if (m_own && data != NULL)
27 { 27 {
28 delete [] data; 28 delete [] data;
29 qDebug("~Filedata: deleting"); 29 // qDebug("~Filedata: deleting");
30 } 30 }
31 else 31 else
32 { 32 {
33 qDebug("~Filedata: not deleting"); 33 // qDebug("~Filedata: not deleting");
34 } 34 }
35 } 35 }
36 tchar* name() const { return (tchar*)(data+sizeof(time_t)); } 36 tchar* name() const { return (tchar*)(data+sizeof(time_t)); }
diff --git a/noncore/apps/opie-reader/FontControl.cpp b/noncore/apps/opie-reader/FontControl.cpp
index f0ed98b..e03bf64 100644
--- a/noncore/apps/opie-reader/FontControl.cpp
+++ b/noncore/apps/opie-reader/FontControl.cpp
@@ -1,6 +1,29 @@
1#include "opie.h" 1#include "opie.h"
2#include "useqpe.h"
2#include "FontControl.h" 3#include "FontControl.h"
3 4
5int FontControl::gzoom()
6{
7 int ret;
8 if (m_size == g_size)
9 {
10 ret = m_fontsizes[m_size]*m_basesize;
11 }
12 else if (g_size < 0)
13 {
14 int f = -g_size;
15 ret = (m_fontsizes[0]*m_basesize) >> (f/2);
16 if (f%2) ret = (2*ret/3);
17 }
18 else
19 {
20 int f = g_size - m_maxsize + 1;
21 ret = (m_fontsizes[m_maxsize-1]*m_basesize) << (f/2);
22 if (f%2) ret = (3*ret/2);
23 }
24 return ret;
25}
26
4bool FontControl::ChangeFont(QString& n, int tgt) 27bool FontControl::ChangeFont(QString& n, int tgt)
5{ 28{
6 QValueList<int>::Iterator it; 29 QValueList<int>::Iterator it;
@@ -20,7 +43,7 @@ bool FontControl::ChangeFont(QString& n, int tgt)
20 uint best = 0; 43 uint best = 0;
21 for (it = sizes.begin(); it != sizes.end(); it++) 44 for (it = sizes.begin(); it != sizes.end(); it++)
22 { 45 {
23#ifdef OPIE 46#if defined(OPIE) || !defined(USEQPE)
24 m_fontsizes[i] = (*it); 47 m_fontsizes[i] = (*it);
25#else 48#else
26 m_fontsizes[i] = (*it)/10; 49 m_fontsizes[i] = (*it)/10;
@@ -31,7 +54,7 @@ bool FontControl::ChangeFont(QString& n, int tgt)
31 } 54 }
32 i++; 55 i++;
33 } 56 }
34 m_size = best; 57 g_size = m_size = best;
35 } 58 }
36 return true; 59 return true;
37} 60}
diff --git a/noncore/apps/opie-reader/FontControl.h b/noncore/apps/opie-reader/FontControl.h
index 02049d0..5681496 100644
--- a/noncore/apps/opie-reader/FontControl.h
+++ b/noncore/apps/opie-reader/FontControl.h
@@ -8,14 +8,20 @@
8class FontControl 8class FontControl
9{ 9{
10 int * m_fontsizes; 10 int * m_fontsizes;
11 int m_size; 11 int m_size, g_size;
12 QString m_fontname; 12 QString m_fontname;
13 QString m_fixedfontname;
13 int m_maxsize; 14 int m_maxsize;
14 bool m_hasCourier; 15 bool m_hasCourier;
16 int m_leading, m_extraspace;
17 unsigned char m_basesize;
15 public: 18 public:
19 void setBaseSize(unsigned char _s) { m_basesize = _s; }
20 unsigned char getBaseSize() { return m_basesize; }
21 int gzoom();
16 FontControl(QString n = "helvetica", int size = 10) 22 FontControl(QString n = "helvetica", int size = 10)
17 : 23 :
18 m_fontsizes(NULL), m_hasCourier(false) 24 m_fontsizes(NULL), m_hasCourier(false), m_leading(0), m_extraspace(0)
19 { 25 {
20 ChangeFont(n, size); 26 ChangeFont(n, size);
21 } 27 }
@@ -23,11 +29,16 @@ class FontControl
23 { 29 {
24 if (m_fontsizes != NULL) delete [] m_fontsizes; 30 if (m_fontsizes != NULL) delete [] m_fontsizes;
25 } 31 }
26 void hasCourier(bool _b) { m_hasCourier = _b; } 32 void hasCourier(bool _b, const QString& _nm)
33 {
34 m_hasCourier = _b;
35 m_fixedfontname = _nm;
36 }
37 QString& fixedfontname() { return m_fixedfontname; }
27 bool hasCourier() { return m_hasCourier; } 38 bool hasCourier() { return m_hasCourier; }
28 QString name() { return m_fontname; } 39 QString name() { return m_fontname; }
29 int currentsize() { return m_fontsizes[m_size]; } 40 int currentsize() { return m_fontsizes[m_size]; }
30 int getsize(CStyle size) 41 int getsize(const CStyle& size)
31 { 42 {
32 int tgt = m_size+size.getFontSize(); 43 int tgt = m_size+size.getFontSize();
33 if (tgt < 0) 44 if (tgt < 0)
@@ -46,7 +57,7 @@ class FontControl
46 QFontMetrics fm(f); 57 QFontMetrics fm(f);
47 return fm.ascent(); 58 return fm.ascent();
48 } 59 }
49 int ascent(CStyle ch) 60 int ascent(const CStyle& ch)
50 { 61 {
51 QFont f(name(), getsize(ch)); 62 QFont f(name(), getsize(ch));
52 QFontMetrics fm(f); 63 QFontMetrics fm(f);
@@ -58,7 +69,7 @@ class FontControl
58 QFontMetrics fm(f); 69 QFontMetrics fm(f);
59 return fm.descent(); 70 return fm.descent();
60 } 71 }
61 int descent(CStyle ch) 72 int descent(const CStyle& ch)
62 { 73 {
63 QFont f(name(), getsize(ch)); 74 QFont f(name(), getsize(ch));
64 QFontMetrics fm(f); 75 QFontMetrics fm(f);
@@ -70,7 +81,7 @@ class FontControl
70 QFontMetrics fm(f); 81 QFontMetrics fm(f);
71 return fm.lineSpacing(); 82 return fm.lineSpacing();
72 } 83 }
73 int lineSpacing(CStyle ch) 84 int lineSpacing(const CStyle& ch)
74 { 85 {
75 QFont f(name(), getsize(ch)); 86 QFont f(name(), getsize(ch));
76 QFontMetrics fm(f); 87 QFontMetrics fm(f);
@@ -78,27 +89,65 @@ class FontControl
78 } 89 }
79 bool decreasesize() 90 bool decreasesize()
80 { 91 {
92/*
81 if (--m_size < 0) 93 if (--m_size < 0)
82 { 94 {
83 m_size = 0; 95 m_size = 0;
84 return false; 96 return false;
85 } 97 }
86 else return true; 98 else return true;
99*/
100 if (g_size-- == m_size)
101 {
102 if (--m_size < 0)
103 {
104 m_size = 0;
105 }
106 }
107 // qDebug("Font:%d Graphics:%d", m_size, g_size);
108 return true;
87 } 109 }
88 bool increasesize() 110 bool increasesize()
89 { 111 {
112/*
90 if (++m_size >= m_maxsize) 113 if (++m_size >= m_maxsize)
91 { 114 {
92 m_size = m_maxsize - 1; 115 m_size = m_maxsize - 1;
93 return false; 116 return false;
94 } 117 }
95 else return true; 118 else return true;
119*/
120 if (g_size++ == m_size)
121 {
122 if (++m_size >= m_maxsize)
123 {
124 m_size = m_maxsize - 1;
125 }
126 }
127 // qDebug("Font:%d Graphics:%d", m_size, g_size);
128 return true;
96 } 129 }
97 bool ChangeFont(QString& n) 130 bool ChangeFont(QString& n)
98 { 131 {
99 return ChangeFont(n, currentsize()); 132 return ChangeFont(n, currentsize());
100 } 133 }
101 bool ChangeFont(QString& n, int tgt); 134 bool ChangeFont(QString& n, int tgt);
135 void setlead(int _lead)
136 {
137 m_leading = _lead;
138 }
139 int getlead()
140 {
141 return m_leading;
142 }
143 void setextraspace(int _lead)
144 {
145 m_extraspace = _lead;
146 }
147 int getextraspace()
148 {
149 return m_extraspace;
150 }
102}; 151};
103 152
104#endif 153#endif
diff --git a/noncore/apps/opie-reader/Navigation.cpp b/noncore/apps/opie-reader/Navigation.cpp
index 4f11887..36e33b4 100644
--- a/noncore/apps/opie-reader/Navigation.cpp
+++ b/noncore/apps/opie-reader/Navigation.cpp
@@ -1,62 +1,80 @@
1#include "Navigation.h" 1#ifdef _WINDOWS
2
3#include <string.h> 2#include <string.h>
3#endif
4#include "Navigation.h"
5//#include <stdio.h>
4 6
7/*
8 void saveposn(size_t posn)
9 save/push position to history buffer for future use of back() function
10*/
5void CNavigation::saveposn(size_t posn) 11void CNavigation::saveposn(size_t posn)
6{ 12{
7// qDebug("Saved:%u [%u,%u,%u]", posn, historystart, historycurrent, historyend); 13 //printf("saving position %u, depth %u\n",posn,historycurrent);
8 historycurrent = historyend = (historycurrent+1)%NAVIGATION_HISTORY_SIZE;
9 history[historycurrent] = posn; 14 history[historycurrent] = posn;
10 if (historystart == historyend) historystart = (historystart+1)%NAVIGATION_HISTORY_SIZE; 15 historycurrent=(historycurrent+1)%NAVIGATION_HISTORY_SIZE;
11// qDebug("Saved:%u [%u,%u,%u]", posn, historystart, historycurrent, historyend); 16 if (historycurrent==historystart)
17 // circular buffer full, forget oldest record
18 historystart=(historystart+1)%NAVIGATION_HISTORY_SIZE;
19 // no forward possible after saveposn
20 historyend = historycurrent;
12} 21}
13 22
14bool CNavigation::forward(size_t& loc) 23/*
24 void writeposn(size_t posn)
25 overwrite current (unused) position
26 useful for saving current position before using back button
27*/
28void CNavigation::writeposn(size_t posn)
15{ 29{
16 if (historycurrent != historyend) 30 //printf("witing position %u, depth %u\n",posn,historycurrent);
17 { 31 history[historycurrent] = posn;
18 historycurrent = (historycurrent + 1)%NAVIGATION_HISTORY_SIZE;
19 loc = history[historycurrent];
20 //qDebug("Forward:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend);
21 return true;
22 }
23 else
24 {
25 return false;
26 }
27} 32}
28 33
29bool CNavigation::back(size_t& loc) 34/*
35 bool back(size_t& posn)
36 go back in history
37 restore last position saved with saveposn() and return true
38 return false if there is nothing saved in history
39*/
40bool CNavigation::back(size_t& posn)
30{ 41{
31 if (historyend != historystart) 42 if (historycurrent!=historystart) {
32 { 43 // buffer is not empty
33 //qDebug("Back:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend); 44 if (historycurrent==0)
34 if (historycurrent == historyend && history[historycurrent] != loc) 45 historycurrent=NAVIGATION_HISTORY_SIZE-1;
35 { 46 else
36 historyend = (historyend+1) % NAVIGATION_HISTORY_SIZE; 47 historycurrent--;
37 history[historyend] = loc; 48 posn=history[historycurrent];
38 } 49 //printf("back(): going back to %u depth %u\n",posn,historycurrent);
39 else 50 return true;
40 { 51
41 size_t sv = historycurrent; 52 } else {
42 historycurrent = (historycurrent + NAVIGATION_HISTORY_SIZE - 1) % NAVIGATION_HISTORY_SIZE; 53 // circular buffer empty
43 if (historycurrent == historystart) 54 //printf("back(): empty history\n");
44 { 55 return false;
45 historycurrent = sv;
46 return false;
47 }
48 }
49 loc = history[historycurrent];
50 //qDebug("Back:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend);
51 return true;
52 }
53 else
54 {
55 return false;
56 } 56 }
57} 57}
58 58
59#include <stdio.h> 59/*
60 bool forward(size_t& posn)
61 go forward in history, if possible
62 undo calling of back()
63*/
64bool CNavigation::forward(size_t& posn)
65{
66 if (historycurrent!=historyend) {
67 // [historycurrent] = current position
68 // [historycurrent+1] = position we need
69 historycurrent=(historycurrent+1)%NAVIGATION_HISTORY_SIZE;
70 posn = history[historycurrent];
71 //printf("forward(): going to position %d\n",posn);
72 return true;
73 } else {
74 //printf("forward(): there is no future :)\n");
75 return false;
76 }
77}
60 78
61void CNavigation::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) 79void CNavigation::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
62{ 80{
@@ -72,10 +90,12 @@ void CNavigation::setSaveData(unsigned char*& data, unsigned short& len, unsigne
72 memcpy(p, &historycurrent, sizeof(size_t)); 90 memcpy(p, &historycurrent, sizeof(size_t));
73 p += sizeof(size_t); 91 p += sizeof(size_t);
74 memcpy(p, history, sizeof(size_t)*NAVIGATION_HISTORY_SIZE); 92 memcpy(p, history, sizeof(size_t)*NAVIGATION_HISTORY_SIZE);
93/*
75 printf("<%u,%u,%u>\n", historystart, historyend, historycurrent); 94 printf("<%u,%u,%u>\n", historystart, historyend, historycurrent);
76 for (int i = historystart; i <= historyend; i++) 95 for (int i = historystart; i <= historyend; i++)
77 printf("<%u> ", history[i]); 96 printf("<%u> ", history[i]);
78 printf("\n"); 97 printf("\n");
98*/
79} 99}
80 100
81void CNavigation::putSaveData(unsigned char*& src, unsigned short& srclen) 101void CNavigation::putSaveData(unsigned char*& src, unsigned short& srclen)
@@ -93,8 +113,10 @@ void CNavigation::putSaveData(unsigned char*& src, unsigned short& srclen)
93 src = p + sizeof(size_t)*NAVIGATION_HISTORY_SIZE; 113 src = p + sizeof(size_t)*NAVIGATION_HISTORY_SIZE;
94 srclen -= sizeof(size_t)*(3+NAVIGATION_HISTORY_SIZE); 114 srclen -= sizeof(size_t)*(3+NAVIGATION_HISTORY_SIZE);
95 } 115 }
116/*
96 printf("<%u,%u,%u>\n", historystart, historyend, historycurrent); 117 printf("<%u,%u,%u>\n", historystart, historyend, historycurrent);
97 for (int i = historystart; i <= historyend; i++) 118 for (int i = historystart; i <= historyend; i++)
98 printf("<%u> ", history[i]); 119 printf("<%u> ", history[i]);
99 printf("\n"); 120 printf("\n");
121*/
100} 122}
diff --git a/noncore/apps/opie-reader/Navigation.h b/noncore/apps/opie-reader/Navigation.h
index 57fb006..19d7f81 100644
--- a/noncore/apps/opie-reader/Navigation.h
+++ b/noncore/apps/opie-reader/Navigation.h
@@ -1,3 +1,4 @@
1#include <string.h>
1#include <stdlib.h> 2#include <stdlib.h>
2 3
3const size_t NAVIGATION_HISTORY_SIZE = 32; 4const size_t NAVIGATION_HISTORY_SIZE = 32;
@@ -9,6 +10,7 @@ class CNavigation
9 public: 10 public:
10 CNavigation() : historystart(0),historyend(0),historycurrent(0) {} 11 CNavigation() : historystart(0),historyend(0),historycurrent(0) {}
11 void saveposn(size_t posn); 12 void saveposn(size_t posn);
13 void writeposn(size_t posn);
12 bool forward(size_t& loc); 14 bool forward(size_t& loc);
13 bool back(size_t& loc); 15 bool back(size_t& loc);
14 void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen); 16 void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen);
diff --git a/noncore/apps/opie-reader/Palm2QImage.cpp b/noncore/apps/opie-reader/Palm2QImage.cpp
index 9603877..bf5ece3 100644
--- a/noncore/apps/opie-reader/Palm2QImage.cpp
+++ b/noncore/apps/opie-reader/Palm2QImage.cpp
@@ -1,9 +1,10 @@
1/* -*- mode: c; indent-tabs-mode: nil; -*- */ 1/* -*- mode: c; indent-tabs-mode: nil; -*- */
2#include "useqpe.h"
2#include <stdio.h> 3#include <stdio.h>
3#include <stdlib.h> 4#include <stdlib.h>
4#include <string.h> 5#include <string.h>
5#ifndef WINDOWS 6#ifndef _WINDOWS
6#include <unistd.h> /* for link */ 7#include <unistd.h> /* for link */
7#endif 8#endif
8#include <sys/types.h> 9#include <sys/types.h>
9#include <sys/stat.h> 10#include <sys/stat.h>
@@ -202,11 +203,11 @@ QImage* Palm2QImage
202 return NULL; 203 return NULL;
203 } 204 }
204 205
205#ifdef WINDOWS 206#ifndef USEQPE
206 QImage* qimage = new QImage(width, height, 32); 207 QImage* qimage = new QImage(width, height, 32);
207#else 208#else
208 QImage* qimage = new QImage(width, height, 16); 209 QImage* qimage = new QImage(width, height, 16);
209#endif 210#endif
210 211
211 /* row by row, uncompress the Palm image and copy it to the JPEG buffer */ 212 /* row by row, uncompress the Palm image and copy it to the JPEG buffer */
212 rowbuf = new unsigned char[bytes_per_row * width]; 213 rowbuf = new unsigned char[bytes_per_row * width];
diff --git a/noncore/apps/opie-reader/Palm2QImage.h b/noncore/apps/opie-reader/Palm2QImage.h
index 3ac2d19..5d327c5 100644
--- a/noncore/apps/opie-reader/Palm2QImage.h
+++ b/noncore/apps/opie-reader/Palm2QImage.h
@@ -4,4 +4,4 @@
4QImage* Palm2QImage 4QImage* Palm2QImage
5(unsigned char *image_bytes_in, int byte_count_in); 5(unsigned char *image_bytes_in, int byte_count_in);
6 6
7QPixmap* hRule(int w, int h, unsigned char r=0, unsigned char g=0, unsigned char b=0); 7QImage* hRule(int w, int h, unsigned char r=0, unsigned char g=0, unsigned char b=0);
diff --git a/noncore/apps/opie-reader/QFloatBar.h b/noncore/apps/opie-reader/QFloatBar.h
index bc70566..cc98233 100644
--- a/noncore/apps/opie-reader/QFloatBar.h
+++ b/noncore/apps/opie-reader/QFloatBar.h
@@ -2,6 +2,7 @@
2#define __QFLOATBAR_H 2#define __QFLOATBAR_H
3 3
4#include <qtoolbar.h> 4#include <qtoolbar.h>
5#include <qmainwindow.h>
5 6
6class QFloatBar : public QToolBar 7class QFloatBar : public QToolBar
7{ 8{
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp
index f2ee027..03c8fbe 100644
--- a/noncore/apps/opie-reader/QTReader.cpp
+++ b/noncore/apps/opie-reader/QTReader.cpp
@@ -8,21 +8,27 @@
8** 8**
9*****************************************************************************/ 9*****************************************************************************/
10 10
11#include "useqpe.h"
11#include <qpainter.h> 12#include <qpainter.h>
13#include <qimage.h>
14#include <qtimer.h>
12#include "config.h" 15#include "config.h"
13#include "QTReader.h" 16#include "QTReader.h"
14#include "QTReaderApp.h" 17#include "QTReaderApp.h"
15#include "CDrawBuffer.h" 18#include "CDrawBuffer.h"
19#ifdef USEQPE
16#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#endif
17#include <math.h> 22#include <math.h>
18#include <ctype.h> 23#include <ctype.h>
19#include <stdio.h> //for sprintf 24#include <stdio.h> //for sprintf
25#ifdef USEQPE
20#include <qpe/config.h> 26#include <qpe/config.h>
21#include <qpe/applnk.h> 27#include <qpe/applnk.h>
22#include <qfontdatabase.h>
23#include <qpe/global.h> 28#include <qpe/global.h>
24#include <qpe/qcopenvelope_qws.h> 29#include <qpe/qcopenvelope_qws.h>
25#include "StateData.h" 30#endif
31#include <qfontdatabase.h>
26 32
27#ifdef _UNICODE 33#ifdef _UNICODE
28const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; 34const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 };
@@ -36,6 +42,10 @@ const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 };
36//const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; 42//const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 };
37//const int QTReader::fontsizes[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0}; 43//const int QTReader::fontsizes[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0};
38 44
45tchar QTReader::pluckernextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 };
46tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>','>',0 };
47//tchar QTReader::jplucknextpart[] = { 10,'#',10,'N','e','x','t',' ','P','a','r','t',' ','>','>',0 };
48
39QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : 49QTReader::QTReader( QWidget *parent, const char *name, WFlags f) :
40 QWidget(parent, name, f), 50 QWidget(parent, name, f),
41 m_delay(100), 51 m_delay(100),
@@ -51,13 +61,18 @@ QTReader::QTReader( QWidget *parent, const char *name, WFlags f) :
51 m_twotouch(true), 61 m_twotouch(true),
52 m_touchone(true), 62 m_touchone(true),
53 bDoUpdates(false), 63 bDoUpdates(false),
54 m_navkeys(true) 64#ifdef _SCROLLPIPE
65 m_pipeout(NULL),
66#endif
67 m_border(2)
55{ 68{
56 m_overlap = 1; 69 m_overlap = 1;
70 setKeyCompression ( true );
57// init(); 71// init();
58} 72}
73
59/* 74/*
60QTReader::QTReader( const QString& filename, QWidget *parent, const tchar *name, WFlags f ) : 75QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) :
61 QWidget(parent, name, f), 76 QWidget(parent, name, f),
62 m_textfont(0), 77 m_textfont(0),
63 m_textsize(1), 78 m_textsize(1),
@@ -72,11 +87,20 @@ QTReader::QTReader( const QString& filename, QWidget *parent, const tchar *name,
72 m_fm(NULL) 87 m_fm(NULL)
73{ 88{
74 init(); 89 init();
75 // qDebug("Load_file(1)"); 90// // qDebug("Load_file(1)");
76 load_file((const tchar*)filename); 91 load_file((const tchar*)filename);
77} 92}
78*/ 93*/
79 94
95/*
96void QTReader::mouseMoveEvent(QMouseEvent* _e)
97{
98
99 mouseUpOn = !(_e->pos().x() == -1);
100
101 qDebug("MouseMove:[%d, %d]", _e->pos().x(), _e->pos().y());
102}
103*/
80long QTReader::real_delay() 104long QTReader::real_delay()
81{ 105{
82 return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); 106 return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing );
@@ -87,54 +111,103 @@ void QTReader::mousePressEvent( QMouseEvent* _e )
87 buffdoc.unsuspend(); 111 buffdoc.unsuspend();
88 if (_e->button() == RightButton) 112 if (_e->button() == RightButton)
89 { 113 {
114 //qDebug("MousePress");
90 mouseUpOn = false; 115 mouseUpOn = false;
91 if (buffdoc.hasnavigation()) 116 if (m_swapmouse)
92 { 117 {
93 if (_e->y() > (2*height())/3) 118 int lineno = 0;
94 { 119 int ht = textarray[0]->lineSpacing();
95 goDown(); 120 while ((ht < _e->y()) && (lineno < numlines))
96 }
97 else if (_e->y() < height()/3)
98 {
99 goUp();
100 }
101 else
102 {
103 if (_e->x() < width()/3)
104 {
105 size_t target = pagelocate();
106 if (buffdoc.back(target))
107 {
108 locate(target);
109 }
110 }
111 else if (_e->x() > (2*width())/3)
112 {
113 size_t target = pagelocate();
114 if (buffdoc.forward(target))
115 {
116 locate(target);
117 }
118 }
119 else
120 { 121 {
121 buffdoc.saveposn(pagelocate()); 122 ht += textarray[++lineno]->lineSpacing();
122 locate(buffdoc.getHome());
123 } 123 }
124 } 124 size_t startpos, startoffset, tgt;
125 getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt);
126 processmousewordevent(startpos, startoffset, _e, lineno);
127 }
128 else
129 processmousepositionevent(_e);
130 }
131}
132
133void QTReader::processmousepositionevent( QMouseEvent* _e )
134{
135 if (buffdoc.hasnavigation())
136 {
137 if (_e->y() > (2*height())/3)
138 {
139 goDown();
140 }
141 else if (_e->y() < height()/3)
142 {
143 goUp();
125 } 144 }
126 else 145 else
127 { 146 {
128 if (_e->y() > height()/2) 147 if (_e->x() < width()/3)
129 { 148 {
130 goDown(); 149 goBack();
150 }
151 else if (_e->x() > (2*width())/3)
152 {
153 goForward();
131 } 154 }
132 else 155 else
133 { 156 {
134 goUp(); 157 goHome();
135 } 158 }
136 } 159 }
137 } 160 }
161 else
162 {
163 if (_e->y() > height()/2)
164 {
165 goDown();
166 }
167 else
168 {
169 goUp();
170 }
171 }
172}
173
174void QTReader::goHome()
175{
176 if (buffdoc.hasnavigation())
177 {
178 size_t current=pagelocate();
179 size_t home=buffdoc.getHome();
180 if (current!=home)
181 {
182 buffdoc.saveposn(current);
183 locate(home);
184 }
185 }
186}
187
188void QTReader::goBack()
189{
190 if (buffdoc.hasnavigation())
191 {
192 size_t target = pagelocate();
193 buffdoc.writeposn(target);
194 if (buffdoc.back(target))
195 {
196 locate(target);
197 }
198 }
199}
200
201void QTReader::goForward()
202{
203 if (buffdoc.hasnavigation())
204 {
205 size_t target = pagelocate();
206 if (buffdoc.forward(target))
207 {
208 locate(target);
209 }
210 }
138} 211}
139 212
140linkType QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt) 213linkType QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt)
@@ -148,19 +221,28 @@ linkType QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, si
148 start = locnarray[lineno]; 221 start = locnarray[lineno];
149 if (m_bMonoSpaced) 222 if (m_bMonoSpaced)
150 { 223 {
151 offset = x/m_charWidth; 224 offset = (x - textarray[lineno]->offset(width(), m_border))/m_charWidth;
152 } 225 }
153 else 226 else
154 { 227 {
155 int i; 228 int i;
156 CDrawBuffer* t = textarray[lineno]; 229 CDrawBuffer* t = textarray[lineno];
157 x = x - t->offset(width()); 230 x = x - t->offset(width(), m_border);
158 for (i = t->length(); i >= 0 && t->width(i) > x; i--); 231 for (i = t->length(); i >= 0 && t->width(i, true, width(), m_border) > x; i--);
159 offset = i; 232 offset = i;
160 } 233 }
161 return textarray[lineno]->getLinkType(offset, tgt); 234 return textarray[lineno]->getLinkType(offset, tgt);
162} 235}
163 236
237void QTReader::suspend()
238{
239#ifdef OPIE
240 if (memcmp("/mnt/", m_lastfile.latin1(), 5) == 0) buffdoc.suspend();
241#else
242 if (memcmp("/usr/mnt.rom/", m_lastfile.latin1(), 13) == 0) buffdoc.suspend();
243#endif
244}
245
164void QTReader::setTwoTouch(bool _b) 246void QTReader::setTwoTouch(bool _b)
165{ 247{
166 setBackgroundColor( white ); 248 setBackgroundColor( white );
@@ -173,6 +255,90 @@ void QTReader::setContinuous(bool _b)
173 buffdoc.setContinuous(m_continuousDocument = _b); 255 buffdoc.setContinuous(m_continuousDocument = _b);
174} 256}
175 257
258void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno)
259{
260 QString wrd;
261 if (m_twotouch)
262 {
263 if (m_touchone)
264 {
265 m_touchone = false;
266 m_startpos = startpos;
267 m_startoffset = startoffset;
268 setBackgroundColor( lightGray );
269 }
270 else
271 {
272 m_touchone = true;
273 setBackgroundColor( white );
274 size_t endpos, endoffset;
275 endpos = startpos;
276 endoffset = startoffset;
277 size_t currentpos = locate();
278 if (endpos >= m_startpos)
279 {
280 jumpto(m_startpos);
281 for (int i = 0; i < m_startoffset; i++)
282 {
283 getch();
284 }
285 if (m_startpos == endpos)
286 {
287 for (int i = m_startoffset; i <= endoffset; i++)
288 {
289 wrd += QChar(getch());
290 }
291 }
292 else
293 {
294 while (buffdoc.explocate() <= endpos)
295 {
296 wrd += QChar(getch());
297 }
298 for (int i = 0; i < endoffset; i++)
299 {
300 wrd += QChar(getch());
301 }
302 }
303 jumpto(currentpos);
304 }
305 }
306 }
307 else if (m_bMonoSpaced)
308 {
309 int chno = (_e->x()-textarray[lineno]->offset(width(), m_border))/m_charWidth;
310 if (chno < ustrlen(textarray[lineno]->data()))
311 {
312 wrd[0] = textarray[lineno]->data()[chno];
313 }
314 }
315 else
316 {
317 CDrawBuffer* t = textarray[lineno];
318 int first = 0;
319 int tgt = _e->x() - t->offset(width(), m_border);
320 while (1)
321 {
322 int i = first+1;
323 while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
324 if (t->width(i, true, width(), m_border) > tgt)
325 {
326 wrd = toQString(t->data()+first, i - first);
327 // qDebug("Got %s", (const char *)wrd);
328 break;
329 }
330 while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
331 if ((*t)[i] == 0) break;
332 first = i;
333 }
334 }
335 if (!wrd.isEmpty())
336 {
337 //qDebug("Selected:%s", (const char*)wrd);
338 emit OnWordSelected(wrd, locnarray[lineno], (m_twotouch) ? wrd : toQString(textarray[lineno]->data()));
339 }
340}
341
176void QTReader::mouseReleaseEvent( QMouseEvent* _e ) 342void QTReader::mouseReleaseEvent( QMouseEvent* _e )
177{ 343{
178 buffdoc.unsuspend(); 344 buffdoc.unsuspend();
@@ -180,9 +346,15 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e )
180 { 346 {
181 if (mouseUpOn) 347 if (mouseUpOn)
182 { 348 {
349 // qDebug("MouseRelease");
350 if (_e->x() > width() - m_border)
351 {
352 locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*_e->y()+height()/2)/height());
353 return;
354 }
183 if (textarray[0] != NULL) 355 if (textarray[0] != NULL)
184 { 356 {
185 QString wrd, line; 357 QString line;
186 // int lineno = _e->y()/m_linespacing; 358 // int lineno = _e->y()/m_linespacing;
187 int lineno = 0; 359 int lineno = 0;
188 int ht = textarray[0]->lineSpacing(); 360 int ht = textarray[0]->lineSpacing();
@@ -196,7 +368,9 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e )
196 case eLink: 368 case eLink:
197 { 369 {
198 size_t saveposn = pagelocate(); 370 size_t saveposn = pagelocate();
199 if (buffdoc.hyperlink(tgt)) 371 QString href;
372 linkType lt = buffdoc.hyperlink(tgt, href);
373 if (lt == eLink)
200 { 374 {
201 buffdoc.saveposn(saveposn); 375 buffdoc.saveposn(saveposn);
202 fillbuffer(); 376 fillbuffer();
@@ -204,14 +378,31 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e )
204 } 378 }
205 else 379 else
206 { 380 {
381 if (lt == ePicture)
382 {
383 QImage* pm = buffdoc.getPicture(tgt);
384 if (pm != NULL)
385 {
386 emit OnShowPicture(*pm);
387 delete pm;
388 }
389 }
390 else
391 {
392 // QString anchortext = textarray[lineno]->getanchortext(startoffset);
393 if (!href.isEmpty())
394 {
395 emit OnURLSelected(href);
396 }
397 }
207 locate(pagelocate()); 398 locate(pagelocate());
208 } 399 }
209 return; 400 return;
210 } 401 }
211 case ePicture: 402 case ePicture:
212 { 403 {
213 qDebug("Picture:%x", tgt); 404 // qDebug("Picture:%x", tgt);
214 QPixmap* pm = buffdoc.getPicture(tgt); 405 QImage* pm = buffdoc.getPicture(tgt);
215 if (pm != NULL) 406 if (pm != NULL)
216 { 407 {
217 emit OnShowPicture(*pm); 408 emit OnShowPicture(*pm);
@@ -226,86 +417,13 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e )
226 case eNone: 417 case eNone:
227 break; 418 break;
228 default: 419 default:
229 qDebug("Unknown linktype"); 420 // qDebug("Unknown linktype");
230 return; 421 return;
231 } 422 }
232 if (m_twotouch) 423 if (m_swapmouse)
233 { 424 processmousepositionevent(_e);
234 if (m_touchone)
235 {
236 m_touchone = false;
237 m_startpos = startpos;
238 m_startoffset = startoffset;
239 setBackgroundColor( lightGray );
240 }
241 else
242 {
243 m_touchone = true;
244 setBackgroundColor( white );
245 size_t endpos, endoffset;
246 endpos = startpos;
247 endoffset = startoffset;
248 size_t currentpos = locate();
249 if (endpos >= m_startpos)
250 {
251 jumpto(m_startpos);
252 for (int i = 0; i < m_startoffset; i++)
253 {
254 getch();
255 }
256 if (m_startpos == endpos)
257 {
258 for (int i = m_startoffset; i <= endoffset; i++)
259 {
260 wrd += QChar(getch());
261 }
262 }
263 else
264 {
265 while (buffdoc.explocate() <= endpos)
266 {
267 wrd += QChar(getch());
268 }
269 for (int i = 0; i < endoffset; i++)
270 {
271 wrd += QChar(getch());
272 }
273 }
274 jumpto(currentpos);
275 }
276 }
277 }
278 else if (m_bMonoSpaced)
279 {
280 int chno = _e->x()/m_charWidth;
281 if (chno < ustrlen(textarray[lineno]->data()))
282 {
283 wrd[0] = textarray[lineno]->data()[chno];
284 }
285 }
286 else 425 else
287 { 426 processmousewordevent(startpos, startoffset, _e, lineno);
288 CDrawBuffer* t = textarray[lineno];
289 int first = 0;
290 int tgt = _e->x() - t->offset(width());
291 while (1)
292 {
293 int i = first+1;
294 while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
295 if (t->width(i) > tgt)
296 {
297 wrd = toQString(t->data()+first, i - first);
298 break;
299 }
300 while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
301 if ((*t)[i] == 0) break;
302 first = i;
303 }
304 }
305 if (!wrd.isEmpty())
306 {
307 emit OnWordSelected(wrd, locnarray[lineno], (m_twotouch) ? wrd : toQString(textarray[lineno]->data()));
308 }
309 } 427 }
310 } 428 }
311 else 429 else
@@ -326,13 +444,15 @@ void QTReader::focusOutEvent(QFocusEvent* e)
326 if (m_autoScroll) 444 if (m_autoScroll)
327 { 445 {
328 timer->stop(); 446 timer->stop();
329 m_scrolldy1 = m_scrolldy2 = 0; 447 //m_scrolldy1 = m_scrolldy2 = 0;
330 } 448 }
331} 449}
332 450
333#include <qapplication.h> 451#include <qapplication.h>
334#include <qdrawutil.h> 452#include <qdrawutil.h>
453#ifndef _WINDOWS
335#include <unistd.h> 454#include <unistd.h>
455#endif
336 456
337void QTReader::goDown() 457void QTReader::goDown()
338{ 458{
@@ -426,9 +546,62 @@ void QTReader::zoomout()
426 } 546 }
427} 547}
428 548
549void QTReader::reduceScroll()
550{
551 if (m_delay < 59049)
552 {
553 m_delay = (3*m_delay)/2;
554 timer->changeInterval(real_delay());
555 }
556 else
557 {
558 m_delay = 59049;
559 }
560}
561
562void QTReader::increaseScroll()
563{
564 if (m_delay > 1024)
565 {
566 m_delay = (2*m_delay)/3;
567 timer->changeInterval(real_delay());
568 }
569 else
570 {
571 m_delay = 1024;
572 }
573}
574
429void QTReader::keyPressEvent(QKeyEvent* e) 575void QTReader::keyPressEvent(QKeyEvent* e)
430{ 576{
431 buffdoc.unsuspend(); 577 buffdoc.unsuspend();
578 ((QTReaderApp*)parent()->parent())->handlekey(e);
579// e->ignore();
580 return;
581#ifdef _SCROLLPIPE
582 if (m_isPaused)
583 {
584 m_isPaused = false;
585 if (e->key() != Key_Space)
586 {
587 m_autoScroll = false;
588 if (m_pipeout != NULL)
589 {
590 pclose(m_pipeout);
591 m_pipeout = NULL;
592 }
593 ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll);
594 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
595 }
596 else
597 {
598 timer->start(real_delay(), false);
599 }
600 e->accept();
601 return;
602 }
603#endif
604/*
432 switch (e->key()) 605 switch (e->key())
433 { 606 {
434 case Key_Down: 607 case Key_Down:
@@ -473,35 +646,6 @@ void QTReader::keyPressEvent(QKeyEvent* e)
473 } 646 }
474 } 647 }
475 break; 648 break;
476 /*
477 case Key_Left:
478 {
479 e->accept();
480 if (m_textfont > 0)
481 {
482 m_textfont--;
483 setfont(NULL);
484 locate(pagelocate());
485 update();
486 }
487 }
488 break;
489 case Key_Right:
490 {
491 e->accept();
492 if (fonts[++m_textfont] == 0)
493 {
494 m_textfont--;
495 }
496 else
497 {
498 setfont(NULL);
499 locate(pagelocate());
500 update();
501 }
502 }
503 break;
504 */
505 case Key_Right: 649 case Key_Right:
506 { 650 {
507 e->accept(); 651 e->accept();
@@ -530,16 +674,10 @@ void QTReader::keyPressEvent(QKeyEvent* e)
530 else zoomout(); 674 else zoomout();
531 } 675 }
532 break; 676 break;
533 case Key_Space:
534 case Key_Return:
535 {
536 e->accept();
537 emit OnActionPressed();
538 }
539 break;
540 default: 677 default:
541 e->ignore(); 678 e->ignore();
542 } 679 }
680*/
543} 681}
544 682
545void QTReader::setautoscroll(bool _sc) 683void QTReader::setautoscroll(bool _sc)
@@ -548,15 +686,34 @@ void QTReader::setautoscroll(bool _sc)
548 if (m_autoScroll) 686 if (m_autoScroll)
549 { 687 {
550 m_autoScroll = false; 688 m_autoScroll = false;
689#ifdef USEQPE
551 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 690 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
691#endif
692#ifdef _SCROLLPIPE
693 if (m_pipeout != NULL)
694 {
695 pclose(m_pipeout);
696 m_pipeout = NULL;
697 }
698#endif
552 } 699 }
553 else 700 else
554 { 701 {
555 CDrawBuffer* reusebuffer = textarray[numlines]; 702 CDrawBuffer* reusebuffer = textarray[numlines];
556 if (reusebuffer == NULL || reusebuffer->eof()) return; 703 if (reusebuffer == NULL || reusebuffer->eof()) return;
557 m_autoScroll = true; 704 m_autoScroll = true;
705#ifdef _SCROLLPIPE
706 if (!m_pipetarget.isEmpty())
707 {
708 // qDebug("Opening pipe to %s", (const char*)m_pipetarget);
709 m_pipeout = popen((const char*)m_pipetarget, "w");
710 m_isPaused = false;
711 }
712#endif
558 autoscroll(); 713 autoscroll();
714#ifdef USEQPE
559 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed 715 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed
716#endif
560 } 717 }
561} 718}
562 719
@@ -565,11 +722,11 @@ bool QTReader::getline(CDrawBuffer *buff)
565 buffdoc.unsuspend(); 722 buffdoc.unsuspend();
566 if (m_bMonoSpaced) 723 if (m_bMonoSpaced)
567 { 724 {
568 return buffdoc.getline(buff ,width(), m_charWidth); 725 return buffdoc.getline(buff ,width(), m_charWidth, m_border);
569 } 726 }
570 else 727 else
571 { 728 {
572 return buffdoc.getline(buff, width()); 729 return buffdoc.getline(buff, width(), m_border);
573 } 730 }
574} 731}
575 732
@@ -588,6 +745,25 @@ void QTReader::doscroll()
588 745
589 if (++m_scrolldy1 == textarray[0]->lineSpacing()) 746 if (++m_scrolldy1 == textarray[0]->lineSpacing())
590 { 747 {
748#ifdef _SCROLLPIPE
749 if (m_pipeout != NULL)
750 {
751 QString outstr = toQString(textarray[0]->data());
752 if (!outstr.isEmpty())
753 {
754 fprintf(m_pipeout, "%s\n", (const char*)outstr);
755 fflush(m_pipeout);
756 }
757 else if (m_pauseAfterEachPara)
758 {
759 m_isPaused = true;
760 timer->stop();
761 }
762 // write(m_pipeout, (const char*)outstr, outstr.length());
763 // write(m_pipeout, "\n", 1);
764 // fputc(10, m_pipeout);
765 }
766#endif
591 CDrawBuffer* buff = textarray[0]; 767 CDrawBuffer* buff = textarray[0];
592 for (int i = 1; i <= numlines; i++) 768 for (int i = 1; i <= numlines; i++)
593 { 769 {
@@ -609,12 +785,29 @@ void QTReader::doscroll()
609 } 785 }
610 locnarray[numlines] = locate(); 786 locnarray[numlines] = locate();
611 int ch = getline(textarray[numlines]); 787 int ch = getline(textarray[numlines]);
612 textarray[numlines-1]->render(&p, height() - textarray[numlines-1]->descent() - 2, m_bMonoSpaced, m_charWidth, width()); 788 textarray[numlines-1]->render(&p, height() - textarray[numlines-1]->descent() - 2, m_bMonoSpaced, m_charWidth, width(), m_border);
613 mylastpos = locate(); 789 mylastpos = locate();
614 if (!ch) 790 if (!ch)
615 { 791 {
616 m_autoScroll = false; 792 m_autoScroll = false;
793#ifdef _SCROLLPIPE
794 for (int i = 0; i < numlines; i++)
795 {
796 if (m_pipeout != NULL)
797 {
798 QString outstr = toQString(textarray[i]->data());
799 if (!outstr.isEmpty())
800 {
801 fprintf(m_pipeout, "%s\n", (const char*)outstr);
802 fflush(m_pipeout);
803 }
804 }
805 }
806#endif
617 ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); 807 ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll);
808#ifdef USEQPE
809 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
810#endif
618 } 811 }
619 emit OnRedraw(); 812 emit OnRedraw();
620 } 813 }
@@ -639,68 +832,83 @@ void QTReader::drawFonts( QPainter *p )
639{ 832{
640 if (bDoUpdates) 833 if (bDoUpdates)
641 { 834 {
642 qDebug("How refreshing..."); 835 //qDebug("How refreshing...");
643 if (buffdoc.empty()) return; 836 if (buffdoc.empty()) return;
644 setfont(); 837 setfont();
645 if (m_lastwidth != width()) 838 if (m_lastwidth != width())
646 { 839 {
647 qDebug("Not Optimised %d", m_lastwidth); 840 // qDebug("Not Optimised %d", m_lastwidth);
648 m_lastwidth = width(); 841 m_lastwidth = width();
649 m_lastheight = height(); 842 m_lastheight = height();
843 buffdoc.setwidth(m_lastwidth-2*m_border);
650 locate(pagelocate()); 844 locate(pagelocate());
651 qDebug("Not Optimised %d", m_lastwidth); 845 // qDebug("Not Optimised %d", m_lastwidth);
652 } 846 }
653 else 847 else
654 { 848 {
655 if (m_lastheight > height()) 849 int newht = height();
850 if (m_lastheight > newht)
656 { 851 {
657 qDebug("Optimised < %d", numlines); 852 // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht);
658 int ypos = 0; 853 int ypos = 0;
659 for (int i = 0; i < numlines; i++) 854 for (int i = 0; i < numlines; i++)
660 { 855 {
661 if ((ypos += textarray[i]->lineSpacing()) > height()) 856 if ((ypos += textarray[i]->lineSpacing()) > newht)
662 { 857 {
663 numlines = i; 858 numlines = i;
664 jumpto(locnarray[i+1]); 859 jumpto(mylastpos = locnarray[i+1]);
665 break; 860 break;
666 } 861 }
667 } 862 }
668 qDebug("Optimised < %d", numlines); 863 // qDebug("Optimised < %d", numlines);
669 m_lastheight = height(); 864 m_lastheight = newht;
670 } 865 }
671 else if (m_lastheight < height()) 866 else if (m_lastheight < newht)
672 { 867 {
673 qDebug("Optimised > %d", numlines); 868 // qDebug("Optimised > %d", numlines);
674 int ypos = 0; 869 int ypos = 0;
675 for (int i = 0; i <= numlines; i++) 870 for (int i = 0; i <= numlines; i++)
676 { 871 {
677 ypos += textarray[i]->lineSpacing(); 872 ypos += textarray[i]->lineSpacing();
678 } 873 }
679 fillbuffer(numlines+1, ypos); 874 fillbuffer(numlines+1, ypos, newht);
680 qDebug("Optimised > %d", numlines); 875 // qDebug("Optimised > %d", numlines);
681 m_lastheight = height();
682 } 876 }
683 if (numlines > 0) 877 if (numlines > 0)
684 { 878 {
685 int ypos = textarray[0]->ascent(); 879 int ypos = textarray[0]->ascent();
686 textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); 880 textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_border);
881 // int last = (m_showlast) ? numlines : numlines-1;
882 // for (int i = 1; i <= last; i++)
687 for (int i = 1; i < numlines; i++) 883 for (int i = 1; i < numlines; i++)
688 { 884 {
689 // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; 885 // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2;
690 ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ 886 ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+
691 (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; 887 (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2;
692 textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width()); 888 textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_border);
693 } 889 }
694// mylastpos = locate(); 890// mylastpos = locate();
695 } 891 }
696 } 892 }
697 m_scrolldy1 = m_scrolldy2 = 0; 893
894 m_scrolldy1 = m_scrolldy2 = m_scrollpart;
895 if (m_border > 5 && !buffdoc.empty())
896 {
897 p->fillRect(width()-2, 0, 2, height(), cyan);
898 int sectionsize = (buffdoc.endSection()-buffdoc.startSection());
899 int mid = (height()*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize);
900 p->fillRect(width()-2, mid-5, 2, 10, yellow);
901 p->fillRect(width()-2, (height()*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize, 2, ((locnarray[numlines]-locnarray[0])*height()+sectionsize/2)/sectionsize, magenta);
902 }
903
698 emit OnRedraw(); 904 emit OnRedraw();
699 } 905 }
906/*
700 else 907 else
701 { 908 {
702 qDebug("Not so refreshing..."); 909 qDebug("Not so refreshing...");
703 } 910 }
911*/
704} 912}
705 913
706QString QTReader::firstword() 914QString QTReader::firstword()
@@ -742,6 +950,7 @@ bool QTReader::ChangeFont(int tgt)
742 950
743void QTReader::init() 951void QTReader::init()
744{ 952{
953// m_showlast = true;
745 // setCaption( "Qt Draw Demo Application" ); 954 // setCaption( "Qt Draw Demo Application" );
746 955
747 buffdoc.unsuspend(); 956 buffdoc.unsuspend();
@@ -771,6 +980,18 @@ void QTReader::init()
771// 980//
772QTReader::~QTReader() 981QTReader::~QTReader()
773{ 982{
983#ifdef USEQPE
984 if (m_autoScroll)
985 {
986 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
987 }
988#endif
989#ifdef _SCROLLPIPE
990 if (m_pipeout != NULL)
991 {
992 fclose(m_pipeout);
993 }
994#endif
774} 995}
775 996
776// 997//
@@ -816,7 +1037,7 @@ void QTReader::paintEvent( QPaintEvent * )
816/* 1037/*
817void QTReader::resizeEvent( QResizeEvent * ) 1038void QTReader::resizeEvent( QResizeEvent * )
818{ 1039{
819 // qDebug("resize:(%u,%u)", width(), height()); 1040// // qDebug("resize:(%u,%u)", width(), height());
820 // bgroup->move( width()-bgroup->width(), 0 ); 1041 // bgroup->move( width()-bgroup->width(), 0 );
821} 1042}
822*/ 1043*/
@@ -841,11 +1062,11 @@ bool QTReader::locate(unsigned long n) {
841 //printf("Locate\n"); 1062 //printf("Locate\n");
842 buffdoc.unsuspend(); 1063 buffdoc.unsuspend();
843 buffdoc.locate(n); 1064 buffdoc.locate(n);
844 // qDebug("&buffdoc.located"); 1065// // qDebug("&buffdoc.located");
845 fillbuffer(); 1066 fillbuffer();
846 // qDebug("&Buffer filled"); 1067// // qDebug("&Buffer filled");
847 update(); 1068 update();
848 // qDebug("&Located"); 1069// // qDebug("&Located");
849 return true; 1070 return true;
850} 1071}
851 1072
@@ -856,18 +1077,22 @@ unsigned int QTReader::screenlines()
856 return (height()-2)/(m_linespacing); 1077 return (height()-2)/(m_linespacing);
857}; 1078};
858 1079
859bool QTReader::fillbuffer(int reuse, int ht) 1080bool QTReader::fillbuffer(int reuse, int ht, int newht)
860{ 1081{
861 buffdoc.unsuspend(); 1082 buffdoc.unsuspend();
862 if (buffdoc.empty()) return false; 1083 if (buffdoc.empty()) return false;
863 m_scrolldy1 = m_scrolldy2 = 0; 1084 if (newht < 0)
1085 m_lastheight = height();
1086 else
1087 m_lastheight = newht;
864 int ch; 1088 int ch;
865 bool ret = false; 1089 bool ret = false;
866 unsigned int oldpagepos = locnarray[reuse]; 1090 unsigned int oldpagepos = locnarray[reuse];
867 int ypos = ht; 1091 int lastypos = ht, ypos = ht;
868 numlines = reuse; 1092 numlines = reuse;
869 while (ypos < height() || numlines < 2) 1093 while (ypos < m_lastheight || numlines < 2)
870 { 1094 {
1095 lastypos = ypos;
871 if (textarray[numlines] == NULL) 1096 if (textarray[numlines] == NULL)
872 { 1097 {
873 textarray[numlines] = new CDrawBuffer(&m_fontControl); 1098 textarray[numlines] = new CDrawBuffer(&m_fontControl);
@@ -894,18 +1119,19 @@ bool QTReader::fillbuffer(int reuse, int ht)
894 1119
895 --numlines; 1120 --numlines;
896 mylastpos = locate(); 1121 mylastpos = locate();
1122 m_scrolldy1 = m_scrolldy2 = m_scrollpart = m_lastheight - lastypos;
897 1123
898 return true; 1124 return true;
899} 1125}
900 1126
901
902void QTReader::dopagedn() 1127void QTReader::dopagedn()
903{ 1128{
1129// qDebug("HEIGHT(2):%d", m_lastheight);
904 buffdoc.unsuspend(); 1130 buffdoc.unsuspend();
905 int skip = 0, ypos = 0; 1131 int skip = 0, ypos = 0;
906 if (locate() != mylastpos) 1132 if (locate() != mylastpos)
907 { 1133 {
908 //qDebug("Jumping to %u", mylastpos); 1134 ////qDebug("Jumping to %u", mylastpos);
909 jumpto(mylastpos); 1135 jumpto(mylastpos);
910 } 1136 }
911 CDrawBuffer* reusebuffer = textarray[numlines]; 1137 CDrawBuffer* reusebuffer = textarray[numlines];
@@ -938,20 +1164,31 @@ void QTReader::dopageup()
938 dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]); 1164 dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]);
939} 1165}
940 1166
1167bool QTReader::synch(size_t start, size_t end)
1168{
1169 jumpto(start);
1170 while (start++ < end)
1171 {
1172 tchar ch = getch();
1173 if (ch == 10) return true;
1174 if (ch == UEOF) return false;
1175 }
1176 return false;
1177}
1178
941void QTReader::dopageup(unsigned int target) 1179void QTReader::dopageup(unsigned int target)
942{ 1180{
943 buffdoc.unsuspend(); 1181 buffdoc.unsuspend();
944 CBufferFace<CDrawBuffer*> buff; 1182 CBufferFace<CDrawBuffer*> buff;
945 CBufferFace<size_t> loc; 1183 CBufferFace<size_t> loc;
946 1184
947 size_t delta, guess = 2048; 1185 size_t delta, guess = 2*(locate()-pagelocate()), lastdelta = 0;
948 bool ch = true; 1186 bool ch = true;
949 int nbfl, ypos = 0; 1187 int nbfl, ypos = 0;
950 1188 if (guess < 128) guess = 128;
951 while (1) 1189 while (1)
952 { 1190 {
953 ch = true; 1191 ch = true;
954 nbfl = 0;
955 if (target < guess) 1192 if (target < guess)
956 { 1193 {
957 delta = 0; // 0 is a flag to say don't guess any more 1194 delta = 0; // 0 is a flag to say don't guess any more
@@ -965,22 +1202,24 @@ void QTReader::dopageup(unsigned int target)
965 else 1202 else
966 { 1203 {
967 delta = guess; 1204 delta = guess;
968 1205 if (!synch(target-delta, target-lastdelta))
969 jumpto(target - delta);
970
971 buff[0] = new CDrawBuffer(&m_fontControl);
972
973 do
974 { 1206 {
975 1207 lastdelta = delta;
976 if (!getline(buff[0])) break; 1208 if (guess < 4000)
977 1209 {
978 if (locate() > target) break; 1210 guess <<= 1;
1211 continue;
1212 }
1213 else
1214 {
1215 jumpto(target-delta);
1216 }
979 } 1217 }
980 while (!buffdoc.iseol());
981 } 1218 }
982 1219
1220 nbfl = 0;
983 ypos = 0; 1221 ypos = 0;
1222
984 while (locate() < target) 1223 while (locate() < target)
985 { 1224 {
986 if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); 1225 if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl);
@@ -990,7 +1229,7 @@ void QTReader::dopageup(unsigned int target)
990 nbfl++; 1229 nbfl++;
991 if (!ch) break; 1230 if (!ch) break;
992 } 1231 }
993 if (ypos < height() && (delta != 0)) 1232 if (guess < 4000 && ypos < height() && (delta != 0))
994 { 1233 {
995 for (int i = 0; i < nbfl; i++) 1234 for (int i = 0; i < nbfl; i++)
996 { 1235 {
@@ -1009,6 +1248,7 @@ void QTReader::dopageup(unsigned int target)
1009 int ch = getline(buff[nbfl]); 1248 int ch = getline(buff[nbfl]);
1010 nbfl++; 1249 nbfl++;
1011 } 1250 }
1251/*
1012 ypos = 0; 1252 ypos = 0;
1013 numlines = 0; 1253 numlines = 0;
1014 while (ypos < height() && numlines <= nbfl-1) 1254 while (ypos < height() && numlines <= nbfl-1)
@@ -1017,6 +1257,18 @@ void QTReader::dopageup(unsigned int target)
1017 numlines++; 1257 numlines++;
1018 } 1258 }
1019 --numlines; 1259 --numlines;
1260*/
1261
1262 ypos = 0;
1263 numlines = 0;
1264 while (ypos < height() && numlines+2 <= nbfl)
1265 {
1266 ypos += buff[nbfl - numlines - 2]->lineSpacing();
1267 numlines++;
1268 }
1269 if (numlines > 0) --numlines;
1270 if (numlines == 0 && nbfl > 1) numlines = 1;
1271
1020 int offset = nbfl-1; 1272 int offset = nbfl-1;
1021 offset -= numlines; 1273 offset -= numlines;
1022 ypos = 0; 1274 ypos = 0;
@@ -1027,7 +1279,11 @@ void QTReader::dopageup(unsigned int target)
1027 locnarray[i] = loc[offset + i]; 1279 locnarray[i] = loc[offset + i];
1028 ypos += textarray[i]->lineSpacing(); 1280 ypos += textarray[i]->lineSpacing();
1029 } 1281 }
1282#ifdef _WINDOWS
1283 for (i = 0; i < nbfl - numlines - 1; i++)
1284#else
1030 for (int i = 0; i < nbfl - numlines - 1; i++) 1285 for (int i = 0; i < nbfl - numlines - 1; i++)
1286#endif
1031 { 1287 {
1032 delete buff[i]; 1288 delete buff[i];
1033 } 1289 }
@@ -1057,21 +1313,22 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn)
1057 { 1313 {
1058 lcn = m_lastposn; 1314 lcn = m_lastposn;
1059 } 1315 }
1060 m_lastfile = newfile;
1061 // QMessageBox::information(0, "Opening...", newfile); 1316 // QMessageBox::information(0, "Opening...", newfile);
1062 m_lastwidth = width(); 1317 m_lastwidth = width();
1063 m_lastheight = height(); 1318 m_lastheight = height();
1064 if (buffdoc.openfile(this,newfile) == 0) 1319 if (buffdoc.openfile(this,newfile) == 0)
1065 { 1320 {
1321 m_lastfile = newfile;
1322 buffdoc.setwidth(m_lastwidth-2*m_border);
1066 bRC = true; 1323 bRC = true;
1067 buffdoc.setContinuous(m_continuousDocument); 1324 buffdoc.setContinuous(m_continuousDocument);
1068 // qDebug("buffdoc.openfile done"); 1325// // qDebug("buffdoc.openfile done");
1069 locate(lcn); 1326 locate(lcn);
1070 // qDebug("buffdoc.locate done"); 1327// // qDebug("buffdoc.locate done");
1071 } 1328 }
1072 setfilter(getfilter()); 1329 setfilter(getfilter());
1073 update(); 1330 update();
1074 // qDebug("Updated"); 1331// // qDebug("Updated");
1075 return bRC; 1332 return bRC;
1076} 1333}
1077 1334
@@ -1089,7 +1346,11 @@ void QTReader::lineDown()
1089 } 1346 }
1090 } 1347 }
1091 offset = numlines - offset; 1348 offset = numlines - offset;
1349#ifdef _WINDOWS
1350 for (i = offset; i <= numlines; i++)
1351#else
1092 for (int i = offset; i <= numlines; i++) 1352 for (int i = offset; i <= numlines; i++)
1353#endif
1093 { 1354 {
1094 CDrawBuffer* buff = textarray[i-offset]; 1355 CDrawBuffer* buff = textarray[i-offset];
1095 textarray[i-offset] = textarray[i]; 1356 textarray[i-offset] = textarray[i];
@@ -1259,7 +1520,11 @@ void QTReader::lineUp()
1259 locnarray[0] = loc; 1520 locnarray[0] = loc;
1260 int start = numlines; 1521 int start = numlines;
1261 int ypos = 0; 1522 int ypos = 0;
1262 for (int i = 0; i <= numlines; i++) 1523#ifdef _WINDOWS
1524 for (i = 0; i <= numlines; i++)
1525#else
1526 for (int i = 0; i <= numlines; i++)
1527#endif
1263 { 1528 {
1264 ypos += textarray[i]->lineSpacing(); 1529 ypos += textarray[i]->lineSpacing();
1265 if (ypos > height()) 1530 if (ypos > height())
@@ -1296,32 +1561,3 @@ MarkupType QTReader::PreferredMarkup()
1296 } 1561 }
1297 return m; 1562 return m;
1298} 1563}
1299
1300void QTReader::setstate(const statedata& sd)
1301{
1302 bstripcr = sd.bstripcr;
1303 btextfmt = sd.btextfmt;
1304 bautofmt = sd.bautofmt;
1305 bstriphtml = sd.bstriphtml;
1306 bpeanut = sd.bpeanut;
1307 bdehyphen = sd.bdehyphen;
1308 bonespace = sd.bonespace;
1309 bunindent = sd.bunindent;
1310 brepara = sd.brepara;
1311 bdblspce = sd.bdblspce;
1312 m_bpagemode = sd.m_bpagemode;
1313 m_navkeys = sd.m_navkeys;
1314 m_bMonoSpaced = sd.m_bMonoSpaced;
1315 bremap = sd.bremap;
1316 bmakebold = sd.bmakebold;
1317 m_continuousDocument = sd.Continuous;
1318#ifdef REPALM
1319 brepalm = sd.brepalm;
1320#endif
1321 bindenter = sd.bindenter;
1322 m_encd = sd.m_charpc;
1323 m_fontname = sd.m_fontname;
1324 setContinuous(sd.Continuous);
1325 ChangeFont(sd.m_textsize);
1326 refresh();
1327}
diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h
index 3d5f57d..dfbdfb9 100644
--- a/noncore/apps/opie-reader/QTReader.h
+++ b/noncore/apps/opie-reader/QTReader.h
@@ -1,6 +1,8 @@
1#ifndef __QTREADER_H 1#ifndef __QTREADER_H
2#define __QTREADER_H 2#define __QTREADER_H
3 3
4//#define _SCROLLPIPE
5
4#include <qwidget.h> 6#include <qwidget.h>
5//#include <qpainter.h> 7//#include <qpainter.h>
6#include "my_list.h" 8#include "my_list.h"
@@ -14,28 +16,42 @@ class CDrawBuffer;
14class QPainter; 16class QPainter;
15class QTimer; 17class QTimer;
16class QPixmap; 18class QPixmap;
17class statedata;
18 19
19class QTReader : public QWidget 20class QTReader : public QWidget
20{ 21{
21 Q_OBJECT 22 Q_OBJECT
22 23
24 static tchar pluckernextpart[];
25 static tchar jplucknextpart[];
23 friend class QTReaderApp; 26 friend class QTReaderApp;
24 void suspend() { buffdoc.suspend(); } 27 void suspend();
28 void increaseScroll();
29 void reduceScroll();
25 void drawText(QPainter& p, int x, int y, tchar* text); 30 void drawText(QPainter& p, int x, int y, tchar* text);
26 int m_delay; 31 int m_delay;
27 unsigned int m_overlap; 32 unsigned int m_overlap;
28 bool m_autoScroll; 33 bool m_autoScroll, m_swapmouse;
29 void autoscroll(); 34 void autoscroll();
30 QTimer* timer; 35 QTimer* timer;
31 int m_scrolldy1, m_scrolldy2, m_encd; 36 int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart;
32 void focusInEvent(QFocusEvent*); 37 void focusInEvent(QFocusEvent*);
33 void focusOutEvent(QFocusEvent*); 38 void focusOutEvent(QFocusEvent*);
39 void processmousepositionevent( QMouseEvent* _e );
40 void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno);
34 bool ChangeFont(int); 41 bool ChangeFont(int);
35 bool getline(CDrawBuffer*); 42 bool getline(CDrawBuffer*);
36 int m_charWidth; 43 int m_charWidth;
37 int m_charpc; 44 int m_charpc;
45 unsigned char m_border;
38 FontControl m_fontControl; 46 FontControl m_fontControl;
47 void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); }
48 unsigned char getBaseSize() { return m_fontControl.getBaseSize(); }
49#ifdef _SCROLLPIPE
50 FILE* m_pipeout;
51 QString m_pipetarget;
52 bool m_isPaused;
53 bool m_pauseAfterEachPara;
54#endif
39public: 55public:
40 QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); 56 QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0);
41 // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); 57 // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0);
@@ -86,89 +102,22 @@ public:
86 } 102 }
87 }; 103 };
88 */ 104 */
89 void setpeanut(bool _b) 105 void setlead(int _lead)
90 {
91 bpeanut = _b;
92 setfilter(getfilter());
93 }
94 void setremap(bool _b)
95 {
96 bremap = _b;
97 setfilter(getfilter());
98 }
99 void setmakebold(bool _b)
100 {
101 bmakebold = _b;
102 setfilter(getfilter());
103 }
104 void setautofmt(bool _b)
105 {
106 bautofmt = _b;
107 if (bautofmt)
108 { 106 {
109 btextfmt = false; 107 m_fontControl.setlead(_lead);
110 bstriphtml = false;; 108 }
111 bpeanut = false; 109 int getlead()
110 {
111 return m_fontControl.getlead();
112 }
113 void setextraspace(int _lead)
114 {
115 m_fontControl.setextraspace(_lead);
116 }
117 int getextraspace()
118 {
119 return m_fontControl.getextraspace();
112 } 120 }
113 setfilter(getfilter());
114 }
115 void settextfmt(bool _b)
116 {
117 btextfmt = _b;
118 setfilter(getfilter());
119 }
120 void setstripcr(bool _b)
121 {
122 bstripcr = _b;
123 setfilter(getfilter());
124 }
125 void setonespace(bool _b)
126 {
127 bonespace = _b;
128 setfilter(getfilter());
129 }
130#ifdef REPALM
131 void setrepalm(bool _b)
132 {
133 brepalm = _b;
134 setfilter(getfilter());
135 }
136#endif
137 void setstriphtml(bool _b)
138 {
139 bstriphtml = _b;
140 setfilter(getfilter());
141 }
142 void setdehyphen(bool _b)
143 {
144 bdehyphen = _b;
145 setfilter(getfilter());
146 }
147 void setunindent(bool _b)
148 {
149 bunindent = _b;
150 setfilter(getfilter());
151 }
152 void setrepara(bool _b)
153 {
154 brepara = _b;
155 setfilter(getfilter());
156 }
157 void setdblspce(bool _b)
158 {
159 bdblspce = _b;
160 setfilter(getfilter());
161 }
162 void indentplus()
163 {
164 if (bindenter < 15) bindenter += 2;
165 setfilter(getfilter());
166 }
167 void indentminus()
168 {
169 if (bindenter > 1) bindenter -= 2;
170 setfilter(getfilter());
171 }
172 void setpagemode(bool _b) 121 void setpagemode(bool _b)
173 { 122 {
174 m_bpagemode = _b; 123 m_bpagemode = _b;
@@ -187,21 +136,26 @@ public:
187 MarkupType PreferredMarkup(); 136 MarkupType PreferredMarkup();
188 CEncoding* getencoding() 137 CEncoding* getencoding()
189 { 138 {
139 // qDebug("m_encd:%d", m_encd);
190 switch (m_encd) 140 switch (m_encd)
191 { 141 {
192 case 5:
193 return new Ccp1252;
194 case 4: 142 case 4:
143 // qDebug("palm");
195 return new CPalm; 144 return new CPalm;
196 case 1: 145 case 1:
146 // qDebug("utf8");
197 return new CUtf8; 147 return new CUtf8;
198 case 2: 148 case 2:
149 // qDebug("ucs16be");
199 return new CUcs16be; 150 return new CUcs16be;
200 case 3: 151 case 3:
152 // qDebug("ucs16le");
201 return new CUcs16le; 153 return new CUcs16le;
202 case 0: 154 case 0:
203 default: 155 // qDebug("ascii");
204 return new CAscii; 156 return new CAscii;
157 default:
158 return new CGeneral8Bit(m_encd-MAX_ENCODING+1);
205 } 159 }
206 } 160 }
207 CFilterChain* getfilter() 161 CFilterChain* getfilter()
@@ -223,12 +177,18 @@ public:
223 if (brepalm) filt->addfilter(new repalm); 177 if (brepalm) filt->addfilter(new repalm);
224#endif 178#endif
225 if (bremap) filt->addfilter(new remap); 179 if (bremap) filt->addfilter(new remap);
180 if (bdepluck) filt->addfilter(new DePluck(pluckernextpart));
181 if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart));
226 if (bmakebold) filt->addfilter(new embolden); 182 if (bmakebold) filt->addfilter(new embolden);
183 if (bfulljust) filt->addfilter(new FullJust);
227 return filt; 184 return filt;
228 } 185 }
229 186
230 187
231private slots: 188private slots:
189 void goHome();
190 void goBack();
191 void goForward();
232 void doscroll(); 192 void doscroll();
233 void drawIt( QPainter * ); 193 void drawIt( QPainter * );
234 void paintEvent( QPaintEvent * ); 194 void paintEvent( QPaintEvent * );
@@ -260,7 +220,8 @@ private slots:
260 CBufferFace<CDrawBuffer*> textarray; 220 CBufferFace<CDrawBuffer*> textarray;
261 CBufferFace<size_t> locnarray; 221 CBufferFace<size_t> locnarray;
262 unsigned int numlines; 222 unsigned int numlines;
263 bool bstripcr, btextfmt, bstriphtml, bdehyphen, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace; 223// bool m_showlast;
224 bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust;
264#ifdef REPALM 225#ifdef REPALM
265 bool brepalm; 226 bool brepalm;
266#endif 227#endif
@@ -270,10 +231,10 @@ private slots:
270 size_t m_lastposn; 231 size_t m_lastposn;
271 public: 232 public:
272 bool bDoUpdates; 233 bool bDoUpdates;
273 bool m_navkeys;
274 void NavUp(); 234 void NavUp();
275 void NavDown(); 235 void NavDown();
276 int getch() { return buffdoc.getch(); } 236 tchar getch() { return buffdoc.getch(); }
237 bool synch(size_t, size_t);
277 bool tight; 238 bool tight;
278 bool load_file(const char *newfile, unsigned int lcn=0); 239 bool load_file(const char *newfile, unsigned int lcn=0);
279 BuffDoc buffdoc; 240 BuffDoc buffdoc;
@@ -292,7 +253,7 @@ private slots:
292 // bool bold; 253 // bool bold;
293 int textsize() { return m_textsize; } 254 int textsize() { return m_textsize; }
294 void textsize(int ts) { m_textsize = ts; } 255 void textsize(int ts) { m_textsize = ts; }
295 bool fillbuffer(int ru = 0, int ht = 0); 256 bool fillbuffer(int ru = 0, int ht = 0, int newht = -1);
296 unsigned int screenlines(); 257 unsigned int screenlines();
297 void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.unsuspend(); buffdoc.sizes(fs,ts); } 258 void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.unsuspend(); buffdoc.sizes(fs,ts); }
298 static const char *fonts[]; 259 static const char *fonts[];
@@ -300,13 +261,12 @@ private slots:
300 int m_ascent, m_descent, m_linespacing; 261 int m_ascent, m_descent, m_linespacing;
301 QFontMetrics* m_fm; 262 QFontMetrics* m_fm;
302 QString firstword(); 263 QString firstword();
303 void setstate(const statedata& sd);
304 264
305 signals: 265 signals:
306 void OnRedraw(); 266 void OnRedraw();
307 void OnWordSelected(const QString&, size_t, const QString&); 267 void OnWordSelected(const QString&, size_t, const QString&);
308 void OnActionPressed(); 268 void OnShowPicture(QImage&);
309 void OnShowPicture(QPixmap&); 269 void OnURLSelected(const QString&);
310}; 270};
311 271
312#endif 272#endif
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index 7333a28..af1da27 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -17,15 +17,20 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20#include "useqpe.h"
21#include <qregexp.h>
21#include <qclipboard.h> 22#include <qclipboard.h>
22#include <qwidgetstack.h> 23#include <qwidgetstack.h>
24#ifdef USEQPE
23#include <qpe/qpemenubar.h> 25#include <qpe/qpemenubar.h>
24//#include <qpe/qpetoolbar.h> 26#include <qpe/qpetoolbar.h>
27#endif
25#include <qmenubar.h> 28#include <qmenubar.h>
26#include <qtoolbar.h> 29#include <qtoolbar.h>
30#ifdef USEQPE
27#include <qpe/menubutton.h> 31#include <qpe/menubutton.h>
28#include <qpe/fontdatabase.h> 32#include <qpe/fontdatabase.h>
33#endif
29#include <qcombobox.h> 34#include <qcombobox.h>
30#include <qpopupmenu.h> 35#include <qpopupmenu.h>
31#include <qaction.h> 36#include <qaction.h>
@@ -34,55 +39,119 @@
34#include <qtoolbutton.h> 39#include <qtoolbutton.h>
35#include <qspinbox.h> 40#include <qspinbox.h>
36#include <qobjectlist.h> 41#include <qobjectlist.h>
42#ifdef USEQPE
37#include <qpe/global.h> 43#include <qpe/global.h>
38#include <qpe/applnk.h> 44#include <qpe/applnk.h>
45#endif
39#include <qfileinfo.h> 46#include <qfileinfo.h>
40#include <stdlib.h> //getenv 47#include <stdlib.h> //getenv
41#include <qprogressbar.h> 48#include <qprogressbar.h>
49#ifdef USEQPE
42#include <qpe/config.h> 50#include <qpe/config.h>
51#endif
43#include <qbuttongroup.h> 52#include <qbuttongroup.h>
44#include <qradiobutton.h> 53#include <qradiobutton.h>
54#ifdef USEQPE
45#include <qpe/qcopenvelope_qws.h> 55#include <qpe/qcopenvelope_qws.h>
46 56#endif
47#include "QTReader.h" 57#include "QTReader.h"
48#include "GraphicWin.h" 58#include "GraphicWin.h"
49#include "Bkmks.h" 59#include "Bkmks.h"
50#include "cbkmkselector.h" 60#include "cbkmkselector.h"
51#include "infowin.h" 61#include "infowin.h"
62#include "ToolbarPrefs.h"
63#include "Prefs.h"
52#include "CAnnoEdit.h" 64#include "CAnnoEdit.h"
53#include "QFloatBar.h" 65#include "QFloatBar.h"
66#include "FixedFont.h"
67#include "URLDialog.h"
54//#include <qpe/fontdatabase.h> 68//#include <qpe/fontdatabase.h>
55 69
70#ifdef USEQPE
56#include <qpe/resource.h> 71#include <qpe/resource.h>
57#include <qpe/qpeapplication.h> 72#include <qpe/qpeapplication.h>
73#include "fileBrowser.h"
74#else
75#include "qfiledialog.h"
76#endif
58 77
59#include "QTReaderApp.h" 78#include "QTReaderApp.h"
60#include "fileBrowser.h"
61#include "CDrawBuffer.h" 79#include "CDrawBuffer.h"
62#include "Filedata.h" 80#include "Filedata.h"
63#include "opie.h" 81#include "opie.h"
64#include "name.h" 82#include "useqpe.h"
65#include "StateData.h" 83#include "names.h"
84#include "CEncoding_tables.h"
85#include "CloseDialog.h"
66 86
67#ifdef OPIE 87bool CheckVersion(int&, int&, char&);
88
89#ifdef _WINDOWS
90#define PICDIR "c:\\uqtreader\\pics\\"
91#else
92#ifdef USEQPE
68#define PICDIR "opie-reader/" 93#define PICDIR "opie-reader/"
69#else 94#else
70#define PICDIR 95#define PICDIR "/home/tim/uqtreader/pics/"
96#endif
71#endif 97#endif
72
73 98
74unsigned long QTReaderApp::m_uid = 0; 99unsigned long QTReaderApp::m_uid = 0;
75 100
76void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } 101void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); }
77 102
103#ifdef USEQPE
104#define geticon(iconname) Resource::loadPixmap( iconname )
105#define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname )
106#else
107#define geticon(iconname) QPixmap(PICDIR iconname ".png")
108#define getmyicon(iconname) geticon(iconname)
109//#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) )
110#endif
111
112#ifndef _WINDOWS
78#include <unistd.h> 113#include <unistd.h>
114#endif
79#include <stddef.h> 115#include <stddef.h>
116#ifndef _WINDOWS
80#include <dirent.h> 117#include <dirent.h>
118#endif
81 119
82void QTReaderApp::listBkmkFiles() 120void QTReaderApp::listBkmkFiles()
83{ 121{
84 bkmkselector->clear(); 122 bkmkselector->clear();
85 bkmkselector->setText("Cancel"); 123 bkmkselector->setText("Cancel");
124#ifndef USEQPE
125 int cnt = 0;
126
127 QDir d = QDir::home(); // "/"
128 if ( !d.cd(APPDIR) ) { // "/tmp"
129 qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
130 d = QDir::home();
131 d.mkdir(APPDIR);
132 d.cd(APPDIR);
133 }
134
135
136
137
138 d.setFilter( QDir::Files | QDir::NoSymLinks );
139// d.setSorting( QDir::Size | QDir::Reversed );
140
141 const QFileInfoList *list = d.entryInfoList();
142 QFileInfoListIterator it( *list ); // create list iterator
143 QFileInfo *fi; // pointer for traversing
144
145 while ( (fi=it.current()) ) { // for each file...
146
147 bkmkselector->insertItem(fi->fileName());
148 cnt++;
149
150 //qDebug( "%10li %s", fi->size(), fi->fileName().data() );
151 ++it; // goto next list element
152 }
153
154#else /* USEQPE */
86 int cnt = 0; 155 int cnt = 0;
87 DIR *d; 156 DIR *d;
88 d = opendir((const char *)Global::applicationFileName(APPDIR,"")); 157 d = opendir((const char *)Global::applicationFileName(APPDIR,""));
@@ -102,35 +171,55 @@ void QTReaderApp::listBkmkFiles()
102 } 171 }
103 172
104 closedir(d); 173 closedir(d);
105 174#endif
106 if (cnt > 0) 175 if (cnt > 0)
107 { 176 {
108//tjw menu->hide(); 177//tjw menu->hide();
109 editBar->hide();
110 if (m_fontVisible) m_fontBar->hide();
111 if (regVisible)
112 {
113 Global::hideInputMethod();
114 regBar->hide();
115 }
116 if (searchVisible)
117 {
118 Global::hideInputMethod();
119 searchBar->hide();
120 }
121 m_nRegAction = cRmBkmkFile;
122 editorStack->raiseWidget( bkmkselector ); 178 editorStack->raiseWidget( bkmkselector );
179 hidetoolbars();
180 m_nBkmkAction = cRmBkmkFile;
123 } 181 }
124 else 182 else
125 QMessageBox::information(this, PROGNAME, "No bookmark files"); 183 QMessageBox::information(this, PROGNAME, "No bookmark files");
126} 184}
127 185
128QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) 186void QTReaderApp::hidetoolbars()
129 : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false)
130{ 187{
131// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); 188 menubar->hide();
132// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); 189 if (fileBar != NULL) fileBar->hide();
190 if (viewBar != NULL) viewBar->hide();
191 if (navBar != NULL) navBar->hide();
192 if (markBar != NULL) markBar->hide();
193 if (m_fontVisible) m_fontBar->hide();
194 if (regVisible)
195 {
196#ifdef USEQPE
197 Global::hideInputMethod();
198#endif
199 regBar->hide();
200 }
201 if (searchVisible)
202 {
203#ifdef USEQPE
204 Global::hideInputMethod();
205#endif
206 searchBar->hide();
207 }
208}
133 209
210QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
211 : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false),
212 fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL)
213{
214 m_url_clipboard = false;
215 m_url_localfile = false;
216 m_url_globalfile = false;
217 ftime(&m_lastkeytime);
218//// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir());
219//// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml"));
220
221 m_bcloseDisabled = true;
222 m_disableesckey = false;
134 pBkmklist = NULL; 223 pBkmklist = NULL;
135 pOpenlist = NULL; 224 pOpenlist = NULL;
136// doc = 0; 225// doc = 0;
@@ -138,26 +227,92 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
138 m_fBkmksChanged = false; 227 m_fBkmksChanged = false;
139 228
140 QString lang = getenv( "LANG" ); 229 QString lang = getenv( "LANG" );
230 QString rot = getenv( "QWS_DISPLAY" );
141 231
142 m_autogenstr = "^ *[A-Z].*[a-z] *$"; 232/*
143 setToolBarsMovable( FALSE ); 233 int m_rot = 0;
234 if (rot.contains("Rot90"))
235 {
236 m_rot = 90;
237 }
238 else if (rot.contains("Rot180"))
239 {
240 m_rot = 180;
241 }
242 else if (rot.contains("Rot270"))
243 {
244 m_rot = 270;
245 }
246
247// qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot);
248*/
249 m_autogenstr = "^ *[A-Z].*[a-z] *$";
144 250
145 setIcon( Resource::loadPixmap( "uqtreader" ) ); 251#ifdef USEQPE
252 setIcon( Resource::loadPixmap( PICDIR "uqtreader") );
253#else
254 setIcon( QPixmap (PICDIR "uqtreader.png") );
255#endif /* USEQPE */
146 256
147// QPEToolBar *bar = new QPEToolBar( this ); 257// QPEToolBar *bar = new QPEToolBar( this );
148 QToolBar *bar = new QToolBar( this ); 258// menubar = new QPEToolBar( this );
149 bar->setHorizontalStretchable( TRUE ); 259#ifdef USEQPE
150 addToolBar(bar, "tool",QMainWindow::Top, true); 260 Config config( APPDIR );
151//tjw menu = bar; 261#else
152 262 QDir d = QDir::home(); // "/"
153 QPEMenuBar *mb = new QPEMenuBar( bar ); 263 if ( !d.cd(APPDIR) ) { // "/tmp"
154// QMenuBar *mb = new QMenuBar( bar ); 264 qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
155 QPopupMenu *file = new QPopupMenu( this ); 265 d = QDir::home();
156 QPopupMenu *format = new QPopupMenu( this ); 266 d.mkdir(APPDIR);
157 // QPopupMenu *edit = new QPopupMenu( this ); 267 d.cd(APPDIR);
268 }
269 QFileInfo fi(d, INIFILE);
270// qDebug("Path:%s", (const char*)fi.absFilePath());
271 Config config(fi.absFilePath());
272#endif
273 config.setGroup("Toolbar");
274 m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false);
275 m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1);
276 m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2);
277 menubar = new QToolBar("Menus", this, m_tbposition);
278
279// fileBar = new QToolBar("File", this);
280// QToolBar* viewBar = new QToolBar("File", this);
281// QToolBar* navBar = new QToolBar("File", this);
282// QToolBar* markBar = new QToolBar("File", this);
283
284#ifdef USEQPE
285 mb = new QPEMenuBar( menubar );
286#else
287 mb = new QMenuBar( menubar );
288#endif
158 289
159// bar = new QToolBar( this ); 290//#ifdef USEQPE
160 editBar = bar; 291 QPopupMenu* tmp = new QPopupMenu(mb);
292 mb->insertItem( geticon( "AppsIcon" ), tmp );
293//#else
294// QMenuBar* tmp = mb;
295//#endif
296
297 QPopupMenu *file = new QPopupMenu( mb );
298 tmp->insertItem( tr( "File" ), file );
299
300 QPopupMenu *navigation = new QPopupMenu(mb);
301 tmp->insertItem( tr( "Navigation" ), navigation );
302
303 QPopupMenu *view = new QPopupMenu( mb );
304 tmp->insertItem( tr( "View" ), view );
305
306 QPopupMenu *marks = new QPopupMenu( this );
307 tmp->insertItem( tr( "Marks" ), marks );
308
309 QPopupMenu *settings = new QPopupMenu( this );
310 tmp->insertItem( tr( "Settings" ), settings );
311
312// addToolBar(menubar, "Menus",QMainWindow::Top);
313// addToolBar(fileBar, "Toolbar",QMainWindow::Top);
314
315 // QPopupMenu *edit = new QPopupMenu( this );
161 316
162 /* 317 /*
163 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 318 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
@@ -173,9 +328,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
173 regVisible = FALSE; 328 regVisible = FALSE;
174 m_fontVisible = false; 329 m_fontVisible = false;
175 330
176 pbar = new QProgressBar(this);
177 pbar->hide();
178
179 m_annoWin = new CAnnoEdit(editorStack); 331 m_annoWin = new CAnnoEdit(editorStack);
180 editorStack->addWidget(m_annoWin, get_unique_id()); 332 editorStack->addWidget(m_annoWin, get_unique_id());
181 connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); 333 connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) );
@@ -205,25 +357,37 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
205 // don't need the close visible, it is redundant... 357 // don't need the close visible, it is redundant...
206 importSelector->setCloseVisible( FALSE ); 358 importSelector->setCloseVisible( FALSE );
207*/ 359*/
208 qDebug("Reading file list"); 360// qDebug("Reading file list");
209 readfilelist(); 361 readfilelist();
210 362
211 reader = new QTReader( editorStack ); 363 reader = new QTReader( editorStack );
212 364
213 reader->bDoUpdates = false; 365 reader->bDoUpdates = false;
214 366
367#ifdef USEQPE
215 ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); 368 ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold);
369#endif
216 370
217 qDebug("Reading config"); 371// qDebug("Reading config");
218 Config config( APPDIR ); 372// Config config( APPDIR );
219 config.setGroup( "View" ); 373 config.setGroup( "View" );
220 374 m_debounce = config.readNumEntry("Debounce", 0);
375#ifdef USEQPE
376 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false);
377#else
378 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true);
379#endif
221 reader->bstripcr = config.readBoolEntry( "StripCr", true ); 380 reader->bstripcr = config.readBoolEntry( "StripCr", true );
381 reader->bfulljust = config.readBoolEntry( "FullJust", false );
382 reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 ));
383 reader->setlead(config.readNumEntry( "ExtraLead", 0 ));
222 reader->btextfmt = config.readBoolEntry( "TextFmt", false ); 384 reader->btextfmt = config.readBoolEntry( "TextFmt", false );
223 reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); 385 reader->bautofmt = config.readBoolEntry( "AutoFmt", true );
224 reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); 386 reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
225 reader->bpeanut = config.readBoolEntry( "Peanut", false ); 387 reader->bpeanut = config.readBoolEntry( "Peanut", false );
226 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); 388 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false );
389 reader->bdepluck = config.readBoolEntry( "Depluck", false );
390 reader->bdejpluck = config.readBoolEntry( "Dejpluck", false );
227 reader->bonespace = config.readBoolEntry( "OneSpace", false ); 391 reader->bonespace = config.readBoolEntry( "OneSpace", false );
228 reader->bunindent = config.readBoolEntry( "Unindent", false ); 392 reader->bunindent = config.readBoolEntry( "Unindent", false );
229 reader->brepara = config.readBoolEntry( "Repara", false ); 393 reader->brepara = config.readBoolEntry( "Repara", false );
@@ -234,12 +398,13 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
234 reader->m_lastfile = config.readEntry( "LastFile", QString::null ); 398 reader->m_lastfile = config.readEntry( "LastFile", QString::null );
235 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); 399 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 );
236 reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); 400 reader->m_bpagemode = config.readBoolEntry( "PageMode", true );
237 reader->m_navkeys = config.readBoolEntry( "CursorNavigation", false );
238 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); 401 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false);
402 reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false);
239 reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); 403 reader->m_fontname = config.readEntry( "Fontname", "helvetica" );
240 reader->m_encd = config.readNumEntry( "Encoding", 0 ); 404 reader->m_encd = config.readNumEntry( "Encoding", 0 );
241 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); 405 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 );
242 reader->m_overlap = config.readNumEntry( "Overlap", 0 ); 406 reader->m_overlap = config.readNumEntry( "Overlap", 0 );
407 reader->m_border = config.readNumEntry( "Margin", 6 );
243#ifdef REPALM 408#ifdef REPALM
244 reader->brepalm = config.readBoolEntry( "Repalm", true ); 409 reader->brepalm = config.readBoolEntry( "Repalm", true );
245#endif 410#endif
@@ -248,90 +413,156 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
248 reader->setContinuous(config.readBoolEntry( "Continuous", true )); 413 reader->setContinuous(config.readBoolEntry( "Continuous", true ));
249 m_targetapp = config.readEntry( "TargetApp", QString::null ); 414 m_targetapp = config.readEntry( "TargetApp", QString::null );
250 m_targetmsg = config.readEntry( "TargetMsg", QString::null ); 415 m_targetmsg = config.readEntry( "TargetMsg", QString::null );
416#ifdef _SCROLLPIPE
417 reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null );
418 reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true );
419#endif
251 m_twoTouch = config.readBoolEntry( "TwoTouch", false); 420 m_twoTouch = config.readBoolEntry( "TwoTouch", false);
252 m_doAnnotation = config.readBoolEntry( "Annotation", false); 421 m_doAnnotation = config.readBoolEntry( "Annotation", false);
253 m_doDictionary = config.readBoolEntry( "Dictionary", false); 422 m_doDictionary = config.readBoolEntry( "Dictionary", false);
254 m_doClipboard = config.readBoolEntry( "Clipboard", false); 423 m_doClipboard = config.readBoolEntry( "Clipboard", false);
255 m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); 424 m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll);
256 setTwoTouch(m_twoTouch); 425 m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone);
426 m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen);
427 m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut);
428 m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn);
429 m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp);
430 m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown);
431
432 m_leftScroll = config.readBoolEntry("LeftScroll", false);
433 m_rightScroll = config.readBoolEntry("RightScroll", false);
434 m_upScroll = config.readBoolEntry("UpScroll", true);
435 m_downScroll = config.readBoolEntry("DownScroll", true);
436
437 m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false);
438 reader->setBaseSize(config.readNumEntry( "Basesize", 10 ));
439
440#ifndef USEQPE
441 config.setGroup( "Geometry" );
442 setGeometry(0,0,
443 config.readNumEntry( "width", QApplication::desktop()->width()/2 ),
444 config.readNumEntry( "height", QApplication::desktop()->height()/2 ));
445 move(
446 config.readNumEntry( "x", 20 ),
447 config.readNumEntry( "y", 20 ));
448#endif
257 449
258 450
259 connect( reader, SIGNAL( OnShowPicture(QPixmap&) ), this, SLOT( showgraphic(QPixmap&) ) ); 451
452 setTwoTouch(m_twoTouch);
453
454 connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) );
260 455
261 connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); 456 connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) );
262 connect( reader, SIGNAL( OnActionPressed() ), this, SLOT( OnActionPressed() ) );
263 connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) ); 457 connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) );
458 connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) );
264 editorStack->addWidget( reader, get_unique_id() ); 459 editorStack->addWidget( reader, get_unique_id() );
265 460
266 QAction *a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 461 m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL);
267 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 462 connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) );
268 a->addTo( bar ); 463 m_preferences_action->addTo( settings );
269 a->addTo( file );
270 464
271 a = new QAction( tr( "Close" ), Resource::loadPixmap( "fileclose" ), QString::null, 0, this, 0 ); 465 m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL);
272 connect( a, SIGNAL( activated() ), this, SLOT( fileClose() ) ); 466 connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) );
273// a->addTo( bar ); 467 m_saveconfig_action->addTo( settings );
274 a->addTo( file ); 468
469 m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL);
470 connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) );
471 m_loadconfig_action->addTo( settings );
472
473 m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL);
474 connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) );
475 m_tidyconfig_action->addTo( settings );
476
477 settings->insertSeparator();
478 m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL);
479 connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) );
480 m_toolbarprefs_action->addTo( settings );
481
482 m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 );
483 connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
484 m_open_action->addTo( file );
485
486 m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 );
487 connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) );
488 m_close_action->addTo( file );
275 489
490#ifdef _SCRIPT
491 a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL);
492 connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) );
493 a->addTo( file );
494#endif
276 /* 495 /*
277 a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 496 a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 );
278 connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); 497 connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) );
279 a->addTo( file ); 498 a->addTo( file );
280 499
281 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 500 a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 );
282 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 501 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
283 a->addTo( editBar ); 502 a->addTo( filebar() );
284 a->addTo( edit ); 503 a->addTo( edit );
285 */ 504 */
286 505
287 a = new QAction( tr( "Info" ), QString::null, 0, this, NULL); 506 m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL);
288 connect( a, SIGNAL( activated() ), this, SLOT( showinfo() ) ); 507 connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) );
289 a->addTo( file ); 508 m_info_action->addTo( file );
290
291 QActionGroup* ag = new QActionGroup(this);
292 QPopupMenu *spacemenu = new QPopupMenu(this);
293 file->insertItem( tr( "On Action..." ), spacemenu );
294
295 m_buttonAction[0] = new QAction( tr( "Open File" ), QString::null, 0, ag, NULL, true );
296
297 m_buttonAction[1] = new QAction( tr( "Autoscroll" ), QString::null, 0, ag, NULL, true );
298
299 m_buttonAction[2] = new QAction( tr( "Mark" ), QString::null, 0, ag, NULL, true );
300 509
301 m_buttonAction[3] = new QAction( tr( "Fullscreen" ), QString::null, 0, ag, NULL, true ); 510 m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true );
511 connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) );
512 m_touch_action->setOn(m_twoTouch);
513 m_touch_action->addTo( file );
302 514
303 ag->addTo(spacemenu); 515 m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL);
516 connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) );
517 file->insertSeparator();
518// a->addTo( bar );
519 m_find_action->addTo( file );
304 520
305 connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) ); 521 m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL);
522 connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) );
523 m_exportlinks_action->addTo( file );
306 524
307 file->insertSeparator(); 525 m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true );
526 connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) );
527 m_scrollButton->addTo(navigation);
528 m_scrollButton->setOn(false);
308 529
309 ag = new QActionGroup(this); 530 m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL);
310 ag->setExclusive(false); 531 connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) );
311 QPopupMenu *encoding = new QPopupMenu(this); 532 m_start_action->addTo(navigation);
312 file->insertItem( tr( "Navigation" ), encoding );
313 533
314 a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( PICDIR "panel-arrow-down" ), QString::null, 0, ag, 0, true ); 534 m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL);
535 connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) );
536 m_end_action->addTo(navigation);
315 537
316 a->setOn(false); 538 m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL);
317 connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); 539 connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) );
318 a->addTo( bar ); 540 m_jump_action->addTo(navigation);
319 541
320 a = new QAction( tr( "Jump" ), QString::null, 0, ag, NULL); 542 m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true );
321 connect( a, SIGNAL( activated() ), this, SLOT( jump() ) ); 543 connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) );
544 m_pageline_action->addTo(navigation);
545 m_pageline_action->setOn(reader->m_bpagemode);
322 546
323 a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, ag, NULL, true ); 547 m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 );
324 connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); 548 connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) );
325 a->setOn(reader->m_bpagemode); 549 m_pageup_action->addTo( navigation );
550
551 m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 );
552 connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) );
553 m_pagedn_action->addTo( navigation );
326 554
327 a = new QAction( tr( "Set Overlap" ), QString::null, 0, ag, NULL); 555 m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 );
328 connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) ); 556 connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) );
557 m_back_action->addTo( navigation );
329 558
330 a = new QAction( tr( "Use Cursor" ), QString::null, 0, ag, NULL, true ); 559 m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 );
331 connect( a, SIGNAL( toggled(bool) ), this, SLOT( navkeys(bool) ) ); 560 connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) );
332 a->setOn(reader->m_navkeys); 561 m_home_action->addTo( navigation );
333 562
334 ag->addTo(encoding); 563 m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 );
564 connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) );
565 m_forward_action->addTo( navigation );
335 566
336 /* 567 /*
337 a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); 568 a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true );
@@ -343,266 +574,145 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
343 a->addTo( file ); 574 a->addTo( file );
344 */ 575 */
345 576
346 file->insertSeparator(); 577// file->insertSeparator();
347 578
348 a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL); 579#ifdef _SCROLLPIPE
349 connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) );
350 a->addTo( file );
351 580
352 a = new QAction( tr( "Two/One Touch" ), QString::null, 0, this, NULL, true ); 581 QActionGroup* ag = new QActionGroup(this);
353 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) );
354 a->setOn(m_twoTouch);
355 a->addTo( file );
356
357 ag = new QActionGroup(this);
358 ag->setExclusive(false); 582 ag->setExclusive(false);
359 encoding = new QPopupMenu(this); 583 spacemenu = new QPopupMenu(this);
360 file->insertItem( tr( "Target" ), encoding ); 584 file->insertItem( tr( "Scrolling" ), spacemenu );
361 585
362 a = new QAction( tr( "Annotation" ), QString::null, 0, ag, NULL, true ); 586 a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL);
363 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnAnnotation(bool) ) ); 587 connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) );
364 a->setOn(m_doAnnotation);
365 588
366 a = new QAction( tr( "Dictionary" ), QString::null, 0, ag, NULL, true ); 589 a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true );
367 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnDictionary(bool) ) ); 590 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) );
368 a->setOn(m_doDictionary); 591 a->setOn(reader->m_pauseAfterEachPara);
369 592
370 a = new QAction( tr( "Clipboard" ), QString::null, 0, ag, NULL, true ); 593 ag->addTo(spacemenu);
371 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnClipboard(bool) ) ); 594// file->insertSeparator();
372 a->setOn(m_doClipboard);
373
374 ag->addTo(encoding);
375 595
596#endif
376 597
377/* 598/*
378 a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); 599 a = new QAction( tr( "Import" ), QString::null, 0, this, NULL );
379 connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); 600 connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) );
380 a->addTo( file ); 601 a->addTo( file );
381*/ 602*/
382
383 a = new QAction( tr( "Up" ), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 );
384 connect( a, SIGNAL( activated() ), this, SLOT( pageup() ) );
385 a->addTo( editBar );
386
387 a = new QAction( tr( "Down" ), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 );
388 connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
389 a->addTo( editBar );
390 603
391 /* 604 /*
392 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 605 a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 );
393 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 606 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
394 a->addTo( editBar ); 607 a->addTo( fileBar );
395 a->addTo( edit ); 608 a->addTo( edit );
396 */ 609 */
397 610
398// a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 611// a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 );
399 a = new QAction( tr( "Find..." ), QString::null, 0, this, NULL);
400 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
401 file->insertSeparator();
402// a->addTo( bar );
403 a->addTo( file );
404
405 612
406 m_fullscreen = false; 613 m_fullscreen = false;
407 a = m_actFullscreen = new QAction( tr( "Fullscreen" ), QString::null, 0, this, NULL, true ); 614 m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true );
408 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); 615 connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) );
409 a->setOn(m_fullscreen); 616 m_actFullscreen->setOn(m_fullscreen);
410 a->addTo( file ); 617 m_actFullscreen->addTo( view );
411
412 a = new QAction( tr( "Continuous" ), QString::null, 0, ag, NULL, true );
413 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setcontinuous(bool) ) );
414 a->setOn(reader->m_continuousDocument);
415 a->addTo( file );
416
417 a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
418 connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) );
419 a->addTo( bar );
420
421 m_bkmkAvail->setEnabled(false);
422 618
619 view->insertSeparator();
423 620
424 ag = new QActionGroup(this); 621 m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this);
425// ag->setExclusive(false); 622 connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) );
426 encoding = new QPopupMenu(this); 623 m_zoomin_action->addTo( view );
427 format->insertItem( tr( "Markup" ), encoding );
428 624
429 a = new QAction( tr( "Auto" ), QString::null, 0, ag, NULL, true ); 625 m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this);
430 a->setOn(reader->bautofmt); 626 connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) );
431 connect( a, SIGNAL( toggled(bool) ), this, SLOT( autofmt(bool) ) ); 627 m_zoomout_action->addTo( view );
432 628
433 a = new QAction( tr( "None" ), QString::null, 0, ag, NULL, true ); 629 view->insertSeparator();
434 a->setOn(!reader->bautofmt && !(reader->btextfmt || reader->bstriphtml || reader->bpeanut)); 630 m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this);
435// connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) ); 631 connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) );
632 m_setfont_action->addTo( view );
436 633
437 a = new QAction( tr( "Text" ), QString::null, 0, ag, NULL, true ); 634 view->insertSeparator();
438 a->setOn(reader->btextfmt); 635 m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this);
439 connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) ); 636 connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) );
637 m_setenc_action->addTo( view );
440 638
441 a = new QAction( tr( "HTML" ), QString::null, 0, ag, NULL, true ); 639 m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true);
442 a->setOn(reader->bstriphtml); 640 connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
443 connect( a, SIGNAL( toggled(bool) ), this, SLOT( striphtml(bool) ) ); 641 m_setmono_action->addTo( view );
642 m_setmono_action->setOn(reader->m_bMonoSpaced);
444 643
445 a = new QAction( tr( "Peanut/PML" ), QString::null, 0, ag, NULL, true );
446 a->setOn(reader->bpeanut);
447 connect( a, SIGNAL( toggled(bool) ), this, SLOT( peanut(bool) ) );
448 644
449 ag->addTo(encoding); 645 // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true );
450 646 // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 );
451
452
453 ag = new QActionGroup(this);
454 ag->setExclusive(false);
455 encoding = new QPopupMenu(this);
456 format->insertItem( tr( "Layout" ), encoding );
457
458 a = new QAction( tr( "Strip CR" ), QString::null, 0, ag, NULL, true );
459 a->setOn(reader->bstripcr);
460 connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) );
461
462 a = new QAction( tr( "Dehyphen" ), QString::null, 0, ag, NULL, true );
463 a->setOn(reader->bdehyphen);
464 connect( a, SIGNAL( toggled(bool) ), this, SLOT( dehyphen(bool) ) );
465// a->addTo( format );
466
467 a = new QAction( tr( "Single Space" ), QString::null, 0, ag, NULL, true );
468 a->setOn(reader->bonespace);
469 connect( a, SIGNAL( toggled(bool) ), this, SLOT( onespace(bool) ) );
470
471 a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true );
472 connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) );
473 a->setOn(reader->bunindent);
474// a->addTo( format );
475
476 a = new QAction( tr( "Re-paragraph" ), QString::null, 0, ag, NULL, true );
477 connect( a, SIGNAL( toggled(bool) ), this, SLOT( repara(bool) ) );
478 a->setOn(reader->brepara);
479// a->addTo( format );
480
481 a = new QAction( tr( "Double Space" ), QString::null, 0, ag, NULL, true );
482 connect( a, SIGNAL( toggled(bool) ), this, SLOT( dblspce(bool) ) );
483 a->setOn(reader->bdblspce);
484// a->addTo( format );
485
486 a = new QAction( tr( "Indent+" ), QString::null, 0, ag, NULL );
487 connect( a, SIGNAL( activated() ), this, SLOT( indentplus() ) );
488// a->addTo( format );
489
490 a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL );
491 connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) );
492#ifdef REPALM
493 a = new QAction( tr( "Repalm" ), QString::null, 0, ag, NULL, true );
494 a->setOn(reader->brepalm);
495 connect( a, SIGNAL( toggled(bool) ), this, SLOT( repalm(bool) ) );
496#endif
497 a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true );
498 connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) );
499 a->setOn(reader->bremap);
500
501 a = new QAction( tr( "Embolden" ), QString::null, 0, ag, NULL, true );
502 connect( a, SIGNAL( toggled(bool) ), this, SLOT( embolden(bool) ) );
503 a->setOn(reader->bmakebold);
504 647
505 ag->addTo(encoding);
506 648
507 // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true );
508 // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
509 format->insertSeparator();
510 a = new QAction( tr( "Zoom In" ), QString::null, 0, this);
511 connect( a, SIGNAL( activated() ), this, SLOT( zoomin() ) );
512 a->addTo( format );
513 a = new QAction( tr( "Zoom Out" ), QString::null, 0, this);
514 connect( a, SIGNAL( activated() ), this, SLOT( zoomout() ) );
515 a->addTo( format );
516 // a->addTo( editBar );
517 format->insertSeparator();
518 649
650 // a->addTo( filebar() );
651// view->insertSeparator();
519 652
653/*
520 a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); 654 a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true );
521 connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); 655 connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
522 a->setOn(reader->m_bMonoSpaced); 656 a->setOn(reader->m_bMonoSpaced);
523 a->addTo( format ); 657 a->addTo( view );
524 658*/
525 a = new QAction( tr( "Set width" ), QString::null, 0, this, NULL); 659/*
660 a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL);
526 connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); 661 connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) );
527 a->addTo( format ); 662 a->addTo( view );
528 663*/
529 encoding = new QPopupMenu(this);
530// format->insertSeparator();
531 format->insertItem( tr( "Encoding" ), encoding );
532
533 ag = new QActionGroup(this);
534
535 m_EncodingAction[0] = new QAction( tr( "Ascii" ), QString::null, 0, ag, NULL, true );
536
537 m_EncodingAction[1] = new QAction( tr( "UTF-8" ), QString::null, 0, ag, NULL, true );
538
539 m_EncodingAction[2] = new QAction( tr( "UCS-2(BE)" ), QString::null, 0, ag, NULL, true );
540
541 m_EncodingAction[3] = new QAction( tr( "USC-2(LE)" ), QString::null, 0, ag, NULL, true );
542
543 m_EncodingAction[4] = new QAction( tr( "Palm" ), QString::null, 0, ag, NULL, true );
544
545 m_EncodingAction[5] = new QAction( tr( "Windows(1252)" ), QString::null, 0, ag, NULL, true );
546
547 ag->addTo(encoding);
548
549 connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( encodingSelected(QAction*) ) );
550
551 a = new QAction( tr( "Set Font" ), QString::null, 0, this);
552 connect( a, SIGNAL( activated() ), this, SLOT( setfont() ) );
553 format->insertSeparator();
554 a->addTo( format );
555
556 QPopupMenu *marks = new QPopupMenu( this );
557 664
558 a = new QAction( tr( "Mark" ), QString::null, 0, this, NULL); 665 m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL);
559 connect( a, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); 666 connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) );
560 a->addTo( marks ); 667 m_mark_action->addTo( marks );
561 668
562 a = new QAction( tr( "Annotate" ), QString::null, 0, this, NULL); 669 m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL);
563 connect( a, SIGNAL( activated() ), this, SLOT( addanno() ) ); 670 connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) );
564 a->addTo( marks ); 671 m_annotate_action->addTo( marks );
565 672
566 a = new QAction( tr( "Goto" ), QString::null, 0, this, NULL, false ); 673 m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false );
567 connect( a, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); 674 connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) );
568 a->addTo( marks ); 675 m_goto_action->addTo( marks );
569 676
570 a = new QAction( tr( "Delete" ), QString::null, 0, this, NULL); 677 m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL);
571 connect( a, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); 678 connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) );
572 a->addTo( marks ); 679 m_delete_action->addTo( marks );
573 680
574 a = new QAction( tr( "Autogen" ), QString::null, 0, this, NULL, false ); 681 m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false );
575 connect( a, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); 682 connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) );
576 marks->insertSeparator(); 683 marks->insertSeparator();
577 a->addTo( marks ); 684 m_autogen_action->addTo( marks );
578 685
579 a = new QAction( tr( "Clear" ), QString::null, 0, this, NULL); 686 m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL);
580 connect( a, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); 687 connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) );
581 a->addTo( marks ); 688 m_clear_action->addTo( marks );
582 689
583 a = new QAction( tr( "Save" ), QString::null, 0, this, NULL ); 690 m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL );
584 connect( a, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); 691 connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) );
585 a->addTo( marks ); 692 m_save_action->addTo( marks );
586 693
587 a = new QAction( tr( "Tidy" ), QString::null, 0, this, NULL); 694 m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL);
588 connect( a, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); 695 connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) );
589 marks->insertSeparator(); 696 marks->insertSeparator();
590 a->addTo( marks ); 697 m_tidy_action->addTo( marks );
591 698
592 a = new QAction( tr( "Start Block" ), QString::null, 0, this, NULL); 699 m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL);
593 connect( a, SIGNAL( activated() ), this, SLOT( editMark() ) ); 700 connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) );
594 marks->insertSeparator(); 701 marks->insertSeparator();
595 a->addTo( marks ); 702 m_startBlock_action->addTo( marks );
703
704 m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL);
705 connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) );
706 m_endBlock_action->addTo( marks );
596 707
597 a = new QAction( tr( "Copy Block" ), QString::null, 0, this, NULL); 708 m_bkmkAvail = NULL;
598 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
599 a->addTo( marks );
600 709
601 710
602 mb->insertItem( tr( "File" ), file ); 711 setToolBarsMovable(m_tbmove);
603 // mb->insertItem( tr( "Edit" ), edit ); 712 addtoolbars(&config);
604 mb->insertItem( tr( "Format" ), format ); 713
605 mb->insertItem( tr( "Marks" ), marks ); 714 pbar = new QProgressBar(this);
715 pbar->hide();
606 716
607 searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); 717 searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE );
608 718
@@ -615,6 +725,7 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
615// searchEdit->setFont( f ); 725// searchEdit->setFont( f );
616 searchBar->setStretchableWidget( searchEdit ); 726 searchBar->setStretchableWidget( searchEdit );
617 727
728
618#ifdef __ISEARCH 729#ifdef __ISEARCH
619 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 730 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
620 this, SLOT( search( const QString& ) ) ); 731 this, SLOT( search( const QString& ) ) );
@@ -622,11 +733,11 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
622 connect( searchEdit, SIGNAL( returnPressed( ) ), 733 connect( searchEdit, SIGNAL( returnPressed( ) ),
623 this, SLOT( search( ) ) ); 734 this, SLOT( search( ) ) );
624#endif 735#endif
625 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 736 QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 );
626 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 737 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
627 a->addTo( searchBar ); 738 a->addTo( searchBar );
628 739
629 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 740 a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 );
630 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 741 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
631 a->addTo( searchBar ); 742 a->addTo( searchBar );
632 743
@@ -645,11 +756,11 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
645 connect( regEdit, SIGNAL( returnPressed( ) ), 756 connect( regEdit, SIGNAL( returnPressed( ) ),
646 this, SLOT( do_regaction() ) ); 757 this, SLOT( do_regaction() ) );
647 758
648 a = new QAction( tr( "Do Reg" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); 759 a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 );
649 connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); 760 connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) );
650 a->addTo( regBar ); 761 a->addTo( regBar );
651 762
652 a = new QAction( tr( "Close Edit" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 763 a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 );
653 connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); 764 connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) );
654 a->addTo( regBar ); 765 a->addTo( regBar );
655 766
@@ -659,14 +770,16 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
659 770
660 m_fontBar->setHorizontalStretchable( TRUE ); 771 m_fontBar->setHorizontalStretchable( TRUE );
661 772
662 qDebug("Font selector"); 773// qDebug("Font selector");
663 m_fontSelector = new QComboBox(false, m_fontBar); 774 m_fontSelector = new QComboBox(false, m_fontBar);
664 m_fontBar->setStretchableWidget( m_fontSelector ); 775 m_fontBar->setStretchableWidget( m_fontSelector );
665 { 776 {
777#ifndef USEQPE
778 QFontDatabase f;
779#else
666 FontDatabase f; 780 FontDatabase f;
781#endif
667 QStringList flist = f.families(); 782 QStringList flist = f.families();
668 m_fontSelector->insertStringList(flist);
669
670 bool realfont = false; 783 bool realfont = false;
671 for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) 784 for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++)
672 { 785 {
@@ -674,32 +787,32 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
674 { 787 {
675 realfont = true; 788 realfont = true;
676 } 789 }
677 if (*nm == "courier") reader->m_fontControl.hasCourier(true); 790 if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm);
678 } 791 }
679 if (!realfont) reader->m_fontname = flist[0]; 792 if (!realfont) reader->m_fontname = flist[0];
680 } // delete the FontDatabase!!! 793 } // delete the FontDatabase!!!
681
682 connect( m_fontSelector, SIGNAL( activated(const QString& ) ), 794 connect( m_fontSelector, SIGNAL( activated(const QString& ) ),
683 this, SLOT( do_setfont(const QString&) ) ); 795 this, SLOT( do_setfont(const QString&) ) );
796 connect( m_fontSelector, SIGNAL( activated(int ) ),
797 this, SLOT( do_setencoding(int) ) );
684 798
685 m_fontBar->hide(); 799 m_fontBar->hide();
686 m_fontVisible = false; 800 m_fontVisible = false;
687 801#ifdef USEMSGS
688 connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), 802 connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ),
689 this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); 803 this, SLOT( msgHandler(const QCString&, const QByteArray&) ) );
690 804#endif
691 qDebug("Initing"); 805// qDebug("Initing");
692 reader->init(); 806 reader->init();
693 qDebug("Inited"); 807// qDebug("Inited");
694 m_EncodingAction[reader->m_encd]->setOn(true); 808// m_buttonAction[m_spaceTarget]->setOn(true);
695 m_buttonAction[m_spaceTarget]->setOn(true); 809// qDebug("fonting");
696 qDebug("fonting");
697 do_setfont(reader->m_fontname); 810 do_setfont(reader->m_fontname);
698 if (!reader->m_lastfile.isEmpty()) 811 if (!reader->m_lastfile.isEmpty())
699 { 812 {
700 qDebug("doclnk"); 813 //qDebug("doclnk");
701 //doc = new DocLnk(reader->m_lastfile); 814 //doc = new DocLnk(reader->m_lastfile);
702 qDebug("doclnk done"); 815 //qDebug("doclnk done");
703 if (pOpenlist != NULL) 816 if (pOpenlist != NULL)
704 { 817 {
705 818
@@ -719,40 +832,303 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
719 { 832 {
720 break; 833 break;
721 } 834 }
722 qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); 835 // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name()));
723 p = NULL; 836 p = NULL;
724 } 837 }
725 if (p != NULL) 838 if (p != NULL)
726 { 839 {
727 qDebug("openfrombkmk"); 840 //qDebug("openfrombkmk");
728 openfrombkmk(p); 841 if (!openfrombkmk(p))
842 showEditTools();
729 } 843 }
730 else 844 else
731 { 845 {
732 qDebug("openfile"); 846 //qDebug("openfile");
733 openFile( reader->m_lastfile ); 847 openFile( reader->m_lastfile );
734 } 848 }
735 } 849 }
736 else 850 else
737 { 851 {
738 qDebug("Openfile 2"); 852 // qDebug("Openfile 2");
739 if (!reader->m_lastfile.isNull()) 853 if (!reader->m_lastfile.isEmpty())
740 openFile( reader->m_lastfile ); 854 openFile( reader->m_lastfile );
741 } 855 }
742 } 856 }
743 qApp->processEvents(); 857 else
858 {
859 showEditTools();
860 }
861// qApp->processEvents();
744 reader->bDoUpdates = true; 862 reader->bDoUpdates = true;
745 reader->update(); 863 reader->update();
746 qDebug("finished update"); 864 config.setGroup("Version");
865 int major = config.readNumEntry("Major", 0);
866 int bkmktype = config.readNumEntry("BkmkType", 0);
867 char minor = config.readNumEntry("Minor", 0);
868 if (CheckVersion(major, bkmktype, minor))
869 {
870 config.writeEntry("Major", major);
871 config.writeEntry("BkmkType", bkmktype);
872 config.writeEntry("Minor", (int)minor);
873 }
874// qDebug("finished update");
875}
876
877void QTReaderApp::addtoolbars(Config* config)
878{
879 config->setGroup("Toolbar");
880
881 if (fileBar != NULL)
882 {
883 if (fileBar != menubar)
884 {
885 fileBar->clear();
886 }
887 else
888 {
889 m_preferences_action->removeFrom( filebar() );
890 m_open_action->removeFrom( filebar() );
891 m_close_action->removeFrom( filebar() );
892 m_info_action->removeFrom( filebar() );
893 m_touch_action->removeFrom( filebar() );
894 m_find_action->removeFrom( filebar() );
895 }
896 }
897
898 m_preferences_action->addTo( filebar() );
899 addfilebar(config, "Open", m_open_action);
900 addfilebar(config, "Close", m_close_action);
901 addfilebar(config, "Info", m_info_action);
902 addfilebar(config, "Two/One Touch", m_touch_action);
903 addfilebar(config, "Find", m_find_action);
904
905 if (navBar != NULL)
906 {
907 if ((navBar == fileBar) && (fileBar == menubar))
908 {
909 m_scrollButton->removeFrom( navbar() );
910 m_start_action->removeFrom( navbar() );
911 m_end_action->removeFrom( navbar() );
912 m_jump_action->removeFrom( navbar() );
913 m_pageline_action->removeFrom( navbar() );
914 m_pageup_action->removeFrom( navbar() );
915 m_pagedn_action->removeFrom( navbar() );
916 m_back_action->removeFrom( navbar() );
917 m_home_action->removeFrom( navbar() );
918 m_forward_action->removeFrom( navbar() );
919 }
920 else if (navBar != fileBar)
921 {
922 navBar->clear();
923 }
924 }
925
926 addnavbar(config, "Scroll", m_scrollButton);
927 addnavbar(config, "Goto Start", m_start_action);
928 addnavbar(config, "Goto End", m_end_action);
929
930 addnavbar(config, "Jump", m_jump_action);
931 addnavbar(config, "Page/Line Scroll", m_pageline_action);
932
933 addnavbar(config, "Page Up", m_pageup_action);
934 addnavbar(config, "Page Down", m_pagedn_action);
935
936 addnavbar(config, "Back", m_back_action);
937 addnavbar(config, "Home", m_home_action);
938 addnavbar(config, "Forward", m_forward_action);
939
940 if (viewBar != NULL)
941 {
942 if ((viewBar == fileBar) && (fileBar == menubar))
943 {
944 m_actFullscreen->removeFrom( filebar() );
945 m_zoomin_action->removeFrom( viewbar() );
946 m_zoomout_action->removeFrom( viewbar() );
947 m_setfont_action->removeFrom( viewbar() );
948 m_setenc_action->removeFrom( viewbar() );
949 m_setmono_action->removeFrom( viewbar() );
950 }
951 else if (viewBar != fileBar)
952 {
953 viewBar->clear();
954 }
955 }
956
957 addviewbar(config, "Fullscreen", m_actFullscreen);
958 addviewbar(config, "Zoom In", m_zoomin_action);
959 addviewbar(config, "Zoom Out", m_zoomout_action);
960 addviewbar(config, "Set Font", m_setfont_action);
961 addviewbar(config, "Encoding Select", m_setenc_action);
962 addviewbar(config, "Ideogram Mode", m_setmono_action);
963
964 if (markBar != NULL)
965 {
966 if ((markBar == fileBar) && (fileBar == menubar))
967 {
968 m_mark_action->removeFrom( markbar() );
969 m_annotate_action->removeFrom( markbar());
970 m_goto_action->removeFrom( markbar() );
971 m_delete_action->removeFrom( markbar() );
972 m_autogen_action->removeFrom( markbar() );
973 m_clear_action->removeFrom( markbar() );
974 m_save_action->removeFrom( markbar() );
975 m_tidy_action->removeFrom( markbar() );
976 m_startBlock_action->removeFrom( markbar() );
977 m_endBlock_action->removeFrom( markbar() );
978 }
979 else if (markBar != fileBar)
980 {
981 markBar->clear();
982 }
983 }
984 addmarkbar(config, "Mark", m_mark_action);
985 addmarkbar(config, "Annotate", m_annotate_action);
986 addmarkbar(config, "Goto", m_goto_action);
987 addmarkbar(config, "Delete", m_delete_action);
988 addmarkbar(config, "Autogen", m_autogen_action);
989 addmarkbar(config, "Clear", m_clear_action);
990 addmarkbar(config, "Save", m_save_action);
991 addmarkbar(config, "Tidy", m_tidy_action);
992 addmarkbar(config, "Start Block", m_startBlock_action);
993 addmarkbar(config, "Copy Block", m_endBlock_action);
994 if (checkbar(config, "Annotation indicator"))
995 {
996 if (m_bkmkAvail == NULL)
997 {
998 m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 );
999 connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) );
1000
1001 m_bkmkAvail->setEnabled(false);
1002 }
1003 QLabel *spacer = new QLabel(markBar, "");
1004 markbar()->setStretchableWidget(spacer);
1005 m_bkmkAvail->removeFrom( markbar() );
1006 m_bkmkAvail->addTo( markbar() );
1007 }
1008 else
1009 {
1010 if (m_bkmkAvail != NULL)
1011 {
1012 m_bkmkAvail->removeFrom( markbar() );
1013 delete m_bkmkAvail;
1014 m_bkmkAvail = NULL;
1015 }
1016 }
1017}
1018
1019bool QTReaderApp::checkbar(Config* _config, const QString& key)
1020{
1021 return _config->readBoolEntry(key, false);
1022}
1023
1024
1025QToolBar* QTReaderApp::filebar()
1026{
1027 if (fileBar == NULL)
1028 {
1029 switch (m_tbpol)
1030 {
1031 case cesSingle:
1032 // qDebug("Setting filebar to menubar");
1033 fileBar = menubar;
1034 break;
1035 default:
1036 qDebug("Incorrect toolbar policy set");
1037 case cesMenuTool:
1038 case cesMultiple:
1039 // qDebug("Creating new file bar");
1040 fileBar = new QToolBar("File", this, m_tbposition);
1041 break;
1042 }
1043 //fileBar->setHorizontalStretchable( true );
1044 }
1045 return fileBar;
1046}
1047QToolBar* QTReaderApp::viewbar()
1048{
1049 if (viewBar == NULL)
1050 {
1051 switch (m_tbpol)
1052 {
1053 case cesMultiple:
1054 viewBar = new QToolBar("View", this, m_tbposition);
1055 break;
1056 default:
1057 qDebug("Incorrect toolbar policy set");
1058 case cesSingle:
1059 case cesMenuTool:
1060 viewBar = fileBar;
1061 break;
1062 }
1063 }
1064 return viewBar;
1065}
1066QToolBar* QTReaderApp::navbar()
1067{
1068 if (navBar == NULL)
1069 {
1070 switch (m_tbpol)
1071 {
1072 case cesMultiple:
1073 // qDebug("Creating new nav bar");
1074 navBar = new QToolBar("Navigation", this, m_tbposition);
1075 break;
1076 default:
1077 qDebug("Incorrect toolbar policy set");
1078 case cesSingle:
1079 case cesMenuTool:
1080 navBar = fileBar;
1081 // qDebug("Setting navbar to filebar");
1082 break;
1083 }
1084 }
1085 return navBar;
1086}
1087QToolBar* QTReaderApp::markbar()
1088{
1089 if (markBar == NULL)
1090 {
1091 switch (m_tbpol)
1092 {
1093 case cesMultiple:
1094 markBar = new QToolBar("Marks", this, m_tbposition);
1095 break;
1096 default:
1097 qDebug("Incorrect toolbar policy set");
1098 case cesSingle:
1099 case cesMenuTool:
1100 markBar = fileBar;
1101 break;
1102 }
1103 }
1104 return markBar;
1105}
1106
1107void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a)
1108{
1109 if (_config->readBoolEntry(key, false)) a->addTo( filebar() );
1110}
1111void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a)
1112{
1113 if (_config->readBoolEntry(key, false)) a->addTo( navbar() );
1114}
1115void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a)
1116{
1117 if (_config->readBoolEntry(key, false)) a->addTo( markbar() );
1118}
1119void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a)
1120{
1121 if (_config->readBoolEntry(key, false)) a->addTo( viewbar() );
747} 1122}
748 1123
749void QTReaderApp::suspend() { reader->suspend(); } 1124void QTReaderApp::suspend() { reader->suspend(); }
750 1125
1126#ifdef USEMSGS
751void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) 1127void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
752{ 1128{
753 QString msg = QString::fromUtf8(_msg); 1129 QString msg = QString::fromUtf8(_msg);
754 1130
755// qDebug("Received:%s", (const char*)msg); 1131//// qDebug("Received:%s", (const char*)msg);
756 1132
757 QDataStream stream( _data, IO_ReadOnly ); 1133 QDataStream stream( _data, IO_ReadOnly );
758 if ( msg == "info(QString)" ) 1134 if ( msg == "info(QString)" )
@@ -761,14 +1137,26 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
761 stream >> info; 1137 stream >> info;
762 QMessageBox::information(this, PROGNAME, info); 1138 QMessageBox::information(this, PROGNAME, info);
763 } 1139 }
1140 else if ( msg == "Update(int)" )
1141 {
1142 int info;
1143 stream >> info;
1144 if (info)
1145 {
1146 reader->bDoUpdates = true;
1147 reader->refresh();
1148 }
1149 else
1150 {
1151 reader->bDoUpdates = false;
1152 }
1153 }
764 else if ( msg == "warn(QString)" ) 1154 else if ( msg == "warn(QString)" )
765 { 1155 {
766 QString info; 1156 QString info;
767 stream >> info; 1157 stream >> info;
768 QMessageBox::warning(this, PROGNAME, info); 1158 QMessageBox::warning(this, PROGNAME, info);
769 } 1159 }
770
771
772 else if ( msg == "exit()" ) 1160 else if ( msg == "exit()" )
773 { 1161 {
774 m_dontSave = true; 1162 m_dontSave = true;
@@ -794,6 +1182,18 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
794 { 1182 {
795 showEditTools(); 1183 showEditTools();
796 } 1184 }
1185 else if ( msg == "home()" )
1186 {
1187 reader->goHome();
1188 }
1189 else if ( msg == "back()" )
1190 {
1191 reader->goBack();
1192 }
1193 else if ( msg == "forward()" )
1194 {
1195 reader->goForward();
1196 }
797 else if ( msg == "File/Open(QString)" ) 1197 else if ( msg == "File/Open(QString)" )
798 { 1198 {
799 QString info; 1199 QString info;
@@ -804,45 +1204,66 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
804 { 1204 {
805 showinfo(); 1205 showinfo();
806 } 1206 }
807 else if ( msg == "File/Start Block()" ) 1207 else if ( msg == "File/Action(QString)" )
808 {
809 editMark();
810 }
811 else if ( msg == "File/Copy Block()" )
812 { 1208 {
813 editCopy(); 1209 QString info;
1210 stream >> info;
1211 m_spaceTarget = ActNameToInt(info);
814 } 1212 }
815 else if ( msg == "File/Scroll(int)" ) 1213 else if ( msg == "Navigation/Scroll(int)" )
816 { 1214 {
817 int info; 1215 int info;
818 stream >> info; 1216 stream >> info;
819 autoScroll(info); 1217 autoScroll(info);
820 } 1218 }
821 else if ( msg == "File/Jump(int)" ) 1219
1220 else if ( msg == "Navigation/GotoStart()" )
1221 {
1222 gotoStart();
1223 }
1224 else if ( msg == "Navigation/GotoEnd()" )
1225 {
1226 gotoEnd();
1227 }
1228 else if ( msg == "Navigation/Jump(int)" )
822 { 1229 {
823 int info; 1230 int info;
824 stream >> info; 1231 stream >> info;
825 reader->locate(info); 1232 reader->locate(info);
826 } 1233 }
827 else if ( msg == "File/Page/Line Scroll(int)" ) 1234 else if ( msg == "Navigation/Page/LineScroll(int)" )
828 { 1235 {
829 int info; 1236 int info;
830 stream >> info; 1237 stream >> info;
831 pagemode(info); 1238 pagemode(info);
832 } 1239 }
833 else if ( msg == "File/Set Overlap(int)" ) 1240 else if ( msg == "Navigation/SetOverlap(int)" )
834 { 1241 {
835 int info; 1242 int info;
836 stream >> info; 1243 stream >> info;
837 reader->m_overlap = info; 1244 reader->m_overlap = info;
838 } 1245 }
839 else if ( msg == "File/Set Dictionary(QString)" ) 1246 else if ( msg == "Navigation/SetMargin(int)" )
1247 {
1248 int info;
1249 stream >> info;
1250 do_margin(info);
1251 }
1252 else if ( msg == "File/SetDictionary(QString)" )
840 { 1253 {
841 QString info; 1254 QString info;
842 stream >> info; 1255 stream >> info;
843 do_settarget(info); 1256 do_settarget(info);
844 } 1257 }
845 else if ( msg == "File/Two/One Touch(int)" ) 1258#ifdef _SCROLLPIPE
1259 else if ( msg == "File/SetScrollTarget(QString)" )
1260 {
1261 QString info;
1262 stream >> info;
1263 reader->m_pipetarget = info;
1264 }
1265#endif
1266 else if ( msg == "File/Two/OneTouch(int)" )
846 { 1267 {
847 int info; 1268 int info;
848 stream >> info; 1269 stream >> info;
@@ -874,11 +1295,11 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
874 size_t pos = reader->pagelocate(); 1295 size_t pos = reader->pagelocate();
875 size_t start = pos; 1296 size_t start = pos;
876 CDrawBuffer test(&(reader->m_fontControl)); 1297 CDrawBuffer test(&(reader->m_fontControl));
877 reader->buffdoc.getline(&test,reader->width()); 1298 reader->getline(&test);
878 while (arg.match(toQString(test.data())) == -1) 1299 while (arg.match(toQString(test.data())) == -1)
879 { 1300 {
880 pos = reader->locate(); 1301 pos = reader->locate();
881 if (!reader->buffdoc.getline(&test,reader->width())) 1302 if (!reader->getline(&test))
882 { 1303 {
883 QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); 1304 QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info);
884 pos = start; 1305 pos = start;
@@ -887,56 +1308,84 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
887 } 1308 }
888 reader->locate(pos); 1309 reader->locate(pos);
889 } 1310 }
890 else if ( msg == "Layout/Strip CR(int)" ) 1311 else if ( msg == "File/Fullscreen(int)" )
891 { 1312 {
892 int info; 1313 int info;
893 stream >> info; 1314 stream >> info;
894 stripcr(info); 1315 setfullscreen(info);
895 } 1316 }
896 else if ( msg == "Layout/Single Space" ) 1317 else if ( msg == "File/Continuous(int)" )
897 { 1318 {
898 int info; 1319 int info;
899 stream >> info; 1320 stream >> info;
900 onespace(info); 1321 setcontinuous(info);
901 } 1322 }
902#ifdef REPALM 1323 else if ( msg == "Markup(QString)" )
903 else if ( msg == "Layout/Repalm(int)" ) 1324 {
1325 QString info;
1326 stream >> info;
1327 if (info == "Auto")
1328 {
1329 autofmt(true);
1330 }
1331 if (info == "None")
1332 {
1333 autofmt(false);
1334 textfmt(false);
1335 striphtml(false);
1336 peanut(false);
1337 }
1338 if (info == "Text")
1339 {
1340 textfmt(true);
1341 }
1342 if (info == "HTML")
1343 {
1344 striphtml(true);
1345 }
1346 if (info == "Peanut/PML")
1347 {
1348 peanut(true);
1349 }
1350 }
1351 else if ( msg == "Layout/StripCR(int)" )
904 { 1352 {
905 int info; 1353 int info;
906 stream >> info; 1354 stream >> info;
907 repalm(info); 1355 stripcr(info);
908 } 1356 }
909#endif 1357 else if ( msg == "Layout/Dehyphen(int)" )
910 else if ( msg == "Markup/Auto(int)" )
911 { 1358 {
912 int info; 1359 int info;
913 stream >> info; 1360 stream >> info;
914 autofmt(info); 1361 dehyphen(info);
915 } 1362 }
916 else if ( msg == "Markup/Text(int)" ) 1363 else if ( msg == "Layout/Depluck(int)" )
917 { 1364 {
918 int info; 1365 int info;
919 stream >> info; 1366 stream >> info;
920 textfmt(info); 1367 depluck(info);
921 } 1368 }
922 else if ( msg == "Markup/HTML(int)" ) 1369 else if ( msg == "Layout/Dejpluck(int)" )
923 { 1370 {
924 int info; 1371 int info;
925 stream >> info; 1372 stream >> info;
926 striphtml(info); 1373 dejpluck(info);
927 } 1374 }
928 else if ( msg == "Markup/Peanut(int)" ) 1375 else if ( msg == "Layout/SingleSpace(int)" )
929 { 1376 {
930 int info; 1377 int info;
931 stream >> info; 1378 stream >> info;
932 peanut(info); 1379 onespace(info);
933 } 1380 }
934 else if ( msg == "Layout/Dehyphen(int)" ) 1381#ifdef REPALM
1382 else if ( msg == "Layout/Repalm(int)" )
935 { 1383 {
936 int info; 1384 int info;
937 stream >> info; 1385 stream >> info;
938 dehyphen(info); 1386 repalm(info);
939 } 1387 }
1388#endif
940 else if ( msg == "Layout/Unindent(int)" ) 1389 else if ( msg == "Layout/Unindent(int)" )
941 { 1390 {
942 int info; 1391 int info;
@@ -949,7 +1398,7 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
949 stream >> info; 1398 stream >> info;
950 repara(info); 1399 repara(info);
951 } 1400 }
952 else if ( msg == "Layout/Double Space(int)" ) 1401 else if ( msg == "Layout/DoubleSpace(int)" )
953 { 1402 {
954 int info; 1403 int info;
955 stream >> info; 1404 stream >> info;
@@ -980,7 +1429,7 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
980 stream >> info; 1429 stream >> info;
981 monospace(info); 1430 monospace(info);
982 } 1431 }
983 else if ( msg == "Format/Set width(int)" ) 1432 else if ( msg == "Format/SetWidth(int)" )
984 { 1433 {
985 int info; 1434 int info;
986 stream >> info; 1435 stream >> info;
@@ -988,13 +1437,7 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
988 reader->setfont(); 1437 reader->setfont();
989 reader->refresh(); 1438 reader->refresh();
990 } 1439 }
991 else if ( msg == "Format/Encoding(QString)" ) 1440 else if ( msg == "Format/SetFont(QString,int)" )
992 {
993 QString info;
994 stream >> info;
995 reader->setencoding(EncNameToInt(info));
996 }
997 else if ( msg == "Format/Set Font(QString,int)" )
998 { 1441 {
999 QString fontname; 1442 QString fontname;
1000 int size; 1443 int size;
@@ -1008,8 +1451,16 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
1008 stream >> info; 1451 stream >> info;
1009 do_autogen(info); 1452 do_autogen(info);
1010 } 1453 }
1454 else if ( msg == "File/StartBlock()" )
1455 {
1456 editMark();
1457 }
1458 else if ( msg == "File/CopyBlock()" )
1459 {
1460 editCopy();
1461 }
1011} 1462}
1012 1463#endif
1013ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) 1464ActionTypes QTReaderApp::ActNameToInt(const QString& _enc)
1014{ 1465{
1015 for (int i = 0; i < MAX_ACTIONS; i++) 1466 for (int i = 0; i < MAX_ACTIONS; i++)
@@ -1024,41 +1475,14 @@ void QTReaderApp::setfullscreen(bool sfs)
1024 reader->bDoUpdates = false; 1475 reader->bDoUpdates = false;
1025 m_fullscreen = sfs; 1476 m_fullscreen = sfs;
1026 showEditTools(); 1477 showEditTools();
1027 qApp->processEvents(); 1478// qApp->processEvents();
1028 reader->bDoUpdates = true; 1479 reader->bDoUpdates = true;
1029 reader->update(); 1480 reader->update();
1030} 1481}
1031 1482
1032void QTReaderApp::setcontinuous(bool sfs)
1033{
1034 reader->setContinuous(sfs);
1035 reader->refresh();
1036}
1037
1038int QTReaderApp::EncNameToInt(const QString& _enc)
1039{
1040 for (int i = 0; i < MAX_ENCODING; i++)
1041 {
1042 if (m_EncodingAction[i]->text() == _enc) return i;
1043 }
1044 return 0;
1045/*
1046 if (_enc == "Ascii") return 0;
1047 if (_enc == "UTF-8") return 1;
1048 if (_enc == "UCS-2(BE)") return 2;
1049 if (_enc == "USC-2(LE)") return 3;
1050*/
1051}
1052
1053void QTReaderApp::encodingSelected(QAction* _a)
1054{
1055// qDebug("es:%x : %s", _a, (const char *)(_a->text()));
1056 reader->setencoding(EncNameToInt(_a->text()));
1057}
1058
1059void QTReaderApp::buttonActionSelected(QAction* _a) 1483void QTReaderApp::buttonActionSelected(QAction* _a)
1060{ 1484{
1061// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); 1485//// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text()));
1062 m_spaceTarget = ActNameToInt(_a->text()); 1486 m_spaceTarget = ActNameToInt(_a->text());
1063} 1487}
1064 1488
@@ -1091,37 +1515,56 @@ void QTReaderApp::clearBkmkList()
1091 1515
1092void QTReaderApp::fileClose() 1516void QTReaderApp::fileClose()
1093{ 1517{
1094 if (pOpenlist != NULL) 1518 CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this);
1519 if (cd->exec())
1095 { 1520 {
1096 int ind = 0; 1521 if (pOpenlist != NULL)
1097 Bkmk* p = (*pOpenlist)[ind];
1098 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
1099 {
1100 p = (*pOpenlist)[++ind];
1101 }
1102 if (p != NULL) pOpenlist->erase(ind);
1103 switch (QMessageBox::information ( this , PROGNAME, "What do you want to delete?", "Nothing", "Marks", "Marks\nFile", 1, 0 ))
1104 { 1522 {
1105 case 0: 1523 int ind = 0;
1106 default: 1524 Bkmk* p = (*pOpenlist)[ind];
1107 break; 1525 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
1108 case 2: 1526 {
1527 p = (*pOpenlist)[++ind];
1528 }
1529 if (p != NULL) pOpenlist->erase(ind);
1530 if (cd->delFile())
1531 {
1109 unlink((const char*)reader->m_lastfile); 1532 unlink((const char*)reader->m_lastfile);
1110 case 1: 1533 }
1111 unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string)); 1534 if (cd->delMarks())
1535 {
1536#ifndef USEQPE
1537 QDir d = QDir::home(); // "/"
1538 d.cd(APPDIR);
1539 d.remove(reader->m_string);
1540#else /* USEQPE */
1541 unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string));
1542#endif /* USEQPE */
1543 }
1544 if (cd->delConfig())
1545 {
1546#ifndef USEQPE
1547 QDir d = QDir::home(); // "/"
1548 d.cd(APPDIR "/configs");
1549 d.remove(reader->m_string);
1550#else /* USEQPE */
1551 unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string));
1552#endif /* USEQPE */
1553 }
1112 } 1554 }
1113 }
1114 1555
1115 fileOpen2(); 1556 fileOpen2();
1557 }
1558 delete cd;
1116} 1559}
1117 1560
1118void QTReaderApp::updatefileinfo() 1561void QTReaderApp::updatefileinfo()
1119{ 1562{
1120 if (reader->m_string.isNull()) return; 1563 if (reader->m_string.isEmpty()) return;
1121 if (reader->m_lastfile.isNull()) return; 1564 if (reader->m_lastfile.isEmpty()) return;
1122 tchar* nm = fromQString(reader->m_string); 1565 tchar* nm = fromQString(reader->m_string);
1123 tchar* fl = fromQString(reader->m_lastfile); 1566 tchar* fl = fromQString(reader->m_lastfile);
1124 qDebug("Lastfile:%x", fl); 1567// qDebug("Lastfile:%x", fl);
1125 bool notadded = true; 1568 bool notadded = true;
1126 if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; 1569 if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>;
1127 else 1570 else
@@ -1135,7 +1578,7 @@ void QTReaderApp::updatefileinfo()
1135 unsigned char* data; 1578 unsigned char* data;
1136 CFiledata fd(iter->anno()); 1579 CFiledata fd(iter->anno());
1137 reader->setSaveData(data, dlen, fd.content(), fd.length()); 1580 reader->setSaveData(data, dlen, fd.content(), fd.length());
1138 qDebug("Filedata(1):%u, %u", fd.length(), dlen); 1581 // qDebug("Filedata(1):%u, %u", fd.length(), dlen);
1139 // getstate(data, dlen); 1582 // getstate(data, dlen);
1140 iter->setAnno(data, dlen); 1583 iter->setAnno(data, dlen);
1141 notadded = false; 1584 notadded = false;
@@ -1144,7 +1587,7 @@ void QTReaderApp::updatefileinfo()
1144 } 1587 }
1145 } 1588 }
1146 } 1589 }
1147 qDebug("Added?:%x", notadded); 1590// qDebug("Added?:%x", notadded);
1148 if (notadded) 1591 if (notadded)
1149 { 1592 {
1150 struct stat fnstat; 1593 struct stat fnstat;
@@ -1154,7 +1597,7 @@ void QTReaderApp::updatefileinfo()
1154 unsigned char* data; 1597 unsigned char* data;
1155 reader->setSaveData(data, dlen, fd.content(), fd.length()); 1598 reader->setSaveData(data, dlen, fd.content(), fd.length());
1156 pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); 1599 pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate()));
1157 qDebug("Filedata(2):%u, %u", fd.length(), dlen); 1600 //qDebug("Filedata(2):%u, %u", fd.length(), dlen);
1158 delete [] data; 1601 delete [] data;
1159 } 1602 }
1160 delete [] nm; 1603 delete [] nm;
@@ -1165,11 +1608,11 @@ void QTReaderApp::fileOpen()
1165{ 1608{
1166/* 1609/*
1167 menu->hide(); 1610 menu->hide();
1168 editBar->hide(); 1611 fileBar->hide();
1169 if (regVisible) regBar->hide(); 1612 if (regVisible) regBar->hide();
1170 if (searchVisible) searchBar->hide(); 1613 if (searchVisible) searchBar->hide();
1171*/ 1614*/
1172 qDebug("fileOpen"); 1615// qDebug("fileOpen");
1173// if (!reader->m_lastfile.isEmpty()) 1616// if (!reader->m_lastfile.isEmpty())
1174 updatefileinfo(); 1617 updatefileinfo();
1175 fileOpen2(); 1618 fileOpen2();
@@ -1193,25 +1636,33 @@ void QTReaderApp::fileOpen2()
1193 editorStack->raiseWidget( fileSelector ); 1636 editorStack->raiseWidget( fileSelector );
1194 fileSelector->reread(); 1637 fileSelector->reread();
1195*/ 1638*/
1639 bool usebrowser = true;
1196 if (pOpenlist != NULL) 1640 if (pOpenlist != NULL)
1197 { 1641 {
1198 m_nRegAction = cOpenFile; 1642 m_nBkmkAction = cOpenFile;
1199 listbkmk(pOpenlist, "Browse"); 1643 if (listbkmk(pOpenlist, "Browse")) usebrowser = false;
1200 } 1644 }
1201 else 1645 if (usebrowser)
1202 { 1646 {
1203 QString fn = usefilebrowser(); 1647 QString fn = usefilebrowser();
1648 //qApp->processEvents();
1204 if (!fn.isEmpty() && QFileInfo(fn).isFile()) 1649 if (!fn.isEmpty() && QFileInfo(fn).isFile())
1205 { 1650 {
1206 openFile(fn); 1651 openFile(fn);
1207 } 1652 }
1208 reader->setFocus(); 1653 reader->setFocus();
1209 } 1654 }
1655// reader->refresh();
1656// qDebug("HEIGHT:%d", reader->m_lastheight);
1210} 1657}
1211 1658
1212QString QTReaderApp::usefilebrowser() 1659QString QTReaderApp::usefilebrowser()
1213{ 1660{
1214 fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE, 1661#ifndef USEQPE
1662 QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) );
1663 return s;
1664#else
1665 fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog,
1215 0, 1666 0,
1216 // WStyle_Customize | WStyle_NoBorderEx, 1667 // WStyle_Customize | WStyle_NoBorderEx,
1217 "*", QFileInfo(reader->m_lastfile).dirPath(true)); 1668 "*", QFileInfo(reader->m_lastfile).dirPath(true));
@@ -1220,20 +1671,252 @@ QString QTReaderApp::usefilebrowser()
1220 QString fn; 1671 QString fn;
1221 if (fb->exec()) 1672 if (fb->exec())
1222 { 1673 {
1223 fn = fb->fileList[0]; 1674 fn = fb->getCurrentFile();
1224 } 1675 }
1225 qDebug("Selected %s", (const char*)fn); 1676// qDebug("Selected %s", (const char*)fn);
1226 delete fb; 1677 delete fb;
1678 showEditTools();
1227 return fn; 1679 return fn;
1680#endif
1228} 1681}
1229 1682
1230void QTReaderApp::showgraphic(QPixmap& pm) 1683void QTReaderApp::showgraphic(QImage& pm)
1231{ 1684{
1232 m_graphicwin->setPixmap(pm); 1685 QPixmap pc;
1686 pc.convertFromImage(pm);
1687 m_graphicwin->setPixmap(pc);
1233 editorStack->raiseWidget( m_graphicwin ); 1688 editorStack->raiseWidget( m_graphicwin );
1234 m_graphicwin->setFocus(); 1689 m_graphicwin->setFocus();
1235} 1690}
1236 1691
1692
1693void QTReaderApp::showprefs()
1694{
1695 CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this);
1696
1697 prefwin->twotouch(m_twoTouch);
1698 prefwin->propfontchange(m_propogatefontchange);
1699 prefwin->StripCR(reader->bstripcr);
1700 prefwin->Dehyphen(reader->bdehyphen);
1701 prefwin->SingleSpace(reader->bonespace);
1702 prefwin->Unindent(reader->bunindent);
1703 prefwin->Reparagraph(reader->brepara);
1704 prefwin->DoubleSpace(reader->bdblspce);
1705 prefwin->Remap(reader->bremap);
1706 prefwin->Embolden(reader->bmakebold);
1707 prefwin->FullJustify(reader->bfulljust);
1708 prefwin->ParaLead(reader->getextraspace());
1709 prefwin->LineLead(reader->getlead());
1710 prefwin->Margin(reader->m_border);
1711 prefwin->Indent(reader->bindenter);
1712 if (reader->bautofmt)
1713 {
1714 prefwin->Markup(0);
1715 }
1716 else if (reader->btextfmt)
1717 {
1718 prefwin->Markup(2);
1719 }
1720 else if (reader->bstriphtml)
1721 {
1722 prefwin->Markup(3);
1723 }
1724 else if (reader->bpeanut)
1725 {
1726 prefwin->Markup(4);
1727 }
1728 else
1729 {
1730 prefwin->Markup(1);
1731 }
1732 prefwin->Depluck(reader->bdepluck);
1733 prefwin->Dejpluck(reader->bdejpluck);
1734 prefwin->Continuous(reader->m_continuousDocument);
1735
1736 prefwin->dictApplication(m_targetapp);
1737 prefwin->dictMessage(m_targetmsg);
1738
1739 prefwin->spaceAction(m_spaceTarget);
1740 prefwin->escapeAction(m_escapeTarget);
1741 prefwin->returnAction(m_returnTarget);
1742 prefwin->leftAction(m_leftTarget);
1743 prefwin->rightAction(m_rightTarget);
1744 prefwin->upAction(m_upTarget);
1745 prefwin->downAction(m_downTarget);
1746
1747 prefwin->leftScroll(m_leftScroll);
1748 prefwin->rightScroll(m_rightScroll);
1749 prefwin->upScroll(m_upScroll);
1750 prefwin->downScroll(m_downScroll);
1751
1752 prefwin->miscannotation(m_doAnnotation);
1753 prefwin->miscdictionary(m_doDictionary);
1754 prefwin->miscclipboard(m_doClipboard);
1755
1756 prefwin->SwapMouse(reader->m_swapmouse);
1757
1758 prefwin->Font(reader->m_fontname);
1759
1760 prefwin->gfxsize(reader->getBaseSize());
1761
1762 prefwin->pageoverlap(reader->m_overlap);
1763
1764 prefwin->ideogram(reader->m_bMonoSpaced);
1765
1766 prefwin->encoding(reader->m_encd);
1767
1768 prefwin->ideogramwidth(reader->m_charpc);
1769
1770 if (prefwin->exec())
1771 {
1772 m_twoTouch = prefwin->twotouch();
1773 reader->setTwoTouch(m_twoTouch);
1774 m_touch_action->setOn(m_twoTouch);
1775
1776 reader->bstripcr = prefwin->StripCR();
1777 reader->bdehyphen = prefwin->Dehyphen();
1778 reader->bonespace = prefwin->SingleSpace();
1779 reader->bunindent = prefwin->Unindent();
1780 reader->brepara = prefwin->Reparagraph();
1781 reader->bdblspce = prefwin->DoubleSpace();
1782 reader->bremap = prefwin->Remap();
1783 reader->bmakebold = prefwin->Embolden();
1784 reader->bfulljust = prefwin->FullJustify();
1785 reader->setextraspace(prefwin->ParaLead());
1786 reader->setlead(prefwin->LineLead());
1787 reader->m_border = prefwin->Margin();
1788 reader->bindenter = prefwin->Indent();
1789 reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false;
1790 switch (prefwin->Markup())
1791 {
1792 case 0:
1793 reader->bautofmt = true;
1794 break;
1795 case 1:
1796 break;
1797 case 2:
1798 reader->btextfmt = true;
1799 break;
1800 case 3:
1801 reader->bstriphtml = true;
1802 break;
1803 case 4:
1804 reader->bpeanut = true;
1805 break;
1806 default:
1807 qDebug("Format out of range");
1808 }
1809 reader->bdepluck = prefwin->Depluck();
1810 reader->bdejpluck = prefwin->Dejpluck();
1811 reader->setContinuous(prefwin->Continuous());
1812
1813 m_spaceTarget = (ActionTypes)prefwin->spaceAction();
1814 m_escapeTarget = (ActionTypes)prefwin->escapeAction();
1815 m_returnTarget = (ActionTypes)prefwin->returnAction();
1816 m_leftTarget = (ActionTypes)prefwin->leftAction();
1817 m_rightTarget = (ActionTypes)prefwin->rightAction();
1818 m_upTarget = (ActionTypes)prefwin->upAction();
1819 m_downTarget = (ActionTypes)prefwin->downAction();
1820 m_leftScroll = prefwin->leftScroll();
1821 m_rightScroll = prefwin->rightScroll();
1822 m_upScroll = prefwin->upScroll();
1823 m_downScroll = prefwin->downScroll();
1824
1825 m_targetapp = prefwin->dictApplication();
1826 m_targetmsg = prefwin->dictMessage();
1827
1828 m_doAnnotation = prefwin->miscannotation();
1829 m_doDictionary = prefwin->miscdictionary();
1830 m_doClipboard = prefwin->miscclipboard();
1831 reader->m_swapmouse = prefwin->SwapMouse();
1832 reader->setBaseSize(prefwin->gfxsize());
1833 reader->m_overlap = prefwin->pageoverlap();
1834 reader->m_bMonoSpaced = prefwin->ideogram();
1835 m_setmono_action->setOn(reader->m_bMonoSpaced);
1836 reader->m_encd = prefwin->encoding();
1837 reader->m_charpc = prefwin->ideogramwidth();
1838
1839 if (
1840 reader->m_fontname != prefwin->Font()
1841 ||
1842 m_propogatefontchange != prefwin->propfontchange())
1843 {
1844 m_propogatefontchange = prefwin->propfontchange();
1845 setfontHelper(prefwin->Font());
1846 }
1847 delete prefwin;
1848 reader->setfilter(reader->getfilter());
1849 reader->refresh();
1850
1851 }
1852 else
1853 {
1854 delete prefwin;
1855 }
1856}
1857
1858void QTReaderApp::showtoolbarprefs()
1859{
1860#ifdef USEQPE
1861 CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this);
1862#else
1863 QFileInfo fi;
1864 QDir d = QDir::home(); // "/"
1865 if ( !d.cd(APPDIR) )
1866 { // "/tmp"
1867 qWarning( "Cannot find the \"~/%s\" directory", APPDIR );
1868 d = QDir::home();
1869 d.mkdir(APPDIR);
1870 d.cd(APPDIR);
1871 }
1872 fi.setFile(d, INIFILE);
1873 CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this);
1874#endif
1875 prefwin->tbpolicy(m_tbpolsave);
1876 prefwin->tbposition(m_tbposition-2);
1877 prefwin->tbmovable(m_tbmovesave);
1878 prefwin->floating(m_bFloatingDialog);
1879 if (prefwin->exec())
1880 {
1881 m_bFloatingDialog = prefwin->floating();
1882 if (
1883 m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy()
1884 ||
1885 m_tbposition != (ToolBarDock)(prefwin->tbposition()+2)
1886 ||
1887 m_tbmovesave != prefwin->tbmovable()
1888 )
1889 {
1890 QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started");
1891 }
1892 m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy();
1893 m_tbposition = (ToolBarDock)(prefwin->tbposition()+2);
1894 m_tbmovesave = prefwin->tbmovable();
1895 bool isChanged = prefwin->isChanged();
1896 delete prefwin;
1897#ifdef USEQPE
1898 Config config( APPDIR );
1899#else
1900 QFileInfo fi;
1901 QDir d = QDir::home(); // "/"
1902 if ( !d.cd(APPDIR) )
1903 { // "/tmp"
1904 qWarning( "Cannot find the \"~/%s\" directory", APPDIR );
1905 d = QDir::home();
1906 d.mkdir(APPDIR);
1907 d.cd(APPDIR);
1908 }
1909 fi.setFile(d, INIFILE);
1910 Config config( fi.absFilePath() );
1911#endif
1912 if (isChanged) addtoolbars(&config);
1913 }
1914 else
1915 {
1916 delete prefwin;
1917 }
1918}
1919
1237void QTReaderApp::showinfo() 1920void QTReaderApp::showinfo()
1238{ 1921{
1239 unsigned long fs, ts, pl; 1922 unsigned long fs, ts, pl;
@@ -1352,7 +2035,9 @@ void QTReaderApp::addanno()
1352 m_annoWin->setPosn(reader->pagelocate()); 2035 m_annoWin->setPosn(reader->pagelocate());
1353 m_annoIsEditing = true; 2036 m_annoIsEditing = true;
1354 editorStack->raiseWidget( m_annoWin ); 2037 editorStack->raiseWidget( m_annoWin );
2038#ifdef USEQPE
1355 Global::showInputMethod(); 2039 Global::showInputMethod();
2040#endif
1356 m_annoWin->setFocus(); 2041 m_annoWin->setFocus();
1357 } 2042 }
1358} 2043}
@@ -1388,6 +2073,10 @@ void QTReaderApp::editCopy()
1388 int ch; 2073 int ch;
1389 unsigned long currentpos = reader->pagelocate(); 2074 unsigned long currentpos = reader->pagelocate();
1390 unsigned long endpos = reader->locate(); 2075 unsigned long endpos = reader->locate();
2076 if (m_savedpos == 0xffffffff)
2077 {
2078 m_savedpos = currentpos;
2079 }
1391 reader->jumpto(m_savedpos); 2080 reader->jumpto(m_savedpos);
1392 while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) 2081 while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF)
1393 { 2082 {
@@ -1395,85 +2084,35 @@ void QTReaderApp::editCopy()
1395 } 2084 }
1396 cb->setText(text); 2085 cb->setText(text);
1397 reader->locate(currentpos); 2086 reader->locate(currentpos);
2087 m_savedpos = 0xffffffff;
1398} 2088}
1399 2089
1400void QTReaderApp::pageup() 2090void QTReaderApp::gotoStart()
1401{ 2091{
1402 reader->NavUp(); 2092 reader->locate(reader->buffdoc.startSection());
1403} 2093}
1404 2094
1405void QTReaderApp::pagedn() 2095void QTReaderApp::gotoEnd()
1406{ 2096{
1407 reader->NavDown(); 2097 reader->dopageup(reader->buffdoc.endSection());
1408} 2098}
1409 2099
1410void QTReaderApp::stripcr(bool _b) 2100void QTReaderApp::pageup()
1411{
1412 reader->setstripcr(_b);
1413}
1414void QTReaderApp::onespace(bool _b)
1415{
1416 reader->setonespace(_b);
1417}
1418#ifdef REPALM
1419void QTReaderApp::repalm(bool _b)
1420{
1421 reader->setrepalm(_b);
1422}
1423#endif
1424void QTReaderApp::remap(bool _b)
1425{
1426 reader->setremap(_b);
1427}
1428void QTReaderApp::peanut(bool _b)
1429{
1430 reader->setpeanut(_b);
1431}
1432void QTReaderApp::embolden(bool _b)
1433{
1434 reader->setmakebold(_b);
1435}
1436void QTReaderApp::autofmt(bool _b)
1437{
1438 reader->setautofmt(_b);
1439}
1440void QTReaderApp::textfmt(bool _b)
1441{
1442 reader->settextfmt(_b);
1443}
1444void QTReaderApp::striphtml(bool _b)
1445{
1446 reader->setstriphtml(_b);
1447}
1448void QTReaderApp::dehyphen(bool _b)
1449{
1450 reader->setdehyphen(_b);
1451}
1452void QTReaderApp::unindent(bool _b)
1453{
1454 reader->setunindent(_b);
1455}
1456void QTReaderApp::repara(bool _b)
1457{ 2101{
1458 reader->setrepara(_b); 2102 reader->NavUp();
1459} 2103}
1460void QTReaderApp::dblspce(bool _b) 2104
2105void QTReaderApp::pagedn()
1461{ 2106{
1462 reader->setdblspce(_b); 2107 reader->NavDown();
1463} 2108}
2109
1464void QTReaderApp::pagemode(bool _b) 2110void QTReaderApp::pagemode(bool _b)
1465{ 2111{
1466 reader->setpagemode(_b); 2112 reader->setpagemode(_b);
1467} 2113}
1468void QTReaderApp::navkeys(bool _b)
1469{
1470 reader->m_navkeys = _b;
1471}
1472void QTReaderApp::monospace(bool _b)
1473{
1474 reader->setmono(_b);
1475}
1476 2114
2115/*
1477void QTReaderApp::setspacing() 2116void QTReaderApp::setspacing()
1478{ 2117{
1479 m_nRegAction = cMonoSpace; 2118 m_nRegAction = cMonoSpace;
@@ -1482,16 +2121,7 @@ void QTReaderApp::setspacing()
1482 regEdit->setText(lcn); 2121 regEdit->setText(lcn);
1483 do_regedit(); 2122 do_regedit();
1484} 2123}
1485 2124*/
1486void QTReaderApp::setoverlap()
1487{
1488 m_nRegAction = cOverlap;
1489 char lcn[20];
1490 sprintf(lcn, "%lu", reader->m_overlap);
1491 regEdit->setText(lcn);
1492 do_regedit();
1493}
1494
1495void QTReaderApp::settarget() 2125void QTReaderApp::settarget()
1496{ 2126{
1497 m_nRegAction = cSetTarget; 2127 m_nRegAction = cSetTarget;
@@ -1502,18 +2132,7 @@ void QTReaderApp::settarget()
1502 do_regedit(); 2132 do_regedit();
1503} 2133}
1504 2134
1505void QTReaderApp::do_overlap(const QString& lcn) 2135/*
1506{
1507 bool ok;
1508 unsigned long ulcn = lcn.toULong(&ok);
1509 if (ok)
1510 {
1511 reader->m_overlap = ulcn;
1512 }
1513 else
1514 QMessageBox::information(this, PROGNAME, "Must be a number");
1515}
1516
1517void QTReaderApp::do_mono(const QString& lcn) 2136void QTReaderApp::do_mono(const QString& lcn)
1518{ 2137{
1519 bool ok; 2138 bool ok;
@@ -1528,7 +2147,7 @@ void QTReaderApp::do_mono(const QString& lcn)
1528 else 2147 else
1529 QMessageBox::information(this, PROGNAME, "Must be a number"); 2148 QMessageBox::information(this, PROGNAME, "Must be a number");
1530} 2149}
1531 2150*/
1532/* 2151/*
1533void QTReaderApp::editPaste() 2152void QTReaderApp::editPaste()
1534{ 2153{
@@ -1544,7 +2163,9 @@ void QTReaderApp::editFind()
1544#ifdef __ISEARCH 2163#ifdef __ISEARCH
1545 searchStack = new QStack<searchrecord>; 2164 searchStack = new QStack<searchrecord>;
1546#endif 2165#endif
2166#ifdef USEQPE
1547 Global::showInputMethod(); 2167 Global::showInputMethod();
2168#endif
1548 searchBar->show(); 2169 searchBar->show();
1549 searchVisible = TRUE; 2170 searchVisible = TRUE;
1550 searchEdit->setFocus(); 2171 searchEdit->setFocus();
@@ -1555,7 +2176,7 @@ void QTReaderApp::editFind()
1555 2176
1556void QTReaderApp::findNext() 2177void QTReaderApp::findNext()
1557{ 2178{
1558 // qDebug("findNext called\n"); 2179// // qDebug("findNext called\n");
1559#ifdef __ISEARCH 2180#ifdef __ISEARCH
1560 QString arg = searchEdit->text(); 2181 QString arg = searchEdit->text();
1561#else 2182#else
@@ -1564,7 +2185,7 @@ void QTReaderApp::findNext()
1564 CDrawBuffer test(&(reader->m_fontControl)); 2185 CDrawBuffer test(&(reader->m_fontControl));
1565 size_t start = reader->pagelocate(); 2186 size_t start = reader->pagelocate();
1566 reader->jumpto(start); 2187 reader->jumpto(start);
1567 reader->buffdoc.getline(&test,reader->width()); 2188 reader->getline(&test);
1568 dosearch(start, test, arg); 2189 dosearch(start, test, arg);
1569} 2190}
1570 2191
@@ -1572,7 +2193,9 @@ void QTReaderApp::findClose()
1572{ 2193{
1573 searchVisible = FALSE; 2194 searchVisible = FALSE;
1574 searchEdit->setText(""); 2195 searchEdit->setText("");
2196#ifdef USEQPE
1575 Global::hideInputMethod(); 2197 Global::hideInputMethod();
2198#endif
1576 searchBar->hide(); 2199 searchBar->hide();
1577#ifdef __ISEARCH 2200#ifdef __ISEARCH
1578// searchStack = new QStack<searchrecord>; 2201// searchStack = new QStack<searchrecord>;
@@ -1590,7 +2213,9 @@ void QTReaderApp::regClose()
1590 regVisible = FALSE; 2213 regVisible = FALSE;
1591 regEdit->setText(""); 2214 regEdit->setText("");
1592 regBar->hide(); 2215 regBar->hide();
2216#ifdef USEQPE
1593 Global::hideInputMethod(); 2217 Global::hideInputMethod();
2218#endif
1594 reader->setFocus(); 2219 reader->setFocus();
1595} 2220}
1596 2221
@@ -1604,48 +2229,66 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
1604 unsigned long fs, ts; 2229 unsigned long fs, ts;
1605 reader->sizes(fs,ts); 2230 reader->sizes(fs,ts);
1606 size_t pos = reader->locate(); 2231 size_t pos = reader->locate();
1607 reader->buffdoc.getline(&test,reader->width()); 2232 pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height());
1608 pbar->show(); 2233 pbar->show();
1609 pbar->resize(width(), editBar->height()); 2234 pbar->raise();
1610 pbar->reset(); 2235 pbar->reset();
2236 int offset;
1611 int lastpc = (100*pos)/ts; 2237 int lastpc = (100*pos)/ts;
1612 pbar->setProgress(lastpc); 2238 pbar->setProgress(lastpc);
1613 qApp->processEvents(); 2239// qApp->processEvents();
1614 reader->setFocus(); 2240 if (reader->buffdoc.getpara(test) >= 0)
2241 {
2242 reader->setFocus();
1615#ifdef __ISEARCH 2243#ifdef __ISEARCH
1616 while (strstr(test.data(),(const tchar*)arg) == NULL) 2244 while (strstr(test.data(),(const tchar*)arg) == NULL)
1617#else 2245#else
1618#ifdef _UNICODE 2246#ifdef _UNICODE
1619 while (arg.match(toQString(test.data())) == -1) 2247 while ((offset = arg.match(toQString(test.data()))) == -1)
1620#else 2248#else
1621 while (arg.match(test.data()) == -1) 2249 while (arg.match(test.data()) == -1)
1622#endif 2250#endif
1623#endif 2251#endif
1624 {
1625 pos = reader->locate();
1626 unsigned int lcn = reader->locate();
1627 int pc = (100*pos)/ts;
1628 if (pc != lastpc)
1629 { 2252 {
1630 pbar->setProgress(pc); 2253 pos = reader->locate();
1631 qApp->processEvents(); 2254 int pc = (100*pos)/ts;
1632 reader->setFocus(); 2255 if (pc != lastpc)
1633 lastpc = pc; 2256 {
2257 pbar->setProgress(pc);
2258 qApp->processEvents();
2259 reader->setFocus();
2260 lastpc = pc;
2261 }
2262
2263 if (reader->buffdoc.getpara(test) < 0)
2264 {
2265 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
2266 pos = searchStart;
2267 else
2268 pos = start;
2269 findClose();
2270 pbar->hide();
2271 reader->locate(pos);
2272 return false;
2273 }
1634 } 2274 }
1635 2275// qDebug("Found it at %u:%u", pos, offset);
1636 if (!reader->buffdoc.getline(&test,reader->width())) 2276 pbar->hide();
1637 { 2277// qDebug("Hid");
1638 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) 2278 reader->locate(pos+offset);
1639 pos = searchStart; 2279// qDebug("Loacted");
1640 else 2280// qDebug("page up");
1641 pos = start; 2281 ret = true;
1642 ret = false; 2282 }
1643 findClose(); 2283 else
1644 break; 2284 {
1645 } 2285 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
1646 } 2286 pos = searchStart;
1647 pbar->hide(); 2287 else
1648 reader->locate(pos); 2288 pos = start;
2289 ret = false;
2290 findClose();
2291 }
1649 return ret; 2292 return ret;
1650} 2293}
1651 2294
@@ -1691,7 +2334,7 @@ void QTReaderApp::search()
1691 2334
1692void QTReaderApp::openFile( const QString &f ) 2335void QTReaderApp::openFile( const QString &f )
1693{ 2336{
1694 qDebug("File:%s", (const char*)f); 2337// qDebug("File:%s", (const char*)f);
1695// openFile(DocLnk(f)); 2338// openFile(DocLnk(f));
1696//} 2339//}
1697// 2340//
@@ -1702,7 +2345,7 @@ void QTReaderApp::openFile( const QString &f )
1702 if ( fm.exists() ) 2345 if ( fm.exists() )
1703 { 2346 {
1704// QMessageBox::information(0, "Progress", "Calling fileNew()"); 2347// QMessageBox::information(0, "Progress", "Calling fileNew()");
1705 2348#ifdef USEQPE
1706 if (fm.extension( FALSE ) == "desktop") 2349 if (fm.extension( FALSE ) == "desktop")
1707 { 2350 {
1708 DocLnk d(f); 2351 DocLnk d(f);
@@ -1710,16 +2353,19 @@ void QTReaderApp::openFile( const QString &f )
1710 fm = fnew; 2353 fm = fnew;
1711 if (!fm.exists()) return; 2354 if (!fm.exists()) return;
1712 } 2355 }
1713 2356#endif
1714 clear(); 2357 clear();
1715 2358
1716 reader->setText(fm.baseName(), fm.absFilePath()); 2359 reader->setText(fm.baseName(), fm.absFilePath());
2360 m_loadedconfig = readconfig(reader->m_string, false);
1717 showEditTools(); 2361 showEditTools();
1718 readbkmks(); 2362 readbkmks();
2363 m_savedpos = 0xffffffff;
1719 } 2364 }
1720 else 2365 else
1721 { 2366 {
1722 QMessageBox::information(this, PROGNAME, "File does not exist"); 2367 QMessageBox::information(this, PROGNAME, "File does not exist");
2368 reader->m_lastfile = QString::null;
1723 } 2369 }
1724 2370
1725} 2371}
@@ -1733,36 +2379,109 @@ void QTReaderApp::resizeEvent(QResizeEvent* e)
1733 } 2379 }
1734} 2380}
1735*/ 2381*/
1736void QTReaderApp::keyPressEvent(QKeyEvent* e) 2382void QTReaderApp::handlekey(QKeyEvent* e)
1737{ 2383{
1738 if (m_fullscreen) 2384// qDebug("Keypress event");
2385 timeb now;
2386 ftime(&now);
2387 unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm;
2388 if (etime < m_debounce)
1739 { 2389 {
1740 switch(e->key()) 2390 return;
1741 { 2391 }
1742 case Key_Escape: 2392 m_lastkeytime = now;
1743 m_actFullscreen->setOn(false); 2393 switch(e->key())
2394 {
2395 case Key_Escape:
2396 // qDebug("escape event");
2397 if (m_disableesckey)
2398 {
2399 m_disableesckey = false;
2400 }
2401 else
2402 {
2403 m_bcloseDisabled = true;
1744 if (m_fullscreen) 2404 if (m_fullscreen)
1745 { 2405 {
1746 qDebug("Fullscreen already set - remove this!"); 2406 m_actFullscreen->setOn(false);
2407 e->accept();
1747 } 2408 }
1748 else 2409 else
1749 { 2410 {
1750 m_fullscreen = false; 2411 // qDebug("escape action");
1751 reader->bDoUpdates = false; 2412 doAction(m_escapeTarget, e);
1752 showEditTools();
1753 qApp->processEvents();
1754 reader->bDoUpdates = true;
1755 reader->update();
1756 } 2413 }
1757 e->accept(); 2414 }
1758 break; 2415 break;
1759 default: 2416 case Key_Space:
1760 e->ignore(); 2417 {
2418 doAction(m_spaceTarget, e);
1761 } 2419 }
1762 } 2420 break;
1763 else 2421 case Key_Return:
1764 { 2422 {
1765 e->ignore(); 2423 doAction(m_returnTarget, e);
2424 }
2425 break;
2426 case Key_Left:
2427 {
2428 if (reader->m_autoScroll && m_leftScroll)
2429 {
2430 reader->reduceScroll();
2431 }
2432 else
2433 {
2434 doAction(m_leftTarget, e);
2435 }
2436 }
2437 break;
2438 case Key_Right:
2439 {
2440 if (reader->m_autoScroll && m_rightScroll)
2441 {
2442 reader->increaseScroll();
2443 }
2444 else
2445 {
2446 doAction(m_rightTarget, e);
2447 }
2448 }
2449 break;
2450 case Key_Up:
2451 {
2452 if (reader->m_autoScroll && m_upScroll)
2453 {
2454 reader->increaseScroll();
2455 }
2456 else
2457 {
2458 doAction(m_upTarget, e);
2459 }
2460 }
2461 break;
2462 case Key_Down:
2463 {
2464 if (reader->m_autoScroll && m_downScroll)
2465 {
2466 reader->reduceScroll();
2467 }
2468 else
2469 {
2470 doAction(m_downTarget, e);
2471 }
2472 }
2473 break;
2474 default:
2475 {
2476 e->ignore();
2477 }
2478
2479/*
2480 QString msg("Key press was:");
2481 QString key;
2482 msg += key.setNum(e->key());
2483 QMessageBox::information(this, PROGNAME, msg);
2484*/
1766 } 2485 }
1767} 2486}
1768 2487
@@ -1772,44 +2491,64 @@ void QTReaderApp::showEditTools()
1772 //close(); 2491 //close();
1773 if (m_fullscreen) 2492 if (m_fullscreen)
1774 { 2493 {
1775 editBar->hide(); 2494 if (menubar != NULL) menubar->hide();
2495 if (fileBar != NULL) fileBar->hide();
2496 if (viewBar != NULL) viewBar->hide();
2497 if (navBar != NULL) navBar->hide();
2498 if (markBar != NULL) markBar->hide();
1776 searchBar->hide(); 2499 searchBar->hide();
1777 regBar->hide(); 2500 regBar->hide();
2501#ifdef USEQPE
1778 Global::hideInputMethod(); 2502 Global::hideInputMethod();
2503#endif
1779 m_fontBar->hide(); 2504 m_fontBar->hide();
1780 //showNormal(); 2505 //showNormal();
1781 showFullScreen(); 2506 showFullScreen();
1782 } 2507 }
1783 else 2508 else
1784 { 2509 {
1785 qDebug("him"); 2510 //qDebug("him");
2511#ifdef USEQPE
1786 Global::hideInputMethod(); 2512 Global::hideInputMethod();
1787 qDebug("eb"); 2513#endif
1788 editBar->show(); 2514 //qDebug("eb");
2515 menubar->show();
2516 if (fileBar != NULL) fileBar->show();
2517 if (viewBar != NULL) viewBar->show();
2518 if (navBar != NULL) navBar->show();
2519 if (markBar != NULL) markBar->show();
2520 mb->show();
1789 if ( searchVisible ) 2521 if ( searchVisible )
1790 { 2522 {
2523#ifdef USEQPE
1791 Global::showInputMethod(); 2524 Global::showInputMethod();
1792 searchBar->show(); 2525#endif
2526 searchBar->show();
1793 } 2527 }
1794 if ( regVisible ) 2528 if ( regVisible )
1795 { 2529 {
2530#ifdef USEQPE
1796 Global::showInputMethod(); 2531 Global::showInputMethod();
1797 regBar->show(); 2532#endif
2533 regBar->show();
1798 } 2534 }
1799 if (m_fontVisible) m_fontBar->show(); 2535 if (m_fontVisible) m_fontBar->show();
1800 qDebug("sn"); 2536 //qDebug("sn");
1801 showNormal(); 2537 showNormal();
1802 qDebug("sm"); 2538 //qDebug("sm");
2539#ifdef USEQPE
1803 showMaximized(); 2540 showMaximized();
2541#endif
1804 //setCentralWidget(reader); 2542 //setCentralWidget(reader);
1805 } 2543 }
1806 2544
1807 qDebug("uc"); 2545// qDebug("uc");
1808 updateCaption(); 2546 updateCaption();
1809 qDebug("rw"); 2547// qDebug("rw");
1810 editorStack->raiseWidget( reader ); 2548 editorStack->raiseWidget( reader );
1811 qDebug("sf"); 2549// qDebug("sf");
1812 reader->setFocus(); 2550 reader->setFocus();
2551 reader->refresh();
1813} 2552}
1814/* 2553/*
1815void QTReaderApp::save() 2554void QTReaderApp::save()
@@ -1876,6 +2615,7 @@ void QTReaderApp::setDocument(const QString& fileref)
1876 2615
1877void QTReaderApp::closeEvent( QCloseEvent *e ) 2616void QTReaderApp::closeEvent( QCloseEvent *e )
1878{ 2617{
2618// qDebug("Close event");
1879 if (m_fullscreen) 2619 if (m_fullscreen)
1880 { 2620 {
1881 m_fullscreen = false; 2621 m_fullscreen = false;
@@ -1890,61 +2630,77 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
1890 { 2630 {
1891 if (editorStack->visibleWidget() == reader) 2631 if (editorStack->visibleWidget() == reader)
1892 { 2632 {
1893 if (m_fontVisible) 2633 if ((m_escapeTarget != cesNone) && m_bcloseDisabled)
1894 {
1895 m_fontBar->hide();
1896 m_fontVisible = false;
1897 }
1898 if (regVisible)
1899 {
1900 regBar->hide();
1901 Global::hideInputMethod();
1902 regVisible = false;
1903 return;
1904 }
1905 if (searchVisible)
1906 { 2634 {
1907 searchBar->hide(); 2635 //qDebug("Close disabled");
1908 Global::hideInputMethod(); 2636 m_bcloseDisabled = false;
1909 searchVisible = false; 2637 e->ignore();
1910 return;
1911 } 2638 }
1912 if (m_fBkmksChanged && pBkmklist != NULL) 2639 else
1913 { 2640 {
1914 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) 2641 if (m_fontVisible)
1915 savebkmks(); 2642 {
1916 delete pBkmklist; 2643 m_fontBar->hide();
1917 pBkmklist = NULL; 2644 m_fontVisible = false;
1918 m_fBkmksChanged = false; 2645 }
2646 if (regVisible)
2647 {
2648 regBar->hide();
2649#ifdef USEQPE
2650 Global::hideInputMethod();
2651#endif
2652 regVisible = false;
2653 return;
2654 }
2655 if (searchVisible)
2656 {
2657 searchBar->hide();
2658#ifdef USEQPE
2659 Global::hideInputMethod();
2660#endif
2661 searchVisible = false;
2662 return;
2663 }
2664 if (m_fBkmksChanged && pBkmklist != NULL)
2665 {
2666 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
2667 savebkmks();
2668 delete pBkmklist;
2669 pBkmklist = NULL;
2670 m_fBkmksChanged = false;
2671 }
2672 bFromDocView = FALSE;
2673 updatefileinfo();
2674 saveprefs();
2675 e->accept();
1919 } 2676 }
1920 bFromDocView = FALSE;
1921 updatefileinfo();
1922 saveprefs();
1923 e->accept();
1924 } 2677 }
1925 else 2678 else
1926 { 2679 {
1927 showEditTools(); 2680 showEditTools();
2681 m_disableesckey = true;
1928 } 2682 }
1929 } 2683 }
1930} 2684}
1931 2685
1932void QTReaderApp::do_gotomark() 2686void QTReaderApp::do_gotomark()
1933{ 2687{
1934 m_nRegAction = cGotoBkmk; 2688 m_nBkmkAction = cGotoBkmk;
1935 listbkmk(pBkmklist); 2689 if (!listbkmk(pBkmklist))
2690 QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
1936} 2691}
1937 2692
1938void QTReaderApp::do_delmark() 2693void QTReaderApp::do_delmark()
1939{ 2694{
1940 m_nRegAction = cDelBkmk; 2695 m_nBkmkAction = cDelBkmk;
1941 listbkmk(pBkmklist); 2696 if (!listbkmk(pBkmklist))
2697 QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
1942} 2698}
1943 2699
1944void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) 2700bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
1945{ 2701{
1946 bkmkselector->clear(); 2702 bkmkselector->clear();
1947 if (_lab.isNull()) 2703 if (_lab.isEmpty())
1948 bkmkselector->setText("Cancel"); 2704 bkmkselector->setText("Cancel");
1949 else 2705 else
1950 bkmkselector->setText(_lab); 2706 bkmkselector->setText(_lab);
@@ -1954,7 +2710,7 @@ void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
1954 for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) 2710 for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++)
1955 { 2711 {
1956#ifdef _UNICODE 2712#ifdef _UNICODE
1957 qDebug("Item:%s", (const char*)toQString(i->name())); 2713 // qDebug("Item:%s", (const char*)toQString(i->name()));
1958 bkmkselector->insertItem(toQString(i->name())); 2714 bkmkselector->insertItem(toQString(i->name()));
1959#else 2715#else
1960 bkmkselector->insertItem(i->name()); 2716 bkmkselector->insertItem(i->name());
@@ -1964,23 +2720,12 @@ void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
1964 } 2720 }
1965 if (cnt > 0) 2721 if (cnt > 0)
1966 { 2722 {
1967//tjw menu->hide(); 2723 hidetoolbars();
1968 editBar->hide();
1969 if (m_fontVisible) m_fontBar->hide();
1970 if (regVisible)
1971 {
1972 Global::hideInputMethod();
1973 regBar->hide();
1974 }
1975 if (searchVisible)
1976 {
1977 Global::hideInputMethod();
1978 searchBar->hide();
1979 }
1980 editorStack->raiseWidget( bkmkselector ); 2724 editorStack->raiseWidget( bkmkselector );
2725 return true;
1981 } 2726 }
1982 else 2727 else
1983 QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); 2728 return false;
1984} 2729}
1985 2730
1986void QTReaderApp::do_autogen() 2731void QTReaderApp::do_autogen()
@@ -1992,15 +2737,17 @@ void QTReaderApp::do_autogen()
1992 2737
1993void QTReaderApp::do_regedit() 2738void QTReaderApp::do_regedit()
1994{ 2739{
1995// editBar->hide(); 2740// fileBar->hide();
1996 reader->bDoUpdates = false; 2741 reader->bDoUpdates = false;
1997 qDebug("Showing regbar"); 2742// qDebug("Showing regbar");
1998 regBar->show(); 2743 regBar->show();
1999 qDebug("Showing kbd"); 2744// qDebug("Showing kbd");
2745#ifdef USEQPE
2000 Global::showInputMethod(); 2746 Global::showInputMethod();
2747#endif
2001 regVisible = true; 2748 regVisible = true;
2002 regEdit->setFocus(); 2749 regEdit->setFocus();
2003 qApp->processEvents(); 2750// qApp->processEvents();
2004 reader->bDoUpdates = true; 2751 reader->bDoUpdates = true;
2005 reader->update(); 2752 reader->update();
2006} 2753}
@@ -2010,10 +2757,10 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
2010 QString fn = toQString( 2757 QString fn = toQString(
2011 CFiledata(bk->anno()).name() 2758 CFiledata(bk->anno()).name()
2012 ); 2759 );
2013 qDebug("fileinfo"); 2760 //qDebug("fileinfo");
2014 if (!fn.isEmpty() && QFileInfo(fn).isFile()) 2761 if (!fn.isEmpty() && QFileInfo(fn).isFile())
2015 { 2762 {
2016 qDebug("Opening"); 2763 //qDebug("Opening");
2017 openFile(fn); 2764 openFile(fn);
2018 struct stat fnstat; 2765 struct stat fnstat;
2019 stat((const char *)reader->m_lastfile, &fnstat); 2766 stat((const char *)reader->m_lastfile, &fnstat);
@@ -2035,7 +2782,8 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
2035 { 2782 {
2036 QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); 2783 QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?");
2037 } 2784 }
2038 qDebug("updating"); 2785 // qDebug("updating");
2786 // showEditTools();
2039 reader->locate(bk->value()); 2787 reader->locate(bk->value());
2040 } 2788 }
2041 return true; 2789 return true;
@@ -2048,10 +2796,12 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
2048 2796
2049void QTReaderApp::gotobkmk(int ind) 2797void QTReaderApp::gotobkmk(int ind)
2050{ 2798{
2051 switch (m_nRegAction) 2799 showEditTools();
2800 switch (m_nBkmkAction)
2052 { 2801 {
2053 case cOpenFile: 2802 case cOpenFile:
2054 { 2803 {
2804 // qApp->processEvents();
2055 if (!openfrombkmk((*pOpenlist)[ind])) 2805 if (!openfrombkmk((*pOpenlist)[ind]))
2056 { 2806 {
2057 pOpenlist->erase(ind); 2807 pOpenlist->erase(ind);
@@ -2063,21 +2813,144 @@ void QTReaderApp::gotobkmk(int ind)
2063 reader->locate((*pBkmklist)[ind]->value()); 2813 reader->locate((*pBkmklist)[ind]->value());
2064 break; 2814 break;
2065 case cDelBkmk: 2815 case cDelBkmk:
2066 // qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); 2816 //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name());
2067 pBkmklist->erase(ind); 2817 pBkmklist->erase(ind);
2068 m_fBkmksChanged = true; 2818 m_fBkmksChanged = true;
2069 // pBkmklist->sort(); 2819 // pBkmklist->sort();
2070 break; 2820 break;
2071 case cRmBkmkFile: 2821 case cRmBkmkFile:
2072 unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); 2822 {
2823#ifndef USEQPE
2824 QDir d = QDir::home(); // "/"
2825 d.cd(APPDIR);
2826 d.remove(bkmkselector->text(ind));
2827#else /* USEQPE */
2828 unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind)));
2829#endif /* USEQPE */
2830 }
2831 break;
2832 case cLdConfig:
2833 readconfig(bkmkselector->text(ind), false);
2834 break;
2835 case cRmConfig:
2836 {
2837#ifndef USEQPE
2838 QDir d = QDir::home(); // "/"
2839 d.cd(APPDIR "/configs");
2840 d.remove(bkmkselector->text(ind));
2841#else /* USEQPE */
2842 unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind)));
2843#endif /* USEQPE */
2844 }
2073 break; 2845 break;
2846 case cExportLinks:
2847 {
2848#ifndef USEQPE
2849 QDir d = QDir::home(); // "/"
2850 d.cd(APPDIR "/urls");
2851 QFileInfo fi(d, bkmkselector->text(ind));
2852 if (fi.exists())
2853 {
2854 QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) );
2855 if (!outfile.isEmpty())
2856 {
2857 FILE* fout = fopen((const char *)outfile, "w");
2858 if (fout != NULL)
2859 {
2860 FILE* fin = fopen((const char *)fi.absFilePath(), "r");
2861 if (fin != NULL)
2862 {
2863 fprintf(fout, "<html><body>\n");
2864 int ch = 0;
2865 while ((ch = fgetc(fin)) != EOF)
2866 {
2867 fputc(ch, fout);
2868 }
2869 fclose(fin);
2870 fprintf(fout, "</html></body>\n");
2871 d.remove(bkmkselector->text(ind));
2872 }
2873 fclose(fout);
2874 }
2875 else
2876 QMessageBox::information(this, PROGNAME, "Couldn't open output");
2877 }
2878 }
2879#else /* USEQPE */
2880 FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r");
2881 if (fin != NULL)
2882 {
2883 bool allok = false;
2884 fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null);
2885 if (fb->exec())
2886 {
2887 QString outfile = fb->getCurrentFile();
2888 FILE* fout = fopen((const char *)outfile, "w");
2889 if (fout != NULL)
2890 {
2891 fprintf(fout, "<html><body>\n");
2892 int ch = 0;
2893 while ((ch = fgetc(fin)) != EOF)
2894 {
2895 fputc(ch, fout);
2896 }
2897 fprintf(fout, "</html></body>\n");
2898 fclose(fout);
2899 allok = true;
2900 }
2901 else
2902 QMessageBox::information(this, PROGNAME, "Couldn't open output");
2903 }
2904 delete fb;
2905 fclose(fin);
2906 if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)));
2907 }
2908 else
2909 {
2910 QMessageBox::information(this, PROGNAME, "Couldn't open input");
2911 }
2912
2913/*
2914 CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE );
2915 int ret = f->exec();
2916 qDebug("Return:%d", ret);
2917 DocLnk* doc = f->getDoc();
2918 if (doc != NULL)
2919 {
2920 FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r");
2921 QString rt;
2922 rt = "<html><body>\n";
2923 int ch = 0;
2924 while ((ch = fgetc(fin)) != EOF)
2925 {
2926 rt += (char)ch;
2927 }
2928 fclose(fin);
2929 rt += "</html></body>\n";
2930 if ( doc->name().isEmpty() )
2931 {
2932 doc->setName(bkmkselector->text(ind));
2933 }
2934 FileManager fm;
2935 fm.saveFile( *doc, rt );
2936 qDebug("YES");
2937 }
2938 else
2939 {
2940 qDebug("NO");
2941 }
2942 delete f;
2943*/
2944
2945#endif /* USEQPE */
2946 }
2947 break;
2074 } 2948 }
2075 showEditTools();
2076} 2949}
2077 2950
2078void QTReaderApp::cancelbkmk() 2951void QTReaderApp::cancelbkmk()
2079{ 2952{
2080 if (m_nRegAction == cOpenFile) 2953 if (m_nBkmkAction == cOpenFile)
2081 { 2954 {
2082 QString fn = usefilebrowser(); 2955 QString fn = usefilebrowser();
2083 if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); 2956 if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn);
@@ -2108,7 +2981,9 @@ void QTReaderApp::do_regaction()
2108{ 2981{
2109 reader->bDoUpdates = false; 2982 reader->bDoUpdates = false;
2110 regBar->hide(); 2983 regBar->hide();
2984#ifdef USEQPE
2111 Global::hideInputMethod(); 2985 Global::hideInputMethod();
2986#endif
2112 regVisible = false; 2987 regVisible = false;
2113 switch(m_nRegAction) 2988 switch(m_nRegAction)
2114 { 2989 {
@@ -2121,20 +2996,28 @@ void QTReaderApp::do_regaction()
2121 case cJump: 2996 case cJump:
2122 do_jump(regEdit->text()); 2997 do_jump(regEdit->text());
2123 break; 2998 break;
2999/*
2124 case cMonoSpace: 3000 case cMonoSpace:
2125 do_mono(regEdit->text()); 3001 do_mono(regEdit->text());
2126 break; 3002 break;
2127 case cOverlap: 3003*/
2128 do_overlap(regEdit->text());
2129 break;
2130 case cSetTarget: 3004 case cSetTarget:
2131 do_settarget(regEdit->text()); 3005 do_settarget(regEdit->text());
2132 break; 3006 break;
3007#ifdef _SCROLLPIPE
3008 case cSetPipeTarget:
3009 do_setpipetarget(regEdit->text());
3010 break;
3011#endif
3012 case cSetConfigName:
3013 // qDebug("Saving config");
3014 do_saveconfig(regEdit->text(), false);
3015 break;
2133 } 3016 }
2134 reader->restore(); 3017// reader->restore();
2135// editBar->show(); 3018// fileBar->show();
2136 reader->setFocus(); 3019 reader->setFocus();
2137 qApp->processEvents(); 3020// qApp->processEvents();
2138 reader->bDoUpdates = true; 3021 reader->bDoUpdates = true;
2139 reader->update(); 3022 reader->update();
2140} 3023}
@@ -2155,8 +3038,37 @@ void QTReaderApp::do_settarget(const QString& _txt)
2155 } 3038 }
2156} 3039}
2157 3040
3041void QTReaderApp::chooseencoding()
3042{
3043 m_fontSelector->clear();
3044 m_fontSelector->insertItem("Ascii");
3045 m_fontSelector->insertItem("UTF-8");
3046 m_fontSelector->insertItem("UCS-2(BE)");
3047 m_fontSelector->insertItem("USC-2(LE)");
3048 m_fontSelector->insertItem("Palm");
3049 for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++)
3050 {
3051 m_fontSelector->insertItem(iter->mime);
3052 } // delete the FontDatabase!!!
3053 m_fontSelector->setCurrentItem (reader->m_encd);
3054 m_fontAction = cChooseEncoding;
3055 m_fontBar->show();
3056 m_fontVisible = true;
3057}
3058
2158void QTReaderApp::setfont() 3059void QTReaderApp::setfont()
2159{ 3060{
3061 m_fontSelector->clear();
3062 {
3063#ifdef USEQPE
3064 FontDatabase f;
3065#else
3066 QFontDatabase f;
3067#endif
3068 QStringList flist = f.families();
3069 m_fontSelector->insertStringList(flist);
3070 } // delete the FontDatabase!!!
3071
2160 for (int i = 1; i <= m_fontSelector->count(); i++) 3072 for (int i = 1; i <= m_fontSelector->count(); i++)
2161 { 3073 {
2162 if (m_fontSelector->text(i) == reader->m_fontname) 3074 if (m_fontSelector->text(i) == reader->m_fontname)
@@ -2165,6 +3077,7 @@ void QTReaderApp::setfont()
2165 break; 3077 break;
2166 } 3078 }
2167 } 3079 }
3080 m_fontAction = cChooseFont;
2168 m_fontBar->show(); 3081 m_fontBar->show();
2169 m_fontVisible = true; 3082 m_fontVisible = true;
2170} 3083}
@@ -2172,50 +3085,68 @@ void QTReaderApp::setfont()
2172void QTReaderApp::setfontHelper(const QString& lcn, int size) 3085void QTReaderApp::setfontHelper(const QString& lcn, int size)
2173{ 3086{
2174 if (size == 0) size = reader->m_fontControl.currentsize(); 3087 if (size == 0) size = reader->m_fontControl.currentsize();
2175 QFont f(lcn, 10 /*, QFont::Bold*/); 3088 if (m_propogatefontchange)
2176 qDebug("bs"); 3089 {
2177 bkmkselector->setFont( f ); 3090 QFont f(lcn, 10);
2178 qDebug("re"); 3091 bkmkselector->setFont( f );
2179 regEdit->setFont( f ); 3092 regEdit->setFont( f );
2180 qDebug("se"); 3093 searchEdit->setFont( f );
2181 searchEdit->setFont( f ); 3094 m_annoWin->setFont( f );
2182 qDebug("aw"); 3095 }
2183 m_annoWin->setFont( f );
2184 reader->m_fontname = lcn; 3096 reader->m_fontname = lcn;
2185 qDebug("cf1");
2186 if (!reader->ChangeFont(size)) 3097 if (!reader->ChangeFont(size))
2187 { 3098 {
2188 qDebug("cf2");
2189 reader->ChangeFont(size); 3099 reader->ChangeFont(size);
2190 } 3100 }
2191 qDebug("ref"); 3101}
3102
3103void QTReaderApp::do_setencoding(int i)
3104{
3105// qDebug("setencoding:%d", i);
3106 if (m_fontAction == cChooseEncoding)
3107 {
3108 reader->setencoding(i);
3109 }
2192 reader->refresh(); 3110 reader->refresh();
2193 m_fontBar->hide(); 3111 m_fontBar->hide();
2194 m_fontVisible = false; 3112 m_fontVisible = false;
2195 qDebug("showedit"); 3113// qDebug("showedit");
2196 if (reader->isVisible()) showEditTools(); 3114 if (reader->isVisible()) showEditTools();
2197 qDebug("showeditdone"); 3115// qDebug("showeditdone");
2198} 3116}
2199 3117
2200void QTReaderApp::do_setfont(const QString& lcn) 3118void QTReaderApp::do_setfont(const QString& lcn)
2201{ 3119{
2202 setfontHelper(lcn); 3120 if (m_fontAction == cChooseFont)
3121 {
3122 setfontHelper(lcn);
3123 }
3124 reader->refresh();
3125 m_fontBar->hide();
3126 m_fontVisible = false;
3127// qDebug("showedit");
3128 //if (reader->isVisible())
3129 showEditTools();
3130// qDebug("showeditdone");
2203} 3131}
2204 3132
2205void QTReaderApp::do_autogen(const QString& regText) 3133void QTReaderApp::do_autogen(const QString& regText)
2206{ 3134{
2207 unsigned long fs, ts; 3135 unsigned long fs, ts;
2208 reader->sizes(fs,ts); 3136 reader->sizes(fs,ts);
2209 // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); 3137// // qDebug("Reg:%s\n", (const tchar*)(regEdit->text()));
2210 m_autogenstr = regText; 3138 m_autogenstr = regText;
2211 QRegExp re(regText); 3139 QRegExp re(regText);
2212 CBuffer buff; 3140 CBuffer buff;
2213 if (pBkmklist != NULL) delete pBkmklist; 3141 if (pBkmklist != NULL) delete pBkmklist;
2214 pBkmklist = new CList<Bkmk>; 3142 pBkmklist = new CList<Bkmk>;
2215 m_fBkmksChanged = true; 3143 m_fBkmksChanged = true;
3144
3145 pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height());
2216 pbar->show(); 3146 pbar->show();
2217pbar->resize(width(), editBar->height()); 3147 pbar->raise();
2218 pbar->reset(); 3148 pbar->reset();
3149 reader->update();
2219 qApp->processEvents(); 3150 qApp->processEvents();
2220 reader->setFocus(); 3151 reader->setFocus();
2221 reader->jumpto(0); 3152 reader->jumpto(0);
@@ -2245,21 +3176,30 @@ pbar->resize(width(), editBar->height());
2245 pbar->setProgress(100); 3176 pbar->setProgress(100);
2246 qApp->processEvents(); 3177 qApp->processEvents();
2247 pbar->hide(); 3178 pbar->hide();
3179 reader->refresh();
2248} 3180}
2249 3181
2250void QTReaderApp::saveprefs() 3182void QTReaderApp::saveprefs()
2251{ 3183{
3184// qDebug("saveprefs");
2252// reader->saveprefs("uqtreader"); 3185// reader->saveprefs("uqtreader");
3186// if (!m_loadedconfig)
3187 do_saveconfig( APPDIR, true );
3188
3189/*
2253 Config config( APPDIR ); 3190 Config config( APPDIR );
2254 config.setGroup( "View" ); 3191 config.setGroup( "View" );
2255 3192
2256 reader->m_lastposn = reader->pagelocate(); 3193 reader->m_lastposn = reader->pagelocate();
2257 3194
3195 config.writeEntry("FloatDialogs", m_bFloatingDialog);
2258 config.writeEntry( "StripCr", reader->bstripcr ); 3196 config.writeEntry( "StripCr", reader->bstripcr );
2259 config.writeEntry( "AutoFmt", reader->bautofmt ); 3197 config.writeEntry( "AutoFmt", reader->bautofmt );
2260 config.writeEntry( "TextFmt", reader->btextfmt ); 3198 config.writeEntry( "TextFmt", reader->btextfmt );
2261 config.writeEntry( "StripHtml", reader->bstriphtml ); 3199 config.writeEntry( "StripHtml", reader->bstriphtml );
2262 config.writeEntry( "Dehyphen", reader->bdehyphen ); 3200 config.writeEntry( "Dehyphen", reader->bdehyphen );
3201 config.writeEntry( "Depluck", reader->bdepluck );
3202 config.writeEntry( "Dejpluck", reader->bdejpluck );
2263 config.writeEntry( "OneSpace", reader->bonespace ); 3203 config.writeEntry( "OneSpace", reader->bonespace );
2264 config.writeEntry( "Unindent", reader->bunindent ); 3204 config.writeEntry( "Unindent", reader->bunindent );
2265 config.writeEntry( "Repara", reader->brepara ); 3205 config.writeEntry( "Repara", reader->brepara );
@@ -2270,19 +3210,34 @@ void QTReaderApp::saveprefs()
2270 config.writeEntry( "LastFile", reader->m_lastfile ); 3210 config.writeEntry( "LastFile", reader->m_lastfile );
2271 config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); 3211 config.writeEntry( "LastPosn", (int)(reader->pagelocate()) );
2272 config.writeEntry( "PageMode", reader->m_bpagemode ); 3212 config.writeEntry( "PageMode", reader->m_bpagemode );
2273 config.writeEntry( "CursorNavigation", reader->m_navkeys );
2274 config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); 3213 config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced );
3214 config.writeEntry( "SwapMouse", reader->m_swapmouse);
2275 config.writeEntry( "Fontname", reader->m_fontname ); 3215 config.writeEntry( "Fontname", reader->m_fontname );
2276 config.writeEntry( "Encoding", reader->m_encd ); 3216 config.writeEntry( "Encoding", reader->m_encd );
2277 config.writeEntry( "CharSpacing", reader->m_charpc ); 3217 config.writeEntry( "CharSpacing", reader->m_charpc );
2278 config.writeEntry( "Overlap", (int)(reader->m_overlap) ); 3218 config.writeEntry( "Overlap", (int)(reader->m_overlap) );
3219 config.writeEntry( "Margin", (int)reader->m_border );
2279 config.writeEntry( "TargetApp", m_targetapp ); 3220 config.writeEntry( "TargetApp", m_targetapp );
2280 config.writeEntry( "TargetMsg", m_targetmsg ); 3221 config.writeEntry( "TargetMsg", m_targetmsg );
3222#ifdef _SCROLLPIPE
3223 config.writeEntry( "PipeTarget", reader->m_pipetarget );
3224 config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara );
3225#endif
2281 config.writeEntry( "TwoTouch", m_twoTouch ); 3226 config.writeEntry( "TwoTouch", m_twoTouch );
2282 config.writeEntry( "Annotation", m_doAnnotation); 3227 config.writeEntry( "Annotation", m_doAnnotation);
2283 config.writeEntry( "Dictionary", m_doDictionary); 3228 config.writeEntry( "Dictionary", m_doDictionary);
2284 config.writeEntry( "Clipboard", m_doClipboard); 3229 config.writeEntry( "Clipboard", m_doClipboard);
2285 config.writeEntry( "SpaceTarget", m_spaceTarget); 3230 config.writeEntry( "SpaceTarget", m_spaceTarget);
3231 config.writeEntry( "EscapeTarget", m_escapeTarget);
3232 config.writeEntry( "ReturnTarget", m_returnTarget);
3233 config.writeEntry( "LeftTarget", m_leftTarget);
3234 config.writeEntry( "RightTarget", m_rightTarget);
3235 config.writeEntry( "UpTarget", m_upTarget);
3236 config.writeEntry( "DownTarget", m_downTarget);
3237 config.writeEntry("LeftScroll", m_leftScroll);
3238 config.writeEntry("RightScroll", m_rightScroll);
3239 config.writeEntry("UpScroll", m_upScroll);
3240 config.writeEntry("DownScroll", m_downScroll);
2286#ifdef REPALM 3241#ifdef REPALM
2287 config.writeEntry( "Repalm", reader->brepalm ); 3242 config.writeEntry( "Repalm", reader->brepalm );
2288#endif 3243#endif
@@ -2290,28 +3245,28 @@ void QTReaderApp::saveprefs()
2290 config.writeEntry( "Peanut", reader->bpeanut ); 3245 config.writeEntry( "Peanut", reader->bpeanut );
2291 config.writeEntry( "MakeBold", reader->bmakebold ); 3246 config.writeEntry( "MakeBold", reader->bmakebold );
2292 config.writeEntry( "Continuous", reader->m_continuousDocument ); 3247 config.writeEntry( "Continuous", reader->m_continuousDocument );
2293 3248 config.writeEntry( "FullJust", reader->bfulljust );
3249 config.writeEntry( "ExtraSpace", reader->getextraspace() );
3250 config.writeEntry( "ExtraLead", reader->getlead() );
3251 config.writeEntry( "Basesize", (int)reader->getBaseSize());
3252 config.writeEntry( "RequestorFontChange", m_propogatefontchange);
3253
3254 config.setGroup( "Toolbar" );
3255 config.writeEntry("Movable", m_tbmovesave);
3256 config.writeEntry("Policy", m_tbpolsave);
3257 config.writeEntry("Position", m_tbposition);
3258*/
2294 savefilelist(); 3259 savefilelist();
2295} 3260}
2296 3261
2297void QTReaderApp::indentplus()
2298{
2299 reader->indentplus();
2300}
2301
2302void QTReaderApp::indentminus()
2303{
2304 reader->indentminus();
2305}
2306
2307/* 3262/*
2308void QTReaderApp::oldFile() 3263void QTReaderApp::oldFile()
2309{ 3264{
2310 qDebug("oldFile called"); 3265// qDebug("oldFile called");
2311 reader->setText(true); 3266 reader->setText(true);
2312 qDebug("settext called"); 3267// qDebug("settext called");
2313 showEditTools(); 3268 showEditTools();
2314 qDebug("showedit called"); 3269// qDebug("showedit called");
2315} 3270}
2316*/ 3271*/
2317 3272
@@ -2364,7 +3319,14 @@ void QTReaderApp::savebkmks()
2364{ 3319{
2365 if (pBkmklist != NULL) 3320 if (pBkmklist != NULL)
2366 { 3321 {
2367 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string), true); 3322#ifndef USEQPE
3323 QDir d = QDir::home(); // "/"
3324 d.cd(APPDIR);
3325 QFileInfo fi(d, reader->m_string);
3326 BkmkFile bf((const char *)fi.absFilePath(), true);
3327#else /* USEQPE */
3328 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true);
3329#endif /* USEQPE */
2368 bf.write(*pBkmklist); 3330 bf.write(*pBkmklist);
2369 } 3331 }
2370 m_fBkmksChanged = false; 3332 m_fBkmksChanged = false;
@@ -2372,19 +3334,33 @@ void QTReaderApp::savebkmks()
2372 3334
2373void QTReaderApp::readfilelist() 3335void QTReaderApp::readfilelist()
2374{ 3336{
2375 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles")); 3337#ifndef USEQPE
2376 qDebug("Reading open files"); 3338 QDir d = QDir::home(); // "/"
3339 d.cd(APPDIR);
3340 QFileInfo fi(d, ".openfiles");
3341 BkmkFile bf((const char *)fi.absFilePath());
3342#else /* USEQPE */
3343 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"));
3344#endif /* USEQPE */
3345// qDebug("Reading open files");
2377 pOpenlist = bf.readall(); 3346 pOpenlist = bf.readall();
2378 if (pOpenlist != NULL) qDebug("...with success"); 3347// if (pOpenlist != NULL) qDebug("...with success");
2379 else qDebug("...without success!"); 3348// else qDebug("...without success!");
2380} 3349}
2381 3350
2382void QTReaderApp::savefilelist() 3351void QTReaderApp::savefilelist()
2383{ 3352{
2384 if (pOpenlist != NULL) 3353 if (pOpenlist != NULL)
2385 { 3354 {
2386 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"), true); 3355#ifndef USEQPE
2387 qDebug("Writing open files"); 3356 QDir d = QDir::home(); // "/"
3357 d.cd(APPDIR);
3358 QFileInfo fi(d, ".openfiles");
3359 BkmkFile bf((const char *)fi.absFilePath(), true);
3360#else /* USEQPE */
3361 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true);
3362#endif /* USEQPE */
3363 //qDebug("Writing open files");
2388 bf.write(*pOpenlist); 3364 bf.write(*pOpenlist);
2389 } 3365 }
2390} 3366}
@@ -2397,19 +3373,36 @@ void QTReaderApp::readbkmks()
2397 } 3373 }
2398 struct stat fnstat; 3374 struct stat fnstat;
2399 struct stat bkstat; 3375 struct stat bkstat;
3376#ifndef USEQPE
3377 QDir d = QDir::home(); // "/"
3378 d.cd(APPDIR);
3379 QFileInfo fi(d, reader->m_string);
3380#endif /* ! USEQPE */
2400 if ( 3381 if (
2401 stat((const char *)reader->m_lastfile, &fnstat) == 0 3382 stat((const char *)reader->m_lastfile, &fnstat) == 0
2402 && 3383 &&
2403 stat((const char *)Global::applicationFileName(APPDIR, reader->m_string), &bkstat) == 0 3384#ifndef USEQPE
3385 stat((const char *)fi.absFilePath(), &bkstat) == 0
3386#else /* USEQPE */
3387 stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0
3388#endif /* USEQPE */
2404 ) 3389 )
2405 { 3390 {
2406 if (bkstat.st_mtime < fnstat.st_mtime) 3391 if (bkstat.st_mtime < fnstat.st_mtime)
2407 { 3392 {
2408 unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string)); 3393#ifndef USEQPE
3394 unlink((const char *)fi.absFilePath());
3395#else /* USEQPE */
3396 unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string));
3397#endif /* USEQPE */
2409 } 3398 }
2410 } 3399 }
2411 3400
2412 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string)); 3401#ifndef USEQPE
3402 BkmkFile bf((const char *)fi.absFilePath());
3403#else /* USEQPE */
3404 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string));
3405#endif /* USEQPE */
2413 3406
2414 pBkmklist = bf.readall(); 3407 pBkmklist = bf.readall();
2415 m_fBkmksChanged = bf.upgraded(); 3408 m_fBkmksChanged = bf.upgraded();
@@ -2456,7 +3449,7 @@ void QTReaderApp::do_addbkmk(const QString& text)
2456 3449
2457void QTReaderApp::OnRedraw() 3450void QTReaderApp::OnRedraw()
2458{ 3451{
2459 if (pBkmklist != NULL) 3452 if ((pBkmklist != NULL) && (m_bkmkAvail != NULL))
2460 { 3453 {
2461 bool found = findNextBookmark(reader->pagelocate()); 3454 bool found = findNextBookmark(reader->pagelocate());
2462 m_bkmkAvail->setEnabled(found); 3455 m_bkmkAvail->setEnabled(found);
@@ -2468,19 +3461,22 @@ void QTReaderApp::showAnnotation()
2468 m_annoWin->setName(toQString(m_anno->name())); 3461 m_annoWin->setName(toQString(m_anno->name()));
2469 m_annoWin->setAnno(toQString(m_anno->anno())); 3462 m_annoWin->setAnno(toQString(m_anno->anno()));
2470 m_annoIsEditing = false; 3463 m_annoIsEditing = false;
3464#ifdef USEQPE
2471 Global::showInputMethod(); 3465 Global::showInputMethod();
3466#endif
2472 editorStack->raiseWidget( m_annoWin ); 3467 editorStack->raiseWidget( m_annoWin );
2473 m_annoWin->setFocus(); 3468 m_annoWin->setFocus();
2474} 3469}
2475 3470
2476void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) 3471void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line)
2477{ 3472{
2478// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); 3473//// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd);
2479 3474
2480 if (m_doClipboard) 3475 if (m_doClipboard)
2481 { 3476 {
2482 QClipboard* cb = QApplication::clipboard(); 3477 QClipboard* cb = QApplication::clipboard();
2483 cb->setText(wrd); 3478 cb->setText(wrd);
3479#ifdef USEQPE
2484 if (wrd.length() > 10) 3480 if (wrd.length() > 10)
2485 { 3481 {
2486 Global::statusMessage(wrd.left(8) + ".."); 3482 Global::statusMessage(wrd.left(8) + "..");
@@ -2489,6 +3485,7 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString&
2489 { 3485 {
2490 Global::statusMessage(wrd); 3486 Global::statusMessage(wrd);
2491 } 3487 }
3488#endif
2492 } 3489 }
2493 if (m_doAnnotation) 3490 if (m_doAnnotation)
2494 { 3491 {
@@ -2497,9 +3494,12 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString&
2497 m_annoWin->setAnno(""); 3494 m_annoWin->setAnno("");
2498 m_annoWin->setPosn(posn); 3495 m_annoWin->setPosn(posn);
2499 m_annoIsEditing = true; 3496 m_annoIsEditing = true;
3497#ifdef USEQPE
2500 Global::showInputMethod(); 3498 Global::showInputMethod();
3499#endif
2501 editorStack->raiseWidget( m_annoWin ); 3500 editorStack->raiseWidget( m_annoWin );
2502 } 3501 }
3502#ifdef USEQPE
2503 if (m_doDictionary) 3503 if (m_doDictionary)
2504 { 3504 {
2505 if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) 3505 if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty())
@@ -2508,44 +3508,237 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString&
2508 e << wrd; 3508 e << wrd;
2509 } 3509 }
2510 } 3510 }
3511#endif
2511} 3512}
2512 3513
2513void QTReaderApp::OnActionPressed() 3514void QTReaderApp::doAction(ActionTypes a, QKeyEvent* e)
2514{ 3515{
2515 switch (m_spaceTarget) 3516 if (a == 0)
2516 { 3517 {
2517 case cesOpenFile: 3518 e->ignore();
2518 { 3519 }
2519 fileOpen(); 3520 else
2520 } 3521 {
2521 break; 3522 e->accept();
2522 case cesAutoScroll: 3523 //qDebug("Accepted");
2523 { 3524 switch (a)
2524 reader->setautoscroll(!reader->m_autoScroll);
2525 setScrollState(reader->m_autoScroll);
2526 }
2527 break;
2528 case cesActionMark:
2529 { 3525 {
2530 addbkmk(); 3526 case cesOpenFile:
3527 {
3528 fileOpen();
3529 }
3530 break;
3531 case cesAutoScroll:
3532 {
3533 reader->setautoscroll(!reader->m_autoScroll);
3534 setScrollState(reader->m_autoScroll);
3535 }
3536 break;
3537 case cesActionMark:
3538 {
3539 addbkmk();
3540 }
3541 break;
3542 case cesFullScreen:
3543 {
3544 m_actFullscreen->setOn(!m_fullscreen);
3545 }
3546 break;
3547 case cesActionAnno:
3548 {
3549 addanno();
3550 }
3551 break;
3552 case cesZoomIn:
3553 zoomin();
3554 break;
3555 case cesZoomOut:
3556 zoomout();
3557 break;
3558 case cesBack:
3559 reader->goBack();
3560 break;
3561 case cesForward:
3562 reader->goForward();
3563 break;
3564 case cesHome:
3565 reader->goHome();
3566 break;
3567 case cesPageUp:
3568 reader->dopageup();
3569 break;
3570 case cesPageDown:
3571 reader->dopagedn();
3572 break;
3573 case cesLineUp:
3574 reader->lineUp();
3575 break;
3576 case cesLineDown:
3577 reader->lineDown();
3578 break;
3579 case cesStartDoc:
3580 gotoStart();
3581 break;
3582 case cesEndDoc:
3583 gotoEnd();
3584 break;
3585 default:
3586 qDebug("Unknown ActionType:%u", a);
3587 break;
2531 } 3588 }
2532 break; 3589 }
2533 case cesFullScreen: 3590}
3591
3592void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); }
3593void QTReaderApp::restoreFocus() { reader->setFocus(); }
3594
3595void QTReaderApp::SaveConfig()
3596{
3597 m_nRegAction = cSetConfigName;
3598 regEdit->setText(reader->m_string);
3599 do_regedit();
3600}
3601
3602void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
3603{
3604// qDebug("do_saveconfig:%s", (const char*)_txt);
3605#ifdef USEQPE
3606 QString configname;
3607 Config::Domain dom;
3608
3609 if (full)
3610 {
3611 configname = _txt;
3612 dom = Config::User;
3613 }
3614 else
3615 {
3616 configname = Global::applicationFileName(APPDIR "/configs", _txt);
3617 dom = Config::File;
3618 }
3619
3620 Config config(configname, dom);
3621 config.setGroup( "View" );
3622
3623#else
3624 QFileInfo fi;
3625 if (full)
2534 { 3626 {
2535 m_actFullscreen->setOn(true); 3627 // qDebug("full:%s", (const char*)_txt);
3628 QDir d = QDir::home(); // "/"
3629 if ( !d.cd(_txt) )
3630 { // "/tmp"
3631 qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt );
3632 d = QDir::home();
3633 d.mkdir(_txt);
3634 d.cd(_txt);
3635 }
3636 fi.setFile(d, INIFILE);
2536 } 3637 }
2537 break; 3638 else
2538 default:
2539 { 3639 {
2540 qDebug("Unknown ActionType:%u", m_spaceTarget); 3640 QDir d = QDir::home(); // "/"
3641 if ( !d.cd(APPDIR) )
3642 { // "/tmp"
3643 qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
3644 d = QDir::home();
3645 d.mkdir(APPDIR);
3646 d.cd(APPDIR);
3647 }
3648 if ( !d.cd("configs") )
3649 { // "/tmp"
3650 qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" );
3651 d = QDir::home();
3652 d.cd(APPDIR);
3653 d.mkdir("configs");
3654 d.cd("configs");
3655 }
3656 fi.setFile(d, _txt);
2541 } 3657 }
2542 break; 3658 //qDebug("Path:%s", (const char*)fi.absFilePath());
3659 Config config(fi.absFilePath());
3660#endif
3661
3662
3663 config.writeEntry( "StripCr", reader->bstripcr );
3664 config.writeEntry( "AutoFmt", reader->bautofmt );
3665 config.writeEntry( "TextFmt", reader->btextfmt );
3666 config.writeEntry( "StripHtml", reader->bstriphtml );
3667 config.writeEntry( "Dehyphen", reader->bdehyphen );
3668 config.writeEntry( "Depluck", reader->bdepluck );
3669 config.writeEntry( "Dejpluck", reader->bdejpluck );
3670 config.writeEntry( "OneSpace", reader->bonespace );
3671 config.writeEntry( "Unindent", reader->bunindent );
3672 config.writeEntry( "Repara", reader->brepara );
3673 config.writeEntry( "DoubleSpace", reader->bdblspce );
3674 config.writeEntry( "Indent", reader->bindenter );
3675 config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) );
3676 config.writeEntry( "ScrollDelay", reader->m_delay);
3677 if (full)
3678 {
3679 config.writeEntry("Debounce", m_debounce);
3680 config.writeEntry("FloatDialogs", m_bFloatingDialog);
3681 reader->m_lastposn = reader->pagelocate();
3682 config.writeEntry( "LastFile", reader->m_lastfile );
3683 config.writeEntry( "LastPosn", (int)(reader->pagelocate()) );
3684 }
3685 config.writeEntry( "PageMode", reader->m_bpagemode );
3686 config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced );
3687 config.writeEntry( "SwapMouse", reader->m_swapmouse);
3688 config.writeEntry( "Fontname", reader->m_fontname );
3689 config.writeEntry( "Encoding", reader->m_encd );
3690 config.writeEntry( "CharSpacing", reader->m_charpc );
3691 config.writeEntry( "Overlap", (int)(reader->m_overlap) );
3692 config.writeEntry( "Margin", (int)reader->m_border );
3693 config.writeEntry( "TargetApp", m_targetapp );
3694 config.writeEntry( "TargetMsg", m_targetmsg );
3695#ifdef _SCROLLPIPE
3696 config.writeEntry( "PipeTarget", reader->m_pipetarget );
3697 config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara );
3698#endif
3699 config.writeEntry( "TwoTouch", m_twoTouch );
3700 config.writeEntry( "Annotation", m_doAnnotation);
3701 config.writeEntry( "Dictionary", m_doDictionary);
3702 config.writeEntry( "Clipboard", m_doClipboard);
3703 config.writeEntry( "SpaceTarget", m_spaceTarget);
3704 config.writeEntry( "EscapeTarget", m_escapeTarget);
3705 config.writeEntry( "ReturnTarget", m_returnTarget);
3706 config.writeEntry( "LeftTarget", m_leftTarget);
3707 config.writeEntry( "RightTarget", m_rightTarget);
3708 config.writeEntry( "UpTarget", m_upTarget);
3709 config.writeEntry( "DownTarget", m_downTarget);
3710 config.writeEntry("LeftScroll", m_leftScroll);
3711 config.writeEntry("RightScroll", m_rightScroll);
3712 config.writeEntry("UpScroll", m_upScroll);
3713 config.writeEntry("DownScroll", m_downScroll);
3714#ifdef REPALM
3715 config.writeEntry( "Repalm", reader->brepalm );
3716#endif
3717 config.writeEntry( "Remap", reader->bremap );
3718 config.writeEntry( "Peanut", reader->bpeanut );
3719 config.writeEntry( "MakeBold", reader->bmakebold );
3720 config.writeEntry( "Continuous", reader->m_continuousDocument );
3721 config.writeEntry( "FullJust", reader->bfulljust );
3722 config.writeEntry( "ExtraSpace", reader->getextraspace() );
3723 config.writeEntry( "ExtraLead", reader->getlead() );
3724 config.writeEntry( "Basesize", (int)reader->getBaseSize());
3725 config.writeEntry( "RequestorFontChange", m_propogatefontchange);
3726 if (full)
3727 {
3728 config.setGroup( "Toolbar" );
3729 config.writeEntry("Movable", m_tbmovesave);
3730 config.writeEntry("Policy", m_tbpolsave);
3731 config.writeEntry("Position", m_tbposition);
3732#ifndef USEQPE
3733 config.setGroup( "Geometry" );
3734 config.writeEntry( "x", x() );
3735 config.writeEntry( "y", y() );
3736 config.writeEntry( "width", width() );
3737 config.writeEntry( "height", height() );
3738#endif
2543 } 3739 }
2544} 3740}
2545 3741
2546void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); }
2547void QTReaderApp::restoreFocus() { reader->setFocus(); }
2548
2549/* 3742/*
2550void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen) 3743void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen)
2551{ 3744{
@@ -2584,12 +3777,13 @@ void QTReaderApp::getstate(unsigned char*& data, unsigned short& len)
2584 sd->bstriphtml = reader->bstriphtml; 3777 sd->bstriphtml = reader->bstriphtml;
2585 sd->bpeanut = reader->bpeanut; 3778 sd->bpeanut = reader->bpeanut;
2586 sd->bdehyphen = reader->bdehyphen; 3779 sd->bdehyphen = reader->bdehyphen;
3780 sd->bdepluck = reader->bdepluck;
3781 sd->bdejpluck = reader->bdejpluck;
2587 sd->bonespace = reader->bonespace; 3782 sd->bonespace = reader->bonespace;
2588 sd->bunindent = reader->bunindent; 3783 sd->bunindent = reader->bunindent;
2589 sd->brepara = reader->brepara; 3784 sd->brepara = reader->brepara;
2590 sd->bdblspce = reader->bdblspce; 3785 sd->bdblspce = reader->bdblspce;
2591 sd->m_bpagemode = reader->m_bpagemode; 3786 sd->m_bpagemode = reader->m_bpagemode;
2592 sd->m_navkeys = reader->m_navkeys;
2593 sd->m_bMonoSpaced = reader->m_bMonoSpaced; 3787 sd->m_bMonoSpaced = reader->m_bMonoSpaced;
2594 sd->bremap = reader->bremap; 3788 sd->bremap = reader->bremap;
2595 sd->bmakebold = reader->bmakebold; 3789 sd->bmakebold = reader->bmakebold;
@@ -2604,3 +3798,425 @@ void QTReaderApp::getstate(unsigned char*& data, unsigned short& len)
2604 strcpy(sd->m_fontname, reader->m_fontname.latin1()); 3798 strcpy(sd->m_fontname, reader->m_fontname.latin1());
2605} 3799}
2606*/ 3800*/
3801#ifdef _SCRIPT
3802void QTReaderApp::RunScript()
3803{
3804 fileBrowser* fb = new fileBrowser(this,"OpieReader",!m_bFloatingDialog,
3805 0,
3806 // WStyle_Customize | WStyle_NoBorderEx,
3807 "*", Global::applicationFileName(APPDIR "/scripts", ""));
3808
3809 QString fn;
3810 if (fb->exec())
3811 {
3812 fn = fb->fileList[0];
3813 }
3814 delete fb;
3815 if ( !fn.isEmpty() && fork() == 0 )
3816 {
3817 execlp((const char *)fn,(const char *)fn,NULL);
3818 }
3819}
3820
3821void QTReaderApp::SaveScript(const char* sname)
3822{
3823 FILE* f = fopen(sname,"w");
3824 if (f != NULL)
3825 {
3826#ifdef OPIE
3827 fprintf(f, "#!/bin/sh\nmsg() {\n\tqcop QPE/Application/reader \"$1\" \"$2\" \"$3\"\n}\n");
3828#else
3829 fprintf(f, "#!/bin/bash\nmsg() {\n\tqcop QPE/Application/uqtreader \"$1\" \"$2\" \"$3\"\n}\n");
3830#endif
3831 fprintf(f, "msg \"Update(int)\" 0\n");
3832 fprintf(f, "msg \"Layout/StripCR(int)\" %d\n", (reader->bstripcr) ? 1:0);
3833 if (reader->btextfmt) fprintf(f, "msg \"Markup(QString)\" \"Text\"\n");
3834 else if (reader->bautofmt) fprintf(f, "msg \"Markup(QString)\" \"Auto\"\n");
3835 else if (reader->bstriphtml) fprintf(f, "msg \"Markup(QString)\" \"HTML\"\n");
3836 else if (reader->bpeanut) fprintf(f, "msg \"Markup(QString)\" \"Peanut/PML\"\n");
3837 else fprintf(f, "msg \"Markup(QString)\" \"None\"\n");
3838 fprintf(f, "msg \"Layout/Dehyphen(int)\" %d\n", (reader->bdehyphen) ? 1:0);
3839 fprintf(f, "msg \"Layout/Depluck(int)\" %d\n", (reader->bdepluck) ? 1:0);
3840 fprintf(f, "msg \"Layout/Dejpluck(int)\" %d\n", (reader->bdejpluck) ? 1:0);
3841 fprintf(f, "msg \"Layout/SingleSpace(int)\" %d\n", (reader->bonespace) ? 1:0);
3842 fprintf(f, "msg \"Layout/Unindent(int)\" %d\n", (reader->bunindent) ? 1:0);
3843 fprintf(f, "msg \"Layout/Re-paragraph(int)\" %d\n", (reader->brepara) ? 1:0);
3844 fprintf(f, "msg \"Layout/DoubleSpace(int)\" %d\n", (reader->bdblspce) ? 1:0);
3845 fprintf(f, "msg \"Layout/Indent(int)\" %d\n", reader->bindenter);
3846 fprintf(f, "msg \"Format/SetFont(QString,int)\" \"%s\" %d\n", (const char*)reader->m_fontname, reader->m_textsize);
3847 fprintf(f, "msg \"Navigation/Page/LineScroll(int)\" %d\n", (reader->m_bpagemode) ? 1:0);
3848 fprintf(f, "msg \"Format/Ideogram/Word(int)\" %d\n", (reader->m_bMonoSpaced) ? 1:0);
3849 fprintf(f, "msg \"Format/Encoding(QString)\" \"%s\"\n", (const char*)m_EncodingAction[reader->m_encd]->text());
3850 fprintf(f, "msg \"Format/SetWidth(int)\" %d\n", reader->m_charpc);
3851 fprintf(f, "msg \"Navigation/SetOverlap(int)\" %d\n", reader->m_overlap);
3852 fprintf(f, "msg \"Layout/Remap(int)\" %d\n", (reader->bremap) ? 1:0);
3853 fprintf(f, "msg \"Layout/Embolden(int)\" %d\n", (reader->bmakebold) ? 1:0);
3854 fprintf(f, "msg \"File/Continuous(int)\" %d\n", (reader->m_continuousDocument) ? 1:0);
3855 fprintf(f, "msg \"File/SetDictionary(QString)\" \"%s/%s\"\n", (const char *)m_targetapp, (const char *)m_targetmsg);
3856#ifdef _SCROLLPIPE
3857 fprintf(f, "msg \"File/SetScrollTarget(QString)\" \"%s\"\n", (const char *)reader->m_pipetarget);
3858#endif
3859 fprintf(f, "msg \"File/Two/OneTouch(int)\" %d\n", (m_twoTouch) ? 1:0);
3860 fprintf(f, "msg \"Target/Annotation(int)\" %d\n", (m_doAnnotation) ? 1:0);
3861 fprintf(f, "msg \"Target/Dictionary(int)\" %d\n", (m_doDictionary) ? 1:0);
3862 fprintf(f, "msg \"Target/Clipboard(int)\" %d\n", (m_doClipboard) ? 1:0);
3863 fprintf(f, "msg \"File/Action(QString)\" \"%s\"\n", (const char *)m_buttonAction[m_spaceTarget]->text());
3864 fprintf(f, "msg \"Update(int)\" 1\n");
3865 fprintf(f, "msg \"info(QString)\" \"All Done\"\n");
3866 fclose(f);
3867 chmod(sname, S_IXUSR | S_IXGRP | S_IXOTH);
3868 }
3869}
3870
3871void QTReaderApp::SaveConfig()
3872{
3873 m_nRegAction = cSetConfigName;
3874 regEdit->setText("");
3875 do_regedit();
3876}
3877
3878void QTReaderApp::do_saveconfig(const QString& _txt)
3879{
3880 SaveScript(Global::applicationFileName(APPDIR "/scripts", _txt));
3881}
3882#endif
3883
3884#ifdef _SCROLLPIPE
3885void QTReaderApp::setpipetarget()
3886{
3887 m_nRegAction = cSetPipeTarget;
3888 QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget;
3889 regEdit->setText(text);
3890 do_regedit();
3891}
3892
3893void QTReaderApp::do_setpipetarget(const QString& _txt)
3894{
3895 reader->m_pipetarget = _txt;
3896}
3897
3898void QTReaderApp::setpause(bool sfs)
3899{
3900 reader->m_pauseAfterEachPara = sfs;
3901}
3902#endif
3903
3904void QTReaderApp::monospace(bool _b)
3905{
3906 reader->setmono(_b);
3907}
3908
3909bool QTReaderApp::readconfig(const QString& _txt, bool full=false)
3910{
3911#ifdef USEQPE
3912 QString configname;
3913 Config::Domain dom;
3914
3915 if (full)
3916 {
3917 configname = _txt;
3918 dom = Config::User;
3919 }
3920 else
3921 {
3922 configname = Global::applicationFileName(APPDIR "/configs", _txt);
3923 QFileInfo fm(configname);
3924 if ( !fm.exists() ) return false;
3925 dom = Config::File;
3926 }
3927
3928 Config config(configname, dom);
3929 config.setGroup( "View" );
3930
3931#else
3932 QFileInfo fi;
3933 if (full)
3934 {
3935 QDir d = QDir::home(); // "/"
3936 if ( !d.cd(_txt) )
3937 { // "/tmp"
3938 qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt );
3939 d = QDir::home();
3940 d.mkdir(_txt);
3941 d.cd(_txt);
3942 }
3943 fi.setFile(d, INIFILE);
3944 }
3945 else
3946 {
3947 QDir d = QDir::home(); // "/"
3948 if ( !d.cd(APPDIR) )
3949 { // "/tmp"
3950 qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
3951 d = QDir::home();
3952 d.mkdir(APPDIR);
3953 d.cd(APPDIR);
3954 }
3955 if ( !d.cd("configs") )
3956 { // "/tmp"
3957 qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" );
3958 d = QDir::home();
3959 d.mkdir("configs");
3960 d.cd("configs");
3961 }
3962 fi.setFile(d, _txt);
3963 }
3964#ifdef _WINDOWS
3965 struct stat fnstat;
3966 if (stat((const char *)reader->m_lastfile, &fnstat) == 0) return false; // get round fileinfo bug on windows
3967#else
3968 if (!fi.exists()) return false;
3969#endif
3970 Config config(fi.absFilePath());
3971#endif
3972 if (full)
3973 {
3974 config.setGroup("Toolbar");
3975 m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false);
3976 m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1);
3977 m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2);
3978 }
3979 config.setGroup( "View" );
3980 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false);
3981 reader->bstripcr = config.readBoolEntry( "StripCr", true );
3982 reader->bfulljust = config.readBoolEntry( "FullJust", false );
3983 reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 ));
3984 reader->setlead(config.readNumEntry( "ExtraLead", 0 ));
3985 reader->btextfmt = config.readBoolEntry( "TextFmt", false );
3986 reader->bautofmt = config.readBoolEntry( "AutoFmt", true );
3987 reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
3988 reader->bpeanut = config.readBoolEntry( "Peanut", false );
3989 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false );
3990 reader->bdepluck = config.readBoolEntry( "Depluck", false );
3991 reader->bdejpluck = config.readBoolEntry( "Dejpluck", false );
3992 reader->bonespace = config.readBoolEntry( "OneSpace", false );
3993 reader->bunindent = config.readBoolEntry( "Unindent", false );
3994 reader->brepara = config.readBoolEntry( "Repara", false );
3995 reader->bdblspce = config.readBoolEntry( "DoubleSpace", false );
3996 reader->bindenter = config.readNumEntry( "Indent", 0 );
3997 reader->m_textsize = config.readNumEntry( "FontSize", 12 );
3998 reader->m_delay = config.readNumEntry( "ScrollDelay", 5184);
3999 if (full)
4000 {
4001 reader->m_lastfile = config.readEntry( "LastFile", QString::null );
4002 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 );
4003 }
4004 reader->m_bpagemode = config.readBoolEntry( "PageMode", true );
4005 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false);
4006 reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false);
4007 reader->m_fontname = config.readEntry( "Fontname", "helvetica" );
4008 reader->m_encd = config.readNumEntry( "Encoding", 0 );
4009 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 );
4010 reader->m_overlap = config.readNumEntry( "Overlap", 0 );
4011 reader->m_border = config.readNumEntry( "Margin", 6 );
4012#ifdef REPALM
4013 reader->brepalm = config.readBoolEntry( "Repalm", true );
4014#endif
4015 reader->bremap = config.readBoolEntry( "Remap", true );
4016 reader->bmakebold = config.readBoolEntry( "MakeBold", false );
4017 reader->setContinuous(config.readBoolEntry( "Continuous", true ));
4018 m_targetapp = config.readEntry( "TargetApp", QString::null );
4019 m_targetmsg = config.readEntry( "TargetMsg", QString::null );
4020#ifdef _SCROLLPIPE
4021 reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null );
4022 reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true );
4023#endif
4024 m_twoTouch = config.readBoolEntry( "TwoTouch", false);
4025 m_doAnnotation = config.readBoolEntry( "Annotation", false);
4026 m_doDictionary = config.readBoolEntry( "Dictionary", false);
4027 m_doClipboard = config.readBoolEntry( "Clipboard", false);
4028 m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll);
4029 m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone);
4030 m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen);
4031 m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut);
4032 m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn);
4033 m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp);
4034 m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown);
4035
4036 m_leftScroll = config.readBoolEntry("LeftScroll", false);
4037 m_rightScroll = config.readBoolEntry("RightScroll", false);
4038 m_upScroll = config.readBoolEntry("UpScroll", true);
4039 m_downScroll = config.readBoolEntry("DownScroll", true);
4040 m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false);
4041 reader->setBaseSize(config.readNumEntry( "Basesize", 10 ));
4042 reader->setTwoTouch(m_twoTouch);
4043
4044 m_touch_action->setOn(m_twoTouch);
4045 m_setmono_action->setOn(reader->m_bMonoSpaced);
4046 setfontHelper(reader->m_fontname);
4047 if (full)
4048 {
4049 addtoolbars(&config);
4050 }
4051 reader->setfilter(reader->getfilter());
4052 reader->refresh();
4053 return true;
4054}
4055
4056bool QTReaderApp::PopulateConfig(const char* tgtdir)
4057{
4058 bkmkselector->clear();
4059 bkmkselector->setText("Cancel");
4060#ifndef USEQPE
4061 int cnt = 0;
4062
4063 QDir d = QDir::home(); // "/"
4064 if ( !d.cd(APPDIR) ) { // "/tmp"
4065 qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
4066 d = QDir::home();
4067 d.mkdir(APPDIR);
4068 d.cd(APPDIR);
4069 }
4070 if ( !d.cd(tgtdir) ) { // "/tmp"
4071 qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir );
4072 d = QDir::home();
4073 d.mkdir(tgtdir);
4074 d.cd(tgtdir);
4075 }
4076 d.setFilter( QDir::Files | QDir::NoSymLinks );
4077// d.setSorting( QDir::Size | QDir::Reversed );
4078
4079 const QFileInfoList *list = d.entryInfoList();
4080 QFileInfoListIterator it( *list ); // create list iterator
4081 QFileInfo *fi; // pointer for traversing
4082
4083 while ( (fi=it.current()) ) { // for each file...
4084
4085 bkmkselector->insertItem(fi->fileName());
4086 cnt++;
4087
4088 //qDebug( "%10li %s", fi->size(), fi->fileName().data() );
4089 ++it; // goto next list element
4090 }
4091
4092#else /* USEQPE */
4093 int cnt = 0;
4094 DIR *d;
4095 char* finaldir;
4096 finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1];
4097 strcpy(finaldir, APPDIR);
4098 strcat(finaldir, "/");
4099 strcat(finaldir, tgtdir);
4100 d = opendir((const char *)Global::applicationFileName(finaldir,""));
4101
4102 while(1)
4103 {
4104 struct dirent* de;
4105 struct stat buf;
4106 de = readdir(d);
4107 if (de == NULL) break;
4108
4109 if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode))
4110 {
4111 bkmkselector->insertItem(de->d_name);
4112 cnt++;
4113 }
4114 }
4115 delete [] finaldir;
4116 closedir(d);
4117#endif
4118 return (cnt > 0);
4119}
4120
4121void QTReaderApp::LoadConfig()
4122{
4123 if (PopulateConfig("configs"))
4124 {
4125 editorStack->raiseWidget( bkmkselector );
4126 hidetoolbars();
4127 m_nBkmkAction = cLdConfig;
4128 }
4129 else
4130 QMessageBox::information(this, PROGNAME, "No config files");
4131}
4132
4133void QTReaderApp::TidyConfig()
4134{
4135 if (PopulateConfig("configs"))
4136 {
4137 editorStack->raiseWidget( bkmkselector );
4138 hidetoolbars();
4139 m_nBkmkAction = cRmConfig;
4140 }
4141 else
4142 QMessageBox::information(this, PROGNAME, "No config files");
4143}
4144
4145void QTReaderApp::ExportLinks()
4146{
4147 if (PopulateConfig("urls"))
4148 {
4149 editorStack->raiseWidget( bkmkselector );
4150 hidetoolbars();
4151 m_nBkmkAction = cExportLinks;
4152 }
4153 else
4154 QMessageBox::information(this, PROGNAME, "No url files");
4155}
4156
4157void QTReaderApp::OnURLSelected(const QString& href)
4158{
4159 CURLDialog* urld = new CURLDialog(href, false, this);
4160 urld->clipboard(m_url_clipboard);
4161 urld->localfile(m_url_localfile);
4162 urld->globalfile(m_url_globalfile);
4163 if (urld->exec())
4164 {
4165 m_url_clipboard = urld->clipboard();
4166 m_url_localfile = urld->localfile();
4167 m_url_globalfile = urld->globalfile();
4168 if (m_url_clipboard)
4169 {
4170 QClipboard* cb = QApplication::clipboard();
4171 cb->setText(href);
4172 qDebug("<a href=\"%s\">%s</a>", (const char*)href, (const char*)href);
4173 }
4174 if (m_url_localfile)
4175 {
4176 writeUrl(reader->m_string, href);
4177 }
4178 if (m_url_globalfile)
4179 {
4180 writeUrl("GlobalURLFile", href);
4181 }
4182 }
4183 delete urld;
4184}
4185
4186void QTReaderApp::writeUrl(const QString& file, const QString& href)
4187{
4188 QString filename;
4189#ifdef USEQPE
4190 filename = Global::applicationFileName(APPDIR "/urls", file);
4191#else
4192 QFileInfo fi;
4193 QDir d = QDir::home(); // "/"
4194 if ( !d.cd(APPDIR) )
4195 { // "/tmp"
4196 qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
4197 d = QDir::home();
4198 d.mkdir(APPDIR);
4199 d.cd(APPDIR);
4200 }
4201 if ( !d.cd("urls") )
4202 { // "/tmp"
4203 qWarning( "Cannot find the \"~/" APPDIR "/urls\" directory" );
4204 d = QDir::home();
4205 d.cd(APPDIR);
4206 d.mkdir("urls");
4207 d.cd("urls");
4208 }
4209 fi.setFile(d, file);
4210 filename = fi.absFilePath();
4211#endif
4212 FILE* fout = fopen(filename, "a");
4213 if (fout != NULL)
4214 {
4215 fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href);
4216 fclose(fout);
4217 }
4218 else
4219 {
4220 QMessageBox::warning(this, PROGNAME, "Problem with writing URL");
4221 }
4222}
diff --git a/noncore/apps/opie-reader/QTReaderApp.h b/noncore/apps/opie-reader/QTReaderApp.h
index cb33e4a..2765d47 100644
--- a/noncore/apps/opie-reader/QTReaderApp.h
+++ b/noncore/apps/opie-reader/QTReaderApp.h
@@ -20,15 +20,19 @@
20#ifndef __QTREADERAPP_H 20#ifndef __QTREADERAPP_H
21#define __QTREADERAPP_H 21#define __QTREADERAPP_H
22 22
23//#define _SCROLLPIPE
23//#define __ISEARCH 24//#define __ISEARCH
24 25
25#define MAX_ENCODING 6 26//#define MAX_ENCODING 6
26#define MAX_ACTIONS 4 27#define MAX_ACTIONS 5
27 28
29#include "useqpe.h"
30#include <sys/timeb.h>
28#include <qmainwindow.h> 31#include <qmainwindow.h>
29#include "CExpander.h" 32#include "CExpander.h"
33#include "CEncoding.h"
30#include <qlist.h> 34#include <qlist.h>
31#include <qpe/filemanager.h> 35//#include <qpe/filemanager.h>
32#include <qmap.h> 36#include <qmap.h>
33#include <qlineedit.h> 37#include <qlineedit.h>
34#include <qstack.h> 38#include <qstack.h>
@@ -39,7 +43,10 @@ class QWidgetStack;
39class QToolButton; 43class QToolButton;
40class QPopupMenu; 44class QPopupMenu;
41class QToolBar; 45class QToolBar;
42//class QPEToolBar; 46#ifdef USEQPE
47class QPEToolBar;
48class QPEMenuBar;
49#endif
43class CBkmkSelector; 50class CBkmkSelector;
44class QProgressBar; 51class QProgressBar;
45class QAction; 52class QAction;
@@ -47,14 +54,74 @@ class CAnnoEdit;
47class QFloatBar; 54class QFloatBar;
48class CDrawBuffer; 55class CDrawBuffer;
49class QTReader; 56class QTReader;
50class QPixmap; 57class QImage;
58class Config;
51 59
52enum ActionTypes 60enum ActionTypes
53{ 61{
54 cesOpenFile = 0, 62 cesNone = 0,
63 cesOpenFile,
55 cesAutoScroll, 64 cesAutoScroll,
56 cesActionMark, 65 cesActionMark,
57 cesFullScreen 66 cesActionAnno,
67 cesFullScreen,
68 cesZoomIn,
69 cesZoomOut,
70 cesBack,
71 cesForward,
72 cesHome,
73 cesPageUp,
74 cesPageDown,
75 cesLineUp,
76 cesLineDown,
77 cesStartDoc,
78 cesEndDoc
79};
80/*
81*m_preferences_action, *m_close_action *m_info_action, *m_touch_action,
82*m_find_action, *m_jump_action, *m_setfont_action *m_goto_action,
83*m_delete_action; *m_autogen_action, *m_clear_action, *m_save_action;
84*m_tidy_action, *m_startBlock_action, *m_endBlock_action;
85*m_setenc_action, *m_setmono_action;
86*/
87enum ToolbarPolicy
88{
89 cesSingle = 0,
90 cesMenuTool,
91 cesMultiple
92};
93
94enum regedit_type
95{
96 cAutoGen,
97 cAddBkmk,
98 cJump,
99 cMonoSpace,
100 cSetTarget,
101#ifdef _SCROLLPIPE
102 cSetPipeTarget,
103#endif
104 cSetConfigName,
105 cMargin,
106 cExtraSpace,
107 cExtraLead
108};
109
110enum bkmk_action
111{
112 cOpenFile,
113 cGotoBkmk,
114 cDelBkmk,
115 cRmBkmkFile,
116 cLdConfig,
117 cRmConfig,
118 cExportLinks
119};
120
121enum fontselector_action
122{
123 cChooseFont,
124 cChooseEncoding
58}; 125};
59 126
60#ifdef __ISEARCH 127#ifdef __ISEARCH
@@ -74,11 +141,24 @@ class QTReaderApp : public QMainWindow
74 Q_OBJECT 141 Q_OBJECT
75 142
76 unsigned long m_savedpos; 143 unsigned long m_savedpos;
144 int m_debounce;
145 timeb m_lastkeytime;
77 bool m_annoIsEditing; 146 bool m_annoIsEditing;
147 bool m_propogatefontchange, m_bFloatingDialog;
148 bool m_url_clipboard, m_url_localfile, m_url_globalfile;
149 fontselector_action m_fontAction;
150 void doAction(ActionTypes a, QKeyEvent* e);
78 151
79 public: 152 public:
80 QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 153 QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
81 ~QTReaderApp(); 154 ~QTReaderApp();
155
156 void handlekey(QKeyEvent* e);
157 void hideEvent(QHideEvent*)
158 {
159 suspend();
160 }
161
82 void suspend(); 162 void suspend();
83 void openFile( const QString & ); 163 void openFile( const QString & );
84 164
@@ -90,27 +170,40 @@ class QTReaderApp : public QMainWindow
90 CAnnoEdit* m_annoWin; 170 CAnnoEdit* m_annoWin;
91 Bkmk* m_anno; 171 Bkmk* m_anno;
92// void resizeEvent(QResizeEvent* e); 172// void resizeEvent(QResizeEvent* e);
93 void keyPressEvent(QKeyEvent* e);
94 void closeEvent( QCloseEvent *e ); 173 void closeEvent( QCloseEvent *e );
95 void readbkmks(); 174 void readbkmks();
96 void do_mono(const QString&); 175 void do_mono(const QString&);
97 void do_jump(const QString&); 176 void do_jump(const QString&);
98 void do_overlap(const QString&);
99 void do_settarget(const QString&); 177 void do_settarget(const QString&);
100 int EncNameToInt(const QString&); 178#ifdef _SCROLLPIPE
179 //void do_setpipetarget(const QString&);
180#endif
181 void do_saveconfig(const QString&, bool);
182 bool readconfig(const QString&, bool);
183 bool PopulateConfig(const char*);
101 ActionTypes ActNameToInt(const QString&); 184 ActionTypes ActNameToInt(const QString&);
102 bool m_doAnnotation; 185 bool m_doAnnotation;
103 bool m_doDictionary; 186 bool m_doDictionary;
104 bool m_doClipboard; 187 bool m_doClipboard;
105 bool m_fullscreen; 188 bool m_fullscreen;
106 189 bool m_loadedconfig;
107 public: 190 public:
108 void saveprefs(); 191 void saveprefs();
192public slots:
193 void setDocument(const QString&);
109private slots: 194private slots:
195#ifdef _SCRIPT
196// void RunScript();
197#endif
198 void SaveConfig();
199 void LoadConfig();
200 void TidyConfig();
201 void ExportLinks();
110 void zoomin(); 202 void zoomin();
111 void zoomout(); 203 void zoomout();
204 void chooseencoding();
112 void setfullscreen(bool sfs); 205 void setfullscreen(bool sfs);
113 void setcontinuous(bool sfs); 206// void setcontinuous(bool sfs);
114 void setTwoTouch(bool _b); 207 void setTwoTouch(bool _b);
115 void restoreFocus(); 208 void restoreFocus();
116 void OnAnnotation(bool _b) 209 void OnAnnotation(bool _b)
@@ -126,20 +219,24 @@ private slots:
126 m_doClipboard = _b; 219 m_doClipboard = _b;
127 } 220 }
128 void OnWordSelected(const QString&, size_t, const QString&); 221 void OnWordSelected(const QString&, size_t, const QString&);
129 void showgraphic(QPixmap&); 222 void OnURLSelected(const QString& href);
223 void showgraphic(QImage&);
130 void addAnno(const QString&, const QString&, size_t); 224 void addAnno(const QString&, const QString&, size_t);
131 void addAnno(const QString&, const QString&); 225 void addAnno(const QString&, const QString&);
132 void addanno(); 226 void addanno();
133 void showAnnotation(); 227 void showAnnotation();
228 void do_setencoding(int i);
134 void do_setfont(const QString&); 229 void do_setfont(const QString&);
135 void encodingSelected(QAction*);
136 void buttonActionSelected(QAction*); 230 void buttonActionSelected(QAction*);
137 void msgHandler(const QCString&, const QByteArray&); 231 //void msgHandler(const QCString&, const QByteArray&);
138 void monospace(bool); 232 void monospace(bool);
139 void jump(); 233 void jump();
140 void setoverlap();
141 void settarget(); 234 void settarget();
142 void setspacing(); 235#ifdef _SCROLLPIPE
236 //void setpipetarget();
237 //void setpause(bool);
238#endif
239 //void setspacing();
143 void setfont(); 240 void setfont();
144 void clearBkmkList(); 241 void clearBkmkList();
145 void listBkmkFiles(); 242 void listBkmkFiles();
@@ -148,13 +245,14 @@ private slots:
148 void addbkmk(); 245 void addbkmk();
149 void savebkmks(); 246 void savebkmks();
150 //void importFiles(); 247 //void importFiles();
248 void showprefs();
249 void showtoolbarprefs();
151 void infoClose(); 250 void infoClose();
152 // void oldFile(); 251 // void oldFile();
153 void showinfo(); 252 void showinfo();
154 void setDocument(const QString&);
155 253
156 void indentplus(); 254// void indentplus();
157 void indentminus(); 255// void indentminus();
158 256
159 void fileOpen(); 257 void fileOpen();
160 void fileClose(); 258 void fileClose();
@@ -162,6 +260,9 @@ private slots:
162 void editCopy(); 260 void editCopy();
163 void editFind(); 261 void editFind();
164 262
263 void gotoStart();
264 void gotoEnd();
265
165 void pageup(); 266 void pageup();
166 void pagedn(); 267 void pagedn();
167 268
@@ -178,23 +279,25 @@ private slots:
178 279
179 void showEditTools(); 280 void showEditTools();
180 281
181 void stripcr(bool); 282// void stripcr(bool);
182 void onespace(bool); 283// void setfulljust(bool);
284// void onespace(bool);
183#ifdef REPALM 285#ifdef REPALM
184// void repalm(bool); 286// void repalm(bool);
185#endif 287#endif
186 void peanut(bool _b); 288// void peanut(bool _b);
187 void remap(bool); 289// void remap(bool);
188 void embolden(bool); 290// void embolden(bool);
189 void autofmt(bool); 291// void autofmt(bool);
190 void textfmt(bool); 292// void textfmt(bool);
191 void striphtml(bool); 293// void striphtml(bool);
192 void dehyphen(bool); 294// void dehyphen(bool);
193 void unindent(bool); 295// void depluck(bool);
194 void repara(bool); 296// void dejpluck(bool);
195 void dblspce(bool); 297// void unindent(bool);
298// void repara(bool);
299// void dblspce(bool);
196 void pagemode(bool); 300 void pagemode(bool);
197 void navkeys(bool);
198 // void gotobkmk(const QString& bm); 301 // void gotobkmk(const QString& bm);
199 void gotobkmk(int); 302 void gotobkmk(int);
200 void cancelbkmk(); 303 void cancelbkmk();
@@ -203,9 +306,38 @@ private slots:
203 void do_autogen(); 306 void do_autogen();
204 void do_regaction(); 307 void do_regaction();
205 void OnRedraw(); 308 void OnRedraw();
206 void OnActionPressed();
207 309
208 private: 310 private:
311 void writeUrl(const QString& file, const QString& href);
312 QAction *m_preferences_action, *m_open_action, *m_close_action;
313 QAction *m_info_action, *m_touch_action, *m_find_action, *m_start_action;
314 QAction *m_end_action, *m_jump_action, *m_pageline_action;
315 QAction *m_pageup_action, *m_pagedn_action, *m_back_action;
316 QAction *m_home_action, *m_forward_action, *m_zoomin_action;
317 QAction *m_zoomout_action, *m_setfont_action, *m_mark_action;
318 QAction *m_annotate_action, *m_goto_action, *m_delete_action;
319 QAction *m_autogen_action, *m_clear_action, *m_save_action;
320 QAction *m_tidy_action, *m_startBlock_action, *m_endBlock_action;
321 QAction *m_setenc_action, *m_setmono_action, *m_saveconfig_action;
322 QAction *m_loadconfig_action, *m_toolbarprefs_action, *m_tidyconfig_action;
323 QAction *m_exportlinks_action;
324 void addtoolbars(Config* config);
325 ToolbarPolicy m_tbpol, m_tbpolsave;
326 ToolBarDock m_tbposition;
327 bool m_tbmove, m_tbmovesave;
328 QToolBar* filebar();
329 QToolBar* viewbar();
330 QToolBar* navbar();
331 QToolBar* markbar();
332 void hidetoolbars();
333 void addfilebar(Config* _config, const QString& key, QAction* a);
334 void addviewbar(Config* _config, const QString& key, QAction* a);
335 void addnavbar(Config* _config, const QString& key, QAction* a);
336 void addmarkbar(Config* _config, const QString& key, QAction* a);
337 bool checkbar(Config* _config, const QString& key);
338#ifdef _SCRIPT
339 void SaveScript(const char* sname);
340#endif
209/* 341/*
210 void setstate(unsigned char* _sd, unsigned short _sdlen); 342 void setstate(unsigned char* _sd, unsigned short _sdlen);
211 void getstate(unsigned char*& data, unsigned short& len); 343 void getstate(unsigned char*& data, unsigned short& len);
@@ -216,7 +348,7 @@ private slots:
216 void updatefileinfo(); 348 void updatefileinfo();
217 bool openfrombkmk(Bkmk*); 349 bool openfrombkmk(Bkmk*);
218 QString m_targetapp, m_targetmsg; 350 QString m_targetapp, m_targetmsg;
219 void listbkmk(CList<Bkmk>*, const QString& _lab = QString::null); 351 bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null);
220 QString usefilebrowser(); 352 QString usefilebrowser();
221 void do_regedit(); 353 void do_regedit();
222 void colorChanged( const QColor &c ); 354 void colorChanged( const QColor &c );
@@ -230,13 +362,14 @@ private slots:
230 362
231 QAction* m_scrollButton; 363 QAction* m_scrollButton;
232 364
233 QAction* m_EncodingAction[MAX_ENCODING];
234
235 QAction* m_buttonAction[MAX_ACTIONS]; 365 QAction* m_buttonAction[MAX_ACTIONS];
236 366
237 CBkmkSelector* bkmkselector; 367 CBkmkSelector* bkmkselector;
238 368
239 ActionTypes m_spaceTarget; 369 ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget,
370 m_upTarget, m_downTarget;
371 bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll;
372 bool m_bcloseDisabled, m_disableesckey;
240 size_t searchStart; 373 size_t searchStart;
241#ifdef __ISEARCH 374#ifdef __ISEARCH
242 QStack<searchrecord>* searchStack; 375 QStack<searchrecord>* searchStack;
@@ -247,8 +380,13 @@ private slots:
247 QWidgetStack *editorStack; 380 QWidgetStack *editorStack;
248 QTReader* reader; 381 QTReader* reader;
249 QComboBox* m_fontSelector; 382 QComboBox* m_fontSelector;
250// QPEToolBar /* *menu,*/ *editBar; 383// QPEToolBar /* *menu,*/ *fileBar;
251 QToolBar /* *menu,*/ *editBar; 384 QToolBar *menubar, *fileBar, *navBar, *viewBar, *markBar;
385#ifdef USEQPE
386 QPEMenuBar *mb;
387#else
388 QMenuBar *mb;
389#endif
252 QFloatBar *searchBar, *regBar/*, *m_fontBar*/; 390 QFloatBar *searchBar, *regBar/*, *m_fontBar*/;
253 QToolBar /* *searchBar, *regBar,*/ *m_fontBar; 391 QToolBar /* *searchBar, *regBar,*/ *m_fontBar;
254 QLineEdit *searchEdit, *regEdit; 392 QLineEdit *searchEdit, *regEdit;
@@ -261,8 +399,8 @@ private slots:
261 /* 399 /*
262 void resizeEvent( QResizeEvent * r) 400 void resizeEvent( QResizeEvent * r)
263 { 401 {
264 qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height()); 402// qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height());
265 qDebug("resize:(%u,%u)", r->size().width(), r->size().height()); 403// qDebug("resize:(%u,%u)", r->size().width(), r->size().height());
266 // bgroup->move( width()-bgroup->width(), 0 ); 404 // bgroup->move( width()-bgroup->width(), 0 );
267 } 405 }
268 */ 406 */
@@ -272,20 +410,33 @@ private slots:
272 GraphicWin* m_graphicwin; 410 GraphicWin* m_graphicwin;
273 QProgressBar* pbar; 411 QProgressBar* pbar;
274 bool m_fBkmksChanged; 412 bool m_fBkmksChanged;
275 int m_nRegAction; 413// int m_nRegAction;
414 regedit_type m_nRegAction;
415 bkmk_action m_nBkmkAction;
276 QString m_autogenstr; 416 QString m_autogenstr;
277 bool m_dontSave; 417 bool m_dontSave;
278}; 418};
279 419
280const int cAutoGen = 0; 420//const int cAutoGen = 0;
281const int cAddBkmk = 1; 421//const int cAddBkmk = 1;
282const int cDelBkmk = 2; 422//const int cDelBkmk = 2;
283const int cGotoBkmk = 3; 423//const int cGotoBkmk = 3;
284const int cRmBkmkFile = 4; 424//const int cRmBkmkFile = 4;
285const int cJump = 5; 425//const int cJump = 5;
286const int cMonoSpace = 6; 426//const int cMonoSpace = 6;
287const int cOverlap = 7; 427//const int cOverlap = 7;
288const int cSetTarget = 8; 428//const int cSetTarget = 8;
289const int cOpenFile = 9; 429//const int cOpenFile = 9;
430//const int cSetPipeTarget = 10;
431//const int cSetConfigName = 11;
432//const int cMargin = 12;
433//const int cExtraSpace = 14;
434//const int cExtraLead = 15;
435//const int cGfxSize = 16;
436//const int cChooseFont = 2;
437//const int cChooseEncoding = 1;
290 438
291#endif 439#endif
440
441
442
diff --git a/noncore/apps/opie-reader/StateData.h b/noncore/apps/opie-reader/StateData.h
index 0cb0f07..e3be778 100644
--- a/noncore/apps/opie-reader/StateData.h
+++ b/noncore/apps/opie-reader/StateData.h
@@ -9,6 +9,7 @@ struct statedata
9 bool bstriphtml/*:1*/; 9 bool bstriphtml/*:1*/;
10 bool bpeanut/*:1*/; 10 bool bpeanut/*:1*/;
11 bool bdehyphen/*:1*/; 11 bool bdehyphen/*:1*/;
12 bool bdepluck/*:1*/;
12 bool bonespace/*:1*/; 13 bool bonespace/*:1*/;
13 bool bunindent/*:1*/; 14 bool bunindent/*:1*/;
14 bool brepara/*:1*/; 15 bool brepara/*:1*/;
diff --git a/noncore/apps/opie-reader/StyleConsts.cpp b/noncore/apps/opie-reader/StyleConsts.cpp
index e111dbd..9fb56b7 100644
--- a/noncore/apps/opie-reader/StyleConsts.cpp
+++ b/noncore/apps/opie-reader/StyleConsts.cpp
@@ -1,12 +1,12 @@
1 1
2#include <qpixmap.h> 2#include <qimage.h>
3#include "StyleConsts.h" 3#include "StyleConsts.h"
4 4
5GraphicLink::~GraphicLink() { delete graphic; } 5GraphicLink::~GraphicLink() { delete graphic; }
6 6
7pmstore::~pmstore() 7pmstore::~pmstore()
8{ 8{
9// qDebug("Deleting image"); 9//// qDebug("Deleting image");
10 delete graphic; 10 delete graphic;
11} 11}
12 12
@@ -21,11 +21,6 @@ CStyle::~CStyle()
21 } 21 }
22} 22}
23 23
24CStyle::CStyle(CStyle& rhs) : graphic(NULL)
25{
26 *this = rhs;
27}
28
29CStyle::CStyle(const CStyle& rhs) : graphic(NULL) 24CStyle::CStyle(const CStyle& rhs) : graphic(NULL)
30{ 25{
31 *this = rhs; 26 *this = rhs;
@@ -85,7 +80,7 @@ void CStyle::unset()
85 } 80 }
86} 81}
87 82
88void CStyle::setPicture(QPixmap* _g, bool il, unsigned long tgt) 83void CStyle::setPicture(bool canScale, QImage* _g, bool il, unsigned long tgt)
89{ 84{
90 if (graphic != NULL) 85 if (graphic != NULL)
91 { 86 {
@@ -95,5 +90,5 @@ void CStyle::setPicture(QPixmap* _g, bool il, unsigned long tgt)
95 } 90 }
96 graphic = NULL; 91 graphic = NULL;
97 } 92 }
98 if (_g != NULL) graphic = new pmstore(_g, il, tgt); 93 if (_g != NULL) graphic = new pmstore(canScale, _g, il, tgt);
99} 94}
diff --git a/noncore/apps/opie-reader/StyleConsts.h b/noncore/apps/opie-reader/StyleConsts.h
index 9701d19..29d7501 100644
--- a/noncore/apps/opie-reader/StyleConsts.h
+++ b/noncore/apps/opie-reader/StyleConsts.h
@@ -3,17 +3,19 @@
3 3
4typedef unsigned short StyleType; 4typedef unsigned short StyleType;
5 5
6#include <stdlib.h> 6#ifdef _WINDOWS
7#include <string.h> 7#include <string.h>
8#endif
9#include <stdlib.h>
8#include <qglobal.h> 10#include <qglobal.h>
9class QPixmap; 11class QImage;
10 12
11struct GraphicLink 13struct GraphicLink
12{ 14{
13 QPixmap* graphic; 15 QImage* graphic;
14 bool isLink; 16 bool isLink;
15 unsigned long link; 17 unsigned long link;
16 GraphicLink(QPixmap* p, bool isLnk, unsigned long tgt) : 18 GraphicLink(QImage* p, bool isLnk, unsigned long tgt) :
17 graphic(p), isLink(isLnk), link(tgt) {} 19 graphic(p), isLink(isLnk), link(tgt) {}
18 ~GraphicLink(); 20 ~GraphicLink();
19}; 21};
@@ -21,8 +23,9 @@ struct GraphicLink
21struct pmstore 23struct pmstore
22{ 24{
23 unsigned int count; 25 unsigned int count;
26 bool m_isScaleable;
24 GraphicLink* graphic; 27 GraphicLink* graphic;
25 pmstore(QPixmap* p, bool isLnk, unsigned long tgt) : count(1) 28 pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale)
26 { 29 {
27 graphic = new GraphicLink(p, isLnk, tgt); 30 graphic = new GraphicLink(p, isLnk, tgt);
28 } 31 }
@@ -51,6 +54,8 @@ class CBasicStyle
51 bool m_strikethru; 54 bool m_strikethru;
52 bool m_monospaced; 55 bool m_monospaced;
53 unsigned char m_leftmargin, m_rightmargin; 56 unsigned char m_leftmargin, m_rightmargin;
57 signed char m_extraspace;
58 signed char m_voffset;
54 CBasicStyle() 59 CBasicStyle()
55 { 60 {
56 unset(); 61 unset();
@@ -73,6 +78,8 @@ class CBasicStyle
73 m_leftmargin = 0; 78 m_leftmargin = 0;
74 m_rightmargin = 0; 79 m_rightmargin = 0;
75 m_monospaced = false; 80 m_monospaced = false;
81 m_extraspace = 0;
82 m_voffset = 0;
76 } 83 }
77}; 84};
78 85
@@ -81,6 +88,10 @@ class CStyle
81 CBasicStyle sty; 88 CBasicStyle sty;
82 pmstore* graphic; 89 pmstore* graphic;
83 public: 90 public:
91 signed char getVOffset() { return sty.m_voffset; }
92 void setVOffset(signed char sp) { sty.m_voffset = sp; }
93 signed char getExtraSpace() { return sty.m_extraspace; }
94 void setExtraSpace(signed char sp) { sty.m_extraspace = sp; }
84 bool getPictureLink() 95 bool getPictureLink()
85 { 96 {
86 return (graphic != NULL && graphic->graphic->isLink); 97 return (graphic != NULL && graphic->graphic->isLink);
@@ -104,16 +115,17 @@ class CStyle
104 } 115 }
105 CStyle() : graphic(NULL) {} 116 CStyle() : graphic(NULL) {}
106 ~CStyle(); 117 ~CStyle();
107 CStyle(CStyle&); 118// CStyle(CStyle&);
108 CStyle(const CStyle&); 119 CStyle(const CStyle&);
109 CStyle& operator=(const CStyle&); 120 CStyle& operator=(const CStyle&);
110 void unset(); 121 void unset();
111 bool isPicture() { return (graphic != NULL); } 122 bool isPicture() { return (graphic != NULL); }
123 bool canScale() { return graphic->m_isScaleable; }
112 void clearPicture(); 124 void clearPicture();
113 void setPicture(QPixmap* _g, bool il=false, unsigned long tgt=0); 125 void setPicture(bool canScale, QImage* _g, bool il=false, unsigned long tgt=0);
114 QPixmap* getPicture() 126 QImage* getPicture()
115 { 127 {
116 QPixmap* pm = ((graphic != NULL) ? graphic->graphic->graphic : NULL); 128 QImage* pm = ((graphic != NULL) ? graphic->graphic->graphic : NULL);
117 return pm; 129 return pm;
118 } 130 }
119 void setUnderline() { sty.m_underline = true; } 131 void setUnderline() { sty.m_underline = true; }
@@ -157,7 +169,7 @@ class CStyle
157 { 169 {
158 sty.m_fontsize = _fs; 170 sty.m_fontsize = _fs;
159 } 171 }
160 int getFontSize() 172 int getFontSize() const
161 { 173 {
162 return sty.m_fontsize; 174 return sty.m_fontsize;
163 } 175 }
diff --git a/noncore/apps/opie-reader/ZText.h b/noncore/apps/opie-reader/ZText.h
index 22d3733..ab81a5e 100644
--- a/noncore/apps/opie-reader/ZText.h
+++ b/noncore/apps/opie-reader/ZText.h
@@ -1,25 +1,28 @@
1#ifndef __Text_h 1#ifndef __Text_h
2#define __Text_h 2#define __Text_h
3#include <stdio.h> 3#include <stdio.h>
4#include "zlib/zlib.h" 4#include <zlib.h>
5#include <sys/stat.h> 5#include <sys/stat.h>
6 6#include "useqpe.h"
7#include "CExpander.h" 7#include "CExpander.h"
8 8
9class Text: public CExpander { 9class Text: public CExpander {
10 gzFile file; 10 gzFile file;
11 unsigned long fsize; 11 unsigned long fsize;
12public: 12public:
13 virtual void suspend() 13 void suspend()
14 { 14 {
15#ifdef USEQPE
15 bSuspended = true; 16 bSuspended = true;
16 suspos = gztell(file); 17 suspos = gztell(file);
17 gzclose(file); 18 gzclose(file);
18 file = NULL; 19 file = NULL;
19 sustime = time(NULL); 20 sustime = time(NULL);
21#endif
20 } 22 }
21 virtual void unsuspend() 23 void unsuspend()
22 { 24 {
25#ifdef USEQPE
23 if (bSuspended) 26 if (bSuspended)
24 { 27 {
25 bSuspended = false; 28 bSuspended = false;
@@ -37,14 +40,15 @@ public:
37 exit(0); 40 exit(0);
38 } 41 }
39 suspos = gzseek(file, suspos, SEEK_SET); 42 suspos = gzseek(file, suspos, SEEK_SET);
40 } 43 }
44#endif
41 } 45 }
42 Text() : file(NULL) {}; 46 Text() : file(NULL) {};
43 virtual ~Text() 47 virtual ~Text()
44 { 48 {
45 if (file != NULL) gzclose(file); 49 if (file != NULL) gzclose(file);
46 } 50 }
47 virtual int OpenFile(const char *src) 51 int OpenFile(const char *src)
48 { 52 {
49 if (file != NULL) gzclose(file); 53 if (file != NULL) gzclose(file);
50 struct stat _stat; 54 struct stat _stat;
@@ -52,15 +56,28 @@ public:
52 fsize = _stat.st_size; 56 fsize = _stat.st_size;
53 return ((file = gzopen(src,"rb")) == NULL); 57 return ((file = gzopen(src,"rb")) == NULL);
54 } 58 }
55 virtual int getch() { return gzgetc(file); } 59 int getch() { return gzgetc(file); }
56 virtual unsigned int locate() { return gztell(file); } 60 unsigned int locate() { return gztell(file); }
57 virtual void locate(unsigned int n) { gzseek(file,n,SEEK_SET); } 61 void locate(unsigned int n) { gzseek(file,n,SEEK_SET); }
58 virtual bool hasrandomaccess() { return true; } 62 bool hasrandomaccess() { return true; }
59 virtual void sizes(unsigned long& _file, unsigned long& _text) 63 void sizes(unsigned long& _file, unsigned long& _text)
60 { 64 {
61 _text = _file = fsize; 65 _text = _file = fsize;
66 FILE* f = fopen(fname, "rb");
67 if (f != NULL)
68 {
69 unsigned char mn[2];
70 fread(mn, 1, 2, f);
71 if ((mn[0] == 31) && (mn[1] == 139))
72 {
73 int tmp = sizeof(_text);
74 fseek(f,-tmp,SEEK_END);
75 fread(&_text, sizeof(_text), 1, f);
76 }
77 fclose(f);
78 }
62 } 79 }
63 virtual MarkupType PreferredMarkup() 80 MarkupType PreferredMarkup()
64 { 81 {
65 return cTEXT; 82 return cTEXT;
66 } 83 }
diff --git a/noncore/apps/opie-reader/fileBrowser.cpp b/noncore/apps/opie-reader/fileBrowser.cpp
index 21c970b..9cd371d 100644
--- a/noncore/apps/opie-reader/fileBrowser.cpp
+++ b/noncore/apps/opie-reader/fileBrowser.cpp
@@ -10,19 +10,40 @@ Extensive modification by Tim Wentford to allow it to work in rotated mode
10#include "fileBrowser.h" 10#include "fileBrowser.h"
11 11
12#include "QtrListView.h" 12#include "QtrListView.h"
13#include <qlineedit.h>
13#include <qpushbutton.h> 14#include <qpushbutton.h>
14#include <qfile.h> 15#include <qfile.h>
15#include <qmessagebox.h> 16#include <qmessagebox.h>
17#ifndef _WINDOWS
16#include <unistd.h> 18#include <unistd.h>
19#endif
17#include <qlayout.h> 20#include <qlayout.h>
21#ifdef _WINDOWS
22#include <direct.h>
23#endif
18 24
19fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) 25#include "opie.h"
20 : QDialog( parent, name, modal, fl ), filterspec(QDir::All) 26
27fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath )
28 : QDialog( parent, name, true,
29 fl/* | WStyle_Customize | WStyle_Tool*/),
30 filterspec(QDir::All)
21{ 31{
22// showMaximized(); 32// showMaximized();
23 if ( !name ) 33 if ( !name )
24 setName( "fileBrowser" ); 34 setName( "fileBrowser" );
25 if (parent != NULL) resize( parent->width(), parent->height() ); 35/*
36 if (parent != NULL)
37 {
38#ifdef OPIE
39 move(0,0);
40 resize( parent->width(), parent->height() );
41#else
42 setGeometry(parent->x(), parent->y(), parent->width(), parent->height() );
43#endif
44 }
45*/
46// showFullScreen();
26 setCaption(tr( "Browse for file" ) ); 47 setCaption(tr( "Browse for file" ) );
27 filterStr=filter; 48 filterStr=filter;
28 49
@@ -66,11 +87,25 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
66 hgrid->addWidget(buttonShowHidden); 87 hgrid->addWidget(buttonShowHidden);
67 hgrid->addWidget(buttonOk); 88 hgrid->addWidget(buttonOk);
68 grid->addWidget(ListView,1); 89 grid->addWidget(ListView,1);
90 if (allownew)
91 {
92 m_filename = new QLineEdit(this);
93 grid->addWidget(m_filename);
94 connect( m_filename, SIGNAL( returnPressed() ), this, SLOT( onReturn() ));
95 }
96 else
97 {
98 m_filename = NULL;
99 }
69 100
70 if (QFileInfo(iPath).exists()) 101 if (QFileInfo(iPath).exists())
71 { 102 {
72 currentDir.setPath(iPath); 103 currentDir.setPath(iPath);
104#ifdef _WINDOWS
105 _chdir(iPath.latin1());
106#else
73 chdir(iPath.latin1()); 107 chdir(iPath.latin1());
108#endif
74 } 109 }
75 else 110 else
76 { 111 {
@@ -79,6 +114,8 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
79 } 114 }
80 115
81 populateList(); 116 populateList();
117
118 if (modal) showMaximized();
82} 119}
83 120
84void fileBrowser::resizeEvent(QResizeEvent* e) 121void fileBrowser::resizeEvent(QResizeEvent* e)
@@ -95,7 +132,7 @@ fileBrowser::~fileBrowser()
95void fileBrowser::populateList() 132void fileBrowser::populateList()
96{ 133{
97 ListView->clear(); 134 ListView->clear();
98//qDebug(currentDir.canonicalPath()); 135////qDebug(currentDir.canonicalPath());
99// currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); 136// currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks );
100 currentDir.setFilter( filterspec ); 137 currentDir.setFilter( filterspec );
101 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 138 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
@@ -119,7 +156,7 @@ void fileBrowser::populateList()
119 } 156 }
120 else 157 else
121 { 158 {
122// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 159//// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
123 } 160 }
124 new QListViewItem( ListView,fileL,fileS ); 161 new QListViewItem( ListView,fileL,fileS );
125 } 162 }
@@ -132,7 +169,7 @@ void fileBrowser::populateList()
132 169
133void fileBrowser::upDir() 170void fileBrowser::upDir()
134{ 171{
135// qDebug(currentDir.canonicalPath()); 172//// qDebug(currentDir.canonicalPath());
136} 173}
137 174
138void fileBrowser::listClicked(QListViewItem *selectedItem) 175void fileBrowser::listClicked(QListViewItem *selectedItem)
@@ -140,7 +177,7 @@ void fileBrowser::listClicked(QListViewItem *selectedItem)
140 if (selectedItem == NULL) return; 177 if (selectedItem == NULL) return;
141 QString strItem=selectedItem->text(0); 178 QString strItem=selectedItem->text(0);
142 179
143// qDebug("%s", (const char*)strItem); 180//// qDebug("%s", (const char*)strItem);
144 181
145 182
146 QString strSize=selectedItem->text(1); 183 QString strSize=selectedItem->text(1);
@@ -161,7 +198,18 @@ void fileBrowser::listClicked(QListViewItem *selectedItem)
161 populateList(); 198 populateList();
162 } 199 }
163 } else 200 } else
201 {
202 QListViewItem *selectedItem = ListView->selectedItem();
203 if (selectedItem == NULL)
204 {
205 filename = "";
206 }
207 else
208 {
209 filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+selectedItem->text(0));
210 }
164 OnOK(); 211 OnOK();
212 }
165 chdir(strItem.latin1()); 213 chdir(strItem.latin1());
166// 214//
167 215
@@ -172,16 +220,13 @@ void fileBrowser::listDoubleClicked(QListViewItem *selectedItem)
172{ 220{
173} 221}
174 222
175void fileBrowser::OnOK() { 223QString fileBrowser::getCurrentFile()
224{
225 return filename;
226}
176 227
177 QListViewItemIterator it1( ListView); 228void fileBrowser::OnOK()
178 for ( ; it1.current(); ++it1 ) { 229{
179 if ( it1.current()->isSelected() ) {
180 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0));
181 // qDebug("selected filename is "+selectedFileName);
182 fileList.append( selectedFileName );
183 }
184 }
185 accept(); 230 accept();
186} 231}
187 232
@@ -205,3 +250,17 @@ void fileBrowser::setHidden(bool _hidden)
205 filterspec = QDir::All; 250 filterspec = QDir::All;
206 populateList(); 251 populateList();
207} 252}
253
254void fileBrowser::onReturn()
255{
256 QListViewItem *selectedItem = ListView->selectedItem();
257 if (selectedItem == NULL)
258 {
259 filename = m_filename->text();
260 }
261 else
262 {
263 filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+m_filename->text());
264 }
265 OnOK();
266}
diff --git a/noncore/apps/opie-reader/fileBrowser.h b/noncore/apps/opie-reader/fileBrowser.h
index 5521383..a5274f8 100644
--- a/noncore/apps/opie-reader/fileBrowser.h
+++ b/noncore/apps/opie-reader/fileBrowser.h
@@ -29,6 +29,7 @@ class QGridLayout;
29class QtrListView; 29class QtrListView;
30class QListViewItem; 30class QListViewItem;
31class QPushButton; 31class QPushButton;
32class QLineEdit;
32 33
33class fileBrowser : public QDialog 34class fileBrowser : public QDialog
34{ 35{
@@ -36,7 +37,7 @@ class fileBrowser : public QDialog
36 37
37public: 38public:
38 void populateList(); 39 void populateList();
39 fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0, const QString iPath=0); 40 fileBrowser( bool allownew, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0, const QString iPath=0);
40 ~fileBrowser(); 41 ~fileBrowser();
41 42
42 QPushButton* buttonOk; 43 QPushButton* buttonOk;
@@ -47,7 +48,8 @@ public:
47 QString selectedFileName, filterStr; 48 QString selectedFileName, filterStr;
48 QDir currentDir; 49 QDir currentDir;
49 QFile file; 50 QFile file;
50 QStringList fileList; 51 QString getCurrentFile();
52 QLineEdit* m_filename;
51 int filterspec; 53 int filterspec;
52// QDir::FilterSpec filterspec; 54// QDir::FilterSpec filterspec;
53 55
@@ -55,7 +57,7 @@ public:
55public slots: 57public slots:
56 58
57private: 59private:
58 60 QString filename;
59private slots: 61private slots:
60 void upDir(); 62 void upDir();
61 void listDoubleClicked(QListViewItem *); 63 void listDoubleClicked(QListViewItem *);
@@ -63,6 +65,7 @@ private slots:
63 void OnRoot(); 65 void OnRoot();
64 void OnCancel(); 66 void OnCancel();
65 void setHidden(bool); 67 void setHidden(bool);
68 void onReturn();
66 69
67protected slots: 70protected slots:
68 71
diff --git a/noncore/apps/opie-reader/infowin.cpp b/noncore/apps/opie-reader/infowin.cpp
index 459b648..c52a1f0 100644
--- a/noncore/apps/opie-reader/infowin.cpp
+++ b/noncore/apps/opie-reader/infowin.cpp
@@ -1,9 +1,9 @@
1#include "name.h"
2#include "infowin.h" 1#include "infowin.h"
3#include "version.h" 2#include "version.h"
4#include <stdio.h> 3#include <stdio.h>
4#include "names.h"
5 5
6infowin::infowin( QWidget *parent, const char *name, WFlags f ) : 6infowin::infowin( QWidget *parent, const char *name, WFlags f) :
7 QWidget(parent, name, f) 7 QWidget(parent, name, f)
8{ 8{
9 grid = new QGridLayout(this, 6, 2); 9 grid = new QGridLayout(this, 6, 2);
diff --git a/noncore/apps/opie-reader/main.cpp b/noncore/apps/opie-reader/main.cpp
index 2440037..3e1f5e7 100644
--- a/noncore/apps/opie-reader/main.cpp
+++ b/noncore/apps/opie-reader/main.cpp
@@ -1,10 +1,17 @@
1#include "useqpe.h"
2#ifdef USEQPE
1#include <qpe/qpeapplication.h> 3#include <qpe/qpeapplication.h>
4#else
5#include <qapplication.h>
6#endif
2#include "QTReaderApp.h" 7#include "QTReaderApp.h"
3 8
4#include "signal.h" 9#include "signal.h"
5#include "stdio.h" 10#include "stdio.h"
6#include "time.h" 11#include "time.h"
7 12
13
14#ifdef USEQPE
8QTReaderApp* app = NULL; 15QTReaderApp* app = NULL;
9 16
10void handler(int signum) 17void handler(int signum)
@@ -16,18 +23,27 @@ void handler(int signum)
16 } 23 }
17 signal(signum, handler); 24 signal(signum, handler);
18} 25}
26#endif
19 27
20int main( int argc, char ** argv ) 28int main( int argc, char ** argv )
21{ 29{
22 signal(SIGCONT, handler);
23 30
31#ifdef USEQPE
32 signal(SIGCONT, handler);
24 QPEApplication a( argc, argv ); 33 QPEApplication a( argc, argv );
25
26 QTReaderApp m; 34 QTReaderApp m;
27
28 a.showMainDocumentWidget( &m ); 35 a.showMainDocumentWidget( &m );
29
30 app = &m; 36 app = &m;
37#else
38 QApplication a( argc, argv );
39 QTReaderApp m;
40 a.setMainWidget( &m );
41 if (argc > 1)
42 {
43 m.setDocument(argv[1]);
44 }
45#endif
46
31 47
32 return a.exec(); 48 return a.exec();
33} 49}
diff --git a/noncore/apps/opie-reader/opie-reader.pro b/noncore/apps/opie-reader/opie-reader.pro
index b8915b3..871fa45 100644
--- a/noncore/apps/opie-reader/opie-reader.pro
+++ b/noncore/apps/opie-reader/opie-reader.pro
@@ -7,14 +7,18 @@ HEADERS = Aportis.h \
7 CBuffer.h \ 7 CBuffer.h \
8 CDrawBuffer.h \ 8 CDrawBuffer.h \
9 CEncoding.h \ 9 CEncoding.h \
10 CEncoding_tables.h \
10 CExpander.h \ 11 CExpander.h \
11 CFilter.h \ 12 CFilter.h \
13 CloseDialog.h \
12 Filedata.h \ 14 Filedata.h \
15 FixedFont.h \
13 FontControl.h \ 16 FontControl.h \
14 GraphicWin.h \ 17 GraphicWin.h \
15 Markups.h \ 18 Markups.h \
16 Navigation.h \ 19 Navigation.h \
17 Palm2QImage.h \ 20 Palm2QImage.h \
21 Prefs.h \
18 QFloatBar.h \ 22 QFloatBar.h \
19 QTReader.h \ 23 QTReader.h \
20 QTReaderApp.h \ 24 QTReaderApp.h \
@@ -22,20 +26,27 @@ HEADERS = Aportis.h \
22 Queue.h \ 26 Queue.h \
23 StateData.h \ 27 StateData.h \
24 StyleConsts.h \ 28 StyleConsts.h \
29 ToolbarPrefs.h \
30 URLDialog.h \
25 ZText.h \ 31 ZText.h \
26 arith.h \ 32 arith.h \
27 cbkmkselector.h \ 33 cbkmkselector.h \
28 config.h \ 34 config.h \
29 fileBrowser.h \ 35 fileBrowser.h \
30 infowin.h \ 36 infowin.h \
37 linktype.h \
31 my_list.h \ 38 my_list.h \
32 name.h \ 39 name.h \
40 names.h \
33 opie.h \ 41 opie.h \
34 pdb.h \ 42 pdb.h \
35 plucker.h \ 43 plucker.h \
44 plucker_base.h \
36 ppm.h \ 45 ppm.h \
37 ppm_expander.h \ 46 ppm_expander.h \
38 ustring.h \ 47 ustring.h \
48 usenef.h \
49 useqpe.h \
39 utypes.h \ 50 utypes.h \
40 version.h \ 51 version.h \
41 ztxt.h 52 ztxt.h
@@ -46,22 +57,29 @@ SOURCES = Aportis.cpp \
46 CBuffer.cpp \ 57 CBuffer.cpp \
47 CDrawBuffer.cpp \ 58 CDrawBuffer.cpp \
48 CEncoding.cpp \ 59 CEncoding.cpp \
60 CEncoding_tables.cpp \
49 CFilter.cpp \ 61 CFilter.cpp \
62 CloseDialog.cpp \
50 FontControl.cpp \ 63 FontControl.cpp \
51 Navigation.cpp \ 64 Navigation.cpp \
52 Palm2QImage.cpp \ 65 Palm2QImage.cpp \
66 Prefs.cpp \
53 QTReader.cpp \ 67 QTReader.cpp \
54 QTReaderApp.cpp \ 68 QTReaderApp.cpp \
55 QtrListView.cpp \ 69 QtrListView.cpp \
56 StyleConsts.cpp \ 70 StyleConsts.cpp \
71 ToolbarPrefs.cpp \
72 URLDialog.cpp \
57 arith_d.cpp \ 73 arith_d.cpp \
58 fileBrowser.cpp \ 74 fileBrowser.cpp \
59 infowin.cpp \ 75 infowin.cpp \
60 main.cpp \ 76 main.cpp \
61 pdb.cpp \ 77 pdb.cpp \
62 plucker.cpp \ 78 plucker.cpp \
79 plucker_base.cpp \
63 ppm.cpp \ 80 ppm.cpp \
64 ppm_expander.cpp \ 81 ppm_expander.cpp \
82 version.cpp \
65 ztxt.cpp 83 ztxt.cpp
66 84
67 INTERFACES= 85 INTERFACES=
diff --git a/noncore/apps/opie-reader/pdb.cpp b/noncore/apps/opie-reader/pdb.cpp
index 3054424..dca67ff 100644
--- a/noncore/apps/opie-reader/pdb.cpp
+++ b/noncore/apps/opie-reader/pdb.cpp
@@ -1,7 +1,7 @@
1#include "pdb.h" 1#include "pdb.h"
2#include <sys/types.h> 2#ifdef _WINDOWS
3#include <sys/stat.h> 3#include <winsock2.h>
4#include <unistd.h> 4#endif
5 5
6size_t Cpdb::recordpos(int n) 6size_t Cpdb::recordpos(int n)
7{ 7{
@@ -49,13 +49,10 @@ bool Cpdb::openfile(const char *src)
49 49
50 // just holds the first few chars of the file 50 // just holds the first few chars of the file
51 //char buf[0x100]; 51 //char buf[0x100];
52 struct stat buf; 52 fseek(fin,0,SEEK_END);
53 stat(src, &buf); 53 file_length = ftell(fin);
54 file_length = buf.st_size;
55// fseek(fin,0,SEEK_END);
56// file_length = ftell(fin);
57 54
58// fseek(fin,0,SEEK_SET); 55 fseek(fin,0,SEEK_SET);
59 56
60 fread(&head, 1, sizeof(head), fin); 57 fread(&head, 1, sizeof(head), fin);
61 58
diff --git a/noncore/apps/opie-reader/pdb.h b/noncore/apps/opie-reader/pdb.h
index 41649bd..eac3ae6 100644
--- a/noncore/apps/opie-reader/pdb.h
+++ b/noncore/apps/opie-reader/pdb.h
@@ -11,7 +11,9 @@
11#ifndef __PDB_H__ 11#ifndef __PDB_H__
12#define __PDB_H__ 12#define __PDB_H__
13 13
14#ifndef _WINDOWS
14#include <netinet/in.h> 15#include <netinet/in.h>
16#endif
15#include <stdio.h> 17#include <stdio.h>
16 18
17/* Normal Palm typedefs */ 19/* Normal Palm typedefs */
diff --git a/noncore/apps/opie-reader/plucker.cpp b/noncore/apps/opie-reader/plucker.cpp
index eb039de..e49e35f 100644
--- a/noncore/apps/opie-reader/plucker.cpp
+++ b/noncore/apps/opie-reader/plucker.cpp
@@ -1,212 +1,58 @@
1#include "useqpe.h"
1#include <stdio.h> 2#include <stdio.h>
2#include <string.h> 3#include <string.h>
3#include <qmessagebox.h> 4#include <qmessagebox.h>
4#include <qpixmap.h> 5#include <qpixmap.h>
6#ifdef USEQPE
5#include <qpe/qcopenvelope_qws.h> 7#include <qpe/qcopenvelope_qws.h>
8#endif
6#ifdef LOCALPICTURES 9#ifdef LOCALPICTURES
7#include <qscrollview.h> 10#include <qscrollview.h>
8#endif 11#endif
12#ifdef USEQPE
9#include <qpe/global.h> 13#include <qpe/global.h>
10#include <qclipboard.h>
11#include <qpe/qpeapplication.h> 14#include <qpe/qpeapplication.h>
15#else
16#include <qapplication.h>
17#endif
18#include <qclipboard.h>
12 19
13#include "plucker.h" 20#include "plucker.h"
14#include "Aportis.h" 21#include "Aportis.h"
15#include "Palm2QImage.h" 22#include "Palm2QImage.h"
16#include "name.h"
17 23
18CPlucker::CPlucker() :
19#ifdef LOCALPICTURES
20 m_viewer(NULL),
21 m_picture(NULL),
22#endif
23 expandedtextbuffer(NULL),
24 compressedtextbuffer(NULL),
25 urls(NULL)
26 { /*printf("constructing:%x\n",fin);*/ }
27 24
28 25struct CPlucker_dataRecord
29void CPlucker::Expand(UInt16 reclen, UInt8 type, UInt8* buffer, UInt16 buffersize)
30{ 26{
31 if (type%2 == 0) 27 UInt16 uid;
32 { 28 UInt16 nParagraphs;
33 fread(buffer, reclen, sizeof(char), fin); 29 UInt16 size;
34 } 30 UInt8 type;
35 else 31 UInt8 reserved;
36 { 32};
37 fread(compressedtextbuffer, reclen, sizeof(char), fin);
38 switch (ntohs(hdr0.version))
39 {
40 case 2:
41 UnZip(reclen, buffer, buffersize);
42 break;
43 case 1:
44 UnDoc(reclen, buffer, buffersize);
45 break;
46 }
47 }
48}
49 33
50int CPlucker::OpenFile(const char *src) 34int CPlucker::HeaderSize()
51{ 35{
52 m_lastBreak = 0; 36 return sizeof(CPlucker_dataRecord);
53 if (!Cpdb::openfile(src))
54 {
55 return -1;
56 }
57
58//printf("Okay %u\n", 4);
59
60 if (memcmp(&head.type, "DataPlkr", 8) != 0) return -1;
61
62// qDebug("Cool - this IS plucker");
63
64 EOPPhase = 0;
65 gotorecordnumber(0);
66 fread(&hdr0, 1, sizeof(hdr0), fin);
67//printf("Okay %u\n", 5);
68 buffersize = 32*1024;
69 compressedtextbuffer = new UInt8[buffersize];
70 expandedtextbuffer = new UInt8[buffersize];
71
72 qDebug("Total number of records:%u", ntohs(head.recordList.numRecords));
73
74 unsigned int nrecs = ntohs(hdr0.nRecords);
75 qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs);
76 UInt16 homerecid = 1;
77 UInt16 urlid = 0;
78 bool urlsfound = false;
79 for (unsigned int i = 0; i < nrecs; i++)
80 {
81 UInt16 id, name;
82 fread(&name, 1, sizeof(name), fin);
83 fread(&id, 1, sizeof(id), fin);
84 qDebug("N:%d, I:%d", ntohs(name), ntohs(id));
85 if (ntohs(name) == 0) homerecid = ntohs(id);
86 if (ntohs(name) == 2)
87 {
88 urlsfound = true;
89 urlid = id;
90 qDebug("Found url index:%d", ntohs(urlid));
91 }
92 //qDebug("%x", id);
93 }
94
95 textlength = 0;
96 for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
97 {
98 CPlucker_dataRecord thisHdr;
99 gotorecordnumber(recptr);
100 fread(&thisHdr, 1, sizeof(thisHdr), fin);
101 if (ntohs(thisHdr.uid) == homerecid)
102 {
103 m_homepos = textlength;
104 qDebug("Home pos found after %u records", recptr);
105 break;
106 }
107 if (thisHdr.type < 2) textlength += ntohs(thisHdr.size);
108 }
109 textlength = 0;
110
111 if (urlsfound)
112 {
113 unsigned short recptr = finduid(ntohs(urlid));
114 if (recptr != 0)
115 {
116 CPlucker_dataRecord thisHdr;
117 gotorecordnumber(recptr);
118 fread(&thisHdr, 1, sizeof(thisHdr), fin);
119 fread(&urlid, 1, sizeof(urlid), fin);
120 fread(&urlid, 1, sizeof(urlid), fin);
121 qDebug("urls are in %d", ntohs(urlid));
122 recptr = finduid(ntohs(urlid));
123 if (recptr != 0)
124 {
125 gotorecordnumber(recptr);
126 fread(&thisHdr, 1, sizeof(thisHdr), fin);
127 qDebug("Found urls:%x",thisHdr.type);
128 UInt16 reclen = recordlength(recptr) - sizeof(thisHdr);
129 gotorecordnumber(recptr);
130 fread(&thisHdr, 1, sizeof(thisHdr), fin);
131 urlsize = ntohs(thisHdr.size);
132 urls = new char[urlsize];
133 Expand(reclen, thisHdr.type, (UInt8*)urls, urlsize);
134 }
135 }
136 }
137/*
138 for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
139 {
140 CPlucker_dataRecord thisHdr;
141 gotorecordnumber(recptr);
142 fread(&thisHdr, 1, sizeof(thisHdr), fin);
143 if (thisHdr.uid == urlid)
144 {
145 qDebug("Found urls:%x",thisHdr.type);
146 UInt16 reclen = recordlength(recptr) - sizeof(thisHdr);
147 gotorecordnumber(recptr);
148 fread(&thisHdr, 1, sizeof(thisHdr), fin);
149 urlsize = ntohs(thisHdr.size);
150 urls = new char[urlsize];
151 Expand(reclen, thisHdr.type, (UInt8*)urls, urlsize);
152 break;
153 }
154 }
155*/
156 home();
157#ifdef LOCALPICTURES
158 if (m_viewer == NULL)
159 {
160 m_viewer = new QScrollView(NULL);
161 m_picture = new QWidget(m_viewer->viewport());
162 m_viewer->addChild(m_picture);
163 }
164#endif
165 return 0;
166
167} 37}
168 38
169void CPlucker::sizes(unsigned long& _file, unsigned long& _text) 39void CPlucker::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved)
170{ 40{
171 qDebug("Sizes called:%u",textlength); 41 CPlucker_dataRecord thishdr;
172 _file = file_length; 42 fread(&thishdr, 1, HeaderSize(), fin);
173 if (textlength == 0) 43 uid = ntohs(thishdr.uid);
174 { 44 nParagraphs = ntohs(thishdr.nParagraphs);
175 for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) 45 size = ntohs(thishdr.size);
176 { 46 type = thishdr.type;
177 CPlucker_dataRecord thisHdr; 47 reserved = thishdr.reserved;
178 gotorecordnumber(recptr);
179 fread(&thisHdr, 1, sizeof(thisHdr), fin);
180 if (thisHdr.type < 2) textlength += ntohs(thisHdr.size);
181 }
182 }
183 _text = textlength;
184//ntohl(hdr0.size);
185} 48}
186 49
50CPlucker::CPlucker()
51 { /*printf("constructing:%x\n",fin);*/ }
187 52
188char* CPlucker::geturl(UInt16 i) 53bool CPlucker::CorrectDecoder()
189{
190 if (urls == NULL) return NULL;
191 char* ptr = urls;
192 int rn = 1;
193 while (ptr - urls < urlsize)
194 {
195 if (rn == i) return ptr;
196 ptr += strlen(ptr)+1;
197 rn++;
198 }
199 return NULL;
200}
201
202CPlucker::~CPlucker()
203{ 54{
204 if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; 55 return (memcmp(&head.type, "DataPlkr", 8) == 0);
205 if (compressedtextbuffer != NULL) delete [] compressedtextbuffer;
206 if (urls != NULL) delete [] urls;
207#ifdef LOCALPICTURES
208 if (m_viewer != NULL) delete m_viewer;
209#endif
210} 56}
211 57
212int CPlucker::bgetch() 58int CPlucker::bgetch()
@@ -216,9 +62,19 @@ int CPlucker::bgetch()
216 { 62 {
217 if (!m_continuous) return EOF; 63 if (!m_continuous) return EOF;
218 if (bufferrec >= ntohs(head.recordList.numRecords) - 1) return EOF; 64 if (bufferrec >= ntohs(head.recordList.numRecords) - 1) return EOF;
219 //qDebug("Passing through %u", currentpos); 65 ////qDebug("Passing through %u", currentpos);
220 if (!expand(bufferrec+1)) return EOF; 66 if (!expand(bufferrec+1)) return EOF;
221 mystyle.unset(); 67 mystyle.unset();
68 if (m_ParaOffsets[m_nextParaIndex] == 0)
69 {
70 while (m_ParaOffsets[m_nextParaIndex+1] == 0)
71 {
72 // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7);
73 m_nextParaIndex++;
74 }
75 }
76 mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2);
77 //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7);
222 ch = 10; 78 ch = 10;
223 EOPPhase = 4; 79 EOPPhase = 4;
224 } 80 }
@@ -228,6 +84,7 @@ int CPlucker::bgetch()
228 { 84 {
229 UInt16 attr = m_ParaAttrs[m_nextParaIndex]; 85 UInt16 attr = m_ParaAttrs[m_nextParaIndex];
230 m_nextParaIndex++; 86 m_nextParaIndex++;
87 // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7);
231 if (m_nextParaIndex == m_nParas) 88 if (m_nextParaIndex == m_nParas)
232 { 89 {
233 m_nextPara = -1; 90 m_nextPara = -1;
@@ -238,6 +95,8 @@ int CPlucker::bgetch()
238 } 95 }
239 } 96 }
240 mystyle.unset(); 97 mystyle.unset();
98 mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2);
99 //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7);
241 if (m_lastBreak == locate()) 100 if (m_lastBreak == locate())
242 { 101 {
243 currentpos++; 102 currentpos++;
@@ -256,18 +115,17 @@ int CPlucker::bgetch()
256 return ch; 115 return ch;
257} 116}
258 117
259int CPlucker::getch() 118tchar CPlucker::getch(bool fast)
260{ 119{
261 mystyle.clearPicture(); 120 mystyle.clearPicture();
262 121
263
264 if (EOPPhase > 0) 122 if (EOPPhase > 0)
265 { 123 {
266 int ch = 10; 124 int ch = 10;
267 switch (EOPPhase) 125 switch (EOPPhase)
268 { 126 {
269 case 4: 127 case 4:
270 mystyle.setPicture(hRule(100,5)); 128 if (!fast) mystyle.setPicture(false, hRule(100,5));
271 mystyle.setCentreJustify(); 129 mystyle.setCentreJustify();
272 ch = '#'; 130 ch = '#';
273 break; 131 break;
@@ -287,955 +145,12 @@ int CPlucker::getch()
287 return ch; 145 return ch;
288 } 146 }
289 147
290 148 return getch_base(fast);
291 int ch = bgetch();
292 while (ch == 0)
293 {
294 ch = bgetch();
295 //qDebug("Function:%x", ch);
296 switch (ch)
297 {
298 case 0x38:
299 // qDebug("Break:%u", locate());
300 if (m_lastBreak == locate())
301 {
302 ch = bgetch();
303 }
304 else
305 {
306 ch = 10;
307 }
308 m_lastBreak = locate();
309 break;
310 case 0x0a:
311 case 0x0c:
312 {
313 unsigned long ln = 0;
314 int skip = ch & 7;
315 for (int i = 0; i < 2; i++)
316 {
317 int ch = bgetch();
318 ln = (ln << 8) + ch;
319 // qDebug("ch:%d, ln:%u", ch, ln);
320 }
321 if (skip == 2)
322 {
323 ln <<= 16;
324 }
325 else
326 {
327 for (int i = 0; i < 2; i++)
328 {
329 int ch = bgetch();
330 ln = (ln << 8) + ch;
331 // qDebug("ch:%d, ln:%u", ch, ln);
332 }
333 }
334 // qDebug("ln:%u", ln);
335 mystyle.setLink(true);
336 mystyle.setData(ln);
337 // mystyle.setColour(255, 0, 0);
338 bool hasseen = false;
339 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++)
340 {
341 if (*it == ln)
342 {
343 hasseen = true;
344 break;
345 }
346 }
347 if (hasseen)
348 {
349 mystyle.setStrikethru();
350 }
351 else
352 {
353 mystyle.setUnderline();
354 }
355 ch = bgetch();
356 }
357 break;
358 case 0x08:
359 ch = bgetch();
360 // mystyle.setColour(0, 0, 0);
361 mystyle.unsetUnderline();
362 mystyle.unsetStrikethru();
363 mystyle.setLink(false);
364 mystyle.setData(0);
365 break;
366 case 0x40:
367 mystyle.setItalic();
368 ch = bgetch();
369 break;
370 case 0x48:
371 mystyle.unsetItalic();
372 ch = bgetch();
373 break;
374 case 0x11:
375 {
376 ch = bgetch();
377 // qDebug("Font:%d",ch);
378 switch (ch)
379 {
380 case 0:
381 mystyle.unsetMono();
382 mystyle.unsetBold();
383 mystyle.setFontSize(0);
384 break;
385 case 1:
386 mystyle.unsetMono();
387 mystyle.setBold();
388 mystyle.setFontSize(3);
389 break;
390 case 2:
391 mystyle.unsetMono();
392 mystyle.setBold();
393 mystyle.setFontSize(2);
394 break;
395 case 3:
396 mystyle.unsetMono();
397 mystyle.setBold();
398 // mystyle.unsetBold();
399 mystyle.setFontSize(1);
400 break;
401 case 4:
402 mystyle.unsetMono();
403 mystyle.setBold();
404 // mystyle.unsetBold();
405 mystyle.setFontSize(0);
406 break;
407 case 5:
408 mystyle.unsetMono();
409 mystyle.setBold();
410 mystyle.setFontSize(0);
411 break;
412 case 6:
413 mystyle.unsetMono();
414 mystyle.setBold();
415 mystyle.setFontSize(0);
416 break;
417 case 7:
418 mystyle.unsetMono();
419 mystyle.setBold();
420 mystyle.setFontSize(0);
421 break;
422 case 8: // should be fixed width
423 qDebug("Trying fixed width");
424 mystyle.unsetBold();
425 mystyle.setFontSize(0);
426 mystyle.setMono();
427 break;
428 default:
429 mystyle.unsetBold();
430 mystyle.unsetMono();
431 mystyle.setFontSize(0);
432 break;
433 }
434 ch = bgetch();
435 }
436 break;
437 case 0x29:
438 ch = bgetch();
439 switch (ch)
440 {
441 case 0:
442 mystyle.setLeftJustify();
443 // qDebug("left");
444 break;
445 case 1:
446 mystyle.setRightJustify();
447 // qDebug("right");
448 break;
449 case 2:
450 mystyle.setCentreJustify();
451 // qDebug("centre");
452 break;
453 case 3:
454 mystyle.setFullJustify();
455 // qDebug("full");
456 break;
457
458 }
459 ch = bgetch();
460 break;
461 case 0x53:
462 {
463 int r = bgetch();
464 int g = bgetch();
465 int b = bgetch();
466 mystyle.setColour(r,g,b);
467 ch = bgetch();
468 }
469 break;
470 case 0x1a:
471 case 0x5c:
472 {
473 bool hasalternate = (ch == 0x5c);
474 UInt16 ir = bgetch();
475 ir = (ir << 8) + bgetch();
476 if (hasalternate)
477 {
478 qDebug("Alternate image:%x", ir);
479 UInt16 ir2 = bgetch();
480 ir2 = (ir2 << 8) + bgetch();
481 mystyle.setPicture(expandimg(ir2, true), true, ir);
482#ifdef LOCALPICTURES
483 UInt32 ln = ir;
484 ln <<= 16;
485 mystyle.setLink(true);
486 mystyle.setData(ln);
487#endif
488 }
489 else
490 {
491 mystyle.setPicture(expandimg(ir));
492 }
493 if (mystyle.getLink()) qDebug("Picture link!");
494 ch = '#';
495 }
496 // ch = bgetch();
497 break;
498 case 0x33:
499 {
500 UInt8 h = bgetch();
501 UInt8 wc = bgetch();
502 UInt8 pc = bgetch();
503 UInt16 w = wc;
504 // qDebug("h,w,pc [%u, %u, %u]", h, w, pc);
505 if (w == 0)
506 {
507 w = (240*(unsigned long)pc)/100;
508 }
509 if (w == 0) w = 320;
510 mystyle.setPicture(hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue()));
511 // if (mystyle.getLink()) qDebug("hRule link!");
512 ch = '#';
513 }
514 break;
515 case 0x60:
516 mystyle.setUnderline();
517 ch = bgetch();
518 break;
519 case 0x68:
520 mystyle.unsetUnderline();
521 ch = bgetch();
522 break;
523 case 0x22:
524 ch = bgetch();
525 mystyle.setLeftMargin(ch);
526 // qDebug("Left margin:%d", ch);
527 ch = bgetch();
528 mystyle.setRightMargin(ch);
529 // qDebug("Right margin:%d", ch);
530 ch = bgetch();
531 break;
532 case 0x70:
533 mystyle.setStrikethru();
534 ch = bgetch();
535 break;
536 case 0x78:
537 mystyle.unsetStrikethru();
538 ch = bgetch();
539 break;
540 case 0x83:
541 case 0x85:
542 default:
543 qDebug("Function:%x NOT IMPLEMENTED", ch);
544 {
545 int skip = ch & 7;
546 for (int i = 0; i < skip; i++)
547 {
548 ch = bgetch();
549 // qDebug("Arg %d, %d", i, ch);
550 }
551 ch = bgetch();
552 }
553 }
554 }
555
556 if (m_lastIsBreak && !mystyle.isMono())
557 {
558 while (ch == ' ')
559 {
560 ch = getch();
561 }
562 }
563
564 m_lastIsBreak = (ch == 10);
565
566 return ch;
567}
568
569void CPlucker::getch(int& ch, CStyle& sty)
570{
571 ch = getch();
572 sty = mystyle;
573}
574
575unsigned int CPlucker::locate()
576{
577 return currentpos;
578/*
579 UInt16 thisrec = 1;
580 unsigned long locpos = 0;
581 gotorecordnumber(thisrec);
582 CPlucker_dataRecord thisHdr;
583 while (thisrec < bufferrec)
584 {
585 fread(&thisHdr, 1, sizeof(thisHdr), fin);
586 if (thisHdr.type < 2) locpos += ntohs(thisHdr.size);
587 thisrec++;
588 gotorecordnumber(thisrec);
589 }
590 return locpos+bufferpos;
591*/
592}
593
594void CPlucker::locate(unsigned int n)
595{
596 UInt16 thisrec = 0;
597 unsigned long locpos = 0;
598 unsigned long bs = 0;
599 CPlucker_dataRecord thisHdr;
600 do
601 {
602 thisrec++;
603 locpos += bs;
604 gotorecordnumber(thisrec);
605 fread(&thisHdr, 1, sizeof(thisHdr), fin);
606 if (thisHdr.type < 2)
607 {
608 bs = ntohs(thisHdr.size);
609 }
610 else
611 {
612 bs = 0;
613 }
614 } while (locpos + bs <= n);
615 currentpos = locpos;
616 expand(thisrec);
617#ifdef _FAST
618 while (currentpos < n && bufferpos < buffercontent) bgetch();
619#else
620 while (currentpos < n && bufferpos < buffercontent) getch();
621#endif
622} 149}
623 150
624bool CPlucker::hyperlink(unsigned int n) 151QImage* CPlucker::imagefromdata(UInt8* imgbuffer, UInt32 imgsize)
625{ 152{
626 visited.push_front(n);
627 UInt16 tuid = (n >> 16);
628 n &= 0xffff;
629// qDebug("Hyper:<%u,%u>", tuid, n);
630 UInt16 thisrec = 1;
631 currentpos = 0;
632 gotorecordnumber(thisrec);
633 CPlucker_dataRecord thisHdr;
634 while (1)
635 {
636 fread(&thisHdr, 1, sizeof(thisHdr), fin);
637 if (tuid == ntohs(thisHdr.uid)) break;
638 if (thisHdr.type < 2) currentpos += ntohs(thisHdr.size);
639 //qDebug("hyper-cp:%u", currentpos);
640 thisrec++;
641 if (thisrec >= ntohs(head.recordList.numRecords))
642 {
643 if (urls == NULL)
644 {
645 QMessageBox::information(NULL,
646 PROGNAME,
647 QString("No external links\nin this pluck")
648 );
649 }
650 else
651 {
652 char *turl = geturl(tuid);
653 if (turl == NULL)
654 {
655 QMessageBox::information(NULL,
656 PROGNAME,
657 QString("Couldn't find link")
658 );
659 }
660 else
661 {
662 QString wrd(turl);
663 QClipboard* cb = QApplication::clipboard();
664 cb->setText(wrd);
665 if (wrd.length() > 10)
666 {
667 Global::statusMessage(wrd.left(8) + "..");
668 }
669 }
670 }
671 return false;
672 }
673 gotorecordnumber(thisrec);
674 }
675 if (thisHdr.type > 1)
676 {
677 if (thisHdr.type == 4)
678 {
679 QMessageBox::information(NULL,
680 PROGNAME,
681 QString("Mailto links\nnot yet supported (2)"));
682 }
683 else
684 {
685#ifdef LOCALPICTURES
686 if (thisHdr.type > 3)
687 {
688#endif
689 QMessageBox::information(NULL,
690 PROGNAME,
691 QString("External links\nnot yet supported (2)")
692 );
693#ifdef LOCALPICTURES
694 }
695 else
696 {
697 showimg(tuid);
698 }
699#endif
700 }
701 return false;
702 }
703/*
704 if (thisHdr.type == 2 || thisHdr.type == 3)
705 {
706 expandimg(thisrec);
707
708 }
709*/
710 else
711 {
712 expand(thisrec);
713 if (n != 0)
714 {
715 if (n >= m_nParas)
716 {
717 QMessageBox::information(NULL,
718 PROGNAME,
719 QString("Error in link\nPara # too big")
720 );
721 return false;
722 }
723 unsigned int noff = 0;
724 for (int i = 0; i < n; i++) noff += m_ParaOffsets[i];
725 n = noff;
726 }
727 if (n > ntohs(thisHdr.size))
728 {
729 QMessageBox::information(NULL,
730 PROGNAME,
731 QString("Error in link\nOffset too big")
732 );
733 return false;
734 }
735 qDebug("Hyper:<%u,%u>", tuid, n);
736 while (bufferpos < n && bufferpos < buffercontent) getch();
737 }
738 return true;
739}
740/*
741bool CPlucker::hyperlink(unsigned int n)
742{
743 visited.push_front(n);
744 UInt16 tuid = (n >> 16);
745 n &= 0xffff;
746// qDebug("Hyper:<%u,%u>", tuid, n);
747 UInt16 thisrec = finduid(tuid);
748 if (thisrec == 0)
749 {
750 if (urls == NULL)
751 {
752 QMessageBox::information(NULL,
753 PROGNAME,
754 QString("No external links\nin this pluck")
755 );
756 }
757 else
758 {
759 char *turl = geturl(tuid);
760 if (turl == NULL)
761 {
762 QMessageBox::information(NULL,
763 PROGNAME,
764 QString("Couldn't find link")
765 );
766 }
767 else
768 {
769 QString wrd(turl);
770 QClipboard* cb = QApplication::clipboard();
771 cb->setText(wrd);
772 if (wrd.length() > 10)
773 {
774 Global::statusMessage(wrd.left(8) + "..");
775 }
776 }
777 }
778 return false;
779 }
780 else
781 {
782 currentpos = 0;
783 gotorecordnumber(thisrec);
784 CPlucker_dataRecord thisHdr;
785 fread(&thisHdr, 1, sizeof(thisHdr), fin);
786
787 if (thisHdr.type > 1)
788 {
789 if (thisHdr.type == 4)
790 {
791 QMessageBox::information(NULL,
792 PROGNAME,
793 QString("Mailto links\nnot yet supported (2)"));
794 }
795 else
796 {
797#ifdef LOCALPICTURES
798 if (thisHdr.type > 3)
799 {
800#endif
801 QMessageBox::information(NULL,
802 PROGNAME,
803 QString("External links\nnot yet supported (2)")
804 );
805#ifdef LOCALPICTURES
806 }
807 else
808 {
809 showimg(tuid);
810 }
811#endif
812 }
813 return false;
814 }
815// if (thisHdr.type == 2 || thisHdr.type == 3)
816// {
817// expandimg(thisrec);
818// }
819 else
820 {
821 expand(thisrec);
822 if (n != 0)
823 {
824 if (n >= m_nParas)
825 {
826 QMessageBox::information(NULL,
827 PROGNAME,
828 QString("Error in link\nPara # too big")
829 );
830 return false;
831 }
832 unsigned int noff = 0;
833 for (int i = 0; i < n; i++) noff += m_ParaOffsets[i];
834 n = noff;
835 }
836 if (n > ntohs(thisHdr.size))
837 {
838 QMessageBox::information(NULL,
839 PROGNAME,
840 QString("Error in link\nOffset too big")
841 );
842 return false;
843 }
844 qDebug("Hyper:<%u,%u>", tuid, n);
845 while (bufferpos < n && bufferpos < buffercontent) getch();
846 }
847 return true;
848 }
849}
850*/
851bool CPlucker::expand(int thisrec)
852{
853 mystyle.unset();
854 size_t reclen = recordlength(thisrec);
855 gotorecordnumber(thisrec);
856 CPlucker_dataRecord thisHdr;
857 while (1)
858 {
859 fread(&thisHdr, 1, sizeof(thisHdr), fin);
860 //qDebug("This (%d) type is %d, uid is %u", thisrec, thisHdr.type, ntohs(thisHdr.uid));
861 if (thisHdr.type < 2) break;
862 qDebug("Skipping paragraph of type %d", thisHdr.type);
863 if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false;
864 reclen = recordlength(thisrec);
865 gotorecordnumber(thisrec);
866 }
867 m_nParas = ntohs(thisHdr.nParagraphs);
868 //qDebug("It has %u paragraphs and is %u bytes", ntohs(thisHdr.nParagraphs), ntohs(thisHdr.size));
869 uid = ntohs(thisHdr.uid);
870 for (int i = 0; i < m_nParas; i++)
871 {
872 UInt16 ubytes, attrs;
873 fread(&ubytes, 1, sizeof(ubytes), fin);
874 fread(&attrs, 1, sizeof(attrs), fin);
875 m_ParaOffsets[i] = ntohs(ubytes);
876 m_ParaAttrs[i] = ntohs(attrs);
877 //qDebug("Bytes %u, Attr %x", ntohs(ubytes), attrs);
878 }
879 if (m_nParas > 0)
880 {
881 m_nextPara = m_ParaOffsets[0];
882 //qDebug("First offset = %u", m_nextPara);
883 m_nextParaIndex = 0;
884 }
885 else
886 {
887 m_nextPara = -1;
888 }
889
890 reclen -= sizeof(thisHdr)+4*m_nParas;
891
892 buffercontent = ntohs(thisHdr.size);
893
894 Expand(reclen, thisHdr.type, expandedtextbuffer, buffercontent);
895 bufferpos = 0;
896 bufferrec = thisrec;
897// qDebug("BC:%u, HS:%u", buffercontent, ntohs(thisHdr.size));
898 return true;
899}
900
901void CPlucker::UnZip(size_t reclen, UInt8* tgtbuffer, UInt16 bsize)
902{
903 z_stream zstream;
904 memset(&zstream,sizeof(zstream),0);
905 zstream.next_in = compressedtextbuffer;
906 zstream.next_out = tgtbuffer;
907 zstream.avail_out = bsize;
908 zstream.avail_in = reclen;
909
910 int keylen = 0;
911
912 zstream.zalloc = Z_NULL;
913 zstream.zfree = Z_NULL;
914 zstream.opaque = Z_NULL;
915
916// printf("Initialising\n");
917
918 inflateInit(&zstream);
919 int err = 0;
920 do {
921 if ( zstream.avail_in == 0 && 0 < keylen ) {
922 zstream.next_in = compressedtextbuffer + keylen;
923 zstream.avail_in = reclen - keylen;
924 keylen = 0;
925 }
926 zstream.next_out = tgtbuffer;
927 zstream.avail_out = bsize;
928
929 err = inflate( &zstream, Z_SYNC_FLUSH );
930
931 //qDebug("err:%d - %u", err, zstream.avail_in);
932
933 } while ( err == Z_OK );
934
935 inflateEnd(&zstream);
936}
937
938void CPlucker::UnDoc(size_t reclen, UInt8* tgtbuffer, UInt16 bsize)
939{
940// UInt16 headerSize;
941 UInt16 docSize;
942 UInt16 i;
943 UInt16 j;
944 UInt16 k;
945
946 UInt8 *inBuf = compressedtextbuffer;
947 UInt8 *outBuf = tgtbuffer;
948
949// headerSize = sizeof( Header ) + record->paragraphs * sizeof( Paragraph );
950 docSize = reclen;
951
952 j = 0;
953 k = 0;
954 while ( j < docSize ) {
955 i = 0;
956 while ( i < bsize && j < docSize ) {
957 UInt16 c;
958
959 c = (UInt16) inBuf[ j++ ];
960 if ( 0 < c && c < 9 ) {
961 while ( 0 < c-- )
962 outBuf[ i++ ] = inBuf[ j++ ];
963 }
964 else if ( c < 0x80 )
965 outBuf[ i++ ] = c;
966 else if ( 0xc0 <= c ) {
967 outBuf[ i++ ] = ' ';
968 outBuf[ i++ ] = c ^ 0x80;
969 }
970 else {
971 Int16 m;
972 Int16 n;
973
974 c <<= 8;
975 c += inBuf[ j++ ];
976
977 m = ( c & 0x3fff ) >> COUNT_BITS;
978 n = c & ( ( 1 << COUNT_BITS ) - 1 );
979 n += 2;
980
981 do {
982 outBuf[ i ] = outBuf[ i - m ];
983 i++;
984 } while ( 0 < n-- );
985 }
986 }
987 k += bsize;
988 }
989}
990
991void CPlucker::home()
992{
993 currentpos = 0;
994 expand(1);
995}
996
997CList<Bkmk>* CPlucker::getbkmklist()
998{
999/*
1000 CPlucker_dataRecord thisHdr;
1001
1002 for (int i = 1; i < ntohs(head.recordList.numRecords); i++)
1003 {
1004 gotorecordnumber(i);
1005 fread(&thisHdr, 1, sizeof(thisHdr), fin);
1006 if (thisHdr.type == 8)
1007 {
1008 UInt16 n;
1009 fread(&n, 1, sizeof(n), fin);
1010 n = ntohs(n);
1011 qDebug("Found %u bookmarks", n);
1012 }
1013 qDebug("Found:%d, %u", i , thisHdr.type);
1014 }
1015*/
1016 return NULL;
1017}
1018
1019QImage* CPlucker::getimg(UInt16 tgt)
1020{
1021// static int imageno;
1022// char* file = "tmp1";
1023// sprintf(file, "image%04u.tbmp", imageno++);
1024// qDebug("Image:%u", tgt);
1025 CPlucker_dataRecord thisHdr;
1026 size_t reclen;
1027 UInt16 thisrec = finduid(tgt);
1028 reclen = recordlength(thisrec);
1029 gotorecordnumber(thisrec);
1030 fread(&thisHdr, 1, sizeof(thisHdr), fin);
1031/*
1032 UInt16 thisrec = 0;
1033 do
1034 {
1035 hthisrec++;
1036 reclen = recordlength(thisrec);
1037 gotorecordnumber(thisrec);
1038 //qDebug("thisrec:%u.%u", ftell(fin),thisrec);
1039 fread(&thisHdr, 1, sizeof(thisHdr), fin);
1040 }
1041 while (ntohs(thisHdr.uid) != tgt);
1042*/
1043 reclen -= sizeof(thisHdr);
1044
1045 UInt16 imgsize = ntohs(thisHdr.size);
1046 UInt8* imgbuffer = new UInt8[imgsize];
1047
1048// qDebug("type:%u", thisHdr.type);
1049 Expand(reclen, thisHdr.type, imgbuffer, imgsize);
1050
1051 QImage* qimage = Palm2QImage(imgbuffer, imgsize); 153 QImage* qimage = Palm2QImage(imgbuffer, imgsize);
1052
1053 delete [] imgbuffer; 154 delete [] imgbuffer;
1054
1055 return qimage; 155 return qimage;
1056} 156}
1057
1058#include <qnamespace.h>
1059
1060QPixmap* CPlucker::expandimg(UInt16 tgt, bool border)
1061{
1062 QImage* qimage = getimg(tgt);
1063 if (qimage == NULL) return NULL;
1064 QPixmap* image = new QPixmap(0,0);
1065 QPixmap* ret;
1066// qDebug("New image");
1067 image->convertFromImage(*qimage);
1068 delete qimage;
1069 if (border)
1070 {
1071 ret = new QPixmap(image->width()+4, image->height()+4);
1072 ret->fill(Qt::red);
1073 bitBlt(ret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP);
1074 delete image;
1075 }
1076 else
1077 {
1078 ret = image;
1079 }
1080 return ret;
1081}
1082
1083#ifdef _BUFFERPICS
1084#include <qmap.h>
1085#endif
1086
1087QPixmap* CPlucker::getPicture(unsigned long tgt)
1088{
1089#ifdef _BUFFERPICS
1090 static QMap<unsigned long, QPixmap> pix;
1091 QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt);
1092 if (t == pix.end())
1093 {
1094 pix[tgt] = *expandimg(tgt);
1095 return &pix[tgt];
1096 }
1097 else
1098 return &(t.data());
1099#else
1100 return expandimg(tgt);
1101#endif
1102}
1103
1104#ifdef LOCALPICTURES
1105#include <unistd.h>
1106#include <qpe/global.h>
1107void CPlucker::showimg(UInt16 tgt)
1108{
1109 qDebug("Crassssssh!");
1110 QPixmap* qimage = expandimg(tgt);
1111 m_picture->setFixedSize(qimage->size());
1112 m_picture->setBackgroundPixmap(*qimage);
1113 delete qimage;
1114 m_viewer->show();
1115
1116/*
1117 char tmp[] = "uqtreader.XXXXXX";
1118 QImage* qimage = getimg(tgt);
1119 QPixmap* image = new QPixmap(0,0);
1120// qDebug("New image");
1121 image->convertFromImage(*qimage);
1122 delete qimage;
1123 char tmpfile[sizeof(tmp)+1];
1124 strcpy(tmpfile,tmp);
1125 int f = mkstemp(tmpfile);
1126 close(f);
1127 qDebug("TMPFILE:%s", tmpfile);
1128 if (image->save(tmpfile,"PNG"))
1129 {
1130 QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)");
1131 e << QString(tmpfile);
1132 }
1133 Global::statusMessage("Opening image");
1134 sleep(5);
1135 delete image;
1136 unlink(tmpfile);
1137*/
1138}
1139
1140#endif
1141
1142void CPlucker::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
1143{
1144 unsigned short sz = 0;
1145 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++)
1146 {
1147 sz++;
1148 }
1149 size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long);
1150 unsigned char* newdata = new unsigned char[newlen];
1151 unsigned char* pdata = newdata;
1152 memcpy(newdata, src, srclen);
1153 newdata += srclen;
1154 memcpy(newdata, &sz, sizeof(sz));
1155 newdata += sizeof(sz);
1156 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++)
1157 {
1158 unsigned long t = *it;
1159 qDebug("[%u]", t);
1160 memcpy(newdata, &t, sizeof(t));
1161 newdata += sizeof(t);
1162 }
1163 m_nav.setSaveData(data, len, pdata, newlen);
1164 delete [] pdata;
1165}
1166
1167void CPlucker::putSaveData(unsigned char*& src, unsigned short& srclen)
1168{
1169 unsigned short sz;
1170 if (srclen >= sizeof(sz))
1171 {
1172 memcpy(&sz, src, sizeof(sz));
1173 src += sizeof(sz);
1174 srclen -= sizeof(sz);
1175 }
1176 for (int i = 0; i < sz; i++)
1177 {
1178 unsigned long t;
1179 if (srclen >= sizeof(t))
1180 {
1181 memcpy(&t, src, sizeof(t));
1182 qDebug("[%u]", t);
1183 visited.push_front(t);
1184 src += sizeof(t);
1185 srclen -= sizeof(t);
1186 }
1187 else
1188 {
1189 QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself");
1190 break;
1191 }
1192 }
1193 m_nav.putSaveData(src, srclen);
1194}
1195
1196unsigned short CPlucker::finduid(unsigned short urlid)
1197{
1198// qDebug("Finding %u", urlid);
1199 unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords);
1200 unsigned short jmid = (jmin+jmax) >> 1;
1201 while (jmax - jmin > 1)
1202 {
1203 CPlucker_dataRecord thisHdr;
1204 gotorecordnumber(jmid);
1205 fread(&thisHdr, 1, sizeof(thisHdr), fin);
1206 unsigned short luid = ntohs(thisHdr.uid);
1207 //qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid);
1208 if (luid == urlid)
1209 {
1210 return jmid;
1211 }
1212 if (luid < urlid)
1213 {
1214 jmin = jmid;
1215 }
1216 else
1217 {
1218 jmax = jmid;
1219 }
1220 jmid = (jmin+jmax) >> 1;
1221 }
1222 CPlucker_dataRecord thisHdr;
1223 gotorecordnumber(jmin);
1224 fread(&thisHdr, 1, sizeof(thisHdr), fin);
1225 unsigned short luid = ntohs(thisHdr.uid);
1226 qDebug("jmin at end:%u,%u", jmin, luid);
1227 if (luid == urlid)
1228 {
1229 return jmin;
1230 }
1231 gotorecordnumber(jmax);
1232 fread(&thisHdr, 1, sizeof(thisHdr), fin);
1233 luid = ntohs(thisHdr.uid);
1234 qDebug("jmax at end:%u,%u", jmax, luid);
1235 if (luid == urlid)
1236 {
1237 return jmax;
1238 }
1239 qDebug("Couldn't find %u", urlid);
1240 return 0; // Not found!
1241}
diff --git a/noncore/apps/opie-reader/plucker.h b/noncore/apps/opie-reader/plucker.h
index 083eac6..6d62195 100644
--- a/noncore/apps/opie-reader/plucker.h
+++ b/noncore/apps/opie-reader/plucker.h
@@ -1,123 +1,36 @@
1#ifndef __plucker_h 1#ifndef __plucker_h
2#define __plucker_h 2#define __plucker_h
3 3
4#include "CExpander.h" 4#include "plucker_base.h"
5#include "zlib/zlib.h"
6#include "ztxt.h"
7#include "pdb.h"
8#include "CBuffer.h"
9#include "Navigation.h"
10#include "my_list.h"
11 5
12#ifdef LOCALPICTURES 6#ifdef LOCALPICTURES
13class QScrollView; 7class QScrollView;
14class QWidget; 8class QWidget;
15#endif 9#endif
16 10
17struct CPlucker_dataRecord 11class CPlucker : public CPlucker_base
18{ 12{
19 UInt16 uid; 13 void start2endSection()
20 UInt16 nParagraphs; 14 {
21 UInt16 size; 15 m_currentstart = currentpos-bufferpos;
22 UInt8 type; 16 m_currentend = m_currentstart+buffercontent;
23 UInt8 reserved; 17 }
24}; 18 void setbuffersize()
25 19 {
26struct CPlucker_record0 20 compressedbuffersize = buffersize = 32*1024;
27{ 21 }
28 UInt16 uid; 22 int HeaderSize();
29 UInt16 version; 23 void GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved);
30 UInt16 nRecords; 24 int bgetch();
31}; 25 tchar getch(bool fast);
26 UInt8 EOPPhase;
32 27
33struct CPluckerbkmk
34{
35 UInt32 offset;
36 tchar title[MAX_BMRK_LENGTH];
37};
38 28
39const UInt32 CPLUCKER_ID = 0x5458547a;
40 29
41class CPlucker : public CExpander, Cpdb 30 bool CorrectDecoder(); // Virtual
42{ 31 void setlink(QString&, const QString&); // Virtual
43 unsigned short finduid(unsigned short); 32 QImage* imagefromdata(UInt8*, UInt32); // virtual
44 char* geturl(UInt16);
45 void Expand(UInt16, UInt8, UInt8*, UInt16);
46 CList<unsigned long> visited;
47 bool m_lastIsBreak;
48#ifdef LOCALPICTURES
49 QScrollView* m_viewer;
50 QWidget* m_picture;
51#endif
52 size_t textlength, m_lastBreak;
53 UInt16 uid;
54 UInt8 EOPPhase;
55 int m_nextPara, m_nextParaIndex;
56 CBufferFace<UInt16> m_ParaOffsets;
57 CBufferFace<UInt16> m_ParaAttrs;
58 UInt16 m_nParas;
59 CStyle mystyle;
60// bool bInit;
61 UInt32 buffersize;
62 UInt32 buffercontent;
63 UInt8* expandedtextbuffer;
64 UInt8* compressedtextbuffer;
65 char* urls;
66 size_t urlsize;
67 size_t bufferpos;
68 UInt16 bufferrec;
69 CPlucker_record0 hdr0;
70 size_t currentpos;
71 bool expand(int);
72 void UnZip(size_t, UInt8*, UInt16);
73 void UnDoc(size_t, UInt8*, UInt16);
74#ifdef LOCALPICTURES
75 void showimg(UInt16 tgt);
76#endif
77 QImage* getimg(UInt16 tgt);
78 QPixmap* expandimg(UInt16 tgt, bool border=false);
79 void home();
80 int bgetch();
81 CNavigation m_nav;
82 public: 33 public:
83 virtual void suspend()
84 {
85 CExpander::suspend(fin);
86 }
87 virtual void unsuspend()
88 {
89 CExpander::unsuspend(fin);
90 }
91 virtual QPixmap* getPicture(unsigned long tgt);
92 virtual void sizes(unsigned long& _file, unsigned long& _text);
93 virtual bool hasrandomaccess() { return true; }
94 virtual ~CPlucker();
95 CPlucker(); 34 CPlucker();
96 virtual int OpenFile(const char *src);
97 virtual int getch();
98 virtual void getch(int&, CStyle&);
99 virtual unsigned int locate();
100 virtual void locate(unsigned int n);
101 virtual CList<Bkmk>* getbkmklist();
102 virtual bool hyperlink(unsigned int n);
103 virtual MarkupType PreferredMarkup()
104 {
105 return cNONE;
106 }
107 void saveposn(size_t posn) { m_nav.saveposn(posn); }
108 bool forward(size_t& loc) { return m_nav.forward(loc); }
109 bool back(size_t& loc) { return m_nav.back(loc); }
110 bool hasnavigation() { return true; }
111 unsigned long startSection()
112 {
113 return currentpos-bufferpos;
114 }
115 unsigned long endSection()
116 {
117 return startSection()+buffercontent;
118 }
119 void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen);
120 void putSaveData(unsigned char*& src, unsigned short& srclen);
121}; 35};
122
123#endif 36#endif
diff --git a/noncore/apps/opie-reader/ppm_expander.h b/noncore/apps/opie-reader/ppm_expander.h
index 4278c82..002de86 100644
--- a/noncore/apps/opie-reader/ppm_expander.h
+++ b/noncore/apps/opie-reader/ppm_expander.h
@@ -1,6 +1,7 @@
1#ifndef __ppm_expander_h 1#ifndef __ppm_expander_h
2#define __ppm_expander_h 2#define __ppm_expander_h
3 3
4#include "useqpe.h"
4#include "CExpander.h" 5#include "CExpander.h"
5#include <sys/stat.h> 6#include <sys/stat.h>
6 7
@@ -26,14 +27,16 @@ class ppm_expander : public CExpander {
26 PPM_ReadBuf* my_read_buf; 27 PPM_ReadBuf* my_read_buf;
27 ppm_worker ppm; 28 ppm_worker ppm;
28public: 29public:
29 virtual void suspend() 30#ifdef USEQPE
31 void suspend()
30 { 32 {
31 CExpander::suspend(my_file_in); 33 CExpander::suspend(my_file_in);
32 } 34 }
33 virtual void unsuspend() 35 void unsuspend()
34 { 36 {
35 CExpander::unsuspend(my_file_in); 37 CExpander::unsuspend(my_file_in);
36 } 38 }
39#endif
37 ppm_expander() : needppmend(false), my_file_in(NULL), my_read_buf(NULL) 40 ppm_expander() : needppmend(false), my_file_in(NULL), my_read_buf(NULL)
38 { 41 {
39 bufsize = 1024; 42 bufsize = 1024;
@@ -41,15 +44,15 @@ public:
41 buf_out = new UCHAR[bufsize]; 44 buf_out = new UCHAR[bufsize];
42 outbytes = 0; 45 outbytes = 0;
43 } 46 }
44 virtual int OpenFile(const char* infile); 47 int OpenFile(const char* infile);
45 virtual int getch(); 48 int getch();
46 int locate(unsigned short block, unsigned int n); 49 int locate(unsigned short block, unsigned int n);
47 virtual ~ppm_expander(); 50 virtual ~ppm_expander();
48 virtual unsigned int locate() { return outbytes; } 51 unsigned int locate() { return outbytes; }
49 virtual void locate(unsigned int n); 52 void locate(unsigned int n);
50 virtual bool hasrandomaccess() { return (numblocks > 1); } 53 bool hasrandomaccess() { return (numblocks > 1); }
51 virtual void sizes(unsigned long& file, unsigned long& text); 54 void sizes(unsigned long& file, unsigned long& text);
52 virtual MarkupType PreferredMarkup() 55 MarkupType PreferredMarkup()
53 { 56 {
54 return cTEXT; 57 return cTEXT;
55 } 58 }
diff --git a/noncore/apps/opie-reader/ustring.h b/noncore/apps/opie-reader/ustring.h
index a3ef8df..95da26b 100644
--- a/noncore/apps/opie-reader/ustring.h
+++ b/noncore/apps/opie-reader/ustring.h
@@ -60,7 +60,17 @@ inline QString toQString(tchar *_p, unsigned int len)
60 unsigned int i = 0; 60 unsigned int i = 0;
61 tchar *p = _p; 61 tchar *p = _p;
62 QString ret; 62 QString ret;
63#ifdef _WINDOWS
64 //ret.fill(' ', len);
65 for (i = 0; i < len; i++)
66 {
67 if (p[i] == 0) break;
68 ret.at((uint)i) = p[i];
69 }
70// while (*p != 0 && i < len) ret.at((uint)i++) = (tchar)(*(p++));
71#else
63 while (*p != 0 && i < len) ret[i++] = *(p++); 72 while (*p != 0 && i < len) ret[i++] = *(p++);
73#endif
64 return ret; 74 return ret;
65} 75}
66 76
diff --git a/noncore/apps/opie-reader/version.h b/noncore/apps/opie-reader/version.h
index 003e9db..85d35a4 100644
--- a/noncore/apps/opie-reader/version.h
+++ b/noncore/apps/opie-reader/version.h
@@ -1,5 +1,9 @@
1#ifndef __VERSION_H
2#define __VERSION_H
1 3
2#define MAJOR 0 4#define MAJOR 0
3#define BKMKTYPE 6 5#define BKMKTYPE 6
4#define MINOR 'a' 6#define MINOR 'j'
5#define RELEASE_TYPE "beta" 7#define RELEASE_TYPE "beta"
8
9#endif
diff --git a/noncore/apps/opie-reader/ztxt.h b/noncore/apps/opie-reader/ztxt.h
index d7cb96a..709a055 100644
--- a/noncore/apps/opie-reader/ztxt.h
+++ b/noncore/apps/opie-reader/ztxt.h
@@ -1,9 +1,14 @@
1#ifndef __ztxt_h 1#ifndef __ztxt_h
2#define __ztxt_h 2#define __ztxt_h
3 3
4#include "useqpe.h"
4#include "CExpander.h" 5#include "CExpander.h"
5#include "zlib/zlib.h" 6#include <zlib.h>
6#include "pdb.h" 7#include "pdb.h"
8#ifdef _WINDOWS
9#include <winsock.h>
10#endif
11
7/* 12/*
8 * Stuff common to both Weasel Reader and makeztxt 13 * Stuff common to both Weasel Reader and makeztxt
9 * 14 *
@@ -75,20 +80,22 @@ class ztxt : public CExpander, Cpdb
75 size_t currentpos; 80 size_t currentpos;
76 void home(); 81 void home();
77public: 82public:
78 virtual void suspend() 83#ifdef USEQPE
84 void suspend()
79 { 85 {
80 CExpander::suspend(fin); 86 CExpander::suspend(fin);
81 } 87 }
82 virtual void unsuspend() 88 void unsuspend()
83 { 89 {
84 CExpander::unsuspend(fin); 90 CExpander::unsuspend(fin);
85 } 91 }
86 virtual void sizes(unsigned long& _file, unsigned long& _text) 92#endif
93 void sizes(unsigned long& _file, unsigned long& _text)
87 { 94 {
88 _file = file_length; 95 _file = file_length;
89 _text = ntohl(hdr0.size); 96 _text = ntohl(hdr0.size);
90 } 97 }
91 virtual bool hasrandomaccess() { return (hdr0.randomAccess != 0); } 98 bool hasrandomaccess() { return (hdr0.randomAccess != 0); }
92 virtual ~ztxt() 99 virtual ~ztxt()
93 { 100 {
94 if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; 101 if (expandedtextbuffer != NULL) delete [] expandedtextbuffer;
@@ -99,12 +106,12 @@ public:
99 } 106 }
100 } 107 }
101 ztxt(); 108 ztxt();
102 virtual int OpenFile(const char *src); 109 int OpenFile(const char *src);
103 virtual int getch(); 110 int getch();
104 virtual unsigned int locate(); 111 unsigned int locate();
105 virtual void locate(unsigned int n); 112 void locate(unsigned int n);
106 virtual CList<Bkmk>* getbkmklist(); 113 CList<Bkmk>* getbkmklist();
107 virtual MarkupType PreferredMarkup() 114 MarkupType PreferredMarkup()
108 { 115 {
109 return cTEXT; 116 return cTEXT;
110 } 117 }