summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-07-01 23:53:13 (UTC)
committer llornkcor <llornkcor>2002-07-01 23:53:13 (UTC)
commit947bd80f93998f75378db1d677b85eb121c10a1d (patch) (side-by-side diff)
tree9559208fb4c5f5aa31e1f354415f91e95175ca4d
parent7ae4965a4052808172e843356cdfb2d0a673bccf (diff)
downloadopie-947bd80f93998f75378db1d677b85eb121c10a1d.zip
opie-947bd80f93998f75378db1d677b85eb121c10a1d.tar.gz
opie-947bd80f93998f75378db1d677b85eb121c10a1d.tar.bz2
changed caption and added cvsigonre
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/.cvsignore3
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp4
2 files changed, 5 insertions, 2 deletions
diff --git a/noncore/apps/opie-reader/.cvsignore b/noncore/apps/opie-reader/.cvsignore
new file mode 100644
index 0000000..5344d1b
--- a/dev/null
+++ b/noncore/apps/opie-reader/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+Makefile.in
+moc* \ No newline at end of file
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index 620e93e..06a35f6 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -622,774 +622,774 @@ 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->locate() < endpos && (ch = reader->getch()) != UEOF)
{
text += ch;
}
cb->setText(text);
// text = cb->text();
// if (text)
// qDebug("The clipboard contains: %s", (const tchar*)text);
reader->locate(currentpos);
#ifndef QT_NO_CLIPBOARD
// TBD();
// reader->copy();
#endif
}
void QTReaderApp::pageup()
{
reader->goUp();
}
void QTReaderApp::pagedn()
{
reader->goDown();
}
void QTReaderApp::stripcr(bool _b)
{
reader->setstripcr(_b);
}
void QTReaderApp::striphtml(bool _b)
{
reader->setstriphtml(_b);
}
void QTReaderApp::dehyphen(bool _b)
{
reader->setdehyphen(_b);
}
void QTReaderApp::unindent(bool _b)
{
reader->setunindent(_b);
}
void QTReaderApp::repara(bool _b)
{
reader->setrepara(_b);
}
void QTReaderApp::setbold(bool _b)
{
reader->m_bBold = _b;
reader->ChangeFont(reader->fontsizes[reader->m_textsize]);
reader->refresh();
}
void QTReaderApp::dblspce(bool _b)
{
reader->setdblspce(_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 = ((reader->m_targetapp.isEmpty()) ? QString("") : reader->m_targetapp)
+ "/"
+ ((reader->m_targetmsg.isEmpty()) ? QString("") : reader->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");
}
void QTReaderApp::do_mono(const QString& lcn)
{
bool ok;
unsigned long ulcn = lcn.toULong(&ok);
if (ok)
{
reader->m_charpc = ulcn;
// reader->setmono(true);
}
else
QMessageBox::information(this, "QTReader", "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
CBuffer test;
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())
{
delete searchStack->pop();
}
delete searchStack;
#endif
reader->setFocus();
}
void QTReaderApp::regClose()
{
regVisible = FALSE;
regEdit->setText("");
regBar->hide();
reader->setFocus();
}
#ifdef __ISEARCH
bool QTReaderApp::dosearch(size_t start, CBuffer& test, const QString& arg)
#else
bool QTReaderApp::dosearch(size_t start, CBuffer& test, const QRegExp& arg)
#endif
{
bool ret = true;
size_t pos = start;
reader->buffdoc.getline(&test,reader->width());
#ifdef __ISEARCH
while (strstr(test.data(),(const tchar*)arg) == NULL)
#else
#ifdef _UNICODE
while (arg.match(toQString(test.data())) == -1)
#else
while (arg.match(test.data()) == -1)
#endif
#endif
{
pos = reader->locate();
if (!reader->buffdoc.getline(&test,reader->width()))
{
if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
pos = searchStart;
else
pos = start;
ret = false;
findClose();
break;
}
}
reader->locate(pos);
return ret;
}
#ifdef __ISEARCH
void QTReaderApp::search(const QString & arg)
{
searchrecord* ss = searchStack->top();
CBuffer test;
size_t start = reader->pagelocate();
bool haspopped = false;
while (arg.left(ss->s.length()) != ss->s)
{
haspopped = true;
start = ss->pos;
// reader->locate(start);
searchStack->pop();
delete ss;
}
if (haspopped) reader->locate(start);
/*
if (arg.length() < ss->len)
{
start = ss->pos;
reader->locate(start);
searchStack->pop();
delete ss;
}
*/
else
{
start = reader->pagelocate();
reader->jumpto(start);
searchStack->push(new searchrecord(arg,start));
}
dosearch(start, test, arg);
}
#else
void QTReaderApp::search()
{
QRegExp arg = searchEdit->text();
CBuffer test;
size_t start = reader->pagelocate();
// reader->jumpto(start);
dosearch(start, test, arg);
}
#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");
}
}
void QTReaderApp::showEditTools()
{
if ( !doc )
close();
// fileSelector->hide();
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("Opie Reader") );
else {
QString s = doc->name();
if ( s.isEmpty() )
s = tr( "Unnamed" );
- setCaption( s + " - " + tr("QTReader") );
+ setCaption( s + " - " + tr("Opie Reader") );
}
}
void QTReaderApp::setDocument(const QString& fileref)
{
bFromDocView = TRUE;
//QMessageBox::information(0, "setDocument", fileref);
openFile(DocLnk(fileref));
// showEditTools();
}
void QTReaderApp::closeEvent( QCloseEvent *e )
{
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)
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)
{
if (m_fBkmksChanged) pBkmklist->sort();
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)
{
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");
}
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;
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");
}
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)
{
reader->m_targetapp = "";
reader->m_targetmsg = "";
QMessageBox::information(this, "QTReader", "Format is\nappname/messagename");
}
else
{
reader->m_targetapp = _txt.left(ind);
reader->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::do_setfont(const QString& lcn)
{
QFont f(lcn, 10 /*, QFont::Bold*/);
bkmkselector->setFont( f );
regEdit->setFont( f );
searchEdit->setFont( f );
reader->m_fontname = lcn;
reader->ChangeFont(reader->fontsizes[reader->m_textsize]);
reader->refresh();
m_fontBar->hide();
m_fontVisible = false;
showEditTools();
}
void QTReaderApp::do_autogen(const QString& regText)
{
unsigned long fs, ts;
reader->sizes(fs,ts);
// qDebug("Reg:%s\n", (const tchar*)(regEdit->text()));
m_autogenstr = regText;
QRegExp re(regText);
CBuffer buff;
if (pBkmklist != NULL) delete pBkmklist;
pBkmklist = new CList<Bkmk>;
m_fBkmksChanged = true;
pbar->show();
pbar->resize(width(), editBar->height());
pbar->reset();
qApp->processEvents();
reader->setFocus();
reader->jumpto(0);
int lastpc = 0;
int i = 0;
while (i >= 0)
{
unsigned int lcn = reader->locate();
int pc = (100*lcn)/ts;
if (pc != lastpc)
{
pbar->setProgress(pc);
qApp->processEvents();
if (reader->locate() != lcn) reader->jumpto(lcn);
reader->setFocus();
lastpc = pc;
}
i = reader->buffdoc.getpara(buff);
#ifdef _UNICODE
if (re.match(toQString(buff.data())) != -1)
#else
if (re.match(buff.data()) != -1)
#endif
pBkmklist->push_back(Bkmk(buff.data(),lcn));
}
pbar->setProgress(100);
qApp->processEvents();
pbar->hide();
}
void QTReaderApp::saveprefs()
{
// reader->saveprefs("uqtreader");
Config config( "uqtreader" );
config.setGroup( "View" );
reader->m_lastposn = reader->pagelocate();
config.writeEntry( "StripCr", reader->bstripcr );
config.writeEntry( "StripHtml", reader->bstriphtml );
config.writeEntry( "Dehyphen", reader->bdehyphen );
config.writeEntry( "Unindent", reader->bunindent );
config.writeEntry( "Repara", reader->brepara );
config.writeEntry( "DoubleSpace", reader->bdblspce );
config.writeEntry( "Indent", reader->bindenter );
config.writeEntry( "FontSize", (int)(reader->fontsizes[reader->m_textsize]) );
config.writeEntry( "Bold", reader->m_bBold );
config.writeEntry( "ScrollDelay", reader->m_delay);
config.writeEntry( "LastFile", reader->m_lastfile );
config.writeEntry( "LastPosn", (int)(reader->pagelocate()) );
config.writeEntry( "PageMode", reader->m_bpagemode );
config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced );
config.writeEntry( "Fontname", reader->m_fontname );
config.writeEntry( "Encoding", reader->m_encd );
config.writeEntry( "CharSpacing", reader->m_charpc );
config.writeEntry( "Overlap", (int)(reader->m_overlap) );
config.writeEntry( "TargetApp", reader->m_targetapp );
config.writeEntry( "TargetMsg", reader->m_targetmsg );
}
void QTReaderApp::indentplus()
{
reader->indentplus();
}
void QTReaderApp::indentminus()
{
reader->indentminus();
}
/*
void QTReaderApp::oldFile()
{
qDebug("oldFile called");
reader->setText(true);
qDebug("settext called");
showEditTools();
qDebug("showedit called");
}
*/
/*
void info_cb(Fl_Widget* o, void* _data)
{
if (infowin == NULL)
{
infowin = new Fl_Window(160,240);
filename = new Fl_Output(45,5,110,14,"Filename");
filesize = new Fl_Output(45,25,110,14,"Filesize");
textsize = new Fl_Output(45,45,110,14,"Textsize");
comprat = new CBar(45,65,110,14,"Ratio %");
posn = new Fl_Output(45,85,110,14,"Location");
frcn = new CBar(45,105,110,14,"% Read");
about = new Fl_Multiline_Output(5,125,150,90);
about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files");
Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay");
infowin->set_modal();
}
if (((reader_ui *)_data)->g_filename[0] != '\0')
{
unsigned long fs,ts;
tchar sz[20];
((reader_ui *)_data)->input->sizes(fs,ts);
unsigned long pl = ((reader_ui *)_data)->input->locate();
filename->value(((reader_ui *)_data)->g_filename);
sprintf(sz,"%u",fs);
filesize->value(sz);
sprintf(sz,"%u",ts);
textsize->value(sz);
comprat->value(100-(100*fs + (ts >> 1))/ts);
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 = false;
if (pBkmklist == NULL)