summaryrefslogtreecommitdiff
authorgroucho <groucho>2003-05-07 09:01:39 (UTC)
committer groucho <groucho>2003-05-07 09:01:39 (UTC)
commit118d03d815a7615b9c53363218a7ac45b3f4c514 (patch) (unidiff)
tree356953e2413cddcec0f35bd47bb6439767da7051
parent00894537decf01c5a5cdc565b2740b5e67a2e90f (diff)
downloadopie-118d03d815a7615b9c53363218a7ac45b3f4c514.zip
opie-118d03d815a7615b9c53363218a7ac45b3f4c514.tar.gz
opie-118d03d815a7615b9c53363218a7ac45b3f4c514.tar.bz2
Incorporated TimWs current source tree and make it compile
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Aportis.cpp8
-rw-r--r--noncore/apps/opie-reader/Aportis.h24
-rw-r--r--noncore/apps/opie-reader/Bkmks.cpp8
-rw-r--r--noncore/apps/opie-reader/BuffDoc.cpp122
-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.cpp277
-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.h61
-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.cpp102
-rw-r--r--noncore/apps/opie-reader/Navigation.h2
-rw-r--r--noncore/apps/opie-reader/Palm2QImage.cpp5
-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.cpp622
-rw-r--r--noncore/apps/opie-reader/QTReader.h138
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp2848
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.h257
-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.h39
-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.cpp2
-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.h123
-rw-r--r--noncore/apps/opie-reader/ppm_expander.h21
-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.h29
43 files changed, 3922 insertions, 2503 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
@@ -30,3 +30,3 @@ CList<Bkmk>* Aportis::getbkmklist()
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);
@@ -37,3 +37,3 @@ CList<Bkmk>* Aportis::getbkmklist()
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];
@@ -123,3 +123,3 @@ int Aportis::OpenFile(const char *src)
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)
@@ -184,3 +184,3 @@ int Aportis::OpenFile(const char *src)
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;
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
@@ -6,3 +6,3 @@
6#define __Aportis_h 6#define __Aportis_h
7 7#include "useqpe.h"
8#include "CExpander.h" 8#include "CExpander.h"
@@ -77,3 +77,4 @@ class Aportis : public CExpander, Cpdb {
77public: 77public:
78 virtual void suspend() 78#ifdef USEQPE
79 void suspend()
79 { 80 {
@@ -81,3 +82,3 @@ public:
81 } 82 }
82 virtual void unsuspend() 83 void unsuspend()
83 { 84 {
@@ -85,3 +86,4 @@ public:
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 {
@@ -90,11 +92,11 @@ public:
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 {
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,2 +1 @@
1#include "name.h"
2#include <qmessagebox.h> #include <qmessagebox.h>
@@ -9,2 +8,3 @@
9#include "version.h" 8#include "version.h"
9#include "names.h"
10 10
@@ -221,3 +221,3 @@ CList<Bkmk>* BkmkFile::readall()
221 bl = readall00(read06); 221 bl = readall00(read06);
222 qDebug("Correct version!"); 222 // qDebug("Correct version!");
223 break; 223 break;
@@ -226,6 +226,6 @@ CList<Bkmk>* BkmkFile::readall()
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;
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,2 +1,4 @@
1#include "name.h" 1#include "names.h"
2
3#define NEWLINEBREAK
2 4
@@ -7,15 +9,26 @@
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) 17{
18 linkType bRet = eNone;
19 if (exp != NULL)
20 {
21 bRet = exp->hyperlink(n, wrd);
22 if (bRet == eLink)
11{ 23{
12 bool bRet = false;
13 lastword.empty(); 24 lastword.empty();
14 lastsizes[0] = laststartline = n; 25 lastsizes[0] = laststartline = n;
26#ifdef NEWLINEBREAK
27 lastispara = true;
28#else
15 lastispara = false; 29 lastispara = false;
16 if (exp != NULL) 30#endif
17 {
18 bRet = exp->hyperlink(n);
19 lastsizes[0] = laststartline = exp->locate(); 31 lastsizes[0] = laststartline = exp->locate();
20 } 32 }
33 }
21 return bRet; 34 return bRet;
@@ -25,14 +38,17 @@ void 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;
42#ifdef NEWLINEBREAK
43 lastispara = true;
44#else
29 lastispara = false; 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{
@@ -40,3 +56,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
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;
@@ -62,3 +78,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
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)
@@ -67,5 +83,9 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
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)
@@ -80,3 +100,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
80 { 100 {
81 lastword.empty(); 101 buff->setendpara();
82 lastispara = true; 102 lastispara = true;
@@ -85,2 +105,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
85 } 105 }
106 lastispara = false;
86 buff->addch(ch, cs); 107 buff->addch(ch, cs);
@@ -96,3 +117,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
96 { 117 {
97 lastword.empty(); 118 if (ch == ' ') buff->truncate(len-1);
98 laststartline = exp->locate(); 119 laststartline = exp->locate();
@@ -102,3 +123,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
102 { 123 {
103 for (int i = len-1; i > 0; i--) 124 for (int i = len-2; i > 0; i--)
104 { 125 {
@@ -118,4 +139,19 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
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);
@@ -136,6 +172,6 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
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;
@@ -158,3 +194,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
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();
@@ -233,3 +269,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
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);
@@ -266,5 +302,5 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
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();
@@ -276,4 +312,4 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw)
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 {
@@ -292,4 +328,4 @@ int 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;
@@ -297,3 +333,7 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
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 /*
@@ -318,2 +358,18 @@ int BuffDoc::openfile(QWidget* _parent, const char *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)
@@ -328,3 +384,3 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
328 delete exp; 384 delete exp;
329 qDebug("Trying ppms"); 385 //qDebug("Trying ppms");
330 exp = new ppm_expander; 386 exp = new ppm_expander;
@@ -336,3 +392,3 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
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);
@@ -346,3 +402,3 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
346 } 402 }
347 // qDebug("Doing final open:%x:%x",exp,filt); 403 // //qDebug("Doing final open:%x:%x",exp,filt);
348 404
@@ -350,6 +406,10 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
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;
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
@@ -3,2 +3,3 @@
3 3
4#include "useqpe.h"
4#include "ZText.h" 5#include "ZText.h"
@@ -40,4 +41,9 @@ class BuffDoc
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()
@@ -52,3 +58,3 @@ class BuffDoc
52 lastword.empty(); 58 lastword.empty();
53 // qDebug("Buffdoc created"); 59 // // qDebug("Buffdoc created");
54 } 60 }
@@ -84,3 +90,4 @@ class BuffDoc
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(); }
@@ -91,7 +98,7 @@ class BuffDoc
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); }
@@ -108,2 +115,3 @@ class BuffDoc
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); }
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
@@ -34,2 +34,3 @@ class CAnnoEdit : public QWidget
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);
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
@@ -9,3 +9,3 @@ CBufferBase& CBufferBase::assign(const void* sztmp, size_t ms)
9 } 9 }
10 memcpy(buffer, sztmp, ms*membersize); 10 memcpy(buffer, sztmp, len);
11 return *this; 11 return *this;
@@ -13,6 +13,6 @@ CBufferBase& CBufferBase::assign(const void* sztmp, size_t ms)
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}
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
@@ -5,2 +5,4 @@
5#include <qpixmap.h> 5#include <qpixmap.h>
6#include <qimage.h>
7#include "useqpe.h"
6#include "opie.h" 8#include "opie.h"
@@ -44,3 +46,3 @@ CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs)
44 int i; 46 int i;
45// qDebug("Trying 2"); 47// //qDebug("Trying 2");
46 len = rhs.len; 48 len = rhs.len;
@@ -62,3 +64,3 @@ CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs)
62 len = i; 64 len = i;
63// qDebug("Tried 2"); 65// //qDebug("Tried 2");
64 return *this; 66 return *this;
@@ -82,2 +84,4 @@ void CDrawBuffer::empty()
82{ 84{
85 m_bSop = false;
86 m_bEop = false;
83 len = 0; 87 len = 0;
@@ -113,7 +117,45 @@ void CDrawBuffer::truncate(int n)
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;
@@ -122,3 +164,3 @@ int CDrawBuffer::width(int numchars)
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)
@@ -130,4 +172,11 @@ int CDrawBuffer::width(int numchars)
130 { 172 {
173 if (currentstyle.canScale())
174 {
175 currentx += (gzoom*currentstyle.getPicture()->width())/100;
176 }
177 else
178 {
131 currentx += currentstyle.getPicture()->width(); 179 currentx += currentstyle.getPicture()->width();
132 } 180 }
181 }
133 else 182 else
@@ -141,3 +190,3 @@ int CDrawBuffer::width(int numchars)
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());
@@ -145,2 +194,34 @@ int CDrawBuffer::width(int numchars)
145 QFontMetrics fm(f); 194 QFontMetrics fm(f);
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 {
146 currentx += fm.width(str); 227 currentx += fm.width(str);
@@ -148,5 +229,6 @@ int CDrawBuffer::width(int numchars)
148 } 229 }
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;
@@ -156,3 +238,3 @@ int 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}
@@ -161,8 +243,8 @@ int 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())
@@ -171,3 +253,3 @@ int CDrawBuffer::offset(int scwidth)
171 { 253 {
172 currentx = scwidth - BORDER - rightMargin() - width(); 254 currentx = scwidth - _border - rightMargin() - width();
173 } 255 }
@@ -184,3 +266,3 @@ int CDrawBuffer::offset(int scwidth)
184 case m_AlignLeft: 266 case m_AlignLeft:
185 currentx = BORDER + leftMargin(); 267 currentx = _border + leftMargin();
186 break; 268 break;
@@ -190,26 +272,45 @@ int CDrawBuffer::offset(int scwidth)
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] != ' ')
203 } 290 {
291 nonspace = i;
204 break; 292 break;
205 case CStyle::m_AlignCentre: 293 }
294 }
295#ifdef _WINDOWS
296 for (i = nonspace; i < len; i++)
297#else
298 for (int i = nonspace; i < len; i++)
299#endif
300 {
301 if ((*this)[i] == ' ')
206 { 302 {
207 currentx = (scwidth - width())/2 - BORDER; 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;
@@ -218,5 +319,5 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
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());
@@ -225,3 +326,3 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
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));
@@ -230,2 +331,3 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
230#endif 331#endif
332 int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2;
231 if (_bMono) 333 if (_bMono)
@@ -234,3 +336,3 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
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 }
@@ -239,3 +341,3 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
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 }
@@ -243,3 +345,3 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
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 }
@@ -251,6 +353,19 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
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 }
@@ -264,3 +379,3 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
264 { 379 {
265 _p->drawLine( currentx, _y, currentx + w, _y); 380 _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset);
266 } 381 }
@@ -269,3 +384,3 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
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 }
@@ -273,5 +388,9 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
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;
@@ -282,6 +401,45 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
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 }
@@ -290,5 +448,4 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
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;
@@ -299,3 +456,3 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
299 } 456 }
300 while (textend != segs.end() && textstart->start < length()-1); 457 while (textend != segs.end() && textstart->start < len);
301} 458}
@@ -316,3 +473,3 @@ linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt)
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;
@@ -321,3 +478,3 @@ linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt)
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*/
@@ -342,5 +499,5 @@ void 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 {
@@ -359,6 +516,6 @@ void CDrawBuffer::resize()
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 }
@@ -378,2 +535,16 @@ void CDrawBuffer::resize()
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
@@ -6,2 +6,3 @@
6#include "my_list.h" 6#include "my_list.h"
7#include "linktype.h"
7 8
@@ -9,9 +10,2 @@ class QPainter;
9 10
10enum linkType
11{
12 eNone,
13 eLink,
14 ePicture
15};
16
17struct textsegment 11struct textsegment
@@ -35,2 +29,3 @@ class CDrawBuffer : public CBuffer
35 bool m_bEof; 29 bool m_bEof;
30 bool m_bSop, m_bEop;
36 CDrawBuffer(const CDrawBuffer&); 31 CDrawBuffer(const CDrawBuffer&);
@@ -38,2 +33,4 @@ class CDrawBuffer : public CBuffer
38 public: 33 public:
34 void setstartpara() { m_bSop = true; }
35 void setendpara() { m_bEop = true; }
39 int leftMargin(); 36 int leftMargin();
@@ -58,5 +55,5 @@ class CDrawBuffer : public CBuffer
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();
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
@@ -5,5 +5,5 @@ void 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 {
@@ -12,3 +12,2 @@ void CUtf8::getch(tchar& ch, CStyle& sty)
12 } 12 }
13 tchar ret = iret;
14 int count = 0; 13 int count = 0;
@@ -20,2 +19,3 @@ void CUtf8::getch(tchar& ch, CStyle& sty)
20 ret <<= 6; 19 ret <<= 6;
20 tchar iret;
21 parent->getch(iret, sty); 21 parent->getch(iret, sty);
@@ -47,5 +47,5 @@ void 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 {
@@ -61,5 +61,5 @@ void 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 {
@@ -75,3 +75,3 @@ void Ccp1252::getch(tchar& ch, CStyle& sty)
75{ 75{
76 int iret; 76 tchar iret;
77 parent->getch(iret, sty); 77 parent->getch(iret, sty);
@@ -80,3 +80,3 @@ void Ccp1252::getch(tchar& ch, CStyle& sty)
80 { 80 {
81 case EOF: 81 case UEOF:
82 ch = UEOF; 82 ch = UEOF;
@@ -199,5 +199,5 @@ void 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 {
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
@@ -5,2 +5,4 @@
5 5
6#define MAX_ENCODING 6
7
6class CEncoding : public CCharacterSource 8class CEncoding : public CCharacterSource
@@ -10,2 +12,3 @@ class CEncoding : public CCharacterSource
10 CExpander* parent; 12 CExpander* parent;
13 linkType hyperlink(unsigned int n, QString& t) { return parent->hyperlink(n,t); }
11public: 14public:
@@ -52,2 +55,20 @@ public:
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
@@ -3,3 +3,5 @@
3 3
4#ifndef _WINDOWS
4#include <unistd.h> 5#include <unistd.h>
6#endif
5#include <stdio.h> 7#include <stdio.h>
@@ -7,2 +9,3 @@
7#include <qmessagebox.h> 9#include <qmessagebox.h>
10#include "useqpe.h"
8#include "config.h" 11#include "config.h"
@@ -10,5 +13,6 @@
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;
@@ -22,2 +26,3 @@ class CCharacterSource
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};
@@ -33,7 +38,11 @@ class CExpander
33 time_t sustime; 38 time_t sustime;
39 int m_scrWidth;
40 unsigned long m_currentstart, m_currentend;
34 public: 41 public:
42#ifdef USEQPE
35 virtual void suspend() = 0; 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; };
@@ -51,5 +60,6 @@ class CExpander
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();
@@ -57,6 +67,6 @@ class CExpander
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 }
@@ -64,18 +74,33 @@ class CExpander
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()
89 {
90 unsigned long current = locate();
91 if (m_currentstart > current || current > m_currentend)
69 { 92 {
70 return 0; 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)
@@ -109,2 +134,3 @@ class CExpander
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)
@@ -122,2 +148,3 @@ class CExpander
122 } 148 }
149 void setwidth(int w) { m_scrWidth = w; }
123}; 150};
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
@@ -684 +684,59 @@ void repalm::getch(tchar& ch, CStyle& sty)
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
@@ -11,2 +11,6 @@ class CFilter : public CCharacterSource
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:
@@ -71,4 +75,4 @@ class stripcr : public CFilter
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 {
@@ -89,4 +93,4 @@ class dehyphen : public CFilter
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 {
@@ -121,4 +125,4 @@ class striphtml : public CFilter
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};
@@ -130,4 +134,4 @@ class unindent : public CFilter
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 {
@@ -152,4 +156,4 @@ class repara : public CFilter
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 {
@@ -181,4 +185,4 @@ class indenter : public CFilter
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 {
@@ -207,4 +211,4 @@ class dblspce : public CFilter
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 {
@@ -234,4 +238,4 @@ class textfmt : public CFilter
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};
@@ -242,4 +246,4 @@ class embolden : public CFilter
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 {
@@ -257,4 +261,4 @@ class remap : public CFilter
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};
@@ -265,4 +269,4 @@ class PeanutFormatter : public CFilter
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};
@@ -274,4 +278,18 @@ class OnePara : public CFilter
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};
@@ -282,6 +300,29 @@ class repalm : public CFilter
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
@@ -28,3 +28,3 @@ class CFiledata
28 delete [] data; 28 delete [] data;
29 qDebug("~Filedata: deleting"); 29 // qDebug("~Filedata: deleting");
30 } 30 }
@@ -32,3 +32,3 @@ class CFiledata
32 { 32 {
33 qDebug("~Filedata: not deleting"); 33 // qDebug("~Filedata: not deleting");
34 } 34 }
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,4 +1,27 @@
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)
@@ -22,3 +45,3 @@ bool FontControl::ChangeFont(QString& n, int tgt)
22 { 45 {
23#ifdef OPIE 46#if defined(OPIE) || !defined(USEQPE)
24 m_fontsizes[i] = (*it); 47 m_fontsizes[i] = (*it);
@@ -33,3 +56,3 @@ bool FontControl::ChangeFont(QString& n, int tgt)
33 } 56 }
34 m_size = best; 57 g_size = m_size = best;
35 } 58 }
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
@@ -10,10 +10,16 @@ class FontControl
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 {
@@ -25,3 +31,8 @@ class FontControl
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; }
@@ -29,3 +40,3 @@ class FontControl
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 {
@@ -48,3 +59,3 @@ class FontControl
48 } 59 }
49 int ascent(CStyle ch) 60 int ascent(const CStyle& ch)
50 { 61 {
@@ -60,3 +71,3 @@ class FontControl
60 } 71 }
61 int descent(CStyle ch) 72 int descent(const CStyle& ch)
62 { 73 {
@@ -72,3 +83,3 @@ class FontControl
72 } 83 }
73 int lineSpacing(CStyle ch) 84 int lineSpacing(const CStyle& ch)
74 { 85 {
@@ -80,2 +91,3 @@ class FontControl
80 { 91 {
92/*
81 if (--m_size < 0) 93 if (--m_size < 0)
@@ -86,2 +98,12 @@ class FontControl
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 }
@@ -89,2 +111,3 @@ class FontControl
89 { 111 {
112/*
90 if (++m_size >= m_maxsize) 113 if (++m_size >= m_maxsize)
@@ -95,2 +118,12 @@ class FontControl
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 }
@@ -101,2 +134,18 @@ class FontControl
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};
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,46 +1,55 @@
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;
11// qDebug("Saved:%u [%u,%u,%u]", posn, historystart, historycurrent, historyend);
12}
13
14bool CNavigation::forward(size_t& loc)
15{
16 if (historycurrent != historyend)
17 {
18 historycurrent = (historycurrent + 1)%NAVIGATION_HISTORY_SIZE; 15 historycurrent = (historycurrent + 1)%NAVIGATION_HISTORY_SIZE;
19 loc = history[historycurrent]; 16 if (historycurrent==historystart)
20 //qDebug("Forward:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend); 17 // circular buffer full, forget oldest record
21 return true; 18 historystart=(historystart+1)%NAVIGATION_HISTORY_SIZE;
19 // no forward possible after saveposn
20 historyend = historycurrent;
22 } 21 }
23 else 22
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)
24 { 29 {
25 return false; 30 //printf("witing position %u, depth %u\n",posn,historycurrent);
26 } 31 history[historycurrent] = posn;
27} 32}
28 33
29bool CNavigation::back(size_t& loc) 34/*
30{ 35 bool back(size_t& posn)
31 if (historyend != historystart) 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)
32 { 41 {
33 //qDebug("Back:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend); 42 if (historycurrent!=historystart) {
34 if (historycurrent == historyend && history[historycurrent] != loc) 43 // buffer is not empty
35 { 44 if (historycurrent==0)
36 historyend = (historyend+1) % NAVIGATION_HISTORY_SIZE; 45 historycurrent=NAVIGATION_HISTORY_SIZE-1;
37 history[historyend] = loc;
38 }
39 else 46 else
40 { 47 historycurrent--;
41 size_t sv = historycurrent; 48 posn=history[historycurrent];
42 historycurrent = (historycurrent + NAVIGATION_HISTORY_SIZE - 1) % NAVIGATION_HISTORY_SIZE; 49 //printf("back(): going back to %u depth %u\n",posn,historycurrent);
43 if (historycurrent == historystart) 50 return true;
44 { 51
45 historycurrent = sv; 52 } else {
53 // circular buffer empty
54 //printf("back(): empty history\n");
46 return false; 55 return false;
@@ -48,8 +57,19 @@ bool CNavigation::back(size_t& loc)
48 } 57 }
49 loc = history[historycurrent]; 58
50 //qDebug("Back:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend); 59/*
51 return true; 60 bool forward(size_t& posn)
52 } 61 go forward in history, if possible
53 else 62 undo calling of back()
63*/
64bool CNavigation::forward(size_t& posn)
54 { 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");
55 return false; 75 return false;
@@ -58,4 +78,2 @@ bool CNavigation::back(size_t& loc)
58 78
59#include <stdio.h>
60
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)
@@ -74,2 +92,3 @@ void CNavigation::setSaveData(unsigned char*& data, unsigned short& len, unsigne
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);
@@ -78,2 +97,3 @@ void CNavigation::setSaveData(unsigned char*& data, unsigned short& len, unsigne
78 printf("\n"); 97 printf("\n");
98*/
79} 99}
@@ -95,2 +115,3 @@ void CNavigation::putSaveData(unsigned char*& src, unsigned short& srclen)
95 } 115 }
116/*
96 printf("<%u,%u,%u>\n", historystart, historyend, historycurrent); 117 printf("<%u,%u,%u>\n", historystart, historyend, historycurrent);
@@ -99,2 +120,3 @@ void CNavigation::putSaveData(unsigned char*& src, unsigned short& srclen)
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 +1,2 @@
1#include <string.h>
1#include <stdlib.h> 2#include <stdlib.h>
@@ -11,2 +12,3 @@ class CNavigation
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);
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,2 +1,3 @@
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>
@@ -4,3 +5,3 @@
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 */
@@ -204,3 +205,3 @@ QImage* Palm2QImage
204 205
205#ifdef WINDOWS 206#ifndef USEQPE
206 QImage* qimage = new QImage(width, height, 32); 207 QImage* qimage = new QImage(width, height, 32);
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
@@ -6,2 +6,2 @@ QImage* Palm2QImage
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
@@ -4,2 +4,3 @@
4#include <qtoolbar.h> 4#include <qtoolbar.h>
5#include <qmainwindow.h>
5 6
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
@@ -10,3 +10,6 @@
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"
@@ -15,3 +18,5 @@
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>
@@ -19,8 +24,9 @@
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
@@ -38,2 +44,6 @@ const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 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) :
@@ -53,9 +63,14 @@ QTReader::QTReader( QWidget *parent, const char *name, WFlags f) :
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),
@@ -74,3 +89,3 @@ QTReader::QTReader( const QString& filename, QWidget *parent, const tchar *name,
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);
@@ -79,2 +94,11 @@ QTReader::QTReader( const QString& filename, QWidget *parent, const tchar *name,
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()
@@ -89,3 +113,23 @@ void QTReader::mousePressEvent( QMouseEvent* _e )
89 { 113 {
114 //qDebug("MousePress");
90 mouseUpOn = false; 115 mouseUpOn = false;
116 if (m_swapmouse)
117 {
118 int lineno = 0;
119 int ht = textarray[0]->lineSpacing();
120 while ((ht < _e->y()) && (lineno < numlines))
121 {
122 ht += textarray[++lineno]->lineSpacing();
123 }
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{
91 if (buffdoc.hasnavigation()) 135 if (buffdoc.hasnavigation())
@@ -104,7 +148,3 @@ void QTReader::mousePressEvent( QMouseEvent* _e )
104 { 148 {
105 size_t target = pagelocate(); 149 goBack();
106 if (buffdoc.back(target))
107 {
108 locate(target);
109 }
110 } 150 }
@@ -112,7 +152,3 @@ void QTReader::mousePressEvent( QMouseEvent* _e )
112 { 152 {
113 size_t target = pagelocate(); 153 goForward();
114 if (buffdoc.forward(target))
115 {
116 locate(target);
117 }
118 } 154 }
@@ -120,4 +156,3 @@ void QTReader::mousePressEvent( QMouseEvent* _e )
120 { 156 {
121 buffdoc.saveposn(pagelocate()); 157 goHome();
122 locate(buffdoc.getHome());
123 } 158 }
@@ -137,2 +172,40 @@ void QTReader::mousePressEvent( QMouseEvent* _e )
137 } 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}
@@ -150,3 +223,3 @@ linkType QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, si
150 { 223 {
151 offset = x/m_charWidth; 224 offset = (x - textarray[lineno]->offset(width(), m_border))/m_charWidth;
152 } 225 }
@@ -156,4 +229,4 @@ linkType QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, si
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;
@@ -163,2 +236,11 @@ linkType QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, si
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)
@@ -175,58 +257,5 @@ void QTReader::setContinuous(bool _b)
175 257
176void QTReader::mouseReleaseEvent( QMouseEvent* _e ) 258void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno)
177{
178 buffdoc.unsuspend();
179 if (_e->button() == LeftButton)
180 {
181 if (mouseUpOn)
182 {
183 if (textarray[0] != NULL)
184 {
185 QString wrd, line;
186 // int lineno = _e->y()/m_linespacing;
187 int lineno = 0;
188 int ht = textarray[0]->lineSpacing();
189 while ((ht < _e->y()) && (lineno < numlines))
190 {
191 ht += textarray[++lineno]->lineSpacing();
192 }
193 size_t startpos, startoffset, tgt;
194 switch (getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt))
195 {
196 case eLink:
197 {
198 size_t saveposn = pagelocate();
199 if (buffdoc.hyperlink(tgt))
200 {
201 buffdoc.saveposn(saveposn);
202 fillbuffer();
203 update();
204 }
205 else
206 {
207 locate(pagelocate());
208 }
209 return;
210 }
211 case ePicture:
212 {
213 qDebug("Picture:%x", tgt);
214 QPixmap* pm = buffdoc.getPicture(tgt);
215 if (pm != NULL)
216 {
217 emit OnShowPicture(*pm);
218 delete pm;
219 }
220 else
221 { 259 {
222 locate(pagelocate()); 260 QString wrd;
223 }
224 return;
225 }
226 case eNone:
227 break;
228 default:
229 qDebug("Unknown linktype");
230 return;
231 }
232 if (m_twotouch) 261 if (m_twotouch)
@@ -279,3 +308,3 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e )
279 { 308 {
280 int chno = _e->x()/m_charWidth; 309 int chno = (_e->x()-textarray[lineno]->offset(width(), m_border))/m_charWidth;
281 if (chno < ustrlen(textarray[lineno]->data())) 310 if (chno < ustrlen(textarray[lineno]->data()))
@@ -289,3 +318,3 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e )
289 int first = 0; 318 int first = 0;
290 int tgt = _e->x() - t->offset(width()); 319 int tgt = _e->x() - t->offset(width(), m_border);
291 while (1) 320 while (1)
@@ -294,5 +323,6 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e )
294 while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; 323 while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
295 if (t->width(i) > tgt) 324 if (t->width(i, true, width(), m_border) > tgt)
296 { 325 {
297 wrd = toQString(t->data()+first, i - first); 326 wrd = toQString(t->data()+first, i - first);
327 // qDebug("Got %s", (const char *)wrd);
298 break; 328 break;
@@ -306,2 +336,3 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e )
306 { 336 {
337 //qDebug("Selected:%s", (const char*)wrd);
307 emit OnWordSelected(wrd, locnarray[lineno], (m_twotouch) ? wrd : toQString(textarray[lineno]->data())); 338 emit OnWordSelected(wrd, locnarray[lineno], (m_twotouch) ? wrd : toQString(textarray[lineno]->data()));
@@ -309,2 +340,89 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e )
309 } 340 }
341
342void QTReader::mouseReleaseEvent( QMouseEvent* _e )
343{
344 buffdoc.unsuspend();
345 if (_e->button() == LeftButton)
346 {
347 if (mouseUpOn)
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 }
355 if (textarray[0] != NULL)
356 {
357 QString line;
358 // int lineno = _e->y()/m_linespacing;
359 int lineno = 0;
360 int ht = textarray[0]->lineSpacing();
361 while ((ht < _e->y()) && (lineno < numlines))
362 {
363 ht += textarray[++lineno]->lineSpacing();
364 }
365 size_t startpos, startoffset, tgt;
366 switch (getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt))
367 {
368 case eLink:
369 {
370 size_t saveposn = pagelocate();
371 QString href;
372 linkType lt = buffdoc.hyperlink(tgt, href);
373 if (lt == eLink)
374 {
375 buffdoc.saveposn(saveposn);
376 fillbuffer();
377 update();
378 }
379 else
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 }
398 locate(pagelocate());
399 }
400 return;
401 }
402 case ePicture:
403 {
404 // qDebug("Picture:%x", tgt);
405 QImage* pm = buffdoc.getPicture(tgt);
406 if (pm != NULL)
407 {
408 emit OnShowPicture(*pm);
409 delete pm;
410 }
411 else
412 {
413 locate(pagelocate());
414 }
415 return;
416 }
417 case eNone:
418 break;
419 default:
420 // qDebug("Unknown linktype");
421 return;
422 }
423 if (m_swapmouse)
424 processmousepositionevent(_e);
425 else
426 processmousewordevent(startpos, startoffset, _e, lineno);
427 }
310 } 428 }
@@ -328,3 +446,3 @@ void QTReader::focusOutEvent(QFocusEvent* e)
328 timer->stop(); 446 timer->stop();
329 m_scrolldy1 = m_scrolldy2 = 0; 447 //m_scrolldy1 = m_scrolldy2 = 0;
330 } 448 }
@@ -334,3 +452,5 @@ void QTReader::focusOutEvent(QFocusEvent* e)
334#include <qdrawutil.h> 452#include <qdrawutil.h>
453#ifndef _WINDOWS
335#include <unistd.h> 454#include <unistd.h>
455#endif
336 456
@@ -428,2 +548,28 @@ void QTReader::zoomout()
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)
@@ -431,2 +577,29 @@ void QTReader::keyPressEvent(QKeyEvent* e)
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())
@@ -475,31 +648,2 @@ void QTReader::keyPressEvent(QKeyEvent* e)
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:
@@ -532,9 +676,2 @@ void QTReader::keyPressEvent(QKeyEvent* e)
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:
@@ -542,2 +679,3 @@ void QTReader::keyPressEvent(QKeyEvent* e)
542 } 679 }
680*/
543} 681}
@@ -550,3 +688,12 @@ void QTReader::setautoscroll(bool _sc)
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 }
@@ -557,4 +704,14 @@ void QTReader::setautoscroll(bool _sc)
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 }
@@ -567,3 +724,3 @@ bool QTReader::getline(CDrawBuffer *buff)
567 { 724 {
568 return buffdoc.getline(buff ,width(), m_charWidth); 725 return buffdoc.getline(buff ,width(), m_charWidth, m_border);
569 } 726 }
@@ -571,3 +728,3 @@ bool QTReader::getline(CDrawBuffer *buff)
571 { 728 {
572 return buffdoc.getline(buff, width()); 729 return buffdoc.getline(buff, width(), m_border);
573 } 730 }
@@ -590,2 +747,21 @@ void QTReader::doscroll()
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];
@@ -611,3 +787,3 @@ void QTReader::doscroll()
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();
@@ -616,3 +792,20 @@ void QTReader::doscroll()
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 }
@@ -641,3 +834,3 @@ void QTReader::drawFonts( QPainter *p )
641 { 834 {
642 qDebug("How refreshing..."); 835 //qDebug("How refreshing...");
643 if (buffdoc.empty()) return; 836 if (buffdoc.empty()) return;
@@ -646,7 +839,8 @@ void QTReader::drawFonts( QPainter *p )
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 }
@@ -654,5 +848,6 @@ void QTReader::drawFonts( QPainter *p )
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;
@@ -660,6 +855,6 @@ void QTReader::drawFonts( QPainter *p )
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;
@@ -667,8 +862,8 @@ void QTReader::drawFonts( QPainter *p )
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;
@@ -678,5 +873,4 @@ void QTReader::drawFonts( QPainter *p )
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 }
@@ -685,3 +879,5 @@ void QTReader::drawFonts( QPainter *p )
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++)
@@ -691,3 +887,3 @@ void QTReader::drawFonts( QPainter *p )
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 }
@@ -696,5 +892,16 @@ void QTReader::drawFonts( QPainter *p )
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
@@ -703,2 +910,3 @@ void QTReader::drawFonts( QPainter *p )
703 } 910 }
911*/
704} 912}
@@ -744,2 +952,3 @@ void QTReader::init()
744{ 952{
953// m_showlast = true;
745 // setCaption( "Qt Draw Demo Application" ); 954 // setCaption( "Qt Draw Demo Application" );
@@ -773,2 +982,14 @@ QTReader::~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}
@@ -818,3 +1039,3 @@ void 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 );
@@ -843,7 +1064,7 @@ bool QTReader::locate(unsigned long n) {
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;
@@ -858,3 +1079,3 @@ unsigned int QTReader::screenlines()
858 1079
859bool QTReader::fillbuffer(int reuse, int ht) 1080bool QTReader::fillbuffer(int reuse, int ht, int newht)
860{ 1081{
@@ -862,3 +1083,6 @@ bool QTReader::fillbuffer(int reuse, int ht)
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;
@@ -866,6 +1090,7 @@ bool QTReader::fillbuffer(int reuse, int ht)
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)
@@ -896,2 +1121,3 @@ bool QTReader::fillbuffer(int reuse, int ht)
896 mylastpos = locate(); 1121 mylastpos = locate();
1122 m_scrolldy1 = m_scrolldy2 = m_scrollpart = m_lastheight - lastypos;
897 1123
@@ -900,5 +1126,5 @@ bool QTReader::fillbuffer(int reuse, int ht)
900 1126
901
902void QTReader::dopagedn() 1127void QTReader::dopagedn()
903{ 1128{
1129// qDebug("HEIGHT(2):%d", m_lastheight);
904 buffdoc.unsuspend(); 1130 buffdoc.unsuspend();
@@ -907,3 +1133,3 @@ void QTReader::dopagedn()
907 { 1133 {
908 //qDebug("Jumping to %u", mylastpos); 1134 ////qDebug("Jumping to %u", mylastpos);
909 jumpto(mylastpos); 1135 jumpto(mylastpos);
@@ -940,2 +1166,14 @@ void QTReader::dopageup()
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)
@@ -946,6 +1184,6 @@ void QTReader::dopageup(unsigned int target)
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)
@@ -953,3 +1191,2 @@ void QTReader::dopageup(unsigned int target)
953 ch = true; 1191 ch = true;
954 nbfl = 0;
955 if (target < guess) 1192 if (target < guess)
@@ -967,18 +1204,20 @@ void QTReader::dopageup(unsigned int target)
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)
@@ -992,3 +1231,3 @@ void QTReader::dopageup(unsigned int target)
992 } 1231 }
993 if (ypos < height() && (delta != 0)) 1232 if (guess < 4000 && ypos < height() && (delta != 0))
994 { 1233 {
@@ -1011,2 +1250,3 @@ void QTReader::dopageup(unsigned int target)
1011 } 1250 }
1251/*
1012 ypos = 0; 1252 ypos = 0;
@@ -1019,2 +1259,14 @@ void QTReader::dopageup(unsigned int target)
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;
@@ -1029,3 +1281,7 @@ void QTReader::dopageup(unsigned int target)
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 {
@@ -1059,3 +1315,2 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn)
1059 } 1315 }
1060 m_lastfile = newfile;
1061 // QMessageBox::information(0, "Opening...", newfile); 1316 // QMessageBox::information(0, "Opening...", newfile);
@@ -1065,7 +1320,9 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn)
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 }
@@ -1073,3 +1330,3 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn)
1073 update(); 1330 update();
1074 // qDebug("Updated"); 1331// // qDebug("Updated");
1075 return bRC; 1332 return bRC;
@@ -1091,3 +1348,7 @@ void QTReader::lineDown()
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 {
@@ -1261,3 +1522,7 @@ void QTReader::lineUp()
1261 int ypos = 0; 1522 int ypos = 0;
1523#ifdef _WINDOWS
1524 for (i = 0; i <= numlines; i++)
1525#else
1262 for (int i = 0; i <= numlines; i++) 1526 for (int i = 0; i <= numlines; i++)
1527#endif
1263 { 1528 {
@@ -1298,30 +1563 @@ MarkupType QTReader::PreferredMarkup()
1298} }
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
@@ -3,2 +3,4 @@
3 3
4//#define _SCROLLPIPE
5
4#include <qwidget.h> 6#include <qwidget.h>
@@ -16,3 +18,2 @@ class QTimer;
16class QPixmap; 18class QPixmap;
17class statedata;
18 19
@@ -22,4 +23,8 @@ class QTReader : public QWidget
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);
@@ -27,8 +32,10 @@ class QTReader : public QWidget
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);
@@ -37,3 +44,12 @@ class QTReader : public QWidget
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:
@@ -88,84 +104,17 @@ public:
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 { 106 {
96 bremap = _b; 107 m_fontControl.setlead(_lead);
97 setfilter(getfilter());
98 } 108 }
99 void setmakebold(bool _b) 109 int getlead()
100 { 110 {
101 bmakebold = _b; 111 return m_fontControl.getlead();
102 setfilter(getfilter());
103 } 112 }
104 void setautofmt(bool _b) 113 void setextraspace(int _lead)
105 {
106 bautofmt = _b;
107 if (bautofmt)
108 { 114 {
109 btextfmt = false; 115 m_fontControl.setextraspace(_lead);
110 bstriphtml = false;;
111 bpeanut = false;
112 }
113 setfilter(getfilter());
114 } 116 }
115 void settextfmt(bool _b) 117 int getextraspace()
116 { 118 {
117 btextfmt = _b; 119 return m_fontControl.getextraspace();
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 } 120 }
@@ -189,17 +138,22 @@ public:
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 }
@@ -225,3 +179,6 @@ public:
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;
@@ -231,2 +188,5 @@ public:
231private slots: 188private slots:
189 void goHome();
190 void goBack();
191 void goForward();
232 void doscroll(); 192 void doscroll();
@@ -262,3 +222,4 @@ private slots:
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
@@ -272,6 +233,6 @@ private slots:
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;
@@ -294,3 +255,3 @@ private slots:
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();
@@ -302,3 +263,2 @@ private slots:
302 QString firstword(); 263 QString firstword();
303 void setstate(const statedata& sd);
304 264
@@ -307,4 +267,4 @@ private slots:
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};
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
@@ -19,11 +19,16 @@
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>
@@ -36,4 +41,6 @@
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>
@@ -41,7 +48,10 @@
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"
@@ -51,11 +61,19 @@
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"
@@ -63,11 +81,18 @@
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
@@ -77,5 +102,18 @@ void 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
@@ -85,2 +123,33 @@ void QTReaderApp::listBkmkFiles()
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;
@@ -104,3 +173,3 @@ void QTReaderApp::listBkmkFiles()
104 closedir(d); 173 closedir(d);
105 174#endif
106 if (cnt > 0) 175 if (cnt > 0)
@@ -108,3 +177,17 @@ void QTReaderApp::listBkmkFiles()
108//tjw menu->hide(); 177//tjw menu->hide();
109 editBar->hide(); 178 editorStack->raiseWidget( bkmkselector );
179 hidetoolbars();
180 m_nBkmkAction = cRmBkmkFile;
181 }
182 else
183 QMessageBox::information(this, PROGNAME, "No bookmark files");
184}
185
186void QTReaderApp::hidetoolbars()
187{
188 menubar->hide();
189 if (fileBar != NULL) fileBar->hide();
190 if (viewBar != NULL) viewBar->hide();
191 if (navBar != NULL) navBar->hide();
192 if (markBar != NULL) markBar->hide();
110 if (m_fontVisible) m_fontBar->hide(); 193 if (m_fontVisible) m_fontBar->hide();
@@ -112,3 +195,5 @@ void QTReaderApp::listBkmkFiles()
112 { 195 {
196#ifdef USEQPE
113 Global::hideInputMethod(); 197 Global::hideInputMethod();
198#endif
114 regBar->hide(); 199 regBar->hide();
@@ -117,10 +202,7 @@ void QTReaderApp::listBkmkFiles()
117 { 202 {
203#ifdef USEQPE
118 Global::hideInputMethod(); 204 Global::hideInputMethod();
205#endif
119 searchBar->hide(); 206 searchBar->hide();
120 } 207 }
121 m_nRegAction = cRmBkmkFile;
122 editorStack->raiseWidget( bkmkselector );
123 }
124 else
125 QMessageBox::information(this, PROGNAME, "No bookmark files");
126} 208}
@@ -128,7 +210,14 @@ void QTReaderApp::listBkmkFiles()
128QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) 210QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
129 : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false) 211 : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false),
130{ 212 fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL)
131// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); 213{
132// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); 214 m_url_clipboard = false;
133 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;
@@ -140,22 +229,88 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
140 QString lang = getenv( "LANG" ); 229 QString lang = getenv( "LANG" );
230 QString rot = getenv( "QWS_DISPLAY" );
231
232/*
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 }
141 246
247// qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot);
248*/
142 m_autogenstr = "^ *[A-Z].*[a-z] *$"; 249 m_autogenstr = "^ *[A-Z].*[a-z] *$";
143 setToolBarsMovable( FALSE );
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
289
290//#ifdef USEQPE
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 );
158 311
159// bar = new QToolBar( this ); 312// addToolBar(menubar, "Menus",QMainWindow::Top);
160 editBar = bar; 313// addToolBar(fileBar, "Toolbar",QMainWindow::Top);
314
315 // QPopupMenu *edit = new QPopupMenu( this );
161 316
@@ -175,5 +330,2 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
175 330
176 pbar = new QProgressBar(this);
177 pbar->hide();
178
179 m_annoWin = new CAnnoEdit(editorStack); 331 m_annoWin = new CAnnoEdit(editorStack);
@@ -207,3 +359,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
207*/ 359*/
208 qDebug("Reading file list"); 360// qDebug("Reading file list");
209 readfilelist(); 361 readfilelist();
@@ -214,9 +366,19 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 );
@@ -226,2 +388,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 );
@@ -236,4 +400,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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" );
@@ -242,2 +406,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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
@@ -250,2 +415,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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);
@@ -255,24 +424,74 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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
449
257 450
258 451
259 connect( reader, SIGNAL( OnShowPicture(QPixmap&) ), this, SLOT( showgraphic(QPixmap&) ) ); 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 );
275 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 );
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() ) );
@@ -280,5 +499,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 );
@@ -286,50 +505,62 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 509
299 m_buttonAction[2] = new QAction( tr( "Mark" ), 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 );
300 514
301 m_buttonAction[3] = new QAction( tr( "Fullscreen" ), QString::null, 0, ag, NULL, true ); 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 );
302 520
303 ag->addTo(spacemenu); 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 );
304 524
305 connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) ); 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);
306 529
307 file->insertSeparator(); 530 m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL);
531 connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) );
532 m_start_action->addTo(navigation);
308 533
309 ag = new QActionGroup(this); 534 m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL);
310 ag->setExclusive(false); 535 connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) );
311 QPopupMenu *encoding = new QPopupMenu(this); 536 m_end_action->addTo(navigation);
312 file->insertItem( tr( "Navigation" ), encoding );
313 537
314 a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( PICDIR "panel-arrow-down" ), QString::null, 0, ag, 0, true ); 538 m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL);
539 connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) );
540 m_jump_action->addTo(navigation);
315 541
316 a->setOn(false); 542 m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true );
317 connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); 543 connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) );
318 a->addTo( bar ); 544 m_pageline_action->addTo(navigation);
545 m_pageline_action->setOn(reader->m_bpagemode);
319 546
320 a = new QAction( tr( "Jump" ), QString::null, 0, ag, NULL); 547 m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 );
321 connect( a, SIGNAL( activated() ), this, SLOT( jump() ) ); 548 connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) );
549 m_pageup_action->addTo( navigation );
322 550
323 a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, ag, NULL, true ); 551 m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 );
324 connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); 552 connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) );
325 a->setOn(reader->m_bpagemode); 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
@@ -345,32 +576,22 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
345 576
346 file->insertSeparator(); 577// file->insertSeparator();
347
348 a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL);
349 connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) );
350 a->addTo( file );
351 578
352 a = new QAction( tr( "Two/One Touch" ), QString::null, 0, this, NULL, true ); 579#ifdef _SCROLLPIPE
353 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) );
354 a->setOn(m_twoTouch);
355 a->addTo( file );
356 580
357 ag = new QActionGroup(this); 581 QActionGroup* 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
362 a = new QAction( tr( "Annotation" ), QString::null, 0, ag, NULL, true );
363 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnAnnotation(bool) ) );
364 a->setOn(m_doAnnotation);
365 585
366 a = new QAction( tr( "Dictionary" ), QString::null, 0, ag, NULL, true ); 586 a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL);
367 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnDictionary(bool) ) ); 587 connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) );
368 a->setOn(m_doDictionary);
369 588
370 a = new QAction( tr( "Clipboard" ), QString::null, 0, ag, NULL, true ); 589 a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true );
371 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnClipboard(bool) ) ); 590 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) );
372 a->setOn(m_doClipboard); 591 a->setOn(reader->m_pauseAfterEachPara);
373 592
374 ag->addTo(encoding); 593 ag->addTo(spacemenu);
594// file->insertSeparator();
375 595
596#endif
376 597
@@ -382,14 +603,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
382 603
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
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 );
@@ -397,124 +610,45 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 618
412 a = new QAction( tr( "Continuous" ), QString::null, 0, ag, NULL, true ); 619 view->insertSeparator();
413 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setcontinuous(bool) ) );
414 a->setOn(reader->m_continuousDocument);
415 a->addTo( file );
416 620
417 a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 621 m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this);
418 connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); 622 connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) );
419 a->addTo( bar ); 623 m_zoomin_action->addTo( view );
420 624
421 m_bkmkAvail->setEnabled(false); 625 m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this);
626 connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) );
627 m_zoomout_action->addTo( view );
422 628
629 view->insertSeparator();
630 m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this);
631 connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) );
632 m_setfont_action->addTo( view );
423 633
424 ag = new QActionGroup(this); 634 view->insertSeparator();
425// ag->setExclusive(false); 635 m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this);
426 encoding = new QPopupMenu(this); 636 connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) );
427 format->insertItem( tr( "Markup" ), encoding ); 637 m_setenc_action->addTo( view );
428 638
429 a = new QAction( tr( "Auto" ), QString::null, 0, ag, NULL, true ); 639 m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true);
430 a->setOn(reader->bautofmt); 640 connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
431 connect( a, SIGNAL( toggled(bool) ), this, SLOT( autofmt(bool) ) ); 641 m_setmono_action->addTo( view );
642 m_setmono_action->setOn(reader->m_bMonoSpaced);
432 643
433 a = new QAction( tr( "None" ), QString::null, 0, ag, NULL, true );
434 a->setOn(!reader->bautofmt && !(reader->btextfmt || reader->bstriphtml || reader->bpeanut));
435// connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) );
436 644
437 a = new QAction( tr( "Text" ), QString::null, 0, ag, NULL, true ); 645 // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true );
438 a->setOn(reader->btextfmt); 646 // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 );
439 connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) );
440
441 a = new QAction( tr( "HTML" ), QString::null, 0, ag, NULL, true );
442 a->setOn(reader->bstriphtml);
443 connect( a, SIGNAL( toggled(bool) ), this, SLOT( striphtml(bool) ) );
444
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
449 ag->addTo(encoding);
450
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 );
@@ -522,85 +656,61 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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
@@ -617,2 +727,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
617 727
728
618#ifdef __ISEARCH 729#ifdef __ISEARCH
@@ -624,3 +735,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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() ) );
@@ -628,3 +739,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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() ) );
@@ -647,3 +758,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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() ) );
@@ -651,3 +762,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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() ) );
@@ -661,3 +772,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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);
@@ -665,6 +776,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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;
@@ -676,3 +789,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 }
@@ -680,5 +793,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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
@@ -686,12 +800,11 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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);
@@ -699,5 +812,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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)
@@ -721,3 +834,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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;
@@ -726,4 +839,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
726 { 839 {
727 qDebug("openfrombkmk"); 840 //qDebug("openfrombkmk");
728 openfrombkmk(p); 841 if (!openfrombkmk(p))
842 showEditTools();
729 } 843 }
@@ -731,3 +845,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
731 { 845 {
732 qDebug("openfile"); 846 //qDebug("openfile");
733 openFile( reader->m_lastfile ); 847 openFile( reader->m_lastfile );
@@ -737,4 +851,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 );
@@ -742,6 +856,267 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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}
@@ -750,2 +1125,3 @@ void 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)
@@ -754,3 +1130,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
754 1130
755// qDebug("Received:%s", (const char*)msg); 1131//// qDebug("Received:%s", (const char*)msg);
756 1132
@@ -763,2 +1139,16 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
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)" )
@@ -769,4 +1159,2 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
769 } 1159 }
770
771
772 else if ( msg == "exit()" ) 1160 else if ( msg == "exit()" )
@@ -796,2 +1184,14 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
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)" )
@@ -806,11 +1206,9 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
806 } 1206 }
807 else if ( msg == "File/Start Block()" ) 1207 else if ( msg == "File/Action(QString)" )
808 { 1208 {
809 editMark(); 1209 QString info;
810 } 1210 stream >> info;
811 else if ( msg == "File/Copy Block()" ) 1211 m_spaceTarget = ActNameToInt(info);
812 {
813 editCopy();
814 } 1212 }
815 else if ( msg == "File/Scroll(int)" ) 1213 else if ( msg == "Navigation/Scroll(int)" )
816 { 1214 {
@@ -820,3 +1218,12 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
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 {
@@ -826,3 +1233,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
826 } 1233 }
827 else if ( msg == "File/Page/Line Scroll(int)" ) 1234 else if ( msg == "Navigation/Page/LineScroll(int)" )
828 { 1235 {
@@ -832,3 +1239,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
832 } 1239 }
833 else if ( msg == "File/Set Overlap(int)" ) 1240 else if ( msg == "Navigation/SetOverlap(int)" )
834 { 1241 {
@@ -838,2 +1245,8 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
838 } 1245 }
1246 else if ( msg == "Navigation/SetMargin(int)" )
1247 {
1248 int info;
1249 stream >> info;
1250 do_margin(info);
1251 }
839 else if ( msg == "File/Set Dictionary(QString)" ) 1252 else if ( msg == "File/Set Dictionary(QString)" )
@@ -844,2 +1257,10 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
844 } 1257 }
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
845 else if ( msg == "File/Two/One Touch(int)" ) 1266 else if ( msg == "File/Two/One Touch(int)" )
@@ -876,3 +1297,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
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)
@@ -880,3 +1301,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
880 pos = reader->locate(); 1301 pos = reader->locate();
881 if (!reader->buffdoc.getline(&test,reader->width())) 1302 if (!reader->getline(&test))
882 { 1303 {
@@ -889,3 +1310,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
889 } 1310 }
890 else if ( msg == "Layout/Strip CR(int)" ) 1311 else if ( msg == "File/Fullscreen(int)" )
891 { 1312 {
@@ -893,5 +1314,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
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 {
@@ -899,6 +1320,33 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
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 {
@@ -906,6 +1354,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
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 {
@@ -913,5 +1360,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
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 {
@@ -919,5 +1366,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
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 {
@@ -925,5 +1372,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
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 {
@@ -931,5 +1378,6 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
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 {
@@ -937,4 +1385,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
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)" )
@@ -982,3 +1431,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
982 } 1431 }
983 else if ( msg == "Format/Set width(int)" ) 1432 else if ( msg == "Format/SetWidth(int)" )
984 { 1433 {
@@ -990,8 +1439,2 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
990 } 1439 }
991 else if ( msg == "Format/Encoding(QString)" )
992 {
993 QString info;
994 stream >> info;
995 reader->setencoding(EncNameToInt(info));
996 }
997 else if ( msg == "Format/Set Font(QString,int)" ) 1440 else if ( msg == "Format/Set Font(QString,int)" )
@@ -1010,4 +1453,12 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
1010 } 1453 }
1454 else if ( msg == "File/StartBlock()" )
1455 {
1456 editMark();
1011} 1457}
1012 1458 else if ( msg == "File/CopyBlock()" )
1459 {
1460 editCopy();
1461 }
1462}
1463#endif
1013ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) 1464ActionTypes QTReaderApp::ActNameToInt(const QString& _enc)
@@ -1026,3 +1477,3 @@ void QTReaderApp::setfullscreen(bool sfs)
1026 showEditTools(); 1477 showEditTools();
1027 qApp->processEvents(); 1478// qApp->processEvents();
1028 reader->bDoUpdates = true; 1479 reader->bDoUpdates = true;
@@ -1031,32 +1482,5 @@ void QTReaderApp::setfullscreen(bool sfs)
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());
@@ -1093,2 +1517,5 @@ void QTReaderApp::fileClose()
1093{ 1517{
1518 CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this);
1519 if (cd->exec())
1520 {
1094 if (pOpenlist != NULL) 1521 if (pOpenlist != NULL)
@@ -1102,11 +1529,25 @@ void QTReaderApp::fileClose()
1102 if (p != NULL) pOpenlist->erase(ind); 1529 if (p != NULL) pOpenlist->erase(ind);
1103 switch (QMessageBox::information ( this , PROGNAME, "What do you want to delete?", "Nothing", "Marks", "Marks\nFile", 1, 0 )) 1530 if (cd->delFile())
1104 { 1531 {
1105 case 0:
1106 default:
1107 break;
1108 case 2:
1109 unlink((const char*)reader->m_lastfile); 1532 unlink((const char*)reader->m_lastfile);
1110 case 1: 1533 }
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 */
1111 unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string)); 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 */
1112 } 1553 }
@@ -1116,2 +1557,4 @@ void QTReaderApp::fileClose()
1116} 1557}
1558 delete cd;
1559}
1117 1560
@@ -1119,7 +1562,7 @@ void 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;
@@ -1137,3 +1580,3 @@ void QTReaderApp::updatefileinfo()
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);
@@ -1146,3 +1589,3 @@ void QTReaderApp::updatefileinfo()
1146 } 1589 }
1147 qDebug("Added?:%x", notadded); 1590// qDebug("Added?:%x", notadded);
1148 if (notadded) 1591 if (notadded)
@@ -1156,3 +1599,3 @@ void QTReaderApp::updatefileinfo()
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;
@@ -1167,3 +1610,3 @@ void QTReaderApp::fileOpen()
1167 menu->hide(); 1610 menu->hide();
1168 editBar->hide(); 1611 fileBar->hide();
1169 if (regVisible) regBar->hide(); 1612 if (regVisible) regBar->hide();
@@ -1171,3 +1614,3 @@ void QTReaderApp::fileOpen()
1171*/ 1614*/
1172 qDebug("fileOpen"); 1615// qDebug("fileOpen");
1173// if (!reader->m_lastfile.isEmpty()) 1616// if (!reader->m_lastfile.isEmpty())
@@ -1195,10 +1638,12 @@ void QTReaderApp::fileOpen2()
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())
@@ -1209,2 +1654,4 @@ void QTReaderApp::fileOpen2()
1209 } 1654 }
1655// reader->refresh();
1656// qDebug("HEIGHT:%d", reader->m_lastheight);
1210} 1657}
@@ -1213,3 +1660,7 @@ QString 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,
@@ -1222,12 +1673,16 @@ QString QTReaderApp::usefilebrowser()
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 );
@@ -1236,2 +1691,230 @@ void QTReaderApp::showgraphic(QPixmap& pm)
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()
@@ -1354,3 +2037,5 @@ void QTReaderApp::addanno()
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();
@@ -1390,2 +2075,6 @@ void QTReaderApp::editCopy()
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);
@@ -1397,68 +2086,25 @@ void QTReaderApp::editCopy()
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)
@@ -1467,11 +2113,4 @@ void QTReaderApp::pagemode(bool _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()
@@ -1484,12 +2123,3 @@ void QTReaderApp::setspacing()
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()
@@ -1504,14 +2134,3 @@ void QTReaderApp::settarget()
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)
@@ -1530,3 +2149,3 @@ void QTReaderApp::do_mono(const QString& lcn)
1530} 2149}
1531 2150*/
1532/* 2151/*
@@ -1546,3 +2165,5 @@ void QTReaderApp::editFind()
1546#endif 2165#endif
2166#ifdef USEQPE
1547 Global::showInputMethod(); 2167 Global::showInputMethod();
2168#endif
1548 searchBar->show(); 2169 searchBar->show();
@@ -1557,3 +2178,3 @@ void QTReaderApp::findNext()
1557{ 2178{
1558 // qDebug("findNext called\n"); 2179// // qDebug("findNext called\n");
1559#ifdef __ISEARCH 2180#ifdef __ISEARCH
@@ -1566,3 +2187,3 @@ void QTReaderApp::findNext()
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);
@@ -1574,3 +2195,5 @@ void QTReaderApp::findClose()
1574 searchEdit->setText(""); 2195 searchEdit->setText("");
2196#ifdef USEQPE
1575 Global::hideInputMethod(); 2197 Global::hideInputMethod();
2198#endif
1576 searchBar->hide(); 2199 searchBar->hide();
@@ -1592,3 +2215,5 @@ void QTReaderApp::regClose()
1592 regBar->hide(); 2215 regBar->hide();
2216#ifdef USEQPE
1593 Global::hideInputMethod(); 2217 Global::hideInputMethod();
2218#endif
1594 reader->setFocus(); 2219 reader->setFocus();
@@ -1606,9 +2231,12 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
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();
2240 if (reader->buffdoc.getpara(test) >= 0)
2241 {
1614 reader->setFocus(); 2242 reader->setFocus();
@@ -1618,3 +2246,3 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
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
@@ -1625,3 +2253,2 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
1625 pos = reader->locate(); 2253 pos = reader->locate();
1626 unsigned int lcn = reader->locate();
1627 int pc = (100*pos)/ts; 2254 int pc = (100*pos)/ts;
@@ -1635,3 +2262,3 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
1635 2262
1636 if (!reader->buffdoc.getline(&test,reader->width())) 2263 if (reader->buffdoc.getpara(test) < 0)
1637 { 2264 {
@@ -1641,9 +2268,25 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
1641 pos = start; 2268 pos = start;
1642 ret = false;
1643 findClose(); 2269 findClose();
1644 break; 2270 pbar->hide();
2271 reader->locate(pos);
2272 return false;
1645 } 2273 }
1646 } 2274 }
2275// qDebug("Found it at %u:%u", pos, offset);
1647 pbar->hide(); 2276 pbar->hide();
1648 reader->locate(pos); 2277// qDebug("Hid");
2278 reader->locate(pos+offset);
2279// qDebug("Loacted");
2280// qDebug("page up");
2281 ret = true;
2282 }
2283 else
2284 {
2285 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
2286 pos = searchStart;
2287 else
2288 pos = start;
2289 ret = false;
2290 findClose();
2291 }
1649 return ret; 2292 return ret;
@@ -1693,3 +2336,3 @@ void 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));
@@ -1704,3 +2347,3 @@ void QTReaderApp::openFile( const QString &f )
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")
@@ -1712,3 +2355,3 @@ void QTReaderApp::openFile( const QString &f )
1712 } 2355 }
1713 2356#endif
1714 clear(); 2357 clear();
@@ -1716,4 +2359,6 @@ void QTReaderApp::openFile( const QString &f )
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 }
@@ -1722,2 +2367,3 @@ void QTReaderApp::openFile( const QString &f )
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 }
@@ -1735,6 +2381,13 @@ void QTReaderApp::resizeEvent(QResizeEvent* e)
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 {
2390 return;
2391 }
2392 m_lastkeytime = now;
1740 switch(e->key()) 2393 switch(e->key())
@@ -1742,6 +2395,14 @@ void QTReaderApp::keyPressEvent(QKeyEvent* e)
1742 case Key_Escape: 2395 case Key_Escape:
1743 m_actFullscreen->setOn(false); 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 }
@@ -1749,14 +2410,22 @@ void QTReaderApp::keyPressEvent(QKeyEvent* e)
1749 { 2410 {
1750 m_fullscreen = false; 2411 // qDebug("escape action");
1751 reader->bDoUpdates = false; 2412 doAction(m_escapeTarget, e);
1752 showEditTools(); 2413 }
1753 qApp->processEvents();
1754 reader->bDoUpdates = true;
1755 reader->update();
1756 } 2414 }
1757 e->accept();
1758 break; 2415 break;
1759 default: 2416 case Key_Space:
1760 e->ignore(); 2417 {
2418 doAction(m_spaceTarget, e);
2419 }
2420 break;
2421 case Key_Return:
2422 {
2423 doAction(m_returnTarget, e);
1761 } 2424 }
2425 break;
2426 case Key_Left:
2427 {
2428 if (reader->m_autoScroll && m_leftScroll)
2429 {
2430 reader->reduceScroll();
1762 } 2431 }
@@ -1764,4 +2433,54 @@ void QTReaderApp::keyPressEvent(QKeyEvent* e)
1764 { 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 {
1765 e->ignore(); 2476 e->ignore();
1766 } 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*/
2485 }
1767} 2486}
@@ -1774,6 +2493,12 @@ void QTReaderApp::showEditTools()
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();
@@ -1784,9 +2509,18 @@ void QTReaderApp::showEditTools()
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();
2525#endif
1792 searchBar->show(); 2526 searchBar->show();
@@ -1795,3 +2529,5 @@ void QTReaderApp::showEditTools()
1795 { 2529 {
2530#ifdef USEQPE
1796 Global::showInputMethod(); 2531 Global::showInputMethod();
2532#endif
1797 regBar->show(); 2533 regBar->show();
@@ -1799,6 +2535,8 @@ void QTReaderApp::showEditTools()
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);
@@ -1806,8 +2544,9 @@ void QTReaderApp::showEditTools()
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}
@@ -1878,2 +2617,3 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
1878{ 2617{
2618// qDebug("Close event");
1879 if (m_fullscreen) 2619 if (m_fullscreen)
@@ -1892,2 +2632,10 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
1892 { 2632 {
2633 if ((m_escapeTarget != cesNone) && m_bcloseDisabled)
2634 {
2635 //qDebug("Close disabled");
2636 m_bcloseDisabled = false;
2637 e->ignore();
2638 }
2639 else
2640 {
1893 if (m_fontVisible) 2641 if (m_fontVisible)
@@ -1900,3 +2648,5 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
1900 regBar->hide(); 2648 regBar->hide();
2649#ifdef USEQPE
1901 Global::hideInputMethod(); 2650 Global::hideInputMethod();
2651#endif
1902 regVisible = false; 2652 regVisible = false;
@@ -1907,3 +2657,5 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
1907 searchBar->hide(); 2657 searchBar->hide();
2658#ifdef USEQPE
1908 Global::hideInputMethod(); 2659 Global::hideInputMethod();
2660#endif
1909 searchVisible = false; 2661 searchVisible = false;
@@ -1924,2 +2676,3 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
1924 } 2676 }
2677 }
1925 else 2678 else
@@ -1927,2 +2680,3 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
1927 showEditTools(); 2680 showEditTools();
2681 m_disableesckey = true;
1928 } 2682 }
@@ -1933,4 +2687,5 @@ void 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}
@@ -1939,10 +2694,11 @@ void 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");
@@ -1956,3 +2712,3 @@ void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
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()));
@@ -1966,19 +2722,8 @@ void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
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}
@@ -1994,11 +2739,13 @@ void 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;
@@ -2012,6 +2759,6 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
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);
@@ -2037,3 +2784,4 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
2037 } 2784 }
2038 qDebug("updating"); 2785 // qDebug("updating");
2786 // showEditTools();
2039 reader->locate(bk->value()); 2787 reader->locate(bk->value());
@@ -2050,3 +2798,4 @@ void QTReaderApp::gotobkmk(int ind)
2050{ 2798{
2051 switch (m_nRegAction) 2799 showEditTools();
2800 switch (m_nBkmkAction)
2052 { 2801 {
@@ -2054,2 +2803,3 @@ void QTReaderApp::gotobkmk(int ind)
2054 { 2803 {
2804 // qApp->processEvents();
2055 if (!openfrombkmk((*pOpenlist)[ind])) 2805 if (!openfrombkmk((*pOpenlist)[ind]))
@@ -2065,3 +2815,3 @@ void QTReaderApp::gotobkmk(int ind)
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);
@@ -2071,6 +2821,129 @@ void QTReaderApp::gotobkmk(int ind)
2071 case cRmBkmkFile: 2821 case cRmBkmkFile:
2822 {
2823#ifndef USEQPE
2824 QDir d = QDir::home(); // "/"
2825 d.cd(APPDIR);
2826 d.remove(bkmkselector->text(ind));
2827#else /* USEQPE */
2072 unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); 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 }
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 }
2073 break; 2947 break;
2074 } 2948 }
2075 showEditTools();
2076} 2949}
@@ -2079,3 +2952,3 @@ void QTReaderApp::cancelbkmk()
2079{ 2952{
2080 if (m_nRegAction == cOpenFile) 2953 if (m_nBkmkAction == cOpenFile)
2081 { 2954 {
@@ -2110,3 +2983,5 @@ void QTReaderApp::do_regaction()
2110 regBar->hide(); 2983 regBar->hide();
2984#ifdef USEQPE
2111 Global::hideInputMethod(); 2985 Global::hideInputMethod();
2986#endif
2112 regVisible = false; 2987 regVisible = false;
@@ -2123,2 +2998,3 @@ void QTReaderApp::do_regaction()
2123 break; 2998 break;
2999/*
2124 case cMonoSpace: 3000 case cMonoSpace:
@@ -2126,5 +3002,3 @@ void QTReaderApp::do_regaction()
2126 break; 3002 break;
2127 case cOverlap: 3003*/
2128 do_overlap(regEdit->text());
2129 break;
2130 case cSetTarget: 3004 case cSetTarget:
@@ -2132,7 +3006,16 @@ void QTReaderApp::do_regaction()
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;
@@ -2157,4 +3040,33 @@ void QTReaderApp::do_settarget(const QString& _txt)
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++)
@@ -2167,2 +3079,3 @@ void QTReaderApp::setfont()
2167 } 3079 }
3080 m_fontAction = cChooseFont;
2168 m_fontBar->show(); 3081 m_fontBar->show();
@@ -2174,19 +3087,24 @@ void QTReaderApp::setfontHelper(const QString& lcn, int size)
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 {
3090 QFont f(lcn, 10);
2177 bkmkselector->setFont( f ); 3091 bkmkselector->setFont( f );
2178 qDebug("re");
2179 regEdit->setFont( f ); 3092 regEdit->setFont( f );
2180 qDebug("se");
2181 searchEdit->setFont( f ); 3093 searchEdit->setFont( f );
2182 qDebug("aw");
2183 m_annoWin->setFont( f ); 3094 m_annoWin->setFont( f );
3095 }
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();
@@ -2194,5 +3112,5 @@ void QTReaderApp::setfontHelper(const QString& lcn, int size)
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}
@@ -2201,4 +3119,14 @@ void QTReaderApp::do_setfont(const QString& lcn)
2201{ 3119{
3120 if (m_fontAction == cChooseFont)
3121 {
2202 setfontHelper(lcn); 3122 setfontHelper(lcn);
2203} 3123}
3124 reader->refresh();
3125 m_fontBar->hide();
3126 m_fontVisible = false;
3127// qDebug("showedit");
3128 //if (reader->isVisible())
3129 showEditTools();
3130// qDebug("showeditdone");
3131}
2204 3132
@@ -2208,3 +3136,3 @@ void QTReaderApp::do_autogen(const QString& regText)
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;
@@ -2215,5 +3143,8 @@ void QTReaderApp::do_autogen(const QString& regText)
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();
@@ -2247,2 +3178,3 @@ pbar->resize(width(), editBar->height());
2247 pbar->hide(); 3178 pbar->hide();
3179 reader->refresh();
2248} 3180}
@@ -2251,3 +3183,8 @@ void 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 );
@@ -2257,2 +3194,3 @@ void QTReaderApp::saveprefs()
2257 3194
3195 config.writeEntry("FloatDialogs", m_bFloatingDialog);
2258 config.writeEntry( "StripCr", reader->bstripcr ); 3196 config.writeEntry( "StripCr", reader->bstripcr );
@@ -2262,2 +3200,4 @@ void QTReaderApp::saveprefs()
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 );
@@ -2272,4 +3212,4 @@ void QTReaderApp::saveprefs()
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 );
@@ -2278,4 +3218,9 @@ void QTReaderApp::saveprefs()
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 );
@@ -2285,2 +3230,12 @@ void QTReaderApp::saveprefs()
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
@@ -2292,3 +3247,13 @@ void QTReaderApp::saveprefs()
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();
@@ -2296,12 +3261,2 @@ void QTReaderApp::saveprefs()
2296 3261
2297void QTReaderApp::indentplus()
2298{
2299 reader->indentplus();
2300}
2301
2302void QTReaderApp::indentminus()
2303{
2304 reader->indentminus();
2305}
2306
2307/* 3262/*
@@ -2309,7 +3264,7 @@ void 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}
@@ -2366,3 +3321,10 @@ void QTReaderApp::savebkmks()
2366 { 3321 {
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 */
2367 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string), true); 3328 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string), true);
3329#endif /* USEQPE */
2368 bf.write(*pBkmklist); 3330 bf.write(*pBkmklist);
@@ -2374,7 +3336,14 @@ void QTReaderApp::readfilelist()
2374{ 3336{
3337#ifndef USEQPE
3338 QDir d = QDir::home(); // "/"
3339 d.cd(APPDIR);
3340 QFileInfo fi(d, ".openfiles");
3341 BkmkFile bf((const char *)fi.absFilePath());
3342#else /* USEQPE */
2375 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles")); 3343 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"));
2376 qDebug("Reading open files"); 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}
@@ -2385,4 +3354,11 @@ void QTReaderApp::savefilelist()
2385 { 3354 {
3355#ifndef USEQPE
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 */
2386 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"), true); 3361 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"), true);
2387 qDebug("Writing open files"); 3362#endif /* USEQPE */
3363 //qDebug("Writing open files");
2388 bf.write(*pOpenlist); 3364 bf.write(*pOpenlist);
@@ -2399,2 +3375,7 @@ void QTReaderApp::readbkmks()
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 (
@@ -2402,3 +3383,7 @@ void QTReaderApp::readbkmks()
2402 && 3383 &&
3384#ifndef USEQPE
3385 stat((const char *)fi.absFilePath(), &bkstat) == 0
3386#else /* USEQPE */
2403 stat((const char *)Global::applicationFileName(APPDIR, reader->m_string), &bkstat) == 0 3387 stat((const char *)Global::applicationFileName(APPDIR, reader->m_string), &bkstat) == 0
3388#endif /* USEQPE */
2404 ) 3389 )
@@ -2407,3 +3392,7 @@ void QTReaderApp::readbkmks()
2407 { 3392 {
3393#ifndef USEQPE
3394 unlink((const char *)fi.absFilePath());
3395#else /* USEQPE */
2408 unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string)); 3396 unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string));
3397#endif /* USEQPE */
2409 } 3398 }
@@ -2411,3 +3400,7 @@ void QTReaderApp::readbkmks()
2411 3400
3401#ifndef USEQPE
3402 BkmkFile bf((const char *)fi.absFilePath());
3403#else /* USEQPE */
2412 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string)); 3404 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string));
3405#endif /* USEQPE */
2413 3406
@@ -2458,3 +3451,3 @@ void QTReaderApp::OnRedraw()
2458{ 3451{
2459 if (pBkmklist != NULL) 3452 if ((pBkmklist != NULL) && (m_bkmkAvail != NULL))
2460 { 3453 {
@@ -2470,3 +3463,5 @@ void QTReaderApp::showAnnotation()
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 );
@@ -2477,3 +3472,3 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString&
2477{ 3472{
2478// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); 3473//// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd);
2479 3474
@@ -2483,2 +3478,3 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString&
2483 cb->setText(wrd); 3478 cb->setText(wrd);
3479#ifdef USEQPE
2484 if (wrd.length() > 10) 3480 if (wrd.length() > 10)
@@ -2491,2 +3487,3 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString&
2491 } 3487 }
3488#endif
2492 } 3489 }
@@ -2499,5 +3496,8 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString&
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)
@@ -2510,7 +3510,16 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString&
2510 } 3510 }
3511#endif
2511} 3512}
2512 3513
2513void QTReaderApp::OnActionPressed() 3514void QTReaderApp::doAction(ActionTypes a, QKeyEvent* e)
3515{
3516 if (a == 0)
3517 {
3518 e->ignore();
3519 }
3520 else
2514{ 3521{
2515 switch (m_spaceTarget) 3522 e->accept();
3523 //qDebug("Accepted");
3524 switch (a)
2516 { 3525 {
@@ -2534,10 +3543,47 @@ void QTReaderApp::OnActionPressed()
2534 { 3543 {
2535 m_actFullscreen->setOn(true); 3544 m_actFullscreen->setOn(!m_fullscreen);
2536 } 3545 }
2537 break; 3546 break;
2538 default: 3547 case cesActionAnno:
2539 { 3548 {
2540 qDebug("Unknown ActionType:%u", m_spaceTarget); 3549 addanno();
2541 } 3550 }
2542 break; 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;
3588 }
2543 } 3589 }
@@ -2548,2 +3594,149 @@ void QTReaderApp::restoreFocus() { reader->setFocus(); }
2548 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)
3626 {
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);
3637 }
3638 else
3639 {
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);
3657 }
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
3739 }
3740}
3741
2549/* 3742/*
@@ -2586,2 +3779,4 @@ void QTReaderApp::getstate(unsigned char*& data, unsigned short& len)
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;
@@ -2591,3 +3786,2 @@ void QTReaderApp::getstate(unsigned char*& data, unsigned short& len)
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;
@@ -2606 +3800,423 @@ void QTReaderApp::getstate(unsigned char*& data, unsigned short& len)
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
@@ -22,11 +22,15 @@
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>
@@ -41,3 +45,6 @@ class QPopupMenu;
41class QToolBar; 45class QToolBar;
42//class QPEToolBar; 46#ifdef USEQPE
47class QPEToolBar;
48class QPEMenuBar;
49#endif
43class CBkmkSelector; 50class CBkmkSelector;
@@ -49,3 +56,4 @@ class CDrawBuffer;
49class QTReader; 56class QTReader;
50class QPixmap; 57class QImage;
58class Config;
51 59
@@ -53,6 +61,65 @@ enum 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};
@@ -76,3 +143,9 @@ class QTReaderApp : public QMainWindow
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
@@ -81,2 +154,9 @@ class QTReaderApp : public QMainWindow
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();
@@ -92,3 +172,2 @@ class QTReaderApp : public QMainWindow
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 );
@@ -97,5 +176,9 @@ class QTReaderApp : public QMainWindow
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&);
@@ -105,10 +188,20 @@ class QTReaderApp : public QMainWindow
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);
@@ -128,3 +221,4 @@ private slots:
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);
@@ -133,11 +227,14 @@ private slots:
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();
@@ -150,2 +247,4 @@ private slots:
150 //void importFiles(); 247 //void importFiles();
248 void showprefs();
249 void showtoolbarprefs();
151 void infoClose(); 250 void infoClose();
@@ -153,6 +252,5 @@ private slots:
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
@@ -164,2 +262,5 @@ private slots:
164 262
263 void gotoStart();
264 void gotoEnd();
265
165 void pageup(); 266 void pageup();
@@ -180,4 +281,5 @@ private slots:
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
@@ -185,14 +287,15 @@ private slots:
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);
@@ -205,5 +308,34 @@ private slots:
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/*
@@ -218,3 +350,3 @@ private slots:
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();
@@ -232,4 +364,2 @@ private slots:
232 364
233 QAction* m_EncodingAction[MAX_ENCODING];
234
235 QAction* m_buttonAction[MAX_ACTIONS]; 365 QAction* m_buttonAction[MAX_ACTIONS];
@@ -238,3 +368,6 @@ private slots:
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;
@@ -249,4 +382,9 @@ private slots:
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*/;
@@ -263,4 +401,4 @@ private slots:
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 );
@@ -274,3 +412,5 @@ private slots:
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;
@@ -279,13 +419,24 @@ private slots:
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
@@ -11,2 +11,3 @@ struct statedata
11 bool bdehyphen/*:1*/; 11 bool bdehyphen/*:1*/;
12 bool bdepluck/*:1*/;
12 bool bonespace/*:1*/; 13 bool bonespace/*: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,3 +1,3 @@
1 1
2#include <qpixmap.h> 2#include <qimage.h>
3#include "StyleConsts.h" 3#include "StyleConsts.h"
@@ -8,3 +8,3 @@ pmstore::~pmstore()
8{ 8{
9// qDebug("Deleting image"); 9//// qDebug("Deleting image");
10 delete graphic; 10 delete graphic;
@@ -23,7 +23,2 @@ CStyle::~CStyle()
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)
@@ -87,3 +82,3 @@ void CStyle::unset()
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{
@@ -97,3 +92,3 @@ void CStyle::setPicture(QPixmap* _g, bool il, unsigned long tgt)
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
@@ -5,6 +5,8 @@ typedef 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
@@ -12,6 +14,6 @@ struct 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) {}
@@ -23,4 +25,5 @@ struct pmstore
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 {
@@ -53,2 +56,4 @@ class CBasicStyle
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()
@@ -75,2 +80,4 @@ class CBasicStyle
75 m_monospaced = false; 80 m_monospaced = false;
81 m_extraspace = 0;
82 m_voffset = 0;
76 } 83 }
@@ -83,2 +90,6 @@ class CStyle
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()
@@ -106,3 +117,3 @@ class CStyle
106 ~CStyle(); 117 ~CStyle();
107 CStyle(CStyle&); 118// CStyle(CStyle&);
108 CStyle(const CStyle&); 119 CStyle(const CStyle&);
@@ -111,7 +122,8 @@ class CStyle
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;
@@ -159,3 +171,3 @@ class CStyle
159 } 171 }
160 int getFontSize() 172 int getFontSize() const
161 { 173 {
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
@@ -3,5 +3,5 @@
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"
@@ -12,4 +12,5 @@ class Text: public CExpander {
12public: 12public:
13 virtual void suspend() 13 void suspend()
14 { 14 {
15#ifdef USEQPE
15 bSuspended = true; 16 bSuspended = true;
@@ -19,5 +20,7 @@ public:
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)
@@ -40,2 +43,3 @@ public:
40 } 43 }
44#endif
41 } 45 }
@@ -46,3 +50,3 @@ public:
46 } 50 }
47 virtual int OpenFile(const char *src) 51 int OpenFile(const char *src)
48 { 52 {
@@ -54,11 +58,24 @@ public:
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 {
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
@@ -12,2 +12,3 @@ Extensive modification by Tim Wentford to allow it to work in rotated mode
12#include "QtrListView.h" 12#include "QtrListView.h"
13#include <qlineedit.h>
13#include <qpushbutton.h> 14#include <qpushbutton.h>
@@ -15,7 +16,16 @@ Extensive modification by Tim Wentford to allow it to work in rotated mode
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{
@@ -24,3 +34,14 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
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" ) );
@@ -68,2 +89,12 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
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
@@ -72,3 +103,7 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
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 }
@@ -81,2 +116,4 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
81 populateList(); 116 populateList();
117
118 if (modal) showMaximized();
82} 119}
@@ -97,3 +134,3 @@ void fileBrowser::populateList()
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 );
@@ -121,3 +158,3 @@ void fileBrowser::populateList()
121 { 158 {
122// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 159//// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
123 } 160 }
@@ -134,3 +171,3 @@ void fileBrowser::upDir()
134{ 171{
135// qDebug(currentDir.canonicalPath()); 172//// qDebug(currentDir.canonicalPath());
136} 173}
@@ -142,3 +179,3 @@ void fileBrowser::listClicked(QListViewItem *selectedItem)
142 179
143// qDebug("%s", (const char*)strItem); 180//// qDebug("%s", (const char*)strItem);
144 181
@@ -163,3 +200,14 @@ void fileBrowser::listClicked(QListViewItem *selectedItem)
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());
@@ -174,12 +222,9 @@ void fileBrowser::listDoubleClicked(QListViewItem *selectedItem)
174 222
175void fileBrowser::OnOK() { 223QString fileBrowser::getCurrentFile()
176 224{
177 QListViewItemIterator it1( ListView); 225 return filename;
178 for ( ; it1.current(); ++it1 ) {
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 } 226 }
227
228void fileBrowser::OnOK()
229{
185 accept(); 230 accept();
@@ -207 +252,15 @@ void fileBrowser::setHidden(bool _hidden)
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
@@ -31,2 +31,3 @@ class QListViewItem;
31class QPushButton; 31class QPushButton;
32class QLineEdit;
32 33
@@ -38,3 +39,3 @@ public:
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();
@@ -49,3 +50,4 @@ public:
49 QFile file; 50 QFile file;
50 QStringList fileList; 51 QString getCurrentFile();
52 QLineEdit* m_filename;
51 int filterspec; 53 int filterspec;
@@ -57,3 +59,3 @@ public slots:
57private: 59private:
58 60 QString filename;
59private slots: 61private slots:
@@ -65,2 +67,3 @@ private slots:
65 void setHidden(bool); 67 void setHidden(bool);
68 void onReturn();
66 69
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,2 +1 @@
1#include "name.h"
2#include "infowin.h" #include "infowin.h"
@@ -4,2 +3,3 @@
4#include <stdio.h> 3#include <stdio.h>
4#include "names.h"
5 5
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,2 +1,7 @@
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"
@@ -7,2 +12,4 @@
7 12
13
14#ifdef USEQPE
8QTReaderApp* app = NULL; 15QTReaderApp* app = NULL;
@@ -18,2 +25,3 @@ void handler(int signum)
18} 25}
26#endif
19 27
@@ -21,11 +29,19 @@ int 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
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
@@ -9,5 +9,8 @@ HEADERS = Aportis.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 \
@@ -17,2 +20,3 @@ HEADERS = Aportis.h \
17 Palm2QImage.h \ 20 Palm2QImage.h \
21 Prefs.h \
18 QFloatBar.h \ 22 QFloatBar.h \
@@ -24,2 +28,4 @@ HEADERS = Aportis.h \
24 StyleConsts.h \ 28 StyleConsts.h \
29 ToolbarPrefs.h \
30 URLDialog.h \
25 ZText.h \ 31 ZText.h \
@@ -30,4 +36,6 @@ HEADERS = Aportis.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 \
@@ -35,2 +43,3 @@ HEADERS = Aportis.h \
35 plucker.h \ 43 plucker.h \
44 plucker_base.h \
36 ppm.h \ 45 ppm.h \
@@ -38,2 +47,4 @@ HEADERS = Aportis.h \
38 ustring.h \ 47 ustring.h \
48 usenef.h \
49 useqpe.h \
39 utypes.h \ 50 utypes.h \
@@ -48,3 +59,5 @@ SOURCES = Aportis.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 \
@@ -52,2 +65,3 @@ SOURCES = Aportis.cpp \
52 Palm2QImage.cpp \ 65 Palm2QImage.cpp \
66 Prefs.cpp \
53 QTReader.cpp \ 67 QTReader.cpp \
@@ -56,2 +70,4 @@ SOURCES = Aportis.cpp \
56 StyleConsts.cpp \ 70 StyleConsts.cpp \
71 ToolbarPrefs.cpp \
72 URLDialog.cpp \
57 arith_d.cpp \ 73 arith_d.cpp \
@@ -62,4 +78,6 @@ SOURCES = Aportis.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
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,5 +1,5 @@
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
@@ -51,9 +51,6 @@ bool Cpdb::openfile(const char *src)
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
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
@@ -13,3 +13,5 @@
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>
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 +1,2 @@
1#include "useqpe.h"
1#include <stdio.h> 2#include <stdio.h>
@@ -4,3 +5,5 @@
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
@@ -8,5 +11,9 @@
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
@@ -15,196 +22,35 @@
15#include "Palm2QImage.h" 22#include "Palm2QImage.h"
16#include "name.h"
17
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 23
28 24
29void CPlucker::Expand(UInt16 reclen, UInt8 type, UInt8* buffer, UInt16 buffersize) 25struct CPlucker_dataRecord
30{
31 if (type%2 == 0)
32 {
33 fread(buffer, reclen, sizeof(char), fin);
34 }
35 else
36 {
37 fread(compressedtextbuffer, reclen, sizeof(char), fin);
38 switch (ntohs(hdr0.version))
39 { 26 {
40 case 2: 27 UInt16 uid;
41 UnZip(reclen, buffer, buffersize); 28 UInt16 nParagraphs;
42 break; 29 UInt16 size;
43 case 1: 30 UInt8 type;
44 UnDoc(reclen, buffer, buffersize); 31 UInt8 reserved;
45 break; 32};
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 } 37 }
57 38
58//printf("Okay %u\n", 4); 39void CPlucker::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved)
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 { 40 {
81 UInt16 id, name; 41 CPlucker_dataRecord thishdr;
82 fread(&name, 1, sizeof(name), fin); 42 fread(&thishdr, 1, HeaderSize(), fin);
83 fread(&id, 1, sizeof(id), fin); 43 uid = ntohs(thishdr.uid);
84 qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); 44 nParagraphs = ntohs(thishdr.nParagraphs);
85 if (ntohs(name) == 0) homerecid = ntohs(id); 45 size = ntohs(thishdr.size);
86 if (ntohs(name) == 2) 46 type = thishdr.type;
87 { 47 reserved = thishdr.reserved;
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} 48}
168 49
169void CPlucker::sizes(unsigned long& _file, unsigned long& _text) 50CPlucker::CPlucker()
170{ 51 { /*printf("constructing:%x\n",fin);*/ }
171 qDebug("Sizes called:%u",textlength);
172 _file = file_length;
173 if (textlength == 0)
174 {
175 for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
176 {
177 CPlucker_dataRecord thisHdr;
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}
186
187
188char* CPlucker::geturl(UInt16 i)
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 52
202CPlucker::~CPlucker() 53bool CPlucker::CorrectDecoder()
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}
@@ -218,5 +64,15 @@ int CPlucker::bgetch()
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;
@@ -230,2 +86,3 @@ int CPlucker::bgetch()
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)
@@ -240,2 +97,4 @@ int CPlucker::bgetch()
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())
@@ -258,3 +117,3 @@ int CPlucker::bgetch()
258 117
259int CPlucker::getch() 118tchar CPlucker::getch(bool fast)
260{ 119{
@@ -262,3 +121,2 @@ int CPlucker::getch()
262 121
263
264 if (EOPPhase > 0) 122 if (EOPPhase > 0)
@@ -269,3 +127,3 @@ int CPlucker::getch()
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();
@@ -289,953 +147,10 @@ int CPlucker::getch()
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}
623
624bool CPlucker::hyperlink(unsigned int n)
625{
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 } 149 }
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 150
1002 for (int i = 1; i < ntohs(head.recordList.numRecords); i++) 151QImage* CPlucker::imagefromdata(UInt8* imgbuffer, UInt32 imgsize)
1003 { 152 {
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
@@ -3,9 +3,3 @@
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
@@ -16,108 +10,27 @@ class QWidget;
16 10
17struct CPlucker_dataRecord 11class CPlucker : public CPlucker_base
18{ 12{
19 UInt16 uid; 13 void start2endSection()
20 UInt16 nParagraphs;
21 UInt16 size;
22 UInt8 type;
23 UInt8 reserved;
24};
25
26struct CPlucker_record0
27{ 14{
28 UInt16 uid; 15 m_currentstart = currentpos-bufferpos;
29 UInt16 version; 16 m_currentend = m_currentstart+buffercontent;
30 UInt16 nRecords; 17 }
31}; 18 void setbuffersize()
32
33struct CPluckerbkmk
34{ 19{
35 UInt32 offset; 20 compressedbuffersize = buffersize = 32*1024;
36 tchar title[MAX_BMRK_LENGTH]; 21 }
37}; 22 int HeaderSize();
23 void GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved);
24 int bgetch();
25 tchar getch(bool fast);
26 UInt8 EOPPhase;
38 27
39const UInt32 CPLUCKER_ID = 0x5458547a;
40 28
41class CPlucker : public CExpander, Cpdb 29
42{ 30 bool CorrectDecoder(); // Virtual
43 unsigned short finduid(unsigned short); 31 void setlink(QString&, const QString&); // Virtual
44 char* geturl(UInt16); 32 QImage* imagefromdata(UInt8*, UInt32); // virtual
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
@@ -3,2 +3,3 @@
3 3
4#include "useqpe.h"
4#include "CExpander.h" 5#include "CExpander.h"
@@ -28,3 +29,4 @@ class ppm_expander : public CExpander {
28public: 29public:
29 virtual void suspend() 30#ifdef USEQPE
31 void suspend()
30 { 32 {
@@ -32,3 +34,3 @@ public:
32 } 34 }
33 virtual void unsuspend() 35 void unsuspend()
34 { 36 {
@@ -36,2 +38,3 @@ public:
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)
@@ -43,11 +46,11 @@ public:
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 {
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
@@ -62,3 +62,13 @@ inline QString toQString(tchar *_p, unsigned int len)
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;
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 +1,3 @@
1#ifndef __VERSION_H
2#define __VERSION_H
1 3
@@ -3,3 +5,5 @@
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
@@ -3,5 +3,10 @@
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/*
@@ -77,3 +82,4 @@ class ztxt : public CExpander, Cpdb
77public: 82public:
78 virtual void suspend() 83#ifdef USEQPE
84 void suspend()
79 { 85 {
@@ -81,3 +87,3 @@ public:
81 } 87 }
82 virtual void unsuspend() 88 void unsuspend()
83 { 89 {
@@ -85,3 +91,4 @@ public:
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 {
@@ -90,3 +97,3 @@ public:
90 } 97 }
91 virtual bool hasrandomaccess() { return (hdr0.randomAccess != 0); } 98 bool hasrandomaccess() { return (hdr0.randomAccess != 0); }
92 virtual ~ztxt() 99 virtual ~ztxt()
@@ -101,8 +108,8 @@ public:
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 {