Diffstat (limited to 'noncore/apps/opie-reader/QTReaderApp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 1224 |
1 files changed, 910 insertions, 314 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index 68c80c1..0608b66 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp @@ -19,4 +19,5 @@ **********************************************************************/ +#include <qclipboard.h> #include <qwidgetstack.h> #include <qpe/qpemenubar.h> @@ -39,8 +40,12 @@ #include <qbuttongroup.h> #include <qradiobutton.h> +#include <qpe/qcopenvelope_qws.h> +#include "QTReader.h" +#include "Bkmks.h" #include "cbkmkselector.h" #include "infowin.h" - +#include "CAnnoEdit.h" +#include "QFloatBar.h" //#include <qpe/fontdatabase.h> @@ -50,4 +55,5 @@ #include "QTReaderApp.h" #include "fileBrowser.h" +#include "CDrawBuffer.h" @@ -69,14 +75,14 @@ void QTReaderApp::listBkmkFiles() 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++; - } + 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++; + } } @@ -85,10 +91,10 @@ void QTReaderApp::listBkmkFiles() if (cnt > 0) { - menu->hide(); +//tjw menu->hide(); editBar->hide(); if (m_fontVisible) m_fontBar->hide(); if (regVisible) regBar->hide(); if (searchVisible) searchBar->hide(); - m_nRegAction = cRmBkmkFile; + m_nRegAction = cRmBkmkFile; editorStack->raiseWidget( bkmkselector ); } @@ -98,5 +104,5 @@ void QTReaderApp::listBkmkFiles() QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) - : QMainWindow( parent, name, f ), bFromDocView( FALSE ) + : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false) { // qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); @@ -106,9 +112,9 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) doc = 0; - m_fBkmksChanged = false; + m_fBkmksChanged = false; QString lang = getenv( "LANG" ); - m_autogenstr = "^ *[A-Z].*[a-z] *$"; + m_autogenstr = "^ *[A-Z].*[a-z] *$"; setToolBarsMovable( FALSE ); @@ -118,5 +124,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) bar->setHorizontalStretchable( TRUE ); addToolBar(bar, "tool",QMainWindow::Top, true); - menu = bar; +//tjw menu = bar; QPEMenuBar *mb = new QPEMenuBar( bar ); @@ -145,4 +151,9 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) 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()); @@ -167,9 +178,15 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) reader = new QTReader( editorStack ); + + ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); + Config config( "uqtreader" ); config.setGroup( "View" ); reader->bstripcr = config.readBoolEntry( "StripCr", true ); + reader->btextfmt = config.readBoolEntry( "TextFmt", false ); + reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); + reader->bpeanut = config.readBoolEntry( "Peanut", false ); reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); reader->bunindent = config.readBoolEntry( "Unindent", false ); @@ -178,5 +195,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) reader->bindenter = config.readNumEntry( "Indent", 0 ); reader->m_textsize = config.readNumEntry( "FontSize", 12 ); - reader->m_bBold = config.readBoolEntry( "Bold", false ); reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); reader->m_lastfile = config.readEntry( "LastFile", QString::null ); @@ -188,7 +204,19 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); reader->m_overlap = config.readNumEntry( "Overlap", 0 ); - reader->m_targetapp = config.readEntry( "TargetApp", QString::null ); - reader->m_targetmsg = config.readEntry( "TargetMsg", QString::null ); - reader->init(); + reader->bremap = config.readBoolEntry( "Remap", true ); + reader->bmakebold = config.readBoolEntry( "MakeBold", false ); + m_targetapp = config.readEntry( "TargetApp", QString::null ); + m_targetmsg = config.readEntry( "TargetMsg", QString::null ); + 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() ); @@ -213,14 +241,20 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) a->addTo( file ); - a = new QAction( tr( "Start Block" ), QString::null, 0, this, NULL); - connect( a, SIGNAL( activated() ), this, SLOT( editMark() ) ); - file->insertSeparator(); - a->addTo( file ); + QActionGroup* ag = new QActionGroup(this); + QPopupMenu *spacemenu = new QPopupMenu(this); + file->insertItem( tr( "On Action..." ), spacemenu ); - a = new QAction( tr( "Copy Block" ), QString::null, 0, this, NULL); - connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); - a->addTo( file ); + 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); - a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( "opie-reader/panel-arrow-down" ), QString::null, 0, this, 0, true ); + 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 ); // connect( a, SIGNAL( activated() ), this, SLOT( autoScroll() ) ); a->setOn(false); @@ -243,5 +277,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) a->addTo( file ); - a = new QAction( tr( "Page/Line scroll" ), QString::null, 0, this, NULL, true ); + 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); @@ -252,8 +286,35 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) 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); + + a = new QAction( tr( "Dictionary" ), QString::null, 0, ag, NULL, true ); + connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnDictionary(bool) ) ); + a->setOn(m_doDictionary); + + a = new QAction( tr( "Clipboard" ), QString::null, 0, ag, NULL, true ); + connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnClipboard(bool) ) ); + a->setOn(m_doClipboard); + + ag->addTo(encoding); + + /* a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); @@ -277,54 +338,93 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) */ - a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); +// a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); + a = new QAction( tr( "Find..." ), QString::null, 0, this, NULL); connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); file->insertSeparator(); - a->addTo( bar ); +// a->addTo( bar ); a->addTo( file ); - a = new QAction( tr( "Strip CR" ), QString::null, 0, this, NULL, true ); - a->setOn(reader->bstripcr); - connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) ); - a->addTo( format ); - // a->setOn(true); + a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); + connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); + a->addTo( bar ); - a = new QAction( tr( "Strip HTML" ), QString::null, 0, this, NULL, true ); + m_bkmkAvail->setEnabled(false); + + + ag = new QActionGroup(this); +// ag->setExclusive(false); + encoding = new QPopupMenu(this); + format->insertItem( tr( "Markup" ), encoding ); + + a = new QAction( tr( "Auto" ), QString::null, 0, ag, NULL, true ); + a->setOn(reader->bautofmt); + connect( a, SIGNAL( toggled(bool) ), this, SLOT( autofmt(bool) ) ); + + a = new QAction( tr( "None" ), QString::null, 0, ag, NULL, true ); + a->setOn(!reader->bautofmt && !(reader->btextfmt || reader->bstriphtml || reader->bpeanut)); +// connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) ); + + a = new QAction( tr( "Text" ), QString::null, 0, ag, NULL, true ); + a->setOn(reader->btextfmt); + connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) ); + + a = new QAction( tr( "HTML" ), QString::null, 0, ag, NULL, true ); a->setOn(reader->bstriphtml); connect( a, SIGNAL( toggled(bool) ), this, SLOT( striphtml(bool) ) ); - a->addTo( format ); - a = new QAction( tr( "Dehyphen" ), QString::null, 0, this, NULL, true ); + a = new QAction( tr( "Peanut/PML" ), QString::null, 0, ag, NULL, true ); + a->setOn(reader->bpeanut); + connect( a, SIGNAL( toggled(bool) ), this, SLOT( peanut(bool) ) ); + + ag->addTo(encoding); + + + + ag = new QActionGroup(this); + ag->setExclusive(false); + encoding = new QPopupMenu(this); + format->insertItem( tr( "Layout" ), encoding ); + + a = new QAction( tr( "Strip CR" ), QString::null, 0, ag, NULL, true ); + a->setOn(reader->bstripcr); + connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) ); + + a = new QAction( tr( "Dehyphen" ), QString::null, 0, ag, NULL, true ); a->setOn(reader->bdehyphen); connect( a, SIGNAL( toggled(bool) ), this, SLOT( dehyphen(bool) ) ); - a->addTo( format ); +// a->addTo( format ); - a = new QAction( tr( "Unindent" ), QString::null, 0, this, NULL, true ); + a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true ); connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) ); a->setOn(reader->bunindent); - a->addTo( format ); +// a->addTo( format ); - a = new QAction( tr( "Re-paragraph" ), QString::null, 0, this, NULL, true ); + a = new QAction( tr( "Re-paragraph" ), QString::null, 0, ag, NULL, true ); connect( a, SIGNAL( toggled(bool) ), this, SLOT( repara(bool) ) ); a->setOn(reader->brepara); - a->addTo( format ); +// a->addTo( format ); - a = new QAction( tr( "Double Space" ), QString::null, 0, this, NULL, true ); + a = new QAction( tr( "Double Space" ), QString::null, 0, ag, NULL, true ); connect( a, SIGNAL( toggled(bool) ), this, SLOT( dblspce(bool) ) ); a->setOn(reader->bdblspce); - a->addTo( format ); +// a->addTo( format ); - a = new QAction( tr( "Indent+" ), QString::null, 0, this, NULL ); + a = new QAction( tr( "Indent+" ), QString::null, 0, ag, NULL ); connect( a, SIGNAL( activated() ), this, SLOT( indentplus() ) ); - a->addTo( format ); +// a->addTo( format ); - a = new QAction( tr( "Indent-" ), QString::null, 0, this, NULL ); + a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL ); connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) ); - a->addTo( format ); - a = new QAction( tr( "Bold" ), QString::null, 0, this, NULL, true ); - a->setOn(reader->m_bBold); - connect( a, SIGNAL( toggled(bool) ), this, SLOT( setbold(bool) ) ); - a->addTo( format ); + a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true ); + connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) ); + a->setOn(reader->bremap); + + a = new QAction( tr( "Embolden" ), QString::null, 0, ag, NULL, true ); + connect( a, SIGNAL( toggled(bool) ), this, SLOT( embolden(bool) ) ); + a->setOn(reader->bmakebold); + + ag->addTo(encoding); // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); @@ -347,9 +447,9 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) a->addTo( format ); - QPopupMenu *encoding = new QPopupMenu(this); - format->insertSeparator(); + encoding = new QPopupMenu(this); +// format->insertSeparator(); format->insertItem( tr( "Encoding" ), encoding ); - QActionGroup* ag = new QActionGroup(this); + ag = new QActionGroup(this); m_EncodingAction[0] = new QAction( tr( "Ascii" ), QString::null, 0, ag, NULL, true ); @@ -380,4 +480,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) a->addTo( marks ); + a = new QAction( tr( "Annotate" ), QString::null, 0, this, NULL); + connect( a, SIGNAL( activated() ), this, SLOT( addanno() ) ); + a->addTo( marks ); + a = new QAction( tr( "Goto" ), QString::null, 0, this, NULL, false ); connect( a, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); @@ -406,4 +510,14 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) a->addTo( marks ); + a = new QAction( tr( "Start Block" ), QString::null, 0, this, NULL); + connect( a, SIGNAL( activated() ), this, SLOT( editMark() ) ); + marks->insertSeparator(); + a->addTo( marks ); + + a = new QAction( tr( "Copy Block" ), QString::null, 0, this, NULL); + connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); + a->addTo( marks ); + + mb->insertItem( tr( "File" ), file ); // mb->insertItem( tr( "Edit" ), edit ); @@ -411,18 +525,21 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) mb->insertItem( tr( "Marks" ), marks ); - searchBar = new QToolBar( "Search", this, QMainWindow::Top, TRUE ); + searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); searchBar->setHorizontalStretchable( TRUE ); + connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); + searchEdit = new QLineEdit( searchBar, "searchEdit" ); // QFont f("unifont", 16 /*, QFont::Bold*/); // searchEdit->setFont( f ); searchBar->setStretchableWidget( searchEdit ); + #ifdef __ISEARCH connect( searchEdit, SIGNAL( textChanged( const QString & ) ), - this, SLOT( search( const QString& ) ) ); + this, SLOT( search( const QString& ) ) ); #else connect( searchEdit, SIGNAL( returnPressed( ) ), - this, SLOT( search( ) ) ); + this, SLOT( search( ) ) ); #endif a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); @@ -436,5 +553,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) searchBar->hide(); - regBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); + regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); + connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); regBar->setHorizontalStretchable( TRUE ); @@ -446,5 +564,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) connect( regEdit, SIGNAL( returnPressed( ) ), - this, SLOT( do_regaction() ) ); + this, SLOT( do_regaction() ) ); a = new QAction( tr( "Do Reg" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); @@ -465,9 +583,22 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) m_fontBar->setStretchableWidget( m_fontSelector ); { - FontDatabase f; - m_fontSelector->insertStringList(f.families()); + 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&) ) ); + this, SLOT( do_setfont(const QString&) ) ); m_fontBar->hide(); @@ -475,13 +606,15 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), - this, SLOT( msgHandler(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); + 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); } @@ -496,20 +629,257 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) if ( msg == "info(QString)" ) { - QString info; - stream >> info; - QMessageBox::information(this, "QTReader", info); - } else if ( msg == "warn(QString)" ) + QString info; + stream >> info; + QMessageBox::information(this, "QTReader", info); + } + else if ( msg == "warn(QString)" ) + { + QString info; + stream >> info; + QMessageBox::warning(this, "QTReader", 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)" ) + { + int info; + stream >> info; + autoScroll(info); + } + else if ( msg == "File/Jump(int)" ) + { + int info; + stream >> info; + reader->locate(info); + } + else if ( msg == "File/Page/Line Scroll(int)" ) + { + int info; + stream >> info; + pagemode(info); + } + else if ( msg == "File/Set Overlap(int)" ) + { + 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); + 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); + } + else if ( msg == "Layout/Re-paragraph(int)" ) + { + int info; + stream >> info; + repara(info); + } + else if ( msg == "Layout/Double Space(int)" ) + { + int info; + stream >> info; + dblspce(info); + } + else if ( msg == "Layout/Indent(int)" ) + { + int info; + stream >> info; + reader->bindenter = info; + reader->setfilter(reader->getfilter()); + } + else if ( msg == "Layout/Remap(int)" ) + { + int info; + stream >> info; + remap(info); + } + else if ( msg == "Layout/Embolden(int)" ) + { + int info; + stream >> info; + embolden(info); + } + else if ( msg == "Format/Ideogram/Word(int)" ) + { + int info; + stream >> info; + monospace(info); + } + else if ( msg == "Format/Set width(int)" ) + { + int info; + stream >> info; + reader->m_charpc = info; + reader->setfont(); + reader->refresh(); + } + else if ( msg == "Format/Encoding(QString)" ) + { + QString info; + stream >> info; + reader->setencoding(EncNameToInt(info)); + } + else if ( msg == "Format/Set Font(QString,int)" ) { - QString info; - stream >> info; - QMessageBox::warning(this, "QTReader", info); + QString fontname; + int size; + stream >> fontname; + stream >> size; + setfontHelper(fontname, size); + } + else if ( msg == "Marks/Autogen(QString)" ) + { + QString info; + stream >> info; + do_autogen(info); } } +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; + if (m_EncodingAction[i]->text() == _enc) return i; } return 0; @@ -528,4 +898,10 @@ void QTReaderApp::encodingSelected(QAction* _a) } +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() { @@ -549,7 +925,7 @@ void QTReaderApp::TBDzoom() void QTReaderApp::clearBkmkList() { - delete pBkmklist; - pBkmklist = NULL; - m_fBkmksChanged = false; + delete pBkmklist; + pBkmklist = NULL; + m_fBkmksChanged = false; } @@ -564,12 +940,12 @@ void QTReaderApp::fileOpen() if (pBkmklist != NULL) { - if (m_fBkmksChanged) - { - if (QMessageBox::warning(this, "QTReader", "Save bookmarks?", "Save", "Don't bother") == 0) - savebkmks(); - } - delete pBkmklist; - pBkmklist = NULL; - m_fBkmksChanged = false; + if (m_fBkmksChanged) + { + if (QMessageBox::warning(this, "QTReader", "Save bookmarks?", "Save", "Don't bother") == 0) + savebkmks(); + } + delete pBkmklist; + pBkmklist = NULL; + m_fBkmksChanged = false; } reader->disableAutoscroll(); @@ -579,15 +955,16 @@ void QTReaderApp::fileOpen() */ fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE, - 0, -// WStyle_Customize | WStyle_NoBorderEx, - "*", QFileInfo(reader->m_lastfile).dirPath(true)); + 0, +// WStyle_Customize | WStyle_NoBorderEx, + "*", QFileInfo(reader->m_lastfile).dirPath(true)); if (fb->exec()) { - QString fn(fb->fileList[0]); + QString fn(fb->fileList[0]); // fb->populateList(); - if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); + if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); } delete fb; + reader->setFocus(); } @@ -597,17 +974,118 @@ void QTReaderApp::showinfo() if (reader->empty()) { - QMessageBox::information(this, "QTReader", "No file loaded", 1); + QMessageBox::information(this, "QTReader", "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(); + 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); + } + 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); + } + else + { + m_annoWin->setName(""); + m_annoWin->setAnno(""); + m_annoWin->setPosn(reader->pagelocate()); + m_annoIsEditing = true; + editorStack->raiseWidget( m_annoWin ); + m_annoWin->setFocus(); } } @@ -639,23 +1117,16 @@ void QTReaderApp::editMark() 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 + 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; + } + cb->setText(text); + reader->locate(currentpos); } @@ -674,4 +1145,24 @@ void QTReaderApp::stripcr(bool _b) reader->setstripcr(_b); } +void QTReaderApp::remap(bool _b) +{ + reader->setremap(_b); +} +void QTReaderApp::peanut(bool _b) +{ + reader->setpeanut(_b); +} +void QTReaderApp::embolden(bool _b) +{ + reader->setmakebold(_b); +} +void QTReaderApp::autofmt(bool _b) +{ + reader->setautofmt(_b); +} +void QTReaderApp::textfmt(bool _b) +{ + reader->settextfmt(_b); +} void QTReaderApp::striphtml(bool _b) { @@ -690,10 +1181,4 @@ 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) { @@ -731,7 +1216,7 @@ void QTReaderApp::settarget() { m_nRegAction = cSetTarget; - QString text = ((reader->m_targetapp.isEmpty()) ? QString("") : reader->m_targetapp) - + "/" - + ((reader->m_targetmsg.isEmpty()) ? QString("") : reader->m_targetmsg); + QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) + + "/" + + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); regEdit->setText(text); do_regedit(); @@ -744,8 +1229,8 @@ void QTReaderApp::do_overlap(const QString& lcn) if (ok) { - reader->m_overlap = ulcn; + reader->m_overlap = ulcn; } else - QMessageBox::information(this, "QTReader", "Must be a number"); + QMessageBox::information(this, "QTReader", "Must be a number"); } @@ -756,9 +1241,11 @@ void QTReaderApp::do_mono(const QString& lcn) if (ok) { - reader->m_charpc = ulcn; -// reader->setmono(true); + reader->m_charpc = ulcn; + reader->setfont(); + reader->refresh(); +// reader->setmono(true); } else - QMessageBox::information(this, "QTReader", "Must be a number"); + QMessageBox::information(this, "QTReader", "Must be a number"); } @@ -794,5 +1281,5 @@ void QTReaderApp::findNext() QRegExp arg = searchEdit->text(); #endif - CBuffer test; + CDrawBuffer test(&(reader->m_fontControl)); size_t start = reader->pagelocate(); reader->jumpto(start); @@ -826,11 +1313,11 @@ void QTReaderApp::regClose() #ifdef __ISEARCH -bool QTReaderApp::dosearch(size_t start, CBuffer& test, const QString& arg) +bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) #else -bool QTReaderApp::dosearch(size_t start, CBuffer& test, const QRegExp& arg) +bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) #endif { bool ret = true; - size_t pos = start; + size_t pos = reader->locate(); reader->buffdoc.getline(&test,reader->width()); #ifdef __ISEARCH @@ -846,13 +1333,13 @@ bool QTReaderApp::dosearch(size_t start, CBuffer& test, const QRegExp& arg) 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; - } + { + if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) + pos = searchStart; + else + pos = start; + ret = false; + findClose(); + break; + } } reader->locate(pos); @@ -896,9 +1383,5 @@ void QTReaderApp::search(const QString & arg) void QTReaderApp::search() { - QRegExp arg = searchEdit->text(); - CBuffer test; - size_t start = reader->pagelocate(); -// reader->jumpto(start); - dosearch(start, test, arg); + findNext(); } #endif @@ -938,5 +1421,5 @@ void QTReaderApp::openFile( const DocLnk &f ) QMessageBox::information(this, "QTReader", "File does not exist"); } - + } @@ -944,12 +1427,12 @@ void QTReaderApp::showEditTools() { if ( !doc ) - close(); + close(); // fileSelector->hide(); - menu->show(); +//tjw menu->show(); editBar->show(); if ( searchVisible ) - searchBar->show(); + searchBar->show(); if ( regVisible ) - regBar->show(); + regBar->show(); if (m_fontVisible) m_fontBar->show(); @@ -962,7 +1445,7 @@ void QTReaderApp::save() { if ( !doc ) - return; + return; if ( !editor->edited() ) - return; + return; QString rt = editor->text(); @@ -970,17 +1453,17 @@ void QTReaderApp::save() 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); + 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; @@ -994,7 +1477,7 @@ void QTReaderApp::clear() { // QMessageBox::information(this, "QTReader", "Deleting doc", 1); - delete doc; + delete doc; // QMessageBox::information(this, "QTReader", "Deleted doc", 1); - doc = 0; + doc = 0; } reader->clear(); @@ -1004,10 +1487,10 @@ void QTReaderApp::updateCaption() { if ( !doc ) - setCaption( tr("Opie Reader") ); + setCaption( tr("QTReader") ); else { - QString s = doc->name(); - if ( s.isEmpty() ) - s = tr( "Unnamed" ); - setCaption( s + " - " + tr("Opie Reader") ); + QString s = doc->name(); + if ( s.isEmpty() ) + s = tr( "Unnamed" ); + setCaption( s + " - " + tr("QTReader") ); } } @@ -1023,38 +1506,45 @@ void QTReaderApp::setDocument(const QString& fileref) void QTReaderApp::closeEvent( QCloseEvent *e ) { - if (editorStack->visibleWidget() == reader) + if (m_dontSave) { - 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(); + e->accept(); } else { - showEditTools(); + 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(); + } } } @@ -1078,18 +1568,17 @@ void QTReaderApp::listbkmk() if (pBkmklist != NULL) { - if (m_fBkmksChanged) pBkmklist->sort(); - for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++) - { + for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++) + { #ifdef _UNICODE - bkmkselector->insertItem(toQString(i->name())); + bkmkselector->insertItem(toQString(i->name())); #else - bkmkselector->insertItem(i->name()); + bkmkselector->insertItem(i->name()); #endif - cnt++; - } + cnt++; + } } if (cnt > 0) { - menu->hide(); +//tjw menu->hide(); editBar->hide(); if (m_fontVisible) m_fontBar->hide(); @@ -1121,15 +1610,16 @@ 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; + 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(); @@ -1155,7 +1645,7 @@ void QTReaderApp::do_jump(const QString& lcn) unsigned long ulcn = lcn.toULong(&ok); if (ok) - reader->locate(ulcn); + reader->locate(ulcn); else - QMessageBox::information(this, "QTReader", "Must be a number"); + QMessageBox::information(this, "QTReader", "Must be a number"); } @@ -1167,21 +1657,21 @@ void QTReaderApp::do_regaction() { case cAutoGen: - do_autogen(regEdit->text()); - break; + do_autogen(regEdit->text()); + break; case cAddBkmk: - do_addbkmk(regEdit->text()); - break; + do_addbkmk(regEdit->text()); + break; case cJump: - do_jump(regEdit->text()); - break; + do_jump(regEdit->text()); + break; case cMonoSpace: - do_mono(regEdit->text()); - break; + do_mono(regEdit->text()); + break; case cOverlap: - do_overlap(regEdit->text()); - break; + do_overlap(regEdit->text()); + break; case cSetTarget: - do_settarget(regEdit->text()); - break; + do_settarget(regEdit->text()); + break; } reader->restore(); @@ -1195,12 +1685,12 @@ void QTReaderApp::do_settarget(const QString& _txt) if (ind == -1) { - reader->m_targetapp = ""; - reader->m_targetmsg = ""; - QMessageBox::information(this, "QTReader", "Format is\nappname/messagename"); + m_targetapp = ""; + 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); + m_targetapp = _txt.left(ind); + m_targetmsg = _txt.right(_txt.length()-ind-1); } } @@ -1210,9 +1700,9 @@ 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; - } + if (m_fontSelector->text(i) == reader->m_fontname) + { + m_fontSelector->setCurrentItem(i); + break; + } } m_fontBar->show(); @@ -1220,12 +1710,17 @@ void QTReaderApp::setfont() } -void QTReaderApp::do_setfont(const QString& lcn) +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; - reader->ChangeFont(reader->fontsizes[reader->m_textsize]); + if (!reader->ChangeFont(size)) + { + reader->ChangeFont(size); + } reader->refresh(); m_fontBar->hide(); @@ -1234,4 +1729,9 @@ void QTReaderApp::do_setfont(const QString& lcn) } +void QTReaderApp::do_setfont(const QString& lcn) +{ + setfontHelper(lcn); +} + void QTReaderApp::do_autogen(const QString& regText) { @@ -1260,7 +1760,7 @@ pbar->resize(width(), editBar->height()); { pbar->setProgress(pc); - qApp->processEvents(); - if (reader->locate() != lcn) reader->jumpto(lcn); - reader->setFocus(); + qApp->processEvents(); + if (reader->locate() != lcn) reader->jumpto(lcn); + reader->setFocus(); lastpc = pc; } @@ -1271,6 +1771,7 @@ pbar->resize(width(), editBar->height()); if (re.match(buff.data()) != -1) #endif - pBkmklist->push_back(Bkmk(buff.data(),lcn)); + pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); } + pBkmklist->sort(); pbar->setProgress(100); qApp->processEvents(); @@ -1287,4 +1788,6 @@ void QTReaderApp::saveprefs() config.writeEntry( "StripCr", reader->bstripcr ); + config.writeEntry( "AutoFmt", reader->bautofmt ); + config.writeEntry( "TextFmt", reader->btextfmt ); config.writeEntry( "StripHtml", reader->bstriphtml ); config.writeEntry( "Dehyphen", reader->bdehyphen ); @@ -1293,6 +1796,5 @@ void QTReaderApp::saveprefs() 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( "FontSize", (int)(reader->m_fontControl.currentsize()) ); config.writeEntry( "ScrollDelay", reader->m_delay); config.writeEntry( "LastFile", reader->m_lastfile ); @@ -1304,6 +1806,14 @@ void QTReaderApp::saveprefs() 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 ); + config.writeEntry( "TargetApp", m_targetapp ); + config.writeEntry( "TargetMsg", m_targetmsg ); + config.writeEntry( "TwoTouch", m_twoTouch ); + config.writeEntry( "Annotation", m_doAnnotation); + config.writeEntry( "Dictionary", m_doDictionary); + config.writeEntry( "Clipboard", m_doClipboard); + config.writeEntry( "SpaceTarget", m_spaceTarget); + config.writeEntry( "Remap", reader->bremap ); + config.writeEntry( "Peanut", reader->bpeanut ); + config.writeEntry( "MakeBold", reader->bmakebold ); } @@ -1335,38 +1845,38 @@ 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(); + + 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(); + 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); + filename->value(((reader_ui *)_data)->g_filename); - sprintf(sz,"%u",fs); - filesize->value(sz); + sprintf(sz,"%u",fs); + filesize->value(sz); - sprintf(sz,"%u",ts); - textsize->value(sz); + sprintf(sz,"%u",ts); + textsize->value(sz); - comprat->value(100-(100*fs + (ts >> 1))/ts); + comprat->value(100-(100*fs + (ts >> 1))/ts); - sprintf(sz,"%u",pl); - posn->value(sz); + sprintf(sz,"%u",pl); + posn->value(sz); - frcn->value((100*pl + (ts >> 1))/ts); + frcn->value((100*pl + (ts >> 1))/ts); } infowin->show(); @@ -1378,8 +1888,8 @@ void QTReaderApp::savebkmks() if (pBkmklist != NULL) { - BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string), true); - bf.write(*pBkmklist); + BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string), true); + bf.write(*pBkmklist); } - m_fBkmksChanged = false; + m_fBkmksChanged = false; } @@ -1388,15 +1898,15 @@ void QTReaderApp::readbkmks() if (pBkmklist != NULL) { - delete pBkmklist; + delete pBkmklist; } BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string)); pBkmklist = bf.readall(); - m_fBkmksChanged = false; + m_fBkmksChanged = bf.upgraded(); if (pBkmklist == NULL) { - pBkmklist = reader->getbkmklist(); + pBkmklist = reader->getbkmklist(); } if (pBkmklist != NULL) - pBkmklist->sort(); + pBkmklist->sort(); } @@ -1410,24 +1920,110 @@ void QTReaderApp::addbkmk() void QTReaderApp::do_addbkmk(const QString& text) { - if (text.isEmpty()) - { - QMessageBox::information(this, "QTReader", "Need a name for the bookmark\nSelect add again", 1); - } - else - { - if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; + if (text.isEmpty()) + { + QMessageBox::information(this, "QTReader", "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(), reader->pagelocate())); + 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())); + pBkmklist->push_front(Bkmk((const tchar*)text,reader->pagelocate())); #endif - m_fBkmksChanged = true; - } + 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) + { + Global::statusMessage(wrd.left(8) + ".."); + } + else + { + Global::statusMessage(wrd); + } + } + if (m_doAnnotation) + { +// addAnno(wrd, "Need to be able to edit this", posn); + m_annoWin->setName(line); + m_annoWin->setAnno(""); + m_annoWin->setPosn(posn); + m_annoIsEditing = true; + editorStack->raiseWidget( m_annoWin ); + } + if (m_doDictionary) + { + if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) + { + QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); + e << wrd; + } + } } + +void QTReaderApp::OnActionPressed() +{ + switch (m_spaceTarget) + { + case cesOpenFile: + { + fileOpen(); + } + break; + case cesAutoScroll: + { + reader->setautoscroll(!reader->m_autoScroll); + setScrollState(reader->m_autoScroll); + } + break; + case cesActionMark: + { + addbkmk(); + } + break; + default: + { + qDebug("Unknown ActionType:%u", m_spaceTarget); + } + break; + } +} + +void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } +void QTReaderApp::restoreFocus() { reader->setFocus(); } |