summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Bkmks.cpp2
-rw-r--r--noncore/apps/opie-reader/BuffDoc.cpp2
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp46
3 files changed, 25 insertions, 25 deletions
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp
index 92ed69f..0cb9ea9 100644
--- a/noncore/apps/opie-reader/Bkmks.cpp
+++ b/noncore/apps/opie-reader/Bkmks.cpp
@@ -125,97 +125,97 @@ void BkmkFile::write(tchar* nm, tchar* an, const unsigned int& pos)
}
void BkmkFile::write(const Bkmk& b) { write(b.name(), b.anno(), b.value()); }
void BkmkFile::write(CList<Bkmk>& bl)
{
if (f != NULL)
{
fwrite(&magic, sizeof(magic), 1, f);
for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++)
{
write(*i);
}
}
}
Bkmk* BkmkFile::read()
{
Bkmk* b = NULL;
if (f != NULL)
{
unsigned short ln;
if (fread(&ln,sizeof(ln),1,f) == 1)
{
b = new Bkmk;
b->m_name = new tchar[ln+1];
fread(b->m_name,sizeof(tchar),ln,f);
b->m_name[ln] = 0;
fread(&ln,sizeof(ln),1,f);
b->m_anno = new tchar[ln+1];
if (ln > 0) fread(b->m_anno,sizeof(tchar),ln,f);
b->m_anno[ln] = 0;
fread(&b->m_position,sizeof(b->m_position),1,f);
}
}
return b;
}
CList<Bkmk>* BkmkFile::readall()
{
CList<Bkmk>* bl = NULL;
if (f != NULL)
{
unsigned long newmagic;
fread(&newmagic, sizeof(newmagic), 1, f);
if (newmagic != magic)
{
- if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of QTReader\ndid you upgrade from?", "0_4*", "Any other version") == 0)
+ if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of OpieReader\ndid you upgrade from?", "0_4*", "Any other version") == 0)
{
fseek(f,0,SEEK_SET);
bl = readall04();
}
else
{
fseek(f,0,SEEK_SET);
bl = readall03();
}
isUpgraded = true;
}
else
{
bl = readall04();
}
}
return bl;
}
CList<Bkmk>* BkmkFile::readall04()
{
CList<Bkmk>* bl = new CList<Bkmk>;
while (1)
{
Bkmk* b = read();
if (b == NULL) break;
bl->push_back(*b);
delete b;
}
return bl;
}
CList<Bkmk>* BkmkFile::readall03()
{
CList<Bkmk>* bl = new CList<Bkmk>;
while (1)
{
Bkmk* b = read03();
if (b == NULL) break;
bl->push_back(*b);
delete b;
}
return bl;
}
Bkmk* BkmkFile::read03()
{
Bkmk* b = NULL;
diff --git a/noncore/apps/opie-reader/BuffDoc.cpp b/noncore/apps/opie-reader/BuffDoc.cpp
index e37b136..d4541ea 100644
--- a/noncore/apps/opie-reader/BuffDoc.cpp
+++ b/noncore/apps/opie-reader/BuffDoc.cpp
@@ -164,61 +164,61 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
int ret = exp->openfile(src);
if (ret == -1)
{
delete exp;
exp = NULL;
return ret;
}
if (ret == -2)
{
delete exp;
exp = new ztxt;
ret = exp->openfile(src);
}
if (ret != 0)
{
delete exp;
exp = new CPlucker;
ret = exp->openfile(src);
}
#ifndef SMALL
if (ret != 0)
{
delete exp;
qDebug("Trying ppms");
exp = new ppm_expander;
ret = exp->openfile(src);
}
if (ret != 0)
{
delete exp;
exp = new Text;
// qDebug("Trying text");
ret = exp->openfile(src);
}
#else
if (ret != 0)
{
delete exp;
exp = new Text;
ret = exp->openfile(src);
}
#endif
if (ret != 0)
{
delete exp;
- QMessageBox::information(_parent, "QTReader", "Unknown file compression type","Try another file");
+ QMessageBox::information(_parent, "OpieReader", "Unknown file compression type","Try another file");
return ret;
}
// qDebug("Doing final open:%x:%x",exp,filt);
lastword.empty();
lastsizes[0] = laststartline = 0;
lastispara = false;
exp->locate(0);
filt->setsource(exp);
// qDebug("BuffDoc:file opened");
return 0;
}
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index 0608b66..ef1f4f1 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -54,116 +54,116 @@
#include "QTReaderApp.h"
#include "fileBrowser.h"
#include "CDrawBuffer.h"
unsigned long QTReaderApp::m_uid = 0;
void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); }
#include <unistd.h>
#include <stddef.h>
#include <dirent.h>
void QTReaderApp::listBkmkFiles()
{
bkmkselector->clear();
int cnt = 0;
DIR *d;
d = opendir((const char *)Global::applicationFileName("uqtreader",""));
while(1)
{
struct dirent* de;
struct stat buf;
de = readdir(d);
if (de == NULL) break;
if (lstat((const char *)Global::applicationFileName("uqtreader",de->d_name),&buf) == 0 && S_ISREG(buf.st_mode))
{
bkmkselector->insertItem(de->d_name);
cnt++;
}
}
closedir(d);
if (cnt > 0)
{
//tjw menu->hide();
editBar->hide();
if (m_fontVisible) m_fontBar->hide();
if (regVisible) regBar->hide();
if (searchVisible) searchBar->hide();
m_nRegAction = cRmBkmkFile;
editorStack->raiseWidget( bkmkselector );
}
else
- QMessageBox::information(this, "QTReader", "No bookmark files");
+ QMessageBox::information(this, "OpieReader", "No bookmark files");
}
QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
: QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false)
{
// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir());
// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml"));
pBkmklist = NULL;
doc = 0;
m_fBkmksChanged = false;
QString lang = getenv( "LANG" );
m_autogenstr = "^ *[A-Z].*[a-z] *$";
setToolBarsMovable( FALSE );
- setIcon( Resource::loadPixmap( "uqtreader" ) );
+ setIcon( Resource::loadPixmap( "opie-reader/uqtreader" ) );
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
addToolBar(bar, "tool",QMainWindow::Top, true);
//tjw menu = bar;
QPEMenuBar *mb = new QPEMenuBar( bar );
QPopupMenu *file = new QPopupMenu( this );
QPopupMenu *format = new QPopupMenu( this );
// QPopupMenu *edit = new QPopupMenu( this );
// bar = new QToolBar( this );
editBar = bar;
/*
QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
a->addTo( bar );
a->addTo( file );
*/
editorStack = new QWidgetStack( this );
setCentralWidget( editorStack );
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() ) );
m_infoWin = new infowin(editorStack);
editorStack->addWidget(m_infoWin, get_unique_id());
connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) );
// bkmkselector = new QListBox(editorStack, "Bookmarks");
bkmkselector = new CBkmkSelector(editorStack, "Bookmarks");
// connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) );
connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) );
connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) );
editorStack->addWidget( bkmkselector, get_unique_id() );
/*
@@ -210,97 +210,97 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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);
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&) ) );
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 );
/*
a = new QAction( tr( "Revert" ), Resource::loadPixmap( "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 );
connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
a->addTo( editBar );
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 );
ag->addTo(spacemenu);
connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) );
- a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( "panel-arrow-down" ), QString::null, 0, this, 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( "Find" ), QString::null, 0, this, NULL, true );
// connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
a->addTo( file );
a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true );
// connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
a->addTo( file );
*/
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 );
file->insertSeparator();
a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL);
connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) );
a->addTo( file );
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);
ag->setExclusive(false);
QPopupMenu *encoding = new QPopupMenu(this);
file->insertItem( tr( "Target" ), encoding );
a = new QAction( tr( "Annotation" ), QString::null, 0, ag, NULL, true );
connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnAnnotation(bool) ) );
a->setOn(m_doAnnotation);
@@ -585,103 +585,103 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
FontDatabase f;
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;
break;
}
}
if (!realfont) reader->m_fontname = flist[0];
} // delete the FontDatabase!!!
connect( m_fontSelector, SIGNAL( activated(const QString& ) ),
this, SLOT( do_setfont(const QString&) ) );
m_fontBar->hide();
m_fontVisible = false;
connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ),
this, SLOT( msgHandler(const QCString&, const QByteArray&) ) );
reader->init();
if (!reader->m_lastfile.isEmpty())
{
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);
}
void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
{
QString msg = QString::fromUtf8(_msg);
// qDebug("Received:%s", (const char*)msg);
QDataStream stream( _data, IO_ReadOnly );
if ( msg == "info(QString)" )
{
QString info;
stream >> info;
- QMessageBox::information(this, "QTReader", info);
+ QMessageBox::information(this, "OpieReader", info);
}
else if ( msg == "warn(QString)" )
{
QString info;
stream >> info;
- QMessageBox::warning(this, "QTReader", info);
+ QMessageBox::warning(this, "OpieReader", info);
}
else if ( msg == "exit()" )
{
m_dontSave = true;
close();
}
else if ( msg == "pageDown()" )
{
reader->dopagedn();
}
else if ( msg == "pageUp()" )
{
reader->dopageup();
}
else if ( msg == "lineDown()" )
{
reader->lineDown();
}
else if ( msg == "lineUp()" )
{
reader->lineUp();
}
else if ( msg == "showText()" )
{
showEditTools();
}
else if ( msg == "File/Open(QString)" )
{
QString info;
stream >> info;
openFile( info );
}
else if ( msg == "File/Info()" )
{
showinfo();
}
else if ( msg == "File/Start Block()" )
{
editMark();
}
else if ( msg == "File/Copy Block()" )
{
editCopy();
}
else if ( msg == "File/Scroll(int)" )
{
@@ -706,97 +706,97 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
int info;
stream >> info;
reader->m_overlap = info;
}
else if ( msg == "File/Set Dictionary(QString)" )
{
QString info;
stream >> info;
do_settarget(info);
}
else if ( msg == "File/Two/One Touch(int)" )
{
int info;
stream >> info;
setTwoTouch(info);
}
else if ( msg == "Target/Annotation(int)" )
{
int info;
stream >> info;
OnAnnotation(info);
}
else if ( msg == "Target/Dictionary(int)" )
{
int info;
stream >> info;
OnDictionary(info);
}
else if ( msg == "Target/Clipboard(int)" )
{
int info;
stream >> info;
OnClipboard(info);
}
else if ( msg == "File/Find(QString)" )
{
QString info;
stream >> info;
QRegExp arg(info);
size_t pos = reader->pagelocate();
size_t start = pos;
CDrawBuffer test(&(reader->m_fontControl));
reader->buffdoc.getline(&test,reader->width());
while (arg.match(toQString(test.data())) == -1)
{
pos = reader->locate();
if (!reader->buffdoc.getline(&test,reader->width()))
{
- QMessageBox::information(this, "QTReader", QString("Can't find\n")+info);
+ QMessageBox::information(this, "OpieReader", QString("Can't find\n")+info);
pos = start;
break;
}
}
reader->locate(pos);
}
else if ( msg == "Layout/Strip CR(int)" )
{
int info;
stream >> info;
stripcr(info);
}
else if ( msg == "Markup/Auto(int)" )
{
int info;
stream >> info;
autofmt(info);
}
else if ( msg == "Markup/Text(int)" )
{
int info;
stream >> info;
textfmt(info);
}
else if ( msg == "Markup/HTML(int)" )
{
int info;
stream >> info;
striphtml(info);
}
else if ( msg == "Markup/Peanut(int)" )
{
int info;
stream >> info;
peanut(info);
}
else if ( msg == "Layout/Dehyphen(int)" )
{
int info;
stream >> info;
dehyphen(info);
}
else if ( msg == "Layout/Unindent(int)" )
{
int info;
stream >> info;
unindent(info);
}
@@ -869,260 +869,260 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
ActionTypes QTReaderApp::ActNameToInt(const QString& _enc)
{
for (int i = 0; i < MAX_ACTIONS; i++)
{
if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i;
}
return cesAutoScroll;
}
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()));
m_spaceTarget = ActNameToInt(_a->text());
}
QTReaderApp::~QTReaderApp()
{
}
void QTReaderApp::autoScroll(bool _b)
{
reader->setautoscroll(_b);
}
void QTReaderApp::TBD()
{
- QMessageBox::information(this, "QTReader", "Not yet implemented", 1);
+ QMessageBox::information(this, "OpieReader", "Not yet implemented", 1);
}
void QTReaderApp::TBDzoom()
{
- QMessageBox::information(this, "QTReader", "Zooming is done interactively\nTry left/right cursor keys", 1);
+ QMessageBox::information(this, "OpieReader", "Zooming is done interactively\nTry left/right cursor keys", 1);
}
void QTReaderApp::clearBkmkList()
{
delete pBkmklist;
pBkmklist = NULL;
m_fBkmksChanged = false;
}
void QTReaderApp::fileOpen()
{
/*
menu->hide();
editBar->hide();
if (regVisible) regBar->hide();
if (searchVisible) searchBar->hide();
*/
if (pBkmklist != NULL)
{
if (m_fBkmksChanged)
{
- if (QMessageBox::warning(this, "QTReader", "Save bookmarks?", "Save", "Don't bother") == 0)
+ if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0)
savebkmks();
}
delete pBkmklist;
pBkmklist = NULL;
m_fBkmksChanged = false;
}
reader->disableAutoscroll();
/*
editorStack->raiseWidget( fileSelector );
fileSelector->reread();
*/
- fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE,
+ fileBrowser* fb = new fileBrowser(this,"OpieReader",TRUE,
0,
// WStyle_Customize | WStyle_NoBorderEx,
"*", QFileInfo(reader->m_lastfile).dirPath(true));
if (fb->exec())
{
QString fn(fb->fileList[0]);
// fb->populateList();
if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn);
}
delete fb;
reader->setFocus();
}
void QTReaderApp::showinfo()
{
unsigned long fs, ts, pl;
if (reader->empty())
{
- QMessageBox::information(this, "QTReader", "No file loaded", 1);
+ QMessageBox::information(this, "OpieReader", "No file loaded", 1);
}
else
{
reader->sizes(fs,ts);
pl = reader->pagelocate();
m_infoWin->setFileSize(fs);
m_infoWin->setTextSize(ts);
m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts);
m_infoWin->setLocation(pl);
m_infoWin->setRead((100*pl + (ts >> 1))/ts);
editorStack->raiseWidget( m_infoWin );
m_infoWin->setFocus();
}
}
void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn)
{
if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>;
#ifdef _UNICODE
CBuffer buff(name.length()+1);
int i;
for (i = 0; i < name.length(); i++)
{
buff[i] = name[i].unicode();
}
buff[i] = 0;
CBuffer buff2(text.length()+1);
for (i = 0; i < text.length(); i++)
{
buff2[i] = text[i].unicode();
}
buff2[i] = 0;
pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn));
#else
pBkmklist->push_front(Bkmk((const tchar*)text,posn));
#endif
m_fBkmksChanged = true;
pBkmklist->sort();
}
void QTReaderApp::addAnno(const QString& name, const QString& text)
{
if (m_annoIsEditing)
{
if (name.isEmpty())
{
- QMessageBox::information(this, "QTReader", "Need a name for the bookmark\nPlease try again", 1);
+ QMessageBox::information(this, "OpieReader", "Need a name for the bookmark\nPlease try again", 1);
}
else
{
addAnno(name, text, m_annoWin->getPosn());
}
showEditTools();
}
else
{
if (m_annoWin->edited())
{
CBuffer buff(text.length()+1);
int i;
for (i = 0; i < text.length(); i++)
{
buff[i] = text[i].unicode();
}
buff[i] = 0;
m_fBkmksChanged = true;
m_anno->setAnno(buff.data());
}
bool found = findNextBookmark(m_anno->value()+1);
if (found)
{
m_annoWin->setName(toQString(m_anno->name()));
m_annoWin->setAnno(toQString(m_anno->anno()));
}
else
{
showEditTools();
}
}
}
bool QTReaderApp::findNextBookmark(size_t start)
{
bool found = false;
for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++)
{
if (iter->value() >= start)
{
if (iter->value() < reader->locate())
{
found = true;
m_anno = iter.pContent();
}
break;
}
}
return found;
}
void QTReaderApp::addanno()
{
if (reader->empty())
{
- QMessageBox::information(this, "QTReader", "No file loaded", 1);
+ QMessageBox::information(this, "OpieReader", "No file loaded", 1);
}
else
{
m_annoWin->setName("");
m_annoWin->setAnno("");
m_annoWin->setPosn(reader->pagelocate());
m_annoIsEditing = true;
editorStack->raiseWidget( m_annoWin );
m_annoWin->setFocus();
}
}
void QTReaderApp::infoClose()
{
showEditTools();
}
/*
void QTReaderApp::fileRevert()
{
clear();
fileOpen();
}
void QTReaderApp::editCut()
{
#ifndef QT_NO_CLIPBOARD
editor->cut();
#endif
}
*/
void QTReaderApp::editMark()
{
m_savedpos = reader->pagelocate();
}
void QTReaderApp::editCopy()
{
QClipboard* cb = QApplication::clipboard();
QString text;
int ch;
unsigned long currentpos = reader->pagelocate();
unsigned long endpos = reader->locate();
reader->jumpto(m_savedpos);
while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF)
{
text += ch;
}
@@ -1186,112 +1186,112 @@ void QTReaderApp::dblspce(bool _b)
}
void QTReaderApp::pagemode(bool _b)
{
reader->setpagemode(_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)
+ "/"
+ ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg);
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, "QTReader", "Must be a number");
+ QMessageBox::information(this, "OpieReader", "Must be a number");
}
void QTReaderApp::do_mono(const QString& lcn)
{
bool ok;
unsigned long ulcn = lcn.toULong(&ok);
if (ok)
{
reader->m_charpc = ulcn;
reader->setfont();
reader->refresh();
// reader->setmono(true);
}
else
- QMessageBox::information(this, "QTReader", "Must be a number");
+ QMessageBox::information(this, "OpieReader", "Must be a number");
}
/*
void QTReaderApp::editPaste()
{
#ifndef QT_NO_CLIPBOARD
editor->paste();
#endif
}
*/
void QTReaderApp::editFind()
{
searchStart = reader->pagelocate();
#ifdef __ISEARCH
searchStack = new QStack<searchrecord>;
#endif
searchBar->show();
searchVisible = TRUE;
searchEdit->setFocus();
#ifdef __ISEARCH
searchStack->push(new searchrecord("",reader->pagelocate()));
#endif
}
void QTReaderApp::findNext()
{
// 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());
dosearch(start, test, arg);
}
void QTReaderApp::findClose()
{
searchVisible = FALSE;
searchEdit->setText("");
searchBar->hide();
#ifdef __ISEARCH
// searchStack = new QStack<searchrecord>;
while (!searchStack->isEmpty())
@@ -1373,365 +1373,365 @@ void QTReaderApp::search(const QString & arg)
*/
else
{
start = reader->pagelocate();
reader->jumpto(start);
searchStack->push(new searchrecord(arg,start));
}
dosearch(start, test, arg);
}
#else
void QTReaderApp::search()
{
findNext();
}
#endif
void QTReaderApp::openFile( const QString &f )
{
openFile(DocLnk(f));
}
void QTReaderApp::openFile( const DocLnk &f )
{
clear();
FileManager fm;
if ( fm.exists( f ) )
{
// QMessageBox::information(0, "Progress", "Calling fileNew()");
clear();
// editorStack->raiseWidget( reader );
// reader->setFocus();
// 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");
// updateCaption();
showEditTools();
reader->setText(doc->name(), doc->file());
readbkmks();
}
else
{
- QMessageBox::information(this, "QTReader", "File does not exist");
+ QMessageBox::information(this, "OpieReader", "File does not exist");
}
}
void QTReaderApp::showEditTools()
{
if ( !doc )
close();
// fileSelector->hide();
//tjw menu->show();
editBar->show();
if ( searchVisible )
searchBar->show();
if ( regVisible )
regBar->show();
if (m_fontVisible) m_fontBar->show();
updateCaption();
editorStack->raiseWidget( reader );
reader->setFocus();
}
/*
void QTReaderApp::save()
{
if ( !doc )
return;
if ( !editor->edited() )
return;
QString rt = editor->text();
QString pt = rt;
if ( doc->name().isEmpty() ) {
unsigned ispace = pt.find( ' ' );
unsigned ienter = pt.find( '\n' );
int i = (ispace < ienter) ? ispace : ienter;
QString docname;
if ( i == -1 ) {
if ( pt.isEmpty() )
docname = "Empty Text";
else
docname = pt;
} else {
docname = pt.left( i );
}
doc->setName(docname);
}
FileManager fm;
fm.saveFile( *doc, rt );
}
*/
void QTReaderApp::clear()
{
if (doc != 0)
{
// QMessageBox::information(this, "QTReader", "Deleting doc", 1);
delete doc;
// QMessageBox::information(this, "QTReader", "Deleted doc", 1);
doc = 0;
}
reader->clear();
}
void QTReaderApp::updateCaption()
{
if ( !doc )
- setCaption( tr("QTReader") );
+ setCaption( tr("OpieReader") );
else {
QString s = doc->name();
if ( s.isEmpty() )
s = tr( "Unnamed" );
- setCaption( s + " - " + tr("QTReader") );
+ setCaption( s + " - " + tr("OpieReader") );
}
}
void QTReaderApp::setDocument(const QString& fileref)
{
bFromDocView = TRUE;
//QMessageBox::information(0, "setDocument", fileref);
openFile(DocLnk(fileref));
// showEditTools();
}
void QTReaderApp::closeEvent( QCloseEvent *e )
{
if (m_dontSave)
{
e->accept();
}
else
{
if (editorStack->visibleWidget() == reader)
{
if (m_fontVisible)
{
m_fontBar->hide();
m_fontVisible = false;
}
if (regVisible)
{
regBar->hide();
regVisible = false;
return;
}
if (searchVisible)
{
searchBar->hide();
searchVisible = false;
return;
}
if (m_fBkmksChanged && pBkmklist != NULL)
{
- if (QMessageBox::warning(this, "QTReader", "Save bookmarks?", "Save", "Don't bother") == 0)
+ if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0)
savebkmks();
delete pBkmklist;
pBkmklist = NULL;
m_fBkmksChanged = false;
}
bFromDocView = FALSE;
saveprefs();
e->accept();
}
else
{
showEditTools();
}
}
}
void QTReaderApp::do_gotomark()
{
m_nRegAction = cGotoBkmk;
listbkmk();
}
void QTReaderApp::do_delmark()
{
m_nRegAction = cDelBkmk;
listbkmk();
}
void QTReaderApp::listbkmk()
{
bkmkselector->clear();
int cnt = 0;
if (pBkmklist != NULL)
{
for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++)
{
#ifdef _UNICODE
bkmkselector->insertItem(toQString(i->name()));
#else
bkmkselector->insertItem(i->name());
#endif
cnt++;
}
}
if (cnt > 0)
{
//tjw menu->hide();
editBar->hide();
if (m_fontVisible) m_fontBar->hide();
if (regVisible) regBar->hide();
if (searchVisible) searchBar->hide();
editorStack->raiseWidget( bkmkselector );
}
else
- QMessageBox::information(this, "QTReader", "No bookmarks in memory");
+ QMessageBox::information(this, "OpieReader", "No bookmarks in memory");
}
void QTReaderApp::do_autogen()
{
m_nRegAction = cAutoGen;
regEdit->setText(m_autogenstr);
do_regedit();
}
void QTReaderApp::do_regedit()
{
// editBar->hide();
regBar->show();
regVisible = true;
regEdit->setFocus();
}
void QTReaderApp::gotobkmk(int ind)
{
switch (m_nRegAction)
{
case cGotoBkmk:
reader->locate((*pBkmklist)[ind]->value());
break;
case cDelBkmk:
// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name());
pBkmklist->erase(ind);
m_fBkmksChanged = true;
// pBkmklist->sort();
break;
case cRmBkmkFile:
unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind)));
break;
}
showEditTools();
}
void QTReaderApp::cancelbkmk()
{
showEditTools();
}
void QTReaderApp::jump()
{
m_nRegAction = cJump;
char lcn[20];
sprintf(lcn, "%lu", reader->pagelocate());
regEdit->setText(lcn);
do_regedit();
}
void QTReaderApp::do_jump(const QString& lcn)
{
bool ok;
unsigned long ulcn = lcn.toULong(&ok);
if (ok)
reader->locate(ulcn);
else
- QMessageBox::information(this, "QTReader", "Must be a number");
+ QMessageBox::information(this, "OpieReader", "Must be a number");
}
void QTReaderApp::do_regaction()
{
regBar->hide();
regVisible = false;
switch(m_nRegAction)
{
case cAutoGen:
do_autogen(regEdit->text());
break;
case cAddBkmk:
do_addbkmk(regEdit->text());
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;
}
reader->restore();
// editBar->show();
reader->setFocus();
}
void QTReaderApp::do_settarget(const QString& _txt)
{
int ind = _txt.find('/');
if (ind == -1)
{
m_targetapp = "";
m_targetmsg = "";
- QMessageBox::information(this, "QTReader", "Format is\nappname/messagename");
+ QMessageBox::information(this, "OpieReader", "Format is\nappname/messagename");
}
else
{
m_targetapp = _txt.left(ind);
m_targetmsg = _txt.right(_txt.length()-ind-1);
}
}
void QTReaderApp::setfont()
{
for (int i = 1; i <= m_fontSelector->count(); i++)
{
if (m_fontSelector->text(i) == reader->m_fontname)
{
m_fontSelector->setCurrentItem(i);
break;
}
}
m_fontBar->show();
m_fontVisible = true;
}
void QTReaderApp::setfontHelper(const QString& lcn, int size = 0)
{
if (size == 0) size = reader->m_fontControl.currentsize();
QFont f(lcn, 10 /*, QFont::Bold*/);
bkmkselector->setFont( f );
regEdit->setFont( f );
searchEdit->setFont( f );
m_annoWin->setFont( f );
reader->m_fontname = lcn;
if (!reader->ChangeFont(size))
{
reader->ChangeFont(size);
}
reader->refresh();
m_fontBar->hide();
m_fontVisible = false;
showEditTools();
}
void QTReaderApp::do_setfont(const QString& lcn)
{
setfontHelper(lcn);
}
void QTReaderApp::do_autogen(const QString& regText)
{
@@ -1876,97 +1876,97 @@ void info_cb(Fl_Widget* o, void* _data)
sprintf(sz,"%u",pl);
posn->value(sz);
frcn->value((100*pl + (ts >> 1))/ts);
}
infowin->show();
}
*/
void QTReaderApp::savebkmks()
{
if (pBkmklist != NULL)
{
BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string), true);
bf.write(*pBkmklist);
}
m_fBkmksChanged = false;
}
void QTReaderApp::readbkmks()
{
if (pBkmklist != NULL)
{
delete pBkmklist;
}
BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string));
pBkmklist = bf.readall();
m_fBkmksChanged = bf.upgraded();
if (pBkmklist == NULL)
{
pBkmklist = reader->getbkmklist();
}
if (pBkmklist != NULL)
pBkmklist->sort();
}
void QTReaderApp::addbkmk()
{
m_nRegAction = cAddBkmk;
regEdit->setText(reader->firstword());
do_regedit();
}
void QTReaderApp::do_addbkmk(const QString& text)
{
if (text.isEmpty())
{
- QMessageBox::information(this, "QTReader", "Need a name for the bookmark\nSelect add again", 1);
+ QMessageBox::information(this, "OpieReader", "Need a name for the bookmark\nSelect add again", 1);
}
else
{
if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>;
#ifdef _UNICODE
CBuffer buff;
int i = 0;
for (i = 0; i < text.length(); i++)
{
buff[i] = text[i].unicode();
}
buff[i] = 0;
pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate()));
#else
pBkmklist->push_front(Bkmk((const tchar*)text,reader->pagelocate()));
#endif
m_fBkmksChanged = true;
pBkmklist->sort();
}
}
void QTReaderApp::OnRedraw()
{
if (pBkmklist != NULL)
{
bool found = findNextBookmark(reader->pagelocate());
m_bkmkAvail->setEnabled(found);
}
}
void QTReaderApp::showAnnotation()
{
m_annoWin->setName(toQString(m_anno->name()));
m_annoWin->setAnno(toQString(m_anno->anno()));
m_annoIsEditing = false;
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);
if (m_doClipboard)
{
QClipboard* cb = QApplication::clipboard();
cb->setText(wrd);
if (wrd.length() > 10)