summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/QTReaderApp.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-reader/QTReaderApp.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp811
1 files changed, 694 insertions, 117 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index 8726df7..2044b1d 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -23,3 +23,6 @@
#include <qpe/qpemenubar.h>
-#include <qpe/qpetoolbar.h>
+//#include <qpe/qpetoolbar.h>
+#include <qmenubar.h>
+#include <qtoolbar.h>
+#include <qpe/menubutton.h>
#include <qpe/fontdatabase.h>
@@ -44,2 +47,3 @@
#include "QTReader.h"
+#include "GraphicWin.h"
#include "Bkmks.h"
@@ -57,2 +61,12 @@
#include "CDrawBuffer.h"
+#include "Filedata.h"
+#include "opie.h"
+#include "name.h"
+#include "StateData.h"
+
+#ifdef OPIE
+#define PICDIR "opie-reader/"
+#else
+#define PICDIR
+#endif
@@ -70,5 +84,6 @@ void QTReaderApp::listBkmkFiles()
bkmkselector->clear();
+ bkmkselector->setText("Cancel");
int cnt = 0;
DIR *d;
- d = opendir((const char *)Global::applicationFileName("uqtreader",""));
+ d = opendir((const char *)Global::applicationFileName(APPDIR,""));
@@ -81,3 +96,3 @@ void QTReaderApp::listBkmkFiles()
- if (lstat((const char *)Global::applicationFileName("uqtreader",de->d_name),&buf) == 0 && S_ISREG(buf.st_mode))
+ if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode))
{
@@ -95,4 +110,12 @@ void QTReaderApp::listBkmkFiles()
if (m_fontVisible) m_fontBar->hide();
- if (regVisible) regBar->hide();
- if (searchVisible) searchBar->hide();
+ if (regVisible)
+ {
+ Global::hideInputMethod();
+ regBar->hide();
+ }
+ if (searchVisible)
+ {
+ Global::hideInputMethod();
+ searchBar->hide();
+ }
m_nRegAction = cRmBkmkFile;
@@ -101,3 +124,3 @@ void QTReaderApp::listBkmkFiles()
else
- QMessageBox::information(this, "OpieReader", "No bookmark files");
+ QMessageBox::information(this, PROGNAME, "No bookmark files");
}
@@ -111,3 +134,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
pBkmklist = NULL;
- doc = 0;
+ pOpenlist = NULL;
+// doc = 0;
@@ -120,5 +144,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
- setIcon( Resource::loadPixmap( "opie-reader/uqtreader" ) );
+ setIcon( Resource::loadPixmap( "uqtreader" ) );
- QPEToolBar *bar = new QPEToolBar( this );
+// QPEToolBar *bar = new QPEToolBar( this );
+ QToolBar *bar = new QToolBar( this );
bar->setHorizontalStretchable( TRUE );
@@ -128,2 +153,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
QPEMenuBar *mb = new QPEMenuBar( bar );
+// QMenuBar *mb = new QMenuBar( bar );
QPopupMenu *file = new QPopupMenu( this );
@@ -161,2 +187,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
+ m_graphicwin = new GraphicWin(editorStack);
+ editorStack->addWidget(m_graphicwin, get_unique_id());
+ connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) );
+
// bkmkselector = new QListBox(editorStack, "Bookmarks");
@@ -177,2 +207,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
*/
+ qDebug("Reading file list");
+ readfilelist();
@@ -180,5 +212,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
+ reader->bDoUpdates = false;
+
((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold);
- Config config( "uqtreader" );
+ qDebug("Reading config");
+ Config config( APPDIR );
config.setGroup( "View" );
@@ -191,2 +226,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
reader->bdehyphen = config.readBoolEntry( "Dehyphen", false );
+ reader->bonespace = config.readBoolEntry( "OneSpace", false );
reader->bunindent = config.readBoolEntry( "Unindent", false );
@@ -200,2 +236,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
reader->m_bpagemode = config.readBoolEntry( "PageMode", true );
+ reader->m_navkeys = config.readBoolEntry( "CursorNavigation", false );
reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false);
@@ -205,4 +242,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
reader->m_overlap = config.readNumEntry( "Overlap", 0 );
+#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 );
@@ -217,2 +258,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
+ connect( reader, SIGNAL( OnShowPicture(QPixmap&) ), this, SLOT( showgraphic(QPixmap&) ) );
+
connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) );
@@ -227,2 +270,7 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
+ 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 );
+
/*
@@ -252,2 +300,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
+ m_buttonAction[3] = new QAction( tr( "Fullscreen" ), QString::null, 0, ag, NULL, true );
+
ag->addTo(spacemenu);
@@ -256,10 +306,30 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
+ file->insertSeparator();
+
+ ag = new QActionGroup(this);
+ ag->setExclusive(false);
+ QPopupMenu *encoding = new QPopupMenu(this);
+ file->insertItem( tr( "Navigation" ), encoding );
+
+ a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( PICDIR "panel-arrow-down" ), QString::null, 0, ag, 0, true );
- a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( "opie-reader/panel-arrow-down" ), QString::null, 0, this, 0, true );
-// connect( a, SIGNAL( activated() ), this, SLOT( autoScroll() ) );
a->setOn(false);
connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) );
- file->insertSeparator();
a->addTo( bar );
- a->addTo( file );
+
+ a = new QAction( tr( "Jump" ), QString::null, 0, ag, NULL);
+ connect( a, SIGNAL( activated() ), this, SLOT( jump() ) );
+
+ 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);
+
+ a = new QAction( tr( "Set Overlap" ), QString::null, 0, ag, NULL);
+ connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) );
+
+ 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);
+
+ ag->addTo(encoding);
@@ -274,14 +344,2 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
*/
- a = new QAction( tr( "Jump" ), QString::null, 0, this, NULL);
- connect( a, SIGNAL( activated() ), this, SLOT( jump() ) );
- a->addTo( file );
-
- a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, this, NULL, true );
- connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) );
- a->setOn(reader->m_bpagemode);
- a->addTo( file );
-
- a = new QAction( tr( "Set Overlap" ), QString::null, 0, this, NULL);
- connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) );
- a->addTo( file );
@@ -300,3 +358,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
ag->setExclusive(false);
- QPopupMenu *encoding = new QPopupMenu(this);
+ encoding = new QPopupMenu(this);
file->insertItem( tr( "Target" ), encoding );
@@ -347,2 +405,13 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
+ 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 );
@@ -397,2 +466,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
+ 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 );
@@ -418,3 +491,7 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 );
@@ -431,7 +508,11 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
// a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
- a = new QAction( tr( "Zoom" ), QString::null, 0, this);
- connect( a, SIGNAL( activated() ), this, SLOT( TBDzoom() ) );
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();
@@ -441,3 +522,2 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
a->setOn(reader->m_bMonoSpaced);
- format->insertSeparator();
a->addTo( format );
@@ -581,2 +661,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
+ qDebug("Font selector");
m_fontSelector = new QComboBox(false, m_fontBar);
@@ -594,4 +675,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
realfont = true;
- break;
}
+ if (*nm == "courier") reader->m_fontControl.hasCourier(true);
}
@@ -609,13 +690,61 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
-
+ qDebug("Initing");
reader->init();
+ qDebug("Inited");
+ m_EncodingAction[reader->m_encd]->setOn(true);
+ m_buttonAction[m_spaceTarget]->setOn(true);
+ qDebug("fonting");
+ do_setfont(reader->m_fontname);
if (!reader->m_lastfile.isEmpty())
{
+ qDebug("doclnk");
+// doc = new DocLnk(reader->m_lastfile);
+ qDebug("doclnk done");
+ if (pOpenlist != NULL)
+ {
+
+/*
+ int ind = 0;
+ Bkmk* p = (*pOpenlist)[ind];
+ while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
+ {
+ p = (*pOpenlist)[++ind];
+ }
+*/
+ Bkmk* p = NULL;
+ for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++)
+ {
+ p = iter.pContent();
+ if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile)
+ {
+ break;
+ }
+ qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name()));
+ p = NULL;
+ }
+ if (p != NULL)
+ {
+ qDebug("openfrombkmk");
+ openfrombkmk(p);
+ }
+ else
+ {
+ qDebug("openfile");
openFile( reader->m_lastfile );
- doc = new DocLnk(reader->m_lastfile);
}
- m_EncodingAction[reader->m_encd]->setOn(true);
- m_buttonAction[m_spaceTarget]->setOn(true);
- do_setfont(reader->m_fontname);
}
+ else
+ {
+ qDebug("Openfile 2");
+ if (!reader->m_lastfile.isNull())
+ openFile( reader->m_lastfile );
+ }
+ }
+ qApp->processEvents();
+ reader->bDoUpdates = true;
+ reader->update();
+ qDebug("finished update");
+}
+
+void QTReaderApp::suspend() { reader->suspend(); }
@@ -632,3 +761,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
stream >> info;
- QMessageBox::information(this, "OpieReader", info);
+ QMessageBox::information(this, PROGNAME, info);
}
@@ -638,3 +767,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
stream >> info;
- QMessageBox::warning(this, "OpieReader", info);
+ QMessageBox::warning(this, PROGNAME, info);
}
@@ -753,3 +882,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
{
- QMessageBox::information(this, "OpieReader", QString("Can't find\n")+info);
+ QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info);
pos = start;
@@ -766,2 +895,16 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
}
+ else if ( msg == "Layout/Single Space" )
+ {
+ int info;
+ stream >> info;
+ onespace(info);
+ }
+#ifdef REPALM
+ else if ( msg == "Layout/Repalm(int)" )
+ {
+ int info;
+ stream >> info;
+ repalm(info);
+ }
+#endif
else if ( msg == "Markup/Auto(int)" )
@@ -878,2 +1021,18 @@ ActionTypes QTReaderApp::ActNameToInt(const QString& _enc)
+void QTReaderApp::setfullscreen(bool sfs)
+{
+ reader->bDoUpdates = false;
+ m_fullscreen = sfs;
+ showEditTools();
+ qApp->processEvents();
+ reader->bDoUpdates = true;
+ reader->update();
+}
+
+void QTReaderApp::setcontinuous(bool sfs)
+{
+ reader->setContinuous(sfs);
+ reader->refresh();
+}
+
int QTReaderApp::EncNameToInt(const QString& _enc)
@@ -912,12 +1071,13 @@ void QTReaderApp::autoScroll(bool _b)
reader->setautoscroll(_b);
+ setScrollState(reader->m_autoScroll);
}
-void QTReaderApp::TBD()
+void QTReaderApp::zoomin()
{
- QMessageBox::information(this, "OpieReader", "Not yet implemented", 1);
+ reader->zoomin();
}
-void QTReaderApp::TBDzoom()
+void QTReaderApp::zoomout()
{
- QMessageBox::information(this, "OpieReader", "Zooming is done interactively\nTry left/right cursor keys", 1);
+ reader->zoomout();
}
@@ -931,2 +1091,74 @@ void QTReaderApp::clearBkmkList()
+void QTReaderApp::fileClose()
+{
+ if (pOpenlist != NULL)
+ {
+ 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 ))
+ {
+ case 0:
+ default:
+ break;
+ case 2:
+ unlink((const char*)reader->m_lastfile);
+ case 1:
+ unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string));
+ }
+ }
+
+ fileOpen2();
+}
+
+void QTReaderApp::updatefileinfo()
+{
+ if (reader->m_string.isNull()) return;
+ if (reader->m_lastfile.isNull()) return;
+ tchar* nm = fromQString(reader->m_string);
+ tchar* fl = fromQString(reader->m_lastfile);
+ qDebug("Lastfile:%x", fl);
+ bool notadded = true;
+ if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>;
+ else
+ {
+ for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++)
+ {
+ if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0)
+ {
+ iter->value(reader->pagelocate());
+ 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);
+// getstate(data, dlen);
+ iter->setAnno(data, dlen);
+ notadded = false;
+ delete [] data;
+ break;
+ }
+ }
+ }
+ qDebug("Added?:%x", notadded);
+ if (notadded)
+ {
+ struct stat fnstat;
+ stat((const char *)reader->m_lastfile, &fnstat);
+ CFiledata fd(fnstat.st_mtime, fl);
+ 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);
+ delete [] data;
+ }
+ delete [] nm;
+ delete [] fl;
+}
+
void QTReaderApp::fileOpen()
@@ -939,2 +1171,10 @@ void QTReaderApp::fileOpen()
*/
+ qDebug("fileOpen");
+// if (!reader->m_lastfile.isEmpty())
+ updatefileinfo();
+ fileOpen2();
+}
+
+void QTReaderApp::fileOpen2()
+{
if (pBkmklist != NULL)
@@ -943,3 +1183,3 @@ void QTReaderApp::fileOpen()
{
- if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0)
+ if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
savebkmks();
@@ -955,3 +1195,21 @@ void QTReaderApp::fileOpen()
*/
- fileBrowser* fb = new fileBrowser(this,"OpieReader",TRUE,
+ if (pOpenlist != NULL)
+ {
+ m_nRegAction = cOpenFile;
+ listbkmk(pOpenlist, "Browse");
+ }
+ else
+ {
+ QString fn = usefilebrowser();
+ if (!fn.isEmpty() && QFileInfo(fn).isFile())
+ {
+ openFile(fn);
+ }
+ reader->setFocus();
+ }
+}
+
+QString QTReaderApp::usefilebrowser()
+{
+ fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE,
0,
@@ -960,10 +1218,18 @@ void QTReaderApp::fileOpen()
+
+ QString fn;
if (fb->exec())
{
- QString fn(fb->fileList[0]);
-// fb->populateList();
- if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn);
+ fn = fb->fileList[0];
}
+ qDebug("Selected %s", (const char*)fn);
delete fb;
- reader->setFocus();
+ return fn;
+}
+
+void QTReaderApp::showgraphic(QPixmap& pm)
+{
+ m_graphicwin->setPixmap(pm);
+ editorStack->raiseWidget( m_graphicwin );
+ m_graphicwin->setFocus();
}
@@ -975,3 +1241,3 @@ void QTReaderApp::showinfo()
{
- QMessageBox::information(this, "OpieReader", "No file loaded", 1);
+ QMessageBox::information(this, PROGNAME, "No file loaded", 1);
}
@@ -1022,3 +1288,3 @@ void QTReaderApp::addAnno(const QString& name, const QString& text)
{
- QMessageBox::information(this, "OpieReader", "Need a name for the bookmark\nPlease try again", 1);
+ QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1);
}
@@ -1079,3 +1345,3 @@ void QTReaderApp::addanno()
{
- QMessageBox::information(this, "OpieReader", "No file loaded", 1);
+ QMessageBox::information(this, PROGNAME, "No file loaded", 1);
}
@@ -1088,2 +1354,3 @@ void QTReaderApp::addanno()
editorStack->raiseWidget( m_annoWin );
+ Global::showInputMethod();
m_annoWin->setFocus();
@@ -1134,3 +1401,3 @@ void QTReaderApp::pageup()
{
- reader->goUp();
+ reader->NavUp();
}
@@ -1139,3 +1406,3 @@ void QTReaderApp::pagedn()
{
- reader->goDown();
+ reader->NavDown();
}
@@ -1146,2 +1413,12 @@ void QTReaderApp::stripcr(bool _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)
@@ -1190,3 +1467,6 @@ void QTReaderApp::pagemode(bool _b)
}
-
+void QTReaderApp::navkeys(bool _b)
+{
+ reader->m_navkeys = _b;
+}
void QTReaderApp::monospace(bool _b)
@@ -1233,3 +1513,3 @@ void QTReaderApp::do_overlap(const QString& lcn)
else
- QMessageBox::information(this, "OpieReader", "Must be a number");
+ QMessageBox::information(this, PROGNAME, "Must be a number");
}
@@ -1248,3 +1528,3 @@ void QTReaderApp::do_mono(const QString& lcn)
else
- QMessageBox::information(this, "OpieReader", "Must be a number");
+ QMessageBox::information(this, PROGNAME, "Must be a number");
}
@@ -1266,2 +1546,3 @@ void QTReaderApp::editFind()
#endif
+ Global::showInputMethod();
searchBar->show();
@@ -1293,2 +1574,3 @@ void QTReaderApp::findClose()
searchEdit->setText("");
+ Global::hideInputMethod();
searchBar->hide();
@@ -1310,2 +1592,3 @@ void QTReaderApp::regClose()
regBar->hide();
+ Global::hideInputMethod();
reader->setFocus();
@@ -1320,4 +1603,13 @@ 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->show();
+ pbar->resize(width(), editBar->height());
+ pbar->reset();
+ int lastpc = (100*pos)/ts;
+ pbar->setProgress(lastpc);
+ qApp->processEvents();
+ reader->setFocus();
#ifdef __ISEARCH
@@ -1333,2 +1625,12 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
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;
+ }
+
if (!reader->buffdoc.getline(&test,reader->width()))
@@ -1344,2 +1646,3 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
}
+ pbar->hide();
reader->locate(pos);
@@ -1390,10 +1693,11 @@ void QTReaderApp::openFile( const QString &f )
{
- openFile(DocLnk(f));
-}
-
-void QTReaderApp::openFile( const DocLnk &f )
-{
+ qDebug("File:%s", (const char*)f);
+// openFile(DocLnk(f));
+//}
+//
+//void QTReaderApp::openFile( const DocLnk &f )
+//{
clear();
- FileManager fm;
- if ( fm.exists( f ) )
+ QFileInfo fm(f);
+ if ( fm.exists() )
{
@@ -1401,17 +1705,14 @@ void QTReaderApp::openFile( const DocLnk &f )
- clear();
-
- // editorStack->raiseWidget( reader );
-
- // reader->setFocus();
+ if (fm.extension( FALSE ) == "desktop")
+ {
+ DocLnk d(f);
+ QFileInfo fnew(d.file());
+ fm = fnew;
+ if (!fm.exists()) return;
+ }
- // QMessageBox::information(0, "DocLnk", "Begin");
- doc = new DocLnk(f);
- // QMessageBox::information(0, "DocLnk done", doc->file());
- // QMessageBox::information(0, "Progress", "Calling setText()");
- // QMessageBox::information(0, "Progress", "Textset");
+ clear();
- // updateCaption();
+ reader->setText(fm.baseName(), fm.absFilePath());
showEditTools();
- reader->setText(doc->name(), doc->file());
readbkmks();
@@ -1420,3 +1721,3 @@ void QTReaderApp::openFile( const DocLnk &f )
{
- QMessageBox::information(this, "OpieReader", "File does not exist");
+ QMessageBox::information(this, PROGNAME, "File does not exist");
}
@@ -1424,2 +1725,44 @@ void QTReaderApp::openFile( const DocLnk &f )
}
+/*
+void QTReaderApp::resizeEvent(QResizeEvent* e)
+{
+ if (m_fullscreen)
+ {
+ showNormal();
+ showFullScreen();
+ }
+}
+*/
+void QTReaderApp::keyPressEvent(QKeyEvent* e)
+{
+ if (m_fullscreen)
+ {
+ switch(e->key())
+ {
+ case Key_Escape:
+ m_actFullscreen->setOn(false);
+ if (m_fullscreen)
+ {
+ qDebug("Fullscreen already set - remove this!");
+ }
+ else
+ {
+ m_fullscreen = false;
+ reader->bDoUpdates = false;
+ showEditTools();
+ qApp->processEvents();
+ reader->bDoUpdates = true;
+ reader->update();
+ }
+ e->accept();
+ break;
+ default:
+ e->ignore();
+ }
+ }
+ else
+ {
+ e->ignore();
+ }
+}
@@ -1427,15 +1770,43 @@ void QTReaderApp::showEditTools()
{
- if ( !doc )
- close();
-// fileSelector->hide();
-//tjw menu->show();
+// if ( !doc )
+// close();
+ if (m_fullscreen)
+ {
+ editBar->hide();
+ searchBar->hide();
+ regBar->hide();
+ Global::hideInputMethod();
+ m_fontBar->hide();
+// showNormal();
+ showFullScreen();
+ }
+ else
+ {
+ qDebug("him");
+ Global::hideInputMethod();
+ qDebug("eb");
editBar->show();
if ( searchVisible )
+ {
+ Global::showInputMethod();
searchBar->show();
+ }
if ( regVisible )
+ {
+ Global::showInputMethod();
regBar->show();
+ }
if (m_fontVisible) m_fontBar->show();
+ qDebug("sn");
+ showNormal();
+ qDebug("sm");
+ showMaximized();
+// setCentralWidget(reader);
+ }
+ qDebug("uc");
updateCaption();
+ qDebug("rw");
editorStack->raiseWidget( reader );
+ qDebug("sf");
reader->setFocus();
@@ -1475,9 +1846,9 @@ void QTReaderApp::clear()
{
- if (doc != 0)
- {
-// QMessageBox::information(this, "QTReader", "Deleting doc", 1);
- delete doc;
-// QMessageBox::information(this, "QTReader", "Deleted doc", 1);
- doc = 0;
- }
+// if (doc != 0)
+// {
+// QMessageBox::information(this, PROGNAME, "Deleting doc", 1);
+// delete doc;
+// QMessageBox::information(this, PROGNAME, "Deleted doc", 1);
+// doc = 0;
+ // }
reader->clear();
@@ -1487,10 +1858,10 @@ void QTReaderApp::updateCaption()
{
- if ( !doc )
- setCaption( tr("OpieReader") );
- else {
- QString s = doc->name();
- if ( s.isEmpty() )
- s = tr( "Unnamed" );
- setCaption( s + " - " + tr("OpieReader") );
- }
+// if ( !doc )
+// setCaption( tr("QTReader") );
+// else {
+// QString s = doc->name();
+// if ( s.isEmpty() )
+// s = tr( "Unnamed" );
+ setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) );
+// }
}
@@ -1501,3 +1872,3 @@ void QTReaderApp::setDocument(const QString& fileref)
//QMessageBox::information(0, "setDocument", fileref);
- openFile(DocLnk(fileref));
+ openFile(fileref);
// showEditTools();
@@ -1507,3 +1878,9 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
{
- if (m_dontSave)
+ if (m_fullscreen)
+ {
+ m_fullscreen = false;
+ showEditTools();
+ e->accept();
+ }
+ else if (m_dontSave)
{
@@ -1523,2 +1900,3 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
regBar->hide();
+ Global::hideInputMethod();
regVisible = false;
@@ -1529,2 +1907,3 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
searchBar->hide();
+ Global::hideInputMethod();
searchVisible = false;
@@ -1534,3 +1913,3 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
{
- if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0)
+ if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
savebkmks();
@@ -1541,2 +1920,3 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
bFromDocView = FALSE;
+ updatefileinfo();
saveprefs();
@@ -1554,3 +1934,3 @@ void QTReaderApp::do_gotomark()
m_nRegAction = cGotoBkmk;
- listbkmk();
+ listbkmk(pBkmklist);
}
@@ -1560,14 +1940,19 @@ void QTReaderApp::do_delmark()
m_nRegAction = cDelBkmk;
- listbkmk();
+ listbkmk(pBkmklist);
}
-void QTReaderApp::listbkmk()
+void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
{
bkmkselector->clear();
+ if (_lab.isNull())
+ bkmkselector->setText("Cancel");
+ else
+ bkmkselector->setText(_lab);
int cnt = 0;
- if (pBkmklist != NULL)
+ if (plist != NULL)
{
- for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++)
+ for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++)
{
#ifdef _UNICODE
+ qDebug("Item:%s", (const char*)toQString(i->name()));
bkmkselector->insertItem(toQString(i->name()));
@@ -1584,4 +1969,12 @@ void QTReaderApp::listbkmk()
if (m_fontVisible) m_fontBar->hide();
- if (regVisible) regBar->hide();
- if (searchVisible) searchBar->hide();
+ if (regVisible)
+ {
+ Global::hideInputMethod();
+ regBar->hide();
+ }
+ if (searchVisible)
+ {
+ Global::hideInputMethod();
+ searchBar->hide();
+ }
editorStack->raiseWidget( bkmkselector );
@@ -1589,3 +1982,3 @@ void QTReaderApp::listbkmk()
else
- QMessageBox::information(this, "OpieReader", "No bookmarks in memory");
+ QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
}
@@ -1602,5 +1995,53 @@ void QTReaderApp::do_regedit()
// editBar->hide();
+ reader->bDoUpdates = false;
+ qDebug("Showing regbar");
regBar->show();
+ qDebug("Showing kbd");
+ Global::showInputMethod();
regVisible = true;
regEdit->setFocus();
+ qApp->processEvents();
+ reader->bDoUpdates = true;
+ reader->update();
+}
+
+bool QTReaderApp::openfrombkmk(Bkmk* bk)
+{
+ QString fn = toQString(
+ CFiledata(bk->anno()).name()
+ );
+ qDebug("fileinfo");
+ if (!fn.isEmpty() && QFileInfo(fn).isFile())
+ {
+ qDebug("Opening");
+ openFile(fn);
+ struct stat fnstat;
+ stat((const char *)reader->m_lastfile, &fnstat);
+
+ if (CFiledata(bk->anno()).date()
+ != fnstat.st_mtime)
+ {
+ CFiledata fd(bk->anno());
+ fd.setdate(fnstat.st_mtime);
+ bk->value(0);
+ }
+ else
+ {
+ unsigned short svlen = bk->filedatalen();
+ unsigned char* svdata = bk->filedata();
+ reader->putSaveData(svdata, svlen);
+// setstate(svdata, svlen);
+ if (svlen != 0)
+ {
+ QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?");
+ }
+ qDebug("updating");
+ reader->locate(bk->value());
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
@@ -1611,2 +2052,11 @@ void QTReaderApp::gotobkmk(int ind)
{
+ case cOpenFile:
+ {
+ if (!openfrombkmk((*pOpenlist)[ind]))
+ {
+ pOpenlist->erase(ind);
+ QMessageBox::information(this, PROGNAME, "Can't find file");
+ }
+ }
+ break;
case cGotoBkmk:
@@ -1621,3 +2071,3 @@ void QTReaderApp::gotobkmk(int ind)
case cRmBkmkFile:
- unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind)));
+ unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind)));
break;
@@ -1629,2 +2079,7 @@ void QTReaderApp::cancelbkmk()
{
+ if (m_nRegAction == cOpenFile)
+ {
+ QString fn = usefilebrowser();
+ if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn);
+ }
showEditTools();
@@ -1648,3 +2103,3 @@ void QTReaderApp::do_jump(const QString& lcn)
else
- QMessageBox::information(this, "OpieReader", "Must be a number");
+ QMessageBox::information(this, PROGNAME, "Must be a number");
}
@@ -1653,3 +2108,5 @@ void QTReaderApp::do_regaction()
{
+ reader->bDoUpdates = false;
regBar->hide();
+ Global::hideInputMethod();
regVisible = false;
@@ -1679,2 +2136,5 @@ void QTReaderApp::do_regaction()
reader->setFocus();
+ qApp->processEvents();
+ reader->bDoUpdates = true;
+ reader->update();
}
@@ -1688,3 +2148,3 @@ void QTReaderApp::do_settarget(const QString& _txt)
m_targetmsg = "";
- QMessageBox::information(this, "OpieReader", "Format is\nappname/messagename");
+ QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename");
}
@@ -1711,3 +2171,3 @@ void QTReaderApp::setfont()
-void QTReaderApp::setfontHelper(const QString& lcn, int size)
+void QTReaderApp::setfontHelper(const QString& lcn, int size = 0)
{
@@ -1715,11 +2175,18 @@ void QTReaderApp::setfontHelper(const QString& lcn, int size)
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 );
reader->m_fontname = lcn;
+ qDebug("cf1");
if (!reader->ChangeFont(size))
{
+ qDebug("cf2");
reader->ChangeFont(size);
}
+ qDebug("ref");
reader->refresh();
@@ -1727,3 +2194,5 @@ void QTReaderApp::setfontHelper(const QString& lcn, int size)
m_fontVisible = false;
- showEditTools();
+ qDebug("showedit");
+ if (reader->isVisible()) showEditTools();
+ qDebug("showeditdone");
}
@@ -1783,3 +2252,3 @@ void QTReaderApp::saveprefs()
// reader->saveprefs("uqtreader");
- Config config( "uqtreader" );
+ Config config( APPDIR );
config.setGroup( "View" );
@@ -1793,2 +2262,3 @@ void QTReaderApp::saveprefs()
config.writeEntry( "Dehyphen", reader->bdehyphen );
+ config.writeEntry( "OneSpace", reader->bonespace );
config.writeEntry( "Unindent", reader->bunindent );
@@ -1802,2 +2272,3 @@ void QTReaderApp::saveprefs()
config.writeEntry( "PageMode", reader->m_bpagemode );
+ config.writeEntry( "CursorNavigation", reader->m_navkeys );
config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced );
@@ -1814,2 +2285,5 @@ void QTReaderApp::saveprefs()
config.writeEntry( "SpaceTarget", m_spaceTarget);
+#ifdef REPALM
+ config.writeEntry( "Repalm", reader->brepalm );
+#endif
config.writeEntry( "Remap", reader->bremap );
@@ -1817,2 +2291,5 @@ void QTReaderApp::saveprefs()
config.writeEntry( "MakeBold", reader->bmakebold );
+ config.writeEntry( "Continuous", reader->m_continuousDocument );
+
+ savefilelist();
}
@@ -1889,3 +2366,3 @@ void QTReaderApp::savebkmks()
{
- BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string), true);
+ BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string), true);
bf.write(*pBkmklist);
@@ -1895,2 +2372,21 @@ void QTReaderApp::savebkmks()
+void QTReaderApp::readfilelist()
+{
+ BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"));
+ qDebug("Reading open files");
+ pOpenlist = bf.readall();
+ 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");
+ bf.write(*pOpenlist);
+ }
+}
+
void QTReaderApp::readbkmks()
@@ -1901,3 +2397,18 @@ void QTReaderApp::readbkmks()
}
- BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string));
+ struct stat fnstat;
+ struct stat bkstat;
+ if (
+ stat((const char *)reader->m_lastfile, &fnstat) == 0
+ &&
+ stat((const char *)Global::applicationFileName(APPDIR, reader->m_string), &bkstat) == 0
+ )
+ {
+ if (bkstat.st_mtime < fnstat.st_mtime)
+ {
+ unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string));
+ }
+ }
+
+ BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string));
+
pBkmklist = bf.readall();
@@ -1923,3 +2434,3 @@ void QTReaderApp::do_addbkmk(const QString& text)
{
- QMessageBox::information(this, "OpieReader", "Need a name for the bookmark\nSelect add again", 1);
+ QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1);
}
@@ -1959,2 +2470,3 @@ void QTReaderApp::showAnnotation()
m_annoIsEditing = false;
+ Global::showInputMethod();
editorStack->raiseWidget( m_annoWin );
@@ -1987,2 +2499,3 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString&
m_annoIsEditing = true;
+ Global::showInputMethod();
editorStack->raiseWidget( m_annoWin );
@@ -2019,2 +2532,7 @@ void QTReaderApp::OnActionPressed()
break;
+ case cesFullScreen:
+ {
+ m_actFullscreen->setOn(true);
+ }
+ break;
default:
@@ -2029 +2547,60 @@ 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;
+ memcpy(&sdlen, _sd, sizeof(sdlen));
+ sdlen -= sizeof(sdlen);
+ _sd += sizeof(sdlen);
+ statedata* sd;
+ char* data;
+ if (sdlen < sizeof(statedata)+1)
+ {
+ sdlen = sizeof(statedata)+1;
+ }
+ data = new char[sdlen];
+ sd = (statedata*)data;
+ memcpy(sd, _sd, sdlen);
+ data[sdlen] = 0;
+ reader->setstate(*sd);
+ delete [] data;
+}
+
+void QTReaderApp::getstate(unsigned char*& data, unsigned short& len)
+{
+ unsigned char* olddata = data;
+ unsigned short oldlen = len;
+ len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length();
+ data = new unsigned char[len];
+ memcpy(data, olddata, oldlen);
+ delete [] olddata;
+ memcpy(data+oldlen, &len, sizeof(len));
+ statedata* sd = (statedata*)(data+oldlen+sizeof(unsigned short));
+
+ sd->bstripcr = reader->bstripcr;
+ sd->btextfmt = reader->btextfmt;
+ sd->bautofmt = reader->bautofmt;
+ sd->bstriphtml = reader->bstriphtml;
+ sd->bpeanut = reader->bpeanut;
+ sd->bdehyphen = reader->bdehyphen;
+ 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;
+#ifdef REPALM
+ sd->brepalm = reader->brepalm;
+#endif
+ sd->bindenter = reader->bindenter;
+ sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize()
+ sd->m_encd = reader->m_encd;
+ sd->m_charpc = reader->m_charpc;
+ strcpy(sd->m_fontname, reader->m_fontname.latin1());
+}
+*/