summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Aportis.cpp8
-rw-r--r--noncore/apps/opie-reader/Aportis.h26
-rw-r--r--noncore/apps/opie-reader/Bkmks.cpp8
-rw-r--r--noncore/apps/opie-reader/BuffDoc.cpp128
-rw-r--r--noncore/apps/opie-reader/BuffDoc.h18
-rw-r--r--noncore/apps/opie-reader/CAnnoEdit.h1
-rw-r--r--noncore/apps/opie-reader/CBuffer.cpp8
-rw-r--r--noncore/apps/opie-reader/CDrawBuffer.cpp281
-rw-r--r--noncore/apps/opie-reader/CDrawBuffer.h17
-rw-r--r--noncore/apps/opie-reader/CEncoding.cpp24
-rw-r--r--noncore/apps/opie-reader/CEncoding.h21
-rw-r--r--noncore/apps/opie-reader/CExpander.h63
-rw-r--r--noncore/apps/opie-reader/CFilter.cpp58
-rw-r--r--noncore/apps/opie-reader/CFilter.h93
-rw-r--r--noncore/apps/opie-reader/Filedata.h4
-rw-r--r--noncore/apps/opie-reader/FontControl.cpp27
-rw-r--r--noncore/apps/opie-reader/FontControl.h63
-rw-r--r--noncore/apps/opie-reader/Navigation.cpp112
-rw-r--r--noncore/apps/opie-reader/Navigation.h2
-rw-r--r--noncore/apps/opie-reader/Palm2QImage.cpp15
-rw-r--r--noncore/apps/opie-reader/Palm2QImage.h2
-rw-r--r--noncore/apps/opie-reader/QFloatBar.h1
-rw-r--r--noncore/apps/opie-reader/QTReader.cpp716
-rw-r--r--noncore/apps/opie-reader/QTReader.h150
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp3074
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.h259
-rw-r--r--noncore/apps/opie-reader/StateData.h1
-rw-r--r--noncore/apps/opie-reader/StyleConsts.cpp13
-rw-r--r--noncore/apps/opie-reader/StyleConsts.h32
-rw-r--r--noncore/apps/opie-reader/ZText.h45
-rw-r--r--noncore/apps/opie-reader/fileBrowser.cpp91
-rw-r--r--noncore/apps/opie-reader/fileBrowser.h9
-rw-r--r--noncore/apps/opie-reader/infowin.cpp4
-rw-r--r--noncore/apps/opie-reader/main.cpp24
-rw-r--r--noncore/apps/opie-reader/opie-reader.pro18
-rw-r--r--noncore/apps/opie-reader/pdb.cpp15
-rw-r--r--noncore/apps/opie-reader/pdb.h2
-rw-r--r--noncore/apps/opie-reader/plucker.cpp1179
-rw-r--r--noncore/apps/opie-reader/plucker.h125
-rw-r--r--noncore/apps/opie-reader/ppm_expander.h25
-rw-r--r--noncore/apps/opie-reader/ustring.h10
-rw-r--r--noncore/apps/opie-reader/version.h6
-rw-r--r--noncore/apps/opie-reader/ztxt.h31
43 files changed, 4114 insertions, 2695 deletions
diff --git a/noncore/apps/opie-reader/Aportis.cpp b/noncore/apps/opie-reader/Aportis.cpp
index b4988da..2f8cdc3 100644
--- a/noncore/apps/opie-reader/Aportis.cpp
+++ b/noncore/apps/opie-reader/Aportis.cpp
@@ -27,16 +27,16 @@ CList<Bkmk>* Aportis::getbkmklist()
for (int i = nRecs; i < nRecs2; i++)
{
char name[17];
name[16] = '\0';
- qDebug("Record:%d, Length:%u",i,recordlength(i));
+// qDebug("Record:%d, Length:%u",i,recordlength(i));
gotorecordnumber(i);
fread(name,1,16,fin);
unsigned long lcn;
fread(&lcn,sizeof(lcn),1,fin);
lcn ^= 0xa5a5a5a5;
lcn = SwapLong(lcn);
- qDebug("Bookmark:%s:%u", name,lcn);
+// qDebug("Bookmark:%s:%u", name,lcn);
tchar tname[17];
memset(tname, 0, sizeof(tname));
for (int i = 0; name[i] != 0; i++)
{
@@ -120,9 +120,9 @@ int Aportis::OpenFile(const char *src)
PeanutHeader hdr0;
gotorecordnumber(0);
fread(&hdr0, sizeof(hdr0), 1, fin);
- qDebug("Version:%x", ntohs(hdr0.Version));
+// qDebug("Version:%x", ntohs(hdr0.Version));
if (hdr0.Version && 0x0200)
{
bCompressed = 2;
}
@@ -181,9 +181,9 @@ int Aportis::OpenFile(const char *src)
currentrec = 0;
cbptr = 0;
outptr = 0;
refreshbuffer();
- qDebug("Number of records:[%u,%u]", nRecs, nRecs2);
+// qDebug("Number of records:[%u,%u]", nRecs, nRecs2);
return ret;
}
int Aportis::getch()
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
@@ -3,9 +3,9 @@
*/
#ifndef __Aportis_h
#define __Aportis_h
-
+#include "useqpe.h"
#include "CExpander.h"
#include "pdb.h"
typedef UInt32 DWORD;
@@ -74,30 +74,32 @@ class Aportis : public CExpander, Cpdb {
unsigned int outptr;
unsigned char circbuf[2048];
char bCompressed;
public:
- virtual void suspend()
+#ifdef USEQPE
+ void suspend()
{
CExpander::suspend(fin);
}
- virtual void unsuspend()
+ void unsuspend()
{
CExpander::unsuspend(fin);
- }
- virtual void sizes(unsigned long& _file, unsigned long& _text)
+ }
+#endif
+ void sizes(unsigned long& _file, unsigned long& _text)
{
_file = dwLen;
_text = dwTLen;
}
- virtual bool hasrandomaccess() { return true; }
+ bool hasrandomaccess() { return true; }
virtual ~Aportis() {}
Aportis();
- virtual int OpenFile(const char *src);
- virtual int getch();
- virtual unsigned int locate();
- virtual void locate(unsigned int n);
- virtual CList<Bkmk>* getbkmklist();
- virtual MarkupType PreferredMarkup()
+ int OpenFile(const char *src);
+ int getch();
+ unsigned int locate();
+ void locate(unsigned int n);
+ CList<Bkmk>* getbkmklist();
+ MarkupType PreferredMarkup()
{
return (peanutfile) ? cPML : cTEXT;
}
private:
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,13 +1,13 @@
-#include "name.h"
#include <qmessagebox.h>
#include "Bkmks.h"
#include "StyleConsts.h"
#include "Markups.h"
#include "my_list.h"
#include "version.h"
+#include "names.h"
const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE);
Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) : m_position(_p)
@@ -218,17 +218,17 @@ CList<Bkmk>* BkmkFile::readall()
{
case 6:
isUpgraded = false;
bl = readall00(read06);
- qDebug("Correct version!");
+// qDebug("Correct version!");
break;
case 5:
isUpgraded = true;
bl = readall00(read05);
- qDebug("Known version!");
+// qDebug("Known version!");
break;
default:
- qDebug("Unknown version!");
+// qDebug("Unknown version!");
isUpgraded = true;
bl = readall00(read05);
}
}
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,45 +1,61 @@
-#include "name.h"
+#include "names.h"
+
+#define NEWLINEBREAK
#include "BuffDoc.h"
//#include <FL/fl_draw.h>
#include "config.h"
#include "CDrawBuffer.h"
#include "plucker.h"
+#include "usenef.h"
+#ifdef USENEF
+#include "nef.h"
+#include "arrierego.h"
+#endif
-
-bool BuffDoc::hyperlink(unsigned int n)
+linkType BuffDoc::hyperlink(unsigned int n, QString& wrd)
{
- bool bRet = false;
- lastword.empty();
- lastsizes[0] = laststartline = n;
- lastispara = false;
+ linkType bRet = eNone;
if (exp != NULL)
{
- bRet = exp->hyperlink(n);
- lastsizes[0] = laststartline = exp->locate();
+ bRet = exp->hyperlink(n, wrd);
+ if (bRet == eLink)
+ {
+ lastword.empty();
+ lastsizes[0] = laststartline = n;
+#ifdef NEWLINEBREAK
+ lastispara = true;
+#else
+ lastispara = false;
+#endif
+ lastsizes[0] = laststartline = exp->locate();
+ }
}
return bRet;
}
void BuffDoc::locate(unsigned int n)
{
- // qDebug("BuffDoc:locating:%u",n);
+ // //qDebug("BuffDoc:locating:%u",n);
lastword.empty();
lastsizes[0] = laststartline = n;
- lastispara = false;
+#ifdef NEWLINEBREAK
+ lastispara = true;
+#else
+ lastispara = false;
+#endif
// tchar linebuf[1024];
if (exp != NULL) exp->locate(n);
- // qDebug("BuffDoc:Located");
+ // //qDebug("BuffDoc:Located");
}
-#define NEWLINEBREAK
#ifdef NEWLINEBREAK
-bool BuffDoc::getline(CDrawBuffer* buff, int wth)
+bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border)
{
bool moreleft = true;
bool margindone = false;
- int w = wth-2*BORDER;
+ int w = wth-2*_border;
tchar ch = 32;
CStyle cs;
buff->empty();
if (exp == NULL)
@@ -59,16 +75,20 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
}
else buff->empty();
lastword.empty();
unsigned int slen = buff->width(len);
- lastispara = false;
+ if (lastispara) buff->setstartpara();
while (1)
{
lastsizes[len] = exp->locate();
getch(ch, cs);
+ if (ch == 10 && len == 0 && !lastispara)
+ {
+ lastsizes[len] = exp->locate();
+ getch(ch, cs);
+ }
if (ch == UEOF)
{
- lastword.empty();
if (len == 0)
{
buff->setEof();
moreleft = false;
@@ -77,13 +97,14 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
break;
}
if (ch == 10)
{
- lastword.empty();
+ buff->setendpara();
lastispara = true;
laststartline = exp->locate();
break;
}
+ lastispara = false;
buff->addch(ch, cs);
len++;
if (!margindone)
{
@@ -93,15 +114,15 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
if ((slen = buff->width(len)) > w)
{
if (ch == ' ' || len == 1)
{
- lastword.empty();
+ if (ch == ' ') buff->truncate(len-1);
laststartline = exp->locate();
break;
}
else // should do a backward search for spaces, first.
{
- for (int i = len-1; i > 0; i--)
+ for (int i = len-2; i > 0; i--)
{
if ((*buff)[i] == ' ')
{
(*buff)[len] = 0;
@@ -115,10 +136,25 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
lastsizes[j] = lastsizes[j+i+1];
}
return true;
}
+ if ((*buff)[i] == '-' && !(((*buff)[i-1] == '-') || ((*buff)[i+1] == '-')))
+ {
+ (*buff)[len] = 0;
+ lastword.setright(*buff, i+1);
+ buff->truncate(i+1);
+ (*buff)[i+1] = '\0';
+ laststartline = lastsizes[i+1];
+ buff->resize();
+ for (int j = 0; j < lastword.length(); j++)
+ {
+ lastsizes[j] = lastsizes[j+i+1];
+ }
+ return true;
+ }
}
laststartline = lastsizes[len-1];
+ (*buff)[len] = 0;
lastword.setright(*buff, len - 1);
buff->truncate(len-1);
buff->addch('-', cs);
for (int j = 0; j < lastword.length(); j++)
@@ -133,12 +169,12 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
buff->resize();
return moreleft;
}
#else
-bool BuffDoc::getline(CDrawBuffer* buff, int wth)
+bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border)
{
bool margindone = false;
- int w = wth-2*BORDER;
+ int w = wth-2*_border;
tchar ch = 32;
CStyle cs;
buff->empty();
if (exp == NULL)
@@ -155,9 +191,9 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
w -= buff->leftMargin() + buff->rightMargin();
margindone = true;
}
else buff->empty();
-// qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data()));
+// //qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data()));
lastcheck = len = buff->length();
unsigned int slen = buff->width(len);
if (slen > w)
{
@@ -230,9 +266,9 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
lastispara = (ch == '\012');
}
(*buff)[len] = '\0';
// lastword = buff->data()+lastcheck;
-#ifdef WINDOWS
+#ifdef _WINDOWS
lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1);
{
int i;
for (i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck];
@@ -263,20 +299,20 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
return true;
}
#endif
-bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw)
+bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw, unsigned char _border)
{
- int w = wth-2*BORDER;
+ int w = wth-2*_border;
buff->empty();
if (exp == NULL)
{
return false;
}
tchar ch;
CStyle cs;
- int i = 0;
- while (i*cw < w)
+ int i = 1;
+ while (i*cw < w-buff->offset(w,0))
{
getch(ch, cs);
if (ch == '\12' || ch == UEOF) break;
buff->addch(ch,cs);
@@ -289,14 +325,18 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw)
}
int BuffDoc::openfile(QWidget* _parent, const char *src)
{
- // qDebug("BuffDoc:Openfile:%s", src);
- // qDebug("Trying aportis %x",exp);
+ // //qDebug("BuffDoc:Openfile:%s", src);
+ // //qDebug("Trying aportis %x",exp);
if (exp != NULL) delete exp;
lastword.empty();
lastsizes[0] = laststartline = 0;
+#ifdef NEWLINEBREAK
+ lastispara = true;
+#else
lastispara = false;
+#endif
/*
exp = new Text;
int ret = exp->openfile(src);
*/
@@ -315,8 +355,24 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
delete exp;
exp = new ztxt;
ret = exp->openfile(src);
}
+#ifdef USENEF
+ if (ret != 0)
+ {
+
+ delete exp;
+ exp = new CArriere;
+ ret = exp->openfile(src);
+ }
+ if (ret != 0)
+ {
+
+ delete exp;
+ exp = new CNEF;
+ ret = exp->openfile(src);
+ }
+#endif
if (ret != 0)
{
delete exp;
@@ -325,17 +381,17 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
}
if (ret != 0)
{
delete exp;
- qDebug("Trying ppms");
+ //qDebug("Trying ppms");
exp = new ppm_expander;
ret = exp->openfile(src);
}
if (ret != 0)
{
delete exp;
exp = new Text;
-// qDebug("Trying text");
+// //qDebug("Trying text");
ret = exp->openfile(src);
}
if (ret != 0)
@@ -343,14 +399,18 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
delete exp;
QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file");
return ret;
}
- // qDebug("Doing final open:%x:%x",exp,filt);
+ // //qDebug("Doing final open:%x:%x",exp,filt);
lastword.empty();
lastsizes[0] = laststartline = 0;
+#ifdef NEWLINEBREAK
+ lastispara = true;
+#else
lastispara = false;
+#endif
exp->locate(0);
filt->setsource(exp);
- // qDebug("BuffDoc:file opened");
+ // //qDebug("BuffDoc:file opened");
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
@@ -1,7 +1,8 @@
#ifndef __BuffDoc_h
#define __BuffDoc_h
+#include "useqpe.h"
#include "ZText.h"
#include "Aportis.h"
#include "ztxt.h"
#include "ppm_expander.h"
@@ -37,10 +38,15 @@ class BuffDoc
{
exp->putSaveData(src, srclen);
}
}
+#ifdef USEQPE
void suspend() { if (exp != NULL) exp->suspend(); }
void unsuspend() { if (exp != NULL) exp->unsuspend(); }
+#else
+ void suspend() {}
+ void unsuspend() {}
+#endif
~BuffDoc()
{
delete filt;
delete exp;
@@ -49,9 +55,9 @@ class BuffDoc
{
exp = NULL;
filt = NULL;
lastword.empty();
- // qDebug("Buffdoc created");
+// // qDebug("Buffdoc created");
}
bool empty() { return (exp == NULL); }
void setfilter(CFilterChain* _f)
{
@@ -81,20 +87,21 @@ class BuffDoc
}
else
ch = UEOF;
}
- QPixmap* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); }
+ void setwidth(int w) { if (exp != NULL) exp->setwidth(w); }
+ QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); }
unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); }
unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); }
unsigned int locate() { return (exp == NULL) ? 0 : laststartline; }
unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); }
void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); }
MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); }
- bool hyperlink(unsigned int n);
+ linkType hyperlink(unsigned int n, QString& wrd);
size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); }
void locate(unsigned int n);
- bool getline(CDrawBuffer* buff, int w);
- bool getline(CDrawBuffer* buff, int w, int cw);
+ bool getline(CDrawBuffer* buff, int w, unsigned char _border);
+ bool getline(CDrawBuffer* buff, int w, int cw, unsigned char _border);
void sizes(unsigned long& fs, unsigned long& ts) { exp->sizes(fs,ts); }
int getpara(CBuffer& buff)
{
tchar ch;
@@ -105,8 +112,9 @@ class BuffDoc
laststartline = exp->locate();
return i;
}
void saveposn(size_t posn) { exp->saveposn(posn); }
+ void writeposn(size_t posn) { exp->writeposn(posn); }
bool forward(size_t& loc) { return exp->forward(loc); }
bool back(size_t& loc) { return exp->back(loc); }
bool hasnavigation() { return exp->hasnavigation(); }
};
diff --git a/noncore/apps/opie-reader/CAnnoEdit.h b/noncore/apps/opie-reader/CAnnoEdit.h
index 3cc9f78..f320061 100644
--- a/noncore/apps/opie-reader/CAnnoEdit.h
+++ b/noncore/apps/opie-reader/CAnnoEdit.h
@@ -31,8 +31,9 @@ class CAnnoEdit : public QWidget
{
QVBoxLayout* grid = new QVBoxLayout(this);
m_name = new QLineEdit(this, "Name");
m_anno = new QMultiLineEdit(this, "Annotation");
+ m_anno->setWordWrap(QMultiLineEdit::WidgetWidth);
QPushButton* exitButton = new QPushButton("Okay", this);
connect(exitButton, SIGNAL( released() ), this, SLOT( slotOkay() ) );
QPushButton* cancelButton = new QPushButton("Cancel", this);
connect(cancelButton, SIGNAL( released() ), this, SLOT( slotCancel() ) );
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
@@ -6,16 +6,16 @@ CBufferBase& CBufferBase::assign(const void* sztmp, size_t ms)
{
delete [] buffer;
buffer = new unsigned char[len = ms*membersize];
}
- memcpy(buffer, sztmp, ms*membersize);
+ memcpy(buffer, sztmp, len);
return *this;
}
-CBufferBase::CBufferBase(size_t ms, size_t n) : len(n), membersize(ms)
+CBufferBase::CBufferBase(size_t ms, size_t n) : len(n*ms), membersize(ms)
{
- buffer = new unsigned char[len*membersize];
- memset(buffer, 0, len*membersize);
+ buffer = new unsigned char[len];
+ memset(buffer, 0, len);
}
void* CBufferBase::operator[](int i)
{
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp
index ca220e6..77b76fb 100644
--- a/noncore/apps/opie-reader/CDrawBuffer.cpp
+++ b/noncore/apps/opie-reader/CDrawBuffer.cpp
@@ -2,8 +2,10 @@
#include "FontControl.h"
#include <qfontmetrics.h>
#include <qpainter.h>
#include <qpixmap.h>
+#include <qimage.h>
+#include "useqpe.h"
#include "opie.h"
CDrawBuffer::~CDrawBuffer()
{
@@ -41,9 +43,9 @@ void CDrawBuffer::setright(CDrawBuffer& rhs, int f)
CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs)
{
int i;
-// qDebug("Trying 2");
+// //qDebug("Trying 2");
len = rhs.len;
m_maxstyle = rhs.m_maxstyle;
m_ascent = rhs.m_ascent;
m_descent = rhs.m_descent;
@@ -59,9 +61,9 @@ CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs)
}
for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i];
(*this)[i] = '\0';
len = i;
-// qDebug("Tried 2");
+// //qDebug("Tried 2");
return *this;
}
CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp)
@@ -79,8 +81,10 @@ CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp)
}
void CDrawBuffer::empty()
{
+ m_bSop = false;
+ m_bEop = false;
len = 0;
(*this)[0] = 0;
while (!segs.isEmpty())
{
@@ -110,26 +114,71 @@ void CDrawBuffer::truncate(int n)
len = n;
(*this)[n] = 0;
}
-int CDrawBuffer::width(int numchars)
+int CDrawBuffer::width(int numchars, bool onscreen, int scwidth, unsigned char _border)
{
+ int gzoom = fc->gzoom();
int currentx = 0, end = 0;
- QString text = toQString(data());
+ QString text = (numchars < 0) ? toQString(data()) : toQString(data(), numchars);
CList<textsegment>::iterator textstart = segs.begin();
+ int extraspace = 0;
+ bool just = (onscreen && !m_bEop && textstart->style.getJustify() == m_AlignJustify);
+ int spaces = 0;
+ int spacesofar = 0;
+ int spacenumber = 0;
+ int nonspace = 0;
+ if (just)
+ {
+ for (int i = 0; i < len; i++)
+ {
+ if ((*this)[i] != ' ')
+ {
+ nonspace = i;
+ break;
+ }
+ }
+#ifdef _WINDOWS
+ for (i = nonspace; i < len; i++)
+#else
+ for (int i = nonspace; i < len; i++)
+#endif
+ {
+ if ((*this)[i] == ' ')
+ {
+ spaces++;
+ }
+ }
+ if (spaces == 0)
+ {
+ just = false;
+ }
+ else
+ {
+ extraspace = (scwidth - 2*_border - rightMargin() - leftMargin() - width());
+ if (extraspace == 0) just = false;
+ }
+ }
CList<textsegment>::iterator textend = textstart;
do
{
textend++;
- end = (textend != segs.end()) ? textend->start : length();
+ end = (textend != segs.end()) ? textend->start : len;
if (numchars >= 0 && end > numchars)
{
end = numchars;
}
CStyle currentstyle = textstart->style;
if (currentstyle.isPicture())
{
- currentx += currentstyle.getPicture()->width();
+ if (currentstyle.canScale())
+ {
+ currentx += (gzoom*currentstyle.getPicture()->width())/100;
+ }
+ else
+ {
+ currentx += currentstyle.getPicture()->width();
+ }
}
else
{
if (currentstyle.isMono() && !fc->hasCourier())
@@ -138,39 +187,72 @@ int CDrawBuffer::width(int numchars)
currentx += cw*(end-textstart->start);
}
else
{
- QFont f(currentstyle.isMono() ? QString("courier") : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
+ QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
// f.setUnderline(currentstyle.isUnderline());
QString str = text.mid(textstart->start, end-textstart->start);
QFontMetrics fm(f);
- currentx += fm.width(str);
+ if (just)
+ {
+ int lastspace = -1;
+ int nsp = 0;
+ int cx = currentx;
+ while ((nsp = str.find(" ", lastspace+1)) >= 0)
+ {
+ if (nsp > nonspace)
+ {
+ spacenumber++;
+ int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar;
+ QString nstr = str.mid(lastspace+1, nsp-lastspace);
+ int lw = fm.width(nstr);
+ cx += lw+nexttoadd;
+ spacesofar += nexttoadd;
+ lastspace = nsp;
+ }
+ else
+ {
+ QString nstr = str.mid(lastspace+1, nsp-lastspace);
+// qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr);
+ int lw = fm.width(nstr);
+ cx += lw;
+ lastspace = nsp;
+ }
+ }
+ QString nstr = str.right(str.length()-1-lastspace);
+ cx += fm.width(nstr);
+ currentx = cx;
+ }
+ else
+ {
+ currentx += fm.width(str);
+ }
}
}
textstart = textend;
}
- while (textend != segs.end() && end != numchars);
+ while (textend != segs.end() && end != numchars && textstart->start < len);
return currentx;
}
int CDrawBuffer::leftMargin()
{
- return (segs.begin()->style.getLeftMargin()*fc->getsize(segs.begin()->style))/6;
+ return (segs.begin()->style.getLeftMargin()*fc->getsize(segs.begin()->style)+3)/6;
}
int CDrawBuffer::rightMargin()
{
- return (segs.begin()->style.getRightMargin()*fc->getsize(segs.begin()->style))/6;
+ return (segs.begin()->style.getRightMargin()*fc->getsize(segs.begin()->style)+3)/6;
}
-int CDrawBuffer::offset(int scwidth)
+int CDrawBuffer::offset(int scwidth, unsigned char _border)
{
- int currentx = BORDER;
+ int currentx = _border;
switch(segs.begin()->style.getJustify())
{
case m_AlignRight:
{
- currentx = scwidth - BORDER - rightMargin() - width();
+ currentx = scwidth - _border - rightMargin() - width();
}
break;
case m_AlignCentre:
{
@@ -181,79 +263,112 @@ int CDrawBuffer::offset(int scwidth)
}
break;
case m_AlignJustify:
case m_AlignLeft:
- currentx = BORDER + leftMargin();
+ currentx = _border + leftMargin();
break;
}
return currentx;
}
-void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth)
+void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth, unsigned char _border)
{
- int currentx = offset(scwidth);
+ int gzoom = fc->gzoom();
+ int currentx = offset(scwidth, _border);
QString text = toQString(data());
CList<textsegment>::iterator textstart = segs.begin();
-/*
- StyleType align = textstart->style.getJustify();
- switch (align)
+ int extraspace = 0;
+ bool just = (!m_bEop && textstart->style.getJustify() == m_AlignJustify);
+ int spaces = 0;
+ int spacesofar = 0;
+ int spacenumber = 0;
+ int nonspace = 0;
+ if (just)
{
- case CStyle::m_AlignRight:
+ for (int i = 0; i < len; i++)
{
- currentx = scwidth - width() - 2*BORDER;
+ if ((*this)[i] != ' ')
+ {
+ nonspace = i;
+ break;
+ }
}
- break;
- case CStyle::m_AlignCentre:
+#ifdef _WINDOWS
+ for (i = nonspace; i < len; i++)
+#else
+ for (int i = nonspace; i < len; i++)
+#endif
{
- currentx = (scwidth - width())/2 - BORDER;
+ if ((*this)[i] == ' ')
+ {
+ spaces++;
+ }
+ }
+ if (spaces == 0)
+ {
+ just = false;
+ }
+ else
+ {
+ extraspace = (scwidth - 2*_border - rightMargin() - leftMargin() - width());
+ if (extraspace == 0) just = false;
}
- break;
- case CStyle::m_AlignJustify:
- case CStyle::m_AlignLeft:
- break;
}
-*/
CList<textsegment>::iterator textend = textstart;
do
{
textend++;
- int end = (textend != segs.end()) ? textend->start : length();
+ int end = (textend != segs.end()) ? textend->start : len;
CStyle currentstyle = textstart->style;
- QFont f((currentstyle.isMono() && fc->hasCourier()) ? QString("courier") : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
+ QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
// f.setUnderline(currentstyle.isUnderline());
// if (currentstyle.isUnderline()) qDebug("UNDERLINE");
_p->setFont(f);
QString str = text.mid(textstart->start, end-textstart->start);
-#ifdef OPIE
+#if defined(OPIE) || !defined(USEQPE)
_p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100));
#else
_p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10));
#endif
+ int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2;
if (_bMono)
{
if (currentstyle.isUnderline())
{
- _p->drawLine( currentx, _y, currentx + str.length()*_charWidth, _y);
+ _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset);
}
if (currentstyle.isStrikethru())
{
int ascent = fc->ascent(currentstyle)/3;
- _p->drawLine( currentx, _y-ascent, currentx + str.length()*_charWidth, _y-ascent);
+ _p->drawLine( currentx, _y-ascent+voffset, currentx + str.length()*_charWidth, _y-ascent+voffset);
}
for (int i = 0; i < str.length(); i++)
{
- _p->drawText( currentx + i*_charWidth, _y, QString(str[i]));
+ _p->drawText( currentx + i*_charWidth, _y+voffset, QString(str[i]));
}
currentx += str.length()*_charWidth;
}
else
{
if (currentstyle.isPicture())
{
+ int ht = (gzoom*currentstyle.getPicture()->height())/100;
+ int wt = (gzoom*currentstyle.getPicture()->width())/100;
int ascent = fc->ascent(currentstyle)/2;
- int yoffset = currentstyle.getPicture()->height()/2 + ascent;
- _p->drawPixmap( currentx, _y-yoffset, *(currentstyle.getPicture()));
- currentx += currentstyle.getPicture()->width();
+ int yoffset = ht/2 + ascent;
+
+ QPixmap pc;
+ if (gzoom != 100 && currentstyle.canScale())
+ {
+ QImage im = currentstyle.getPicture()->smoothScale(wt,ht);
+ pc.convertFromImage(im);
+ }
+ else
+ {
+ pc.convertFromImage(*currentstyle.getPicture());
+ }
+ _p->drawPixmap( currentx, _y-yoffset, pc );
+ currentx += wt;
}
else
{
if (currentstyle.isMono() && !fc->hasCourier())
@@ -261,44 +376,86 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
int cw = (7*fc->getsize(currentstyle))/10;
int w = cw*(end-textstart->start);
if (currentstyle.isUnderline())
{
- _p->drawLine( currentx, _y, currentx + w, _y);
+ _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset);
}
if (currentstyle.isStrikethru())
{
int ascent = fc->ascent(currentstyle)/3;
- _p->drawLine( currentx, _y-ascent, currentx + w, _y-ascent);
+ _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset);
}
QString str = text.mid(textstart->start, end-textstart->start);
- for (int i = 0; i < str.length(); i++)
+ for (unsigned int i = 0; i < str.length(); i++)
{
- _p->drawText( currentx, _y, QString(str[i]));
+#ifdef _WINDOWS
+ _p->drawText( currentx, _y+voffset, QString(str.at(i)));
+#else
+ _p->drawText( currentx, _y+voffset, QString(str[i]));
+#endif
currentx += cw;
}
}
else
{
QFontMetrics fm(f);
- int w = fm.width(str);
+ int w;
+ if (just)
+ {
+ int lastspace = -1;
+ int nsp = 0;
+ int cx = currentx;
+ while ((nsp = str.find(" ", lastspace+1)) >= 0)
+ {
+ if (nsp+textstart->start >= nonspace)
+ {
+ spacenumber++;
+ int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar;
+ QString nstr = str.mid(lastspace+1, nsp-lastspace);
+// qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr);
+ int lw = fm.width(nstr);
+ _p->drawText( cx, _y+voffset, nstr);
+ cx += lw+nexttoadd;
+ spacesofar += nexttoadd;
+ lastspace = nsp;
+ }
+ else
+ {
+ QString nstr = str.mid(lastspace+1, nsp-lastspace);
+// qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr);
+ int lw = fm.width(nstr);
+ _p->drawText( cx, _y+voffset, nstr);
+ cx += lw;
+ lastspace = nsp;
+ }
+ }
+ QString nstr = str.right(str.length()-1-lastspace);
+ _p->drawText( cx, _y+voffset, nstr);
+ cx += fm.width(nstr);
+ w = cx - currentx;
+ }
+ else
+ {
+ _p->drawText( currentx, _y+voffset, str);
+ w = fm.width(str);
+ }
if (currentstyle.isUnderline())
{
- _p->drawLine( currentx, _y, currentx + w, _y);
+ _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset);
}
if (currentstyle.isStrikethru())
{
int ascent = fc->ascent(currentstyle)/3;
- _p->drawLine( currentx, _y-ascent, currentx + w, _y-ascent);
+ _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset);
}
- _p->drawText( currentx, _y, str);
currentx += w;
}
}
}
textstart = textend;
}
- while (textend != segs.end() && textstart->start < length()-1);
+ while (textend != segs.end() && textstart->start < len);
}
CStyle CDrawBuffer::laststyle()
{
@@ -313,14 +470,14 @@ linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt)
CList<textsegment>::iterator textend = textstart;
do
{
textend++;
- end = (textend != segs.end()) ? textend->start : length();
+ end = (textend != segs.end()) ? textend->start : len;
currentstyle = textstart->style;
/*
if (currentstyle.isPicture()) qDebug("Passed thru picture");
if (currentstyle.getLink()) qDebug("Passed thru link");
- qDebug("islink:%d - %d", numchars, end);
+ //qDebug("islink:%d - %d", numchars, end);
*/
textstart = textend;
}
while (textend != segs.end() && end <= numchars);
@@ -339,11 +496,11 @@ linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt)
}
void CDrawBuffer::resize()
{
- int i;
+ int gzoom = fc->gzoom();
m_maxstyle = m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0;
- for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= length(); )
+ for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; )
{
CList<textsegment>::iterator next = iter;
iter++;
int st = next->start;
@@ -356,12 +513,12 @@ void CDrawBuffer::resize()
ascent = fc->ascent(_style);
descent = fc->descent(_style);
linespacing = fc->lineSpacing(_style);
extra = linespacing - ascent - descent;
- if (_style.isPicture())
+ if (_style.isPicture() && _style.canScale())
{
- descent = (_style.getPicture()->height()-ascent)/2;
- ascent = (_style.getPicture()->height()+ascent)/2;
+ descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2;
+ ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2;
}
/*
else if (fc != NULL)
{
@@ -375,5 +532,19 @@ void CDrawBuffer::resize()
if (descent > m_descent) m_descent = descent;
if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra;
m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing;
}
+ int lead = fc->getlead();
+ if (lead != 0)
+ {
+ int xt = (lead*m_lineSpacing+5)/10;
+ m_descent += xt;
+ m_lineSpacing += xt;
+ }
+ if (m_bSop)
+ {
+ int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10;
+// qDebug("ExtraSpace:%d", xt);
+ m_ascent += xt;
+ m_lineSpacing += xt;
+ }
}
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
@@ -3,18 +3,12 @@
#include "StyleConsts.h"
#include "CBuffer.h"
#include "my_list.h"
+#include "linktype.h"
class QPainter;
-enum linkType
-{
- eNone,
- eLink,
- ePicture
-};
-
struct textsegment
{
int start;
CStyle style;
@@ -32,11 +26,14 @@ class CDrawBuffer : public CBuffer
int len;
FontControl* fc;
int m_maxstyle, m_ascent, m_descent, m_lineSpacing, m_lineExtraSpacing;
bool m_bEof;
+ bool m_bSop, m_bEop;
CDrawBuffer(const CDrawBuffer&);
CDrawBuffer& operator=(const tchar*sztmp);
public:
+ void setstartpara() { m_bSop = true; }
+ void setendpara() { m_bEop = true; }
int leftMargin();
int rightMargin();
void setEof() { m_bEof = true; }
bool eof() { return m_bEof; }
@@ -55,11 +52,11 @@ class CDrawBuffer : public CBuffer
{
empty();
}
*/
- int width(int numchars = -1);
- int offset(int);
- void render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scw);
+ int width(int numchars = -1, bool onscreen = false, int scwidth = 0, unsigned char _border = 0);
+ int offset(int, unsigned char);
+ void render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scw, unsigned char);
void empty();
void addch(tchar ch, CStyle _style);
void truncate(int);
void setright(CDrawBuffer&, int);
diff --git a/noncore/apps/opie-reader/CEncoding.cpp b/noncore/apps/opie-reader/CEncoding.cpp
index c1dcfe8..60a1057 100644
--- a/noncore/apps/opie-reader/CEncoding.cpp
+++ b/noncore/apps/opie-reader/CEncoding.cpp
@@ -2,23 +2,23 @@
#include "CEncoding.h"
void CUtf8::getch(tchar& ch, CStyle& sty)
{
- int iret;
- parent->getch(iret, sty);
- if (iret == EOF)
+ tchar ret;
+ parent->getch(ret, sty);
+ if (ret == UEOF)
{
ch = UEOF;
return;
}
- tchar ret = iret;
int count = 0;
if (ret & (1 << 7))
{
unsigned char flags = ret << 1;
while ((flags & (1 << 7)) != 0)
{
ret <<= 6;
+ tchar iret;
parent->getch(iret, sty);
ret += iret & 0x3f;
flags <<= 1;
count++;
@@ -44,11 +44,11 @@ void CUtf8::getch(tchar& ch, CStyle& sty)
}
void CUcs16be::getch(tchar& ch, CStyle& sty)
{
- int iret;
+ tchar iret;
parent->getch(iret, sty);
- if (iret == EOF)
+ if (iret == UEOF)
{
ch = UEOF;
return;
}
@@ -58,11 +58,11 @@ void CUcs16be::getch(tchar& ch, CStyle& sty)
}
void CUcs16le::getch(tchar& ch, CStyle& sty)
{
- int iret;
+ tchar iret;
parent->getch(iret, sty);
- if (iret == EOF)
+ if (iret == UEOF)
{
ch = UEOF;
return;
}
@@ -72,14 +72,14 @@ void CUcs16le::getch(tchar& ch, CStyle& sty)
}
void Ccp1252::getch(tchar& ch, CStyle& sty)
{
- int iret;
+ tchar iret;
parent->getch(iret, sty);
ch = iret;
switch (ch)
{
- case EOF:
+ case UEOF:
ch = UEOF;
break;
case 0x80:
ch = 0x20ac;
@@ -196,11 +196,11 @@ void CPalm::getch(tchar& ch, CStyle& sty)
}
void CAscii::getch(tchar& ch, CStyle& sty)
{
- int iret;
+ tchar iret;
parent->getch(iret, sty);
- if (iret == EOF)
+ if (iret == UEOF)
{
ch = UEOF;
}
else
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
@@ -2,13 +2,16 @@
#define __CENCODING_H
#include "CExpander.h"
+#define MAX_ENCODING 6
+
class CEncoding : public CCharacterSource
{
friend class CFilterChain;
protected:
CExpander* parent;
+ linkType hyperlink(unsigned int n, QString& t) { return parent->hyperlink(n,t); }
public:
CEncoding() : parent(NULL) {}
void setparent(CExpander* p) { parent = p; }
virtual ~CEncoding() {};
@@ -49,5 +52,23 @@ class CAscii : public CEncoding
public:
void getch(tchar& ch, CStyle& sty);
};
+#include "CEncoding_tables.h"
+
+class CGeneral8Bit : public CEncoding
+{
+ int m_index;
+ public:
+ CGeneral8Bit(int _i) : m_index(_i)
+ {
+// qDebug("8Bit:%d", _i);
+// qDebug("%s", unicodetable::iterator(_i)->mime);
+ }
+ void getch(tchar& ch, CStyle& sty)
+ {
+ parent->getch(ch, sty);
+ ch = unicodetable::unicodevalue(m_index, ch);
+ }
+};
+
#endif
diff --git a/noncore/apps/opie-reader/CExpander.h b/noncore/apps/opie-reader/CExpander.h
index c281398..7b21d3e 100644
--- a/noncore/apps/opie-reader/CExpander.h
+++ b/noncore/apps/opie-reader/CExpander.h
@@ -1,17 +1,21 @@
#ifndef __CExpander_h
#define __CExpander_h
+#ifndef _WINDOWS
#include <unistd.h>
+#endif
#include <stdio.h>
#include <time.h>
#include <qmessagebox.h>
+#include "useqpe.h"
#include "config.h"
#include "StyleConsts.h"
#include "Markups.h"
-#include "name.h"
+#include "names.h"
+#include "linktype.h"
-class QPixmap;
+class QImage;
class Bkmk;
template<class T>
class CList;
@@ -19,8 +23,9 @@ class CList;
class CCharacterSource
{
public:
virtual void getch(tchar&, CStyle&) = 0;
+ virtual linkType hyperlink(unsigned int n, QString&) = 0;
};
class CExpander
{
@@ -30,13 +35,17 @@ class CExpander
char* fname;
bool bSuspended;
size_t suspos;
time_t sustime;
+ int m_scrWidth;
+ unsigned long m_currentstart, m_currentend;
public:
- virtual void suspend() = 0;
+#ifdef USEQPE
+ virtual void suspend() = 0;
virtual void unsuspend() = 0;
+#endif
size_t getHome() { return m_homepos; }
- CExpander() : m_homepos(0), fname(NULL) {};
+ CExpander() : m_homepos(0), fname(NULL), m_scrWidth(240), m_currentstart(1), m_currentend(0) {};
virtual ~CExpander() { if (fname != NULL) delete [] fname; };
int openfile(const char *src)
{
bSuspended = false;
@@ -48,37 +57,53 @@ class CExpander
virtual void locate(unsigned int n) = 0;
virtual bool hasrandomaccess() = 0;
virtual void sizes(unsigned long& file, unsigned long& text) = 0;
virtual CList<Bkmk>* getbkmklist() { return NULL; }
- virtual void getch(int& ch, CStyle& sty)
+ virtual void getch(tchar& ch, CStyle& sty)
{
- ch = getch();
+ int ich = getch();
+ ch = (ich == EOF) ? UEOF : ich;
sty.unset();
}
virtual int getch() = 0;
- virtual bool hyperlink(unsigned int n)
+ virtual linkType hyperlink(unsigned int n, QString& wrd)
{
locate(n);
- return true;
+ return eLink;
}
virtual MarkupType PreferredMarkup() = 0;
virtual void saveposn(size_t posn) {}
- virtual bool forward(size_t& loc) {}
- virtual bool back(size_t& loc) {}
+ virtual void writeposn(size_t posn) {}
+ virtual bool forward(size_t& loc) { return false; }
+ virtual bool back(size_t& loc) { return false; }
virtual bool hasnavigation() { return false; }
- virtual unsigned long startSection()
+ unsigned long startSection()
+ {
+ unsigned long current = locate();
+ if (m_currentstart > current || current > m_currentend)
+ {
+ start2endSection();
+ }
+ return m_currentstart;
+ }
+ unsigned long endSection()
{
- return 0;
+ unsigned long current = locate();
+ if (m_currentstart > current || current > m_currentend)
+ {
+ start2endSection();
+ }
+ return m_currentend;
}
- virtual unsigned long endSection()
+ virtual void start2endSection()
{
- unsigned long file, text;
- sizes(file, text);
- return text;
+ m_currentstart = 0;
+ unsigned long file;
+ sizes(file, m_currentend);
}
- virtual QPixmap* getPicture(unsigned long tgt) { return NULL; }
+ virtual QImage* getPicture(unsigned long tgt) { return NULL; }
void setContinuous(bool _b) { m_continuous = _b; }
-
+#ifdef USEQPE
virtual void suspend(FILE*& fin)
{
bSuspended = true;
suspos = ftell(fin);
@@ -106,8 +131,9 @@ class CExpander
}
suspos = fseek(fin, suspos, SEEK_SET);
}
}
+#endif
virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
{
len = srclen;
data = new unsigned char[len];
@@ -119,6 +145,7 @@ class CExpander
{
qDebug("Don't know what to do with non-zero save data");
}
}
+ void setwidth(int w) { m_scrWidth = w; }
};
#endif
diff --git a/noncore/apps/opie-reader/CFilter.cpp b/noncore/apps/opie-reader/CFilter.cpp
index d5e3116..73a0872 100644
--- a/noncore/apps/opie-reader/CFilter.cpp
+++ b/noncore/apps/opie-reader/CFilter.cpp
@@ -681,4 +681,62 @@ void repalm::getch(tchar& ch, CStyle& sty)
break;
}
}
#endif
+
+//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 };
+//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 };
+
+void DePluck::getch(tchar& ch, CStyle& sty)
+{
+ if (m_buffed > 0)
+ {
+ sty = m_laststyle;
+ ch = nextpart[m_current++];
+ if (m_current == m_buffed)
+ {
+ m_current = m_buffed = 0;
+ }
+ }
+ else
+ {
+ if (m_buffer != 0)
+ {
+ ch = m_buffer;
+ m_buffer = 0;
+ return;
+ }
+ unsigned long lnk;
+ do
+ {
+ if (nextpart[m_buffed] == 0) break;
+ parent->getch(ch, sty);
+ m_laststyle = sty;
+ if (sty.getLink()) lnk = sty.getData();
+ } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed);
+ m_current = 0;
+ if (nextpart[m_buffed] == 0)
+ {
+ m_buffed = 0;
+ QString dmy;
+ parent->hyperlink(lnk, dmy);
+ do
+ {
+ parent->getch(ch, sty);
+ }
+ while (ch != 10);
+ parent->getch(ch, sty);
+ }
+ else if (m_buffed > 0)
+ {
+ m_buffer = ch;
+ ch = nextpart[0];
+ if (m_buffed == 1)
+ {
+ m_buffed = 0;
+ }
+ else m_current = 1;
+ }
+ }
+
+ return;
+}
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
@@ -8,8 +8,12 @@ class CFilter : public CCharacterSource
{
friend class CFilterChain;
protected:
CCharacterSource* parent;
+ linkType hyperlink(unsigned int n, QString& w)
+ {
+ return parent->hyperlink(n,w);
+ }
public:
CFilter() : parent(NULL) {}
void setparent(CCharacterSource* p) { parent = p; }
virtual ~CFilter() {};
@@ -68,10 +72,10 @@ class CFilterChain
class stripcr : public CFilter
{
public:
stripcr() {}
- virtual ~stripcr() {}
- virtual void getch(tchar& ch, CStyle& sty)
+ ~stripcr() {}
+ void getch(tchar& ch, CStyle& sty)
{
do
{
parent->getch(ch, sty);
@@ -86,10 +90,10 @@ class dehyphen : public CFilter
tchar m_nextChar;
CStyle m_nextSty;
public:
dehyphen() : m_bCharWaiting(false) {}
- virtual ~dehyphen() {}
- virtual void getch(tchar& ch, CStyle& sty)
+ ~dehyphen() {}
+ void getch(tchar& ch, CStyle& sty)
{
if (m_bCharWaiting)
{
m_bCharWaiting = false;
@@ -118,19 +122,19 @@ class striphtml : public CFilter
unsigned short parse_m();
void mygetch(tchar& ch, CStyle& sty);
public:
striphtml() {}
- virtual ~striphtml() {}
- virtual void getch(tchar& ch, CStyle& sty);
+ ~striphtml() {}
+ void getch(tchar& ch, CStyle& sty);
};
class unindent : public CFilter
{
tchar lc;
public:
unindent() : lc(0) {}
- virtual ~unindent() {}
- virtual void getch(tchar& ch, CStyle& sty)
+ ~unindent() {}
+ void getch(tchar& ch, CStyle& sty)
{
if (lc == 10)
{
do
@@ -149,10 +153,10 @@ class repara : public CFilter
{
tchar tch;
public:
repara() : tch(0) {}
- virtual ~repara() {}
- virtual void getch(tchar& ch, CStyle& sty)
+ ~repara() {}
+ void getch(tchar& ch, CStyle& sty)
{
parent->getch(ch, sty);
if (ch == 10)
{
@@ -178,10 +182,10 @@ class indenter : public CFilter
int indent;
CStyle lsty;
public:
indenter(int _a=5) : amnt(_a), indent(0) {}
- virtual ~indenter() {}
- virtual void getch(tchar& ch, CStyle& sty)
+ ~indenter() {}
+ void getch(tchar& ch, CStyle& sty)
{
if (indent > 0)
{
indent--;
@@ -204,10 +208,10 @@ class dblspce : public CFilter
bool lastlf;
CStyle lsty;
public:
dblspce() : lastlf(false) {}
- virtual ~dblspce() {}
- virtual void getch(tchar& ch, CStyle& sty)
+ ~dblspce() {}
+ void getch(tchar& ch, CStyle& sty)
{
if (lastlf)
{
lastlf = false;
@@ -231,18 +235,18 @@ class textfmt : public CFilter
bool uselast;
void mygetch(tchar&, CStyle&);
public:
textfmt() : lastchar(0), uselast(false) {}
- virtual ~textfmt() {}
- virtual void getch(tchar& ch, CStyle& sty);
+ ~textfmt() {}
+ void getch(tchar& ch, CStyle& sty);
};
class embolden : public CFilter
{
public:
embolden() {}
- virtual ~embolden() {}
- virtual void getch(tchar& ch, CStyle& sty)
+ ~embolden() {}
+ void getch(tchar& ch, CStyle& sty)
{
parent->getch(ch, sty);
sty.setBold();
}
@@ -254,34 +258,71 @@ class remap : public CFilter
int offset;
CStyle currentstyle;
public:
remap() : offset(0) { q[0] = 0; }
- virtual ~remap() {}
- virtual void getch(tchar& ch, CStyle& sty);
+ ~remap() {}
+ void getch(tchar& ch, CStyle& sty);
};
class PeanutFormatter : public CFilter
{
CStyle currentstyle;
public:
- virtual ~PeanutFormatter() {}
- virtual void getch(tchar& ch, CStyle& sty);
+ ~PeanutFormatter() {}
+ void getch(tchar& ch, CStyle& sty);
};
class OnePara : public CFilter
{
tchar m_lastchar;
public:
OnePara() : m_lastchar(0) {}
- virtual ~OnePara() {}
- virtual void getch(tchar& ch, CStyle& sty);
+ ~OnePara() {}
+ void getch(tchar& ch, CStyle& sty);
+};
+
+class DePluck : public CFilter
+{
+ tchar* nextpart;
+ tchar m_buffer;
+ int m_buffed;
+ int m_current;
+ bool m_debuff;
+ CStyle m_laststyle;
+ public:
+ DePluck(tchar* t) : nextpart(t), m_buffer(0), m_buffed(0), m_current(0), m_debuff(false) {}
+ ~DePluck() {}
+ void getch(tchar& ch, CStyle& sty);
};
#ifdef REPALM
class repalm : public CFilter
{
public:
- virtual ~repalm() {}
- virtual void getch(tchar& ch, CStyle& sty);
+ ~repalm() {}
+ void getch(tchar& ch, CStyle& sty);
};
#endif
+
+class FullJust : public CFilter
+{
+ public:
+ void getch(tchar& ch, CStyle& sty)
+ {
+ parent->getch(ch, sty);
+ if (sty.getJustify() == m_AlignLeft) sty.setFullJustify();
+ }
+};
+/*
+class AddSpace : public CFilter
+{
+ unsigned char m_espc;
+ public:
+ AddSpace(unsigned char s) : m_espc(s) {}
+ void getch(tchar& ch, CStyle& sty)
+ {
+ parent->getch(ch, sty);
+ sty.setExtraSpace(m_espc);
+ }
+};
+*/
#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
@@ -25,13 +25,13 @@ class CFiledata
{
if (m_own && data != NULL)
{
delete [] data;
- qDebug("~Filedata: deleting");
+// qDebug("~Filedata: deleting");
}
else
{
- qDebug("~Filedata: not deleting");
+// qDebug("~Filedata: not deleting");
}
}
tchar* name() const { return (tchar*)(data+sizeof(time_t)); }
time_t date() { return *((time_t *)data); }
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,7 +1,30 @@
#include "opie.h"
+#include "useqpe.h"
#include "FontControl.h"
+int FontControl::gzoom()
+{
+ int ret;
+ if (m_size == g_size)
+ {
+ ret = m_fontsizes[m_size]*m_basesize;
+ }
+ else if (g_size < 0)
+ {
+ int f = -g_size;
+ ret = (m_fontsizes[0]*m_basesize) >> (f/2);
+ if (f%2) ret = (2*ret/3);
+ }
+ else
+ {
+ int f = g_size - m_maxsize + 1;
+ ret = (m_fontsizes[m_maxsize-1]*m_basesize) << (f/2);
+ if (f%2) ret = (3*ret/2);
+ }
+ return ret;
+}
+
bool FontControl::ChangeFont(QString& n, int tgt)
{
QValueList<int>::Iterator it;
QFontDatabase fdb;
@@ -19,9 +42,9 @@ bool FontControl::ChangeFont(QString& n, int tgt)
uint i = 0;
uint best = 0;
for (it = sizes.begin(); it != sizes.end(); it++)
{
-#ifdef OPIE
+#if defined(OPIE) || !defined(USEQPE)
m_fontsizes[i] = (*it);
#else
m_fontsizes[i] = (*it)/10;
#endif
@@ -30,8 +53,8 @@ bool FontControl::ChangeFont(QString& n, int tgt)
best = i;
}
i++;
}
- m_size = best;
+ g_size = m_size = best;
}
return true;
}
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
@@ -7,28 +7,39 @@
class FontControl
{
int * m_fontsizes;
- int m_size;
+ int m_size, g_size;
QString m_fontname;
+ QString m_fixedfontname;
int m_maxsize;
bool m_hasCourier;
+ int m_leading, m_extraspace;
+ unsigned char m_basesize;
public:
+ void setBaseSize(unsigned char _s) { m_basesize = _s; }
+ unsigned char getBaseSize() { return m_basesize; }
+ int gzoom();
FontControl(QString n = "helvetica", int size = 10)
:
- m_fontsizes(NULL), m_hasCourier(false)
+ m_fontsizes(NULL), m_hasCourier(false), m_leading(0), m_extraspace(0)
{
ChangeFont(n, size);
}
~FontControl()
{
if (m_fontsizes != NULL) delete [] m_fontsizes;
}
- void hasCourier(bool _b) { m_hasCourier = _b; }
+ void hasCourier(bool _b, const QString& _nm)
+ {
+ m_hasCourier = _b;
+ m_fixedfontname = _nm;
+ }
+ QString& fixedfontname() { return m_fixedfontname; }
bool hasCourier() { return m_hasCourier; }
QString name() { return m_fontname; }
int currentsize() { return m_fontsizes[m_size]; }
- int getsize(CStyle size)
+ int getsize(const CStyle& size)
{
int tgt = m_size+size.getFontSize();
if (tgt < 0)
{
@@ -45,9 +56,9 @@ class FontControl
QFont f(name(), currentsize());
QFontMetrics fm(f);
return fm.ascent();
}
- int ascent(CStyle ch)
+ int ascent(const CStyle& ch)
{
QFont f(name(), getsize(ch));
QFontMetrics fm(f);
return fm.ascent();
@@ -57,9 +68,9 @@ class FontControl
QFont f(name(), currentsize());
QFontMetrics fm(f);
return fm.descent();
}
- int descent(CStyle ch)
+ int descent(const CStyle& ch)
{
QFont f(name(), getsize(ch));
QFontMetrics fm(f);
return fm.descent();
@@ -69,36 +80,74 @@ class FontControl
QFont f(name(), currentsize());
QFontMetrics fm(f);
return fm.lineSpacing();
}
- int lineSpacing(CStyle ch)
+ int lineSpacing(const CStyle& ch)
{
QFont f(name(), getsize(ch));
QFontMetrics fm(f);
return fm.lineSpacing();
}
bool decreasesize()
{
+/*
if (--m_size < 0)
{
m_size = 0;
return false;
}
else return true;
+*/
+ if (g_size-- == m_size)
+ {
+ if (--m_size < 0)
+ {
+ m_size = 0;
+ }
+ }
+// qDebug("Font:%d Graphics:%d", m_size, g_size);
+ return true;
}
bool increasesize()
{
+/*
if (++m_size >= m_maxsize)
{
m_size = m_maxsize - 1;
return false;
}
else return true;
+*/
+ if (g_size++ == m_size)
+ {
+ if (++m_size >= m_maxsize)
+ {
+ m_size = m_maxsize - 1;
+ }
+ }
+// qDebug("Font:%d Graphics:%d", m_size, g_size);
+ return true;
}
bool ChangeFont(QString& n)
{
return ChangeFont(n, currentsize());
}
bool ChangeFont(QString& n, int tgt);
+ void setlead(int _lead)
+ {
+ m_leading = _lead;
+ }
+ int getlead()
+ {
+ return m_leading;
+ }
+ void setextraspace(int _lead)
+ {
+ m_extraspace = _lead;
+ }
+ int getextraspace()
+ {
+ return m_extraspace;
+ }
};
#endif
diff --git a/noncore/apps/opie-reader/Navigation.cpp b/noncore/apps/opie-reader/Navigation.cpp
index 4f11887..36e33b4 100644
--- a/noncore/apps/opie-reader/Navigation.cpp
+++ b/noncore/apps/opie-reader/Navigation.cpp
@@ -1,63 +1,81 @@
-#include "Navigation.h"
-
+#ifdef _WINDOWS
#include <string.h>
+#endif
+#include "Navigation.h"
+//#include <stdio.h>
+/*
+ void saveposn(size_t posn)
+ save/push position to history buffer for future use of back() function
+*/
void CNavigation::saveposn(size_t posn)
{
-// qDebug("Saved:%u [%u,%u,%u]", posn, historystart, historycurrent, historyend);
- historycurrent = historyend = (historycurrent+1)%NAVIGATION_HISTORY_SIZE;
+ //printf("saving position %u, depth %u\n",posn,historycurrent);
history[historycurrent] = posn;
- if (historystart == historyend) historystart = (historystart+1)%NAVIGATION_HISTORY_SIZE;
-// qDebug("Saved:%u [%u,%u,%u]", posn, historystart, historycurrent, historyend);
+ historycurrent=(historycurrent+1)%NAVIGATION_HISTORY_SIZE;
+ if (historycurrent==historystart)
+ // circular buffer full, forget oldest record
+ historystart=(historystart+1)%NAVIGATION_HISTORY_SIZE;
+ // no forward possible after saveposn
+ historyend = historycurrent;
}
-bool CNavigation::forward(size_t& loc)
+/*
+ void writeposn(size_t posn)
+ overwrite current (unused) position
+ useful for saving current position before using back button
+*/
+void CNavigation::writeposn(size_t posn)
{
- if (historycurrent != historyend)
- {
- historycurrent = (historycurrent + 1)%NAVIGATION_HISTORY_SIZE;
- loc = history[historycurrent];
-// qDebug("Forward:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend);
- return true;
- }
- else
- {
- return false;
- }
+ //printf("witing position %u, depth %u\n",posn,historycurrent);
+ history[historycurrent] = posn;
}
-bool CNavigation::back(size_t& loc)
+/*
+ bool back(size_t& posn)
+ go back in history
+ restore last position saved with saveposn() and return true
+ return false if there is nothing saved in history
+*/
+bool CNavigation::back(size_t& posn)
{
- if (historyend != historystart)
- {
-// qDebug("Back:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend);
- if (historycurrent == historyend && history[historycurrent] != loc)
- {
- historyend = (historyend+1) % NAVIGATION_HISTORY_SIZE;
- history[historyend] = loc;
- }
- else
- {
- size_t sv = historycurrent;
- historycurrent = (historycurrent + NAVIGATION_HISTORY_SIZE - 1) % NAVIGATION_HISTORY_SIZE;
- if (historycurrent == historystart)
- {
- historycurrent = sv;
- return false;
- }
- }
- loc = history[historycurrent];
-// qDebug("Back:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend);
- return true;
- }
- else
- {
- return false;
+ if (historycurrent!=historystart) {
+ // buffer is not empty
+ if (historycurrent==0)
+ historycurrent=NAVIGATION_HISTORY_SIZE-1;
+ else
+ historycurrent--;
+ posn=history[historycurrent];
+ //printf("back(): going back to %u depth %u\n",posn,historycurrent);
+ return true;
+
+ } else {
+ // circular buffer empty
+ //printf("back(): empty history\n");
+ return false;
}
}
-#include <stdio.h>
+/*
+ bool forward(size_t& posn)
+ go forward in history, if possible
+ undo calling of back()
+*/
+bool CNavigation::forward(size_t& posn)
+{
+ if (historycurrent!=historyend) {
+ // [historycurrent] = current position
+ // [historycurrent+1] = position we need
+ historycurrent=(historycurrent+1)%NAVIGATION_HISTORY_SIZE;
+ posn = history[historycurrent];
+ //printf("forward(): going to position %d\n",posn);
+ return true;
+ } else {
+ //printf("forward(): there is no future :)\n");
+ return false;
+ }
+}
void CNavigation::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
{
len = srclen+sizeof(size_t)*(3+NAVIGATION_HISTORY_SIZE);
@@ -71,12 +89,14 @@ void CNavigation::setSaveData(unsigned char*& data, unsigned short& len, unsigne
p += sizeof(size_t);
memcpy(p, &historycurrent, sizeof(size_t));
p += sizeof(size_t);
memcpy(p, history, sizeof(size_t)*NAVIGATION_HISTORY_SIZE);
+/*
printf("<%u,%u,%u>\n", historystart, historyend, historycurrent);
for (int i = historystart; i <= historyend; i++)
printf("<%u> ", history[i]);
printf("\n");
+*/
}
void CNavigation::putSaveData(unsigned char*& src, unsigned short& srclen)
{
@@ -92,9 +112,11 @@ void CNavigation::putSaveData(unsigned char*& src, unsigned short& srclen)
memcpy(history, p, sizeof(size_t)*NAVIGATION_HISTORY_SIZE);
src = p + sizeof(size_t)*NAVIGATION_HISTORY_SIZE;
srclen -= sizeof(size_t)*(3+NAVIGATION_HISTORY_SIZE);
}
+/*
printf("<%u,%u,%u>\n", historystart, historyend, historycurrent);
for (int i = historystart; i <= historyend; i++)
printf("<%u> ", history[i]);
printf("\n");
+*/
}
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,4 +1,5 @@
+#include <string.h>
#include <stdlib.h>
const size_t NAVIGATION_HISTORY_SIZE = 32;
@@ -8,8 +9,9 @@ class CNavigation
size_t historystart, historyend, historycurrent;
public:
CNavigation() : historystart(0),historyend(0),historycurrent(0) {}
void saveposn(size_t posn);
+ void writeposn(size_t posn);
bool forward(size_t& loc);
bool back(size_t& loc);
void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen);
void putSaveData(unsigned char*& src, unsigned short& srclen);
diff --git a/noncore/apps/opie-reader/Palm2QImage.cpp b/noncore/apps/opie-reader/Palm2QImage.cpp
index 9603877..bf5ece3 100644
--- a/noncore/apps/opie-reader/Palm2QImage.cpp
+++ b/noncore/apps/opie-reader/Palm2QImage.cpp
@@ -1,10 +1,11 @@
/* -*- mode: c; indent-tabs-mode: nil; -*- */
+#include "useqpe.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#ifndef WINDOWS
-#include <unistd.h> /* for link */
+#ifndef _WINDOWS
+#include <unistd.h> /* for link */
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <stdarg.h>
@@ -201,13 +202,13 @@ QImage* Palm2QImage
// qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel);
return NULL;
}
-#ifdef WINDOWS
- QImage* qimage = new QImage(width, height, 32);
-#else
- QImage* qimage = new QImage(width, height, 16);
-#endif
+#ifndef USEQPE
+ QImage* qimage = new QImage(width, height, 32);
+#else
+ QImage* qimage = new QImage(width, height, 16);
+#endif
/* row by row, uncompress the Palm image and copy it to the JPEG buffer */
rowbuf = new unsigned char[bytes_per_row * width];
lastrow = new unsigned char[bytes_per_row * width];
diff --git a/noncore/apps/opie-reader/Palm2QImage.h b/noncore/apps/opie-reader/Palm2QImage.h
index 3ac2d19..5d327c5 100644
--- a/noncore/apps/opie-reader/Palm2QImage.h
+++ b/noncore/apps/opie-reader/Palm2QImage.h
@@ -3,5 +3,5 @@
QImage* Palm2QImage
(unsigned char *image_bytes_in, int byte_count_in);
-QPixmap* hRule(int w, int h, unsigned char r=0, unsigned char g=0, unsigned char b=0);
+QImage* 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
@@ -1,8 +1,9 @@
#ifndef __QFLOATBAR_H
#define __QFLOATBAR_H
#include <qtoolbar.h>
+#include <qmainwindow.h>
class QFloatBar : public QToolBar
{
Q_OBJECT
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
@@ -7,23 +7,29 @@
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
+#include "useqpe.h"
#include <qpainter.h>
+#include <qimage.h>
+#include <qtimer.h>
#include "config.h"
#include "QTReader.h"
#include "QTReaderApp.h"
#include "CDrawBuffer.h"
+#ifdef USEQPE
#include <qpe/qpeapplication.h>
+#endif
#include <math.h>
#include <ctype.h>
#include <stdio.h> //for sprintf
+#ifdef USEQPE
#include <qpe/config.h>
#include <qpe/applnk.h>
-#include <qfontdatabase.h>
#include <qpe/global.h>
#include <qpe/qcopenvelope_qws.h>
-#include "StateData.h"
+#endif
+#include <qfontdatabase.h>
#ifdef _UNICODE
const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 };
#else
@@ -35,8 +41,12 @@ const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 };
//const int QTReader::fontsizes[] = {10,16,17,22,0};
//const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 };
//const int QTReader::fontsizes[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0};
+tchar 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 };
+tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>','>',0 };
+//tchar QTReader::jplucknextpart[] = { 10,'#',10,'N','e','x','t',' ','P','a','r','t',' ','>','>',0 };
+
QTReader::QTReader( QWidget *parent, const char *name, WFlags f) :
QWidget(parent, name, f),
m_delay(100),
m_scrolldy1(0),
@@ -50,15 +60,20 @@ QTReader::QTReader( QWidget *parent, const char *name, WFlags f) :
mouseUpOn(true),
m_twotouch(true),
m_touchone(true),
bDoUpdates(false),
- m_navkeys(true)
+#ifdef _SCROLLPIPE
+ m_pipeout(NULL),
+#endif
+ m_border(2)
{
m_overlap = 1;
+ setKeyCompression ( true );
// init();
}
+
/*
-QTReader::QTReader( const QString& filename, QWidget *parent, const tchar *name, WFlags f ) :
+QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) :
QWidget(parent, name, f),
m_textfont(0),
m_textsize(1),
textarray(NULL),
@@ -71,13 +86,22 @@ QTReader::QTReader( const QString& filename, QWidget *parent, const tchar *name,
bindenter(0),
m_fm(NULL)
{
init();
- // qDebug("Load_file(1)");
+// // qDebug("Load_file(1)");
load_file((const tchar*)filename);
}
*/
+/*
+void QTReader::mouseMoveEvent(QMouseEvent* _e)
+{
+
+ mouseUpOn = !(_e->pos().x() == -1);
+
+ qDebug("MouseMove:[%d, %d]", _e->pos().x(), _e->pos().y());
+}
+*/
long QTReader::real_delay()
{
return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing );
}
@@ -86,56 +110,105 @@ void QTReader::mousePressEvent( QMouseEvent* _e )
{
buffdoc.unsuspend();
if (_e->button() == RightButton)
{
+// qDebug("MousePress");
mouseUpOn = false;
- if (buffdoc.hasnavigation())
+ if (m_swapmouse)
{
- if (_e->y() > (2*height())/3)
- {
- goDown();
- }
- else if (_e->y() < height()/3)
- {
- goUp();
- }
- else
- {
- if (_e->x() < width()/3)
- {
- size_t target = pagelocate();
- if (buffdoc.back(target))
- {
- locate(target);
- }
- }
- else if (_e->x() > (2*width())/3)
- {
- size_t target = pagelocate();
- if (buffdoc.forward(target))
- {
- locate(target);
- }
- }
- else
+ int lineno = 0;
+ int ht = textarray[0]->lineSpacing();
+ while ((ht < _e->y()) && (lineno < numlines))
{
- buffdoc.saveposn(pagelocate());
- locate(buffdoc.getHome());
+ ht += textarray[++lineno]->lineSpacing();
}
- }
+ size_t startpos, startoffset, tgt;
+ getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt);
+ processmousewordevent(startpos, startoffset, _e, lineno);
+ }
+ else
+ processmousepositionevent(_e);
+ }
+}
+
+void QTReader::processmousepositionevent( QMouseEvent* _e )
+{
+ if (buffdoc.hasnavigation())
+ {
+ if (_e->y() > (2*height())/3)
+ {
+ goDown();
+ }
+ else if (_e->y() < height()/3)
+ {
+ goUp();
}
else
{
- if (_e->y() > height()/2)
+ if (_e->x() < width()/3)
{
- goDown();
+ goBack();
+ }
+ else if (_e->x() > (2*width())/3)
+ {
+ goForward();
}
else
{
- goUp();
+ goHome();
}
}
}
+ else
+ {
+ if (_e->y() > height()/2)
+ {
+ goDown();
+ }
+ else
+ {
+ goUp();
+ }
+ }
+}
+
+void QTReader::goHome()
+{
+ if (buffdoc.hasnavigation())
+ {
+ size_t current=pagelocate();
+ size_t home=buffdoc.getHome();
+ if (current!=home)
+ {
+ buffdoc.saveposn(current);
+ locate(home);
+ }
+ }
+}
+
+void QTReader::goBack()
+{
+ if (buffdoc.hasnavigation())
+ {
+ size_t target = pagelocate();
+ buffdoc.writeposn(target);
+ if (buffdoc.back(target))
+ {
+ locate(target);
+ }
+ }
+}
+
+void QTReader::goForward()
+{
+ if (buffdoc.hasnavigation())
+ {
+ size_t target = pagelocate();
+ if (buffdoc.forward(target))
+ {
+ locate(target);
+ }
+ }
}
linkType QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt)
{
@@ -147,21 +220,30 @@ linkType QTReader::getcurrentpos(int x, int y, size_t& start, size_t& offset, si
}
start = locnarray[lineno];
if (m_bMonoSpaced)
{
- offset = x/m_charWidth;
+ offset = (x - textarray[lineno]->offset(width(), m_border))/m_charWidth;
}
else
{
int i;
CDrawBuffer* t = textarray[lineno];
- x = x - t->offset(width());
- for (i = t->length(); i >= 0 && t->width(i) > x; i--);
+ x = x - t->offset(width(), m_border);
+ for (i = t->length(); i >= 0 && t->width(i, true, width(), m_border) > x; i--);
offset = i;
}
return textarray[lineno]->getLinkType(offset, tgt);
}
+void QTReader::suspend()
+{
+#ifdef OPIE
+ if (memcmp("/mnt/", m_lastfile.latin1(), 5) == 0) buffdoc.suspend();
+#else
+ if (memcmp("/usr/mnt.rom/", m_lastfile.latin1(), 13) == 0) buffdoc.suspend();
+#endif
+}
+
void QTReader::setTwoTouch(bool _b)
{
setBackgroundColor( white );
m_twotouch = m_touchone = _b;
@@ -172,18 +254,108 @@ void QTReader::setContinuous(bool _b)
buffdoc.unsuspend();
buffdoc.setContinuous(m_continuousDocument = _b);
}
+void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno)
+{
+ QString wrd;
+ if (m_twotouch)
+ {
+ if (m_touchone)
+ {
+ m_touchone = false;
+ m_startpos = startpos;
+ m_startoffset = startoffset;
+ setBackgroundColor( lightGray );
+ }
+ else
+ {
+ m_touchone = true;
+ setBackgroundColor( white );
+ size_t endpos, endoffset;
+ endpos = startpos;
+ endoffset = startoffset;
+ size_t currentpos = locate();
+ if (endpos >= m_startpos)
+ {
+ jumpto(m_startpos);
+ for (int i = 0; i < m_startoffset; i++)
+ {
+ getch();
+ }
+ if (m_startpos == endpos)
+ {
+ for (int i = m_startoffset; i <= endoffset; i++)
+ {
+ wrd += QChar(getch());
+ }
+ }
+ else
+ {
+ while (buffdoc.explocate() <= endpos)
+ {
+ wrd += QChar(getch());
+ }
+ for (int i = 0; i < endoffset; i++)
+ {
+ wrd += QChar(getch());
+ }
+ }
+ jumpto(currentpos);
+ }
+ }
+ }
+ else if (m_bMonoSpaced)
+ {
+ int chno = (_e->x()-textarray[lineno]->offset(width(), m_border))/m_charWidth;
+ if (chno < ustrlen(textarray[lineno]->data()))
+ {
+ wrd[0] = textarray[lineno]->data()[chno];
+ }
+ }
+ else
+ {
+ CDrawBuffer* t = textarray[lineno];
+ int first = 0;
+ int tgt = _e->x() - t->offset(width(), m_border);
+ while (1)
+ {
+ int i = first+1;
+ while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
+ if (t->width(i, true, width(), m_border) > tgt)
+ {
+ wrd = toQString(t->data()+first, i - first);
+// qDebug("Got %s", (const char *)wrd);
+ break;
+ }
+ while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
+ if ((*t)[i] == 0) break;
+ first = i;
+ }
+ }
+ if (!wrd.isEmpty())
+ {
+// qDebug("Selected:%s", (const char*)wrd);
+ emit OnWordSelected(wrd, locnarray[lineno], (m_twotouch) ? wrd : toQString(textarray[lineno]->data()));
+ }
+}
+
void QTReader::mouseReleaseEvent( QMouseEvent* _e )
{
buffdoc.unsuspend();
if (_e->button() == LeftButton)
{
if (mouseUpOn)
{
+// qDebug("MouseRelease");
+ if (_e->x() > width() - m_border)
+ {
+ locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*_e->y()+height()/2)/height());
+ return;
+ }
if (textarray[0] != NULL)
{
- QString wrd, line;
+ QString line;
// int lineno = _e->y()/m_linespacing;
int lineno = 0;
int ht = textarray[0]->lineSpacing();
while ((ht < _e->y()) && (lineno < numlines))
@@ -195,24 +367,43 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e )
{
case eLink:
{
size_t saveposn = pagelocate();
- if (buffdoc.hyperlink(tgt))
+ QString href;
+ linkType lt = buffdoc.hyperlink(tgt, href);
+ if (lt == eLink)
{
buffdoc.saveposn(saveposn);
fillbuffer();
update();
}
else
{
+ if (lt == ePicture)
+ {
+ QImage* pm = buffdoc.getPicture(tgt);
+ if (pm != NULL)
+ {
+ emit OnShowPicture(*pm);
+ delete pm;
+ }
+ }
+ else
+ {
+// QString anchortext = textarray[lineno]->getanchortext(startoffset);
+ if (!href.isEmpty())
+ {
+ emit OnURLSelected(href);
+ }
+ }
locate(pagelocate());
}
return;
}
case ePicture:
{
- qDebug("Picture:%x", tgt);
- QPixmap* pm = buffdoc.getPicture(tgt);
+// qDebug("Picture:%x", tgt);
+ QImage* pm = buffdoc.getPicture(tgt);
if (pm != NULL)
{
emit OnShowPicture(*pm);
delete pm;
@@ -225,88 +416,15 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e )
}
case eNone:
break;
default:
- qDebug("Unknown linktype");
+// qDebug("Unknown linktype");
return;
}
- if (m_twotouch)
- {
- if (m_touchone)
- {
- m_touchone = false;
- m_startpos = startpos;
- m_startoffset = startoffset;
- setBackgroundColor( lightGray );
- }
- else
- {
- m_touchone = true;
- setBackgroundColor( white );
- size_t endpos, endoffset;
- endpos = startpos;
- endoffset = startoffset;
- size_t currentpos = locate();
- if (endpos >= m_startpos)
- {
- jumpto(m_startpos);
- for (int i = 0; i < m_startoffset; i++)
- {
- getch();
- }
- if (m_startpos == endpos)
- {
- for (int i = m_startoffset; i <= endoffset; i++)
- {
- wrd += QChar(getch());
- }
- }
- else
- {
- while (buffdoc.explocate() <= endpos)
- {
- wrd += QChar(getch());
- }
- for (int i = 0; i < endoffset; i++)
- {
- wrd += QChar(getch());
- }
- }
- jumpto(currentpos);
- }
- }
- }
- else if (m_bMonoSpaced)
- {
- int chno = _e->x()/m_charWidth;
- if (chno < ustrlen(textarray[lineno]->data()))
- {
- wrd[0] = textarray[lineno]->data()[chno];
- }
- }
+ if (m_swapmouse)
+ processmousepositionevent(_e);
else
- {
- CDrawBuffer* t = textarray[lineno];
- int first = 0;
- int tgt = _e->x() - t->offset(width());
- while (1)
- {
- int i = first+1;
- while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
- if (t->width(i) > tgt)
- {
- wrd = toQString(t->data()+first, i - first);
- break;
- }
- while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
- if ((*t)[i] == 0) break;
- first = i;
- }
- }
- if (!wrd.isEmpty())
- {
- emit OnWordSelected(wrd, locnarray[lineno], (m_twotouch) ? wrd : toQString(textarray[lineno]->data()));
- }
+ processmousewordevent(startpos, startoffset, _e, lineno);
}
}
else
{
@@ -325,15 +443,17 @@ void QTReader::focusOutEvent(QFocusEvent* e)
{
if (m_autoScroll)
{
timer->stop();
- m_scrolldy1 = m_scrolldy2 = 0;
+// m_scrolldy1 = m_scrolldy2 = 0;
}
}
#include <qapplication.h>
#include <qdrawutil.h>
+#ifndef _WINDOWS
#include <unistd.h>
+#endif
void QTReader::goDown()
{
if (m_bpagemode)
@@ -425,11 +545,64 @@ void QTReader::zoomout()
if (m_autoScroll) autoscroll();
}
}
+void QTReader::reduceScroll()
+{
+ if (m_delay < 59049)
+ {
+ m_delay = (3*m_delay)/2;
+ timer->changeInterval(real_delay());
+ }
+ else
+ {
+ m_delay = 59049;
+ }
+}
+
+void QTReader::increaseScroll()
+{
+ if (m_delay > 1024)
+ {
+ m_delay = (2*m_delay)/3;
+ timer->changeInterval(real_delay());
+ }
+ else
+ {
+ m_delay = 1024;
+ }
+}
+
void QTReader::keyPressEvent(QKeyEvent* e)
{
buffdoc.unsuspend();
+ ((QTReaderApp*)parent()->parent())->handlekey(e);
+// e->ignore();
+ return;
+#ifdef _SCROLLPIPE
+ if (m_isPaused)
+ {
+ m_isPaused = false;
+ if (e->key() != Key_Space)
+ {
+ m_autoScroll = false;
+ if (m_pipeout != NULL)
+ {
+ pclose(m_pipeout);
+ m_pipeout = NULL;
+ }
+ ((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll);
+ QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
+ }
+ else
+ {
+ timer->start(real_delay(), false);
+ }
+ e->accept();
+ return;
+ }
+#endif
+/*
switch (e->key())
{
case Key_Down:
{
@@ -472,37 +645,8 @@ void QTReader::keyPressEvent(QKeyEvent* e)
goUp();
}
}
break;
- /*
- case Key_Left:
- {
- e->accept();
- if (m_textfont > 0)
- {
- m_textfont--;
- setfont(NULL);
- locate(pagelocate());
- update();
- }
- }
- break;
- case Key_Right:
- {
- e->accept();
- if (fonts[++m_textfont] == 0)
- {
- m_textfont--;
- }
- else
- {
- setfont(NULL);
- locate(pagelocate());
- update();
- }
- }
- break;
- */
case Key_Right:
{
e->accept();
if (m_navkeys && buffdoc.hasnavigation())
@@ -529,48 +673,61 @@ void QTReader::keyPressEvent(QKeyEvent* e)
}
else zoomout();
}
break;
- case Key_Space:
- case Key_Return:
- {
- e->accept();
- emit OnActionPressed();
- }
- break;
default:
e->ignore();
}
+*/
}
void QTReader::setautoscroll(bool _sc)
{
if (_sc == m_autoScroll) return;
if (m_autoScroll)
{
m_autoScroll = false;
+#ifdef USEQPE
QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
+#endif
+#ifdef _SCROLLPIPE
+ if (m_pipeout != NULL)
+ {
+ pclose(m_pipeout);
+ m_pipeout = NULL;
+ }
+#endif
}
else
{
CDrawBuffer* reusebuffer = textarray[numlines];
if (reusebuffer == NULL || reusebuffer->eof()) return;
m_autoScroll = true;
+#ifdef _SCROLLPIPE
+ if (!m_pipetarget.isEmpty())
+ {
+// qDebug("Opening pipe to %s", (const char*)m_pipetarget);
+ m_pipeout = popen((const char*)m_pipetarget, "w");
+ m_isPaused = false;
+ }
+#endif
autoscroll();
+#ifdef USEQPE
QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed
+#endif
}
}
bool QTReader::getline(CDrawBuffer *buff)
{
buffdoc.unsuspend();
if (m_bMonoSpaced)
{
- return buffdoc.getline(buff ,width(), m_charWidth);
+ return buffdoc.getline(buff ,width(), m_charWidth, m_border);
}
else
{
- return buffdoc.getline(buff, width());
+ return buffdoc.getline(buff, width(), m_border);
}
}
void QTReader::doscroll()
@@ -587,8 +744,27 @@ void QTReader::doscroll()
qDrawPlainRect(&p,0,height() - 2,width(),2,white,1,&b);
if (++m_scrolldy1 == textarray[0]->lineSpacing())
{
+#ifdef _SCROLLPIPE
+ if (m_pipeout != NULL)
+ {
+ QString outstr = toQString(textarray[0]->data());
+ if (!outstr.isEmpty())
+ {
+ fprintf(m_pipeout, "%s\n", (const char*)outstr);
+ fflush(m_pipeout);
+ }
+ else if (m_pauseAfterEachPara)
+ {
+ m_isPaused = true;
+ timer->stop();
+ }
+// write(m_pipeout, (const char*)outstr, outstr.length());
+// write(m_pipeout, "\n", 1);
+// fputc(10, m_pipeout);
+ }
+#endif
CDrawBuffer* buff = textarray[0];
for (int i = 1; i <= numlines; i++)
{
textarray[i-1] = textarray[i];
@@ -608,14 +784,31 @@ void QTReader::doscroll()
textarray[numlines] = new CDrawBuffer(&m_fontControl);
}
locnarray[numlines] = locate();
int ch = getline(textarray[numlines]);
- textarray[numlines-1]->render(&p, height() - textarray[numlines-1]->descent() - 2, m_bMonoSpaced, m_charWidth, width());
+ textarray[numlines-1]->render(&p, height() - textarray[numlines-1]->descent() - 2, m_bMonoSpaced, m_charWidth, width(), m_border);
mylastpos = locate();
if (!ch)
{
m_autoScroll = false;
+#ifdef _SCROLLPIPE
+ for (int i = 0; i < numlines; i++)
+ {
+ if (m_pipeout != NULL)
+ {
+ QString outstr = toQString(textarray[i]->data());
+ if (!outstr.isEmpty())
+ {
+ fprintf(m_pipeout, "%s\n", (const char*)outstr);
+ fflush(m_pipeout);
+ }
+ }
+ }
+#endif
((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll);
+#ifdef USEQPE
+ QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
+#endif
}
emit OnRedraw();
}
}
@@ -638,70 +831,85 @@ void QTReader::setfont()
void QTReader::drawFonts( QPainter *p )
{
if (bDoUpdates)
{
- qDebug("How refreshing...");
+// qDebug("How refreshing...");
if (buffdoc.empty()) return;
setfont();
if (m_lastwidth != width())
{
- qDebug("Not Optimised %d", m_lastwidth);
+// qDebug("Not Optimised %d", m_lastwidth);
m_lastwidth = width();
m_lastheight = height();
+ buffdoc.setwidth(m_lastwidth-2*m_border);
locate(pagelocate());
- qDebug("Not Optimised %d", m_lastwidth);
+// qDebug("Not Optimised %d", m_lastwidth);
}
else
{
- if (m_lastheight > height())
+ int newht = height();
+ if (m_lastheight > newht)
{
- qDebug("Optimised < %d", numlines);
+// qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht);
int ypos = 0;
for (int i = 0; i < numlines; i++)
{
- if ((ypos += textarray[i]->lineSpacing()) > height())
+ if ((ypos += textarray[i]->lineSpacing()) > newht)
{
numlines = i;
- jumpto(locnarray[i+1]);
+ jumpto(mylastpos = locnarray[i+1]);
break;
}
}
- qDebug("Optimised < %d", numlines);
- m_lastheight = height();
+// qDebug("Optimised < %d", numlines);
+ m_lastheight = newht;
}
- else if (m_lastheight < height())
+ else if (m_lastheight < newht)
{
- qDebug("Optimised > %d", numlines);
+// qDebug("Optimised > %d", numlines);
int ypos = 0;
for (int i = 0; i <= numlines; i++)
{
ypos += textarray[i]->lineSpacing();
}
- fillbuffer(numlines+1, ypos);
- qDebug("Optimised > %d", numlines);
- m_lastheight = height();
+ fillbuffer(numlines+1, ypos, newht);
+// qDebug("Optimised > %d", numlines);
}
if (numlines > 0)
{
int ypos = textarray[0]->ascent();
- textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width());
+ textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_border);
+// int last = (m_showlast) ? numlines : numlines-1;
+// for (int i = 1; i <= last; i++)
for (int i = 1; i < numlines; i++)
{
// ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2;
ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+
(textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2;
- textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width());
+ textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_border);
}
// mylastpos = locate();
}
}
- m_scrolldy1 = m_scrolldy2 = 0;
+
+ m_scrolldy1 = m_scrolldy2 = m_scrollpart;
+ if (m_border > 5 && !buffdoc.empty())
+ {
+ p->fillRect(width()-2, 0, 2, height(), cyan);
+ int sectionsize = (buffdoc.endSection()-buffdoc.startSection());
+ int mid = (height()*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize);
+ p->fillRect(width()-2, mid-5, 2, 10, yellow);
+ p->fillRect(width()-2, (height()*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize, 2, ((locnarray[numlines]-locnarray[0])*height()+sectionsize/2)/sectionsize, magenta);
+ }
+
emit OnRedraw();
}
+/*
else
{
qDebug("Not so refreshing...");
}
+*/
}
QString QTReader::firstword()
{
@@ -741,8 +949,9 @@ bool QTReader::ChangeFont(int tgt)
}
void QTReader::init()
{
+// m_showlast = true;
// setCaption( "Qt Draw Demo Application" );
buffdoc.unsuspend();
setBackgroundColor( white );
@@ -770,8 +979,20 @@ void QTReader::init()
// Clean up
//
QTReader::~QTReader()
{
+#ifdef USEQPE
+ if (m_autoScroll)
+ {
+ QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
+ }
+#endif
+#ifdef _SCROLLPIPE
+ if (m_pipeout != NULL)
+ {
+ fclose(m_pipeout);
+ }
+#endif
}
//
// Calls the drawing function as specified by the radio buttons.
@@ -815,9 +1036,9 @@ void QTReader::paintEvent( QPaintEvent * )
/*
void QTReader::resizeEvent( QResizeEvent * )
{
- // qDebug("resize:(%u,%u)", width(), height());
+// // qDebug("resize:(%u,%u)", width(), height());
// bgroup->move( width()-bgroup->width(), 0 );
}
*/
@@ -840,13 +1061,13 @@ int main( int argc, tchar **argv )
bool QTReader::locate(unsigned long n) {
//printf("Locate\n");
buffdoc.unsuspend();
buffdoc.locate(n);
- // qDebug("&buffdoc.located");
+// // qDebug("&buffdoc.located");
fillbuffer();
- // qDebug("&Buffer filled");
+// // qDebug("&Buffer filled");
update();
- // qDebug("&Located");
+// // qDebug("&Located");
return true;
}
unsigned int QTReader::screenlines()
@@ -855,20 +1076,24 @@ unsigned int QTReader::screenlines()
// return (height()-m_descent)/(m_linespacing);
return (height()-2)/(m_linespacing);
};
-bool QTReader::fillbuffer(int reuse, int ht)
+bool QTReader::fillbuffer(int reuse, int ht, int newht)
{
buffdoc.unsuspend();
if (buffdoc.empty()) return false;
- m_scrolldy1 = m_scrolldy2 = 0;
+ if (newht < 0)
+ m_lastheight = height();
+ else
+ m_lastheight = newht;
int ch;
bool ret = false;
unsigned int oldpagepos = locnarray[reuse];
- int ypos = ht;
+ int lastypos = ht, ypos = ht;
numlines = reuse;
- while (ypos < height() || numlines < 2)
+ while (ypos < m_lastheight || numlines < 2)
{
+ lastypos = ypos;
if (textarray[numlines] == NULL)
{
textarray[numlines] = new CDrawBuffer(&m_fontControl);
}
@@ -893,20 +1118,21 @@ bool QTReader::fillbuffer(int reuse, int ht)
}
--numlines;
mylastpos = locate();
+ m_scrolldy1 = m_scrolldy2 = m_scrollpart = m_lastheight - lastypos;
return true;
}
-
void QTReader::dopagedn()
{
+// qDebug("HEIGHT(2):%d", m_lastheight);
buffdoc.unsuspend();
int skip = 0, ypos = 0;
if (locate() != mylastpos)
{
-// qDebug("Jumping to %u", mylastpos);
+//// qDebug("Jumping to %u", mylastpos);
jumpto(mylastpos);
}
CDrawBuffer* reusebuffer = textarray[numlines];
if (reusebuffer != NULL && reusebuffer->eof()) return;
@@ -937,22 +1163,33 @@ void QTReader::dopageup()
buffdoc.unsuspend();
dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]);
}
+bool QTReader::synch(size_t start, size_t end)
+{
+ jumpto(start);
+ while (start++ < end)
+ {
+ tchar ch = getch();
+ if (ch == 10) return true;
+ if (ch == UEOF) return false;
+ }
+ return false;
+}
+
void QTReader::dopageup(unsigned int target)
{
buffdoc.unsuspend();
CBufferFace<CDrawBuffer*> buff;
CBufferFace<size_t> loc;
- size_t delta, guess = 2048;
+ size_t delta, guess = 2*(locate()-pagelocate()), lastdelta = 0;
bool ch = true;
int nbfl, ypos = 0;
-
+ if (guess < 128) guess = 128;
while (1)
{
ch = true;
- nbfl = 0;
if (target < guess)
{
delta = 0; // 0 is a flag to say don't guess any more
jumpto( (m_continuousDocument) ? 0 : buffdoc.startSection() );
@@ -964,24 +1201,26 @@ void QTReader::dopageup(unsigned int target)
}
else
{
delta = guess;
-
- jumpto(target - delta);
-
- buff[0] = new CDrawBuffer(&m_fontControl);
-
- do
+ if (!synch(target-delta, target-lastdelta))
{
-
- if (!getline(buff[0])) break;
-
- if (locate() > target) break;
+ lastdelta = delta;
+ if (guess < 4000)
+ {
+ guess <<= 1;
+ continue;
+ }
+ else
+ {
+ jumpto(target-delta);
+ }
}
- while (!buffdoc.iseol());
}
+ nbfl = 0;
ypos = 0;
+
while (locate() < target)
{
if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl);
loc[nbfl] = locate();
@@ -989,9 +1228,9 @@ void QTReader::dopageup(unsigned int target)
ypos += buff[nbfl]->lineSpacing();
nbfl++;
if (!ch) break;
}
- if (ypos < height() && (delta != 0))
+ if (guess < 4000 && ypos < height() && (delta != 0))
{
for (int i = 0; i < nbfl; i++)
{
delete buff[i];
@@ -1008,16 +1247,29 @@ void QTReader::dopageup(unsigned int target)
loc[nbfl] = locate();
int ch = getline(buff[nbfl]);
nbfl++;
}
+/*
ypos = 0;
numlines = 0;
while (ypos < height() && numlines <= nbfl-1)
{
ypos += buff[nbfl - numlines - 1]->lineSpacing();
numlines++;
}
--numlines;
+*/
+
+ ypos = 0;
+ numlines = 0;
+ while (ypos < height() && numlines+2 <= nbfl)
+ {
+ ypos += buff[nbfl - numlines - 2]->lineSpacing();
+ numlines++;
+ }
+ if (numlines > 0) --numlines;
+ if (numlines == 0 && nbfl > 1) numlines = 1;
+
int offset = nbfl-1;
offset -= numlines;
ypos = 0;
for (int i = 0; i <= numlines; i++)
@@ -1026,9 +1278,13 @@ void QTReader::dopageup(unsigned int target)
textarray[i] = buff[offset+i];
locnarray[i] = loc[offset + i];
ypos += textarray[i]->lineSpacing();
}
+#ifdef _WINDOWS
+ for (i = 0; i < nbfl - numlines - 1; i++)
+#else
for (int i = 0; i < nbfl - numlines - 1; i++)
+#endif
{
delete buff[i];
}
@@ -1056,23 +1312,24 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn)
if (m_lastfile == newfile)
{
lcn = m_lastposn;
}
- m_lastfile = newfile;
// QMessageBox::information(0, "Opening...", newfile);
m_lastwidth = width();
m_lastheight = height();
if (buffdoc.openfile(this,newfile) == 0)
- {
+ {
+ m_lastfile = newfile;
+ buffdoc.setwidth(m_lastwidth-2*m_border);
bRC = true;
buffdoc.setContinuous(m_continuousDocument);
- // qDebug("buffdoc.openfile done");
+// // qDebug("buffdoc.openfile done");
locate(lcn);
- // qDebug("buffdoc.locate done");
+// // qDebug("buffdoc.locate done");
}
setfilter(getfilter());
update();
- // qDebug("Updated");
+// // qDebug("Updated");
return bRC;
}
void QTReader::lineDown()
@@ -1088,9 +1345,13 @@ void QTReader::lineDown()
break;
}
}
offset = numlines - offset;
+#ifdef _WINDOWS
+ for (i = offset; i <= numlines; i++)
+#else
for (int i = offset; i <= numlines; i++)
+#endif
{
CDrawBuffer* buff = textarray[i-offset];
textarray[i-offset] = textarray[i];
locnarray[i-offset] = locnarray[i];
@@ -1258,9 +1519,13 @@ void QTReader::lineUp()
textarray[0] = buff;
locnarray[0] = loc;
int start = numlines;
int ypos = 0;
- for (int i = 0; i <= numlines; i++)
+#ifdef _WINDOWS
+ for (i = 0; i <= numlines; i++)
+#else
+ for (int i = 0; i <= numlines; i++)
+#endif
{
ypos += textarray[i]->lineSpacing();
if (ypos > height())
{
@@ -1295,33 +1560,4 @@ MarkupType QTReader::PreferredMarkup()
}
}
return m;
}
-
-void QTReader::setstate(const statedata& sd)
-{
- bstripcr = sd.bstripcr;
- btextfmt = sd.btextfmt;
- bautofmt = sd.bautofmt;
- bstriphtml = sd.bstriphtml;
- bpeanut = sd.bpeanut;
- bdehyphen = sd.bdehyphen;
- bonespace = sd.bonespace;
- bunindent = sd.bunindent;
- brepara = sd.brepara;
- bdblspce = sd.bdblspce;
- m_bpagemode = sd.m_bpagemode;
- m_navkeys = sd.m_navkeys;
- m_bMonoSpaced = sd.m_bMonoSpaced;
- bremap = sd.bremap;
- bmakebold = sd.bmakebold;
- m_continuousDocument = sd.Continuous;
-#ifdef REPALM
- brepalm = sd.brepalm;
-#endif
- bindenter = sd.bindenter;
- m_encd = sd.m_charpc;
- m_fontname = sd.m_fontname;
- setContinuous(sd.Continuous);
- ChangeFont(sd.m_textsize);
- refresh();
-}
diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h
index 3d5f57d..dfbdfb9 100644
--- a/noncore/apps/opie-reader/QTReader.h
+++ b/noncore/apps/opie-reader/QTReader.h
@@ -1,7 +1,9 @@
#ifndef __QTREADER_H
#define __QTREADER_H
+//#define _SCROLLPIPE
+
#include <qwidget.h>
//#include <qpainter.h>
#include "my_list.h"
#include "BuffDoc.h"
@@ -13,30 +15,44 @@ class CDrawBuffer;
//class CBuffer;
class QPainter;
class QTimer;
class QPixmap;
-class statedata;
class QTReader : public QWidget
{
Q_OBJECT
+ static tchar pluckernextpart[];
+ static tchar jplucknextpart[];
friend class QTReaderApp;
- void suspend() { buffdoc.suspend(); }
+ void suspend();
+ void increaseScroll();
+ void reduceScroll();
void drawText(QPainter& p, int x, int y, tchar* text);
int m_delay;
unsigned int m_overlap;
- bool m_autoScroll;
+ bool m_autoScroll, m_swapmouse;
void autoscroll();
QTimer* timer;
- int m_scrolldy1, m_scrolldy2, m_encd;
+ int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart;
void focusInEvent(QFocusEvent*);
void focusOutEvent(QFocusEvent*);
+ void processmousepositionevent( QMouseEvent* _e );
+ void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno);
bool ChangeFont(int);
bool getline(CDrawBuffer*);
int m_charWidth;
int m_charpc;
+ unsigned char m_border;
FontControl m_fontControl;
+ void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); }
+ unsigned char getBaseSize() { return m_fontControl.getBaseSize(); }
+#ifdef _SCROLLPIPE
+ FILE* m_pipeout;
+ QString m_pipetarget;
+ bool m_isPaused;
+ bool m_pauseAfterEachPara;
+#endif
public:
QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0);
// QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0);
~QTReader();
@@ -85,91 +101,24 @@ public:
m_string = QString::null;
}
};
*/
- void setpeanut(bool _b)
- {
- bpeanut = _b;
- setfilter(getfilter());
- }
- void setremap(bool _b)
- {
- bremap = _b;
- setfilter(getfilter());
- }
- void setmakebold(bool _b)
- {
- bmakebold = _b;
- setfilter(getfilter());
- }
- void setautofmt(bool _b)
- {
- bautofmt = _b;
- if (bautofmt)
+ void setlead(int _lead)
{
- btextfmt = false;
- bstriphtml = false;;
- bpeanut = false;
+ m_fontControl.setlead(_lead);
+ }
+ int getlead()
+ {
+ return m_fontControl.getlead();
+ }
+ void setextraspace(int _lead)
+ {
+ m_fontControl.setextraspace(_lead);
+ }
+ int getextraspace()
+ {
+ return m_fontControl.getextraspace();
}
- setfilter(getfilter());
- }
- void settextfmt(bool _b)
- {
- btextfmt = _b;
- setfilter(getfilter());
- }
- void setstripcr(bool _b)
- {
- bstripcr = _b;
- setfilter(getfilter());
- }
- void setonespace(bool _b)
- {
- bonespace = _b;
- setfilter(getfilter());
- }
-#ifdef REPALM
- void setrepalm(bool _b)
- {
- brepalm = _b;
- setfilter(getfilter());
- }
-#endif
- void setstriphtml(bool _b)
- {
- bstriphtml = _b;
- setfilter(getfilter());
- }
- void setdehyphen(bool _b)
- {
- bdehyphen = _b;
- setfilter(getfilter());
- }
- void setunindent(bool _b)
- {
- bunindent = _b;
- setfilter(getfilter());
- }
- void setrepara(bool _b)
- {
- brepara = _b;
- setfilter(getfilter());
- }
- void setdblspce(bool _b)
- {
- bdblspce = _b;
- setfilter(getfilter());
- }
- void indentplus()
- {
- if (bindenter < 15) bindenter += 2;
- setfilter(getfilter());
- }
- void indentminus()
- {
- if (bindenter > 1) bindenter -= 2;
- setfilter(getfilter());
- }
void setpagemode(bool _b)
{
m_bpagemode = _b;
}
@@ -186,23 +135,28 @@ public:
}
MarkupType PreferredMarkup();
CEncoding* getencoding()
{
+// qDebug("m_encd:%d", m_encd);
switch (m_encd)
{
- case 5:
- return new Ccp1252;
case 4:
+// qDebug("palm");
return new CPalm;
case 1:
+// qDebug("utf8");
return new CUtf8;
case 2:
+// qDebug("ucs16be");
return new CUcs16be;
case 3:
+// qDebug("ucs16le");
return new CUcs16le;
case 0:
- default:
+// qDebug("ascii");
return new CAscii;
+ default:
+ return new CGeneral8Bit(m_encd-MAX_ENCODING+1);
}
}
CFilterChain* getfilter()
{
@@ -222,14 +176,20 @@ public:
#ifdef REPALM
if (brepalm) filt->addfilter(new repalm);
#endif
if (bremap) filt->addfilter(new remap);
+ if (bdepluck) filt->addfilter(new DePluck(pluckernextpart));
+ if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart));
if (bmakebold) filt->addfilter(new embolden);
+ if (bfulljust) filt->addfilter(new FullJust);
return filt;
}
private slots:
+ void goHome();
+ void goBack();
+ void goForward();
void doscroll();
void drawIt( QPainter * );
void paintEvent( QPaintEvent * );
// void resizeEvent( QResizeEvent * p ) { update(); }
@@ -259,9 +219,10 @@ private slots:
int m_lastwidth, m_lastheight;
CBufferFace<CDrawBuffer*> textarray;
CBufferFace<size_t> locnarray;
unsigned int numlines;
- bool bstripcr, btextfmt, bstriphtml, bdehyphen, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace;
+// bool m_showlast;
+ bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust;
#ifdef REPALM
bool brepalm;
#endif
bool m_bpagemode, m_bMonoSpaced, m_continuousDocument;
@@ -269,12 +230,12 @@ private slots:
QString m_lastfile;
size_t m_lastposn;
public:
bool bDoUpdates;
- bool m_navkeys;
void NavUp();
void NavDown();
- int getch() { return buffdoc.getch(); }
+ tchar getch() { return buffdoc.getch(); }
+ bool synch(size_t, size_t);
bool tight;
bool load_file(const char *newfile, unsigned int lcn=0);
BuffDoc buffdoc;
CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); }
@@ -291,22 +252,21 @@ private slots:
void goDown();
// bool bold;
int textsize() { return m_textsize; }
void textsize(int ts) { m_textsize = ts; }
- bool fillbuffer(int ru = 0, int ht = 0);
+ bool fillbuffer(int ru = 0, int ht = 0, int newht = -1);
unsigned int screenlines();
void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.unsuspend(); buffdoc.sizes(fs,ts); }
static const char *fonts[];
// unsigned int *fontsizes;
int m_ascent, m_descent, m_linespacing;
QFontMetrics* m_fm;
QString firstword();
- void setstate(const statedata& sd);
signals:
void OnRedraw();
void OnWordSelected(const QString&, size_t, const QString&);
- void OnActionPressed();
- void OnShowPicture(QPixmap&);
+ void OnShowPicture(QImage&);
+ void OnURLSelected(const QString&);
};
#endif
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index 7333a28..af1da27 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -16,74 +16,143 @@
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
-
+#include "useqpe.h"
+#include <qregexp.h>
#include <qclipboard.h>
#include <qwidgetstack.h>
+#ifdef USEQPE
#include <qpe/qpemenubar.h>
-//#include <qpe/qpetoolbar.h>
+#include <qpe/qpetoolbar.h>
+#endif
#include <qmenubar.h>
#include <qtoolbar.h>
+#ifdef USEQPE
#include <qpe/menubutton.h>
#include <qpe/fontdatabase.h>
+#endif
#include <qcombobox.h>
#include <qpopupmenu.h>
#include <qaction.h>
#include <qapplication.h>
#include <qlineedit.h>
#include <qtoolbutton.h>
#include <qspinbox.h>
#include <qobjectlist.h>
+#ifdef USEQPE
#include <qpe/global.h>
#include <qpe/applnk.h>
+#endif
#include <qfileinfo.h>
#include <stdlib.h> //getenv
#include <qprogressbar.h>
+#ifdef USEQPE
#include <qpe/config.h>
+#endif
#include <qbuttongroup.h>
#include <qradiobutton.h>
+#ifdef USEQPE
#include <qpe/qcopenvelope_qws.h>
-
+#endif
#include "QTReader.h"
#include "GraphicWin.h"
#include "Bkmks.h"
#include "cbkmkselector.h"
#include "infowin.h"
+#include "ToolbarPrefs.h"
+#include "Prefs.h"
#include "CAnnoEdit.h"
#include "QFloatBar.h"
+#include "FixedFont.h"
+#include "URLDialog.h"
//#include <qpe/fontdatabase.h>
+#ifdef USEQPE
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
+#include "fileBrowser.h"
+#else
+#include "qfiledialog.h"
+#endif
#include "QTReaderApp.h"
-#include "fileBrowser.h"
#include "CDrawBuffer.h"
#include "Filedata.h"
#include "opie.h"
-#include "name.h"
-#include "StateData.h"
+#include "useqpe.h"
+#include "names.h"
+#include "CEncoding_tables.h"
+#include "CloseDialog.h"
-#ifdef OPIE
+bool CheckVersion(int&, int&, char&);
+
+#ifdef _WINDOWS
+#define PICDIR "c:\\uqtreader\\pics\\"
+#else
+#ifdef USEQPE
#define PICDIR "opie-reader/"
#else
-#define PICDIR
+#define PICDIR "/home/tim/uqtreader/pics/"
+#endif
#endif
-
unsigned long QTReaderApp::m_uid = 0;
void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); }
+#ifdef USEQPE
+#define geticon(iconname) Resource::loadPixmap( iconname )
+#define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname )
+#else
+#define geticon(iconname) QPixmap(PICDIR iconname ".png")
+#define getmyicon(iconname) geticon(iconname)
+//#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) )
+#endif
+
+#ifndef _WINDOWS
#include <unistd.h>
+#endif
#include <stddef.h>
+#ifndef _WINDOWS
#include <dirent.h>
+#endif
void QTReaderApp::listBkmkFiles()
{
bkmkselector->clear();
bkmkselector->setText("Cancel");
+#ifndef USEQPE
+ int cnt = 0;
+
+ QDir d = QDir::home(); // "/"
+ if ( !d.cd(APPDIR) ) { // "/tmp"
+ qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
+ d = QDir::home();
+ d.mkdir(APPDIR);
+ d.cd(APPDIR);
+ }
+
+
+
+
+ d.setFilter( QDir::Files | QDir::NoSymLinks );
+// d.setSorting( QDir::Size | QDir::Reversed );
+
+ const QFileInfoList *list = d.entryInfoList();
+ QFileInfoListIterator it( *list ); // create list iterator
+ QFileInfo *fi; // pointer for traversing
+
+ while ( (fi=it.current()) ) { // for each file...
+
+ bkmkselector->insertItem(fi->fileName());
+ cnt++;
+
+ //qDebug( "%10li %s", fi->size(), fi->fileName().data() );
+ ++it; // goto next list element
+ }
+
+#else /* USEQPE */
int cnt = 0;
DIR *d;
d = opendir((const char *)Global::applicationFileName(APPDIR,""));
@@ -101,64 +170,150 @@ void QTReaderApp::listBkmkFiles()
}
}
closedir(d);
-
+#endif
if (cnt > 0)
{
//tjw menu->hide();
- editBar->hide();
- if (m_fontVisible) m_fontBar->hide();
- if (regVisible)
- {
- Global::hideInputMethod();
- regBar->hide();
- }
- if (searchVisible)
- {
- Global::hideInputMethod();
- searchBar->hide();
- }
- m_nRegAction = cRmBkmkFile;
editorStack->raiseWidget( bkmkselector );
+ hidetoolbars();
+ m_nBkmkAction = cRmBkmkFile;
}
else
QMessageBox::information(this, PROGNAME, "No bookmark files");
}
-QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
- : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false)
+void QTReaderApp::hidetoolbars()
{
-// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir());
-// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml"));
+ menubar->hide();
+ if (fileBar != NULL) fileBar->hide();
+ if (viewBar != NULL) viewBar->hide();
+ if (navBar != NULL) navBar->hide();
+ if (markBar != NULL) markBar->hide();
+ if (m_fontVisible) m_fontBar->hide();
+ if (regVisible)
+ {
+#ifdef USEQPE
+ Global::hideInputMethod();
+#endif
+ regBar->hide();
+ }
+ if (searchVisible)
+ {
+#ifdef USEQPE
+ Global::hideInputMethod();
+#endif
+ searchBar->hide();
+ }
+}
+QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
+ : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false),
+ fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL)
+{
+ m_url_clipboard = false;
+ m_url_localfile = false;
+ m_url_globalfile = false;
+ ftime(&m_lastkeytime);
+//// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir());
+//// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml"));
+
+ m_bcloseDisabled = true;
+ m_disableesckey = false;
pBkmklist = NULL;
pOpenlist = NULL;
// doc = 0;
m_fBkmksChanged = false;
QString lang = getenv( "LANG" );
+ QString rot = getenv( "QWS_DISPLAY" );
- m_autogenstr = "^ *[A-Z].*[a-z] *$";
- setToolBarsMovable( FALSE );
+/*
+ int m_rot = 0;
+ if (rot.contains("Rot90"))
+ {
+ m_rot = 90;
+ }
+ else if (rot.contains("Rot180"))
+ {
+ m_rot = 180;
+ }
+ else if (rot.contains("Rot270"))
+ {
+ m_rot = 270;
+ }
+
+// qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot);
+*/
+ m_autogenstr = "^ *[A-Z].*[a-z] *$";
- setIcon( Resource::loadPixmap( "uqtreader" ) );
+#ifdef USEQPE
+ setIcon( Resource::loadPixmap( PICDIR "uqtreader") );
+#else
+ setIcon( QPixmap (PICDIR "uqtreader.png") );
+#endif /* USEQPE */
// QPEToolBar *bar = new QPEToolBar( this );
- QToolBar *bar = new QToolBar( this );
- bar->setHorizontalStretchable( TRUE );
- addToolBar(bar, "tool",QMainWindow::Top, true);
-//tjw menu = bar;
-
- QPEMenuBar *mb = new QPEMenuBar( bar );
-// QMenuBar *mb = new QMenuBar( bar );
- QPopupMenu *file = new QPopupMenu( this );
- QPopupMenu *format = new QPopupMenu( this );
- // QPopupMenu *edit = new QPopupMenu( this );
+// menubar = new QPEToolBar( this );
+#ifdef USEQPE
+ Config config( APPDIR );
+#else
+ QDir d = QDir::home(); // "/"
+ if ( !d.cd(APPDIR) ) { // "/tmp"
+ qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
+ d = QDir::home();
+ d.mkdir(APPDIR);
+ d.cd(APPDIR);
+ }
+ QFileInfo fi(d, INIFILE);
+// qDebug("Path:%s", (const char*)fi.absFilePath());
+ Config config(fi.absFilePath());
+#endif
+ config.setGroup("Toolbar");
+ m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false);
+ m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1);
+ m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2);
+ menubar = new QToolBar("Menus", this, m_tbposition);
+
+// fileBar = new QToolBar("File", this);
+// QToolBar* viewBar = new QToolBar("File", this);
+// QToolBar* navBar = new QToolBar("File", this);
+// QToolBar* markBar = new QToolBar("File", this);
+
+#ifdef USEQPE
+ mb = new QPEMenuBar( menubar );
+#else
+ mb = new QMenuBar( menubar );
+#endif
-// bar = new QToolBar( this );
- editBar = bar;
+//#ifdef USEQPE
+ QPopupMenu* tmp = new QPopupMenu(mb);
+ mb->insertItem( geticon( "AppsIcon" ), tmp );
+//#else
+// QMenuBar* tmp = mb;
+//#endif
+
+ QPopupMenu *file = new QPopupMenu( mb );
+ tmp->insertItem( tr( "File" ), file );
+
+ QPopupMenu *navigation = new QPopupMenu(mb);
+ tmp->insertItem( tr( "Navigation" ), navigation );
+
+ QPopupMenu *view = new QPopupMenu( mb );
+ tmp->insertItem( tr( "View" ), view );
+
+ QPopupMenu *marks = new QPopupMenu( this );
+ tmp->insertItem( tr( "Marks" ), marks );
+
+ QPopupMenu *settings = new QPopupMenu( this );
+ tmp->insertItem( tr( "Settings" ), settings );
+
+// addToolBar(menubar, "Menus",QMainWindow::Top);
+// addToolBar(fileBar, "Toolbar",QMainWindow::Top);
+
+ // QPopupMenu *edit = new QPopupMenu( this );
/*
QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
@@ -172,11 +327,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
searchVisible = FALSE;
regVisible = FALSE;
m_fontVisible = false;
- pbar = new QProgressBar(this);
- pbar->hide();
-
m_annoWin = new CAnnoEdit(editorStack);
editorStack->addWidget(m_annoWin, get_unique_id());
connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) );
connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) );
@@ -204,27 +356,39 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
// don't need the close visible, it is redundant...
importSelector->setCloseVisible( FALSE );
*/
- qDebug("Reading file list");
+// qDebug("Reading file list");
readfilelist();
reader = new QTReader( editorStack );
reader->bDoUpdates = false;
+#ifdef USEQPE
((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold);
+#endif
- qDebug("Reading config");
- Config config( APPDIR );
+// qDebug("Reading config");
+// Config config( APPDIR );
config.setGroup( "View" );
-
+ m_debounce = config.readNumEntry("Debounce", 0);
+#ifdef USEQPE
+ m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false);
+#else
+ m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true);
+#endif
reader->bstripcr = config.readBoolEntry( "StripCr", true );
+ reader->bfulljust = config.readBoolEntry( "FullJust", false );
+ reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 ));
+ reader->setlead(config.readNumEntry( "ExtraLead", 0 ));
reader->btextfmt = config.readBoolEntry( "TextFmt", false );
reader->bautofmt = config.readBoolEntry( "AutoFmt", true );
reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
reader->bpeanut = config.readBoolEntry( "Peanut", false );
reader->bdehyphen = config.readBoolEntry( "Dehyphen", false );
+ reader->bdepluck = config.readBoolEntry( "Depluck", false );
+ reader->bdejpluck = config.readBoolEntry( "Dejpluck", false );
reader->bonespace = config.readBoolEntry( "OneSpace", false );
reader->bunindent = config.readBoolEntry( "Unindent", false );
reader->brepara = config.readBoolEntry( "Repara", false );
reader->bdblspce = config.readBoolEntry( "DoubleSpace", false );
@@ -233,106 +397,173 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
reader->m_delay = config.readNumEntry( "ScrollDelay", 5184);
reader->m_lastfile = config.readEntry( "LastFile", QString::null );
reader->m_lastposn = config.readNumEntry( "LastPosn", 0 );
reader->m_bpagemode = config.readBoolEntry( "PageMode", true );
- reader->m_navkeys = config.readBoolEntry( "CursorNavigation", false );
reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false);
+ reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false);
reader->m_fontname = config.readEntry( "Fontname", "helvetica" );
reader->m_encd = config.readNumEntry( "Encoding", 0 );
reader->m_charpc = config.readNumEntry( "CharSpacing", 100 );
reader->m_overlap = config.readNumEntry( "Overlap", 0 );
+ reader->m_border = config.readNumEntry( "Margin", 6 );
#ifdef REPALM
reader->brepalm = config.readBoolEntry( "Repalm", true );
#endif
reader->bremap = config.readBoolEntry( "Remap", true );
reader->bmakebold = config.readBoolEntry( "MakeBold", false );
reader->setContinuous(config.readBoolEntry( "Continuous", true ));
m_targetapp = config.readEntry( "TargetApp", QString::null );
m_targetmsg = config.readEntry( "TargetMsg", QString::null );
+#ifdef _SCROLLPIPE
+ reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null );
+ reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true );
+#endif
m_twoTouch = config.readBoolEntry( "TwoTouch", false);
m_doAnnotation = config.readBoolEntry( "Annotation", false);
m_doDictionary = config.readBoolEntry( "Dictionary", false);
m_doClipboard = config.readBoolEntry( "Clipboard", false);
m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll);
- setTwoTouch(m_twoTouch);
+ m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone);
+ m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen);
+ m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut);
+ m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn);
+ m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp);
+ m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown);
+
+ m_leftScroll = config.readBoolEntry("LeftScroll", false);
+ m_rightScroll = config.readBoolEntry("RightScroll", false);
+ m_upScroll = config.readBoolEntry("UpScroll", true);
+ m_downScroll = config.readBoolEntry("DownScroll", true);
+
+ m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false);
+ reader->setBaseSize(config.readNumEntry( "Basesize", 10 ));
+
+#ifndef USEQPE
+ config.setGroup( "Geometry" );
+ setGeometry(0,0,
+ config.readNumEntry( "width", QApplication::desktop()->width()/2 ),
+ config.readNumEntry( "height", QApplication::desktop()->height()/2 ));
+ move(
+ config.readNumEntry( "x", 20 ),
+ config.readNumEntry( "y", 20 ));
+#endif
- connect( reader, SIGNAL( OnShowPicture(QPixmap&) ), this, SLOT( showgraphic(QPixmap&) ) );
+
+ setTwoTouch(m_twoTouch);
+
+ connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) );
connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) );
- connect( reader, SIGNAL( OnActionPressed() ), this, SLOT( OnActionPressed() ) );
connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) );
+ connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) );
editorStack->addWidget( reader, get_unique_id() );
- QAction *a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
- connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
- a->addTo( bar );
- a->addTo( file );
+ m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL);
+ connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) );
+ m_preferences_action->addTo( settings );
- a = new QAction( tr( "Close" ), Resource::loadPixmap( "fileclose" ), QString::null, 0, this, 0 );
- connect( a, SIGNAL( activated() ), this, SLOT( fileClose() ) );
-// a->addTo( bar );
- a->addTo( file );
+ m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL);
+ connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) );
+ m_saveconfig_action->addTo( settings );
+
+ m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL);
+ connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) );
+ m_loadconfig_action->addTo( settings );
+
+ m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL);
+ connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) );
+ m_tidyconfig_action->addTo( settings );
+
+ settings->insertSeparator();
+ m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL);
+ connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) );
+ m_toolbarprefs_action->addTo( settings );
+
+ m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 );
+ connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
+ m_open_action->addTo( file );
+
+ m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 );
+ connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) );
+ m_close_action->addTo( file );
+#ifdef _SCRIPT
+ a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL);
+ connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) );
+ a->addTo( file );
+#endif
/*
- a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
+ a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) );
a->addTo( file );
- a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
+ a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
- a->addTo( editBar );
+ a->addTo( filebar() );
a->addTo( edit );
*/
- a = new QAction( tr( "Info" ), QString::null, 0, this, NULL);
- connect( a, SIGNAL( activated() ), this, SLOT( showinfo() ) );
- a->addTo( file );
-
- QActionGroup* ag = new QActionGroup(this);
- QPopupMenu *spacemenu = new QPopupMenu(this);
- file->insertItem( tr( "On Action..." ), spacemenu );
-
- m_buttonAction[0] = new QAction( tr( "Open File" ), QString::null, 0, ag, NULL, true );
-
- m_buttonAction[1] = new QAction( tr( "Autoscroll" ), QString::null, 0, ag, NULL, true );
-
- m_buttonAction[2] = new QAction( tr( "Mark" ), QString::null, 0, ag, NULL, true );
+ m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL);
+ connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) );
+ m_info_action->addTo( file );
- m_buttonAction[3] = new QAction( tr( "Fullscreen" ), QString::null, 0, ag, NULL, true );
+ m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true );
+ connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) );
+ m_touch_action->setOn(m_twoTouch);
+ m_touch_action->addTo( file );
- ag->addTo(spacemenu);
+ m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL);
+ connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) );
+ file->insertSeparator();
+// a->addTo( bar );
+ m_find_action->addTo( file );
- connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) );
+ m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL);
+ connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) );
+ m_exportlinks_action->addTo( file );
- file->insertSeparator();
+ m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true );
+ connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) );
+ m_scrollButton->addTo(navigation);
+ m_scrollButton->setOn(false);
- ag = new QActionGroup(this);
- ag->setExclusive(false);
- QPopupMenu *encoding = new QPopupMenu(this);
- file->insertItem( tr( "Navigation" ), encoding );
+ m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL);
+ connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) );
+ m_start_action->addTo(navigation);
- a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( PICDIR "panel-arrow-down" ), QString::null, 0, ag, 0, true );
+ m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL);
+ connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) );
+ m_end_action->addTo(navigation);
- a->setOn(false);
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) );
- a->addTo( bar );
+ m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL);
+ connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) );
+ m_jump_action->addTo(navigation);
- a = new QAction( tr( "Jump" ), QString::null, 0, ag, NULL);
- connect( a, SIGNAL( activated() ), this, SLOT( jump() ) );
+ m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true );
+ connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) );
+ m_pageline_action->addTo(navigation);
+ m_pageline_action->setOn(reader->m_bpagemode);
- a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, ag, NULL, true );
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) );
- a->setOn(reader->m_bpagemode);
+ m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 );
+ connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) );
+ m_pageup_action->addTo( navigation );
+
+ m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 );
+ connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) );
+ m_pagedn_action->addTo( navigation );
- a = new QAction( tr( "Set Overlap" ), QString::null, 0, ag, NULL);
- connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) );
+ m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 );
+ connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) );
+ m_back_action->addTo( navigation );
- a = new QAction( tr( "Use Cursor" ), QString::null, 0, ag, NULL, true );
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( navkeys(bool) ) );
- a->setOn(reader->m_navkeys);
+ m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 );
+ connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) );
+ m_home_action->addTo( navigation );
- ag->addTo(encoding);
+ m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 );
+ connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) );
+ m_forward_action->addTo( navigation );
/*
a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true );
// connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
@@ -342,268 +573,147 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
// connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
a->addTo( file );
*/
- file->insertSeparator();
+// file->insertSeparator();
- a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL);
- connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) );
- a->addTo( file );
+#ifdef _SCROLLPIPE
- a = new QAction( tr( "Two/One Touch" ), QString::null, 0, this, NULL, true );
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) );
- a->setOn(m_twoTouch);
- a->addTo( file );
-
- ag = new QActionGroup(this);
+ QActionGroup* ag = new QActionGroup(this);
ag->setExclusive(false);
- encoding = new QPopupMenu(this);
- file->insertItem( tr( "Target" ), encoding );
+ spacemenu = new QPopupMenu(this);
+ file->insertItem( tr( "Scrolling" ), spacemenu );
- a = new QAction( tr( "Annotation" ), QString::null, 0, ag, NULL, true );
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnAnnotation(bool) ) );
- a->setOn(m_doAnnotation);
+ a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL);
+ connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) );
- a = new QAction( tr( "Dictionary" ), QString::null, 0, ag, NULL, true );
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnDictionary(bool) ) );
- a->setOn(m_doDictionary);
+ a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true );
+ connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) );
+ a->setOn(reader->m_pauseAfterEachPara);
- a = new QAction( tr( "Clipboard" ), QString::null, 0, ag, NULL, true );
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnClipboard(bool) ) );
- a->setOn(m_doClipboard);
-
- ag->addTo(encoding);
+ ag->addTo(spacemenu);
+// file->insertSeparator();
+#endif
/*
a = new QAction( tr( "Import" ), QString::null, 0, this, NULL );
connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) );
a->addTo( file );
*/
-
- a = new QAction( tr( "Up" ), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 );
- connect( a, SIGNAL( activated() ), this, SLOT( pageup() ) );
- a->addTo( editBar );
-
- a = new QAction( tr( "Down" ), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 );
- connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
- a->addTo( editBar );
/*
- a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
+ a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
- a->addTo( editBar );
+ a->addTo( fileBar );
a->addTo( edit );
*/
-// a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
- a = new QAction( tr( "Find..." ), QString::null, 0, this, NULL);
- connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
- file->insertSeparator();
-// a->addTo( bar );
- a->addTo( file );
-
+// a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 );
m_fullscreen = false;
- a = m_actFullscreen = new QAction( tr( "Fullscreen" ), QString::null, 0, this, NULL, true );
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) );
- a->setOn(m_fullscreen);
- a->addTo( file );
-
- a = new QAction( tr( "Continuous" ), QString::null, 0, ag, NULL, true );
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( setcontinuous(bool) ) );
- a->setOn(reader->m_continuousDocument);
- a->addTo( file );
-
- a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
- connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) );
- a->addTo( bar );
-
- m_bkmkAvail->setEnabled(false);
+ m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true );
+ connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) );
+ m_actFullscreen->setOn(m_fullscreen);
+ m_actFullscreen->addTo( view );
+ view->insertSeparator();
- ag = new QActionGroup(this);
-// ag->setExclusive(false);
- encoding = new QPopupMenu(this);
- format->insertItem( tr( "Markup" ), encoding );
+ m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this);
+ connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) );
+ m_zoomin_action->addTo( view );
- a = new QAction( tr( "Auto" ), QString::null, 0, ag, NULL, true );
- a->setOn(reader->bautofmt);
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( autofmt(bool) ) );
+ m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this);
+ connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) );
+ m_zoomout_action->addTo( view );
- a = new QAction( tr( "None" ), QString::null, 0, ag, NULL, true );
- a->setOn(!reader->bautofmt && !(reader->btextfmt || reader->bstriphtml || reader->bpeanut));
-// connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) );
+ view->insertSeparator();
+ m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this);
+ connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) );
+ m_setfont_action->addTo( view );
- a = new QAction( tr( "Text" ), QString::null, 0, ag, NULL, true );
- a->setOn(reader->btextfmt);
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) );
+ view->insertSeparator();
+ m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this);
+ connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) );
+ m_setenc_action->addTo( view );
- a = new QAction( tr( "HTML" ), QString::null, 0, ag, NULL, true );
- a->setOn(reader->bstriphtml);
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( striphtml(bool) ) );
+ m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true);
+ connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
+ m_setmono_action->addTo( view );
+ m_setmono_action->setOn(reader->m_bMonoSpaced);
- a = new QAction( tr( "Peanut/PML" ), QString::null, 0, ag, NULL, true );
- a->setOn(reader->bpeanut);
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( peanut(bool) ) );
- ag->addTo(encoding);
-
-
-
- ag = new QActionGroup(this);
- ag->setExclusive(false);
- encoding = new QPopupMenu(this);
- format->insertItem( tr( "Layout" ), encoding );
-
- a = new QAction( tr( "Strip CR" ), QString::null, 0, ag, NULL, true );
- a->setOn(reader->bstripcr);
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) );
-
- a = new QAction( tr( "Dehyphen" ), QString::null, 0, ag, NULL, true );
- a->setOn(reader->bdehyphen);
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( dehyphen(bool) ) );
-// a->addTo( format );
-
- a = new QAction( tr( "Single Space" ), QString::null, 0, ag, NULL, true );
- a->setOn(reader->bonespace);
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( onespace(bool) ) );
-
- a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true );
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) );
- a->setOn(reader->bunindent);
-// a->addTo( format );
-
- a = new QAction( tr( "Re-paragraph" ), QString::null, 0, ag, NULL, true );
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( repara(bool) ) );
- a->setOn(reader->brepara);
-// a->addTo( format );
-
- a = new QAction( tr( "Double Space" ), QString::null, 0, ag, NULL, true );
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( dblspce(bool) ) );
- a->setOn(reader->bdblspce);
-// a->addTo( format );
-
- a = new QAction( tr( "Indent+" ), QString::null, 0, ag, NULL );
- connect( a, SIGNAL( activated() ), this, SLOT( indentplus() ) );
-// a->addTo( format );
-
- a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL );
- connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) );
-#ifdef REPALM
- a = new QAction( tr( "Repalm" ), QString::null, 0, ag, NULL, true );
- a->setOn(reader->brepalm);
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( repalm(bool) ) );
-#endif
- a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true );
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) );
- a->setOn(reader->bremap);
-
- a = new QAction( tr( "Embolden" ), QString::null, 0, ag, NULL, true );
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( embolden(bool) ) );
- a->setOn(reader->bmakebold);
+ // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true );
+ // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 );
- ag->addTo(encoding);
- // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true );
- // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
- format->insertSeparator();
- a = new QAction( tr( "Zoom In" ), QString::null, 0, this);
- connect( a, SIGNAL( activated() ), this, SLOT( zoomin() ) );
- a->addTo( format );
- a = new QAction( tr( "Zoom Out" ), QString::null, 0, this);
- connect( a, SIGNAL( activated() ), this, SLOT( zoomout() ) );
- a->addTo( format );
- // a->addTo( editBar );
- format->insertSeparator();
+ // a->addTo( filebar() );
+// view->insertSeparator();
+/*
a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true );
connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
a->setOn(reader->m_bMonoSpaced);
- a->addTo( format );
-
- a = new QAction( tr( "Set width" ), QString::null, 0, this, NULL);
+ a->addTo( view );
+*/
+/*
+ a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL);
connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) );
- a->addTo( format );
-
- encoding = new QPopupMenu(this);
-// format->insertSeparator();
- format->insertItem( tr( "Encoding" ), encoding );
-
- ag = new QActionGroup(this);
-
- m_EncodingAction[0] = new QAction( tr( "Ascii" ), QString::null, 0, ag, NULL, true );
-
- m_EncodingAction[1] = new QAction( tr( "UTF-8" ), QString::null, 0, ag, NULL, true );
-
- m_EncodingAction[2] = new QAction( tr( "UCS-2(BE)" ), QString::null, 0, ag, NULL, true );
-
- m_EncodingAction[3] = new QAction( tr( "USC-2(LE)" ), QString::null, 0, ag, NULL, true );
-
- m_EncodingAction[4] = new QAction( tr( "Palm" ), QString::null, 0, ag, NULL, true );
-
- m_EncodingAction[5] = new QAction( tr( "Windows(1252)" ), QString::null, 0, ag, NULL, true );
-
- ag->addTo(encoding);
-
- connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( encodingSelected(QAction*) ) );
-
- a = new QAction( tr( "Set Font" ), QString::null, 0, this);
- connect( a, SIGNAL( activated() ), this, SLOT( setfont() ) );
- format->insertSeparator();
- a->addTo( format );
-
- QPopupMenu *marks = new QPopupMenu( this );
+ a->addTo( view );
+*/
- a = new QAction( tr( "Mark" ), QString::null, 0, this, NULL);
- connect( a, SIGNAL( activated() ), this, SLOT( addbkmk() ) );
- a->addTo( marks );
+ m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL);
+ connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) );
+ m_mark_action->addTo( marks );
- a = new QAction( tr( "Annotate" ), QString::null, 0, this, NULL);
- connect( a, SIGNAL( activated() ), this, SLOT( addanno() ) );
- a->addTo( marks );
+ m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL);
+ connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) );
+ m_annotate_action->addTo( marks );
- a = new QAction( tr( "Goto" ), QString::null, 0, this, NULL, false );
- connect( a, SIGNAL( activated() ), this, SLOT( do_gotomark() ) );
- a->addTo( marks );
+ m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false );
+ connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) );
+ m_goto_action->addTo( marks );
- a = new QAction( tr( "Delete" ), QString::null, 0, this, NULL);
- connect( a, SIGNAL( activated() ), this, SLOT( do_delmark() ) );
- a->addTo( marks );
+ m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL);
+ connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) );
+ m_delete_action->addTo( marks );
- a = new QAction( tr( "Autogen" ), QString::null, 0, this, NULL, false );
- connect( a, SIGNAL( activated() ), this, SLOT( do_autogen() ) );
+ m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false );
+ connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) );
marks->insertSeparator();
- a->addTo( marks );
+ m_autogen_action->addTo( marks );
- a = new QAction( tr( "Clear" ), QString::null, 0, this, NULL);
- connect( a, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) );
- a->addTo( marks );
+ m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL);
+ connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) );
+ m_clear_action->addTo( marks );
- a = new QAction( tr( "Save" ), QString::null, 0, this, NULL );
- connect( a, SIGNAL( activated() ), this, SLOT( savebkmks() ) );
- a->addTo( marks );
+ m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL );
+ connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) );
+ m_save_action->addTo( marks );
- a = new QAction( tr( "Tidy" ), QString::null, 0, this, NULL);
- connect( a, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) );
+ m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL);
+ connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) );
marks->insertSeparator();
- a->addTo( marks );
+ m_tidy_action->addTo( marks );
- a = new QAction( tr( "Start Block" ), QString::null, 0, this, NULL);
- connect( a, SIGNAL( activated() ), this, SLOT( editMark() ) );
+ m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL);
+ connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) );
marks->insertSeparator();
- a->addTo( marks );
+ m_startBlock_action->addTo( marks );
+
+ m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL);
+ connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) );
+ m_endBlock_action->addTo( marks );
- a = new QAction( tr( "Copy Block" ), QString::null, 0, this, NULL);
- connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
- a->addTo( marks );
+ m_bkmkAvail = NULL;
- mb->insertItem( tr( "File" ), file );
- // mb->insertItem( tr( "Edit" ), edit );
- mb->insertItem( tr( "Format" ), format );
- mb->insertItem( tr( "Marks" ), marks );
+ setToolBarsMovable(m_tbmove);
+ addtoolbars(&config);
+
+ pbar = new QProgressBar(this);
+ pbar->hide();
searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE );
searchBar->setHorizontalStretchable( TRUE );
@@ -614,20 +724,21 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
// QFont f("unifont", 16 /*, QFont::Bold*/);
// searchEdit->setFont( f );
searchBar->setStretchableWidget( searchEdit );
+
#ifdef __ISEARCH
connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
this, SLOT( search( const QString& ) ) );
#else
connect( searchEdit, SIGNAL( returnPressed( ) ),
this, SLOT( search( ) ) );
#endif
- a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
+ QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
a->addTo( searchBar );
- a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
+ a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
a->addTo( searchBar );
searchBar->hide();
@@ -644,13 +755,13 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
connect( regEdit, SIGNAL( returnPressed( ) ),
this, SLOT( do_regaction() ) );
- a = new QAction( tr( "Do Reg" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
+ a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) );
a->addTo( regBar );
- a = new QAction( tr( "Close Edit" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
+ a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) );
a->addTo( regBar );
regBar->hide();
@@ -658,49 +769,51 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE );
m_fontBar->setHorizontalStretchable( TRUE );
- qDebug("Font selector");
+// qDebug("Font selector");
m_fontSelector = new QComboBox(false, m_fontBar);
m_fontBar->setStretchableWidget( m_fontSelector );
{
+#ifndef USEQPE
+ QFontDatabase f;
+#else
FontDatabase f;
+#endif
QStringList flist = f.families();
- m_fontSelector->insertStringList(flist);
-
bool realfont = false;
for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++)
{
if (reader->m_fontname == *nm)
{
realfont = true;
}
- if (*nm == "courier") reader->m_fontControl.hasCourier(true);
+ if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm);
}
if (!realfont) reader->m_fontname = flist[0];
} // delete the FontDatabase!!!
-
connect( m_fontSelector, SIGNAL( activated(const QString& ) ),
this, SLOT( do_setfont(const QString&) ) );
+ connect( m_fontSelector, SIGNAL( activated(int ) ),
+ this, SLOT( do_setencoding(int) ) );
m_fontBar->hide();
m_fontVisible = false;
-
+#ifdef USEMSGS
connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ),
this, SLOT( msgHandler(const QCString&, const QByteArray&) ) );
-
- qDebug("Initing");
+#endif
+// qDebug("Initing");
reader->init();
- qDebug("Inited");
- m_EncodingAction[reader->m_encd]->setOn(true);
- m_buttonAction[m_spaceTarget]->setOn(true);
- qDebug("fonting");
+// qDebug("Inited");
+// m_buttonAction[m_spaceTarget]->setOn(true);
+// qDebug("fonting");
do_setfont(reader->m_fontname);
if (!reader->m_lastfile.isEmpty())
{
- qDebug("doclnk");
+// qDebug("doclnk");
// doc = new DocLnk(reader->m_lastfile);
- qDebug("doclnk done");
+// qDebug("doclnk done");
if (pOpenlist != NULL)
{
/*
@@ -718,58 +831,333 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile)
{
break;
}
- qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name()));
+// qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name()));
p = NULL;
}
if (p != NULL)
{
- qDebug("openfrombkmk");
- openfrombkmk(p);
+// qDebug("openfrombkmk");
+ if (!openfrombkmk(p))
+ showEditTools();
}
else
{
- qDebug("openfile");
+// qDebug("openfile");
openFile( reader->m_lastfile );
}
}
else
{
- qDebug("Openfile 2");
- if (!reader->m_lastfile.isNull())
+// qDebug("Openfile 2");
+ if (!reader->m_lastfile.isEmpty())
openFile( reader->m_lastfile );
}
}
- qApp->processEvents();
+ else
+ {
+ showEditTools();
+ }
+// qApp->processEvents();
reader->bDoUpdates = true;
reader->update();
- qDebug("finished update");
+ config.setGroup("Version");
+ int major = config.readNumEntry("Major", 0);
+ int bkmktype = config.readNumEntry("BkmkType", 0);
+ char minor = config.readNumEntry("Minor", 0);
+ if (CheckVersion(major, bkmktype, minor))
+ {
+ config.writeEntry("Major", major);
+ config.writeEntry("BkmkType", bkmktype);
+ config.writeEntry("Minor", (int)minor);
+ }
+// qDebug("finished update");
+}
+
+void QTReaderApp::addtoolbars(Config* config)
+{
+ config->setGroup("Toolbar");
+
+ if (fileBar != NULL)
+ {
+ if (fileBar != menubar)
+ {
+ fileBar->clear();
+ }
+ else
+ {
+ m_preferences_action->removeFrom( filebar() );
+ m_open_action->removeFrom( filebar() );
+ m_close_action->removeFrom( filebar() );
+ m_info_action->removeFrom( filebar() );
+ m_touch_action->removeFrom( filebar() );
+ m_find_action->removeFrom( filebar() );
+ }
+ }
+
+ m_preferences_action->addTo( filebar() );
+ addfilebar(config, "Open", m_open_action);
+ addfilebar(config, "Close", m_close_action);
+ addfilebar(config, "Info", m_info_action);
+ addfilebar(config, "Two/One Touch", m_touch_action);
+ addfilebar(config, "Find", m_find_action);
+
+ if (navBar != NULL)
+ {
+ if ((navBar == fileBar) && (fileBar == menubar))
+ {
+ m_scrollButton->removeFrom( navbar() );
+ m_start_action->removeFrom( navbar() );
+ m_end_action->removeFrom( navbar() );
+ m_jump_action->removeFrom( navbar() );
+ m_pageline_action->removeFrom( navbar() );
+ m_pageup_action->removeFrom( navbar() );
+ m_pagedn_action->removeFrom( navbar() );
+ m_back_action->removeFrom( navbar() );
+ m_home_action->removeFrom( navbar() );
+ m_forward_action->removeFrom( navbar() );
+ }
+ else if (navBar != fileBar)
+ {
+ navBar->clear();
+ }
+ }
+
+ addnavbar(config, "Scroll", m_scrollButton);
+ addnavbar(config, "Goto Start", m_start_action);
+ addnavbar(config, "Goto End", m_end_action);
+
+ addnavbar(config, "Jump", m_jump_action);
+ addnavbar(config, "Page/Line Scroll", m_pageline_action);
+
+ addnavbar(config, "Page Up", m_pageup_action);
+ addnavbar(config, "Page Down", m_pagedn_action);
+
+ addnavbar(config, "Back", m_back_action);
+ addnavbar(config, "Home", m_home_action);
+ addnavbar(config, "Forward", m_forward_action);
+
+ if (viewBar != NULL)
+ {
+ if ((viewBar == fileBar) && (fileBar == menubar))
+ {
+ m_actFullscreen->removeFrom( filebar() );
+ m_zoomin_action->removeFrom( viewbar() );
+ m_zoomout_action->removeFrom( viewbar() );
+ m_setfont_action->removeFrom( viewbar() );
+ m_setenc_action->removeFrom( viewbar() );
+ m_setmono_action->removeFrom( viewbar() );
+ }
+ else if (viewBar != fileBar)
+ {
+ viewBar->clear();
+ }
+ }
+
+ addviewbar(config, "Fullscreen", m_actFullscreen);
+ addviewbar(config, "Zoom In", m_zoomin_action);
+ addviewbar(config, "Zoom Out", m_zoomout_action);
+ addviewbar(config, "Set Font", m_setfont_action);
+ addviewbar(config, "Encoding Select", m_setenc_action);
+ addviewbar(config, "Ideogram Mode", m_setmono_action);
+
+ if (markBar != NULL)
+ {
+ if ((markBar == fileBar) && (fileBar == menubar))
+ {
+ m_mark_action->removeFrom( markbar() );
+ m_annotate_action->removeFrom( markbar());
+ m_goto_action->removeFrom( markbar() );
+ m_delete_action->removeFrom( markbar() );
+ m_autogen_action->removeFrom( markbar() );
+ m_clear_action->removeFrom( markbar() );
+ m_save_action->removeFrom( markbar() );
+ m_tidy_action->removeFrom( markbar() );
+ m_startBlock_action->removeFrom( markbar() );
+ m_endBlock_action->removeFrom( markbar() );
+ }
+ else if (markBar != fileBar)
+ {
+ markBar->clear();
+ }
+ }
+ addmarkbar(config, "Mark", m_mark_action);
+ addmarkbar(config, "Annotate", m_annotate_action);
+ addmarkbar(config, "Goto", m_goto_action);
+ addmarkbar(config, "Delete", m_delete_action);
+ addmarkbar(config, "Autogen", m_autogen_action);
+ addmarkbar(config, "Clear", m_clear_action);
+ addmarkbar(config, "Save", m_save_action);
+ addmarkbar(config, "Tidy", m_tidy_action);
+ addmarkbar(config, "Start Block", m_startBlock_action);
+ addmarkbar(config, "Copy Block", m_endBlock_action);
+ if (checkbar(config, "Annotation indicator"))
+ {
+ if (m_bkmkAvail == NULL)
+ {
+ m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 );
+ connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) );
+
+ m_bkmkAvail->setEnabled(false);
+ }
+ QLabel *spacer = new QLabel(markBar, "");
+ markbar()->setStretchableWidget(spacer);
+ m_bkmkAvail->removeFrom( markbar() );
+ m_bkmkAvail->addTo( markbar() );
+ }
+ else
+ {
+ if (m_bkmkAvail != NULL)
+ {
+ m_bkmkAvail->removeFrom( markbar() );
+ delete m_bkmkAvail;
+ m_bkmkAvail = NULL;
+ }
+ }
+}
+
+bool QTReaderApp::checkbar(Config* _config, const QString& key)
+{
+ return _config->readBoolEntry(key, false);
+}
+
+
+QToolBar* QTReaderApp::filebar()
+{
+ if (fileBar == NULL)
+ {
+ switch (m_tbpol)
+ {
+ case cesSingle:
+// qDebug("Setting filebar to menubar");
+ fileBar = menubar;
+ break;
+ default:
+ qDebug("Incorrect toolbar policy set");
+ case cesMenuTool:
+ case cesMultiple:
+// qDebug("Creating new file bar");
+ fileBar = new QToolBar("File", this, m_tbposition);
+ break;
+ }
+// fileBar->setHorizontalStretchable( true );
+ }
+ return fileBar;
+}
+QToolBar* QTReaderApp::viewbar()
+{
+ if (viewBar == NULL)
+ {
+ switch (m_tbpol)
+ {
+ case cesMultiple:
+ viewBar = new QToolBar("View", this, m_tbposition);
+ break;
+ default:
+ qDebug("Incorrect toolbar policy set");
+ case cesSingle:
+ case cesMenuTool:
+ viewBar = fileBar;
+ break;
+ }
+ }
+ return viewBar;
+}
+QToolBar* QTReaderApp::navbar()
+{
+ if (navBar == NULL)
+ {
+ switch (m_tbpol)
+ {
+ case cesMultiple:
+// qDebug("Creating new nav bar");
+ navBar = new QToolBar("Navigation", this, m_tbposition);
+ break;
+ default:
+ qDebug("Incorrect toolbar policy set");
+ case cesSingle:
+ case cesMenuTool:
+ navBar = fileBar;
+// qDebug("Setting navbar to filebar");
+ break;
+ }
+ }
+ return navBar;
+}
+QToolBar* QTReaderApp::markbar()
+{
+ if (markBar == NULL)
+ {
+ switch (m_tbpol)
+ {
+ case cesMultiple:
+ markBar = new QToolBar("Marks", this, m_tbposition);
+ break;
+ default:
+ qDebug("Incorrect toolbar policy set");
+ case cesSingle:
+ case cesMenuTool:
+ markBar = fileBar;
+ break;
+ }
+ }
+ return markBar;
+}
+
+void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a)
+{
+ if (_config->readBoolEntry(key, false)) a->addTo( filebar() );
+}
+void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a)
+{
+ if (_config->readBoolEntry(key, false)) a->addTo( navbar() );
+}
+void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a)
+{
+ if (_config->readBoolEntry(key, false)) a->addTo( markbar() );
+}
+void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a)
+{
+ if (_config->readBoolEntry(key, false)) a->addTo( viewbar() );
}
void QTReaderApp::suspend() { reader->suspend(); }
+#ifdef USEMSGS
void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
{
QString msg = QString::fromUtf8(_msg);
-// qDebug("Received:%s", (const char*)msg);
+//// qDebug("Received:%s", (const char*)msg);
QDataStream stream( _data, IO_ReadOnly );
if ( msg == "info(QString)" )
{
QString info;
stream >> info;
QMessageBox::information(this, PROGNAME, info);
}
+ else if ( msg == "Update(int)" )
+ {
+ int info;
+ stream >> info;
+ if (info)
+ {
+ reader->bDoUpdates = true;
+ reader->refresh();
+ }
+ else
+ {
+ reader->bDoUpdates = false;
+ }
+ }
else if ( msg == "warn(QString)" )
{
QString info;
stream >> info;
QMessageBox::warning(this, PROGNAME, info);
}
-
-
else if ( msg == "exit()" )
{
m_dontSave = true;
close();
@@ -793,8 +1181,20 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
else if ( msg == "showText()" )
{
showEditTools();
}
+ else if ( msg == "home()" )
+ {
+ reader->goHome();
+ }
+ else if ( msg == "back()" )
+ {
+ reader->goBack();
+ }
+ else if ( msg == "forward()" )
+ {
+ reader->goForward();
+ }
else if ( msg == "File/Open(QString)" )
{
QString info;
stream >> info;
@@ -803,47 +1203,68 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
else if ( msg == "File/Info()" )
{
showinfo();
}
- else if ( msg == "File/Start Block()" )
- {
- editMark();
- }
- else if ( msg == "File/Copy Block()" )
+ else if ( msg == "File/Action(QString)" )
{
- editCopy();
+ QString info;
+ stream >> info;
+ m_spaceTarget = ActNameToInt(info);
}
- else if ( msg == "File/Scroll(int)" )
+ else if ( msg == "Navigation/Scroll(int)" )
{
int info;
stream >> info;
autoScroll(info);
}
- else if ( msg == "File/Jump(int)" )
+
+ else if ( msg == "Navigation/GotoStart()" )
+ {
+ gotoStart();
+ }
+ else if ( msg == "Navigation/GotoEnd()" )
+ {
+ gotoEnd();
+ }
+ else if ( msg == "Navigation/Jump(int)" )
{
int info;
stream >> info;
reader->locate(info);
}
- else if ( msg == "File/Page/Line Scroll(int)" )
+ else if ( msg == "Navigation/Page/LineScroll(int)" )
{
int info;
stream >> info;
pagemode(info);
}
- else if ( msg == "File/Set Overlap(int)" )
+ else if ( msg == "Navigation/SetOverlap(int)" )
{
int info;
stream >> info;
reader->m_overlap = info;
}
- else if ( msg == "File/Set Dictionary(QString)" )
+ else if ( msg == "Navigation/SetMargin(int)" )
+ {
+ int info;
+ stream >> info;
+ do_margin(info);
+ }
+ else if ( msg == "File/SetDictionary(QString)" )
{
QString info;
stream >> info;
do_settarget(info);
}
- else if ( msg == "File/Two/One Touch(int)" )
+#ifdef _SCROLLPIPE
+ else if ( msg == "File/SetScrollTarget(QString)" )
+ {
+ QString info;
+ stream >> info;
+ reader->m_pipetarget = info;
+ }
+#endif
+ else if ( msg == "File/Two/OneTouch(int)" )
{
int info;
stream >> info;
setTwoTouch(info);
@@ -873,71 +1294,99 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
QRegExp arg(info);
size_t pos = reader->pagelocate();
size_t start = pos;
CDrawBuffer test(&(reader->m_fontControl));
- reader->buffdoc.getline(&test,reader->width());
+ reader->getline(&test);
while (arg.match(toQString(test.data())) == -1)
{
pos = reader->locate();
- if (!reader->buffdoc.getline(&test,reader->width()))
+ if (!reader->getline(&test))
{
QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info);
pos = start;
break;
}
}
reader->locate(pos);
}
- else if ( msg == "Layout/Strip CR(int)" )
+ else if ( msg == "File/Fullscreen(int)" )
{
int info;
stream >> info;
- stripcr(info);
+ setfullscreen(info);
}
- else if ( msg == "Layout/Single Space" )
+ else if ( msg == "File/Continuous(int)" )
{
int info;
stream >> info;
- onespace(info);
+ setcontinuous(info);
}
-#ifdef REPALM
- else if ( msg == "Layout/Repalm(int)" )
+ else if ( msg == "Markup(QString)" )
+ {
+ QString info;
+ stream >> info;
+ if (info == "Auto")
+ {
+ autofmt(true);
+ }
+ if (info == "None")
+ {
+ autofmt(false);
+ textfmt(false);
+ striphtml(false);
+ peanut(false);
+ }
+ if (info == "Text")
+ {
+ textfmt(true);
+ }
+ if (info == "HTML")
+ {
+ striphtml(true);
+ }
+ if (info == "Peanut/PML")
+ {
+ peanut(true);
+ }
+ }
+ else if ( msg == "Layout/StripCR(int)" )
{
int info;
stream >> info;
- repalm(info);
+ stripcr(info);
}
-#endif
- else if ( msg == "Markup/Auto(int)" )
+ else if ( msg == "Layout/Dehyphen(int)" )
{
int info;
stream >> info;
- autofmt(info);
+ dehyphen(info);
}
- else if ( msg == "Markup/Text(int)" )
+ else if ( msg == "Layout/Depluck(int)" )
{
int info;
stream >> info;
- textfmt(info);
+ depluck(info);
}
- else if ( msg == "Markup/HTML(int)" )
+ else if ( msg == "Layout/Dejpluck(int)" )
{
int info;
stream >> info;
- striphtml(info);
+ dejpluck(info);
}
- else if ( msg == "Markup/Peanut(int)" )
+ else if ( msg == "Layout/SingleSpace(int)" )
{
int info;
stream >> info;
- peanut(info);
+ onespace(info);
}
- else if ( msg == "Layout/Dehyphen(int)" )
+#ifdef REPALM
+ else if ( msg == "Layout/Repalm(int)" )
{
int info;
stream >> info;
- dehyphen(info);
+ repalm(info);
}
+#endif
else if ( msg == "Layout/Unindent(int)" )
{
int info;
stream >> info;
@@ -948,9 +1397,9 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
int info;
stream >> info;
repara(info);
}
- else if ( msg == "Layout/Double Space(int)" )
+ else if ( msg == "Layout/DoubleSpace(int)" )
{
int info;
stream >> info;
dblspce(info);
@@ -979,23 +1428,17 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
int info;
stream >> info;
monospace(info);
}
- else if ( msg == "Format/Set width(int)" )
+ else if ( msg == "Format/SetWidth(int)" )
{
int info;
stream >> info;
reader->m_charpc = info;
reader->setfont();
reader->refresh();
}
- else if ( msg == "Format/Encoding(QString)" )
- {
- QString info;
- stream >> info;
- reader->setencoding(EncNameToInt(info));
- }
- else if ( msg == "Format/Set Font(QString,int)" )
+ else if ( msg == "Format/SetFont(QString,int)" )
{
QString fontname;
int size;
stream >> fontname;
@@ -1007,10 +1450,18 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
QString info;
stream >> info;
do_autogen(info);
}
+ else if ( msg == "File/StartBlock()" )
+ {
+ editMark();
+ }
+ else if ( msg == "File/CopyBlock()" )
+ {
+ editCopy();
+ }
}
-
+#endif
ActionTypes QTReaderApp::ActNameToInt(const QString& _enc)
{
for (int i = 0; i < MAX_ACTIONS; i++)
{
@@ -1023,43 +1474,16 @@ void QTReaderApp::setfullscreen(bool sfs)
{
reader->bDoUpdates = false;
m_fullscreen = sfs;
showEditTools();
- qApp->processEvents();
+// qApp->processEvents();
reader->bDoUpdates = true;
reader->update();
}
-void QTReaderApp::setcontinuous(bool sfs)
-{
- reader->setContinuous(sfs);
- reader->refresh();
-}
-
-int QTReaderApp::EncNameToInt(const QString& _enc)
-{
- for (int i = 0; i < MAX_ENCODING; i++)
- {
- if (m_EncodingAction[i]->text() == _enc) return i;
- }
- return 0;
-/*
- if (_enc == "Ascii") return 0;
- if (_enc == "UTF-8") return 1;
- if (_enc == "UCS-2(BE)") return 2;
- if (_enc == "USC-2(LE)") return 3;
-*/
-}
-
-void QTReaderApp::encodingSelected(QAction* _a)
-{
-// qDebug("es:%x : %s", _a, (const char *)(_a->text()));
- reader->setencoding(EncNameToInt(_a->text()));
-}
-
void QTReaderApp::buttonActionSelected(QAction* _a)
{
-// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text()));
+//// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text()));
m_spaceTarget = ActNameToInt(_a->text());
}
QTReaderApp::~QTReaderApp()
@@ -1090,39 +1514,58 @@ void QTReaderApp::clearBkmkList()
}
void QTReaderApp::fileClose()
{
- if (pOpenlist != NULL)
+ CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this);
+ if (cd->exec())
{
- int ind = 0;
- Bkmk* p = (*pOpenlist)[ind];
- while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
- {
- p = (*pOpenlist)[++ind];
- }
- if (p != NULL) pOpenlist->erase(ind);
- switch (QMessageBox::information ( this , PROGNAME, "What do you want to delete?", "Nothing", "Marks", "Marks\nFile", 1, 0 ))
+ if (pOpenlist != NULL)
{
- case 0:
- default:
- break;
- case 2:
+ int ind = 0;
+ Bkmk* p = (*pOpenlist)[ind];
+ while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
+ {
+ p = (*pOpenlist)[++ind];
+ }
+ if (p != NULL) pOpenlist->erase(ind);
+ if (cd->delFile())
+ {
unlink((const char*)reader->m_lastfile);
- case 1:
- unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string));
+ }
+ if (cd->delMarks())
+ {
+#ifndef USEQPE
+ QDir d = QDir::home(); // "/"
+ d.cd(APPDIR);
+ d.remove(reader->m_string);
+#else /* USEQPE */
+ unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string));
+#endif /* USEQPE */
+ }
+ if (cd->delConfig())
+ {
+#ifndef USEQPE
+ QDir d = QDir::home(); // "/"
+ d.cd(APPDIR "/configs");
+ d.remove(reader->m_string);
+#else /* USEQPE */
+ unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string));
+#endif /* USEQPE */
+ }
}
- }
- fileOpen2();
+ fileOpen2();
+ }
+ delete cd;
}
void QTReaderApp::updatefileinfo()
{
- if (reader->m_string.isNull()) return;
- if (reader->m_lastfile.isNull()) return;
+ if (reader->m_string.isEmpty()) return;
+ if (reader->m_lastfile.isEmpty()) return;
tchar* nm = fromQString(reader->m_string);
tchar* fl = fromQString(reader->m_lastfile);
- qDebug("Lastfile:%x", fl);
+// qDebug("Lastfile:%x", fl);
bool notadded = true;
if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>;
else
{
@@ -1134,18 +1577,18 @@ void QTReaderApp::updatefileinfo()
unsigned short dlen;
unsigned char* data;
CFiledata fd(iter->anno());
reader->setSaveData(data, dlen, fd.content(), fd.length());
- qDebug("Filedata(1):%u, %u", fd.length(), dlen);
+// qDebug("Filedata(1):%u, %u", fd.length(), dlen);
// getstate(data, dlen);
iter->setAnno(data, dlen);
notadded = false;
delete [] data;
break;
}
}
}
- qDebug("Added?:%x", notadded);
+// qDebug("Added?:%x", notadded);
if (notadded)
{
struct stat fnstat;
stat((const char *)reader->m_lastfile, &fnstat);
@@ -1153,9 +1596,9 @@ void QTReaderApp::updatefileinfo()
unsigned short dlen;
unsigned char* data;
reader->setSaveData(data, dlen, fd.content(), fd.length());
pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate()));
- qDebug("Filedata(2):%u, %u", fd.length(), dlen);
+// qDebug("Filedata(2):%u, %u", fd.length(), dlen);
delete [] data;
}
delete [] nm;
delete [] fl;
@@ -1164,13 +1607,13 @@ void QTReaderApp::updatefileinfo()
void QTReaderApp::fileOpen()
{
/*
menu->hide();
- editBar->hide();
+ fileBar->hide();
if (regVisible) regBar->hide();
if (searchVisible) searchBar->hide();
*/
- qDebug("fileOpen");
+// qDebug("fileOpen");
// if (!reader->m_lastfile.isEmpty())
updatefileinfo();
fileOpen2();
}
@@ -1192,49 +1635,289 @@ void QTReaderApp::fileOpen2()
/*
editorStack->raiseWidget( fileSelector );
fileSelector->reread();
*/
+ bool usebrowser = true;
if (pOpenlist != NULL)
{
- m_nRegAction = cOpenFile;
- listbkmk(pOpenlist, "Browse");
+ m_nBkmkAction = cOpenFile;
+ if (listbkmk(pOpenlist, "Browse")) usebrowser = false;
}
- else
+ if (usebrowser)
{
QString fn = usefilebrowser();
+// qApp->processEvents();
if (!fn.isEmpty() && QFileInfo(fn).isFile())
{
openFile(fn);
}
reader->setFocus();
}
+// reader->refresh();
+// qDebug("HEIGHT:%d", reader->m_lastheight);
}
QString QTReaderApp::usefilebrowser()
{
- fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE,
+#ifndef USEQPE
+ QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) );
+ return s;
+#else
+ fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog,
0,
// WStyle_Customize | WStyle_NoBorderEx,
"*", QFileInfo(reader->m_lastfile).dirPath(true));
QString fn;
if (fb->exec())
{
- fn = fb->fileList[0];
+ fn = fb->getCurrentFile();
}
- qDebug("Selected %s", (const char*)fn);
+// qDebug("Selected %s", (const char*)fn);
delete fb;
+ showEditTools();
return fn;
+#endif
}
-void QTReaderApp::showgraphic(QPixmap& pm)
+void QTReaderApp::showgraphic(QImage& pm)
{
- m_graphicwin->setPixmap(pm);
+ QPixmap pc;
+ pc.convertFromImage(pm);
+ m_graphicwin->setPixmap(pc);
editorStack->raiseWidget( m_graphicwin );
m_graphicwin->setFocus();
}
+
+void QTReaderApp::showprefs()
+{
+ CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this);
+
+ prefwin->twotouch(m_twoTouch);
+ prefwin->propfontchange(m_propogatefontchange);
+ prefwin->StripCR(reader->bstripcr);
+ prefwin->Dehyphen(reader->bdehyphen);
+ prefwin->SingleSpace(reader->bonespace);
+ prefwin->Unindent(reader->bunindent);
+ prefwin->Reparagraph(reader->brepara);
+ prefwin->DoubleSpace(reader->bdblspce);
+ prefwin->Remap(reader->bremap);
+ prefwin->Embolden(reader->bmakebold);
+ prefwin->FullJustify(reader->bfulljust);
+ prefwin->ParaLead(reader->getextraspace());
+ prefwin->LineLead(reader->getlead());
+ prefwin->Margin(reader->m_border);
+ prefwin->Indent(reader->bindenter);
+ if (reader->bautofmt)
+ {
+ prefwin->Markup(0);
+ }
+ else if (reader->btextfmt)
+ {
+ prefwin->Markup(2);
+ }
+ else if (reader->bstriphtml)
+ {
+ prefwin->Markup(3);
+ }
+ else if (reader->bpeanut)
+ {
+ prefwin->Markup(4);
+ }
+ else
+ {
+ prefwin->Markup(1);
+ }
+ prefwin->Depluck(reader->bdepluck);
+ prefwin->Dejpluck(reader->bdejpluck);
+ prefwin->Continuous(reader->m_continuousDocument);
+
+ prefwin->dictApplication(m_targetapp);
+ prefwin->dictMessage(m_targetmsg);
+
+ prefwin->spaceAction(m_spaceTarget);
+ prefwin->escapeAction(m_escapeTarget);
+ prefwin->returnAction(m_returnTarget);
+ prefwin->leftAction(m_leftTarget);
+ prefwin->rightAction(m_rightTarget);
+ prefwin->upAction(m_upTarget);
+ prefwin->downAction(m_downTarget);
+
+ prefwin->leftScroll(m_leftScroll);
+ prefwin->rightScroll(m_rightScroll);
+ prefwin->upScroll(m_upScroll);
+ prefwin->downScroll(m_downScroll);
+
+ prefwin->miscannotation(m_doAnnotation);
+ prefwin->miscdictionary(m_doDictionary);
+ prefwin->miscclipboard(m_doClipboard);
+
+ prefwin->SwapMouse(reader->m_swapmouse);
+
+ prefwin->Font(reader->m_fontname);
+
+ prefwin->gfxsize(reader->getBaseSize());
+
+ prefwin->pageoverlap(reader->m_overlap);
+
+ prefwin->ideogram(reader->m_bMonoSpaced);
+
+ prefwin->encoding(reader->m_encd);
+
+ prefwin->ideogramwidth(reader->m_charpc);
+
+ if (prefwin->exec())
+ {
+ m_twoTouch = prefwin->twotouch();
+ reader->setTwoTouch(m_twoTouch);
+ m_touch_action->setOn(m_twoTouch);
+
+ reader->bstripcr = prefwin->StripCR();
+ reader->bdehyphen = prefwin->Dehyphen();
+ reader->bonespace = prefwin->SingleSpace();
+ reader->bunindent = prefwin->Unindent();
+ reader->brepara = prefwin->Reparagraph();
+ reader->bdblspce = prefwin->DoubleSpace();
+ reader->bremap = prefwin->Remap();
+ reader->bmakebold = prefwin->Embolden();
+ reader->bfulljust = prefwin->FullJustify();
+ reader->setextraspace(prefwin->ParaLead());
+ reader->setlead(prefwin->LineLead());
+ reader->m_border = prefwin->Margin();
+ reader->bindenter = prefwin->Indent();
+ reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false;
+ switch (prefwin->Markup())
+ {
+ case 0:
+ reader->bautofmt = true;
+ break;
+ case 1:
+ break;
+ case 2:
+ reader->btextfmt = true;
+ break;
+ case 3:
+ reader->bstriphtml = true;
+ break;
+ case 4:
+ reader->bpeanut = true;
+ break;
+ default:
+ qDebug("Format out of range");
+ }
+ reader->bdepluck = prefwin->Depluck();
+ reader->bdejpluck = prefwin->Dejpluck();
+ reader->setContinuous(prefwin->Continuous());
+
+ m_spaceTarget = (ActionTypes)prefwin->spaceAction();
+ m_escapeTarget = (ActionTypes)prefwin->escapeAction();
+ m_returnTarget = (ActionTypes)prefwin->returnAction();
+ m_leftTarget = (ActionTypes)prefwin->leftAction();
+ m_rightTarget = (ActionTypes)prefwin->rightAction();
+ m_upTarget = (ActionTypes)prefwin->upAction();
+ m_downTarget = (ActionTypes)prefwin->downAction();
+ m_leftScroll = prefwin->leftScroll();
+ m_rightScroll = prefwin->rightScroll();
+ m_upScroll = prefwin->upScroll();
+ m_downScroll = prefwin->downScroll();
+
+ m_targetapp = prefwin->dictApplication();
+ m_targetmsg = prefwin->dictMessage();
+
+ m_doAnnotation = prefwin->miscannotation();
+ m_doDictionary = prefwin->miscdictionary();
+ m_doClipboard = prefwin->miscclipboard();
+ reader->m_swapmouse = prefwin->SwapMouse();
+ reader->setBaseSize(prefwin->gfxsize());
+ reader->m_overlap = prefwin->pageoverlap();
+ reader->m_bMonoSpaced = prefwin->ideogram();
+ m_setmono_action->setOn(reader->m_bMonoSpaced);
+ reader->m_encd = prefwin->encoding();
+ reader->m_charpc = prefwin->ideogramwidth();
+
+ if (
+ reader->m_fontname != prefwin->Font()
+ ||
+ m_propogatefontchange != prefwin->propfontchange())
+ {
+ m_propogatefontchange = prefwin->propfontchange();
+ setfontHelper(prefwin->Font());
+ }
+ delete prefwin;
+ reader->setfilter(reader->getfilter());
+ reader->refresh();
+
+ }
+ else
+ {
+ delete prefwin;
+ }
+}
+
+void QTReaderApp::showtoolbarprefs()
+{
+#ifdef USEQPE
+ CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this);
+#else
+ QFileInfo fi;
+ QDir d = QDir::home(); // "/"
+ if ( !d.cd(APPDIR) )
+ { // "/tmp"
+ qWarning( "Cannot find the \"~/%s\" directory", APPDIR );
+ d = QDir::home();
+ d.mkdir(APPDIR);
+ d.cd(APPDIR);
+ }
+ fi.setFile(d, INIFILE);
+ CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this);
+#endif
+ prefwin->tbpolicy(m_tbpolsave);
+ prefwin->tbposition(m_tbposition-2);
+ prefwin->tbmovable(m_tbmovesave);
+ prefwin->floating(m_bFloatingDialog);
+ if (prefwin->exec())
+ {
+ m_bFloatingDialog = prefwin->floating();
+ if (
+ m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy()
+ ||
+ m_tbposition != (ToolBarDock)(prefwin->tbposition()+2)
+ ||
+ m_tbmovesave != prefwin->tbmovable()
+ )
+ {
+ QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started");
+ }
+ m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy();
+ m_tbposition = (ToolBarDock)(prefwin->tbposition()+2);
+ m_tbmovesave = prefwin->tbmovable();
+ bool isChanged = prefwin->isChanged();
+ delete prefwin;
+#ifdef USEQPE
+ Config config( APPDIR );
+#else
+ QFileInfo fi;
+ QDir d = QDir::home(); // "/"
+ if ( !d.cd(APPDIR) )
+ { // "/tmp"
+ qWarning( "Cannot find the \"~/%s\" directory", APPDIR );
+ d = QDir::home();
+ d.mkdir(APPDIR);
+ d.cd(APPDIR);
+ }
+ fi.setFile(d, INIFILE);
+ Config config( fi.absFilePath() );
+#endif
+ if (isChanged) addtoolbars(&config);
+ }
+ else
+ {
+ delete prefwin;
+ }
+}
+
void QTReaderApp::showinfo()
{
unsigned long fs, ts, pl;
if (reader->empty())
@@ -1351,9 +2034,11 @@ void QTReaderApp::addanno()
m_annoWin->setAnno("");
m_annoWin->setPosn(reader->pagelocate());
m_annoIsEditing = true;
editorStack->raiseWidget( m_annoWin );
+#ifdef USEQPE
Global::showInputMethod();
+#endif
m_annoWin->setFocus();
}
}
@@ -1387,112 +2072,57 @@ void QTReaderApp::editCopy()
QString text;
int ch;
unsigned long currentpos = reader->pagelocate();
unsigned long endpos = reader->locate();
+ if (m_savedpos == 0xffffffff)
+ {
+ m_savedpos = currentpos;
+ }
reader->jumpto(m_savedpos);
while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF)
{
text += ch;
}
cb->setText(text);
reader->locate(currentpos);
+ m_savedpos = 0xffffffff;
}
-void QTReaderApp::pageup()
+void QTReaderApp::gotoStart()
{
- reader->NavUp();
+ reader->locate(reader->buffdoc.startSection());
}
-void QTReaderApp::pagedn()
+void QTReaderApp::gotoEnd()
{
- reader->NavDown();
+ reader->dopageup(reader->buffdoc.endSection());
}
-void QTReaderApp::stripcr(bool _b)
-{
- reader->setstripcr(_b);
-}
-void QTReaderApp::onespace(bool _b)
-{
- reader->setonespace(_b);
-}
-#ifdef REPALM
-void QTReaderApp::repalm(bool _b)
-{
- reader->setrepalm(_b);
-}
-#endif
-void QTReaderApp::remap(bool _b)
-{
- reader->setremap(_b);
-}
-void QTReaderApp::peanut(bool _b)
-{
- reader->setpeanut(_b);
-}
-void QTReaderApp::embolden(bool _b)
-{
- reader->setmakebold(_b);
-}
-void QTReaderApp::autofmt(bool _b)
-{
- reader->setautofmt(_b);
-}
-void QTReaderApp::textfmt(bool _b)
-{
- reader->settextfmt(_b);
-}
-void QTReaderApp::striphtml(bool _b)
-{
- reader->setstriphtml(_b);
-}
-void QTReaderApp::dehyphen(bool _b)
-{
- reader->setdehyphen(_b);
-}
-void QTReaderApp::unindent(bool _b)
-{
- reader->setunindent(_b);
-}
-void QTReaderApp::repara(bool _b)
+void QTReaderApp::pageup()
{
- reader->setrepara(_b);
+ reader->NavUp();
}
-void QTReaderApp::dblspce(bool _b)
+
+void QTReaderApp::pagedn()
{
- reader->setdblspce(_b);
+ reader->NavDown();
}
+
void QTReaderApp::pagemode(bool _b)
{
reader->setpagemode(_b);
}
-void QTReaderApp::navkeys(bool _b)
-{
- reader->m_navkeys = _b;
-}
-void QTReaderApp::monospace(bool _b)
-{
- reader->setmono(_b);
-}
+/*
void QTReaderApp::setspacing()
{
m_nRegAction = cMonoSpace;
char lcn[20];
sprintf(lcn, "%lu", reader->m_charpc);
regEdit->setText(lcn);
do_regedit();
}
-
-void QTReaderApp::setoverlap()
-{
- m_nRegAction = cOverlap;
- char lcn[20];
- sprintf(lcn, "%lu", reader->m_overlap);
- regEdit->setText(lcn);
- do_regedit();
-}
-
+*/
void QTReaderApp::settarget()
{
m_nRegAction = cSetTarget;
QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp)
@@ -1501,20 +2131,9 @@ void QTReaderApp::settarget()
regEdit->setText(text);
do_regedit();
}
-void QTReaderApp::do_overlap(const QString& lcn)
-{
- bool ok;
- unsigned long ulcn = lcn.toULong(&ok);
- if (ok)
- {
- reader->m_overlap = ulcn;
- }
- else
- QMessageBox::information(this, PROGNAME, "Must be a number");
-}
-
+/*
void QTReaderApp::do_mono(const QString& lcn)
{
bool ok;
unsigned long ulcn = lcn.toULong(&ok);
@@ -1527,9 +2146,9 @@ void QTReaderApp::do_mono(const QString& lcn)
}
else
QMessageBox::information(this, PROGNAME, "Must be a number");
}
-
+*/
/*
void QTReaderApp::editPaste()
{
#ifndef QT_NO_CLIPBOARD
@@ -1543,9 +2162,11 @@ void QTReaderApp::editFind()
searchStart = reader->pagelocate();
#ifdef __ISEARCH
searchStack = new QStack<searchrecord>;
#endif
+#ifdef USEQPE
Global::showInputMethod();
+#endif
searchBar->show();
searchVisible = TRUE;
searchEdit->setFocus();
#ifdef __ISEARCH
@@ -1554,26 +2175,28 @@ void QTReaderApp::editFind()
}
void QTReaderApp::findNext()
{
- // qDebug("findNext called\n");
+// // qDebug("findNext called\n");
#ifdef __ISEARCH
QString arg = searchEdit->text();
#else
QRegExp arg = searchEdit->text();
#endif
CDrawBuffer test(&(reader->m_fontControl));
size_t start = reader->pagelocate();
reader->jumpto(start);
- reader->buffdoc.getline(&test,reader->width());
+ reader->getline(&test);
dosearch(start, test, arg);
}
void QTReaderApp::findClose()
{
searchVisible = FALSE;
searchEdit->setText("");
+#ifdef USEQPE
Global::hideInputMethod();
+#endif
searchBar->hide();
#ifdef __ISEARCH
// searchStack = new QStack<searchrecord>;
while (!searchStack->isEmpty())
@@ -1589,9 +2212,11 @@ void QTReaderApp::regClose()
{
regVisible = FALSE;
regEdit->setText("");
regBar->hide();
+#ifdef USEQPE
Global::hideInputMethod();
+#endif
reader->setFocus();
}
#ifdef __ISEARCH
@@ -1603,50 +2228,68 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
bool ret = true;
unsigned long fs, ts;
reader->sizes(fs,ts);
size_t pos = reader->locate();
- reader->buffdoc.getline(&test,reader->width());
+ pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height());
pbar->show();
- pbar->resize(width(), editBar->height());
+ pbar->raise();
pbar->reset();
+ int offset;
int lastpc = (100*pos)/ts;
pbar->setProgress(lastpc);
- qApp->processEvents();
- reader->setFocus();
+// qApp->processEvents();
+ if (reader->buffdoc.getpara(test) >= 0)
+ {
+ reader->setFocus();
#ifdef __ISEARCH
- while (strstr(test.data(),(const tchar*)arg) == NULL)
+ while (strstr(test.data(),(const tchar*)arg) == NULL)
#else
#ifdef _UNICODE
- while (arg.match(toQString(test.data())) == -1)
+ while ((offset = arg.match(toQString(test.data()))) == -1)
#else
- while (arg.match(test.data()) == -1)
+ while (arg.match(test.data()) == -1)
#endif
#endif
- {
- pos = reader->locate();
- unsigned int lcn = reader->locate();
- int pc = (100*pos)/ts;
- if (pc != lastpc)
{
- pbar->setProgress(pc);
- qApp->processEvents();
- reader->setFocus();
- lastpc = pc;
+ pos = reader->locate();
+ int pc = (100*pos)/ts;
+ if (pc != lastpc)
+ {
+ pbar->setProgress(pc);
+ qApp->processEvents();
+ reader->setFocus();
+ lastpc = pc;
+ }
+
+ if (reader->buffdoc.getpara(test) < 0)
+ {
+ if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
+ pos = searchStart;
+ else
+ pos = start;
+ findClose();
+ pbar->hide();
+ reader->locate(pos);
+ return false;
+ }
}
-
- if (!reader->buffdoc.getline(&test,reader->width()))
- {
- if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
- pos = searchStart;
- else
- pos = start;
- ret = false;
- findClose();
- break;
- }
- }
- pbar->hide();
- reader->locate(pos);
+// qDebug("Found it at %u:%u", pos, offset);
+ pbar->hide();
+// qDebug("Hid");
+ reader->locate(pos+offset);
+// qDebug("Loacted");
+// qDebug("page up");
+ ret = true;
+ }
+ else
+ {
+ if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
+ pos = searchStart;
+ else
+ pos = start;
+ ret = false;
+ findClose();
+ }
return ret;
}
#ifdef __ISEARCH
@@ -1690,9 +2333,9 @@ void QTReaderApp::search()
#endif
void QTReaderApp::openFile( const QString &f )
{
- qDebug("File:%s", (const char*)f);
+// qDebug("File:%s", (const char*)f);
// openFile(DocLnk(f));
//}
//
//void QTReaderApp::openFile( const DocLnk &f )
@@ -1701,26 +2344,29 @@ void QTReaderApp::openFile( const QString &f )
QFileInfo fm(f);
if ( fm.exists() )
{
// QMessageBox::information(0, "Progress", "Calling fileNew()");
-
+#ifdef USEQPE
if (fm.extension( FALSE ) == "desktop")
{
DocLnk d(f);
QFileInfo fnew(d.file());
fm = fnew;
if (!fm.exists()) return;
}
-
+#endif
clear();
reader->setText(fm.baseName(), fm.absFilePath());
+ m_loadedconfig = readconfig(reader->m_string, false);
showEditTools();
readbkmks();
+ m_savedpos = 0xffffffff;
}
else
{
QMessageBox::information(this, PROGNAME, "File does not exist");
+ reader->m_lastfile = QString::null;
}
}
/*
@@ -1732,38 +2378,111 @@ void QTReaderApp::resizeEvent(QResizeEvent* e)
showFullScreen();
}
}
*/
-void QTReaderApp::keyPressEvent(QKeyEvent* e)
+void QTReaderApp::handlekey(QKeyEvent* e)
{
- if (m_fullscreen)
+// qDebug("Keypress event");
+ timeb now;
+ ftime(&now);
+ unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm;
+ if (etime < m_debounce)
{
- switch(e->key())
- {
- case Key_Escape:
- m_actFullscreen->setOn(false);
+ return;
+ }
+ m_lastkeytime = now;
+ switch(e->key())
+ {
+ case Key_Escape:
+// qDebug("escape event");
+ if (m_disableesckey)
+ {
+ m_disableesckey = false;
+ }
+ else
+ {
+ m_bcloseDisabled = true;
if (m_fullscreen)
{
- qDebug("Fullscreen already set - remove this!");
+ m_actFullscreen->setOn(false);
+ e->accept();
}
else
{
- m_fullscreen = false;
- reader->bDoUpdates = false;
- showEditTools();
- qApp->processEvents();
- reader->bDoUpdates = true;
- reader->update();
+// qDebug("escape action");
+ doAction(m_escapeTarget, e);
}
- e->accept();
- break;
- default:
- e->ignore();
+ }
+ break;
+ case Key_Space:
+ {
+ doAction(m_spaceTarget, e);
}
- }
- else
- {
- e->ignore();
+ break;
+ case Key_Return:
+ {
+ doAction(m_returnTarget, e);
+ }
+ break;
+ case Key_Left:
+ {
+ if (reader->m_autoScroll && m_leftScroll)
+ {
+ reader->reduceScroll();
+ }
+ else
+ {
+ doAction(m_leftTarget, e);
+ }
+ }
+ break;
+ case Key_Right:
+ {
+ if (reader->m_autoScroll && m_rightScroll)
+ {
+ reader->increaseScroll();
+ }
+ else
+ {
+ doAction(m_rightTarget, e);
+ }
+ }
+ break;
+ case Key_Up:
+ {
+ if (reader->m_autoScroll && m_upScroll)
+ {
+ reader->increaseScroll();
+ }
+ else
+ {
+ doAction(m_upTarget, e);
+ }
+ }
+ break;
+ case Key_Down:
+ {
+ if (reader->m_autoScroll && m_downScroll)
+ {
+ reader->reduceScroll();
+ }
+ else
+ {
+ doAction(m_downTarget, e);
+ }
+ }
+ break;
+ default:
+ {
+ e->ignore();
+ }
+
+/*
+ QString msg("Key press was:");
+ QString key;
+ msg += key.setNum(e->key());
+ QMessageBox::information(this, PROGNAME, msg);
+*/
}
}
void QTReaderApp::showEditTools()
@@ -1771,46 +2490,66 @@ void QTReaderApp::showEditTools()
// if ( !doc )
// close();
if (m_fullscreen)
{
- editBar->hide();
+ if (menubar != NULL) menubar->hide();
+ if (fileBar != NULL) fileBar->hide();
+ if (viewBar != NULL) viewBar->hide();
+ if (navBar != NULL) navBar->hide();
+ if (markBar != NULL) markBar->hide();
searchBar->hide();
regBar->hide();
+#ifdef USEQPE
Global::hideInputMethod();
+#endif
m_fontBar->hide();
// showNormal();
showFullScreen();
}
else
{
- qDebug("him");
+// qDebug("him");
+#ifdef USEQPE
Global::hideInputMethod();
- qDebug("eb");
- editBar->show();
+#endif
+// qDebug("eb");
+ menubar->show();
+ if (fileBar != NULL) fileBar->show();
+ if (viewBar != NULL) viewBar->show();
+ if (navBar != NULL) navBar->show();
+ if (markBar != NULL) markBar->show();
+ mb->show();
if ( searchVisible )
{
+#ifdef USEQPE
Global::showInputMethod();
- searchBar->show();
+#endif
+ searchBar->show();
}
if ( regVisible )
{
+#ifdef USEQPE
Global::showInputMethod();
- regBar->show();
+#endif
+ regBar->show();
}
if (m_fontVisible) m_fontBar->show();
- qDebug("sn");
+// qDebug("sn");
showNormal();
- qDebug("sm");
+// qDebug("sm");
+#ifdef USEQPE
showMaximized();
+#endif
// setCentralWidget(reader);
}
- qDebug("uc");
+// qDebug("uc");
updateCaption();
- qDebug("rw");
+// qDebug("rw");
editorStack->raiseWidget( reader );
- qDebug("sf");
+// qDebug("sf");
reader->setFocus();
+ reader->refresh();
}
/*
void QTReaderApp::save()
{
@@ -1875,8 +2614,9 @@ void QTReaderApp::setDocument(const QString& fileref)
}
void QTReaderApp::closeEvent( QCloseEvent *e )
{
+// qDebug("Close event");
if (m_fullscreen)
{
m_fullscreen = false;
showEditTools();
@@ -1889,63 +2629,79 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
else
{
if (editorStack->visibleWidget() == reader)
{
- if (m_fontVisible)
- {
- m_fontBar->hide();
- m_fontVisible = false;
- }
- if (regVisible)
- {
- regBar->hide();
- Global::hideInputMethod();
- regVisible = false;
- return;
- }
- if (searchVisible)
+ if ((m_escapeTarget != cesNone) && m_bcloseDisabled)
{
- searchBar->hide();
- Global::hideInputMethod();
- searchVisible = false;
- return;
+// qDebug("Close disabled");
+ m_bcloseDisabled = false;
+ e->ignore();
}
- if (m_fBkmksChanged && pBkmklist != NULL)
+ else
{
- if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
- savebkmks();
- delete pBkmklist;
- pBkmklist = NULL;
- m_fBkmksChanged = false;
+ if (m_fontVisible)
+ {
+ m_fontBar->hide();
+ m_fontVisible = false;
+ }
+ if (regVisible)
+ {
+ regBar->hide();
+#ifdef USEQPE
+ Global::hideInputMethod();
+#endif
+ regVisible = false;
+ return;
+ }
+ if (searchVisible)
+ {
+ searchBar->hide();
+#ifdef USEQPE
+ Global::hideInputMethod();
+#endif
+ searchVisible = false;
+ return;
+ }
+ if (m_fBkmksChanged && pBkmklist != NULL)
+ {
+ if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
+ savebkmks();
+ delete pBkmklist;
+ pBkmklist = NULL;
+ m_fBkmksChanged = false;
+ }
+ bFromDocView = FALSE;
+ updatefileinfo();
+ saveprefs();
+ e->accept();
}
- bFromDocView = FALSE;
- updatefileinfo();
- saveprefs();
- e->accept();
}
else
{
showEditTools();
+ m_disableesckey = true;
}
}
}
void QTReaderApp::do_gotomark()
{
- m_nRegAction = cGotoBkmk;
- listbkmk(pBkmklist);
+ m_nBkmkAction = cGotoBkmk;
+ if (!listbkmk(pBkmklist))
+ QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
}
void QTReaderApp::do_delmark()
{
- m_nRegAction = cDelBkmk;
- listbkmk(pBkmklist);
+ m_nBkmkAction = cDelBkmk;
+ if (!listbkmk(pBkmklist))
+ QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
}
-void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
+bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
{
bkmkselector->clear();
- if (_lab.isNull())
+ if (_lab.isEmpty())
bkmkselector->setText("Cancel");
else
bkmkselector->setText(_lab);
int cnt = 0;
@@ -1953,9 +2709,9 @@ void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
{
for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++)
{
#ifdef _UNICODE
- qDebug("Item:%s", (const char*)toQString(i->name()));
+// qDebug("Item:%s", (const char*)toQString(i->name()));
bkmkselector->insertItem(toQString(i->name()));
#else
bkmkselector->insertItem(i->name());
#endif
@@ -1963,25 +2719,14 @@ void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
}
}
if (cnt > 0)
{
-//tjw menu->hide();
- editBar->hide();
- if (m_fontVisible) m_fontBar->hide();
- if (regVisible)
- {
- Global::hideInputMethod();
- regBar->hide();
- }
- if (searchVisible)
- {
- Global::hideInputMethod();
- searchBar->hide();
- }
+ hidetoolbars();
editorStack->raiseWidget( bkmkselector );
+ return true;
}
else
- QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
+ return false;
}
void QTReaderApp::do_autogen()
{
@@ -1991,17 +2736,19 @@ void QTReaderApp::do_autogen()
}
void QTReaderApp::do_regedit()
{
-// editBar->hide();
+// fileBar->hide();
reader->bDoUpdates = false;
- qDebug("Showing regbar");
+// qDebug("Showing regbar");
regBar->show();
- qDebug("Showing kbd");
+// qDebug("Showing kbd");
+#ifdef USEQPE
Global::showInputMethod();
+#endif
regVisible = true;
regEdit->setFocus();
- qApp->processEvents();
+// qApp->processEvents();
reader->bDoUpdates = true;
reader->update();
}
@@ -2009,12 +2756,12 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
{
QString fn = toQString(
CFiledata(bk->anno()).name()
);
- qDebug("fileinfo");
+// qDebug("fileinfo");
if (!fn.isEmpty() && QFileInfo(fn).isFile())
{
- qDebug("Opening");
+// qDebug("Opening");
openFile(fn);
struct stat fnstat;
stat((const char *)reader->m_lastfile, &fnstat);
@@ -2034,9 +2781,10 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
if (svlen != 0)
{
QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?");
}
- qDebug("updating");
+// qDebug("updating");
+// showEditTools();
reader->locate(bk->value());
}
return true;
}
@@ -2047,12 +2795,14 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
}
void QTReaderApp::gotobkmk(int ind)
{
- switch (m_nRegAction)
+ showEditTools();
+ switch (m_nBkmkAction)
{
case cOpenFile:
{
+// qApp->processEvents();
if (!openfrombkmk((*pOpenlist)[ind]))
{
pOpenlist->erase(ind);
QMessageBox::information(this, PROGNAME, "Can't find file");
@@ -2062,23 +2812,146 @@ void QTReaderApp::gotobkmk(int ind)
case cGotoBkmk:
reader->locate((*pBkmklist)[ind]->value());
break;
case cDelBkmk:
-// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name());
+//// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name());
pBkmklist->erase(ind);
m_fBkmksChanged = true;
// pBkmklist->sort();
break;
case cRmBkmkFile:
- unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind)));
+ {
+#ifndef USEQPE
+ QDir d = QDir::home(); // "/"
+ d.cd(APPDIR);
+ d.remove(bkmkselector->text(ind));
+#else /* USEQPE */
+ unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind)));
+#endif /* USEQPE */
+ }
+ break;
+ case cLdConfig:
+ readconfig(bkmkselector->text(ind), false);
+ break;
+ case cRmConfig:
+ {
+#ifndef USEQPE
+ QDir d = QDir::home(); // "/"
+ d.cd(APPDIR "/configs");
+ d.remove(bkmkselector->text(ind));
+#else /* USEQPE */
+ unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind)));
+#endif /* USEQPE */
+ }
break;
+ case cExportLinks:
+ {
+#ifndef USEQPE
+ QDir d = QDir::home(); // "/"
+ d.cd(APPDIR "/urls");
+ QFileInfo fi(d, bkmkselector->text(ind));
+ if (fi.exists())
+ {
+ QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) );
+ if (!outfile.isEmpty())
+ {
+ FILE* fout = fopen((const char *)outfile, "w");
+ if (fout != NULL)
+ {
+ FILE* fin = fopen((const char *)fi.absFilePath(), "r");
+ if (fin != NULL)
+ {
+ fprintf(fout, "<html><body>\n");
+ int ch = 0;
+ while ((ch = fgetc(fin)) != EOF)
+ {
+ fputc(ch, fout);
+ }
+ fclose(fin);
+ fprintf(fout, "</html></body>\n");
+ d.remove(bkmkselector->text(ind));
+ }
+ fclose(fout);
+ }
+ else
+ QMessageBox::information(this, PROGNAME, "Couldn't open output");
+ }
+ }
+#else /* USEQPE */
+ FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r");
+ if (fin != NULL)
+ {
+ bool allok = false;
+ fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null);
+ if (fb->exec())
+ {
+ QString outfile = fb->getCurrentFile();
+ FILE* fout = fopen((const char *)outfile, "w");
+ if (fout != NULL)
+ {
+ fprintf(fout, "<html><body>\n");
+ int ch = 0;
+ while ((ch = fgetc(fin)) != EOF)
+ {
+ fputc(ch, fout);
+ }
+ fprintf(fout, "</html></body>\n");
+ fclose(fout);
+ allok = true;
+ }
+ else
+ QMessageBox::information(this, PROGNAME, "Couldn't open output");
+ }
+ delete fb;
+ fclose(fin);
+ if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)));
+ }
+ else
+ {
+ QMessageBox::information(this, PROGNAME, "Couldn't open input");
+ }
+
+/*
+ CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE );
+ int ret = f->exec();
+ qDebug("Return:%d", ret);
+ DocLnk* doc = f->getDoc();
+ if (doc != NULL)
+ {
+ FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r");
+ QString rt;
+ rt = "<html><body>\n";
+ int ch = 0;
+ while ((ch = fgetc(fin)) != EOF)
+ {
+ rt += (char)ch;
+ }
+ fclose(fin);
+ rt += "</html></body>\n";
+ if ( doc->name().isEmpty() )
+ {
+ doc->setName(bkmkselector->text(ind));
+ }
+ FileManager fm;
+ fm.saveFile( *doc, rt );
+ qDebug("YES");
+ }
+ else
+ {
+ qDebug("NO");
+ }
+ delete f;
+*/
+
+#endif /* USEQPE */
+ }
+ break;
}
- showEditTools();
}
void QTReaderApp::cancelbkmk()
{
- if (m_nRegAction == cOpenFile)
+ if (m_nBkmkAction == cOpenFile)
{
QString fn = usefilebrowser();
if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn);
}
@@ -2107,9 +2980,11 @@ void QTReaderApp::do_jump(const QString& lcn)
void QTReaderApp::do_regaction()
{
reader->bDoUpdates = false;
regBar->hide();
+#ifdef USEQPE
Global::hideInputMethod();
+#endif
regVisible = false;
switch(m_nRegAction)
{
case cAutoGen:
@@ -2120,22 +2995,30 @@ void QTReaderApp::do_regaction()
break;
case cJump:
do_jump(regEdit->text());
break;
+/*
case cMonoSpace:
do_mono(regEdit->text());
break;
- case cOverlap:
- do_overlap(regEdit->text());
- break;
+*/
case cSetTarget:
do_settarget(regEdit->text());
break;
+#ifdef _SCROLLPIPE
+ case cSetPipeTarget:
+ do_setpipetarget(regEdit->text());
+ break;
+#endif
+ case cSetConfigName:
+// qDebug("Saving config");
+ do_saveconfig(regEdit->text(), false);
+ break;
}
- reader->restore();
-// editBar->show();
+// reader->restore();
+// fileBar->show();
reader->setFocus();
- qApp->processEvents();
+// qApp->processEvents();
reader->bDoUpdates = true;
reader->update();
}
@@ -2154,69 +3037,117 @@ void QTReaderApp::do_settarget(const QString& _txt)
m_targetmsg = _txt.right(_txt.length()-ind-1);
}
}
+void QTReaderApp::chooseencoding()
+{
+ m_fontSelector->clear();
+ m_fontSelector->insertItem("Ascii");
+ m_fontSelector->insertItem("UTF-8");
+ m_fontSelector->insertItem("UCS-2(BE)");
+ m_fontSelector->insertItem("USC-2(LE)");
+ m_fontSelector->insertItem("Palm");
+ for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++)
+ {
+ m_fontSelector->insertItem(iter->mime);
+ } // delete the FontDatabase!!!
+ m_fontSelector->setCurrentItem (reader->m_encd);
+ m_fontAction = cChooseEncoding;
+ m_fontBar->show();
+ m_fontVisible = true;
+}
+
void QTReaderApp::setfont()
{
+ m_fontSelector->clear();
+ {
+#ifdef USEQPE
+ FontDatabase f;
+#else
+ QFontDatabase f;
+#endif
+ QStringList flist = f.families();
+ m_fontSelector->insertStringList(flist);
+ } // delete the FontDatabase!!!
+
for (int i = 1; i <= m_fontSelector->count(); i++)
{
if (m_fontSelector->text(i) == reader->m_fontname)
{
m_fontSelector->setCurrentItem(i);
break;
}
}
+ m_fontAction = cChooseFont;
m_fontBar->show();
m_fontVisible = true;
}
void QTReaderApp::setfontHelper(const QString& lcn, int size)
{
if (size == 0) size = reader->m_fontControl.currentsize();
- QFont f(lcn, 10 /*, QFont::Bold*/);
- qDebug("bs");
- bkmkselector->setFont( f );
- qDebug("re");
- regEdit->setFont( f );
- qDebug("se");
- searchEdit->setFont( f );
- qDebug("aw");
- m_annoWin->setFont( f );
+ if (m_propogatefontchange)
+ {
+ QFont f(lcn, 10);
+ bkmkselector->setFont( f );
+ regEdit->setFont( f );
+ searchEdit->setFont( f );
+ m_annoWin->setFont( f );
+ }
reader->m_fontname = lcn;
- qDebug("cf1");
if (!reader->ChangeFont(size))
{
- qDebug("cf2");
reader->ChangeFont(size);
}
- qDebug("ref");
+}
+
+void QTReaderApp::do_setencoding(int i)
+{
+// qDebug("setencoding:%d", i);
+ if (m_fontAction == cChooseEncoding)
+ {
+ reader->setencoding(i);
+ }
reader->refresh();
m_fontBar->hide();
m_fontVisible = false;
- qDebug("showedit");
+// qDebug("showedit");
if (reader->isVisible()) showEditTools();
- qDebug("showeditdone");
+// qDebug("showeditdone");
}
void QTReaderApp::do_setfont(const QString& lcn)
{
- setfontHelper(lcn);
+ if (m_fontAction == cChooseFont)
+ {
+ setfontHelper(lcn);
+ }
+ reader->refresh();
+ m_fontBar->hide();
+ m_fontVisible = false;
+// qDebug("showedit");
+ //if (reader->isVisible())
+ showEditTools();
+// qDebug("showeditdone");
}
void QTReaderApp::do_autogen(const QString& regText)
{
unsigned long fs, ts;
reader->sizes(fs,ts);
- // qDebug("Reg:%s\n", (const tchar*)(regEdit->text()));
+// // qDebug("Reg:%s\n", (const tchar*)(regEdit->text()));
m_autogenstr = regText;
QRegExp re(regText);
CBuffer buff;
if (pBkmklist != NULL) delete pBkmklist;
pBkmklist = new CList<Bkmk>;
m_fBkmksChanged = true;
+
+ pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height());
pbar->show();
-pbar->resize(width(), editBar->height());
+ pbar->raise();
pbar->reset();
+ reader->update();
qApp->processEvents();
reader->setFocus();
reader->jumpto(0);
int lastpc = 0;
@@ -2244,23 +3175,32 @@ pbar->resize(width(), editBar->height());
pBkmklist->sort();
pbar->setProgress(100);
qApp->processEvents();
pbar->hide();
+ reader->refresh();
}
void QTReaderApp::saveprefs()
{
+// qDebug("saveprefs");
// reader->saveprefs("uqtreader");
+// if (!m_loadedconfig)
+ do_saveconfig( APPDIR, true );
+
+/*
Config config( APPDIR );
config.setGroup( "View" );
reader->m_lastposn = reader->pagelocate();
+ config.writeEntry("FloatDialogs", m_bFloatingDialog);
config.writeEntry( "StripCr", reader->bstripcr );
config.writeEntry( "AutoFmt", reader->bautofmt );
config.writeEntry( "TextFmt", reader->btextfmt );
config.writeEntry( "StripHtml", reader->bstriphtml );
config.writeEntry( "Dehyphen", reader->bdehyphen );
+ config.writeEntry( "Depluck", reader->bdepluck );
+ config.writeEntry( "Dejpluck", reader->bdejpluck );
config.writeEntry( "OneSpace", reader->bonespace );
config.writeEntry( "Unindent", reader->bunindent );
config.writeEntry( "Repara", reader->brepara );
config.writeEntry( "DoubleSpace", reader->bdblspce );
@@ -2269,50 +3209,65 @@ void QTReaderApp::saveprefs()
config.writeEntry( "ScrollDelay", reader->m_delay);
config.writeEntry( "LastFile", reader->m_lastfile );
config.writeEntry( "LastPosn", (int)(reader->pagelocate()) );
config.writeEntry( "PageMode", reader->m_bpagemode );
- config.writeEntry( "CursorNavigation", reader->m_navkeys );
config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced );
+ config.writeEntry( "SwapMouse", reader->m_swapmouse);
config.writeEntry( "Fontname", reader->m_fontname );
config.writeEntry( "Encoding", reader->m_encd );
config.writeEntry( "CharSpacing", reader->m_charpc );
config.writeEntry( "Overlap", (int)(reader->m_overlap) );
+ config.writeEntry( "Margin", (int)reader->m_border );
config.writeEntry( "TargetApp", m_targetapp );
config.writeEntry( "TargetMsg", m_targetmsg );
+#ifdef _SCROLLPIPE
+ config.writeEntry( "PipeTarget", reader->m_pipetarget );
+ config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara );
+#endif
config.writeEntry( "TwoTouch", m_twoTouch );
config.writeEntry( "Annotation", m_doAnnotation);
config.writeEntry( "Dictionary", m_doDictionary);
config.writeEntry( "Clipboard", m_doClipboard);
config.writeEntry( "SpaceTarget", m_spaceTarget);
+ config.writeEntry( "EscapeTarget", m_escapeTarget);
+ config.writeEntry( "ReturnTarget", m_returnTarget);
+ config.writeEntry( "LeftTarget", m_leftTarget);
+ config.writeEntry( "RightTarget", m_rightTarget);
+ config.writeEntry( "UpTarget", m_upTarget);
+ config.writeEntry( "DownTarget", m_downTarget);
+ config.writeEntry("LeftScroll", m_leftScroll);
+ config.writeEntry("RightScroll", m_rightScroll);
+ config.writeEntry("UpScroll", m_upScroll);
+ config.writeEntry("DownScroll", m_downScroll);
#ifdef REPALM
config.writeEntry( "Repalm", reader->brepalm );
#endif
config.writeEntry( "Remap", reader->bremap );
config.writeEntry( "Peanut", reader->bpeanut );
config.writeEntry( "MakeBold", reader->bmakebold );
config.writeEntry( "Continuous", reader->m_continuousDocument );
-
+ config.writeEntry( "FullJust", reader->bfulljust );
+ config.writeEntry( "ExtraSpace", reader->getextraspace() );
+ config.writeEntry( "ExtraLead", reader->getlead() );
+ config.writeEntry( "Basesize", (int)reader->getBaseSize());
+ config.writeEntry( "RequestorFontChange", m_propogatefontchange);
+
+ config.setGroup( "Toolbar" );
+ config.writeEntry("Movable", m_tbmovesave);
+ config.writeEntry("Policy", m_tbpolsave);
+ config.writeEntry("Position", m_tbposition);
+*/
savefilelist();
}
-void QTReaderApp::indentplus()
-{
- reader->indentplus();
-}
-
-void QTReaderApp::indentminus()
-{
- reader->indentminus();
-}
-
/*
void QTReaderApp::oldFile()
{
- qDebug("oldFile called");
+// qDebug("oldFile called");
reader->setText(true);
- qDebug("settext called");
+// qDebug("settext called");
showEditTools();
- qDebug("showedit called");
+// qDebug("showedit called");
}
*/
/*
@@ -2363,29 +3318,50 @@ void info_cb(Fl_Widget* o, void* _data)
void QTReaderApp::savebkmks()
{
if (pBkmklist != NULL)
{
- BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string), true);
+#ifndef USEQPE
+ QDir d = QDir::home(); // "/"
+ d.cd(APPDIR);
+ QFileInfo fi(d, reader->m_string);
+ BkmkFile bf((const char *)fi.absFilePath(), true);
+#else /* USEQPE */
+ BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true);
+#endif /* USEQPE */
bf.write(*pBkmklist);
}
m_fBkmksChanged = false;
}
void QTReaderApp::readfilelist()
{
- BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"));
- qDebug("Reading open files");
+#ifndef USEQPE
+ QDir d = QDir::home(); // "/"
+ d.cd(APPDIR);
+ QFileInfo fi(d, ".openfiles");
+ BkmkFile bf((const char *)fi.absFilePath());
+#else /* USEQPE */
+ BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"));
+#endif /* USEQPE */
+// qDebug("Reading open files");
pOpenlist = bf.readall();
- if (pOpenlist != NULL) qDebug("...with success");
- else qDebug("...without success!");
+// if (pOpenlist != NULL) qDebug("...with success");
+// else qDebug("...without success!");
}
void QTReaderApp::savefilelist()
{
if (pOpenlist != NULL)
{
- BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"), true);
- qDebug("Writing open files");
+#ifndef USEQPE
+ QDir d = QDir::home(); // "/"
+ d.cd(APPDIR);
+ QFileInfo fi(d, ".openfiles");
+ BkmkFile bf((const char *)fi.absFilePath(), true);
+#else /* USEQPE */
+ BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true);
+#endif /* USEQPE */
+// qDebug("Writing open files");
bf.write(*pOpenlist);
}
}
@@ -2396,21 +3372,38 @@ void QTReaderApp::readbkmks()
delete pBkmklist;
}
struct stat fnstat;
struct stat bkstat;
+#ifndef USEQPE
+ QDir d = QDir::home(); // "/"
+ d.cd(APPDIR);
+ QFileInfo fi(d, reader->m_string);
+#endif /* ! USEQPE */
if (
stat((const char *)reader->m_lastfile, &fnstat) == 0
&&
- stat((const char *)Global::applicationFileName(APPDIR, reader->m_string), &bkstat) == 0
+#ifndef USEQPE
+ stat((const char *)fi.absFilePath(), &bkstat) == 0
+#else /* USEQPE */
+ stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0
+#endif /* USEQPE */
)
{
if (bkstat.st_mtime < fnstat.st_mtime)
{
- unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string));
+#ifndef USEQPE
+ unlink((const char *)fi.absFilePath());
+#else /* USEQPE */
+ unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string));
+#endif /* USEQPE */
}
}
- BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string));
+#ifndef USEQPE
+ BkmkFile bf((const char *)fi.absFilePath());
+#else /* USEQPE */
+ BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string));
+#endif /* USEQPE */
pBkmklist = bf.readall();
m_fBkmksChanged = bf.upgraded();
if (pBkmklist == NULL)
@@ -2455,9 +3448,9 @@ void QTReaderApp::do_addbkmk(const QString& text)
}
void QTReaderApp::OnRedraw()
{
- if (pBkmklist != NULL)
+ if ((pBkmklist != NULL) && (m_bkmkAvail != NULL))
{
bool found = findNextBookmark(reader->pagelocate());
m_bkmkAvail->setEnabled(found);
}
@@ -2467,86 +3460,286 @@ void QTReaderApp::showAnnotation()
{
m_annoWin->setName(toQString(m_anno->name()));
m_annoWin->setAnno(toQString(m_anno->anno()));
m_annoIsEditing = false;
+#ifdef USEQPE
Global::showInputMethod();
+#endif
editorStack->raiseWidget( m_annoWin );
m_annoWin->setFocus();
}
void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line)
{
-// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd);
+//// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd);
if (m_doClipboard)
{
QClipboard* cb = QApplication::clipboard();
cb->setText(wrd);
+#ifdef USEQPE
if (wrd.length() > 10)
{
Global::statusMessage(wrd.left(8) + "..");
}
else
{
Global::statusMessage(wrd);
}
+#endif
}
if (m_doAnnotation)
{
// addAnno(wrd, "Need to be able to edit this", posn);
m_annoWin->setName(line);
m_annoWin->setAnno("");
m_annoWin->setPosn(posn);
m_annoIsEditing = true;
+#ifdef USEQPE
Global::showInputMethod();
+#endif
editorStack->raiseWidget( m_annoWin );
}
+#ifdef USEQPE
if (m_doDictionary)
{
if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty())
{
QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8());
e << wrd;
}
}
+#endif
}
-void QTReaderApp::OnActionPressed()
+void QTReaderApp::doAction(ActionTypes a, QKeyEvent* e)
{
- switch (m_spaceTarget)
+ if (a == 0)
{
- case cesOpenFile:
- {
- fileOpen();
- }
- break;
- case cesAutoScroll:
- {
- reader->setautoscroll(!reader->m_autoScroll);
- setScrollState(reader->m_autoScroll);
- }
- break;
- case cesActionMark:
+ e->ignore();
+ }
+ else
+ {
+ e->accept();
+// qDebug("Accepted");
+ switch (a)
{
- addbkmk();
+ case cesOpenFile:
+ {
+ fileOpen();
+ }
+ break;
+ case cesAutoScroll:
+ {
+ reader->setautoscroll(!reader->m_autoScroll);
+ setScrollState(reader->m_autoScroll);
+ }
+ break;
+ case cesActionMark:
+ {
+ addbkmk();
+ }
+ break;
+ case cesFullScreen:
+ {
+ m_actFullscreen->setOn(!m_fullscreen);
+ }
+ break;
+ case cesActionAnno:
+ {
+ addanno();
+ }
+ break;
+ case cesZoomIn:
+ zoomin();
+ break;
+ case cesZoomOut:
+ zoomout();
+ break;
+ case cesBack:
+ reader->goBack();
+ break;
+ case cesForward:
+ reader->goForward();
+ break;
+ case cesHome:
+ reader->goHome();
+ break;
+ case cesPageUp:
+ reader->dopageup();
+ break;
+ case cesPageDown:
+ reader->dopagedn();
+ break;
+ case cesLineUp:
+ reader->lineUp();
+ break;
+ case cesLineDown:
+ reader->lineDown();
+ break;
+ case cesStartDoc:
+ gotoStart();
+ break;
+ case cesEndDoc:
+ gotoEnd();
+ break;
+ default:
+ qDebug("Unknown ActionType:%u", a);
+ break;
}
- break;
- case cesFullScreen:
+ }
+}
+
+void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); }
+void QTReaderApp::restoreFocus() { reader->setFocus(); }
+
+void QTReaderApp::SaveConfig()
+{
+ m_nRegAction = cSetConfigName;
+ regEdit->setText(reader->m_string);
+ do_regedit();
+}
+
+void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
+{
+// qDebug("do_saveconfig:%s", (const char*)_txt);
+#ifdef USEQPE
+ QString configname;
+ Config::Domain dom;
+
+ if (full)
+ {
+ configname = _txt;
+ dom = Config::User;
+ }
+ else
+ {
+ configname = Global::applicationFileName(APPDIR "/configs", _txt);
+ dom = Config::File;
+ }
+
+ Config config(configname, dom);
+ config.setGroup( "View" );
+
+#else
+ QFileInfo fi;
+ if (full)
{
- m_actFullscreen->setOn(true);
+// qDebug("full:%s", (const char*)_txt);
+ QDir d = QDir::home(); // "/"
+ if ( !d.cd(_txt) )
+ { // "/tmp"
+ qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt );
+ d = QDir::home();
+ d.mkdir(_txt);
+ d.cd(_txt);
+ }
+ fi.setFile(d, INIFILE);
}
- break;
- default:
+ else
{
- qDebug("Unknown ActionType:%u", m_spaceTarget);
+ QDir d = QDir::home(); // "/"
+ if ( !d.cd(APPDIR) )
+ { // "/tmp"
+ qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
+ d = QDir::home();
+ d.mkdir(APPDIR);
+ d.cd(APPDIR);
+ }
+ if ( !d.cd("configs") )
+ { // "/tmp"
+ qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" );
+ d = QDir::home();
+ d.cd(APPDIR);
+ d.mkdir("configs");
+ d.cd("configs");
+ }
+ fi.setFile(d, _txt);
}
- break;
+// qDebug("Path:%s", (const char*)fi.absFilePath());
+ Config config(fi.absFilePath());
+#endif
+
+
+ config.writeEntry( "StripCr", reader->bstripcr );
+ config.writeEntry( "AutoFmt", reader->bautofmt );
+ config.writeEntry( "TextFmt", reader->btextfmt );
+ config.writeEntry( "StripHtml", reader->bstriphtml );
+ config.writeEntry( "Dehyphen", reader->bdehyphen );
+ config.writeEntry( "Depluck", reader->bdepluck );
+ config.writeEntry( "Dejpluck", reader->bdejpluck );
+ config.writeEntry( "OneSpace", reader->bonespace );
+ config.writeEntry( "Unindent", reader->bunindent );
+ config.writeEntry( "Repara", reader->brepara );
+ config.writeEntry( "DoubleSpace", reader->bdblspce );
+ config.writeEntry( "Indent", reader->bindenter );
+ config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) );
+ config.writeEntry( "ScrollDelay", reader->m_delay);
+ if (full)
+ {
+ config.writeEntry("Debounce", m_debounce);
+ config.writeEntry("FloatDialogs", m_bFloatingDialog);
+ reader->m_lastposn = reader->pagelocate();
+ config.writeEntry( "LastFile", reader->m_lastfile );
+ config.writeEntry( "LastPosn", (int)(reader->pagelocate()) );
+ }
+ config.writeEntry( "PageMode", reader->m_bpagemode );
+ config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced );
+ config.writeEntry( "SwapMouse", reader->m_swapmouse);
+ config.writeEntry( "Fontname", reader->m_fontname );
+ config.writeEntry( "Encoding", reader->m_encd );
+ config.writeEntry( "CharSpacing", reader->m_charpc );
+ config.writeEntry( "Overlap", (int)(reader->m_overlap) );
+ config.writeEntry( "Margin", (int)reader->m_border );
+ config.writeEntry( "TargetApp", m_targetapp );
+ config.writeEntry( "TargetMsg", m_targetmsg );
+#ifdef _SCROLLPIPE
+ config.writeEntry( "PipeTarget", reader->m_pipetarget );
+ config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara );
+#endif
+ config.writeEntry( "TwoTouch", m_twoTouch );
+ config.writeEntry( "Annotation", m_doAnnotation);
+ config.writeEntry( "Dictionary", m_doDictionary);
+ config.writeEntry( "Clipboard", m_doClipboard);
+ config.writeEntry( "SpaceTarget", m_spaceTarget);
+ config.writeEntry( "EscapeTarget", m_escapeTarget);
+ config.writeEntry( "ReturnTarget", m_returnTarget);
+ config.writeEntry( "LeftTarget", m_leftTarget);
+ config.writeEntry( "RightTarget", m_rightTarget);
+ config.writeEntry( "UpTarget", m_upTarget);
+ config.writeEntry( "DownTarget", m_downTarget);
+ config.writeEntry("LeftScroll", m_leftScroll);
+ config.writeEntry("RightScroll", m_rightScroll);
+ config.writeEntry("UpScroll", m_upScroll);
+ config.writeEntry("DownScroll", m_downScroll);
+#ifdef REPALM
+ config.writeEntry( "Repalm", reader->brepalm );
+#endif
+ config.writeEntry( "Remap", reader->bremap );
+ config.writeEntry( "Peanut", reader->bpeanut );
+ config.writeEntry( "MakeBold", reader->bmakebold );
+ config.writeEntry( "Continuous", reader->m_continuousDocument );
+ config.writeEntry( "FullJust", reader->bfulljust );
+ config.writeEntry( "ExtraSpace", reader->getextraspace() );
+ config.writeEntry( "ExtraLead", reader->getlead() );
+ config.writeEntry( "Basesize", (int)reader->getBaseSize());
+ config.writeEntry( "RequestorFontChange", m_propogatefontchange);
+ if (full)
+ {
+ config.setGroup( "Toolbar" );
+ config.writeEntry("Movable", m_tbmovesave);
+ config.writeEntry("Policy", m_tbpolsave);
+ config.writeEntry("Position", m_tbposition);
+#ifndef USEQPE
+ config.setGroup( "Geometry" );
+ config.writeEntry( "x", x() );
+ config.writeEntry( "y", y() );
+ config.writeEntry( "width", width() );
+ config.writeEntry( "height", height() );
+#endif
}
}
-void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); }
-void QTReaderApp::restoreFocus() { reader->setFocus(); }
-
/*
void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen)
{
unsigned short sdlen;
@@ -2583,14 +3776,15 @@ void QTReaderApp::getstate(unsigned char*& data, unsigned short& len)
sd->bautofmt = reader->bautofmt;
sd->bstriphtml = reader->bstriphtml;
sd->bpeanut = reader->bpeanut;
sd->bdehyphen = reader->bdehyphen;
+ sd->bdepluck = reader->bdepluck;
+ sd->bdejpluck = reader->bdejpluck;
sd->bonespace = reader->bonespace;
sd->bunindent = reader->bunindent;
sd->brepara = reader->brepara;
sd->bdblspce = reader->bdblspce;
sd->m_bpagemode = reader->m_bpagemode;
- sd->m_navkeys = reader->m_navkeys;
sd->m_bMonoSpaced = reader->m_bMonoSpaced;
sd->bremap = reader->bremap;
sd->bmakebold = reader->bmakebold;
sd->Continuous = reader->m_continuousDocument;
@@ -2603,4 +3797,426 @@ void QTReaderApp::getstate(unsigned char*& data, unsigned short& len)
sd->m_charpc = reader->m_charpc;
strcpy(sd->m_fontname, reader->m_fontname.latin1());
}
*/
+#ifdef _SCRIPT
+void QTReaderApp::RunScript()
+{
+ fileBrowser* fb = new fileBrowser(this,"OpieReader",!m_bFloatingDialog,
+ 0,
+// WStyle_Customize | WStyle_NoBorderEx,
+ "*", Global::applicationFileName(APPDIR "/scripts", ""));
+
+ QString fn;
+ if (fb->exec())
+ {
+ fn = fb->fileList[0];
+ }
+ delete fb;
+ if ( !fn.isEmpty() && fork() == 0 )
+ {
+ execlp((const char *)fn,(const char *)fn,NULL);
+ }
+}
+
+void QTReaderApp::SaveScript(const char* sname)
+{
+ FILE* f = fopen(sname,"w");
+ if (f != NULL)
+ {
+#ifdef OPIE
+ fprintf(f, "#!/bin/sh\nmsg() {\n\tqcop QPE/Application/reader \"$1\" \"$2\" \"$3\"\n}\n");
+#else
+ fprintf(f, "#!/bin/bash\nmsg() {\n\tqcop QPE/Application/uqtreader \"$1\" \"$2\" \"$3\"\n}\n");
+#endif
+ fprintf(f, "msg \"Update(int)\" 0\n");
+ fprintf(f, "msg \"Layout/StripCR(int)\" %d\n", (reader->bstripcr) ? 1:0);
+ if (reader->btextfmt) fprintf(f, "msg \"Markup(QString)\" \"Text\"\n");
+ else if (reader->bautofmt) fprintf(f, "msg \"Markup(QString)\" \"Auto\"\n");
+ else if (reader->bstriphtml) fprintf(f, "msg \"Markup(QString)\" \"HTML\"\n");
+ else if (reader->bpeanut) fprintf(f, "msg \"Markup(QString)\" \"Peanut/PML\"\n");
+ else fprintf(f, "msg \"Markup(QString)\" \"None\"\n");
+ fprintf(f, "msg \"Layout/Dehyphen(int)\" %d\n", (reader->bdehyphen) ? 1:0);
+ fprintf(f, "msg \"Layout/Depluck(int)\" %d\n", (reader->bdepluck) ? 1:0);
+ fprintf(f, "msg \"Layout/Dejpluck(int)\" %d\n", (reader->bdejpluck) ? 1:0);
+ fprintf(f, "msg \"Layout/SingleSpace(int)\" %d\n", (reader->bonespace) ? 1:0);
+ fprintf(f, "msg \"Layout/Unindent(int)\" %d\n", (reader->bunindent) ? 1:0);
+ fprintf(f, "msg \"Layout/Re-paragraph(int)\" %d\n", (reader->brepara) ? 1:0);
+ fprintf(f, "msg \"Layout/DoubleSpace(int)\" %d\n", (reader->bdblspce) ? 1:0);
+ fprintf(f, "msg \"Layout/Indent(int)\" %d\n", reader->bindenter);
+ fprintf(f, "msg \"Format/SetFont(QString,int)\" \"%s\" %d\n", (const char*)reader->m_fontname, reader->m_textsize);
+ fprintf(f, "msg \"Navigation/Page/LineScroll(int)\" %d\n", (reader->m_bpagemode) ? 1:0);
+ fprintf(f, "msg \"Format/Ideogram/Word(int)\" %d\n", (reader->m_bMonoSpaced) ? 1:0);
+ fprintf(f, "msg \"Format/Encoding(QString)\" \"%s\"\n", (const char*)m_EncodingAction[reader->m_encd]->text());
+ fprintf(f, "msg \"Format/SetWidth(int)\" %d\n", reader->m_charpc);
+ fprintf(f, "msg \"Navigation/SetOverlap(int)\" %d\n", reader->m_overlap);
+ fprintf(f, "msg \"Layout/Remap(int)\" %d\n", (reader->bremap) ? 1:0);
+ fprintf(f, "msg \"Layout/Embolden(int)\" %d\n", (reader->bmakebold) ? 1:0);
+ fprintf(f, "msg \"File/Continuous(int)\" %d\n", (reader->m_continuousDocument) ? 1:0);
+ fprintf(f, "msg \"File/SetDictionary(QString)\" \"%s/%s\"\n", (const char *)m_targetapp, (const char *)m_targetmsg);
+#ifdef _SCROLLPIPE
+ fprintf(f, "msg \"File/SetScrollTarget(QString)\" \"%s\"\n", (const char *)reader->m_pipetarget);
+#endif
+ fprintf(f, "msg \"File/Two/OneTouch(int)\" %d\n", (m_twoTouch) ? 1:0);
+ fprintf(f, "msg \"Target/Annotation(int)\" %d\n", (m_doAnnotation) ? 1:0);
+ fprintf(f, "msg \"Target/Dictionary(int)\" %d\n", (m_doDictionary) ? 1:0);
+ fprintf(f, "msg \"Target/Clipboard(int)\" %d\n", (m_doClipboard) ? 1:0);
+ fprintf(f, "msg \"File/Action(QString)\" \"%s\"\n", (const char *)m_buttonAction[m_spaceTarget]->text());
+ fprintf(f, "msg \"Update(int)\" 1\n");
+ fprintf(f, "msg \"info(QString)\" \"All Done\"\n");
+ fclose(f);
+ chmod(sname, S_IXUSR | S_IXGRP | S_IXOTH);
+ }
+}
+
+void QTReaderApp::SaveConfig()
+{
+ m_nRegAction = cSetConfigName;
+ regEdit->setText("");
+ do_regedit();
+}
+
+void QTReaderApp::do_saveconfig(const QString& _txt)
+{
+ SaveScript(Global::applicationFileName(APPDIR "/scripts", _txt));
+}
+#endif
+
+#ifdef _SCROLLPIPE
+void QTReaderApp::setpipetarget()
+{
+ m_nRegAction = cSetPipeTarget;
+ QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget;
+ regEdit->setText(text);
+ do_regedit();
+}
+
+void QTReaderApp::do_setpipetarget(const QString& _txt)
+{
+ reader->m_pipetarget = _txt;
+}
+
+void QTReaderApp::setpause(bool sfs)
+{
+ reader->m_pauseAfterEachPara = sfs;
+}
+#endif
+
+void QTReaderApp::monospace(bool _b)
+{
+ reader->setmono(_b);
+}
+
+bool QTReaderApp::readconfig(const QString& _txt, bool full=false)
+{
+#ifdef USEQPE
+ QString configname;
+ Config::Domain dom;
+
+ if (full)
+ {
+ configname = _txt;
+ dom = Config::User;
+ }
+ else
+ {
+ configname = Global::applicationFileName(APPDIR "/configs", _txt);
+ QFileInfo fm(configname);
+ if ( !fm.exists() ) return false;
+ dom = Config::File;
+ }
+
+ Config config(configname, dom);
+ config.setGroup( "View" );
+
+#else
+ QFileInfo fi;
+ if (full)
+ {
+ QDir d = QDir::home(); // "/"
+ if ( !d.cd(_txt) )
+ { // "/tmp"
+ qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt );
+ d = QDir::home();
+ d.mkdir(_txt);
+ d.cd(_txt);
+ }
+ fi.setFile(d, INIFILE);
+ }
+ else
+ {
+ QDir d = QDir::home(); // "/"
+ if ( !d.cd(APPDIR) )
+ { // "/tmp"
+ qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
+ d = QDir::home();
+ d.mkdir(APPDIR);
+ d.cd(APPDIR);
+ }
+ if ( !d.cd("configs") )
+ { // "/tmp"
+ qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" );
+ d = QDir::home();
+ d.mkdir("configs");
+ d.cd("configs");
+ }
+ fi.setFile(d, _txt);
+ }
+#ifdef _WINDOWS
+ struct stat fnstat;
+ if (stat((const char *)reader->m_lastfile, &fnstat) == 0) return false; // get round fileinfo bug on windows
+#else
+ if (!fi.exists()) return false;
+#endif
+ Config config(fi.absFilePath());
+#endif
+ if (full)
+ {
+ config.setGroup("Toolbar");
+ m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false);
+ m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1);
+ m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2);
+ }
+ config.setGroup( "View" );
+ m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false);
+ reader->bstripcr = config.readBoolEntry( "StripCr", true );
+ reader->bfulljust = config.readBoolEntry( "FullJust", false );
+ reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 ));
+ reader->setlead(config.readNumEntry( "ExtraLead", 0 ));
+ reader->btextfmt = config.readBoolEntry( "TextFmt", false );
+ reader->bautofmt = config.readBoolEntry( "AutoFmt", true );
+ reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
+ reader->bpeanut = config.readBoolEntry( "Peanut", false );
+ reader->bdehyphen = config.readBoolEntry( "Dehyphen", false );
+ reader->bdepluck = config.readBoolEntry( "Depluck", false );
+ reader->bdejpluck = config.readBoolEntry( "Dejpluck", false );
+ reader->bonespace = config.readBoolEntry( "OneSpace", false );
+ reader->bunindent = config.readBoolEntry( "Unindent", false );
+ reader->brepara = config.readBoolEntry( "Repara", false );
+ reader->bdblspce = config.readBoolEntry( "DoubleSpace", false );
+ reader->bindenter = config.readNumEntry( "Indent", 0 );
+ reader->m_textsize = config.readNumEntry( "FontSize", 12 );
+ reader->m_delay = config.readNumEntry( "ScrollDelay", 5184);
+ if (full)
+ {
+ reader->m_lastfile = config.readEntry( "LastFile", QString::null );
+ reader->m_lastposn = config.readNumEntry( "LastPosn", 0 );
+ }
+ reader->m_bpagemode = config.readBoolEntry( "PageMode", true );
+ reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false);
+ reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false);
+ reader->m_fontname = config.readEntry( "Fontname", "helvetica" );
+ reader->m_encd = config.readNumEntry( "Encoding", 0 );
+ reader->m_charpc = config.readNumEntry( "CharSpacing", 100 );
+ reader->m_overlap = config.readNumEntry( "Overlap", 0 );
+ reader->m_border = config.readNumEntry( "Margin", 6 );
+#ifdef REPALM
+ reader->brepalm = config.readBoolEntry( "Repalm", true );
+#endif
+ reader->bremap = config.readBoolEntry( "Remap", true );
+ reader->bmakebold = config.readBoolEntry( "MakeBold", false );
+ reader->setContinuous(config.readBoolEntry( "Continuous", true ));
+ m_targetapp = config.readEntry( "TargetApp", QString::null );
+ m_targetmsg = config.readEntry( "TargetMsg", QString::null );
+#ifdef _SCROLLPIPE
+ reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null );
+ reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true );
+#endif
+ m_twoTouch = config.readBoolEntry( "TwoTouch", false);
+ m_doAnnotation = config.readBoolEntry( "Annotation", false);
+ m_doDictionary = config.readBoolEntry( "Dictionary", false);
+ m_doClipboard = config.readBoolEntry( "Clipboard", false);
+ m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll);
+ m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone);
+ m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen);
+ m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut);
+ m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn);
+ m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp);
+ m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown);
+
+ m_leftScroll = config.readBoolEntry("LeftScroll", false);
+ m_rightScroll = config.readBoolEntry("RightScroll", false);
+ m_upScroll = config.readBoolEntry("UpScroll", true);
+ m_downScroll = config.readBoolEntry("DownScroll", true);
+ m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false);
+ reader->setBaseSize(config.readNumEntry( "Basesize", 10 ));
+ reader->setTwoTouch(m_twoTouch);
+
+ m_touch_action->setOn(m_twoTouch);
+ m_setmono_action->setOn(reader->m_bMonoSpaced);
+ setfontHelper(reader->m_fontname);
+ if (full)
+ {
+ addtoolbars(&config);
+ }
+ reader->setfilter(reader->getfilter());
+ reader->refresh();
+ return true;
+}
+
+bool QTReaderApp::PopulateConfig(const char* tgtdir)
+{
+ bkmkselector->clear();
+ bkmkselector->setText("Cancel");
+#ifndef USEQPE
+ int cnt = 0;
+
+ QDir d = QDir::home(); // "/"
+ if ( !d.cd(APPDIR) ) { // "/tmp"
+ qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
+ d = QDir::home();
+ d.mkdir(APPDIR);
+ d.cd(APPDIR);
+ }
+ if ( !d.cd(tgtdir) ) { // "/tmp"
+ qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir );
+ d = QDir::home();
+ d.mkdir(tgtdir);
+ d.cd(tgtdir);
+ }
+ d.setFilter( QDir::Files | QDir::NoSymLinks );
+// d.setSorting( QDir::Size | QDir::Reversed );
+
+ const QFileInfoList *list = d.entryInfoList();
+ QFileInfoListIterator it( *list ); // create list iterator
+ QFileInfo *fi; // pointer for traversing
+
+ while ( (fi=it.current()) ) { // for each file...
+
+ bkmkselector->insertItem(fi->fileName());
+ cnt++;
+
+ //qDebug( "%10li %s", fi->size(), fi->fileName().data() );
+ ++it; // goto next list element
+ }
+
+#else /* USEQPE */
+ int cnt = 0;
+ DIR *d;
+ char* finaldir;
+ finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1];
+ strcpy(finaldir, APPDIR);
+ strcat(finaldir, "/");
+ strcat(finaldir, tgtdir);
+ d = opendir((const char *)Global::applicationFileName(finaldir,""));
+
+ while(1)
+ {
+ struct dirent* de;
+ struct stat buf;
+ de = readdir(d);
+ if (de == NULL) break;
+
+ if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode))
+ {
+ bkmkselector->insertItem(de->d_name);
+ cnt++;
+ }
+ }
+ delete [] finaldir;
+ closedir(d);
+#endif
+ return (cnt > 0);
+}
+
+void QTReaderApp::LoadConfig()
+{
+ if (PopulateConfig("configs"))
+ {
+ editorStack->raiseWidget( bkmkselector );
+ hidetoolbars();
+ m_nBkmkAction = cLdConfig;
+ }
+ else
+ QMessageBox::information(this, PROGNAME, "No config files");
+}
+
+void QTReaderApp::TidyConfig()
+{
+ if (PopulateConfig("configs"))
+ {
+ editorStack->raiseWidget( bkmkselector );
+ hidetoolbars();
+ m_nBkmkAction = cRmConfig;
+ }
+ else
+ QMessageBox::information(this, PROGNAME, "No config files");
+}
+
+void QTReaderApp::ExportLinks()
+{
+ if (PopulateConfig("urls"))
+ {
+ editorStack->raiseWidget( bkmkselector );
+ hidetoolbars();
+ m_nBkmkAction = cExportLinks;
+ }
+ else
+ QMessageBox::information(this, PROGNAME, "No url files");
+}
+
+void QTReaderApp::OnURLSelected(const QString& href)
+{
+ CURLDialog* urld = new CURLDialog(href, false, this);
+ urld->clipboard(m_url_clipboard);
+ urld->localfile(m_url_localfile);
+ urld->globalfile(m_url_globalfile);
+ if (urld->exec())
+ {
+ m_url_clipboard = urld->clipboard();
+ m_url_localfile = urld->localfile();
+ m_url_globalfile = urld->globalfile();
+ if (m_url_clipboard)
+ {
+ QClipboard* cb = QApplication::clipboard();
+ cb->setText(href);
+ qDebug("<a href=\"%s\">%s</a>", (const char*)href, (const char*)href);
+ }
+ if (m_url_localfile)
+ {
+ writeUrl(reader->m_string, href);
+ }
+ if (m_url_globalfile)
+ {
+ writeUrl("GlobalURLFile", href);
+ }
+ }
+ delete urld;
+}
+
+void QTReaderApp::writeUrl(const QString& file, const QString& href)
+{
+ QString filename;
+#ifdef USEQPE
+ filename = Global::applicationFileName(APPDIR "/urls", file);
+#else
+ QFileInfo fi;
+ QDir d = QDir::home(); // "/"
+ if ( !d.cd(APPDIR) )
+ { // "/tmp"
+ qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
+ d = QDir::home();
+ d.mkdir(APPDIR);
+ d.cd(APPDIR);
+ }
+ if ( !d.cd("urls") )
+ { // "/tmp"
+ qWarning( "Cannot find the \"~/" APPDIR "/urls\" directory" );
+ d = QDir::home();
+ d.cd(APPDIR);
+ d.mkdir("urls");
+ d.cd("urls");
+ }
+ fi.setFile(d, file);
+ filename = fi.absFilePath();
+#endif
+ FILE* fout = fopen(filename, "a");
+ if (fout != NULL)
+ {
+ fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href);
+ fclose(fout);
+ }
+ else
+ {
+ QMessageBox::warning(this, PROGNAME, "Problem with writing URL");
+ }
+}
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
@@ -19,17 +19,21 @@
**********************************************************************/
#ifndef __QTREADERAPP_H
#define __QTREADERAPP_H
+//#define _SCROLLPIPE
//#define __ISEARCH
-#define MAX_ENCODING 6
-#define MAX_ACTIONS 4
+//#define MAX_ENCODING 6
+#define MAX_ACTIONS 5
+#include "useqpe.h"
+#include <sys/timeb.h>
#include <qmainwindow.h>
#include "CExpander.h"
+#include "CEncoding.h"
#include <qlist.h>
-#include <qpe/filemanager.h>
+//#include <qpe/filemanager.h>
#include <qmap.h>
#include <qlineedit.h>
#include <qstack.h>
#include <qlistbox.h>
@@ -38,24 +42,87 @@
class QWidgetStack;
class QToolButton;
class QPopupMenu;
class QToolBar;
-//class QPEToolBar;
+#ifdef USEQPE
+class QPEToolBar;
+class QPEMenuBar;
+#endif
class CBkmkSelector;
class QProgressBar;
class QAction;
class CAnnoEdit;
class QFloatBar;
class CDrawBuffer;
class QTReader;
-class QPixmap;
+class QImage;
+class Config;
enum ActionTypes
{
- cesOpenFile = 0,
+ cesNone = 0,
+ cesOpenFile,
cesAutoScroll,
cesActionMark,
- cesFullScreen
+ cesActionAnno,
+ cesFullScreen,
+ cesZoomIn,
+ cesZoomOut,
+ cesBack,
+ cesForward,
+ cesHome,
+ cesPageUp,
+ cesPageDown,
+ cesLineUp,
+ cesLineDown,
+ cesStartDoc,
+ cesEndDoc
+};
+/*
+*m_preferences_action, *m_close_action *m_info_action, *m_touch_action,
+*m_find_action, *m_jump_action, *m_setfont_action *m_goto_action,
+*m_delete_action; *m_autogen_action, *m_clear_action, *m_save_action;
+*m_tidy_action, *m_startBlock_action, *m_endBlock_action;
+*m_setenc_action, *m_setmono_action;
+*/
+enum ToolbarPolicy
+{
+ cesSingle = 0,
+ cesMenuTool,
+ cesMultiple
+};
+
+enum regedit_type
+{
+ cAutoGen,
+ cAddBkmk,
+ cJump,
+ cMonoSpace,
+ cSetTarget,
+#ifdef _SCROLLPIPE
+ cSetPipeTarget,
+#endif
+ cSetConfigName,
+ cMargin,
+ cExtraSpace,
+ cExtraLead
+};
+
+enum bkmk_action
+{
+ cOpenFile,
+ cGotoBkmk,
+ cDelBkmk,
+ cRmBkmkFile,
+ cLdConfig,
+ cRmConfig,
+ cExportLinks
+};
+
+enum fontselector_action
+{
+ cChooseFont,
+ cChooseEncoding
};
#ifdef __ISEARCH
struct searchrecord
@@ -73,13 +140,26 @@ class QTReaderApp : public QMainWindow
{
Q_OBJECT
unsigned long m_savedpos;
+ int m_debounce;
+ timeb m_lastkeytime;
bool m_annoIsEditing;
+ bool m_propogatefontchange, m_bFloatingDialog;
+ bool m_url_clipboard, m_url_localfile, m_url_globalfile;
+ fontselector_action m_fontAction;
+ void doAction(ActionTypes a, QKeyEvent* e);
public:
QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~QTReaderApp();
+
+ void handlekey(QKeyEvent* e);
+ void hideEvent(QHideEvent*)
+ {
+ suspend();
+ }
+
void suspend();
void openFile( const QString & );
void setScrollState(bool _b);
@@ -89,29 +169,42 @@ class QTReaderApp : public QMainWindow
QAction* m_bkmkAvail, *m_actFullscreen;
CAnnoEdit* m_annoWin;
Bkmk* m_anno;
// void resizeEvent(QResizeEvent* e);
- void keyPressEvent(QKeyEvent* e);
void closeEvent( QCloseEvent *e );
void readbkmks();
void do_mono(const QString&);
void do_jump(const QString&);
- void do_overlap(const QString&);
void do_settarget(const QString&);
- int EncNameToInt(const QString&);
+#ifdef _SCROLLPIPE
+// void do_setpipetarget(const QString&);
+#endif
+ void do_saveconfig(const QString&, bool);
+ bool readconfig(const QString&, bool);
+ bool PopulateConfig(const char*);
ActionTypes ActNameToInt(const QString&);
bool m_doAnnotation;
bool m_doDictionary;
bool m_doClipboard;
bool m_fullscreen;
-
+ bool m_loadedconfig;
public:
void saveprefs();
+public slots:
+ void setDocument(const QString&);
private slots:
+#ifdef _SCRIPT
+// void RunScript();
+#endif
+ void SaveConfig();
+ void LoadConfig();
+ void TidyConfig();
+ void ExportLinks();
void zoomin();
void zoomout();
+ void chooseencoding();
void setfullscreen(bool sfs);
- void setcontinuous(bool sfs);
+// void setcontinuous(bool sfs);
void setTwoTouch(bool _b);
void restoreFocus();
void OnAnnotation(bool _b)
{
@@ -125,44 +218,52 @@ private slots:
{
m_doClipboard = _b;
}
void OnWordSelected(const QString&, size_t, const QString&);
- void showgraphic(QPixmap&);
+ void OnURLSelected(const QString& href);
+ void showgraphic(QImage&);
void addAnno(const QString&, const QString&, size_t);
void addAnno(const QString&, const QString&);
void addanno();
void showAnnotation();
+ void do_setencoding(int i);
void do_setfont(const QString&);
- void encodingSelected(QAction*);
void buttonActionSelected(QAction*);
- void msgHandler(const QCString&, const QByteArray&);
- void monospace(bool);
+// void msgHandler(const QCString&, const QByteArray&);
+ void monospace(bool);
void jump();
- void setoverlap();
void settarget();
- void setspacing();
+#ifdef _SCROLLPIPE
+// void setpipetarget();
+// void setpause(bool);
+#endif
+// void setspacing();
void setfont();
void clearBkmkList();
void listBkmkFiles();
void editMark();
void autoScroll(bool);
void addbkmk();
void savebkmks();
// void importFiles();
+ void showprefs();
+ void showtoolbarprefs();
void infoClose();
// void oldFile();
void showinfo();
- void setDocument(const QString&);
- void indentplus();
- void indentminus();
+// void indentplus();
+// void indentminus();
void fileOpen();
void fileClose();
void editCopy();
void editFind();
+ void gotoStart();
+ void gotoEnd();
+
void pageup();
void pagedn();
void findNext();
@@ -177,36 +278,67 @@ private slots:
#endif
void showEditTools();
- void stripcr(bool);
- void onespace(bool);
+// void stripcr(bool);
+// void setfulljust(bool);
+// void onespace(bool);
#ifdef REPALM
// void repalm(bool);
#endif
- void peanut(bool _b);
- void remap(bool);
- void embolden(bool);
- void autofmt(bool);
- void textfmt(bool);
- void striphtml(bool);
- void dehyphen(bool);
- void unindent(bool);
- void repara(bool);
- void dblspce(bool);
+// void peanut(bool _b);
+// void remap(bool);
+// void embolden(bool);
+// void autofmt(bool);
+// void textfmt(bool);
+// void striphtml(bool);
+// void dehyphen(bool);
+// void depluck(bool);
+// void dejpluck(bool);
+// void unindent(bool);
+// void repara(bool);
+// void dblspce(bool);
void pagemode(bool);
- void navkeys(bool);
// void gotobkmk(const QString& bm);
void gotobkmk(int);
void cancelbkmk();
void do_gotomark();
void do_delmark();
void do_autogen();
void do_regaction();
void OnRedraw();
- void OnActionPressed();
private:
+ void writeUrl(const QString& file, const QString& href);
+ QAction *m_preferences_action, *m_open_action, *m_close_action;
+ QAction *m_info_action, *m_touch_action, *m_find_action, *m_start_action;
+ QAction *m_end_action, *m_jump_action, *m_pageline_action;
+ QAction *m_pageup_action, *m_pagedn_action, *m_back_action;
+ QAction *m_home_action, *m_forward_action, *m_zoomin_action;
+ QAction *m_zoomout_action, *m_setfont_action, *m_mark_action;
+ QAction *m_annotate_action, *m_goto_action, *m_delete_action;
+ QAction *m_autogen_action, *m_clear_action, *m_save_action;
+ QAction *m_tidy_action, *m_startBlock_action, *m_endBlock_action;
+ QAction *m_setenc_action, *m_setmono_action, *m_saveconfig_action;
+ QAction *m_loadconfig_action, *m_toolbarprefs_action, *m_tidyconfig_action;
+ QAction *m_exportlinks_action;
+ void addtoolbars(Config* config);
+ ToolbarPolicy m_tbpol, m_tbpolsave;
+ ToolBarDock m_tbposition;
+ bool m_tbmove, m_tbmovesave;
+ QToolBar* filebar();
+ QToolBar* viewbar();
+ QToolBar* navbar();
+ QToolBar* markbar();
+ void hidetoolbars();
+ void addfilebar(Config* _config, const QString& key, QAction* a);
+ void addviewbar(Config* _config, const QString& key, QAction* a);
+ void addnavbar(Config* _config, const QString& key, QAction* a);
+ void addmarkbar(Config* _config, const QString& key, QAction* a);
+ bool checkbar(Config* _config, const QString& key);
+#ifdef _SCRIPT
+ void SaveScript(const char* sname);
+#endif
/*
void setstate(unsigned char* _sd, unsigned short _sdlen);
void getstate(unsigned char*& data, unsigned short& len);
*/
@@ -215,9 +347,9 @@ private slots:
void savefilelist();
void updatefileinfo();
bool openfrombkmk(Bkmk*);
QString m_targetapp, m_targetmsg;
- void listbkmk(CList<Bkmk>*, const QString& _lab = QString::null);
+ bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null);
QString usefilebrowser();
void do_regedit();
void colorChanged( const QColor &c );
void clear();
@@ -229,15 +361,16 @@ private slots:
private:
QAction* m_scrollButton;
- QAction* m_EncodingAction[MAX_ENCODING];
-
QAction* m_buttonAction[MAX_ACTIONS];
CBkmkSelector* bkmkselector;
- ActionTypes m_spaceTarget;
+ ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget,
+ m_upTarget, m_downTarget;
+ bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll;
+ bool m_bcloseDisabled, m_disableesckey;
size_t searchStart;
#ifdef __ISEARCH
QStack<searchrecord>* searchStack;
bool dosearch(size_t start, CDrawBuffer& test, const QString& arg);
@@ -246,10 +379,15 @@ private slots:
#endif
QWidgetStack *editorStack;
QTReader* reader;
QComboBox* m_fontSelector;
-// QPEToolBar /* *menu,*/ *editBar;
- QToolBar /* *menu,*/ *editBar;
+// QPEToolBar /* *menu,*/ *fileBar;
+ QToolBar *menubar, *fileBar, *navBar, *viewBar, *markBar;
+#ifdef USEQPE
+ QPEMenuBar *mb;
+#else
+ QMenuBar *mb;
+#endif
QFloatBar *searchBar, *regBar/*, *m_fontBar*/;
QToolBar /* *searchBar, *regBar,*/ *m_fontBar;
QLineEdit *searchEdit, *regEdit;
bool searchVisible;
@@ -260,10 +398,10 @@ private slots:
long unsigned get_unique_id() { return m_uid++; }
/*
void resizeEvent( QResizeEvent * r)
{
- qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height());
- qDebug("resize:(%u,%u)", r->size().width(), r->size().height());
+// qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height());
+// qDebug("resize:(%u,%u)", r->size().width(), r->size().height());
// bgroup->move( width()-bgroup->width(), 0 );
}
*/
CList<Bkmk>* pBkmklist;
@@ -271,21 +409,34 @@ private slots:
infowin* m_infoWin;
GraphicWin* m_graphicwin;
QProgressBar* pbar;
bool m_fBkmksChanged;
- int m_nRegAction;
+// int m_nRegAction;
+ regedit_type m_nRegAction;
+ bkmk_action m_nBkmkAction;
QString m_autogenstr;
bool m_dontSave;
};
-const int cAutoGen = 0;
-const int cAddBkmk = 1;
-const int cDelBkmk = 2;
-const int cGotoBkmk = 3;
-const int cRmBkmkFile = 4;
-const int cJump = 5;
-const int cMonoSpace = 6;
-const int cOverlap = 7;
-const int cSetTarget = 8;
-const int cOpenFile = 9;
+//const int cAutoGen = 0;
+//const int cAddBkmk = 1;
+//const int cDelBkmk = 2;
+//const int cGotoBkmk = 3;
+//const int cRmBkmkFile = 4;
+//const int cJump = 5;
+//const int cMonoSpace = 6;
+//const int cOverlap = 7;
+//const int cSetTarget = 8;
+//const int cOpenFile = 9;
+//const int cSetPipeTarget = 10;
+//const int cSetConfigName = 11;
+//const int cMargin = 12;
+//const int cExtraSpace = 14;
+//const int cExtraLead = 15;
+//const int cGfxSize = 16;
+//const int cChooseFont = 2;
+//const int cChooseEncoding = 1;
#endif
+
+
+
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
@@ -8,8 +8,9 @@ struct statedata
bool bautofmt/*:1*/;
bool bstriphtml/*:1*/;
bool bpeanut/*:1*/;
bool bdehyphen/*:1*/;
+ bool bdepluck/*:1*/;
bool bonespace/*:1*/;
bool bunindent/*:1*/;
bool brepara/*:1*/;
bool bdblspce/*: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,13 +1,13 @@
-#include <qpixmap.h>
+#include <qimage.h>
#include "StyleConsts.h"
GraphicLink::~GraphicLink() { delete graphic; }
pmstore::~pmstore()
{
-// qDebug("Deleting image");
+//// qDebug("Deleting image");
delete graphic;
}
CStyle::~CStyle()
@@ -20,13 +20,8 @@ CStyle::~CStyle()
}
}
}
-CStyle::CStyle(CStyle& rhs) : graphic(NULL)
-{
- *this = rhs;
-}
-
CStyle::CStyle(const CStyle& rhs) : graphic(NULL)
{
*this = rhs;
}
@@ -84,9 +79,9 @@ void CStyle::unset()
graphic = NULL;
}
}
-void CStyle::setPicture(QPixmap* _g, bool il, unsigned long tgt)
+void CStyle::setPicture(bool canScale, QImage* _g, bool il, unsigned long tgt)
{
if (graphic != NULL)
{
if (--(graphic->count) == 0)
@@ -94,6 +89,6 @@ void CStyle::setPicture(QPixmap* _g, bool il, unsigned long tgt)
delete graphic;
}
graphic = NULL;
}
- if (_g != NULL) graphic = new pmstore(_g, il, tgt);
+ if (_g != NULL) graphic = new pmstore(canScale, _g, il, tgt);
}
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
@@ -2,28 +2,31 @@
#define __STYLECONSTS_H
typedef unsigned short StyleType;
-#include <stdlib.h>
+#ifdef _WINDOWS
#include <string.h>
+#endif
+#include <stdlib.h>
#include <qglobal.h>
-class QPixmap;
+class QImage;
struct GraphicLink
{
- QPixmap* graphic;
+ QImage* graphic;
bool isLink;
unsigned long link;
- GraphicLink(QPixmap* p, bool isLnk, unsigned long tgt) :
+ GraphicLink(QImage* p, bool isLnk, unsigned long tgt) :
graphic(p), isLink(isLnk), link(tgt) {}
~GraphicLink();
};
struct pmstore
{
unsigned int count;
+ bool m_isScaleable;
GraphicLink* graphic;
- pmstore(QPixmap* p, bool isLnk, unsigned long tgt) : count(1)
+ pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale)
{
graphic = new GraphicLink(p, isLnk, tgt);
}
~pmstore();
@@ -50,8 +53,10 @@ class CBasicStyle
bool m_underline;
bool m_strikethru;
bool m_monospaced;
unsigned char m_leftmargin, m_rightmargin;
+ signed char m_extraspace;
+ signed char m_voffset;
CBasicStyle()
{
unset();
}
@@ -72,16 +77,22 @@ class CBasicStyle
m_strikethru = false;
m_leftmargin = 0;
m_rightmargin = 0;
m_monospaced = false;
+ m_extraspace = 0;
+ m_voffset = 0;
}
};
class CStyle
{
CBasicStyle sty;
pmstore* graphic;
public:
+ signed char getVOffset() { return sty.m_voffset; }
+ void setVOffset(signed char sp) { sty.m_voffset = sp; }
+ signed char getExtraSpace() { return sty.m_extraspace; }
+ void setExtraSpace(signed char sp) { sty.m_extraspace = sp; }
bool getPictureLink()
{
return (graphic != NULL && graphic->graphic->isLink);
}
@@ -103,18 +114,19 @@ class CStyle
sty.blue = b;
}
CStyle() : graphic(NULL) {}
~CStyle();
- CStyle(CStyle&);
+// CStyle(CStyle&);
CStyle(const CStyle&);
CStyle& operator=(const CStyle&);
void unset();
bool isPicture() { return (graphic != NULL); }
+ bool canScale() { return graphic->m_isScaleable; }
void clearPicture();
- void setPicture(QPixmap* _g, bool il=false, unsigned long tgt=0);
- QPixmap* getPicture()
+ void setPicture(bool canScale, QImage* _g, bool il=false, unsigned long tgt=0);
+ QImage* getPicture()
{
- QPixmap* pm = ((graphic != NULL) ? graphic->graphic->graphic : NULL);
+ QImage* pm = ((graphic != NULL) ? graphic->graphic->graphic : NULL);
return pm;
}
void setUnderline() { sty.m_underline = true; }
void unsetUnderline() { sty.m_underline = false; }
@@ -156,9 +168,9 @@ class CStyle
void setFontSize(int _fs)
{
sty.m_fontsize = _fs;
}
- int getFontSize()
+ int getFontSize() const
{
return sty.m_fontsize;
}
bool operator!=(const CStyle& rhs)
diff --git a/noncore/apps/opie-reader/ZText.h b/noncore/apps/opie-reader/ZText.h
index 22d3733..ab81a5e 100644
--- a/noncore/apps/opie-reader/ZText.h
+++ b/noncore/apps/opie-reader/ZText.h
@@ -1,26 +1,29 @@
#ifndef __Text_h
#define __Text_h
#include <stdio.h>
-#include "zlib/zlib.h"
+#include <zlib.h>
#include <sys/stat.h>
-
+#include "useqpe.h"
#include "CExpander.h"
class Text: public CExpander {
gzFile file;
unsigned long fsize;
public:
- virtual void suspend()
- {
+ void suspend()
+ {
+#ifdef USEQPE
bSuspended = true;
suspos = gztell(file);
gzclose(file);
file = NULL;
- sustime = time(NULL);
+ sustime = time(NULL);
+#endif
}
- virtual void unsuspend()
+ void unsuspend()
{
+#ifdef USEQPE
if (bSuspended)
{
bSuspended = false;
int delay = time(NULL) - sustime;
@@ -36,32 +39,46 @@ public:
QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file");
exit(0);
}
suspos = gzseek(file, suspos, SEEK_SET);
- }
+ }
+#endif
}
Text() : file(NULL) {};
virtual ~Text()
{
if (file != NULL) gzclose(file);
}
- virtual int OpenFile(const char *src)
+ int OpenFile(const char *src)
{
if (file != NULL) gzclose(file);
struct stat _stat;
stat(src,&_stat);
fsize = _stat.st_size;
return ((file = gzopen(src,"rb")) == NULL);
}
- virtual int getch() { return gzgetc(file); }
- virtual unsigned int locate() { return gztell(file); }
- virtual void locate(unsigned int n) { gzseek(file,n,SEEK_SET); }
- virtual bool hasrandomaccess() { return true; }
- virtual void sizes(unsigned long& _file, unsigned long& _text)
+ int getch() { return gzgetc(file); }
+ unsigned int locate() { return gztell(file); }
+ void locate(unsigned int n) { gzseek(file,n,SEEK_SET); }
+ bool hasrandomaccess() { return true; }
+ void sizes(unsigned long& _file, unsigned long& _text)
{
_text = _file = fsize;
+ FILE* f = fopen(fname, "rb");
+ if (f != NULL)
+ {
+ unsigned char mn[2];
+ fread(mn, 1, 2, f);
+ if ((mn[0] == 31) && (mn[1] == 139))
+ {
+ int tmp = sizeof(_text);
+ fseek(f,-tmp,SEEK_END);
+ fread(&_text, sizeof(_text), 1, f);
+ }
+ fclose(f);
+ }
}
- virtual MarkupType PreferredMarkup()
+ MarkupType PreferredMarkup()
{
return cTEXT;
}
};
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
@@ -9,21 +9,42 @@ Extensive modification by Tim Wentford to allow it to work in rotated mode
****************************************************************************/
#include "fileBrowser.h"
#include "QtrListView.h"
+#include <qlineedit.h>
#include <qpushbutton.h>
#include <qfile.h>
#include <qmessagebox.h>
+#ifndef _WINDOWS
#include <unistd.h>
+#endif
#include <qlayout.h>
+#ifdef _WINDOWS
+#include <direct.h>
+#endif
-fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath )
- : QDialog( parent, name, modal, fl ), filterspec(QDir::All)
+#include "opie.h"
+
+fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath )
+ : QDialog( parent, name, true,
+ fl/* | WStyle_Customize | WStyle_Tool*/),
+ filterspec(QDir::All)
{
// showMaximized();
if ( !name )
setName( "fileBrowser" );
- if (parent != NULL) resize( parent->width(), parent->height() );
+/*
+ if (parent != NULL)
+ {
+#ifdef OPIE
+ move(0,0);
+ resize( parent->width(), parent->height() );
+#else
+ setGeometry(parent->x(), parent->y(), parent->width(), parent->height() );
+#endif
+ }
+*/
+// showFullScreen();
setCaption(tr( "Browse for file" ) );
filterStr=filter;
buttonOk = new QPushButton( this, "buttonOk" );
@@ -65,21 +86,37 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
hgrid->addWidget(dirLabel,1);
hgrid->addWidget(buttonShowHidden);
hgrid->addWidget(buttonOk);
grid->addWidget(ListView,1);
+ if (allownew)
+ {
+ m_filename = new QLineEdit(this);
+ grid->addWidget(m_filename);
+ connect( m_filename, SIGNAL( returnPressed() ), this, SLOT( onReturn() ));
+ }
+ else
+ {
+ m_filename = NULL;
+ }
if (QFileInfo(iPath).exists())
{
currentDir.setPath(iPath);
+#ifdef _WINDOWS
+ _chdir(iPath.latin1());
+#else
chdir(iPath.latin1());
+#endif
}
else
{
currentDir.setPath(QDir::currentDirPath());
chdir(QDir::currentDirPath().latin1());
}
populateList();
+
+ if (modal) showMaximized();
}
void fileBrowser::resizeEvent(QResizeEvent* e)
{
@@ -94,9 +131,9 @@ fileBrowser::~fileBrowser()
void fileBrowser::populateList()
{
ListView->clear();
-//qDebug(currentDir.canonicalPath());
+////qDebug(currentDir.canonicalPath());
// currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks );
currentDir.setFilter( filterspec );
currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
currentDir.setMatchAllDirs(TRUE);
@@ -118,9 +155,9 @@ void fileBrowser::populateList()
fileL+="/";
}
else
{
-// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
+//// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
}
new QListViewItem( ListView,fileL,fileS );
}
++it;
@@ -131,17 +168,17 @@ void fileBrowser::populateList()
}
void fileBrowser::upDir()
{
-// qDebug(currentDir.canonicalPath());
+//// qDebug(currentDir.canonicalPath());
}
void fileBrowser::listClicked(QListViewItem *selectedItem)
{
if (selectedItem == NULL) return;
QString strItem=selectedItem->text(0);
-// qDebug("%s", (const char*)strItem);
+//// qDebug("%s", (const char*)strItem);
QString strSize=selectedItem->text(1);
@@ -160,9 +197,20 @@ void fileBrowser::listClicked(QListViewItem *selectedItem)
currentDir.cd(strItem, TRUE);
populateList();
}
} else
+ {
+ QListViewItem *selectedItem = ListView->selectedItem();
+ if (selectedItem == NULL)
+ {
+ filename = "";
+ }
+ else
+ {
+ filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+selectedItem->text(0));
+ }
OnOK();
+ }
chdir(strItem.latin1());
//
}
@@ -171,18 +219,15 @@ void fileBrowser::listClicked(QListViewItem *selectedItem)
void fileBrowser::listDoubleClicked(QListViewItem *selectedItem)
{
}
-void fileBrowser::OnOK() {
+QString fileBrowser::getCurrentFile()
+{
+ return filename;
+}
- QListViewItemIterator it1( ListView);
- for ( ; it1.current(); ++it1 ) {
- if ( it1.current()->isSelected() ) {
- selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0));
-// qDebug("selected filename is "+selectedFileName);
- fileList.append( selectedFileName );
- }
- }
+void fileBrowser::OnOK()
+{
accept();
}
void fileBrowser::OnRoot()
@@ -204,4 +249,18 @@ void fileBrowser::setHidden(bool _hidden)
else
filterspec = QDir::All;
populateList();
}
+
+void fileBrowser::onReturn()
+{
+ QListViewItem *selectedItem = ListView->selectedItem();
+ if (selectedItem == NULL)
+ {
+ filename = m_filename->text();
+ }
+ else
+ {
+ filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+m_filename->text());
+ }
+ OnOK();
+}
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
@@ -28,16 +28,17 @@ class QHBoxLayout;
class QGridLayout;
class QtrListView;
class QListViewItem;
class QPushButton;
+class QLineEdit;
class fileBrowser : public QDialog
{
Q_OBJECT
public:
void populateList();
- fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0, const QString iPath=0);
+ fileBrowser( bool allownew, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0, const QString iPath=0);
~fileBrowser();
QPushButton* buttonOk;
QPushButton* buttonShowHidden;
@@ -46,24 +47,26 @@ public:
QLabel *dirLabel;
QString selectedFileName, filterStr;
QDir currentDir;
QFile file;
- QStringList fileList;
+ QString getCurrentFile();
+ QLineEdit* m_filename;
int filterspec;
// QDir::FilterSpec filterspec;
//QListViewItem * item;
public slots:
private:
-
+ QString filename;
private slots:
void upDir();
void listDoubleClicked(QListViewItem *);
void listClicked(QListViewItem *);
void OnRoot();
void OnCancel();
void setHidden(bool);
+ void onReturn();
protected slots:
protected:
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,10 +1,10 @@
-#include "name.h"
#include "infowin.h"
#include "version.h"
#include <stdio.h>
+#include "names.h"
-infowin::infowin( QWidget *parent, const char *name, WFlags f ) :
+infowin::infowin( QWidget *parent, const char *name, WFlags f) :
QWidget(parent, name, f)
{
grid = new QGridLayout(this, 6, 2);
QLabel* l;
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,11 +1,18 @@
+#include "useqpe.h"
+#ifdef USEQPE
#include <qpe/qpeapplication.h>
+#else
+#include <qapplication.h>
+#endif
#include "QTReaderApp.h"
#include "signal.h"
#include "stdio.h"
#include "time.h"
+
+#ifdef USEQPE
QTReaderApp* app = NULL;
void handler(int signum)
{
@@ -15,20 +22,29 @@ void handler(int signum)
app->saveprefs();
}
signal(signum, handler);
}
+#endif
int main( int argc, char ** argv )
{
- signal(SIGCONT, handler);
+#ifdef USEQPE
+ signal(SIGCONT, handler);
QPEApplication a( argc, argv );
-
QTReaderApp m;
-
a.showMainDocumentWidget( &m );
-
app = &m;
+#else
+ QApplication a( argc, argv );
+ QTReaderApp m;
+ a.setMainWidget( &m );
+ if (argc > 1)
+ {
+ m.setDocument(argv[1]);
+ }
+#endif
+
return a.exec();
}
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
@@ -6,37 +6,48 @@ HEADERS = Aportis.h \
CAnnoEdit.h \
CBuffer.h \
CDrawBuffer.h \
CEncoding.h \
+ CEncoding_tables.h \
CExpander.h \
CFilter.h \
+ CloseDialog.h \
Filedata.h \
+ FixedFont.h \
FontControl.h \
GraphicWin.h \
Markups.h \
Navigation.h \
Palm2QImage.h \
+ Prefs.h \
QFloatBar.h \
QTReader.h \
QTReaderApp.h \
QtrListView.h \
Queue.h \
StateData.h \
StyleConsts.h \
+ ToolbarPrefs.h \
+ URLDialog.h \
ZText.h \
arith.h \
cbkmkselector.h \
config.h \
fileBrowser.h \
infowin.h \
+ linktype.h \
my_list.h \
name.h \
+ names.h \
opie.h \
pdb.h \
plucker.h \
+ plucker_base.h \
ppm.h \
ppm_expander.h \
ustring.h \
+ usenef.h \
+ useqpe.h \
utypes.h \
version.h \
ztxt.h
@@ -45,24 +56,31 @@ SOURCES = Aportis.cpp \
BuffDoc.cpp \
CBuffer.cpp \
CDrawBuffer.cpp \
CEncoding.cpp \
+ CEncoding_tables.cpp \
CFilter.cpp \
+ CloseDialog.cpp \
FontControl.cpp \
Navigation.cpp \
Palm2QImage.cpp \
+ Prefs.cpp \
QTReader.cpp \
QTReaderApp.cpp \
QtrListView.cpp \
StyleConsts.cpp \
+ ToolbarPrefs.cpp \
+ URLDialog.cpp \
arith_d.cpp \
fileBrowser.cpp \
infowin.cpp \
main.cpp \
pdb.cpp \
plucker.cpp \
+ plucker_base.cpp \
ppm.cpp \
ppm_expander.cpp \
+ version.cpp \
ztxt.cpp
INTERFACES =
DESTDIR = $(OPIEDIR)/bin
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,8 +1,8 @@
#include "pdb.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
+#ifdef _WINDOWS
+#include <winsock2.h>
+#endif
size_t Cpdb::recordpos(int n)
{
UInt16 mxn = ntohs(head.recordList.numRecords);
@@ -48,15 +48,12 @@ bool Cpdb::openfile(const char *src)
}
// just holds the first few chars of the file
// char buf[0x100];
- struct stat buf;
- stat(src, &buf);
- file_length = buf.st_size;
-// fseek(fin,0,SEEK_END);
-// file_length = ftell(fin);
+ fseek(fin,0,SEEK_END);
+ file_length = ftell(fin);
-// fseek(fin,0,SEEK_SET);
+ fseek(fin,0,SEEK_SET);
fread(&head, 1, sizeof(head), fin);
return true;
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
@@ -10,9 +10,11 @@
#ifndef __PDB_H__
#define __PDB_H__
+#ifndef _WINDOWS
#include <netinet/in.h>
+#endif
#include <stdio.h>
/* Normal Palm typedefs */
typedef unsigned char UInt8;
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,213 +1,59 @@
+#include "useqpe.h"
#include <stdio.h>
#include <string.h>
#include <qmessagebox.h>
#include <qpixmap.h>
+#ifdef USEQPE
#include <qpe/qcopenvelope_qws.h>
+#endif
#ifdef LOCALPICTURES
#include <qscrollview.h>
#endif
+#ifdef USEQPE
#include <qpe/global.h>
-#include <qclipboard.h>
#include <qpe/qpeapplication.h>
+#else
+#include <qapplication.h>
+#endif
+#include <qclipboard.h>
#include "plucker.h"
#include "Aportis.h"
#include "Palm2QImage.h"
-#include "name.h"
-CPlucker::CPlucker() :
-#ifdef LOCALPICTURES
- m_viewer(NULL),
- m_picture(NULL),
-#endif
- expandedtextbuffer(NULL),
- compressedtextbuffer(NULL),
- urls(NULL)
- { /*printf("constructing:%x\n",fin);*/ }
-
-void CPlucker::Expand(UInt16 reclen, UInt8 type, UInt8* buffer, UInt16 buffersize)
+struct CPlucker_dataRecord
{
- if (type%2 == 0)
- {
- fread(buffer, reclen, sizeof(char), fin);
- }
- else
- {
- fread(compressedtextbuffer, reclen, sizeof(char), fin);
- switch (ntohs(hdr0.version))
- {
- case 2:
- UnZip(reclen, buffer, buffersize);
- break;
- case 1:
- UnDoc(reclen, buffer, buffersize);
- break;
- }
- }
-}
+ UInt16 uid;
+ UInt16 nParagraphs;
+ UInt16 size;
+ UInt8 type;
+ UInt8 reserved;
+};
-int CPlucker::OpenFile(const char *src)
+int CPlucker::HeaderSize()
{
- m_lastBreak = 0;
- if (!Cpdb::openfile(src))
- {
- return -1;
- }
-
-//printf("Okay %u\n", 4);
-
- if (memcmp(&head.type, "DataPlkr", 8) != 0) return -1;
-
-// qDebug("Cool - this IS plucker");
-
- EOPPhase = 0;
- gotorecordnumber(0);
- fread(&hdr0, 1, sizeof(hdr0), fin);
-//printf("Okay %u\n", 5);
- buffersize = 32*1024;
- compressedtextbuffer = new UInt8[buffersize];
- expandedtextbuffer = new UInt8[buffersize];
-
- qDebug("Total number of records:%u", ntohs(head.recordList.numRecords));
-
- unsigned int nrecs = ntohs(hdr0.nRecords);
- qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs);
- UInt16 homerecid = 1;
- UInt16 urlid = 0;
- bool urlsfound = false;
- for (unsigned int i = 0; i < nrecs; i++)
- {
- UInt16 id, name;
- fread(&name, 1, sizeof(name), fin);
- fread(&id, 1, sizeof(id), fin);
- qDebug("N:%d, I:%d", ntohs(name), ntohs(id));
- if (ntohs(name) == 0) homerecid = ntohs(id);
- if (ntohs(name) == 2)
- {
- urlsfound = true;
- urlid = id;
- qDebug("Found url index:%d", ntohs(urlid));
- }
-// qDebug("%x", id);
- }
-
- textlength = 0;
- for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
- {
- CPlucker_dataRecord thisHdr;
- gotorecordnumber(recptr);
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- if (ntohs(thisHdr.uid) == homerecid)
- {
- m_homepos = textlength;
- qDebug("Home pos found after %u records", recptr);
- break;
- }
- if (thisHdr.type < 2) textlength += ntohs(thisHdr.size);
- }
- textlength = 0;
-
- if (urlsfound)
- {
- unsigned short recptr = finduid(ntohs(urlid));
- if (recptr != 0)
- {
- CPlucker_dataRecord thisHdr;
- gotorecordnumber(recptr);
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- fread(&urlid, 1, sizeof(urlid), fin);
- fread(&urlid, 1, sizeof(urlid), fin);
- qDebug("urls are in %d", ntohs(urlid));
- recptr = finduid(ntohs(urlid));
- if (recptr != 0)
- {
- gotorecordnumber(recptr);
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- qDebug("Found urls:%x",thisHdr.type);
- UInt16 reclen = recordlength(recptr) - sizeof(thisHdr);
- gotorecordnumber(recptr);
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- urlsize = ntohs(thisHdr.size);
- urls = new char[urlsize];
- Expand(reclen, thisHdr.type, (UInt8*)urls, urlsize);
- }
- }
- }
-/*
- for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
- {
- CPlucker_dataRecord thisHdr;
- gotorecordnumber(recptr);
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- if (thisHdr.uid == urlid)
- {
- qDebug("Found urls:%x",thisHdr.type);
- UInt16 reclen = recordlength(recptr) - sizeof(thisHdr);
- gotorecordnumber(recptr);
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- urlsize = ntohs(thisHdr.size);
- urls = new char[urlsize];
- Expand(reclen, thisHdr.type, (UInt8*)urls, urlsize);
- break;
- }
- }
-*/
- home();
-#ifdef LOCALPICTURES
- if (m_viewer == NULL)
- {
- m_viewer = new QScrollView(NULL);
- m_picture = new QWidget(m_viewer->viewport());
- m_viewer->addChild(m_picture);
- }
-#endif
- return 0;
-
+ return sizeof(CPlucker_dataRecord);
}
-void CPlucker::sizes(unsigned long& _file, unsigned long& _text)
+void CPlucker::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved)
{
- qDebug("Sizes called:%u",textlength);
- _file = file_length;
- if (textlength == 0)
- {
- for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
- {
- CPlucker_dataRecord thisHdr;
- gotorecordnumber(recptr);
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- if (thisHdr.type < 2) textlength += ntohs(thisHdr.size);
- }
- }
- _text = textlength;
-//ntohl(hdr0.size);
+ CPlucker_dataRecord thishdr;
+ fread(&thishdr, 1, HeaderSize(), fin);
+ uid = ntohs(thishdr.uid);
+ nParagraphs = ntohs(thishdr.nParagraphs);
+ size = ntohs(thishdr.size);
+ type = thishdr.type;
+ reserved = thishdr.reserved;
}
+CPlucker::CPlucker()
+ { /*printf("constructing:%x\n",fin);*/ }
-char* CPlucker::geturl(UInt16 i)
-{
- if (urls == NULL) return NULL;
- char* ptr = urls;
- int rn = 1;
- while (ptr - urls < urlsize)
- {
- if (rn == i) return ptr;
- ptr += strlen(ptr)+1;
- rn++;
- }
- return NULL;
-}
-
-CPlucker::~CPlucker()
+bool CPlucker::CorrectDecoder()
{
- if (expandedtextbuffer != NULL) delete [] expandedtextbuffer;
- if (compressedtextbuffer != NULL) delete [] compressedtextbuffer;
- if (urls != NULL) delete [] urls;
-#ifdef LOCALPICTURES
- if (m_viewer != NULL) delete m_viewer;
-#endif
+ return (memcmp(&head.type, "DataPlkr", 8) == 0);
}
int CPlucker::bgetch()
{
@@ -215,11 +61,21 @@ int CPlucker::bgetch()
if (bufferpos >= buffercontent)
{
if (!m_continuous) return EOF;
if (bufferrec >= ntohs(head.recordList.numRecords) - 1) return EOF;
-// qDebug("Passing through %u", currentpos);
+//// qDebug("Passing through %u", currentpos);
if (!expand(bufferrec+1)) return EOF;
mystyle.unset();
+ if (m_ParaOffsets[m_nextParaIndex] == 0)
+ {
+ while (m_ParaOffsets[m_nextParaIndex+1] == 0)
+ {
+// qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7);
+ m_nextParaIndex++;
+ }
+ }
+ mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2);
+// qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7);
ch = 10;
EOPPhase = 4;
}
else if (bufferpos == m_nextPara)
@@ -227,8 +83,9 @@ int CPlucker::bgetch()
while (bufferpos == m_nextPara)
{
UInt16 attr = m_ParaAttrs[m_nextParaIndex];
m_nextParaIndex++;
+// qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7);
if (m_nextParaIndex == m_nParas)
{
m_nextPara = -1;
}
@@ -237,8 +94,10 @@ int CPlucker::bgetch()
m_nextPara += m_ParaOffsets[m_nextParaIndex];
}
}
mystyle.unset();
+ mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2);
+// qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7);
if (m_lastBreak == locate())
{
currentpos++;
ch = expandedtextbuffer[bufferpos++];
@@ -255,20 +114,19 @@ int CPlucker::bgetch()
}
return ch;
}
-int CPlucker::getch()
+tchar CPlucker::getch(bool fast)
{
mystyle.clearPicture();
-
if (EOPPhase > 0)
{
int ch = 10;
switch (EOPPhase)
{
case 4:
- mystyle.setPicture(hRule(100,5));
+ if (!fast) mystyle.setPicture(false, hRule(100,5));
mystyle.setCentreJustify();
ch = '#';
break;
case 3:
@@ -286,956 +144,13 @@ int CPlucker::getch()
EOPPhase--;
return ch;
}
-
- int ch = bgetch();
- while (ch == 0)
- {
- ch = bgetch();
-// qDebug("Function:%x", ch);
- switch (ch)
- {
- case 0x38:
-// qDebug("Break:%u", locate());
- if (m_lastBreak == locate())
- {
- ch = bgetch();
- }
- else
- {
- ch = 10;
- }
- m_lastBreak = locate();
- break;
- case 0x0a:
- case 0x0c:
- {
- unsigned long ln = 0;
- int skip = ch & 7;
- for (int i = 0; i < 2; i++)
- {
- int ch = bgetch();
- ln = (ln << 8) + ch;
-// qDebug("ch:%d, ln:%u", ch, ln);
- }
- if (skip == 2)
- {
- ln <<= 16;
- }
- else
- {
- for (int i = 0; i < 2; i++)
- {
- int ch = bgetch();
- ln = (ln << 8) + ch;
-// qDebug("ch:%d, ln:%u", ch, ln);
- }
- }
-// qDebug("ln:%u", ln);
- mystyle.setLink(true);
- mystyle.setData(ln);
-// mystyle.setColour(255, 0, 0);
- bool hasseen = false;
- for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++)
- {
- if (*it == ln)
- {
- hasseen = true;
- break;
- }
- }
- if (hasseen)
- {
- mystyle.setStrikethru();
- }
- else
- {
- mystyle.setUnderline();
- }
- ch = bgetch();
- }
- break;
- case 0x08:
- ch = bgetch();
-// mystyle.setColour(0, 0, 0);
- mystyle.unsetUnderline();
- mystyle.unsetStrikethru();
- mystyle.setLink(false);
- mystyle.setData(0);
- break;
- case 0x40:
- mystyle.setItalic();
- ch = bgetch();
- break;
- case 0x48:
- mystyle.unsetItalic();
- ch = bgetch();
- break;
- case 0x11:
- {
- ch = bgetch();
-// qDebug("Font:%d",ch);
- switch (ch)
- {
- case 0:
- mystyle.unsetMono();
- mystyle.unsetBold();
- mystyle.setFontSize(0);
- break;
- case 1:
- mystyle.unsetMono();
- mystyle.setBold();
- mystyle.setFontSize(3);
- break;
- case 2:
- mystyle.unsetMono();
- mystyle.setBold();
- mystyle.setFontSize(2);
- break;
- case 3:
- mystyle.unsetMono();
- mystyle.setBold();
-// mystyle.unsetBold();
- mystyle.setFontSize(1);
- break;
- case 4:
- mystyle.unsetMono();
- mystyle.setBold();
-// mystyle.unsetBold();
- mystyle.setFontSize(0);
- break;
- case 5:
- mystyle.unsetMono();
- mystyle.setBold();
- mystyle.setFontSize(0);
- break;
- case 6:
- mystyle.unsetMono();
- mystyle.setBold();
- mystyle.setFontSize(0);
- break;
- case 7:
- mystyle.unsetMono();
- mystyle.setBold();
- mystyle.setFontSize(0);
- break;
- case 8: // should be fixed width
- qDebug("Trying fixed width");
- mystyle.unsetBold();
- mystyle.setFontSize(0);
- mystyle.setMono();
- break;
- default:
- mystyle.unsetBold();
- mystyle.unsetMono();
- mystyle.setFontSize(0);
- break;
- }
- ch = bgetch();
- }
- break;
- case 0x29:
- ch = bgetch();
- switch (ch)
- {
- case 0:
- mystyle.setLeftJustify();
-// qDebug("left");
- break;
- case 1:
- mystyle.setRightJustify();
-// qDebug("right");
- break;
- case 2:
- mystyle.setCentreJustify();
-// qDebug("centre");
- break;
- case 3:
- mystyle.setFullJustify();
-// qDebug("full");
- break;
-
- }
- ch = bgetch();
- break;
- case 0x53:
- {
- int r = bgetch();
- int g = bgetch();
- int b = bgetch();
- mystyle.setColour(r,g,b);
- ch = bgetch();
- }
- break;
- case 0x1a:
- case 0x5c:
- {
- bool hasalternate = (ch == 0x5c);
- UInt16 ir = bgetch();
- ir = (ir << 8) + bgetch();
- if (hasalternate)
- {
- qDebug("Alternate image:%x", ir);
- UInt16 ir2 = bgetch();
- ir2 = (ir2 << 8) + bgetch();
- mystyle.setPicture(expandimg(ir2, true), true, ir);
-#ifdef LOCALPICTURES
- UInt32 ln = ir;
- ln <<= 16;
- mystyle.setLink(true);
- mystyle.setData(ln);
-#endif
- }
- else
- {
- mystyle.setPicture(expandimg(ir));
- }
- if (mystyle.getLink()) qDebug("Picture link!");
- ch = '#';
- }
-// ch = bgetch();
- break;
- case 0x33:
- {
- UInt8 h = bgetch();
- UInt8 wc = bgetch();
- UInt8 pc = bgetch();
- UInt16 w = wc;
-// qDebug("h,w,pc [%u, %u, %u]", h, w, pc);
- if (w == 0)
- {
- w = (240*(unsigned long)pc)/100;
- }
- if (w == 0) w = 320;
- mystyle.setPicture(hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue()));
-// if (mystyle.getLink()) qDebug("hRule link!");
- ch = '#';
- }
- break;
- case 0x60:
- mystyle.setUnderline();
- ch = bgetch();
- break;
- case 0x68:
- mystyle.unsetUnderline();
- ch = bgetch();
- break;
- case 0x22:
- ch = bgetch();
- mystyle.setLeftMargin(ch);
-// qDebug("Left margin:%d", ch);
- ch = bgetch();
- mystyle.setRightMargin(ch);
-// qDebug("Right margin:%d", ch);
- ch = bgetch();
- break;
- case 0x70:
- mystyle.setStrikethru();
- ch = bgetch();
- break;
- case 0x78:
- mystyle.unsetStrikethru();
- ch = bgetch();
- break;
- case 0x83:
- case 0x85:
- default:
- qDebug("Function:%x NOT IMPLEMENTED", ch);
- {
- int skip = ch & 7;
- for (int i = 0; i < skip; i++)
- {
- ch = bgetch();
-// qDebug("Arg %d, %d", i, ch);
- }
- ch = bgetch();
- }
- }
- }
-
- if (m_lastIsBreak && !mystyle.isMono())
- {
- while (ch == ' ')
- {
- ch = getch();
- }
- }
-
- m_lastIsBreak = (ch == 10);
-
- return ch;
-}
-
-void CPlucker::getch(int& ch, CStyle& sty)
-{
- ch = getch();
- sty = mystyle;
-}
-
-unsigned int CPlucker::locate()
-{
- return currentpos;
-/*
- UInt16 thisrec = 1;
- unsigned long locpos = 0;
- gotorecordnumber(thisrec);
- CPlucker_dataRecord thisHdr;
- while (thisrec < bufferrec)
- {
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- if (thisHdr.type < 2) locpos += ntohs(thisHdr.size);
- thisrec++;
- gotorecordnumber(thisrec);
- }
- return locpos+bufferpos;
-*/
-}
-
-void CPlucker::locate(unsigned int n)
-{
- UInt16 thisrec = 0;
- unsigned long locpos = 0;
- unsigned long bs = 0;
- CPlucker_dataRecord thisHdr;
- do
- {
- thisrec++;
- locpos += bs;
- gotorecordnumber(thisrec);
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- if (thisHdr.type < 2)
- {
- bs = ntohs(thisHdr.size);
- }
- else
- {
- bs = 0;
- }
- } while (locpos + bs <= n);
- currentpos = locpos;
- expand(thisrec);
-#ifdef _FAST
- while (currentpos < n && bufferpos < buffercontent) bgetch();
-#else
- while (currentpos < n && bufferpos < buffercontent) getch();
-#endif
+ return getch_base(fast);
}
-bool CPlucker::hyperlink(unsigned int n)
+QImage* CPlucker::imagefromdata(UInt8* imgbuffer, UInt32 imgsize)
{
- visited.push_front(n);
- UInt16 tuid = (n >> 16);
- n &= 0xffff;
-// qDebug("Hyper:<%u,%u>", tuid, n);
- UInt16 thisrec = 1;
- currentpos = 0;
- gotorecordnumber(thisrec);
- CPlucker_dataRecord thisHdr;
- while (1)
- {
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- if (tuid == ntohs(thisHdr.uid)) break;
- if (thisHdr.type < 2) currentpos += ntohs(thisHdr.size);
-// qDebug("hyper-cp:%u", currentpos);
- thisrec++;
- if (thisrec >= ntohs(head.recordList.numRecords))
- {
- if (urls == NULL)
- {
- QMessageBox::information(NULL,
- PROGNAME,
- QString("No external links\nin this pluck")
- );
- }
- else
- {
- char *turl = geturl(tuid);
- if (turl == NULL)
- {
- QMessageBox::information(NULL,
- PROGNAME,
- QString("Couldn't find link")
- );
- }
- else
- {
- QString wrd(turl);
- QClipboard* cb = QApplication::clipboard();
- cb->setText(wrd);
- if (wrd.length() > 10)
- {
- Global::statusMessage(wrd.left(8) + "..");
- }
- }
- }
- return false;
- }
- gotorecordnumber(thisrec);
- }
- if (thisHdr.type > 1)
- {
- if (thisHdr.type == 4)
- {
- QMessageBox::information(NULL,
- PROGNAME,
- QString("Mailto links\nnot yet supported (2)"));
- }
- else
- {
-#ifdef LOCALPICTURES
- if (thisHdr.type > 3)
- {
-#endif
- QMessageBox::information(NULL,
- PROGNAME,
- QString("External links\nnot yet supported (2)")
- );
-#ifdef LOCALPICTURES
- }
- else
- {
- showimg(tuid);
- }
-#endif
- }
- return false;
- }
-/*
- if (thisHdr.type == 2 || thisHdr.type == 3)
- {
- expandimg(thisrec);
-
- }
-*/
- else
- {
- expand(thisrec);
- if (n != 0)
- {
- if (n >= m_nParas)
- {
- QMessageBox::information(NULL,
- PROGNAME,
- QString("Error in link\nPara # too big")
- );
- return false;
- }
- unsigned int noff = 0;
- for (int i = 0; i < n; i++) noff += m_ParaOffsets[i];
- n = noff;
- }
- if (n > ntohs(thisHdr.size))
- {
- QMessageBox::information(NULL,
- PROGNAME,
- QString("Error in link\nOffset too big")
- );
- return false;
- }
- qDebug("Hyper:<%u,%u>", tuid, n);
- while (bufferpos < n && bufferpos < buffercontent) getch();
- }
- return true;
-}
-/*
-bool CPlucker::hyperlink(unsigned int n)
-{
- visited.push_front(n);
- UInt16 tuid = (n >> 16);
- n &= 0xffff;
-// qDebug("Hyper:<%u,%u>", tuid, n);
- UInt16 thisrec = finduid(tuid);
- if (thisrec == 0)
- {
- if (urls == NULL)
- {
- QMessageBox::information(NULL,
- PROGNAME,
- QString("No external links\nin this pluck")
- );
- }
- else
- {
- char *turl = geturl(tuid);
- if (turl == NULL)
- {
- QMessageBox::information(NULL,
- PROGNAME,
- QString("Couldn't find link")
- );
- }
- else
- {
- QString wrd(turl);
- QClipboard* cb = QApplication::clipboard();
- cb->setText(wrd);
- if (wrd.length() > 10)
- {
- Global::statusMessage(wrd.left(8) + "..");
- }
- }
- }
- return false;
- }
- else
- {
- currentpos = 0;
- gotorecordnumber(thisrec);
- CPlucker_dataRecord thisHdr;
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
-
- if (thisHdr.type > 1)
- {
- if (thisHdr.type == 4)
- {
- QMessageBox::information(NULL,
- PROGNAME,
- QString("Mailto links\nnot yet supported (2)"));
- }
- else
- {
-#ifdef LOCALPICTURES
- if (thisHdr.type > 3)
- {
-#endif
- QMessageBox::information(NULL,
- PROGNAME,
- QString("External links\nnot yet supported (2)")
- );
-#ifdef LOCALPICTURES
- }
- else
- {
- showimg(tuid);
- }
-#endif
- }
- return false;
- }
-// if (thisHdr.type == 2 || thisHdr.type == 3)
-// {
-// expandimg(thisrec);
-// }
- else
- {
- expand(thisrec);
- if (n != 0)
- {
- if (n >= m_nParas)
- {
- QMessageBox::information(NULL,
- PROGNAME,
- QString("Error in link\nPara # too big")
- );
- return false;
- }
- unsigned int noff = 0;
- for (int i = 0; i < n; i++) noff += m_ParaOffsets[i];
- n = noff;
- }
- if (n > ntohs(thisHdr.size))
- {
- QMessageBox::information(NULL,
- PROGNAME,
- QString("Error in link\nOffset too big")
- );
- return false;
- }
- qDebug("Hyper:<%u,%u>", tuid, n);
- while (bufferpos < n && bufferpos < buffercontent) getch();
- }
- return true;
- }
-}
-*/
-bool CPlucker::expand(int thisrec)
-{
- mystyle.unset();
- size_t reclen = recordlength(thisrec);
- gotorecordnumber(thisrec);
- CPlucker_dataRecord thisHdr;
- while (1)
- {
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
-// qDebug("This (%d) type is %d, uid is %u", thisrec, thisHdr.type, ntohs(thisHdr.uid));
- if (thisHdr.type < 2) break;
- qDebug("Skipping paragraph of type %d", thisHdr.type);
- if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false;
- reclen = recordlength(thisrec);
- gotorecordnumber(thisrec);
- }
- m_nParas = ntohs(thisHdr.nParagraphs);
-// qDebug("It has %u paragraphs and is %u bytes", ntohs(thisHdr.nParagraphs), ntohs(thisHdr.size));
- uid = ntohs(thisHdr.uid);
- for (int i = 0; i < m_nParas; i++)
- {
- UInt16 ubytes, attrs;
- fread(&ubytes, 1, sizeof(ubytes), fin);
- fread(&attrs, 1, sizeof(attrs), fin);
- m_ParaOffsets[i] = ntohs(ubytes);
- m_ParaAttrs[i] = ntohs(attrs);
-// qDebug("Bytes %u, Attr %x", ntohs(ubytes), attrs);
- }
- if (m_nParas > 0)
- {
- m_nextPara = m_ParaOffsets[0];
-// qDebug("First offset = %u", m_nextPara);
- m_nextParaIndex = 0;
- }
- else
- {
- m_nextPara = -1;
- }
-
- reclen -= sizeof(thisHdr)+4*m_nParas;
-
- buffercontent = ntohs(thisHdr.size);
-
- Expand(reclen, thisHdr.type, expandedtextbuffer, buffercontent);
- bufferpos = 0;
- bufferrec = thisrec;
-// qDebug("BC:%u, HS:%u", buffercontent, ntohs(thisHdr.size));
- return true;
-}
-
-void CPlucker::UnZip(size_t reclen, UInt8* tgtbuffer, UInt16 bsize)
-{
- z_stream zstream;
- memset(&zstream,sizeof(zstream),0);
- zstream.next_in = compressedtextbuffer;
- zstream.next_out = tgtbuffer;
- zstream.avail_out = bsize;
- zstream.avail_in = reclen;
-
- int keylen = 0;
-
- zstream.zalloc = Z_NULL;
- zstream.zfree = Z_NULL;
- zstream.opaque = Z_NULL;
-
-// printf("Initialising\n");
-
- inflateInit(&zstream);
- int err = 0;
- do {
- if ( zstream.avail_in == 0 && 0 < keylen ) {
- zstream.next_in = compressedtextbuffer + keylen;
- zstream.avail_in = reclen - keylen;
- keylen = 0;
- }
- zstream.next_out = tgtbuffer;
- zstream.avail_out = bsize;
-
- err = inflate( &zstream, Z_SYNC_FLUSH );
-
-// qDebug("err:%d - %u", err, zstream.avail_in);
-
- } while ( err == Z_OK );
-
- inflateEnd(&zstream);
-}
-
-void CPlucker::UnDoc(size_t reclen, UInt8* tgtbuffer, UInt16 bsize)
-{
-// UInt16 headerSize;
- UInt16 docSize;
- UInt16 i;
- UInt16 j;
- UInt16 k;
-
- UInt8 *inBuf = compressedtextbuffer;
- UInt8 *outBuf = tgtbuffer;
-
-// headerSize = sizeof( Header ) + record->paragraphs * sizeof( Paragraph );
- docSize = reclen;
-
- j = 0;
- k = 0;
- while ( j < docSize ) {
- i = 0;
- while ( i < bsize && j < docSize ) {
- UInt16 c;
-
- c = (UInt16) inBuf[ j++ ];
- if ( 0 < c && c < 9 ) {
- while ( 0 < c-- )
- outBuf[ i++ ] = inBuf[ j++ ];
- }
- else if ( c < 0x80 )
- outBuf[ i++ ] = c;
- else if ( 0xc0 <= c ) {
- outBuf[ i++ ] = ' ';
- outBuf[ i++ ] = c ^ 0x80;
- }
- else {
- Int16 m;
- Int16 n;
-
- c <<= 8;
- c += inBuf[ j++ ];
-
- m = ( c & 0x3fff ) >> COUNT_BITS;
- n = c & ( ( 1 << COUNT_BITS ) - 1 );
- n += 2;
-
- do {
- outBuf[ i ] = outBuf[ i - m ];
- i++;
- } while ( 0 < n-- );
- }
- }
- k += bsize;
- }
-}
-
-void CPlucker::home()
-{
- currentpos = 0;
- expand(1);
-}
-
-CList<Bkmk>* CPlucker::getbkmklist()
-{
-/*
- CPlucker_dataRecord thisHdr;
-
- for (int i = 1; i < ntohs(head.recordList.numRecords); i++)
- {
- gotorecordnumber(i);
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- if (thisHdr.type == 8)
- {
- UInt16 n;
- fread(&n, 1, sizeof(n), fin);
- n = ntohs(n);
- qDebug("Found %u bookmarks", n);
- }
- qDebug("Found:%d, %u", i , thisHdr.type);
- }
-*/
- return NULL;
-}
-
-QImage* CPlucker::getimg(UInt16 tgt)
-{
-// static int imageno;
-// char* file = "tmp1";
-// sprintf(file, "image%04u.tbmp", imageno++);
-// qDebug("Image:%u", tgt);
- CPlucker_dataRecord thisHdr;
- size_t reclen;
- UInt16 thisrec = finduid(tgt);
- reclen = recordlength(thisrec);
- gotorecordnumber(thisrec);
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
-/*
- UInt16 thisrec = 0;
- do
- {
- hthisrec++;
- reclen = recordlength(thisrec);
- gotorecordnumber(thisrec);
-// qDebug("thisrec:%u.%u", ftell(fin),thisrec);
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- }
- while (ntohs(thisHdr.uid) != tgt);
-*/
- reclen -= sizeof(thisHdr);
-
- UInt16 imgsize = ntohs(thisHdr.size);
- UInt8* imgbuffer = new UInt8[imgsize];
-
-// qDebug("type:%u", thisHdr.type);
- Expand(reclen, thisHdr.type, imgbuffer, imgsize);
-
QImage* qimage = Palm2QImage(imgbuffer, imgsize);
-
delete [] imgbuffer;
-
return qimage;
}
-
-#include <qnamespace.h>
-
-QPixmap* CPlucker::expandimg(UInt16 tgt, bool border)
-{
- QImage* qimage = getimg(tgt);
- if (qimage == NULL) return NULL;
- QPixmap* image = new QPixmap(0,0);
- QPixmap* ret;
-// qDebug("New image");
- image->convertFromImage(*qimage);
- delete qimage;
- if (border)
- {
- ret = new QPixmap(image->width()+4, image->height()+4);
- ret->fill(Qt::red);
- bitBlt(ret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP);
- delete image;
- }
- else
- {
- ret = image;
- }
- return ret;
-}
-
-#ifdef _BUFFERPICS
-#include <qmap.h>
-#endif
-
-QPixmap* CPlucker::getPicture(unsigned long tgt)
-{
-#ifdef _BUFFERPICS
- static QMap<unsigned long, QPixmap> pix;
- QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt);
- if (t == pix.end())
- {
- pix[tgt] = *expandimg(tgt);
- return &pix[tgt];
- }
- else
- return &(t.data());
-#else
- return expandimg(tgt);
-#endif
-}
-
-#ifdef LOCALPICTURES
-#include <unistd.h>
-#include <qpe/global.h>
-void CPlucker::showimg(UInt16 tgt)
-{
- qDebug("Crassssssh!");
- QPixmap* qimage = expandimg(tgt);
- m_picture->setFixedSize(qimage->size());
- m_picture->setBackgroundPixmap(*qimage);
- delete qimage;
- m_viewer->show();
-
-/*
- char tmp[] = "uqtreader.XXXXXX";
- QImage* qimage = getimg(tgt);
- QPixmap* image = new QPixmap(0,0);
-// qDebug("New image");
- image->convertFromImage(*qimage);
- delete qimage;
- char tmpfile[sizeof(tmp)+1];
- strcpy(tmpfile,tmp);
- int f = mkstemp(tmpfile);
- close(f);
- qDebug("TMPFILE:%s", tmpfile);
- if (image->save(tmpfile,"PNG"))
- {
- QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)");
- e << QString(tmpfile);
- }
- Global::statusMessage("Opening image");
- sleep(5);
- delete image;
- unlink(tmpfile);
-*/
-}
-
-#endif
-
-void CPlucker::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
-{
- unsigned short sz = 0;
- for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++)
- {
- sz++;
- }
- size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long);
- unsigned char* newdata = new unsigned char[newlen];
- unsigned char* pdata = newdata;
- memcpy(newdata, src, srclen);
- newdata += srclen;
- memcpy(newdata, &sz, sizeof(sz));
- newdata += sizeof(sz);
- for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++)
- {
- unsigned long t = *it;
- qDebug("[%u]", t);
- memcpy(newdata, &t, sizeof(t));
- newdata += sizeof(t);
- }
- m_nav.setSaveData(data, len, pdata, newlen);
- delete [] pdata;
-}
-
-void CPlucker::putSaveData(unsigned char*& src, unsigned short& srclen)
-{
- unsigned short sz;
- if (srclen >= sizeof(sz))
- {
- memcpy(&sz, src, sizeof(sz));
- src += sizeof(sz);
- srclen -= sizeof(sz);
- }
- for (int i = 0; i < sz; i++)
- {
- unsigned long t;
- if (srclen >= sizeof(t))
- {
- memcpy(&t, src, sizeof(t));
- qDebug("[%u]", t);
- visited.push_front(t);
- src += sizeof(t);
- srclen -= sizeof(t);
- }
- else
- {
- QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself");
- break;
- }
- }
- m_nav.putSaveData(src, srclen);
-}
-
-unsigned short CPlucker::finduid(unsigned short urlid)
-{
-// qDebug("Finding %u", urlid);
- unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords);
- unsigned short jmid = (jmin+jmax) >> 1;
- while (jmax - jmin > 1)
- {
- CPlucker_dataRecord thisHdr;
- gotorecordnumber(jmid);
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- unsigned short luid = ntohs(thisHdr.uid);
-// qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid);
- if (luid == urlid)
- {
- return jmid;
- }
- if (luid < urlid)
- {
- jmin = jmid;
- }
- else
- {
- jmax = jmid;
- }
- jmid = (jmin+jmax) >> 1;
- }
- CPlucker_dataRecord thisHdr;
- gotorecordnumber(jmin);
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- unsigned short luid = ntohs(thisHdr.uid);
- qDebug("jmin at end:%u,%u", jmin, luid);
- if (luid == urlid)
- {
- return jmin;
- }
- gotorecordnumber(jmax);
- fread(&thisHdr, 1, sizeof(thisHdr), fin);
- luid = ntohs(thisHdr.uid);
- qDebug("jmax at end:%u,%u", jmax, luid);
- if (luid == urlid)
- {
- return jmax;
- }
- qDebug("Couldn't find %u", urlid);
- return 0; // Not found!
-}
diff --git a/noncore/apps/opie-reader/plucker.h b/noncore/apps/opie-reader/plucker.h
index 083eac6..6d62195 100644
--- a/noncore/apps/opie-reader/plucker.h
+++ b/noncore/apps/opie-reader/plucker.h
@@ -1,123 +1,36 @@
#ifndef __plucker_h
#define __plucker_h
-#include "CExpander.h"
-#include "zlib/zlib.h"
-#include "ztxt.h"
-#include "pdb.h"
-#include "CBuffer.h"
-#include "Navigation.h"
-#include "my_list.h"
+#include "plucker_base.h"
#ifdef LOCALPICTURES
class QScrollView;
class QWidget;
#endif
-struct CPlucker_dataRecord
+class CPlucker : public CPlucker_base
{
- UInt16 uid;
- UInt16 nParagraphs;
- UInt16 size;
- UInt8 type;
- UInt8 reserved;
-};
-
-struct CPlucker_record0
-{
- UInt16 uid;
- UInt16 version;
- UInt16 nRecords;
-};
+ void start2endSection()
+ {
+ m_currentstart = currentpos-bufferpos;
+ m_currentend = m_currentstart+buffercontent;
+ }
+ void setbuffersize()
+ {
+ compressedbuffersize = buffersize = 32*1024;
+ }
+ int HeaderSize();
+ void GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved);
+ int bgetch();
+ tchar getch(bool fast);
+ UInt8 EOPPhase;
-struct CPluckerbkmk
-{
- UInt32 offset;
- tchar title[MAX_BMRK_LENGTH];
-};
-const UInt32 CPLUCKER_ID = 0x5458547a;
-class CPlucker : public CExpander, Cpdb
-{
- unsigned short finduid(unsigned short);
- char* geturl(UInt16);
- void Expand(UInt16, UInt8, UInt8*, UInt16);
- CList<unsigned long> visited;
- bool m_lastIsBreak;
-#ifdef LOCALPICTURES
- QScrollView* m_viewer;
- QWidget* m_picture;
-#endif
- size_t textlength, m_lastBreak;
- UInt16 uid;
- UInt8 EOPPhase;
- int m_nextPara, m_nextParaIndex;
- CBufferFace<UInt16> m_ParaOffsets;
- CBufferFace<UInt16> m_ParaAttrs;
- UInt16 m_nParas;
- CStyle mystyle;
-// bool bInit;
- UInt32 buffersize;
- UInt32 buffercontent;
- UInt8* expandedtextbuffer;
- UInt8* compressedtextbuffer;
- char* urls;
- size_t urlsize;
- size_t bufferpos;
- UInt16 bufferrec;
- CPlucker_record0 hdr0;
- size_t currentpos;
- bool expand(int);
- void UnZip(size_t, UInt8*, UInt16);
- void UnDoc(size_t, UInt8*, UInt16);
-#ifdef LOCALPICTURES
- void showimg(UInt16 tgt);
-#endif
- QImage* getimg(UInt16 tgt);
- QPixmap* expandimg(UInt16 tgt, bool border=false);
- void home();
- int bgetch();
- CNavigation m_nav;
+ bool CorrectDecoder(); // Virtual
+ void setlink(QString&, const QString&); // Virtual
+ QImage* imagefromdata(UInt8*, UInt32); // virtual
public:
- virtual void suspend()
- {
- CExpander::suspend(fin);
- }
- virtual void unsuspend()
- {
- CExpander::unsuspend(fin);
- }
- virtual QPixmap* getPicture(unsigned long tgt);
- virtual void sizes(unsigned long& _file, unsigned long& _text);
- virtual bool hasrandomaccess() { return true; }
- virtual ~CPlucker();
CPlucker();
- virtual int OpenFile(const char *src);
- virtual int getch();
- virtual void getch(int&, CStyle&);
- virtual unsigned int locate();
- virtual void locate(unsigned int n);
- virtual CList<Bkmk>* getbkmklist();
- virtual bool hyperlink(unsigned int n);
- virtual MarkupType PreferredMarkup()
- {
- return cNONE;
- }
- void saveposn(size_t posn) { m_nav.saveposn(posn); }
- bool forward(size_t& loc) { return m_nav.forward(loc); }
- bool back(size_t& loc) { return m_nav.back(loc); }
- bool hasnavigation() { return true; }
- unsigned long startSection()
- {
- return currentpos-bufferpos;
- }
- unsigned long endSection()
- {
- return startSection()+buffercontent;
- }
- void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen);
- void putSaveData(unsigned char*& src, unsigned short& srclen);
};
-
#endif
diff --git a/noncore/apps/opie-reader/ppm_expander.h b/noncore/apps/opie-reader/ppm_expander.h
index 4278c82..002de86 100644
--- a/noncore/apps/opie-reader/ppm_expander.h
+++ b/noncore/apps/opie-reader/ppm_expander.h
@@ -1,7 +1,8 @@
#ifndef __ppm_expander_h
#define __ppm_expander_h
-
+
+#include "useqpe.h"
#include "CExpander.h"
#include <sys/stat.h>
@@ -25,32 +26,34 @@ class ppm_expander : public CExpander {
FILE* my_file_in;
PPM_ReadBuf* my_read_buf;
ppm_worker ppm;
public:
- virtual void suspend()
+#ifdef USEQPE
+ void suspend()
{
CExpander::suspend(my_file_in);
}
- virtual void unsuspend()
+ void unsuspend()
{
CExpander::unsuspend(my_file_in);
- }
+ }
+#endif
ppm_expander() : needppmend(false), my_file_in(NULL), my_read_buf(NULL)
{
bufsize = 1024;
buf_in = new UCHAR[bufsize];
buf_out = new UCHAR[bufsize];
outbytes = 0;
}
- virtual int OpenFile(const char* infile);
- virtual int getch();
+ int OpenFile(const char* infile);
+ int getch();
int locate(unsigned short block, unsigned int n);
virtual ~ppm_expander();
- virtual unsigned int locate() { return outbytes; }
- virtual void locate(unsigned int n);
- virtual bool hasrandomaccess() { return (numblocks > 1); }
- virtual void sizes(unsigned long& file, unsigned long& text);
- virtual MarkupType PreferredMarkup()
+ unsigned int locate() { return outbytes; }
+ void locate(unsigned int n);
+ bool hasrandomaccess() { return (numblocks > 1); }
+ void sizes(unsigned long& file, unsigned long& text);
+ MarkupType PreferredMarkup()
{
return cTEXT;
}
};
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
@@ -59,9 +59,19 @@ inline QString toQString(tchar *_p, unsigned int len)
if (_p == NULL) return 0;
unsigned int i = 0;
tchar *p = _p;
QString ret;
+#ifdef _WINDOWS
+// ret.fill(' ', len);
+ for (i = 0; i < len; i++)
+ {
+ if (p[i] == 0) break;
+ ret.at((uint)i) = p[i];
+ }
+// while (*p != 0 && i < len) ret.at((uint)i++) = (tchar)(*(p++));
+#else
while (*p != 0 && i < len) ret[i++] = *(p++);
+#endif
return ret;
}
inline tchar* fromQString(const QString& qs)
diff --git a/noncore/apps/opie-reader/version.h b/noncore/apps/opie-reader/version.h
index 003e9db..85d35a4 100644
--- a/noncore/apps/opie-reader/version.h
+++ b/noncore/apps/opie-reader/version.h
@@ -1,5 +1,9 @@
+#ifndef __VERSION_H
+#define __VERSION_H
#define MAJOR 0
#define BKMKTYPE 6
-#define MINOR 'a'
+#define MINOR 'j'
#define RELEASE_TYPE "beta"
+
+#endif
diff --git a/noncore/apps/opie-reader/ztxt.h b/noncore/apps/opie-reader/ztxt.h
index d7cb96a..709a055 100644
--- a/noncore/apps/opie-reader/ztxt.h
+++ b/noncore/apps/opie-reader/ztxt.h
@@ -1,10 +1,15 @@
#ifndef __ztxt_h
#define __ztxt_h
+#include "useqpe.h"
#include "CExpander.h"
-#include "zlib/zlib.h"
+#include <zlib.h>
#include "pdb.h"
+#ifdef _WINDOWS
+#include <winsock.h>
+#endif
+
/*
* Stuff common to both Weasel Reader and makeztxt
*
* $Id$
@@ -74,22 +79,24 @@ class ztxt : public CExpander, Cpdb
zTXT_record0 hdr0;
size_t currentpos;
void home();
public:
- virtual void suspend()
+#ifdef USEQPE
+ void suspend()
{
CExpander::suspend(fin);
}
- virtual void unsuspend()
+ void unsuspend()
{
CExpander::unsuspend(fin);
- }
- virtual void sizes(unsigned long& _file, unsigned long& _text)
+ }
+#endif
+ void sizes(unsigned long& _file, unsigned long& _text)
{
_file = file_length;
_text = ntohl(hdr0.size);
}
- virtual bool hasrandomaccess() { return (hdr0.randomAccess != 0); }
+ bool hasrandomaccess() { return (hdr0.randomAccess != 0); }
virtual ~ztxt()
{
if (expandedtextbuffer != NULL) delete [] expandedtextbuffer;
if (compressedtextbuffer != NULL) delete [] compressedtextbuffer;
@@ -98,14 +105,14 @@ public:
inflateEnd(&zstream);
}
}
ztxt();
- virtual int OpenFile(const char *src);
- virtual int getch();
- virtual unsigned int locate();
- virtual void locate(unsigned int n);
- virtual CList<Bkmk>* getbkmklist();
- virtual MarkupType PreferredMarkup()
+ int OpenFile(const char *src);
+ int getch();
+ unsigned int locate();
+ void locate(unsigned int n);
+ CList<Bkmk>* getbkmklist();
+ MarkupType PreferredMarkup()
{
return cTEXT;
}
};