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) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp246
1 files changed, 176 insertions, 70 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index 876b65a..6753698 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -14,12 +14,13 @@
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+
#include <qregexp.h>
#include <qclipboard.h>
#include <qwidgetstack.h>
#ifdef USEQPE
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
@@ -63,35 +64,40 @@
#include "CAnnoEdit.h"
#include "QFloatBar.h"
#include "FixedFont.h"
#include "URLDialog.h"
#include "util.h"
#include <qfontdatabase.h>
+
#ifdef USEQPE
#include <qpe/resource.h>
#ifdef OPIE
-//#include <qpe/applnk.h>
+#if defined(OPIEFILEDIALOG)
+#include <qpe/applnk.h>
#include <opie2/ofiledialog.h>
using namespace Opie::Ui;
#else
#include "fileBrowser.h"
#endif
#else
+#include "fileBrowser.h"
+#endif
+#else
#include "qfiledialog.h"
#endif
#include "QTReaderApp.h"
#include "CDrawBuffer.h"
#include "Filedata.h"
#include "names.h"
#include "CEncoding_tables.h"
#include "CloseDialog.h"
#include "ButtonPrefs.h"
-bool CheckVersion(int&, int&, char&);
+bool CheckVersion(int&, int&, char&, QWidget*);
#ifdef _WINDOWS
#define PICDIR "c:\\uqtreader\\pics\\"
#else
#ifdef USEQPE
#define USEMSGS
@@ -150,17 +156,15 @@ void QTReaderApp::listBkmkFiles()
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++;
+ bkmkselector->insertItem(fi->fileName(), cnt++);
//qDebug( "%10li %s", fi->size(), fi->fileName().data() );
++it; // goto next list element
}
#else /* USEQPE */
@@ -174,14 +178,13 @@ void QTReaderApp::listBkmkFiles()
struct stat buf;
de = readdir(d);
if (de == NULL) break;
if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode))
{
- bkmkselector->insertItem(de->d_name);
- cnt++;
+ bkmkselector->insertItem(de->d_name, cnt++);
}
}
closedir(d);
#endif
if (cnt > 0)
@@ -199,13 +202,13 @@ void QTReaderApp::listBkmkFiles()
void QTReaderApp::hidetoolbars()
{
if (m_scrollbar != NULL) m_scrollbar->hide();
if (m_prog != NULL) m_prog->hide();
-#ifdef USEQPE
+#if defined(USEQPE)
menubar->hide();
#endif
if (m_scrollbar != NULL) m_scrollbar->hide();
if (fileBar != NULL) fileBar->hide();
@@ -330,20 +333,20 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
// 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
+#if defined(USEQPE)
menubar = new QToolBar("Menus", this, m_tbposition);
mb = new QPEMenuBar( menubar );
#else
mb = new QMenuBar( this );
#endif
-#ifdef USEQPE
+#if defined(USEQPE)
QPopupMenu* tmp = new QPopupMenu(mb);
mb->insertItem( geticon( "AppsIcon" ), tmp );
#else
QMenuBar* tmp = mb;
#endif
@@ -433,12 +436,15 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold);
#endif
// qDebug("Reading config");
// Config config( APPDIR );
config.setGroup( "View" );
+#if defined(USEQPE) && defined(USENEWFULLSCREEN)
+ m_usenewfullscreen = config.readBoolEntry("NewFullScreen", false);
+#endif
m_debounce = config.readNumEntry("Debounce", 0);
m_buttonprefs->Debounce(m_debounce);
#ifdef USEQPE
m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false);
#else
m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true);
@@ -453,12 +459,13 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", 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->bNoInlineTables = config.readBoolEntry( "NoInlineTables", 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 );
@@ -468,12 +475,14 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
m_themename = config.readEntry("Theme", QString::null );
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);
reader->m_scrollstep = config.readNumEntry( "ScrollStep", 1);
+ reader->m_outputName = config.readEntry( "OutputCodec", "");
+
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_rotated = config.readBoolEntry( "IsRotated", false );
@@ -497,28 +506,32 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
reader->m_abstopmargin = config.readNumEntry( "Top Margin", 100 );
reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", 100 );
reader->m_absleft_border = config.readNumEntry( "Left Margin", 100 );
reader->m_absright_border = config.readNumEntry( "Right Margin", 100 );
m_scrollishidden = config.readBoolEntry( "HideScrollBar", false );
+ m_hidebars = config.readBoolEntry( "HideToolBar", false );
reader->brepalm = config.readBoolEntry( "Repalm", false );
+ reader->bunderlineLink = config.readBoolEntry( "UnderlineLink", true );
reader->bkern = config.readBoolEntry( "Kern", false );
reader->bremap = config.readBoolEntry( "Remap", true );
reader->bmakebold = config.readBoolEntry( "MakeBold", false );
reader->setContinuous(config.readBoolEntry( "Continuous", true ));
+ reader->setDoubleBuffer(config.readBoolEntry("DoubleBuffer", 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_doOutput = config.readBoolEntry( "OutputTgt", 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);
@@ -839,12 +852,24 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
m_bkmkAvail = NULL;
setToolBarsMovable(m_tbmove);
addtoolbars(&config);
+ if (m_hidebars)
+ {
+#if defined(USEQPE)
+ menubar->hide();
+#endif
+ if (fileBar != NULL) fileBar->hide();
+ if (viewBar != NULL) viewBar->hide();
+ if (navBar != NULL) navBar->hide();
+ if (markBar != NULL) markBar->hide();
+ mb->hide();
+ }
+
pbar = new QProgressBar(this);
pbar->hide();
searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE );
@@ -969,12 +994,13 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
// qDebug("fonting");
do_setfont(reader->m_fontname);
// qDebug("fonted");
QFont progfont(reader->m_fontname, reader->m_fontControl.getsize(0));
m_prog->setFont( progfont );
if (m_statusishidden) m_prog->hide();
+ showEditTools();
if (!reader->m_lastfile.isEmpty())
{
// qDebug("doclnk");
// doc = new DocLnk(reader->m_lastfile);
// qDebug("doclnk done");
if (pOpenlist != NULL)
@@ -1029,19 +1055,19 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
reader->m_scrollpos = m_localscroll;
}
else
{
reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0;
}
- reader->bDoUpdates = true;
- reader->update();
+ // reader->bDoUpdates = true;
+ // reader->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))
+ if (CheckVersion(major, bkmktype, minor, this))
{
config.writeEntry("Major", major);
config.writeEntry("BkmkType", bkmktype);
config.writeEntry("Minor", (int)minor);
}
// qDebug("finished update");
@@ -1062,13 +1088,13 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
void QTReaderApp::addtoolbars(Config* config)
{
config->setGroup("Toolbar");
if (fileBar != NULL)
{
-#ifdef USEQPE
+#if defined(USEQPE)
if (fileBar != menubar)
{
fileBar->clear();
}
else
{
@@ -1090,13 +1116,13 @@ void QTReaderApp::addtoolbars(Config* config)
addfilebar(config, "Info", m_info_action);
addfilebar(config, "Two/One Touch", m_touch_action);
addfilebar(config, "Find", m_find_action);
if (navBar != NULL)
{
-#ifdef USEQPE
+#if defined(USEQPE)
if ((navBar == fileBar) && (fileBar == menubar))
#else
if (navBar == fileBar)
#endif
{
m_scrollButton->removeFrom( navbar() );
@@ -1129,13 +1155,13 @@ void QTReaderApp::addtoolbars(Config* config)
addnavbar(config, "Back", m_back_action);
addnavbar(config, "Home", m_home_action);
addnavbar(config, "Forward", m_forward_action);
if (viewBar != NULL)
{
-#ifdef USEQPE
+#if defined(USEQPE)
if ((viewBar == fileBar) && (fileBar == menubar))
#else
if (viewBar == fileBar)
#endif
{
m_actFullscreen->removeFrom( filebar() );
@@ -1161,13 +1187,13 @@ void QTReaderApp::addtoolbars(Config* config)
addviewbar(config, "Set Font", m_setfont_action);
addviewbar(config, "Encoding Select", m_setenc_action);
addviewbar(config, "Ideogram Mode", m_setmono_action);
if (markBar != NULL)
{
-#ifdef USEQPE
+#if defined(USEQPE)
if ((markBar == fileBar) && (fileBar == menubar))
#else
if (markBar == fileBar)
#endif
{
m_mark_action->removeFrom( markbar() );
@@ -1230,13 +1256,13 @@ bool QTReaderApp::checkbar(Config* _config, const QString& key)
QToolBar* QTReaderApp::filebar()
{
if (fileBar == NULL)
{
switch (m_tbpol)
{
-#ifdef USEQPE
+#if defined(USEQPE)
case cesSingle:
// qDebug("Setting filebar to menubar");
fileBar = menubar;
break;
#endif
default:
@@ -1714,13 +1740,12 @@ void QTReaderApp::setrotated(bool sfs)
connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineDown()) );
connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopageup()) );
connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopagedn()) );
connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) );
}
// reader->repaint(0, reader->m_left_border, reader->width(), reader->height()-2*reader->m_border);
- reader->repaint();
}
else
{
m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight );
if (m_scrollbar != NULL)
{
@@ -1730,15 +1755,14 @@ void QTReaderApp::setrotated(bool sfs)
connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineUp()) );
connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopagedn()) );
connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopageup()) );
connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) );
}
// reader->repaint(reader->m_border, 0, reader->width()-2*reader->m_border, reader->height());
- reader->repaint();
}
- // reader->update();
+ reader->refresh();
}
void QTReaderApp::setgrab(bool sfs)
{
#ifdef USEQPE
m_grabkeyboard = sfs;
@@ -1925,13 +1949,13 @@ void QTReaderApp::fileOpen2()
fileSelector->reread();
*/
bool usebrowser = true;
if (pOpenlist != NULL)
{
m_nBkmkAction = cOpenFile;
- if (listbkmk(pOpenlist, "Browse")) usebrowser = false;
+ if (listbkmk(pOpenlist, "Browse", true)) usebrowser = false;
}
if (usebrowser)
{
QString fn = usefilebrowser();
// qApp->processEvents();
if (!fn.isEmpty() && QFileInfo(fn).isFile())
@@ -1948,13 +1972,13 @@ QString QTReaderApp::usefilebrowser()
{
#ifndef USEQPE
QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) );
return s;
#else
QString fn;
-#ifdef OPIE
+#if defined(OPIE) && defined(OPIEFILEDIALOG)
QMap<QString, QStringList> mimeTypes;
QStringList etypes;
etypes << "etext/*";
mimeTypes.insert( tr("eText"), etypes );
QStringList types;
types << "text/*";
@@ -2000,24 +2024,26 @@ void QTReaderApp::showprefs()
{
CPrefs* prefwin = new CPrefs(reader->width(), !m_bFloatingDialog, this);
// prefwin->Debounce(m_debounce);
prefwin->bgtype(m_bgtype);
prefwin->repalm(reader->brepalm);
+ prefwin->UnderlineLink(reader->bunderlineLink);
prefwin->kern(reader->bkern);
prefwin->hyphenate(reader->hyphenate);
// prefwin->customhyphen(reader->buffdoc.getCustomHyphen());
prefwin->scrolltype(reader->m_scrolltype);
prefwin->scrollstep(reader->m_scrollstep);
prefwin->scrollcolor(m_scrollcolor);
prefwin->minibarcol(m_scrollbarcolor);
prefwin->foreground(m_foreground);
prefwin->background(m_background);
prefwin->twotouch(m_twoTouch);
prefwin->propfontchange(m_propogatefontchange);
prefwin->StripCR(reader->bstripcr);
+ prefwin->InlineTables(!reader->bNoInlineTables);
prefwin->Dehyphen(reader->bdehyphen);
prefwin->SingleSpace(reader->bonespace);
prefwin->Unindent(reader->bunindent);
prefwin->Reparagraph(reader->brepara);
prefwin->DoubleSpace(reader->bdblspce);
prefwin->Remap(reader->bremap);
@@ -2053,12 +2079,13 @@ void QTReaderApp::showprefs()
{
prefwin->Markup(1);
}
prefwin->Depluck(reader->bdepluck);
prefwin->Dejpluck(reader->bdejpluck);
prefwin->Continuous(reader->m_continuousDocument);
+ prefwin->DoubleBuffer(reader->m_doubleBuffered);
prefwin->dictApplication(m_targetapp);
prefwin->dictMessage(m_targetmsg);
/*
prefwin->leftScroll(m_leftScroll);
@@ -2067,12 +2094,13 @@ void QTReaderApp::showprefs()
prefwin->downScroll(m_downScroll);
*/
prefwin->miscannotation(m_doAnnotation);
prefwin->miscdictionary(m_doDictionary);
prefwin->miscclipboard(m_doClipboard);
+ prefwin->miscoutput(m_doOutput);
prefwin->SwapMouse(reader->m_swapmouse);
prefwin->Font(reader->m_fontname);
prefwin->gfxsize(reader->getBaseSize());
@@ -2082,16 +2110,20 @@ void QTReaderApp::showprefs()
prefwin->ideogram(reader->m_bMonoSpaced);
prefwin->encoding(reader->m_encd);
prefwin->ideogramwidth(reader->m_charpc);
+ prefwin->outcodec(reader->m_outputName);
+
if (prefwin->exec())
{
// m_debounce = prefwin->Debounce();
reader->brepalm = prefwin->repalm();
+ reader->bunderlineLink = prefwin->UnderlineLink();
+
reader->bkern = prefwin->kern();
reader->hyphenate = prefwin->hyphenate();
// reader->buffdoc.setCustomHyphen(prefwin->customhyphen());
reader->m_scrolltype = prefwin->scrolltype();
reader->m_scrollstep = prefwin->scrollstep();
m_scrollcolor = prefwin->scrollcolor();
@@ -2104,12 +2136,13 @@ void QTReaderApp::showprefs()
reader->setBackground(getcolour(m_background));
m_twoTouch = prefwin->twotouch();
reader->setTwoTouch(m_twoTouch);
m_touch_action->setOn(m_twoTouch);
reader->bstripcr = prefwin->StripCR();
+ reader->bNoInlineTables = !prefwin->InlineTables();
reader->bdehyphen = prefwin->Dehyphen();
reader->bonespace = prefwin->SingleSpace();
reader->bunindent = prefwin->Unindent();
reader->brepara = prefwin->Reparagraph();
reader->bdblspce = prefwin->DoubleSpace();
reader->bremap = prefwin->Remap();
@@ -2146,12 +2179,13 @@ void QTReaderApp::showprefs()
default:
qDebug("Format out of range");
}
reader->bdepluck = prefwin->Depluck();
reader->bdejpluck = prefwin->Dejpluck();
reader->setContinuous(prefwin->Continuous());
+ reader->setDoubleBuffer(prefwin->DoubleBuffer());
/*
m_leftScroll = prefwin->leftScroll();
m_rightScroll = prefwin->rightScroll();
m_upScroll = prefwin->upScroll();
m_downScroll = prefwin->downScroll();
@@ -2159,12 +2193,13 @@ void QTReaderApp::showprefs()
m_targetapp = prefwin->dictApplication();
m_targetmsg = prefwin->dictMessage();
m_doAnnotation = prefwin->miscannotation();
m_doDictionary = prefwin->miscdictionary();
m_doClipboard = prefwin->miscclipboard();
+ m_doOutput = prefwin->miscoutput();
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();
@@ -2180,12 +2215,21 @@ void QTReaderApp::showprefs()
}
if (m_bgtype != (bground)prefwin->bgtype())
{
m_bgtype = (bground)prefwin->bgtype();
setBackgroundBitmap();
}
+ qDebug("OutCodec:%s", (const char*)prefwin->outcodec());
+ if (reader->m_outputName != prefwin->outcodec())
+ {
+ if (reader->m_output != NULL)
+ {
+ QMessageBox::warning(this, PROGNAME, "Change of output codec\nrequires a restart");
+ }
+ reader->m_outputName = prefwin->outcodec();
+ }
delete prefwin;
reader->setfilter(reader->getfilter());
reader->refresh();
}
else
{
@@ -2287,18 +2331,42 @@ void QTReaderApp::showinfo()
reader->sizes(fs,ts);
ds = reader->buffdoc.endSection() - reader->buffdoc.startSection();
pl = reader->pagelocate();
dl = pl - reader->buffdoc.startSection();
m_infoWin->setFileSize(fs);
m_infoWin->setTextSize(ts);
- m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts);
+ if (fs > UINT_MAX/100)
+ {
+ unsigned long t1 = (ts+50)/100;
+ m_infoWin->setRatio(100-(fs + (t1 >> 1))/t1);
+ }
+ else
+ {
+ m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts);
+ }
m_infoWin->setLocation(pl);
- m_infoWin->setRead((100*pl + (ts >> 1))/ts);
+ if (pl > UINT_MAX/100)
+ {
+ unsigned long t1 = (ts+50)/100;
+ m_infoWin->setRead((pl + (t1 >> 1))/t1);
+ }
+ else
+ {
+ m_infoWin->setRead((100*pl + (ts >> 1))/ts);
+ }
m_infoWin->setDocSize(ds);
m_infoWin->setDocLocation(dl);
- m_infoWin->setDocRead((100*dl + (ds >> 1))/ds);
+ if (dl > UINT_MAX/100)
+ {
+ unsigned long d1 = (ds+50)/100;
+ m_infoWin->setDocRead((dl + (d1 >> 1))/d1);
+ }
+ else
+ {
+ m_infoWin->setDocRead((100*dl + (ds >> 1))/ds);
+ }
m_infoWin->setZoom(reader->m_fontControl.currentsize()*10);
m_infoWin->setAbout(QString("\nApplication (c) Tim Wentford\n")+reader->about());
editorStack->raiseWidget( m_infoWin );
hidetoolbars();
m_infoWin->setFocus();
}
@@ -2739,13 +2807,13 @@ void QTReaderApp::search(const QString & arg)
void QTReaderApp::search()
{
findNext();
}
#endif
-void QTReaderApp::openFile( const QString &f )
+void QTReaderApp::openFile( const QString &f, unsigned int loc )
{
// qDebug("File:%s", (const char*)f);
// openFile(DocLnk(f));
//}
//
//void QTReaderApp::openFile( const DocLnk &f )
@@ -2762,13 +2830,13 @@ void QTReaderApp::openFile( const QString &f )
QFileInfo fnew(d.file());
fm = fnew;
if (!fm.exists()) return;
}
#endif
clear();
- reader->setText(fm.baseName(), fm.absFilePath());
+ reader->setText(fm.baseName(), fm.absFilePath(), loc);
m_loadedconfig = readconfig(APPDIR "/configs", reader->m_string, false);
qDebug("Showing tools");
showEditTools();
qDebug("Shown tools");
readbkmks();
qDebug("read markss");
@@ -2803,13 +2871,13 @@ void QTReaderApp::handlekey(QKeyEvent* e)
{
return;
}
switch(e->key())
{
case Key_Escape:
-// qDebug("escape event");
+ qDebug("escape event");
if (m_disableesckey)
{
m_disableesckey = false;
}
else
{
@@ -2888,46 +2956,47 @@ void QTReaderApp::handlekey(QKeyEvent* e)
QMessageBox::information(this, PROGNAME, msg);
*/
}
ftime(&m_lastkeytime);
}
-#ifdef NEWFULLSCREEN
-void QTReaderApp::enableFullscreen()
-{
- setFixedSize(qApp->desktop()->size());
- showNormal();
- reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0));
- showFullScreen();
-}
-
-void QTReaderApp::resizeEvent(QResizeEvent *)
+#if defined(USEQPE) && defined(USENEWFULLSCREEN)
+void QTReaderApp::focusInEvent(QFocusEvent *)
{
- if (m_fullscreen && (size() != qApp->desktop()->size()))
+ if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader))
{
- enableFullscreen();
+ m_usenewfullscreen = false;
+ reader->bDoUpdates = false;
+ showEditTools();
+ reader->bDoUpdates = true;
+ reader->update();
+ m_usenewfullscreen = true;
}
}
-void QTReaderApp::focusInEvent(QFocusEvent*)
+void QTReaderApp::resizeEvent(QResizeEvent *)
{
- if (m_fullscreen)
+ if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader))
{
- enableFullscreen();
- raise();
+ m_usenewfullscreen = false;
+ reader->bDoUpdates = false;
+ showEditTools();
+ reader->bDoUpdates = true;
+ reader->update();
+ m_usenewfullscreen = true;
}
}
#endif
void QTReaderApp::showEditTools()
{
// if ( !doc )
// close();
if (m_fullscreen)
{
-#ifdef USEQPE
+#if defined(USEQPE)
if (menubar != NULL) menubar->hide();
#endif
if (fileBar != NULL) fileBar->hide();
if (viewBar != NULL) viewBar->hide();
if (navBar != NULL) navBar->hide();
if (markBar != NULL) markBar->hide();
@@ -2941,18 +3010,14 @@ void QTReaderApp::showEditTools()
#ifdef USEQPE
Global::hideInputMethod();
#endif
if (m_scrollbar != NULL) m_scrollbar->hide();
m_fontBar->hide();
// showNormal();
-#ifdef NEWFULLSCREEN
- enableFullscreen();
-#else
showFullScreen();
-#endif
- }
+ }
else
{
// qDebug("him");
#ifdef USEQPE
Global::hideInputMethod();
#endif
@@ -2967,13 +3032,13 @@ void QTReaderApp::showEditTools()
{
m_scrollbar->show();
}
}
if (!m_hidebars)
{
-#ifdef USEQPE
+#if defined(USEQPE)
menubar->show();
#endif
if (fileBar != NULL) fileBar->show();
if (viewBar != NULL) viewBar->show();
if (navBar != NULL) navBar->show();
if (markBar != NULL) markBar->show();
@@ -3001,26 +3066,26 @@ void QTReaderApp::showEditTools()
regBar->show();
}
if (m_fontVisible) m_fontBar->show();
// qDebug("sn");
showNormal();
// qDebug("sm");
-#ifdef USEQPE
+#if defined(USEQPE) && !defined(SIMPAD)
showMaximized();
#endif
// setCentralWidget(reader);
}
// qDebug("uc");
updateCaption();
// qDebug("rw");
editorStack->raiseWidget( reader );
// qDebug("sf");
reader->setFocus();
// qDebug("ref");
- reader->refresh(true);
+ //reader->refresh(true);
// qDebug("done");
}
/*
void QTReaderApp::save()
{
if ( !doc )
@@ -3171,37 +3236,47 @@ void QTReaderApp::do_delmark()
{
m_nBkmkAction = cDelBkmk;
if (!listbkmk(pBkmklist))
QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
}
-bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
+bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab, bool presel)
{
bkmkselector->clear();
if (_lab.isEmpty())
bkmkselector->setText("Cancel");
else
bkmkselector->setText(_lab);
int cnt = 0;
+ int slt = -1;
if (plist != NULL)
{
for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++)
{
+ if (presel)
+ {
+ Bkmk* p = i.pContent();
+ if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile)
+ {
+ slt = cnt;
+ }
+ }
#ifdef _UNICODE
// qDebug("Item:%s", (const char*)toQString(i->name()));
- bkmkselector->insertItem(toQString(i->name()));
+ bkmkselector->insertItem(toQString(i->name()), cnt++);
#else
- bkmkselector->insertItem(i->name());
+ bkmkselector->insertItem(i->name(), cnt++);
#endif
- cnt++;
+
}
}
if (cnt > 0)
{
hidetoolbars();
editorStack->raiseWidget( bkmkselector );
+ if (slt != -1) bkmkselector->setCurrentItem(slt);
return true;
}
else
return false;
}
@@ -3235,36 +3310,37 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
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);
+ stat((const char *)fn, &fnstat);
if (CFiledata(bk->anno()).date()
!= fnstat.st_mtime)
{
CFiledata fd(bk->anno());
fd.setdate(fnstat.st_mtime);
bk->value(0);
+ reader->m_lastposn = 0;
+ openFile(fn);
}
else
{
unsigned short svlen = bk->filedatalen();
unsigned char* svdata = bk->filedata();
+ openFile(fn, bk->value());
reader->putSaveData(svdata, svlen);
// setstate(svdata, svlen);
if (svlen != 0)
{
QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?");
}
// qDebug("updating");
// showEditTools();
- reader->locate(bk->value());
}
return true;
}
else
{
return false;
@@ -3363,13 +3439,13 @@ void QTReaderApp::gotobkmk(int ind)
}
#else /* USEQPE */
FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r");
if (fin != NULL)
{
bool allok = false;
-#ifdef OPIE
+#if defined(OPIE) && defined(OPIEFILEDIALOG)
QString outfile = OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, QString::null, QString::null, MimeTypes(), 0, "OpieReader");
if (!outfile.isEmpty())
{
FILE* fout = fopen((const char *)outfile, "w");
if (fout != NULL)
{
@@ -3700,15 +3776,16 @@ void QTReaderApp::do_autogen(const QString& regText)
reader->update();
qApp->processEvents();
reader->setFocus();
reader->jumpto(0);
int lastpc = 0;
int i = 0;
+ unsigned int llcn = reader->locate();
while (i >= 0)
{
- unsigned int lcn = reader->locate();
+ unsigned int lcn = llcn;
int pc = (100*lcn)/ts;
if (pc != lastpc)
{
pbar->setProgress(pc);
qApp->processEvents();
if (reader->locate() != lcn) reader->jumpto(lcn);
@@ -3719,12 +3796,20 @@ void QTReaderApp::do_autogen(const QString& regText)
#ifdef _UNICODE
if (re.match(toQString(buff.data())) != -1)
#else
if (re.match(buff.data()) != -1)
#endif
pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn));
+ /*
+ llcn = reader->locate();
+ if ((i == 0) && (llcn+1 < ts))
+ {
+ reader->jumpto(++llcn);
+ i = 1;
+ }
+ */
}
pBkmklist->sort();
pbar->setProgress(100);
qApp->processEvents();
pbar->hide();
reader->refresh();
@@ -4029,12 +4114,16 @@ void QTReaderApp::showAnnotation()
}
void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, size_t posn2, const QString& line)
{
//// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd);
+ if (m_doOutput && reader->checkoutput())
+ {
+ reader->doOutput(wrd);
+ }
if (m_doClipboard)
{
QClipboard* cb = QApplication::clipboard();
cb->setText(wrd);
#ifdef USEQPE
if (wrd.length() > 10)
@@ -4113,24 +4202,24 @@ void QTReaderApp::doAction(QKeyEvent* e)
m_inverse_action->setOn(!reader->bInverse);
break;
case cesToggleBars:
m_hidebars = !m_hidebars;
if (m_hidebars)
{
-#ifdef USEQPE
+#if defined(USEQPE)
menubar->hide();
#endif
if (fileBar != NULL) fileBar->hide();
if (viewBar != NULL) viewBar->hide();
if (navBar != NULL) navBar->hide();
if (markBar != NULL) markBar->hide();
mb->hide();
}
else
{
-#ifdef USEQPE
+#if defined(USEQPE)
menubar->show();
#endif
if (fileBar != NULL) fileBar->show();
if (viewBar != NULL) viewBar->show();
if (navBar != NULL) navBar->show();
if (markBar != NULL) markBar->show();
@@ -4337,12 +4426,13 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
// qDebug("Path:%s", (const char*)fi.absFilePath());
Config config(fi.absFilePath());
#endif
config.writeEntry( "StripCr", reader->bstripcr );
+ config.writeEntry( "NoInlineTables", reader->bNoInlineTables );
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 );
@@ -4362,12 +4452,13 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool 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( "OutputCodec", reader->m_outputName);
}
config.writeEntry( "PageMode", reader->m_bpagemode );
config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced );
config.writeEntry( "SwapMouse", reader->m_swapmouse);
config.writeEntry( "IsRotated", reader->m_rotated );
config.writeEntry("StatusContent", m_statusstring);
@@ -4393,12 +4484,13 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
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( "OutputTgt", m_doOutput);
/*
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);
@@ -4407,18 +4499,21 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
config.writeEntry("LeftScroll", m_leftScroll);
config.writeEntry("RightScroll", m_rightScroll);
config.writeEntry("UpScroll", m_upScroll);
config.writeEntry("DownScroll", m_downScroll);
*/
config.writeEntry( "Repalm", reader->brepalm );
+ config.writeEntry( "UnderlineLink", reader->bunderlineLink );
config.writeEntry( "HideScrollBar", m_scrollishidden );
+ config.writeEntry( "HideToolBar", m_hidebars );
config.writeEntry( "Kern", reader->bkern );
config.writeEntry( "Remap", reader->bremap );
config.writeEntry( "Peanut", reader->bpeanut );
config.writeEntry( "MakeBold", reader->bmakebold );
config.writeEntry( "Continuous", reader->m_continuousDocument );
+ config.writeEntry( "DoubleBuffer", reader->m_doubleBuffered);
config.writeEntry( "FullJust", reader->bfulljust );
// config.writeEntry( "Negative", reader->bNegative );
config.writeEntry( "Inverse", reader->bInverse );
config.writeEntry( "FixGraphics", reader->m_fontControl.FixGraphics());
config.writeEntry( "ExtraSpace", reader->getextraspace() );
config.writeEntry( "ExtraLead", reader->getlead() );
@@ -4516,12 +4611,13 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f
m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", m_tbpolsave);
m_tbposition = (ToolBarDock)config.readNumEntry("Position", m_tbposition);
}
config.setGroup( "View" );
m_bFloatingDialog = config.readBoolEntry("FloatDialogs", m_bFloatingDialog);
reader->bstripcr = config.readBoolEntry( "StripCr", reader->bstripcr );
+ reader->bNoInlineTables = config.readBoolEntry( "NoInlineTables", reader->bNoInlineTables );
reader->bfulljust = config.readBoolEntry( "FullJust", reader->bfulljust );
reader->bInverse = config.readBoolEntry( "Inverse", reader->bInverse );
// reader->bNegative = config.readBoolEntry( "Negative", false );
reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", reader->m_fontControl.FixGraphics() ));
reader->setextraspace(config.readNumEntry( "ExtraSpace", reader->getextraspace() ));
reader->setlead(config.readNumEntry( "ExtraLead", reader->getlead() ));
@@ -4571,33 +4667,39 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f
reader->m_overlap = config.readNumEntry( "Overlap", reader->m_overlap );
reader->m_abstopmargin = config.readNumEntry( "Top Margin", reader->m_abstopmargin );
reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", reader->m_absbottommargin );
reader->m_absleft_border = config.readNumEntry( "Left Margin", reader->m_absleft_border );
reader->m_absright_border = config.readNumEntry( "Right Margin", reader->m_absright_border );
m_scrollishidden = config.readBoolEntry( "HideScrollBar", m_scrollishidden );
+ m_hidebars = config.readBoolEntry( "HideToolBar", m_hidebars );
reader->brepalm = config.readBoolEntry( "Repalm", reader->brepalm );
+ reader->bunderlineLink = config.readBoolEntry( "UnderlineLink", reader->bunderlineLink );
reader->bkern = config.readBoolEntry( "Kern", reader->bkern );
reader->bremap = config.readBoolEntry( "Remap", reader->bremap );
reader->bmakebold = config.readBoolEntry( "MakeBold", reader->bmakebold );
reader->setContinuous(config.readBoolEntry( "Continuous", reader->m_continuousDocument ));
+ reader->setDoubleBuffer(config.readBoolEntry("DoubleBuffer", reader->m_doubleBuffered));
m_targetapp = config.readEntry( "TargetApp", m_targetapp );
m_targetmsg = config.readEntry( "TargetMsg", m_targetmsg );
#ifdef _SCROLLPIPE
reader->m_pipetarget = config.readEntry( "PipeTarget", reader->m_pipetarget );
reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", reader->m_pauseAfterEachPara );
#endif
m_twoTouch = config.readBoolEntry( "TwoTouch", m_twoTouch);
m_doAnnotation = config.readBoolEntry( "Annotation", m_doAnnotation);
m_doDictionary = config.readBoolEntry( "Dictionary", m_doDictionary);
m_doClipboard = config.readBoolEntry( "Clipboard", m_doClipboard);
+ m_doOutput = config.readBoolEntry( "OutputTgt", m_doOutput);
#ifdef USEQPE
m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", m_grabkeyboard);
#endif
m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", m_propogatefontchange);
reader->setBaseSize(config.readNumEntry( "Basesize", reader->getBaseSize() ));
reader->setTwoTouch(m_twoTouch);
+
+ reader->m_outputName = config.readEntry( "OutputCodec", reader->m_outputName);
m_touch_action->setOn(m_twoTouch);
m_setmono_action->setOn(reader->m_bMonoSpaced);
setfontHelper(reader->m_fontname);
if (full)
{
@@ -4634,14 +4736,13 @@ bool QTReaderApp::PopulateConfig(const char* tgtdir, bool usedirs)
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++;
+ bkmkselector->insertItem(fi->fileName(), cnt++);
//qDebug( "%10li %s", fi->size(), fi->fileName().data() );
++it; // goto next list element
}
#else /* USEQPE */
@@ -4660,14 +4761,13 @@ bool QTReaderApp::PopulateConfig(const char* tgtdir, bool usedirs)
struct stat buf;
de = readdir(d);
if (de == NULL) break;
if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && ((usedirs && S_ISDIR(buf.st_mode)) || (!usedirs && S_ISREG(buf.st_mode))))
{
- bkmkselector->insertItem(de->d_name);
- cnt++;
+ bkmkselector->insertItem(de->d_name, cnt++);
}
}
delete [] finaldir;
closedir(d);
#endif
return (cnt > 0);
@@ -4732,12 +4832,14 @@ void QTReaderApp::OnURLSelected(const QString& href, const size_t tgt)
qDebug("Type:%s", (const char*)type);
}
else
{
qDebug("No type");
}
+ QString msg = "External URL\n" + href;
+ QMessageBox::information(this, PROGNAME, msg);
#else
if (href.isEmpty())
{
QMessageBox::information(this, PROGNAME, "No URL information supplied");
}
else
@@ -4898,13 +5000,13 @@ void QTReaderApp::forceopen(const QString& filename)
{
/*
QFileInfo fi(reader->m_lastfile);
fi = QFileInfo(filename);
QString flnm = fi.absFilePath();
*/
- if (!filename.isEmpty())
+ if (!filename.isEmpty() && QFileInfo(filename).exists())
{
updatefileinfo();
if (pBkmklist != NULL)
{
if (m_fBkmksChanged)
{
@@ -4915,12 +5017,16 @@ void QTReaderApp::forceopen(const QString& filename)
m_fBkmksChanged = false;
}
reader->disableAutoscroll();
openFile(filename);
reader->setFocus();
}
+ else
+ {
+ OnURLSelected(filename, 0);
+ }
}
void QTReaderApp::actionscroll(int v)
{
if (reader->m_rotated)
{